Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#2190"
goal_ref: "#2190 AC6/AC11/AC12: artifact confinementを実装し、Child1-4の統合結果に対して#2190の全AC(AC1-AC12)を最終検証して親issueをクローズする"
change_kind: codeParent Issue
Parent Goal Ref
- Goal: 実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190(親)は production preflight profile 群を remote default-ref OID に fail-closed で束縛した detached dedicated linked worktree lifecycle へ移行する。本Issueはartifact confinementの実装と、#2190の全AC(AC1-AC12)最終統合検証・親issueクローズを担う最終フェーズ。
- Desired Destination: 実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 の Allowed Paths のうち
scripts/agent-ops/worktree_bootstrap_exec.py/scripts/agent-ops/worktree_catalog.py/scripts/agent-guards/skill_runtime_exec.pyと cleanup/artifact handoff テストのみを扱う。
Current Validated Scope
- Child 1(実装: control-plane preflight 用 sanitized Git subprocess 実行基盤を新設する #2196)sanitized Git subprocess基盤、Child 2(実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197)remote OIDプロトコル、Child 3(実装: control-plane preflight lifecycle 用 git-common-dir スコープ排他ロックを実装する #2198)lifecycle lock、Child 4(実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199)identity probe・command class分離・4 production profile移行が全て実装済みであることを前提とする
- PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495(マージ済み)により、
scripts/agent-ops/worktree_bootstrap_exec.pyにcontrol_plane_dedicated_execution_session()(生存する親コントローラーがlifecycle lockを保持したままdedicated worktree child processをsuperviseする構造)が実装済みであることを前提とする。これは re-exec モデルではない。 - Issue 実装: 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 migration)は CLOSED(completed)であり、PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520(contract_update mutation profileのdedicated control-plane runtimeへの移行、mutation再送禁止のinner_transaction_result_ref/inner_transaction_disposition/inner_transaction_state=unknownfallback契約の実装)と PR test: contract_update artifact-projection failure の real-dispatcher テストを追加する #2533(contract_update artifact-projection failure の real-dispatcher regression test、scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py内)はいずれも MERGED 済みであることを前提とする。これらは本Issueの既存 non-regression baseline として取り込む。 - 実装開始時点の main HEAD における
scripts/agent-guards/skill_runtime_exec.pyのPRODUCTION_DEDICATED_WORKTREE_COMMAND_IDSには、4 production preflight profile(preflight.run/preflight.run.with_anchor/preflight.run.with_human_context/preflight.run.with_agent_report)に加えてcontract_update.run.with_anchor/contract_update.run.with_human_contextの計6 profileが含まれ、_dispatch_child_and_check_postconditions()はこの6 profile共有の経路であることを前提とする - 固定 SHA を Issue 本文に埋め込まない。実装着手時/PR作成時点の
baseline_commit(git rev-parse HEAD)は PR description または contract snapshot に記録し、本Issue本文では陳腐化を避けるため具体的な SHA 値を主張しない scripts/agent-guards/skill_runtime_exec.pyの_dispatch_child_and_check_postconditions()が、child実行 → 書き込み差分確認 → stdout内artifact path確認(_validate_stdout_artifact_projection())→ stdout/stderr出力 → 終了コード返却、の順序で本番 preflight profile 群(および PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520/test: contract_update artifact-projection failure の real-dispatcher テストを追加する #2533 により contract_update 2 profile)にすでに配線されていることを前提とする(本Issueはこの既存配線を拡張する。新規配線の追加ではない)scripts/agent-ops/worktree_bootstrap_exec.py/scripts/agent-ops/worktree_catalog.py/scripts/agent-guards/skill_runtime_exec.pyに、dedicated artifact cleanupのbounded処理、dirty/unknown-owner worktreeへのforce remove禁止、cleanup_failed/artifact_escape/artifact_oversized/stale_artifactreason code固定を実装する- artifact handoff(
refinement_preflight_result/v1結果ファイルの再読込にあたっての re-serialize/re-encode 禁止、component-wise no-follow・regular-file限定・owner Issue一致・size/count上限検証)を実装する - lock保持をartifact検証完了まで延長する
- 既存legacy regression test(
tests/agent_ops/test_worktree_bootstrap_exec.py等5本)に回帰がないことを確認し、実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 の全AC(AC1-AC12)のfinal verificationを行い親issueをクローズする。実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 AC9 の記述は、PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495 で採用された parent-controller 構造(re-exec ではない)を正規 architecture として解釈する(## Required Design References参照)
Remaining Parent Gaps
- (解消済み)
contract_update.run.with_anchor/contract_update.run.with_human_contextの dedicated worktree 化は、Issue 実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 で対応完了し PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520(dedicated runtime migration + inner-transaction-result-preservation契約)・PR test: contract_update artifact-projection failure の real-dispatcher テストを追加する #2533(real-dispatcher regression test)としてマージ済みである。本Issueはこの完了済み作業を「既存 non-regression baseline」として扱い、AC6/AC7 で回帰がないことを実証する(## Current Validated Scopeおよび下記 AC6/AC7 参照)
Outcome
PR #2495 の既存 parent-controller(control_plane_dedicated_execution_session())と既存 producer/consumer path contract(stdout compact projection、refinement_preflight_result/v1)、および PR #2520/#2533 の contract_update inner-transaction-result-preservation契約を維持したまま、本番 preflight 経路(scripts/agent-guards/skill_runtime_exec.py の _dispatch_child_and_check_postconditions())に artifact confinement 検証・bounded cleanup・結果公開順序の保証を実装/明文化する。
本Issueが実装する artifact lifetime semantics は generation invalidation 契約として定義する: accepted OID refresh や dedicated worktree recreation は artifact の generation boundary であり、旧 generation の artifact は consumer が未読であっても消えてよい(永続保全は要求しない)。ただし旧 generation の handoff から GitHub mutation を続行してはならない。stale / missing / provenance-invalid な artifact を検出した consumer(repair_action.apply 等)は mutation retry ではなく fresh preflight へ既存 transport を維持したまま deterministic に戻る。stale artifact を暗黙 reuse しない、primary checkout や同名 path へ fallback しない。永続的な artifact lifecycle manager(新しい lease DB、heartbeat、常駐 cleanup daemon 等)は追加しない。
Git の dirty/unknown-owner worktree 判定(git status --porcelain --untracked-files=all を使用し、--ignored は使わない)と、上記の artifact generation/lifetime 判定は別の判定軸であり、混同しない。前者は worktree の force-remove可否判定、後者は結果JSON等のartifactの新旧・利用可否判定である。
必須の artifact 検証・cleanup 判定が完了する前に、利用可能に見える STATUS/NEXT_ACTION/ARTIFACT を公開しない。ただし child の non-zero exit code を一律 failure と扱わず、既存 preflight protocol の warn/needs_fix 等の正当な control result と、confinement/cleanup/postcondition failure を分離する。
本Issueの PR で #2190 の残る critical regressions と本Issueの local AC を green にする。#2190 の全AC(AC1-AC12)最終検証結果の記録と親issueクローズは、本Issue PRのmerge後の delivery step として扱う(詳細は ## Acceptance Criteria AC7 および ## Delivery Rule を参照)。
Runtime Verification Applicability
decision: immediate
reason: "isolated tmp git repo fixtureに対しartifact confinementのdirty/unknown-owner worktree拒否・size/count上限・reason code固定・publish/cleanup順序・generation invalidation挙動を実証し、既存legacy regression test(PR #2520/#2533のinner-transaction-result-preservation契約を含む)の回帰有無を確認する。production primary checkoutを操作しない。"
applicable_acs:
- AC1
- AC2
- AC3
- AC4
- AC5
- AC6
- AC7
execution_environment:
cli_tools:
- python3
- uv
- git
auth_required: false
network_required: false
skip_conditions:
- "isolated tmp git repo fixture が構築できない場合は SKIP ではなく environment blocked として扱う"
fallback_policy:
fallback_success_is_pass: false
notes: "fallback経由の成功をPASSに変換しない"
artifact_requirements:
- "pytest output"
- "artifact confinement validation trace(no-follow / regular-file判定 / size・count上限判定の記録)"
- "publish順序を示すsequence log(検証完了 → 公開 → cleanup の順序が確認できるもの)"Local AC ↔ Parent (#2190) AC Crosswalk
machine consumer が本Issueのローカル AC 番号(applicable_acs に列挙)と親 #2190 の AC 番号を混同しないよう、対応表を分離する。
| 本Issue(#2200)ローカル AC | 対応する #2190 の AC |
|---|---|
| AC1 | AC6, AC11 |
| AC2 | AC6, AC11 |
| AC3 | AC6, AC11 |
| AC4 | AC6, AC11 |
| AC5 | AC7, AC11 |
| AC6 | AC7, AC11 |
| AC7 | 親issueで定義された全ての Acceptance Criteria(本IssueのPRではlocal AC1-6 + 既存回帰の green化を実証し、#2190 最終検証結果の記録とクローズは ## Delivery Rule の delivery step で扱う) |
In Scope
- dedicated artifact cleanupのbounded処理実装
- dirty/unknown-owner worktreeへの
git worktree remove --force禁止と、そのような場合の停止ロジック(git status --porcelain --untracked-files=allを使用し、--ignoredは使わない。このGit cleanliness判定はAC3のartifact generation invalidation判定とは別軸であり混同しない) cleanup_failed/artifact_escape/artifact_oversized/stale_artifactreason codeの固定- artifact handoff(
refinement_preflight_result/v1結果ファイルの re-serialize/re-encode なしの再利用、component-wise no-follow・regular-file限定・owner Issue一致・size/count上限検証) - artifact lifetime を以下の3カテゴリに分けて実装する(generation invalidation 契約。永続保全は要求しない):
- 未公開 temporary files / failed-run leftovers — 検証した範囲だけ bounded cleanup 対象とする
- 公開済みの result/artifact — accepted OID refresh / dedicated worktree recreation という generation boundary を跨いだ時点で、downstream consumer(
repair_action.apply等)が未読であっても cleanup / worktree refresh により消えてよい(永続保全は要求しない)。ただし旧 generation の handoff から GitHub mutation を続行してはならない - 次回 run・accepted OID drift・worktree refresh で stale になった artifact — missing path や旧 artifact の暗黙 reuse として処理せず、provenance/freshness(mtime単独に依存しない)が成立しない場合は既存 transport を維持したまま fresh preflight へ deterministic に戻す(この fresh-preflight への実際の routing 実装は本Issueの Out of Scope。
## Out of Scope参照)
- publish/cleanup/release ordering の明文化・実装:
scripts/agent-guards/skill_runtime_exec.pyの_dispatch_child_and_check_postconditions()が既に維持している「検証 → 公開」の順序(artifact projection 検証失敗時は stdout 未公開のまま終了)を、cleanup 処理追加後も壊さないことを実装・テストで保証する。child の non-zero exit code(warn/needs_fix等)は正当な control result として扱い、confinement/cleanup失敗と分離する - confinement の検証対象フィールドと bounds を固定する(下記 AC4 参照): target Issue root・issue_number/repo所有一致・consumerが実際に読む既知の参照先(
repair_action.candidate_body_artifact等)、各 path component の no-follow、開いた同一 FD での regular-file 判定と読み取り、1ファイル/合計の読み取り量上限・entry数上限、mtime単独に依存しない新規性判定、status/実行経路により生成されない artifact の正当な省略 - lifecycle lockのartifact検証完了までの保持延長。失敗時も既存
finallyrelease semantics を維持する。2プロセス同期は固定 sleep ではなく barrier を使う - 新しい cleanup/lifetime semantics(generation invalidation を含む)の対象 command-id は、
PRODUCTION_DEDICATED_WORKTREE_COMMAND_IDSのうち4 production preflight profile(preflight.run/preflight.run.with_anchor/preflight.run.with_human_context/preflight.run.with_agent_report)のみに限定する。contract_update 2 profile(contract_update.run.with_anchor/contract_update.run.with_human_context)はこの新しい semantics の対象外とし、PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520/test: contract_update artifact-projection failure の real-dispatcher テストを追加する #2533 で実装済みの inner-transaction-result-preservation契約(GitHub mutation 再送禁止・inner_transaction_state=unknownfallback)の regression がないことのみを求める - 既存legacy regression test(
tests/agent_ops/test_worktree_bootstrap_exec.py、tests/codex/test_worktree_bootstrap_command_policy.py、scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py、scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py(PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520/test: contract_update artifact-projection failure の real-dispatcher テストを追加する #2533 由来の contract_update inner-transaction regression testを含む)、scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py)の回帰確認 - テスト設計は (1) artifact confinement/provenance/bounds の focused unit tests、(2) accepted-OID refresh + lifecycle lock の barrier-based integration test、(3) 実際の
preflight → needs_fix → repair_action.applyの production-chain E2E 1本、の3層に絞る(巨大な profile×failure combination matrixは新設しない) - 本Issueの PR で 実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 の残る critical regressions と本Issueの local AC(AC1-6) を green にする(AC7の範囲は本節および
## Delivery Rule参照)
Out of Scope
- sanitized Git subprocess実行基盤・remote OIDプロトコル・lifecycle lock・identity probeの本体実装(Child 1-4 で実装済み)
WORKTREE_CATALOG_ENTRY_V1スキーマ変更contract_update.run.with_anchor/contract_update.run.with_human_contextの dedicated worktree 化(Issue 実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 で完了済み。PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520/test: contract_update artifact-projection failure の real-dispatcher テストを追加する #2533 参照。本Issueはこの2 profileの新しい cleanup/lifetime semantics化を行わず、既存 inner-transaction-result-preservation契約の non-regression のみを扱う)- generic worktree強制hookやglobal permission planeの追加
- 新しい lease DB、heartbeat、常駐 cleanup daemon、generic artifact broker、新しい receipt/state-store framework の追加(AC3の generation invalidation 契約は consumer acknowledgement機構を必要としない単純化された設計であり、永続的なartifact lifecycle manager を新設しない)
- 新しい openat2 wrapper、security module、hardlink registry、generic broker、generic authorization/token framework の追加
worktree_catalog.pyへのartifact内容検証責務の追加(identity/catalog責務のみ維持する)- stdout回収方式(
communicate())の全面改修。stdout capture のメモリ上限保証は、本Issueが扱う artifact サイズ上限保証とは区別し scope外とする - child stdout の subprocess capture を binary mode(
binary_output=True)へ切り替える変更。artifact handoff の byte-for-byte 要求は「preflight が書き込んだ結果JSONファイルを repair consumer が re-serialize/re-encode せずそのまま再読込する」ことを指し、child stdout の text-mode capture(改行の\n正規化を含む)はこの要求の対象ではない。既存の compact stdout projection contract(STATUS/NEXT_ACTION/ARTIFACT等の text projection)を別の JSON transport に再設計しない - stale artifact を検出した consumer(
repair_action.apply等)から実際に freshpreflight.runを再起動する routing 実装。本Issueが実装するのは confinement/cleanup/generation境界の判定(stale artifactの検出とnot_attempted+secure_open_rejectedの返却)までであり、consumer側のfresh-preflight復帰ロジック自体は.claude/skills/issue-refinement-loop/SKILL.mdおよび.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py側の別スコープとして扱う(別Issueで扱う。本Issueでは新規起票しない)
Acceptance Criteria
- AC1: 実 executor(
scripts/agent-guards/skill_runtime_exec.pyの_dispatch_child_and_check_postconditions())から dedicated child、artifact validator(_validate_stdout_artifact_projection()拡張)までの経路が本番 dispatch から実際に呼ばれ、helper 単体の成功だけで AC 達成としないことを実証する - AC2:
preflight → needs_fix → cleanup → repair_action.applyの通常 handoff で、結果JSONと候補本文を修復 consumer が手動移動なしに読み、処理が進むことを実証する(既存の dedicated artifact → repair consumer handoff テストを維持・強化する) - AC3: 同一Issue再実行、別Issue実行、accepted OID更新による worktree 再作成(
recover_or_create_fixed_control_plane_worktree())の各ケースで、generation invalidation 契約(旧 generation の artifact は consumer未読でも消えてよく永続保全は要求しない。ただし旧 generationのhandoffからGitHub mutationを継続しない)が成立することを実証する。旧 artifact を誤って採用しない(暗黙reuse・primary checkoutや同名pathへのfallback禁止)ことを実証する。stale / missing / provenance-invalid と判定した artifact を検出した consumer(repair_action.apply等)が mutation retry ではなくnot_attempted+secure_open_rejectedを返し既存 transport を維持したまま fresh-preflight-eligible な状態に戻ることを実証する(実際の fresh preflight 再起動routing自体は Out of Scope。本ACは検出・返却までを対象とする) - AC4: confinement の検証対象として、target Issue root・issue_number/repo所有一致、各 path component の no-follow、開いた同一 FD での regular-file 判定と読み取り、1ファイル/合計の読み取り量上限・entry数上限、mtime単独に依存しない新規性判定、正当な省略(status/実行経路により生成されない artifact を無条件欠落エラーにしない)を実装し、symlink・non-regular-file・Issue不一致・oversized・stale result の各異常系を focused unit/integration test で確認することを実証する。JSON内の任意文字列や
must_readを生成 artifact と誤分類しないことも確認する。freshness判定は issue_number/repo + schema + preflight_run_identity + content digest 等、既存 schema に定義済みの provenance フィールドを優先し、新しい timestamp プロトコルや artifact registry は追加しない - AC5: 必須の artifact 検証・cleanup 判定が完了する前に利用可能に見える
STATUS/NEXT_ACTION/ARTIFACTを公開しないことを実証する。child の non-zero exit code(warn/needs_fix等の正当な control result)を一律 failure と扱わず、confinement/cleanup/postcondition failure と分離することを実証する - AC6: 検証・cleanup中は既存 lifecycle lock を保持し、失敗後は既存
finallyrelease semantics により解放されることを実証する。2プロセスの同期には固定 sleep ではなく barrier を使うことを実証する。本Issueの cleanup/publish ordering 変更後も、PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520/test: contract_update artifact-projection failure の real-dispatcher テストを追加する #2533 で実装済みの contract_update inner-transaction-result-preservation契約(GitHub mutation 再送禁止・inner_transaction_state=unknownfallback)に回帰がないことを実証する - AC7: 新規dedicated-lane test群(本Issue、および Child 1-4 で追加された全新規テストファイル)と既存legacy regression testの両方がPASSし、normal regular issue-worktree bootstrapの既存positive/negative matrixに回帰がないことを実証する。既存legacy regression testには
scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py(PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520/test: contract_update artifact-projection failure の real-dispatcher テストを追加する #2533 由来の contract_update inner-transaction regression testを含む)を含める。本ACの runtime-verification 範囲は本Issue PRでの code acceptance(local ACとcritical regressionのgreen化)に限定し、親issue 実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 のクローズ自体は## Delivery Ruleに定義する merge後の delivery step として扱う
Delivery Rule
- 本Issue(実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200)の PR は、critical regressions(AC1-AC6 および既存 legacy regression test群)と本Issue local AC(AC1-6) を green にすることをもって merge 可能とする
- 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 merge 後、delivery step として、実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 の残る AC evidence(既存 Child1-4 PR evidence + 本Issue PRで取得した fresh critical regression 結果)を記録し、実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 をクローズする
- 実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 の final verification は、既存 PR evidence と fresh critical regression の記録で足りるものとし、実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 の historical child test(Child1-4 の全テスト)を毎iteration全件再演することは必須としない
Verification Commands
# AC1
$ uv run --locked pytest scripts/agent-guards/tests/test_control_plane_artifact_handoff.py -q# AC2
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py -q# AC3
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_cleanup.py -q# AC4
$ uv run --locked pytest scripts/agent-guards/tests/test_control_plane_artifact_handoff.py -q# AC5
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_cleanup.py scripts/agent-guards/tests/test_control_plane_artifact_handoff.py -q# AC6
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_cleanup.py scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py -q# AC7
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py tests/agent_ops/test_control_plane_worktree_remote_binding.py tests/agent_ops/test_control_plane_worktree_concurrency.py tests/agent_ops/test_control_plane_worktree_cleanup.py scripts/agent-guards/tests/test_skill_runtime_control_plane_policy.py scripts/agent-guards/tests/test_skill_runtime_control_plane_exec.py scripts/agent-guards/tests/test_control_plane_artifact_handoff.py tests/agent_ops/test_worktree_bootstrap_exec.py tests/codex/test_worktree_bootstrap_command_policy.py scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py -q$ pnpm typecheck$ pnpm lint$ pnpm test$ pnpm build$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py -qAllowed Paths
scripts/agent-ops/worktree_bootstrap_exec.py
scripts/agent-ops/worktree_catalog.py
scripts/agent-guards/skill_runtime_exec.py
tests/agent_ops/test_control_plane_worktree_cleanup.py
scripts/agent-guards/tests/test_control_plane_artifact_handoff.py
tests/agent_ops/test_control_plane_worktree_bootstrap.py
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
Required Skills
なし
Required Design References
- docs/dev/agent-skill-boundaries.md
- docs/dev/workflow.md
- https://git-scm.com/docs/git-worktree.html(`--detach --lock --reason`、porcelain identity fields)
- PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495(マージ済み):
control_plane_dedicated_execution_session()による parent-controller 構造の正規採用 - Issue 実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 OWNER comment: 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 に対し「既存の producer/consumer transport を再設計せず、confinement・bounded cleanup・release ordering を追加する」方針を明示
- Issue 実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393(CLOSED、completed):
contract_update.run.with_anchor/contract_update.run.with_human_contextの dedicated runtime migration を実装完了。PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520(dedicated runtime移行・inner-transaction-result-preservation契約)・PR test: contract_update artifact-projection failure の real-dispatcher テストを追加する #2533(real-dispatcher artifact-projection failure regression test)としてマージ済み
Scope Collision Record
- (historical context)Scope Collision (C3): related_issue=実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393; 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 と 実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 は
scripts/agent-guards/skill_runtime_exec.pyとtests/agent_ops/test_control_plane_worktree_bootstrap.pyを Allowed Paths として共に edit 対象に持っていた。実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 は完了・PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520/#2533としてマージ済みのため、このcollisionは解消済みである。本Issueは 実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 が実装した contract_update 2 profile の変更を行わず、既存 non-regression baseline として扱う。
Scope Delta(任意)
scope_delta_status: approved_by_trusted_anchor
source: "https://github.com/squne121/loop-protocol/issues/2200#issuecomment-5556182485"
allowed_path_deltas:
add:
- scripts/agent-guards/skill_runtime_exec.py
- tests/agent_ops/test_control_plane_worktree_bootstrap.py
reason: "production wiring(_dispatch_child_and_check_postconditions())と既存repair-consumer handoffテストが本Issueの実装対象そのものであり、これらのAllowed Paths欠落は#2495と同型のwiring失敗を誘発するため(OWNER anchor comment P1-1)"
Activity
feat: sanitized Git subprocess execution utility for control-plane pr…
feat(#2197): control-plane remote default-ref observe/fetch/pin/verif…
squne121 commentedon Sep 6, 2026
結論
Issue #2200 は、現状の仕様のまま実装に進めるのではなく、
REQUEST_CHANGESとして再 refinement するのが妥当です。ただし、専用 worktree 化そのものをやり直す必要はありません。問題の中心はセキュリティ機構の不足ではなく、**「成果物を検証した後、次の処理が本当に使えるか」「cleanup と結果公開の順序が正しいか」「実装を接続するファイルがスコープに入っているか」**です。
確認対象のコードは main の
b127017d9482fd3c0990b826a7b12b004d3e04ebです。前提となる PR #2495 はマージ済みで、現在は生存する親コントローラーがロックを保持し、専用 worktree 内の子プロセスを監督する構造になっています。この構造は維持すべきです。#2199 の OWNER コメントも、#2200 について「既存の producer/consumer transport を再設計せず、confinement・bounded cleanup・release ordering を追加し、修復 consumer の可読性を維持する」と明示しています。以下は、その方針を現行コードに照合したレビューです。
P1-1:Allowed Paths が、実際に変更すべき executor を含んでいない
#2200 の Allowed Paths は、
worktree_bootstrap_exec.py、worktree_catalog.py、新しい cleanup/handoff テストの4ファイルです。しかし現行の本番経路で成果物の検証と stdout 公開を実行しているのは、scripts/agent-guards/skill_runtime_exec.pyの_dispatch_child_and_check_postconditions()です。現在の処理順は、概略次のとおりです。
一方、bootstrap 側の
control_plane_dedicated_execution_session()は、ロックと worktree の実行コンテキストを管理しますが、対象 Issue 番号や child の stdout を直接受け取る構造ではありません。したがって、bootstrap に helper だけ追加しても、対象 Issue と実際の出力に結び付いた検証を本番経路へ接続できません。これは過去の #2495 で起きた失敗に近いです。当初は専用実行用の定数や primitive が存在し、Verification Commands も通っていましたが、実際の
main()に配線されていないことがレビューで検出されています。その問題は現在は修正済みですが、#2200 のスコープ設定は同じ失敗を誘発します。修正案: 最初に有限の Scope Delta を入れ、少なくとも次を追加してください。
後者には既に dedicated artifact を実際の修復 consumer に渡すテストがあります。新しい巨大 fixture を作るより、その経路へ cleanup を挟んで保証を強化する方が有用です。
worktree_catalog.pyは、artifact の内容検証を押し込む場所にせず、identity/catalog の責務に留めることを勧めます。P1-2:cleanup の対象だけでなく、公開した成果物の「寿命」が未定義
今回、最も優先して直すべき点です。
既存の修復経路は、preflight の結果 JSON と、その中で参照される候補本文を後から読みます。#2199 では dedicated worktree 内の artifact を
repair_action.applyが読めるように修正され、関連テストも追加されています。つまり、preflight の終了は artifact の利用終了ではありません。ところが #2200 は、bounded cleanup、stale artifact の拒否、検証済み root への限定は要求する一方で、何をいつまで残し、何を削除してよいかを十分に固定していません。終了時に対象 root を消せば安全、という実装では通常の自動修復が壊れます。
次回の worktree 再作成も、成果物を消す経路になる
現行の
recover_or_create_fixed_control_plane_worktree()は、accepted OID が変わった場合、clean と判定した既存 worktree を削除して再作成します。clean 判定はgit status --porcelain --untracked-files=allですが、リポジトリの.gitignoreにはartifacts/が含まれています。ここで重要なのは、Git の clean 判定は、ignored な成果物が存在しないことを意味しない点です。Git 本体の
check_clean_worktree()と削除処理も確認しました。通常の status で clean と判定した後、worktree のディレクトリを削除するため、ignored なファイルは保存されません。(raw.githubusercontent.com)ローカルの独立した最小 fixture、Git 2.47.3 でも、以下を確認しました。
したがって、通常の並行作業でも次の経路が成立し得ます。
preflight 実行中のロックを正しく保持するだけでは、この寿命の問題は解決しません。 現在のロック範囲と worktree 更新処理から導ける、後続 consumer との接続上のリスクです。
修正案: cleanup 契約を、少なくとも次の3種類に分けてください。
対象 | 推奨する扱い -- | -- 未公開の一時ファイル・失敗 run の残骸 | 検証した範囲だけ bounded cleanup する 今回公開した結果 JSON と、その処理に必要な参照ファイル | 通常の後続 consumer が読む前に削除しない 次回 run・OID 更新で失効する成果物 | 保全するか、明示的に stale と判定して自動で fresh preflight に戻す。暗黙の欠落や旧結果の再利用にしないテストは、既存の production-chain E2E を1〜2本強化し、異常系の組合せは小さな unit/integration test に寄せることを推奨します。#2495 では、配線変更に伴う fixture 不足から Scope Delta が何度も発生していました。今回も全 profile × 全異常系の巨大な synthetic repository 群を増やすと、目的物よりハーネスの保守が重くなります。
今回、増やさなくてよいもの
新しい broker、authorization token、lease DB、heartbeat、常駐 cleanup daemon、receipt framework は不要です。 対象 Issue の明示的な artifact root を扱うだけなら、既存ロック、既存 reader のパターン、小さな上限付き処理で進めるのが適切です。
また、#2199 で修正された external venv、human-context evidence の primary-root 明示受け渡し、dedicated artifact を読む修復 consumer は戻さないでください。現在のコードに存在する、通常のワークフローを成立させるための修正です。primary checkout watchdog のコスト最適化まで #2200 の必須条件に広げることも勧めません。
推奨順序は、親・子の契約整合 → 成果物の寿命と失効条件の確定 → 有限の Allowed Paths 拡張 → 既存 E2E を使った実装です。
評価の中心は「安全そうな検査が増えたか」ではなく、**「初回も再実行も、成果物を手で移動・復旧せず、自動修復まで到達できるか」**に置くべきです。
なお、今回実施したのは GitHub 上の Issue・関連コメント・PR 情報・固定 SHA のコード確認と、Git/Python の独立した最小再現です。プロジェクト全体の pytest や CI の再実行はしていません。 GitHub への書き込みも行っていません。
## 結論Issue #2200 は、現状の仕様のまま実装に進めるのではなく、
REQUEST_CHANGESとして再 refinement するのが妥当です。ただし、専用 worktree 化そのものをやり直す必要はありません。問題の中心はセキュリティ機構の不足ではなく、**「成果物を検証した後、次の処理が本当に使えるか」「cleanup と結果公開の順序が正しいか」「実装を接続するファイルがスコープに入っているか」**です。
確認対象のコードは main の
b127017d9482fd3c0990b826a7b12b004d3e04ebです。前提となる PR #2495 はマージ済みで、現在は生存する親コントローラーがロックを保持し、専用 worktree 内の子プロセスを監督する構造になっています。この構造は維持すべきです。#2199 の OWNER コメントも、#2200 について「既存の producer/consumer transport を再設計せず、confinement・bounded cleanup・release ordering を追加し、修復 consumer の可読性を維持する」と明示しています。以下は、その方針を現行コードに照合したレビューです。
P1-1:Allowed Paths が、実際に変更すべき executor を含んでいない
#2200 の Allowed Paths は、
worktree_bootstrap_exec.py、worktree_catalog.py、新しい cleanup/handoff テストの4ファイルです。しかし現行の本番経路で成果物の検証と stdout 公開を実行しているのは、scripts/agent-guards/skill_runtime_exec.pyの_dispatch_child_and_check_postconditions()です。現在の処理順は、概略次のとおりです。
一方、bootstrap 側の
control_plane_dedicated_execution_session()は、ロックと worktree の実行コンテキストを管理しますが、対象 Issue 番号や child の stdout を直接受け取る構造ではありません。したがって、bootstrap に helper だけ追加しても、対象 Issue と実際の出力に結び付いた検証を本番経路へ接続できません。これは過去の #2495 で起きた失敗に近いです。当初は専用実行用の定数や primitive が存在し、Verification Commands も通っていましたが、実際の
main()に配線されていないことがレビューで検出されています。その問題は現在は修正済みですが、#2200 のスコープ設定は同じ失敗を誘発します。修正案: 最初に有限の Scope Delta を入れ、少なくとも次を追加してください。
後者には既に dedicated artifact を実際の修復 consumer に渡すテストがあります。新しい巨大 fixture を作るより、その経路へ cleanup を挟んで保証を強化する方が有用です。
worktree_catalog.pyは、artifact の内容検証を押し込む場所にせず、identity/catalog の責務に留めることを勧めます。P1-2:cleanup の対象だけでなく、公開した成果物の「寿命」が未定義
今回、最も優先して直すべき点です。
既存の修復経路は、preflight の結果 JSON と、その中で参照される候補本文を後から読みます。#2199 では dedicated worktree 内の artifact を
repair_action.applyが読めるように修正され、関連テストも追加されています。つまり、preflight の終了は artifact の利用終了ではありません。ところが #2200 は、bounded cleanup、stale artifact の拒否、検証済み root への限定は要求する一方で、何をいつまで残し、何を削除してよいかを十分に固定していません。終了時に対象 root を消せば安全、という実装では通常の自動修復が壊れます。
次回の worktree 再作成も、成果物を消す経路になる
現行の
recover_or_create_fixed_control_plane_worktree()は、accepted OID が変わった場合、clean と判定した既存 worktree を削除して再作成します。clean 判定はgit status --porcelain --untracked-files=allですが、リポジトリの.gitignoreにはartifacts/が含まれています。ここで重要なのは、Git の clean 判定は、ignored な成果物が存在しないことを意味しない点です。Git 本体の
check_clean_worktree()と削除処理も確認しました。通常の status で clean と判定した後、worktree のディレクトリを削除するため、ignored なファイルは保存されません。([raw.githubusercontent.com]1)ローカルの独立した最小 fixture、Git 2.47.3 でも、以下を確認しました。
したがって、通常の並行作業でも次の経路が成立し得ます。
preflight 実行中のロックを正しく保持するだけでは、この寿命の問題は解決しません。 現在のロック範囲と worktree 更新処理から導ける、後続 consumer との接続上のリスクです。
修正案: cleanup 契約を、少なくとも次の3種類に分けてください。
OID 更新をまたぐ保存方法まで、このレビューで未検証の方式に決め打ちするのは避けます。ただし、「未消費の成果物をどう扱うか未定のまま、cleanup と refresh を実装する」のは不可です。
新しい lease DB や常駐 GC は不要です。まず通常の handoff を維持し、再実行・refresh 時の有効期限と自動復旧を明文化する方が、ユーザーのワークフローに合っています。
P1-3:cleanup 失敗より先に、利用可能に見える stdout を公開してしまう
現行 executor は、artifact projection の検証後、session を抜ける前に stdout を書き出します。その後に親 checkout の invariant 確認も行います。ここへ単純に「context manager の
finallyで cleanup」を追加すると、次の順序になります。これは、後続エージェントから見ると 「結果を使ってよいのか、処理全体が失敗したのか」 が分かりにくい出力です。問題は新しい status enum が必要なことではなく、採用可能な結果を公開するタイミングが早いことです。
修正案: child の出力を一旦保持し、既存ロックの中で必要な検証と cleanup の判定を済ませてから公開するようにしてください。
ここで exit 0 以外を一律に「公開禁止」にしてはいけません。preflight の既存契約には
warn / exit 1、needs_fix / exit 4などがあり、特にneeds_fixは自動修復へ進む正常な制御結果です。整合性検証の失敗と、preflight 自体が返した正当な診断結果を分ける必要があります。また、失敗時にロックを保持し続ける設計にもせず、必要な失敗処理を試みた後は
finallyで解放する現在の基本構造を維持するべきです。P2:
byte-for-byte要求と、現在の text-mode capture も整合していない#2200 は stdout の byte-for-byte 再利用を求めていますが、現行の production preflight は
binary_output=Falseで、supervisor はtext=not binary_outputを使用します。binary capture は既に存在しますが、現在それを選ぶのは structural repair の経路です。Python の text mode は stdout の改行を
\nに変換します。独立した最小再現でも、child が出したb"STATUS: pass\r\n"は"STATUS: pass\n"になりました。通常の producer が LF のみを出していれば表面化しませんが、一般的な byte-for-byte 保証にはなりません。([Python documentation]2)厳密な bytes 保持が必要なら、既存の
binary_outputを対象 profile に適用し、検証用の解析結果と公開する元 bytes を分ければ足ります。stdout を JSON に作り直す変更は不要です。なお、実際の stdout は JSON 文書ではなく、STATUS、NEXT_ACTION、ARTIFACTなどの compact projection です。P1-4:confinement の検証対象と、bounded の単位が曖昧
現行の
_validate_stdout_artifact_projection()は、stdout から抽出したパスをrealpath()で解決し、許可 root 内かを確認する処理です。この関数自体は、component-wise no-follow、regular file、Issue 所有、内容のサイズ、今回 run の新規性を検証していません。#2200 が追加実装する必要のある部分ですが、現行 helper を呼んだだけで AC 達成と扱える書き方は避けるべきです。特に、トップレベルの結果 JSON の所在だけ確認して終わりにすると、
repair_action.candidate_body_artifactのような、実際に次の処理が読む参照先が保証から抜けます。既存の結果・修復契約には、こうした参照と provenance 情報があります。一方で、JSON 内のすべての文字列や
must_readを一律に「生成 artifact」として扱う検証も勧めません。既存 schema のmust_readは一般的な読み取り対象を表すため、検証対象を広げすぎると正当な参照まで拒否する原因になります。修正案: Issue に、検証する既知の artifact field と、必要条件を小さな表で固定してください。
issue_number/repo、consumer が実際に読む既知の参照先実装は新規のセキュリティ基盤ではなく、既存パターンの再利用がよいです。リポジトリには既に
secure_read_repair_apply_artifact()と、それを共有する修復経路があり、FIFO を拒否するテストもあります。Python 標準ライブラリにもdir_fd相対の open/stat/unlink などの仕組みがあります。似た reader を何個も新設するより、既存の実装・テストを利用する方が保守しやすいです。([Python documentation]3)なお、上限の検証は「全部読んでからサイズを判定」では不十分です。同様に stdout まで bounded と主張するなら、現在の
communicate()は全出力をメモリに蓄えるため、回収後のサイズチェックだけではメモリ上限の保証になりません。ただし stdout の回収方式全面改修まで今回に入れるかは別判断であり、まず artifact の上限保証と区別して記述すべきです。([Python documentation]2)P1-5:「#2190 の全AC最終検証」が、古い親契約に引きずられる
取得した #2190 の AC9 には、bootstrap 完了後に dedicated worktree 内の executor へ re-exec する要求が残っています。一方、採用済みの実装は、生存する親コントローラーがロックを保持して dedicated child を監督する構造です。
そのため、#2200 の成果物処理だけを完成させても、旧 AC をそのまま機械的に検証すると、次のどちらかになります。
正しい現行実装を旧仕様へ巻き戻すか、満たしていない旧 AC を PASS と記録するか。
どちらも避けるべきです。#2200 の実装前に、親 #2190 の AC と既に採用した実装を整合させ、「親コントローラーを維持する」ことを正規の契約にする必要があります。ロックも、既に child と既存 post-checks まで保持されているため、「新しいロック方式を導入する」「initializer から FD を渡して re-exec する」といった再設計は不要です。
また、#2200 に残る contract-update follow-up の新規作成指示は、既存の #2393 を参照する形へ更新してください。#2393 は2つの mutation profile の dedicated runtime 移行を所有し、#2200 の confinement と親全体の最終検証は明示的に対象外としています。重複 Issue を作る必要はありません。
ただし、#2393 の完了まで #2200 を無条件に待たせる提案ではありません。 担当範囲は分けたまま、共有 executor の変更を並行して衝突させず、最終的な profile 境界に対して回帰確認する扱いで十分です。#2393 自体も共有 runtime path の並行編集を避ける契約です。
P2:Runtime Verification の AC 番号が、この Issue の AC と一致していない
#2200 のローカル AC は AC1〜AC5 ですが、
Runtime Verification Applicabilityはapplicable_acs: [AC6, AC11, AC12]です。親 AC を指しているように見えますが、その区別が記述上ありません。これは小さい修正で済む一方、機械処理上は無視できません。ローカル AC の適用範囲と、親 AC への対応表を分離してください。親の番号をローカル AC 欄へ流用しない方が明確です。
私なら、#2200 をこの完了条件に書き換える
Outcome は、次の方向に絞ります。
追加・改訂する AC は、この程度のまとまりで十分です。
preflight → needs_fix → cleanup → repair_action.applyで、結果 JSON と候補本文を読み、処理が進むwarn/needs_fixなどは維持するテストは、既存の production-chain E2E を1〜2本強化し、異常系の組合せは小さな unit/integration test に寄せることを推奨します。#2495 では、配線変更に伴う fixture 不足から Scope Delta が何度も発生していました。今回も全 profile × 全異常系の巨大な synthetic repository 群を増やすと、目的物よりハーネスの保守が重くなります。
今回、増やさなくてよいもの
新しい broker、authorization token、lease DB、heartbeat、常駐 cleanup daemon、receipt framework は不要です。 対象 Issue の明示的な artifact root を扱うだけなら、既存ロック、既存 reader のパターン、小さな上限付き処理で進めるのが適切です。
また、#2199 で修正された external venv、human-context evidence の primary-root 明示受け渡し、dedicated artifact を読む修復 consumer は戻さないでください。現在のコードに存在する、通常のワークフローを成立させるための修正です。primary checkout watchdog のコスト最適化まで #2200 の必須条件に広げることも勧めません。
推奨順序は、親・子の契約整合 → 成果物の寿命と失効条件の確定 → 有限の Allowed Paths 拡張 → 既存 E2E を使った実装です。
評価の中心は「安全そうな検査が増えたか」ではなく、**「初回も再実行も、成果物を手で移動・復旧せず、自動修復まで到達できるか」**に置くべきです。
なお、今回実施したのは GitHub 上の Issue・関連コメント・PR 情報・固定 SHA のコード確認と、Git/Python の独立した最小再現です。プロジェクト全体の pytest や CI の再実行はしていません。 GitHub への書き込みも行っていません。
squne121 commentedon Sep 6, 2026
推奨は、#2200 をそのまま実装フェーズへ送らず、対象コメントを trusted human context とした
issue-refinement-loopを自律実行し、semantic reframe まで完了させることです。現在の #2200 は Allowed Paths が4ファイルに限定されている一方、レビューでは production executor のskill_runtime_exec.pyと既存 production-chain test が実変更点として不足していると指摘されています。さらに artifact の「検証」だけでなく、後続repair_action.applyが読むまでの寿命、cleanup→公開順序、stale 時の fresh-preflight 復帰まで契約化する必要があります。加えて、親 #2190 に残る re-exec 契約が PR #2495 後の parent-controller 実装と食い違うなら、#2200 だけで無理に吸収せず、#2190 の契約を先に semantic refinement して現行実装へ合わせるべきです。一方
contract_update.*の dedicated runtime 移行については既に #2393 が所有しているため、新規 follow-up を重複起票せず、#2200 から #2393 を参照して shared-path collision/順序だけ扱うのが適切です。issue-refinement-loop自体は iteration ごとの人間承認をデフォルトで要求しません。また semantic design review はissue-design-reviewersibling SubAgent の完了を待つ join barrierを明示的に持ち、blocker/high finding は semantic rewrite に送れます。したがって、今回の「承認なしで semantic に直す」は既存設計に沿っています。Claude Code の Auto mode はリポジトリの loop approval と別物です。Auto mode は permission prompt をなくしつつ classifier を残すモードなので、今回はこちらを使うのが適切です。チャットの指示で Auto mode に切り替えるのではなく、interactive CLI 側で選択する必要があります。([Claude]1)
推奨する実行方針は次の5点です。
#issuecomment-5556182485を入力にする。ループ間承認は要求しない。rewrite_lane: semantic→issue-editorまで自動継続する。semantic rewrite は AC/VC/Allowed Paths/Stop Conditions の変更を正式に扱える契約になっています。skill_runtime_exec.pyとtest_control_plane_worktree_bootstrap.pyの有限 Scope Delta、artifact lifetime、公開/cleanup ordering、known artifact fields の confinement、byte-for-byte 要求と binary/text capture の整合、local AC と parent AC crosswalk の分離を反映する。新しい lease DB、broker、daemon、巨大 synthetic harness は作らない。approve/proceedになるまで bounded loopする。途中のneeds_fixは承認を求めず修復する。停止対象は、証拠から一意に決められない本物のhuman_judgment_required、権限/環境不能、または no-progress のみとする。Claude Code には以下をそのまま渡すのがよいです。
あなたは
squne121/loop-protocolの maintainer として、Issue #2200 をissue-refinement-loopで refinement してください。対象:
実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 (comment)
最終目的
Issue #2200 を、実装開始可能な
approve / proceed相当の状態まで自律的に refinement する。これはレビューだけを返すタスクではない。
必要な Issue 本文修正、semantic rewrite、deterministic repair、fresh review の再実行まで実際に行うこと。
人間による iteration ごとの承認は要求しない。
私は、この anchor comment に記載された evidence-backed な REQUEST_CHANGES を、矛盾がない限り Issue 契約へ反映することを明示的に承認する。
ただしコード実装や PR 作成には進まない。
今回のゴールは Issue contract の refinement 完了まで。
Claude Code / loop execution policy
現在の interactive session の Auto mode をそのまま使用する。
issue-refinement-loopの canonical procedure、planner、controlled Issue mutation path を使用し、rawgh issue edit等で canonical workflow を迂回しないこと。loop iteration approval gate は不要。
needs_fix、request_changes、deterministic repair、semantic rewrite の各反復では、人間への「続けますか?」確認を挟まず自動継続する。max_iterations は 5 とする。
同一 mutation の no-progress retry は行わない。
以下だけを terminal escalation とする:
human_judgment_required単なる Allowed Paths の有限拡張、AC/VC の semantic rewrite、既存 Issue への参照変更、stale contract の現行実装への整合は human approval 理由にしない。
SubAgent orchestration — 必須
main thread だけで調査を完結させないこと。
最初の mutation より前に、少なくとも以下の sibling SubAgent workstream を起動する。
SubAgent A — runtime / artifact lifecycle investigator
以下を current main で調査する:
scripts/agent-guards/skill_runtime_exec.pyscripts/agent-ops/worktree_bootstrap_exec.pyscripts/agent-ops/worktree_catalog.pytests/agent_ops/test_control_plane_worktree_bootstrap.pyrepair_action.apply等の consumer chainartifacts/と dedicated worktree refresh/remove の関係目的は「helper が存在するか」ではなく、production
main()経路へ実際に配線されているかを確認すること。SubAgent B — cross-Issue contract investigator
以下を current state で突き合わせる:
特に確認する:
re-exec契約が残っているかcontrol_plane_dedicated_execution_session()であることcontract_update.run.with_anchor/contract_update.run.with_human_contextの dedicated migration が既に 実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 所有か必要なら web-researcher を sibling として追加してよい。ただし repository evidence だけで決着する論点に不要な web research を増やさないこと。
Join barrier
すべての上記 SubAgent の作業完了を待つこと。
SubAgent がまだ running の状態で:
へ進んではならない。
各 SubAgent は nested SubAgent を起動しないこと。
必要な追加 delegation は必ず main thread から sibling として行う。
SubAgent の findings を main thread で統合してから canonical
issue-refinement-loopの decision に投入する。Anchor comment の主要 finding を必ず検証する
anchor comment を盲目的にコピーするのではなく current main に対して freshness を確認すること。
ただし freshness が確認できた finding は semantic rewrite の入力として扱う。
最低限、以下を disposition すること。
1. Allowed Paths / production wiring
#2200 の現在の Allowed Paths だけで production path を実装可能か確認する。
anchor finding が current main でも成立する場合、有限 Scope Delta として少なくとも:
scripts/agent-guards/skill_runtime_exec.pytests/agent_ops/test_control_plane_worktree_bootstrap.pyを #2200 の Allowed Paths / In Scope / Verification に整合的に追加する。
必要な focused test path が他にも存在する場合は evidence を示して有限追加してよい。
「後で必要になるかもしれない」という理由で広い wildcard scope にしない。
worktree_catalog.pyに artifact content validation の責務を押し込まない。identity/catalog responsibility は維持する。
2. Artifact lifetime
#2200 に artifact の「場所の安全性」だけでなく「寿命」を明記する。
少なくとも次の3カテゴリを区別する:
未公開 temporary files / failed-run leftovers
outward result として公開済みで、通常の downstream consumer がまだ必要とする result/artifact
次回 run / accepted OID drift / worktree refresh によって stale になった artifact
保存方式として新しい lease DB、heartbeat、daemon、broker、receipt framework を追加しない。
既存 producer/consumer transport と existing provenance を最大限再利用する。
実装方式を Issue refinement 段階で証拠なしに過剰固定する必要はないが、
「未消費 artifact を refresh が削除してよいか未定」の状態は残さない。
3. Publish / cleanup / release ordering
現在の production ordering を確認し、usable-looking な
STATUSNEXT_ACTIONARTIFACTを外部公開した後で confinement/cleanup/postcondition failure が発生する契約にしない。
必要な validation と、公開前に完了すべき cleanup/postconditions を明示すること。
一方で child process の non-zero exit code を一律 failure と扱わない。
既存 preflight protocol の
warn/needs_fix等は正常な control result になり得るため、を分離すること。
failure path でも lock を永久保持せず、必要な failure handling 後は existing
finallyrelease semantics を維持する。4. byte-for-byte contract
#2200 の
refinement_preflight_result/v1byte-for-byte 要求と、current executor の text/binary capture を照合する。text-mode capture のまま一般的な byte-for-byte preservation を AC として主張しない。
strict byte preservation が本当に必要なら、既存
binary_outputcapability の bounded reuse を第一候補とする。検証用 parsed representation と outward に再公開する original bytes を分離できるか調査する。
stdout contract を別 JSON transport に再設計しない。
strict byte identity が product requirement ではなく、単に既存 semantic contract を変えないことが本旨なら、AC の表現を実際に保証できる semantics に修正する。
どちらを選んだかを Issue に明示し、AC と Verification Command を一致させる。
5. Confinement の validation surface
既存
_validate_stdout_artifact_projection()を呼ぶだけで AC を満たしたことにしない。既存 schema と downstream consumer を調べ、
「今回の run が生成し、後続処理が実際に読む known artifact fields」を列挙・分類する。
少なくとも必要に応じて:
を扱う。
一方
must_readや JSON 内の任意文字列まで生成 artifact と誤分類しない。既存
secure_read_repair_apply_artifact()等の reader/validator が利用可能なら再利用し、類似 security framework を複製しない。
「全内容を読み込んだ後に size over を判定」するだけで bounded read と主張しない。
stdout buffering 全面再設計まで本 Issue に含める必要がないなら、
artifact bound と stdout-memory bound を意図的に区別して Scope/Out of Scope に書く。
6. #2190 contract alignment
#2190 の current body を fresh に確認する。
もし、PR #2495 で既に parent-controller 型へ移行済みなのに、
#2190 の AC/VC に bootstrap 後
re-execを要求する stale contract が残っているなら、#2200 の final verification より先に整合させる必要がある。
この user instruction は、以下の semantic decision を owner-authorized とする:
canonical workflow が cross-Issue mutation を許可するなら、
#2190 に対して別の bounded
issue-refinement-loopを起動し、semantic contract repair を完了すること。その場合も approval checkpoint は要求しない。
cross-Issue direct mutation が canonical workflow 上許可されない場合は、
#2200 に stale parent contract を無視して PASS する文言を書かず、
canonical dependency/follow-up materialization route を使用すること。
7. #2393
contract_update.run.with_anchor/contract_update.run.with_human_contextの dedicated runtime migration について新規 follow-up Issue を重複作成しない。
#2393 が現在もその責務を所有していることを確認したうえで、
#2200 の Remaining Parent Gaps / Out of Scope / references を #2393 参照へ更新する。
ただし #2393 完了を無条件の hard dependency にする必要があるとは仮定しない。
skill_runtime_exec.py等の shared paths を両 Issue が同時に変更する場合の collision を明示し、repository の scope-rollup / collision policy に従って sequencing を決める。
「並列編集しない」が十分なら、そのためだけに新規 broker/branch coordination mechanism を作らない。
8. Runtime Verification AC numbering
#2200 ローカル AC が AC1〜AC5 なのに
Runtime Verification Applicability.applicable_acsが親 #2190 の AC 番号を直接指している状態が残っていないか確認する。
ローカル AC applicability と parent AC crosswalk を分離する。
例:
applicable_acs: 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 local AC identifiers#2200 ACx -> #2190 ACymachine consumer が local/parent numbering を混同しない形にする。
Deterministic repair / semantic repair policy
issue-refinement-loopの canonical preflight が:NEXT_ACTION: apply_deterministic_repairNEXT_ACTION: apply_deterministic_structural_repairを返し、repair disposition が safe/eligible なら、人間確認なしで canonical repair consumer を実行する。
repair 後は必ず fresh preflight を行い、old artifact / old verdict を再利用しない。
deterministic repair だけでは anchor finding を解消できない場合、そこで停止しない。
今回の anchor は:
を含むため、semantic review applicability を明示的に評価すること。
semantic design review が applicable なら、
canonical
issue-design-reviewersibling SubAgent を起動し、その完了を待つ completion join barrier を守ること。
blocker/high semantic finding が open の場合は
rewrite_lane: semantic/SEMANTIC_REWRITE_CONSTRAINTS_V1を再構築せずそのまま
issue-editorへ渡す。issue-editorの semantic rewrite では、finding の単語を機械置換するのではなく evidence と production topology に基づき:
を一貫して更新する。
既存 Machine-Readable Contract の required keys や unrelated design decisions を不用意に変更しない。
Review loop
各 mutation 後:
needs-fixなら次 iteration の rewriteapprove / proceedなら終了を行う。
SubAgent / review result は body SHA 等の freshness binding を守り、古い review artifact を次 iteration に流用しない。
VERDICT: approveを deterministic checker が返しただけで終了せず、今回の architecture/semantic finding に semantic review が applicable なら Step 2.5 を必ず完了する。
Quality priorities
個人趣味開発であることを踏まえ、品質・有用性・workflow completion を優先する。
追加しないもの:
既存 primitive、existing production-chain E2E、focused unit/integration tests を再利用する。
テスト設計は、
「安全そうな helper が単体で存在する」
ではなく、
「production chain が初回・needs_fix・repair・再実行で手動 artifact 移動なしに完走する」
ことを中心にする。
Completion criteria
以下をすべて満たしてから終了する:
最後に、コード実装へ進まず、簡潔に以下だけ報告する:
この形なら、単に「コメントを Issue に反映する」のではなく、既存の deterministic repair と semantic review/editor を使って 実装可能になるまで自動で収束させる指示になります。
squne121 commentedon Sep 6, 2026
結論
現状の Issue #2200 は
REQUEST_CHANGESが妥当です。 前回レビューで問題だった「実 executor が Allowed Paths にない」「artifact lifetime が未定義」はかなり改善されています。実 production path、cleanup/publish ordering、既存 repair consumer E2E まで AC に入った点は良いです。ただし、現在は別の問題が残っています。特に AC3 の artifact lifetime 契約が、現在の architecture では過剰に強く、しかも stale → fresh-preflight の責任主体が Allowed Paths に存在しません。加えて #2393/PR #2520/PR #2533 が既に完了しているため、Issue 本文の実装前提そのものが stale です。
重要度 | Finding | 判定 -- | -- | -- P1-1 | #2393 を OPEN/in-flight とする baseline が stale。現在は #2393 closed、PR #2520 merged で contract-update 2 profile も dedicated runtime に入っている | 実装前修正必須 P1-2 | AC3 の「未消費 artifact を refresh が消さない」と「refresh 後は stale → fresh preflight」を同時要求しているが、現在は「未消費」を判定する acknowledgement/lease がない | 契約を単純化すべき P1-3 | stale artifact を実際に読む repair_action.apply は、missing/unsafe input を secure_open_rejected で停止するだけで fresh preflight への routing を所有していない | routing owner が欠落 P1-4 | _dispatch_child_and_check_postconditions() は現在6 profile共有。#2200 の generic confinement変更が contract-update の「mutation済み inner result 保全」を壊し得る | explicit regression contract 必須 P2-1 | ignored artifact 問題を git status --ignored で worktree dirty 化して解決すると refresh を常時妨害しかねない | targeted invalidation にする P2-2 | mtime/size ベース freshness を canonical 判定へ昇格すると既存 provenance より弱い | existing run identity/digest を使う P2-3 | AC7 の親Issue closeを pytest 的ACとして扱うとハーネスが肥大化する | post-merge delivery conditionへ移す P2-4 | filesystem hardening は既に consumer がかなり持っている | openat2 等を追加しないP1-1: Issue の baseline が既に現行 main と食い違っている
#2200 は現在も「#2393 は OPEN」「#2393 と shared path collision 中」「PR #2495 時点の
b127017dを main HEAD」と記述しています。しかし #2393 は completed/closed で、PR #2520 も merge 済みです。 現行コードでは
PRODUCTION_DEDICATED_WORKTREE_COMMAND_IDSに、4つの preflight に加えてcontract_update.run.with_anchor/.with_human_contextが入っています。さらに PR #2533 まで merge され、contract-update について artifact-projection failure 後も inner mutation result を保全し、blind resend しない real-dispatcher regression が追加されています。 確認時点の main は
9e4a0065b478038d0d1eb6228fe07eaf4fb33627です。これは単なる説明文の古さではありません。#2200 が編集する
skill_runtime_exec.pyの共通 dispatcher が、今は GitHub mutation lane まで supervision しているためです。したがって Current Validated Scope はもう一度 fresh 化し、#2393 collision 記述を削除し、PR #2520/#2533 を既存 non-regression baseline として取り込むべきです。長寿命 Issue に「main HEAD = 固定SHA」を書き続けるより、実装開始時/PR作成時に
baseline_commitを記録する方が陳腐化しません。P1-2: AC3 は「artifact を保存する」のではなく「generation を失効させる」に寄せるべき
現在の AC3 は、accepted OID 更新などで worktree を再作成した際に、**「未消費の公開済み成果物を暗黙に削除しない」**ことと、stale なら fresh preflight へ戻すことの両方を要求しています。
ここで「未消費」をどう判定するかが定義されていません。preflight と
repair_action.applyは別 dispatch なので、artifact consumer acknowledgement を保持しない限り、bootstrap は「まだ読む予定なのか」「もう不要なのか」を知れません。これを厳密に実装すると、まさに今回避けたい lease/refcount/receipt-store のような仕組みが必要になります。前回レビューで示されていた選択肢は「保全 または stale として fresh preflight に戻す」でした。 現在の AC3 は refinement 過程で実質的に両方を要求する形になっています。
このプロジェクトなら、artifact の永続保全を捨てて generation invalidation を正規契約にするのが適切です。accepted OID refresh は artifact generation の境界とし、旧 worktree 内 artifact は消えてよい。ただし旧 handoff から mutation してはいけず、fresh preflight を生成し直す。この方が圧倒的に単純です。
P1-3: その stale → fresh-preflight route が、現在の Allowed Paths にはない
これは AC3 の実装可能性に直結します。
現在の
run_repair_action_apply()は preflight result と candidate body を component-wise no-follow で secure-read していますが、artifact が missing/unsafe ならphase="candidate_load", failure_code="secure_open_rejected"のnot_attemptedに落とします。そこで fresh preflight を起動する処理はありません。secure_open_rejected自体は既存 schema の正式な failure code です。一方、#2200 の Allowed Paths には
run_refinement_preflight.pyも.claude/skills/issue-refinement-loop/SKILL.mdもありません。ここは low-level bootstrap に workflow routing を押し込むべきではありません。最小構成なら、既存の
not_attempted + secure_open_rejectedを mutation retry せず freshpreflight.runへ戻す routing を issue-refinement-loop 側に追加するのがよいです。新しい schema/version/reason code を consumer に増やす必要もありません。persistent artifact lifecycle manager も不要です。この方針なら「盲目的な mutation retry 禁止」とも矛盾しません。再実行するのは mutation ではなく read-only producer/preflight です。
P1-4: #2200 は contract-update を変更対象外ではなく「明示的 non-regression 対象」にする必要がある
PR #2520 は、outer timeout / unauthorized-write / artifact-projection failure が起きても、inner GitHub transaction がすでに成立していた場合は
inner_transaction_result_ref/inner_transaction_dispositionを回収し、状態不明ならinner_transaction_state=unknownとして mutation を再送しない契約を実装しました。 PR #2533 は artifact-projection branch も real dispatcher で直接検証しています。#2200 はまさに
_validate_stdout_artifact_projection()と publish ordering を変更します。したがって「4 preflight の artifact confinement」という認識だけで実装すると危険です。ここは scope を広げて contract-update cleanup を再設計する必要はありません。新しい cleanup/lifetime semantics の対象 command-id は4 production preflight のみと固定しつつ、6-profile共有 dispatcherについて PR #2520/#2533 の inner-result-preservation test を regression として必須にするのが最小です。
Git の worktree cleanup は「ignored 全件を dirty 扱い」にしてはいけない
現行 recovery は dedicated worktree の cleanliness を
git status --porcelain --untracked-files=allで確認しています。 Git の公式仕様では ignored files は--ignoredを指定しない限り status に現れません。(Git) 一方git worktree removeは clean worktree を削除可能で、locked worktree の remove は force 指定を要求します。(Git)したがって前回レビューで再現された「ignored artifact があっても cleanliness probe は空、worktree refresh で artifact が消える」は構造上妥当です。
ただし解決策を
git status --ignored=matchingに変えるのは勧めません。artifact が普通に存在するだけで worktree を恒久的に dirty 扱いし、accepted OID refresh が止まるからです。Git cleanliness と artifact lifetime を分離してください。 Git source の dirty/unknown-owner 判定は現状維持し、refresh 前には schemaで既知の artifact refs だけを bounded に確認する。旧 generation は stale として捨ててよく、その後の consumer が fresh preflight に復帰する。この設計なら ignored tree 全走査も不要です。
freshness は mtime ではなく、既にある provenance を使える
現行 schema には既に
repair_action.preflight_run_identityがあり、consumer 側には candidate digest 検証も存在します。PR #2520 の
(mtime_ns, size)は「今回の dispatch 中に inner result が生成されたらしいか」を outer failure diagnostic で保守的に判断するための仕組みです。これを #2200 の canonical freshness authority に流用しない方がよいです。#2200 の AC4 にある「mtime 単独に依存しない」は正しいので、既存の
issue_number/repo + schema + preflight_run_identity + content digestを優先し、新しい artifact registry や timestamp protocol は増やさない方が整合します。filesystem hardening はこれ以上増やさなくてよい
現行 repair consumer は既に ancestor を
O_DIRECTORY | O_NOFOLLOWで1段ずつ dir-fd 相対 open し、leaf もO_NOFOLLOWで開き、同じ FD からfstat、size check、byte read、UTF-8 decode、SHA-256、post-read inode check まで行っています。Linux の
O_NOFOLLOWは本来 final component にしか効かず、全 path component をまとめて禁止できるopenat2(RESOLVE_NO_SYMLINKS)もあります。(man7.org) ただしopenat2は Linux 固有で glibc wrapper もなく、man page 自身も一般用途での過剰な symlink 禁止は互換性問題を生み得ると警告しています。(man7.org) Python はos.open(..., dir_fd=...)を正式にサポートしています。(Python documentation)したがって #2200 で openat2 wrapper、新 security module、hardlink registry 等を追加する価値はありません。現行の stdlib/dir-fd パターンを pre-publish validator に必要な範囲だけ適用すれば十分です。
テスト設計も少し削った方がよい
PR #2495 は production wiring を実際に行った結果、fixture の Scope Delta が3ラウンドまで広がった前例があります。 #2200 で同じことを繰り返さないため、証明の中心は「artifact confinement unit」「OID refresh + barrier の lifecycle integration」「real preflight → needs_fix → repair_action.apply の1本の production-chain E2E」で十分です。既存 bootstrap E2E は既に real repair consumer まで届いているので、そこを強化する方が新巨大fixtureより有用です。
また AC7 の「#2190 をクローズすることを pytest 等で実証」は、code acceptance と GitHub delivery postcondition が混ざっています。 親 #2190 は既に
surviving_parent_controller/re_exec: forbiddenに semantic contract が更新済みです。 そのため全 Child の歴史的テストを毎 iteration 再演するより、#2200 merge 後に既存 PR evidence + fresh critical regression を #2190 に記録して close、を Delivery Rule にする方が実用的です。推奨する再-refinement
実装前に #2200 をもう1回だけ semantic rewrite する価値があります。中心はセキュリティ強化ではなく、「artifact を保存する」という要求を捨て、「worktree refresh は generation invalidation。旧 handoff は mutation せず fresh preflight へ戻る」と固定することです。
その上で、#2393/PR #2520/#2533 を current baseline に反映し、stale recovery の owner として issue-refinement-loop routing の最小 Scope Delta を許可し、contract-update は既存 inner-result-preservation の regression のみに留める。この形なら、broker・lease DB・cleanup daemon・新しい receipt framework は不要で、通常ワークフローの成功率を落とさず #2200 の本来の correctness gap を閉じられます。
## 結論現状の Issue #2200 は
REQUEST_CHANGESが妥当です。 前回レビューで問題だった「実 executor が Allowed Paths にない」「artifact lifetime が未定義」はかなり改善されています。実 production path、cleanup/publish ordering、既存 repair consumer E2E まで AC に入った点は良いです。ただし、現在は別の問題が残っています。特に AC3 の artifact lifetime 契約が、現在の architecture では過剰に強く、しかも stale → fresh-preflight の責任主体が Allowed Paths に存在しません。加えて #2393/PR #2520/PR #2533 が既に完了しているため、Issue 本文の実装前提そのものが stale です。
repair_action.applyは、missing/unsafe input をsecure_open_rejectedで停止するだけで fresh preflight への routing を所有していない_dispatch_child_and_check_postconditions()は現在6 profile共有。#2200 の generic confinement変更が contract-update の「mutation済み inner result 保全」を壊し得るgit status --ignoredで worktree dirty 化して解決すると refresh を常時妨害しかねないP1-1: Issue の baseline が既に現行 main と食い違っている
#2200 は現在も「#2393 は OPEN」「#2393 と shared path collision 中」「PR #2495 時点の
b127017dを main HEAD」と記述しています。しかし #2393 は completed/closed で、PR #2520 も merge 済みです。 現行コードでは
PRODUCTION_DEDICATED_WORKTREE_COMMAND_IDSに、4つの preflight に加えてcontract_update.run.with_anchor/.with_human_contextが入っています。さらに PR #2533 まで merge され、contract-update について artifact-projection failure 後も inner mutation result を保全し、blind resend しない real-dispatcher regression が追加されています。 確認時点の main は
9e4a0065b478038d0d1eb6228fe07eaf4fb33627です。これは単なる説明文の古さではありません。#2200 が編集する
skill_runtime_exec.pyの共通 dispatcher が、今は GitHub mutation lane まで supervision しているためです。したがって Current Validated Scope はもう一度 fresh 化し、#2393 collision 記述を削除し、PR #2520/#2533 を既存 non-regression baseline として取り込むべきです。長寿命 Issue に「main HEAD = 固定SHA」を書き続けるより、実装開始時/PR作成時に
baseline_commitを記録する方が陳腐化しません。P1-2: AC3 は「artifact を保存する」のではなく「generation を失効させる」に寄せるべき
現在の AC3 は、accepted OID 更新などで worktree を再作成した際に、**「未消費の公開済み成果物を暗黙に削除しない」**ことと、stale なら fresh preflight へ戻すことの両方を要求しています。
ここで「未消費」をどう判定するかが定義されていません。preflight と
repair_action.applyは別 dispatch なので、artifact consumer acknowledgement を保持しない限り、bootstrap は「まだ読む予定なのか」「もう不要なのか」を知れません。これを厳密に実装すると、まさに今回避けたい lease/refcount/receipt-store のような仕組みが必要になります。前回レビューで示されていた選択肢は「保全 または stale として fresh preflight に戻す」でした。 現在の AC3 は refinement 過程で実質的に両方を要求する形になっています。
このプロジェクトなら、artifact の永続保全を捨てて generation invalidation を正規契約にするのが適切です。accepted OID refresh は artifact generation の境界とし、旧 worktree 内 artifact は消えてよい。ただし旧 handoff から mutation してはいけず、fresh preflight を生成し直す。この方が圧倒的に単純です。
P1-3: その stale → fresh-preflight route が、現在の Allowed Paths にはない
これは AC3 の実装可能性に直結します。
現在の
run_repair_action_apply()は preflight result と candidate body を component-wise no-follow で secure-read していますが、artifact が missing/unsafe ならphase="candidate_load", failure_code="secure_open_rejected"のnot_attemptedに落とします。そこで fresh preflight を起動する処理はありません。secure_open_rejected自体は既存 schema の正式な failure code です。一方、#2200 の Allowed Paths には
run_refinement_preflight.pyも.claude/skills/issue-refinement-loop/SKILL.mdもありません。ここは low-level bootstrap に workflow routing を押し込むべきではありません。最小構成なら、既存の
not_attempted + secure_open_rejectedを mutation retry せず freshpreflight.runへ戻す routing を issue-refinement-loop 側に追加するのがよいです。新しい schema/version/reason code を consumer に増やす必要もありません。persistent artifact lifecycle manager も不要です。この方針なら「盲目的な mutation retry 禁止」とも矛盾しません。再実行するのは mutation ではなく read-only producer/preflight です。
P1-4: #2200 は contract-update を変更対象外ではなく「明示的 non-regression 対象」にする必要がある
PR #2520 は、outer timeout / unauthorized-write / artifact-projection failure が起きても、inner GitHub transaction がすでに成立していた場合は
inner_transaction_result_ref/inner_transaction_dispositionを回収し、状態不明ならinner_transaction_state=unknownとして mutation を再送しない契約を実装しました。 PR #2533 は artifact-projection branch も real dispatcher で直接検証しています。#2200 はまさに
_validate_stdout_artifact_projection()と publish ordering を変更します。したがって「4 preflight の artifact confinement」という認識だけで実装すると危険です。ここは scope を広げて contract-update cleanup を再設計する必要はありません。新しい cleanup/lifetime semantics の対象 command-id は4 production preflight のみと固定しつつ、6-profile共有 dispatcherについて PR #2520/#2533 の inner-result-preservation test を regression として必須にするのが最小です。
Git の worktree cleanup は「ignored 全件を dirty 扱い」にしてはいけない
現行 recovery は dedicated worktree の cleanliness を
git status --porcelain --untracked-files=allで確認しています。 Git の公式仕様では ignored files は--ignoredを指定しない限り status に現れません。(Git) 一方git worktree removeは clean worktree を削除可能で、locked worktree の remove は force 指定を要求します。(Git)したがって前回レビューで再現された「ignored artifact があっても cleanliness probe は空、worktree refresh で artifact が消える」は構造上妥当です。
ただし解決策を
git status --ignored=matchingに変えるのは勧めません。artifact が普通に存在するだけで worktree を恒久的に dirty 扱いし、accepted OID refresh が止まるからです。Git cleanliness と artifact lifetime を分離してください。 Git source の dirty/unknown-owner 判定は現状維持し、refresh 前には schemaで既知の artifact refs だけを bounded に確認する。旧 generation は stale として捨ててよく、その後の consumer が fresh preflight に復帰する。この設計なら ignored tree 全走査も不要です。
freshness は mtime ではなく、既にある provenance を使える
現行 schema には既に
repair_action.preflight_run_identityがあり、consumer 側には candidate digest 検証も存在します。PR #2520 の
(mtime_ns, size)は「今回の dispatch 中に inner result が生成されたらしいか」を outer failure diagnostic で保守的に判断するための仕組みです。これを #2200 の canonical freshness authority に流用しない方がよいです。#2200 の AC4 にある「mtime 単独に依存しない」は正しいので、既存の
issue_number/repo + schema + preflight_run_identity + content digestを優先し、新しい artifact registry や timestamp protocol は増やさない方が整合します。filesystem hardening はこれ以上増やさなくてよい
現行 repair consumer は既に ancestor を
O_DIRECTORY | O_NOFOLLOWで1段ずつ dir-fd 相対 open し、leaf もO_NOFOLLOWで開き、同じ FD からfstat、size check、byte read、UTF-8 decode、SHA-256、post-read inode check まで行っています。Linux の
O_NOFOLLOWは本来 final component にしか効かず、全 path component をまとめて禁止できるopenat2(RESOLVE_NO_SYMLINKS)もあります。([man7.org]3) ただしopenat2は Linux 固有で glibc wrapper もなく、man page 自身も一般用途での過剰な symlink 禁止は互換性問題を生み得ると警告しています。([man7.org]4) Python はos.open(..., dir_fd=...)を正式にサポートしています。([Python documentation]5)したがって #2200 で openat2 wrapper、新 security module、hardlink registry 等を追加する価値はありません。現行の stdlib/dir-fd パターンを pre-publish validator に必要な範囲だけ適用すれば十分です。
テスト設計も少し削った方がよい
PR #2495 は production wiring を実際に行った結果、fixture の Scope Delta が3ラウンドまで広がった前例があります。 #2200 で同じことを繰り返さないため、証明の中心は「artifact confinement unit」「OID refresh + barrier の lifecycle integration」「real preflight → needs_fix → repair_action.apply の1本の production-chain E2E」で十分です。既存 bootstrap E2E は既に real repair consumer まで届いているので、そこを強化する方が新巨大fixtureより有用です。
また AC7 の「#2190 をクローズすることを pytest 等で実証」は、code acceptance と GitHub delivery postcondition が混ざっています。 親 #2190 は既に
surviving_parent_controller/re_exec: forbiddenに semantic contract が更新済みです。 そのため全 Child の歴史的テストを毎 iteration 再演するより、#2200 merge 後に既存 PR evidence + fresh critical regression を #2190 に記録して close、を Delivery Rule にする方が実用的です。推奨する再-refinement
実装前に #2200 をもう1回だけ semantic rewrite する価値があります。中心はセキュリティ強化ではなく、「artifact を保存する」という要求を捨て、「worktree refresh は generation invalidation。旧 handoff は mutation せず fresh preflight へ戻る」と固定することです。
その上で、#2393/PR #2520/#2533 を current baseline に反映し、stale recovery の owner として issue-refinement-loop routing の最小 Scope Delta を許可し、contract-update は既存 inner-result-preservation の regression のみに留める。この形なら、broker・lease DB・cleanup daemon・新しい receipt framework は不要で、通常ワークフローの成功率を落とさず #2200 の本来の correctness gap を閉じられます。
squne121 commentedon Sep 7, 2026
推奨は、#2200 を実装へ進めず、対象コメントを trusted human-context anchor にして
issue-refinement-loopをもう1回だけ収束させることです。理由は明確です。現在の #2200 本文はまだ #2393 を OPEN/in-flight と記述していますが、#2393 は completed/closed、PR #2520 と #2533 は merge 済みです。 また対象コメント時点では main が
9e4a0065...でしたが、現在はさらにfa932bb3...へ進んでいるため、固定 SHA を本文の「current main」にする設計自体を外すべきです。また現行 AC3 は「未消費 artifact を消さない」と「refresh 後 stale なら fresh preflight」を同時要求しています。 対象レビューが提案する generation invalidation を正規契約にし、旧 handoff では mutation せず fresh preflight に戻す方が、lease/receipt/broker を増やさず現行 architecture と整合します。
以下をそのまま、既に auto mode で起動中の Claude Code に渡すのがよいです。
Issue #2200 を、次の human-context anchor comment を対象に
.claude/skills/issue-refinement-loopで再 refinement してください。squne121/loop-protocol#2200https://github.com/squne121/loop-protocol/issues/2200#issuecomment-5562621548最重要方針
これは実装作業ではなく、Issue #2200 を implementation-ready に収束させる refinement task です。
.claude/skills/issue-refinement-loop/SKILL.mdを SSOT として読み、独自の簡略化した refinement 手順を作らず、canonical planner / preflight / review / rewrite / final readiness routing に従ってください。anchor comment は operator が明示的に選択した human context です。URL だけから origin を推測せず、repository/issue/comment binding と authority を検証したうえで canonical
preflight.run.with_human_contextlane を使用してください。通常の iteration、read-only investigation、Issue 本文の controlled rewrite、canonical deterministic repair、canonical structural repair、review の再実行について、人間承認を挟まないでください。
SubAgent の使用
必ず SubAgent を使用してください。
Step 0f の planner result に従い、少なくとも repository/current-code の検証が必要な場合は
codebase-investigatorを起動してください。外部技術 claim の検証が planner により required と判定された場合は
web-researcherも起動してください。Step 1 と Step 1b が両方 required なら並列実行して構いません。ただし、
すべての起動済み SubAgent の完了を必ず待ち、その structured result を回収・join してから Step 2 に進んでください。
SubAgent を fire-and-forget して main thread だけ先に終了してはいけません。
Issue rewrite が必要なら canonical Step 4 の
issue-editorSubAgent を使用し、その完了・author result・GitHub readback を待ってから fresh review に戻ってください。終了時にも未完了の SubAgent が残っていないことを確認してください。
最初に fresh baseline を取り直す
anchor comment 内の SHA や Issue 本文の「current main」を現在値として信用しないでください。
実行開始時点の live repository state を再取得し、少なくとも以下を確認してください。
scripts/agent-guards/skill_runtime_exec.pyscripts/agent-ops/worktree_bootstrap_exec.pyscripts/agent-ops/worktree_catalog.py.claude/skills/issue-refinement-loop/SKILL.md長寿命 Issue の本文に「main HEAD = <固定SHA>」を current-state contract として残さず、必要なら
baseline_commitを implementation start / PR evidence として取得する契約へ修正してください。Anchor comment の主要 findings を fact-check する
anchor comment をそのまま採用するのではなく、current main のコード・関連 Issue/PR・tests と照合してください。
特に以下を検証してください。
1. #2393 baseline の stale 化
#2393 が既に completed で、PR #2520 が merge 済みなら、
#2393 OPEN#2393 と in-flight scope collisioncontract_update.run.* はまだ dedicated runtime 外という #2200 の記述を削除・更新してください。
PR #2520 / #2533 によって成立した contract-update behavior は、#2200 が shared dispatcher を変更しても壊してはいけない current non-regression baseline としてください。
2. AC3 を generation invalidation 契約へ単純化する
現在の AC3 にある、
を同時に満たすために acknowledgement / lease / receipt / refcount 等を新設する設計にはしないでください。
current architecture で consumer acknowledgement が存在しないことを確認したうえで、原則として次の契約へ寄せてください。
Git cleanliness と artifact lifetime を混同しないでください。
ignored artifact があることだけを理由に dedicated worktree 全体を dirty と扱う
git status --ignored型の解決へ寄せないでください。3. stale → fresh-preflight routing owner を明示する
current
repair_action.applyが missing / unsafe / provenance-invalid artifact に対し、どのphase/failure_code/mutation_outcomeを返すか current code で確認してください。low-level
worktree_bootstrap_exec.pyに workflow routing を押し込まないでください。既存 consumer の「mutation 未実行」を示す formal outcome を利用して、issue-refinement-loop orchestrator が fresh
preflight.runに復帰するのが最小なら、それを正規 ownership としてください。特に anchor comment が指摘する
not_attempted + secure_open_rejected等について、を現行 failure vocabulary で区別できるか調査してください。
既存 failure code を雑にすべて fresh-preflight retry に変換してはいけません。
blind mutation retry も禁止です。
必要な Scope Delta は current implementation から最小限に導出してください。
少なくとも
.claude/skills/issue-refinement-loop/SKILL.mdが routing contract の owner になるか確認してください。run_refinement_preflight.py、references、tests 等の追加 edit path が本当に必要なら codebase evidence に基づいて有限に追加してください。将来必要そうという理由だけで Allowed Paths を広げないでください。
4. contract-update を shared-dispatcher non-regression 対象にする
#2200 の新しい artifact confinement / cleanup / publish semantics の適用対象を、意図せず contract-update mutation profiles へ拡張しないでください。
一方で
skill_runtime_exec.pyの shared dispatcher を変更する以上、PR #2520 / #2533 が保証した以下は必須 regression としてください。原則:
としてください。
5. freshness authority を増やしすぎない
mtime を canonical freshness authority にしないでください。
current schema/consumer に既に存在する provenance を調べ、
など、既存の強い identity を再利用してください。
新しい timestamp protocol、artifact registry、receipt store は原則追加しないでください。
6. filesystem hardening を目的化しない
current consumer の component-wise dir-fd relative open、
O_NOFOLLOW、same-FDfstat/ bounded read / digest / post-read identity check 等を確認してください。既存 stdlib mechanism で要件を満たせるなら、
を追加しないでください。
個人趣味開発として、workflow correctness と保守容易性を優先してください。
7. テスト契約を実用的な最小構成にする
巨大な profile × failure combination fixture matrix を新設しないでください。
証明の中心は原則として次の3層に絞ってください。
preflight → needs_fix → repair_action.applyproduction-chain E2E 1本必要な contract-update regression は既存 PR #2520/#2533 tests を再利用・維持してください。
fixed sleep による concurrency test は避け、barrier/synchronization primitive を使ってください。
8. #2190 closure を code AC と delivery postcondition に分離する
#2200 AC7 で「#2190 を close すること」を pytest の runtime evidence のように扱わないでください。
code acceptance と GitHub delivery postcondition を分離してください。
望ましい形は概ね:
です。
#2190 の historical test を毎 iteration 全件再演する必要性も current cost/benefit で見直してください。
issue-refinement-loop を canonical に最後まで回す
手作業で Issue 本文を直接書き換えて終わらず、skill の canonical flow を実行してください。
概念的には:
を max_iterations の範囲で自動反復してください。
canonical_step2_routeや planner decision を prose で再判定せず、SSOT の routing result に従ってください。Approval-free execution policy
次の操作について「実行してよいですか?」と人間へ確認しないでください。
auto mode の既存 permission state を変更する必要はありません。
repo loop iteration approval と Claude Code permission mode を混同しないでください。
停止条件
通常の「確認のための人間承認」では停止しないでください。
ただし次の場合だけは安全側に停止し、実行済み内容・未完了内容・blocker を簡潔に報告してください。
human_judgment_requiredを返し、自動で意味を決定する authority が存在しない「Allowed Paths の変更が必要」というだけでは、trusted anchor と canonical Scope Delta mechanism で自動解決できる場合は停止しないでください。
まず codebase-investigator と canonical scope-delta routing を使ってください。
完了条件
次をすべて満たすまで作業完了としないでください。
approve/proceed相当に収束している最後に、以下だけを簡潔に報告してください。
この形なら、対象コメントを単に本文へ転記するのではなく、現行 main で fact-check → semantic rewrite → controlled mutation → fresh review → READY 判定まで自動で収束させられます。特に
secure_open_rejectedを無条件 retry に変えない点は残しておくべきです。現行スキルではこの failure class は blind retry を避ける扱いになっているため、#2200 では「stale generation と確認できる場合だけ fresh producer に戻す」境界を refinement で明文化するのが重要です。squne121 commentedon Sep 7, 2026
root-owned entry router audit
route: invoke_impl_review_loop
reason: fresh_review_go_live_equality
squne121 commentedon Sep 7, 2026
issue-refinement-loop 終了報告
anchor comment(https://github.com/squne121/loop-protocol/issues/2200#issuecomment-5562621548)の
P1-1〜P1-4 / P2-1〜P2-4 全 finding を repository evidence(codebase-investigator)と一次資料
(web-researcher)で fact-check した上で、Step 2.5 semantic design review(1回目: blocker 2件・
high 2件・medium 1件・low 1件)→ Step 4 rewrite → 2回目 confirm semantic review(残 low 2件、
rewrite 不要)を経て、fresh preflight / fresh deterministic review / fresh semantic confirm
review まで収束しました。
run_root_review_pipeline.py producefresh review,VERDICT: approve,canonical_step2_route: step_2_5→ semantic confirmeffective_verdict: approve)root_entry_router.run_root_transition():route: invoke_impl_review_loop,reason: fresh_review_go_live_equality(live body / reviewed body / base SHA 完全一致)主要変更点(rewrite要約)
baseline_commit記録方式へ変更)## Delivery Rule(実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 close の post-merge delivery条件)に分離未解決の軽微事項(rewrite対象外、warning記録のみ)
semantic confirm review で low severity 2件(Outcome文言とAC3/In Scopeの限定句の粒度不一致、
Remaining Parent Gaps のチェックボックス表記矛盾)が残存。
finding_policy: route_high_open_to_rewriteにより rewrite 対象外(medium/low は warning 止まり)。実装着手のブロッカーではない。
実装着手について
本 loop は Issue #2200 を implementation-ready にする refinement task であり、実装作業そのものは
スコープ外のため、
impl-review-loopの起動はここでは行っていません。root_entry_routerの判定はinvoke_impl_review_loopで fresh go ですが、実際の実装着手は別途明示的なトリガーを待ちます。squne121 commentedon Sep 7, 2026
推奨は、#2200 を再 refinement せず、そのまま
impl-review-loopの正式な Root-Owned Entry から実装へ入れることです。最新の refinement 終了報告はimpl_ready/run_impl_review_loop、blocker 0、fresh review approve まで到達しています。ただし、過去の
LOOP_HANDOFF_RESULT_V1だけを Step 1 の authorization にしてはいけません。impl-review-loopの現行契約では、root thread が live Issue取得 → current-run contract review → live再取得 → routing → 同一継続 turn 内で Step 1 起動まで行う必要があります。 また SubAgent はimplementation-worker → test-runner → pr-reviewerが正規経路で、終了判定は PR reviewer の APPROVE だけでなく live mergeability と blocker 0 まで確認します。特に「SubAgent の完了待ち」は明示した方がよいです。正規契約では
wait_agentの戻りだけでは不十分で、final result を受け取り、その後list_agentsで同一 canonical task が terminalcompletedになったことの両方を確認してから次へ進む必要があります。以下を、現在 Auto mode で動いている Claude Code にそのまま投入する形を推奨します。
squne121/loop-protocolの Issue #2200 を対象に、.claude/skills/impl-review-loopを正規手順どおり実行してください。Target:
squne121/loop-protocol#2200https://github.com/squne121/loop-protocol/issues/2200https://github.com/squne121/loop-protocol/issues/2200#issuecomment-5568615928この Claude Code session は既に Auto mode で起動済みです。permission mode の変更は不要です。
最終目的
Issue #2200 の live contract に基づいて、
pr-reviewerによるレビューを bounded loop で繰り返し、
.claude/skills/impl-review-loopが定義するroute: approved、すなわち マージ直前の merge-ready 状態まで到達してください。実際の merge だけは行わないでください。
gh pr merge、auto-merge 有効化、merge 後の delivery、Issue #2190 の post-merge close は実行禁止です。そこが今回唯一の通常系 human approval boundary です。
重要: 過去の handoff を authorization にしない
最新コメントの
LOOP_HANDOFF_RESULT_V1.status: impl_ready/routing_action: run_impl_review_loopは readiness telemetry として参照してください。ただし、それ単独で Step 1 を開始しないでください。.claude/skills/impl-review-loop/SKILL.mdとsteps/preparation.mdの Root-Owned Synchronous Entry Transition を正規経路として使い、root/main thread 自身が同一の継続した invocation / turn 内で、issue-contract-reviewroot_entry_router.run_root_transition()相当の routing 判定route: invoke_impl_review_loopを確認まで連続して実行してください。
過去コメント、artifact、digest、snapshot、launch ledger の存在だけを authorization にしないでください。
現在の live contract が refinement 終了時から変化していた場合も、canonical routing が自動回復可能なら人間承認を求めず fresh review まで行い、その結果
invoke_impl_review_loopに戻ればそのまま実装を開始してください。Issue #2200 固有の実装方針
live Issue 本文を正本としてください。
特に以下を維持してください。
STATUS/NEXT_ACTION/ARTIFACTは mandatory validation / cleanup / postcondition が完了する前に usable-looking な形で公開しない。warn/needs_fix等の control result と confinement/cleanup failure を分離する。baseline_commitは PR description / contract evidence に記録する。SubAgent の使用を必須とする
root/main thread が実装・テスト・レビューを自分で代行しないでください。
.claude/skills/impl-review-loopの canonical delegation を使ってください。Step 1
implementation-workerSubAgent を起動し、.claude/skills/implement-issue/SKILL.mdに従わせる。担当:
Closes #2200を含む適切な PR bodybaseline_commitと検証証跡の記録Step 2
Step 1 完了後に
test-runnerSubAgent を新規 task として起動する。担当:
を read-only report として返す。
Step 2 の current-head adjudication が
blocking == falseになるまで Step 4 を開始しない。Step 4
current-head VC gate を再照合した直後に
pr-reviewerSubAgent を起動し、.claude/skills/pr-review-judge/SKILL.mdに従って独立レビューさせる。reviewer には必ず実値として以下を渡すこと:
placeholder や stale head を渡さない。
SubAgent の完了待ちを厳格に行う
各 SubAgent を起動したら、その作業完了を必ず待ってください。
implementation-worker、test-runner、pr-reviewer、および loop 内で追加起動した canonical worker task すべてについて Common Completion Protocol を守ること。
各 task ごとに:
spawn_agentで得た canonicaltask_nameを保存する。wait_agentは mailbox activity の待機にだけ使う。list_agentsで同じ canonical task name を確認する。completedであることを確認する。completedの両方が揃うまで次の Step、routing、commit判断、review判断へ進まない。errored/interrupted/shutdown/ task-levelnot_foundは成功扱いしない。特に:
SubAgent を fire-and-forget しないこと。
canonical skill が明示的に要求しない限り nested delegation を増やさず、root/main thread が sibling SubAgent の join を管理してください。
人間承認を要求せず自動継続する操作
次の通常操作について、iteration ごと・ファイルごと・commit ごとの人間承認を求めないでください。
Closes #2200の追加・修正BEHIND時の canonicalupdate_branch「この修正をしてよいですか」「PRを作ってよいですか」「pushしてよいですか」「再レビューしますか」のような routine approval request はしないでください。
REVIEW → FIX の自動ループ
pr-reviewerがREQUEST_CHANGESを返した場合:fix_deltaに正規化する。implementation-workerに渡す。BEHINDなら canonical mechanical update-branch route を使い、その後 verification と review を fresh にやり直す。PR review と修正の各 iteration で人間承認を求めないでください。
CI / mergeability
PR review 前後で required checks を current head に bind して確認してください。
APPROVE単独で終了しないこと。最終的に次をすべて満たす必要があります。
pr-reviewerverdict:APPROVEreviewed_head_sha == current PR headblockers == []mergeable == MERGEABLEmerge_state_statusが canonical approvable state (CLEAN/HAS_HOOKS)ここまで到達したら
impl-review-loopの approved termination として終了してください。停止条件
routine approval では停止しないでください。
ただし canonical skill が定める genuine hard gate は迂回しないこと。少なくとも以下では停止して事実を報告してください。
CONFLICTING/DIRTY) を canonical runbook でも自動解消できないpr-reviewerの正式 verdict がHUMAN_REVIEW_REQUIRED単なる artifact/snapshot/ledger の欠落、SubAgent の boolean
human_review_required: true自己申告、stale review、BEHIND、recoverable agent discovery failure、transient CI state は、それだけで人間承認停止にしないでください。canonical recovery routing を先に使ってください。マージ境界
route_loop_verdict_v2()が最終的にroute: approvedを返した時点で停止してください。その時点では以下を 実行しない:
gh pr mergePR body に closing keyword があること自体は問題ありません。実際の merge を発生させないでください。
最終報告
停止時は冗長な作業日誌ではなく、最低限以下を返してください。
MERGE_READY_AWAITING_HUMAN_MERGEまたは hard-stop reasonCloses #2200の有無開始してください。途中で通常の承認確認は挟まず、SubAgent の完了を確実に join しながら、マージ直前まで自律的に進めてください。
この形なら、#2200 の最新 refinement を尊重しつつ、過去 handoff を不正に authorization として再利用せず、現行
impl-review-loopの同期 entry・SubAgent join・current-head VC gate・PR review・mergeability routingまで通せます。#2200 自体も artifact confinement と generation invalidation、PR #2520/#2533 の非回帰を現在の実装範囲として明示しています。squne121 commentedon Sep 7, 2026
root-owned entry router audit
route: invoke_impl_review_loop
reason: fresh_review_go_live_equality
squne121 commentedon Sep 7, 2026
implement-issue: 実装完了 (2026-09-07T10:35:26Z)
.claude/worktrees/issue-2200-control-plane-preflight-artifact-confineworktree-issue-2200-control-plane-preflight-artifact-confine7c3c537a13935d2bc8d59bd7a1e731b52429fd7bfix: PR #2557 review指摘の provenance強化・E2E継続テスト・scan budgetを実装する (#2200)
feat: control-plane preflight にartifact confinement検証とbounded cleanup…