Skip to content

fix(bin): route remaining large snapshot JSON through files instead of argv - #4008

Open
mihneamanolache wants to merge 5 commits into
kunchenguid:mainfrom
mihneamanolache:bugfix/fm-bearings-snapshot-argv-overflow
Open

mihneamanolache wants to merge 5 commits into
kunchenguid:mainfrom
mihneamanolache:bugfix/fm-bearings-snapshot-argv-overflow

Conversation

@mihneamanolache

Copy link
Copy Markdown

Intent

Filed 2026-09-01 and reproduced then. Priority 1, and it has sat queued a week because the fleet
kept having louder problems - which is itself the argument for fixing it now.

Bearings is completely blocked. /bearings in every mode - plain, file, and lavish - fails
before any field projection:

/usr/bin/jq: Argument list too long (bin/fm-fleet-snapshot.sh:611)
fm-fleet-snapshot: main inventory summary failed

Passing a reduced --fields list does not help, because the failure is upstream of projection.

Cause, already diagnosed: main_inventory_json() passes the entire backlog JSON and the entire
tasks JSON to jq as COMMAND-LINE arguments, via --argjson "$1" / --argjson "$2". Those blobs
land in argv, so once they exceed the kernel argument limit the exec simply fails.
data/backlog.md is now 129,785 bytes and this home carries 73 open captain holds, several with
long multi-sentence reasons. That is what crossed the threshold.

Why it matters more than one broken command. This is the single deterministic fleet-state
source the bearings skill mandates, and that skill explicitly forbids substituting a second reader.
So the failure removes the fleet's entire catch-up surface at exactly the moment the backlog is
large enough to need one. It is a threshold failure rather than a gradual one: it worked earlier
that day and now fails on every invocation until the backlog shrinks, and it will recur in any home
whose backlog grows.

