Skip to content

fix(bin): stream contribution input through stdin so a large backlog fits - #6302

Open
limitall wants to merge 2 commits into
kunchenguid:mainfrom
limitall:fm/fm-snapshot-argmax
Open

limitall wants to merge 2 commits into
kunchenguid:mainfrom
limitall:fm/fm-snapshot-argmax

Conversation

@limitall

@limitall limitall commented Oct 1, 2026 •

Copy link
Copy Markdown

Intent

Session start can fail with jq: Argument list too long when a home holds a large backlog and many task records, because large JSON reaches jq as command-line arguments. Pass it through stdin or a file instead, so the fleet snapshot completes whatever the backlog size.

What Changed

  • bin/fm-fleet-snapshot.sh --contribution-input no longer passes the backlog and task JSON to jq as --argjson arguments. It now pipes both documents through stdin with jq -s. Before, a large backlog went over the per-argument size limit and the command failed with jq: Argument list too long. If assembling the input fails, the script now prints fm-fleet-snapshot: contribution input assembly failed and exits non-zero.
  • Added test_large_backlog_contribution_input to tests/fm-contributions.test.sh. It adds 1500 filler items to a backlog, checks that the generated backlog JSON is larger than 128 KiB, and then checks two things: fm-contributions.sh snapshot still projects the one tracked PR, and the full bearings snapshot still reports the contribution.

The run printed messages about MCP connectors, which this change doesn't use:

  • These connectors need authorizing before their tools work: claude.ai Figma, Gmail and Google Calendar (in claude.ai connector settings), and plugin:clickhouse:clickhouse, plugin:data:amplitude, plugin:data:amplitude-eu, plugin:data:atlassian and plugin:data:hex (via claude mcp or /mcp in an interactive session).
  • plugin:data:definite failed to connect: the endpoint at https://api.definite.app was not found.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: One small, well-bounded change: the last place that passed the whole backlog to jq as a command-line argument (the --contribution-input path) now sends it through stdin, and jq failures now exit non-zero. The full snapshot path already passed this data through files, and a new behavioral test runs both entry points on a backlog larger than 128 KiB.

Testing

I drove the real session-start path, the snapshot --contribution-input mode, the contributions poll and the full bearings snapshot in a disposable lab home with a large real-shaped backlog, on base and on target. Base shows the exact reported Argument list too long error in BOOTSTRAP and returns empty contribution input with exit 0. Target prints no error and carries the full backlog. It also holds up when the tasks payload goes over the argument limit, and an empty home still works. The new regression test fails on base and passes on target; that is an automated test, not a live run. The contributions suite has the same 6 failures on base and target, so they come from before this change. All checks are CLI transcripts saved to the evidence directory; there is no UI surface.

  • Live validation: ✅ go - 5 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Session start in a home with a long backlog prints no jq 'Argument list too long' error in BOOTSTRAP ✅ pass live session-start-bootstrap-base-vs-target.txt: base prints the error at fm-fleet-snapshot.sh line 1994, target's BOOTSTRAP is clean
fm-fleet-snapshot.sh --contribution-input on a backlog with 226 KB of JSON outputs the full backlog/tasks pair ✅ pass live large-backlog-repro.txt: base exits 0 with empty output and the jq error; target outputs 122 backlog records
Contributions poll and full bearings snapshot run cleanly on the large backlog ✅ pass live large-backlog-repro.txt: poll on base prints the jq error, on target it prints nothing; full snapshot reports 122 records on both
Adversarial: tasks payload (1100 task metas) and backlog both over the 128 KiB per-argument limit ✅ pass live large-backlog-and-tasks.txt: base fails with the jq error; target keeps 122 records and 1100 tasks, and the last task's PR URL is intact
Empty home (no backlog, no tasks) still gives a valid contribution input pair ✅ pass live empty-home-contribution-input.json
Regression test reproduces the bug on base and passes on target ⏸️ untested no The prior payload recorded this only as an automated test run with a stubbed forge (live=false), so it did not establish a live result. The live behavior it covers is shown by the scenarios above.
Evidence: Session-start BOOTSTRAP section, base vs target (error on base, clean on target)

Source: Session-start BOOTSTRAP section, base vs target (error on base, clean on target)

base BOOTSTRAP: <repo>/bin/fm-fleet-snapshot.sh: line 1994: /usr/bin/jq: Argument list too long target BOOTSTRAP: (no such line)

