Repository navigation
feat: contract_update.run.with_human_context の mutation phase に investigation evidence transport を配線する - #2684
Conversation
…tigation evidence transport を配線する (#2678) #2086 AC3 の read-only investigation evidence(investigation_derived_path_literals)を mutation phase(contract_update.run.with_human_context)にも配線し、 expands_allowed_paths boundary を解除して得られた contract_update_required decision が 実際の GitHub mutation でも再現されるようにする。 - command_registry.py: contract_update.run.with_human_context に investigation_evidence_transport_path / investigation_evidence_primary_root の optional_flag_pair を追加 - skill_runtime_exec.py: transport flag の許可対象と primary-root 内部生成・伝搬を contract_update.run.with_human_context にも拡張 - skill_runtime_command_policy.py: exact-command parser / expected argv・placeholders を transport + primary-root の組み合わせに対応 - run_refinement_preflight.py: transport 検証失敗時、anchor 本文単独から別の有効な patch plan が導出可能でも mutation consumer を呼び出さない write-zero guard を追加 - テストフィクスチャ(_install_real_contract_update_fixture)に欠落していた impl-review-loop/scripts・pr-review-judge/scripts・changed_file_matcher.py の cross-skill 依存を追加し、post-update fresh-checks gate が正しく評価されるよう修正 (既存テストの誤った "needs_fix" 期待値も併せて是正) Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #2684 closed). |
CI ruff check failed on line 507 (124 > 120 chars). Wrap the f-string concatenation across multiple lines; no change to the tested argv values or assertions. Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
確認した限り、#2684 は現時点で 最優先はレビュー開始ではなく CI blocker の修正です。 推奨は、AC8 を維持しつつ 以下をそのまま、既に auto mode で起動している ClaudeCode に貼る想定です。 対象は既存 PR #2684 と、その linked implementation Issue #2678 です。
現在このセッションは auto mode です。通常の implementation、編集、テスト、commit、push、既存 PR の更新、PR body 更新、CI 再検証、review fix、branch update、次 iteration について人間へ「進めてよいですか」と承認を求めないでください。 ただし merge は実行しないでください。auto-merge も有効化しないでください。Issue #2678 も close しないでください。最終的な merge 判断だけを人間へ残してください。 Live state を正本にする開始時に必ず GitHub と repository を fresh read してください。以下は開始時点の観測値であり、authoritative な固定値ではありません。 PR #2684: 既存 worktree / branch は以下です。
PR を新規作成しないでください。既存 PR #2684 と既存 branch/worktree を canonical rules に従って再利用してください。 live Issue #2678 の Outcome / In Scope / Acceptance Criteria / Allowed Paths / Verification Commands / Runtime Verification Applicability / Stop Conditions を正本として再取得してください。過去 artifact や PR body の自己申告を live contract より優先しないでください。 Issue #2678 の OWNER REQUEST_CHANGES comment 最初に処理すべき既知 blocker現在 head の GitHub Actions run root cause は 失敗しているテストは:
failure はどちらも:
です。 main の この failure から また、現在の PR body にある「 SubAgent orchestrationroot thread 自身で implementation judgment、test judgment、PR review judgmentを代替しないでください。 canonical child SubAgent からさらに SubAgent を起動する nested delegation は行わないでください。 各 SubAgent dispatch では必ず Common Completion Protocol を守ってください。 final result と terminal
起動済み SubAgent が残っている状態で root session の最終回答を返してはいけません。 実行順序
最初の fix_delta は、 Issue #2678 の AC8 は、 推奨修正方針は、Step 0g の canonical command example と必要最小限の normative rule を Issue #2678 の Allowed Paths 外へ変更を広げないでください。一般化や将来用 abstraction を追加しないでください。 worker の final result + terminal completed を確認してから進んでください。
少なくとも今回失敗した line-budget 2 tests を明示的に再実行し、Issue #2678 の AC1〜AC8 Verification Commands、関連 regression、runtime verification requirements も current HEAD で fresh に実行してください。 特に以下の semantic coverage を維持してください。 registry render / exact-command positive-negative、executor-internal primary-root propagation、transport-absent byte-identical behavior、primary-only transport + dedicated worktree real-subprocess positive path、invalid transport + independently valid anchor の write-zero negative path、対象外 boundary flags の非緩和、SKILL.md と anchor-comment-handling.md の mutation-phase 操作手順の semantic consistency。 PR body の過去の test result を current-head verification の代用にしないでください。 test-runner の final result + terminal completed を待った後、canonical adjudication を使って current
PR body の Summary / Changes / Checks / AC evidence / Runtime Verification Evidence / Safety Claim Matrix 等は current evidence に合わせて修正してください。特に line-budget CI failure を修正した事実と fresh test result を反映し、古い「uv_version_mismatch のみ」という誤った current-state 表現は訂正してください。
failure / cancelled があれば canonical failed-log helper で evidence を取得し、原因を分類してください。 PR 起因の failure なら人間へ確認せず environment / pre-existing failure と判断する場合も、推測だけで bypass せず、main comparison や canonical evidence requirements を満たしてください。 candidate HEAD が変化した時点で旧 verification / CI / review evidence は stale としてください。
pr-reviewer には placeholder ではなく、fresh に materialize した PR number reviewer の authoritative output は canonical minimal convention の pr-reviewer の final result と terminal
reviewed head が current head と異なるなら stale-head re-review を行ってください。 live mergeability が actual Git conflict のみ conflict hard-stop として扱ってください。 PR が Draft であること単独を human escalation にしないでください。Draft の扱いは live canonical root が review blocker を勝手に non-blocking と再分類しないでください。 max iteration、genuine 成功終了current Issue #2678 の AC が final candidate head で満たされ、current-head Verification が non-blocking、required CI が canonical policy 上 pass、current-head pr-reviewer verdict が canonical merge はしないでください。 最終報告には termination reason、PR #2684、Issue #2678、final head SHA、iteration count、最終 changed paths、AC1〜AC8 の status、current-head Verification results、required CI result、final reviewer verdict、live mergeability、remaining blockers/warnings、PR draft/ready state、merge / auto-merge / Issue close を実行していないこと、spawn した全 SubAgent が terminal state に到達済みであることを含めてください。 途中の「実装完了」「テスト完了」「CI待ち」「review開始」を最終終了点にせず、起動した SubAgent の完了を必ず待ちながら canonical impl-review-loop の merge直前 handoff まで継続してください。 このプロンプトでは、現在判明している CI blocker を最初から |
…ransport-mutation
…) を解消する PR #2684 の investigation evidence transport 追記で SKILL.md が 513 行になり test_skill_md_is_under_500_lines / test_skill_md_stays_within_line_budget が CI で fail していた。Step 0g の investigation evidence transport 節の重複詳細 説明を references/anchor-comment-handling.md の既存「mutation phase(#2678)」 節へ委譲し、SKILL.md 側は正規化ルールと inline command example のみを残す 最小差分で 500 行以下(498 行)に収めた。AC8 が要求する `investigation-evidence-transport-path` 文字列と Step 0g のコマンド例は維持。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ransport-mutation
…ransport-mutation
…ransport-mutation
|
PR #2684 を、Issue #2678、OWNER 指摘、関連する #2086 / PR #2096 / PR #2520 / PR #2623、変更ファイル、CI 設定まで辿って確認しました。対象 head は 判定は REQUEST_CHANGES 相当です。ただし production wiring に P0 級の欠陥は見つけていません。主実装はかなり筋が良く、修正すべきなのは主にテスト隔離と受け入れ証跡です。新しい security layer や harness を追加する必要はありません。
一方、核心設計は維持してよいです。 したがって、production code の primary-root propagation と |
|
現在の PR #2684 は open / draft / mergeable、取得時の head は 推奨アクションは、P1 2件を必須 blocker として先に処理し、P2 も低コストなので同一ループで解消することです。特に そのまま既に auto mode で起動している ClaudeCode に貼れる形です。 PR #2684 の既存ブランチ/既存PRを対象に、以下のレビューコメントを initial fix_delta として Target PR: Initial review / fix_delta anchor: Skill: 目的は、PR #2684 を 人間の途中承認なしで実装・検証・PRレビューのループに通し、マージ直前の状態まで仕上げることです。 最初に行うこと
initial fix_delta対象コメントの指摘を以下の優先順位で扱う。 P1-1: テストが production checkout を直接 mutate する問題
を作成・削除し、pytest-xdist の並列 worker と競合し得る問題を解消する。 優先方針:
production implementation の primary-root propagation や P1-2: AC7 / requires_issue_split の証跡不足investigation-derived path literals が存在する場合でも次の boundary が緩和されないことを実テストで証明する。
現状不足している 既存 parameterized test に1ケース追加できるなら、それを優先する。 P2-1: AC8 documentation の「同一の呼び出し」表現以下の意味になるよう、 誤: 正しい意味: command ID が異なる2つの P2-2: AC6 write-zero matrix既存 helper / parameterization を利用し、可能な限り低コストで mutation-phase の write-zero rejection matrix をレビュー宣言と一致させる。 少なくとも現在確認済みの:
に加えて、AC / docs が明示的に保証している rejection reason のうち不足しているもの 重要: ただし重複 fixture を大量コピーしない。 P2-3: テスト重複削減今回の本質的な production change に対して test code が過大になっているため、
を既存 fixture/helper に統合できる場合のみ整理する。 ただし「行数を減らすこと」自体を目的に大規模リファクタしない。 impl-review-loop の実行規則main thread は control-plane に徹し、skill が指定する SubAgent を必ず使用する。 少なくとも以下を独立 SubAgent として実行すること。
必要な場合のみ skill の規約に従って他 SubAgent を追加する。 SubAgent の待機は必須SubAgent を起動しただけで main thread の処理を終了してはいけない。 各 SubAgent について:
複数 SubAgent を並列実行できる工程では並列化してよいが、 「SubAgent に依頼しました。結果を待ってください」のような状態でユーザーへ制御を返さないこと。 自律実行ポリシーこのセッションは既に auto mode で起動済み。 通常の実装判断について人間への確認を挟まない。 以下は承認不要で自律実行する。
ただし 例えば:
SubAgent が単に iteration
各 iteration:
reviewed head と current PR head がずれた場合は stale verdict を採用せず current head でレビューし直す。 PR が base behind なら skill の Verificationtarget comment の各指摘を個別に regression test と結び付ける。 最低限:
を実行する。 テスト失敗について、今回の変更による regression と既存環境要因を証拠なしに混同しない。 pytest-xdist race の修正なので、可能なら repository の実 CI と同等または十分近い parallel execution でも再検証する。 Review実装後は必ず target comment の指摘を「修正したつもり」で終了せず、
を current-head evidence と突き合わせてレビューする。 reviewer が REQUEST_CHANGES を返したら、その blocker を次の fix_delta として再度 implementation-worker に渡す。 APPROVE が出ても単独では終了しない。 PR Draft / mergePR #2684 の Draft 解除は、current skill / CI / review routing 上必要な場合は実行してよい。 ただし以下は禁止:
最終 merge は人間に残す。 外部調査今回の target comment では pytest-xdist / pytest tmp_path / subprocess cwd / git worktree / uv locked semantics は既に調査済み。 今回の修正は基本的に repository-internal なので、 実装中に外部仕様の不確実性が実際に発生した場合のみ、skill の指定経路で調査する。 完了条件以下をすべて満たすまでユーザーへ作業終了を返さない。
終了時は、PR #2684 に skill の規約に従った終了報告を投稿し、最後に以下を簡潔に報告する。
途中経過の確認要求は不要です。 このプロンプトでは、対象コメントを単なる「修正指示」として処理するのではなく、current-head の |
…AC8文言)を修正する - test_investigation_evidence_transport_mutation_guard.py / boundary_flags.py: preflight._find_repo_root() を tmp_path 配下の使い捨て git checkout へ monkeypatch し、production checkout への artifact 書き込み+shutil.rmtree() を廃止(P1-1)。write-zero matrix を wrong_repo/wrong_anchor/unsafe_path まで拡張し、既存の重複4テストを1つの parametrize test へ統合(P2-2)。 - boundary_flags.py: requires_issue_split の positive boundary case を 既存 parameterized test に追加(P1-2)。 - SKILL.md / anchor-comment-handling.md: 「同一の呼び出しで」という誤解を 招く表現を、read-only invocation と同一 manifest path を別の command ID の invocation へ再利用する、という正しい意味に修正(P2-1)。 Issue #2678 / PR #2684 review: #2684 (comment) Co-Authored-By: Claude Sonnet 5 <[email protected]>
impl-review-loop: 完了 (2026-09-20T00:00:00Z)
target comment #2684 (comment) の各指摘への対応:
Verification Evidence
Reviewer Verdictverdict: APPROVE
reviewed_head_sha: "a72cc1d17c894e2e3b0bb3bdde449c883254256c"
blockers: []
warnings:
- "PR body Safety Claim Matrix の write-zero guard row が実装の7種tamperカバレッジより古い4種のみを記載していた(stale evidence text) → PR body を修正済み(non-blocking)"IMPL_REVIEW_LOOP_RESULT_V1:
schema_version: 1
status: draft_pr_ready
pr_url: "https://github.com/squne121/loop-protocol/pull/2684"
head_sha: "a72cc1d17c894e2e3b0bb3bdde449c883254256c"
issue_number: 2678
termination_reason: approved
merge_ready: true
iteration: 1
FOLLOW_UP_MATERIALIZATION_RESULT_V1:
schema_version: 1
materialized_by: impl-review-loop
follow_up_issues: []
note_only_observations: []
ISSUE_SCOPE_ROLLUP_DECISION_V2:
schema_version: 2
recorded_at: "2026-09-20T00:00:00Z"
rollup_plan_ref:
body_sha256: null
generated_at: null
decision: skipped
executed_actions: []
skipped_reason: "既存 PR 継続の fix_delta 実行であり、scope rollup preflight は manual advisory diagnostic のため今回は実行しなかった"
candidates_reviewed: [] |
Summary
issue-refinement-loopの#2086 AC3で実装済みだった read-only investigation evidence(investigation_derived_path_literals)を、実際に GitHub mutation を行う mutation phase(contract_update.run.with_human_context)にも配線する。これまではpreflight.run.with_human_context(read-only lane)でexpands_allowed_pathsboundary を解除してcontract_update_requireddecision を得ても、専用worktree実行方式(PR #2520)で実際の mutation を行うcontract_update.run.with_human_context側では同じ transport 引数を受け取れず、trusted operator-selected human-context directive が無限にhuman_escalationへ差し戻される構造的欠陥があった。本 PR はこの欠陥を、command_registry.py/skill_runtime_exec.py/skill_runtime_command_policy.py/run_refinement_preflight.pyの 4 ファイルへの最小差分と、それに対応する real-subprocess を含むテストで解消する。あわせて、OWNER REQUEST_CHANGES(
#2678コメント 5746675533)で指摘された「transport path 単体の許可では専用worktree実行方式との不整合により再停止する」「transport 検証失敗時に他の有効な patch plan 経由で mutation が進んでしまう fail-open の穴が残る」という 2 点を、primary-root 伝搬(executor 内部生成、caller 供給不可)と write-zero guard(_investigation_evidence_transport_rejectedフラグ)でそれぞれ解消した。Changes(変更内容)
command_registry.py:contract_update.run.with_human_contextエントリにinvestigation_evidence_transport_path/investigation_evidence_primary_rootのoptional_flag_pairを追加(preflight.run.with_human_contextと同一形状)。skill_runtime_exec.py: transport flag の許可対象命令 ID リストと primary-root(project_root、executor 内部確認済みの値のみ)の内部生成・伝搬をcontract_update.run.with_human_contextにも拡張。skill_runtime_command_policy.py: exact-command parser(transport/primary-root の 2/4 token suffix 文法)と_EXPECTED_ARGV_BY_COMMAND/_EXPECTED_PLACEHOLDERS_BY_COMMANDを transport + primary-root の組み合わせに対応させた。run_refinement_preflight.py:investigation_evidence_transport_pathが明示指定され、かつ検証に失敗した場合に mutation consumer(consume_trusted_anchor_contract_patch_plan())へ進まないための_investigation_evidence_transport_rejectedフラグを追加。anchor 本文単独から独立に有効な patch plan が導出できるケースを含め write-zero を保証する。SKILL.md/references/anchor-comment-handling.md: mutation phase での transport 引数の実際の操作手順(read-only preflight で得た transport manifest を同一呼び出しで mutation phase へ引き渡す手順)を追記。_install_real_contract_update_fixture()(test_skill_runtime_exec_anchor.py)に欠落していた cross-skill 依存(impl-review-loop/scriptsのevaluate_product_spec_gate/pr-review-judge/scriptsのallowed_paths_review_gate/scripts/agent-guards/changed_file_matcher.py)を追加し、post-update fresh-checks gate(fresh_review/allowed_paths等)が実際に評価されるよう修正した。この修正により、既存の real-subprocess テスト 4 件が「AC/VC 不整合によるneeds_fix」と誤って解釈していた期待値(実際は fixture の import 失敗による誤判定だった)を是正している。SKILL.md(追加 fix_delta): 上記 AC8 追記により.claude/skills/issue-refinement-loop/SKILL.mdが 513 行になり、CI のpython-test-core(test_skill_md_is_under_500_lines/test_skill_md_stays_within_line_budget)が deterministic に fail していた(GitHub Actions run35496111240)。investigation evidence transport 節の重複詳細説明をreferences/anchor-comment-handling.mdの既存「mutation phase(実装: contract_update.run.with_human_context の mutation phase に investigation evidence transport (#2086 AC3) を配線する #2678)」節へ委譲し、SKILL.md 側は正規化ルールと inline command example のみを残す最小差分で 498 行に縮小して解消した(AC8 のinvestigation-evidence-transport-path文字列・Step 0g のコマンド例は維持)。Checks
uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py::test_contract_update_with_human_context_render_accepts_investigation_evidence_transport_path— passuv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py::test_contract_update_investigation_evidence_primary_root_propagated_from_confirmed_project_root— passuv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py::test_contract_update_with_human_context_exact_parser_rejects_malformed_investigation_evidence_argv— passuv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py::test_contract_update_investigation_evidence_transport_absent_byte_identical_regression— passuv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py::test_contract_update_phase_with_primary_only_transport_reaches_dedicated_worktree_consumer_and_applies— passuv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_investigation_evidence_transport_mutation_guard.py::test_invalid_transport_with_independently_valid_anchor_write_zero— passuv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_investigation_evidence_transport_boundary_flags.py::test_destructive_and_permission_boundary_flags_not_relaxed— passrg -n "investigation-evidence-transport-path" .claude/skills/issue-refinement-loop/SKILL.md— match(Step 0g に操作手順を追記済み、fix_delta 後 498 行)uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_thin_entrypoint.py::test_skill_md_is_under_500_lines .claude/skills/issue-refinement-loop/tests/test_step_0f_parent_owned_preflight.py::test_skill_md_stays_within_line_budget— pass(fix_delta 後、current head で再実行して確認。修正前はgot 513で fail していた)uv run --locked pytest scripts/agent-guards/tests/— 1626/1626 実行対象は個別再実行で全 pass。フル一括実行ではuv_version_mismatch(_resolve_trusted_executableの hosted uv バージョン照合)に起因する 8 件が失敗するが、この worktree 変更を一切含まないmainブランチでも同一の 8 件が同一原因で再現する既存環境依存の flake であり、本 PR の変更には起因しない(該当ファイル・関数は本 PR で一切変更していない)。uv run --locked pytest .claude/skills/issue-refinement-loop/tests/— 1895/1898 pass、3 件はtest_command_registry.pyのTestAuthorityTransportPrivilegedExecutorRealSubprocessDispatchで同一のuv_version_mismatch環境 flake(mainでも再現、本 PR の変更対象外)。注意: この 3 件はissue-refinement-loop/tests/配下で確認された唯一の flake ではない。current-head CI run35496111240では、上記とは別原因(本 PR の SKILL.md 追記による deterministic な line-budget 超過、uv_version_mismatchではない)でtest_skill_md_is_under_500_lines/test_skill_md_stays_within_line_budgetの 2 件が fail しており、これは上記 fix_delta で解消済み(現在は current head で pass を再確認済み)。pnpm typecheck— passpnpm lint— passpnpm test— passpnpm build— passuv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py— 24 passedSchema Change Applicability
(理由: 下記の通り、本 PR は JSON schema 自体を変更していない)
refinement_preflight_result_v1.schema.json等の JSON schema 自体は変更していない。command_registry.pyの argv テンプレートへのoptional_flag_pairプレースホルダー追加は、既存のpreflight.run.with_human_contextで確立済みの同一パターンをもう一方の profile へ複製したものであり、新規スキーマ・新規永続 receipt・新規 state store を一切導入しない。Schema Consumer Inventory
N/A(
Schema Change Applicabilityの decision がnot_schema_changeのため対象外)。Safety Claim Matrix
本変更は
.claude/skills/配下の skill-invocation procedure / contract を変更するため safety-sensitive PR として扱い、以下に具体的な安全性主張と検証根拠を記載する。--investigation-evidence-primary-rootは caller が指定できない(executor 内部生成のみ)skill_runtime_exec.pyの argparse に当該フラグの定義自体が存在しない。test_contract_update_investigation_evidence_primary_root_propagated_from_confirmed_project_rootが実 subprocess で primary-root の値が常に PRIMARY checkout の実パスと一致することを検証test_contract_update_investigation_evidence_transport_absent_byte_identical_regressiontest_investigation_evidence_transport_mutation_guard.pyの 7 tamper variant(stale body / stale HEAD / wrong issue / digest mismatch / wrong repo / wrong anchor / unsafe path)すべてでapply_transaction/fresh_checks呼出し回数 0 を検証destructive_or_non_idempotent_operation/changes_permission_boundary/changes_external_service_boundary/requires_issue_splitboundary は緩和されないtest_investigation_evidence_transport_boundary_flags.pyの classifier-level + realrun_preflight()call chain end-to-end テスト=形式・余分な引数をすべて拒否するtest_contract_update_with_human_context_exact_parser_rejects_malformed_investigation_evidence_argvの 9 negative case + positive controlexecution_root)に transport artifact をコピーせず PRIMARY checkout にのみ配置しても mutation が実際に到達・適用されるtest_contract_update_phase_with_primary_only_transport_reaches_dedicated_worktree_consumer_and_applies(fake GitHub 境界での readback 一致、update request exactly 1 回を検証)Notes
immediateへの変更)に従って実装した。test_skill_runtime_exec_anchor.py::test_contract_update_phase_reaches_fake_transaction_and_fresh_handoffを含む既存 4 テストの期待値修正(failed/needs_fix→applied/approve)は、fixture の cross-skill 依存欠落という pre-existing バグの是正であり、本 Issue の投資調査 transport wiring そのものとは独立した副産物である。詳細はコミットメッセージと該当テストのコメントを参照。