Skip to content

実装: issue-reviewer の deterministic-domain blocker 生成を fail-closed に制限する #1042

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: "issue-reviewer / review-issue が unsupported deterministic-domain finding を blocker として流せない fail-closed contract を確立する"
change_kind: workflow

Parent Issue

none

Parent Goal Ref

  • Goal: unsupported deterministic-domain finding を reviewer blocker として通さない
  • Desired Destination: review-issue producer contract、issue-reviewer surface、compact_review_result.py consumer artifact が current repo reality に揃い、deterministic-domain blocker は checker evidence なしに blocking routing へ寄与できない状態

Current Validated Scope

  • .claude/agents/issue-reviewer.md / .codex/agents/issue-reviewer.toml / .agents/skills/review-issue/SKILL.md の reviewer contract / Codex parity surface を current repo reality に揃える
  • .claude/skills/review-issue/ の full artifact contract・findings[]・checker evidence・validator / test を fail-closed に更新する
  • .claude/skills/issue-refinement-loop/scripts/compact_review_result.py と関連 test で provenance を含む新 artifact contract を保持できるよう更新する

Remaining Parent Gaps

Outcome

review-issue / issue-reviewer / compact_review_result.py が evidence なし deterministic-domain finding を blocking routing に流さない fail-closed contract を共有し、Codex parity drift を検出する test が PASS している状態。

In Scope

  • REVIEW_ISSUE_RESULT_V1 full artifact に findings[] と producer schema version を追加し、deterministic-domain blocker / checker_gap / heuristic_concern を機械可読に区別する
  • deterministic-domain blocker に checker evidence を必須化し、unsupported finding は producer 側で reject または non-blocking に降格する
  • compact_review_result.py artifact に freshness / producer provenance を保持し、legacy field 併存時の fail-closed 条件を定義する
  • .codex/agents/issue-reviewer.toml の repo_local_skill_surface を current repo の実在 surface に揃え、Claude/Codex parity を test で固定する
  • review-issue 実 artifact shape を使った integration-oriented test を追加し、unsupported deterministic-domain finding が rewrite routing を消費しないことを確認する

Out of Scope

  • check_issue_contract.py / contract_readiness_check.py / baseline_vc_preflight.py / vc_contract_syntax.py の rule semantics 変更
  • 存在しない consumer-side replay/arbitration surface を前提にした実装や、その recreate
  • issue-author の rewrite strategy 全面改修
  • unrelated agent permission / hook / runtime config 変更

Acceptance Criteria

  • AC1: REVIEW_ISSUE_RESULT_V1 full artifact に findings[] が追加され、各 finding は少なくとも finding_kind, blocking, deterministic_domain_key, checker_evidence[] を持つ
  • AC2: finding_kind=deterministic_domain_blocker の finding は checker_evidence[] を 1 件以上必須とし、evidence なし finding は blocker として artifact / compact output / routing に流れない
  • AC3: checker_evidence[] は少なくとも source_check, rule_id, category, artifact_path, artifact_schema, body_sha256 を保持し、current body と一致しない evidence は stale として reject される
  • AC4: checker_gap は「deterministic-domain registry に該当するが current checker evidence がない finding」、heuristic_concern は「registry 外の主観的・構造的懸念」として明文化され、どちらも blocking=false かつ rewrite iteration を消費しない
  • AC5: compact_review_result.py は新 full artifact contract を保持しつつ、legacy compact stdout を維持する。schema mismatch / stale provenance / unsupported finding 混在時は fail-closed にする
  • AC6: .codex/agents/issue-reviewer.toml の repo_local_skill_surface が current repo の実在 skill surface を指し、.agents/skills/review-issue/SKILL.md を含む parity test で drift を検出できる
  • AC7: review-issue 実 artifact fixture → compact_review_result.py の経路を使う test で、unsupported deterministic-domain finding が non-blocking に留まることを確認する
  • AC8: checker-backed deterministic-domain finding を含む fixture では、従来どおり needs-fix routing されることを test で確認する

