rehearsal reporter: save the raw diagnosis, harden its parsing, re-check the sig before filing (dup #402 + 3 silent diagnosis flakes) #403

Closed
opened 2026-08-10 16:41:49 +00:00 by ben · 1 comment
Owner

The reporter's headless diagnosis + filing path has three related defects, all observed live today (drives 141050Z, 154053Z, 162053Z):

  1. Diagnosis output is discarded on failure. diagnosis="$(timeout 900 claude -p …)" — when the output doesn't parse, nothing records what claude actually emitted (reporter-claude.err was 0 bytes on all three flakes; jq's stderr is sent to /dev/null). Save the raw stdout to $run_dir/logs/reporter-claude.out unconditionally so a flake is diagnosable after the fact.

  2. Output parsing is fragile. A manual run of the identical prompt returns clean JSON, but the in-pipeline run intermittently yields something jq can't parse (empty title → generic ready-for-human filing, 3 of 5 runs today). Harden: strip markdown code fences before jq, or invoke claude -p --output-format json and unwrap .result; treat a still-unparseable diagnosis as unconfident but SAVE it (per 1).

  3. Stale open-issues snapshot files duplicates. open_issues is fetched once at script start (rehearsal-report.sh:62), but filing happens after a diagnosis that can take up to 15 minutes — any sig-matched issue filed in between is invisible. Live consequence: #402 filed as a duplicate of #400 (same sig dcf630511b50), blocked the drive with a ready-for-human dup, needed hand cleanup. Re-fetch (or at least re-check the sig) immediately before filing.

All three live in .sandcastle/rehearsal-report.sh. Not wired as a #378 blocker — reds still block the drive today; this makes their tickets trustworthy and duplicate-free.

The reporter's headless diagnosis + filing path has three related defects, all observed live today (drives `141050Z`, `154053Z`, `162053Z`): 1. **Diagnosis output is discarded on failure.** `diagnosis="$(timeout 900 claude -p …)"` — when the output doesn't parse, nothing records what claude actually emitted (`reporter-claude.err` was 0 bytes on all three flakes; jq's stderr is sent to /dev/null). Save the raw stdout to `$run_dir/logs/reporter-claude.out` unconditionally so a flake is diagnosable after the fact. 2. **Output parsing is fragile.** A manual run of the identical prompt returns clean JSON, but the in-pipeline run intermittently yields something jq can't parse (empty title → generic ready-for-human filing, 3 of 5 runs today). Harden: strip markdown code fences before jq, or invoke `claude -p --output-format json` and unwrap `.result`; treat a still-unparseable diagnosis as unconfident but SAVE it (per 1). 3. **Stale open-issues snapshot files duplicates.** `open_issues` is fetched once at script start (`rehearsal-report.sh:62`), but filing happens after a diagnosis that can take up to 15 minutes — any sig-matched issue filed in between is invisible. Live consequence: #402 filed as a duplicate of #400 (same sig `dcf630511b50`), blocked the drive with a ready-for-human dup, needed hand cleanup. Re-fetch (or at least re-check the sig) immediately before filing. All three live in `.sandcastle/rehearsal-report.sh`. Not wired as a #378 blocker — reds still block the drive today; this makes their tickets trustworthy and duplicate-free.
Author
Owner

Fixed in b977854 (on origin/main). All three defects in .sandcastle/rehearsal-report.sh:

  1. Raw diagnosis saved — the raw claude stdout is now printfed to logs/reporter-claude.out unconditionally (right after capture, before any continue), so a parse flake is diagnosable after the fact.
  2. Parsing hardened — new parse_diagnosis strips lone markdown-fence lines (```json) then falls back to carving the first-brace…last-brace span before jq; a still-unparseable diagnosis is filed unconfident (ready-for-human) but SAVED, never dropped (the fallback body now points at reporter-claude.out).
  3. Sig re-checked before filing — the open_issues snapshot is re-fetched (match_sig + append_evidence extracted for reuse) immediately before the create POST; a sig filed by a concurrent drive during the up-to-15-min diagnosis is appended-to, not re-filed as a duplicate (the #402→#400 bug).

Test-first at the offline seam .sandcastle/tests/rehearsal-report-test.sh (drives the real script with shimmed curl/claude): cases 12–15 added — raw save; fenced JSON parses to a confident filing; unparseable diagnosis saved + filed ready-for-human; stale-snapshot appends instead of re-filing (the curl shim gained a 2nd-fetch fixture to simulate the concurrent filing). All 15 cases pass; verified red→green against the pre-change script. STATUS.md updated.

Fixed in b977854 (on origin/main). All three defects in `.sandcastle/rehearsal-report.sh`: 1. **Raw diagnosis saved** — the raw claude stdout is now `printf`ed to `logs/reporter-claude.out` unconditionally (right after capture, before any `continue`), so a parse flake is diagnosable after the fact. 2. **Parsing hardened** — new `parse_diagnosis` strips lone markdown-fence lines (```` ```json ````) then falls back to carving the first-brace…last-brace span before jq; a still-unparseable diagnosis is filed unconfident (ready-for-human) but SAVED, never dropped (the fallback body now points at reporter-claude.out). 3. **Sig re-checked before filing** — the `open_issues` snapshot is re-fetched (`match_sig` + `append_evidence` extracted for reuse) immediately before the create POST; a sig filed by a concurrent drive during the up-to-15-min diagnosis is appended-to, not re-filed as a duplicate (the #402→#400 bug). Test-first at the offline seam `.sandcastle/tests/rehearsal-report-test.sh` (drives the real script with shimmed curl/claude): cases 12–15 added — raw save; fenced JSON parses to a confident filing; unparseable diagnosis saved + filed ready-for-human; stale-snapshot appends instead of re-filing (the curl shim gained a 2nd-fetch fixture to simulate the concurrent filing). All 15 cases pass; verified red→green against the pre-change script. STATUS.md updated.
ben closed this issue 2026-08-10 17:15:00 +00:00
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#403
No description provided.