===== base: fm-session-start.sh (lab home, grown real backlog) - BOOTSTRAP section =====
BOOTSTRAP
--------------------------------------------------------------------------------
MISSING: tmux (install: brew install tmux  # or the platform's package manager)
MISSING: quota-axi (install: npm install -g quota-axi)
<repo>/bin/fm-fleet-snapshot.sh: line 1994: /usr/bin/jq: Argument list too long

WAKE QUEUE
===== target: fm-session-start.sh (lab home, grown real backlog) - BOOTSTRAP section =====
BOOTSTRAP
--------------------------------------------------------------------------------
MISSING: tmux (install: brew install tmux  # or the platform's package manager)
MISSING: quota-axi (install: npm install -g quota-axi)

WAKE QUEUE
Evidence: Large backlog repro: contribution-input / poll / full snapshot, base vs target

Source: Large backlog repro: contribution-input / poll / full snapshot, base vs target

## lab home: real backlog.md grown to 100521 bytes (real items plus id-suffixed copies under ## Queued)

\### base: fm-fleet-snapshot.sh --contribution-input
exit=0
<repo>/bin/fm-fleet-snapshot.sh: line 1994: /usr/bin/jq: Argument list too long
\### base: fm-contributions.sh poll (session-start contribution poll path)
exit=0
<repo>/bin/fm-fleet-snapshot.sh: line 1994: /usr/bin/jq: Argument list too long
\### base: fm-fleet-snapshot.sh (full bearings)
exit=0
{"contributions_known":0,"backlog_records":122}

\### target: fm-fleet-snapshot.sh --contribution-input
exit=0
backlog json bytes: 226729; backlog records: 122
\### target: fm-contributions.sh poll (session-start contribution poll path)
exit=0
\### target: fm-fleet-snapshot.sh (full bearings)
exit=0
{"contributions_known":0,"backlog_records":122}
Evidence: Adversarial: backlog and tasks both over 128 KiB

Source: Adversarial: backlog and tasks both over 128 KiB

target: {"backlog_bytes":226728,"backlog_records":122,"tasks_bytes":229887,"tasks":1100,...}

## lab home: grown real backlog + 1100 task metas with PR urls
\### base: fm-fleet-snapshot.sh --contribution-input
exit=0
<repo>/bin/fm-fleet-snapshot.sh: line 1994: /usr/bin/jq: Argument list too long
\### target: fm-fleet-snapshot.sh --contribution-input
exit=0
{"backlog_bytes":226728,"backlog_records":122,"tasks_bytes":229887,"tasks":1100,"task_1100_pr":"https://github.com/example-org/example-repository-with-a-long-name/pull/1100"}
Evidence: Empty home contribution input on target

Source: Empty home contribution input on target

{
  "backlog": {
    "path": "<lab>/data/backlog.md",
    "present": false,
    "records": []
  },
  "tasks": []
}
Evidence: Regression test fails on base, passes on target

Source: Regression test fails on base, passes on target

===== base bin/ with test_large_backlog_contribution_input =====
<repo>/bin/fm-fleet-snapshot.sh: line 1994: /usr/bin/jq: Argument list too long
not ok - large backlog fixture stayed under the argument limit: 0 bytes
not ok - 1 contribution regressions
exit=1
===== target bin/ with test_large_backlog_contribution_input =====
ok - contribution input carries a backlog larger than one argument
exit=0
Evidence: fm-contributions.test.sh: same 6 failures on base and target

Source: fm-contributions.test.sh: same 6 failures on base and target

===== base: bash tests/fm-contributions.test.sh (failures + summary) =====
not ok - ready-for-pr on an explicitly filed issue must become a planning wake
not ok - a fresh open issue did not remain measured maintainer triage
not ok - add/remove between polls lost ready-for-pr transition
not ok - watcher did not surface the new contribution signal: 
not ok - data root '<tmp>/task-identity/data' named tasks [
not ok - reservation poll printed an unavailable wake: contributions: observation unavailable for https://github.com/o/r/issues/9
not ok - 6 contribution regressions
exit=1
ok count: 39
===== target: bash tests/fm-contributions.test.sh (failures + summary) =====
not ok - ready-for-pr on an explicitly filed issue must become a planning wake
not ok - a fresh open issue did not remain measured maintainer triage
not ok - add/remove between polls lost ready-for-pr transition
not ok - watcher did not surface the new contribution signal: 
not ok - data root '<tmp>/task-identity/data' named tasks [
not ok - reservation poll printed an unavailable wake: contributions: observation unavailable for https://github.com/o/r/issues/9
not ok - 6 contribution regressions
exit=1
ok count: 40
- Outcome: ⚠️ 1 warning across 2 runs (25m38s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 warning
  • ⚠️ tests/fm-contributions.test.sh - On the target, tests/fm-contributions.test.sh reports 5 failures: the issue ready-for-pr planning wake, fresh-issue maintainer triage, the add/remove ready-for-pr transition, record task identity, and the reservation poll unavailable wake. None of them obviously touches the changed jq call, but the task-identity and poll tests do go through the contribution input path. The same file on base 549e07f had not finished, so it is not yet known whether these failed before this change. Compare with bash tests/fm-contributions.test.sh on base before shipping.
  • 🚨 live validation verdict: no-go (3 of 5 scenarios were driven live against the product)
  • Live validation: ❌ no-go - 3 of 5 scenarios driven live against the product
Scenario Result Live Evidence
A home with a large backlog runs fm-fleet-snapshot.sh --contribution-input and gets complete JSON with no 'Argument list too long' error ✅ pass live contribution-input-base-vs-target.txt
Adversarial check: in a large-backlog home, an open-PR contribution is not silently dropped from fm-contributions.sh snapshot ✅ pass live contributions-and-bearings-base-vs-target.txt
The session-start bearings snapshot still reports contributions in a large-backlog home ✅ pass live contributions-and-bearings-base-vs-target.txt: target exit 0, known=1, no argv error
The new regression test reproduces the bug on base and passes on target ⏸️ untested no The prior payload recorded this only as an automated test run (live=false), so it did not establish a live result against the running product.
The rest of tests/fm-contributions.test.sh still passes with the change ⏸️ untested no The prior payload recorded this only as an automated test-suite run (live=false), not a live product run; in addition, the base 549e07f comparison run had not finished, so whether the 5 failures preda…
  • Disposable lab home created with bin/fm-lab-home.sh create, then filled with a 294 KB backlog (1600 items) and 201 data dirs
  • FM_HOME=$LAB bin/fm-fleet-snapshot.sh --contribution-input run on base 549e07f and on target 3e65cd9
  • Base and target compared on fm-fleet-snapshot.sh --contribution-input | fm-contributions.sh snapshot &lt;input&gt; --all with a real open-PR contribution record
  • fm-bearings-snapshot.sh --json run on base and target against the lab home
  • test_large_backlog_contribution_input run alone against base bin/ (fails) and target bin/ (passes)
  • bash tests/fm-contributions.test.sh on target: 5 failures
  • Same test file on base 549e07f started in the background; not finished when this result was due
  • Lab home and temp files removed; worktree clean

🔧 No changes applied.
1 warning still open:

  • ⚠️ tests/fm-contributions.test.sh - tests/fm-contributions.test.sh fails 6 tests on this host, identically on base 549e07f and on target: the ready-for-pr planning wake, fresh-issue maintainer triage, the add/remove ready-for-pr transition, the watcher surfacing a new contribution, record task identity, and the reservation poll unavailable wake. They existed before this change and were not caused by it. Target passes one more test than base (the new large-backlog test). CI will hit them anyway; fixing them belongs in separate follow-up work.
  • Live validation: ✅ go - 5 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Session start in a home with a long backlog prints no jq 'Argument list too long' error in BOOTSTRAP ✅ pass live session-start-bootstrap-base-vs-target.txt: base prints the error at fm-fleet-snapshot.sh line 1994, target's BOOTSTRAP is clean
fm-fleet-snapshot.sh --contribution-input on a backlog with 226 KB of JSON outputs the full backlog/tasks pair ✅ pass live large-backlog-repro.txt: base exits 0 with empty output and the jq error; target outputs 122 backlog records
Contributions poll and full bearings snapshot run cleanly on the large backlog ✅ pass live large-backlog-repro.txt: poll on base prints the jq error, on target it prints nothing; full snapshot reports 122 records on both
Adversarial: tasks payload (1100 task metas) and backlog both over the 128 KiB per-argument limit ✅ pass live large-backlog-and-tasks.txt: base fails with the jq error; target keeps 122 records and 1100 tasks, and the last task's PR URL is intact
Empty home (no backlog, no tasks) still gives a valid contribution input pair ✅ pass live empty-home-contribution-input.json
Regression test reproduces the bug on base and passes on target ⏸️ untested no The prior payload recorded this only as an automated test run with a stubbed forge (live=false), so it did not establish a live result. The live behavior it covers is shown by the scenarios above.
  • FM_HOME=$LAB bin/fm-session-start.sh on base 549e07f vs target, in a lab home made by bin/fm-lab-home.sh create with a copy of the real backlog.md grown past 128 KiB of JSON, comparing the BOOTSTRAP section
  • FM_HOME=$LAB bin/fm-fleet-snapshot.sh --contribution-input on base vs target (exit code, stderr, backlog bytes and record count)
  • FM_HOME=$LAB bin/fm-contributions.sh poll on base vs target
  • FM_HOME=$LAB bin/fm-fleet-snapshot.sh (full bearings) on base vs target
  • Adversarial: 1100 task metas plus the large backlog so both halves of the pair exceed 128 KiB, --contribution-input on base vs target
  • Empty lab home with no backlog: --contribution-input on target
  • New test_large_backlog_contribution_input run alone against base bin/ (fails) and target bin/ (passes)
  • bash tests/fm-contributions.test.sh on base and target side by side, to settle the prior-round question about failing tests
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

…fits

fm-fleet-snapshot.sh --contribution-input passed the whole backlog JSON to jq
as an --argjson argument, so a home whose backlog exceeds the 128 KiB
per-argument limit failed with 'Argument list too long' at session start and
still exited 0 with empty output. Stream both documents through stdin and
fail when assembly fails.
@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Changes how a shell script passes large data to a command.

The PR appears safe to merge with respect to the reviewed changes.

Reviews (3) · Last reviewed commit: "Merge origin/main into fm/fm-snapshot-ar..."

@limitall
limitall force-pushed the fm/fm-snapshot-argmax branch from 3e65cd9 to f76aa62 Compare October 1, 2026 12:00
# Conflicts:
#	tests/fm-contributions.test.sh
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