Verification Commands

# AC1
$ uv run pytest .claude/skills/review-issue/tests -q

# AC2
$ uv run pytest .claude/skills/review-issue/tests -q

# AC3
$ uv run pytest .claude/skills/review-issue/tests -q

# AC4
$ uv run pytest .claude/skills/review-issue/tests -q

# AC5
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_compact_review_result.py -q

# AC6
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_skill_md_wiring.py -q

# AC7
$ uv run pytest .claude/skills/issue-refinement-loop/tests -q

# AC8
$ uv run pytest .claude/skills/issue-refinement-loop/tests -q

Allowed Paths

  • .claude/agents/issue-reviewer.md
  • .codex/agents/issue-reviewer.toml
  • .agents/skills/review-issue/SKILL.md
  • .claude/skills/review-issue/SKILL.md
  • .claude/skills/review-issue/scripts/*
  • .claude/skills/review-issue/tests/*
  • .claude/skills/issue-refinement-loop/scripts/compact_review_result.py
  • .claude/skills/issue-refinement-loop/tests/*

Stop Conditions

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

Required Skills

なし

Scope Delta(任意)

N/A

Delivery Rule

  • 1 Issue = 1 PR
  • Draft PR で開始する
  • consumer-side replay safety net の有無に依存せず、producer-side fail-closed contract と Codex parity を先に固定する
  • 既存 compact stdout 互換は維持しつつ、full artifact schema と validator を current repo reality に合わせて更新する

Runtime Verification Applicability

  • decision: not_applicable
  • reason: workflow / artifact contract / test の更新であり、runtime 動作検証よりも static validator と test suite が正本になるため

Activity

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

    @squne121
    OwnerAuthor

    結論

    #1042 は方向性は正しいですが、このまま実装に渡すにはまだ粗いです。
    特に危険なのは、「deterministic-domain blocker を checker evidence なしに blocker 化しない」という目的が、schema / artifact / routing / Codex parity / state corruption のどこで強制されるかが曖昧な点です。

    #1042 自体は open でコメントなし、主な前提は #1021 と PR #1032 です。#1021 は reviewer blocker が deterministic checker と結び付かないまま iteration を消費する問題への consumer-side arbitration で、すでに completed。PR #1032 も merged され、reviewer_claim_replay.py と Step 2a arbitration が入っています。#1042 はその後段 safety net ではなく、上流の issue-reviewer / review-issue artifact contract を fail-closed にする follow-up として扱うべきです。

    主要 Blocker

    B1. 「instructions に追記」では既に足りない。既存 instructions はすでに checker SSOT と言っている

    現行の .claude/agents/issue-reviewer.md は、LLM が C1〜C12 を独自判定しない、checker 結果の整形・pass-through のみ、non_blocking_improvements や diff_proposal へ独自追記しない、と明記済みです。つまり #1042 で単に「deterministic checker 対象領域を再判定しない」を追記しても、過去の失敗を防げません。必要なのは prompt 文言ではなく、artifact schema と validator が unsupported blocker を機械的に拒否することです。

    Claude Code の subagent は独自 context・tool/permission・system prompt を持つ仕組みで、project-local agent 定義や skill preload に依存します。公式 docs 上も、subagent/skill は制約を記述できる一方、最終的には local files・tools・permissions・hooks・validators の組み合わせで運用するものです。したがって、自然言語 instruction だけを enforcement boundary と見なす設計は弱いです。([Claude API Docs]1) ([Claude API Docs]2)

    B2. 現行 reviewer_claim_replay.py は mixed blocker を誤って通す

    現在の analyze() は blocker ごとに evidence を作りますが、最終判定は any_backed です。つまり、reviewer output に「evidence 付き deterministic blocker 1件」と「unsupported deterministic-domain blocker 1件」が混在すると、全体が deterministic_fail_confirmed になり、unsupported blocker が見逃されます。#1042 の目的はこの経路を閉じることなので、aggregate verdict を any_backed で決める実装を禁止する AC が必要です。

    必要な仕様は次です。

    aggregate_rule:
      - deterministic_domain_blocker は blocker ごとに evidence 必須
      - evidence なし deterministic_domain finding は blocking=false に降格
      - rewrite payload へ渡せるのは evidence_backed=true の blocker のみ
      - unsupported deterministic-domain finding が混在しても any_backed で全体通過しない

    B3. producer-consumer contract がまだ壊れやすい

    review-issue/SKILL.md は readiness errors の fix_hint を blocking_issues に転写し、errors[] 構造体を structured_blockers に転写すると書いています。一方、reviewer_claim_replay.py は structured_blockers を先に読み、dict の code / reviewer_blocker_code がなければ無視し、次に blocking_issues の文字列全体を blocker code として扱います。

    さらに既存テストの COMPACT_C4 / COMPACT_MISSING_SECTION は、blocking_issues: [{"code": "..."}] という手作り fixture です。これは real producer である review-issue -> compact_review_result.py の実 artifact shape を十分に再現していません。

    #1042 には、次の integration test を明示的に入れるべきです。

    review-issue raw REVIEW_ISSUE_RESULT_V1 fixture
      -> compact_review_result.py
      -> reviewer_claim_replay.py
      -> issue-refinement-loop routing

    fixture-only の analyze() 単体テストだけでは、再発防止になりません。

    B4. artifact_path と current-iteration freshness が不足している

    #1042 は source_check / rule_id / artifact_path などの checker evidence を必須にすると書いていますが、現行 reviewer_claim_replay.py の evidence は source_check / rule_id / category / line_start / line_end / body_sha256 だけで、どの checker artifact から来た evidence なのかを保持していません。

    compact_review_result.py の artifact にも、readiness result artifact path、checker artifact path、iteration id、producer schema version は入っていません。

    #1042 の AC は次のように強めるべきです。

    checker_evidence:
      source_check: string
      rule_id: string | null
      category: string | null
      artifact_path: string        # 必須
      artifact_schema: string      # 必須
      body_sha256: string          # current body と一致必須
      iteration_id: string         # current iteration と一致必須
      line_start: int | null
      line_end: int | null
    
    reject_when:
      - artifact_path missing
      - body_sha256 mismatch
      - artifact_schema unexpected
      - evidence belongs to previous iteration

    これがないと、stale artifact や別 iteration の checker fail を reviewer blocker の裏付けとして誤用できます。

    B5. phase state が rewrite に進みすぎる

    issue-refinement-loop/SKILL.md は VERDICT: needs-fix のとき、phase state を rewrite に更新し、その直後に Step 2a replay arbitration を実行すると書いています。しかし arbitration の結果が downgrade_to_non_blocking なら、rewrite に進まないはずです。phase が先に rewrite になると、loop state / hard stop / routing log が実態とズレます。

    修正案はどちらかです。

    preferred:
      phase: review_arbitration
      deterministic_fail_confirmed の場合だけ phase: rewrite
    
    acceptable:
      review phase のまま Step 2a を実行
      deterministic_fail_confirmed の後に初めて phase: rewrite

    #1042 の scope には issue-refinement-loop の routing / compact artifact / tests が含まれているため、この点は入れるべきです。

    B6. state file corruption が fail-closed compact JSON になっていない

    _load_json_file() は JSON decode error を ValueError に包みますが、_load_state() は json.loads() の例外をそのまま出します。main() が catch するのは ValueError だけなので、壊れた state file は compact input_or_runtime_error ではなく traceback になり得ます。

    #1042 は unsupported blocker だけでなく、arbitration state の破損も fail-closed output contract に含めるべきです。追加テストは最低限これです。

    malformed reviewer_claim_replay_state.json
      -> stdout は REVIEWER_CLAIM_REPLAY_V1 compact JSON
      -> verdict=input_or_runtime_error
      -> routing=human_judgment_required
      -> traceback を stdout/stderr に漏らさない

    B7. Codex parity の allowed paths が足りない可能性がある

    .codex/agents/issue-reviewer.toml は repo_local_skill_surface: .agents/skills/review-issue/SKILL.md を参照しています。一方 #1042 の allowed paths は .claude/skills/review-issue/... と .codex/agents/issue-reviewer.toml だけで、.agents/skills/review-issue/SKILL.md が含まれていません。

    これは実装時に次のどちらかで止まるべきです。

    1. .agents/skills/review-issue/SKILL.md が実在し、Codex runtime がそれを使うなら、実装: issue-reviewer の deterministic-domain blocker 生成を fail-closed に制限する #1042 の allowed paths に追加する。
    2. 実在しない / stale なら、.codex/agents/issue-reviewer.toml の参照先を実際の skill surface に修正し、Codex parity test を追加する。

    Codex 公式 docs でも project-local .codex/ config/rules/hooks は trusted project でのみ読み込まれる前提です。つまり、Codex 側の配布品質は「TOML を置いた」だけでは成立せず、trusted project / project config / skill surface の実在性まで検証が必要です。([OpenAI Developers]3)

    B8. checker_gap と heuristic_concern の分類基準が未定義

    #1042 は evidence のない deterministic-domain 指摘を heuristic_concern または checker_gap として扱う、と書いています。しかし両者の差が未定義です。ここが曖昧だと、実装者は「checker_gap だから blocker」または「heuristic_concern だから無視」という恣意的 routing を入れます。

    明示すべき分類は次です。

    finding_kind:
      deterministic_domain_blocker:
        condition: deterministic-domain registry key に該当し、current checker evidence が存在する
        blocking: true
    
      checker_gap:
        condition: deterministic-domain registry key に該当するが、current checker evidence が存在しない
        blocking: false
        route: non_blocking_or_followup_candidate
        may_consume_iteration: false
    
      heuristic_concern:
        condition: deterministic-domain registry 外の主観的・構造的懸念
        blocking: false
        route: non_blocking_improvements
        may_consume_iteration: false

    B9. ISSUE_REVIEW_RESULT_COMPACT_V1 の versioning 方針がない

    compact_review_result.py は VALID_VERDICTS = {"approve", "needs-fix"}、VALID_STATUSES = {"ok", "failed"} に固定されています。一方 review-issue/SKILL.md は human_judgment を needs-fix に畳み込まないと書いており、既存 contract だけでもズレがあります。

    #1042 で full artifact schema に finding_kind を追加するなら、次を決める必要があります。

    compact_stdout:
      keep_schema: ISSUE_REVIEW_RESULT_COMPACT_V1
      fields: unchanged
    
    full_artifact:
      schema_version: bump or add producer_contract_version
      findings: required
      legacy blocking_issues / structured_blockers: backward-compatible only
    
    arbitration:
      reject old artifacts when VERDICT=needs-fix and findings[] missing
      or run legacy adapter with explicit warning + tests

    高品質化のための #1042 修正文案

    #1042 の本文にそのまま追記するなら、最低限この差分が必要です。

    ## Additional Acceptance Criteria
    
    - [ ] `REVIEW_ISSUE_RESULT_V1` full artifact に `findings[]` を追加し、各 finding は `finding_kind`, `blocking`, `deterministic_domain_key`, `checker_evidence[]` を持つ
    - [ ] `finding_kind=deterministic_domain_blocker` の場合、`checker_evidence[]` は 1 件以上必須。空の場合は contract violation として reject する
    - [ ] `checker_evidence[]` は `source_check`, `rule_id`, `category`, `artifact_path`, `artifact_schema`, `body_sha256`, `iteration_id`, `line_start`, `line_end` を保持する
    - [ ] `body_sha256` / `iteration_id` が current body / current iteration と一致しない evidence は stale として reject する
    - [ ] unsupported deterministic-domain finding は `blocking=false` に降格し、`VERDICT: needs-fix` / rewrite iteration / issue-author payload に寄与しない
    - [ ] mixed findings で `any_backed` により全体を `deterministic_fail_confirmed` にしない。rewrite payload へ渡すのは evidence-backed blocker のみ
    - [ ] `checker_gap` と `heuristic_concern` の routing を明文化し、どちらも rewrite iteration を消費しない
    - [ ] malformed / stale / schema-mismatched reviewer_claim_replay state は compact `input_or_runtime_error` として fail-closed する
    - [ ] real producer integration test として `review-issue` fixture → `compact_review_result.py` → `reviewer_claim_replay.py` → routing の経路を検証する
    - [ ] `.codex/agents/issue-reviewer.toml` の `repo_local_skill_surface` が実在する skill surface を指していることを test で確認する。必要なら `.agents/skills/review-issue/SKILL.md` を allowed paths に追加する

    実装時の優先順位

    1. artifact schema を先に固定
      finding_kind / checker_evidence / deterministic_domain_key の schema を先に決める。ここを曖昧にすると、後続の routing test が意味を失います。

    2. producer-realistic integration test を先に追加
      現行の hand-rolled fixture は弱いです。まず実際の compact_review_result.py artifact shape で落ちる test を作るべきです。

    3. any_backed を廃止
      blocker 単位で routing し、unsupported finding を別 lane に分離する。

    4. phase state を review_arbitration にするか、rewrite 更新を遅延
      arbitration 前に rewrite phase を記録しない。

    5. Codex surface drift を解消
      .codex/agents/issue-reviewer.toml の参照先と allowed paths の不整合を潰す。

    最終判定

    この Issue は必要。ただし現状のままでは実装者が「instructions を少し足して、fixture を追加して PASS」に逃げられる余地があります。
    #1042 の成功条件は、PR #1032 の後段 replay を増強することではなく、issue-reviewer が unsupported deterministic-domain blocker を 生成できない / blocker として compact artifact に入れられない / routing で iteration を消費できない ところまで上流で閉じることです。

  3. squne121 commented on Jun 20, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: 本文更新

    • owner comment の主論点に合わせて、instructions 追記中心の曖昧な改善から、producer-side fail-closed contract / compact artifact / Codex parity を固定する実装 Issue に絞り直しました。
    • current repo reality に合わせて、.agents/skills/review-issue/SKILL.md を含む surface parity を明示し、存在しない consumer-side replay surface への依存は Out of Scope 側へ退避しました。
    • Acceptance Criteria を AC1-AC8 の安定参照付きに更新し、finding_kind / checker_evidence / stale evidence rejection / checker_gap と heuristic_concern の分類境界を明文化しました。
    • Verification Commands は bare # AC<N> 形式へ正規化し、check_issue_contract.py と contract_readiness_check.py --mode preflight-static の両方で green を確認済みです。
  4. squne121 commented on Jun 20, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

  5. squne121 commented on Jun 20, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-20T17:27:24Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1042
      body_sha256: "sha256:cd7a8d17dd7f559051d11c71c93c146a3d097ddb0f6a0668c0c40cbbd78234bb"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
      source: ensure_contract_snapshot_auto
  6. squne121 commented on Jun 20, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-06-21T00:00:00Z)

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      draft_pr_ready: true
      github_merge_ready: true
      github_merge_state_status: CLEAN
      merge_ready: true
      pr_url: "https://github.com/squne121/loop-protocol/pull/1058"
      head_sha: "72a7943990429e245dff782732bc823fc1bbf287"
      issue_number: 1042
      termination_reason: approved
      iteration: 1
      required_auto_actions: []
    
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: impl-review-loop
      follow_up_issues: []
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