Skip to content

feat(bin): add fm-control park verb so stopped seats stop re-flagging stale - #7119

Open
RooseveltAdvisors wants to merge 3 commits into
kunchenguid:mainfrom
RooseveltAdvisors:fm/parked-seat-marker
Open

RooseveltAdvisors wants to merge 3 commits into
kunchenguid:mainfrom
RooseveltAdvisors:fm/parked-seat-marker

Conversation

@RooseveltAdvisors

Copy link
Copy Markdown
Contributor

Intent

Add a supported way to record a task as intentionally parked with a stopped seat so supervision stops flagging it stale forever while unlanded work stays untouched (bead fm-parked-seat-stale-loop). Situation: a ship task has unlanded commits, its agent is deliberately stopped, and no work is planned until a later dispatch. The three existing tools each fail for the correct reason and must not be bent: a worker-appended paused line needs a live worker, fm-control.sh exit preserves the endpoint by design, and fm-teardown.sh refuses unlanded work, and that refusal must not change. Requirements stated on the bead: the park must be settable WITHOUT a live agent (the supervisor sets it), it must suppress the per-cycle stale noise without removing the endpoint record or touching unlanded work, and it must carry an expiry or recheck so a parked seat that later needs attention is never silent forever. Hard constraint: do not change bin/fm-watch.sh. Design chosen: a new fm-control.sh verb, park, with required --until and --reason. It refuses unless the backend classifier reads the agent dead or missing (a live worker declares its own wait), refuses secondmates (idle by design), and appends one stamped supervisor 'paused: ... until ' declaration to the task status log, verifying the shared classifier reads it back. It changes nothing else. Suppression then rides the watcher's EXISTING declared-wait cadence for a dead agent (absorbed, rechecked on the long pause cadence, resurfaced once the until time passes), which existing watcher tests already cover, so no watcher edit. fm-crew-state reports paused (source status-log, detail 'seat stopped') instead of unknown for a dead or missing tmux/herdr endpoint whose declared pause names an until time still ahead. After that time it falls back to the unchanged death verdicts, so the stale-claim sweep can reclaim it again. The word parked is deliberately not used as a crew-state state because crew-state already uses parked for a no-mistakes gate. Docs: docs/agent-control.md verb table row plus a one-line trigger in the stuck-crewmate-recovery skill.

What Changed

  • Added a park verb to bin/fm-control.sh, used as park --until <YYYY-MM-DDTHH:MM[:SS]Z> --reason <text>. Both flags are required, and the --until time must be in the future. The verb refuses secondmates. It also refuses any seat whose backend classifier does not read the agent as dead or missing. When it succeeds, it appends one stamped supervisor paused: ... until <time> line to the task status log. It then confirms that the shared classifier reads that line back as the declared wait with the same recheck time. Nothing else changes: the record, endpoint, worktree and unlanded work stay as they were. bin/fm-watch.sh is not modified.
  • bin/fm-crew-state.sh now reports paused instead of unknown for a parked seat. The status source is status-log and the detail is seat stopped. This applies only to a dead or missing tmux/herdr endpoint whose declared pause has an until time that has not passed yet. Once that time passes, the existing death verdicts apply again.
  • Updated documentation: a park row in the docs/agent-control.md verb table, a one-line trigger in the stuck-crewmate-recovery skill, and a note in docs/architecture.md. Added tests in tests/fm-control.test.sh and tests/fm-crew-state.test.sh.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The change is small and additive. It adds an append-only verb that refuses live agents and secondmates and checks --until up front, plus a crew-state branch that only applies to dead or missing tmux/herdr endpoints. fm-watch.sh is untouched and teardown's refusal to remove unlanded work is unchanged. The only defect found is a rare mismatch in how the postcondition reads back the time.

Testing

I drove the real fm-control.sh park, fm-crew-state.sh and fm-teardown.sh scripts against two disposable labs: one with a private tmux server running real shell and claude panes, and one guarded non-default Herdr session. Both labs were torn down afterwards. The round-1 failure is fixed: a parked seat whose shell pane is still readable now reports paused on both backends. All other intent scenarios passed live. These were the park write with no side effects, the refusals, expiry fallback to the old verdict, the missing-endpoint paused report, and teardown still refusing unlanded work. This is a CLI change with no UI, so the evidence is CLI transcripts. The check that bin/fm-watch.sh was not modified is a static diff check, so it is marked untested rather than live.

  • Live validation: ✅ go - 7 of 8 scenarios driven live against the product
