fix: accept a punctuation-delimited reason on the RESULT line - #9
Conversation
The result parser only matched a RESULT line whose terminal token was the
entire rest of the line, but the implementer contract in the same file presents
the tokens as "RESULT: BLOCKED — name the blocker". Implementers reasonably
emit that shape, the line failed to match, and a correct run with a correct
report was classified IMPLEMENTER_STATE: COMPANION_FAILURE — exiting 11 without
ever running the caller's --verify.
Accept an optional trailing reason that starts with a punctuation character, so
the parser agrees with the shape its own contract displays. Every existing
rejection survives: RESULT: DONEISH still fails on the token boundary, bare
trailing prose ("RESULT: DONE and everything passed") stays unparseable, and
the ^ anchor keeps the contract's own four indented token lines inert, so a
report quoting the contract cannot self-classify.
The fix goes in the parser rather than the contract wording, because the parser
is the layer that authors the disagreement, and rewording cannot help reports
already written in that shape.
Verified: tests/run.sh 18 passed 0 failed; tests/stop-report.sh 24 passed.
Reverting only lib-write-turn.sh turns the new t7b case red while t7 keeps
passing, so the new case isolates exactly the new behaviour.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe result parser now accepts supported statuses followed by trailing reason text. The stop-report tests add a ChangesRESULT Parsing
Estimated code review effort: 2 (Simple) | ~10 minutes Mergeability Score: ⚪ Minimal · up to This localized parser change accepts punctuation-delimited reasons on RESULT lines while preserving the existing token boundaries; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
What
_write_turn_result_state(hooks/lib-write-turn.sh:27) only matched a RESULT line whose terminal token was the entire rest of the line:It now accepts an optional trailing reason that starts with a punctuation character.
Why
The implementer contract in the same file (
lib-write-turn.sh:75-78) presents the tokens as:So implementers emit
RESULT: BLOCKED — <reason>. That line did not match, the run was classifiedIMPLEMENTER_STATE: COMPANION_FAILURE, and the loop exited 11 without ever running the caller's--verify— even though the work and the report were correct.The fix goes in the parser, not the contract wording: the parser is the layer that authors the disagreement, and rewording cannot help reports already written in that shape.
Observed live — the dispatch that implemented this fix was itself rejected by the old parser, for ending with
RESULT: DONE — plan fully executed, verification output pasted below.Safety — every existing rejection survives
RESULT: BLOCKEDBLOCKEDRESULT: BLOCKED — active lock prevented testsBLOCKEDRESULT: DONE - all greenDONERESULT: FAILED: verifier diedFAILEDRESULT: NEEDS_ANSWERS␠␠␠NEEDS_ANSWERSRESULT: DONEISHRESULT: DONE_ISHRESULT: DONE and everything passedRESULT: DONE — quoted- RESULT: DONETwo of these carry the safety argument. The
^anchor keeps the contract's own four token lines inert — they are indented four spaces inside theCONTRACTstring — so a report that quotes the contract still cannot self-classify. And trailing prose must start with punctuation, soRESULT: DONE and everything passedstays unparseable rather than being silently read as DONE.The expression is pure POSIX ERE with no multibyte literal in a bracket expression, so the em dash is matched by a negated ASCII class.
How it was verified
bash tests/run.sh— 18 passed, 0 failedbash tests/stop-report.sh— 24 passed, 0 failedbash -n hooks/lib-write-turn.sh— cleanhooks/lib-write-turn.shturns the newt7bcase red (trailing-reason was classified as companion failure) whilet7keeps passing — so the new case isolates exactly the new behaviour and can fail.Installation impact
The change lands in this repo's
hooks/, but dispatches run the installed copy at~/.claude/hooks/. It takes effect afternode install.mjs, not at merge.Summary by CodeRabbit
Bug Fixes
BLOCKEDresults with additional reasons are now correctly recognized and reported.Tests