mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 22:27:56 +01:00
register/probe-loop
13
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
fa5e277329 |
fix(dossier): a run's stderr is not the project's next step (#805)
The dossier every dispatch carries opens with "## Latest handoff → Done /
Next / Health", read from the newest `user_projects.dev_log` entry. For a
hosted (Hermes) run that entry was built like this:
done: label.slice(0, 100) // label = `Hosted dispatch (Hermes) — ${task.slice(0, 70)}`
next: text.slice(0, 2_000) // text = the run's OUTPUT, or its ERROR
health: "good" // on every entry, FAILED ones included
Three separate lies, all reported in #584 on 2026-09-10 and all still
reproducing on 2026-09-20 — the first of them in the dispatch that opened
this session:
- Done: Hosted dispatch (Hermes) — # Loki operator dispatch
Everything in this message is assembled by Lo
`task` for an autopilot run IS the assembled envelope, so slicing its
first 70 characters yields preamble. "What did the last run do?" came
back as a truncated system prompt, and then every subsequent dispatch for
that project re-served it for hours.
`extractOperatorTask` already exists for exactly this — the Activity feed
uses it so a row shows what was ASKED rather than the scaffolding. The
hosted runner had its own slice() sitting beside it. It now uses the
helper, so the line names the actual instruction.
`next` held the run's output. On failure that is the raw error, stack
frames and all, filed under the heading that tells the next agent what to
do. It is now empty — and the dossier omits a blank line entirely, which
is the honest rendering, because a hosted run genuinely does not know the
project's next step. Nothing is lost: the full output and the full error
already live on the orchestration run's payload via closeHostedRun and in
the task_completed/task_failed event beside it. The dev log is the
summary, not the archive.
`done` now states the outcome — the PR url, the pushed branch, "no file
changes", or FAILED plus the error's first line. First line, not the
error flattened: "Error: spawn pnpm ENOENT" plus three stack frames comes
to 158 characters, under any sane clamp, so flattening would have carried
`node:internal/child_process:285:19` into a line agents read. The test
pins that case; it caught it.
And a failed run no longer reports health "good", which it did
unconditionally — so the Health line agreed with itself no matter what
had happened.
The decision moves to src/lib/hosted-run-log.ts where it can be tested,
rather than living as four slice() calls at four call sites. What the
dossier shows to every future agent is a product decision, not a
formatting detail.
verify: 216/216 unit tests, tsc clean, lint 0 errors (2 pre-existing
warnings).
Refs #584
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
aa287aa2cf |
fix(hosted): a one-shot runner drains its work before it exits, so the thread hears (#721)
A hosted dispatch ran, Hermes did the task, the run closed `done/success` with its summary — and the conversation that asked for it never heard a word. Nothing errored. Nothing logged. `updateOrchestrationRun` fires `void notifyRunClosed(...)` — its contract is never to slow a close — and that call is what writes the outcome turn. The web server outlives such a promise for free. `hosted-runner.ts --once` is a 45-second cron tick: it drained the command and called `process.exit(0)` while the write was still in flight. - settle-background-work.ts: a bounded drain window (5s, HOSTED_RUNNER_DRAIN_MS), paid only by a tick that actually drained something. A window rather than a promise registry, because the void-call is this codebase's convention at dozens of sites and threading bookkeeping through all of them to repair one process boundary is the larger change. - loki-loop-e2e.ts now reads the run's state when no turn arrives, so the two halves can never be confused again: a CLOSED run with no turn is a lost notification (the work happened); an OPEN one is a stuck builder. That distinction cost an hour today. Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
f7c4e35fdc |
feat(builder): a project can pin its work to the hosted runner — no Claude credential needed (#718)
builder_pref gains a third value, 'hosted'. A project pinned to it never touches a runner PTY: the dispatch goes straight to the hosted runner (Hermes in its own clone on the box, on the providers the box already holds keys for — Copilot, Gemini, Groq), and the hosted runner closes the tracked run with the pull request as evidence, so the outcome reaches the thread that asked, like any other run. Why now: the box's Claude Code credential died silently and every self-dispatch hung, while Hermes on the same box answered fine. The unattended path should not depend on a person's Claude subscription at all. - statuses.ts: HOSTED_BUILDER_PREF / BUILDER_PREFS (channels stay what they were — nothing claims 'hosted' from a queue); API enum widened. - inject-core: hosted branch before the channel pin; run id travels in the hosted_dispatch payload. - hosted-runner: closeHostedRun() through updateOrchestrationRun (outcome turn, ledger, escalation bookkeeping all fire); delivered stamp at claim. - Control → project profile → Runs on: third choice with its explanation. - docs/development/cloud-local-workflows.md: the tier in the SSOT table. Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
95c40a9cd8 |
refactor: rename the product from FleetCrown to Loki (#695)
The product, its assistant, the repo, the host and every unit on the box now share one name. 638 files, ~3,000 mentions: UI copy, config, env keys (FLEETCROWN_* -> LOKI_*), systemd units (fleetcrown-* -> loki-*), docs, articles, the deploy workflow other repos reuse, and nine file names. - Three article slugs carried the old name and had been shared; permanent redirects keep those links alive (next.config.ts). - test-no-retired-name.sh now also forbids the old product name across the whole repo, so the rename cannot creep back through templates and examples. - ASSISTANT_STACK collapses the product and the assistant into one entry, because they are now the same name. Infra was cut over ahead of this merge: /opt/loki, loki-* units, the `loki` database and role, loki.orangecat.ch (old host 308s to it; /api, /widget, /embed keep proxying), GitHub repos bitbaum/loki and bitbaum/loki-releases. The Resend sending domain stays fleetcrown.orangecat.ch until the new domain is verified in DNS. Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
f847ba8fb5 |
feat(retire): a site can be taken off the internet, password-protected, or removed (#657)
Creating a site makes about forty things. Deleting the project undid two of
them, plus the repository if you asked. Everything else survived — and the
part that survived is the part that is public.
After "Delete project" on a kicked-off project you still had: the live site at
<slug>.orangecat.ch, its Caddy vhost and TLS certificate, an enabled systemd
unit, /opt/<slug> with its secrets, the checkout, an apps.conf row holding a
port that could never be reclaimed, a monitoring target that keeps paging about
a site you deleted, the box's SSH deploy key sitting in the repository, and the
project's milestones orphaned onto /goals. The only way off the internet was a
human with SSH.
FOUR LEVELS, because "undo it" means four different things:
offline stops serving at once; code, files and port kept. Reversible.
private keeps working behind a password; repository made private.
restore undoes either of the above.
delete unit, vhost, /opt, checkout, apps.conf row (freeing the port),
monitoring target and the leftover deploy key. The repository is
ARCHIVED, never deleted, unless explicitly asked — that is the one
step nobody can undo, so it is never a default.
NOTHING HAPPENS WITHOUT A SECOND ASK. The default prints exactly what it would
touch and performs no action, and that preview is produced by the same script
that does the work — a plan written separately is a description that drifts.
The route runs the plan through the runner and returns it inline, so the
confirmation is the real thing rather than a promise about it.
Refusals are refusals: thirteen infrastructure slugs (fleetcrown, orangecat,
the bridge…) cannot be retired at all, and a LIVE client engagement needs an
explicit second hand — money terms are not a thing a button decides.
Shape follows new-site.sh, deliberately: a closed set of parameters validated
against a fixed grammar, handed to the script as an ARGUMENT VECTOR via
execFile, armed by the same FLEETCROWN_SITE_FACTORY switch that arms creation.
A runner allowed to bring public hosts into being is the one allowed to take
them away, and no other.
Also fixed, found by the same inventory:
- GitHub visibility could only be set at creation. setGithubRepoVisibility
makes a repository private (or public) afterwards — new-site.sh creates
public repos, so "make this not public" had no answer for the code.
- Deleting a project now deletes the milestones the kickoff wrote FOR it,
instead of leaving them unowned on /goals (ON DELETE SET NULL).
- "Danger zone" says what it does NOT do, and points at the site controls.
Verified: pnpm run verify green. 32 assertions on the script (a dry run never
edits the register; every artifact named in a delete plan; infrastructure
refused; no backticks), 41 on the validator (a plan never carries --go; no mode
defaults to deleting a repository).
DEPLOYMENT: set FLEETCROWN_RETIRE_SITE_SCRIPT in /opt/fleetcrown/runner/.env to
the retire-site.sh in the factory checkout, beside the FLEETCROWN_NEW_SITE_SCRIPT
already there, and update that checkout. Until then the command is rejected with
that exact reason rather than silently doing nothing.
Claude-Session: https://claude.ai/code/session_01WSNERoZZqW2TgqbAGHSQZf
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
e9a5a2c043 |
feat(hosted): the fleet can create a site, not only change one (#598)
* feat(hosted): the fleet can create a site, not only change one The factory had a hole at the only step that starts anything. `hosted_analyze` reads a repo; `hosted_dispatch` sends a coding task to Hermes, which clones, edits, pushes a branch and opens a PR. Neither can bring a site into existence. So every site so far was made by a person typing `new-site.sh` into a terminal — causius on 2026-09-10 included, by an agent in a CLI session, not by FleetCrown. Asked "was it built by the chain?", the honest answer was no, and this is the missing piece rather than a better answer. `hosted_new_site` carries four fields — slug, title, kind, status — and that is the whole point. WHY THIS IS A TYPED COMMAND AND NOT A PROMPT The older control path (api/control/tab-inject-raw) injects FREE TEXT into a live terminal for an agent to obey. It works, and it stays; interactive terminal work is a real need and this does not replace it. But anything reaching that queue becomes instructions on a real shell on a real box, which is the shape that gets prompt-injected. Creating a site does not need that. It is a closed operation over four parameters, and new-site.sh is already its audited implementation. So this path validates every field against a fixed grammar and passes them as an ARGUMENT VECTOR via execFile — no shell, no prompt, no interpolation. A title of `"; rm -rf / #` stays one inert argument, and there is a test asserting exactly that, because the claim is only worth what checks it. Refusals are refusals, never repairs: reserved labels, malformed slugs, unknown kinds, control characters, and `|` (the register's own separator) are rejected rather than sanitised into something that runs. A live client engagement is refused outright — the register's plan/price columns are answerable when someone types the command and never again, so money terms do not travel over a queue. Dispatch it as a prospect and a human flips it with the terms. Two switches, both off by default, because merging code should not arm a machine that creates public repositories, DNS-visible hosts and TLS certificates: FLEETCROWN_SITE_FACTORY=1 arms a runner, FLEETCROWN_NEW_SITE_SCRIPT says where the script is. A runner missing either reports the refusal on the command instead of guessing. Shape follows the existing seams rather than inventing new ones. Validation is pure and lives in lib/hosted-runner/new-site.ts. requestNewSite in provision.ts is the single enqueue path, mirroring dispatch.ts for Hermes, so a future Control button or OrangeCat flow cannot grow its own weaker copy. The command joins HOSTED_COMMAND_TYPES for the 20-minute lease — provisioning takes minutes, and a 90s lease would let a second drainer re-run a healthy scaffold, which here does not duplicate a branch but tries to create a second site on a slug the first is mid-way through claiming. The dead-exports ratchet caught the first draft: the consumer existed and nothing enqueued it. That is the "shipped unreachable" failure this repo has had before, caught this time by a gate instead of by a person reading a live page. scripts/new-site-dispatch.ts is the first real caller. Verified: 143/143 unit files pass (39 new assertions in scripts/test/ hosted-new-site.ts); tsc --noEmit exits 0; the ratchet is green. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018Z7YRpgsEtNjRqr1usHMQY * style: prettier on the new site-factory files fleetcrown's `verify` opens with `prettier --check .`, so unformatted files fail CI before a test runs. I ran the unit suite and tsc locally but not the formatter — the gate caught what I skipped. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018Z7YRpgsEtNjRqr1usHMQY --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
caa0e41c3b |
chore: add a formatter (#449)
* chore: add a formatter, matching the style this repo already writes singleQuote=false was chosen by counting this repo's own imports, not by fleet decree. The fleet is genuinely split and the two repos that already had a .prettierrc disagreed with each other, so there was no standard to restore. Quote style does not cross repo boundaries; having a gate does. Markdown is ignored for now — prettier rewraps prose, which would bury the real diff. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * style: format with prettier (1062 files) Mechanical. No behaviour change. This SHA is listed in .git-blame-ignore-revs so `git blame` skips it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore: teach git blame to skip the reformat Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(lint): reattach two guards the reformat detached Both effects were one-liners, so a trailing eslint-disable-line covered the setState call: useEffect(() => { setSelected(new Set()); }, [q.length]); // eslint-disable-line ... prettier expanded the block. The comment stayed on the closing line while the call moved above it, so the guard protected nothing and the rule its author had deliberately silenced failed the build. This is the second shape of the same defect — hirnli had the eslint-disable-NEXT-line variant. Both come from the same fact: an eslint directive binds to a line number, so reformatting can silently unbind it, which makes 'mechanical, no behaviour change' false for any bulk reformat. * chore(desktop): bump the runner version the reformat requires desktop-release-drift enforces that anything built into Fleet Runner which differs from the last released tag must carry a version ahead of that tag — main read 0.8.15 and fleet-runner-v0.8.15 already shipped. A whole-repo reformat changes bytes under desktop/, so the gate fires. The alternative was adding desktop/ to .prettierignore, which would buy a quiet PR by carving a permanent hole in the formatter's coverage — the precise shape of silent drift this test was written to catch. Bumping is what the rule asks for and costs one patch release whose only content is whitespace. * chore: merge main and re-format A whole-repo reformat conflicts with any concurrent commit, and a conflicting PR runs no checks at all while reporting nothing. Conflicts resolved to main, which is correct because this branch changes formatting and nothing else. * chore: leave desktop/ out of this reformat desktop-release-drift is right to refuse this. Everything under desktop/ is built into Fleet Runner, so changing it means shipping: bump the version AND add a FLEET_RUNNER_RELEASES entry, whose stated audience is 'person who installed Fleet Runner and wants to know what changed'. For a whitespace-only build the honest answer is 'nothing', so that release should not exist — and I should not write release notes claiming otherwise. I had bumped to 0.8.16 to get the gate green. That was the wrong direction: publishing a build to three OS runners to keep a formatting PR quiet. Reverted. desktop/ is excluded in .prettierignore with the reasoning recorded there, to be formatted alongside the next real runner change, where the bump and the notes are true anyway. --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
572ed08cca |
feat(hosted-runner): intentional dispatch SSOT + UI trigger + recent-activity context
Make Hermes usable on purpose, not just as an offline accident. Three changes, one converging design (verified: tsc clean, eslint clean, gpt-4.1 run proven): 1. dispatchToHostedRunner() — SSOT for INTENTIONAL hosted dispatch (resolve project → enqueue → emit Activity event). The CLI (hermes-dispatch.ts) and the new API route both funnel through it, so resolution + attribution never drift. The inject-core auto-route stays the offline fallback. 2. UI trigger — POST /api/hermes/dispatch (thin shell over the SSOT) + a self-contained 'Run in cloud' button in Control's intent panel. Works regardless of local-runner state (the composer's Send only auto-routes to Hermes when the runner is OFFLINE) — this broadens hosted usage from offline-only to any-time-on-purpose. 3. Recent-activity context — getRecentProjectActivity() + a compact 'what was just done' block injected at the consumer (the single choke point for ALL hosted dispatches), so Hermes doesn't repeat or undo recent work. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
38c7d11ef9 |
feat(hosted-runner): make Hermes usage observable + reconcile parked-adapter truth
The hosted Hermes path (inject-core auto-routes offline coding dispatches → scripts/hosted-runner.ts → runHermesTask, drained by fleetcrown-hosted-runner.timer) ran with zero Activity visibility: successes went only to console + the project dev log, failures went to console ALONE. 'Is Hermes being used' required DB archaeology. - Instrument the path into orchestration_events (the SSOT Activity already reads): producer marks the offline→hosted routing (source=hosted-runner, adapter=hermes, deduped by command id); consumer emits task_started/task_completed/task_failed for both hosted_dispatch (Hermes) and hosted_analyze, attributing the real executor. Adapter recorded via a localized "hermes" as AdapterId cast — the same pattern close-sweep already uses for adapters outside ORCHESTRATION_ADAPTER_IDS. - Fix failure-invisibility: hosted failures now also append to the project dev log, not just console. - Reconcile the stale agents/index.ts comment: it claimed runHermesTask is unwired and the CLI 'isn't installed anywhere' — both false. Interactive adapter is parked (out of ALL_ADAPTERS by design); the HOSTED executor is wired + installed (box v0.17.0). Distinguish the two clearly. - deploy: sync scripts/hosted-runner.ts to the runner dir (the timer runs it there; it was never being updated on deploy). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
ff32e90aff |
feat(hosted-runner): fall back to GITHUB_TOKEN when no OAuth account is linked
On the hosted box there's no linked GitHub OAuth account (accounts table empty), so getGithubToken returns null and Hermes couldn't push/PR. Fall back to process.env.GITHUB_TOKEN (provided by `gh auth login` on the box → its stored token, repo+workflow scopes). Verified live: the runner now clones, edits via Hermes, pushes a branch, and opens a PR (fleetcrown#54). |
||
|
|
51fc7d1250 |
feat(hosted-runner): Hermes goes live — auto-route offline dispatches, preserve work as a PR
Now that Hermes is installed + Nous-Portal-authed + verified executing agentic code on the box, wire it end to end: - run-hermes.ts: real invocation (`hermes -z "<task>" --yolo`, model+creds from ~/.hermes/config.yaml — dropped --ignore-user-config which bypassed the Nous config). Crucially, it now PRESERVES the work: after the agent edits, commit on a fresh `hermes/<slug>` branch, push, and open a PR via the GitHub API. No auto-merge — a human reviews. No-op runs report "no changes" honestly. - inject-core.ts (producer): when a WORK dispatch queues with the local Fleet Runner offline, auto-enqueue a hosted_dispatch so Hermes makes the change and opens a PR instead of the command waiting forever. Gated: real git URL + not a lifecycle (close/stop) command. Hermes uses its own Nous model, so we don't pass the local agent's model pref. Response surfaces hostedDispatchId. - hosted-runner.ts: surface the PR URL / branch in the executed-command result and dev log. tsc=0, eslint=0. |
||
|
|
509f2a4189 |
feat(hosted-runner): wire runHermesTask via hosted_dispatch + positioning one-pager + harness essay (#52)
- hosted_dispatch command type + enqueueHostedDispatchCommand (pending-commands.ts): write-class tasks, distinct from read-only hosted_analyze and the local-runner path. - scripts/hosted-runner.ts: the worker now claims BOTH hosted types and routes — hosted_analyze → Groq read-only analysis (Phase 0); hosted_dispatch → runHermesTask (Phase 1, orchestrate Hermes in its own sandbox). Verified: dispatch routes to Hermes and reports a clean needs-install result (no crash) until the CLI is provisioned. The whole path is ready the moment a Hermes credential lands. - docs/positioning.md: the captain's-bridge one-pager — what we are (orchestration layer over runtimes), what we're NOT (a runtime), the layer model, the moat (cross-model verification + governance + economy), honest status. - content/thoughts/the-harness-not-the-prompt.md: essay — leverage moved from prompt engineering to harness engineering; FleetCrown is a harness at fleet scale; maps our shipped pieces (profile-as-context, cross-model DoD gate, the loop) to harness primitives, and names memory as the weakest strut. (Recovers the box too: the prior Hermes-spike deploy failed on a missing `ws` dep the fleet's Loki-gateway commit added; npm install fixed local node_modules, so this build is clean.) tsc=0, eslint=0. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|
|
4cf27f23f5 |
feat(hosted-runner): wire Phase 0 to presence + the claim queue (#50)
The read-only analysis core now runs the real runner loop, verified end-to-end:
- setRunnerConnected (runner-presence.ts): a hosted runner registers presence
(no bridge SSE), so a project stops showing fully dark while the operator's
laptop is off. Phase-0 simplification noted (shared presence boolean).
- hosted_analyze command type + enqueueHostedAnalyzeCommand (pending-commands.ts):
its own type so it never collides with the local-runner dispatch/inject path.
- scripts/hosted-runner.ts: the worker loop. Persistent mode claims presence +
polls; --once is a one-shot drain (cron-style) that does NOT claim persistent
presence. Each claimed command → getProjectContext + getGithubToken →
analyzeRepo → markCommandExecuted({ok,text}) + appendProjectDevLog so the
result shows on the project. Stale-claim reclaim + purge come free from
claimNextPendingCommand.
Verified locally: enqueue → presence ON → claim → clone+analyze a real repo →
report (result.ok, devlog) → presence reset. tsc=0, eslint=0.
Next (operational): run the worker as a box service (DATABASE_URL + GROQ_API_KEY)
so the founder's projects actually get a hosted runner; then a UI trigger
("Analyze on hosted runner"). Phase 1 swaps analyzeRepo for a sandboxed coding
agent. See docs/architecture/hosted-ephemeral-runner.md.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|