Skip to content

実装: review checker compact artifact の blocking semantics を修正し C4 VC failure を human escalation に誤分類しない #1086

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: "check_issue_contract.py --json の deterministic failure を compact artifact と arbitration に正しく伝播させ、VC command format failure を non-blocking checker_gap として握りつぶさない"
change_kind: workflow
stage: 1
blocked_by: []
dedupe_key: ops-improvement:loop-protocol:compact-review-blocker-fix:2026-06

Background

#985 の loop では check_issue_contract.py が C4_vc_commands_present を deterministic fail として検出した一方、compact_review_result.py では finding_kind=checker_gap, blocking=false, domain=vc_command_format へ落ちた。その結果 reviewer_claim_replay.py が reviewer claim を unbacked と扱い、2回目で reviewer_false_positive_suspected → human_escalation になった。

これは reviewer の問題というより、deterministic checker JSON から compact blocker を再構成する consumer 側の schema/semantics gap である。

一方で、#1042 / PR #1058 で固定した fail-closed semantics は維持する必要がある。checker_gap をそのまま blocking 化するのではなく、deterministic evidence と artifact の整合を判定した上で、必要なら checker_artifact_inconsistency か正規 deterministic_domain_blocker へ再構成する contract に寄せる。

Parent Issue

none

Parent Goal Ref

  • Goal: check_issue_contract.py --json の deterministic failure が compact artifact と arbitration に正しく伝播し、VC command format failure が non-blocking checker_gap として握りつぶされない
  • Desired Destination: 実装: existing enemy_chaser を new taxonomy へ非破壊移行する #985 再現 fixture で C4 deterministic fail が compact/arbitration を通じて blocking として保持され、unsupported deterministic-domain finding は引き続き fail-closed に留まる状態

Current Validated Scope

  • .claude/skills/review-issue/scripts/check_issue_contract.py の findings / deterministic_checks / checker_evidence 出力整合を明確化する
  • .claude/skills/review-issue/schemas/review_issue_result_v1.json に structured_blockers と findings/evidence consistency expectation を固定する
  • .claude/skills/issue-refinement-loop/scripts/compact_review_result.py で full artifact から compact blocker を再構成する
  • .claude/skills/issue-refinement-loop/scripts/reviewer_claim_replay.py で checker_artifact_inconsistency lane と fallback evidence 探索を固定する
  • .claude/skills/issue-refinement-loop/scripts/build_refinement_phase_state.py を含む JSON artifact/state の strict JSON policy を固定する
  • .claude/skills/issue-refinement-loop/tests/ と tests/test_issue_refinement_ops_review.py / tests/test_check_agent_friendly_stdout.py に 実装: existing enemy_chaser を new taxonomy へ非破壊移行する #985 再現 fixture と strict JSON regression を追加する
  • .claude/agents/issue-reviewer.md / .codex/agents/issue-reviewer.toml に compact result schema surface を明記する

Remaining Parent Gaps

なし(単独改善 Issue のため)

Outcome

check_issue_contract.py --json の deterministic failure が compact artifact と arbitration に正しく伝播し、VC command format failure が non-blocking checker_gap として握りつぶされず、#1042 の fail-closed semantics を壊さない。

In Scope

  • check_issue_contract.py の deterministic-domain finding と checker_evidence の整合整理
  • review_issue_result_v1.json への structured_blockers と findings/evidence consistency expectation 追加
  • compact_review_result.py の findings / structured_blockers からの compact blocker 再構成
  • reviewer_claim_replay.py の checker_artifact_inconsistency lane と fallback evidence 探索ルール整理
  • build_refinement_phase_state.py / compact artifact / replay state の strict JSON policy 追加
  • 実装: existing enemy_chaser を new taxonomy へ非破壊移行する #985 C4 failure 再現 fixture と strict JSON regression fixture 追加
  • issue-reviewer surface 文書の current repo reality への同期

Out of Scope

  • check_issue_contract.py の C1-C13 checker logic 自体の意味変更
  • scope_signal_guard の変更
  • guard / hook / permission profile の変更
  • runtime UI / Pages preview / deploy artifact の変更

