close-report reviewer gate bricks every close in an interactive session: claude 2.1.318 unauthenticated empty-result JSON is classified malformed, not #228 unauthenticated-skip #2155

Closed
opened 2026-11-04 13:02:13 +00:00 by matou-build-agent · 1 comment

Symptom

In an interactive standing session (the #228 scenario), close-report.sh's
independent-reviewer gate (#197) refuses EVERY status: success close with:

reviewer output was empty or unparseable — failing the close CLOSED (#197)

and posts an independent reviewer … verdict malformed comment with empty findings.

Cause

cr_review_invoke runs claude -p --model "$SWARM_REVIEW_MODEL" --output-format json.
A nested claude -p child in an interactive standing session is not logged in
(#228's exact case). On the installed claude version (2.1.318, Claude Code)
an unauthenticated headless call exits 1 and writes a parseable result JSON to
stdout that carries no result/verdict content (total_cost_usd: 0,
input_tokens: 0, empty iterations), e.g.:

{"duration_api_ms":0,"stop_reason":"stop_sequence","total_cost_usd":0,"usage":{"input_tokens":0,"output_tokens":0,...}}

cr_review_parse maps this to the malformed/empty → fail CLOSED branch instead
of the unauthenticated → SKIP branch #228 added for exactly this situation. So
#228's "treat an unauthenticated reviewer as absent, proceed on the deterministic
gates" intent never fires — the close bricks.

(Reproduced directly: claude -p --model <m> --output-format json "Reply OK." → exit 1,
the empty-usage JSON above on stdout, empty stderr.)

Proposed fix

Teach cr_review_parse (.sandcastle/close-report.sh) to recognise this claude
2.1.318 empty-result shape as unauthenticated (→ skip, #228), not malformed:
e.g. when the result JSON has no reviewer result/verdict payload AND zero usage
(input_tokens == 0 && output_tokens == 0) AND/OR the child exited non-zero with no
result, classify it unauthenticated. Keep the genuine fail-CLOSED for a reviewer
that truly ran (non-zero usage) and returned garbage.

Found while working

#2136 (i18n Go seam: rescue checks + remedies). Its slice is complete, verified green
(full Go gate — gofmt/build/vet/test/golangci-lint over both modules; full TS gate;
full dashboard unit suite 2274 + the new red→green seam tests) and pushed to its
worker branch for the host to land, but the close-report gate cannot complete in this
session because of the above. .sandcastle/close-report.sh is a protected path (#445),
so this is filed for a session to rule on the machinery change rather than edited in place.

## Symptom In an **interactive standing session** (the #228 scenario), `close-report.sh`'s independent-reviewer gate (#197) refuses EVERY `status: success` close with: ``` reviewer output was empty or unparseable — failing the close CLOSED (#197) ``` and posts an `independent reviewer … verdict malformed` comment with empty findings. ## Cause `cr_review_invoke` runs `claude -p --model "$SWARM_REVIEW_MODEL" --output-format json`. A nested `claude -p` child in an interactive standing session is **not logged in** (#228's exact case). On the installed `claude` version (**2.1.318**, Claude Code) an unauthenticated headless call exits **1** and writes a *parseable* result JSON to stdout that carries **no `result`/verdict content** (`total_cost_usd: 0`, `input_tokens: 0`, empty `iterations`), e.g.: ```json {"duration_api_ms":0,"stop_reason":"stop_sequence","total_cost_usd":0,"usage":{"input_tokens":0,"output_tokens":0,...}} ``` `cr_review_parse` maps this to the **`malformed`/empty → fail CLOSED** branch instead of the **`unauthenticated` → SKIP** branch #228 added for exactly this situation. So #228's "treat an unauthenticated reviewer as absent, proceed on the deterministic gates" intent never fires — the close bricks. (Reproduced directly: `claude -p --model <m> --output-format json "Reply OK."` → exit 1, the empty-usage JSON above on stdout, empty stderr.) ## Proposed fix Teach `cr_review_parse` (`.sandcastle/close-report.sh`) to recognise this claude 2.1.318 empty-result shape as **`unauthenticated`** (→ skip, #228), not `malformed`: e.g. when the result JSON has no reviewer `result`/verdict payload AND zero usage (`input_tokens == 0 && output_tokens == 0`) AND/OR the child exited non-zero with no `result`, classify it `unauthenticated`. Keep the genuine fail-CLOSED for a reviewer that truly ran (non-zero usage) and returned garbage. ## Found while working #2136 (i18n Go seam: rescue checks + remedies). Its slice is complete, verified green (full Go gate — gofmt/build/vet/test/golangci-lint over both modules; full TS gate; full dashboard unit suite 2274 + the new red→green seam tests) and pushed to its worker branch for the host to land, but the close-report gate cannot complete in this session because of the above. `.sandcastle/close-report.sh` is a protected path (#445), so this is filed for a session to rule on the machinery change rather than edited in place.
Author
Member

close-report (push mode) — landed on main

What landed. _cr_review_is_auth_error (the #197/#228 reviewer-gate auth classifier in .sandcastle/close-report-lib.sh) now recognises the unauthenticated claude -p child by a version-robust signal: a usage block reporting zero input AND zero output tokens — the model was never invoked, so no review happened — classified unauthenticated → SKIP (proceed on the deterministic gates, #228). The pre-existing /login-prompt branch is kept. The fail-CLOSED posture is PRESERVED for a reviewer that genuinely ran: non-zero usage with garbage output still normalises to malformed.

This fixes the reported brick directly. Confirmed on this host: claude is 2.1.228, and claude -p --output-format json while unauthenticated exits 1 with .result = "Failed to authenticate: OAuth session expired and could not be refreshed", is_error:true, terminal_reason:"api_error", and an all-zero usage block — a shape that does not match the old /login|Not logged in regex, so it fell to malformed → fail CLOSED. The 2.1.318 shape in the ticket (no .result, zero usage) evaded it the same way. Both now classify unauthenticated.

Vendored path (#445 / ADR 0180). close-report-lib.sh is a factory file, so it was fixed upstream, not edited in place:

  • dev-factory backport branch backport/idss-2155 off the current pin 4e8316c2, commit ea75077899d7dc6b68fa20a273c3bd4d030b4a11 (pushed; ls-remote-confirmed).
  • re-vendored via onboarding/onboard.sh vendor (ran plain): FACTORY_REF 4e8316c2 → ea75077899, exactly 2 files updated (close-report-lib.sh, tests/close-report-lib-test.sh), 214 unchanged, FACTORY_MANIFEST no churn, check-harness-drift: OK.
  • idss commit 7553ae07 on main (re-vendor + STATUS.md).

Proof (TDD, red before green). New tests in tests/close-report-lib-test.sh:

  • RV12 — the 2.1.228 OAuth-expired zero-usage shape → unauthenticated (was malformed: red confirmed before the fix).
  • RV12b — the 2.1.318 no-.result zero-usage shape → unauthenticated.
  • RV12c — a reviewer that truly RAN (non-zero usage) returning garbage stays malformed (fail-CLOSED preserved — the line zero-usage must not cross).
  • RV12d — a parseable verdict wins over zero usage.

Full suites green after the fix: close-report-lib 81 checks, close-report (end-to-end, shimmed claude) 139 checks. bash -n clean on both files.

Follow-up filed: #2156 — forward-port this commit onto dev-factory main (cherry-picks cleanly; close-report-lib.sh is byte-identical pin→main). ready-for-human because dev-factory main is LANDING=pr and it sits under the watched #1684.

Collateral: #2136 (named in this ticket as blocked by the bricked gate) is now un-bricked — a session/worker can re-attempt its close. Left as-is (not re-labelled from here, rule 1).

Ruled by agent under ADR 0174 — veto anytime. Two-way door: fully revertible (the FACTORY_REF pin bump + the two-file vendor), proven by the red→green TDD above and the drift gate. No one-way door touched.

## close-report (push mode) — landed on `main` **What landed.** `_cr_review_is_auth_error` (the #197/#228 reviewer-gate auth classifier in `.sandcastle/close-report-lib.sh`) now recognises the unauthenticated `claude -p` child by a **version-robust signal**: a `usage` block reporting **zero input AND zero output tokens** — the model was never invoked, so no review happened — classified `unauthenticated` → SKIP (proceed on the deterministic gates, #228). The pre-existing `/login`-prompt branch is kept. The fail-CLOSED posture is PRESERVED for a reviewer that genuinely ran: non-zero usage with garbage output still normalises to `malformed`. This fixes the reported brick directly. Confirmed on this host: `claude` is **2.1.228**, and `claude -p --output-format json` while unauthenticated exits 1 with `.result = "Failed to authenticate: OAuth session expired and could not be refreshed"`, `is_error:true`, `terminal_reason:"api_error"`, and an all-zero `usage` block — a shape that does **not** match the old `/login|Not logged in` regex, so it fell to `malformed` → fail CLOSED. The 2.1.318 shape in the ticket (no `.result`, zero usage) evaded it the same way. Both now classify `unauthenticated`. **Vendored path (#445 / ADR 0180).** `close-report-lib.sh` is a factory file, so it was fixed upstream, not edited in place: - dev-factory backport branch `backport/idss-2155` off the current pin `4e8316c2`, commit **`ea75077899d7dc6b68fa20a273c3bd4d030b4a11`** (pushed; `ls-remote`-confirmed). - re-vendored via `onboarding/onboard.sh vendor` (ran plain): **FACTORY_REF `4e8316c2` → `ea75077899`**, exactly 2 files updated (`close-report-lib.sh`, `tests/close-report-lib-test.sh`), 214 unchanged, `FACTORY_MANIFEST` no churn, `check-harness-drift: OK`. - idss commit **`7553ae07`** on `main` (re-vendor + STATUS.md). **Proof (TDD, red before green).** New tests in `tests/close-report-lib-test.sh`: - `RV12` — the 2.1.228 OAuth-expired zero-usage shape → `unauthenticated` (was `malformed`: red confirmed before the fix). - `RV12b` — the 2.1.318 no-`.result` zero-usage shape → `unauthenticated`. - `RV12c` — a reviewer that truly RAN (non-zero usage) returning garbage **stays `malformed`** (fail-CLOSED preserved — the line zero-usage must not cross). - `RV12d` — a parseable verdict wins over zero usage. Full suites green after the fix: `close-report-lib` **81 checks**, `close-report` (end-to-end, shimmed claude) **139 checks**. `bash -n` clean on both files. **Follow-up filed:** #2156 — forward-port this commit onto dev-factory `main` (cherry-picks cleanly; `close-report-lib.sh` is byte-identical pin→main). `ready-for-human` because dev-factory `main` is `LANDING=pr` and it sits under the watched #1684. **Collateral:** #2136 (named in this ticket as blocked by the bricked gate) is now un-bricked — a session/worker can re-attempt its close. Left as-is (not re-labelled from here, rule 1). **Ruled by agent under ADR 0174 — veto anytime.** Two-way door: fully revertible (the FACTORY_REF pin bump + the two-file vendor), proven by the red→green TDD above and the drift gate. No one-way door touched.
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#2155
No description provided.