Skip to content

実装: issue-reviewer SubAgent 内に Step 2a arbitration を co-locate し親の raw artifact 直接読み契約を廃止する #1472

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1465"
goal_ref: "Step 2a の producer(issue-reviewer SubAgent)と consumer(reviewer_claim_replay.py)を同一 SubAgent 実行境界内に co-locate し、親が子 worktree の raw artifact を直接読む契約を廃止する(#1465 採用方針 (e))"
change_kind: code+docs

Parent Issue

#1465

Parent Goal Ref

  • Goal: isolation worktree 環境で issue-reviewer 等 SubAgent の artifact が呼び出し元(orchestrator)から解決できない問題に対し、runtime evidence に基づいて対応方針を決定する
  • Desired Destination: OWNER 採択の候補 (e)(producer/consumer co-location)を実装する implementation Issue

Current Validated Scope

  • issue-reviewer SubAgent が VERDICT: needs-fix を返す場合に、同一 SubAgent 実行境界内で reviewer_claim_replay.py(Step 2a arbitration)を追加実行し、REVIEWER_CLAIM_REPLAY_V1 相当の compact な結果を stdout に含めて返す
  • .claude/skills/issue-refinement-loop/SKILL.md Step 2a の手順を、orchestrator が --review-result-file に artifact パスを渡して reviewer_claim_replay.py を呼ぶ設計から、issue-reviewer SubAgent の stdout に含まれる compact な arbitration 結果を orchestrator がそのまま consume する設計に更新する
  • .claude/agents/issue-reviewer.md と .codex/agents/issue-reviewer.toml の出力契約・実行手順の同期(Claude/Codex parity 維持)
  • session/issue number binding を検証する negative test の追加(tamper / symlink / wrong session / wrong issue number / wrong body hash / oversize / stale artifact)

Remaining Parent Gaps

Outcome

issue-reviewer SubAgent が VERDICT: needs-fix の場合に reviewer_claim_replay.py(Step 2a arbitration)を SubAgent 内で実行し、REVIEWER_CLAIM_REPLAY_V1 相当の compact な結果(verdict / routing / should_consume_iteration / body_sha256 / artifact_digest を含む)を stdout に追記した状態で issue-refinement-loop orchestrator が consume できるように、.claude/agents/issue-reviewer.md / .codex/agents/issue-reviewer.toml / .claude/skills/issue-refinement-loop/SKILL.md Step 2a を更新し、既存テストスイート(.claude/skills/issue-refinement-loop/tests/ および tests/test_agent_parity.py)が全て green になっている状態。

