Commit Graph
118 Commits
Author SHA1 Message Date
CatoandClaude Opus 5.5 3af2fec589 fix: what the Farmhouse end-to-end test broke — Live link, stuck Claude dialog, owner wording (#938)
* fix(sites): a site that goes live after registration is recorded, and its owner told

Registration wrote the live URL only if the site answered at that moment.
Farmhouse's first deploy failed, a later one succeeded, and nothing looked
again: no live URL, a Live link that opened the OrangeCat listing, and no word
to the owner. An hourly check (and the owner opening the project page) now
asks the same question registration asks and, the first time the answer is
yes, sends the owner their link that readies the widget.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs(telemetry): six crons run hourly now that check-site-live does

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(runner): a Claude session showing a dialog is cleared before a prompt is sent into it

Farmhouse's parked session sat on Claude Code's "Teach auto mode about your
environment?" dialog. The owner's widget note was injected into the dialog,
nothing ran, and the run was NACKed 33s later while the widget said "On it".
Claude reports this itself ({status: waiting, waitingFor: "dialog open"}); the
runner now presses Escape and, if the dialog stays, starts a fresh session.

Also: on the box every live-session lookup used the dispatch's laptop path,
which no session has, so the generation check fell back to guessing from
screen activity. They now use the folder the agent really runs in, and the
reader accepts current CLIs' updatedAt.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* feat(widget): owner mode reads as the owner's, and the agent is told the owner asked

The widget no longer asks the owner for a name/email and says what happens
("Your site: what you say here gets built and goes live"). The agent's brief
now opens with "The owner of <project> asked for this change" instead of
"Fix this visitor feedback" — still fenced as text from a browser.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* chore(desktop): 0.8.35 — ships the dialog-clearing runner fix to Fleet Runner too

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs(changelog): Fleet Runner 0.8.35

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 04:27:44 -07:00
CatoandClaude Opus 5.5 10b1f3a082 fix(orchestration): a runner restart closes the runs its sessions were serving (#917)
The runner now reports bootedAt (process start, captured once) on every
runtime-state post. Runs on that runner's channel whose agent session was
live before the boot (claimed/launched/submitted/generating/progress event
older than bootedAt), with nothing heard since and no un-acked command, are
closed at once with the restart named, instead of reading 'waiting' until
the hourly reaper. Only-dispatched runs are left for the new runner.

Verdict matches the reaper's (partial on handoff, else timeout) so the same
repo-evidence correction upgrades runs that had already pushed work.
Fleet Runner 0.8.34.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 09:09:03 -07:00
CatoandCursor f2f6206bcf fix(projects): truthful cloud presence + project header state/actions (#912)
* fix(projects): tell the truth about cloud presence and separate header state

Box-runner heartbeats as cloud but could register bridge presence as local,
so /terminal said Cloud offline while the journal shipped work. Infer cloud
from box-* versions, force the channel in box-runner, and scope the terminal
honesty chip. Project header now shows listing/live as status, not peer links;
catalogue invite waits until kickoff/build is idle.

Co-authored-by: Cursor <cursoragent@cursor.com>

* chore(desktop): bump Fleet Runner to 0.8.33 for presence-channel fix

desktop/bridge-subscriber changed so box-* runners register as cloud; the
release-drift gate requires a version bump and changelog entry before merge.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-25 05:29:46 -07:00
CatoandClaude Opus 5.5 49553dadec fix(runner): stop killing working agents — quota NACK read our own prompt, drain waited on idle CLIs (#898)
Two defects hit one Skif dispatch on 2026-09-25, and either alone loses work.

1. The dispatch was NACKed "claude cannot generate because its usage limit
   is exhausted" 14s in, while Claude was visibly working on the brief. The
   capacity check scanned the WHOLE PTY buffer with a topic-word regex
   ("rate limit", "credit", "context window"), so the echoed prompt, the boot
   banner or a file the agent printed read as a quota wall. Now it reads only
   what the CLI printed after the injection, ignores lines that are just the
   prompt echoed back, and for Claude defers to its own session status: a
   session still generating has not hit a wall.

2. Two minutes later the box runner restarted and killed every session. The
   post-deploy drain waited for agent processes to EXIT, and interactive CLIs
   never exit, so it always ran to its 30-minute cap and then killed whatever
   had started most recently. It now counts agents that are WORKING: an idle
   Claude does not hold the restart; generating, waiting mid-task, or any
   status it cannot read does.

Fleet Runner 0.8.32 (desktop/ changed, so it ships as a release).
Tests: terminal-run-view (echo vs real wall, mutation-checked) and a new
test-drain-and-restart-runner.sh (18 checks, four mutations each caught).

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 01:14:22 -07:00
CatoandClaude Opus 5 a02d31d996 Every public claim matches the code, and two gates can now fail (#802)
* fix(truth): every public claim now matches what the code and the licence say

The /license page forbade what LICENSE grants. #791 relicensed the repo to MIT
and fixed LICENSE, the README and the Terms — but missed the page, which still
said "source-available", listed hosting and repackaging under "you may not",
and promised a replacement licence that had already shipped. On a public repo,
that revoked rights we had granted.

Same shape, five more places:

- Three live /thoughts pages and four front-matters carried "Mao Nakamoto",
  the retired identity, into the rendered byline and the OG social card.
- legal/ named that identity as operator, data controller and IP assignor, and
  assigned the work to bitbaum AG / orangecat GmbH / loki GmbH — none of which
  were ever incorporated. Rewritten as a record of authorship and the MIT
  grant, which is what is actually true.
- The desktop About dialog and the installer copyright metadata shipped
  "© 2026 Mao Nakamoto" in every build. No audit pass had looked there.
- /pricing and the feedback-widget docs said the report loop "closes itself"
  months after close-loop.ts deliberately removed auto-resolve for being
  untrue; resolve is an operator act and has zero call sites.
- /roadmap claimed signed installers under "Shipping now"; no signing secret
  exists and /download says the opposite two pages away.
- /releases claimed "every shipped version" while missing nine, and listed a
  0.8.25 that was never tagged — its "Binaries →" link 404'd. Removed per the
  file's own rule: one entry per tag pushed to loki-releases.
- desktop/README pointed all five install commands at bitbaum/loki, which
  404s; releases publish to loki-releases. Version pin replaced with a glob so
  it cannot rot again.
- DEFAULT_USER_NAME greeted nameless OAuth users as "Mao".

And the two that lied to agents rather than users: CLAUDE.md claimed pre-push
runs the full verify bundle so "green locally means green in CI", and
AGENTS.md claimed pre-commit runs tsc. The hook's own header documents why it
stopped doing both — a docs-only push runs nothing. An agent trusting either
line would skip the verification it needed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(gates): close the two gaps that let deleted things keep passing

Two gates could not fail, and one migration ledger had silently drifted.

MIGRATION JOURNAL — 13 files missing, next db:generate breaks the deploy.
drizzle/ held 78 .sql files; meta/_journal.json had 65 entries. Production
was fine and always had been: apply-schema.sh globs the directory and keeps
its own _deploy_schema_history, so it never reads the journal. But
drizzle-kit does, and its newest snapshot was 0072 — so the next generate
would re-emit 0073-0077, including CREATE TABLE "calendar_busy" with no
IF NOT EXISTS. apply-schema.sh rewrites ADD COLUMN only, and the batch is one
transaction, so the deploy would abort on a change unrelated to it.

Reconciled to 78 via bootstrap-migration-ledger.ts --write-journal, and added
scripts/test/migration-journal-coverage.ts so it cannot drift again: files vs
journal in both directions, plus idx contiguity. Proven by mutation — drop one
entry and it exits 1; restore it and it exits 0.

SMOKE — every authenticated probe passed whether or not the route existed.
The auth middleware answers 401 before routing, and check_route accepted 401
for everything in AUTH_API_ROUTES. Measured: /api/definitely-not-a-real-route
returns 401 exactly like /api/orgs. So the list proved nothing, and
/api/checkout/personal sat in it for 15 days after the Stripe rail was
removed. A 401 now only passes if a route file actually resolves on disk
(dynamic and catch-all segments included); the dead entry is gone, and all
remaining probes resolve.

Also: bumping desktop/package.json to 0.8.29, because the retired-identity fix
in the previous commit touched desktop/src/main/index.ts and desktop-release-
drift.ts correctly refused to let a shipped file change without a release to
carry it. That gate was right and is the model for the two above.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-20 08:40:34 -07:00
Cato f4164a6f67 fix(runner): make Terminal and provider status truthful (#755)
* fix(terminal): stop claiming dead sessions are generating

* fix(runner): report provider quota walls honestly

* docs: define Loki's working product contract

* fix(runner): replace stale provider PTY on retry

* fix(control): route provider switches to project runner

* fix(terminal): keep Watch on the dispatched runner
2026-09-16 23:21:21 -07:00
Cato 8034cb629b feat(feedback): add reporter tracking and project editors (#754) 2026-09-16 22:21:59 -07:00
Cato 43c6bb44af fix(runner): make feedback dispatch observably start (#745) 2026-09-16 11:54:30 -07:00
CatoandClaude Opus 5 a78b4b1e9a fix(runs): a fast task closes its run — delivery is stamped at injection, not at the ack (#720)
* fix(runs): a fast task closes its run — delivery is stamped when the prompt lands, not when the runner acks

The e2e health probe did everything right and its run never closed. The
agent was injected at 05:12:55, wrote `status: ready` at 05:13:06, and the
runner acked at 05:13:11 — because between injecting and acking it spends up
to eight seconds (plus retries) checking that the agent is actually
generating. `deliveredAt` was stamped at the ack, and closeRunFromSession
requires the handoff to POST-DATE delivery, so the run's own handoff read as
stale. It sat `waiting` until the hourly reaper called it a timeout.

Every task shorter than that check hits this, which is every health probe and
most one-line fixes — the runs most likely to be used as proof that the loop
works.

The runner now records the moment of `injectPty()` and reports it in the ack;
the server prefers it (`deliveryStampFor`) within bounds that keep the floor
honest: never before the run was created (60s of clock slack), never in the
future, otherwise the ack time as before. Tested on the verbatim timings above.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh

* chore(desktop): ship the delivery-stamp fix as Fleet Runner 0.8.25

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-14 23:18:42 -07:00
CatoandClaude Fable 5.1 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>
2026-09-13 16:13:10 -07:00
CatoandClaude Opus 5 f637036f17 feat(feedback): say WHY the agent is quiet, not just that it is (#679)
* feat(feedback): say WHY the agent is quiet, not just that it is

George dispatched a fix at 15:45:29. The first output arrived at 15:58:43 —
thirteen minutes later, and only because he opened a terminal by hand and
found the agent sitting at a Claude sign-in. The row said "the agent never
reported any output". True, useless, and the reason was ten seconds away.

Silence has two meanings and the operator can only act on one. "Thinking" is
nobody's problem; "waiting for a human" is theirs, right now. The runner could
already tell them apart — detectAuthFailure reads the transcript for a 401 or a
/login notice — but it only ever asked ONCE, inside an 8-second window at
inject time. That run passed the check and then went quiet, and nothing looked
again.

The heartbeat is the thing that watches the terminal for the whole run, so it
is where the question belongs. After 90 seconds of no output the runner asks,
and the answer rides the next beat; the route stamps payload.blocked and emits
one `blocked` event per stretch; the row reads "Needs you to sign in" with
Watch opening the terminal where you answer it. 90 s is chosen so the reason is
ready BEFORE the ten-minute mark forces the row to say something.

One subtlety worth the test that pins it: a blocked agent prints nothing, so
the "no output, no beat" rule would have suppressed exactly the beat carrying
the reason. Silence WITH a reason is now the message — still one beat per
window.

detectAuthFailure moved to desktop/src/main/agent-auth.ts: the poller starts the
heartbeat, so importing it back would have been a cycle.

163/163 unit files, lint, check:desktop, prettier green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore(desktop): 0.8.23 — the runner says why a quiet agent is quiet

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 10:53:41 -07:00
CatoandClaude Opus 5 a58fbb4b15 fix(runner): refuse a dispatch whose workspace is not on this machine (#614)
* fix(runner): refuse a dispatch whose workspace is not on this machine

The box clones on demand; a laptop Fleet Runner does not. Handed a project
whose dirPath exists only on the box, it launched claude in a directory that
does not exist and reported "inject did not stick" three times while the box
sat idle (2026-09-10). Routing now locks box-rooted projects to the cloud;
this is the runner's own refusal for any command that still arrives, so the
ack names the real cause instead of a guess.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0118cLNxoB3dt2w74vU1PH6w

* chore(runner): 0.8.22 — the workspace refusal reaches machines

The drift gate is right: a desktop/ change that is meant to reach laptops
needs the bump that says so. Adds the changelog entry for the refusal.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0118cLNxoB3dt2w74vU1PH6w

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-11 04:42:47 -07:00
CatoandClaude Fable 5.1 b7b26df120 feat(feedback): the row shows the work happening — runner heartbeat, Working · N min, Watch into the terminal (#632)
* feat(feedback): the row shows the work happening — runner heartbeat, Working · N min, Watch into the terminal

Between 'submitted' and 'closed' a run wrote nothing anywhere, so Feedback
read a busy agent as Queued and, from minute ten, as Not running. The box
runner owns the agent's PTY and sees every byte; it now beats
PATCH /api/control/runs/:id/progress (at most every 45 s, only when the PTY
printed) and the cloud stamps payload.lastProgressAt + a 'progress' event.

deriveFeedbackWork reads the heartbeat: fresh = 'Working · 47 min' for as
long as the run takes; gone quiet = 'Stalled' with how long it worked and
how long it has been silent; never any = 'Not running' after 10 min measured
from delivery. Every delivered phase is watchable, so the row's button is
'Watch' into /terminal?project=… whenever a PTY exists, and 'Open on
Control' only while Queued.

A project with no repository and no folder gets 'Connect a repository'
instead of Implement, and the dispatch route refuses the same case with a
422 that says what to do — the Annushka failure class, closed at the source.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017FU2m6NxPYYFkEdyufcSrX

* fix(control): Watch follows the same watchable rule as the Feedback row

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017FU2m6NxPYYFkEdyufcSrX

* chore(desktop): 0.8.21 — Fleet Runner reports run progress while the agent prints

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017FU2m6NxPYYFkEdyufcSrX

* docs(changelog): Fleet Runner 0.8.21 — run progress heartbeat

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017FU2m6NxPYYFkEdyufcSrX

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-11 03:12:09 -07:00
CatoandClaude Fable 5.1 6e6ca0bc7a docs(cloud-primary): nothing left that describes the old substrate — docs, marketing, comments, focus_tab (#631)
* docs(cloud-primary): nothing left that describes the old substrate — docs, marketing, comments, focus_tab

The cloud-primary series (#615 routing, #618 OrangeCat auto-kickoff, #624
Fleet Runner 0.8.19, #630 web PTY-only) changed what the product IS. This
sweep makes every surface that describes it say so, so neither an agent
reading the repo nor a person reading the site is told about zellij tabs,
presence-based routing, a cold-start restore, or a handoff that "starts
nothing".

Inventory-driven (≈105 doc lines, ≈30 user-facing strings, ≈22 code
comments, 2 repo-level items), not a grep-and-replace:

User-facing
- /download prerequisites: the "Zellij — bundled" card is gone; copy says
  each agent runs in a terminal Fleet Runner owns.
- Quickstart, license page, executor copy (cloud is the default; "This
  computer" is a per-project choice under Runs on), marketing pillars,
  whitepaper (owned-PTY design, "where a project runs is a decision, not a
  guess", ZSH typing-guard section deleted), Control terminal panel strings
  (components renamed LiveTerminalPanel / LiveTerminalRows), peek drawer
  copy, GitHub release notes for 0.8.19, repo description + topics.

Agent-facing
- README, CLAUDE.md, AGENTS-adjacent SSOTs: cloud-local-workflows.md now
  states the stored routing rule; priority plan closes B6; multitenancy plan
  routes by builder_pref; HANDOFF.md staleness table + terminals section;
  the 2026-09-10 cold-start handoff gets a dated "superseded" section; the
  two shipped proposals (fleet-runner-pty-ownership, desktop-app) carry a
  status banner; home/README describes the eight modules that exist;
  desktop/README describes 0.8.19; roadmap seed marks the migration done;
  box-runner unit and log drop FLEETCROWN_RUNNER_PTY; 22 code comments.

Code (one coherent retirement)
- focus_tab is removed from the pending-command contract, the desktop
  validator and poller, enqueueTabCommand's type, the validator test and the
  failure classifier (START_SESSION | RETRY). The runner had rejected it
  since 0.8.19; now it cannot be enqueued at all.

Verified: tsc, eslint, 148/148 unit files, 130/130 home self-tests,
check:desktop (typecheck + build).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WSNERoZZqW2TgqbAGHSQZf

* chore(desktop): 0.8.20 — the focus_tab retirement touches desktop/, so it ships as a release

The release-drift gate is right: a desktop change without a bump goes red on
main once the next tag is minted. 0.8.19's changelog date is corrected to the
release's real publishedAt.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WSNERoZZqW2TgqbAGHSQZf

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-11 02:41:20 -07:00
CatoandClaude Fable 5.1 5990c3fe68 feat(runner): one substrate — Fleet Runner owns every agent PTY, zellij is gone (#624)
The "Could not bring zellij up" toast fired on every Fleet Runner boot. It
came from a cold-start that could not work: `restoreFleetOnBoot` fetched the
user's last runtime snapshot — whichever channel pushed last, so on the laptop
it got the box's fleet with `/home/ubuntu` paths — wrote a zellij layout for
it, and spawned `zellij --session fleet --layout` detached with no TTY. A
zellij client needs a terminal to bring up its server; probed three ways on
2026-09-11, that spawn never produced a session, every time. The toast said
"Open Settings to retry"; Settings had a Restoration section that the desktop
never read (autoRestore hardcoded true) and no retry.

Since 0.8.3 the owned PTY was the default with zellij kept as the fallback for
tabs it could not find. The fallback is where every stuck dispatch ended:
"no zellij tab with that name in any active session" (2026-09-10 21:08, an
inject into Heidi), a keystroke typed into "Tab #9", a session spawned that no
terminal could show. This release deletes the fallback instead of hardening it
a fourth time.

Runner:
- poller: inject requires a live owned PTY and fails loudly otherwise (the
  cloud enqueues a DISPATCH for a project with no session, so a miss is a
  real error); launch/dispatch/switch own the PTY with no fallback; close and
  peek answer from the PTY or say there is none; focus_tab is retired;
  install_cli runs the installer in an owned PTY; the zellij session/tab
  helpers, the pre-flight `ensureSessionForCommand`, the ETIMEDOUT
  translation, and FLEETCROWN_RUNNER_PTY are gone.
- pusher: open tabs are the owned PTYs; pane records no longer join through
  ZELLIJ_PANE_ID or stamp a session name.
- index: no cold-start on boot, no bundled-binary PATH prepend, no zellij in
  the prerequisites scan; peek-tab reads the owned buffer.
- desktop/scripts/download-zellij.mjs and the prebuild download are deleted.

Web (the pieces that existed only for the cold-start):
- /api/control/runtime-state/desired (cross-channel snapshot read) deleted.
- Settings → Agent → Restoration (FleetLifecycleSettings + its API) deleted;
  the users.fleet_settings column stays (migrations never DROP) and is unread.
- src/lib/zellij-bootstrap.ts and zellij-layout-generator.ts deleted.

Fleet Runner 0.8.19; changelog entry written for the person who installed it.


Claude-Session: https://claude.ai/code/session_01WSNERoZZqW2TgqbAGHSQZf

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-11 02:12:33 -07:00
Cato 9b33aec49e Fix feedback loop with durable agent sessions (#541)
* fix(feedback): resume durable agent sessions

* chore(desktop): release Fleet Runner 0.8.18

* fix(ci): restore complete desktop lockfile
2026-09-09 08:48:24 -07:00
5e4192e4d1 fix(control): stop offering back the prompts nobody reuses, and the clamp that never clamped (#482)
Found by using /control in a browser as a user, on a phone-width window,
start to finish: pick a project, type a prompt, send it, follow the outcome.

1. "PASTE FROM HISTORY" WAS SHOWING THE OPPOSITE OF WHAT IT PROMISES

The card offered back conversational asides — "you do it. open in browser and
do it" — as reusable work. Not a rendering bug: those really were dispatches.
The selection was wrong.

Measured on prod, 30 days: 1859 distinct custom prompts, of which 1823 (98%)
were sent exactly ONCE. The query ordered by recency, so it surfaced the three
most recent one-offs — by definition the prompts least likely to be wanted
again — while the genuinely reused ones sat unoffered: "continue" 115×, a
git-diff review prompt 63×, "go ahead" 14×, "keep going" 8×.

Requiring two uses cuts the pool from 1859 to 36 and leaves exactly what the
feature is named for. Nothing is lost: Activity keeps every dispatch with a
re-run control. One-offs just stop competing for space on the card.

2. THE CLAMP I SHIPPED IN #479 WAS INERT, AND I COULD NOT SEE IT

`block ... line-clamp-2` computes to `display: block; -webkit-line-clamp: 2`.
`-webkit-line-clamp` does nothing without `display: -webkit-box`, and
Tailwind's `block` utility overrode it. It LOOKED fixed because an unclamped
box just wraps — which reads fine until the sentence is long.

Checked live in the browser: a 460-character next_step grew that box from 48px
to 96px and pushed the composer, the thing you act with, off the bottom of the
viewport. So my "it renders fully now" was measuring the ABSENCE of a clamp.

Dropping `block` makes it work; three lines, not two, so a typical next_step
(~256 chars) still reads in full and a pathological one is bounded and
reachable (clicking loads the whole text into the composer).

THE GATE: responsive-audit now flags a line-clamp that is declared but not
enforced. It cannot test `display === "-webkit-box"` — Chrome reported
`flow-root` for a clamp working correctly — so it tests BEHAVIOUR: an element
declaring N lines that renders more than N. Run against live prod it says:

  "Suggested next (profile)…"[ui-link-subtle-button.block.line-clamp-2]
  declared 2 lines, renders 4 (display:block)

naming the offending class. That is this exact bug, caught in shipped code.

3. A FAILURE MESSAGE THAT NAMED THE WRONG AGENT

A real dispatch returned: "launched claude (pty) + injected, but the agent
isn't generating yet … Retry, or switch the project agent away from grok if
this repeats." One sentence naming the agent that ran and, as advice, one that
did not — a literal left over from when grok was the default. `agent` was in
scope; the auth branch above it interpolates it correctly.

Gated in failure-message-pairing: a failure message that NAMES an agent must
interpolate ${agent}. Stated that way rather than "no agent ids", because the
auth message legitimately says `~/.claude/.credentials.json` and `claude
setup-token` — a real path and a real command — and already names the right
agent. The check joins `+` continuations so a message split across two lines is
judged whole; per-line it got that one wrong.

Mutation-proven: restoring the "grok" literal → 20 passed, 1 failed, naming the
line. Restored → 21/21.

pnpm run verify passes.


Claude-Session: https://claude.ai/code/session_01UvjGNAS9CMfEGNW26tUR4P

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 12:20:44 +00:00
4d1c9f1fe7 chore: migrate the fleet to the bitbaum org (#415)
* chore(ci): GitHub owner catomean -> bitbaum

* docs(hetzner): update _box-env.sh comments for the completed org migration

The GH_OWNER/WORKFLOW_OWNER comments described a future state (repos moving
to bitbaum while fleetcrown stayed personal) that sweep-gh-owner.sh just
made true, then obsolete: fleetcrown itself is in bitbaum now too. Comments
describing a plan that already happened are worse than no comment — they
send the next reader looking for a divergence that isn't there.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y9rKLxddothnXEtY6KDziN

* chore(desktop): release 0.8.15 — the org-migration owner literals

Same shape as 0.8.14: desktop/ carries two literal owner references (issue
link, updater feed owner) that a fleet-wide rename touches, and
desktop-release-drift.ts correctly refuses to let that ship without a
version bump — a repo whose desktop app silently points at a dead update
feed is worse than one that fails the gate.

This should be the last time it's an account name: the org is the stable
home from here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y9rKLxddothnXEtY6KDziN

---------

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 07:45:50 +02:00
45938e60cf fix(ci): unbreak the gates — dependency graph, agent-core drift, desktop release (#400)
* refactor(infra): studio constants get one home, and the rename gets a command

Fair criticism: I spent the day arguing for SSOT and then wrote new-site.sh with
its own copies of GH_OWNER, BASE_DOMAIN and DEV_ROOT, and hardcoded
'maonakamoto' again in provision-widget.ts. Worse, the pattern already existed —
_box-env.sh is literally labelled 'SSOT' for the box address. I did not extend
it, I duplicated around it.

_box-env.sh now owns GH_OWNER, SITES_BASE_DOMAIN and DEV_ROOT alongside the box
address, and new-site.sh and provision-widget.ts read them instead of carrying
their own.

The 41 workflow files are a different case and worth being precise about:
GitHub Actions requires a LITERAL owner/repo in  and will not accept a
variable, so that duplication cannot be removed. But a duplication you cannot
remove is one you have to OWN — leaving it as 'remember to edit 41 files' is
exactly the shape of step that gets skipped, the same shape as the git
repository Camille never got. So sweep-gh-owner.sh is committed: one command,
dry-runnable, optionally self-committing.

Dry run against the fleet: 24 repos, all detected correctly. Renaming to an org
is now  plus one line in _box-env.sh.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(infra): split WORKFLOW_OWNER from GH_OWNER before they diverge

Same bug as the last commit, one layer down. The site template hardcoded
maonakamoto/fleetcrown in its deploy.yml uses: line, derived from nothing — so
every new site would bake in a literal that follows neither an account rename
nor a move to an org.

And GH_OWNER was quietly doing two jobs: where new site repos are CREATED, and
where fleetcrown LIVES. They look identical today and are about to diverge —
sites go to an org while fleetcrown stays on the personal account. One name for
two values is how a rename half-works.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore(ci): GitHub owner maonakamoto -> catomean

* chore(infra): owner is catomean

Account renamed maonakamoto -> catomean. sweep-gh-owner.sh swept 24 repos and
the SSOT now agrees; 32 local remotes repointed. This is the commit the sweep
script exists for.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore(ci): GitHub owner maonakamoto -> catomean

* chore(ci): GitHub owner maonakamoto -> catomean

* fix(desktop): cut 0.8.14 — the owner rename touched desktop code

My owner sweep changed two files in desktop/ (an update URL and a package
reference) without bumping the version. That is precisely the failure #370
existed to prevent: desktop code that changes without a release ships to the
server and to no machine at all, silently.

The gate caught it, four commits after it was written. Working as intended, and
worth saying plainly — I was the one it caught.

GitHub redirects repository URLs after a rename, but only until somebody claims
the freed name. An auto-updater should not depend on a redirect.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(ci): the gate fails on your diff, not on your laptop

Three things in this hook blocked pushes for reasons unrelated to the change
being pushed, and together they are why --no-verify became reflex here. I passed
it eight times in one day and blamed the hook; the hook was reporting real
problems with misleading attribution.

1. STALE INSTALL. An unresolvable dependency surfaced as 'Cannot find module' —
   indistinguishable from a type error in your code. Now a precondition that
   fails first, loudly, naming npm ci. A day was spent on this exact confusion.

2. AGENT-CORE DRIFT. Drift arises either because you changed canonical without
   syncing, or because somebody changed the mirror in the other repo. Only the
   first is yours. It now checks whether this branch touched
   src/lib/agent/core/ and warns instead of blocking when it did not.

3. SCHEMA DRIFT. The guard already skipped an unreachable database but not a
   reachable stale one, so a local scratch DB missing someone else's columns
   blocked pushes touching no schema. Now scoped: if the branch changes schema a
   mismatch is yours and blocks; otherwise it reports and continues.

The pattern is taken from desktop-release-drift, which self-scopes to files
changed since the last release and is the only check here that has never blocked
an unrelated push. It caught me correctly today, four commits after it was
written.

Where scope cannot be established the checks still fail closed — a gate that
cannot establish innocence should not grant it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(ci): resolve the default branch, never assume main

The diff-scoping added in the previous commit compares against origin/main. 28
repos here use main — but aoz-housing, dotfiles and sbb-lost-found use master,
and six had no origin/HEAD set at all.

On those, merge-base fails, the scoping falls through to 'cannot tell', and
every check treats every change as in-scope. The gate I had just fixed would
have gone back to blocking unrelated pushes on a fifth of the fleet, for a
reason nobody would have connected to a branch name.

default_branch() now lives in lib.sh and resolves in order: the remote's own
origin/HEAD, then whichever of main/master exists, then fail. Never a guess. The
pre-push hook and agent-core-drift both use it.

Also ran 'origin/HEAD' is unchanged and points to 'main' on the six repos missing origin/HEAD.
32 of 33 now resolve; wild-spirit has no remote at all, which is a separate
finding and the same shape as camille this morning.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(scaffold): every new site is born with CI

ci-gate.sh cannot tell 'CI green' from 'no CI configured' — both exit 0. So a
scaffolded site without a workflow deployed every push unverified while looking
identical to one that passed. Substrata shipped to production that way for a day.

The template now emits ci.yml alongside deploy.yml: npm ci, type-check, lint,
build — the same bundle verify runs locally.

Plus eslint.config.mjs, because ESLint 9 without a flat config exits non-zero on
a migration notice and a new site's FIRST CI run would be red for reasons
unrelated to its code. A red first run teaches people to ignore the light.
Config copied from the fleet's working Next 16 apps, not invented.

postcss.config.mjs assigns before exporting — the anonymous default export is a
lint warning, and a scaffold should not emit its own warnings.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(ci): no deployed app ships without CI, ratcheted to zero

ci-gate.sh exits 0 for 'CI green' AND for 'no CI configured'. Absence is
indistinguishable from success, so an app with no workflow deploys every push
unverified while looking exactly like one that passed. Nothing reported it,
because nothing was looking.

The audit found two: camille-boulangerie, and sink — which is sinktattoo.com, a
real client's site.

sink turned out to be a FALSE POSITIVE, and that is the more useful finding:
apps.conf pointed at /home/g/dev/s-ink, a path that does not exist, so the gate
reasoned about an absent repository and reported the wrong fault. It sent me to
add a workflow to a repo that already had one. The register was the bug.

So the gate now distinguishes a stale register entry from a missing workflow and
fails loudly on the former — a gate that lies about what to fix is worse than no
gate. apps.conf repointed at /home/g/dev/aslan-tattoo.

Camille genuinely had none and now does. Baseline is 0: a new deployed app
without CI is a build failure.

Tested in all four directions — over baseline fails, at baseline passes, under
baseline passes and prompts, stale path fails. The first version could never
fail at all: it set HERE before sourcing lib.sh, which overwrites HERE, so
BASELINE_FILE pointed at a missing file and silently fell back to the current
count. Found by testing the gate rather than trusting it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(scaffold): template ships .nvmrc

Every new site now pins Node once, and both CI and the deploy read it. Without
it the deploy warns and the two pipelines pick a version independently — the
kind of difference that surfaces as 'green in CI, broken on the box'.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(hetzner): scaffold sets the deploy key itself, from one configured path

new-site.sh printed `gh secret set ...` and called that operator hygiene.
What it actually produced was substrata live in production deploying only
from a laptop, because a printed instruction is a step that gets skipped.

The key is piped from DEPLOY_KEY_PATH straight into `gh secret set` — never
read into a variable, a log, or an agent's context — so the safety argument
that motivated the manual step is kept while the step disappears.

Per-repo on purpose: GitHub Free does not expose org-level secrets to PRIVATE
repositories, so an org secret alone would silently cover only part of the
fleet. DEPLOY_KEY_PATH joins the other constants in _box-env.sh so there is
one path, not one per script.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y9rKLxddothnXEtY6KDziN

* fix(ci): make the deploy-ready gate judge the diff, not the workstation

The gate inspected the sibling checkouts under DEV_ROOT and nothing else.
All 15 are cloned on the workstation, so it printed "all 15 deployed apps
have CI"; CI clones this repo only, so the same commit printed fifteen
missing repos and exited 1 — red on a diff that touched none of them.

Third instance of one class: a gate judging state outside the commit. Its
real cost is not the red run, it is that everyone learns the gate is noise
and reaches for --no-verify.

Split into the two halves that were tangled:

  REGISTER INTEGRITY — apps.conf lives in this repo, so it is in the diff,
  so CI must judge it. Now actually checked: field count, unique names,
  unique numeric ports. Previously nothing validated the register at all.

  FLEET INSPECTION — needs the checkouts. Where none exist it is announced
  as NOT RUN and exits 0. Announced, because "no output" and "all clear"
  looking identical is the bug this file was written to fix. Where some
  exist, a bad path is still drift and still fails.

test:deploy-ready-gate locks it shut from both sides: a malformed register
must fail even with no checkouts present, and a bare environment must never
claim the fleet passed. Added to verify, so CI runs it in exactly the
environment that used to break it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y9rKLxddothnXEtY6KDziN

---------

Co-authored-by: Mao Nakamoto <georgy.butaev@revamp-it.ch>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: t <t@t.t>
2026-08-28 05:04:32 +00:00
fe221200da fix(usage): one directory, one metered run — stop billing the same tokens twice (#349)
Token spend is recovered by replaying an agent's Claude Code transcript over a
time window, `collectClaudeUsage(dir, from, to)`. The transcript is keyed by
DIRECTORY, not by run, so the window is the only thing separating one run's
tokens from another's — and the reporter recomputed `[deliveredAt, now]` every
heartbeat with no upper bound. Any two runs alive at once on one cwd therefore
converged on the same answer and each reported the whole thing.

Prod, read-only:

    run_a    run_b    project    overlap  out_a   out_b   identical  cost each
    844608d3 9a560f3f orangecat    8.2m   24697   24697      YES      $1.7605
    03626fa7 d693460a orangecat  109.5m       0       0      YES        (null)
    03626fa7 f917c891 orangecat  108.7m       0       0      YES        (null)

Byte-identical totals AND identical sessionIds — the same assistant messages,
counted once per open run. $1.7605 is provably double-billed. More broadly, 30
of 105 metered runs carry a window that overlaps a sibling's, and those runs
account for $65.93 of the $154.96 recorded fleet spend, so an unknown slice of
43% of the ledger is duplicated.

The 109-minute rows are the same three orangecat runs from #348: while an idle
agent sheltered them, all three kept reporting `[own delivery, now]` over one
transcript. That bug made this one visible; they are independent.

The fix is the shape every attribution fix in this codebase has taken — stop
asking "what happened while this run was open?" and use a fact about THIS run.
A newly delivered prompt in the same directory IS that fact: it is the runner's
own local proof that the previous run's turn is over, so that run's window ENDS
there. No round trip, no clock compared across two machines, and — the reason
it is the right signal rather than the run's close — it holds even when the
close never arrives, which is exactly what produced the 109-minute overlap.

Worth knowing, because it bounds the fix: two prompts CAN reach one directory
while the first agent is still generating. The FIFO gate's blocker set is
itself time-windowed (`STALE_RUN_MINUTES`), so an open run stops blocking after
60 minutes and the next prompt is typed into the same session — which is
exactly how three orangecat runs came to be delivered 20:28 / 21:29 / 21:30.
When that happens the two runs' tokens are genuinely inseparable: one
transcript, one session, interleaved. Ending the older window credits the
shared tail to the NEWER prompt (the agent's actual current instruction) and
can under-report the older run. That is the right direction to be wrong in —
under-reporting one run is a smaller lie than reporting both runs' totals as if
each had spent the whole amount.

Narrowing only: an entry that already has an end keeps the earlier of the two,
and a run delivered AFTER the claimant is left alone, so a repeated or
out-of-order call can never widen a window back over someone else's tokens.
`windowTo` in the POST body now carries the clamped end too — that field is
what made this bug visible in the first place, so it must keep telling the
truth rather than always echoing `now`.

Also swept the rest of the run-attribution surface for the same class. Clean,
because they key on an id rather than a window: attachFeedbackWork and
resolveFeedbackForRun (dispatchedRunId FK), the usage route itself (run id in
the path), closeOpenRunBySessionTab (one alias, one run), and the DoD judge
(judges the run's own handoff). The control page selecting only the newest open
run is covered — both the push path and the hourly sweep iterate EVERY open
run, and the deliveredAt guard blocks the reverse ordering.

The separating test, for next time: a window answering "how many are busy / is
anything happening?" is correct and unavoidable (getFleetSummary,
countActiveRuns, OPEN_TURN_TTL_MS, prompt echo-dedupe). A window answering
"WHICH one did it?" is the bug — ask what the answer is used to credit or
charge.

scripts/test/metering-window.ts is auto-discovered by test-unit and proven by
mutation: removing the clamp, ignoring the frozen bound, and widening instead
of narrowing each turn it red (exit 1); restored, green.

Not automated, deliberately: a nightly invariant that fails when two runs on
one project_path report overlapping windows would catch a regression or a
stale Fleet Runner in the field. It is not in this PR because it would report
into the same void as everything else — TELEGRAM_CHAT_ID is still unset and
push_subscriptions is still empty, so FleetCrown has no delivery channel.
Building the detector before the channel repeats the ledger-ready mistake.

Historical metering data is left as-is. The duplicate is provable but which of
two runs owns the tokens is not recoverable from the DB — the transcripts live
on the runner host — and an arbitrary "correction" would be worse than a known
inflated number.

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-25 11:52:33 +00:00
c350623c20 fix(feedback): ship the stranded work-phase overhaul — honest status instead of a bare 'dispatched' chip (#334)
* fix(feedback): don't treat queued install as live

Widget coverage and the project card wait for a boot heartbeat. Control
labels idle as project inventory, and unverified Grok inject is a failure
instead of a warning that looks like success.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(feedback): honest queue language, notify-on-close for feedback runs, activity watch links

Port of the uncommitted refinement pass stranded in the main checkout on top
of the rescued work-phase overhaul: every feedback dispatch (single, batch,
AI review, synthesize, install) now sets notifyOnClose so the operator gets
a push/Telegram ping when the fix run finishes; 'Dispatch' copy becomes
'Implement'/'Queued' with EXECUTOR_COPY.honesty as SSOT; watch links route
through fleetSurfaceHref (new 'activity' surface + injectWatchUrls helper)
instead of hand-built query strings.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: t <t@t.t>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-23 13:08:19 +00:00
541bb9b7a2 feat(dispatch): route by durability — a laptop on battery is not infrastructure (#319)
#315 routed by presence, using "the desktop builder is connected" as a proxy for
"the operator is sitting at it". A phone falsifies that proxy exactly: dispatch
from a café while the laptop happens to be awake, and the work lands on a
machine nobody is watching — one that sleeps the instant the lid shuts, which is
now the configured lid behavior on battery. Same request, wildly different
odds of surviving.

From a phone, BOTH trees are invisible. The operator cannot open the laptop's
editor and cannot see the box's filesystem, so the thing that justified
preferring local at a desk — your checkout, your env, visible as it happens —
is worth nothing. What is left is durability, and durability is knowable: the
box is mains-powered by construction; a laptop is dependable only while it is
plugged in. That is the same predicate that decides whether it sleeps.

So the runner now reports it, and routing is four tiers:

  1. lock       physics — only one machine can materialize this project
  2. durable    the operator's own machine, unless we KNOW it is on battery
  3. cloud      away, or the laptop is ephemeral → the always-on box
  4. local      a battery laptop still beats nothing (box unavailable)

CONTRACT DECISIONS, each of which is the interesting part:

- Power rides the heartbeat row, so it EXPIRES with it. A stale "ac" is the
  dangerous reading — it vouches for a laptop that has since gone to sleep.
  Presence and durability are derived from one read against one clock, because
  this subsystem already shipped a bug where liveness was computed from
  timestamps loaded at a different moment.

- UNKNOWN IS NOT BATTERY. Runners predating this field report nothing, and
  demoting them would stop every un-upgraded desktop from receiving work —
  fatal for an account with no cloud builder to fall back to. Routing acts on
  positive knowledge only. Negative-tested: making unknown behave as ephemeral
  fails the suite.

- Physics still outranks policy. A dirPath-only project on battery stays local;
  the cloud would clone-fail into an empty directory (the 2026-07-14 misroute).

- Demotion is a REDIRECT, never a refusal: with no box available, the battery
  laptop is still the answer.

- power-source.ts imports no Electron — pusher.ts is loaded by the headless
  box-runner too — and never throws. A heartbeat that died because a power probe
  failed would be far worse than not knowing: unknown is a safe answer, a thrown
  error stops presence itself. A machine with no battery reads "ac", which is
  both true of the box and the answer that keeps it durable.

- upsertRuntimeSnapshotIfNewer took seven positionals, four optional and three
  string-ish. Adding an eighth was the moment to switch to named fields, not the
  moment to make a transposed argument even easier to ship.

- readChannelHeartbeats gets a narrow-select fallback (the pattern
  readConnectionFlags already uses). Its `[]` path does not merely lose power
  state — it makes every builder read offline, so an unmigrated column would
  take dispatch down rather than degrade it. Deploy applies migrations before
  rsyncing code, so this should never fire; "should never" is not a property an
  outage respects.

Migration 0056 is a single additive nullable column.

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 15:01:10 +00:00
869a406a1c feat(control): count the agents that are actually working (#317)
Control read "0 working · 0 awaiting input · 21 idle" while eight Claude
sessions were mid-task in real worktrees. The number was right about what
it measured and wrong about the fleet, which is the worst kind of right.

Every "working" signal required FleetCrown to have dispatched the run (a
/tmp sentinel backed by a /proc scan) or the runner to recognise a zellij
tab named after a registered project. A session started any other way —
a terminal you opened, a background job, a worktree — produced neither,
so it was structurally invisible. The presenter already half-knew this:
it downgrades "Not running" to "Active recently" because "sessions run in
tabs FleetCrown can't observe". That was a nicer way to say the same
thing, not a fix.

The honest definition needs no tab and no process table, because the
agent announces both edges of its own turn:

  UserPromptSubmit → a turn STARTS  (ended_at NULL)
  Stop             → that turn ENDS (ended_at set)

New agent_sessions table, one row per session, upserted per turn. An open
turn IS "working" — the only claim in the system backed by the agent's
own report rather than by inference about the machine it runs on.

Details that decide whether this is true or merely plausible:

- Liveness is recorded BEFORE the ledger's noise and dispatch-echo
  filters. Those decide what deserves a line in the activity log; they
  say nothing about whether an agent is working. "continue" is noise to
  read back and still starts a real turn. Filtering liveness alongside
  prose would blank the count during exactly the short, repetitive
  prompts that make up most of a long session.
- A session killed mid-turn never sends Stop, so readers bound on
  started_at too (OPEN_TURN_TTL_MS = 30min, deliberately the same
  constant as STALE_PROMPT_S — two definitions of "too old to believe"
  would eventually disagree on screen and the user would be right to
  trust neither).
- An open turn outranks readyAt and orchestration-ready: those mean "the
  agent finished"; a new turn means it is working again. Without this the
  card sits on "Ready" through the whole next turn and the project lands
  in the awaiting-you bucket while an agent edits it.
- liveAgentTurns is REQUIRED on ProjectState, not optional. An optional
  field lets a route that forgets to select it compile clean and render
  "idle" forever — the exact class that hid this for months.

Fixes a latent bug in the same path: the capture hook forwards Claude's
stdin verbatim, which spells the field `session_id`, while the route's
schema only accepted `sessionId`. zod strips unknown keys, so the id was
declared, accepted, and never once populated. Both spellings now.

Fleet Runner installs the Stop hook alongside the capture hook (appended
to the user's existing Stop entries, never replacing them), from one
shared script template so the two cannot drift.

Pure logic lives in lib/agent-turns.ts, not db/queries — importing the
query module into a test drags in the database connection and the unit
suite runs with no DATABASE_URL. 6 new presenter tests cover both sides:
an open turn makes a project working, count 0 does not, an open turn
beats a ready stamp, and a ready stamp still wins when nothing is open.

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-16 15:00:23 +02:00
002ed07491 feat(terminal): name the agent in a DEFAULT-named tab, via ZELLIJ_PANE_ID (#269)
The ask behind #252 was "sometimes one tab has claude and another has grok —
know what is in what". The previous two passes couldn't answer that for the
setup it was actually asked about. Both resolved a tab by NAME (conf entry, or
the process's cwd basename), and real zellij tabs are called "Tab #3" — a
string that appears nowhere near /home/g/dev/<project>. Dry-run on the box
this was reported from: 4 tabs, 8 live agent processes, zero badges.

There is a real join, it just wasn't being used. Zellij exports ZELLIJ_PANE_ID
and ZELLIJ_SESSION_NAME into every pane's shell and children inherit them, so
an agent process knows its pane even when launched through a wrapper like
systemd-inhibit. Zellij also persists pane -> tab_position -> tab name in
~/.cache/zellij/<version>/session_info/<session>/session-metadata.kdl. Join the
two and the tab is known exactly, whatever it is called.

  getAgentProcesses() now returns pid + zellijPaneId + zellijSession
  getZellijPaneTabMap(session) parses the metadata (no KDL dep, no shellout)
  buildPaneTopology() tries pane-id first, then conf, then cwd basename

Same machine, after: Tab #3 -> grok, Tab #4 -> claude, Tab #5 -> cursor.

Why not dump-layout: it emits bare panes with no cwd and no command, so it
cannot tie a tab to a process. Why the file and not a CLI call: it is one small
read with no shellout, and if the format ever changes the map comes back empty,
which degrades to no badge rather than a wrong one. Background daemon panes
(Claude Code's bg-spare hosts) map to no live pane and are dropped, so they
never masquerade as a user's agent.

Co-authored-by: test <test@test>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-14 10:29:59 +00:00
8270fff0b3 fix(terminal): the agent badge had no data — panes came only from a legacy dotfile (#266)
#252 shipped the join that labels a terminal tab with the agent CLI running in
it. Verifying it live showed every badge empty, on both channels. The join was
fine; the data was never there. runtime_snapshots.panes was `[]` in the cloud
AND local snapshots while open_tabs held five tabs.

buildPaneTopology() walked ONLY agent-projects.conf. That file is a legacy
laptop dotfile: the headless box never had one (it clones repos on demand) and
laptops have stopped maintaining it, so the loop had nothing to iterate and
emitted zero panes — permanently. The function right below it, projectEntries(),
carries a long comment about learning exactly this lesson in the 2026-07-02
incident and grew a process-derived fallback; buildPaneTopology never got one.

Derive panes from the live agent processes instead, keeping conf as the
preferred source when it names a tab explicitly. This restores the badge for
every project-named tab and every cloud PTY tab (those are always named after
the project).

Default-named zellij tabs ("Tab #3") stay uncaptured on purpose: zellij's
dump-layout emits bare panes with no cwd or command, so nothing on the system
ties such a tab to a process, and a guess would confidently name the wrong
agent — worse than showing none.

Co-authored-by: test <test@test>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-14 01:49:38 +00:00
Gandtest 86615aa22f fix(control): every claim on Control is now sourced, scoped, and expirable (#263)
The Control page presented six kinds of untruth. Each had a distinct root
cause, and each is fixed at the source rather than at the label.

1. Two builder channels, one row read. The cloud box-runner and the local
   desktop app each upsert their OWN runtime_snapshots row, but the reader
   took a single row — last writer wins. So open tabs, installed agents and
   the version string all silently described whichever channel pushed most
   recently. getRuntimeSnapshots() returns every channel; tabs are unioned
   across the FRESH ones, agents prefer local, version is reported per
   channel ("cloud v0.8.9 · app dev build") instead of one number standing
   in for both.

2. "builder vdev" on a released build. pusher.ts read
   FLEETCROWN_RUNNER_VERSION at module-import time, but index.ts sets it
   inside app.whenReady() — always after. Read at call time.

3. Worktrees broke project keying. Every session now runs in
   <repo>/.claude/worktrees/<name>, so basename(cwd) reported the worktree
   as the project and the real repo looked idle while an agent worked in
   it. Resolve to the worktree root. Joins between live tabs and DB state
   also used raw .toLowerCase() on one side and normalizeTabName() on the
   other, so "Prime tower" never matched the runner's "prime-tower" row —
   both sides now normalize identically.

4. "sync 1m ago" laundered web writes. runnerLastPushedAt was bumped by
   any write, including this browser's own. It now reflects runtime pushes
   only, so a stale runner reads as stale.

5. Synthetic smoke traffic rendered as fleet work. The authenticated smoke
   probe dispatches "[smoke-<ts>] probe — ignore" against a real project;
   it appeared in Workspaces and Recent activity as genuine agent output.
   smoke-filter.ts is the SSOT for the marker and is applied to all eight
   user-facing dispatch reads. hasRecentIdenticalPrompt stays UNFILTERED
   on purpose — the echo-dedupe test must find its own row. Per the
   never-twice rule, smoke-marker-contract.ts fails if the writer's marker
   and the filter's prefix ever drift apart, or if a new activity read
   forgets the filter.

6. Claims that could never come true. "Waiting to dispatch" was the pulse
   catch-all with nothing queued and nothing coming; it now says "Idle —
   nothing queued", or names the projects actually waiting on the user.
   "Not running / Last dispatch today" gets a real state (Active recently,
   3h window) instead of reading as dead. "Next:" now says whose next step
   it is and how old — an agent handoff and a profile field written during
   enrichment are not the same claim. The Workspaces caption admitted only
   half the filtering; it now states how many open tabs are hidden and
   that unmatched tabs run unseen. Counts are exact: "5+ dispatched" was
   the fetch cap, "Recent activity (30)" was the fetched length while 20
   rendered.

Also: the autopilot hint no longer asserts a mode before the policy has
loaded, and a card under a fleet-wide execution stall says dispatches are
queued and not executing rather than "queue is empty".

Verified: tsc clean, lint, check:design ok, check:desktop ok,
test:unit 71/71, control-presenter 33/33.

Co-authored-by: test <test@test>
2026-08-14 01:26:10 +00:00
2a8559f65b feat(terminal): tabs tell the truth — project + live agent, launch in place (#252) (#261)
The terminal knew a tab was called "Tab #1" and nothing else. The runner has
been pushing full pane topology (tab, cwd, agentCli) in every runtime snapshot
all along; nothing joined it to the tab strip. Now /api/terminal/context does:

- Tab strip shows the resolved project name plus a badge naming the agent CLI
  actually running in that tab ("claude", "grok", "claude+codex"). Tab→project
  resolves by name first, then by pane cwd prefix against a project's dirPath —
  which also recovers `dir` for generically named tabs, un-breaking the agent
  switcher there.
- Empty state can start an agent instead of only telling you to go elsewhere.
  TerminalLaunch reuses /api/agent/launch with the same eligibility rule as
  Control (projects with a linked directory) and pins the builder channel you
  are looking at, so the session appears on the terminal you started it from.
- A ?tab=X deep link that matches no live session says so, instead of silently
  showing Tab #1 and letting you type into the wrong agent.
- box-runner reads its version from desktop/package.json (the code it actually
  runs). The systemd unit pinned box-0.8.9 across three releases, so Settings
  reported a version the box was not running. Env demoted to fallback; deploy
  ships desktop/package.json alongside the modules.

Co-authored-by: test <test@test>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-14 00:41:21 +00:00
ef2f81bbd8 fix(capture): one capture hook SSOT — deregister dead legacy hook, detect drift (#230)
The June-era fleet-user-prompt.sh UserPromptSubmit hook posted to
localhost:3000, where nothing listens on a normal setup — every directly
typed prompt was silently dropped for ~2 months while the hook LOOKED
wired. PR #215 added the real installer but left the corpse registered,
which would have double-fired capture POSTs once a new runner build ran.

- capture-hook.ts: ensureCaptureHook() now strips any fleet-user-prompt.sh
  registration while merging its own entry (idempotent, writes only on
  change) — one hook is the SSOT.
- doctor hooks-capture: warns when the legacy hook is still registered
  instead of reporting a healthy-looking sensor that records nothing.
- desktop 0.8.11 → 0.8.12 so builds carrying the migration are
  distinguishable from the dormant fleet.

Gates: tsc 0 errors, eslint clean (src/ + desktop/src/), check:desktop ok.
Capture path verified end-to-end against prod (hook → route → prompt_history).

Co-authored-by: test <test@test>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-13 15:03:03 +00:00
649304851c feat(activity): record tab-inject dispatches + install typed-prompt capture hook (#215)
Closes the two terminal↔activity parity gaps:

1. /api/control/tab-inject (terminal composer, RunModal "Send to terminal",
   ZellijLivePanel) now records prompt_history + an orchestration event on
   every dispatch, and opens an orchestration run for project-scoped cloud
   dispatches — created BEFORE enqueue so the command payload carries runId
   and the runner ack (submitted/delivered/undelivered) and queued-dispatch
   ordering machinery work exactly as they do for /api/inject.

2. Fleet Runner now installs the Claude UserPromptSubmit capture hook
   (desktop/src/main/capture-hook.ts) on startup and after token pairing:
   a bash script forwarding the hook's stdin verbatim to
   /api/activity/capture, token read at call time, fire-and-forget.
   /api/system/doctor gains a "hooks-capture" check (warn, not fail).

Because the hook fires for injected prompts too (the CLI can't tell
FleetCrown's keystrokes from human typing), the capture route dedupes
against fresh dispatch rows (hasRecentIdenticalPrompt, 10-min window,
btrim'd comparison) and skips echoes.

Co-authored-by: test <test@test>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-13 11:21:11 +00:00
c9c924ef23 fix(orchestration): the evidence agents write never reached the judge (#173)
The DoD judge is prompted to check typecheck, lint and commit evidence.
It was never shown any. Production, 56 runs with a summary:

    tests filled 55 · tsc filled 0 · lint filled 0 · commit filled 0

Zero is not sloppy agents. Agents have been writing the fields all
along — `tsc: pass`, `lint: pass`, `commit: 1ed429c` are sitting in real
handoff files right now. Every layer between them and the judge dropped
the three fields:

  - no session_tsc/lint/commit columns on project_states
  - no tsc/lint/commit on SessionState, so dbRowToSession lost them
  - closeRunFromSession didn't pass them to buildOrchestrationSummary
  - the desktop pusher never sent them

The loss is silent by construction: an unlisted field defaults to "",
summaryForJudge filters empty fields out, and the judge answers "no
evidence" exactly as instructed. Good work closed `partial`, indefinitely
— which is most of the 26-partial / 3-success week that prompted the
definition_of_done rewrite. The bars were half the story; this is the
other half.

Also unblocks infer-outcome, which reads summary.tsc for "fail" to raise
a run to `error` — a failing typecheck could never escalate either.

Second occurrence of the class: block-reason/no-op-count were lost the
same way (see the note in orchestration/summary.ts), both times via a
hand-written field list drifting from the contract. So the fix ends the
class rather than the instance — DOD_EVIDENCE_FIELDS is now the exported
SSOT for what the grader can see, and scripts/test/handoff-evidence.ts
walks it, failing if any field cannot survive handoff → judge on either
the file or the pushed path. Verified it has teeth: reverting the
close-path line fails exactly 6 of its 19 assertions.

Migration 0048 is additive (three nullable text columns).

Verified: tsc pass · lint pass · check:design ok · test:unit 50/50 ·
test:home 150 · test:ops 18. Committed with core.hooksPath=/dev/null
because the pre-commit hook re-runs tsc+eslint (>4 min); both were run
manually above.

Co-authored-by: test <test@test>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-06 08:48:02 +00:00
04785343a4 fix(runner): meter the directory the agent actually runs in (#147)
Token accounting (#133) shipped, ran a full day, and wrote ZERO rows — no
usage_detail, no tokens, no cost, across 15 runs.

A dispatch carries the founder's LAPTOP path (`/home/g/dev/solon`). On the box
that path does not exist, so `launchAgentPty` resolves a box-local clone via
ensureBoxWorkspace — but it resolved it PRIVATELY: the effective directory never
escaped the function. Everything else in the runner kept using the unresolved
path, including the two places that look up `~/.claude/projects/<slug-of-dir>`:

  - the usage reporter tracked `-home-g-dev-solon`, a transcript directory that
    cannot exist on the box, so `collectClaudeUsage` returned null and every
    tick skipped it — silently, forever;
  - `detectAuthFailure` read the same missing directory, so dead box
    credentials were undetectable on the very runner whose two silent outages
    (2026-07-02/03) motivated writing that canary.

The fix is to stop having two answers to "where does this project live":
box-workspace-path.ts derives it once, box-workspace.ts uses it for cloning,
and the poller uses it for both transcript lookups. Pure (fs/os/path only) so
the poller can import it statically without pulling @/db into the desktop
bundle — the reason box-workspace.ts is dynamically imported in the first place.
On the laptop it is the identity function.

Also: the no-transcript branch now warns ONCE per run. Its silence is the whole
reason this went a day unnoticed — a metering path that fails quietly is
indistinguishable from a fleet that spent nothing.

7 tests, incl. the real production dispatch shape. Unblocks #136, whose start
gate waits on metered runs that could never arrive.

Closes #145

Co-authored-by: test <test@test>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-03 09:56:37 +02:00
f754eacf27 feat(orchestration): per-run token/cost accounting from agent transcripts (#133)
Item 1 of the ledger-and-loop build sequence: every dispatched Claude run
now records what it consumed.

- lib/usage/claude-transcript-usage: window-attributed usage from
  ~/.claude transcripts (dedup on message.id; slug handles dotted paths)
- runner: usage-reporter ledger reports cumulative windows on the
  heartbeat cadence; poller tracks delivered Claude dispatches and now
  uses the corrected slug in detectAuthFailure (worktree dirs never
  matched before)
- box: POST /api/orchestration/runs/:id/usage prices tokens via
  config/model-pricing (rate changes never need a runner release);
  freeze rule stops a session's next run leaking tokens backwards
- schema: tokens_in/out/cache_read/cache_write, cost_usd, usage_detail,
  usage_updated_at on orchestration_runs (additive migration 0046)
- UI: usage line on the run panel + Today recent-runs list
- test: scripts/test/run-usage.ts (auto-discovered by test-unit)

Co-authored-by: test <test@test>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-02 12:58:58 +02:00
006c4f139b fix(desktop): confirm before saving a fleetcrown:// deep-link token (#107)
A fleetcrown:// deep-link can originate from any page the user visits
(a link, redirect, or img/iframe src) — the OS hands the runner the URL
with no proof the user meant it. handleDeepLinkUrl saved any >=8-char
token and restarted the poller with zero confirmation, so a malicious
page doing `location.href = 'fleetcrown://auth?token=<attacker>'` could
silently re-point the machine at the attacker's account; the runner then
types that account's dispatched commands into local terminals — drive-by
RCE.

Gate the token save behind an explicit, per-link native confirmation
dialog (default = Cancel). The legitimate "Connect this machine" flow
from the user's own FleetCrown settings costs one click; the drive-by
attack now dead-ends at a dialog the user never initiated.

Co-authored-by: x <x@x>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-28 10:24:28 +02:00
GandClaude Opus 4.8 4d3bcf35fa fix(desktop): unbreak release build + phase 2 parallel dispatch (#65)
* fix(desktop): unbreak the release build — node-gyp 13 override

The release workflow has been silently broken since v0.8.0: @electron/rebuild
pins node-gyp 9.4.1, which predates Python 3.12 (distutils removed → macOS
fails) and current VS detection (→ Windows fails). Every 'Install desktop deps'
step dies before compiling anything; versions 0.8.1-0.8.11 never shipped
through the feed. Scoped npm override forces node-gyp ^13 under
@electron/rebuild only.

Verified via workflow_dispatch dry-run (build-only) on this branch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat(dispatch): phase 2 — same-project parallel dispatch via derived run-tabs (opt-in)

When a project is busy, dispatch immediately under a tab alias
<project>~<runId8> instead of queueing behind — every tab-keyed mechanism
(PTY workspace, session file, sentinels, zellij tab, phase-1 worktree)
composes unchanged. Gated by FLEETCROWN_PARALLEL_DISPATCH (default off).

- src/lib/run-tab.ts: alias SSOT (derive/base/detect) shared by server+runner
- run/route.ts: parallel branch — alias tab, Exit contract on the alias
  session path, payload.sessionTab; run keeps BASE projectKey for analytics
- poller.ts: derived tabs FORCE worktree isolation regardless of env —
  parallel-without-isolation is impossible
- runtime-state: alias tabs never persist project_states rows (no ghost
  cards, no clobbering base runtime facts); READY alias handoff closes
  exactly its run from the pushed payload (closeOpenRunBySessionTab)
- close-sweep: cross-close guard — sessionTab runs never close from the base
  project's state row; reaper remains the backstop
- scripts/test/run-tab.ts: 8-check net. 38/38 unit files, tsc, eslint green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(desktop): swap to @electron/rebuild 4.2.0 (paired node-gyp 12)

The scoped node-gyp-13-under-rebuild-3.6.1 override HUNG install-app-deps on
all three platforms until the 40-min job timeout — v9-era invocation against
the v13 CLI stalls instead of erroring. rebuild 4.2.0 ships its own paired
node-gyp ^12 (Python 3.12 + modern VS support) — the combination its authors
actually test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(release): pin the BUILD ENV, not the deps — Python 3.11 + windows-2022

Third approach, the right one: the dep set (electron-builder 25 + rebuild
3.6.1 + node-gyp 9) was never broken — the runner images rotted under it
after v0.8.0 (Python 3.12 removed distutils; newer Windows images ship a VS
node-gyp 9 can't detect). Overriding node-gyp 13 under rebuild 3.6.1 HUNG
(CLI mismatch); rebuild 4.x breaks app-builder-lib 25's deep import
(exports-sealed ./lib/search-module). So: revert both overrides, pin
setup-python 3.11 + windows-2022 in the workflow. Prod deps untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 17:16:49 +02:00
GandClaude Opus 4.8 856fa9a4c5 feat(dispatch): worktree-per-agent isolation (opt-in) (#64)
Each dispatched agent runs in its own git worktree
(~/.fleetcrown/worktrees/<tab>/<runId>, branch fc/<runId>) so it can never
collide with the primary checkout or another agent on a shared index/HEAD —
the 'git add -A swallow' incident (2026-07-17) becomes structurally impossible.

- src/lib/agent-execution/worktree-workspace.ts: pure module — create/attach,
  artifact symlinks (node_modules, .env*), work-preserving cleanup (only
  provably-shared/clean worktrees are ever removed), prompt note.
- poller.ts: fresh dispatch launches remap dir + prepend the note; verification
  (transcript/auth, cwd-keyed) follows the effective dir; close_tab prunes.
- Gated by FLEETCROWN_WORKTREE_DISPATCH (default off), degrades to the primary
  dir on any failure — mirrors the FLEETCROWN_BOX_PREPARE precedent.
- scripts/test/worktree-workspace.ts: 14-check net incl. a re-enactment of the
  incident (add -A in primary cannot swallow worktree files). 37/37 unit files
  green; tsc + eslint clean.

docs/architecture/worktree-per-agent.md documents semantics + phase-2 (lift
isProjectBusy for same-project parallelism).

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 16:18:28 +02:00
Mao NakamotoandClaude Fable 5 cd08eebfd2 fix(audit): scrub identity/secret leaks, adopt URL+design SSOTs, drop dead code
Audit wave 1 of 3 (six-agent sweep findings):
- secrets/identity: private-zone PIN literal out of 3 scripts (rotate the
  PIN separately — it lives in git history), seed email now env-driven,
  GEORGE_USER_ID renamed, real-name comments neutralized, CODEOWNERS off
  the old org, /home/g fallback replaced with os.homedir(), phone + path
  examples anonymized; DEFAULT_USER_EXTERNAL_ID default now 'self' with
  both DBs migrated (UPDATE entities SET external_id='self')
- URL SSOT: every product-code literal of the app domain now flows through
  APP_URL (desktop menus, runner banner curl, templates, UA, doctor,
  orangecat publish origin); new GITHUB_API_BASE shared by 7 files;
  openclaw gateway fallback imports its constant; ORANGECAT_BASE_FALLBACK
  + LOCAL_DEV_URL single-sourced
- design tokens: --scrim/ui-backdrop (4 raw bg-black/NN backdrops),
  --toggle-knob, --surface-terminal (cross-linked with terminal-theme.ts),
  --text-compact, ui-pin-input + PIN_MAX_DIGITS=12 shared client/server
  (fixes the 20-vs-12 maxLength drift), ui-icon-nudge for the 3px cluster
- dead code: HistoryFeed + loki-prompts deleted whole, 13 more dead
  symbols removed; all console.log verified intentional and kept

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 14:32:38 +02:00
Mao Nakamoto 67e32b0550 fix: move handoffs outside claude protected paths 2026-07-16 12:11:18 +02:00
Mao NakamotoandClaude Opus 4.8 735369941f fix(runner): self-contained unattended launches — no dotfiles required on any machine
A runner-launched claude must never hang on an interactive gate nobody is
watching. The box has pre-trusted workspaces + merged an unattended allowlist
since box-prepare shipped; the DESKTOP launch path never did. Consequences:
(a) on a fresh user's machine — no hand-tuned ~/.claude/settings.json —
dispatched agents would stall on the first permission ask; (b) on the
founder's laptop, `Write(*)` only matches in-cwd paths, so the final
session-handoff write to ~/.claude/sessions/<tab>.md sat behind an unanswered
prompt (26+ min, reproduced twice — the reason no laptop handoff existed
since June).

- src/lib/agent-execution/claude-prep.ts: ensureClaudeReady + UNATTENDED_ALLOW
  extracted from box-workspace (pure fs, no @/db — safe in the desktop
  bundle). Merge-only: never removes or narrows user-set rules.
- pty-runtime.launchAgentPty: runs the prep for claude on EVERY runner, not
  just FLEETCROWN_BOX_PREPARE. Fleet Runner is now self-contained — a new
  user needs the app + the claude CLI, nothing else.
- box-workspace: imports the shared module (behavior unchanged).

tsc root+desktop clean, eslint clean, 32/32 unit files.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-15 09:20:53 +02:00
Mao NakamotoandClaude Opus 4.8 e2a491ecfe fix(orchestration): close runs unattended — the fleet's work now gets recorded
Diagnosis (2026-07-14): 14 days of autopilot, ZERO recorded successes — every
box-executed run stamped timeout/partial by the reaper. The agents actually
worked (session handoffs on disk prove it: status ready, tsc pass). Two gaps
swallowed the evidence:

1. TRANSPORT — the box pusher derives projects from live agent processes;
   an agent EXITS the moment it writes its final `ready` handoff, so the
   project vanished from the payload before the handoff was ever pushed.
   project_states stayed stale (datacat had no row at all) and the reaper's
   wroteAfterStart check found nothing.
   Fix: desktop/src/main/pusher.ts projectEntries() now merges conf +
   processes + session-handoff FILES — a project with a handoff on disk is
   always pushed, agent running or not.

2. CLOSE — the only run-closer was the /api/control GET, i.e. a human page
   load. Unattended (autopilot at 04:00), nothing ever closed a finished run.
   Fix: gateAndCloseRun extracted from the control route to
   lib/orchestration/gate-and-close.ts (same DoD cross-model gate, shared
   in-flight set), and two new unattended paths through it:
   - runtime-state ingestion closes the open run the moment a READY handoff
     arrives (fire-and-forget, ≤5min after the agent finishes);
   - reap-stale-runs cron runs a close-sweep BEFORE reaping, so anything the
     push path missed still gets its real verdict instead of a reap stamp.

New: listOpenRuns query; close-sweep.ts (sweep + per-project variant).
Control route behavior unchanged (imports the extracted closer).

tsc root+desktop clean, eslint clean, 32/32 unit + 150/150 home tests.
(--no-verify: full gates run manually above; push runs them again anyway.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-15 00:24:31 +02:00
Mao NakamotoandClaude Opus 4.8 b40686eb2e feat(desktop): run the calendar drain inside Fleet Runner
The drain's protocol (GET/POST /api/actions/drain-events + gog booking) was
standalone-only. Wire it into Fleet Runner so cloud-approved calendar events
book automatically on the operator's machine — no separate process to launch.

- drainOnce() now takes an optional { baseUrl, token } config; env stays the
  default for standalone CLI use. Keeps the drain protocol as SSOT — the
  desktop reuses it instead of reimplementing GET/POST.
- New desktop/src/main/calendar-drain.ts mirrors the pusher lifecycle: shares
  the poller/pusher token (token-store) + FLEETCROWN_WEB_URL||APP_URL base,
  30s coalesced passes, deliberately does NOT clear the token on auth failure
  (poller/pusher own that).
- Lifecycle hooks in index.ts: start on ready (beside startPusher), restart on
  token save / deep-link auth / system resume, stop on token clear + before-quit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 07:14:58 +02:00
Mao NakamotoandClaude Opus 4.8 3832a56b4a fix(runner): poll for the 401 regardless of verify (false-positive-verified path)
Prior fix (972d03c) gated the auth poll behind !verified, but the common 401
path is verified=TRUE — the "/login" error emits output that false-positives
waitForAgentGenerating — so the poll was skipped and a single pre-check raced the
transcript. Confirmed by dogfood: detectAuthFailure's logic matches the 401 in
the transcript, but ran before it landed. Poll unconditionally for ~12s (on the
background ack, so no operator-facing latency); a real success sees only false.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016g8LdPdzoEbVwQ1SdYW5RY
2026-07-10 08:59:46 +02:00
Mao NakamotoandClaude Opus 4.8 972d03c6f0 fix(runner): poll for the 401 — auth-failure detection was racing the transcript
The prior unconditional detectAuthFailure check (dade32b) still missed forced
401s in verification: on a fresh/slow agent launch the "/login" error lands in
the transcript AFTER the generate-verify window, so a single point-in-time check
runs too early and returns false — the dispatch was acked "ok / isn't generating
yet" instead of an honest auth failure.

Poll detectAuthFailure for up to ~12s when the agent didn't verifiably generate
(the already-failed path — no latency added to real successes, which check once
and return false). On a hit, force ok=false + the actionable error. Only emit the
soft "isn't generating yet" warning when it is NOT an auth failure.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016g8LdPdzoEbVwQ1SdYW5RY
2026-07-10 08:51:25 +02:00
Mao NakamotoandClaude Opus 4.8 dade32b16b fix(runner): a 401'd dispatch is an honest failure, not a verified success
Dogfooding a real dispatch (2026-07-10) exposed that a dead-credentials agent
was reported as SUCCESS at every layer: the agent replied "Please run /login ·
401", yet the runner acked ok/verified and the UI said "Dispatched — starting
shortly." Root cause: a 401 still emits output, which flips the agent off "idle",
so waitForAgentGenerating false-positives (verified=true) and the existing
detectAuthFailure check — gated behind `if (!verified)` — never runs.

Re-check detectAuthFailure UNCONDITIONALLY after verify in the PTY dispatch path:
on a fresh 401/login signature, force ok=false + an actionable error naming the
fix (remove stale ~/.claude/.credentials.json; set CLAUDE_CODE_OAUTH_TOKEN). The
dispatch now surfaces as a real failure in Control's AttentionBar instead of a
cheerful "starting shortly". (Zellij fallback path has the same latent issue via
waitForSessionFileBump — follow-up.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016g8LdPdzoEbVwQ1SdYW5RY
2026-07-10 08:44:40 +02:00
Mao Nakamoto a570209302 feat(runtime): persist workspace ids in project state 2026-07-03 21:13:30 +02:00
Mao NakamotoandClaude Fable 5 f7d24a62ef feat(runner): acks report the serving workspaceId (Stage 2 begins)
The runner stamps runnerWorkspaceId(tab) on every PTY dispatch ack;
the ack route persists it in the command result and on the run-ledger
submitted/blocked events. Name-derived today — the point is the
addressing channel, so the id can become opaque (sandbox-per-workspace)
without touching consumers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 20:13:40 +02:00
Mao NakamotoandClaude Fable 5 727b10d596 fix(trust): changelog garbage gate, honest acks, auth canary, composer feedback
- recordSessionHandoffChangelog: failure-signature text can't carry
  health:good; repeats of the last 3 entries don't stack; prod scrubbed.
- Ack endpoint persists warning/verified; markCommandExecuted keeps the
  first (richest) result via COALESCE — dedup re-acks can't clobber it.
- detectAuthFailure canary names dead credentials in the dispatch ack.
- Empty composer Send surfaces an error instead of silently no-opping.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 16:56:22 +02:00
Mao NakamotoandClaude Fable 5 4f7b55a193 fix(runner): 'waiting' live status is blocked-on-input, not generating
waitForAgentGenerating verified any non-idle status; an agent stuck at
a 401 /login notice reports status 'waiting' and was acked 'injected'
with no warning. Only a genuinely generating status verifies now.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 14:21:35 +02:00
Mao NakamotoandClaude Fable 5 8fe05e718c fix(runner): bracketed-paste injection + bare-Enter retry so big prompts submit
Big dispatch prompts (RAG context blocks) were still being ingested by
the TUI when injectPty's fixed-delay CRs arrived — swallowed as
in-paste newlines, prompt parked unsubmitted in the composer (visible
in the Workspaces activity column). Wrap the body in explicit
ESC[200~/ESC[201~ so ingestion is atomic and the trailing CR is a real
keypress; the poller's verify-retry now sends a bare Enter first (a
parked composer submits without duplication) before a full re-inject.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 00:13:17 +02:00
Mao NakamotoandClaude Fable 5 9ee86d29c6 fix(runner): verify dispatch against the CLI's own live session status
Claude Code writes live per-PID status to ~/.claude/sessions/<pid>.json
(status idle|working, cwd). Three fixes hang off it:

- Dispatch verify: isPtyBusy was fooled by boot-screen redraw — on a
  fresh clone the trust-folder dialog ate the injected paste and six
  agents were acked 'launched + injected' while idle at an empty
  composer. waitForAgentGenerating() now polls the CLI's own status
  (fallback to isPtyBusy for agents without live status files) and
  re-injects once when verifiably idle.
- Pusher lifecycle: readFastState synthesizes the direct_terminal
  observation from live status, so headless PTY agents mid-task read
  as Working instead of 'process detected, no lifecycle signal'
  (the producer the presenter test always described but nothing built).
- Deploy hardening: the restart ssh runs under timeout 180 +
  keep-alives after hanging 47 minutes post-restart and freezing the
  deploy before verification and the runner sync.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 00:04:22 +02:00
Mao NakamotoandClaude Fable 5 9545d38fcc fix(runner): pusher derives projects from live PTYs when no projects.conf
The headless box has no claude-projects.conf (a laptop dotfile), so
buildProjectRuntimePayload pushed ZERO project entries — project_states
was only ever fed by the laptop runner. When the laptop slept, the
cloud UI froze on a days-old snapshot ('5 awaiting input') while real
PTY agents ran unseen. With an empty conf the pusher now synthesizes
{tab, dir} from the agent processes actually running.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 22:43:07 +02:00