Repository navigation
Description
Machine-Readable Contract
以下に機械可読コントラクトを示す。
contract_schema_version: v1
issue_kind: research
parent_issue: "none"
goal_ref: "impl-review-loop preparation の scope rollup preflight を read-only Haiku SubAgent に委譲し、main conversation は検証済み summary marker のみ採用する"
change_kind: docsParent Issue
none(単独設計提案)
Parent Goal Ref
単独の設計改善であり、親 Issue は存在しない。
- Goal: N/A(単独設計提案のため該当なし)
- Desired Destination: N/A(同上)
Background
impl-review-loop の main conversation は orchestration / routing / final adoption を責務とするべきであり、plan_issue_scope_rollup.py のような決定論的 preflight 実行や大量の gh issue list / gh pr list 出力処理を main context に載せ続けるのは context 汚染・token 消費・責務肥大化につながる。
Claude Code SubAgent は独立 context、tool 制限、model: haiku、permissionMode を持てるため、read-only / mutation-free な preflight runner と相性がよい。
本 Issue は #607 の ## Scope Boundary Note で「別 Issue として扱う」と明記されたアーキテクチャ変更の設計 Issue である。
Outcome
この Issue の実装完了後、以下の状態になる。
.claude/agents/scope-rollup-runner.md が存在し、model: haiku / permissionMode: auto で plan_issue_scope_rollup.py を実行・結果 marker を生成する専用 agent が定義されている。impl-review-loop/steps/preparation.md の Step 2.5 は runner 委譲型に変更され、runner が stdout に ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 marker を返す。marker は ref-based 設計とし、full plan の inline 埋め込みを禁止する。marker に含めるのは raw_plan_location(ファイルパス)、result_sha256(ファイルバイト列の sha256)、suggested_actions_summary(1-3 行の要約)のみ。main conversation は marker の検証後に raw_plan_location から plan を必要に応じて読み込む(default では読み込まない)。GitHub comment への直接投稿は runner の責務ではなく、main conversation が必要に応じて行う。
In Scope
.claude/agents/scope-rollup-runner.mdの新規作成model: haikupermissionMode: automaxTurnsの設定tools: Read, Grep, Glob, Bash- Write/Edit/PR作成/Issue編集は禁止
plan_issue_scope_rollup.py実行と summary marker 出力に限定- runner は GitHub mutation を行わない(
gh issue comment,gh api -X POST/PATCH,git push,git commit等を禁止)
.claude/skills/impl-review-loop/steps/preparation.mdの Step 2.5 を runner 委譲型に変更- main は runner の marker を
schema/issue/repo/invocation_id/input_sha/result_sha/script_shaで検証する - main は raw plan を default で読み込まない(
raw_plan_locationは debug 専用) - runner unavailable / permission denied の fallback を明示する(silent fallback で main が raw output を読むことを禁止)
- main は runner の marker を
- runner 出力の machine-readable marker 仕様追加
ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1は ref-based 設計(full plan inline 禁止)- 含むフィールド:
schema_version,repo,current_issue,invocation_id,requested_at,generated_at,git_head_sha,script_path,script_blob_sha256 inputs:current_issue_sha256,issues_all_sha256,prs_all_sha256,issue_count,pr_countresult:plan_schema,raw_plan_location(ファイルパス),result_sha256(ファイルバイト列 sha256),suggested_actions_summary(1-3 行),candidate_count,high_confidence_count- full plan JSON は marker に含めない(main context 汚染防止)
result_sha256計算仕様- 計算対象:
raw_plan_locationのファイルバイト列(sha256sum/shasum -a 256コマンドの出力と同一) - 正規化不要: ファイルバイト列をそのまま sha256 計算するため canonical JSON(RFC 8785 等)は不要
- runner: plan を
raw_plan_locationのパスに保存し、そのバイト列の sha256 を計算してresult_sha256に格納 - main: marker の
raw_plan_locationからファイルを読み取り、バイト列の sha256 を計算してresult_sha256と照合する
- 計算対象:
Out of Scope
plan_issue_scope_rollup.pyの判定ロジック変更(実装: preflight scope rollup に proceed_with_coordination を追加し uncertain 衝突の過剰停止を廃止する #607 担当)proceed_with_coordinationの導入(実装: preflight scope rollup に proceed_with_coordination を追加し uncertain 衝突の過剰停止を廃止する #607 担当)- security-risk gate の新規設計・実装(設計: scope rollup から security escalation を分離した専用 security-risk gate skill を検討する #558 担当)
- Issue 本文編集、label変更、PR作成の runner への委譲
- nested SubAgent delegation
- runner による Issue/PR/comment mutation
- raw plan の main context 取り込み
- runtime Bash mutation enforcement(PreToolUse hook / allowlist による実行時遮断)は本 Issue の対象外。別 Issue で設計する。
Acceptance Criteria
- AC1:
.claude/agents/scope-rollup-runner.mdが存在し、name: scope-rollup-runner,model: haiku,tools: Read, Grep, Glob, Bash,maxTurnsが設定されている - AC2: runner の agent 定義ファイルに GitHub mutation / repo mutation コマンドが記述されていない(テキスト禁止モデル)。対象禁止パターン:
gh issue (edit|close|comment|create),gh pr (create|merge|close|edit),gh api -X (POST|PATCH|PUT|DELETE),git (push|commit|checkout|branch|worktree),teeのリポジトリパス出力 - AC3: Step 2.5 は runner 委譲を明記し、main conversation で raw
gh issue/pr listoutput を展開しない - AC4:
ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1はrepo/current_issue/invocation_id/generated_at/script_blob_sha256/inputs_sha/result_shaを含む - AC5: main conversation は marker を検証し、不正・stale・issue mismatch・sha mismatch の場合は採用しない
- AC6:
proceed_with_coordination候補は既存 実装: preflight scope rollup に proceed_with_coordination を追加し uncertain 衝突の過剰停止を廃止する #607/feat(#607): uncertain 衝突に proceed_with_coordination を導入しキーワードベース即時停止を廃止する #613 の semantics を維持し、LOOP_STATE.scope_rollup_decision.related_coordination[]に反映される - AC7: runner unavailable / permission denied の fallback は明示され、silent fallback で main が raw output を読むことを禁止する
Verification Commands
各 AC に対応する検証コマンドを以下に示す。
# AC1
$ test -f .claude/agents/scope-rollup-runner.md# AC1
# preflight-scope: pr_review_only
$ rg -q "name: scope-rollup-runner" .claude/agents/scope-rollup-runner.md# AC1
# preflight-scope: pr_review_only
$ rg -q "model: haiku" .claude/agents/scope-rollup-runner.md# AC1
# preflight-scope: pr_review_only
$ rg -q "maxTurns:" .claude/agents/scope-rollup-runner.md# AC2
$ ! rg -n "gh issue (edit|close|comment)|gh pr (create|merge|close|edit)|gh api .* -X (POST|PATCH|PUT|DELETE)|git (push|commit)|\\btee\\b" .claude/agents/scope-rollup-runner.md# AC3
$ rg -q "scope-rollup-runner" .claude/skills/impl-review-loop/steps/preparation.md# AC4
$ rg -q "ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1" .claude/skills/impl-review-loop/steps/preparation.md# AC4
$ rg -q "invocation_id" .claude/skills/impl-review-loop/steps/preparation.md# AC4
$ rg -q "raw_plan_location" .claude/skills/impl-review-loop/steps/preparation.md# AC4
$ rg -q "suggested_actions_summary" .claude/skills/impl-review-loop/steps/preparation.md# AC5
$ rg -q "mismatch\|stale\|採用しない\|reject" .claude/skills/impl-review-loop/steps/preparation.md# AC6
$ rg -q "related_coordination\|proceed_with_coordination" .claude/skills/impl-review-loop/steps/preparation.md# AC7
$ rg -q "scope_rollup_runner_unavailable\|fallback.*runner\|runner.*unavailable" .claude/skills/impl-review-loop/steps/preparation.mdAllowed Paths
変更対象ファイルを以下に限定する。
.claude/agents/scope-rollup-runner.md.claude/skills/impl-review-loop/steps/preparation.md
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- runner が
plan_issue_scope_rollup.pyの判定ロジック変更を要求する場合 - Haiku 以外のモデルが必要と判明した場合
Required Skills
なし
Runtime Verification Applicability
本 Issue はワークフロー文書および agent 定義の変更のみであり、ゲームの実行時挙動を変更しない。
decision: not_applicable
reason: "Workflow documentation and agent definition changes only. No runtime game behavior changed."Handoff Contract
Current Objective: scope-rollup preflight を Haiku SubAgent runner に委譲し、main conversation への raw output 流入を防ぐBounded Current Context:.claude/agents/scope-rollup-runner.md(新規)および.claude/skills/impl-review-loop/steps/preparation.md(Step 2.5 変更)Open Questions: なし(AC/VC により定義済み)Next Action: impl-review-loop で実装Artifact Refs: なし
Activity
squne121 commentedon Jun 3, 2026
判定: REQUEST_CHANGES
#611 の方向性は妥当です。
plan_issue_scope_rollup.pyの大量gh issue/pr list出力を main conversation に載せ続けない、という問題意識は Claude Code subagent の用途と一致しています。公式 docs でも、subagent は独立 context で作業し、main conversation には結果だけ返す用途に適しているとされています。([GitHub]1)ただし、現 Issue 契約のままだと実装時に破綻する可能性が高いです。主な問題は「read-only runner」と「GitHub comment marker 再取得」が同居している点です。
Blocker 1: read-only runner と GitHub comment marker が矛盾している
#611 は runner を
Read, Grep, Glob, Bashに限定し、Write/Edit/PR 作成/Issue 編集を禁止するとしています。一方で Outcome では、main conversation が「GitHub comment の machine-readable marker を再取得」して採用すると書かれています。([GitHub]1)GitHub comment を生成するには
gh issue commentや REST API POST などの mutation が必要です。ところが AC4 の禁止確認はgh issue edit|gh pr create|Edit|Writeだけで、gh issue comment、gh api -X POST、gh api repos/.../issues/.../commentsを捕捉できません。結果として、runner が「read-only」と称しながら GitHub にコメント投稿できる抜け道が残ります。([GitHub]1)修正方針はどちらかに寄せるべきです。
ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1の最小 marker だけを返す。main はその marker を検証してLOOP_STATEに採用する。GitHub comment は使わない。gh issue commentのみに限定する。この場合、AC4 と negative grep を全面的に書き換える必要があります。現時点の #611 は 1〜3 のどれでもなく、中途半端です。
Blocker 2:
permissionMode: dontAskは Bash runner と相性が悪い#611 は
permissionMode: dontAskを AC2 に入れていますが、Claude Code docs ではdontAskは permission prompt を自動 deny する mode です。明示的に許可された tool は動く一方、Bash command の許可 prompt が発生する場合は失敗し得ます。([code.claude.com]2)この runner は
gh issue view、gh issue list、gh pr list、python3 ...plan_issue_scope_rollup.pyを Bash で実行する設計です。現在の #611 には、それらの Bash command を permission allowlist に入れる記述がありません。dontAsk固定だと「自律 runner なのに許可 denied で止まる」実装になる可能性があります。([GitHub]3)修正案:
または、
dontAskを維持するなら、project settings 側で以下のような許可範囲を明記する必要があります。ただし
autoでも high-stakes mutation の代替にはならないため、runner は mutation-free に閉じるのが安全です。Anthropic も auto mode は高リスク操作に対する careful human review の完全代替ではないと説明しています。([Anthropic]4)Blocker 3: marker の真正性・鮮度検証が弱い
#611 の marker fields は
schema_version,current_issue,generated_at,script,input_refs,result_sha256,suggested_actions_summary,raw_plan_locationです。([GitHub]1)これだけでは stale marker や別入力の流用を十分に防げません。最低限、以下を marker に追加すべきです。
main conversation 側は
repo/current_issue/invocation_id/script_blob_sha256/input sha/result_sha/generated_atを検証してから採用するべきです。generated_atだけでは、古い正常 marker を再利用する攻撃・誤採用を防げません。Blocker 4:
raw_plan_locationが context 汚染を再発させる#611 は「raw output 流入を防ぐ」ことを goal にしていますが、marker に
raw_plan_locationを持たせる設計です。([GitHub]1)これは危険です。main conversation が
raw_plan_locationを開く運用になれば、結局 raw plan が main context に流入します。runner の価値は「大量探索を subagent に隔離し、main に summary だけ返す」点にあります。Claude Code docs でも、subagent は大量検索結果や file contents を main conversation に持ち込まない用途が想定されています。([code.claude.com]2)修正案:
または raw plan を保存するなら、main は通常
result_sha256と summary だけを使い、debug 時だけ人間が明示的に読む設計にしてください。Blocker 5: Bash tool だけでは mutation-free を保証できない
tools: Read, Grep, Glob, Bashから Write/Edit を外しても、Bash は shell redirection や CLI 経由でファイル作成・GitHub mutation・git 操作ができます。Claude Code docs も、tool access は allowlist/denylist で制御できる一方、Bash を許す場合は permission mode や policy が別途重要になります。([code.claude.com]2)#611 の AC4 は
gh issue edit|gh pr create|Edit|Writeの grep だけなので、以下を検出できません。少なくとも negative verification はこの程度まで広げるべきです。
ただし grep は完全なセキュリティ境界ではありません。最終的には
permissionModeと command allowlist で制御すべきです。Blocker 6: subagent のロード/起動条件が契約にない
Claude Code の project subagent は
.claude/agents/に置けますが、docs では subagent file は session start 時にロードされ、直接 file を追加・編集した場合は session restart が必要とされています。([code.claude.com]2)#611 は
.claude/agents/scope-rollup-runner.mdを追加するだけで、impl-review-loopからの明示 invocation 方式が曖昧です。Step 2.5 に「scope-rollup-runner に委譲」と書くだけでは、既存 session で確実に起動できる保証がありません。([GitHub]1)preparation.md には、少なくとも以下を明記すべきです。
関連 Issue / PR との整合
#607 は、
uncertainを人間停止ではなくproceed_with_coordinationに倒す修正で、#613 により merged 済みです。#613 は最終的に TEST_VERDICT_MACHINE v1 の検証コメント、44 件の pytest pass、typecheck/test/build pass を確認して approve/merge されています。([GitHub]5)現在 main の preparation Step 2.5 は、worktree 作成前に
gh issue list/gh pr list/plan_issue_scope_rollup.pyを main conversation 側で実行する設計です。#611 はここを subagent 委譲型に置換する後続設計なので、#607/#613 の判定ロジック自体には触れない、という Out of Scope は正しいです。([GitHub]3)#558 は「scope rollup は security gate ではない。security-risk gate は別責務」という整理です。#611 の runner は scope collision preflight executor に閉じ、security/auth/credential 判定を追加しないほうが整合します。([GitHub]6)
#597 は似た「Haiku SubAgent による preflight materialization」案ですが、現在は “Closed as not planned” です。#611 の設計で
permissionMode: dontAskや GitHub comment 生成の前例として #597 を無批判に流用しないほうがよいです。([GitHub]7)推奨する #611 契約修正版
最小修正ならこうです。
AC もこう直すべきです。
最終コメント
#611 は着眼点は良いですが、今のままだと「context 汚染を避けるための runner」が、GitHub comment mutation・Bash 書き込み・permission denied・stale marker 誤採用という別の事故源になります。
実装に進める前に、まず runner は本当に read-only なのか、GitHub comment を誰が投稿するのか、main は何を検証して採用するのか を Issue 本文に固定してください。そこを直せば、#607/#613 の後続として実装可能です。
squne121 commentedon Jun 3, 2026
コントラクトレビュー: BLOCKED (2026-06-03T07:00:00Z)
不足項目と修正方法
ブロッカー 1:
## Handoff Contractが存在しない(research.yml 必須)以下を Issue 本文末尾に追加してください:
ブロッカー 2: AC1 の rg コマンドに
# preflight-scope: pr_review_onlyマーカーを追加(simple_contract_hygiene_fix)rg はターゲットファイルが存在しない場合 exit code 2(エラー)を返すため、分類不能(human_judgment)になります。baseline では
test -fが存在確認を担うため、コンテンツ検証 rg にはpr_review_onlyマーカーを付与してください:推奨アクション
上記 2 点を修正後、
issue-contract-reviewを再度実行してください。なお
issue_kind: researchかつ Allowed Paths に実装対象ファイルが含まれている点は、research テンプレートの想定範囲(読み取り専用・次 Issue 起票ゴール)と乖離しています。issue_kind: implementationへの変更も検討してください。squne121 commentedon Jun 3, 2026
コントラクトスナップショット (2026-06-03T07:10:00Z)
.claude/agents/scope-rollup-runner.mdがmodel: haiku/permissionMode: autoでplan_issue_scope_rollup.pyを実行しISSUE_SCOPE_ROLLUP_RUN_RESULT_V1marker を stdout に返す専用 agent として定義され、impl-review-loop/steps/preparation.mdの Step 2.5 が runner 委譲型に変更された状態.claude/agents/scope-rollup-runner.md.claude/skills/impl-review-loop/steps/preparation.md.claude/worktrees/issue-611-impl-review-loop-preparation-preflight-hworktree-issue-611-impl-review-loop-preparation-preflight-h[-]設計: impl-review-loop preparation の決定論的 preflight を Haiku SubAgent runner に委譲する[/-][+]実装: impl-review-loop preparation の決定論的 preflight を Haiku SubAgent runner に委譲する[/+]squne121 commentedon Jun 3, 2026
implement-issue: 実装完了 (2026-06-03T07:12:45Z)
.claude/worktrees/issue-611-impl-review-loop-preparation-preflight-hworktree-issue-611-impl-review-loop-preparation-preflight-hsqune121 commentedon Jun 3, 2026
コントラクトスナップショット v2 (2026-06-03T08:10:00Z)
前回のスナップショット(
status: go、07:10:00Z)は Issue #611 本文更新により無効化されました。本コメントが最新の有効スナップショットです。.claude/agents/scope-rollup-runner.mdがmodel: haiku/permissionMode: autoでplan_issue_scope_rollup.pyを実行しISSUE_SCOPE_ROLLUP_RUN_RESULT_V1marker(ref-based:raw_plan_location+result_sha256+suggested_actions_summary)を stdout に返す専用 agent として定義され、impl-review-loop/steps/preparation.mdの Step 2.5 が runner 委譲型に変更された状態.claude/agents/scope-rollup-runner.md.claude/skills/impl-review-loop/steps/preparation.md.claude/worktrees/issue-611-impl-review-loop-preparation-preflight-hworktree-issue-611-impl-review-loop-preparation-preflight-h主な変更点(前回スナップショットからの差分)
raw_plan_location+result_sha256+suggested_actions_summary)に変更result_sha256計算仕様追加(ファイルバイト列 sha256、RFC 8785 不要)raw_plan_location/suggested_actions_summaryの確認コマンドを追加fix(#611): scope-rollup marker を ref-based 設計に変更し result_sha256 仕様を明確化
feat(#611): scope-rollup-runner SubAgent と preparation Step 2.5 の run…
squne121 commentedon Jun 3, 2026
PR #625 がマージされたため本 Issue をクローズします。
squne121 commentedon Jun 3, 2026
post-merge-cleanup: 完了 (2026-06-03T08:55:00Z)
worktree-issue-572-quick-save-ssotbranch(未マージ)とstash@{0}の処分を人間が判断実行結果
feat(#634): handoff/PR hygiene failure の before-fail/after-pass 回帰テスト…