There is an interim workaround - read state/*.meta, bin/fm-crew-state.sh per task, and the
backlog directly - but the skill deliberately prohibits that substitute and it must not become the
norm.

What Changed

  • fm-bearings-snapshot.sh now accumulates candidate open-PR rows in a mktemp JSONL file (cleaned up via an EXIT trap) and hands them to the model jq with --slurpfile, replacing the --argjson accumulator that put the whole PR inventory in argv.
  • fm-fleet-snapshot.sh gains a json_envelope_file helper plus a shared JQ_ENVELOPE_PRELUDE (envelope/member) so per-task components, parent-evidence bundles, and the unbounded status-log note travel to jq as named-key files (--slurpfile/--rawfile) rather than --argjson arguments; the prelude errors out on a transport that is not a single JSON object or that is missing a key instead of folding it to null.
  • task_json_lines and scout_report_lines now build rows into a file instead of a piped jq -s loop, so a failed record composition returns non-zero and aborts the snapshot instead of publishing a silently truncated tasks[]/scout_reports[]; parent evidence reconciliation and contradiction reads fail closed with per-task diagnostics, and the header documents that records are omitted only through disclosed bounds. Four tests cover large PR/decision inventories exceeding the per-argument limit and mid-inventory task and scout-report composition failures.

Risk Assessment

✅ Low: The change is a well-bounded argv-to-file transport migration whose durable fix I reproduced end to end (base commit both overflows jq argv and fail-opens with a task silently missing; HEAD renders the same 146 KB component correctly), every remaining --arg/--argjson in both scripts carries a bounded per-item scalar, the new envelope guard provably fails closed on empty or multi-value components, and the only findings are three informational polish/attribution items.

Testing

Built real FM_HOME fixtures matching the report (131,485-byte backlog, 73 long-reason captain holds, live crewmate metas/status logs, one registered secondmate home) and drove /bearings the way each mode does, on both the base and target commits. Base reproduces the reported failure on the argv transports this change removes: the PR-enrichment path exits 1 with jq: Argument list too long and no fleet state, and an oversized per-task component makes the snapshot exit 0 while silently omitting a live task from Underway and from the fleet-state inventory the bearings skill mandates. Target projects all of it completely with clean stderr (620 PR rows, 401-decision secondmate present, parked crewmate visible in Underway). I also ran the full owning suite tests/fm-bearings-snapshot.test.sh and the downstream tests/fm-fleet-snapshot-view.test.sh at target (all ok), and ran each of the 4 new tests against base scripts where all 4 fail, confirming they are real regressions. No visual artifact applies: the change is shell/JSON transport with no rendered surface, and the lavish board is composed downstream from the same --json step I exercised and is untouched by the diff. Worktree left clean; transient fixture scaffolding removed and only transcripts plus reproduction scripts kept in the evidence directory.

Evidence: Before/after CLI transcript: three argv-overflow scenarios plus base-vs-target verdicts for the 4 new tests

Source: Before/after CLI transcript: three argv-overflow scenarios plus base-vs-target verdicts for the 4 new tests

=======================================================================
/bearings argv-overflow reproduction - BEFORE (base b84e0e3) vs AFTER (target 6f64ebe)
Reproduced on Linux (MAX_ARG_STRLEN = 131072 bytes per single argument).
Every home below is a real FM_HOME on disk: data/backlog.md is 131,485 bytes
carrying 73 open captain holds with long multi-sentence reasons, plus live
crewmate metas/status logs and one registered local secondmate home.
=======================================================================

=======================================================================
SCENARIO A - "/bearings include PRs" over a 31-repo fleet home
  Documented expansion only: --include-prs --all-pr-repos, default
  FM_BEARINGS_PR_LIMIT=20, 20 open PRs per repo.
=======================================================================
--- BEFORE (base b84e0e3) ---
$ bin/fm-bearings-snapshot.sh --include-prs --all-pr-repos --json
  /tmp/fm-argv-repro/base/bin/fm-bearings-snapshot.sh: line 279: /usr/bin/jq: Argument list too long
  jq: invalid JSON text passed to --argjson
  Use jq --help for help with command-line options,
  or see the jq manpage, or online docs  at https://jqlang.github.io/jq
  jq: invalid JSON text passed to --argjson
  exit: 1   stdout bytes: 0   -> the captain gets no fleet state at all

--- AFTER (target 6f64ebe) ---
$ bin/fm-bearings-snapshot.sh --include-prs --all-pr-repos --json
  stderr: (empty)
  exit: 0
  {"prs":"checked (31 repos, 620 open)","candidate_prs":620,"first_row":{"num":"1","repo":"kunchenguid/service-1","task":"fleet-transport-1","url":"https://github.com/kunchenguid/firstmate/pull/1","review":"","mergeable":"MERGEABLE","checks":"passing"},"last_row":{"num":"20","repo":"kunchenguid/firstmate","task":"fleet-transport-20","url":"https://github.com/kunchenguid/firstmate/pull/20","review":"","mergeable":"MERGEABLE","checks":"passing"}}

=======================================================================
SCENARIO C - plain "/bearings" in a home with a parked crewmate that has
  accumulated 520 keyed open captain decisions (state/ship-parked.status
  is 124 KB; its open-decision component serializes to ~137 KB).
  This is the silent-loss case: exit 0, but the crewmate waiting on the
  captain disappears from the captain-facing Underway section.
=======================================================================
--- BEFORE (base b84e0e3) ---
$ bin/fm-bearings-snapshot.sh --fields home,in_flight,decisions_open
  stderr: /tmp/fm-argv-repro/base/bin/fm-fleet-snapshot.sh: line 802: /usr/bin/jq: Argument list too long
  exit: 0
  in_flight[3]{id,kind,state,repo,doing}:
    scout-x,scout,done,firstmate,"report ready for the captain, the failure reproduces on every invocation"
    ship-task,ship,working,firstmate,harness busy (claude-hook)
    mate/mate,ship,working,firstmate,harness busy (claude-hook)
  secondmates[1]{id,state,doing,provenance,freshness,age_seconds,contradiction,reason}:

--- AFTER (target 6f64ebe) ---
$ bin/fm-bearings-snapshot.sh --fields home,in_flight,decisions_open
  stderr: (empty)
  exit: 0
  in_flight[4]{id,kind,state,repo,doing}:
    scout-x,scout,done,firstmate,"report ready for the captain, the failure reproduces on every invocation"
    ship-parked,ship,paused,firstmate,parked waiting on the captain to pick a route
    ship-task,ship,working,firstmate,harness busy (claude-hook)
    mate/mate,ship,working,firstmate,harness busy (claude-hook)

=======================================================================
SCENARIO B - the same class on the deterministic fleet-state source the
  bearings skill mandates: a persistent secondmate stream carrying 401
  keyed open captain decisions (state/mate.status is 122 KB).
=======================================================================
--- BEFORE (base b84e0e3) ---
$ bin/fm-fleet-snapshot.sh --json
  stderr: /tmp/fm-argv-repro/base/bin/fm-fleet-snapshot.sh: line 802: /usr/bin/jq: Argument list too long
  exit: 0
  tasks[] inventory: scout-x, ship-task
  task "mate" open captain decisions: TASK MISSING FROM INVENTORY

--- AFTER (target 6f64ebe) ---
$ bin/fm-fleet-snapshot.sh --json
  stderr: (empty)
  exit: 0
  tasks[] inventory: mate, scout-x, ship-task
  task "mate" open captain decisions: 401

=======================================================================
REGRESSION TESTS - tests/fm-bearings-snapshot.test.sh (the 4 cases this
  change adds), run against the BASE scripts and the TARGET scripts.
=======================================================================
  base b84e0e3   not ok - large candidate PR fixture did not exceed the per-argument limit
  base b84e0e3   not ok - large task-decision component did not exceed the per-argument limit
  base b84e0e3   not ok - a failed task component published an exit-0 snapshot
  base b84e0e3   not ok - a failed scout-report record published an exit-0 snapshot

  target 6f64ebe ok - large candidate PR inventories avoid argument transport
  target 6f64ebe ok - large task-decision inventories avoid argument transport
  target 6f64ebe ok - a failed per-task component fails the snapshot instead of dropping tasks
  target 6f64ebe ok - a failed scout-report record fails the snapshot instead of dropping reports
Evidence: /bearings on the reproduced reported home at the target commit - plain, reduced --fields, --json, --include-prs

Source: /bearings on the reproduced reported home at the target commit - plain, reduced --fields, --json, --include-prs

# /bearings on a faithful rebuild of the reported home, TARGET commit 6f64ebe.
# data/backlog.md = 131,485 bytes, 73 open captain holds with long multi-sentence
# reasons, 3 live tasks, 1 registered local secondmate home.
# Covers every mode's entry point: plain (TOON digest), a reduced --fields list,
# --json (the single step file mode and lavish mode both start from), and
# --include-prs.

===== home under test =====
FM_HOME=/tmp/fm-argv-repro/home-report
data/backlog.md: 131485 bytes, 73 open captain holds
tasks: 3

===== /bearings (plain mode) -> bin/fm-bearings-snapshot.sh =====
schema: fm-bearings.v1
home: fm-argv-repro/home-report
generated: "2026-09-08T12:00:00Z"
prs: "not_requested (run: /bearings include PRs)"
in_flight[3]{id,kind,state,repo,doing}:
  scout-x,scout,done,firstmate,"report ready for the captain, the failure reproduces on every invocation"
  ship-task,ship,working,firstmate,harness busy (claude-hook)
  mate/mate,ship,working,firstmate,harness busy (claude-hook)
secondmates[1]{id,state,doing,provenance,freshness,age_seconds,contradiction,reason}:
  mate,captain_decision,Choose subscription order,structured-home,fresh,0,true,"-"
secondmate_reconcile[1]{id,spawn_gen,host,kind,ids}:
  mate,null,null,null,"[]"
decisions_open[20]{id,key,verb,summary,owner}:
  hold-01,hold-01,captain-hold,"Captain decision 01 on fleet route 01: the captain has to choose between keeping the curre…",(main)
  hold-02,hold-02,captain-hold,"Captain decision 02 on fleet route 02: the captain has to choose between keeping the curre…",(main)
  hold-03,hold-03,captain-hold,"Captain decision 03 on fleet route 03: the captain has to choose between keeping the curre…",(main)
  hold-04,hold-04,captain-hold,"Captain decision 04 on fleet route 04: the captain has to choose between keeping the curre…",(main)
  hold-05,hold-05,captain-hold,"Captain decision 05 on fleet route 05: the captain has to choose between keeping the curre…",(main)
  hold-06,hold-06,captain-hold,"Captain decision 06 on fleet route 06: the captain has to choose between keeping the curre…",(main)
  hold-07,hold-07,captain-hold,"Captain decision 07 on fleet route 07: the captain has to choose between keeping the curre…",(main)
  hold-08,hold-08,captain-hold,"Captain decision 08 on fleet route 08: the captain has to choose between keeping the curre…",(main)
  hold-09,hold-09,captain-hold,"Captain decision 09 on fleet route 09: the captain has to choose between keeping the curre…",(main)
  hold-10,hold-10,captain-hold,"Captain decision 10 on fleet route 10: the captain has to choose between keeping the curre…",(main)
  hold-11,hold-11,captain-hold,"Captain decision 11 on fleet route 11: the captain has to choose between keeping the curre…",(main)
  hold-12,hold-12,captain-hold,"Captain decision 12 on fleet route 12: the captain has to choose between keeping the curre…",(main)
  hold-13,hold-13,captain-hold,"Captain decision 13 on fleet route 13: the captain has to choose between keeping the curre…",(main)
  hold-14,hold-14,captain-hold,"Captain decision 14 on fleet route 14: the captain has to choose between keeping the curre…",(main)
  hold-15,hold-15,captain-hold,"Captain decision 15 on fleet route 15: the captain has to choose between keeping the curre…",(main)
  hold-16,hold-16,captain-hold,"Captain decision 16 on fleet route 16: the captain has to choose between keeping the curre…",(main)
  hold-17,hold-17,captain-hold,"Captain decision 17 on fleet route 17: the captain has to choose between keeping the curre…",(main)
  hold-18,hold-18,captain-hold,"Captain decision 18 on fleet route 18: the captain has to choose between keeping the curre…",(main)
  hold-19,hold-19,captain-hold,"Captain decision 19 on fleet route 19: the captain has to choose between keeping the curre…",(main)
  hold-20,hold-20,captain-hold,"Captain decision 20 on fleet route 20: the captain has to choose between keeping the curre…",(main)
landed[6]{id,what,artifact,owner}:
  done-083,Landed fleet work 083,"https://github.com/kunchenguid/firstmate/pull/3083",(main)
  mate-landed,Secondmate-managed fix,"https://github.com/kunchenguid/firstmate/pull/50",mate
  done-055,Landed fleet work 055,"https://github.com/kunchenguid/firstmate/pull/3055",(main)
  done-027,Landed fleet work 027,"https://github.com/kunchenguid/firstmate/pull/3027",(main)
  done-082,Landed fleet work 082,"https://github.com/kunchenguid/firstmate/pull/3082",(main)
  done-054,Landed fleet work 054,"https://github.com/kunchenguid/firstmate/pull/3054",(main)
gates[20]{id,title,blocked_by,reason,owner}:
  queued-001,Queued fleet work 001,ship-task,"-",(main)
  queued-002,Queued fleet work 002,ship-task,"-",(main)
  queued-003,Queued fleet work 003,ship-task,"-",(main)
  queued-004,Queued fleet work 004,ship-task,"-",(main)
  queued-005,Queued fleet work 005,ship-task,"-",(main)
  queued-006,Queued fleet work 006,ship-task,"-",(main)
  queued-007,Queued fleet work 007,ship-task,"-",(main)
  queued-008,Queued fleet work 008,ship-task,"-",(main)
  queued-009,Queued fleet work 009,ship-task,"-",(main)
  queued-010,Queued fleet work 010,ship-task,"-",(main)
  queued-011,Queued fleet work 011,ship-task,"-",(main)
  queued-012,Queued fleet work 012,ship-task,"-",(main)
  queued-013,Queued fleet work 013,ship-task,"-",(main)
  queued-014,Queued fleet work 014,ship-task,"-",(main)
  queued-015,Queued fleet work 015,ship-task,"-",(main)
  queued-016,Queued fleet work 016,ship-task,"-",(main)
  queued-017,Queued fleet work 017,ship-task,"-",(main)
  queued-018,Queued fleet work 018,ship-task,"-",(main)
  queued-019,Queued fleet work 019,ship-task,"-",(main)
  queued-020,Queued fleet work 020,ship-task,"-",(main)
reports[1]{id,path}:
  scout-x,/tmp/fm-argv-repro/home-report/data/scout-x/report.md
recorded_prs[1]{id,url}:
  ship-task,"https://github.com/kunchenguid/firstmate/pull/9"
unhealthy_endpoints[1]{id,backend,target,exists,agent}:
  mate,tmux,"firstmate:fm-mate",true,dead
omitted[10]{surface,reveal}:
  backlog item bodies,"--fields bodies"
  task paths,"--fields paths"
  watch/steer actions,"--fields actions"
  healthy endpoint detail,"--fields endpoints"
  full scout-report inventory,"--all-reports"
  landed showing 6 of 7 (incl. 1 secondmate home(s)),"--all-landed"
  landed per-home capped at 6 for 1 home(s),"--all-landed"
  decisions_open showing 20 of 74,"--all-decisions"
  gates showing 20 of 90,"--all-queued"
  live PR discovery + checks,"--include-prs"
exit=0

===== /bearings with a reduced --fields list =====
schema: fm-bearings.v1
home: fm-argv-repro/home-report
generated: "2026-09-08T12:00:00Z"
prs: "not_requested (run: /bearings include PRs)"
in_flight[3]{id,kind,state,repo,doing}:
  scout-x,scout,done,firstmate,"report ready for the captain, the failure reproduces on every invocation"
  ship-task,ship,working,firstmate,harness busy (claude-hook)
  mate/mate,ship,working,firstmate,harness busy (claude-hook)
secondmates[1]{id,state,doing,provenance,freshness,age_seconds,contradiction,reason}:
  mate,captain_decision,Choose subscription order,structured-home,fresh,0,true,"-"
secondmate_reconcile[1]{id,spawn_gen,host,kind,ids}:
  mate,null,null,null,"[]"
decisions_open[20]{id,key,verb,summary,owner}:
  hold-01,hold-01,captain-hold,"Captain decision 01 on fleet route 01: the captain has to choose between keeping the curre…",(main)
  hold-02,hold-02,captain-hold,"Captain decision 02 on fleet route 02: the captain has to choose between keeping the curre…",(main)
  hold-03,hold-03,captain-hold,"Captain decision 03 on fleet route 03: the captain has to choose between keeping the curre…",(main)
  hold-04,hold-04,captain-hold,"Captain decision 04 on fleet route 04: the captain has to choose between keeping the curre…",(main)
  hold-05,hold-05,captain-hold,"Captain decision 05 on fleet route 05: the captain has to choose between keeping the curre…",(main)
  hold-06,hold-06,captain-hold,"Captain decision 06 on fleet route 06: the captain has to choose between keeping the curre…",(main)
  hold-07,hold-07,captain-hold,"Captain decision 07 on fleet route 07: the captain has to choose between keeping the curre…",(main)
  hold-08,hold-08,captain-hold,"Captain decision 08 on fleet route 08: the captain has to choose between keeping the curre…",(main)
  hold-09,hold-09,captain-hold,"Captain decision 09 on fleet route 09: the captain has to choose between keeping the curre…",(main)
  hold-10,hold-10,captain-hold,"Captain decision 10 on fleet route 10: the captain has to choose between keeping the curre…",(main)
  hold-11,hold-11,captain-hold,"Captain decision 11 on fleet route 11: the captain has to choose between keeping the curre…",(main)
  hold-12,hold-12,captain-hold,"Captain decision 12 on fleet route 12: the captain has to choose between keeping the curre…",(main)
  hold-13,hold-13,captain-hold,"Captain decision 13 on fleet route 13: the captain has to choose between keeping the curre…",(main)
  hold-14,hold-14,captain-hold,"Captain decision 14 on fleet route 14: the captain has to choose between keeping the curre…",(main)
  hold-15,hold-15,captain-hold,"Captain decision 15 on fleet route 15: the captain has to choose between keeping the curre…",(main)
  hold-16,hold-16,captain-hold,"Captain decision 16 on fleet route 16: the captain has to choose between keeping the curre…",(main)
  hold-17,hold-17,captain-hold,"Captain decision 17 on fleet route 17: the captain has to choose between keeping the curre…",(main)
  hold-18,hold-18,captain-hold,"Captain decision 18 on fleet route 18: the captain has to choose between keeping the curre…",(main)
  hold-19,hold-19,captain-hold,"Captain decision 19 on fleet route 19: the captain has to choose between keeping the curre…",(main)
  hold-20,hold-20,captain-hold,"Captain decision 20 on fleet route 20: the captain has to choose between keeping the curre…",(main)
landed[6]{id,what,artifact,owner}:
  done-083,Landed fleet work 083,"https://github.com/kunchenguid/firstmate/pull/3083",(main)
  mate-landed,Secondmate-managed fix,"https://github.com/kunchenguid/firstmate/pull/50",mate
  done-055,Landed fleet work 055,"https://github.com/kunchenguid/firstmate/pull/3055",(main)
  done-027,Landed fleet work 027,"https://github.com/kunchenguid/firstmate/pull/3027",(main)
  done-082,Landed fleet work 082,"https://github.com/kunchenguid/firstmate/pull/3082",(main)
  done-054,Landed fleet work 054,"https://github.com/kunchenguid/firstmate/pull/3054",(main)
gates[20]{id,title,blocked_by,reason,owner}:
  queued-001,Queued fleet work 001,ship-task,"-",(main)
  queued-002,Queued fleet work 002,ship-task,"-",(main)
  queued-003,Queued fleet work 003,ship-task,"-",(main)
  queued-004,Queued fleet work 004,ship-task,"-",(main)
  queued-005,Queued fleet work 005,ship-task,"-",(main)
  queued-006,Queued fleet work 006,ship-task,"-",(main)
  queued-007,Queued fleet work 007,ship-task,"-",(main)
  queued-008,Queued fleet work 008,ship-task,"-",(main)
  queued-009,Queued fleet work 009,ship-task,"-",(main)
  queued-010,Queued fleet work 010,ship-task,"-",(main)
  queued-011,Queued fleet work 011,ship-task,"-",(main)
  queued-012,Queued fleet work 012,ship-task,"-",(main)
  queued-013,Queued fleet work 013,ship-task,"-",(main)
  queued-014,Queued fleet work 014,ship-task,"-",(main)
  queued-015,Queued fleet work 015,ship-task,"-",(main)
  queued-016,Queued fleet work 016,ship-task,"-",(main)
  queued-017,Queued fleet work 017,ship-task,"-",(main)
  queued-018,Queued fleet work 018,ship-task,"-",(main)
  queued-019,Queued fleet work 019,ship-task,"-",(main)
  queued-020,Queued fleet work 020,ship-task,"-",(main)
reports[1]{id,path}:
  scout-x,/tmp/fm-argv-repro/home-report/data/scout-x/report.md
recorded_prs[1]{id,url}:
  ship-task,"https://github.com/kunchenguid/firstmate/pull/9"
unhealthy_endpoints[1]{id,backend,target,exists,agent}:
  mate,tmux,"firstmate:fm-mate",true,dead
omitted[10]{surface,reveal}:
  backlog item bodies,"--fields bodies"
  task paths,"--fields paths"
  watch/steer actions,"--fields actions"
  healthy endpoint detail,"--fields endpoints"
  full scout-report inventory,"--all-reports"
  landed showing 6 of 7 (incl. 1 secondmate home(s)),"--all-landed"
  landed per-home capped at 6 for 1 home(s),"--all-landed"
  decisions_open showing 20 of 74,"--all-decisions"
  gates showing 20 of 90,"--all-queued"
  live PR discovery + checks,"--include-prs"
exit=0

===== /bearings file + lavish mode step 1 -> bin/fm-bearings-snapshot.sh --json =====
exit=0 bytes=11290
{
  "schema": "fm-bearings.v1",
  "home": "fm-argv-repro/home-report",
  "in_flight": 3,
  "decisions_open": 20,
  "gates": 20,
  "landed": 6,
  "reports": 1,
  "secondmates": 1,
  "omitted": 10
}
first three Captain's Call rows:
{"id":"hold-01","key":"hold-01","verb":"captain-hold","summary":"Captain decision 01 on fleet route 01: the captain has to choose between keeping the curre…","owner":"(main)"}
{"id":"hold-02","key":"hold-02","verb":"captain-hold","summary":"Captain decision 02 on fleet route 02: the captain has to choose between keeping the curre…","owner":"(main)"}
{"id":"hold-03","key":"hold-03","verb":"captain-hold","summary":"Captain decision 03 on fleet route 03: the captain has to choose between keeping the curre…","owner":"(main)"}
secondmate row:
{"id":"mate","state":"captain_decision","doing":"Choose subscription order","provenance":"structured-home","freshness":"fresh","age_seconds":0,"contradiction":true,"reason":"-"}

===== /bearings include PRs -> bin/fm-bearings-snapshot.sh --include-prs --json =====
exit=0
{
  "prs": "checked (1 repos, 60 open)",
  "candidate_prs": 60
}
Evidence: Same mode sweep at the base commit (honest context: that home's plain path already survives on base after #3677)

Source: Same mode sweep at the base commit (honest context: that home's plain path already survives on base after #3677)

# The same runs against the BASE commit b84e0e3, for honest context: base already
# carries the backlog/tasks file transport (#3677), so this particular home no
# longer reproduces the reported crash on the plain path. The remaining argv
# transports this change removes still fail on base - see bearings-before-after.txt.

===== home under test =====
FM_HOME=/tmp/fm-argv-repro/home-report-base
data/backlog.md: 131485 bytes, 73 open captain holds
tasks: 3

===== /bearings (plain mode) -> bin/fm-bearings-snapshot.sh =====
schema: fm-bearings.v1
home: fm-argv-repro/home-report-base
generated: "2026-09-08T12:00:00Z"
prs: "not_requested (run: /bearings include PRs)"
in_flight[3]{id,kind,state,repo,doing}:
  scout-x,scout,done,firstmate,"report ready for the captain, the failure reproduces on every invocation"
  ship-task,ship,working,firstmate,harness busy (claude-hook)
  mate/mate,ship,working,firstmate,harness busy (claude-hook)
secondmates[1]{id,state,doing,provenance,freshness,age_seconds,contradiction,reason}:
  mate,captain_decision,Choose subscription order,structured-home,fresh,0,true,"-"
secondmate_reconcile[1]{id,spawn_gen,host,kind,ids}:
  mate,null,null,null,"[]"
decisions_open[20]{id,key,verb,summary,owner}:
  hold-01,hold-01,captain-hold,"Captain decision 01 on fleet route 01: the captain has to choose between keeping the curre…",(main)
  hold-02,hold-02,captain-hold,"Captain decision 02 on fleet route 02: the captain has to choose between keeping the curre…",(main)
  hold-03,hold-03,captain-hold,"Captain decision 03 on fleet route 03: the captain has to choose between keeping the curre…",(main)
  hold-04,hold-04,captain-hold,"Captain decision 04 on fleet route 04: the captain has to choose between keeping the curre…",(main)
  hold-05,hold-05,captain-hold,"Captain decision 05 on fleet route 05: the captain has to choose between keeping the curre…",(main)
  hold-06,hold-06,captain-hold,"Captain decision 06 on fleet route 06: the captain has to choose between keeping the curre…",(main)
  hold-07,hold-07,captain-hold,"Captain decision 07 on fleet route 07: the captain has to choose between keeping the curre…",(main)
  hold-08,hold-08,captain-hold,"Captain decision 08 on fleet route 08: the captain has to choose between keeping the curre…",(main)
  hold-09,hold-09,captain-hold,"Captain decision 09 on fleet route 09: the captain has to choose between keeping the curre…",(main)
  hold-10,hold-10,captain-hold,"Captain decision 10 on fleet route 10: the captain has to choose between keeping the curre…",(main)
  hold-11,hold-11,captain-hold,"Captain decision 11 on fleet route 11: the captain has to choose between keeping the curre…",(main)
  hold-12,hold-12,captain-hold,"Captain decision 12 on fleet route 12: the captain has to choose between keeping the curre…",(main)
  hold-13,hold-13,captain-hold,"Captain decision 13 on fleet route 13: the captain has to choose between keeping the curre…",(main)
  hold-14,hold-14,captain-hold,"Captain decision 14 on fleet route 14: the captain has to choose between keeping the curre…",(main)
  hold-15,hold-15,captain-hold,"Captain decision 15 on fleet route 15: the captain has to choose between keeping the curre…",(main)
  hold-16,hold-16,captain-hold,"Captain decision 16 on fleet route 16: the captain has to choose between keeping the curre…",(main)
  hold-17,hold-17,captain-hold,"Captain decision 17 on fleet route 17: the captain has to choose between keeping the curre…",(main)
  hold-18,hold-18,captain-hold,"Captain decision 18 on fleet route 18: the captain has to choose between keeping the curre…",(main)
  hold-19,hold-19,captain-hold,"Captain decision 19 on fleet route 19: the captain has to choose between keeping the curre…",(main)
  hold-20,hold-20,captain-hold,"Captain decision 20 on fleet route 20: the captain has to choose between keeping the curre…",(main)
landed[6]{id,what,artifact,owner}:
  done-083,Landed fleet work 083,"https://github.com/kunchenguid/firstmate/pull/3083",(main)
  mate-landed,Secondmate-managed fix,"https://github.com/kunchenguid/firstmate/pull/50",mate
  done-055,Landed fleet work 055,"https://github.com/kunchenguid/firstmate/pull/3055",(main)
  done-027,Landed fleet work 027,"https://github.com/kunchenguid/firstmate/pull/3027",(main)
  done-082,Landed fleet work 082,"https://github.com/kunchenguid/firstmate/pull/3082",(main)
  done-054,Landed fleet work 054,"https://github.com/kunchenguid/firstmate/pull/3054",(main)
gates[20]{id,title,blocked_by,reason,owner}:
  queued-001,Queued fleet work 001,ship-task,"-",(main)
  queued-002,Queued fleet work 002,ship-task,"-",(main)
  queued-003,Queued fleet work 003,ship-task,"-",(main)
  queued-004,Queued fleet work 004,ship-task,"-",(main)
  queued-005,Queued fleet work 005,ship-task,"-",(main)
  queued-006,Queued fleet work 006,ship-task,"-",(main)
  queued-007,Queued fleet work 007,ship-task,"-",(main)
  queued-008,Queued fleet work 008,ship-task,"-",(main)
  queued-009,Queued fleet work 009,ship-task,"-",(main)
  queued-010,Queued fleet work 010,ship-task,"-",(main)
  queued-011,Queued fleet work 011,ship-task,"-",(main)
  queued-012,Queued fleet work 012,ship-task,"-",(main)
  queued-013,Queued fleet work 013,ship-task,"-",(main)
  queued-014,Queued fleet work 014,ship-task,"-",(main)
  queued-015,Queued fleet work 015,ship-task,"-",(main)
  queued-016,Queued fleet work 016,ship-task,"-",(main)
  queued-017,Queued fleet work 017,ship-task,"-",(main)
  queued-018,Queued fleet work 018,ship-task,"-",(main)
  queued-019,Queued fleet work 019,ship-task,"-",(main)
  queued-020,Queued fleet work 020,ship-task,"-",(main)
reports[1]{id,path}:
  scout-x,/tmp/fm-argv-repro/home-report-base/data/scout-x/report.md
recorded_prs[1]{id,url}:
  ship-task,"https://github.com/kunchenguid/firstmate/pull/9"
unhealthy_endpoints[1]{id,backend,target,exists,agent}:
  mate,tmux,"firstmate:fm-mate",true,dead
omitted[10]{surface,reveal}:
  backlog item bodies,"--fields bodies"
  task paths,"--fields paths"
  watch/steer actions,"--fields actions"
  healthy endpoint detail,"--fields endpoints"
  full scout-report inventory,"--all-reports"
  landed showing 6 of 7 (incl. 1 secondmate home(s)),"--all-landed"
  landed per-home capped at 6 for 1 home(s),"--all-landed"
  decisions_open showing 20 of 74,"--all-decisions"
  gates showing 20 of 90,"--all-queued"
  live PR discovery + checks,"--include-prs"
exit=0

===== /bearings with a reduced --fields list =====
schema: fm-bearings.v1
home: fm-argv-repro/home-report-base
generated: "2026-09-08T12:00:00Z"
prs: "not_requested (run: /bearings include PRs)"
in_flight[3]{id,kind,state,repo,doing}:
  scout-x,scout,done,firstmate,"report ready for the captain, the failure reproduces on every invocation"
  ship-task,ship,working,firstmate,harness busy (claude-hook)
  mate/mate,ship,working,firstmate,harness busy (claude-hook)
secondmates[1]{id,state,doing,provenance,freshness,age_seconds,contradiction,reason}:
  mate,captain_decision,Choose subscription order,structured-home,fresh,0,true,"-"
secondmate_reconcile[1]{id,spawn_gen,host,kind,ids}:
  mate,null,null,null,"[]"
decisions_open[20]{id,key,verb,summary,owner}:
  hold-01,hold-01,captain-hold,"Captain decision 01 on fleet route 01: the captain has to choose between keeping the curre…",(main)
  hold-02,hold-02,captain-hold,"Captain decision 02 on fleet route 02: the captain has to choose between keeping the curre…",(main)
  hold-03,hold-03,captain-hold,"Captain decision 03 on fleet route 03: the captain has to choose between keeping the curre…",(main)
  hold-04,hold-04,captain-hold,"Captain decision 04 on fleet route 04: the captain has to choose between keeping the curre…",(main)
  hold-05,hold-05,captain-hold,"Captain decision 05 on fleet route 05: the captain has to choose between keeping the curre…",(main)
  hold-06,hold-06,captain-hold,"Captain decision 06 on fleet route 06: the captain has to choose between keeping the curre…",(main)
  hold-07,hold-07,captain-hold,"Captain decision 07 on fleet route 07: the captain has to choose between keeping the curre…",(main)
  hold-08,hold-08,captain-hold,"Captain decision 08 on fleet route 08: the captain has to choose between keeping the curre…",(main)
  hold-09,hold-09,captain-hold,"Captain decision 09 on fleet route 09: the captain has to choose between keeping the curre…",(main)
  hold-10,hold-10,captain-hold,"Captain decision 10 on fleet route 10: the captain has to choose between keeping the curre…",(main)
  hold-11,hold-11,captain-hold,"Captain decision 11 on fleet route 11: the captain has to choose between keeping the curre…",(main)
  hold-12,hold-12,captain-hold,"Captain decision 12 on fleet route 12: the captain has to choose between keeping the curre…",(main)
  hold-13,hold-13,captain-hold,"Captain decision 13 on fleet route 13: the captain has to choose between keeping the curre…",(main)
  hold-14,hold-14,captain-hold,"Captain decision 14 on fleet route 14: the captain has to choose between keeping the curre…",(main)
  hold-15,hold-15,captain-hold,"Captain decision 15 on fleet route 15: the captain has to choose between keeping the curre…",(main)
  hold-16,hold-16,captain-hold,"Captain decision 16 on fleet route 16: the captain has to choose between keeping the curre…",(main)
  hold-17,hold-17,captain-hold,"Captain decision 17 on fleet route 17: the captain has to choose between keeping the curre…",(main)
  hold-18,hold-18,captain-hold,"Captain decision 18 on fleet route 18: the captain has to choose between keeping the curre…",(main)
  hold-19,hold-19,captain-hold,"Captain decision 19 on fleet route 19: the captain has to choose between keeping the curre…",(main)
  hold-20,hold-20,captain-hold,"Captain decision 20 on fleet route 20: the captain has to choose between keeping the curre…",(main)
landed[6]{id,what,artifact,owner}:
  done-083,Landed fleet work 083,"https://github.com/kunchenguid/firstmate/pull/3083",(main)
  mate-landed,Secondmate-managed fix,"https://github.com/kunchenguid/firstmate/pull/50",mate
  done-055,Landed fleet work 055,"https://github.com/kunchenguid/firstmate/pull/3055",(main)
  done-027,Landed fleet work 027,"https://github.com/kunchenguid/firstmate/pull/3027",(main)
  done-082,Landed fleet work 082,"https://github.com/kunchenguid/firstmate/pull/3082",(main)
  done-054,Landed fleet work 054,"https://github.com/kunchenguid/firstmate/pull/3054",(main)
gates[20]{id,title,blocked_by,reason,owner}:
  queued-001,Queued fleet work 001,ship-task,"-",(main)
  queued-002,Queued fleet work 002,ship-task,"-",(main)
  queued-003,Queued fleet work 003,ship-task,"-",(main)
  queued-004,Queued fleet work 004,ship-task,"-",(main)
  queued-005,Queued fleet work 005,ship-task,"-",(main)
  queued-006,Queued fleet work 006,ship-task,"-",(main)
  queued-007,Queued fleet work 007,ship-task,"-",(main)
  queued-008,Queued fleet work 008,ship-task,"-",(main)
  queued-009,Queued fleet work 009,ship-task,"-",(main)
  queued-010,Queued fleet work 010,ship-task,"-",(main)
  queued-011,Queued fleet work 011,ship-task,"-",(main)
  queued-012,Queued fleet work 012,ship-task,"-",(main)
  queued-013,Queued fleet work 013,ship-task,"-",(main)
  queued-014,Queued fleet work 014,ship-task,"-",(main)
  queued-015,Queued fleet work 015,ship-task,"-",(main)
  queued-016,Queued fleet work 016,ship-task,"-",(main)
  queued-017,Queued fleet work 017,ship-task,"-",(main)
  queued-018,Queued fleet work 018,ship-task,"-",(main)
  queued-019,Queued fleet work 019,ship-task,"-",(main)
  queued-020,Queued fleet work 020,ship-task,"-",(main)
reports[1]{id,path}:
  scout-x,/tmp/fm-argv-repro/home-report-base/data/scout-x/report.md
recorded_prs[1]{id,url}:
  ship-task,"https://github.com/kunchenguid/firstmate/pull/9"
unhealthy_endpoints[1]{id,backend,target,exists,agent}:
  mate,tmux,"firstmate:fm-mate",true,dead
omitted[10]{surface,reveal}:
  backlog item bodies,"--fields bodies"
  task paths,"--fields paths"
  watch/steer actions,"--fields actions"
  healthy endpoint detail,"--fields endpoints"
  full scout-report inventory,"--all-reports"
  landed showing 6 of 7 (incl. 1 secondmate home(s)),"--all-landed"
  landed per-home capped at 6 for 1 home(s),"--all-landed"
  decisions_open showing 20 of 74,"--all-decisions"
  gates showing 20 of 90,"--all-queued"
  live PR discovery + checks,"--include-prs"
exit=0

===== /bearings file + lavish mode step 1 -> bin/fm-bearings-snapshot.sh --json =====
exit=0 bytes=11300
{
  "schema": "fm-bearings.v1",
  "home": "fm-argv-repro/home-report-base",
  "in_flight": 3,
  "decisions_open": 20,
  "gates": 20,
  "landed": 6,
  "reports": 1,
  "secondmates": 1,
  "omitted": 10
}
first three Captain's Call rows:
{"id":"hold-01","key":"hold-01","verb":"captain-hold","summary":"Captain decision 01 on fleet route 01: the captain has to choose between keeping the curre…","owner":"(main)"}
{"id":"hold-02","key":"hold-02","verb":"captain-hold","summary":"Captain decision 02 on fleet route 02: the captain has to choose between keeping the curre…","owner":"(main)"}
{"id":"hold-03","key":"hold-03","verb":"captain-hold","summary":"Captain decision 03 on fleet route 03: the captain has to choose between keeping the curre…","owner":"(main)"}
secondmate row:
{"id":"mate","state":"captain_decision","doing":"Choose subscription order","provenance":"structured-home","freshness":"fresh","age_seconds":0,"contradiction":true,"reason":"-"}

===== /bearings include PRs -> bin/fm-bearings-snapshot.sh --include-prs --json =====
exit=0
{
  "prs": "checked (1 repos, 60 open)",
  "candidate_prs": 60
}
- Evidence: [Reproduction fixture generator for the reported home (backlog size, captain holds, tasks, secondmate, gh fake)](https://github.com/mihneamanolache/firstmate/blob/8b675db9421842ddd9bac1884ed05021422158e4/.no-mistakes/evidence/bugfix/fm-bearings-snapshot-argv-overflow/make-home.sh) - Evidence: [Reproduction helper adding the parked crewmate whose 520 keyed open decisions overflow one argument](https://github.com/mihneamanolache/firstmate/blob/8b675db9421842ddd9bac1884ed05021422158e4/.no-mistakes/evidence/bugfix/fm-bearings-snapshot-argv-overflow/mk-parked.sh) - Evidence: [Mode-sweep runner used for the reported-home transcripts](https://github.com/mihneamanolache/firstmate/blob/8b675db9421842ddd9bac1884ed05021422158e4/.no-mistakes/evidence/bugfix/fm-bearings-snapshot-argv-overflow/run-modes.sh)
Evidence: Captain-facing digest difference (excerpt)
BASE b84e0e3 (stderr: fm-fleet-snapshot.sh: line 802: /usr/bin/jq: Argument list too long; exit 0)
in_flight[3]{id,kind,state,repo,doing}:
scout-x,scout,done,firstmate,"report ready for the captain..."
ship-task,ship,working,firstmate,harness busy (claude-hook)
mate/mate,ship,working,firstmate,harness busy (claude-hook)

TARGET 6f64ebe (stderr: empty; exit 0)
in_flight[4]{id,kind,state,repo,doing}:
scout-x,scout,done,firstmate,"report ready for the captain..."
ship-parked,ship,paused,firstmate,parked waiting on the captain to pick a route
ship-task,ship,working,firstmate,harness busy (claude-hook)
mate/mate,ship,working,firstmate,harness busy (claude-hook)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 3 infos
  • ⚠️ bin/fm-fleet-snapshot.sh:1994 - scout_report_lines still uses the exact fail-open piped-loop shape that commit ab116ce removed from task_json_lines: find … | sort | while … jq -n … done | jq -s 'sort_by(.id)'. The script does not set pipefail, so the function's exit status is the final jq -s, which succeeds on whatever prefix reached it. Concrete path: make one task directory under $DATA unreadable (mode 000). find prints its readable entries, writes 'Permission denied' to stderr and exits 1; jq -s exits 0 on the partial stream; scout_report_lines > "$SCOUT_REPORTS_JSON_FILE" || { … exit 1; } never fires, and the snapshot publishes scout_reports with records silently missing - so a completed scout report never reaches the captain and /bearings shows an inventory it believes is complete. The same holds if the inner jq -n fails for any single report. This is the identical violated invariant ('composition failures must fail this function rather than … leave a sorted truncated prefix as the published inventory') at the immediately adjacent sibling collector, and the fix is the same one already applied at line 939: accumulate into a file with || return 1 per record, then jq -s 'sort_by(.id)' < "$file".
  • ℹ️ bin/fm-fleet-snapshot.sh:1853 - reconciliation=$(parent_evidence_reconciliation_json "$summary_file" "$evidence_file") discards the return status, and the new envelope guard gives that call a real new failure mode (a malformed task/activity_scan component now makes it error() out). When it fails, $reconciliation is empty, contradiction=$(printf '' | jq -r '.contradiction') yields the empty string, and the run only fails later because --argjson contradiction "" is rejected as invalid JSON by the record-composing jq. It does fail closed, but via a downstream accident and with an opaque 'Invalid JSON text passed to --argjson' message rather than the named diagnostic the rest of this branch establishes. Add || return 1 to the call so the failure is attributed where it happens.
  • ℹ️ bin/fm-fleet-snapshot.sh:1855 - The terminal_contradiction jq now loads the whole parent-evidence envelope via --slurpfile plus the prelude solely to re-derive $note from $task.paths.status_log.last_event.note, when the identical value is already in the shell as $event_note (line 1762) and is passed as a plain argument to terminal_evidence_json on the next line. $event_note is a single bounded status-log note, not an unbounded blob, so it does not need file transport. Replacing the --slurpfile/prelude with --arg note "$event_note" removes a redundant file read and one of the two places this field is derived.
  • ℹ️ bin/fm-fleet-snapshot.sh:739 - Each failure path in task_json_lines (lines 739, 783, 831, 850, 931) calls snapshot_task_cleanup before return 1, but trap snapshot_cleanup EXIT already runs snapshot_task_cleanup, and the sole caller (TASKS_JSON=$(task_json_lines) || … exit 1) exits immediately. Because the caller is a command substitution, these in-function calls also tear down the observation directory that the parent shell's SNAPSHOT_TASK_DIR still names, which would break any future non-fatal handling of a task_json_lines failure. Dropping the five snapshot_task_cleanup calls and keeping bare return 1 leaves behavior identical and removes the duplicated teardown.
  • ℹ️ tests/fm-bearings-snapshot.test.sh:1582 - test_large_task_decision_inventory_avoids_argument_transport asserts that the whole canonical snapshot exceeds 131072 bytes, but the bug it guards is a single argument (--argjson open_decisions) exceeding MAX_ARG_STRLEN. Those are different quantities: the snapshot already carries the backlog, task rows and secondmate records, so a later fixture trim (fewer decisions, or a shorter suffix) could keep the total above 131072 while open_decisions itself drops under 128 KiB, and the test would then pass against the pre-fix code. Assert on the component instead, e.g. [.tasks[] | select(.id == "mate")][0].hints.open_decisions | tojson | length > 131072, so the guard pins the argument that actually overflowed. (The sibling candidate-PR test at line 1554 is tight enough, since candidate_prs dominates that model.)

🔧 Fix: fail closed on scout report and reconciliation failures
3 infos still open:

  • ℹ️ bin/fm-fleet-snapshot.sh:1992 - scout_report_lines writes find output to paths_file, sorts it into sorted_file, then loops over sorted_file - but the function's final jq -s 'sort_by(.id)' (line 1999) re-orders every record by .id, and .id is basename(dirname(report)), which is unique per record. The pre-sort therefore cannot affect the published order: it is one extra file plus one extra process per snapshot for no observable difference. Read the loop directly from paths_file and drop sorted_file (and the LC_ALL=C sort line). Verified: the emitted scout_reports array is identical either way because sort_by(.id) is total over unique ids.
  • ℹ️ bin/fm-fleet-snapshot.sh:1858 - terminal=$(terminal_evidence_json "$task" "$event_note" true) (and the sibling at line 1908) discards the return status, two lines below the parent_evidence_reconciliation_json call this fix round deliberately hardened with || { echo ...; return 1; }. terminal_evidence_json can exit non-zero: its final jq -n --argjson bytes "$bytes" --argjson lines "$lines" rejects an empty bytes/lines, which happens if the wc -c/wc -l pipeline fails. On that path $terminal is empty, json_envelope_file (line 1863) emits "terminal":}, and the run dies at the record-composing jq with a bare Invalid JSON text parse error against a temp file path rather than the named per-task diagnostic the surrounding code now establishes. It does fail closed, so this is attribution only - add the same || { echo "fm-fleet-snapshot: terminal evidence capture failed for $id" >&2; return 1; } guard to both call sites.
  • ℹ️ bin/fm-fleet-snapshot.sh:1990 - Noting a verified behavior change for visibility, not as a defect: find ... > "$paths_file" || return 1 now propagates any non-zero find exit, so a single unreadable directory under $DATA aborts the entire snapshot. Verified directly - with chmod 000 $DATA/locked, base b84e0e3 exits 0 and publishes the readable reports, HEAD exits 1 with fm-fleet-snapshot: scout report snapshot failed and emits nothing, taking down the whole /bearings catch-up surface the intent calls the fleet's only deterministic fleet-state source. This is precisely the fail-closed behavior round 1 requested (its repro was a mode-000 task directory) and is the right trade against silently omitting a finished scout report, so no change is recommended. Nothing in the repo creates a $DATA/<id> directory with restricted permissions or removes one (fm-brief.sh:186 only mkdir -ps them), so there is no reachable transient-race path that would make this fire in normal operation. If a degraded-but-published surface is ever wanted here, the script already has the idiom for it (available:false / reasons in bounded_parent_activities_json).
✅ **Test** - passed

✅ No issues found.

  • bash tests/fm-bearings-snapshot.test.sh at target commit - full owning suite, every case ok including the 4 new argv/fail-closed cases
  • bash tests/fm-fleet-snapshot-view.test.sh at target commit - downstream consumer of the changed snapshot producer, all ok
  • ONLY_TEST=<test> bash tests/fm-bearings-snapshot.test.sh for each of the 4 new tests against a base-commit tree: all report not ok (fail-before / pass-after proven)
  • Manual scenario A: bin/fm-bearings-snapshot.sh --include-prs --all-pr-repos --json on a 31-repo home with 20 open PRs per repo and default caps - base vs target
  • Manual scenario C: bin/fm-bearings-snapshot.sh --fields home,in_flight,decisions_open on a home whose parked crewmate carries 520 keyed open decisions (124,334-byte status log, 136,761-byte component) - base vs target
  • Manual scenario B: bin/fm-fleet-snapshot.sh --json on a home whose persistent secondmate stream carries 401 keyed open decisions (122 KB status log) - base vs target, comparing tasks[] inventory and hints.open_decisions
  • Manual mode sweep on the reproduced reported home: bin/fm-bearings-snapshot.sh, --fields home,decisions_open,in_flight, --json, --include-prs --json
  • Edge checks at target: fresh empty FM_HOME still snapshots (exit 0, empty inventories) and no /tmp/fm-bearings-prs.* transport files leak after a run
⚠️ **Document** - 1 info
  • ℹ️ .agents/skills/bearings/SKILL.md:37 - .agents/skills/bearings/SKILL.md step 1 mandates bin/fm-bearings-snapshot.sh --json as the single fleet-state source and forbids a second reader, but gives no guidance for a non-zero exit - which this change makes a reachable outcome for a composition failure, not just a missing home. Left unchanged deliberately: the failure mode is pre-existing (the command could always exit non-zero on a backlog or observation failure), and restating the exit contract in the skill would duplicate the script header that the skill already names as authoritative. Worth a follow-up only if the captain wants an explicit "report the failure, do not fall back to reading state/*.meta" instruction in the skill.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown

Confidence Score: 4/5

The PR appears safe to merge, with only a non-blocking temporary-file cleanup gap on signal termination.

The file-backed transport and fail-closed collection paths preserve the snapshot contract, but interrupted PR enrichment can leave its newly introduced temporary file behind.

Files Needing Attention: bin/fm-bearings-snapshot.sh

Reviews (1): Last reviewed commit: "no-mistakes(document): document snapshot..." | Re-trigger Greptile

cleanup_candidate_prs() {
rm -f -- "$CANDIDATE_PRS_FILE"
}
trap cleanup_candidate_prs EXIT

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Signal exits leak transport files

When the script receives SIGINT, SIGTERM, or SIGHUP during PR collection, the EXIT-only cleanup does not run, leaving an fm-bearings-prs.* transport file in the temporary directory. Register signal handlers so interrupted invocations exit through the existing cleanup path.

Suggested change
trap cleanup_candidate_prs EXIT
trap cleanup_candidate_prs EXIT
trap 'exit 130' INT
trap 'exit 143' HUP TERM

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant