Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#2190"
goal_ref: "#2190 AC1/AC3/AC5/AC9/AC10: production preflight profile群の実 child execution rootを#2197 dedicated worktreeへ透過移行し、primary checkout不変性とlifecycle guard保持範囲拡張を実装する"
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 は、4 production preflight profile の実 child execution root を dedicated worktree へ透過的に移し、primary checkout 不変性を保ったまま lifecycle guard の保持範囲を child dispatch と既存 post-child checks 完了まで拡張する統合フェーズ。
- Desired Destination: 実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 の Allowed Paths のうち production preflight executor(
skill_runtime_exec.py)・policy(skill_runtime_command_policy.py)・worktree bootstrap/catalog/command-policy 系ファイルと、対応する focused test のみを扱う。
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 observe/fetch/pin/verify プロトコル、Child 3(実装: control-plane preflight lifecycle 用 git-common-dir スコープ排他ロックを実装する #2198)の lifecycle lock が実装済みであることを前提とする。
scripts/agent-ops/worktree_bootstrap_exec.py::run_control_plane_preflight_session()(現行 line 417-499)は、lifecycle guard を acquire → remote binding(run_control_plane_remote_default_ref_binding())→ fixed worktree recovery(recover_or_create_fixed_control_plane_worktree())→finallyでの guard release、までを実装済みである。docstring 自身が「このfunctionは実際のchild dispatchやartifact validationを一切行わない — それらは 実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 / 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 の責務」(line 445-446)と明記しており、現状は guard が実 child 実行より前に release される。scripts/agent-guards/skill_runtime_exec.py::_validate_runtime_context()(line 881-903 相当)が canonical main root / default branch を強制し、_snapshot_repo_paths()/_find_unauthorized_repo_changes()(line 353-430, 923-980)が before/after snapshot・unauthorized write detection を行い、_parse_artifact_projection()/_validate_stdout_artifact_projection()(line 1023-1054)が stdout artifact projection を検証している。これらは現状すべて primary root(canonical main root)を対象にしている。scripts/agent-guards/skill_runtime_command_policy.pyの4 production profile(preflight.run/preflight.run.with_anchor/preflight.run.with_human_context/preflight.run.with_agent_report)は現状すべてrequired_cwd: canonical_main_root/required_branch: default_branchを宣言しており、child dispatch の実行先を dedicated worktree へ切り替える機構を持たない。scripts/agent-ops/worktree_catalog.py::list_worktrees()/_git_common_dir()は現状 ambientsubprocess.run(["git", ...])を直接呼んでおり、parse_worktree_porcelain_z()が返すWORKTREE_CATALOG_ENTRY_V1相当のエントリにはlocked/prunableフィールドが存在しない。.claude/skills/issue-refinement-loop/scripts/command_registry.pyの barepreflight.runargv は 実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311 によりworkflow_start_entry.pyが first hop になっている(本 Issue はこの first-hop 契約と、production 4 profile のrequired_cwd: canonical_main_rootargv 宣言そのものは変更しない)。_sanitize_env()(skill_runtime_exec.pyline 824-878)が、GH_CONFIG_DIRを carrier command IDs(preflight.run/contract_update.run.with_anchor/contract_update.run.with_human_context/repair_action.apply/structural_repair_action.apply)へ限定伝播し(fix: preserve GH_CONFIG_DIR for bare preflight.run #2407)、barepreflight.run専用にLOOP_SPARK_MODE/LOOP_SPARK_FALLBACK/LOOP_PLANNED_OPERATIONS_JSONを伝播している。
Remaining Parent Gaps
- artifact confinement・実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 全AC最終検証(AC6/AC11/AC12)は 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200(後続 Issue)で扱う。実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 は、本 Issue (実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199) で既に成立している dedicated preflight producer(
investigation_evidence_primary_root経由の primary-root相対 evidence path 解決)→ 既存 repair consumer(repair_action.apply等)の path/transport contract を再設計しないこと。実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 の残責務は、この既存 transport を保持したまま artifact confinement / bounded cleanup / lifecycle release ordering / 実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 全AC 最終検証を扱う。cleanup 導入後もpreflight -> needs_fix -> repair_action.apply が既存 artifact を読めることを non-regression として維持する。
Outcome
scripts/agent-guards/skill_runtime_exec.py が長寿命 parent controller として、acquire lifecycle guard → remote binding → fixed worktree recover/create → dedicated identity verification → supervised child(cwd=dedicated execution_root) → 既存 post-child checks(同じ execution_root に対して)→ release lifecycle guard の一続きの lifetime を実行し、4 production preflight profile(preflight.run/preflight.run.with_anchor/preflight.run.with_human_context/preflight.run.with_agent_report)の実 child dispatch が dedicated worktree(execution_root)で行われ、primary checkout が bootstrap/child/post-child の成功・失敗を通じて不変であることを実証する新規 pytest(tests/agent_ops/test_control_plane_worktree_bootstrap.py)と既存 focused test の拡張が全て PASS している状態。4 production preflight profile の outward invocation shape(skill_runtime_exec.py --command-id preflight.run ... および sibling profile の外向き invocation contract)は互換性を維持し(command_registry.py の preflight.run.with_human_context エントリへの --investigation-evidence-primary-root のような内部 argv transport の bounded extension は許容する)、fixture profile / contract_update.* の実行先は変更しない。
Runtime Verification Applicability
decision: immediate
reason: "isolated tmp git repo fixtureに対しdedicated execution rootでのchild dispatch・lifecycle guard保持範囲拡張・primary checkout不変性・dedicated identity fail-closedマトリクスの成功・失敗経路を実証する。production primary checkoutを切替・汚染しない。"
applicable_acs:
- AC1
- AC2
- AC3
- AC4
- AC5
- AC6
- AC7
- AC8
- AC9
- AC10
- AC11
- AC12
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"
- "primary_snapshot(toplevel_raw/head_mode_raw/head_oid_raw/status_raw)の実行前後比較 artifact"In Scope
skill_runtime_exec.pyを長寿命 parent controller とし、lifecycle guard の保持範囲をacquireから実 child 実行・既存 post-child checks 完了までに拡張する(run_control_plane_preflight_session()との互換性を保ちつつ、必要な内部 primitive を context-manager 化する形を含む)- 4 production preflight profile(
preflight.run/preflight.run.with_anchor/preflight.run.with_human_context/preflight.run.with_agent_report)の child dispatch cwd を、実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197 のaccepted_oidに束縛された fixed dedicated worktree(execution_root)へ切り替える - 既存 post-child checks(before/after repository snapshot、unauthorized write/change detection、stdout/artifact projection の path 解釈・validation)が、child と同じ
execution_root(4 profile では dedicated、fixture /contract_update.*では primary のまま)を対象にするよう整合させる worktree_catalog.pyにWORKTREE_CATALOG_ENTRY_V1スキーマを変更しない dedicated-lane 専用 identity probe を追加する(catalog entry 一意性・detached HEAD・locked==true・prunable==false・実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197accepted_oidとの一致・git common dir linkage・invocation cwd/executor script identity/execution_root の同一 dedicated identity 所属の検証)。Git 実行は 実装: #2197向け remote protocol Git builderを閉鎖型に hardenする #2378/実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197 の既存 closed/sanitized Git execution seam を再利用し、worktree_catalog.py内に新しい ambientsubprocess.run(["git", ...])authority を追加しない。remote identity の確認は 実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197 のaccepted_oidと dedicated HEAD の比較のみとし、二回目のls-remoteは追加しない- missing/duplicate catalog entry・linkage mismatch・symlink component・non-detached head・
locked==false・prunable==true・OID mismatch・initializer/refresh failure の fail-closed 経路実装。ambientLOOP_DEFAULT_BRANCHの存在は authority として無視し(canonical remote HEAD /accepted_oidが authority)、それによって dedicated identity の判定結果が変化しないことを検証する - primary checkout invariant 検証時の index lock friction 回避(
git --no-optional-locks相当の使用)。実装済みのcapture_primary_checkout_invariant_snapshot()(scripts/agent-guards/skill_runtime_exec.py)は、4 production profile の dispatch 前後で無条件に exhaustive な untracked-file enumeration を含む byte-identical invariant watchdog として動作する。これは dedicated child が primary drift を「引き起こした」ことを因果的に証明する機構ではなく、観測された変化があれば無条件に停止する fail-closed watchdog である - bare
preflight.runのworkflow_start_entry.pyfirst-hop(実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311)・invocation-scopedLOOP_SPARK_MODE/LOOP_SPARK_FALLBACK/LOOP_PLANNED_OPERATIONS_JSON・GH_CONFIG_DIR(fix: preserve GH_CONFIG_DIR for bare preflight.run #2407 carrier command ids)transport の維持 main()の実 dispatch/cwd 選択ロジックと post-child checks の execution_root 選択ロジックを、4 production preflight profile について実際に配線する(primitive の存在だけでは不十分)。あわせて.claude/skills/issue-refinement-loop/scripts/tests/test_workflow_start_entry_canonical_executor.pyとscripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.pyの既存テストを、新しい production dispatch 契約(cwd=execution_root)に整合するよう更新する。更新は実 GitHub network access を要求しない deterministic な local/tmp-repo fixture のみで行うmain()配線後に新規回帰した6ファイル(scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py、scripts/agent-guards/tests/test_skill_runtime_exec_pytest_cache.py、scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest.py、scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py、scripts/agent-guards/tests/test_skill_runtime_exec_stale_shadow_log_preflight.py、scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py)についても、4 production preflight profile の新しい dedicated-root production dispatch 契約(cwd=execution_root)に対して実際に pass するよう更新する。更新は実 GitHub network access を要求しない deterministic な local/tmp-repo fixture のみで行い、network_required: false/auth_required: falseを維持する。AC11 の fail-closed 保証を弱めるための production profile 向け primary-root fallback path は一切導入しない- 本 Issue の実装完了を主張する前に、
scripts/agent-guards/tests/に加えて、同じく repository-required CI target であり real-subprocesspreflight.run/sibling-command fixture を含みうる.claude/skills/issue-refinement-loop/scripts/tests/と.claude/skills/issue-refinement-loop/tests/の両ディレクトリについても、配線済みのmain()に対して FULL directory 実行で回帰の有無を確認する。これにより Allowed Paths 外の新たな回帰が判明した場合は、既存の## Stop Conditions(「本child issueのAllowed Paths外への波及が必要と判明した場合」)に従って停止・報告し、この Scope Delta プロセスを経ずに Allowed Paths をこれ以上サイレントに拡張しない。 - 本 Issue の実装完了は、必ず live CI(
gh pr checksによるrepository-required job の実行結果)の green を独立確認して判定し、ローカルの限定的な pytest 実行結果(特定ディレクトリの full-directory 実行含む)だけでは完了と判定しない。(round 2 完了時に「ローカルfull-directory実行PASS」を根拠に完了と誤判定し、その後 live CI で新規回帰が判明した反省を踏まえる)
Out of Scope
- sanitized Git subprocess 実行基盤そのもの(Child 1 で実装済み。実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 AC2/AC8)
- remote OID observe/fetch/pin/verify プロトコルの本体実装(Child 2 で実装済み。実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 AC4)
- lifecycle lock の本体実装(Child 3 で実装済み。実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 AC7)
- artifact confinement・bounded cleanup・artifact handoff validation・final release ordering(実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 AC6/AC11/AC12、実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 で扱う。ただし 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 は本 Issue で既に成立している
investigation_evidence_primary_rootproducer/consumer path/transport contract を再設計しない。cleanup 導入後もpreflight -> needs_fix -> repair_action.apply が既存 artifact を読めることは non-regression として維持する) - test-only fixture profile(
preflight.run.fixture/preflight.run.fixture.with_human_context)とcontract_update.run.with_anchor/contract_update.run.with_human_contextの dedicated worktree 化 - 4 production preflight profile の outward / operator-facing invocation shape の変更・新規 operator-facing initializer argv の導入。ただし dedicated child migration を成立させるための内部 argv transport の bounded extension(
command_registry.pyのpreflight.run.with_human_contextエントリへの--investigation-evidence-primary-root追加)は本 Issue の実装済みスコープに含む(AC7 参照) .claude/settings.jsonの broad allowlist 拡張、新しい generic permission surface の導入- 新規 authorization token / ledger / lease / daemon / heartbeat / receipt / persistent state store / generic broker / generic worktree framework / repository-wide permission framework の追加
WORKTREE_CATALOG_ENTRY_V1schema の変更
Acceptance Criteria
- AC1: primary checkout(
toplevel_raw/head_mode_raw/head_oid_raw/status_raw)が、4 production profile の bootstrap/child dispatch/post-child checks の成功・失敗全経路を通じて実行前後で byte-identical であることを実証する - AC2: dedicated identity 検証が catalog match exactly one・detached HEAD・
locked==true・prunable==false・実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197accepted_oidとの HEAD 一致・git common dir linkage・invocation cwd/executor script identity/execution_root の同一 dedicated identity 所属を確認することを実証する - AC3: lifecycle guard が
acquireから実 child dispatch と既存 post-child checks(before/after snapshot・write detection・stdout/artifact projection validation)完了までの一続きの区間で保持され、成功・失敗いずれの経路でも最終的に release されること、かつ新規 TTL / lease / daemon / heartbeat / stale takeover / persistent lock broker が追加されていないことを実証する - AC4:
scripts/agent-guards/skill_runtime_exec.py::main()の実 child-dispatch コード経路が、4 production preflight profile(preflight.run/preflight.run.with_anchor/preflight.run.with_human_context/preflight.run.with_agent_report)についてcwd=execution_root(実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197accepted_oidに束縛された dedicated worktree)を選択して child を起動することを実証する。PRODUCTION_DEDICATED_WORKTREE_COMMAND_IDS == {...}(同一 PR 内で定義された同じ4リテラル文字列との比較)のような定数/集合の等価性のみを検証するテストはこの AC を満たさない — テストはmain()の実 dispatch selection ロジックを呼び出すことで、child process へ実際に渡されるcwdを観測しなければならない。main()の dispatch selection ロジックを独自に再実装した模擬(simulation)で代替することはこの AC を満たさない - AC5: bare
preflight.runについて、main()wiring 後の実 process chain(skill_runtime_exec.py(outer) →_sanitize_env()→workflow_start_entry.py→ capability preflight → inner refinement preflight)がmain()を通じて実際に exercise され、dedicatedexecution_rootを cwd として実行されること、かつ first-hop parity(LOOP_SPARK_MODE/LOOP_SPARK_FALLBACK/LOOP_PLANNED_OPERATIONS_JSON/GH_CONFIG_DIRtransport)が wiring 後の end-to-end 経路で証明されることを実証する。孤立した helper 関数呼び出しだけでの検証はこの AC を満たさない - AC6: invocation-scoped の
LOOP_SPARK_MODE/LOOP_SPARK_FALLBACK/LOOP_PLANNED_OPERATIONS_JSON(barepreflight.run限定)と、fix: preserve GH_CONFIG_DIR for bare preflight.run #2407 の carrier command ids に対するGH_CONFIG_DIRtransport が、wiring 後に実際に起動される dedicated-root child process に対して変更なく伝播することを実証する。_sanitize_env()単体が孤立した呼び出しで不変であることの確認のみではこの AC を満たさない。他の環境変数への generic pass-through 拡張が発生していないことも併せて実証する - AC7: 4 production preflight profile の operator-facing / outward invocation shape(
skill_runtime_exec.py --command-id preflight.run ...および sibling profile を利用する外向き invocation contract)が互換性を維持していることを実証する。ただし、dedicated child migration を成立させるための内部 argv transport、特に human-context evidence の--investigation-evidence-primary-rootのような bounded extension(preflight.run.with_human_contextエントリへの追加)は許容する。「REGISTRY entry の token 列が一文字も変化してはならない」という closure condition は要求しない - AC8: fixture profile(
preflight.run.fixture/preflight.run.fixture.with_human_context)とcontract_update.run.with_anchor/contract_update.run.with_human_contextが、引き続き primary root(canonical_main_root)で実行され、dedicated worktree 化の対象外のままであることを実証する(non-regression) - AC9:
main()の post-child checks(_find_unauthorized_repo_changes・_validate_stdout_artifact_projection・および repo-snapshot 系 helper)がcommand_idに基づいて分岐し、4 production profile では dedicatedexecution_root、fixture/contract_update.*ではproject_rootを対象にすることを、main()の実コード経路を通じて実証する。synthetic な引数を渡す standalone helper 関数呼び出しのみでの検証はこの AC を満たさない - AC10: dedicated identity検証が 実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197 の
accepted_oidを再利用し、新たな2回目のls-remote等の remote observation を追加しないことを実証する - AC11: missing/duplicate catalog entry・linkage mismatch・symlink component・non-detached head・
locked==false・prunable==true・OID mismatch・initializer/refresh failure の各ケースで、primary fallback も dedicated 側の代替続行も行わず fail-closed することを実証する - AC12:
scripts/agent-ops/worktree_catalog.pyのWORKTREE_CATALOG_ENTRY_V1相当スキーマ(parse_worktree_porcelain_z()が返すフィールド集合)が変更されておらず、dedicated identity 検証専用フィールド(locked/prunable等)は catalog schema への追加ではなく別の identity probe 経路で取得されていることを実証する
Verification Commands
# AC1
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py -q -k primary_snapshot_invariant# AC2
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py -q -k dedicated_identity_positive# AC3
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py -q -k lifecycle_guard_held_through_child# AC4
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py -q -k production_profile_dedicated_execution_root# AC5
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py -q -k dedicated_first_hop_parity# AC6
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py -q -k env_transport_parity# AC7
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py -q -k outward_command_shape_unchanged(non-blocking 注記: 現在の VC test test_given_registry_entries_when_inspected_then_outward_command_shape_unchanged(tests/agent_ops/test_control_plane_worktree_bootstrap.py:874-892)は bare preflight.run エントリの外向き shape 不変と、4 production profile の required_cwd/required_branch のみを検証しており、preflight.run.with_human_context への bounded internal extension 追加を禁止するものではない。AC7 の新定義に対して本 VC は引き続き green のまま満たされる。新しい VC test の追加は求めない)
# AC8
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py -q -k fixture_and_contract_update_non_regression# AC9
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py -q -k post_child_execution_root_consistency# AC10
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py -q -k accepted_oid_reused_no_second_remote_observation# AC11
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py -q -k fail_closed_identity_matrix# AC12
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py -q -k catalog_schema_unchanged$ pnpm typecheck$ pnpm lint$ pnpm test$ pnpm build$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py -q# Non-regression: newly-added Allowed Path test file (existing tests, no new markers)
$ uv run --locked pytest .claude/skills/issue-refinement-loop/scripts/tests/test_workflow_start_entry_canonical_executor.py -q# Non-regression: newly-added Allowed Path test file (existing tests, no new markers)
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py -q# Non-regression: newly-added Allowed Path test file (existing tests, no new markers)
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py -q# Non-regression: newly-added Allowed Path test file (existing tests, no new markers)
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_pytest_cache.py -q# Non-regression: newly-added Allowed Path test file (existing tests, no new markers)
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest.py -q# Non-regression: newly-added Allowed Path test file (existing tests, no new markers)
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py -q# Non-regression: newly-added Allowed Path test file (existing tests, no new markers)
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_stale_shadow_log_preflight.py -q# Non-regression: newly-added Allowed Path test file (existing tests, no new markers)
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py -q# Non-regression: newly-added Allowed Path test file (existing tests, no new markers)
$ uv run --locked pytest tests/agent_guards/test_worktree_scope_guard.py -q# Non-regression: newly-added Allowed Path test file (existing tests, no new markers)
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_policy_anchor.py -qAllowed Paths
scripts/agent-guards/skill_runtime_exec.py
scripts/agent-guards/skill_runtime_command_policy.py
scripts/agent-ops/worktree_bootstrap_exec.py
scripts/agent-ops/worktree_catalog.py
scripts/agent-guards/worktree_bootstrap_command_policy.py
tests/agent_ops/test_control_plane_worktree_bootstrap.py
scripts/agent-guards/tests/test_skill_runtime_control_plane_exec.py
.claude/skills/issue-refinement-loop/scripts/tests/test_workflow_start_entry.py
.claude/skills/issue-refinement-loop/scripts/tests/test_workflow_start_entry_canonical_executor.py
scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py
scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py
scripts/agent-guards/tests/test_skill_runtime_exec_pytest_cache.py
scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest.py
scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py
scripts/agent-guards/tests/test_skill_runtime_exec_stale_shadow_log_preflight.py
scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py
tests/agent_guards/test_worktree_scope_guard.py
scripts/agent-guards/tests/test_skill_runtime_policy_anchor.py
.claude/skills/issue-refinement-loop/scripts/command_registry.py
.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- 本child issueのAllowed Paths外への波及が必要と判明した場合
Required Skills
- worktree-bootstrap
Required Design References
- docs/dev/agent-skill-boundaries.md
- docs/dev/workflow.md
- docs/dev/current-focus.md
.claude/skills/issue-refinement-loop/SKILL.md(Step 0g: main control-plane 限定 mutation phase の既存契約)- 実装: #2197向け remote protocol Git builderを閉鎖型に hardenする #2378(closed/sanitized Git builder 契約: remote symref readback, private-ref fetch, OID readback, worktree HEAD readback, CAS-only private-ref delete)
- 実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197(remote default-ref OID observe/fetch/pin/verify プロトコルと
accepted_oidの由来) - 実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311(bare
preflight.runのworkflow_start_entry.pyfirst-hop契約) - fix: preserve GH_CONFIG_DIR for bare preflight.run #2407(
GH_CONFIG_DIRcarrier command ids と invocation-scoped env transport契約) - https://git-scm.com/docs/git-worktree.html(`--detach --lock --reason
、porcelainlocked/prunable` fields) - https://git-scm.com/docs/git(`--no-optional-locks` の挙動)
- https://peps.python.org/pep-0446/ および https://docs.python.org/3/library/os.html#os.open(CPython 3.4+ の non-inheritable file descriptor /
O_CLOEXECデフォルト、subprocess.Popen(pass_fds=...))
Scope Delta(任意)
- 変更内容: PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495(Draft, branch
worktree-issue-2199-dedicated-worktree-preflight)は dedicated worktree identity probe / lifecycle guard context manager / primary checkout invariant snapshot の primitive を実装したが、scripts/agent-guards/skill_runtime_exec.py::main()の実 child-dispatch コードは配線されておらず、main()は依然として全 command id に対し無条件にcwd=project_rootで dispatch している(pr-reviewer REQUEST_CHANGES: https://github.com/squne121/loop-protocol/pull/2495#issuecomment-5540166708)。AC4 を検証していたテストはPRODUCTION_DEDICATED_WORKTREE_COMMAND_IDS == {...}(同一 PR 内で定義された同じ4リテラル文字列との比較)という tautology であり、実 dispatch/cwd を検証していなかった。 - 理由: Owner が follow-up Issue への分離ではなく、本 Issue のスコープを最小 Scope Delta で拡張する判断をした(Owner Decision: https://github.com/squne121/loop-protocol/issues/2199#issuecomment-5540607147)。
- Allowed Paths への追加(正確に2ファイルのみ):
.claude/skills/issue-refinement-loop/scripts/tests/test_workflow_start_entry_canonical_executor.pyscripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py
- 影響範囲: In Scope に
main()wiring の明示要件を追加し、AC4/AC5/AC6/AC9 を「配線済み実 dispatch を通じて検証」する要件へ強化した。AC1/AC2/AC3/AC7/AC8/AC10/AC11/AC12、Out of Scope の既存境界、Stop Conditions は変更しない。network_required: false/auth_required: falseは維持する。 - 2026-09-05 追加分:
- 変更内容: PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495 で
main()wiring(round 1 Scope Delta)を実装した結果、Allowed Paths外・repository-required CI targetscripts/agent-guards/tests/配下の6ファイル・42 testに新規回帰が発生した(停止報告: 実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 (comment) )。原因は round 1 で追加した2ファイルと同型で、既存 real-subprocess fixture がworktree_bootstrap_exec.py/worktree_catalog.py/実 remote binding を同梱しておらず、production profile の dedicated execution root 配線により fail し始めたため。この6ファイル・42 testという件数はscripts/agent-guards/tests/配下の全ファイルを対象にした FULL directory 実行(サンプリングではない)によって確定したものであり、同じ real-subprocesspreflight.run系 dispatch を行う他のファイル(test_skill_runtime_policy_anchor.py/test_skill_runtime_policy_commands.py/test_isolated_anchor_single_authority.py等を含む)は同じ full-directory 実行で全て PASS することを確認済みである。つまりscripts/agent-guards/tests/ディレクトリ内に限っては、この6ファイルのリストは exhaustive である。 - 理由: Owner が follow-up Issue への分離ではなく、本 Issue の Scope Delta をさらに拡張する判断をした(Owner Decision: 実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 (comment) )。
- Allowed Paths への追加(正確に6ファイルのみ):
scripts/agent-guards/tests/test_skill_runtime_exec_anchor.pyscripts/agent-guards/tests/test_skill_runtime_exec_pytest_cache.pyscripts/agent-guards/tests/test_skill_runtime_exec_session_manifest.pyscripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.pyscripts/agent-guards/tests/test_skill_runtime_exec_stale_shadow_log_preflight.pyscripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py
- 影響範囲: In Scope に、この6ファイルを新しい production dispatch 契約(
cwd=execution_root)に合わせて更新する要件を追加した。Verification Commands にこの6ファイルそれぞれの non-regression VC を追加した。AC1-AC12 の文言・Out of Scope・Stop Conditions は変更しない。network_required: false/auth_required: falseは維持する。AC11 の fail-closed 保証(4 production profile に対する primary-root fallback の非導入)は今回の拡張でも弱めない。 - 2026-09-05 追加分(round 3):
- 変更内容: round 2 完了後、
scripts/agent-guards/tests/配下だけでなく repo root 直下tests/agent_guards/(アンダースコア区切り、命名類似で見落とされていた)にも同型の real-subprocess 回帰が存在し、live CI(gh pr checks/run 33928665138、PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495 head46cb2b223ef927c3800ea2d7bbddad2a905cd801)で独立確認したところ、round 1/2 でカバーされていなかった正確に2ファイル・6テストが新規回帰していることが判明した。うち1ファイルは既に Allowed Paths 内のtest_skill_runtime_policy_anchor.pyだが、round 2 完了時に「フルディレクトリ実行で PASS 確認済み」とされた1テスト(test_investigation_evidence_transport_path_reaches_real_subprocess_ac3)が実際には live CI で FAIL していた(ローカル実行と CI xdist 実行の食い違い)。exhaustive read-only investigation(direct command-id-literal grep・fixture-installer-pattern grep・.github/ci/python-test-plan.jsonとのcross-reference の3手法収束・CI target inventory 照合)により、この2ファイルが repository-required CI 全体を通じて実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 のmain()配線に起因する新規回帰の exhaustive かつ finite な全体であることを確認した。.claude/skills/issue-contract-review/scripts/tests/test_vc_process_group_cancellation.py::test_outer_deadline_via_run_baseline_vc_preflight_reaps_full_process_treeはこの調査で無関係(flaky_or_environmental)と分類され、preflight.run/skill_runtime_exec.py/worktree_bootstrapへの参照が皆無であり、同じ live CI run でも FAIL していないことを確認した上で、Scope Delta に含めない。 - 理由: Owner Decision(実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 (comment) )— round 3 以降は個別ファイル単位でなく、CI 実行面から影響範囲を一括棚卸ししてからconsolidated Scope Delta として追加する方針への転換。
- Allowed Paths への追加(正確に2ファイルのみ):
tests/agent_guards/test_worktree_scope_guard.pyscripts/agent-guards/tests/test_skill_runtime_policy_anchor.py
- 影響範囲: In Scope に、この2ファイルを新しい production dedicated dispatch 契約(
cwd=execution_root)に合わせて更新する要件を追加した。また、実装完了の判定は今後必ずlive CI(gh pr checks)の green を独立確認して行い、ローカルの限定 pytest 実行結果だけでは完了と判定しないことを In Scope に明記した(round 2 で「ローカル full-directory 実行 PASS」を根拠に完了と誤判定した反省)。Verification Commands に以下の2つの non-regression VC を追加した:$ uv run --locked pytest tests/agent_guards/test_worktree_scope_guard.py -q$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_policy_anchor.py -q
AC1-AC12 の文言・Out of Scope・Stop Conditions は変更しない。network_required: false/auth_required: falseは維持する。AC11 の fail-closed 保証(4 production profile に対する primary-root fallback の非導入)は今回の拡張でも弱めない。
- 変更内容: round 2 完了後、
- 2026-09-06 追加分(round 4: OWNER最終判定 + semantic design review reconciliation):
- 変更内容: PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495 は merge済み(merge commit
aa94a78d779d8b788a72319bb6bf0a8e1c8fceac、2026-09-05T14:06:08Z、17 files, +3963/-362)。
OWNER 最終レビュー(実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 (comment) )は実装を ACCEPT、
Issue contract を REQUEST_CHANGES とし、deterministic checker approve 後の semantic design review(issue-design-reviewer SubAgent)が
blocker 2件(AC7 の文言と merged reality の不一致、Allowed Paths への2ファイル欠落)・high 1件(In Scope の primary invariant 記述と実装の不一致)・
medium 2件(AC1-12 の未チェック残存、実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 境界記述の陳腐化)を検証済み evidence 付きで報告した。
merged final diff には.claude/skills/issue-refinement-loop/scripts/command_registry.py(+11行、
preflight.run.with_human_contextエントリへの--investigation-evidence-primary-rootargv 追加)と
.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py(+55行/-3行、
primary-root相対 evidence path 解決ロジック追加)が含まれていたが、round 1-3 の Scope Delta ではこの2ファイルが
Allowed Paths に反映されていなかったことが判明した。 - 理由: OWNER Decision(上記コメント)+ semantic design review。round 1-3 は
main()wiring / test 回帰対応が中心だったため、
AC7 が要求する「outward command shape 不変」の検証対象を絞り込む過程でこの2ファイルの取り込みが見落とされていた。 - Allowed Paths への追加(正確に2ファイルのみ):
.claude/skills/issue-refinement-loop/scripts/command_registry.py.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
- 影響範囲: AC7 の定義を、4 production profile の outward invocation shape 不変を要求しつつ、
dedicated child migration のための内部 argv transport の bounded extension
(preflight.run.with_human_contextへの--investigation-evidence-primary-root追加)を許容する形へ修正した。
Outcome・Out of Scope の対応する文言も同じ定義に整合させた。In Scope の primary invariant 記述を、実装済みの
capture_primary_checkout_invariant_snapshot()が4 production profile の dispatch 前後で無条件に exhaustive な
untracked-file enumeration を伴う fail-closed watchdog として動作する実態に合わせて修正した(実装変更は要求しない)。
production dispatch ごとの exhaustive untracked enumeration のコストは、意味のある workflow friction が確認された場合は
将来の follow-up として軽量化を検討する余地があるが、本 Issue の closure blocker としない(non-blocking follow-up recommendation)。
Remaining Parent Gaps / Out of Scope の 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 関連記述を、本 Issue で既に成立している
investigation_evidence_primary_rootproducer/consumer path/transport contract を 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 が再設計しないことを明記する形へ更新した
(実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 の Issue 本文自体は編集していない)。AC1-AC3/AC8-AC12 は merge済み PR の live CI green(gh pr checks 2495で 20/0 確認)と
対応する VC(tests/agent_ops/test_control_plane_worktree_bootstrap.pyの該当-kフィルタ)の実行結果を根拠に- [x]へ更新した。
AC4-AC6/AC9 はmain()wiring 実装と対応 test の CI green を根拠に- [x]へ更新した。AC7 は新定義に対して既存 VC test
(barepreflight.runの outward shape 不変検証)が引き続き green であることを根拠に- [x]へ更新した。
Stop Conditions・network_required: false/auth_required: falseは変更しない。
- 変更内容: PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495 は merge済み(merge commit
- 変更内容: PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495 で
Activity
feat(#2197): control-plane remote default-ref observe/fetch/pin/verif…
squne121 commentedon Sep 3, 2026
結論
Issue #2199 は、目的自体は妥当ですが、現状の契約のまま実装開始するのは
REFRAME_REQUIREDです。特に #2199 作成後に #2197、#2311、#2407 などが入り、production preflight の実経路が変わっています。レビューは 2026-09-04 07:19 JST 時点の current main HEAD
8283fb80c5132420d8279cf4e179394d6f358582を基準にしました。この HEAD 自体が barepreflight.runのGH_CONFIG_DIRtransport を修正した直後です。#2199 は現在 open で、Issue 自体にはコメントがありません。
私なら この Issue を一度 refinement してから実装します。主要 findings は以下です。
優先度 | Finding | 判定 -- | -- | -- P0 | Allowed Paths だけでは4 production profile を実際には移行できない | contract blocker P0 | 現行 flock と「initializer → re-exec」の組合せでは lock が child execution まで保持されない | architecture blocker P0 | #2199/#2200 の分割境界が current executor の post-child validation と不整合 | integration blocker P0 | bare preflight.run が #2311/#2407 後の新しい first-hop/env contract を持つ | regression blocker P1 | identity probe を worktree_catalog.py の既存 Git 実行方式で作ると sanitized Git seam を迂回する | must-fix P1 | dedicated identity に locked / prunable の検証が不足 | must-fix P1 | outward command を initializer に変更すると Claude Code の allowlist と衝突する | workflow regression P2 | LOOP_DEFAULT_BRANCH の存在だけで停止、通常の git status による optional lock は不要な摩擦 | simplifyP0 — Allowed Paths が current main と矛盾しています
現在の production executor は
skill_runtime_exec.pyが command を受け取り、そこでcwd == canonical_main_rootとcurrent branch == default branchを直接強制しています。さらに registry を読み、child をcwd=project_rootで起動しています。つまり dedicated detached worktree 化するには、このファイルの変更がほぼ不可避です。しかし #2199 の Allowed Paths には
scripts/agent-guards/skill_runtime_exec.pyもscripts/agent-guards/skill_runtime_command_policy.pyも入っていません。一方 current policy は4 profileについて依然canonical_main_root/default_branchを契約にしています。したがって、「command_registry と guard 数本だけ変えて4 profileを dedicated worktree に移す」契約は現在成立しません。
推奨は Allowed Paths に少なくとも次を追加することです。
scripts/agent-guards/skill_runtime_exec.pyscripts/agent-guards/skill_runtime_command_policy.py対応する focused policy/exec tests
新しい迂回 executor を増やすより、既存の privileged executor を狭く拡張する方が保守性も workflow 完走率も高いです。
P0 —
initializer → re-execを文字通り実装すると lifecycle lock が切れます#2197 で merged 済みの
run_control_plane_preflight_session()は remote binding と fixed worktree recovery を終えると結果を返し、その直後finallyで guard を release します。docstringにも actual child dispatch は #2199 と明記されています。さらに lock guard は owner PID と process-local token に束縛され、FD は
O_CLOEXECで開かれています。 Python では通常、新しく作った FD は non-inheritable で、exec 時に閉じられます。(Python documentation)したがって次の実装は不可です。
skill_runtime_exec → fixed initializer subprocess → initializer終了 → dedicated側へos.exec/re-execinitializer が終了した時点で mutex は消えます。
os.exec*で owner process 自体を置換する案も、現在の ownership token/O_CLOEXEC 設計とは整合しません。推奨構造は parent-controller 型です。
skill_runtime_exec.pyを生存させたまま、acquire guard → remote bind → recover worktree → identity verify → supervised child(cwd=dedicated) → post-child処理 → releaseとします。
run_control_plane_preflight_session()は、後方互換 wrapper を残しつつ内部に例えばcontrol_plane_preflight_context()という context manager を切るのが最も小さい変更です。TTL、lease、daemon、lock inheritance は不要です。P0 — #2199 と #2200 の境界が今は成立しません
current executor は child の終了後に、
_find_unauthorized_repo_changes(project_root, ...)と
_validate_stdout_artifact_projection(project_root, ...)を実行します。 artifact projection 自体も渡された
project_rootを root として相対パスを解決しています。つまり child だけ
.claude/worktrees/control-plane-preflightへ移すと、child が dedicated checkout を使うのに、parent の post-child validation は primary checkout を見る
状態になります。
#2200 を「あとで artifact confinement を追加するだけ」と考えるには、current main は進化しすぎています。
ここは #2199 で最低限
execution_rootを end-to-end で通し、既存の snapshot/write/artifact projection も dedicated root を見るところまで移すべきです。#2200 にはその上で「より強い artifact validation / confinement / release ordering」を残すのがよいです。P0 — bare
preflight.runの契約が Issue 作成時から変わっています#2311 によって bare
preflight.runだけはrun_refinement_preflight.py直呼びではなくworkflow_start_entry.pyが first hop になりました。さらに current executor は bare profile に限り、
LOOP_SPARK_MODELOOP_SPARK_FALLBACKLOOP_PLANNED_OPERATIONS_JSONを child へ transport しています。また最新 HEAD では
GH_CONFIG_DIRも command-id ごとに選択的に保持します。したがって dedicated migration のテストは単に「4 profile が dedicated cwd で起動した」では不足です。特に bare profile について、
existing outer executor → bootstrap → dedicated
workflow_start_entry.py→ capability preflight → inner preflightまで real subprocess で通し、これら invocation-scoped env が失われないことを確認する必要があります。
これは新しいハーネスを作る話ではなく、既存テストを migration parity test にするだけで十分です。
P1 — identity probe は
worktree_catalog.pyの既存 Git 呼び出しを流用しない方がよいですcurrent
worktree_catalog.pyはshutil.which("git")と通常のsubprocess.run()を使い、ambient environment をそのまま継承しています。一方 #2378 は remote/control-plane Git を「closed typed builder」として harden することを明示的に終えています。
#2199 の identity probe を
worktree_catalog.pyに実装する際、そこで新たに rawgit rev-parse ...を増やすのは設計上の逆戻りです。ここは、
worktree_catalog.py= parse/evaluate onlyGit execution = 既存 sanitized/closed Git layer
にしてください。
--show-toplevel、--absolute-git-dir、--git-common-dirは Git 自身が canonical path を提供する正しい probe です。(Git) ただしそれを呼ぶ executor は既存 seam を再利用すべきです。P1 —
locked/prunableは #2199 で回収すべきですcurrent catalog parser は
HEADとdetachedは読みますが、locked/prunableを捨てています。PR #2482 の adversarial review でも、existing worktree の locked/prunable 未確認は #2199 follow-up 候補として既に指摘されていました。
Git の
worktree list --porcelain -zは script 向けの安定した形式で、lockedとprunableも正式な属性です。またworktree add --lockは creation と lock を一体化できます。(Git)WORKTREE_CATALOG_ENTRY_V1の schema を広げる必要はありません。#2199 が要求している専用 identity probe の内部 result だけで、detached == truelocked == trueprunable == falseHEAD == accepted_oidcommon_dir == expectedexactly one catalog matchを確認すれば十分です。
P1 — outward command は変えない方がよいです
現在
.claude/settings.jsonは既存のskill_runtime_exec.py --command-id preflight.run ...と anchor profile の形を Bash allowlist に持っています。
ここを operator-facing に
worktree_bootstrap_exec.py --ensure-control-plane-preflight --jsonへ変更すると、Claude Code 側の permission / hook surface まで広がり、今回の目的である「primary branch を触らせない」こととは無関係な承認摩擦が増えます。
外向き argv は今のまま維持し、bootstrap は
skill_runtime_exec.pyの内部動作にするのを推奨します。これなら
.claude/settings.jsonを変更せずに済み、普段の Claude Code 操作も変わりません。P2 — workflow friction をさらに減らせます
Issue にある「
LOOP_DEFAULT_BRANCHoverride があれば fail-closed」は少し過剰です。#2197 が canonical remote HEAD からaccepted_oidを確定する現在の設計なら、LOOP_DEFAULT_BRANCHはauthority として無視すればよく、存在しただけで全処理を停止する必要はありません。重要なのは「その値で dedicated identity が変わらない」ことです。また primary checkout invariant 用の
git statusにはgit --no-optional-locks status ...を使うべきです。Git 自身も background/script 用途ではstatusの index refresh lock 競合を避けるためこれを推奨しています。(Git)--untracked-files=allは大きな worktree では遅くなるため、これは production 毎回ではなく invariant test/helper に限定するのが妥当です。(Git)推奨する #2199 の着地点
契約を次のように修正してから
impl-review-loopに渡すのがよいです。Goal は「既存
skill_runtime_exec.pyの外向き command shape を維持したまま、4 production preflight profile の child execution root だけを、#2197 が remote HEAD OID に bind した fixed dedicated worktree へ透過的に移す」とする。Execution model は
skill_runtime_execが長寿命 controller になり、control_plane_preflight_contextの中で mutex → remote binding → recovery → identity probe → supervised child → current post-child checks を一続きで実施する。os.exec*や lock FD inheritance は使わない。Identity は remote を再度
ls-remoteしないでください。#2197 が得たaccepted_oidと dedicated HEAD を比較すれば足ります。二度目の remote observation はネットワークコストと別の TOCTOU windowを増やすだけです。Profile parity は bare / anchor / human-context / agent-report の4本だけ dedicated にし、fixture profiles と
contract_update.*は変更しない。bare はworkflow_start_entry.py、残り3つは current first hop をそのまま維持する。Workflow priority として、新規 authorization token、ledger、lease、daemon、heartbeat、receipt は追加しない。既存の
flock、closed Git builders、child supervisor、env sanitizer を組み合わせれば足ります。この形なら #2199 はかなり価値があります。逆に 現行 Issue 本文の Allowed Paths と「fixed initializer → re-exec」の記述をそのまま実装すると、current main では高確率で途中停止か、primary/dedicated の二重 root 検証になります。 まず Issue contract の更新を推奨します。
## 結論Issue #2199 は、目的自体は妥当ですが、現状の契約のまま実装開始するのは
REFRAME_REQUIREDです。特に #2199 作成後に #2197、#2311、#2407 などが入り、production preflight の実経路が変わっています。レビューは 2026-09-04 07:19 JST 時点の current main HEAD
8283fb80c5132420d8279cf4e179394d6f358582を基準にしました。この HEAD 自体が barepreflight.runのGH_CONFIG_DIRtransport を修正した直後です。#2199 は現在 open で、Issue 自体にはコメントがありません。
私なら この Issue を一度 refinement してから実装します。主要 findings は以下です。
flockと「initializer → re-exec」の組合せでは lock が child execution まで保持されないpreflight.runが #2311/#2407 後の新しい first-hop/env contract を持つworktree_catalog.pyの既存 Git 実行方式で作ると sanitized Git seam を迂回するlocked/prunableの検証が不足LOOP_DEFAULT_BRANCHの存在だけで停止、通常のgit statusによる optional lock は不要な摩擦P0 — Allowed Paths が current main と矛盾しています
現在の production executor は
skill_runtime_exec.pyが command を受け取り、そこでcwd == canonical_main_rootとcurrent branch == default branchを直接強制しています。さらに registry を読み、child をcwd=project_rootで起動しています。つまり dedicated detached worktree 化するには、このファイルの変更がほぼ不可避です。しかし #2199 の Allowed Paths には
scripts/agent-guards/skill_runtime_exec.pyもscripts/agent-guards/skill_runtime_command_policy.pyも入っていません。一方 current policy は4 profileについて依然canonical_main_root/default_branchを契約にしています。したがって、「command_registry と guard 数本だけ変えて4 profileを dedicated worktree に移す」契約は現在成立しません。
推奨は Allowed Paths に少なくとも次を追加することです。
scripts/agent-guards/skill_runtime_exec.pyscripts/agent-guards/skill_runtime_command_policy.py新しい迂回 executor を増やすより、既存の privileged executor を狭く拡張する方が保守性も workflow 完走率も高いです。
P0 —
initializer → re-execを文字通り実装すると lifecycle lock が切れます#2197 で merged 済みの
run_control_plane_preflight_session()は remote binding と fixed worktree recovery を終えると結果を返し、その直後finallyで guard を release します。docstringにも actual child dispatch は #2199 と明記されています。さらに lock guard は owner PID と process-local token に束縛され、FD は
O_CLOEXECで開かれています。 Python では通常、新しく作った FD は non-inheritable で、exec 時に閉じられます。([Python documentation]1)したがって次の実装は不可です。
skill_runtime_exec → fixed initializer subprocess → initializer終了 → dedicated側へos.exec/re-execinitializer が終了した時点で mutex は消えます。
os.exec*で owner process 自体を置換する案も、現在の ownership token/O_CLOEXEC 設計とは整合しません。推奨構造は parent-controller 型です。
skill_runtime_exec.pyを生存させたまま、acquire guard → remote bind → recover worktree → identity verify → supervised child(cwd=dedicated) → post-child処理 → releaseとします。
run_control_plane_preflight_session()は、後方互換 wrapper を残しつつ内部に例えばcontrol_plane_preflight_context()という context manager を切るのが最も小さい変更です。TTL、lease、daemon、lock inheritance は不要です。P0 — #2199 と #2200 の境界が今は成立しません
current executor は child の終了後に、
_find_unauthorized_repo_changes(project_root, ...)と
_validate_stdout_artifact_projection(project_root, ...)を実行します。 artifact projection 自体も渡された
project_rootを root として相対パスを解決しています。つまり child だけ
.claude/worktrees/control-plane-preflightへ移すと、child が dedicated checkout を使うのに、parent の post-child validation は primary checkout を見る
状態になります。
#2200 を「あとで artifact confinement を追加するだけ」と考えるには、current main は進化しすぎています。
ここは #2199 で最低限
execution_rootを end-to-end で通し、既存の snapshot/write/artifact projection も dedicated root を見るところまで移すべきです。#2200 にはその上で「より強い artifact validation / confinement / release ordering」を残すのがよいです。P0 — bare
preflight.runの契約が Issue 作成時から変わっています#2311 によって bare
preflight.runだけはrun_refinement_preflight.py直呼びではなくworkflow_start_entry.pyが first hop になりました。さらに current executor は bare profile に限り、
LOOP_SPARK_MODELOOP_SPARK_FALLBACKLOOP_PLANNED_OPERATIONS_JSONを child へ transport しています。また最新 HEAD では
GH_CONFIG_DIRも command-id ごとに選択的に保持します。したがって dedicated migration のテストは単に「4 profile が dedicated cwd で起動した」では不足です。特に bare profile について、
existing outer executor → bootstrap → dedicated
workflow_start_entry.py→ capability preflight → inner preflightまで real subprocess で通し、これら invocation-scoped env が失われないことを確認する必要があります。
これは新しいハーネスを作る話ではなく、既存テストを migration parity test にするだけで十分です。
P1 — identity probe は
worktree_catalog.pyの既存 Git 呼び出しを流用しない方がよいですcurrent
worktree_catalog.pyはshutil.which("git")と通常のsubprocess.run()を使い、ambient environment をそのまま継承しています。一方 #2378 は remote/control-plane Git を「closed typed builder」として harden することを明示的に終えています。
#2199 の identity probe を
worktree_catalog.pyに実装する際、そこで新たに rawgit rev-parse ...を増やすのは設計上の逆戻りです。ここは、
worktree_catalog.py= parse/evaluate onlyGit execution = 既存 sanitized/closed Git layer
にしてください。
--show-toplevel、--absolute-git-dir、--git-common-dirは Git 自身が canonical path を提供する正しい probe です。(Git) ただしそれを呼ぶ executor は既存 seam を再利用すべきです。P1 —
locked/prunableは #2199 で回収すべきですcurrent catalog parser は
HEADとdetachedは読みますが、locked/prunableを捨てています。PR #2482 の adversarial review でも、existing worktree の locked/prunable 未確認は #2199 follow-up 候補として既に指摘されていました。
Git の
worktree list --porcelain -zは script 向けの安定した形式で、lockedとprunableも正式な属性です。またworktree add --lockは creation と lock を一体化できます。(Git)WORKTREE_CATALOG_ENTRY_V1の schema を広げる必要はありません。#2199 が要求している専用 identity probe の内部 result だけで、detached == truelocked == trueprunable == falseHEAD == accepted_oidcommon_dir == expectedexactly one catalog matchを確認すれば十分です。
P1 — outward command は変えない方がよいです
現在
.claude/settings.jsonは既存のskill_runtime_exec.py --command-id preflight.run ...と anchor profile の形を Bash allowlist に持っています。
ここを operator-facing に
worktree_bootstrap_exec.py --ensure-control-plane-preflight --jsonへ変更すると、Claude Code 側の permission / hook surface まで広がり、今回の目的である「primary branch を触らせない」こととは無関係な承認摩擦が増えます。
外向き argv は今のまま維持し、bootstrap は
skill_runtime_exec.pyの内部動作にするのを推奨します。これなら
.claude/settings.jsonを変更せずに済み、普段の Claude Code 操作も変わりません。P2 — workflow friction をさらに減らせます
Issue にある「
LOOP_DEFAULT_BRANCHoverride があれば fail-closed」は少し過剰です。#2197 が canonical remote HEAD からaccepted_oidを確定する現在の設計なら、LOOP_DEFAULT_BRANCHはauthority として無視すればよく、存在しただけで全処理を停止する必要はありません。重要なのは「その値で dedicated identity が変わらない」ことです。また primary checkout invariant 用の
git statusにはgit --no-optional-locks status ...を使うべきです。Git 自身も background/script 用途ではstatusの index refresh lock 競合を避けるためこれを推奨しています。(Git)--untracked-files=allは大きな worktree では遅くなるため、これは production 毎回ではなく invariant test/helper に限定するのが妥当です。([Git]4)推奨する #2199 の着地点
契約を次のように修正してから
impl-review-loopに渡すのがよいです。Goal は「既存
skill_runtime_exec.pyの外向き command shape を維持したまま、4 production preflight profile の child execution root だけを、#2197 が remote HEAD OID に bind した fixed dedicated worktree へ透過的に移す」とする。Execution model は
skill_runtime_execが長寿命 controller になり、control_plane_preflight_contextの中で mutex → remote binding → recovery → identity probe → supervised child → current post-child checks を一続きで実施する。os.exec*や lock FD inheritance は使わない。Identity は remote を再度
ls-remoteしないでください。#2197 が得たaccepted_oidと dedicated HEAD を比較すれば足ります。二度目の remote observation はネットワークコストと別の TOCTOU windowを増やすだけです。Profile parity は bare / anchor / human-context / agent-report の4本だけ dedicated にし、fixture profiles と
contract_update.*は変更しない。bare はworkflow_start_entry.py、残り3つは current first hop をそのまま維持する。Workflow priority として、新規 authorization token、ledger、lease、daemon、heartbeat、receipt は追加しない。既存の
flock、closed Git builders、child supervisor、env sanitizer を組み合わせれば足ります。この形なら #2199 はかなり価値があります。逆に 現行 Issue 本文の Allowed Paths と「fixed initializer → re-exec」の記述をそのまま実装すると、current main では高確率で途中停止か、primary/dedicated の二重 root 検証になります。 まず Issue contract の更新を推奨します。
squne121 commentedon Sep 4, 2026
推奨は、#2199 の実装にはまだ入らず、指定コメントを
operator-selected human contextとしてissue-refinement-loopで Issue 契約を in-place reframe することです。指定レビューは、現行契約のinitializer → re-exec、Allowed Paths、#2200 との責務境界、barepreflight.runの first-hop/env parity が current main と合わないためREFRAME_REQUIREDとしています。特に refinement 後の設計は、外向きの
skill_runtime_exec.py --command-id ...を維持しつつ、skill_runtime_exec自身を長寿命 controller にして lock 保持中に dedicated worktree で child と既存 post-child checks を完結させる形が妥当です。#2197/PR #2482 の remote-binding・fixed-worktree・process-scoped lock は既に前提として使えます。 #2200 はまだ古い Child 4 境界を前提としているため、今回は #2199 だけを書き換え、#2200 自体の更新は別 refinement に分けるのを勧めます。また、現行
issue-refinement-loop自体は iteration ごとの人間承認を既定で要求しません。これは Claude Code の permission mode とは別概念なので、Auto modeを使いつつbypassPermissionsや dangerous skip に広げる必要はありません。 なお approved 後の root transition は条件が揃うと同一 turn 内でimpl-review-loopStep 1 を直接起動し得るため、今回のプロンプトでは refinement-only を明示して実装開始前で止めるようにしています。そのまま対話的 Claude Code の Auto mode に渡すなら、以下を推奨します。
squne121/loop-protocolの Issue #2199 に対して、issue-refinement-loopを実行してください。対象:
squne121/loop-protocol#2199https://github.com/squne121/loop-protocol/issues/2199#issuecomment-5532985403目的
Issue #2199 の現行契約を current main の実装事実と指定 anchor comment に合わせて in-place reframe し、
issue-refinement-loopの final review と contract readiness が通るところまで、人間の途中承認を要求せず自律的に完走してください。今回はコード実装、実装用 worktree 作成、実装ブランチ作成、PR 作成、
impl-review-loopの開始は行わないでください。refinement が
implementation_readyまで到達したらそこで停止し、実装可能になったことだけを最終報告してください。最重要の実行方針
.claude/skills/issue-refinement-loop/SKILL.mdと、その canonical references / planner / command registry / controlled executor を正本として実行してください。独自の簡略フローを作らず、repository-defined
issue-refinement-loopを実際に使用してください。loop iteration の継続について人間へ確認しないでください。
needs-fixかつ iteration 上限未満なら自動的に次 iteration へ進むこれは repository loop の approval gate を不要にする指示であって、Claude Code の permission model を無効化する指示ではありません。
以下は禁止します。
--dangerously-skip-permissionsbypassPermissionsBash(*)uv/ Python /ghの新規 blanket allowAuto mode と既存の narrow
PermissionRequest/ controlled transaction surface をそのまま利用してください。Anchor の扱い
指定コメントを、今回 operator が明示的に選択した
human_contextとして扱ってください。つまり origin を自動推定せず、canonical な
preflight.run.with_human_contextlane 相当の operator-selected human context として処理してください。anchor comment の内容をそのまま正しいと仮定せず、current main、関連 Issue/PR、テスト、実装を調査して各 claim を fact-check してください。
anchor は freeform comment なので、構造化
ANCHOR_SCOPE_REFRAME_V1を人間に書き直させないでください。scope expansion に exact path の導出が追加で必要なら、repository-defined read-only investigation lane を使用してください。SubAgent の使用
SubAgent を積極的に使用してください。
ただし canonical skill の ownership boundary を守ってください。
必須
Step 1 investigation では
codebase-investigatorSubAgent を起動してください。少なくとも以下を current main で確認させてください。
scripts/agent-guards/skill_runtime_exec.pyのscripts/agent-guards/skill_runtime_command_policy.pyの4 production preflight profileの current policyscripts/agent-ops/worktree_bootstrap_exec.pyのrun_control_plane_preflight_session()O_CLOEXECscripts/agent-ops/worktree_catalog.pyの current Git execution seam と catalog parsing実装: #2197向け remote protocol Git builderを閉鎖型に hardenする #2378 / 実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197 / PR feat(#2197): control-plane remote default-ref observe/fetch/pin/verify プロトコル #2482 の closed/sanitized Git builder 契約
実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311 後の bare
preflight.runfirst hopfix: preserve GH_CONFIG_DIR for bare preflight.run #2407 後の environment transport
.claude/settings.jsonと current outward command allow surface実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 が現在所有すると記述している artifact/confinement scope
current tests の中で 実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 の migration parity test として再利用・拡張すべき exact files
SubAgent を dispatch したら、その SubAgent の作業完了を必ず待ってください。
結果を受け取らないまま次 phase、Issue mutation、review、termination へ進まないでください。
SubAgent が追加 SubAgent を起動する nested delegation は行わせないでください。必要な追加 investigation は root orchestrator から別の top-level SubAgent として dispatch してください。
Web research
planner / investigation が disposition に影響する external claim を検出した場合のみ
web-researcherSubAgent を起動してください。特に Git / Python の runtime semantics を current repository evidence だけで確定できない場合は公式一次資料を確認してください。
例:
locked/prunablegit --no-optional-locks statusO_CLOEXECこの SubAgentについても、作業完了を待ってから review に進んでください。
Review
canonical Step 2 は repository の current
run_root_review_pipeline.py produceを root/main thread から実行してください。canonical Step 2 の代わりに
issue-reviewerSubAgent を新規起動しないでください。Rewrite
rewrite が必要と判定された場合は canonical
issue-editorSubAgent を使用してください。issue-editorを dispatch した後は、完了結果を受け取るまで必ず待ってください。その後 live Issue body を再取得して mutation/readback を確認してから次 review に進んでください。
#2199 で再検討すべき設計
以下は anchor comment の有力な proposed disposition です。
ただし blindly copy せず、current main の fact-check 結果と整合する形で Issue 契約へ反映してください。
1. Goal
旧 Goal の
fixed initializer -> dedicated executor re-execを主軸にしないでください。
新しい Goal は概ね次の性質にしてください。
skill_runtime_exec.py --command-id preflight.run...を維持する
実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197 が canonical remote default-ref OID に bind した fixed dedicated worktree へ透過的に移す
2. Execution model
skill_runtime_exec.pyを long-lived parent controller としてください。概念上は次の lifetime を一続きにしてください。
acquire lifecycle guard→
remote binding→
fixed worktree recover/create→
dedicated identity verification→
supervised child(cwd=dedicated execution_root)→
existing post-child checks against the same execution_root→
release lifecycle guardinitializer subprocess が終了してから re-execや
os.exec* に lock FD を継承させる設計へ寄せないでください。
既存
run_control_plane_preflight_session()との互換性を保ちながら、必要なら内部 primitive を context-manager 化する案を評価してください。新規 TTL / lease / daemon / heartbeat / stale takeover / persistent lock broker は追加しないでください。
3. execution_root の end-to-end 整合
child の cwd だけ dedicated worktree に変えて、parent の post-child validation が primary checkout を見る設計を禁止してください。
#2199 の契約では少なくとも、current executor が既に持つ以下の処理が同じ
execution_rootを見ることを要求してください。ただし #2200 の本来の責務を丸ごと #2199 に吸収しないでください。
#2200 には、#2199 が coherent execution root を確立した上での
より強い artifact confinement、bounded cleanup、artifact handoff validation、final release ordering
を残してください。
今回の invocation では Issue #2200 本文を更新しないでください。
#2199 refinement 完了後、#2200 も current #2199 boundary に合わせて別途 refinement が必要なら最終報告に明記してください。
4. Allowed Paths
現行 #2199 の Allowed Paths をそのまま維持する前提にしないでください。
current main を調査して、4 production profile の実 migration に必要な exact paths を導出してください。
少なくとも次の2ファイルが本当に必要かを確認し、必要なら Allowed Paths に追加してください。
scripts/agent-guards/skill_runtime_exec.pyscripts/agent-guards/skill_runtime_command_policy.pyさらに、それらの current behavior を直接検証する既存 focused test files を exact path で追加してください。
テスト用だからという理由で
tests/**のように無制限に広げず、current repository organization に沿った最小限の exact paths / narrow directory scope にしてください。既存の Allowed Paths で不要になったファイルがあれば、それも current design に合わせて整理してください。
5. Identity probe
WORKTREE_CATALOG_ENTRY_V1の schema は変更しない方向を優先してください。dedicated identity の runtime verification では少なくとも次を確認する契約を検討してください。
locked == trueprunable == falseaccepted_oidGit execution は #2378/#2197 の既存 closed/sanitized Git execution seam を再利用してください。
worktree_catalog.py内で新しい ambientsubprocess.run(["git", ...])authority を増やす案は避け、catalog parsing/evaluation と Git execution authority を分離してください。また remote identity を確認するために二回目の
ls-remoteを追加しないでください。#2197 で accepted された OID と dedicated HEAD の比較を基本にし、不要なネットワーク cost / TOCTOU window を増やさないでください。
6. Production profile parity
dedicated migration の対象は4 production profilesに限定してください。
preflight.runpreflight.run.with_anchorpreflight.run.with_human_contextpreflight.run.with_agent_reportfixture profiles と
contract_update.*を勝手に dedicated 化しないでください。current first-hop semantics を保存してください。
特に bare
preflight.runについては、current main でworkflow_start_entry.pyが first hop になっている事実を保持してください。migration verification では bare profile について少なくとも実 process chain:
existing outer skill_runtime_exec→ control-plane bootstrap/context
→ dedicated
workflow_start_entry.py→ capability preflight
→ inner refinement preflight
を通す parity test を検討してください。
また current command-scoped environment transport を壊さないことを AC/Verification に明記してください。
特に確認対象:
LOOP_SPARK_MODELOOP_SPARK_FALLBACKLOOP_PLANNED_OPERATIONS_JSONGH_CONFIG_DIRその他の環境変数を便乗して global pass-through に広げないでください。
7. outward command / permission friction
operator-facing command を新しい bootstrap initializer argv に置き換えないでください。
既存の outward
skill_runtime_exec.py --command-id ...surface を維持し、bootstrap を executor の内部 lifecycle として扱う案を優先してください。.claude/settings.jsonの broad allowlist 拡張や、新しい generic permission surface を #2199 の成立条件にしないでください。8.
LOOP_DEFAULT_BRANCHambient
LOOP_DEFAULT_BRANCHの存在そのものだけを理由に処理全体を失敗させる必要が本当にあるか current authority model から再評価してください。canonical remote HEAD / accepted OID が authority なら、ambient override は authority として無視し、それによって dedicated identity が変化しないことを検証する方を優先してください。
9. primary snapshot
primary checkout invariant を検証するときは、production workflow に不要な index lock friction を持ち込まない設計を評価してください。
current Git semantics と repository helper を確認し、必要なら
--no-optional-locks相当を fixture/invariant helper に使用してください。高コストな full untracked scan を毎 production invocation の必須処理へ安易に追加しないでください。
Acceptance Criteria の再構成
旧 AC を文言修正するだけではなく、current architecture に合わせて再構成してください。
最低限、以下が検証可能な AC として表現されるようにしてください。
workflow_start_entry.pyfirst-hop parityWORKTREE_CATALOG_ENTRY_V1schema を不用意に変更しないAC と Verification Command は一対一で説明可能にしてください。
既存テストを再利用できる場合は新しい巨大 harness を作らず、focused test / migration parity test を優先してください。
Scope / workflow の品質優先順位
個人趣味開発として、workflow 完走率と有用性を優先してください。
必要以上の新規 infrastructure は作らないでください。
特に以下は strong evidence が無い限り追加しないでください。
既存
flock、closed Git builders、child supervisor、env sanitizer、controlled Issue editor を組み合わせて最小実装可能な契約にしてください。Mutation 手順
anchor fact-check と canonical review が rewrite を要求した場合、人間へ「この変更を適用してよいか」と質問しないでください。
repository-defined canonical routing に従って自動適用してください。
trusted human-context preflight が contract patch plan を返す場合は canonical
contract_update.run.with_human_contextlane を使用してください。patch plan だけでは full reframe を表現できず
NEXT_ACTION: issue_editor_requiredになる場合は、canonicalissue-editorrewrite lane に自動的に進んでください。raw
gh issue editを独自に組み立てて controlled transaction を迂回しないでください。各 mutation 後は必ず:
過去 revision の approve / readiness を再利用しないでください。
停止条件
通常の iteration continuation や known deterministic rewrite を人間承認待ちの停止条件にしないでください。
以下の場合のみ fail-closed / escalation してください。
停止時も「続けますか?」という確認質問はしないでください。
停止理由、実行済み evidence、未完了点を最終報告してください。
refinement-only の終端
この invocation では Issue refinement だけを行います。
Issue #2199 が
CONTRACT_REVIEW_RESULT_V1.status == goとなった場合、
implementation_readyとして refinement を終了してください。repository-defined termination comment /
LOOP_HANDOFF_RESULT_V1telemetry の publication が issue-refinement-loop の通常終了処理として必要なら実行して構いません。ただし、その後の root implementation transition は実行しないでください。
特に以下は今回実行しないでください。
root_entry_router.run_root_transition()からのinvoke_impl_review_loopimpl-review-loopStep 1これは repository workflow 自体を書き換える要求ではなく、今回の operator invocation の作業範囲を refinement-only に制限する指示です。
最終報告
完了時は簡潔に以下を報告してください。
implementation_ready: yes/no途中経過の確認を人間へ求めず、上記停止条件に当たらない限り自律的に最後まで進めてください。
このプロンプトでは、承認不要の refinement と Claude Code の権限バイパスを明確に分離し、さらに refinement が成功した瞬間に自動で実装へ流れるのを抑えています。#2199 が
implementation_readyになった後は、その最終本文を入力にして別セッションでimpl-review-loopを走らせるのが境界として最も扱いやすいです。squne121 commentedon Sep 4, 2026
issue-refinement-loop 終了報告
termination_cause:
approved(refinement-only invocation。実装フェーズへの遷移は本 invocation では行わない)skill_runtime_exec.py/skill_runtime_command_policy.py欠落)は current main の実装事実と乖離していることを確認し、Issue 本文を in-place で reframe した(3 rewrite iteration)。path::test_namenode-id 形式に修正。canonical Step 2 review は VC の pytest exit code 不整合(exit 5 non-canonical)で needs-fix。existing_file_missing_node_id_noncanonical回避)。canonical Step 2 review は approve。issue-design-reviewer): medium 1件・low 1件の非ブロッキング finding(route_high_open_to_rewriteポリシー下では rewrite 対象外)。join_review_results.pyのeffective_verdict: approve。未解決の non-blocking 観察事項(Step 2.5 semantic finding、owner 判断待ち・rewrite は trigger しない):
skill_runtime_exec.pyに無いことを確認。実装時は新しい operation kind の追加(seam の拡張)を要する。#2200 について: 現状の #2200 本文は「Child 4(#2199)が identity probe・command class 分離・4 production profile 移行を実装済み」という旧 #2199 の枠組みを前提として書かれている。本 refinement で #2199 の Execution model(command class 分離ではなく、長寿命 parent controller + guard 保持範囲拡張)が変わったため、#2200 も #2199 の新しい境界に合わせた別途 refinement が必要。本 invocation では #2200 本文は変更していない。
implementation_ready: yes— このセッションでは実装(コード編集・worktree 作成・PR 作成・impl-review-loop 起動)は一切行っていない。squne121 commentedon Sep 4, 2026
#2199 はすでに refinement を完了しており、終了コメントも
implementation_ready: yesです。Issue 本文も、旧initializer → re-exec案ではなく、skill_runtime_exec.pyを長寿命 parent controller として guard を child/post-child checks まで保持する契約へ更新されています。したがって推奨アクションは、再 refinement せず、その live Issue を入力に
impl-review-loopを開始することです。特に実装時の要注意点は、refinement で残った medium finding――locked/prunableの identity probe に必要な closed/sanitized Git operation がまだ存在しないため、generic Git executor を増やさず既存 seam を狭く拡張すること――です。また現行
impl-review-loopは、implementation-worker → test-runner → pr-reviewerを SubAgent に委譲し、APPROVEだけでなく live mergeability がCLEAN/HAS_HOOKS、かつ blocker が空になるまで回して、最終的にdraft_pr_readyで止まる設計です。つまり「マージはしないがマージ直前まで」は既存終了契約と合っています。Claude Code の Auto mode は routine permission prompt を classifier に代替しますが、force push・破壊的操作などは引き続き止めます。
bypassPermissionsに変える必要はありません。CLI ならclaude --permission-mode autoで開始できます。([Claude]1) SubAgent は独立コンテキストで実行され、親セッションの permission を継承するため、下のプロンプトでは「起動したら completion を待つ」を明示しています。([Claude]2)以下をそのまま Auto mode の対話的 Claude Code に貼るのがよいです。
Repository: squne121/loop-protocol
Target Issue: #2199
このセッションでは、Issue #2199 を repository-defined
impl-review-loopで実装し、実装・検証・PRレビュー・レビュー修正を自律的に反復して、人間が merge を実行する直前の状態まで進めてください。Claude Code は Auto mode で動作している前提です。
通常のファイル編集、テスト、commit、push、PR作成、PR body更新、レビュー対応、CI確認、branch update について、途中の人間承認を求めないでください。
ただし
bypassPermissions/--dangerously-skip-permissionsへの切り替えは行わず、Claude Code Auto mode、repository hooks、permission rules、Issue #2199 の Stop Conditions はそのまま尊重してください。最終目標
以下を満たすまで
impl-review-loopを継続してください。pr-reviewerの current-head verdict がAPPROVEimpl-review-loopの approved 条件を満たすIMPL_REVIEW_LOOP_RESULT_V1.status == draft_pr_ready相当まで到達PR の merge 自体は絶対に実行しないでください。
auto-merge の enable も不要です。
merge-ready になった時点で停止し、人間に最終状態だけ報告してください。
正本
最初に必ず以下を live repository から読み直してください。
.claude/skills/impl-review-loop/SKILL.mdimpl-review-loop/steps/の canonical procedure.claude/skills/implement-issue/SKILL.mddocs/dev/workflow.mddocs/dev/agent-skill-boundaries.mddocs/dev/current-focus.md過去の会話やこのプロンプト中の要約より、live Issue と current repository HEAD を優先してください。
Issue #2199 は refinement 済みなので、fresh live contract が implementation-ready である限り、通常は issue-refinement-loop に戻らず implementation を開始してください。
開始前に、Issue #2199 を直接実装する既存 open PR / branch / worktree がないか確認してください。
存在する場合は repository-defined resume/reuse 契約に従い、重複PRを作らないでください。
impl-review-loop の実行
独自の簡易ループを作らず、repository-defined
.claude/skills/impl-review-loopを実際に使用してください。max_iterationsは 8 を使用してください。通常の reviewer fix iteration ごとに人間へ継続確認を求めないでください。
root/main thread は orchestration と routing を担当し、repository が定義する SubAgent に実作業を委譲してください。
SubAgent completion の必須条件
SubAgent を fire-and-forget にしてはいけません。
各委譲について必ず、
という順序を守ってください。
「SubAgent を起動した」という事実だけを完了証拠にしてはいけません。
repository-defined Common Completion Protocol がある場合は必ず使用してください。
Step 1 — Implementation
implementation-workerSubAgent を repository-defined call shape で起動し、implement-issueskill に Issue #2199 の実装を委譲してください。implementation-worker の完了を必ず待ってください。
初回は live Issue #2199 の全 contract / Allowed Paths を渡してください。
REQUEST_CHANGES 後は、reviewer blockers を canonical
fix_deltaとして渡し、スコープを拡大せず修正してください。implementation-worker 自身が実装を完了する前に root/main thread が代わりにコード編集を始めないでください。
Step 2 — Verification
implementation-worker の terminal result を受領した後、repository-defined
test-runnerSubAgent に current PR head の独立検証を委譲してください。test-runner の完了を必ず待ってください。
Issue #2199 の Verification Commands を literal contract として扱ってください。
少なくとも Issue に現在定義されている以下の領域を current head で実証してください。
preflight.runfirst-hop paritySKIP、fallback success、stale head の結果を PASS に読み替えないでください。
Step 2 の canonical adjudication が blocking なら、人間へ質問せず repository-defined route で Step 1 の fix iteration に戻してください。
Step 4 — PR Review
current-head verification gate が通った場合のみ、
pr-reviewerSubAgent を起動してください。pr-reviewer の完了を必ず待ってください。
実装を行った agent と reviewer の役割を混同せず、独立した adversarial review としてください。
reviewer には必ず current PR head SHA を materialize して渡してください。
review 中に PR head または Issue body が変化した場合は stale verdict を採用せず、repository-defined current-head gate に従って verification/review を再取得してください。
REQUEST_CHANGESの場合は blockers をそのまま放置せず、canonical fix_delta に変換して implementation-worker に戻し、implementation-worker completion
→ test-runner completion
→ pr-reviewer completion
の順に再度回してください。
#2199 固有の技術方針
live Issue contract が変更されていないことを確認した上で、以下を重要な実装方向として扱ってください。
1. parent-controller 型を維持する
skill_runtime_exec.pyを長寿命 controller として維持し、acquire lifecycle guard
→ remote binding
→ fixed worktree recover/create
→ dedicated identity verification
→ supervised child(cwd=dedicated execution_root)
→ existing post-child checks against the same execution_root
→ lifecycle guard release
を一続きの lifetime にしてください。
initializer subprocess → 終了 → re-execのように guard lifetime が切れる構造へ戻さないでください。lock FD inheritance、TTL、lease、daemon、heartbeat、persistent lock broker 等を新設して問題を迂回しないでください。
2. dedicated identity probe
Issue の identity requirements を満たしてください。
特に、
を実証してください。
現在の closed/sanitized Git seam に
locked/prunable等を取得する十分な operation が無ければ、generic raw argv executor や ambientsubprocess.run(["git", ...])を追加せず、既存 closed/sanitized seam に必要最小限の typed operation を追加してください。WORKTREE_CATALOG_ENTRY_V1の field schema を拡張して解決しないでください。3. remote authority を増やさない
dedicated identity 検証には #2197 から得た
accepted_oidを再利用してください。identity verification のためだけに二度目の
ls-remote等の remote observation を追加しないでください。ambient
LOOP_DEFAULT_BRANCHは authority として使用しないでください。4. outward contract を維持する
既存の operator-facing
skill_runtime_exec.py --command-id preflight.run ...形状と command registry の outward argv を維持してください。
新しい operator-facing initializer command を導入しないでください。
.claude/settings.jsonの broad allowlist を広げて解決しないでください。5. profile parity
dedicated execution root への移行対象は live Issue に記載された 4 production profile に限定してください。
preflight.runpreflight.run.with_anchorpreflight.run.with_human_contextpreflight.run.with_agent_reportfixture profiles と
contract_update.*は primary root のまま維持してください。bare
preflight.runはworkflow_start_entry.pyfirst-hop と、LOOP_SPARK_MODELOOP_SPARK_FALLBACKLOOP_PLANNED_OPERATIONS_JSONGH_CONFIG_DIRtransport parity を維持してください。
6. execution_root の end-to-end consistency
child だけを dedicated root へ移して、post-child validation が primary root を見る状態を作らないでください。
snapshot、unauthorized write detection、stdout/artifact projection path validation を含む既存 post-child checks は、4 production profile では child と同じ dedicated
execution_rootを使用してください。fixture /
contract_update.*では primary root を維持してください。7. primary checkout invariant
bootstrap、child、post-child validation の success / failure paths 全てで primary checkout が byte-identical であることを fixture ベースで実証してください。
invariant probe による不要な index lock friction を避けるため、live Issue の
--no-optional-locks方針を守ってください。production invocation 毎に高コストな full untracked scan を追加しないでください。
Allowed Paths
live Issue の Allowed Paths が絶対的な境界です。
開始時に Issue 本文から Allowed Paths を再取得してください。
このプロンプトに記載されたパス一覧と live Issue が異なる場合は live Issue を優先してください。
Allowed Paths 外への変更が必要になった場合は勝手に広げないでください。
Issue-defined Stop Condition として処理してください。
自律継続ポリシー
以下は人間承認を要求せず、自動で続行してください。
単に「念のため確認したい」「変更が大きい」「レビューをもう一度回してよいか」といった理由では停止しないでください。
停止条件
このプロンプト独自の広い停止条件を追加しないでください。
まず Issue #2199 と impl-review-loop が定義する formal Stop Conditions / termination routing を優先してください。
加えて以下だけは実行せず停止してください。
permission classifier に止められた場合、その安全境界を無効化するために bypass mode へ切り替えないでください。
#2200
#2200 はこの Issue の実装スコープに混ぜないでください。
#2199 refinement 終了時点で #2200 は新しい #2199 execution model に合わせた別 refinement が必要と判定されています。
#2199 の AC 達成に不要な #2200 の本文変更・実装・スコープ取り込みを行わないでください。
最終報告
impl-review-loopが approved / draft_pr_ready に到達した時だけ通常完了としてください。最終報告には簡潔に以下を含めてください。
draft_pr_ready: yes/nodraft_pr_ready: yesならそこで停止してください。人間への依頼は「PRを確認して merge 判断してください」だけで構いません。
max_iterations: 8にしたのは、#2199 のような統合フェーズで reviewer fix が3回を超えただけで人間へ戻るのを避けるためです。一方、Issue 自体の Stop Conditions やimplementation-workerの hard-stop 契約までは上書きしない構成にしています。squne121 commentedon Sep 4, 2026
implement-issue: 実装完了(一部・main() 配線は未完了として報告)
.claude/worktrees/issue-2199-dedicated-worktree-preflightworktree-issue-2199-dedicated-worktree-preflighttests/agent_ops/test_control_plane_worktree_bootstrap.pyの 12 AC marker は全て PASS(22 tests)。gemini-cli-headless-delegation model-routing pytest も PASS(24 tests)。実装内容
worktree_catalog.py: 既存WORKTREE_CATALOG_ENTRY_V1スキーマを変更せず、locked/prunableを含む別スキーマ(WORKTREE_IDENTITY_PROBE_ENTRY_V1)用パーサーparse_worktree_porcelain_locked_prunable_z()を追加。skill_runtime_exec.py: closed/sanitized Git execution seam にlist_worktrees_porcelain_locked_prunabletyped operation(--no-optional-locks付き)を追加。primary checkout の軽量不変性証明用capture_primary_checkout_invariant_snapshot()とPRODUCTION_DEDICATED_WORKTREE_COMMAND_IDS定数を追加。worktree_bootstrap_exec.py: lifecycle guard を子プロセス dispatch + post-child checks まで保持するcontrol_plane_dedicated_execution_session()と、fail-closed のverify_dedicated_control_plane_identity()(catalog 一意性・detached・locked・not-prunable・accepted_oid 一致・git-common-dir linkage・invocation cwd/script/execution_root 同一性)を追加。未完了として報告する点(実装中に発見した架構的な衝突)
skill_runtime_exec.py::main()の実 child dispatch を dedicated worktree(execution_root)へ切り替える配線を実際に組み込んで検証したところ、本 Issue の Allowed Paths 外にある複数の既存 real-subprocess テストが壊れることを実測で確認した(fixture がworktree_bootstrap_exec.pyを同梱せず、実 GitHub remoteCONTROL_PLANE_CANONICAL_REMOTE_URLへの到達を新たに要求するようになるため)。具体的には.claude/skills/issue-refinement-loop/scripts/tests/test_workflow_start_entry_canonical_executor.py(3 tests)・scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py(4 tests)で新規 FAIL を確認し、配線を戻すと 23/23 PASS に復帰することをgit stash比較で確認済み。これは Issue 本文の Stop Conditions「本 child issue の Allowed Paths 外への波及が必要と判明した場合」「外部サービス利用・既存テスト大規模改変が必要になった場合」に該当すると判断し、
main()自体の配線は本 PR に含めていない。PRODUCTION_DEDICATED_WORKTREE_COMMAND_IDSはmain()から未参照のまま公開し、新規テストは primitive を直接(dedicated 実行境界をmain()を介さず)検証する形にとどめた。AC4/AC5/AC6/AC9 は「main()に配線されれば成立する mechanism」を証明しているのであって、main()の実挙動そのものは未証明(PR 本文・各テスト docstring に明記)。main()の実配線完了には、Allowed Paths 外にある既存テスト群の fixture 更新、または段階的ロールアウト機構の設計が必要と判断する。Issue contract の改訂または follow-up Issue でのスコープ分割を推奨する。11 remaining items
squne121 commentedon Sep 5, 2026
Owner Decision: option 2。repository-required CI が exercise する #2199 production-preflight real-subprocess fixture の影響面を先に一括棚卸しする。その結果が bounded test/fixture parity update に収まり、#2200 や production architecture redesign を必要としない場合、判明した exact affected files 全体を一度の consolidated Scope Delta として #2199 に追加し、そのまま impl-review-loop を merge 直前まで再開することを承認する。
fix: round-3 Scope Delta 2ファイルを production dedicated dispatch契約へ更新 (#…
fix: fixed-delay peer-write race を go-file/ack-fileバリアへ置換 (#2199)
fix: AC6(env_transport_parity)の孤立sanitize_env呼び出し+vacuous assertionを実…
fix: nested pytest-cache-files temp dir拒否テストのfixed-delayレース除去 (#2199)
fix: dedicated worktree preflight のuv環境誤検知・artifact受け渡し・invariant過大主張…
fix: decide.run fixtureにpinned uv pyproject.tomlを追加しCI RED原因を解消 (#2199)
fix: managed-uv-projectフィクスチャを依存ゼロ化しCI required job network分離違反を解消 (#…
feat: control-plane preflight に dedicated-lane identity probe primiti…
squne121 commentedon Sep 5, 2026
結論
実装方針は採用でよいです。コードを巻き戻す理由はありません。
ただし、Issue #2199 を現在の本文のまま completed として閉じるのは反対です。判定を分けると、
実装: ACCEPT
Issue contract / closure evidence: REQUEST_CHANGES
です。
初期レビューで問題だった「primitive だけ作って
main()が実際には dedicated worktree を使わない」「initializer→re-exec で lock が切れる」「post-child check が primary を見る」といった大穴は、PR #2495 の反復実装でほぼ解消されています。PR は 2026-09-05 にマージ済みで、最終的に 17 files / +3963 / -362 まで膨らんでいます。一方、#2199 自体は現在も open で、最終更新は 2026-09-05 03:44 UTC。その後に入った OWNER feedback 対応が Issue contract に反映されていません。
敵対的に見ると、残っている問題は以下です。
P0 — 最終実装が live Issue の Allowed Paths / AC7 を破っています。これはコード不良ではなく closure contract 不良です。 最終 PR は
.claude/skills/issue-refinement-loop/scripts/command_registry.pyに--investigation-evidence-primary-rootを追加し、さらにrun_refinement_preflight.pyに primary-root を受け取って evidence path を解決する実装を追加しています。 現在のcommand_registry.pyにもこの child argv が残っています。 ところが live 実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 はこの2ファイルを現在の Allowed Paths に含めず、AC7 は「registry argv / required_cwd を変更しない」前提です。さらに PR 本文側も 「AC7:command_registry.pyREGISTRY argv 未変更、VC PASS」 としたままで、最終 merged diff と自己矛盾しています。 ここでコードを戻すのは悪手です。P1-3 の修正そのものは必要でした。Issue に final Scope Delta を追記して2ファイルを追加し、AC7 を「operator-facingskill_runtime_exec.py --command-id ...の外向き command shape は不変。ただし dedicated child 内部 transport は bounded に拡張可」に修正するのが最小かつ正しい処理です。P1 — primary invariant が「証明」ではなく、production workflow を止める無帰属 watchdog になっています。 現在の
capture_primary_checkout_invariant_snapshot()は自分自身の docstring で、primary の変化を dedicated child に帰属できず、同時に動いた別プロセスによる変更でも無条件停止すると明記しています。そのうえgit status --porcelain=v1 --untracked-files=all -zを使い、既に dirty な tracked file は SHA-256 まで取ります。 実際に production dedicated dispatch の前後で2回比較し、差があれば停止します。 Git 自身も untracked enumeration は大きな worktree では非常に遅くなり得ると明記しています。一方--no-optional-locksの採用自体は background/script 用途として正しいです。([Git]1) 個人開発・並列 Claude/Codex/herdr を重視するなら、ここは過剰防御寄りです。おすすめは exhaustive な--untracked-files=allbyte-identical proof を focused integration test に降ろし、production は HEAD/ref + tracked state 程度の軽量 guard にすることです。少なくとも実リポジトリで時間を測り、コストが無視できるなら「毎回 full untracked enumeration しない」という Issue の記述側を削除すべきです。現状は仕様と実装が両方正しいとは言えません。P1 — 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 の責務境界が feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495 後の世界に追従していません。 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 は依然として artifact confinement、handoff、cleanup、lock release ordering、実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 全ACの最終検証を所有する open Issue です。 しかし 実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 は OWNER P1-2 対応で既に「dedicated worktree 内の preflight artifact を既存 repair consumer が読める」ための path contract に踏み込んでいます。current main には実際に
dedicated preflight → needs_fix → real repair consumerの E2E test まであります。 したがって 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 実装時に昔の設計をそのまま読むと、artifact のコピー・移送・cleanup を重複実装する危険があります。実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 は「producer/consumer の transport を再設計しない。既存 path contract を保持したまま confinement / bounded cleanup / release ordering だけを追加する」と再 refinement すべきです。 特に cleanup 導入後もpreflight → needs_fix → repair_action.apply が artifact を読めることを non-regression AC に入れるべきです。P2 — managed uv 対応は正しいが、毎回
uv sync --locked→uv runは二重確認になっています。.venvが dedicated checkout 内に生成されて unauthorized write になる問題を、worktree 外の固定UV_PROJECT_ENVIRONMENTに逃がした設計は良いです。専用 venv は worktree 再作成を跨いで再利用されます。 uv も absoluteUV_PROJECT_ENVIRONMENTを正式にサポートしています。([Astral Docs]2) ただし preparation で明示的にuv sync --lockedを行った直後、registry の child は通常のuv run python3 ...なので、uv は再び lock/environment が最新か検査します。 uv はuv run前に自動同期し、--no-sync/UV_NO_SYNC=1でそれを止められます。([Astral Docs]3) これは blocker ではありません。実測して意味のある遅延なら、preparation 成功後の dedicated child だけUV_NO_SYNC=1にする程度で十分です。新しい environment manager や cache ledger は不要です。P2 — ハーネスが目的物に対して重くなり始めています。 feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495 が約4k行追加まで膨らんだ主因のかなりの部分は、production dedicated dispatch 化によって既存の real-subprocess fixture が次々壊れ、それを追従させたこと、さらに fixed-delay race を deterministic barrier に差し替えたことです。最終的に CI green まで持っていった点は評価できますが、これは同時に「runtime topology の変更1件が大量の擬似リポジトリ fixture を連鎖修正する」という保守コストのシグナルです。 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 以降は profile ごとの巨大 fixture matrix を増やさず、production chain E2E を1~2本、残りは focused unit/integration test に寄せる方が、趣味開発としての価値密度は高いです。
戻さない方がよい部分
dedicated worktree の基本構造は現在かなり良くなっています。
detached + locked + !prunable + accepted_oid + common-dir + catalog uniquenessを検証する方針は Git の正式な worktree model と一致しています。Git はworktree list --porcelain -zを安定した script 向け形式として提供し、locked/prunableも正式な属性です。またworktree add --lockは add→lock 間の race を避けるための機能です。([Git]4)また、
skill_runtime_exec.pyを生存する parent-controller にして lock を保持したまま dedicated child を supervise する構造も維持すべきです。Python の FD はデフォルト non-inheritable で exec 時には閉じるため、以前案にあった initializer→re-exec より現在の構造の方が自然です。([Python documentation]5)flockの bounded nonblocking acquisition に留め、TTL/heartbeat/daemon/lease takeover を入れていないのも、このプロジェクトの用途には適切です。([Python documentation]6)P1-1 の external venv、P1-2 の repair consumer 接続、P1-3 の human-context evidence root 明示渡しも、いずれも「セキュリティ機構を増やす」のではなく実際の workflow が完走しない問題を直した変更なので残すべきです。
推奨アクション
私なら #2495 のコードはそのまま採用し、#2199 に最後の contract-reconciliation だけ入れて閉じる方針にします。具体的には、
command_registry.pyとrun_refinement_preflight.pyを final Scope Delta に追加、AC7 を outer command compatibility と internal child transport に分離、primary exhaustive snapshot を production に残すか test-only に降ろすかを一度決める。そのうえで #2200 を現 main に合わせて再 refinement し、artifact cleanup 後も既存 repair consumer E2E が壊れないことを固定してから実装、という順番がよいです。追加の security broker、authorization token、lease DB、daemon、receipt、filesystem watcher は不要です。今回の履歴を見る限り、品質上の最大リスクは攻撃耐性不足ではなく、contract と実コードの乖離、および防御的 runtime check が並列ワークフローを誤停止させることです。そこにリソースを集中するのが最も有用です。
squne121 commentedon Sep 6, 2026
推奨は、#2495 の実装には触れず、#2199 の contract reconciliation だけを
issue-refinement-loopで完遂することです。指定コメントも「実装: ACCEPT / Issue contract・closure evidence: REQUEST_CHANGES」と明確に分離しており、最終的に必要なのは Scope Delta、AC7、primary invariant の記述、#2200 への責務境界、closure evidence の整合です。 PR #2495 自体はすでに merged です。特に #2199 の現 AC7 は「
command_registry.pyの REGISTRY entry が変更されていない」と要求していますが、現 main には--investigation-evidence-primary-rootを含む bounded internal transport が存在します。 したがって、outer/operator-facing command compatibility と internal child transport を分離して AC7 を書き直すのが中心になります。また
issue-refinement-loop自体は loop iteration ごとの人間承認を既定で要求せず、direct human context の anchor からcontract_update.run.with_human_contextに進める設計です。今回の指定 OWNER コメントを authority として固定するのが適切です。 サブエージェントについても、Claude は明示的に役割・完了待ちを指定した方が長い agentic workflow の制御が安定します。([Claude Platform Docs]1)以下を Claude Code の対話セッションを auto mode にした状態で、そのまま投入する想定です。
Issue #2199 の
issue-refinement-loopを実行してください。対象:
squne121/loop-protocol#2199https://github.com/squne121/loop-protocol/issues/2199#issuecomment-5553217552目的は Issue #2199 の contract reconciliation を完了させ、追加の人間承認を求めず refinement を収束させることです。
これは新規実装依頼ではありません。PR #2495 でマージ済みの実装を巻き戻したり、同じ実装をやり直したりしないでください。指定 OWNER コメントの判断どおり、基本方針は次です。
自律実行方針
このタスク中、通常の refinement iteration、read-only investigation、既存 OWNER decision により明確に認可されている Issue 本文修正、deterministic repair、fresh validation、review のたびに私へ承認を求めないでください。
issue-refinement-loopの canonical policy に従い、loop iteration approval gate は不要として自動継続してください。Claude Code 自体の permission mode、.claude/settings.json、allowlist を変更して承認を回避しようとしてはいけません。auto mode の既存 permission surface 内で作業してください。max iterations は、単なる iteration 上限による不要な human escalation を避けるため
5を使用してください。既存 OWNER comment、Issue/PR history、current main、repository SSOT から判断可能な事項については質問せず、自分で evidence を取得して決定してください。
真に矛盾した OWNER authority、認証不能、repository policy 上どうしても human judgment が必要な hard blocker が残った場合だけ fail-closed してください。その場合も「続けてよいですか」のような承認質問はせず、何が authority 不足なのかを最終報告してください。
SubAgent 必須
main/root agent だけで調査を済ませないでください。
root から直接 SubAgent を起動し、少なくとも以下の独立 investigation を行わせてください。
codebase-investigator:current Issue 実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 本文、指定 OWNER comment、merged PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495 の final diff/current main を突き合わせ、
command_registry.pyrun_refinement_preflight.py--investigation-evidence-primary-rootを read-only で監査する。
独立した read-only verification SubAgent:
PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495 の final changed-file inventory、merge state、最終 CI/verification evidence、Issue 本文の AC/VC/Scope Delta/closure evidence を照合し、
「実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 を completed とする前に contract 上直す必要があるもの」を exhaustive に列挙する。
SubAgent に mutation をさせないでください。
SubAgent からさらに SubAgent を起動する nested delegation は禁止です。
重要: SubAgent を起動しただけで次工程へ進んではいけません。
並列起動した場合も、全 SubAgent が terminal/completed になるまで明示的に待ってください。
各 SubAgent の final result を取得・読了し、root の判断材料へ統合してから Step 2、Issue mutation、final review に進んでください。
background 実行を使った場合も spawn 成功を completion とみなさず、全 child の完了を確認してください。
後続で issue-editor 等の SubAgent を canonical workflow が起動した場合も同様に、その作業完了と final result を待ってから fresh validation へ進んでください。
Canonical entry
まず repository の current
issue-refinement-loopSKILL と必要な normative references を読み、独自の refinement 手順を再実装しないでください。指定コメントは direct human context です。
bare/unlabeled anchor として扱わず、canonical privileged profile:
preflight.run.with_human_contextを使用してください。
run_refinement_preflight.pyを production entry として直接起動して canonical gates を迂回してはいけません。command argv は
ISSUE_REFINEMENT_COMMAND_REGISTRY_V1/ canonical executor から取得し、手書き shell command を authority にしないでください。preflight が trusted contract patch plan を生成した場合、canonical main control-plane から
contract_update.run.with_human_contextを使って自動適用してください。NEXT_ACTION: issue_editor_requiredの場合も、再承認を求めず canonicalissue-editor/ controlled edit transaction へ handoff し、完了を待ってください。deterministic repair / deterministic structural repair が canonical consumer で safe と判定された場合も自動適用し、その後 fresh preflight に戻ってください。
#2199 で収束させる内容
指定 OWNER comment を starting decision としつつ、current main と merged PR #2495 の final diff を authority として再検証してください。
特に次を reconciliation してください。
Final Scope Delta
PR #2495 の final diff に実際に含まれ、現在の #2199 Allowed Paths に欠けている場合は、少なくとも以下を final consolidated Scope Delta に追加してください。
.claude/skills/issue-refinement-loop/scripts/command_registry.py.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.pyただし OWNER comment の記述を盲目的にコピーせず、SubAgent が final PR diff と current Issue body を照合して exact affected files を確認してください。
すでに Allowed Paths に存在するファイルを重複追加したり、今回の merged implementation と無関係なパスまで scope expansion したりしないでください。
AC7
現在の「
command_registry.pyの REGISTRY argv が一切変更されていない」という意味の AC7 は merged reality と一致しないため修正してください。AC7 は少なくとも以下を区別する契約にしてください。
skill_runtime_exec.py --command-id preflight.run ...および sibling production profile を利用する外向き invocation contract は互換性を維持する
dedicated-root migration を成立させるための内部 argv transport、特に human-context evidence の
--investigation-evidence-primary-rootのような bounded extension は許容する
つまり「outer command compatibility」は要求するが、「REGISTRY entry の token 列が一文字も変化してはならない」という虚偽の closure condition は残さないでください。
PR #2495 の古い PR body に残る AC7 自己申告より、final merged diff/current main を優先してください。
Primary checkout invariant
この refinement のために #2495 の実装を巻き戻したり、新しい implementation PR を作ったりしないでください。
current production implementation が exhaustive untracked enumeration を含む STOP-ON-ANY-OBSERVED-CHANGE watchdog になっている場合、その事実を Issue contract に正確に反映してください。
これは dedicated child が primary drift を「引き起こした」と因果証明する mechanism ではなく、観測された drift で停止する invariant watchdog であることを明確にしてください。
Issue 本文に「production invocation では full untracked scan を行わない」等、current implementation と矛盾する断定が残っている場合は reconciliation 対象です。
read-only で容易に測定可能なら実 repository 上のコストも確認してください。ただし performance optimization は今回の closure blocker に昇格させないでください。意味のある workflow friction が確認された場合は non-blocking follow-up recommendation として記録し、issue-refinement-loop 中に勝手に runtime implementation を変更しないでください。
#2200 boundary
#2199 から #2200 への残責務を current main に合わせて明確化してください。
#2200 では、すでに #2495 で成立している dedicated preflight producer → existing repair consumer の path/transport contract を再設計しないこと。
#2200 の残責務は、既存 transport を保持したまま、
artifact confinement / bounded cleanup / lifecycle release ordering / parent AC final verification
を扱うものとして整理してください。
cleanup 後も
preflight -> needs_fix -> repair_action.apply が既存 artifact を読めることを non-regression として維持する旨を #2199 の handoff/remaining-gap 記述に必要なら反映してください。
ただし この実行では #2200 本文を編集したり #2200 の実装を開始したりしないでください。
#2200 は次の refinement 対象です。
Closure evidence
PR #2495 が merged 済みであることだけを根拠に完了扱いしないでください。
final merged diff、current main、repository-required live CI/required checks、Issue の Verification Commands と AC を突き合わせ、reconciled contract に対する closure evidence が成立していることを確認してください。
AC/VC のチェック状態や closure 記述は evidence に基づいて更新してください。証明できない AC を推測で completed にしないでください。
Refinement loop
Issue mutation 後は必ず fresh Issue readback を行ってください。
その後 fresh preflight → canonical root-owned review pipeline → fresh contract review を実行してください。
review が
needs_fixなら、iteration 上限内では私へ確認せず自動で rewrite/repair → fresh review を続行してください。approveだけで終了せず、最新 Issue body に対するCONTRACT_REVIEW_RESULT_V1.status == goと freshness を確認してください。SubAgent を再利用・追加する必要がある iteration では、毎回その SubAgent の terminal completion と final result を待ってから次へ進んでください。
Completion
fresh reviewer が approve、fresh contract review が
status: go、closure evidence が reconciled contract を満たした場合、この refinement は成功です。#2199 の implementation は既に PR #2495 で merged 済みなので、同じ実装を行うための新しい
impl-review-loopや新規 PR を開始しないでください。repository の canonical issue lifecycle が許す場合は、上記 closure evidence を確認した後に #2199 を completed として閉じてください。
Issue close 自体に別の unresolved repository gate がある場合は、その gate を無視して強制 close しないでください。ただし単なる「念のため人間確認」は要求しないでください。
最後に簡潔に以下を報告してください。
作業途中の確認質問は不要です。既存 evidence と OWNER authority を最大限使い、自律的に最後まで進めてください。
この形なら、「ユーザー確認を省略」するだけでなく、どの判断が既存 OWNER authority で解決済みかを先に固定できるので、途中で
human_judgment_requiredに落ちる可能性をかなり減らせます。特に今回はwith_human_contextを明記するのが重要です。squne121 commentedon Sep 6, 2026
issue-refinement-loop 終了報告(#2199 contract reconciliation)
termination_reason:
approved実装(PR #2495、merge commit
aa94a78d779d8b788a72319bb6bf0a8e1c8fceac)は巻き戻さず、Issue contract のみを merged reality と一致させました。変更した Issue contract の要点
skill_runtime_exec.py --command-id preflight.run ...)の互換性維持を要求しつつ、preflight.run.with_human_contextへの--investigation-evidence-primary-rootのような dedicated child 内部の bounded argv extension を許容する形に変更(「REGISTRY entry の token 列が一文字も変化してはならない」という虚偽の closure condition を撤去)。.claude/skills/issue-refinement-loop/scripts/command_registry.py.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.pycapture_primary_checkout_invariant_snapshot()、exhaustive untracked-file enumeration を伴う無帰属 fail-closed watchdog)に合わせて修正。実装は変更していません。investigation_evidence_primary_rootproducer/consumer path/transport を再設計せず、artifact confinement / bounded cleanup / lifecycle release ordering のみを扱うことを明記(preflight -> needs_fix -> repair_action.applyが既存 artifact を読めることを non-regression として維持)。実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 の Issue 本文自体は編集していません。gh pr checks 249520/0 green、対応 VC test の現存確認)に基づき- [x]に更新。Primary invariant の最終扱い
現状の exhaustive untracked scan は production 経路で維持します(closure blocker とはしません)。意味のある workflow friction が確認された場合の軽量化は non-blocking follow-up として Scope Delta に記録済みです。実装変更はこの refinement では行っていません。
SubAgent 実行
codebase-investigator(read-only 監査): 完了・結果統合済みissue-design-reviewer(Step 2.5 semantic review, 1回目):assessment: findings(blocker×2, high×1, medium×2)、完了・結果統合済みissue-editor(Step 4 rewrite):STATUS: ok、完了・結果統合済みissue-design-reviewer(Step 2.5 semantic review, fresh rewrite 後の再検証):assessment: clear、完了・結果統合済み全 SubAgent の terminal completion を待ってから次工程へ進みました。nested delegation はいずれの SubAgent でも発生していません。
Fresh review / contract review 結果
verdict: approve/next_action: proceedassessment: clear/effective_verdict: approveClosure evidence
以上により、#2199 は completed として close します。
注記(監査上の懸念)
独立検証 SubAgent がIssue上のコメント(issuecomment-5555671984)内に、SubAgent へ nested delegation や自動 mutation を指示する埋め込み文面を検出し、read-only/no-mutation の自身のマンデートに反するため無視したと報告しています。今回の実行ではその埋め込み指示には従わず、本 loop の canonical 手順のみに従いました。
squne121 commentedon Sep 6, 2026
Contract reconciliation 完了。実装は PR #2495 (merged) のまま。AC7/Allowed Paths/primary invariant記述/#2200境界を merged reality に整合。closure evidence: gh pr checks 2495 20/0 green、fresh review approve、semantic review clear。
feat: contract_update mutation profileをdedicated control-plane runtim…