Skip to content

fix: robust KAIZEN_IMPEDIMENTS JSON extraction (kaizen #313)#252

Merged
aviadr1 merged 3 commits intomainfrom
fix/kaizen-impediments-json-extraction
Mar 21, 2026
Merged

fix: robust KAIZEN_IMPEDIMENTS JSON extraction (kaizen #313)#252
aviadr1 merged 3 commits intomainfrom
fix/kaizen-impediments-json-extraction

Conversation

@aviadr1
Copy link
Copy Markdown

@aviadr1 aviadr1 commented Mar 21, 2026

Summary

  • Adds multi-fallback JSON extraction to pr-kaizen-clear.sh so KAIZEN_IMPEDIMENTS declarations succeed on first submission
  • Fixes edge cases where STDOUT lacks the KAIZEN_IMPEDIMENTS: prefix (raw JSON array) or STDOUT is empty (heredoc body extraction)
  • Adds 3 new test cases (81 total, all pass)

Root Cause

The original extraction only tried two paths: STDOUT with prefix, then CMD_LINE (which has heredoc body stripped). When STDOUT contained just the JSON without the prefix, both paths failed.

Changes

  • Fallback 1: Try parsing STDOUT directly as a JSON array (no prefix needed)
  • Fallback 2: Extract heredoc body from the full COMMAND text (not the stripped CMD_LINE)
  • Fallback 3: Existing CMD_LINE inline extraction preserved

Test plan

  • All 81 pr-kaizen-clear tests pass
  • All hook test suites pass (700+ tests)
  • New test: raw JSON array in STDOUT without prefix
  • New test: multiline JSON without prefix
  • New test: empty STDOUT with heredoc body extraction

Closes Garsson-io/kaizen#313

Run tag: batch-260321-1108-3ef8/run-2

🤖 Generated with Claude Code

…aizen qwibitai#313)

The JSON extraction pipeline could fail when STDOUT didn't contain the
KAIZEN_IMPEDIMENTS: prefix (just raw JSON), or when STDOUT was empty
but the COMMAND contained a heredoc with the JSON body.

Added three fallback layers:
1. Primary: extract from STDOUT after KAIZEN_IMPEDIMENTS: prefix (existing)
2. Fallback 1: try parsing STDOUT directly as JSON array (no prefix needed)
3. Fallback 2: extract heredoc body from full COMMAND text
4. Fallback 3: extract from CMD_LINE inline echo (existing)

Added 3 new test cases covering the qwibitai#313 edge cases (81 total, all pass).

Run tag: batch-260321-1108-3ef8/run-2
Closes Garsson-io/kaizen#313

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aviadr1 aviadr1 enabled auto-merge (squash) March 21, 2026 09:46
aviadr1 and others added 2 commits March 21, 2026 11:50
The cross-worktree gate clearing tests expected 0 state files after
clearing, but mark_reflection_done() (from PR #249, kaizen #288) creates
kaizen-done-* marker files. Updated assertions to exclude these expected
markers when counting remaining state files.

Fixes 2 pre-existing test failures (62 total, all pass now).

Run tag: batch-260321-1108-3ef8/run-2

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Accept upstream's more precise approach (ls pr-kaizen-* instead of
filtering with grep -v) for the interaction matrix tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aviadr1 aviadr1 merged commit 4d566fe into main Mar 21, 2026
3 checks passed
@aviadr1 aviadr1 added the overnight-dent Created by overnight-dent batch automation label Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

overnight-dent Created by overnight-dent batch automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[L2] KAIZEN_IMPEDIMENTS structured JSON sometimes fails to clear gate on first submission

1 participant