Repository navigation
feat(#1024): add build_loop_state.py — issue-refinement-loop の LOOP_STATE builder を追加し手書き JSON routing を禁止する - #1077
Conversation
… validation Adds scripts/build_loop_state.py that constructs LOOP_STATE_V1 from REFINEMENT_LOOP_PLAN_V1 and ISSUE_REVIEW_RESULT_COMPACT_V1. Includes schema validation, provenance tracking, and builder-first flow docs. AC1: build_loop_state.py added with approve/needs-fix fixture tests AC2: validates against loop_state.schema.json via iter_errors() (all errors) AC3: decide_next_loop_action.py integration tested with builder output AC4: SKILL.md updated to reference build_loop_state (builder-first flow) AC5: LOOP_STATE_BUILD_RESULT_V1 with status/sha256/errors/warnings/provenance AC6: provenance includes planner/review path/hash, issue_number, iteration, schema path/hash AC7: builder does not produce next_action field AC8: argparse allow_abbrev=False, file-path-only input AC9: negative fixtures — required missing, mismatch, regression, unknown verdict, boundary AC10: integration tests approve/needs-fix/scope_signal/max_iterations routing AC11: references/loop-state.md updated with builder-first flow section AC12: builder performs no gh mutations AC13: pnpm typecheck/lint/test/build and pytest all pass Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Preview URLPreview removed (PR #1077 closed). |
PR Review: feat(#1024) -- build_loop_state.pyAllowed Paths Gate
AC VerificationAC1: PASS (control-plane: 17 passed) AC5 CLI Output (preflight-scope: pr_review_only)Executed by review-subagent using fixtures extracted from PR branch head (57c5144): Output (exit code 0, status=ok): VerdictLOOP_VERDICT_V2: |
判定REQUEST_CHANGES。 #1024 は、 Blocking findings1.
|
- Blocker 1: split load_json into load_json_object/load_json_array so --blockers-history-file accepts only JSON arrays; non-array files are warned rather than silently swallowed - Blocker 2: validate required planner decisions fields (web_research_policy, scope_signal_guard, delivery_rollup, follow_up_materialization) and review VERDICT; missing fields return status=invalid - Blocker 3: decide_next_loop_action.py now uses loop_state.last_verdict as the single source of truth when --review-result-verdict is omitted - Blocker 4: wrap int() conversion of issue_number fields in try/except; non-integer values return status=invalid with JSON output (no traceback) - Non-blocking: use jsonschema.validators.validator_for() to auto-select validator based on $schema - Add 12 new negative/integration tests covering all 4 blockers Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
test comment from review subagent |
|
削除テスト用コメント(直後に上書き予定) |
|
LOOP_VERDICT_V2 PR 1077 iteration 1: verdict=REQUEST_CHANGES, blockers=[B0: PR Body Japanese Check CI fail] |
|
LOOP_VERDICT_V2 PR1077 iter1: REQUEST_CHANGES. B0=PR Body Japanese Check CI fail. 4 blockers fixed ok. AC5 ok. |
squne121
left a comment
There was a problem hiding this comment.
iteration 1 fix_delta review: APPROVE (self-authored, comment only).
All 4 prior REQUEST_CHANGES blockers confirmed fixed, verified behaviorally on PR head 1585485. Bot self-report not used.
Verification summary
- Allowed Paths Gate: ok. All 14 changed files lie within the Issue 1024 contract Allowed Paths (review_subagent recomputed deterministically from changed-files set x contract snapshot).
- AC5 CLI (preflight-scope pr_review_only): ran PR-head build_loop_state.py and got status ok with full LOOP_STATE_BUILD_RESULT_V1 fields (status, loop_state_path, loop_state_sha256, errors[], warnings[], provenance). provenance carries planner/review/schema path+hash, issue_number, iteration (AC5, AC6).
- PR-head tests: builder, negative, decide-integration suites = 46 passed (consistent with control-plane 909 all-pass).
Blocker fixes (behavioral)
- Blocker 1 (blockers-history JSON array): array preserved, object or missing routed to warnings list (fail-closed, no silent swallow). 3 negative tests.
- Blocker 2 (missing input artifact fail-closed): planner decisions missing, the four decision sub-fields missing, and review VERDICT missing all yield status=invalid plus an errors list. Negative tests cover each.
- Blocker 3 (router last_verdict): when the verdict flag is omitted, loop_state.last_verdict is used as the authoritative source (integration tests cover approve and needs-fix). The conflict guard is retained: both values present and differing yields inconsistent_state with exit code 3 (directly confirmed). No regression.
- Blocker 4 (issue_number type safety): non-integer issue_number in planner or review is caught, no traceback, status=invalid plus an errors list. 2 negative tests.
LOOP_VERDICT_V2
LOOP_VERDICT_V2:
pr_number: 1077
reviewed_head_sha: "158548566470b920fb44ea945642b7553a81284c"
verdict: APPROVE
merge_ready: true
required_auto_actions: []
allowed_paths_gate:
status: ok
producer_role: review_subagent
worker_report_used_as_canonical: false
changed_files_count: 14
out_of_path_files: []
blockers: []
summary: iteration 1 fix_delta resolves the four prior blockers and stays within scopeSelf-authored PR: merge is left to human judgment.
概要
Issue #1024 の実装。
build_loop_state.pyを追加し、REFINEMENT_LOOP_PLAN_V1とISSUE_REVIEW_RESULT_COMPACT_V1からLOOP_STATE_V1を生成して routing に渡す builder-first フローを確立する。変更内容
.claude/skills/issue-refinement-loop/scripts/build_loop_state.py— LOOP_STATE_V1 ビルダー(AC1-AC13).claude/skills/issue-refinement-loop/schemas/loop_state_build_result.schema.json— ビルド結果スキーマ(AC5).claude/skills/issue-refinement-loop/tests/test_loop_state_builder.py— 主要テスト(AC1,AC6,AC7,AC8,AC12).claude/skills/issue-refinement-loop/tests/test_loop_state_builder_negative.py— ネガティブフィクスチャ(AC9).claude/skills/issue-refinement-loop/tests/test_loop_state_decide_integration.py— 統合テスト(AC3,AC10).claude/skills/issue-refinement-loop/tests/fixtures/loop_state_builder/**— テストフィクスチャ 6 件.claude/skills/issue-refinement-loop/SKILL.md—build_loop_state参照追加(AC4,AC11).claude/skills/issue-refinement-loop/references/loop-state.md— builder-first flow セクション追加(AC11)AC 達成状況
pytest test_loop_state_builder.py -v— 17 passedtest -f build_loop_state.py— 存在確認 + スキーマ検証テストpytest test_loop_state_decide_integration.py -v— 7 passedSKILL.mdにbuild_loop_state2 箇所preflight-scope: pr_review_onlypytest -k provenance— 2 passedpytest -k no_next_action— 1 passedpytest -k no_raw_json— 1 passed;allow_abbrev=False確認pytest test_loop_state_builder_negative.py -v— 10 passedpytest -k builder— 7 passedreferences/loop-state.mdにbuild_loop_state2 箇所pytest -k no_gh_mutation— 1 passed; ソースに gh コマンドなしpnpm typecheck/lint/test/build— all pass; pytest 864 passedテスト計画
uv run pytest .claude/skills/issue-refinement-loop/tests/test_loop_state_builder.py -v— 17 passeduv run pytest .claude/skills/issue-refinement-loop/tests/test_loop_state_builder_negative.py -v— 10 passeduv run pytest .claude/skills/issue-refinement-loop/tests/test_loop_state_decide_integration.py -v— 7 passeduv run pytest .claude/skills/issue-refinement-loop/tests/ -q— 864 passed (既存テスト含む)pnpm typecheck— passpnpm lint(playwright-report 除外) — passpnpm test— 922 passedpnpm build— passCloses #1024
🤖 Generated with Claude Code