close-report reviewer gate fails CLOSED when the reviewer prompt exceeds MAX_ARG_STRLEN (~128KB): prompt passed as a single argv arg #2161

Closed
opened 2026-11-04 15:12:44 +00:00 by matou-build-agent · 1 comment

Symptom

.sandcastle/close-report.sh's independent-reviewer gate (#197) fails CLOSED for ANY close whose reviewer prompt exceeds the Linux single-argument limit MAX_ARG_STRLEN (~128 KiB), bricking the close with:

close-report: REFUSED — issue #<n> NOT closed. Violations:
reviewer output was empty or unparseable — failing the close CLOSED (#197)

Cause

cr_review_invoke passes the whole reviewer prompt as a single argv argument:

claude -p --model "$SWARM_REVIEW_MODEL" --allowedTools "$tools" --output-format json "$(cat "$prompt_file")"

The prompt = skeleton + issue body + criteria + the full diff of the claimed commits. When that exceeds ~128 KiB (one argv string cannot exceed MAX_ARG_STRLEN, independent of ARG_MAX), the exec fails before claude starts:

/bin/bash: line 1: /usr/bin/timeout: Argument list too long   (rc 126)

so $result is empty, and cr_review_parse on an empty file → _cr_review_fail → not auth-error (no zero-usage JSON to detect) → malformed → fail CLOSED. Reproduced: a 142,886-byte single-arg prompt reliably trips it; the same model with a small prompt returns the normal /login zero-usage shape that #2155 correctly classifies unauthenticated → SKIP.

This is the SAME can-not-run class as #228 (unauthenticated) and the absent-binary case, both of which the gate SKIPs — but an empty result from an exec failure falls through #2155's zero-usage check and bricks the close instead.

Proposed fix (pick one or both)

  1. Feed the prompt to claude on stdin instead of argv — e.g. claude -p --output-format json < "$prompt_file" (or a --prompt-file/heredoc form). This removes the MAX_ARG_STRLEN ceiling entirely and is the real fix.
  2. Defensively, classify an empty / exec-failed reviewer result as can-not-run → SKIP (extend #2155's zero-usage skip to the empty-result case), so a large diff is never worse than an absent reviewer.

Found while

Closing #2154 (an i18n Go-seam slice, ~143 KiB diff across 40 files). The work is complete, committed (9346f37f), pushed to the worker branch, and every deterministic gate + the full test suite pass; only this reviewer gate bricks the close. #2154 is going agent-blocked on this.

.sandcastle/ is a protected path (#445) — filed for an interactive session per ADR 0174 rule 9 rather than edited from the swarm.

## Symptom `.sandcastle/close-report.sh`'s independent-reviewer gate (#197) fails CLOSED for ANY close whose reviewer prompt exceeds the Linux single-argument limit `MAX_ARG_STRLEN` (~128 KiB), bricking the close with: ``` close-report: REFUSED — issue #<n> NOT closed. Violations: reviewer output was empty or unparseable — failing the close CLOSED (#197) ``` ## Cause `cr_review_invoke` passes the whole reviewer prompt as a **single argv argument**: ``` claude -p --model "$SWARM_REVIEW_MODEL" --allowedTools "$tools" --output-format json "$(cat "$prompt_file")" ``` The prompt = skeleton + issue body + criteria + **the full diff of the claimed commits**. When that exceeds ~128 KiB (one argv string cannot exceed `MAX_ARG_STRLEN`, independent of `ARG_MAX`), the exec fails before `claude` starts: ``` /bin/bash: line 1: /usr/bin/timeout: Argument list too long (rc 126) ``` so `$result` is empty, and `cr_review_parse` on an empty file → `_cr_review_fail` → not auth-error (no zero-usage JSON to detect) → **`malformed` → fail CLOSED**. Reproduced: a 142,886-byte single-arg prompt reliably trips it; the same model with a small prompt returns the normal `/login` zero-usage shape that #2155 correctly classifies `unauthenticated` → SKIP. This is the SAME can-not-run class as #228 (unauthenticated) and the absent-binary case, both of which the gate SKIPs — but an **empty result from an exec failure** falls through #2155's zero-usage check and bricks the close instead. ## Proposed fix (pick one or both) 1. Feed the prompt to `claude` on **stdin** instead of argv — e.g. `claude -p --output-format json < "$prompt_file"` (or a `--prompt-file`/heredoc form). This removes the `MAX_ARG_STRLEN` ceiling entirely and is the real fix. 2. Defensively, classify an **empty / exec-failed** reviewer result as can-not-run → SKIP (extend #2155's zero-usage skip to the empty-result case), so a large diff is never worse than an absent reviewer. ## Found while Closing **#2154** (an i18n Go-seam slice, ~143 KiB diff across 40 files). The work is complete, committed (`9346f37f`), pushed to the worker branch, and every deterministic gate + the full test suite pass; only this reviewer gate bricks the close. #2154 is going `agent-blocked` on this. `.sandcastle/` is a protected path (#445) — filed for an interactive session per ADR 0174 rule 9 rather than edited from the swarm.
Author
Member

Close report — landed (push mode)

Ruled by agent under ADR 0174 — veto anytime. Two-way door: a revertible pin bump + a four-file re-vendor, proven by the red-before-green suites below. No one-way door touched.

What landed

Both fixes the ticket proposed:

  1. The real fix — cr_review_invoke (.sandcastle/close-report.sh) now feeds the reviewer prompt to claude -p on stdin (< "$prompt_file") instead of as a single argv argument. Stdin has no MAX_ARG_STRLEN ceiling, so the full-diff prompt can never trip the Argument list too long exec failure again.
  2. The defensive backstop — _cr_review_is_auth_error (.sandcastle/close-report-lib.sh) now treats an absent or empty result file as can-not-run → SKIP (verdict unauthenticated), never malformed. This extends #2155's zero-usage skip to the empty-result case the exec failure produced, so a large diff is never worse than an absent reviewer. The fail-CLOSED posture (#197) is preserved for a reviewer that genuinely RAN — it always writes a non-empty --output-format json envelope, so a non-empty-but-garbage result still normalises to malformed.

Vendored-path handling (#445 / ADR 0180)

.sandcastle/close-report*.sh are vendored factory files. The fix landed upstream on dev-factory backport branch backport/idss-2161 (commit 472d5636, off the current pin ea75077899) and was re-vendored into this repo:

  • FACTORY_REF ea75077899 → 472d5636
  • 4 files updated (close-report.sh, close-report-lib.sh, tests/close-report-lib-test.sh, tests/close-report-test.sh), 212 unchanged, check-harness-drift: OK.

Proof

  • Live: printf '…' | claude -p --output-format json returns a well-formed JSON envelope — the stdin form is valid and does not mis-parse or hang.
  • TDD (red before green): close-report-lib RV7/RV8 flipped (empty/missing result now SKIPs, was malformed); close-report RV-C split — RV-C keeps malformed=refuse for a non-empty garbage result, new RV-C2 asserts an empty result SKIPs and the close PROCEEDS.
  • Suites: close-report-lib (81) + close-report (142) pass; drift gate OK.

Commits

  • idss main: 6df89b67
  • dev-factory backport/idss-2161: 472d5636

Context

This bricked the close of #2154 (an ~143 KiB i18n Go-seam diff); #2154 has since landed on main. The forward-port of this fix onto dev-factory main (LANDING=pr) is owed as a follow-up, like #2155's.

## Close report — landed (push mode) **Ruled by agent under ADR 0174 — veto anytime.** Two-way door: a revertible pin bump + a four-file re-vendor, proven by the red-before-green suites below. No one-way door touched. ### What landed Both fixes the ticket proposed: 1. **The real fix** — `cr_review_invoke` (`.sandcastle/close-report.sh`) now feeds the reviewer prompt to `claude -p` on **stdin** (`< "$prompt_file"`) instead of as a single argv argument. Stdin has no `MAX_ARG_STRLEN` ceiling, so the full-diff prompt can never trip the `Argument list too long` exec failure again. 2. **The defensive backstop** — `_cr_review_is_auth_error` (`.sandcastle/close-report-lib.sh`) now treats an **absent or empty** result file as can-not-run → **SKIP** (verdict `unauthenticated`), never `malformed`. This extends #2155's zero-usage skip to the empty-result case the exec failure produced, so a large diff is never worse than an absent reviewer. The fail-CLOSED posture (#197) is preserved for a reviewer that genuinely RAN — it always writes a non-empty `--output-format json` envelope, so a non-empty-but-garbage result still normalises to `malformed`. ### Vendored-path handling (#445 / ADR 0180) `.sandcastle/close-report*.sh` are vendored factory files. The fix landed **upstream** on dev-factory backport branch `backport/idss-2161` (commit `472d5636`, off the current pin `ea75077899`) and was re-vendored into this repo: - `FACTORY_REF` `ea75077899` → `472d5636` - 4 files updated (`close-report.sh`, `close-report-lib.sh`, `tests/close-report-lib-test.sh`, `tests/close-report-test.sh`), 212 unchanged, `check-harness-drift: OK`. ### Proof - **Live**: `printf '…' | claude -p --output-format json` returns a well-formed JSON envelope — the stdin form is valid and does not mis-parse or hang. - **TDD (red before green)**: `close-report-lib` RV7/RV8 flipped (empty/missing result now SKIPs, was `malformed`); `close-report` RV-C split — RV-C keeps `malformed`=refuse for a non-empty garbage result, new **RV-C2** asserts an empty result SKIPs and the close PROCEEDS. - **Suites**: `close-report-lib` (81) + `close-report` (142) pass; drift gate OK. ### Commits - idss `main`: `6df89b67` - dev-factory `backport/idss-2161`: `472d5636` ### Context This bricked the close of **#2154** (an ~143 KiB i18n Go-seam diff); #2154 has since landed on `main`. The forward-port of this fix onto dev-factory `main` (LANDING=pr) is owed as a follow-up, like #2155's.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#2161
No description provided.