Repository navigation
fix(bin): stage contribution-input backlog through --slurpfile - #4861
haroarthur wants to merge 2 commits into
Conversation
The missed --argjson backlog pass overflowed Linux MAX_ARG_STRLEN on homes whose structured backlog exceeds 128 KiB, so reuse the existing slurpfile transport for that mode too.
|
Speaking as Kun's firstmate: thank you @haroarthur. The diagnosis was right and the before/after evidence is thorough. This is my first look. The fix has already landed on main another way. #6830 (merged 2026-10-10) moved the One part isn't on main: a regression test that pushes a backlog over 128 KiB through contract-class: restore (the default contribution read was broken on large backlogs, and main has since restored it). |
Intent
The captain, 2026-09-18, ruling D6 on the fleet backlog triage board: "Ship the fix now - it is small and it fires every session".
Context needed to read it: bin/fm-fleet-snapshot.sh has one remaining call site that passes a whole backlog JSON document to jq through --argjson on argv: the contribution-input output mode near the end of the script (
jq -n --argjson backlog "$BACKLOG_JSON" --argjson tasks "$contribution_tasks" ...). Linux limits one argv string to 128 KiB (MAX_ARG_STRLEN), so on the analytics home, whose backlog is about 85 KB in markdown and larger once structured, the read dies with "jq: Argument list too long" and the contribution-input read fails at every analytics session start. The earlier fix fix-fleet-snapshot-argjson-limit (done 2026-09-03) moved the other three call sites to a temporary transport directory and --slurpfile; this site was missed. The verified line is reported in data/fleet-backlog-triage-board/report.md: the remaining --argjson backlog pass is that contribution-input jq invocation near the end of bin/fm-fleet-snapshot.sh.What Changed
--contribution-inputoutput mode inbin/fm-fleet-snapshot.shoff thejq -n --argjson backlog "$BACKLOG_JSON" ...argv pass, the last call site still doing so. It now stages the backlog and contribution-tasks documents into the shared temporary transport directory and assembles them withjq --slurpfile, so a backlog larger than Linux's 128 KiB single-argv limit (MAX_ARG_STRLEN) no longer aborts the read with "jq: Argument list too long". The transport-directory creation and backlog staging were reordered ahead of the contribution-input branch so it can reuse them.tests/fm-contributions.test.shthat builds a backlog whose structured form exceeds 128 KiB and asserts--contribution-inputreturns all 400 records intact through to the consumer.tests/fm-home-summary-refresh.test.shto exercise--contribution-inputin the large-backlog scenario, asserting the backlog records and tasks array survive alongside the existing json and secondmate-home-summary mode checks.Risk Assessment
✅ Low: A small, well-bounded fix that moves the one remaining contribution-input jq call from --argjson to the established temp-transport --slurpfile pattern with byte-identical output, correct branch ordering, trap-based cleanup, and a behavioral large-backlog regression test.
Testing
I derived the scenarios from the intent (large-backlog argv overflow at the contribution-input jq site) and drove them live against the real script and its consumer. On the base script a 229 KB backlog (~1 MB structured, far over the 128 KiB argv limit) reproduces exactly
jq: Argument list too longat line 1978 and silently emits nothing, causing the consumer to report all contributions as vanished (known:0, unreadable_records:1). On the fixed script the same backlog produces a valid 900-record document that the consumer reads intact (known:900). The existing contribution-input test suite stays green, confirming the small-backlog happy path is preserved, and I added a durable regression test that fails before the fix and passes after. Evidence is a CLI transcript artifact; there is no UI surface for this CLI/JSON change.bin/fm-fleet-snapshot.sh --contribution-inputwith a 229 KB / ~1 MB-structured backlog; exit 0, 900 records emitted, structured backlog 1,005,853 bytes (>131072 argv limit). Artifact: contributi…jq: Argument list too longat line 1978 with 0 bytes of output - the exact reported failure the fix removes.bin/fm-contributions.sh snapshot input.json --allon the fixed output reports known:900; on the base empty output reports known:0 / unreadable_records:1, showing the real end-user damage the fix pre…bash tests/fm-contributions.test.shfull suite exits 0, including all pre-existing --contribution-input scenarios (unobserved-head, away-yolo, etc.).Evidence: contribution-input argv-overflow before/after transcript
Source: contribution-input argv-overflow before/after transcript
Evidence: Base script fails at the argjson site
Evidence: Fixed script succeeds over the argv limit
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bin/fm-fleet-snapshot.sh --contribution-inputwith a 229 KB / ~1 MB-structured backlog; exit 0, 900 records emitted, structured backlog 1,005,853 bytes (>131072 argv limit). Artifact: contributi…jq: Argument list too longat line 1978 with 0 bytes of output - the exact reported failure the fix removes.bin/fm-contributions.sh snapshot input.json --allon the fixed output reports known:900; on the base empty output reports known:0 / unreadable_records:1, showing the real end-user damage the fix pre…bash tests/fm-contributions.test.shfull suite exits 0, including all pre-existing --contribution-input scenarios (unobserved-head, away-yolo, etc.).bash tests/fm-contributions.test.sh(full suite, exit 0 - all existing --contribution-input scenarios still pass)Manual E2E: 900-record / 229 KB backlog (~1 MB structured) run throughbin/fm-fleet-snapshot.sh --contribution-inputon the target script -> exit 0, 900 records emittedManual E2E on base commit script (daaffdb) run frombin/with libs loaded ->jq: Argument list too longat line 1978, 0 bytes emittedDownstream consumerbin/fm-contributions.sh snapshot input.json --allon fixed output -> known:900; on base empty output -> known:0, unreadable_records:1Added and rantest_large_backlog_contribution_input_survives_argv_limit; passes on the fix, fails on the base script (true regression guard)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.