Repository navigation
fix: pass backlog-sized JSON to jq through files in the fleet snapshot contribution input - #62
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
The fleet snapshot script (bin/fm-fleet-snapshot.sh) fails with a jq "Argument list too long" error when the backlog is large (about 200 tasks), so the fleet view and the live board built from it can break.
The secondmate that found it (backlog-closer) could not dispatch it because firstmate is not registered in its home; the captain's standing instruction is to dispatch ready queued work.
What Changed
bin/fm-fleet-snapshot.sh --contribution-inputno longer hands the backlog and contribution task JSON to jq as--argjsoncommand-line arguments, where a single argument is capped near 128 KiB and a large backlog failed with "Argument list too long". It now writes both to files in amktemp -dtransport directory and loads them with--slurpfile, producing the same{backlog, tasks}output shape.exit 0, and reports a specific error if the transport directory or either temporary file cannot be created.test_large_backlog_reaches_jq_through_filestotests/fm-fleet-snapshot-view.test.sh: it builds a 700-task queued backlog, asserts the output exceeds 131072 bytes (one argv entry), and checks that all 700 backlog records survive on the contribution input.Risk Assessment
✅ Low: The change replaces the only backlog-sized jq argv argument in the script (base line 2043) with the file transport the --json and --live-board-input paths already use, the temp dir is removed by the existing EXIT trap, and the new test drives the real script with a backlog over 128 KiB.
Testing
Drove the real
bin/fm-fleet-snapshot.shat base 8793116 and target cfcab60 against throwaway FM_HOME directories with generated backlogs (200 realistic tasks, 2000 tasks, 300 shell-hostile titles, 5 tasks), with tmux, no-mistakes and herdr stubbed on PATH so nothing touched the live fleet. The base reproduced the reported jq failure and the target fixed it; a small backlog gives the same JSON value on both commits; the default, live-board-input and secondmate-home-summary modes andfm-fleet-view.shall succeed on the 200-task home; an unwritable TMPDIR fails loudly with exit 1; no temp directories leak. The existing regression test intests/fm-fleet-snapshot-view.test.shalso passes. No visual artifact: the change is a CLI JSON emitter, and the live board HTML render was not driven. The base script was placed inbin/temporarily for the comparison and removed; the worktree is clean.fm-fleet-snapshot.sh --contribution-inputon a home with about 200 queued tasks and gets the full backlog/tasks JSON instead of a jq 'Argument list too long' error/usr/bin/jq: Argument list too long, exit=0, 0 stdout bytes; target exit=0, 452187 bytes, 200 backlog records from task-0001 to task-0200jq -S(8266 bytes); raw bytes differ only in nested object key order--live-board-inputexit=0 (452822 bytes),--secondmate-home-summaryexit=0,fm-fleet-view.shexit=0 with 217 lines including task-0…fm-contributions.sh pollon a 200-task home receives a usable contribution inputghl…$(...), backticks, backslashes and UTF-8 pass through intactfm-fleet-snapshot: temporary transport directory creation failedfm-fleet-snapshot.*directories in the temp dir before and after the whole driverfm-live-board.shand Lavish, which serve against the operator's real Lavish sessions; no isolated lab recipe for the board is in the runbook. The change does not tou…Evidence: Base-vs-target CLI transcript
Source: Base-vs-target CLI transcript
== S1: realistic backlog, 200 queued tasks with detail lines backlog.md bytes: 173093 -- base 8793116 base --contribution-input exit=0 stdout_bytes=0 stderr: .../bin/fm-fleet-snapshot.base.sh: line 2043: /usr/bin/jq: Argument list too long -- target cfcab60 target --contribution-input exit=0 stdout_bytes=452187 payload: {"backlog_records":200,"tasks":0,"first":"task-0001","last":"task-0200"} temp dirs left behind by target run: 0 == S2: small backlog byte-identical: no (object key order differs) same JSON value after key sort (jq -S): yes (8266 bytes) == S3: 200-task home, target target (default fleet JSON) exit=0 stdout_bytes=454150 target --live-board-input exit=0 stdout_bytes=452822 target --secondmate-home-summary exit=0 stdout_bytes=11888 fm-fleet-view.sh exit=0 stdout_bytes=27374 view lines: 217, mentions task-0200: 1 == S4: adversarial target --contribution-input, 2000 tasks exit=0 stdout_bytes=5288181 payload: {"backlog_records":2000,"tasks":0} target --contribution-input, shell-hostile titles exit=0 stdout_bytes=407821 target --contribution-input, TMPDIR read-only exit=1 stdout_bytes=0 stderr: fm-fleet-snapshot: temporary transport directory creation failed -- no temp dirs leaked across the whole run: 28 present now vs 28 at startEvidence: Driver script used for the run
Source: Driver script used for the run
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-fleet-snapshot.sh:2044- The contribution-input branch repeats the transport setup the full path already does at bin/fm-fleet-snapshot.sh:2057-2068 and the same jq projection at :2098-2099 (mktemp, backlog file write,{backlog:$backlog[0],tasks:$tasks[0]}). Hoisting the mktemp and backlog write above the branch would remove about four lines. Behaviour is correct as written and cleanup is covered by the existingtrap snapshot_cleanup EXIT(:1550), so no action is needed.bin/fm-fleet-snapshot.sh:2050- Nested object key order in--contribution-inputoutput differs between base and target under jq 1.6 (--slurpfilevs--argjson). The JSON value is identical afterjq -S. Only a consumer that compares the raw bytes or hashes the output would notice; none was found among the callers (fm-contributions.shreads it with jq).bin/fm-fleet-snapshot.sh:2052- The base failure was silent: jq failed but the script ended withexit 0and empty stdout, sofm-contributions.sh pollcontinued on an empty input file. The target'sexit $?now propagates a jq failure.fm-fleet-snapshot.sh --contribution-inputon a home with about 200 queued tasks and gets the full backlog/tasks JSON instead of a jq 'Argument list too long' error/usr/bin/jq: Argument list too long, exit=0, 0 stdout bytes; target exit=0, 452187 bytes, 200 backlog records from task-0001 to task-0200jq -S(8266 bytes); raw bytes differ only in nested object key order--live-board-inputexit=0 (452822 bytes),--secondmate-home-summaryexit=0,fm-fleet-view.shexit=0 with 217 lines including task-0…fm-contributions.sh pollon a 200-task home receives a usable contribution inputghl…$(...), backticks, backslashes and UTF-8 pass through intactfm-fleet-snapshot: temporary transport directory creation failedfm-fleet-snapshot.*directories in the temp dir before and after the whole driverfm-live-board.shand Lavish, which serve against the operator's real Lavish sessions; no isolated lab recipe for the board is in the runbook. The change does not tou…bash ~/.no-mistakes/evidence/01M4KZSHTDPVDYFB3WZ61FH23S/drive.sh "$PWD" fm-fleet-snapshot.base.sh- base-vs-target driver against isolated homes; base script extracted withgit show 8793116:bin/fm-fleet-snapshot.shfm-fleet-snapshot.sh --contribution-inputon a 200-task backlog (173 KB backlog.md), base and targetfm-fleet-snapshot.sh --contribution-inputon a 5-task backlog, base vs target compared withjq -Sfm-fleet-snapshot.sh(default),--live-board-input,--secondmate-home-summaryandfm-fleet-view.shon the 200-task home, targetfm-contributions.sh pollon a 200-task home, target and a temp copy ofbin/with the base snapshot script swapped infm-fleet-snapshot.sh --contribution-inputon 2000 tasks (2.4 MB backlog.md) and on 300 titles containing quotes,$(...), backticks, backslashes and UTF-8TMPDIR=<read-only dir> fm-fleet-snapshot.sh --contribution-inputCount offm-fleet-snapshot.*directories in the temp dir before and after the runsbash tests/fm-fleet-snapshot-view.test.sh- includestest_large_backlog_reaches_jq_through_files✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.