Skip to content

feat: add attended supervision for Claude and Cursor hosts - #5748

Merged
kunchenguid merged 14 commits into
mainfrom
fm/fm-3c3-attended-core-r1
Sep 26, 2026
Merged

kunchenguid merged 14 commits into
mainfrom
fm/fm-3c3-attended-core-r1

Conversation

@kunchenguid

@kunchenguid kunchenguid commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Intent

yes do A.

Context: that chose option A for PR #5631 (AFK revamp rung 3c, attended posture and /quiet on the supervision host): land the approved repeated-escalation fix first, then re-cut 5631 from the branch's final validated tree into four PRs in dependency order - 3c-1 broken-session latch; 3c-2 dialog mirror for Claude and Cursor; 3c-3 attended posture core with the two drain fixes and the reconciled prompt rule, keeping every Pi home unchanged; 3c-4 the /quiet statement - and move Codex attended support to rung 3d. Each PR ships through no-mistakes and the captain merges. 3c-1 (#5701) and 3c-2 (#5707) have landed; this is 3c-3.

The AFK revamp's standing words also apply: "2 should be done by opus crewmates" and "this is a major architectural revamp so i want it to do very careful live validation including regression in isolated live environments with some real complex sessions before calling it done. it's ok to use my real llm tokens here".

Substance of the referenced assessment for 3c-3: the attended posture core is the offer-rule single owner (branchOfferForWake shared with the host through fm-branch-dispatch.mjs), the host's attended acceptor and exits, the dialog mirror feed into the wake, the drain's present subcommand and BRANCH OUTCOMES section with the mark-processed acknowledgement, the report CLI attended path, and the prompt's host-neutral mirror wording - roughly 560 production, 620 test, and 110 doc lines, behind the config/supervision-host opt-in. Two drain defects must be fixed. D1: a new captain outcome can be hidden behind older routine outcomes, because print_branch_outcomes_section caps the routine list at 2,000 bytes and then lists only captain rows up to the last printed routine row, so with about a dozen waiting routine rows the captain outcome that woke main is omitted; fix by presenting captain rows independently of the routine cap (captain first) and collapsing routine overflow into a count that is marked read. D2: after a return, the first attended drain replays the whole away window (measured: a window shaped like the real one needs 96 drains and about 580 KB of repeated text), because nothing at the return advances the store's read cursor or processed marker; fix by advancing the read cursor through the window's rows once the return brief has rendered, and collapsing repeated captain rows per task. D3: the PR's ungated shared prompt rule (bin/fm-branch-prompt.sh) told the branch to report captain "even when an earlier outcome already told MAIN", which changes every Pi home and contradicts one report per unchanged situation; it becomes a reconciled rule - captain once per unchanged situation, including after an earlier routine outcome mentioned it - applying only to the attended posture on the supervision host, so every Pi home stays unchanged. The one live re-check is on Claude: routine stays off main, a captain outcome reaches main, a large routine backlog plus a fresh captain outcome, and a return after a long away window.

Chosen design for the return: the drain is the only presenter and cursor owner; the return brief stops listing branch outcomes and points at them; the drain collapses repeated captain rows per task and counts routine overflow, so a long away window costs one short drain; no new state. The resulting return experience: away outcomes appear once, grouped per task, repeats collapsed to one line, routine items as a single count, and nothing from the window is re-shown afterward.

What Changed

  • Route eligible attended wakes through the supervision host using the shared Pi branch offer rule and a dialog-mirror feed; pass main-only wakes through unchanged.
  • Deliver attended captain outcomes through the host and add a drain-owned BRANCH OUTCOMES section with acknowledgement, per-task captain collapse, and bounded routine presentation.
  • Make return briefs point to the drain instead of repeating away-window outcomes, and apply the reconciled captain-reporting rule only to attended host wakes.

Risk Assessment

⚠️ Medium: The opt-in change crosses host dispatch, mirror delivery, outcome presentation, and return handling; no new source-backed defect was found, but those coordinated lifecycle changes warrant the dedicated validation phase.

Testing

Targeted host checks passed through the attended and drain cases before a 480-second timeout; the return, branch, mirror, and instruction checks passed separately. The live outcome-store CLI showed captain acknowledgement and fail-closed cursor behavior. The host scenarios were supported only by tests, not a running primary; no real-Claude primary was driven.

  • Live validation: ⚠️ inconclusive - 1 of 6 scenarios driven live against the product