Scenario Result Live Evidence
Supervisor parks a stopped tmux seat: one stamped paused line is appended, and meta, worktree, unlanded commit and endpoint are untouched ✅ pass live park-tmux-lab.log S2
crew-state reports paused · status-log · seat stopped for a parked tmux seat whose shell pane is still open (the round-1 failure) ✅ pass live park-tmux-lab.log S3
crew-state reports paused for a parked Herdr seat whose shell pane is still open (no agent registered) ✅ pass live park-herdr-lab.log H2/H3
After the until time passes, crew-state falls back to the unchanged non-paused verdict (tmux and Herdr) ✅ pass live park-tmux-lab.log S4; park-herdr-lab.log H4
crew-state reports paused for a parked seat whose tmux window has been removed (missing endpoint) ✅ pass live park-tmux-lab.log S5
park refuses a live claude agent, a secondmate, and a past, missing or malformed --until or missing --reason; --until on another verb is rejected; no status log is written ✅ pass live park-tmux-lab.log S6
fm-teardown.sh still refuses a parked seat's unlanded work ✅ pass live park-tmux-lab.log S7
bin/fm-watch.sh is not modified (hard constraint) ⏸️ untested no The prior payload did not establish a live result: this is a static constraint check (an empty git diff 20dcbf91 HEAD -- bin/fm-watch.sh) with no runtime surface to drive.
Evidence: tmux lab transcript (park, crew-state, refusals, teardown)

Source: tmux lab transcript (park, crew-state, refusals, teardown)

== pane commands
fm-t1 zsh
fm-m1 zsh
fm-live claude
== S1: crew-state before park (stopped seat, readable shell pane)
$ bin/fm-crew-state.sh t1
state: unknown · source: pane · harness state unavailable (unknown missing)
[rc=0]
== S2: park the stopped seat
$ bin/fm-control.sh t1 park --until 2099-01-01T00:00Z --reason held for a later dispatch
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-lab.lYO6Oh
parked t1 until=2099-01-01T00:00Z agent=dead backend=tmux endpoint=fmses:fm-t1 worktree=/tmp/fm-lab.lYO6Oh/wt-t1
[rc=0]
-- status log tail:
paused [at=1791787473]: parked by the supervisor with the seat stopped - held for a later dispatch until 2099-01-01T00:00Z
-- meta unchanged: yes
-- worktree HEAD unchanged: yes; unlanded.txt present: yes
-- tmux window still present: 1
== S3: crew-state after park (readable shell pane, future until)
$ bin/fm-crew-state.sh t1
state: paused · source: status-log · parked by the supervisor with the seat stopped - held for a later dispatch until 2099-01-01T00:00Z · seat stopped
[rc=0]
== S4: expired park falls back to death verdict
$ bin/fm-crew-state.sh t1
state: unknown · source: pane · harness state unavailable (unknown missing)
[rc=0]
== S5: missing endpoint (window killed) with future park
$ bin/fm-crew-state.sh t1
state: paused · source: status-log · parked by the supervisor with the seat stopped - held for a later dispatch until 2099-01-01T00:00Z · seat stopped
[rc=0]
== S6: refusals
$ bin/fm-control.sh live park --until 2099-01-01T00:00Z --reason r
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-lab.lYO6Oh
error: task live's agent is still running; a live worker declares its own wait, so stop it with 'exit' first if the seat is meant to be parked
[rc=1]
$ bin/fm-control.sh m1 park --until 2099-01-01T00:00Z --reason r
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-lab.lYO6Oh
error: task m1 is a secondmate, whose idle endpoint is healthy by design and never needs parking
[rc=1]
$ bin/fm-control.sh m1 park --until 2000-01-01T00:00Z --reason r
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-lab.lYO6Oh
error: --until '2000-01-01T00:00Z' is not in the future
[rc=1]
$ bin/fm-control.sh m1 park --reason r
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-lab.lYO6Oh
error: park requires --until <YYYY-MM-DDTHH:MM[:SS]Z>; a parked seat must name when it is rechecked
[rc=1]
$ bin/fm-control.sh m1 park --until tomorrow --reason r
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-lab.lYO6Oh
error: --until 'tomorrow' is not a UTC time of the form YYYY-MM-DDTHH:MM[:SS]Z
[rc=1]
$ bin/fm-control.sh m1 park --until 2099-01-01T00:00Z
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-lab.lYO6Oh
error: park requires a non-empty --reason
[rc=1]
$ bin/fm-control.sh m1 exit --until 2099-01-01T00:00Z
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-lab.lYO6Oh
error: --until and --reason apply to 'park' only
[rc=1]
-- live/m1 status logs written: none
== S7: teardown still refuses unlanded work after park
$ bin/fm-teardown.sh t1
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-lab.lYO6Oh
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  3 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  watcher supervision needs Stop-owned automatic recovery; inspect the hook registration and startup status before ending the turn.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
REFUSED: worktree /tmp/fm-lab.lYO6Oh/wt-t1 has work not on any remote and not landed.
unpushed commits:
1717eaa unlanded work
1215bdc init
Push the branch, land its PR, or get the captain's explicit OK to discard, then --force.
[rc=1]
-- worktree still present: yes
Evidence: Herdr lab transcript (park + crew-state on readable shell pane)