In Scope

  • issue-reviewer SubAgent 内での producer(compact_review_result.py)→ consumer(reviewer_claim_replay.py)実行の co-location
  • .claude/agents/issue-reviewer.md / .codex/agents/issue-reviewer.toml の出力契約更新(REVIEWER_CLAIM_REPLAY_V1 相当フィールドの stdout 追記)
  • .claude/skills/issue-refinement-loop/SKILL.md Step 2a 手順の更新(orchestrator 側の呼び出し契約を「artifact パス経由呼び出し」から「SubAgent stdout consume」へ変更)
  • .claude/skills/issue-refinement-loop/references/loop-state.md の consumer 記述更新(必要な場合のみ)
  • 上記変更に伴う既存テスト(test_reviewer_claim_replay.py 系、test_agent_parity.py、test_design_note_contract.py 等)の更新
  • tamper / symlink / wrong session / wrong issue number / wrong body hash / oversize / stale artifact の negative test 追加(既存 test_artifact_security.py / test_reviewer_claim_replay.py に session/issue番号 binding の検証が不足していることが 調査: isolation worktree 環境で issue-reviewer 等 SubAgent の artifact が呼び出し元から解決できない問題の対応方針を決定する #1465 調査で判明したための gap 埋め)
  • isolation worktree 環境で親が子 worktree の raw artifact を直接読む必要がなくなることの runtime evidence による再確認

Out of Scope

Acceptance Criteria

  • AC1: .claude/agents/issue-reviewer.md が VERDICT: needs-fix の場合に SubAgent 内で reviewer_claim_replay.py を実行し、REVIEWER_CLAIM_REPLAY_V1 相当のフィールドを stdout に含める手順を記述している
  • AC2: .claude/skills/issue-refinement-loop/SKILL.md Step 2a が、orchestrator が子 worktree の raw compact_review_result artifact を artifact パス経由で直接 open/read せず、SubAgent stdout の compact な arbitration 結果を consume する契約を記述している
  • AC3: .codex/agents/issue-reviewer.toml が .claude/agents/issue-reviewer.md と同じ出力契約を記述しており、tests/test_agent_parity.py が新しい drift/ok fixture で PASS する
  • AC4: session/issue number binding の negative test(tamper / symlink / wrong session / wrong issue number / wrong body hash / oversize / stale artifact)が .claude/skills/issue-refinement-loop/tests/ に追加され、変更前は存在しなかったことが確認できる
  • AC5: .claude/skills/issue-refinement-loop/tests/ 配下の既存テストスイートが全て green である
  • AC6: tests/test_agent_parity.py が green である

Verification Commands

# AC1
$ rg -n "reviewer_claim_replay" .claude/agents/issue-reviewer.md
# AC2
$ rg -n "SubAgent stdout の compact な arbitration" .claude/skills/issue-refinement-loop/SKILL.md
# AC3
$ rg -n "reviewer_claim_replay" .codex/agents/issue-reviewer.toml
# AC4
$ rg -n "wrong_body_hash" .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay.py
# AC5
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/ -q
# AC6
# preflight-scope: pr_review_only
$ uv run --locked pytest tests/test_agent_parity.py -q

Allowed Paths

  • .claude/agents/issue-reviewer.md
  • .codex/agents/issue-reviewer.toml
  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/skills/issue-refinement-loop/references/loop-state.md
  • .claude/skills/issue-refinement-loop/tests/
  • tests/agent-parity/
  • tests/test_agent_parity.py
  • docs/dev/workflows/issue-refinement-loop-design.md

Stop Conditions

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

Required Skills

  • なし

Required Design References

Scope Delta(任意)

N/A

Delivery Rule

  • 1 Issue = 1 PR
  • 実装は専用 worktree(.claude/worktrees/issue-<N>-<slug>/)で行う
  • PR は Draft を既定とする

Runtime Verification Applicability

  • decision: immediate
  • reason: SubAgent 実行境界・isolation worktree 環境での動作確認(producer/consumer co-location の実際の SubAgent 起動・stdout 検証)を伴うため
  • if immediate:
    applicable_acs: AC1, AC3, AC4, AC5, AC6
    execution_environment: uv run --locked pytest、rg、Claude Code Agent tool(isolation worktree 起動、issue-reviewer SubAgent 実行)
    skip_conditions: isolation worktree 起動権限がない、または Agent tool を呼び出せない環境では該当 AC の runtime 実行を SKIP し、docs/dev/runtime-verification-policy.md の SKIP 規約に従って exit 77 と理由を記録する
    fallback_policy: SubAgent 実行や negative test 実行ができない場合に、既存ログの参照や自己申告のみで PASS を主張しない。実行不能な場合は SKIP として記録し、PASS とは扱わない
    artifact_requirements: runtime 実行結果(issue-reviewer SubAgent の実際の stdout、pytest 実行ログの exit code)は本 Issue のコメントまたは PR 本文に machine-readable な形式(コマンドと exit code の組)で記録する

Related Issues

Notes for Reviewer

  • 本 Issue の Allowed Paths は 調査: isolation worktree 環境で issue-reviewer 等 SubAgent の artifact が呼び出し元から解決できない問題の対応方針を決定する #1465 で確認済みの consumer inventory(rg -n "ISSUE_REVIEW_RESULT_COMPACT_V1|REVIEWER_CLAIM_REPLAY_V1|reviewer_claim_replay" .claude .codex .agents docs scripts tests で列挙された23ファイル)のうち、実際の変更が必要なファイルに絞っている
  • compact_review_result.py / reviewer_claim_replay.py の本体スクリプトは Allowed Paths に含めていない(判定ロジック本体は Out of Scope。呼び出しタイミング・出力 pass-through のみを変更する想定のため)。実装過程で本体スクリプトへの変更が必要と判明した場合は Stop Conditions に従い一時停止し、Scope Delta として明記してから続行すること
  • .claude/skills/issue-refinement-loop/scripts/build_refinement_phase_state.py / check_issue_contract.py などの周辺スクリプトへの波及有無は実装時に確認すること(現時点では不要と判断)
  • AC6 の tests/test_agent_parity.py は contract-review 時点で .claude/agents/web-researcher.md: expected route token 'grounded_research_or_direct_web' not found という、本 Issue の Allowed Paths(.claude/agents/issue-reviewer.md / .codex/agents/issue-reviewer.toml)と無関係な既存の pre-existing failure により baseline で red である(preflight-scope: pr_review_only を付与済み)。pr-review-judge は本 PR の diff 適用前後で該当 failure の有無・内容が変化していないこと(本 PR が原因で新規に悪化させていないこと)を確認し、issue-reviewer / web-researcher それぞれの failures エントリを区別して判定すること

Handoff Contract

  • Current Objective: issue-reviewer SubAgent 内に Step 2a arbitration(reviewer_claim_replay.py)を co-locate し、orchestrator が子 worktree の raw artifact を直接読む契約を廃止する
  • Bounded Current Context: .claude/agents/issue-reviewer.md / .codex/agents/issue-reviewer.toml の出力契約、.claude/skills/issue-refinement-loop/SKILL.md Step 2a の呼び出し手順、reviewer_claim_replay.py の --review-result-file 入力契約
  • Open Questions: SubAgent 内実行時の --readiness-result-file / --vc-preflight-result-file 等の追加入力をどう SubAgent 内で取得するか(既存の contract_readiness_check.py --mode execute 呼び出しとの結線)
  • Next Action: issue-reviewer.md の手順に reviewer_claim_replay.py 呼び出しを追加し、SKILL.md Step 2a を stdout consume 契約に書き換え、negative test を追加する
  • Artifact Refs: Issue 調査: isolation worktree 環境で issue-reviewer 等 SubAgent の artifact が呼び出し元から解決できない問題の対応方針を決定する #1465 本文(採用方針決定の経緯・runtime evidence・negative_test_cases 定義)

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Jul 11, 2026
  2. squne121 commented on Jul 11, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-11T15:49:09Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1472
      body_sha256: "sha256:479fe86f7ef7339f7798fb9bd51add694fd61c61b66ac85f7d5222c91f93a4b1"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight:
          decision: pass
          classifications: [{"ac":"AC1","line":2,"raw_command":"rg -n \"reviewer_claim_replay\" .claude/agents/issue-reviewer.md","command_hash":"sha256:ddc955506a4dd87656441ed8244f5cf15b75f487c6a95ad8dcdf045c3fe19423","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":2,"fix_hint":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC2","line":2,"raw_command":"rg -n \"SubAgent stdout の compact な arbitration\" .claude/skills/issue-refinement-loop/SKILL.md","command_hash":"sha256:c356d44d8616102fd1a6a47db88fc68c8a03886855895d60d6e012f79f6ec183","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":2,"fix_hint":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC3","line":2,"raw_command":"rg -n \"reviewer_claim_replay\" .codex/agents/issue-reviewer.toml","command_hash":"sha256:c78828de32f8c278d7cc98526b564a7ae1fcd36701f87b87c501956ba19345f1","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":1,"fix_hint":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC4","line":2,"raw_command":"rg -n \"wrong_body_hash\" .claude/skills/issue-refinement-loop/tests/test_reviewer_claim_replay.py","command_hash":"sha256:7effe840d4ccbd10380f68a0a8476f8ecfb9c938e53c724c1853828baa70fa7c","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":1,"fix_hint":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC5","line":2,"raw_command":"uv run --locked pytest .claude/skills/issue-refinement-loop/tests/ -q","command_hash":"sha256:8a75b24e69ea4f8ccdf6e76669f8f58e64f79cbdd81ed6ded3d812335206a9aa","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["........................................................................ [  5%]","........................................................................ [ 11%]","........................................................................ [ 17%]","........................................................................ [ 23%]","........................................................................ [ 28%]","........................................................................ [ 34%]","........................................................................ [ 40%]","........................................................................ [ 46%]","........................................................................ [ 51%]","........................................................................ [ 57%]","........................................................................ [ 63%]","........................................................................ [ 69%]","........................................................................ [ 74%]","........................................................................ [ 80%]","........................................................................ [ 86%]","........................................................................ [ 92%]","........................................................................ [ 97%]","............................                                             [100%]","1252 passed in 27.13s"],"stdout_truncated":false,"stdout_original_line_count":20,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":27459,"fix_hint":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC6","line":3,"raw_command":"uv run --locked pytest tests/test_agent_parity.py -q","command_hash":"sha256:78a84e5604db3ae51a43ef62642490b69b10fa95f029b77bbf299de5b56694fb","runner":"skipped","exit_code":null,"classification":"skipped","category":"preflight_scope_pr_review_only","decision":"go","scope_class":"pr_review_only","confidence":"low","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":0,"fix_hint":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"verification_owner":"pr-review-judge","deferred_reason":"VC marked pr_review_only; verification deferred to PR review","runtime_verification_required":false}]
      source: ensure_contract_snapshot_auto
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