Repository navigation
Conversation
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (3): Last reviewed commit: "no-mistakes(document): record argv-size ..." | Re-trigger Greptile |
|
Speaking as Kun's firstmate: full diff review of HEAD VISION (per-rule): One captain / honest interface — aligns (oversized backlog/status/PR/outcome no longer erase the whole fleet read; one bad secondmate no longer blanks every read). Authority explicit — aligns (scripts-only plumbing; no autonomy/consent change). Scripts own mechanics — aligns ( Contract-class: restore. Snapshot/bearings/emit were already supposed to produce JSON; the argv Approved fork CI for this HEAD only: CI Waiting on author for a no-mistakes pipeline attestation that MATCHES this HEAD. Do not merge this pass. No Firstmate flag (author/CI blockers). |
A single argv entry is capped at MAX_ARG_STRLEN (128 KiB on Linux), independently of the far larger ARG_MAX, so every jq call that handed a whole fleet document to --argjson failed with E2BIG once the home grew. This home's real backlog (108333 bytes) renders to 153355 bytes of JSON, which broke fm-fleet-snapshot.sh --json, its secondmate-home-summary mode, and fm-bearings-snapshot.sh --json outright, and left the home summary unpublished. Convert every unbounded document in bin/fm-fleet-snapshot.sh to --slurpfile through process substitution: the main inventory, the secondmate home summary, the parent-evidence reconciliation, the secondmate union, both per-record assemblies, the record accumulator, the landed projection, the per-task open-decision fold, and the final assembly. A shared jq def unwraps each slurped document and refuses an empty one, so a producer that returned nothing still fails closed instead of binding null. Counts, booleans, timestamps, single paths, and single status lines stay on argv. bin/fm-bearings-snapshot.sh already piped the snapshot on stdin, but its accumulated candidate PR rows had the same shape and the same failure: 900 open PRs made the projection exec fail. Convert those two sites too. Output is byte-identical for every input that fits under the cap.
The review round that made an unusable secondmate home summary degrade
to the unknown-state record left no explanation in the file, so the
reason for the four summary='{}' resets and the length == 1 schema check
lived only in the commit history. Put it where the next reader of that
sampling block will meet it.
This records one deliberate observable-output change, the only exception
to this change's byte-identical-output requirement.
The input class is a sampled secondmate home summary that is unusable:
it exits 0 but is not valid JSON, is two concatenated documents, or
exceeds FM_SNAPSHOT_SECONDMATE_MAX_BYTES. That unparseable value used to
reach the record assembly and cascade through the empty record, the
accumulator's doc() guard, and the final assembly, so the whole snapshot
exited 1 with "registered secondmate aggregation failed" and emitted
nothing. It now degrades to the unknown-state record the surrounding
code was already written to produce, and the snapshot exits 0.
The reason is that one bad input must not break every fleet read in the
home, which is the same failure class this whole change targets. The
fallback record already existed and was simply unreachable.
Every other path stays byte-identical, verified base against HEAD.
…t for new argv regression
The stock macOS Bash lane asserts an exact count of `ok -` lines from the snapshot and Bearings suites, so it fails whenever either suite legitimately grows. This branch adds four regressions that pin the argv-size fix, and the lane still expected the pre-change totals. The snapshot suite gains three cases (oversized backlog, oversized status line, and unusable secondmate home summary), so 15 becomes 18. The Bearings suite gains one case (oversized candidate PR set), so 42 becomes 43. The numbers move only because tests were added. The lane's real assertions are unchanged: it still requires every listed file to parse under /bin/bash 3.2.57 and every test in both suites to pass there. The failing run already proved both halves hold, printing 18 passing snapshot tests with no parse error and failing only on the stale literal.
ef98f7a to
17634dd
Compare
|
Following up on the 2026-08-31 triage, which was waiting on the author for a no-mistakes pipeline attestation matching the head. That attestation is now in the PR body, and its The remaining blocker is on your side rather than ours: this is a fork PR, so its workflow runs sit at Could a maintainer approve the workflow runs for this head when convenient? Happy to rebase or supply anything else that would help. For context on the urgency, with no wish to rush anyone: the argv bound this fixes is now breaking fleet snapshots in day-to-day use once a backlog crosses the single-argument limit, so the fix is doing real work while it waits. |
Intent
Get the existing upstream pull request #3418 green on every check. This is not a fresh implementation: six commits already exist and the PR is already open, and the work must be continued rather than restarted, rewritten, or squashed, because those commits carry the evidence the PR body cites.
The underlying change: bin/fm-fleet-snapshot.sh and neighbours built JSON by handing whole unbounded documents to jq as single command-line arguments (--argjson backlog "$1" and similar). Linux caps a single argv entry at MAX_ARG_STRLEN = 128 KiB, independent of ARG_MAX, so once one document crosses it exec fails with E2BIG and jq never runs. Those values now reach jq through files (--slurpfile/--rawfile via process substitution) instead. It also fixes a neighbouring script (bin/fm-bearings-snapshot.sh) that a first audit wrongly reported clean, moves unbounded status-line and outcome-text values in bin/fm-public-followup-emit.sh off jq argv, and adds a guard refusing multi-document slurps in the fleet snapshot JQ_DOC path.
Two checks were failing and this run must clear both.
Failure 1, "Stock macOS Bash snapshot compatibility" (job macos-stock-bash in .github/workflows/ci.yml). Diagnosed from the real failing job log, not assumed: the job runs on stock Bash 3.2.57, parses every file from bin/fm-lint.sh --list-files with /bin/bash -n, then runs the snapshot and Bearings suites and asserts an EXACT count of "ok - " lines. The log shows the parse sweep clean and all tests passing under real Bash 3.2.57, failing only on "expected 15 snapshot/fleet-view tests, got 18". The regressions this change added moved the totals, so the hardcoded literals were stale: the snapshot suite gained three cases (oversized backlog, oversized status line, unusable secondmate home summary) so 15 becomes 18, and the Bearings suite gained one case (oversized candidate PR set) so 42 becomes 43. The Bearings literal was a latent second failure that the job never reached. Only the two stale literals were changed; the job's real assertions are untouched, and it still requires every listed file to parse under /bin/bash 3.2.57 and every test in both suites to pass there. Do not weaken, skip or disable this gate.
Failure 2, "PR must be raised via no-mistakes". PR 3418 was opened by hand with gh because at the time the pipeline had no write access anywhere and the fork did not exist. The captain authorised the fork https://github.com/rrecheve/firstmate on 2026-08-31 and it now has write access, so the gate must be satisfied the legitimate way: by having this pipeline push the branch to that fork and raise or re-raise the PR against kunchenguid/firstmate, producing a genuine attestation bound to the current head SHA. The gate is deliberately not forgery-proof, but hand-writing the signature or attestation into the PR body is explicitly out of scope and must not be done. The pipeline push target was configured with no-mistakes init --fork-url for exactly this reason. Prefer bringing the existing PR 3418 into compliance over closing and re-raising it.
Rebase context: upstream main moved to a5f3cbe "fix: support first public-followup registration on Bash 3.2 (#3420)", which touches the same file family and the same Bash 3.2 theme. Their fix is a different bug in a different file (empty array under set -u in bin/fm-public-followup.sh) from ours (argv size limits in bin/fm-public-followup-emit.sh), so the two are complementary and neither supersedes the other. The branch has been rebased onto their main; the one conflict, in docs/verification/public-followup.md, was purely additive and both sides were kept, theirs first. Their bin/fm-public-followup.sh and tests/fm-pr-check-security.test.sh changes are untouched by us. Never resolve a conflict by discarding their work; we are guests in their repository and if their approach supersedes ours we adopt theirs.
Constraints: bin/*.sh must pass shellcheck and bin/fm-lint.sh must be clean (both verified green locally, including actionlint on the edited workflow). Tracked Markdown uses one sentence per line and a plain dash, never an em dash. Never add an agent name as a commit co-author. This is somebody else's repository and their gates are not ours to lower: if a check cannot be made to pass for a reason outside our control, stop and report it with evidence rather than disabling, skipping or weakening the check.
What Changed
bin/fm-fleet-snapshot.sh,bin/fm-bearings-snapshot.sh, andbin/fm-public-followup-emit.shnow hand every value whose length has no producer bound (backlog and task documents, secondmate home summaries and reconciliations, status-log lines and PR URLs, candidate PR rows, composed deliverables, and outcome text) tojqthrough--slurpfile/--rawfileprocess substitution instead of--argjson/--arg. Previously a single document past Linux's 128 KiBMAX_ARG_STRLENmade theexecfail withE2BIGsojqnever ran. Bounded values (ids, kinds, counts, timestamps, single paths, fixed state words) stay on argv.JQ_DOCdoc($d; $name)helper unwraps each slurped document and errors unless exactly one arrived, so a producer that emits nothing or concatenates multiple documents fails closed rather than bindingnullor silently keeping the first value;fm-public-followup-emit.shapplies the same length guard inline for deliverables.{}and degrades to its own unknown-state record instead of cascading into a whole-snapshot exit 1, and its schema check runs underjq -swithlength == 1so concatenated documents are rejected too.ok -counts to 19 snapshot/fleet-view and 43 Bearings tests, and recorded the new argv-size guarantee indocs/verification/public-followup.md.Risk Assessment
✅ Low: The change is a mechanical, hunk-by-hunk semantics-preserving move of unbounded values from jq argv onto --slurpfile/--rawfile with a shared one-document guard, backed by real fail-before/pass-after regressions and CI count literals I independently recounted as correct (19 and 43); the single warning is a pre-existing fail-open pipeline boundary with no realistically reachable trigger left after this change.
Testing
Ran the three suites that own the changed scripts (19 snapshot, 43 Bearings, 54 public-followup ok lines, no failures) plus two consumer suites, then went past pass/fail for product evidence: with only the three fixed scripts reverted to base, an operator running fm-fleet-view.sh, fm-bearings-snapshot.sh and fm-public-followup-emit.sh on oversized-but-ordinary inputs gets "Argument list too long" and no output at all, while the target commit renders the fleet view, the Bearings board and the published terminal event with the long values intact; a two-document remote summary likewise degrades to one unknown-state record instead of killing the whole snapshot. For the failing CI check I extracted the macos-stock-bash job script and ran it verbatim (exit 0, no ::error::, correct 19/43/1 counts) and reproduced the original failure by running the base version of that script against the current suites. Stock Bash 3.2.57 is unavailable on this Linux runner, so the job's parse sweep ran under 5.2.21 and the 3.2-specific half is left to the macOS lane in remote CI; the "PR must be raised via no-mistakes" check is a pipeline action outside this phase. One consumer suite, fm-bearings-board.test.sh, fails identically on base and target from a sandbox-level process-event source claim, so it is environmental rather than a regression. Evidence transcripts are in /tmp/no-mistakes-evidence/01M1E9Z2JZ2H9T9ABV54TBPXST.
Evidence: Operator CLI transcript: oversized backlog and status line, before vs after
Evidence: Public-followup emit with a 176 KB outcome text, before vs after
=== BEFORE (base a5f3cbe) === outcome text file: 176059 bytes (one argv entry is capped at 131072) $ bin/fm-public-followup-emit.sh --home $HOME --obligation pf-demo --outcome pr-merged --outcome-text-file outcome.txt fm-public-followup-emit.sh: line 247: /usr/bin/jq: Argument list too long fm-public-followup-emit: could not build the typed terminal event -> exit 1 no terminal event was published - the promised public reply never happens === AFTER (target 7a9c65a) === -> exit 0 published terminal event: 51221036412dfdcc11284f409b66ce772e8238a5dfca3a2733e09f5765562206.json { "schema_version": 1, "obligation_id": "pf-demo", "outcome_type": "pr-merged", "deliverables": { "pr_url": "https://github.com/example/repo/pull/5" }, "public_safe_outcome_chars": 600, "public_safe_outcome_head": "Shipped the café fix, and here is the rest of the report: a very long " }Evidence: Multi-document slurp guard: whole-snapshot failure becomes one degraded record
=== BEFORE (base a5f3cbe) === remote home summary emits: 2 JSON documents $ FM_HOME=$HOME_DIR bin/fm-fleet-snapshot.sh --json -> exit 1 stderr: jq: invalid JSON text passed to --argjson (no snapshot output at all - every fleet read in this home is dead) === AFTER (target 7a9c65a) === remote home summary emits: 2 JSON documents -> exit 0 { "secondmate_records": 1, "id": "twodocs", "state": "unknown", "reason": "structured home snapshot was malformed or stale", "reconcile_inventory": null }Evidence: macos-stock-bash job script run verbatim on the target: exit 0, no ::error::
Evidence: Reported CI failure reproduced with the pre-fix literals
=== the base a5f3cbe job script against the current suites === ok - fleet view renders secondmate agent liveness ::error::expected 15 snapshot/fleet-view tests, got 19 job exit=1 === the same script at target 7a9c65a === job exit=0 (19 snapshot + 43 Bearings + 1 public-followup ok lines, no ::error::)Evidence: All six new regressions failing against the pre-fix scripts
Evidence: Suite runs on the target: snapshot (19), Bearings (43), public-followup (54)
Evidence: docs/verification/public-followup.md transcript matches the live suite output
doc lines: 54 run lines: 54 IDENTICAL: docs/verification/public-followup.md transcript matches this run line for lineEvidence: Evidence index with baseline-tree reconstruction steps
Note for maintainers: a pre-existing issue this change deliberately leaves alone
While working in
bin/fm-fleet-snapshot.shI noticed that a per-task read failure can discard a live worker silently instead of surfacing an error.task_json_lines(line 469) ends its loop withdone | jq -s 'sort_by(.id)'at line 676, and the script setsset -uat line 73 withoutpipefail, so the function's exit status is the one fromjq -sand never from the per-taskjq.The caller's guard at line 1506 therefore does not see that failure: the affected task emits no line, the loop continues, the snapshot exits 0, the task disappears from
.tasks, and its still-live in-flight backlog row is then reported underorphan_in_flight.The earliest place the invariant could be enforced is the loop itself, around line 676, either with a per-task status check or a local
set -o pipefail.This predates this branch, and the change here does not touch that construct, so I have left it exactly as it is rather than widening a pull request that is about the single-argument size limit.
Whether a lost task should fail the read or degrade to a disclosed record looks like a design call for this repository's maintainers, and the same trade-off appears in this branch's own handling of an unusable secondmate home summary, so I am reporting it here instead of choosing on your behalf.
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-fleet-snapshot.sh:613---arg pr "$pr"is the one remaining task-level argv value the script itself derives from status-log text, which the change's own rule at lines 221-226 declares unbounded ("A status log line has no producer bound at all"). At lines 505-507prfalls back tofirst_pr_url_in_file "$status_log", i.e.grep -Eo 'https?://[^[:space:])"]+/pull/[0-9]+'; POSIX ERE takes the longest leftmost match, so a status line of the formhttps://x/+ >128 KiB of non-space, non-), non-"bytes +/pull/1yields a single argv entry past MAX_ARG_STRLEN. That per-taskjq -nthen fails with E2BIG,task_json_lines'sdone | jq -ssilently drops the task's line while still exiting 0, andmain_inventoryreports the still-live backlog row asorphan_in_flight- the exact "a supervisor would be told a live worker does not exist" failuretest_oversized_status_line_keeps_the_taskwas added to close, reachable through a sibling field in the same jq invocation that was just fixed. Every neighbouring status-derived value (raw,note,verb,detail,last_event_raw) was moved to--rawfile;prwas not. Fix at the same boundary:--rawfile pr <(printf '%s' "$pr"). Reachability is low (it needs a pathological unbroken URL-shaped token in a status log), which is why this is a follow-up rather than a merge blocker.bin/fm-bearings-snapshot.sh:268- The "exactly one slurped document" invariant is open-coded twice in this file with two independently written implementations and two divergent error strings - the accumulator at line 268 (if (($a | length) == 1) and (($b | length) == 1) ... error("...for each candidate PR row set...")) and the projection at line 332 (if length == 1 then .[0] else error("...for $candidate_prs...")). The sibling script factored the identical invariant into the reusableJQ_DOChelper (bin/fm-fleet-snapshot.sh:234), which yields one uniform, self-naming message. Defining the same one-linedef doc($d; $name)constant here and callingdoc($a; "a") + doc($b; "b")anddoc($candidate_prs; "candidate_prs")removes both hand-rolled copies with no behavior change. Non-functional cleanup only.🔧 Fix: move PR URL off jq argv and share bearings doc guard
2 issues (1 warning, 1 info) still open:
bin/fm-fleet-snapshot.sh:676- The guards this change adds inside the per-task jq fail OPEN, not closed.task_json_linesendsdone | jq -s 'sort_by(.id)'with nopipefail(the script sets onlyset -uat line 73), so the function's exit status isjq -s's, never the per-task jq's. The caller's guard at line 1506,TASKS_JSON=$(task_json_lines) || { echo "task snapshot failed"; exit 1; }, is therefore dead for the dominant failure mode: a per-task jq that dies emits no line, the loop continues, the snapshot exits 0, the task vanishes from.tasks, andmain_inventory_json(line 685) reports its still-live in-flight backlog row underorphan_in_flightwith reason "in-flight backlog item has no child metadata". That is verbatim the failuretest_oversized_status_line_keeps_the_taskwas added to close ("A supervisor reading that would be told a live worker does not exist"). This change adds three NEWerror()sites into exactly that jq -doc($open_decisions),doc($current_state),doc($status_log)at lines 630-632 - each of which, when it fires, silently deletes a live worker and manufactures a false orphan instead of failing the read. The two named triggers are now closed, and the one residual argv path I can name is contrived (path_present_jsonat line 239 still uses--arg path, so a hand-editedworktree=value past MAX_ARG_STRLEN would E2BIG, yield an emptyworktree_json, and break--argjson worktree_path; real writers setWTto a created git worktree, so PATH_MAX bounds it in practice). The defect is the boundary itself, not a specific trigger: the earliest place the invariant can be made to hold is line 676, by giving the loop a per-task status check (or a localset -o pipefail) so a lost task surfaces instead of degrading into a false orphan. Which remedy is right is a product call - commit 5494ad4 chose "degrade to a disclosed unknown record" for an unusable secondmate home rather than hard-failing, and the same choice applies here - so this needs the author's decision rather than a mechanical fix.tests/fm-fleet-snapshot-view.test.sh:850- All five new regressions gate their fixtures on a hardcoded131072(here and at lines 915 and 988, plus tests/fm-bearings-snapshot.test.sh:1187 and tests/fm-public-followup.test.sh:291), but that number is not a constant: Linux computes MAX_ARG_STRLEN as PAGE_SIZE * 32, so it is 131072 only on 4 KiB-page hosts (verified 4096 here, so these tests genuinely fail-before/pass-after in this environment), 524288 on a 16 KiB-page aarch64 kernel, and 2 MiB on a 64 KiB-page one. Darwin has no per-argument cap at all - only the ~1 MiB total ARG_MAX - so on themacos-stock-bashlane, which is the very job this change exists to green and which runs both of these suites in full, a ~136 KiB single argv entry execs fine and every one of these cases passes with the--arg/--argjsonbug fully restored. The fixture guards cannot detect this:-gt 131072still succeeds while the fixture sits below the host's real cap, so the case degrades from a regression proof into a plain happy-path assertion without any signal. The assertions themselves are correct behavior checks on every platform, and the x86-64 Linux lane still provides the fail-before proof, so nothing here is wrong or flaky - noting it so the durability limit is on the record rather than proposing a change.tests/fm-bearings-board.test.sh- tests/fm-bearings-board.test.sh fails in this sandbox at "the order-proof board build failed" because bin/fm-procevent.sh cannot claim a lavish-* process-event source here. It is not caused by this change: the identical failure reproduces on the base commit a5f3cbe with the pre-fix scripts. Recorded only so the failing line in the evidence directory is not mistaken for a regression; remote CI owns this lane./bin/bash tests/fm-fleet-snapshot-view.test.sh- 19 ok lines, matches the CI literal/bin/bash tests/fm-bearings-snapshot.test.sh- 43 ok lines, matches the CI literal/bin/bash tests/fm-public-followup.test.sh- full owner suite of the changed emit script, 54 ok linesFM_TEST_ONLY=test_first_register_succeeds_with_empty_lock_list_under_bash32 /bin/bash tests/fm-public-followup.test.sh- the third count the CI job assertsExtracted themacos-stock-bashjob's run script from .github/workflows/ci.yml and executed it verbatim (Bash 3.2.57 gate and global npm install substituted): exit 0, no::error::, 63 ok linesRan the same job script taken from base a5f3cbe against the current suites to reproduce the reported failure:::error::expected 15 snapshot/fleet-view tests, got 19, exit 1Ran all six new regressions against a tree with only the three fixed scripts reverted to a5f3cbe: every one fails with E2BIG /invalid JSON text passed to --argjsonManual before/after:FM_HOME=<big-home> bin/fm-fleet-view.shandbin/fm-bearings-snapshot.shwith a 107 KB backlog and a 180 KB status lineManual before/after:bin/fm-public-followup-emit.sh --outcome-text-filewith a 176 KB outcome body, checking the published event JSONManual before/after: remote secondmate whose home-summary command emits two concatenated JSON documents, checking the multi-document slurp guard/bin/bash tests/fm-home-summary-refresh.test.shand/bin/bash tests/fm-bearings-board-render.test.sh- consumer suites of the changed scripts, cleanCompared the recorded transcript in docs/verification/public-followup.md against the live suite output - identical, all 54 linesbin/fm-bearings-snapshot.sh:109- TheJQ_DOCsingle-document guard is defined three times in executable code -bin/fm-fleet-snapshot.sh:234,bin/fm-bearings-snapshot.sh:109, and a hand-inlined variant inside the event builder inbin/fm-public-followup-emit.sh- differing only in the error prefix. I reduced the duplicated prose to a pointer, but the definition itself is code, so consolidating it (both scripts already source shared libs such asbin/fm-timeout-lib.sh, so a lib-owned helper is feasible) would change executable behavior and is outside this documentation phase. Proposed as a follow-up, not needed for this change.✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.