Source: Herdr lab transcript (park + crew-state on readable shell pane)

== herdr lab session=fm-lab-park-shell-1287523-29647 pane=w1:p1 (plain shell, no agent)
{"pane_id":"w1:p1","agent":null,"agent_status":"unknown"}

== H1: crew-state before park
$ bin/fm-crew-state.sh h1
state: unknown · source: pane · harness state unavailable (unknown missing)
[rc=0]
== H2: park
$ bin/fm-control.sh h1 park --until 2099-01-01T00:00Z --reason waiting on upstream fix
fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-lab.IOdm1A
parked h1 until=2099-01-01T00:00Z agent=dead backend=herdr endpoint=fm-lab-park-shell-1287523-29647:w1:p1 worktree=/tmp/fm-lab.IOdm1A/wt-h1
[rc=0]
paused [at=1791787515]: parked by the supervisor with the seat stopped - waiting on upstream fix until 2099-01-01T00:00Z
-- pane still present: yes; unlanded.txt: yes
== H3: crew-state after park (readable shell pane)
$ bin/fm-crew-state.sh h1
state: paused · source: status-log · parked by the supervisor with the seat stopped - waiting on upstream fix until 2099-01-01T00:00Z · seat stopped
[rc=0]
== H4: expired park
$ bin/fm-crew-state.sh h1
state: unknown · source: pane · harness state unavailable (unknown missing)
[rc=0]
[teardown rc=0]
Evidence: Key crew-state lines after park (tmux, readable shell pane)
before: state: unknown · source: pane · harness state unavailable (unknown missing)
after park: state: paused · source: status-log · parked by the supervisor with the seat stopped - held for a later dispatch until 2099-01-01T00:00Z · seat stopped
expired: state: unknown · source: pane · harness state unavailable (unknown missing)
- Outcome: 🔧 3 issues found → auto-fixed ✅ across 2 runs (12m23s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ℹ️ bin/fm-control.sh:1233 - The park postcondition can fail after the line is already written when --reason contains its own until &lt;time&gt; token in a different precision from --until. Example: --reason &#34;vendor says until 2026-12-01T00:00Z&#34; --until 2026-11-01T00:00:00Z. status_paused_until (bin/fm-classify-lib.sh:430) runs the minute-format sed expression first, so it returns the time from the reason text instead of the --until time. The read-back check at bin/fm-control.sh:1238 then dies, but the line has already been appended at :1233. That leaves a declaration whose effective recheck time is the one in the reason. The fix is to refuse a --reason that contains an until &lt;time&gt; token during argument validation (bin/fm-control.sh:~329), before anything is appended.
🔧 **Test** - 3 issues found → auto-fixed ✅
  • 🚨 bin/fm-crew-state.sh:1306 - The new paused branch sits inside if ! pane_readable, so it only runs when the pane cannot be read. A stopped seat whose shell pane is still open is readable. That pane is what exit leaves behind, and it is the dead state that park itself requires. It goes to the busy-verdict path and emits unknown · pane · harness state unavailable. Live: parked tmux pane (classifier=dead) gave unknown, and parked Herdr pane (classifier=dead) gave unknown. This breaks the intent's requirement that a dead or missing tmux/herdr endpoint with a future until time reports paused · status-log · seat stopped. The unit test only covers the missing-endpoint path, using FM_FAKE_TMUX_MISSING. Fix: apply the same dead/missing + future-until check when the pane is readable but the busy verdict is not busy, and add a test for a readable shell-only pane.
  • ⚠️ bin/fm-crew-state.sh:323 - This is not caused by this change, but it hides the park branch on this host. With tmux 3.7b, tmux display-message -p -t &lt;missing-session&gt;:&lt;win&gt; exits 0 with empty fields, and a missing window in a live session resolves to another pane. So pane_readable succeeds for a missing tmux endpoint (classifier=missing), and crew-state never reaches the missing/dead branch, including the new paused report. Live tmux runs with the session killed still printed unknown · pane. Consider probing with list-panes -t (which errors correctly) or with the window inventory.
  • 🚨 live validation verdict: no-go (9 of 10 scenarios were driven live against the product); failed: crew-state reports paused for a parked DEAD endpoint (shell pane still open) with a future until time
  • Live validation: ❌ no-go - 9 of 10 scenarios driven live against the product
Scenario Result Live Evidence
Supervisor parks a stopped ship seat (tmux shell-only pane) with --until/--reason and gets one stamped paused declaration ✅ pass live park-live-tmux.log S1: parked t1 until=... agent=dead backend=tmux, status log has one paused [at=...]: parked by the supervisor with the seat stopped - held for a later dispatch until ... line
Park changes nothing else: meta, worktree HEAD, unlanded commit, and tmux endpoint unchanged ✅ pass live park-live-tmux.log S1: meta unchanged yes, HEAD unchanged yes, fm-t1 window still present
Adversarial: park refuses missing/past/malformed --until, missing --reason, --until on another verb, and a secondmate, writing nothing ✅ pass live park-live-tmux.log S2: each exits 1 with a specific error; (no status log written)
Adversarial: park refuses an endpoint not proven stopped ✅ pass live First tmux run: a sleep pane classified ambiguous was refused with refusing to park a seat that is not proven stopped
fm-teardown.sh still refuses unlanded work after a park ✅ pass live park-live-tmux.log S4: REFUSED: worktree ... has work not on any remote and not landed, worktree and HEAD intact
Park works on Herdr for a stopped seat ✅ pass live crew-state-live-herdr.log H2: parked t1 ... agent=dead backend=herdr
crew-state reports paused · status-log · seat stopped for a parked missing endpoint with a future until time ✅ pass live crew-state-live-herdr.log H3 (Herdr pane closed): state: paused · source: status-log · ... · seat stopped. On tmux 3.7b the same case stays unknown · pane because display-message succeeds on mis…
crew-state reports paused for a parked DEAD endpoint (shell pane still open) with a future until time ❌ fail live crew-state-live-tmux.log A (classifier=dead) and crew-state-live-herdr.log H2 (classifier=dead): both state: unknown · source: pane · harness state unavailable (unknown missing)
After the until time passes, crew-state falls back to the unchanged death verdict ✅ pass live crew-state-live-herdr.log H4: state: unknown · source: none · backend target gone: ...
Watcher absorbs the parked stopped seat on the long pause cadence and resurfaces it after until ⏸️ untested no The intent says suppression uses the watcher's existing declared-wait path, which existing watcher tests cover, and this change leaves bin/fm-watch.sh alone. Proving it live means running the watcher…
  • Lab home via bin/fm-lab-home.sh create + private tmux socket (fm-lab-home.sh tmux-dir); real git project/worktree with an unlanded commit; ship meta pointing at a real tmux window running bash --norc (stopped agent), a secondmate meta, and a claude-argv0 live pane
  • bin/fm-control.sh t1 park with missing --until, past --until, malformed --until, missing --reason, exit --until, and a secondmate: each refused, no status log written
  • bin/fm-control.sh t1 park --until &lt;now+2h&gt; --reason ... on a dead tmux pane, then checked status log, meta, worktree HEAD and tmux windows
  • bin/fm-teardown.sh t1 after parking: REFUSED unlanded work, worktree and HEAD intact
  • bin/fm-crew-state.sh t1 on tmux: dead pane parked, endpoint session killed (classifier=missing), expired park, re-park of a missing endpoint
  • Herdr lab bin/fm-herdr-lab.sh provision fm-lab-park-hd-* with the e2e session shim; real shell-only pane plus full herdr_* meta; fm-control.sh park (agent=dead) and fm-crew-state.sh for dead, missing (pane closed) and expired; lab torn down
  • bash tests/fm-control.test.sh (park tests ok) and bash tests/fm-crew-state.test.sh (all 285 ok, including the parked-seat test)

🔧 Fix applied.
✅ Re-checked - no issues remain.

  • Live validation: ✅ go - 7 of 8 scenarios driven live against the product
Scenario Result Live Evidence
Supervisor parks a stopped tmux seat: one stamped paused line is appended, and meta, worktree, unlanded commit and endpoint are untouched ✅ pass live park-tmux-lab.log S2
crew-state reports paused · status-log · seat stopped for a parked tmux seat whose shell pane is still open (the round-1 failure) ✅ pass live park-tmux-lab.log S3
crew-state reports paused for a parked Herdr seat whose shell pane is still open (no agent registered) ✅ pass live park-herdr-lab.log H2/H3
After the until time passes, crew-state falls back to the unchanged non-paused verdict (tmux and Herdr) ✅ pass live park-tmux-lab.log S4; park-herdr-lab.log H4
crew-state reports paused for a parked seat whose tmux window has been removed (missing endpoint) ✅ pass live park-tmux-lab.log S5
park refuses a live claude agent, a secondmate, and a past, missing or malformed --until or missing --reason; --until on another verb is rejected; no status log is written ✅ pass live park-tmux-lab.log S6
fm-teardown.sh still refuses a parked seat's unlanded work ✅ pass live park-tmux-lab.log S7
bin/fm-watch.sh is not modified (hard constraint) ⏸️ untested no The prior payload did not establish a live result: this is a static constraint check (an empty git diff 20dcbf91 HEAD -- bin/fm-watch.sh) with no runtime surface to drive.
  • bin/fm-crew-state.sh t1 before and after bin/fm-control.sh t1 park --until 2099-01-01T00:00Z --reason ... on a real private tmux server (tmux -L fm-lab, lab FM_HOME from bin/fm-lab-home.sh create). The pane was a plain zsh shell, read as classifier dead.
  • Checked meta checksum, worktree HEAD, unlanded file and tmux window after the park: all unchanged.
  • Expired park line (until 2000-01-01) → crew-state, tmux
  • Killed the tmux window (missing endpoint) with a future park → crew-state
  • fm-control.sh park refusals: a real running claude pane, a secondmate, a past --until, missing --until, malformed --until, missing --reason, and --until on the exit verb. Also checked that no status log was written.
  • bin/fm-teardown.sh t1 after the park, on a worktree holding an unlanded commit
  • Guarded Herdr lab (bin/fm-herdr-lab.sh name/provision/run/teardown, herdr 0.9.3), plain shell pane w1:p1 with agent=null: crew-state before the park, park, crew-state after, then an expired park. Lab teardown confirmed with rc=0.
  • git diff 20dcbf91 HEAD -- bin/fm-watch.sh is empty (watcher not edited)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Add fm-control.sh park <task-id> --until <UTC time> --reason <text>. It records that a ship or scout whose agent is already stopped is intentionally parked, by appending one supervisor paused declaration with an until time to the task status log. The record, endpoint, worktree and unlanded work are untouched, so teardown keeps refusing unlanded work.

The watcher already absorbs a stopped seat with a declared pause and rechecks it on the long pause cadence, surfacing it again once the stated time passes, so no watcher change is needed. fm-crew-state now reports paused instead of unknown for a stopped seat whose declared pause names a time still ahead.
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @RooseveltAdvisors. I compared head f6a10ed245f3 against main 20dcbf91.

Contract-class: opt-in. fm-control.sh … park --until … --reason … is an explicit supervisor verb. Unconfigured path unchanged: without calling park, crew-state and stale detection behave as before. Park refuses live agents and secondmates; unlanded work stays untouched (teardown refusal preserved).

VISION.md

  • One captain / Authority / Scripts / Restart / Spine / Scope: align (live go 7/8; declared-wait cadence reused; unlanded work refused as before).
  • Vendor: aligns.

CI: Require no-mistakes SUCCESS (attestation MATCH). Behavior portable serial 4 failed on unrelated tests/fm-remote-reply.test.sh ("header-collision line was not captured") — not in this PR's files. I requeued the failed jobs. Security clean.

Status: waiting-ci. When green this is auto-merge eligible (opt-in).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants