Repository navigation
Conversation
|
| if [ -n "$last" ] && status_is_paused_or_captain_held "$last"; then | ||
| : | ||
| elif fm_control_deliberate_stop_present "$state" "$task"; then | ||
| deliberate=1 |
There was a problem hiding this comment.
Parked captain hold skips rechecks When a deliberately stopped task's last status still says it is captain-held, this branch checks the status before the stop marker. In away mode, the daemon then skips rechecks for as long as the away record exists. The parked task never gets the bounded deliberate-stop recheck. Give the stop marker precedence over the leftover status.
| key=$(_stale_key "$task") | ||
| marker="$state/.subsuper-paused-$key" | ||
| [ -e "$marker" ] || _now > "$marker" | ||
| [ -e "$marker" ] && return 0 |
There was a problem hiding this comment.
Old pause time survives stop If a task already has a daemon pause marker when it is deliberately stopped, this return keeps the old pause time instead of starting the recheck window at the stop. Once its status changes to
done:, housekeeping can send a deliberate-stop recheck immediately after the stop. This creates an unnecessary early notification rather than waiting FM_PAUSE_RESURFACE_SECS from the stop.
…n tests/fm-control-relaunch.test.sh at 'a fresh spawn reviving an existing record should succeed' with `error: no launch template for harness 'unknown' (from config/crew-harness or detection)`. Invariant violated: a test must resolve the launch harness from state it controls, never from the ambient machine's detected harness, or its outcome depends on the environment. Root cause: the two regression tests added by this PR's review rounds (commit 2a9ceb2 and 7001c59) invoke fm-spawn.sh for a *fresh* (non --relaunch) revive without pinning a harness. A fresh spawn resolves the harness from config/crew-harness and then ambient harness detection (bin/fm-harness.sh crew). CI has no harness ancestor, so detection returns `unknown` and the spawn aborts; it passed locally only because the developer's shell runs under an agent (pi). Reproduced the exact CI failure locally by running the suite in a detached process tree (`setsid --fork`, no harness ancestor). Sites where the invariant must hold: every fresh-spawn invocation added in the changed area — tests/fm-control-relaunch.test.sh lines 441, 459, and 467. Fixed all three with the same small correction: pin `--harness claude`, matching the harness the fixture already records in the task meta. Relaunch call sites are unaffected because they either reuse the recorded harness or already pass an explicit --harness; no shared helper change was safe because several tests deliberately exercise harness resolution (e.g. crew-config tests), so per-call-site pinning is the correct boundary. Verification: before the fix the test failed in the detached CI-like environment with the reported error; after the fix the full suite passes there (exit 0, 79 ok, no 'not ok'), and passes in the normal environment too. `shellcheck -S warning` and `bin/fm-lint.sh tests/fm-control-relaunch.test.sh` both pass. No production code changed; deliberate-stop clearing behavior is untouched. Diff is 3 insertions/3 deletions in one test file
|
Speaking as Kun's firstmate: Status: waiting on you (the author) · contract-class: new-default · head CI and the no-mistakes check are green at this head, so thank you for that. One thing needs a push from you:
On the class: I'm judging this from the tip rather than from the earlier Overlap: this branch carries the two commits of your earlier #5068 (head VISION.md per-rule: One captain, one interface: aligns (removes benign |
|
We built the same thing in parallel and did not spot this PR first. That is our miss, not a disagreement: yours is eleven hours older and broader, so we are closing ours (#6724) rather than competing with it. Posting the comparison only in case any of it is useful to you. We checked rather than assumed, and the two things we expected to be our differentiators are already in yours:
The one real design difference is where parking comes from. Yours ties it to the deliberate-stop path, so a stopped task is parked automatically and nobody has to remember. Ours is an explicit Two things from ours that may or may not already be covered in yours, offered as questions rather than requests:
Context for why we went looking: a single home raised four separate Happy to close ours with no further noise. If either question above is a gap, say so and we will send the specific piece as a small follow-up to yours instead of a competing branch. |
|
Speaking as Kun's firstmate: Status: still waiting on you (the author) · contract-class: new-default · head Thanks for closing #5068, which settles the overlap: this PR is the one going forward. @markhomexa closed #6724 in favor of this one, and their two questions above (whether the session-start digest lists parked work, and whether a task can be parked without being stopped) are for you to answer if you want to. What's still open is the same as before: the Greptile P1 in |
Intent
Fix the defect this home reported upstream as firstmate issue #5004: a deliberately parked, finished task keeps registering as stale, so its idle endpoint is escalated as a possible wedge.
The observed behaviour, which this home hit live on 2026-09-20 with a finished investigation whose worker had been stopped while its task record stayed open: the stop path proves the stopped or already-stopped transition and retires the busy state, but leaves no durable record that the stop was deliberate, while the watcher's pause classification still admits only a declared pause and a captain-held task. A deliberately parked finished worker whose endpoint is idle therefore has no legitimate case to fall into and keeps being treated as stale and escalated.
Upstream triage accepted the report: verdict ready-for-pr, contract class restore, judged at commit 90cd351 (#5004 (comment)). It confirmed the same diagnosis and invited exactly this scope: write a durable deliberate-stop marker from the stop command, cleared on relaunch and cleanup, so the watcher treats a parked finished task like a declared pause - a long bounded recheck cadence and no escalation.
What Changed
fm-control.sh exitoutcome (stopped,already-stopped,endpoint-gone) now records a durablestate/<id>.deliberate-stopmarker owned bybin/fm-control-lib.sh; a refused or unconfirmed stop records nothing, and the marker is cleared at the spawn commit point and by teardown.FM_PAUSE_RESURFACE_SECSrecheck, never the stale/wedge escalation ladder, with the pause window anchored on the stop marker's mtime so a churny pane cannot reset it.Risk Assessment
✅ Low: The change is a well-bounded, intent-conformant marker feature whose previous review findings were closed by the two fix rounds; independent traces of the stop, spawn-revive/rollback, teardown, and watcher/daemon parking paths found no reachable case producing a wrong classification or escalation, and no new auth/privacy boundary is touched.
Testing
I confirmed the core of the change against the real product and not just its tests. Using a disposable marked lab home with a real tmux server isolated behind a private-socket shim, I drove real bin/fm-control.sh
exit(writes the marker on a verified stop and refuses without one on an unprovable endpoint), real bin/fm-watch.sh (absorbs the deliberately stopped finished pane with no wedge timer, re-surfaces it once past the pause cadence labeled as a recheck rather than a wedge, parks a semantically busy stopped pane too, and returns to ordinary terminal-stale escalation once the marker is gone), and real bin/fm-teardown.sh (clears the marker with the record). The clearing paths that need a full spawn/relaunch transaction or the away-mode daemon process, plus the churning parked pane, were exercised only by the change's own behavior suites, which drive the real fm-spawn/fm-control/fm-daemon/fm-watch code and all pass: fm-control (45 ok), fm-control-relaunch (79 ok), fm-daemon (147 ok), fm-teardown (113 ok), fm-watch-triage (147 ok). Those four scenarios are not live results and are recorded as untested. The live transcript, the driver script, and the targeted-suite results are published as artifacts. No live scenario failed; no UI surface is involved.fm-control.sh <id> exitreports a verified stop and writesstate/<id>.deliberate-stopwhile the task record stays open.already-stopped parked harness=claude backend=tmux endpoint=fmlab:fm-parkedrc=0 and-rw-r--r-- .../state/parked.deliberate-stopwith content 1791271…fm-control.sh exiton a task whose tmux window is absent refuses and leaves no marker, so an unproven stop keeps escalating as before.confirmed: no deliberate-stop marker for a refused stopdone:is absorbed with no wake and no wedge timer.absorbed stale (deliberate stop, age Ns), and no.stale-since/.wedge-escalationsmarkersstale: fmlab:fm-parked (deliberately stopped 501s ago, rechecked on a long cadence not a wedge; relaunch the worker or clean up the finished task)queu…stale: fmlab:fm-parkedwith the marker removed.stale-since-fmlab_fm-busy, thenstale: fmlab:fm-busy (deliberately stopped 501s ago, ...); alsotests/fm-watch-triage.test.sh…fm-teardown.sh <id> --forcethe task record and its deliberate-stop marker are both gone.teardown teardown complete ..., andconfirmed: teardown cleared the deliberate-stop markerEvidence: Live deliberate-stop scenarios transcript (real product binaries, real tmux, disposable lab home)
Source: Live deliberate-stop scenarios transcript (real product binaries, real tmux, disposable lab home)
SCENARIO 1 marker: already-stopped parked harness=claude backend=tmux endpoint=fmlab:fm-parked ... | SCENARIO 3 watcher rc=124 (absorbed), triage: absorbed stale (deliberate stop, age 2s): fmlab:fm-parked | SCENARIO 4: stale: fmlab:fm-parked (deliberately stopped 501s ago, rechecked on a long cadence not a wedge; relaunch the worker or clean up the finished task) | SCENARIO 5: stale: fmlab:fm-parked | SCENARIO 6 busy recheck: stale: fmlab:fm-busy (deliberately stopped 501s ago, ...) | SCENARIO 7: confirmed: teardown cleared the deliberate-stop markerEvidence: Reproducible live driver script (creates and tears down its own lab home, private tmux socket)
Source: Reproducible live driver script (creates and tears down its own lab home, private tmux socket)
Evidence: Targeted behavior-suite results for the change (all new deliberate-stop tests green)
Source: Targeted behavior-suite results for the change (all new deliberate-stop tests green)
fm-control.test.sh 45 ok/0 not-ok: 'a verified stop records the deliberate-stop marker; a refused stop does not' | fm-control-relaunch.test.sh 79 ok/0: relaunch clears marker, failed backlog commit clears marker, fresh-spawn revive clears marker, retry after rollback clears orphaned marker | fm-daemon.test.sh 147 ok/0: parks instead of wedge-escalating, re-surfaces on pause cadence, anchors first recheck on the stop | fm-teardown.test.sh 113 ok/0: retires the marker | fm-watch-triage.test.sh 147 ok/0: parked not stale, re-stop, cleared resumes terminal stale, unchanged pane, busy parked, churning recheckPipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-spawn.sh:5510- The durable deliberate-stop marker is cleared only underif [ "$RELAUNCH" -eq 1 ](bin/fm-spawn.sh:5505-5514). But a fresh spawn is a supported way to revive an existing task whose recorded endpoint is a dead/agent-less husk, and it republishesstate/<id>.metawithout clearingstate/<id>.deliberate-stop: the Herdr presentation reclaim corridor (herdr_projection_existing_meta_allows_flatreturns 0 for adead|no-agentpane, bin/fm-spawn.sh:3463-3537, invoked at 3719-3720) and the same-identity restart reclaim exercised as intended usage bytests/fm-backend-herdr-presentation-e2e.test.sh(spawn_task "$RESTART_ID" ...with no--relaunch, ~line 1214). Concrete sequence: (1)fm-control.sh <id> exiton a Herdr ship/scout task stops the agent and writesstate/<id>.deliberate-stop; (2) a Herdr server/host restart leaves the recorded pane as an agent-free husk; (3) the restart reclaim runs a freshfm-spawn.sh <id> <project>, which launches and records a replacement worker but leaves the marker; (4) because the marker is present,bin/fm-watch.sh's deliberate branch (handle_deliberate_stop_stale, bin/fm-watch.sh:1659-1674, selected at 3093 and 3249 and viabusy_turn_bound_checkat 1701) and the daemon's pause loop (bin/fm-supervise-daemon.sh:1320-1390) keep absorbing the replacement's idle pane, so a genuinely wedged replacement never escalates until teardown. The same sibling fresh-spawn revive path isbin/fm-secondmate-liveness-lib.sh:294(fm-spawn.sh <id> --secondmateafter killing a dead/missing mate); secondmates are currently exempt from the pane-stale path, so that instance is inert today but would inherit the same stale marker. The marker is scoped to a task record, not to the incarnation, so its presence is a stale authorization assumption once a new agent owns the record. The smallest honest remedy (clear the marker at the same commit point for any spawn that reuses an existing task record, or key its validity to the current agent incarnation) extends the intent's stated clearing triggers beyondrelaunch/cleanup, so this needs an author decision rather than an automatic fix.🔧 Fix applied.
2 warnings still open:
bin/fm-spawn.sh:5510- The durable deliberate-stop marker is cleared only underif [ "$RELAUNCH" -eq 1 ](bin/fm-spawn.sh:5505-5514). But a fresh spawn is a supported way to revive an existing task whose recorded endpoint is a dead/agent-less husk, and it republishesstate/<id>.metawithout clearingstate/<id>.deliberate-stop: the Herdr presentation reclaim corridor (herdr_projection_existing_meta_allows_flatreturns 0 for adead|no-agentpane, bin/fm-spawn.sh:3463-3537, invoked at 3719-3720) and the same-identity restart reclaim exercised as intended usage bytests/fm-backend-herdr-presentation-e2e.test.sh(spawn_task "$RESTART_ID" ...with no--relaunch, ~line 1214). Concrete sequence: (1)fm-control.sh <id> exiton a Herdr ship/scout task stops the agent and writesstate/<id>.deliberate-stop; (2) a Herdr server/host restart leaves the recorded pane as an agent-free husk; (3) the restart reclaim runs a freshfm-spawn.sh <id> <project>, which launches and records a replacement worker but leaves the marker; (4) because the marker is present,bin/fm-watch.sh's deliberate branch (handle_deliberate_stop_stale, bin/fm-watch.sh:1659-1674, selected at 3093 and 3249 and viabusy_turn_bound_checkat 1701) and the daemon's pause loop (bin/fm-supervise-daemon.sh:1320-1390) keep absorbing the replacement's idle pane, so a genuinely wedged replacement never escalates until teardown. The same sibling fresh-spawn revive path isbin/fm-secondmate-liveness-lib.sh:294(fm-spawn.sh <id> --secondmateafter killing a dead/missing mate); secondmates are currently exempt from the pane-stale path, so that instance is inert today but would inherit the same stale marker. The marker is scoped to a task record, not to the incarnation, so its presence is a stale authorization assumption once a new agent owns the record. The smallest honest remedy (clear the marker at the same commit point for any spawn that reuses an existing task record, or key its validity to the current agent incarnation) extends the intent's stated clearing triggers beyondrelaunch/cleanup, so this needs an author decision rather than an automatic fix.bin/fm-spawn.sh:5509- The review fix round (commit 2a9ceb2, "Clear deliberate-stop marker on fresh-spawn task revive", AUTHORED BY THE PIPELINE) widened the clear toRELAUNCH=1 || SPAWN_REUSED_TASK_RECORD=1, where SPAWN_REUSED_TASK_RECORD is latched at bin/fm-spawn.sh:1711 purely from$STATE/$ID.metaexisting at lock-acquisition time. That closes the round-1 happy path, but the same marker can still survive into a new incarnation because the fresh-spawn rollback deletes the record without clearing the marker, and the retry (which the script's own error text tells the operator to run: "its record was removed ... then re-run the spawn") then sees no meta and therefore does NOT clear it. Concrete sequence: (1)fm-control.sh <id> exiton a task (e.g. Herdr husk reclaim or a failed secondmate liveness revive) writesstate/<id>.deliberate-stop; (2) a freshfm-spawn.sh <id> <project>revive latches SPAWN_REUSED_TASK_RECORD=1, publishes the replacement record at bin/fm-spawn.sh:5020, then fails during launch delivery (e.g. kimi/rovo/agy*_spawn_fail, afm_backend_send_text_submitfailure) before reaching the commit point; (3) the EXIT trap runsspawn_fresh_commit_rollback(bin/fm-spawn.sh:1250, invoked at 1364-1366) which callsfm_backlog_dispatch_rollback->fm_backlog_record_removeand DELETES$STATE/$ID.meta; the marker is left behind because the clear at 5514 was never reached; (4) the documented retryfm-spawn.sh <id> <project>now finds no meta, latches SPAWN_REUSED_TASK_RECORD=0, publishes a brand-new record, and never clears the orphaned marker; (5) the replacement worker is indefinitely classified as a deliberately parked task by bin/fm-watch.sh:3093/1700/3249 and bin/fm-supervise-daemon.sh:462/578/610/1272/1320, so a genuinely wedged replacement is only ever given the long bounded recheck and never escalates until a laterexit/teardown clears it — exactly the escalation loss the round-1 finding described. Sibling record-removal sites that must hold this invariant: bin/fm-spawn.sh:1250 (spawn_fresh_commit_rollbackremoves the record — no clear), bin/fm-spawn.sh:1328 and 1364-1366 (its abort-cleanup invocations), and bin/fm-spawn.sh:5020 (fresh publish over an existing record); the teardown removals already clear it (bin/fm-teardown.sh:3818, :3339), and the remote-secondmate teardown removal at bin/fm-teardown.sh:1076 is not reachable for a marker because bin/fm-control.sh:344 refuses every lifecycle action for aremote_hosttask. Smallest honest remedy at the earliest shared boundary: drop theRELAUNCH/SPAWN_REUSED_TASK_RECORD gate and clear the marker unconditionally at the bin/fm-spawn.sh:5509 commit point (anrm -fon a missing marker is already a no-op), so any spawn that successfully publishes a record — including a retry after a rollback — supersedes the prior stop. The latch at bin/fm-spawn.sh:1711 then becomes unnecessary machinery.🔧 Fix applied.
1 info still open:
bin/fm-control-lib.sh:452-fm_control_deliberate_stop_recordwrites the stop epoch intostate/<id>.deliberate-stop, and the helper's comment andbin/fm-control-lib.sh:443-445document that body as the stop's epoch second. No consumer reads it: every reader relies on the file's existence plus its mtime -fm_control_deliberate_stop_present(bin/fm-control-lib.sh:459-461), the watcher'sage_of "$marker"(bin/fm-watch.sh:1667-1669) and the daemon's_stat_file_mtime/_stat_file_mtime-backed anchoring (bin/fm-supervise-daemon.sh:577-584). A repo-wide grep finds no other reader, andtests/fm-control.test.sh:838-839merely asserts the body is non-empty. Presence + mtime alone satisfy the User intent ('write a durable deliberate-stop marker ... cleared on relaunch and cleanup'), so the body is a second representation of the same fact rather than a required component. This is immaterial (no behavioral effect, not user-visible, and not a wrong result), so no action is required; if the author wants it trimmed, the smallest form is a presence-only marker (e.g.: > "$path") with the comment and the non-empty assertion dropped.fm-control.sh <id> exitreports a verified stop and writesstate/<id>.deliberate-stopwhile the task record stays open.already-stopped parked harness=claude backend=tmux endpoint=fmlab:fm-parkedrc=0 and-rw-r--r-- .../state/parked.deliberate-stopwith content 1791271…fm-control.sh exiton a task whose tmux window is absent refuses and leaves no marker, so an unproven stop keeps escalating as before.confirmed: no deliberate-stop marker for a refused stopdone:is absorbed with no wake and no wedge timer.absorbed stale (deliberate stop, age Ns), and no.stale-since/.wedge-escalationsmarkersstale: fmlab:fm-parked (deliberately stopped 501s ago, rechecked on a long cadence not a wedge; relaunch the worker or clean up the finished task)queu…stale: fmlab:fm-parkedwith the marker removed.stale-since-fmlab_fm-busy, thenstale: fmlab:fm-busy (deliberately stopped 501s ago, ...); alsotests/fm-watch-triage.test.sh…fm-teardown.sh <id> --forcethe task record and its deliberate-stop marker are both gone.teardown teardown complete ..., andconfirmed: teardown cleared the deliberate-stop markerbash ~/.no-mistakes/evidence/01M47P3KXRB8XVP735SHTFDQ1C/live-deliberate-stop-driver.sh $PWD- live scenarios 1-7 against real bin/fm-control.sh, bin/fm-watch.sh, bin/fm-busy-event.sh, bin/fm-teardown.sh with a real tmux server on a private socket and a throwaway marked lab homelive:bin/fm-control.sh parked exit->already-stopped parked ...andstate/parked.deliberate-stopwrittenlive:bin/fm-control.sh refused exiton a missing tmux window -> rc=1 refusal and no markerlive:bin/fm-watch.shabsorbed the stoppeddone:pane (rc=124, triageabsorbed stale (deliberate stop, ...), no.stale-since/.wedge-escalations)live:bin/fm-watch.shre-surfaced the marker aged past FM_PAUSE_RESURFACE_SECS asstale: ... deliberately stopped ... rechecked on a long cadence not a wedgelive:bin/fm-watch.shwith the marker removed surfaced the same finished pane asstale: fmlab:fm-parkedlive:bin/fm-watch.shparked a semantically busy deliberately stopped pane (real fm-busy-event record) and rechecked it, never a wedgelive:bin/fm-teardown.sh teardown --forceagainst a real treehouse worktree cleared the marker with the task recordbash tests/fm-control.test.sh(45 ok, exit 0)bash tests/fm-control-relaunch.test.sh(79 ok, exit 0)bash tests/fm-daemon.test.sh(147 ok, exit 0)bash tests/fm-teardown.test.sh(113 ok, exit 0)bash tests/fm-watch-triage.test.sh(147 ok, exit 0)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.