Scenario Result Live Evidence
A captain drains a fresh captain outcome ahead of routine work and acknowledges it without replay ⏸️ untested no The prior payload recorded only test cases, not a live running captain. An authorized short lab path for the private tmux socket is needed to drive this against a real primary.
A captain returns from a long away window and sees collapsed outcomes once ⏸️ untested no The prior payload recorded only test cases, not a live long-window return. An authorized short lab path for the private tmux socket is needed to drive this against a real primary.
Presentation failures and an unreadable mirror preserve outcomes or hand the wake to main ⏸️ untested no The prior payload recorded only test cases, not live failure handling. An authorized short lab path for the private tmux socket is needed to drive these cases against a real primary.
An outcome-store user reads and acknowledges a captain row while a corrupt cursor refuses presentation ✅ pass live Outcome-store CLI presentation, acknowledgement, and corrupt-cursor refusal artifact
A Pi home keeps its existing outcome and instruction behavior ⏸️ untested no The prior payload recorded only test cases, not a live Pi-home run. A live Pi home must be driven to establish this result.
A real Claude primary keeps a routine wake off main, routes a captain outcome to main, and handles a long-window return ⏸️ untested no A private tmux socket under this worktree exceeds the socket-path limit; the workspace boundary does not authorize a shorter external lab path. Provide an authorized short lab path for the required re…
Evidence: Outcome-store CLI presentation, acknowledgement, and corrupt-cursor refusal

Source: Outcome-store CLI presentation, acknowledgement, and corrupt-cursor refusal

1
2
--- presentation before acknowledgement ---
{"seq":1,"task":"alpha","verdict":"routine","summary":"followed up","unread":true}
{"seq":2,"task":"alpha","verdict":"captain","summary":"decision needed","unread":true}
--- presentation after read (captain remains unprocessed) ---
{"seq":2,"task":"alpha","verdict":"captain","summary":"decision needed","unread":false}
after acknowledgement presentation rows: 0
error: refusing operation because the outcome cursor is malformed
--- corrupt cursor refusal above; no rows were presented ---
- Outcome: ⚠️ 2 warnings across 1 run (12m51s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

⏭️ **Rebase** - skipped

Step was skipped.

⚠️ **Review** - medium risk

✅ No issues found.

⚠️ **Test** - 2 warnings
  • ⚠️ The real-Claude attended and return paths remain undemonstrated. The required private tmux socket cannot fit beneath this worktree's path, and the workspace boundary does not authorize a shorter external lab path. Provide an authorized short lab path for live validation.
  • ⚠️ live validation verdict: inconclusive (1 of 6 scenarios were driven live against the product); untested: A captain drains a fresh captain outcome ahead of routine work and acknowledges it without replay, A captain returns from a long away window and sees collapsed outcomes once, Presentation failures and an unreadable mirror preserve outcomes or hand the wake to main, A Pi home keeps its existing outcome and instruction behavior, A real Claude primary keeps a routine wake off main, routes a captain outcome to main, and handles a long-window return
  • Live validation: ⚠️ inconclusive - 1 of 6 scenarios driven live against the product
Scenario Result Live Evidence
A captain drains a fresh captain outcome ahead of routine work and acknowledges it without replay ⏸️ untested no The prior payload recorded only test cases, not a live running captain. An authorized short lab path for the private tmux socket is needed to drive this against a real primary.
A captain returns from a long away window and sees collapsed outcomes once ⏸️ untested no The prior payload recorded only test cases, not a live long-window return. An authorized short lab path for the private tmux socket is needed to drive this against a real primary.
Presentation failures and an unreadable mirror preserve outcomes or hand the wake to main ⏸️ untested no The prior payload recorded only test cases, not live failure handling. An authorized short lab path for the private tmux socket is needed to drive these cases against a real primary.
An outcome-store user reads and acknowledges a captain row while a corrupt cursor refuses presentation ✅ pass live Outcome-store CLI presentation, acknowledgement, and corrupt-cursor refusal artifact
A Pi home keeps its existing outcome and instruction behavior ⏸️ untested no The prior payload recorded only test cases, not a live Pi-home run. A live Pi home must be driven to establish this result.
A real Claude primary keeps a routine wake off main, routes a captain outcome to main, and handles a long-window return ⏸️ untested no A private tmux socket under this worktree exceeds the socket-path limit; the workspace boundary does not authorize a shorter external lab path. Provide an authorized short lab path for the required re…
  • tests/fm-supervision-host.test.sh (attended, drain, and failure-path cases passed before the command timed out at 480 seconds)
  • tests/fm-afk-return.test.sh
  • bash tests/fm-branch-supervision.test.sh
  • bash tests/fm-host-mirror.test.sh
  • bash tests/fm-supervision-instructions.test.sh
  • Manually drove bin/fm-branch-outcome.sh append, present, mark-read, mark-processed, and malformed-cursor refusal in an isolated worktree home
⏭️ **Document** - skipped

Step was skipped.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

On a home opted into config/supervision-host with a Claude or Cursor
primary, the supervision host now takes the attended wakes the Pi branch
would take: routine outcomes stay off main, and a captain outcome wakes
main once with a branch-outcome line and waits in the drain's new
BRANCH OUTCOMES section until main acknowledges it with mark-processed.

- The offer rule moves into branchOfferForWake, shared by the Pi watcher
  and the host through bin/fm-branch-dispatch.mjs offer.
- The host feeds the dialog mirror at the head of each attended wake and
  passes a close through unchanged when it is main-only, the engine or a
  tool is missing, the primary has no verified mirror, the main session
  cannot be identified, or the session is cooling down.
- The drain presents captain outcomes first, one line per task, never
  behind older routine outcomes, and collapses routine overflow into a
  count that is marked read.
- The return advances the store's read cursor through the away window
  once the brief has rendered, so the first drain does not replay it.
- The branch prompt's mirror wording is host-neutral, and the rule to
  report what main must act on as captain, once per unchanged situation,
  applies only to the attended posture on the host.
@kunchenguid
kunchenguid force-pushed the fm/fm-3c3-attended-core-r1 branch from fcbe352 to 9174aa6 Compare September 26, 2026 06:55
@kunchenguid kunchenguid changed the title feat: run attended supervision on Claude and Cursor hosts feat: add attended supervision for Claude and Cursor hosts Sep 26, 2026
@kunchenguid

Copy link
Copy Markdown
Owner Author

Validation notes

The pipeline's own live runs could not start a Claude primary (their lab socket path was too long), so the Test step shows most live scenarios as untested. The live checks were driven outside the pipeline, in isolated lab homes with a real Claude Code 2.1.283 primary and sonnet engine and real Pi workers:

  • Tree 25b37c02 (the drain as the only outcome presenter):
    • an attended routine wake stayed off main;
    • a finished worker's captain outcome woke main once and was landed and acknowledged;
    • a fresh captain outcome after a 12-row routine backlog printed first, with the routine overflow counted, in one drain;
    • after a 130-outcome away window the return brief listed no outcomes, one drain showed each task's captain outcomes collapsed to one line with routines as a count, and later drains showed nothing from the window;
    • a Pi home without config/supervision-host kept its routine, captain, and processed flow with no BRANCH OUTCOMES section.
  • Tree a58c8834 (turn-start offer recheck): attended routine and captain routing and the return drain, re-checked.

Pi homes stay unchanged. The shared offer rule in .pi/extensions/lib/fm-branch-dispatch.ts gained an attendedHost flag (commit "Documentation remains accurate for attended supervision", which despite its label moves the stale-row decision scan). Every Pi caller leaves the flag false (fm-primary-pi-watch.ts, fm-branch-supervision.ts); only the host's bin/fm-branch-dispatch.mjs offer sets it. With the flag false the moved block runs under the same condition (task && kind === "stale") at the same point in the per-row loop, so Pi's offer decisions are identical for every input. test_attended_close_that_turns_main_only_before_its_turn_passes_to_main covers the host-only veto and asserts Pi's branchOfferForWake verdict is unchanged; the Pi watch-extension, Pi branch-extension, and branch-supervision suites pass. The branch prompt's only Pi-visible change is the host-neutral mirror sentence; the reconciled captain rule is gated to the attended posture on the supervision host.

Not driven live (covered by deterministic tests): a failed outcome projection or missing jq keeping the return's catch-up gated, and an unreadable dialog mirror at wake-prompt time.

@kunchenguid
kunchenguid merged commit 9b52cf5 into main Sep 26, 2026
20 checks passed
@kunchenguid
kunchenguid deleted the fm/fm-3c3-attended-core-r1 branch September 26, 2026 07:49
wpartin added a commit to wpartin/firstmate that referenced this pull request Sep 27, 2026
* docs: make configuration settings easier to find and understand (#5589)

* docs: make configuration settings easier to find and understand

* no-mistakes(review): Restore dropped qualifiers and fix misplaced config doc labels

* no-mistakes(review): Restore three dropped qualifiers in configuration reference

* fix: limit project memory edits to factual corrections (#5636)

* fix: bound worker edits of project AGENTS.md/CLAUDE.md to factual corrections

These files are loaded into every agent session of a project, so additions
should be a deliberate human choice rather than automated task output. The
ship brief's project-memory section and AGENTS.md section 6 previously invited
workers to record durable knowledge, which let project AGENTS.md files accrete
detail the codebase or README already carries. Workers now edit only to fix
factually wrong content - including content their own change made wrong - and
fm-ensure-agents-md.sh runs only alongside such a correction. Stow no longer
routes project-memory additions through ship tasks, and the generated skeleton
no longer invites discovery-driven additions.

* no-mistakes(review): Stop running fm-ensure-agents-md.sh on memory-file corrections

* no-mistakes(document): Clarify manual project-memory initialization and remove duplicate guidance

* feat: permit gate lifecycle calls against disposable lab homes (#5635)

* fix(bin): let gate agents drive lifecycle against marked lab homes

Part 2 of the #5615 split. A no-mistakes gate agent runs inside a
checkout carrying the fleet-captain identity, so fm-gate-refuse-lib
refuses fleet mutation on the gate signal. That refusal was absolute,
which kept gate validation from ever exercising the real lifecycle.

Stamp a disposable lab FM_HOME with a .fm-lab-home marker file that
only bin/fm-lab-home.sh writes, and only onto a fresh empty dir, so
no call path can mark a populated real home. fm_refuse_if_gate_agent
then permits lifecycle only when FM_HOME carries the marker and is
driven through its stock layout - any FM_*_OVERRIDE relocation stays
refused so part of the "lab" cannot be split back onto the real fleet.
The threat model is a confused agent touching the real fleet, not
deliberate forgery, so the marker is a plain token file rather than a
bound record. FM_GATE_REFUSE_BYPASS is unchanged: it still serves the
test harness, which cannot mark hundreds of temp homes.

Teardown's slot-ownership scan compared state-dir paths textually
while fm_firstmate_root_home canonicalizes, so a lab home under a
symlinked TMPDIR scanned its own record twice and self-collided;
compare file identity (-ef) instead.

* no-mistakes(review): Refuse unlistable lab homes and hardlinked slot records

* no-mistakes(review): Mint lab markers only on verified-empty fresh dirs

* no-mistakes(document): Clarify lab-home gate documentation and comment contracts

* no-mistakes(document): Clarify lab-home gate documentation and remove stale claims

* no-mistakes(document): Clarify gate lab-home documentation and boundary wording

* fix(bin): evict a watcher whose beacon stalls past a hard bound instead of refusing every re-arm (#5594)

* fix(bin): replace a watcher whose beacon stalls past a hard bound instead of refusing every re-arm

A fleet watcher that is alive but whose liveness beacon has gone stale could
never be replaced: every re-arm was refused because the lock holder was a live
pid, and the holder was never evicted because it was not dead. Add
FM_WATCHER_STALL_BOUND (default 3x the stale grace): below it the refusal is
unchanged; at or past it the arm re-verifies the holder against the lock's
recorded identity, sends TERM, waits boundedly, and takes the lock the normal
way, ledgering a stalled-holder-replaced row. A holder that survives TERM keeps
the old refusal.

Fixes #4400

* no-mistakes(test): poll for replacement message to fix watcher-lock test flake

* no-mistakes(document): document FM_WATCHER_STALL_BOUND in config inventory

* fix(pi): hide queued Firstmate inputs under Calm only when the s