Acceptance Criteria

  • AC1: check_issue_contract.py --json が C4_vc_commands_present=fail を返す fixture で、REVIEW_ISSUE_RESULT_V1 の blocking_issues / findings / deterministic_checks が相互矛盾しない
  • AC2: C4 fail は finding_kind=deterministic_domain_blocker / blocking=true / checker_evidence>=1、または checker_artifact_inconsistency として fail-closed され、checker_gap のまま blocking 化しない
  • AC3: structured_blockers がない compact artifact でも、findings[] の正規 deterministic_domain_blocker から reviewer_claim_replay.py が rewrite-ready blocker を再構成できる
  • AC4: matched_findings が checker_gap / heuristic_concern のみの場合、reviewer_claim_replay.py は readiness / vc_syntax / vc_preflight fallback evidence 探索を抑止しない
  • AC5: deterministic_checks.C4_vc_commands_present=fail と findings[].checker_gap が同居する場合、reviewer_false_positive_suspected ではなく checker_artifact_inconsistency に分離される
  • AC6: 実装: existing enemy_chaser を new taxonomy へ非破壊移行する #985 再現 fixture で Pass 1 / Pass 2 が human_escalation に直行せず、正規 blocker reconstruction または checker_artifact_inconsistency になる
  • AC7: compact_review_result.py / reviewer_claim_replay.py / build_refinement_phase_state.py の JSON 出力と状態保存は allow_nan=False、読み込みは parse_constant reject を使う
  • AC8: REVIEW_ISSUE_RESULT_V1 schema に structured_blockers と findings/evidence consistency の期待が明記され、schema または custom invariant test で固定される
  • AC9: 既存 実装: issue-reviewer の deterministic-domain blocker 生成を fail-closed に制限する #1042 方針を維持し、evidence なし deterministic-domain finding を単純に blocking 化しない

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

  • Python
  • JSON Schema validation

Verification Commands

# AC1
# AC2
# AC8
# AC9
$ uv run pytest .claude/skills/review-issue/tests -q
# AC3
# AC4
# AC5
# AC6
# AC7
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_compact_review_result.py .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay.py .claude/skills/issue-refinement-loop/tests/test_issue_refinement_ops_review.py -q
# strict_json regression detail
$ uv run pytest .claude/skills/issue-refinement-loop/tests -k "nan or infinity or strict_json" -q
# canonical gates
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build

Allowed Paths

  • .claude/skills/review-issue/scripts/check_issue_contract.py
  • .claude/skills/review-issue/schemas/review_issue_result_v1.json
  • .claude/skills/review-issue/tests/test_check_issue_contract.py
  • .claude/skills/issue-refinement-loop/scripts/compact_review_result.py
  • .claude/skills/issue-refinement-loop/scripts/reviewer_claim_replay.py
  • .claude/skills/issue-refinement-loop/scripts/build_refinement_phase_state.py
  • .claude/skills/issue-refinement-loop/tests/
  • tests/test_issue_refinement_ops_review.py
  • tests/test_check_agent_friendly_stdout.py
  • .claude/agents/issue-reviewer.md
  • .codex/agents/issue-reviewer.toml

Runtime Verification Applicability

Related Issues

