Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "issue-refinement-loop Step 2 の validator-first ゲートを child intermediate validator(review_compact.validate_intermediate_v1)へ完全移行し、build_refinement_phase_state.py の review phase gate を validation_status のみでなく schema/schema_version/envelope_kind/violations/入力バイト digest/issue番号へ束縛することで、SKILL.md Step 2 (line 210 相当) と Step 2a (line 262 相当) の wiring 矛盾と phase gate の弱い束縛を解消する"
change_kind: codeParent Issue
なし(単独改善)
Parent Goal Ref
N/A(親 Issue なし)
Current Validated Scope
本 Issue は OWNER の敵対的レビュー(issuecomment-5091837021、REQUEST_CHANGES)を受けて全面的に再定義されたものであり、issue-refinement-loop の codebase-investigator による独立検証で以下を確認済みである。
.claude/skills/issue-refinement-loop/scripts/emit_parent_review_envelope_v2.pyのvalidate_child_intermediate()/build_validate_intermediate_result()(command registry 登録済みreview_compact.validate_intermediate_v1)が実装済みであり、child intermediate(approve 8 行 / needs-fix 9 行)専用の grammar としてvalidate_review_compact_output.pyの V1/V2 final grammar とは明示的に分離されている。.claude/skills/issue-refinement-loop/SKILL.mdの Step 2「validator-first 順序」節(209-210 行付近)は、approve / needs-fix いずれの経路でも SubAgent の最終応答テキストをそのままvalidate_review_compact_output.py(review_compact.validate)へ渡すと定めている一方、同じファイルの Step 2a(262 行付近)は child の raw stdout bytes を独立コマンドreview_compact.validate_intermediate_v1へ先に渡すべきと定めており、同一 SSOT 内で wiring が矛盾している。.claude/skills/issue-refinement-loop/scripts/build_refinement_phase_state.pyの_validate_review_validation_gate()(Issue 実装: issue-reviewer SubAgent の compact 出力を orchestrator 側で決定論的に検証する fail-closed gate を追加する #1507 AC24)は、--phase reviewかつ--source-kind issue_review_result_compact_v1のとき--review-validation-result-pathの JSON のvalidation_status == "valid"のみを検証しており、schema/schema_version/envelope_kind/violations == []/ 実入力バイトとの digest 束縛 / issue 番号束縛のいずれも検証していない。
Remaining Parent Gaps
なし
Outcome
issue-refinement-loop の Step 2 が、child SubAgent の raw stdout を必ず review_compact.validate_intermediate_v1(emit_parent_review_envelope_v2.py --validate-intermediate)へ通してから routing 判断を行うという単一の wiring に統一される(approve / needs-fix いずれの経路でも、SKILL.md 内に矛盾する直接呼び出し記述が残らない)。あわせて build_refinement_phase_state.py の review phase gate が、REVIEW_COMPACT_INTERMEDIATE_VALIDATION_RESULT_V1 の schema / schema_version / envelope_kind / violations == [] を検証し、渡された --source-path の実バイト内容から再計算した SHA256 が validation result の input_sha256 と一致することを確認し、新規必須引数 --issue-number(review phase + issue_review_result_compact_v1 の場合のみ必須)と normalized_payload.ARTIFACT の issue 番号セグメントが一致することを確認する。これにより、validation_status == "valid" という caller-supplied claim のみを信用する現状(stale / 別 Issue の validation result を別の source artifact と組み合わせて通過させ得る状態)が解消される。
Background
.claude/skills/issue-refinement-loop/scripts/emit_parent_review_envelope_v2.py は 3 つの独立した grammar / validator を明示的に区別している。
- child intermediate(
validate_child_intermediate()/build_validate_intermediate_result()、command registryreview_compact.validate_intermediate_v1): approve 8 行 / needs-fix 9 行(REVIEWER_BLOCKER_CLAIM込み)。schema literal はREVIEW_COMPACT_INTERMEDIATE_VALIDATION_RESULT_V1(同ファイルのVALIDATE_INTERMEDIATE_SCHEMA定数)。 - legacy V1 final(
validate_review_compact_output.pyのvalidate_review_compact_output()、command registryreview_compact.validate): approve 8 行 / needs-fix 13 行(REPLAY_*5 フィールド込み)。schema literal はREVIEW_COMPACT_VALIDATION_RESULT_V1。 - parent-owned V2 final(
validate_review_compact_output.pyのvalidate_review_compact_output_v2()、command registryreview_compact.validate_v2): needs-fix 15 行(REVIEWER_BLOCKER_CLAIM+PARENT_REPLAY_*6 フィールド込み)。
.claude/skills/issue-refinement-loop/SKILL.md の Step 2「validator-first 順序」節(209-210 行付近)は、次のように「approve / needs-fix いずれの経路でも」validate_review_compact_output.py(review_compact.validate)へ SubAgent の最終応答テキストをそのまま渡すと定めている。
validator-first 順序(Issue #1507 AC23、routing table より前に評価する): orchestrator は approve / needs-fix いずれの経路でも、SubAgent stdout の生フィールドを consume する前に、必ず
validate_review_compact_output.py(review_compact.validate, command_registry.py 登録済み、--issue-number必須引数)へ SubAgent の最終応答テキストをそのまま(re-transcribe せず)渡し、REVIEW_COMPACT_VALIDATION_RESULT_V1を得る。
一方、同じファイルの Step 2a(262 行付近)は次のように、child の raw stdout bytes を先に review_compact.validate_intermediate_v1 へ通すべきと定めている。
orchestrator は child の raw stdout bytes を、独立コマンド
review_compact.validate_intermediate_v1(emit_parent_review_envelope_v2.py --validate-intermediate、Issue #1541 PR #1557 OWNER REQUEST_CHANGES Blocker 1)へ渡し、strict validation 済みのenvelope_kind(approve/needs_fix_intermediate)・normalized_payload・canonical_reviewer_blocker_claimを得る。
compact_review_result.py の needs-fix 実出力は 9 行(approve 8 フィールド + REVIEWER_BLOCKER_CLAIM)であり、この 9 行を Step 2 の記述通り validate_review_compact_output.py(V1 final grammar、13 行固定の REPLAY_* を期待)へ直接渡すと unknown_field violation で validation_status: invalid / human_judgment_required に fail-close される(このバグ現象自体は #1755 起票時点の Issue でも観測されている)。しかし、この現象に対する正しい修正は V1 final grammar の NEEDS_FIX_FIELDS を書き換えることではなく、Step 2 の wiring を Step 2a と同じ review_compact.validate_intermediate_v1 に統一することである(V1 final grammar は legacy 経路向けの独立した pure validation grammar として意図的に維持されている)。
さらに、build_refinement_phase_state.py の _validate_review_validation_gate()(Issue #1507 AC24)は、review phase の入力について実質的に次の 1 点しか確認していない。
validation_status = validation_payload.get("validation_status")
if validation_status != "valid":
raise ValueError(...)schema / schema_version / envelope_kind / violations == [] / 実際の source artifact(child raw stdout)との digest 束縛 / issue 番号束縛のいずれも検証されないため、別 Issue や別 iteration の validation_status: valid な validation result ファイルを、現在処理中の Issue の source artifact と組み合わせて渡しても phase gate を通過してしまう(stale / cross-issue receipt を拒否する仕組みがない)。既存テスト .claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate.py の write_valid_review_validation_result() や .claude/skills/issue-refinement-loop/tests/test_strict_json.py の fixture も、{"validation_status": "valid"} のような最小限の hand-crafted payload で gate を通過させており、この弱い束縛を追認する形になっている。
In Scope
.claude/skills/issue-refinement-loop/SKILL.mdの Step 2「validator-first 順序」節を書き換え、approve / needs-fix いずれの経路でも、SubAgent の raw stdout bytes に対して最初に呼ぶ validator はreview_compact.validate_intermediate_v1(emit_parent_review_envelope_v2.py --validate-intermediate)であると明記する。validate_review_compact_output.py(review_compact.validate、V1 final grammar)を SubAgent の raw stdout に対して直接呼ぶ記述は残さない(review_compact.validate_v2は Step 2a の V2 emission 後にのみ呼ばれる旨を維持する).claude/skills/issue-refinement-loop/SKILL.mdの Step 2 内、build_refinement_phase_state.py --phase reviewの呼び出しブロックと--review-validation-result-pathの説明を、intermediate validation result(REVIEW_COMPACT_INTERMEDIATE_VALIDATION_RESULT_V1)と新規--issue-number引数を渡す形に更新する.claude/skills/issue-refinement-loop/scripts/build_refinement_phase_state.pyの_validate_review_validation_gate()(review phase gate)を拡張し、--phase reviewかつ--source-kind issue_review_result_compact_v1のとき以下を fail-closed(非ゼロ終了・phase-state ファイル未生成)で検証する:--review-validation-result-pathの JSON のschemaが厳密に"REVIEW_COMPACT_INTERMEDIATE_VALIDATION_RESULT_V1"であること(旧"REVIEW_COMPACT_VALIDATION_RESULT_V1"は拒否する)schema_version == "1"validation_status == "valid"envelope_kindが"approve"または"needs_fix_intermediate"のいずれかであることviolationsが空リスト([])であること--source-pathの実バイト内容から再計算した SHA256 が、validation result のinput_sha256フィールド("sha256:<64 hex>"形式)と一致すること
build_refinement_phase_state.pyに新規 CLI 引数--issue-number(positive int)を追加し、--phase reviewかつ--source-kind issue_review_result_compact_v1の場合のみ必須とする。この場合、validation result のnormalized_payload.ARTIFACTに含まれる issue 番号セグメント(.claude/artifacts/issue-refinement-loop/<N>/...の<N>)が--issue-numberの値と一致することを fail-closed で検証する- 上記変更に追従する形で
.claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate.py/.claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate_validation_seam.py/.claude/skills/issue-refinement-loop/tests/test_strict_json.pyの review-phase gate 関連 fixture・ヘルパー・アサーションを新スキーマ・新規引数に合わせて更新する - 新規テストファイル
.claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate_validation_seam_gates.pyを追加し、stale / cross-issue receipt(別 Issue 向けのvalidな validation result を現在の source artifact と組み合わせて渡すケース)・violations非空ケース・legacy schema literal 拒否ケース・実 producer(compact_review_result.py→review_compact.validate_intermediate_v1)の正常系ケースをカバーする negative/positive test を実装する(AC2-AC6 の検証対象) docs/dev/workflows/issue-refinement-loop-design.mdの Step 2a 節の該当箇所を更新し、review phase gate の入力がREVIEW_COMPACT_INTERMEDIATE_VALIDATION_RESULT_V1である旨を明記する(旧REVIEW_COMPACT_VALIDATION_RESULT_V1を review phase gate の入力として説明する記述を残さない)
Out of Scope
.claude/skills/issue-refinement-loop/scripts/validate_review_compact_output.pyの V1 final grammarNEEDS_FIX_FIELDS(13 行固定、REPLAY_*系)自体の変更・廃止判断。本 Issue はこの legacy grammar を「独立した pure validation grammar として維持する」前提のまま Step 2 の wiring のみを修正する。V1 の retirement policy / deprecated 化を正式に決定する場合は別 Issue(schema governance 判断)で扱う.claude/skills/issue-refinement-loop/scripts/emit_parent_review_envelope_v2.pyのbuild_validate_intermediate_result()にある、REVIEWER_BLOCKER_CLAIMの canonicalization 失敗時にvalidation_statusをinvalidへ降格させ忘れているバグ(343-358 行付近、reviewer_blocker_claim_canonicalization_failedviolation が追加されてもvalidation_status: validのまま返る)の修正。これは本 Issue の主題(Step 2 wiring 移行と phase gate の入力束縛)とは異なるレイヤーの独立した契約整合性バグであり、別 Issue として切り出すことを推奨する.claude/skills/issue-refinement-loop/scripts/validate_review_compact_output.pyの_validate_reviewer_blocker_claim_field()(最小限の字句検証のみ)と.claude/skills/issue-refinement-loop/scripts/parent_replay_binding.pyのvalidate_reviewer_blocker_claim()(strict validator)の重複解消・統合。同上、別 Issue 判断で扱う- schema governance の consumer inventory 更新・V1 retirement policy の正式な version bump 判断(
REVIEW_COMPACT_VALIDATION_RESULT_V1/REVIEW_COMPACT_INTERMEDIATE_VALIDATION_RESULT_V1/ISSUE_REVIEW_RESULT_COMPACT_V2の consumer 一覧・互換性ポリシーの正式化) parent_replay_binding.py/reviewer_claim_replay.py/reviewer_claim_replay_state_store.pyの実装変更(本 Issue の対象は Step 2 の validator wiring と review phase gate の入力束縛のみ)post_rewrite_check/decide_next_actionphase の review-validation-result-path 取り扱い(Issue 実装: issue-reviewer SubAgent の compact 出力を orchestrator 側で決定論的に検証する fail-closed gate を追加する #1507 AC24 の Out of Scope を維持し、review phase gate の拡張はreviewphase にのみ適用する)
Acceptance Criteria
- AC1:
.claude/skills/issue-refinement-loop/SKILL.mdの Step 2 セクション(### Step 2:見出しから次の##/###見出し直前まで、#### Step 2aを含む)内に、review_compact.validate_intermediate_v1を指す固有パターン(validate_intermediate_v1または_intermediate_v1)がreview_compact.validate_v2を指すパターンより先に出現し、かつreview_compact.validate(_intermediate_v1にも_v2にも一致しない、bare なreview_compact.validateトークン)が Step 2 セクション内に存在しない - AC2:
.claude/skills/issue-refinement-loop/scripts/build_refinement_phase_state.pyの review phase gate に、--phase reviewかつ--source-kind issue_review_result_compact_v1のとき、--review-validation-result-pathの JSON のschemaが"REVIEW_COMPACT_VALIDATION_RESULT_V1"(旧 legacy schema literal)である場合に fail-closed(非ゼロ終了・--output-pathにファイル未生成)にする分岐が実装されている - AC3: 同ゲートが
schema_version != "1"/validation_status != "valid"/envelope_kindが{"approve", "needs_fix_intermediate"}以外 /violationsが非空リストのいずれかに該当する場合、fail-closed(非ゼロ終了・phase-state ファイル未生成)になる - AC4: 同ゲートが
--source-pathの実バイト内容から再計算した SHA256 と validation result のinput_sha256フィールドが一致しない場合(stale / 別入力の validation result を使い回すケース)、fail-closed(非ゼロ終了・phase-state ファイル未生成)になる - AC5:
build_refinement_phase_state.pyに--issue-number(positive int)引数が追加されており、--phase reviewかつ--source-kind issue_review_result_compact_v1のときこの引数が必須であること、および validation result のnormalized_payload.ARTIFACTに含まれる issue 番号セグメントと--issue-numberの値が一致しない場合に fail-closed(非ゼロ終了・phase-state ファイル未生成)になることの両方が実装されている - AC6:
compact_review_result.pyの実際の needs-fix stdout(9 行)をemit_parent_review_envelope_v2.py --validate-intermediate(review_compact.validate_intermediate_v1)に通して得た実際のREVIEW_COMPACT_INTERMEDIATE_VALIDATION_RESULT_V1(validation_status: valid、violations: []、対応する--issue-number)を AC2-AC5 実装後の phase gate に渡すと、phase-state ファイルが正しく生成される(正常系が壊れていないことの回帰確認) - AC7:
.claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate.py/.claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate_validation_seam.py/.claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate_validation_seam_gates.py/.claude/skills/issue-refinement-loop/tests/test_strict_json.pyが全件 PASS する - AC8:
docs/dev/workflows/issue-refinement-loop-design.mdの Step 2a 節にREVIEW_COMPACT_INTERMEDIATE_VALIDATION_RESULT_V1という schema literal が記述されている
Verification Commands
# AC1
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_skill_md_step2_intermediate_wiring.py -v# AC2
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate_validation_seam_gates.py::test_legacy_schema_literal_rejected -v# AC3
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate_validation_seam_gates.py::test_gate_rejects_malformed_intermediate_result -v# AC4
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate_validation_seam_gates.py::test_gate_rejects_input_sha256_mismatch -v# AC5
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate_validation_seam_gates.py::test_gate_rejects_issue_number_mismatch -v# AC6
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate_validation_seam_gates.py::test_gate_accepts_real_producer_intermediate_result -v# AC7
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate.py .claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate_validation_seam.py .claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate_validation_seam_gates.py .claude/skills/issue-refinement-loop/tests/test_strict_json.py -v# AC8
$ rg -n "REVIEW_COMPACT_INTERMEDIATE_VALIDATION_RESULT_V1" docs/dev/workflows/issue-refinement-loop-design.mdAllowed Paths
.claude/skills/issue-refinement-loop/SKILL.md.claude/skills/issue-refinement-loop/scripts/build_refinement_phase_state.py.claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate.py.claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate_validation_seam.py.claude/skills/issue-refinement-loop/tests/test_strict_json.py.claude/skills/issue-refinement-loop/tests/test_skill_md_step2_intermediate_wiring.py(新規ファイル).claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate_validation_seam_gates.py(新規ファイル)docs/dev/workflows/issue-refinement-loop-design.md
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- Allowed Paths 外(特に
emit_parent_review_envelope_v2.py/validate_review_compact_output.py自体)の変更が必要と判明した場合は Out of Scope 違反として Stop する - canonicalization 降格漏れバグ・
REVIEWER_BLOCKER_CLAIMstrict validator 統合等、Out of Scope に列挙した項目が本 Issue のスコープ内でしか修正できないと判明した場合は新規 Issue 起票を検討する
Required Skills
なし
Required Design References
.claude/skills/issue-refinement-loop/scripts/emit_parent_review_envelope_v2.py(validate_child_intermediate()/build_validate_intermediate_result()、child intermediate grammar の SSOT、command registryreview_compact.validate_intermediate_v1).claude/skills/issue-refinement-loop/SKILL.md(Step 2「validator-first 順序」節、Step 2a)docs/dev/workflows/issue-refinement-loop-design.md(Step 2a 節)- OWNER 敵対的レビュー: 実装: issue-refinement-loop Step 2 を child intermediate validator に移行し review phase gate を入力digestへ束縛する #1755 (comment)
Scope Delta(任意)
N/A(本 Issue は起票段階での全面的な再定義であり、実装開始後の Scope Delta ではない)
Notes for Reviewer
- 本 Issue は元 実装: issue-refinement-loop Step 2 を child intermediate validator に移行し review phase gate を入力digestへ束縛する #1755(
validate_review_compact_output.pyのNEEDS_FIX_FIELDSを 9 行へ書き換える案)に対する OWNER の敵対的レビュー(REQUEST_CHANGES、issuecomment-5091837021)を受けて全面的に再定義したものである。元の案は V1 final grammar と child intermediate grammar の責務を混同しており、実装すると既存の専用 intermediate validator(review_compact.validate_intermediate_v1)と重複する別実装を作ることになり、#1541が意図的に採用した grammar 分離設計を逆行させる、という指摘を issue-author として受け入れた - OWNER の指摘のうち、以下の 2 点は本 Issue の主題(Step 2 wiring 移行・phase gate の入力束縛)とは異なるレイヤーの独立した欠陥修正であるため、意図的に Out of Scope とした。実装時にこれらのバグへの対処が本 Issue のスコープ内でしか完結できないと判明した場合は、別途 follow-up Issue の起票が必要である:
emit_parent_review_envelope_v2.pyの canonicalization 失敗時validation_status降格漏れバグ_validate_reviewer_blocker_claim_field()とparent_replay_binding.validate_reviewer_blocker_claim()の重複解消・統合
- schema governance(consumer inventory・V1 retirement policy の正式な version bump 判断)についても、本 Issue はレビュー時に指摘された論点への対処として phase gate 側の schema literal 厳密化(legacy literal の拒否)のみを行い、
validate_review_compact_output.pyの V1 grammar 自体の deprecated 化・削除という正式な governance 判断は別 Issue に委ねる
Runtime Verification Applicability
本 Issue の変更対象はワークフロー文書・スクリプトのみです。ゲームの実行時動作には影響しません。
decision: not_applicable
reason: "Workflow documentation and script changes only. No runtime game behavior changed."
Activity
squne121 commentedon Jul 27, 2026
敵対的レビュー結果
判定:
REQUEST_CHANGES— 問題現象は実在しますが、Issue #1755 は修正対象のレイヤーを誤っています。現契約のまま実装へ進めるべきではありません。compact_review_result.pyが現在の needs-fix 時に返すのは、共通8フィールドにREVIEWER_BLOCKER_CLAIMを追加した9行です。一方、Step 2 の一部記述は旧review_compact.validateを呼ぶため、9行を拒否し得るという指摘自体は正しいです。しかし、現在の設計ではすでに次の3契約が意図的に分離されています。
REPLAY_*REVIEWER_BLOCKER_CLAIM + PARENT_REPLAY_*専用の
validate_child_intermediate()とreview_compact.validate_intermediate_v1も実装・registry登録済みです。コード自身が「V1 final、V2 finalとは別の grammar」と明記しています。したがって、根本原因は
NEEDS_FIX_FIELDS定数のドリフトではなく、Step 2 の consumer wiring と phase gate が #1541/PR #1557 後の intermediate 契約へ完全移行していないことです。P0-1: V1 validator を9行へ変更すると、既存の専用 intermediate validator と責務が二重化する
Issue #1755 は V1 の
NEEDS_FIX_FIELDSを9行へ変更し、旧13行を拒否する案です。これは単なるバグ修正ではありません。現行コードでは旧13行 V1を「producer path からは廃止済みだが、V1 parity 用の pure validation grammar として残す」と明記しています。また、9行 intermediate と15行 V2は独立した field set と validator を持っています。
#1755 を実装すると、次の状態になります。
validate_review_compact_output()が9行を検証validate_child_intermediate()も同じ9行を検証REVIEW_COMPACT_VALIDATION_RESULT_V1の意味だけがversion据え置きで変更これは #1541 が明示的に採用した「8/9 intermediate を V1/V2 final grammar から分離する」設計を逆行させます。
必須修正:
validate_review_compact_output.pyの V1 field setは変更せず、Step 2を既存のreview_compact.validate_intermediate_v1へ移行してください。P0-2: Allowed Pathsでは正しい修正を実装できない
実際に古い経路を指定しているのは
SKILL.mdのStep 2です。同じファイルのStep 2aでは、すでに専用intermediate validatorを使うよう指示しており、同一SSOT内で矛盾しています。さらに
build_refinement_phase_state.pyは、review phaseの入力を以下に固定しています。source kind:
issue_review_result_compact_v1validation schema:
REVIEW_COMPACT_VALIDATION_RESULT_V1しかし #1755 の Allowed Paths は validator本体と単体テストだけです。SKILL、phase gate、schema governance、command-chain testを変更できません。
したがって、現IssueのStop Conditionである「Allowed Paths外の変更が必要」にすでに該当します。
P0-3: phase gateはvalidation resultと実入力を束縛していない
build_refinement_phase_state.pyの実装は、validation resultについて実質的に次の1点しか確認していません。以下は検証されません。
schema == REVIEW_COMPACT_VALIDATION_RESULT_V1schema_versionenvelope_kindviolations == []input_sha256source_pathの同一性既存テストも手書きの
validation_status: invalidを拒否するケースしかなく、手書きのvalidや別入力のvalid receiptを拒否するテストはありません。攻撃・事故形状は単純です。
これはvalidator-firstではなく、caller-supplied validity claim firstです。
必須修正:
violations == []envelope_kindinput_sha256をphase gateに追加してください。
P1-1:
REVIEWER_BLOCKER_CLAIMの検証要件が弱すぎる現行の
_validate_reviewer_blocker_claim_field()は最小限の字句検証しかしていません。body_sha256の存在・形式を検証しない一方、
parent_replay_binding.validate_reviewer_blocker_claim()には、必要なstrict validationがすでに存在します。sha256:<64 hex>#1755 でV1側に別の簡易実装を追加すると、再びschema driftを作ります。strict validatorをSSOTとして再利用すべきです。
JSONについても、RFC 8259はduplicate member nameの処理が実装間で不定になること、
NaN/InfinityがJSONとして許可されないことを明記しています。Python標準ライブラリはobject_pairs_hookとparse_constantでこれらをfail-closedに処理できます。([RFC Editor]1)P1-2: 現行intermediate validatorにもstatus整合性バグがある
build_validate_intermediate_result()はstrict claim canonicalizationに失敗するとviolationを追加しますが、元のvalidation_statusをinvalidへ変更していません。結果として、次の矛盾したpayloadを生成し得ます。
{ "validation_status": "valid", "canonical_reviewer_blocker_claim": null, "violations": [ {"code": "reviewer_blocker_claim_canonicalization_failed"} ] }#1755 の正しい修正方針としてintermediate validatorへ統一するなら、この隣接バグも同時に閉じる必要があります。
失敗時は必ず以下にすべきです。
P1-3: 提案されているAC2はproduction経路を証明しない
#1755 のAC2は、real producerの9行出力を直接
validate_review_compact_output()に渡す単体parity testです。これは提案した関数変更自体しか検証しません。既存のproduction testはすでに次の実経路を通しています。
必要なのはV1関数へのdirect testではなく、次のseam testです。
これでなければ、単体テストがPASSしてもStep 2が古いcommandを呼ぶ不具合は残ります。
P1-4: Versioned schemaをversion据え置きで破壊している
プロジェクトのschema governanceは、producer/consumer境界を越えるmachine-readable contractをschemaとして扱い、V1 validation result、blocker claim、V2 resultを別schemaとしてconsumer inventoryに登録しています。
旧13行をvalidからinvalidへ変更し、9行intermediateを同じV1 schemaとしてvalidにするのは、互換性のない意味変更です。一般的なversioned API原則でも、非互換変更は新versionとして扱うべきです。([Semantic Versioning]2)
#1755 には少なくとも以下が欠けています。
WEB調査を反映した実装上の要件
Canonical digestを使う境界では、producerとconsumerが同一の不変byte表現を使う必要があります。RFC 8785も、hashやsignatureを再現可能にするためのcanonical representationを要求しています。([RFC Editor]3)
このリポジトリはJCSそのものではなく、Pythonローカルのcanonical JSON関数を採用し、JCS互換を主張しないことまで明記しています。この判断自体は妥当です。重要なのは、別validatorで別serializerを再実装せず、同じstrict parserとcanonicalizerを全consumerが再利用することです。
推奨するIssue再定義
推奨タイトル:
推奨Outcome:
必要な変更対象は少なくとも次です。
SKILL.mdbuild_refinement_phase_state.pyemit_parent_review_envelope_v2.pyvalidate_review_compact_output.pyの旧V1 grammarは、runtime consumerから外してdeprecated扱いにするか、別Issueで明示的に削除すべきです。9行intermediateへ黙って転用してはいけません。最終判定
#1755 は「定数を9行へ変更するIssue」ではなく、#1541後に残ったorchestration migration漏れを修正するIssueとして全面的に書き直すべきです。
squne121 commentedon Jul 27, 2026
Refinement Loop: Human Escalation Required
The loop has terminated and requires human review. Cause: human judgment required
human_escalationhuman_judgment_requiredBlockers
[-]実装: validate_review_compact_output.py の NEEDS_FIX_FIELDS を compact_review_result.py の現行 needs-fix producer 契約に一致させる[/-][+]fix: issue-refinement-loop Step 2 を child intermediate validator に移行し review phase gate を入力digestへ束縛する[/+]squne121 commentedon Jul 27, 2026
Refinement Loop: Human Escalation Required
The loop has terminated and requires human review. Cause: human judgment required
human_escalationhuman_judgment_requiredBlockers
squne121 commentedon Jul 27, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approved[-]fix: issue-refinement-loop Step 2 を child intermediate validator に移行し review phase gate を入力digestへ束縛する[/-][+]実装: issue-refinement-loop Step 2 を child intermediate validator に移行し review phase gate を入力digestへ束縛する[/+]squne121 commentedon Jul 27, 2026
Contract Review Result
squne121 commentedon Jul 27, 2026
implement-issue: 実装完了
.claude/worktrees/issue-1755-issue-refinement-loop-step-2-child-interworktree-issue-1755-issue-refinement-loop-step-2-child-internot_applicable(issue-contract-review 確認済み)squne121 commentedon Jul 27, 2026
fix_delta 適用結果(PR #1826)
pr-review-judge の REQUEST_CHANGES(reviewed_head_sha:
3d98b54051639089d1620210cdc3bf04f42e4198)を受け、IMPLEMENTATION_WORKER_REQUEST_V2としてupdate_pr_body_hygieneとupdate_branchの両モードを実行しました。1. PR Body Japanese Check(failed_blocks=5)の解消
.claude/skills/create-issue/scripts/validate_japanese_content.pyで per-block 検証した結果、失敗ブロックは次の 5 件でした。Closes #1755(単独行)## Contract Snapshot(非 canonical 見出し)🤖 Generated with [Claude Code]...フッターCo-Authored-By: ...フッターPR body 全体を書き直し、各 prose block に日本語説明を追加し、フッター 2 行(他の最近マージ済み PR にも存在しない慣習)を削除しました。修正後
aggregate_ratio: 0.495、failed_blocks: 0で PASS を確認済みです。2. 必須セクション追加
.claude/skills/open-pr/scripts/update_pr.pywrapper が要求する必須セクション(Summary/Checks/Schema Change Applicability/Schema Consumer Inventory/Safety Claim Matrix/Notes)と、指示された追加セクション(受け入れ条件の達成状況/Allowed Paths 遵守)をすべて追加しました。受け入れ条件の達成状況: AC1-AC8 それぞれについて[x]と根拠テストを記載Allowed Paths 遵守:git diff --stat origin/main...HEADで確認した変更ファイル一覧(8 件)が Allowed Paths と一致することを記載Safety Claim Matrix: 本変更が review phase gate を fail-closed 化して「強める」変更であることを明記(Not controlled が非空の行には Follow-up に#1755を記載)Schema Change Applicability:decision: schema_changeと判定理由を記載Schema Consumer Inventory: Before/After と consumer 一覧(SKILL.md orchestrator・テスト 4 ファイル・docs/dev/schema-governance.mdの既存エントリが未更新である旨)を記載body 更新は
open-pr/scripts/update_pr.pywrapper 経由で実行しました(gh pr edit --body-fileの直接呼び出しは行っていません)。UPDATED=trueを確認済みです。3. update_branch(BEHIND 解消)
expected_head_sha: 3d98b54051639089d1620210cdc3bf04f42e4198を起点にPUT /repos/squne121/loop-protocol/pulls/1826/update-branchを実行しました。headRefOidがfee87ce1affdf7cd1444065bef578dfe38f7eb2cに変化(before_head_sha: 3d98b540...→after_head_sha: fee87ce1...)mergeStateStatusはBEHIND→BLOCKED(CI 実行中)→CLEANに遷移4. 再検証
worktree(
.claude/worktrees/issue-1755-issue-refinement-loop-step-2-child-inter)を新しい head へ同期後、AC1-AC8 に対応する 5 テストファイル(test_skill_md_step2_intermediate_wiring.py/test_refinement_phase_gate_validation_seam_gates.py/test_refinement_phase_gate.py/test_refinement_phase_gate_validation_seam.py/test_strict_json.py)を再実行し、66 件全て PASS を確認しました。git statusは Allowed Paths 内(8 ファイル)に収まっています。CI 全 required check(
PR Body Japanese Check/test/lint/typecheck/build/e2e/python-test/actionlint/check-hook-integrity/agy-causal-claim-drift-gate/validate-generated-artifact/deploy-pr)は green、mergeStateStatus: CLEAN、mergeable: MERGEABLEです。PR #1826: #1826
fix: review phase gate の forged receipt バイパスを実 validator 再実行で閉じる (#1755)
squne121 commentedon Jul 27, 2026
PR #1826 fix_delta 適用完了(OWNER REQUEST_CHANGES 対応)
OWNER の PR #1826 への REQUEST_CHANGES(issuecomment-5097192886)を受けて
apply_pr_review_fix_deltaとして修正を適用し、push 済みです(head:3cbacc2c1a7586a35c588f30c3f2ece4686371ce)。P0(必須・実装済み): forged receipt によるゲート完全バイパスを閉じる
build_refinement_phase_state.pyの_validate_review_validation_gate()を、--source-pathの実バイトをemit_parent_review_envelope_v2.build_validate_intermediate_result()(実 validator)へ再投入し、その出力全体を渡された validation result と完全一致するまで検証するよう変更しました。個別フィールドの部分チェックに加えて、この round-trip 一致を最終ゲートとして追加しています。以下をすべて拒否できることを確認済みです(新規テストで検証):
envelope_kind: approveなのに needs-fix 用 payload が混入envelope_kind: needs_fix_intermediateなのに canonical claim が欠落input_byte_count不一致normalized_payloadの欠落・追加・値不整合P2(必須・実装済み)
_strict_json_loads()にobject_pairs_hookを追加し、top-level /normalized_payloadいずれの duplicate JSON key も拒否--source-path(2048 byte,emit_parent_review_envelope_v2.MAX_INPUT_BYTESと同一)と--review-validation-result-path(64KiB)を bounded read にし、input_byte_countが実バイト数と一致することを検証compact_review_result.py→validate_intermediate_v1→build_refinement_phase_state.pyの実 E2E チェーンを approve 経路(review_result_approve.jsonfixture)でも追加source_sha256/source_byte_count/issue_numberを追加保存P3(必須・実装済み)
--issue-number > 0の正数制約を_validate_review_validation_gate()自体でも強制し、build_phase_state()を直接呼び出す経路での argparse 迂回を閉じました。既存テストの更新
test_refinement_phase_gate.py/test_strict_json.pyにあった「手作りの最小 receipt(b"{}"相当)を正常系として通す」fixture を、実 validator を実際に呼び出して receipt を生成する形に更新しました。test_refinement_phase_gate_validation_seam.py/test_refinement_phase_gate_validation_seam_gates.pyの既存テストは無変更で全 PASS(個別フィールドの mutation が round-trip チェックより先に fail-closed するため、影響を受けませんでした)。追加テスト
test_refinement_phase_gate_validation_seam_gates.pyに以下を追加しました:input_byte_count不一致・oversized source(bounded read)normalized_payload双方)build_phase_state()直接呼び出しでのissue_number <= 0拒否P1(未実装・スコープ判断が必要)
OWNER コメントの P1(
command_registry.pyへのphase_state.build.review追加、docs/dev/schema-governance.mdの registry entry 更新、references/loop-state.mdのコマンド例更新)は、Issue #1755 現在の Allowed Paths 外かつ Issue 本文の Out of Scope に明示されているため、Stop Conditions に従い実装していません。別途スコープ判断(follow-up Issue の要否含む)が必要です。検証結果
.claude/skills/issue-refinement-loop/tests/配下 1650 pytest 全 PASSruff check全 PASSbuild_refinement_phase_state.py/test_refinement_phase_gate.py/test_refinement_phase_gate_validation_seam_gates.py/test_strict_json.py)内に収まっていることを確認済み(test_refinement_phase_gate_validation_seam.pyは変更不要)squne121 commentedon Jul 27, 2026
IMPLEMENTATION_WORKER_RESULT_V2 (required_auto_actions 2件を実行)
PR #1826 に残っていた
required_auto_actions2 件を実行しました。1. update_branch
expected_head_sha: 3cbacc2c1a7586a35c588f30c3f2ece4686371ce(pr-review-judge の reviewed_head_sha と一致)を起点にPUT /pulls/1826/update-branchを実行しました。after_head_sha: 0b435236ce0c73db6b939ae1fa134d3836adc761を確認しました(main を fast-forward merge した head)。status: ok、before_head_sha: 3cbacc2c1a7586a35c588f30c3f2ece4686371ce、after_head_sha: 0b435236ce0c73db6b939ae1fa134d3836adc761。rerun_required.verification: true/rerun_required.pr_review: trueです(pr-review-judge の再レビューが必要)。2. update_pr_body_hygiene
open-pr/scripts/update_pr.pywrapper(gh pr edit直叩きは使用していません)経由で PR body を更新しました。wrapper_used: true、validator は pass(UPDATED=true)。command_registry.py等)が Allowed Paths 外として意図的にスコープ外である旨と、follow-up Issue 起票が未完了である旨を明記しました(起票自体は本タスクの範囲外のため未実施)。独立検証(control-plane 再実行)
.claude/worktrees/issue-1755-issue-refinement-loop-step-2-child-inter)をorigin/worktree-issue-1755-issue-refinement-loop-step-2-child-inter(head0b435236)まで fast-forward し、git statusが clean であることを確認しました。git diff --stat origin/main...HEADは 8 ファイルのみで、Issue 実装: issue-refinement-loop Step 2 を child intermediate validator に移行し review phase gate を入力digestへ束縛する #1755 の Allowed Paths と完全一致することを確認しました(Allowed Paths 外への変更なし)。test_refinement_phase_gate.py/test_refinement_phase_gate_validation_seam.py/test_refinement_phase_gate_validation_seam_gates.py/test_strict_json.py)+test_skill_md_step2_intermediate_wiring.pyを実行し、76 件全て PASSを確認しました。現在の PR 状態
0b435236ce0c73db6b939ae1fa134d3836adc761MERGEABLEBLOCKED(review 必須の再取得待ちと推測。head 変化に伴う pr-review-judge 再レビューが必要です)head が更新されたため、pr-review-judge による再レビュー(reviewed_head_sha を
0b435236...に更新した上での再判定)が必要です。実装: issue-refinement-loop Step 2 を child intermediate validator に移行し …