Repository navigation
Description
Machine-Readable Contract
contract_schema_version: "v1"
issue_kind: implementation
parent_issue: none
goal_ref: "#2393"
change_kind: choreParent Issue
なし
(単独改善。参考: 親トラッカー #2190、起点 #2393、実装元 PR #2520)
Parent Goal Ref
- Goal: 実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 は
contract_update.run.with_anchor/contract_update.run.with_human_contextの dedicated-runtime 移行を目的とし、PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520 でマージ済み。本 Issue はその PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520 の AC5 修正で発覚したテストカバレッジ gap を埋める follow-up。 - Desired Destination: N/A
Current Validated Scope
scripts/agent-guards/skill_runtime_exec.py の _dispatch_child_and_check_postconditions() が持つ 3 つの outer-failure emission site(timeout / unauthorized-write / artifact-projection failure)のうち、real-dispatcher regression test が存在しないのは artifact-projection failure のみ。この gap を対象に real-dispatcher test を追加する。
Remaining Parent Gaps
本 Issue 完了後も、_resolve_inner_transaction_evidence_fields() 自体の設計や _dispatch_child_and_check_postconditions() の三分岐構造そのものへの改修は未着手のまま残る(Non-goals 参照)。
Outcome
scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py に、real dispatcher(registry → policy → executor → subprocess chain)を経由して artifact-projection failure を意図的に発生させる新規テスト test_contract_update_outer_artifact_projection_failure_preserves_inner_transaction_result を追加する。
このテストは、既存の fake GitHub executable + isolated Git fixture(test_contract_update_phase_reaches_fake_transaction_and_fresh_handoff と同種の fixture)を再利用し、inner GitHub mutation・最終 readback・inner result JSON 保存がすべて完了した「後」に、stdout 上の artifact projection だけを不正にする。production code は一切変更しない。
テストは次を一体で検証する。
- outer dispatch が狙った artifact-projection failure 分岐で失敗すること(
returncode・空のstdout・reason_code/recovery/stale_pathを AND 条件で確認)。 - inner transaction の recovery —
SKILL_RUNTIME_FAILstderr からinner_transaction_result_refとinner_transaction_disposition=patchの両方を回収し、その参照先を実際に開いて期待される inner result JSON を確認できること。 - fake GitHub executable への mutation/write がちょうど 1 回であり、blind resend が発生していないこと。
uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py が新規テストを含めて green になった時点で完了とする。
Runtime Verification Applicability
decision: immediate
applicable_acs:
- AC1
- AC2
- AC3
- AC4
- AC5
execution_environment:
cli_tools:
- python3
- uv
auth_required: false
network_required: false
skip_conditions:
- "isolated Git fixture / fake GitHub executable が利用できない環境では SKIP ではなく environment blocked として扱う"
fallback_policy:
fallback_success_is_pass: false
notes: "fallback 経由の成功を PASS に変換しない"
artifact_requirements:
- "pytest output (node ID 実行 + モジュール全体実行)"reason: isolated Git fixture + fake GitHub executable のみで完結する real-code, real-test の追加であり、production 実行には触れないため。
In Scope
scripts/agent-guards/tests/test_skill_runtime_exec_anchor.pyに、artifact-projection failure 経路の real-dispatcher regression testtest_contract_update_outer_artifact_projection_failure_preserves_inner_transaction_resultを追加する。- 追加テストは、既存の fake GitHub executable + isolated Git fixture を使い、inner GitHub mutation + 最終 readback + inner result JSON 保存が完了した「後」に、outer 側で artifact-projection failure を発生させるシナリオを構築する。production code は変更しない。
- 注入は、fixture に存在する artifact root 外パス(例:
README.md)を、parser が実際に読む最初のARTIFACT:block 内の項目として参照させることで行う。そのパスへの実書き込みは行わず、unauthorized-write failure を誘発しない。stdout 末尾に2個目のARTIFACT:section を追加する方式は採用しない(現行 parser は最初の non-indent 行で読み取りを終了するため、その方式では注入が検出されない)。 - 既存
test_contract_update_phase_reaches_fake_transaction_and_fresh_handofffixture を可能な限り再利用する。
Out of Scope
- PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520 で既にマージ済みの P1-A / P1-B 修正の変更。
_resolve_inner_transaction_evidence_fields()の再設計。- 3 つの outer-failure emitter の dispatch 構造そのものの再設計。
- 親 controller
control_plane_dedicated_execution_session()への変更。 run_refinement_preflight.pyへの test-only injection point 追加(Investigation により、production code 変更なしで本 Issue の Outcome を達成できることを確認済みのため、本 Issue のスコープから除外する)。- 実装中に production 側の不具合を別途発見した場合、その修正。再現条件と事実のみを Issue コメントに記録し、canonical workflow が別途必要と判断した場合に限り follow-up Issue として切り出す(本 Issue へ無条件に混ぜない)。
Acceptance Criteria
- AC1:
scripts/agent-guards/tests/test_skill_runtime_exec_anchor.pyに、real dispatcher(registry → policy → executor → subprocess chain)経由で artifact-projection failure を発生させる新規テスト関数test_contract_update_outer_artifact_projection_failure_preserves_inner_transaction_resultが追加されている。production code(scripts/agent-guards/skill_runtime_exec.pyを含む)は変更しない。 - AC2: 追加テストは、既存 fake GitHub executable + isolated Git fixture を用い、inner GitHub mutation・最終 readback・inner result JSON 保存が完了した「後」に、parser が読む最初の
ARTIFACT:block 内の項目として fixture 内の artifact root 外パス(例:README.md)を参照させることで outer artifact-projection failure を注入する。当該パスへ実際の書き込みは行わない。 - AC3: 追加テストは、狙った outer failure 分岐であることを次の組合せで AND 条件により assert する:
returncode == 2、stdout == ""(未検証の artifact projection が caller へ公開されない)、stderr のreason_code == "stale_worktree_runtime_state"、stderr のrecovery == "do_not_publish_artifact_projection_outside_issue_artifact_root"、stderr のstale_pathがテストで注入したパス(README.md)と一致すること。 - AC4: 追加テストは、
SKILL_RUNTIME_FAILstderr 行からinner_transaction_result_refとinner_transaction_disposition=patchの両方を回収することを必須とする(どちらか一方のみで合格とする OR 条件は禁止。inner_transaction_state=unknownはこのシナリオでは失敗として扱う — mutation・readback・result 保存がすべて成立した後に artifact projection だけを壊したケースでunknownになる場合はそれ自体を regression として検出する。これは timeout 等、真に transaction state が確定できない別ケースのunknownsemantics を変更するものではない)。テストは自前で期待パスを組み立てて結果 JSON を読むだけでは不十分であり、stderr に実際に出力されたinner_transaction_result_refを parse し、その参照先を開き、専用 worktree / 当該 Issue の正しい result artifact であることと、その JSON 内容が次と一致することを確認する:contract_update.status == "failed",disposition == "patch",writes == 1,final_readback == "verified",fresh_review == "needs_fix"。 - AC5: 追加テストは、fake GitHub executable への mutation/write 呼び出し回数がちょうど 1 回であることを assert する。outer artifact-projection failure の後に mutation を再送して成功扱いにする blind resend が発生していないことを確認する。
Verification Commands
# AC1
# 新規テスト関数名の存在を baseline で確認する(実装前は不在、実装後に出現することを rg で検証する)
$ rg -n "def test_contract_update_outer_artifact_projection_failure_preserves_inner_transaction_result\(" scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py
# AC2
# AC3
# AC4
# AC5
# 対象モジュール全体を実行し、新規テストを含めた green を確認する(production code 無変更のため既存正常系テストの green 維持も同時に確認する)
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py -q注記: <file>::<new_test_name> 形式の pytest node ID を直接 Verification Commands に記載しない。既存ファイルに対する未実装 node-id 参照は本リポジトリの baseline VC preflight ポリシー(Issue #1285 / PR #1305、existing_file_missing_node_id_noncanonical は non-canonical shape として block される)に反するため、fresh canonical review の結果を踏まえてこの形に確定した。AC1 は新規テスト関数の存在を rg で個別に検証し、AC2–AC5 の実際の振る舞いはモジュール全体の pytest 実行(新規テストを含む)で検証する。
Allowed Paths
scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py
Stop Conditions
実装中にこれらの状況が発生したら直ちに作業を停止し、Issue comment に状況を記録して人間の判断を待つ。
- Allowed Paths 外の変更が必要と判明した場合(
scripts/agent-guards/run_refinement_preflight.pyを含む production code への変更が必要になった場合を含む) - In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- 決定論的な artifact-projection failure を production code 変更なしに実現できないと判明した場合(Investigation により実現可能と確認済みだが、実装時に反証が見つかった場合はここで停止し記録する)
- production code 側の不具合を別途発見した場合(本 Issue のスコープへ混ぜず、再現条件と事実のみを記録する)
Required Skills
なし
Required Design References
- docs/dev/agent-skill-boundaries.md
- docs/dev/workflow.md
Delivery Rule
1 Issue = 1 PR。worktree を切って実装し、Draft PR を既定とする。
Notes for Reviewer
この gap は PR #2520 の Safety Claim Matrix で透明に開示され、pr-review-judge により non-blocking と判断された。判断根拠は、artifact-projection call site が timeout / unauthorized-write の 2 経路とまったく同じ evidence-recovery 関数を同一引数で呼んでいるという構造的推論であり、本 Issue はそれを real-dispatcher レベルで実証的に固めるためのテストカバレッジ改善である。低優先度の単独 follow-up であり、ブロッカーではない。
本 Issue の contract は、OWNER の human review anchor comment(REQUEST_CHANGES、comment)を反映して refinement 済みである。反映内容: (1) production code modification fallback の削除と Allowed Paths の縮小、(2) 注入方法を「inner mutation/readback/result 保存完了後に最初の ARTIFACT: block 内だけを不正にする」方式へ固定、(3) 狙った outer failure 分岐を returncode/stdout/reason_code/recovery/stale_path の AND 条件で証明する要求への変更、(4) inner transaction recovery を inner_transaction_result_ref と inner_transaction_disposition=patch の両方必須(OR 禁止)かつ実際の参照先 readback による検証へ強化、(5) blind resend がないことの維持、(6) Verification Commands を新規テストの完全な pytest node ID 優先の順序へ整理。fresh repository investigation により、これらはすべて既存コードの実装と技術的に整合し、production code 変更なしで実現可能であることを確認済み。
Scope Overlap Note
Scope Collision (C1) advisory: overlap preflight (check_issue_overlap.py) が scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py について #1601(scope_rollup 統合、別 concern)との literal path 重複を検出。non_conflict_reason: 本 Issue は #1601 とは異なる concern(artifact-projection failure テストカバレッジ)を扱い、同一ファイルへの追記のみでコンフリクトのリスクは低い。scripts/agent-guards/run_refinement_preflight.py は本 refinement で Allowed Paths から除外されたため、当該ファイルに関する #420 / #205 との advisory overlap は本 Issue には適用されない。
Source
dedupe_key: follow-up:squne121/loop-protocol:pr/2520:ac5-artifact-projection-dispatcher-test
Activity
squne121 commentedon Sep 6, 2026
create-issue transaction partial-failure
Issue: #2526
Failure stage: label-apply
Message: label-apply failed
Requested:
Completed steps: create
Failure context: command=gh issue edit --repo squne121/loop-protocol 2526 --add-label triage-required,test-coverage
output=failed to update #2526: 'test-coverage' not found
failed to update 1 issue
matching_issue_numbers=[2526]
issue_number=2526
Recovery hint: stage 'label-apply' encountered an unexpected failure.
Generic guidance: verify the issue state manually and re-run the transaction if safe.
gh issue view 2526 --repo squne121/loop-protocol --json number,title,labels,state
idempotent re-run: depends on the specific failure
Please recover deterministically before re-running the create issue transaction.
squne121 commentedon Sep 6, 2026
判定:
REQUEST_CHANGES— テストの合格条件と注入方法を明確にすれば着手してよいテストを追加する方針は妥当です。ただし、現状のIssueでは「artifact-projection failureを正しく通していない」「更新結果を回収できていない」テストでも、合格扱いにできる余地があります。 修正は、本番の監督機構を増やすのではなく、今回のテストが何を証明するかを絞る方向を勧めます。
PR #2520 はマージ済みで、#2526 はそこで開示されたテスト不足を埋める低優先度のfollow-upです。今回の指摘を理由に、移行済み機能を差し戻したり、別の開発を止めたりする必要はありません。
対象Issueとコメント、#2393・#2190、PR #2520の本文・レビューコメント、executor・producer・関連テスト、責務境界・開発ワークフローを照合しました。コードのレビュー基準は、取得したコミット
608b1ae47fb4a0c72f0ac56205877079a43d4e0aです。リポジトリのpytestは実行していません。 実行したのは、取得したartifact parserと同じ処理を切り出した最小確認です。以下では、それとコードから判断した事項を区別します。
1. P1:AC3の「どちらかのフィールドがあれば合格」では、結果回収を証明できない
現在のAC3は、次のいずれかがstderrに含まれることを要求しています。
しかし、IssueのOutcomeは「更新結果の参照とdispositionを回収できること」です。フィールド名の存在だけ、しかもOR条件では弱すぎます。 参照先が存在しない場合や、dispositionだけ分かって結果の詳細を読めない場合でも通せてしまいます。
現行の
_resolve_inner_transaction_evidence_fields()は、今回のdispatch中に更新された結果ファイルからdispositionを読めた場合、参照先とdispositionの両方を返します。読み取れなければunknownです。したがって、今回の成功済み更新シナリオに合わせて、合格条件も両方の回収を必須にできます。推奨修正
今回のテストでは、最終結果JSONが保存された後に、stdoutのartifact参照だけを不正にすると固定してください。そのうえで、次を一体として検証するのが適切です。
stderrから取得した参照先を実際に開き、専用worktreeの当該Issueの結果ファイルと一致し、期待した更新結果が読めること。 テスト側で別途組み立てた「正しいはずのパス」だけを読んでは、stderrによる引き渡しを検証したことになりません。
既存の
test_contract_update_phase_reaches_fake_transaction_and_fresh_handoffと同じfixtureを使うなら、期待する内部結果は次です。このfixtureはfake GitHubへの更新とreadbackには成功し、その後のレビューがneeds_fixになる構成です。このケースでは、
inner_transaction_state=unknownを合格にしないでください。結果を確定・保存してから別の出力を壊したのにunknownへ落ちるなら、それこそ今回検出すべき回帰です。これは、本番の
unknown扱いをなくす提案ではありません。更新途中のtimeoutなど、本当に確定できないケースとはテストを分ける、という意味です。2. P1:exit codeだけでは、狙ったartifact-projection分岐を通った証明にならない
現行dispatcherの処理順は、次のようになっています。
つまり、許可範囲外にファイルを書いて失敗を注入すると、artifact検証より前のunauthorized-write判定に捕まります。これでは、既存のunauthorized-writeテストを別名でもう一本作るだけです。
さらに、既存の正常なdispatchでも、内部レビューが
needs_fixならexit codeは2です。実際、既存テストは「returncodeが2であること」と「SKILL_RUNTIME_FAILがないこと」を同時に確認しています。returncode != 0だけでは、外側の失敗さえ証明できません。この分岐を識別する条件をACに入れる
今回のテストでは、少なくとも次の組合せを要求してください。
README.mdは注入先の例です。fixtureに既にある、許可されたartifact root外のパスをstdoutで参照させます。そのファイルへの書き込みは不要です。reason_code=stale_worktree_runtime_stateは別の環境異常にも使われるため、reason codeだけでなく、recovery値と注入したパスまで照合することが重要です。加えて、前項の結果参照・dispositionが同じ失敗報告から回収できることを確認します。注入先は「最初の
ARTIFACT:ブロック内」にする現行parserは、
ARTIFACT:を見つけてからインデントされた行を読み、次の非インデント行で処理を終了します。したがって、後続セクションの後に2個目のARTIFACT:を追加しても、通常はそこまで読みません。この処理を切り出し、後続に
注入方法 | 最小実行での結果 -- | -- 出力末尾に2個目のARTIFACT:を追加 | 注入したREADME.mdを検出しない 最初のARTIFACT:ブロック内に項目を追加 | README.mdを検出するNEXT_ACTION:がある入力で実行した結果は次でした。この方針なら、Allowed Pathsは原則として次の1ファイルで足ります。
実装中に本番の不具合が見つかった場合は、その事実と再現条件を区別して記録し、このテスト追加へ無条件に混ぜない方がよいです。
検証コマンドも、目的に合わせて小さくする
現在のAC1の
rgは、テスト名の文字列があることしか確認しません。また、同じテストモジュールをAC2・AC3・AC4として繰り返し実行する必要もありません。新規テスト名を次のようにするなら、新規テストの完全なnode ID指定 → 対象モジュール全体の順を勧めます。
完全なnode IDを指定すれば、新規テストが存在しない・収集できない場合に、既存の別テストだけ通って済むことを避けられます。
--lockedを付けるのは、検証中に依存関係のlockfileを更新させないためです。uvは通常、run時にlock・syncを行い、--lockedではlockfileが古ければ更新せずエラーにします。今回のための依存更新や新規パッケージ導入は不要です。stdout/stderrは既存の
subprocess.run(capture_output=True, text=True)の戻り値を別々にassertする方式を維持してください。PythonのAPIは両ストリームを分けて返すため、**「失敗報告はstderrにあるが、未検証の成功案内はstdoutに漏れない」**ことをそのまま検証できます。emitter単体のcapsysテストへ戻す必要はありません。標準CIは維持しつつ、今回だけの新しい全体ハーネスや重い検証ゲートは追加しない判断でよいです。
最終推奨
「本番コード無変更」「既存のreal contract-update fixtureを再利用」「保存済みの結果には触れず、最終stdoutの参照だけを壊す」方式を採用してください。
そのうえで、今回のテストが必ず証明するのは、次の一連の振る舞いです。
#2393でも、artifact confinement全体の完成やtransaction frameworkの再設計は別スコープとされています。#2526のために、それらを前提条件へ引き上げる必要はありません。
今回必要なのは、監視機構を強くすることではなく、既にある失敗処理が利用者に必要な情報を残すことを、正しい分岐で確認する1本のテストです。
squne121 commentedon Sep 6, 2026
推奨アクション
#2526 は実装へ進める前に、anchor comment の
REQUEST_CHANGESをそのまま Issue contract に反映するのが適切です。PR #2520 自体は既にマージ済みで、今回の対象はそこで明示された artifact-projection real-dispatcher test の不足だけなので、既存実装の再設計や runtime supervision の強化へ広げるべきではありません。特に現行 Issue は、AC3 が
result_ref/disposition/unknownの OR 条件であり、さらにrun_refinement_preflight.pyへの production-side test hook 追加を許容しています。レビューコメントは、この2点を明確に否定し、「保存済み inner result は正常なまま、最初のARTIFACT:block の stdout 参照だけを壊す」test-only injection に固定するよう求めています。推奨する contract delta は次です。
run_refinement_preflight.pyの production 変更 fallback を削除する。既存 real contract-update fixture を再利用し、最初のARTIFACT:block 内へREADME.md等の artifact-root 外参照を test harness 側だけで注入する。実ファイルへの unauthorized write は行わない。returncode == 2だけでなく、stdout == ""、reason_code=stale_worktree_runtime_state、recovery=do_not_publish_artifact_projection_outside_issue_artifact_root、注入したstale_pathの一致を AND 条件で確認する。SKILL_RUNTIME_FAILstderr からinner_transaction_result_refとinner_transaction_disposition=patchの両方を取得し、stderr が示した参照先を実際に開く。そこでstatus: failed / disposition: patch / writes: 1 / final_readback: verified / fresh_review: needs_fixを確認する。このシナリオではunknownを合格にしない。uv run --locked pytest ...を実行する。文字列rgだけを AC1 の実証には使わない。issue-refinement-loopは通常のneeds-fixでは人間承認なしで反復できます。既定3 iteration の bounded loop は維持し、human_judgment_required、runtime failure、max-iteration 等の本来の hard stop だけ停止させるのがよいです。なお Claude Code の Auto mode は bypass permissions ではありません。通常の確認負荷は classifier が処理しますが、明示的な
askrule や危険・scope 外と判定された操作は停止し得ます。また Auto mode は subagent にも継承されます。したがって以下のプロンプトでは「通常の refinement 途中でユーザー承認を求めない」と明記しつつ、permission system 自体を迂回させません。 ([GitHub]1)そのまま対話的 Claude Code の Auto mode に投入するなら、以下を推奨します。
Issue #2526 を、以下の human review anchor を authority として
issue-refinement-loopで refinement してください。Issue:
#2526
Human review anchor:
#2526 (comment)
目的は、anchor comment の
REQUEST_CHANGESを Issue contract に反映し、fresh review と final contract gate が通るところまで、人間の途中承認なしで bounded refinement loop を完遂することです。実行方針
issue-refinement-loopの現行 SKILL.md・references・command registry を正本として使用してください。この anchor は direct human review directive として扱い、canonical な
with_human_contextlane を使用してください。unlabeledwith_anchorやwith_agent_reportと混同しないでください。Issue 本文を ad-hoc に直接編集するのではなく、
issue-refinement-loopが定義する preflight → investigation → review → authorized rewrite / contract-update → fresh readback → fresh review → final gate の経路を使用してください。通常の
needs-fix、deterministic repair、rewrite、fresh review の各反復について、私への「進めてよいですか」「修正してよいですか」等の承認要求を行わず、そのまま次の iteration へ進んでください。repository loop policy と Claude Code permission mode は別物です。Auto mode の permission classifier、既存 hooks、deny/ask rules、安全境界を無効化したり、
bypassPermissionsや--dangerously-skip-permissionsへ切り替えたりしないでください。max_iterationsは repository の既定値 3 を基本としてください。通常の review feedback はその範囲で自動修正・再レビューしてください。ただし、canonical policy が明示的に
human_judgment_required、runtime/environment failure、scope-signal hard stop、または max-iterations termination を返した場合には policy を迂回しないでください。その場合だけ、termination state と blockers を記録して停止してください。途中で私へ判断を求めて待機する必要はありません。SubAgent execution rule
SubAgent を実際に使用してください。
少なくとも repository investigation について
codebase-investigator相当の canonical SubAgent を使用し、Issue #2526、anchor comment、PR #2520、必要に応じて #2393 / #2190、skill_runtime_exec.py、run_refinement_preflight.py、およびtest_skill_runtime_exec_anchor.pyの既存 real-dispatcher fixture / tests を照合してください。planner が external research を必要と判断した場合だけ、canonical
web-researcherを追加してください。不要なら無理に起動しないでください。rewrite/edit が canonical routing 上
issue-editorSubAgent または対応 skill を要求する場合は、その正規経路を使用してください。SubAgent からさらに SubAgent を起動する nested delegation は行わせないでください。
重要:
SubAgent を起動しただけで完了扱いにしないでください。
起動したすべての SubAgent の作業完了を待ち、最終結果を回収してから review / rewrite / routing の次段階へ進んでください。
並列起動した場合も全 SubAgent の completion を待ってください。
spawn acknowledgment や「実行中」を completion とみなさないでください。
今回の refinement で解消すべき substantive points
anchor comment の内容を fresh repository evidence と照合したうえで、少なくとも以下を Issue contract に反映してください。fresh evidence に明確な反証がある場合のみ、その理由を記録して canonical reviewer に再判定させてください。
1. Production code modification fallback を削除する
今回の artifact-projection failure injection は production code を変更せず、既存 real contract-update fixture と test harness のみで成立させる方針へ固定してください。
run_refinement_preflight.pyに test-only injection point を追加できる、という現在の fallback は原則削除してください。Allowed Paths は原則として次だけに縮小してください。
scripts/agent-guards/tests/test_skill_runtime_exec_anchor.pyproduction bug を別途発見した場合、それをこの Issue へ無条件に混ぜないでください。再現条件と事実を記録し、canonical workflow が必要と判断した場合のみ別 scope として扱ってください。
2. 注入方法を artifact-projection failure に固定する
inner GitHub mutation と final readback、および inner result JSON の保存が完了した「後」に、stdout 上の artifact projection だけを不正にしてください。
fixture に存在する artifact root 外パス、たとえば
README.mdを参照させて構いません。そのパスへ実際に書き込んではいけません。
unauthorized-write failure を発生させてはいけません。
注入は parser が実際に読む最初の
ARTIFACT:block 内へ行ってください。stdout 末尾などへ2個目の
ARTIFACT:section を追加するだけの方式は採用しないでください。3. 狙った outer failure 分岐を明示的に証明する
新規 real-dispatcher test は、単なる non-zero return code ではなく、少なくとも以下を一体で検証する contract にしてください。
reason_codeが artifact-projection failure の期待値であることrecoveryがdo_not_publish_artifact_projection_outside_issue_artifact_rootであることstale_pathが test で注入したパスと一致すること現在の実装と anchor comment に整合するなら期待値は以下です。
returncode == 2reason_code=stale_worktree_runtime_staterecovery=do_not_publish_artifact_projection_outside_issue_artifact_rootstale_path=README.mdreason code 単独では別 failure と区別できないため、recovery と stale_path も AND 条件にしてください。
4. inner transaction recovery を実証する
このシナリオでは inner transaction は artifact projection failure より前に完了済みです。
したがって
SKILL_RUNTIME_FAILstderr から、inner_transaction_result_refおよび
inner_transaction_disposition=patchの両方を回収することを必須にしてください。
どちらか片方が存在すればよい、という OR 条件にはしないでください。
また test が自前で期待パスを組み立てて結果 JSON を読むだけでは不十分です。
stderr に実際に出力された
inner_transaction_result_refを parse し、その参照先を開き、専用 worktree / 当該 Issue の正しい result artifact であることと、その JSON 内容を確認してください。既存
test_contract_update_phase_reaches_fake_transaction_and_fresh_handofffixture を再利用できるなら、少なくとも以下の inner result を期待してください。contract_update:
status: failed
disposition: patch
writes: 1
final_readback: verified
fresh_review: needs_fix
このケースでは
inner_transaction_state=unknownを成功条件として許可しないでください。mutation と readback と result 保存が成立した後に artifact projection だけを壊したケースで
unknownになるなら、それ自体を regression として検出してください。これは timeout 等、本当に transaction state が確定できない別ケースの
unknownsemantics を変更する要求ではありません。5. blind resend がないことを維持する
fake GitHub executable に対する mutation/write がちょうど1回であることを assert してください。
outer artifact-projection failure の後に mutation を再送して成功扱いにする動作は禁止です。
6. Verification Commands を focused にする
新規 test の完全な pytest node ID を直接実行して、test が存在しない場合や収集されない場合にも failure になるようにしてください。
候補 test 名は anchor comment に合わせて以下で構いません。
test_contract_update_outer_artifact_projection_failure_preserves_inner_transaction_resultverification は最低限、以下の順序へ整理してください。
uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py::test_contract_update_outer_artifact_projection_failure_preserves_inner_transaction_result -qその後、
uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py -qを実行する contract にしてください。
テスト関数名を
rgで発見するだけの確認を、新規 test の成立証明として扱わないでください。依存追加、lockfile 更新、新しい全体 harness や重い safety gate は今回の scope に追加しないでください。
Scope discipline
PR #2520 の既存実装を差し戻したり、
_resolve_inner_transaction_evidence_fields()を再設計したり、dispatcher の timeout / unauthorized-write / artifact-projection 三分岐構造を再設計したりしないでください。この Issue は PR #2520 で明示された artifact-projection real-dispatcher coverage gap の follow-up です。
品質を上げるために必要な Issue contract の具体化は行ってよいですが、unrelated architecture cleanup を混ぜないでください。
既存の scope-overlap advisory は literal path overlap と concern overlap を区別して扱ってください。
Loop completion condition
Issue 本文を更新しただけで完了扱いにしないでください。
更新後に fresh body readback を行い、fresh preflight と fresh review を実行してください。
review が再度
needs-fixを返した場合は、人間承認を求めず、bounded loop 内で修正して再レビューしてください。最終的に repository の canonical termination policy に従い、
CONTRACT_REVIEW_RESULT_V1.status == "go"まで到達した場合のみ
approved/implementation_ready相当として終了してください。stale な review snapshot を再利用しないでください。
refinement 完了後も、このセッションでは Issue #2526 の実装や PR 作成には進まないでください。今回の作業範囲は Issue contract refinement の完了までです。
最終報告
完了時には簡潔に以下を報告してください。
途中承認は不要です。canonical hard stop が発生しない限り、自律的に最後まで進めてください。
この形なら「確認待ちをなくす」ことと、「repository が意図的に残している human-judgment hard stop を破壊しない」ことを分離できます。特に #2526 はレビュー内容が具体的なので、通常は1回の contract rewrite と fresh review で収束しやすいケースです。
squne121 commentedon Sep 6, 2026
Refinement Loop 終了報告
Termination:
approvedHuman review anchor(comment、OWNER、REQUEST_CHANGES)で指摘された6点をすべて Issue contract へ反映し、fresh review と final contract gate が通過しました。
反映した主な変更点
scripts/agent-guards/tests/test_skill_runtime_exec_anchor.pyの1ファイルへ縮小。ARTIFACT:block 内だけを不正にする」方式へ固定(2個目のARTIFACT:section 追加方式は不採用)。returncode == 2/stdout == ""/reason_code == stale_worktree_runtime_state/recovery == do_not_publish_artifact_projection_outside_issue_artifact_root/stale_path == README.mdの AND 条件で証明する AC へ変更。inner_transaction_result_refとinner_transaction_disposition=patchの両方必須(OR禁止)とし、stderr から実際に取得した参照先を開いてcontract_update.status=failed / disposition=patch / writes=1 / final_readback=verified / fresh_review=needs_fixの内容一致まで検証する AC へ強化。unknownはこのシナリオでは regression として扱う。Repository investigation との整合性
codebase-investigatorによる fresh repository investigation の結果、anchor comment の6点はすべて現行実装(skill_runtime_exec.pyの分岐順序・stderr フィールド・_resolve_inner_transaction_evidence_fields()の挙動・ARTIFACT: parser の仕様)と技術的に整合し、production code 変更なしで実現可能であることを確認しました。fresh evidence による1点の技術的調整(anchor の文言からの差分)
anchor comment は Verification Commands に「新規テストの完全な pytest node ID(
<file>::<new_test_name>)を直接実行する」ことを要求していましたが、これは本リポジトリの baseline VC preflight ポリシー(Issue #1285 / PR #1305: 既存ファイルに対する未実装 node-id 参照existing_file_missing_node_id_noncanonicalは non-canonical shape として deterministic に block される)と技術的に両立しません。canonical Step 2 review(deterministic checker)がこの点を実際にneeds-fix(VCP_EXISTING_FILE_MISSINblocker)として検出したため、AC1 を「新規テスト関数名の rg による baseline 存在確認」、AC2–AC5 を「対象モジュール全体の pytest 実行(新規テストを含む)」に置き換えました。この差分の理由は Issue 本文の Verification Commands セクション直下に注記として記録し、fresh canonical review により re-judge されています(結果: 2周目でverdict: approve/ blockers 0件)。Loop 実行詳細
needs-fix— C11 decision-tag consistency 未付与 + VCP_EXISTING_FILE_MISSIN、2周目approve)approve/next_action: proceed(canonical_step2_route: step_2_5→semantic_review_applicable: falseにより Step 2.5 スキップ)run_contract_review_once.py --mode execute→CONTRACT_REVIEW_ONCE_RESULT_V1.status: go(readiness: go, vc_preflight: pass, product_spec: pass, idempotency: 既存 go comment なし, errors: 0件)02ced279...)と review 対象 body_sha256 が一致することを独立に確認済みSubAgent 実行記録
codebase-investigator(repository investigation、completion 回収済み、web-researcher は不要と判断し起動せず)issue-editor(fix_delta iteration 1: whole-body rewrite、completion 回収済み、readback で body_sha256 一致確認)issue-editor(fix_delta iteration 2: Step 2 needs-fix 反映の whole-body rewrite、completion 回収済み、readback で body_sha256 一致確認)いずれも spawn 通知ではなく、完了通知受信後に結果を回収してから次段階へ進みました。nested SubAgent delegation は発生していません。
本セッションでの意図的な範囲制限(policy 迂回ではなく、依頼者指示によるスコープ限定)
本 Issue は
issue_kind: implementationのため、canonicalLOOP_HANDOFF_RESULT_V1終端契約は通常impl-review-loopへの自動 handoff(run_root_transition()経由)を伴います。しかし本セッションは「refinement 完了後もこのセッションでは実装や PR 作成に進まない」という明示指示を受けているため、LOOP_HANDOFF_RESULT_V1marker の投稿とrun_root_transition()の実行は本セッションでは行いません。Issue #2526 は implementation-ready な状態(CONTRACT_REVIEW_RESULT_V1.status: go)です。squne121 commentedon Sep 6, 2026
#2526 はすでに refinement を完了しており、fresh review=
approve、final contract gate=goの implementation-ready 状態です。したがって、refinement をやり直さず、canonical root entry transition からimpl-review-loopに入るのが適切です。前回セッションでは意図的に implementation handoff だけ省略されています。今回、途中承認をなくすうえで重要なのは2点です。
open-prはpublish: yesを明示しないと承認待ちになるため、今回のプロンプト自体で #2526 に限定した push / PR publication を事前承認します。さらにdraft: falseを指定するのを推奨します。Issue の既定は Draft PR ですが、実際の GitHub Draft 状態を人間が解除する工程を残すと「マージ直前まで自動」と噛み合わないためです。マージ・auto-merge は許可しません。また、現在の Issue では canonical Verification Commands から未実装 pytest node ID が意図的に外されています。一方 Runtime Verification の artifact requirement は「node ID 実行 + module 全体実行」です。したがって、Issue 本文の VC は変更せず、実装後の追加 runtime evidence として node ID 単体も実行させるのが正しい整理です。
Claude Code の Auto mode は tool call を安全分類して自動承認しますが、明示的な
ask/denyルールなどをプロンプトで迂回するものではありません。親セッションが Auto mode なら SubAgent も Auto mode を継承します。([Claude]1) したがって「workflow 上の確認待ち」は除去できますが、Claude Code 自体の強制 permission boundary まで無効化する指示にはしていません。そのまま Auto mode の対話的 Claude Code に投入するなら、以下を推奨します。
Issue #2526 を
impl-review-loopで実装し、current-head verification・独立 PR review・必要な修正反復を完了させ、人間が merge を実行する直前の merge-ready 状態まで自律的に進めてください。Issue:
#2526
Repository:
squne121/loop-protocolこのセッションは Claude Code の Auto mode で実行しています。
Objective
Issue #2526 の live contract を正本として、
implementation
→ verification
→ PR publication
→ current-head PR review
→ REQUEST_CHANGES の修正
→ verification / re-review
→ live mergeability 判定
を
impl-review-loopの canonical workflow で反復し、最終的にIMPL_REVIEW_LOOP_RESULT_V1.status: draft_pr_readyかつ
termination_reason: approved相当の状態まで進めてください。
ここでいう
draft_pr_readyは impl-review-loop の workflow terminal status です。実際の GitHub PR は、人間による Draft → Ready 変換を途中工程として残さないでください。
今回の目的は merge 直前まで自律完了させることなので、canonical
open-prがdraft: falseを受理する現在の契約であれば、この run ではdraft: falseを明示して PR を作成してください。ただし、merge 自体は実行しないでください。
auto-merge も enable しないでください。
最終 merge は人間の判断として残してください。
Existing refinement state
Issue #2526 はすでに
issue-refinement-loopを完了しています。既存の refinement completion comment では、fresh review が
approve、final contract gate がgoになり、Issue が implementation-ready であることが確認されています。ただし、過去の comment / snapshot / handoff marker 単独を Step 1 authorization として使用しないでください。
impl-review-loopの現行SKILL.mdとsteps/preparation.mdを正本として、root/main thread が canonical Root-Owned Synchronous Entry Transition をこの run で fresh に実行してください。すなわち、同一の continuous root control flow 内で、
capability preflight
→ live Issue fetch
→ current-run issue-contract-review
→ immediate live re-fetch
→ root entry routing
→ route が
invoke_impl_review_loopの場合のみ Step 1 dispatchまでを実行してください。
過去の
LOOP_HANDOFF_RESULT_V1や refinement completion comment を authorization packet の代用にしないでください。Issue body drift が検出された場合は、root entry transition が定義する fresh review / rerouting をそのまま実行してください。通常の drift repair のために私へ途中承認を求めないでください。
Historical REQUEST_CHANGES の扱い
Issue comment:
#2526 (comment)
は過去の OWNER
REQUEST_CHANGESanchor ですが、その内容はすでに refinement loop によって現在の live Issue contract へ反映され、fresh review / final gate を通過しています。したがって、この historical comment を新しい human veto として ad-hoc に再解釈しないでください。
current-run canonical policy に従って freshness / ordering を判断し、現在有効な unresolved human stop が存在する場合だけ hard stop としてください。
Upfront publication authorization
このプロンプトは Issue #2526 のこの impl-review-loop run に対する、以下の操作の明示的な human authorization です。
したがって、
open-prの semantic publication gateには、この run について明示的にpublish: yesを渡してください。
PR は今回、
draft: falseを明示してください。
この authorization は Issue #2526 の canonical worktree / branch / PR にのみ限定します。
force push、history rewrite、unrelated branch mutation、別 Issue / PR の mutation、merge、auto-merge は authorization に含みません。
Claude Code 自体の Auto-mode classifier、hooks、explicit ask/deny rules、protected-path boundary 等は迂回しないでください。
bypassPermissionsや--dangerously-skip-permissionsへ変更しないでください。Canonical SubAgent execution
impl-review-loopの現行 SKILL.md に従い、root/main thread は control-plane と routing に専念し、canonical SubAgent を実際に使用してください。少なくとも以下の canonical dispatch を使用してください。
Step 1:
implementation-worker→
implement-issueStep 2:
test-runner→ current-head Verification Commands / evidence の独立検証
Step 4:
pr-reviewer→
pr-review-judge必要な update_branch 等も、SKILL.md が
implementation-workerへの delegation を要求している場合はその経路を使用してください。root thread が implementation-worker の代わりに直接ファイルを編集したり、test-runner の代わりに verification verdict を自己判定したり、pr-reviewer の代わりに APPROVE を自己生成したりしないでください。
No nested delegation
root/main → canonical SubAgent の delegation は使用してください。
ただし、Issue #2526 の Stop Conditions にある nested SubAgent delegation は発生させないでください。
SubAgent からさらに SubAgent を spawn する新しい nested delegation を導入しないでください。
既存 canonical skill を実行するために nested SubAgent delegation が本当に必要だと判明した場合は、Issue-specific Stop Condition として扱ってください。
Mandatory SubAgent completion protocol
SubAgent を spawn しただけで完了扱いにしてはいけません。
Step 1 / Step 2 / Step 4、および canonical workflow が同じ protocol を要求するその他の dispatch について、現行
impl-review-loopの Common Completion Protocol を厳密に適用してください。各 SubAgent について必ず、
spawn_agentの返した canonical task name を保存する。wait_agentを使用する。wait_agenttimeout、途中 mailbox update、steer acknowledgement、「実行中」通知を completion とみなさない。list_agentsで、保存した canonical task name が terminalcompletedになっていることを確認する。final resultと terminalcompletedの両方を確認してからだけ次の routing を行う。errored/interrupted/shutdown/not_foundを成功扱いしてはいけません。複数 SubAgent が並列実行された場合、必要な全 SubAgent の final result と terminal completion が揃うまで次段階へ進まないでください。
background execution の開始通知は completion ではありません。
Implementation scope for #2526
live Issue body の Outcome / AC / Allowed Paths / Stop Conditions を正本にしてください。
Allowed Paths は現在、
scripts/agent-guards/tests/test_skill_runtime_exec_anchor.pyのみです。
production code は変更しないでください。
特に以下を変更しないでください。
scripts/agent-guards/skill_runtime_exec.pyscripts/agent-guards/run_refinement_preflight.py_resolve_inner_transaction_evidence_fields()dispatcher の timeout / unauthorized-write / artifact-projection の production structure
Issue body / contract 自体も implementation の都合で変更しないでください。
Required test implementation
既存の
test_contract_update_phase_reaches_fake_transaction_and_fresh_handoffとその fake GitHub executable + isolated Git fixture を可能な限り再利用してください。
追加する test 名は live contract の通り、
test_contract_update_outer_artifact_projection_failure_preserves_inner_transaction_resultとしてください。
この test では inner transaction が先に成立している状態を作ってください。
inner GitHub mutation
→ final readback
→ inner result JSON 保存
を完了させた後でのみ、outer stdout の artifact projection を壊してください。
artifact root 外の fixture path、現在の contract では
README.mdを使用できます。README.md自体へ書き込んではいけません。unauthorized-write failure を起こして artifact-projection failure を偽装しないでください。
parser が実際に読む最初の
ARTIFACT:block 内に invalid projection を注入してください。stdout の末尾へ2個目の
ARTIFACT:section を追加するだけの方式は使用しないでください。Assertions
新規 test は少なくとも次を同一 scenario で検証してください。
outer result:
returncode == 2stdout == ""同一
SKILL_RUNTIME_FAILstderr:reason_code=stale_worktree_runtime_staterecovery=do_not_publish_artifact_projection_outside_issue_artifact_rootstale_path=README.md加えて stderr から、
inner_transaction_result_refと
inner_transaction_disposition=patchを両方 parse してください。
OR 条件にしてはいけません。
inner_transaction_state=unknownをこの scenario の success として扱わないでください。test 自身が期待 result path を別途組み立てて、その path だけを読む実装にはしないでください。
stderr に実際に出力された
inner_transaction_result_refを取得し、その参照先を開いて、正しい dedicated worktree / Issue result artifact であることを確認してください。result JSON では live contract に従い、少なくとも
contract_update.status == "failed"disposition == "patch"writes == 1final_readback == "verified"fresh_review == "needs_fix"を確認してください。
fake GitHub executable に対する mutation/write 呼び出しがちょうど1回であることも確認してください。
outer failure 後の blind resend を許可しないでください。
Verification
live Issue body の Verification Commands を literal authority としてください。
重要:
historical review anchor には新規 pytest node ID を Verification Commands に直接入れる案がありましたが、fresh refinement の結果、これは baseline VC preflight の
existing_file_missing_node_id_noncanonicalに抵触するため採用されていません。
したがって Issue body の canonical Verification Commands を node-ID 形式へ書き戻したり変更したりしないでください。
canonical VC は live body の通り実行してください。
少なくとも、
rg -n "def test_contract_update_outer_artifact_projection_failure_preserves_inner_transaction_result\\(" scripts/agent-guards/tests/test_skill_runtime_exec_anchor.pyおよび
uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py -qを実行してください。
ただし Runtime Verification Applicability の artifact requirement は
pytest output (node ID 実行 + モジュール全体実行)です。
したがって、test 実装後には canonical VC を変更することなく、追加 runtime evidence として、
uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py::test_contract_update_outer_artifact_projection_failure_preserves_inner_transaction_result -qも実行し、結果を PR evidence に残してください。
node-ID execution は「Issue の baseline Verification Commands の変更」ではなく、「実装後に test が存在する状態で取得する runtime evidence」として扱ってください。
SKIP を PASS に変換しないでください。
isolated Git fixture / fake GitHub executable が利用できない場合、Issue contract の通り environment blocked として扱ってください。
依存追加や lockfile update は行わないでください。
Autonomous review/fix loop
通常の以下の状態では、私へ途中承認を求めず canonical loop を続けてください。
REQUEST_CHANGESBEHINDに対する canonical update_branchhuman_review_required: trueboolean self-report で、canonical policy 上の hard stop ではないものREQUEST_CHANGES を受け取ったら blockers を
fix_deltaとして次 iteration のimplementation-workerへ渡し、Allowed Paths 内だけを修正してください。reviewer の APPROVE 単独を終了条件にしないでください。
current head に対して、
まで確認してください。
max_iterationsは現行 repository default の3を使用してください。この Issue は single-file test-only change なので、no-progress budget を無意味に拡張しないでください。
Hard stops
「途中承認不要」は canonical hard stop を破壊する指示ではありません。
以下の場合は repository policy と Issue #2526 の Stop Conditions に従って停止してください。
pr-reviewerの正式なHUMAN_REVIEW_REQUIREDverdictIssue-specific Stop Condition に該当した場合は、Issue contract が要求する通り事実・再現条件・blocker を Issue comment に記録して停止してください。
通常の review feedback や SubAgent の曖昧な自己申告を hard stop に昇格させないでください。
Merge boundary
最終成功条件に到達しても、
gh pr merge相当の merge mutationを実行しないでください。
auto-merge を enable しないでください。
merge commit / squash / rebase merge を実行しないでください。
最終状態は「人間が PR を確認して merge 操作を行えばよい」状態にしてください。
Final report
成功時は簡潔に以下を報告してください。
Issue #2526
PR URL / PR number
branch
current head SHA
変更ファイル
iteration 数
実行した canonical SubAgent
各 SubAgent について final result と terminal
completedの双方を確認したことnew test node-ID runtime evidence
module-wide pytest result
allowed-paths compliance
final pr-review verdict
required CI status
live mergeability
IMPL_REVIEW_LOOP_RESULT_V1termination reason
そして最後に明確に、
MERGE NOT EXECUTED — awaiting human merge decisionと記載してください。
途中承認は不要です。
canonical hard stop が発生しない限り、実装・検証・PR publication・レビュー・修正・再レビューを自律的に最後まで継続してください。
特に効くのは、
publish: yesを最初から authorization として渡すこと、draft: falseで人間の Draft解除工程を消すこと、Common Completion Protocol を明文化することです。現行 repository は SubAgent の spawn 通知やwait_agentの途中応答を completion と認めず、final result と terminalcompletedの双方を要求しています。もう一点、#2526 は production code 無変更・単一テストファイル限定なので、3 iteration を超えて粘るより、そこまでで収束しなければ実装前提が崩れている可能性を疑う方が適切です。現在の Issue Stop Conditions も Allowed Paths 外変更や production-side fix が必要になった場合は明示的な停止を要求しています。
squne121 commentedon Sep 6, 2026
root-owned entry router audit
route: invoke_impl_review_loop
reason: fresh_review_go_live_equality
test: contract_update artifact-projection failure の real-dispatcher テ…