Activity

  1. added
    enhancement
    phase/implementation
    agent/implementer
    on Jun 21, 2026
  2. squne121 commented on Jun 21, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES / #1086 は必要だが、このまま実装に渡すと再び semantics が壊れる可能性が高いです。

    #1086 の問題意識は正しいです。現行 check_issue_contract.py は C4/C5 を deterministic_domain_blocker として _append_findings() に渡していますが、checker_evidence を渡していないため、_append_findings() 内で checker_gap / blocking=false に降格されます。これが #1086 の背景にある「C4 deterministic fail が non-blocking checker_gap に落ちる」現象と整合します。

    ただし、#1086 の現在の AC/Scope は #1042 / PR #1058 で作った checker_gap semantics と衝突しています。review_issue_result_v1.json は checker_gap の blocking=false を schema 上で固定し、deterministic_domain_blocker の場合だけ blocking=true かつ checker_evidence 最低1件を要求しています。 JSON Schema の if/then は条件に応じて subschema を適用する仕組みで、配列長も minItems で制約できます。つまり現 schema 設計では「checker_gap のまま blocking に昇格」は schema 違反方向です。([JSON Schema]1) ([JSON Schema]2)

    Blocker 1: AC3 の表現が schema と衝突している

    #1086 の AC3 は「domain=vc_command_format かつ deterministic evidence ありの checker_gap は blocking へ昇格」としています。これは危険です。

    checker_gap は #1042 の目的上、「deterministic-domain に見えるが current checker evidence がないので non-blocking」として導入された分類です。実際、schema でも checker_gap は blocking=false に固定されています。

    修正すべき表現はこれです。

    AC3 revised:
    domain=vc_command_format の finding が checker_gap である一方、同一 artifact 内の deterministic_checks.C4_vc_commands_present=fail または current body hash 一致済み checker evidence が存在する場合、checker_gap を blocking 化するのではなく、checker_artifact_inconsistency として検出する。
    そのうえで rewrite に進める場合は finding_kind=deterministic_domain_blocker / blocking=true / checker_evidence>=1 の正規形へ再構成する。

    Blocker 2: check_issue_contract.py 側の evidence 生成方法が未定義

    現在の check_issue_contract.py は body_sha256 を持ち、findings[] も出しますが、C4/C5 には valid checker_evidence を付けていません。結果として _append_findings() が deterministic blocker を checker_gap に落とします。

    #1086 は「check_issue_contract.py: structured_blockers 出力の追加または確認」と書いていますが、現在の REVIEW_ISSUE_RESULT_V1 schema の required fields には structured_blockers が含まれていません。compact_review_result.py は structured_blockers を読むだけで、schema による契約固定はありません。

    したがって、#1086 の Allowed Paths に以下を追加すべきです。

    - .claude/skills/review-issue/schemas/review_issue_result_v1.json

    追加しない場合、structured_blockers を足しても「schema で保証されない optional side-channel」になります。

    Blocker 3: reviewer_claim_replay.py の fallback suppression が本質バグ

    現行 reviewer_claim_replay.py は、対象 kind に一致する findings[] が1件でもあると、readiness / vc_syntax / vc_preflight 側の fallback evidence 探索に入りません。つまり vc_command_format の checker_gap が存在するだけで、readiness artifact に VCS001 等の deterministic evidence があっても無視されます。

    これは #1086 の中核です。compact_review_result.py だけでなく、reviewer_claim_replay.py 側にも明示 AC が必要です。

    - [ ] AC追加: matched_findings が checker_gap / heuristic_concern のみの場合、readiness / vc_syntax / vc_preflight fallback evidence 探索を抑止しない。
    - [ ] AC追加: matched_findings に deterministic_domain_blocker があるが evidence invalid の場合は checker_artifact_inconsistency として分離し、単純な reviewer_false_positive_suspected にしない。

    Blocker 4: checker_artifact_inconsistency の判定条件が不足

    #1086 は checker_artifact_inconsistency と reviewer_false_positive_suspected の分離を要求していますが、どの入力状態を inconsistency とするかが未定義です。

    最低限、以下を固定してください。

    checker_artifact_inconsistency:
      - review_result.verdict == "needs-fix"
      - blocking_issues または structured_blockers に deterministic-domain blocker がある
      - 同一 domain の findings[] が checker_gap / blocking=false
      - または deterministic_checks.C4_vc_commands_present == "fail" なのに findings[] 側が checker_gap
      - または readiness/vc_syntax/vc_preflight に current body hash 相当の deterministic evidence があるのに matched_findings が non-blocking
    routing: proceed_to_rewrite または fix_checker_artifact
    should_consume_iteration: false unless canonical blocker reconstruction succeeds

    ここを曖昧にすると、単に「2回目 human escalation を避ける」ために何でも rewrite へ流す実装になり、#1042 の fail-closed 方針を破壊します。

    Blocker 5: AC7 strict JSON が現行実装と噛み合っていない

    #1086 の AC7 は「compact stdout は strict JSON serializable」としていますが、compact_review_result.py の stdout は JSON ではなく STATUS: ... の line protocol です。一方、full artifact は json.dumps(..., allow_nan=False) を使っていません。

    同様に reviewer_claim_replay.py も compact JSON を json.dumps(..., ensure_ascii=False) で出しており、allow_nan=False がありません。 build_refinement_phase_state.py も同様です。

    Python の json.dumps は既定で NaN / Infinity / -Infinity を出力し得ます。厳密 JSON にするには allow_nan=False が必要で、読み込み側も parse_constant で NaN 等を reject できます。([Python documentation]3)

    AC7 はこう書き換えるべきです。

    - [ ] AC7: compact_review_result.py が書く artifact JSON、reviewer_claim_replay.py の stdout/state JSON、build_refinement_phase_state.py の phase_state JSON は json.dumps(..., allow_nan=False) を使い、NaN/Infinity/-Infinity を ValueError として fail-closed する。
    - [ ] AC7b: json.loads 読み込み側は parse_constant で NaN/Infinity/-Infinity を reject する。

    Major: #1086 は PR #1058 の失敗パターンを再発し得る

    PR #1058 は findings[] を追加したと主張しましたが、レビューでは「checker producer にフィールドを足しただけで、consumer と agent 配布面が閉じていない」と指摘されています。

    #1086 も同じ危険があります。compact_review_result.py の artifact 保持、reviewer_claim_replay.py の fallback/arbitration、review_issue_result_v1.json の schema、issue-reviewer.md / .codex surface の説明を同時に揃えないと、また「producer は出しているが consumer が意味を誤読する」状態になります。issue-reviewer.md は full artifact に findings[] / checker_evidence[] / body_sha256 / producer schema version を lossless に保持すると明記しています。 .codex/agents/issue-reviewer.toml も同じ surface を要求しています。

    修正版 AC 案

    #1086 は以下のように AC を差し替えるのが安全です。

    ## Acceptance Criteria revised
    
    - [ ] AC1: check_issue_contract.py --json が C4_vc_commands_present=fail を返す fixture で、REVIEW_ISSUE_RESULT_V1 の blocking_issues / findings / deterministic_checks が相互矛盾しない。
    - [ ] AC2: C4 fail は finding_kind=deterministic_domain_blocker / blocking=true / checker_evidence>=1、または checker_artifact_inconsistency として fail-closed され、checker_gap のまま blocking 化しない。
    - [ ] AC3: structured_blockers がない compact artifact でも、findings[] の正規 deterministic_domain_blocker から reviewer_claim_replay.py が rewrite_ready_blockers を再構成できる。
    - [ ] AC4: matched_findings が checker_gap / heuristic_concern のみの場合、reviewer_claim_replay.py は readiness / vc_syntax / vc_preflight fallback evidence 探索を抑止しない。
    - [ ] AC5: deterministic_checks.C4_vc_commands_present=fail と findings[].checker_gap が同居する場合、reviewer_false_positive_suspected ではなく checker_artifact_inconsistency に分離される。
    - [ ] AC6: #985 再現 fixture で Pass 1 / Pass 2 が human_escalation に直行せず、正規 blocker reconstruction または checker_artifact_inconsistency になる。
    - [ ] AC7: compact_review_result.py / reviewer_claim_replay.py / build_refinement_phase_state.py の JSON 出力と状態保存は allow_nan=False、読み込みは parse_constant reject を使う。
    - [ ] AC8: REVIEW_ISSUE_RESULT_V1 schema に structured_blockers と findings/evidence consistency の期待を明記し、schema または custom invariant test で固定する。
    - [ ] AC9: 既存 #1042 方針を維持し、evidence なし deterministic-domain finding を単純に blocking 化しない。

    Verification Commands 修正案

    現行 #1086 の VC には AC 番号コメントがないため、C5 alignment 系の checker でまた事故る余地があります。こうしてください。

    # AC1, AC2, AC8, AC9
    $ uv run pytest .claude/skills/review-issue/tests -q
    
    # AC3, AC4, AC5, AC6, AC7
    $ uv run pytest \
      .claude/skills/issue-refinement-loop/tests/test_compact_review_result.py \
      .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay.py \
      .claude/skills/issue-refinement-loop/tests/test_issue_refinement_ops_review.py \
      -q
    
    # AC7
    $ uv run pytest .claude/skills/issue-refinement-loop/tests -k "nan or infinity or strict_json" -q
    
    # canonical gates
    $ pnpm typecheck
    $ pnpm lint
    $ pnpm test
    $ pnpm build

    配布物・証跡の扱い

    この Issue は runtime UI や Pages preview ではなく、workflow artifact / schema / arbitration の問題です。証跡は Preview URL ではなく、対象 pytest、pnpm typecheck/lint/test/build、再現 fixture、compact artifact JSON の before/after で十分です。GitHub の artifact attestations は、利用者が検証する release binaries/packages/manifests には有効ですが、頻繁な automated testing build や個別 source/doc/image file には推奨されていません。([GitHub Docs]4)

    GitHub に貼るコメント案

    ## 判定
    
    REQUEST_CHANGES / #1086 は必要だが、現 contract のまま実装すると #1042 の checker_gap semantics を壊す可能性があります。
    
    ### Blockers
    
    1. AC3 の「checker_gap を blocking へ昇格」は schema と衝突しています。
       - `checker_gap` は `blocking=false` が正規 semantics。
       - evidence 付きで rewrite へ進めるなら `finding_kind=deterministic_domain_blocker / blocking=true / checker_evidence>=1` に再構成してください。
       - checker_gap と deterministic_checks fail が同居する場合は `checker_artifact_inconsistency` として分離してください。
    
    2. `check_issue_contract.py` の C4/C5 は deterministic_domain_blocker として `_append_findings()` に渡されますが、checker_evidence が無いため checker_gap に降格されます。
       - C4/C5 に正規 checker_evidence を付けるか、
       - compact/replay 側で deterministic_checks fail + blocking_issues との矛盾を検出してください。
    
    3. `reviewer_claim_replay.py` は matched_findings が存在すると readiness / vc_syntax / vc_preflight fallback evidence を探索しません。
       - matched_findings が checker_gap / heuristic_concern のみの場合は fallback を抑止しない AC を追加してください。
    
    4. `structured_blockers` を contract 化するなら `.claude/skills/review-issue/schemas/review_issue_result_v1.json` を Allowed Paths に追加してください。
       - 現状 schema required fields に `structured_blockers` はありません。
    
    5. AC7 は line protocol と JSON artifact を混同しています。
       - `compact_review_result.py` artifact JSON、`reviewer_claim_replay.py` stdout/state JSON、`build_refinement_phase_state.py` phase_state JSON で `allow_nan=False` を要求してください。
       - 読み込み側も `parse_constant` で NaN/Infinity を reject してください。
    
    ### Required contract rewrite
    
    - `checker_gap` は blocking 化しない。
    - deterministic evidence があるなら正規 `deterministic_domain_blocker` に再構成する。
    - deterministic_checks fail と findings checker_gap の矛盾は `checker_artifact_inconsistency`。
    - unbacked reviewer claim と checker artifact inconsistency を別 lane にする。
    - #985 fixture では Pass 2 が `reviewer_false_positive_suspected -> human_escalation` へ直行しないことを固定する。

    結論として、#1086 は着手価値があります。ただし、まず Issue 本文を上記の形に補強してから実装させるべきです。今のままだと「checker_gap を blocking にする」という短絡修正で、#1042 の fail-closed safety net を逆に壊します。

  3. squne121 commented on Jun 21, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Human Escalation Required

    The loop has terminated and requires human review. Cause: human judgment required

    Blockers

    "PLANNER_FAIL_CLOSED: missing_required_section=Parent Issue — implementation/stage:1 形式に必須の ## Parent Issue セクションが欠落しています。"
    
    "anchor_comment の REQUEST_CHANGES (AC1-AC8 再構成・Allowed Paths 追加・VC修正) は preflight 通過後に適用予定でしたが、preflight が blocked のため未適用です。"
    
    "rewrite_constraints.freeform_rewrite_forbidden=true のため、Parent Issue 追加と anchor comment 変更を同一 pass で実行できません。"
    
    "次の action: ## Parent Issue セクションに記載すべき内容(親 tracker Issue 番号、または standalone の場合は issue_kind 変更)を人間が確定してから refinement loop を再実行してください。"
    
  4. squne121 commented on Jun 21, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-21T08:43:37Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1086
      body_sha256: "sha256:526a11335b516660e49d8d35c6268007237b6942b1128a7035ce86da08edb4e7"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
      source: ensure_contract_snapshot_auto
  5. squne121 commented on Jun 21, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-06-21T09:05:33Z)

    • PR: fix: preserve deterministic review blockers (#1086) #1101
    • Worktree: .claude/worktrees/issue-1086-review-checker-compact-artifact-blocking
    • Branch: worktree-issue-1086-review-checker-compact-artifact-blocking
    • Commit: 4b632af9
    • Verification:
      • uv run pytest .claude/skills/review-issue/tests -q PASS
      • uv run pytest .claude/skills/issue-refinement-loop/tests/test_compact_review_result.py .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay.py tests/test_issue_refinement_ops_review.py -q PASS
      • uv run pytest .claude/skills/issue-refinement-loop/tests -k "nan or infinity or strict_json" -q PASS
      • pnpm typecheck PASS
      • pnpm lint PASS
      • pnpm test PASS
      • pnpm build PASS
    • 後続: PR レビュー -> マージ -> post-merge-cleanup
  6. squne121 commented on Jun 21, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-21T09:17:46Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1086
      body_sha256: "sha256:cc514b0bc29fbd87ab99f48f3a1f60bd9fd4ddb11ba77e13dfafff8ca7c44a5e"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
      source: impl_review_loop_snapshot_refresh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions