Skip to content

fix(bin): record forced scout teardown as discarded instead of delivered - #8159

Merged
kunchenguid merged 5 commits into
kunchenguid:mainfrom
tiago-peixoto:fm/tr-8154-scout-discard
Nov 5, 2026
Merged

kunchenguid merged 5 commits into
kunchenguid:mainfrom
tiago-peixoto:fm/tr-8154-scout-discard

Conversation

@tiago-peixoto

@tiago-peixoto tiago-peixoto commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Fixes #8154

bin/fm-teardown.sh must not record a discarded or forced scout as done with a report path.
Upstream issue: #8154 (forced scout cleanup skips the report-existence check but backlog_done_args still passes --report, and the landed reader then treats the scout as delivered).

What Changed

  • bin/fm-teardown.sh now closes a --force scout with --note discarded instead of --report, and a retained scout only records a report path when data/<id>/report.md exists, so the landed reader no longer treats a discarded or report-less scout as delivered.
  • bin/fm-backlog-transition-lib.sh accepts discarded as a valid close-marker note and replays it verbatim, so a teardown interrupted after recording the close still lands as discarded at the next session start.
  • Added tests for forced scout discards with missing and partial reports, for close-marker replay of a discarded scout, and for the landed snapshot excluding a discarded scout; updated docs/captain-hold-lifecycle.md to describe the held-scout case.

Risk Assessment

✅ Low: The change is a small, well-bounded branch in backlog_done_args plus a matching validator alias and a narrowed replay decoder; I traced forced close, forced retain with and without a report, marker write, replay, and the captain-hold answer path and found no wrong value or reachable regression, and the new tests fail at the base commit and pass with the fix.

Testing

Ran bash tests/fm-backlog-atomicity.test.sh (102 ok, exit 0, including the two new forced-discard and discarded-replay cases), bash tests/fm-bearings-snapshot.test.sh (60 ok, exit 0, including the landed-exclusion case for a discarded scout), and bash tests/fm-captain-hold-lifecycle.test.sh (67 ok; its final case test_archived_answer_in_a_user_configured_archive_satisfies_the_gate failed with "fm-captain-hold: compatible tasks-axi is required" because tasks-axi runs through a mise node shim that errors when HOME is redirected; rerunning that case with the real node directory ahead on PATH passed, and the case does not touch the changed code). Wrote a disposable driver reusing the suite's fixture helpers that drives the real teardown, bootstrap, captain-hold and bearings scripts against throwaway homes; ran it at the base commit (reproduces the bug: forced scout recorded with a report path and listed in .landed) and at the target commit (forced scout recorded as done with note "discarded", no report link, excluded from .landed; held scout keeps a report link only when report.md exists; replay keeps "discarded" and still decodes "local%20main"; four invalid note values are refused). Transcripts, test logs, the rerun log and a before/after summary are in the evidence directory. Every scenario passed live.

  • Live validation: ✅ go - 12 of 12 scenarios driven live against the product
Scenario Result Live Evidence
Forced cleanup of an unheld scout with a missing report closes the row with note 'discarded', no report link, and the landed reader lists nothing ✅ pass live live-target-transcript.txt S1-missing; before-after-summary.txt
Forced cleanup of an unheld scout with a partial report.md closes the row with note 'discarded', no report link, and the landed reader lists nothing ✅ pass live live-target-transcript.txt S1-partial; before-after-summary.txt
Base-commit reproduction: the same forced cleanup at 4bd1e3a records report:data/<id>/report.md and the landed reader lists the scout as delivered ✅ pass live live-base-transcript.txt S1-missing and S1-partial; before-after-summary.txt
Cleanup of an unheld scout without --force and without a report is still refused and the row stays in_flight ✅ pass live live-target-transcript.txt S2
Ordinary scout completion with its report (no --force) still records the report link and appears in the landed list ✅ pass live live-target-transcript.txt S3; tests/fm-backlog-atomicity.test.sh test_completion_closes_a_scout_with_its_report
Forced cleanup of a captain-held scout with report.md present returns the row to queued, held, with the report recorded as its deliverable ✅ pass live live-target-transcript.txt S4-present; tests/fm-captain-hold-lifecycle.test.sh test_teardown_never_closes_a_captain_held_task (ok)
Forced cleanup of a captain-held scout with no report.md returns the row to queued, held, with no report link and no deliverable line (base recorded a false report deliverable) ✅ pass live live-target-transcript.txt S4-absent vs live-base-transcript.txt S4-absent; before-after-summary.txt
Session start replays an interrupted 'arg=--note / arg=discarded' close marker as the note 'discarded' and removes the marker ✅ pass live live-target-transcript.txt S5; tests/fm-backlog-atomicity.test.sh test_recovery_replays_a_discarded_scout_close_as_discarded
Session start still decodes an 'arg=--note / arg=local%20main' close marker to the note 'local main' ✅ pass live live-target-transcript.txt S6
Adversarial: close markers with a note other than local%20main or discarded (evil, discarded%20x, Discarded, 'local main') are refused and leave the row in_flight with the marker retained ✅ pass live live-target-transcript.txt S7
Landed reader excludes a done scout whose only completion is the note 'discarded' while keeping the note in the backlog ✅ pass live fm-bearings-snapshot.test.log 'landed accepts only kind-owned delivery artifacts while answered questions stay out'; live-target-transcript.txt S1 .landed = []
Plan-listed suite tests/fm-captain-hold-lifecycle.test.sh: captain-hold and retain paths keep working (67 ok; final case fails only under the host's mise node shim and passes with real node on PATH) ✅ pass live fm-captain-hold-lifecycle.test.log; captain-hold-archived-answer-rerun.log
Evidence: Before/after summary of live teardown, bootstrap, and landed-reader results at base vs target

Source: Before/after summary of live teardown, bootstrap, and landed-reader results at base vs target

Live before/after for #8154 - real bin/fm-teardown.sh, bin/fm-bootstrap.sh, bin/fm-bearings-snapshot.sh driven against throwaway homes
base 4bd1e3aa (bug)                                      | target 6f244064 (fix)

## S1-missing: forced teardown of an unheld scout with a missing report
  [base] state: done links: "report:data/scout-forced-missing/report.md" body: "" [{"id":"scout-forced-missing","what":"item for scout-forced-missing","artifact":"data/scout-forced-missing/report.md"}] 
  [target] state: done links: none body: discarded [] 

## S1-partial: forced teardown of an unheld scout with a partial report
  [base] state: done links: "report:data/scout-forced-partial/report.md" body: "" [{"id":"scout-forced-partial","what":"item for scout-forced-partial","artifact":"data/scout-forced-partial/report.md"}] 
  [target] state: done links: none body: discarded [] 

## S4-absent: forced teardown of a CAPTAIN-HELD scout whose report is absent
  [base] state: queued links: "report:data/scout-held-absent/report.md" body: "Captain hold set: 2026-11-05T01:22:43Z\n\nDeliverable of the finished work: report data/scout-held-absent/report.md" [] 
  [target] state: queued links: none body: "Captain hold set: 2026-11-05T01:21:42Z" [] 

## S5: session start replays a recorded 'discarded' close marker as the note 'discarded'
  [base] BACKLOG_RECONCILE: scout-replay-forced: recorded backlog close could not be replayed: invalid pending-close arguments
  [target] state: done links: none body: discarded 
Evidence: Live transcript at target 6f24406 (real fm-teardown.sh, fm-bootstrap.sh, fm-bearings-snapshot.sh against throwaway homes)

Source: Live transcript at target 6f244064 (real fm-teardown.sh, fm-bootstrap.sh, fm-bearings-snapshot.sh against throwaway homes)

=== checkout: {run-worktree} (6f244064)

##### S1-missing: forced teardown of an unheld scout with a missing report
$ fm-teardown.sh scout-forced-missing --force
teardown scout-forced-missing complete (window firstmate:fm-scout-forced-missing, worktree /tmp/fm-backlog-atomicity.38I3ci/forced-missing/absent-worktree)
Backlog: scout-forced-missing is closed in /tmp/fm-backlog-atomicity.38I3ci/forced-missing/home/data/backlog.md. Run bin/fm-tasks-axi.sh ready for dependency-cleared candidates, check date gates, and dispatch only work whose blockers are gone and date is due.
exit=0
$ tasks-axi show scout-forced-missing --full
task:
  id: scout-forced-missing
  title: item for scout-forced-missing
  state: done
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: scout
  repo: "-"
  priority: "-"
  created: "-"
  closed: 2026-11-05
  deps: none
  links: none
  body: discarded
$ fm-bearings-snapshot.sh --json | .landed
[]

##### S1-partial: forced teardown of an unheld scout with a partial report
$ fm-teardown.sh scout-forced-partial --force
teardown scout-forced-partial complete (window firstmate:fm-scout-forced-partial, worktree /tmp/fm-backlog-atomicity.38I3ci/forced-partial/absent-worktree)
Backlog: scout-forced-partial is closed in /tmp/fm-backlog-atomicity.38I3ci/forced-partial/home/data/backlog.md. Run bin/fm-tasks-axi.sh ready for dependency-cleared candidates, check date gates, and dispatch only work whose blockers are gone and date is due.
exit=0
$ tasks-axi show scout-forced-partial --full
task:
  id: scout-forced-partial
  title: item for scout-forced-partial
  state: done
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: scout
  repo: "-"
  priority: "-"
  created: "-"
  closed: 2026-11-05
  deps: none
  links: none
  body: discarded
$ fm-bearings-snapshot.sh --json | .landed
[]

##### S2: forced teardown of an unheld scout WITHOUT --force is still refused when the report is missing
$ fm-teardown.sh scout-unforced-missing
REFUSED: scout task scout-unforced-missing has no report at /tmp/fm-backlog-atomicity.38I3ci/unforced-missing/home/data/scout-unforced-missing/report.md.
The report is the work product. Have the crewmate write it, or use --force after explicit discard approval.
exit=1
$ tasks-axi show scout-unforced-missing --full
task:
  id: scout-unforced-missing
  title: item for scout-unforced-missing
  state: in_flight
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: scout
  repo: "-"
  priority: "-"
  created: 2026-11-05
  closed: "-"
  deps: none
  links: none
  body: ""

##### S3: ordinary scout completion with its report (no --force) still records the report path
$ fm-teardown.sh scout-reported
teardown scout-reported complete (window firstmate:fm-scout-reported, worktree /tmp/fm-backlog-atomicity.38I3ci/reported/absent-worktree)
Backlog: scout-reported is closed in /tmp/fm-backlog-atomicity.38I3ci/reported/home/data/backlog.md. Run bin/fm-tasks-axi.sh ready for dependency-cleared candidates, check date gates, and dispatch only work whose blockers are gone and date is due.
exit=0
$ tasks-axi show scout-reported --full
task:
  id: scout-reported
  title: item for scout-reported data/scout-reported/report.md
  state: done
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: scout
  repo: "-"
  priority: "-"
  created: "-"
  closed: 2026-11-05
  deps: none
  links: "report:data/scout-reported/report.md"
  body: ""
$ fm-bearings-snapshot.sh --json | .landed
[{"id":"scout-reported","what":"item for scout-reported","artifact":"data/scout-reported/report.md"}]

##### S4-present: forced teardown of a CAPTAIN-HELD scout whose report is present
$ fm-teardown.sh scout-held-present --force
teardown scout-held-present complete (window firstmate:fm-scout-held-present, worktree /tmp/fm-backlog-atomicity.38I3ci/held-present/absent-worktree)
Backlog: scout-held-present stays open in /tmp/fm-backlog-atomicity.38I3ci/held-present/home/data/backlog.md, still held for the captain with its deliverable recorded. Relay the question and close it only with bin/fm-captain-hold.sh answer.
exit=0
$ tasks-axi show scout-held-present --full
task:
  id: scout-held-present
  title: item for scout-held-present data/scout-held-present/report.md
  state: queued
  blocked: no
  blocked_by: none
  held: yes
  hold_reason: "fm-hold-v1:Y2FwdGFpbiBtdXN0IGNob29zZQ=="
  hold_kind: captain
  hold_until: "-"
  kind: scout
  repo: "-"
  priority: "-"
  created: 2026-11-05
  closed: "-"
  deps: none
  links: "report:data/scout-held-present/report.md"
  body: "Captain hold set: 2026-11-05T01:21:36Z\n\nDeliverable of the finished work: report data/scout-held-present/report.md"
$ fm-bearings-snapshot.sh --json | .landed
[]

##### S4-absent: forced teardown of a CAPTAIN-HELD scout whose report is absent
$ fm-teardown.sh scout-held-absent --force
teardown scout-held-absent complete (window firstmate:fm-scout-held-absent, worktree /tmp/fm-backlog-atomicity.38I3ci/held-absent/absent-worktree)
Backlog: scout-held-absent stays open in /tmp/fm-backlog-atomicity.38I3ci/held-absent/home/data/backlog.md, still held for the captain with its deliverable recorded. Relay the question and close it only with bin/fm-captain-hold.sh answer.
exit=0
$ tasks-axi show scout-held-absent --full
task:
  id: scout-held-absent
  title: item for scout-held-absent
  state: queued
  blocked: no
  blocked_by: none
  held: yes
  hold_reason: "fm-hold-v1:Y2FwdGFpbiBtdXN0IGNob29zZQ=="
  hold_kind: captain
  hold_until: "-"
  kind: scout
  repo: "-"
  priority: "-"
  created: 2026-11-05
  closed: "-"
  deps: none
  links: none
  body: "Captain hold set: 2026-11-05T01:21:42Z"
$ fm-bearings-snapshot.sh --json | .landed
[]

##### S5: session start replays a recorded 'discarded' close marker as the note 'discarded'
$ cat state/scout-replay-forced.backlog-close
id=scout-replay-forced
data=/tmp/fm-backlog-atomicity.38I3ci/replay-forced/home/data
spawn_gen=spawn-replay
arg=--note
arg=discarded
$ fm-bootstrap.sh
BOOTSTRAP_INFO: closed the backlog item for scout-replay-forced that an interrupted cleanup left open
$ tasks-axi show scout-replay-forced --full
task:
  id: scout-replay-forced
  title: item for scout-replay-forced
  state: done
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: scout
  repo: "-"
  priority: "-"
  created: "-"
  closed: 2026-11-05
  deps: none
  links: none
  body: discarded
marker remains? no

##### S6: session start still decodes a recorded 'local%20main' close marker to the note 'local main'
$ fm-bootstrap.sh
BOOTSTRAP_INFO: closed the backlog item for ship-replay-local that an interrupted cleanup left open
$ tasks-axi show ship-replay-local --full
task:
  id: ship-replay-local
  title: item for ship-replay-local
  state: done
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: ship
  repo: "-"
  priority: "-"
  created: "-"
  closed: 2026-11-05
  deps: none
  links: none
  body: local main

##### S7 (adversarial): a close marker with a note other than local%20main or discarded is rejected
--- note value: 'evil'
$ fm-bootstrap.sh
BACKLOG_RECONCILE: ship-replay-bad: recorded backlog close could not be replayed: invalid pending-close arguments in /tmp/fm-backlog-atomicity.38I3ci/replay-bad-23848/home/state/ship-replay-bad.backlog-close
row state: in_flight; marker remains? yes
--- note value: 'discarded%20x'
$ fm-bootstrap.sh
BACKLOG_RECONCILE: ship-replay-bad: recorded backlog close could not be replayed: invalid pending-close arguments in /tmp/fm-backlog-atomicity.38I3ci/replay-bad-22655/home/state/ship-replay-bad.backlog-close
row state: in_flight; marker remains? yes
--- note value: 'Discarded'
$ fm-bootstrap.sh
BACKLOG_RECONCILE: ship-replay-bad: recorded backlog close could not be replayed: invalid pending-close arguments in /tmp/fm-backlog-atomicity.38I3ci/replay-bad-28636/home/state/ship-replay-bad.backlog-close
row state: in_flight; marker remains? yes
--- note value: 'local main'
$ fm-bootstrap.sh
BACKLOG_RECONCILE: ship-replay-bad: recorded backlog close could not be replayed: invalid pending-close arguments in /tmp/fm-backlog-atomicity.38I3ci/replay-bad-26440/home/state/ship-replay-bad.backlog-close
row state: in_flight; marker remains? yes
=== driver done
Evidence: Live transcript at base 4bd1e3a reproducing the #8154 bug

Source: Live transcript at base 4bd1e3aa reproducing the #8154 bug

=== checkout: /tmp/fm-8154-base.SMloZy (base-archive)

##### S1-missing: forced teardown of an unheld scout with a missing report
$ fm-teardown.sh scout-forced-missing --force
teardown scout-forced-missing complete (window firstmate:fm-scout-forced-missing, worktree /tmp/fm-backlog-atomicity.vPlt85/forced-missing/absent-worktree)
Backlog: scout-forced-missing is closed in /tmp/fm-backlog-atomicity.vPlt85/forced-missing/home/data/backlog.md. Run bin/fm-tasks-axi.sh ready for dependency-cleared candidates, check date gates, and dispatch only work whose blockers are gone and date is due.
exit=0
$ tasks-axi show scout-forced-missing --full
task:
  id: scout-forced-missing
  title: item for scout-forced-missing data/scout-forced-missing/report.md
  state: done
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: scout
  repo: "-"
  priority: "-"
  created: "-"
  closed: 2026-11-05
  deps: none
  links: "report:data/scout-forced-missing/report.md"
  body: ""
$ fm-bearings-snapshot.sh --json | .landed
[{"id":"scout-forced-missing","what":"item for scout-forced-missing","artifact":"data/scout-forced-missing/report.md"}]

##### S1-partial: forced teardown of an unheld scout with a partial report
$ fm-teardown.sh scout-forced-partial --force
teardown scout-forced-partial complete (window firstmate:fm-scout-forced-partial, worktree /tmp/fm-backlog-atomicity.vPlt85/forced-partial/absent-worktree)
Backlog: scout-forced-partial is closed in /tmp/fm-backlog-atomicity.vPlt85/forced-partial/home/data/backlog.md. Run bin/fm-tasks-axi.sh ready for dependency-cleared candidates, check date gates, and dispatch only work whose blockers are gone and date is due.
exit=0
$ tasks-axi show scout-forced-partial --full
task:
  id: scout-forced-partial
  title: item for scout-forced-partial data/scout-forced-partial/report.md
  state: done
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: scout
  repo: "-"
  priority: "-"
  created: "-"
  closed: 2026-11-05
  deps: none
  links: "report:data/scout-forced-partial/report.md"
  body: ""
$ fm-bearings-snapshot.sh --json | .landed
[{"id":"scout-forced-partial","what":"item for scout-forced-partial","artifact":"data/scout-forced-partial/report.md"}]

##### S2: forced teardown of an unheld scout WITHOUT --force is still refused when the report is missing
$ fm-teardown.sh scout-unforced-missing
REFUSED: scout task scout-unforced-missing has no report at /tmp/fm-backlog-atomicity.vPlt85/unforced-missing/home/data/scout-unforced-missing/report.md.
The report is the work product. Have the crewmate write it, or use --force after explicit discard approval.
exit=1
$ tasks-axi show scout-unforced-missing --full
task:
  id: scout-unforced-missing
  title: item for scout-unforced-missing
  state: in_flight
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: scout
  repo: "-"
  priority: "-"
  created: 2026-11-05
  closed: "-"
  deps: none
  links: none
  body: ""

##### S3: ordinary scout completion with its report (no --force) still records the report path
$ fm-teardown.sh scout-reported
teardown scout-reported complete (window firstmate:fm-scout-reported, worktree /tmp/fm-backlog-atomicity.vPlt85/reported/absent-worktree)
Backlog: scout-reported is closed in /tmp/fm-backlog-atomicity.vPlt85/reported/home/data/backlog.md. Run bin/fm-tasks-axi.sh ready for dependency-cleared candidates, check date gates, and dispatch only work whose blockers are gone and date is due.
exit=0
$ tasks-axi show scout-reported --full
task:
  id: scout-reported
  title: item for scout-reported data/scout-reported/report.md
  state: done
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: scout
  repo: "-"
  priority: "-"
  created: "-"
  closed: 2026-11-05
  deps: none
  links: "report:data/scout-reported/report.md"
  body: ""
$ fm-bearings-snapshot.sh --json | .landed
[{"id":"scout-reported","what":"item for scout-reported","artifact":"data/scout-reported/report.md"}]

##### S4-present: forced teardown of a CAPTAIN-HELD scout whose report is present
$ fm-teardown.sh scout-held-present --force
teardown scout-held-present complete (window firstmate:fm-scout-held-present, worktree /tmp/fm-backlog-atomicity.vPlt85/held-present/absent-worktree)
Backlog: scout-held-present stays open in /tmp/fm-backlog-atomicity.vPlt85/held-present/home/data/backlog.md, still held for the captain with its deliverable recorded. Relay the question and close it only with bin/fm-captain-hold.sh answer.
exit=0
$ tasks-axi show scout-held-present --full
task:
  id: scout-held-present
  title: item for scout-held-present data/scout-held-present/report.md
  state: queued
  blocked: no
  blocked_by: none
  held: yes
  hold_reason: "fm-hold-v1:Y2FwdGFpbiBtdXN0IGNob29zZQ=="
  hold_kind: captain
  hold_until: "-"
  kind: scout
  repo: "-"
  priority: "-"
  created: 2026-11-05
  closed: "-"
  deps: none
  links: "report:data/scout-held-present/report.md"
  body: "Captain hold set: 2026-11-05T01:22:37Z\n\nDeliverable of the finished work: report data/scout-held-present/report.md"
$ fm-bearings-snapshot.sh --json | .landed
[]

##### S4-absent: forced teardown of a CAPTAIN-HELD scout whose report is absent
$ fm-teardown.sh scout-held-absent --force
teardown scout-held-absent complete (window firstmate:fm-scout-held-absent, worktree /tmp/fm-backlog-atomicity.vPlt85/held-absent/absent-worktree)
Backlog: scout-held-absent stays open in /tmp/fm-backlog-atomicity.vPlt85/held-absent/home/data/backlog.md, still held for the captain with its deliverable recorded. Relay the question and close it only with bin/fm-captain-hold.sh answer.
exit=0
$ tasks-axi show scout-held-absent --full
task:
  id: scout-held-absent
  title: item for scout-held-absent data/scout-held-absent/report.md
  state: queued
  blocked: no
  blocked_by: none
  held: yes
  hold_reason: "fm-hold-v1:Y2FwdGFpbiBtdXN0IGNob29zZQ=="
  hold_kind: captain
  hold_until: "-"
  kind: scout
  repo: "-"
  priority: "-"
  created: 2026-11-05
  closed: "-"
  deps: none
  links: "report:data/scout-held-absent/report.md"
  body: "Captain hold set: 2026-11-05T01:22:43Z\n\nDeliverable of the finished work: report data/scout-held-absent/report.md"
$ fm-bearings-snapshot.sh --json | .landed
[]

##### S5: session start replays a recorded 'discarded' close marker as the note 'discarded'
$ cat state/scout-replay-forced.backlog-close
id=scout-replay-forced
data=/tmp/fm-backlog-atomicity.vPlt85/replay-forced/home/data
spawn_gen=spawn-replay
arg=--note
arg=discarded
$ fm-bootstrap.sh
BACKLOG_RECONCILE: scout-replay-forced: recorded backlog close could not be replayed: invalid pending-close arguments in /tmp/fm-backlog-atomicity.vPlt85/replay-forced/home/state/scout-replay-forced.backlog-close
$ tasks-axi show scout-replay-forced --full
task:
  id: scout-replay-forced
  title: item for scout-replay-forced
  state: in_flight
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: scout
  repo: "-"
  priority: "-"
  created: 2026-11-05
  closed: "-"
  deps: none
  links: none
  body: ""
marker remains? yes

##### S6: session start still decodes a recorded 'local%20main' close marker to the note 'local main'
$ fm-bootstrap.sh
BOOTSTRAP_INFO: closed the backlog item for ship-replay-local that an interrupted cleanup left open
$ tasks-axi show ship-replay-local --full
task:
  id: ship-replay-local
  title: item for ship-replay-local
  state: done
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: ship
  repo: "-"
  priority: "-"
  created: "-"
  closed: 2026-11-05
  deps: none
  links: none
  body: local main

##### S7 (adversarial): a close marker with a note other than local%20main or discarded is rejected
--- note value: 'evil'
$ fm-bootstrap.sh
BACKLOG_RECONCILE: ship-replay-bad: recorded backlog close could not be replayed: invalid pending-close arguments in /tmp/fm-backlog-atomicity.vPlt85/replay-bad-24918/home/state/ship-replay-bad.backlog-close
row state: in_flight; marker remains? yes
--- note value: 'discarded%20x'
$ fm-bootstrap.sh
BACKLOG_RECONCILE: ship-replay-bad: recorded backlog close could not be replayed: invalid pending-close arguments in /tmp/fm-backlog-atomicity.vPlt85/replay-bad-20914/home/state/ship-replay-bad.backlog-close
row state: in_flight; marker remains? yes
--- note value: 'Discarded'
$ fm-bootstrap.sh
BACKLOG_RECONCILE: ship-replay-bad: recorded backlog close could not be replayed: invalid pending-close arguments in /tmp/fm-backlog-atomicity.vPlt85/replay-bad-21439/home/state/ship-replay-bad.backlog-close
row state: in_flight; marker remains? yes
--- note value: 'local main'
$ fm-bootstrap.sh
BACKLOG_RECONCILE: ship-replay-bad: recorded backlog close could not be replayed: invalid pending-close arguments in /tmp/fm-backlog-atomicity.vPlt85/replay-bad-51/home/state/ship-replay-bad.backlog-close
row state: in_flight; marker remains? yes
=== driver done
Evidence: Disposable live driver script used for both transcripts

Source: Disposable live driver script used for both transcripts

#!/usr/bin/env bash
# Disposable live driver for #8154: drives the REAL bin/fm-teardown.sh,
# bin/fm-bootstrap.sh, bin/fm-captain-hold.sh and bin/fm-bearings-snapshot.sh
# of the checkout given as $1 against throwaway homes built by the atomicity
# suite's own fixture helpers. Prints a transcript; asserts nothing.
REPO=$1; shift
set -u
# Reuse the suite's fixture helpers (make_home, add_item, run_teardown, ...)
# without running its test list: source only the preamble before "--- dispatch".
preamble=$(mktemp)
sed -n '1,/^# --- dispatch/p' "$REPO/tests/fm-backlog-atomicity.test.sh" \
  | sed -e "s|\$(dirname \"\${BASH_SOURCE\[0\]}\")|$REPO/tests|" > "$preamble"
. "$preamble"
rm -f "$preamble"
BEARINGS="$ROOT/bin/fm-bearings-snapshot.sh"
CAPTAIN="$ROOT/bin/fm-captain-hold.sh"
echo "=== checkout: $ROOT ($(git -C "$ROOT" rev-parse --short HEAD 2>/dev/null || echo base-archive))"

show_row() { tasks-axi show "$2" --file "$(backlog_of "$1")" --full; }
bearings_landed() {  # <case-dir>
  PATH="$1/fakebin:$PATH" FM_HOME="$(home_of "$1")" FM_BEARINGS_NOW=2026-07-14T12:00:00Z \
    "$BEARINGS" --json 2>/dev/null | jq -c '[.landed[] | {id, what, artifact}]'
}
run_captain() {  # <case-dir> <args...>
  local case_dir=$1; shift
  PATH="$case_dir/fakebin:$PATH" FM_ROOT_OVERRIDE="$ROOT" FM_HOME="$(home_of "$case_dir")" \
    "$CAPTAIN" "$@"
}

scenario() { printf '\n##### %s\n' "$*"; }

for report in missing partial; do
  scenario "S1-$report: forced teardown of an unheld scout with a $report report"
  id="scout-forced-$report"
  c=$(make_home "forced-$report")
  add_item "$c" "$id" scout; start_item "$c" "$id"
  write_task_meta "$c" "$id" scout '' "spawn_gen=spawn-forced-$report"
  if [ "$report" = partial ]; then
    mkdir -p "$(home_of "$c")/data/$id"; printf 'unfinished findings\n' > "$(home_of "$c")/data/$id/report.md"
  fi
  echo "\$ fm-teardown.sh $id --force"; run_teardown "$c" "$id" --force; echo "exit=$?"
  echo "\$ tasks-axi show $id --full"; show_row "$c" "$id"
  echo "\$ fm-bearings-snapshot.sh --json | .landed"; bearings_landed "$c"
done

scenario "S2: forced teardown of an unheld scout WITHOUT --force is still refused when the report is missing"
id=scout-unforced-missing; c=$(make_home unforced-missing)
add_item "$c" "$id" scout; start_item "$c" "$id"
write_task_meta "$c" "$id" scout '' "spawn_gen=spawn-unforced"
echo "\$ fm-teardown.sh $id"; run_teardown "$c" "$id"; echo "exit=$?"
echo "\$ tasks-axi show $id --full"; show_row "$c" "$id"

scenario "S3: ordinary scout completion with its report (no --force) still records the report path"
id=scout-reported; c=$(make_home reported)
add_item "$c" "$id" scout; start_item "$c" "$id"
write_task_meta "$c" "$id" scout '' "spawn_gen=spawn-reported"
mkdir -p "$(home_of "$c")/data/$id"; printf 'findings\n' > "$(home_of "$c")/data/$id/report.md"
run_captain "$c" complete "$id" --none >/dev/null || echo "captain complete failed"
echo "\$ fm-teardown.sh $id"; run_teardown "$c" "$id"; echo "exit=$?"
echo "\$ tasks-axi show $id --full"; show_row "$c" "$id"
echo "\$ fm-bearings-snapshot.sh --json | .landed"; bearings_landed "$c"

for report in present absent; do
  scenario "S4-$report: forced teardown of a CAPTAIN-HELD scout whose report is $report"
  id="scout-held-$report"; c=$(make_home "held-$report")
  add_item "$c" "$id" scout; start_item "$c" "$id"
  write_task_meta "$c" "$id" scout '' "spawn_gen=spawn-held-$report"
  if [ "$report" = present ]; then
    mkdir -p "$(home_of "$c")/data/$id"; printf 'one captain choice remains\n' > "$(home_of "$c")/data/$id/report.md"
  fi
  run_captain "$c" hold "$id" --reason "captain must choose" >/dev/null || echo "captain hold failed"
  echo "\$ fm-teardown.sh $id --force"; run_teardown "$c" "$id" --force; echo "exit=$?"
  echo "\$ tasks-axi show $id --full"; show_row "$c" "$id"
  echo "\$ fm-bearings-snapshot.sh --json | .landed"; bearings_landed "$c"
done

scenario "S5: session start replays a recorded 'discarded' close marker as the note 'discarded'"
id=scout-replay-forced; c=$(make_home replay-forced)
add_item "$c" "$id" scout; start_item "$c" "$id"
printf 'id=%s\ndata=%s\nspawn_gen=spawn-replay\narg=--note\narg=discarded\n' "$id" "$(home_of "$c")/data" \
  > "$(home_of "$c")/state/$id.backlog-close"
echo "\$ cat state/$id.backlog-close"; cat "$(home_of "$c")/state/$id.backlog-close"
echo "\$ fm-bootstrap.sh"; run_bootstrap "$c" | grep -i "$id\|close\|replay" || true
echo "\$ tasks-axi show $id --full"; show_row "$c" "$id"
echo "marker remains? $([ -e "$(home_of "$c")/state/$id.backlog-close" ] && echo yes || echo no)"

scenario "S6: session start still decodes a recorded 'local%20main' close marker to the note 'local main'"
id=ship-replay-local; c=$(make_home replay-local)
add_item "$c" "$id"; start_item "$c" "$id"
printf 'id=%s\ndata=%s\nspawn_gen=spawn-replay-local\narg=--note\narg=local%%20main\n' "$id" "$(home_of "$c")/data" \
  > "$(home_of "$c")/state/$id.backlog-close"
echo "\$ fm-bootstrap.sh"; run_bootstrap "$c" | grep -i "$id\|close\|replay" || true
echo "\$ tasks-axi show $id --full"; show_row "$c" "$id"

scenario "S7 (adversarial): a close marker with a note other than local%20main or discarded is rejected"
for bad in 'evil' 'discarded%20x' 'Discarded' 'local main'; do
  id=ship-replay-bad; c=$(make_home "replay-bad-$RANDOM")
  add_item "$c" "$id"; start_item "$c" "$id"
  printf 'id=%s\ndata=%s\nspawn_gen=spawn-replay-bad\narg=--note\narg=%s\n' "$id" "$(home_of "$c")/data" "$bad" \
    > "$(home_of "$c")/state/$id.backlog-close"
  echo "--- note value: '$bad'"
  echo "\$ fm-bootstrap.sh"; run_bootstrap "$c" | grep -i "$id\|close\|replay\|refus\|invalid" || true
  echo "row state: $(row_state "$c" "$id"); marker remains? $([ -e "$(home_of "$c")/state/$id.backlog-close" ] && echo yes || echo no)"
done
echo "=== driver done"
Evidence: fm-backlog-atomicity.test.sh output (102 ok, exit 0)

Source: fm-backlog-atomicity.test.sh output (102 ok, exit 0)

ok - backend resolution preserves unreadable configuration errors for every caller
ok - backend resolution preserves environment, project, user, and default precedence
ok - backlog readers and mutations refuse unresolved backends without touching either backlog
ok - captain hold refuses backend errors and preserves relocated addressing for valid configuration
ok - dispatch publishes the record and moves the backlog item In flight in one run
ok - dispatch omits the markdown file when probing a Beads backlog
ok - a leftover markdown symlink does not brick a Beads home's dispatch
ok - completion applies and closes a Beads backlog without any markdown file
ok - dispatch refuses to supersede a pending authoritative close
ok - dispatch refuses held rows before creating resources
ok - dispatch refuses dependency-blocked rows before creating resources
ok - dispatch refuses held In-flight rows before relaunch
ok - dispatch reads backlog rows from the backlog addressing root
ok - recovery uses the parent of a trailing-slash data record
ok - completion targets nested relative data from the caller directory
ok - an immediate-child absolute data path keeps one paired backlog
ok - bare relative data addresses one backlog through dispatch and completion
ok - dispatch refuses symlinked backlogs without crossing homes
ok - automatic homes refuse lifecycle mutation without compatible tasks-axi
ok - dispatch refuses an unresolvable backlog data directory
ok - completion refuses before mutation when backlog data is unresolvable
ok - dispatch refuses, before creating anything, when the home has no item for the id
ok - dispatch distinguishes backlog read failures from missing items
ok - dispatch refuses a closed item instead of silently reopening it
ok - dispatch cannot commit without a verified task-record publication
ok - a failed backlog transition fails the dispatch loudly and leaves no record
ok - dispatch reports when failed-transition rollback cannot remove its record
ok - dispatch verifies both task and busy records during rollback
ok - dispatch commits neither record nor backlog state before launch delivery succeeds
ok - dispatch retries interrupted transitions before honoring termination
ok - a signal-deferred spawn verifies its preserved state and repairs a row that did not move
ok - a signal-deferred spawn reports attempted preservation as attempted when it cannot be verified
ok - a signal-deferred spawn bounds its verification so an unresponsive tasks-axi cannot hold the meta lock forever
ok - fm_tasks_axi bounds the call through its perl watchdog when no timeout binary exists
ok - fm_tasks_axi's perl watchdog passes the child status and output through unchanged
ok - fm_tasks_axi fails closed rather than running unbounded when no bounding mechanism exists
ok - fm_tasks_axi's GNU timeout kills a child that ignores SIGTERM after one further bound
ok - Kimi readiness interruptions fail before backlog commit
ok - dispatch does not resurrect a row closed after preflight
ok - dispatch fails when its backlog row vanishes after preflight
ok - completion closes a local-only ship, with its landing note, before reporting success
ok - completion closes a scout item against its report
ok - forced scout discards record no report for missing or partial reports
ok - completion leaves legacy records open when no incarnation can be recorded
ok - completion refuses ambiguous task incarnations
ok - completion records relocated scout reports relative to the backlog root
ok - space-containing scout report paths round-trip through recovery
ok - control-byte data paths fail closed before paired transitions
ok - unreplayable data paths are refused before destructive cleanup
ok - completion preserves recovery state when task-record removal fails
ok - completion refuses to report success while its item is still open, and records what it owes
ok - restart recovers closes recorded before destructive cleanup
ok - completion refuses directory-symlink close targets
ok - completion reports failure until its durable close marker is removed
ok - session start retries a close whose marker could not be removed
ok - session start reports owned backlog rows it cannot read
ok - Orca cleanup recovery is excluded from backlog lifecycle transitions
ok - session start marks an item In flight when this home already owns a worker for it
ok - session start rejects internal worker-record symlinks
ok - session start rejects symlinked worker records
ok - session start finishes a close an interrupted cleanup recorded but never landed
ok - session start replays a recorded scout discard as discarded
ok - session start replays a recorded Gerrit close with its change URL as a note
ok - recovery backfills recorded links onto already Done items
ok - session start preserves a pending close across a transient backlog read failure
ok - recovery preserves incomplete-cleanup evidence across a failed replay
ok - session start finishes a close for the matching meta incarnation
ok - recovery preserves closes for ambiguous task incarnations
ok - recovery preserves both records when meta removal fails
ok - recovery preserves closes beside symlinked metadata
ok - recovery binds close-marker identity to its locked filename
ok - recovery rejects close markers targeting another home's data
ok - recovery validates an unterminated final marker field
ok - recovery rejects lexical traversal before resolving marker data
ok - recovery rejects marker control bytes before parsing
ok - recovery rejects malformed PR URL values
ok - a retained pending close is never started by reconciliation
ok - recovery rejects close-marker arguments outside its protocol
ok - recovery reports and rejects dangling symlink close markers
ok - session start drops a close recorded for an older meta incarnation
ok - session start rejects an unversioned close marker
ok - bootstrap rechecks worker-record containment after locking
ok - lifecycle files reject ancestor symlinks outside home roots
ok - same-home state overrides remain supported
ok - bootstrap refuses symlinked state before reconciliation
ok - bootstrap stops when backlog data disappears before reconciliation
ok - bootstrap preserves secondmate, manual, and absent-backlog exemptions
ok - session start leaves a captain-held item where the captain put it
ok - no-backlog teardown refuses symlinked records before resource actions
ok - teardown rechecks record parents after locking
ok - teardown refuses symlinked state before resource actions
ok - a home with no backlog remains exempt from lifecycle transitions
ok - spawn refuses a special-file tasks-axi config instead of blocking on it
ok - spawn refuses an unsafe tasks-axi config before any exemption is derived from it
ok - spawn refuses a data directory symlinked outside the home
ok - a configured adapter refuses a data directory outside the home
ok - dispatch and completion transition structurally with evidence
ok - refused teardown leaves the backlog item in flight
ok - environment-selected adapters bypass the legacy markdown file override
ok - a manual-backlog home dispatches and completes without a hard failure
ok - a secondmate home keeps its own books paired through dispatch and completion
ok - dispatching a persistent secondmate needs no backlog item
exit=0
Evidence: Rerun of the failed captain-hold case with real node on PATH (ok) and the shim's HOME-redirect error

Source: Rerun of the failed captain-hold case with real node on PATH (ok) and the shim's HOME-redirect error

=== rerun of test_archived_answer_in_a_user_configured_archive_satisfies_the_gate with real node dir ahead on PATH (~/.local/share/mise/installs/node/22.23.1/bin)
ok - an answered captain call archived to a user-configured location still satisfies the completion gate
exit=0
Evidence: Key before/after lines
S1 forced scout, missing report
base: state: done links: "report:data/scout-forced-missing/report.md" .landed: [{"id":"scout-forced-missing","artifact":"data/scout-forced-missing/report.md"}]
target: state: done links: none body: discarded .landed: []
S4 held scout, report absent, --force
base: state: queued links: "report:data/scout-held-absent/report.md" body: "...Deliverable of the finished work: report data/scout-held-absent/report.md"
target: state: queued links: none body: "Captain hold set: ..."
S5 replay of arg=--note/arg=discarded
base: BACKLOG_RECONCILE: invalid pending-close arguments (row stays in_flight)
target: state: done body: discarded (marker removed)
  • Outcome: ⚠️ 1 info across 1 run (21m9s)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ℹ️ bin/fm-teardown.sh:1813 - Informational: a forced teardown of a captain-held scout whose report.md exists still records --report data/&lt;id&gt;/report.md as the retained deliverable (bin/fm-teardown.sh:1812-1816). The row stays Queued, so fm-teardown.sh itself never marks it done, but the later fm-captain-hold.sh answer closes that row with the report path and the landed reader then lists it. This matches the pre-existing captain-hold contract (tests/fm-captain-hold-lifecycle.test.sh:2806 and :3123 on the base commit require the deliverable to survive the answer), so it is a deliberate boundary rather than a defect. The -f guard is what keeps a forced held scout with no report from recording a dangling path that the answer would later turn into a false delivery.
⚠️ **Test** - 1 info
  • ℹ️ tests/fm-captain-hold-lifecycle.test.sh:5043 - Host environment note, not a product defect: tests/fm-captain-hold-lifecycle.test.sh test_archived_answer_in_a_user_configured_archive_satisfies_the_gate redirects HOME, and on this host tasks-axi runs through a mise node shim that then errors with 'Config files in ~/.config/mise/config.toml are not trusted', so fm-captain-hold.sh reports 'compatible tasks-axi is required'. The case passed when rerun with the real node directory (mise which node) ahead on PATH. It exercises the completion gate's archive lookup and does not touch the code changed here.
  • Live validation: ✅ go - 12 of 12 scenarios driven live against the product
Scenario Result Live Evidence
Forced cleanup of an unheld scout with a missing report closes the row with note 'discarded', no report link, and the landed reader lists nothing ✅ pass live live-target-transcript.txt S1-missing; before-after-summary.txt
Forced cleanup of an unheld scout with a partial report.md closes the row with note 'discarded', no report link, and the landed reader lists nothing ✅ pass live live-target-transcript.txt S1-partial; before-after-summary.txt
Base-commit reproduction: the same forced cleanup at 4bd1e3a records report:data/<id>/report.md and the landed reader lists the scout as delivered ✅ pass live live-base-transcript.txt S1-missing and S1-partial; before-after-summary.txt
Cleanup of an unheld scout without --force and without a report is still refused and the row stays in_flight ✅ pass live live-target-transcript.txt S2
Ordinary scout completion with its report (no --force) still records the report link and appears in the landed list ✅ pass live live-target-transcript.txt S3; tests/fm-backlog-atomicity.test.sh test_completion_closes_a_scout_with_its_report
Forced cleanup of a captain-held scout with report.md present returns the row to queued, held, with the report recorded as its deliverable ✅ pass live live-target-transcript.txt S4-present; tests/fm-captain-hold-lifecycle.test.sh test_teardown_never_closes_a_captain_held_task (ok)
Forced cleanup of a captain-held scout with no report.md returns the row to queued, held, with no report link and no deliverable line (base recorded a false report deliverable) ✅ pass live live-target-transcript.txt S4-absent vs live-base-transcript.txt S4-absent; before-after-summary.txt
Session start replays an interrupted 'arg=--note / arg=discarded' close marker as the note 'discarded' and removes the marker ✅ pass live live-target-transcript.txt S5; tests/fm-backlog-atomicity.test.sh test_recovery_replays_a_discarded_scout_close_as_discarded
Session start still decodes an 'arg=--note / arg=local%20main' close marker to the note 'local main' ✅ pass live live-target-transcript.txt S6
Adversarial: close markers with a note other than local%20main or discarded (evil, discarded%20x, Discarded, 'local main') are refused and leave the row in_flight with the marker retained ✅ pass live live-target-transcript.txt S7
Landed reader excludes a done scout whose only completion is the note 'discarded' while keeping the note in the backlog ✅ pass live fm-bearings-snapshot.test.log 'landed accepts only kind-owned delivery artifacts while answered questions stay out'; live-target-transcript.txt S1 .landed = []
Plan-listed suite tests/fm-captain-hold-lifecycle.test.sh: captain-hold and retain paths keep working (67 ok; final case fails only under the host's mise node shim and passes with real node on PATH) ✅ pass live fm-captain-hold-lifecycle.test.log; captain-hold-archived-answer-rerun.log
  • bash tests/fm-backlog-atomicity.test.sh (102 ok, exit 0)
  • bash tests/fm-bearings-snapshot.test.sh (60 ok, exit 0)
  • bash tests/fm-captain-hold-lifecycle.test.sh (67 ok, 1 not ok on the final case; failure caused by the mise node shim under redirected HOME)
  • Isolated rerun of test_archived_answer_in_a_user_configured_archive_satisfies_the_gate with PATH=$(dirname $(mise which node)):$PATH (ok, exit 0), plus HOME=&lt;tmp&gt; node --version showing the shim's mise trust error
  • Live driver live-driver.sh &lt;checkout&gt; at target 6f244064: real bin/fm-teardown.sh &lt;scout&gt; --force with missing and partial report, then tasks-axi show --full and bin/fm-bearings-snapshot.sh --json | .landed
  • Live driver at base 4bd1e3aa via git archive 4bd1e3aa into a temp dir: same scenarios reproduce the reported bug (report link recorded, scout listed in .landed)
  • Live: bin/fm-teardown.sh &lt;scout&gt; without --force and no report is still refused with the REFUSED message
  • Live: ordinary scout completion with report after fm-captain-hold.sh complete --none records report:data/&lt;id&gt;/report.md and appears in .landed
  • Live: forced teardown of a captain-held scout with report present keeps the row queued and held with its report link; with report absent keeps it queued and held with no report link and no deliverable line
  • Live: bin/fm-bootstrap.sh replays a hand-written close marker arg=--note / arg=discarded to body discarded and removes the marker; arg=local%20main still replays as local main
  • Live adversarial: close markers with note evil, discarded%20x, Discarded, local main are refused (invalid pending-close arguments), row stays in_flight, marker retained
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable new issues were found.

Reviews (2) · Last reviewed commit: "no-mistakes(document): document forced s..." · Reviewed by Greptile

@kunchenguid kunchenguid added the full-ci Maintainer go-ahead: run the full CI suite on this outside pull request label Nov 4, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @tiago-peixoto, this is a clean fix. A scout torn down with --force is now recorded as discarded instead of as a delivered report, which is what the --force docs and the Recently Landed reader already promise, so I've classed it as a restore. The attestation binds 818e552d with no skipped steps, live is 5 of 5 including the repro on the old base, the quick checks pass, Greptile is 5/5 with no threads, and it merges cleanly with main.

I've added the full-ci label so the full suite runs. If it comes back green, this merges and closes #8154. Nothing more is needed from you.

Contract-class: restore. VISION: aligns on every rule; the board no longer shows discarded work as delivered.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: Full suite on 818e552d failed in Behavior portable parallel 1 (run 41896986382). The failing assertion was:

not ok - session start did not record the finished work's deliverable (missing: 'Deliverable of the finished work: report data/sample-held-cleanup-failure/report.md')

That sits next to this PR's forced-teardown → discarded recording, so please take a look and push a fix. I've left the full-ci label on so your next push re-runs the Full suite. Nothing else is blocked on my side once that lane is green.

@tiago-peixoto
tiago-peixoto force-pushed the fm/tr-8154-scout-discard branch from 818e552 to 87e6e60 Compare November 5, 2026 01:43
@tiago-peixoto tiago-peixoto changed the title fix(bin): record forced scout teardown as discarded instead of reported fix(bin): record forced scout teardown as discarded instead of delivered Nov 5, 2026
@kunchenguid
kunchenguid merged commit 7c6170e into kunchenguid:main Nov 5, 2026
25 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @tiago-peixoto — really appreciate you taking the time on this.

dascapytal1559 added a commit to dascapytal1559/firstmate that referenced this pull request Nov 6, 2026
Brings in upstream's 12 commits through kunchenguid#8191, including the OSC 7501
worker status reporter (kunchenguid#8011), fm-pr-merge --expected-head (kunchenguid#8157),
scout force-cleanup recorded as discarded (kunchenguid#8159), and full captain-hold
questions in decision snapshots (kunchenguid#8173).

Conflict: bin/fm-bearings-snapshot.sh help field list. Kept upstream's
decisions_open question field and the fork's ideas line.

FORK.md names the overlap between upstream's terminal status reporter
and the fork's T3 Code card status.
kayis-rahman pushed a commit to kayis-rahman/firstmate that referenced this pull request Nov 8, 2026
…red (kunchenguid#8159)

* Fixes kunchenguid#8154 record forced scout discards

* no-mistakes(review): keep discarded note across close-marker replay

* no-mistakes(review): assert discarded note on row body, not task id

* Fixes kunchenguid#8154 preserve reports on held scout cleanup

* no-mistakes(document): document forced scout discard in teardown docs
vinicius928e8r84 pushed a commit to vinicius928e8r84/firstmate that referenced this pull request Nov 11, 2026
…red (kunchenguid#8159)

* Fixes kunchenguid#8154 record forced scout discards

* no-mistakes(review): keep discarded note across close-marker replay

* no-mistakes(review): assert discarded note on row body, not task id

* Fixes kunchenguid#8154 preserve reports on held scout cleanup

* no-mistakes(document): document forced scout discard in teardown docs

(cherry picked from commit 7c6170e)
demy00 added a commit to demy00/firstmate that referenced this pull request Nov 14, 2026
* feat: report worker status through OSC 7501 (#8011)

* feat(bin): report worker state via OSC 7501 for firstmate-launched agents

Stage 2 of the herdr-core/app staged plan: agents firstmate launches now
report idle/working/blocked/done to their terminal through the OSC 7501
Program Status Protocol, so 7501-aware terminals (herdr-core, the Herdr
app, Ghostty, Rex) show task state without screen inference.

bin/fm-osc7501.sh is armed inside the launch command before the agent
starts. Its watcher folds the task's durable signals (status log,
busy-state, unhandled inbox) into root records with
app=firstmate-<harness> and title=fm-<id>, and parks the record on exit.
Arm emits nothing unless the terminal is known-aware (HC_TERMINAL_ID,
REX_BLOCK/REX_SESSION, TERM_PROGRAM=ghostty) or answers the capability
query, stands down for natively reporting harnesses (claude >= 2.1.295,
pi >= 1.1.0), and never writes to worker input. The env -i floor now
forwards the HC_* pane markers so detection survives an allowlist.

config/osc7501-status gates the feature per home (default on).
The herdr backend is untouched; core/app integration stays Stage 3.

* no-mistakes(review): Fix OSC 7501 reporter tty identity, lifetime, mapping, and stty restore

* no-mistakes(review): Honor hc terminals under herdr; retire superseded status declarations

* no-mistakes(review): Retire stale declarations on any newer busy record

* no-mistakes(review): Drop report command; retire declarations on later inbox steers

* no-mistakes(review): Classify activity via busy lib; confirm reporter retirement

* no-mistakes(review): Order retirement by nanosecond times; drop pull-source turn guess

* no-mistakes(review): Retire declarations only on later steers, with stable thresholds

* no-mistakes(review): Drop probe cache; restore hc socket pinning in floor

* no-mistakes(review): Drop declared-wait mapping; report from single-source signals only

* no-mistakes(review): Give the watcher backend capture for pane-classified harnesses

* no-mistakes(document): Clarify OSC 7501 documentation ownership and Rex compatibility

* no-mistakes(review): Newline-delimit launch disarm; keep arm warnings visible

* no-mistakes(review): Require stand-in pidfile before checking disarm

* no-mistakes(review): Skip status-bridge records in Rex activity readers

* no-mistakes(ci): Fixed Cortex launch assertions mistaking the OSC reporter’s --config for an unsupported Cortex flag, including the sibling xhigh check. Reproduced failure before fix; Cortex suite, bash syntax, and diff checks pass afterward. Full suite failure was downstream of this test failure

* no-mistakes(ci): Removed active terminal capability queries, tty reads/mode changes, and the unused query timeout. Unknown terminals now silently no-op; passive detection remains. Updated docs and behavioral tests. Regression rejects pre-fix code; all 18 reporter tests, syntax checks, ShellCheck (excluding source-resolution notices), and diff checks pass

* no-mistakes(review): Exclude native codex and gate records on activity

* no-mistakes(review): Never write bridge records without known activity

* no-mistakes(review): Probe the launched binary for native reporters

* no-mistakes(review): Arm no reporter for raw launch commands

* no-mistakes(review): Report raw launches only with established agents

* no-mistakes(document): Consolidate OSC reporting documentation ownership

* no-mistakes(ci): Fixed standing captain holds to report blocked kind=question before activity fallback. Added behavioral coverage for idle/busy holds and supersession; confirmed regression fails before the fix and full OSC suite passes afterward. Shell syntax and diff checks passed

* no-mistakes(ci): Fixed the flaky startup-teardown fixture in tests/fm-watcher-lock.test.sh: replace racing recursive deletion with a checked atomic rename, retaining the old inode. Full suite failure was downstream of this shard failure. Complete watcher-lock suite, shell syntax, and git diff checks passed locally

* fix(osc7501): keep the bridge's own record honest when activity reads unknown

The unknown-activity silence that protected a native writer's root record
also left the bridge's own working/blocked on the pane forever - including
past the agent's exit, which never emitted its final record. While the
bridge's last write still stands, the durable signals now keep it honest:
they fold the same way with idle activity and the result is written once
per change, with no hold and no heartbeat. A watcher that never wrote
still stays silent so a native owner is never touched. The final record
likewise lands whenever the bridge's last write stands, keeping done/error
and parking the rest at idle. Rovo and Antigravity, whose only activity
source resolves busy or unknown, thereby still reach idle, blocked, done,
and error. Arm also writes one idle record once every gate passes, clearing
whatever a watcher that died without its final write left on the pane.

* no-mistakes(review): Carry arm-time ownership into watcher, trim osc_seq

* no-mistakes(document): Clarify OSC status lifecycle documentation

* fix(osc7501): park stale terminal lines and clear leftovers on unarmed relaunches

A done/failed status line carries the phase that wrote it, not the turn
now in flight: under unknown activity the fold now reports a terminal line
only when it was stamped at or after the reading that last proved the
worker busy, so an earlier phase's result parks at idle instead of
displaying done or error for a whole turn. A same-second stamp still
counts - a truly older line can never coincide with the last busy reading.

arm's residue clear now runs once the pane's terminal proves 7501-aware
and a leftover pidfile marks the record as the bridge's own, before the
config and native gates - so off and native relaunches retire a dead
watcher's record too, while panes that never armed still see no bytes.

* no-mistakes(review): Order stale results by append; keep result at exit

* no-mistakes(document): Clarify OSC status reporting documentation

* no-mistakes(ci): Replaced the version probe’s unbounded TERM/wait loop with shared fm_run_timed process-group termination and KILL escalation. Added a regression proving worker launch proceeds despite a TERM-resistant probe and descendant; reproduced failure before the fix. All 31 OSC tests pass, including the regression with the bash timeout fallback. Shell syntax and git diff checks pass

* fix(osc7501): disarm writes the final record a dead watcher never could

fm-spawn runs disarm after the agent command returns, so a SIGKILLed
watchers pidfile is removed there - before the next launch ever sees it,
which left the dead watcher's working/blocked record standing on off and
native relaunches. disarm now writes that final record itself (idle,
keeping done/error, exactly osc_final's fold) when the pidfile names no
live reporter; the pidfile carries harness and kind so the write names
the right app= and folds decisions under the worker's real kind. The
real-order regression now exercises SIGKILL -> disarm -> off/native
relaunch.

* no-mistakes(review): Write final record when retirement kills watcher

* no-mistakes(review): Always write final record once retirement confirms

* no-mistakes(lint): Suppress intentional generated-script expansion warning

* feat(bin): add opt-in Linux container check for changed shell tests (#8148)

* feat(bin): add opt-in Linux container check for changed shell tests

* no-mistakes(review): Run Linux check as host user with git clone

* no-mistakes(review): Remove locally deleted files from Linux scratch copy

* no-mistakes(review): Use keep-id for podman in Linux test check

* no-mistakes(ci): Fixed the three selected review findings locally (nothing committed or pushed). ci-2: bin/fm-test-linux.sh now clones with --no-hardlinks, so the container cannot write the host object files. ci-3: tests/linux/Dockerfile now installs python3, nodejs and curl (tools the ordinary suites require); tests/fm-test-linux.test.sh container case adds a tools.test.sh fixture that runs python3, node and curl. ci-4: both the overlay check (line 100) and the prune check (line 104) treat [ -L ] as present; the same fixture commits a dangling symlink and asserts it survives in the container. Verified with FM_TEST_LINUX_CONTAINER=1 bash tests/fm-test-linux.test.sh on Docker: all 4 pass. Mutation check: removing the [ -L ] at line 104 turns the fixture red ("dangling link lost"). Removing it at line 100 alone does not, because the clone already carries committed symlinks; that check only matters for untracked dangling links, which has no fixture. The check stays opt-in

* feat(bin): accept a caller-supplied expected PR head in fm-pr-merge (#8157)

* feat(bin): accept a caller-supplied expected PR head

The merge path read the live head again and used that value for the forge
head match. A push after review could replace the tested commit.
--expected-head takes one full commit, refuses a different live head, and
sends that same value to GitHub, GitLab, and Forgejo.
Callers that omit it keep the live-head match.

Closes #8124

* no-mistakes(review): Drop no-op head pin; test authority and identity refusals

* no-mistakes(review): Inline merge head assignment

* test: add fail-closed test for the pinned Herdr installer (#7753)

* fix(bin): download pinned Herdr from its current repository

* no-mistakes(review): list installer test in pure-contract-unit family

* no-mistakes(ci): The Test coverage guard failure came from this PR, and I fixed it. Full suite also fails for a reason outside the code: it needs a maintainer's label. **Test coverage guard (ci-2):** The rule is that at most 15% of the portable-serial test scripts may lack a measured duration hint. The new `tests/fm-install-herdr.test.sh` had no hint, so 43 of 286 scripts lacked one (15.03%). Before this PR it was 42 of 285. The duration-hint table in `bin/fm-test-run.sh` is the only place this needs fixing. I added `tests/fm-install-herdr.test.sh 1000` to that table in alphabetical order. I also added one line to `docs/fm-test-portable-shards.md` recording it as a provisional local measurement: the slowest of five local runs took 223 ms (range 155-223 ms), and the next CI refresh will replace it with an Ubuntu measurement. Other new tests have been handled the same way. After the change, `bin/fm-test-run.sh --check-coverage` exits 0 with `serial_unhinted=42`. **Full suite (ci-1):** This job failed with `FM_CI_FULL=false`, which means the `full-ci` label is missing. Outside pull requests need a maintainer to add that label, so no code change can fix this part. The job also reported a failed lane, most likely the coverage guard fixed above. **Verification:** I ran `tests/fm-test-run.test.sh`. All the coverage, shard, partition and packing tests passed. One script failed: `tests/fm-session-lock-ancestry.test.sh`, which checks that the pty-host is reparented to init after its daemon ends. It is in a different test family, and its result depends on how processes are parented on the machine running it. This change only adds a duration hint, which affects how tests are spread across shards, not which tests run, so I don't think the change caused it. I did not rerun it on the base commit to confirm

---------

Co-authored-by: c-c6aw <225476801+c-c6aw@users.noreply.github.com>

* fix(bin): record forced scout teardown as discarded instead of delivered (#8159)

* Fixes #8154 record forced scout discards

* no-mistakes(review): keep discarded note across close-marker replay

* no-mistakes(review): assert discarded note on row body, not task id

* Fixes #8154 preserve reports on held scout cleanup

* no-mistakes(document): document forced scout discard in teardown docs

* fix: preserve full captain-hold questions in decision snapshots (#8173)

* fix: preserve full Bearings decision questions

* no-mistakes(document): Document full decision question presentation

* fix(bin): canonicalize Windows drive-letter herdr socket paths before identity comparison (#8185)

* fix(bin): canonicalize Windows drive-letter herdr socket paths before identity comparison

* test(herdr): cover Windows drive-letter socket normalization

Adds the regression coverage the review asked for. `cygpath` ships only with
Git for Windows, so the cases stub it and therefore run on every platform; the
adapter guard matches only `[A-Za-z]:[\/]*`, a shape that cannot occur on
Linux or macOS.

Three cases: a drive-letter spelling normalizes to the same identity as the
POSIX spelling of the same socket, a failed `cygpath` is refused rather than
compared half-converted, and empty `cygpath` output is refused.

Verified the cases fail for the right reason: with the guard removed, the
normalization case reports an empty identity against the expected POSIX path.

---------

Co-authored-by: 3min-lang <karta1359200@gmail.com>

* fix: wait for busy-state locks to reach the stale threshold (#8177)

* fix(bin): outwait a fresh orphan busy-state lock before refusing

lock_acquire gave up after about two seconds, but only breaks a lock once
it is FM_BUSY_LOCK_STALE_SECS (default five) old. A writer killed inside its
critical section, such as a worker exit hook during teardown, leaves a fresh
orphan lock, so the first retire always failed with a lock timeout and only
a later retry succeeded.

A waiter now keeps polling until any lock that existed when it began has
had time to cross the stale bound, then breaks it as before. A lock that
stays younger than the bound for the whole wait still ends in a
lock-timeout refusal, about stale + 2 seconds after the wait began, and a
live writer that releases within the bound is waited for, never broken.

* no-mistakes(ci): Captain, fixed ci-2 by normalizing stale-lock settings to decimal before arithmetic. Added an 08 behavior regression that failed before the fix and passes afterward. Busy-state tests, focused lint, and diff checks pass. Workflow policy and labels remain unchanged

* fix: sync record exports with empty overrides and hidden state files (#8188)

* fix: refresh owner lease before detached process-event launches (#8191)

* Refresh owner presence before detached process-event startup

* no-mistakes(review): Correct lease documentation and CI evidence claims

* fix: recover remote inheritance after sender counter loss (#8104) (#8187)

* fix: recover remote inheritance generations after counter loss

* no-mistakes(review): Restore inheritance pushes to older receivers

* no-mistakes(document): Document inheritance counter recovery

* test: cover inheritance selection and mutation kill boundary

* no-mistakes(document): Clarify receiver generation query documentation

* feat: support explicit GitHub branch updates before merging (#6330)

* fix: update green behind PR before merge

* no-mistakes(review): Update behind PRs for any method; await UNKNOWN

* no-mistakes(review): Cap update-branch wait under merge locks

* no-mistakes(review): Fix stale update-wait header comment

* docs: clarify branch update authority

* fix(merge): require branch-update consent and stop on failure

* no-mistakes(review): Await UNKNOWN after waivers; report unreadable post-update state

* fix(merge): pin branch update to checked head

Send expected_head_sha with the REST update so a concurrent push cannot
advance an unchecked replacement head.

Refuse a head mismatch without retrying against the new head.

* no-mistakes(document): Clarify branch-update consent, head pinning, and polling guidance

* fix(bin): stop waits on non-check refusals

Pending or missing checks must not mask draft, state, conflict, or required-check read refusals after a branch update.

* no-mistakes(review): Refuse blockers while awaiting updated pull request heads

* no-mistakes(document): Document immediate refusals during branch update polling

* fix: clean up Perl timeout processes on interruption (#7922)

* fix: reap Perl timeout groups when callers are interrupted

* no-mistakes(review): Preserve caller signal handlers after timeout runner cleanup

* no-mistakes(review): Prevent startup interrupt loss and remove parent-death cancellation

* no-mistakes(document): Correct timeout fallback comments and remove stale duplication

* fix: preserve interruption status and use monotonic timeout clocks

* no-mistakes(document): Correct timeout contract references and document monotonic timing

* no-mistakes(review): Preserve active traps in Perl timeout cleanup

* no-mistakes(document): Clarify Perl timeout trap restoration

* fix: prevent watcher marker collisions between endpoints (#7923)

* Preserve independent watcher history for distinct endpoints

* no-mistakes(review): Complete shared watcher-marker key migration

* no-mistakes(document): Document shared watcher marker identity

* no-mistakes(ci): Fixed SC1091 by adding the daemon’s missing ShellCheck source annotation. Focused full-analysis lint, bash syntax validation, and git diff --check passed. Tier 2: the existing lint gate enforces this correction; no runtime redesign was needed

* no-mistakes(ci): Implemented bounded SHA-256 endpoint keys and a failing-first long-endpoint regression, which now passes. ci-1 remains unchanged as unrelated. Incomplete: focused lint reports SC2030/SC2031 in fixture setup. The command guard rejected focused testing as indirect execution. Stopped without bypassing or retrying. Pipeline must resolve lint and finish verification

* test: scope watcher fixture environment to child commands

* docs: explain watcher key upgrade reset and cache cleanup

* no-mistakes(test): Confirm six required scenarios pass; exclude optional Codex probe

* chore: remove accidental validation scratch

* no-mistakes(document): Replace obsolete watcher-key comment with owner pointer

* no-mistakes(review): Use shared keys in Pi-stream fixtures

* no-mistakes(document): Deduplicate watcher marker cleanup guidance

* test: stabilize extension orphan recovery readiness (#8210)

* test: wait for recovered orphan-readiness runners instead of a fixed marker poll

The lifecycle-orphan-readiness section polled each recovered source's
handled marker for a fixed 10s after reconcile. Reconcile only confirms
each launch; each runner then polls, captures, takes a silent verdict and
a terminal verdict, and the two runners take their verdicts in turn under
the home's extension lifecycle lock. On a CPU-starved host that chain of
short host and fixture processes can exceed 10s, so the section flaked.

Wait for the recorded runner process groups to exit, bounded by the
coordinator's section-lane deadline, then assert the handled markers,
retirement and claim release. On timeout, kill the recorded runner groups
and sweep the home before failing, and track the home so any exit sweeps
it.

* no-mistakes(review): Bound recovered-runner wait to coordinator deadline

* feat: allow configurable TypeSafe dispatch base URLs (#7957) (#8192)

* test: cover TypeSafe dispatch base URL configuration

* test: compare the recorded TypeSafe endpoint argument

* feat: allow an explicit TypeSafe dispatch base URL

* no-mistakes(review): Use literal TypeSafe endpoint test expectations

* no-mistakes(document): Correct TypeSafe base URL documentation

* no-mistakes(ci): Implemented ci-2 and ci-3: malformed TypeSafe addresses fail before credential lookup, and both curl paths disable URL globbing. Added focused regressions. Tier 1 fixes address the shared boundaries. Configured local lint passed. Required ci-box tests and the documentation audience check remain unverified. The command guard rejected the inspection/preflight command as “Privilege escalation in chained command.” No retry or bypass was attempted

* fix: reject brackets in TypeSafe base paths

* no-mistakes(review): Narrow TypeSafe host validation

* no-mistakes(document): Clarify TypeSafe base URL documentation

* test: isolate dispatch base from exported settings

* fix(bin): refresh stale remote refs before teardown refuses landed work (#8030)

* fix(teardown): refresh remote refs before refusing work as unlanded

Teardown read landed work from the task copy's remote-tracking refs, so work
pushed from another checkout was refused until someone fetched by hand. Refresh
each remote, bounded and without pruning, when the refs do not show the work.
A failed refresh leaves the refs as they were, still refuses, and names the
remote in the refusal.

* no-mistakes(review): Use fixed 30-second fetch bound, removing timeout override

* no-mistakes(ci): Final state, replacing the earlier reports: the fix is in the worktree, uncommitted. The full run of tests/fm-teardown.test.sh did NOT complete: it was stopped at the 20-minute background limit after about 126 of 156 tests. All 126 passed with no failures, including the new test. The remaining ~30 did not run, so the outer test phase must run the full file. Change: validate_worktree_teardown_safety re-runs the dirty check through read_worktree_dirt right after refresh_remote_refs and refuses the same way if it fails or finds work. Added one test, test_edit_saved_during_refresh_refuses, covering local-only, direct-PR and no-mistakes modes. Kept the timed-out agent's code change; removed its extra second test and fake-git hook, per the one-test instruction. Verified: the new test failed with the recheck removed and passed with it restored. bash -n on bin/fm-teardown.sh passed. Not verified: shellcheck is not on PATH, so it did not run. The path where the recheck itself cannot read the copy has no test, per the one-test instruction. Partial log: /tmp/fm-teardown-full.log

* fix(bin): bind crewmate spawns to the recorded dispatch selection (#8262)

* fix(spawn): bind launch flags to dispatch selection

* no-mistakes(review): Bind spawn to resolver-recorded dispatch selection

* no-mistakes(review): Bind spawn to per-task dispatch resolution record

* no-mistakes(document): Document relaunch exemption and fix task record heading

* no-mistakes(ci): Fixed the selected Greptile findings ci-2 and ci-3. Changes are left uncommitted in the worktree. ci-2 rule: a spawn under a clear recorded dispatch selection launches only that selection unless the task records an override. A raw launch command (a full command line instead of a harness name) keeps its own --model/--effort options, so matching flags beside it proved nothing. bin/fm-spawn.sh now refuses any raw launch command under a clear record unless --dispatch-override <reason> is given. The error message now says "with no raw launch command". This check gates both the single-task path and the batch path. Raw commands under ambiguous/escalate/error/off records still work, so the manual path is unchanged. ci-3 rule: the resolver writes the task record where fm-spawn.sh reads it, which is FM_DATA_OVERRIDE, else $FM_HOME/data. bin/fm-dispatch-resolve.sh used to look for a folder literally named "data". It now records only when the brief is <data root>/<id>/brief.md, comparing real directory paths. As a side effect, a data/<id>/ folder outside the configured root no longer gets a record. The resolver header comment and docs/configuration.md now describe the override. Tests added: - tests/fm-spawn-dispatch-profile.test.sh: the reviewer's case is refused (record selects claude/haiku/low; raw command "claude --model opus --effort high" with --model haiku --effort low). The same command launches with an override, and the reason is saved in the .meta file. - tests/fm-dispatch-resolve.test.sh: a brief under FM_DATA_OVERRIDE gets its record. A data/ folder outside the configured root does not. The existing task-record test now puts its brief under $FM_HOME/data. Verification: both full suites passed locally. For the spawn suite I put the real Python and Node install folders ahead of mise's wrapper scripts on PATH, because those wrappers fail on this host when a test changes HOME. That is a host problem, not a product defect. Shellcheck shows only info notes about sourced files it was not asked to follow. I did not run the new tests against the old code. From reading the old checks, each would have failed there. ci-1 and ci-4 were not touched, because the user chose to ignore both

* fix(procevent): stop launch confirmation starving the runner it awaits (#8265)

A runner needs the source lock to claim. ensure-listening and reconcile
both polled that lock every 50ms while waiting for the claim, so on a
loaded host the confirmation competed with the launch it was confirming.
At a load average near 50 a healthy runner claimed in 1.0-1.7s under a
lock-free observer and took 3.3-5.6s under ensure-listening, past the
default confirm window.

The miss was not harmless. arm then retired its own registration, half of
the arms in a twelve-run sample failed on a correct board, and a later
ensure-listening reported the source as not registered. reconcile announced
a launch failure for a source that was starting normally.

Take the lock only once a claim file exists, since until then there is
nothing to confirm. The same sample then armed twelve of twelve. The
regression test holds a runner just before its first lock acquisition and
asserts nothing else takes the lock, so it does not depend on timing.

Co-authored-by: Frederik Hagelund <5653787+Fredehagelund92@users.noreply.github.com>

* fix: restore Claude supervision after API-error turn ends (#8134)

* fix(bin): re-arm supervision on Claude StopFailure so error-ended turns are not blind

A Claude turn that ends on an API error runs no Stop phase, so the
Stop-owned auto-arm never fired and the home had no watcher coverage
until external input (observed as 15h and 4.7h blind gaps). Claude
2.1.317 fires StopFailure for those turn ends and honors the same
asyncRewake/exit-2 rewake as Stop, verified live on a herdr-hosted
primary: the tracked auto-arm under StopFailure armed a real watcher,
delivered the queued wake as an unprompted turn, and the chained error
end was suppressed by the new per-cooldown rewake bound instead of
storming.

* no-mistakes(review): Pace StopFailure continuations instead of dropping

* no-mistakes(review): Recheck AFK and need after StopFailure pacing

* no-mistakes(document): Document StopFailure supervision continuity

* no-mistakes(ci): Normalized the validated StopFailure cooldown to base 10. Updated the behavioral pacing regression to use 08 after a cooldown marker exists; it failed before the fix and passes afterward. Full auto-arm test suite, Bash syntax checks, and git diff --check pass. Changes remain local; nothing published

* no-mistakes(ci): Fixed the watcher-lock test’s flaky STOP-and-scan synchronization by pausing at the lock-free poll sleep. Full watcher-lock suite, repeated focused regressions, Bash syntax, and diff checks pass. Full suite failure was downstream of the shard failure. Changes remain local; nothing published

* fix: prevent Codex Stop hook JSON contamination (#7231)

* fix: keep Codex Stop responses free of login-shell output

* no-mistakes(document): Consolidate Codex Stop documentation under authoritative owners

* no-mistakes(ci): Fixed both Pi before_agent_start handlers to narrow prompt-bearing events before accessing event.prompt, addressing the two TS2339 CI errors. Custom events now bypass user-prompt handling; ordinary prompt events and existing message_start paths remain unchanged. Local verification is blocked: tsc is not on PATH. No tools were installed and no other pipeline phases were executed

* fix: keep Codex Stop responses free of login-shell output

* no-mistakes(document): Consolidate Codex Stop documentation under authoritative owners

* no-mistakes(document): Correct Codex verification prerequisites and guard coverage

* fix(calm): leave one blank row above the Claude Code working boat (#7253)

* fix(calm): leave one blank row above the Claude Code working boat

Refs #7160

* no-mistakes(review): Assert spinner Box padding by walking tree

* fix(bin): refuse to relaunch a worker into a primary home or checkout (#8127)

* fix(spawn): refuse to relaunch a worker into a primary home or checkout

A relaunch trusted the recorded worktree and started the worker there. After a machine restart the restored record could point at the primary home or a repository's primary checkout, so a worker was relaunched inside it. Relaunch now refuses with a named error when the recorded worktree is the home, the code root, or a repository's primary checkout (git dir equals git common dir).

* no-mistakes(document): Document relaunch refusal of primary home or checkout worktrees

* no-mistakes(ci): Fixed ci-2 (the Greptile P1 finding). ci-1, the Full suite failure, is the expected maintainer-label gate; the user chose to leave it alone, so nothing was changed for it. Invariant: the relaunch refusal must judge whether the recorded worktree is a primary checkout from the directory's own layout on disk. Inherited Git location variables must not be able to change the answer. In this change, the only place that probes Git for that decision is the git-dir and common-dir check in the `--relaunch` refusal in `bin/fm-spawn.sh`. The home and code-root comparison doesn't use git, so it can't be affected. Fix in `bin/fm-spawn.sh`: both probes now run in a single subshell. That subshell first unsets the same Git variables that `bin/fm-claude-trust.sh` clears (`GIT_DIR`, `GIT_WORK_TREE`, `GIT_COMMON_DIR`, `GIT_OBJECT_DIRECTORY`, `GIT_INDEX_FILE`, `GIT_ALTERNATE_OBJECT_DIRECTORIES`, `GIT_CEILING_DIRECTORIES`, `GIT_NAMESPACE`, `GIT_DISCOVERY_ACROSS_FILESYSTEM`, `GIT_CONFIG*`). It then runs one `git rev-parse --path-format=absolute --git-dir --git-common-dir` and splits the two output lines. The unset is scoped to the subshell, so the environment the rest of the script and the launched worker see is unchanged. When git fails, the result is empty and the code falls through exactly as before. Regression test in `tests/fm-control-relaunch.test.sh`: `test_relaunch_refuses_the_primary_checkout_under_inherited_git_overrides`. It records `worktree` as the project's primary checkout, then runs `fm-spawn --relaunch` with `GIT_DIR` set to the linked worktree's git directory and `GIT_WORK_TREE` set to the primary checkout. It asserts exit code 1, the "primary home or checkout" error, and that nothing was launched. The test is registered in the suite's run list. Verification: - `bash tests/fm-control-relaunch.test.sh` with the fix: rc=0, all tests pass, including the new one. - With the `fm-spawn.sh` change temporarily reverted: rc=1, and the new test fails with `missing: 'primary home or checkout'`. So it reproduces the reported bypass. - `shellcheck` on both files reports no warnings or errors

---------

Co-authored-by: Trillium Smith <5898009+trillium@users.noreply.github.com>

* fix(bin): read session-lock owner identity without the ps binary (#7609)

* fix(session-lock): read process identity without the ps binary

An EDR-style policy can deny the ps binary's exec itself - observed on
a hardened macOS host where /bin/ps was refused even for 'ps -V', while
kill, head, sysctl, pgrep and lsof all ran. The session lock proved
identity by walking harness ancestry through ps, so the walk died at
its first call: every session in that home became a permanent
lock-refused read-only one, and a live lock owner looked reclaimable,
so a fresh process could take over a lock whose owner was still
running.

All identity reads now go through one fm_proc_info reader. ps stays
primary and is used verbatim wherever it executes, so a host where ps
works is byte-identical to before. Only a ps that cannot execute at
all - bash exit 126 for a refused exec, 127 for a missing binary,
while a pid merely being gone exits ps 1 - routes one read to an OS
provider: /proc on Linux, bin/fm-procinfo.py on macOS, which reads the
ppid through a self-verified KERN_PROC_PID chain and the identity
through the KERN_PROCARGS2 argv region.

That last point is a correctness requirement, not a preference. macOS
'ps -o comm=' reports argv[0] and 'ps -o args=' reports the full argv,
so the ps-free route keys both fields on the same argv region. A
helper that reported the resolved exec path instead disagreed with ps
for renamed, symlinked, or argv[0]-wrapped harnesses, and that
disagreement turns a lock refusal into a wrong take-ownership decision.

Every read fails closed and is verified against the requested pid: no
route guessing, foreign chains still refused, dead pids still stop the
walk. A record that is not exactly one line of three fields with a
numeric ppid is refused rather than loosely sliced.

Two defects found by diffing the change against the unchanged base on
a live host are fixed here as well:

1. A pid ps can see but cannot name - a live process whose comm was
   emptied - was reported as stale, which means reclaimable. The base
   reports unknown for that case, and reporting it stale let a fresh
   process take over a lock whose owner was still running. The ps route
   now reports the pid as present, and the provider route accepts a
   record whose comm field is legitimately empty so both routes agree.

2. The provider record parser rejected a record with an empty field,
   but the field COUNT is what it must pin: a TAB is IFS whitespace, so
   a record with a MISSING field parsed exactly like a record whose
   field was empty. The parser now rebuilds the record from the parsed
   fields and compares it to the original, which proves the count
   without rejecting a legitimate empty field.

Verified against the unchanged base: 120 identity reads and 200 lock
inspections across live pids show zero divergence, and the empty-comm
case reads unknown on both.

* no-mistakes(review): Refuse reclaiming session locks with unreadable owner identity

* no-mistakes(review): Reject partial process identity reads; reclaim non-pid locks

* no-mistakes(review): Preserve platform process identity byte rendering across routes

* no-mistakes(review): Normalize trailing empty argv elements across identity providers

* no-mistakes(document): Document session-lock recovery requirements

* no-mistakes(lint): Fix ShellCheck arithmetic array index style

* fix(session-lock): decide the owner verdict from liveness first, not identity

The review rounds that closed the "a live owner can be taken over" hole
inverted the order of the two facts the verdict is built from: the
provider read decided whether the recorded owner was alive, and liveness
was only consulted afterwards. That order breaks two cases the base
already handled.

A pid this session cannot signal is not a live owner it may reclaim
over, whatever a process table still says about it. A recorded owner
that is gone therefore has to read as gone, or the stale lock can never
be reclaimed and the session stays lock-refused read-only for good -
the exact wedge this change exists to remove. The repository's own
suites pin that: tests/fm-session-lock-ancestry.test.sh asserts that a
recorded pid whose kill -0 fails is left for the ordinary reclaim, and
tests/fm-session-lock-ancestry.test.sh's sibling case asserts that a
recorded pid of 1 - which this session may not signal - is still
reclaimable.

The verdict now asks liveness first and identity second:

  kill -0 succeeds, the provider reads   -> readable
  kill -0 succeeds, the provider fails   -> unreadable: alive, identity
                                            not readable, so the lock
                                            must not be reclaimed
  kill -0 fails, the provider reads      -> unknown: the process exists
                                            but this session may not
                                            signal it, so it is not a
                                            harness this session can
                                            prove - the base's "no live
                                            harness owner"
  kill -0 fails, the provider fails      -> dead

That keeps the protection the review rounds were after - a live owner
whose identity cannot be read is never reclaimable - while restoring the
base's reclaim behaviour for the cases the base handled. The new case
"kill -0 succeeds, the provider fails" is the one that closes the
reported takeover path, and it is unchanged.

Verified on this host: tests/fm-session-lock-ancestry.test.sh exits 0
again (it exits 1 on the previous head, where the recorded-dead-pid case
failed), tests/fm-session-lock-ps-denied.test.sh exits 0, and
tests/fm-gotmp.test.sh exits 0. tests/fm-secondmate-harness.test.sh and
tests/fm-session-start.test.sh still exit 1 with exactly the failures
they have on the unchanged base: this host's restricted PATH lacks
dirname, cat and awk.

* no-mistakes(review): Preserve successful status for unreadable owner verdicts

* fix(session-lock): keep the ppid a walk input, not an identity field

The review round that made a partial identity read refuse the reclaim
extended the rule from the arguments to the parent pid as well: a read
that could not answer ps -o ppid= was treated as an unreadable
identity, so the whole read failed.

The parent pid is not an identity field. The identity the matcher reads
is comm and args, and both of those are still fail-closed: a live
harness whose arguments cannot be read is not reduced to a bare
interpreter name, and its lock is still not reclaimable. The parent pid
is a walk input, and a parent pid that cannot be read only ends the
ancestry walk one hop early - the walk finds no harness and the
session refuses the lock rather than taking one it cannot prove, which
is the conservative direction.

The base read the parent pid exactly this tolerant way, and the
repository's own suites pin it: tests/fm-grok-harness.test.sh and
tests/fm-kimi-harness.test.sh stub ps so that it answers comm= and
args= and refuses every other question, and both expect the lock to be
recognised as held by a live harness. Under the stricter rule both
suites failed with "fm-lock did not recognize grok as a live holder"
and "fm-lock did not acquire from Kimi ancestry".

The provider route is unchanged and stays all-or-nothing: on Linux the
parent pid comes from the same /proc read as the command name, and on
macOS from the same KERN_PROC_PID chain, so a provider read is either
complete or unreadable. The case that proves it - a /proc entry with no
readable cmdline - still refuses the reclaim.

The new test case is corrected rather than dropped: the failed-args
case still has to refuse the reclaim, and the failed-ppid case now
pins the tolerant contract - the verdict stays readable and the parent
pid is empty.

The same commit restores the shellcheck directives on the assignments
inside fm_session_lock_inspect's verdict switch. The globals are read
by bin/fm-lock.sh and bin/fm-inbox.sh, but the assignments inside the
switch had lost their disable comments, so 'Lint 1' failed with SC2034
on FM_LOCK_INSPECT_STATE and FM_LOCK_INSPECT_LIVE_HARNESS.

Verified on this host: tests/fm-session-lock-ps-denied.test.sh exits 0,
tests/fm-session-lock-ancestry.test.sh exits 0,
tests/fm-grok-harness.test.sh exits 0 (it exits 1 before this commit),
tests/fm-kimi-harness.test.sh exits 0 (it exits 1 before this commit),
tests/fm-gotmp.test.sh exits 0, and bin/fm-lint.sh exits 0.

* no-mistakes(document): Clarify session-lock recovery ownership

* no-mistakes(lint): Fix single-iteration ShellCheck loop

* test(session-lock): drop the unused loop variable from the partial-identity case

The failed-args case no longer runs through a loop, so the local that
held the field name is never read, and the lint partition reports it as
an unused variable (SC2034). The declaration loses it; nothing else
about the case changes.

* no-mistakes(review): Protect tagged lock owners; preserve Cygwin identity reads

* no-mistakes(review): Fix zero-form locks; focused tests fail pty-host, ShellCheck warnings

* fix(session-lock): read a classified live harness holder as held

fm_session_lock_inspect lost its identity check on the readable verdict,
so every live holder was classified unknown instead of held: grok and
kimi holders failed the live-holder assertions, and a claude-named
holder made fm-inbox report unknown for a lock that was held.

Decide held from the single fm_harness_process_matches call on the
readable branch. The Windows-tagged pre-block that made the same
decision a second time is removed: fm_session_lock_pid_verdict already
resolves the tagged pid through the Windows table and leaves the same
FM_PROC_COMM/FM_PROC_ARGS, so re-reading it could only let the two
answers diverge, and its winpid/win_rc were the unused bindings
ShellCheck flagged as SC2034.

* no-mistakes(document): Align session-lock docs with the shared reclaim verdict

* fix(session-lock): emit the denied-ps diagnostic once per run

`FM_OS_PROC_DIAG_SHOWN` was set by the diagnostic inside
`triple=$(fm_os_proc_triple "$pid")`, so it died with that
command-substitution subshell and every later ancestor read reprinted the
same cause during one lock acquisition.

`fm_proc_info` now spends the once-per-run guard in the shell that owns
the walk. A cause line exists only on the provider's failure routes, so a
failed read is exactly where that budget is used up; a readable read
leaves it unspent for a later failure.

The new case drives three failing reads in one shell and asserts one
stderr line, then repeats with a readable first pid to prove a successful
read does not spend the budget.

* no-mistakes(document): Correct the denied-ps diagnostic scope to per shell

* no-mistakes(review): Preserve UTF-8 process identity in Linux fallback

* no-mistakes(document): Record the ps-free identity byte rule and helper inventory

* test(session-lock): compare control-byte argv by shape, not by ps bytes

The control-byte route-equivalence case compared the provider record and
the ps record byte for byte. That pins one procps build's choice of byte
for a control byte: 4.0.x writes a space where an argument's newline was
and '?' for other controls, while other builds write '?' for the newline
too, so the same two routes agree on one build and differ on the other
even when both make the same identity decision.

Fold each route's separator byte onto the placeholder the /proc route
writes before comparing, keep the ppid and comm fields a raw comparison,
and assert the fixture's words still straddle the control bytes on both
routes so the case cannot pass by matching a loss. Pin the fold against
both Linux renderings of this fixture's newline and assert those
renderings really differ, so a return to raw bytes fails here instead of
only on the other procps build.

* no-mistakes(document): Align session-lock reclaim docs with the shared verdict

* test(session-lock): keep the base PATH when no python3 shim is added

The e2e blocked-ps case built the child PATH from fakebin alone on a host
without python3, dropping the inherited base path with it. On Linux that
left the /proc provider without the cat and tr it reads through, so the
walk failed for a reason unrelated to the denied ps and the case failed
spuriously on exactly the host it is meant to cover.

Set the base path unconditionally and let the python3 branch only insert
the shim ahead of it.

* no-mistakes(document): Correct session-lock verdict comments and library ownership header

* no-mistakes(document): Correct stale issue pointer in session-lock scope comment

* no-mistakes(document): Correct malformed-lock reclaim wording and ps-denied nudge limit

* fix(session-lock): parse /proc stat fields as stat_fields so rex.sh lints clean

ShellCheck follows source directives: bin/backends/rex.sh sources
bin/fm-agent-process-lib.sh, which sources bin/fm-session-lock-lib.sh, so the
new array local named `fields` made rex.sh's string use of its own `fields`
read as an array/string clash (SC2178/SC2128) and failed CI lane Lint 2 on
6e26ecb, while main's same lane passes.

Rename the array to stat_fields, the name the repo's other /proc stat readers
(bin/fm-remote-job-lib.sh, bin/fm-teardown.sh) already use. Verified with
`shellcheck --norc --external-sources bin/backends/rex.sh` (was rc=1, now
rc=0) and `bin/fm-lint.sh --partition 2of2` locally (rc=0, rex.sh reason=ok).

* no-mistakes(document): Sync session-lock docs and stat-parser comment

* test(run): hint fm-session-lock-ps-denied so the coverage guard stays under its unmeasured share

The new session-lock denial script left 43 of 284 portable serial scripts
without a measured duration hint on CI (main: 42), one past the guard's 15%
bound. Record the 3012ms this run measured, in sorted order beside its
ancestry sibling.

* fix(bin): keep every custom check wake line and payload before acknowledgement (#8031)

* fix(watch): print multi-line check output as one wake line

A custom check that printed several lines queued one row with the lines
joined, but the watcher printed the raw lines, and wake consumers that keep
only prefixed lines (such as the Claude Stop-hook banner) dropped every line
after the first. Flatten the wake line the same way the queued row is
flattened, so both carry every line.

* fix(wake): present every distinct check payload before acknowledgement

The drain kept only the newest row per kind and key, and its acknowledgement
then consumed the hidden rows too. Two different wakes queued by one check
before a drain therefore lost the earlier payload unread. Collapse check
rows only when their payload is identical; signal, stale and heartbeat rows
keep their existing newest-wins collapse.

* feat(bin): check watched tools against published npm and GitHub releases (#3841)

* feat: check published releases for watched tools

* no-mistakes(review): Restore whole-registry validation while retaining published-release checks

* no-mistakes(document): Clarify successful installed-version probe requirement

* fix: retain completed tool sweeps at the budget boundary

* no-mistakes(review): Restore unconditional sweep recording and cadence; focused tests pass

* no-mistakes(review): Correct incomplete sweep recording and cadence documentation

* no-mistakes(document): Drop stale conditional sweep-recording wording from configuration docs

* no-mistakes(review): Require successful probes only for published-release comparison

* test: expect a newer announced version beside the published source

Upstream now reports an announcement naming an installed version only as
update not in effect, so the composition test announces 0.8.4.

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

* no-mistakes(review): Compare published releases with the newest installed copy

* no-mistakes(review): Reject watched tools setting both published and version_url

* no-mistakes(document): Scope curl hardening note to published release reads

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix(bin): restore Claude slash-command submission on Herdr (#6695)

* fix(bin): read a typed slash command above Claude 2.1.291's marked popup row

Claude Code 2.1.291 draws the selected row of its slash-command popup with the
same `❯` marker as its composer, so that row below the composer's closing rule
became the bottom-most bare composer candidate and the whole popup list was
read as the typed command. The Herdr Claude payload proof then judged the
payload unsent, cleared it, and reported send-failed, so `fm-control exit` and
every slash command sent through `fm-send` failed on Herdr.

Demote that row to the proven envelope above it, but only when the envelope's
own glyph row holds typed `/` text (the fallback read can never be empty) and
the row has the popup shape: a leading `/` or a truncated `…` name, then a gap
of two or more spaces before its description. Numbered-choice dialog rows,
one-word drafts, empty composers, and typed prose keep their old reading, and
the head-truncation and placeholder-remainder refusals are unchanged.

Regression tests run against real captures of the 2.1.291 screens. The live
guard gains a /context scenario, and the dated verification record is updated.

* no-mistakes(review): Ghost-strip popup demotion guard; relocate 2.1.291 docs

* no-mistakes(review): Match popup guard to fallback's plain glyph row

* no-mistakes(review): Narrow box popup test; note box follow-up in docs

* no-mistakes(document): Point same-glyph footer rule at 2.1.291 popup exception

* no-mistakes(ci): Both selected Greptile findings are fixed. Only the live test and the verification doc changed; product code and box handling are untouched. The changes are left uncommitted for the outer executor. **ci-2** (tests/fm-herdr-submit-confirm-live-e2e.test.sh) - Invariant: a live delivery check must show that the command actually ran, through its rendered output. An empty composer and a registered agent are not enough. - Fix: after the `/context` verdict, the test now polls the pane the same way the earlier reply check does, until `/context`'s `Context Usage` heading renders. Any other result fails. - I confirmed that heading with a probe in an isolated `fm-lab-` session. The popup's description says "context usage" in lowercase, so the case-sensitive match cannot hit the popup. - The read window is 1000 lines (`--source recent --lines 1000`). The report runs to hundreds of rows here with its heading at the top, so the 200-line window the reply check uses would lose it. - The existing agent-registered and composer-empty checks are kept. The header comment, block comment and pass message were updated to match. **ci-3** (docs/verification/runtime-backends.md) - Invariant: only tests that fail against the previous classifier may be called before-and-after regressions. - I ran each of the five tests on its own against base 5838f105's `bin/fm-composer-lib.sh`: - These 3 fail there and are now labelled before-and-after regressions: `marked_row_is_not_a_second_composer`, `composer_content_..._not_the_composer`, and `send_text_submit_..._proven_and_submitted` (the last one returned 'unknown'). - These 2 pass there and are now labelled guards: `demotion_only_ever_refuses` and `popup_still_refuses_a_partial_payload`. - I corrected one more claim in the same paragraph. It said the live guard fails against the old classifier "at the `/exit` scenario". A live run against the old classifier (session `fm-lab-herdr-submit-con-1106578-15406`) actually fails earlier, at `/context`, with `send-failed`. The doc now says that. - The doc's recorded live output was replaced with the real output of the new run. **Verification** - Live guard on HEAD: `FM_HERDR_SUBMIT_CONFIRM_LIVE=1 ANTHROPIC_MODEL=claude-haiku-4-5-20251001` passed all 4 checks, including "...proves and submits a typed /context behind its command popup and renders its report". It ran in its own session, `fm-lab-herdr-submit-con-1098793-23839`. - Every live run used only its own `fm-lab-` session. Afterwards `herdr session list` shows only `default`, which was never touched. - `tests/fm-composer-lib.test.sh` returned 0 with 47 ok, and `tests/fm-backend-herdr.test.sh` returned 0 with 233 ok. - With the opt-in off, the live test skips with rc 0. - `bin/fm-lint.sh` returned 0 (ShellCheck 0.11.0, actionlint 1.7.12). - Temporary directories were removed. **Gap:** the new check's failure path was never triggered in a live run, because the old classifier fails earlier, at the verdict. That the check can tell a run from no run rests on the probe: the heading is not on screen before submission, and the popup text is lowercase

* no-mistakes(document): Include Tern in popup classifier inheritance documentation

* fix(bin): tolerate slow Herdr worktree entry in fm-spawn (#8139)

* fix(spawn): tolerate slow Herdr worktree entry

Restore shell startup tolerance after out-of-pane leasing, resend the worktree cd once, and diagnose a pane that never moves. Cover delayed and dropped entry portably and ordinary/delayed projected spawns in an isolated real-Herdr lab.

Fixes https://github.com/kunchenguid/firstmate/issues/8138

* no-mistakes(document): Document Herdr worktree cd resend in agent-control

* no-mistakes(ci): I fixed Greptile ci-1. On supported Herdr releases below the presentation floor (0.8.0, including pinned 0.7.4), the live test `tests/fm-herdr-projected-cd-live-e2e.test.sh` reported a correct flat spawn as a failure. Now it skips clearly on those releases. **Invariant:** the test may expect a projected spawn only when the same floor classifier `fm-spawn` uses says projection is the default. **Where it must hold:** the one decision point before the case loop. Both cases (delay 0 and delay 1) assert the `.herdr-presentation` marker, and both sit after that check. **Change (test file only):** after the lab is provisioned, the test calls the existing `fm_backend_herdr_presentation_release_supported` from `bin/backends/herdr.sh`. It goes through the test's fake `herdr`, which routes every call to the named lab session, so the check covers the same client and server `fm-spawn` sees. The result is handled three ways: - **At or above the floor:** the projected and delayed cases run as before. - **Below the floor:** the test prints `skip: Herdr <release> is below the 0.8.0 presentation floor, so spawns stay flat` and exits 0. The cleanup trap still tears down the lab. - **Can't be classified:** the test fails. No production code changed, and the overall Herdr support floor is unchanged. **Verification** (Herdr was only run through `bin/fm-herdr-lab.sh` on its own `fm-lab-` session): - **Above the floor:** on the installed Herdr 0.9.5, both cases pass: "Herdr 0.9.5 projected spawn enters its recorded copy" for delayed=0 and delayed=1. - **Below the floor:** I pointed `HERDR_LAB_HELPER` at a temporary wrapper around the real lab helper. It changes only the `status --json` reply so the client and server report 0.7.4, protocol 17. The test printed "skip: Herdr server version 0.7.4 (protocol 17) is below the 0.8.0 presentation floor, so spawns stay flat" and exited 0. This is simulated, not a real 0.7.4 install. - Afterwards no lab sessions were left over. - `tests/fm-spawn-herdr-lease.test.sh` passed through `bin/fm-test-run.sh`. - `bash -n` is clean. shellcheck shows only the existing SC1091 info note about the sourced `tests/fixtures.sh`. I did not edit the PR body, so its links to issue #8138 are untouched

* no-mistakes(document): Document live projected-cd test's below-floor skip

* feat: report worker status through OSC 7501 (#8011)

* feat(bin): report worker state via OSC 7501 for firstmate-launched agents

Stage 2 of the herdr-core/app staged plan: agents firstmate launches now
report idle/working/blocked/done to their terminal through the OSC 7501
Program Status Protocol, so 7501-aware terminals (herdr-core, the Herdr
app, Ghostty, Rex) show task state without screen inference.

bin/fm-osc7501.sh is armed inside the launch command before the agent
starts. Its watcher folds the task's durable signals (status log,
busy-state, unhandled inbox) into root records with
app=firstmate-<harness> and title=fm-<id>, and parks the record on exit.
Arm emits nothing unless the terminal is known-aware (HC_TERMINAL_ID,
REX_BLOCK/REX_SESSION, TERM_PROGRAM=ghostty) or answers the capability
query, stands down for natively reporting harnesses (claude >= 2.1.295,
pi >= 1.1.0), and never writes to worker input. The env -i floor now
forwards the HC_* pane markers so detection survives an allowlist.

config/osc7501-status gates the feature per home (default on).
The herdr backend is untouched; core/app integration stays Stage 3.

* no-mistakes(review): Fix OSC 7501 reporter tty identity, lifetime, mapping, and stty restore

* no-mistakes(review): Honor hc terminals under herdr; retire superseded status declarations

* no-mistakes(review): Retire stale declarations on any newer busy record

* no-mistakes(review): Drop report command; retire declarations on later inbox steers

* no-mistakes(review): Classify activity via busy lib; confirm reporter retirement

* no-mistakes(review): Order retirement by nanosecond times; drop pull-source turn guess

* no-mistakes(review): Retire declarations only on later steers, with stable thresholds

* no-mistakes(review): Drop probe cache; restore hc socket pinning in floor

* no-mistakes(review): Drop declared-wait mapping; report from single-source signals only

* no-mistakes(review): Give the watcher backend capture for pane-classified harnesses

* no-mistakes(document): Clarify OSC 7501 documentation ownership and Rex compatibility

* no-mistakes(review): Newline-delimit launch disarm; keep arm warnings visible

* no-mistakes(review): Require stand-in pidfile before checking disarm

* no-mistakes(review): Skip status-bridge records in Rex activity readers

* no-mistakes(ci): Fixed Cortex launch assertions mistaking the OSC reporter’s --config for an unsupported Cortex flag, including the sibling xhigh check. Reproduced failure before fix; Cortex suite, bash syntax, and diff checks pass afterward. Full suite failure was downstream of this test failure

* no-mistakes(ci): Removed active terminal capability queries, tty reads/mode changes, and the unused query timeout. Unknown terminals now silently no-op; passive detection remains. Updated docs and behavioral tests. Regression rejects pre-fix code; all 18 reporter tests, syntax checks, ShellCheck (excluding source-resolution notices), and diff checks pass

* no-mistakes(review): Exclude native codex and gate records on activity

* no-mistakes(review): Never write bridge records without known activity

* no-mistakes(review): Probe the launched binary for native reporters

* no-mistakes(review): Arm no reporter for raw launch commands

* no-mistakes(review): Report raw launches only with established agents

* no-mistakes(document): Consolidate OSC reporting documentation ownership

* no-mistakes(ci): Fixed standing captain holds to report blocked kind=question before activity fallback. Added behavioral coverage for idle/busy holds and supersession; confirmed regression fails before the fix and full OSC suite passes afterward. Shell syntax and diff checks passed

* no-mistakes(ci): Fixed the flaky startup-teardown fixture in tests/fm-watcher-lock.test.sh: replace racing recursive deletion with a checked atomic rename, retaining the old inode. Full suite failure was downstream of this shard failure. Complete watcher-lock suite, shell syntax, and git diff checks passed locally

* fix(osc7501): keep the bridge's own record honest when activity reads unknown

The unknown-activity silence that protected a native writer's root record
also left the bridge's own working/blocked on the pane forever - including
past the agent's exit, which never emitted its final record. While the
bridge's last write still stands, the durable signals now keep it honest:
they fold the same way with idle activity and the result is written once
per change, with no hold and no heartbeat. A watcher that never wrote
still stays silent so a native owner is never touched. The final record
likewise lands whenever the bridge's last write stands, keeping done/error
and parking the rest at idle. Rovo and Antigravity, whose only activity
source resolves busy or unknown, thereby still reach idle, blocked, done,
and error. Arm also writes one idle record once every gate passes, clearing
whatever a watcher that died without its final write left on the pane.

* no-mistakes(review): Carry arm-time ownership into watcher, trim osc_seq

* no-mistakes(document): Clarify OSC status lifecycle documentation

* fix(osc7501): park stale terminal lines and clear leftovers on unarmed relaunches

A done/failed status line carries the phase that wrote it, not the turn
now in flight: under unknown activity the fold now reports a terminal line
only when it was stamped at or after the reading that last proved the
worker busy, so an earlier phase's result parks at idle instead of
displaying done or error for a whole turn. A same-second stamp still
counts - a truly older line can never coincide with the last busy reading.

arm's residue clear now runs once the pane's terminal proves 7501-aware
and a leftover pidfile marks the record as the bridge's own, before the
config and native gates - so off and native relaunches retire a dead
watcher's record too, while panes that never armed still see no bytes.

* no-mistakes(review): Order stale results by append; keep result at exit

* no-mistakes(document): Clarify OSC status reporting documentation

* no-mistakes(ci): Replaced the version probe’s unbounded TERM/wait loop with shared fm_run_timed process-group termination and KILL escalation. Added a regression proving worker launch proceeds despite a TERM-resistant probe and descendant; reproduced failure before the fix. All 31 OSC tests pass, including the regression with the bash timeout fallback. Shell syntax and git diff checks pass

* fix(osc7501): disarm writes the final record a dead watcher never could

fm-spawn runs disarm after the agent command returns, so a SIGKILLed
watchers pidfile is removed there - before the next launch ever sees it,
which left the dead watcher's working/blocked record standing on off and
native relaunches. disarm now writes that final record itself (idle,
keeping done/error, exactly osc_final's fold) when the pidfile names no
live reporter; the pidfile carries harness and kind so the write names
the right app= and folds decisions under the worker's real kind. The
real-order regression now exercises SIGKILL -> disarm -> off/native
relaunch.

* no-mistakes(review): Write final record when retirement kills watcher

* no-mistakes(review): Always write final record once retirement confirms

* no-mistakes(lint): Suppress intentional generated-script expansion warning

* feat(bin): add opt-in Linux container check for changed shell tests (#8148)

* feat(bin): add opt-in Linux container check for changed shell tests

* no-mistakes(review): Run Linux check as host user with git clone

* no-mistakes(review): Remove locally deleted files from Linux scratch copy

* no-mistakes(review): Use keep-id for podman in Linux test check

* no-mistakes(ci): Fixed the three selected review findings locally (nothing committed or pushed). ci-2: bin/fm-test-linux.sh now clones with --no-hardlinks, so the container cannot write the host object files. ci-3: tests/linux/Dockerfile now installs python3, nodejs and curl (tools the ordinary suites require); tests/fm-test-linux.test.sh container case adds a tools.test.sh fixture that runs python3, node and curl. ci-4: both the overlay check (line 100) and the prune check (line 104) treat [ -L ] as present; the same fixture commits a dangling symlink and asserts it survives in the container. Verified with FM_TEST_LINUX_CONTAINER=1 bash tests/fm-test-linux.test.sh on Docker: all 4 pass. Mutation check: removing the [ -L ] at line 104 turns the fixture red ("dangling link lost"). Removing it at line 100 alone does not, because the clone already carries committed symlinks; that check only matters for untracked dangling links, which has no fixture. The check stays opt-in

* feat(bin): accept a caller-supplied expected PR head in fm-pr-merge (#8157)

* feat(bin): accept a caller-supplied expected PR head

The merge path read the live head again and used that value for the forge
head match. A push after review could replace the tested commit.
--expected-head takes one full commit, refuses a different live head, and
sends that same value to GitHub, GitLab, and Forgejo.
Callers that omit it keep the live-head match.

Closes #8124

* no-mistakes(review): Drop no-op head pin; test authority and identity refusals

* no-mistakes(review): Inline merge head assignment

* fix(bin): re-arm supervision on Claude StopFailure so error-ended turns are not blind

A Claude turn that ends on an API error runs no Stop phase, so the
Stop-owned auto-arm never fired and the home had no watcher coverage
until external input (observed as 15h and 4.7h blind gaps). Claude
2.1.317 fires StopFailure for those turn ends and honors the same
asyncRewake/exit-2 rewake as Stop, verified live on a herdr-hosted
primary: the tracked auto-arm under StopFailure armed a real watcher,
delivered the queued wake as an unprompted turn, and the chained error
end was suppressed by the new per-cooldown rewake bound instead of
storming.

* no-mistakes(review): Pace StopFailure continuations instead of dropping

* no-mistakes(review): Recheck AFK and need after StopFailure pacing

* no-mistakes(document): Document StopFailure supervision continuity

* no-mistakes(ci): Normalized the validated StopFailure cooldown to base 10. Updated the behavioral pacing regression to use 08 after a cooldown marker exists; it failed before the fix and passes afterward. Full auto-arm test suite, Bash syntax checks, and git diff --check pass. Changes remain local; nothing published

* no-mistakes(ci): Fixed the watcher-lock test’s flaky STOP-and-scan synchronization by pausing at the lock-free poll sleep. Full watcher-lock suite, repeated focused regressions, Bash syntax, and diff checks pass. Full suite failure was downstream of the shard failure. Changes remain local; nothing published

* no-mistakes(document): Clarify StopFailure continuity documentation

---------

Co…
joergoss pushed a commit to joergoss/firstmate that referenced this pull request Nov 23, 2026
…red (kunchenguid#8159)

* Fixes kunchenguid#8154 record forced scout discards

* no-mistakes(review): keep discarded note across close-marker replay

* no-mistakes(review): assert discarded note on row body, not task id

* Fixes kunchenguid#8154 preserve reports on held scout cleanup

* no-mistakes(document): document forced scout discard in teardown docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Maintainer go-ahead: run the full CI suite on this outside pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants