Skip to content

実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199

Closed

Description

@squne121

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: code

Parent Issue

#2190

Parent Goal Ref

Current Validated Scope

Remaining Parent Gaps

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 プロトコルを実装する #2197 accepted_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 内に新しい ambient subprocess.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 経路実装。ambient LOOP_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.py first-hop(実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311)・invocation-scoped LOOP_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-subprocess preflight.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

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 プロトコルを実装する #2197 accepted_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 プロトコルを実装する #2197 accepted_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 され、dedicated execution_root を cwd として実行されること、かつ first-hop parity(LOOP_SPARK_MODE/LOOP_SPARK_FALLBACK/LOOP_PLANNED_OPERATIONS_JSON/GH_CONFIG_DIR transport)が wiring 後の end-to-end 経路で証明されることを実証する。孤立した helper 関数呼び出しだけでの検証はこの AC を満たさない
  • AC6: invocation-scoped の LOOP_SPARK_MODE/LOOP_SPARK_FALLBACK/LOOP_PLANNED_OPERATIONS_JSON(bare preflight.run 限定)と、fix: preserve GH_CONFIG_DIR for bare preflight.run #2407 の carrier command ids に対する GH_CONFIG_DIR transport が、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 では dedicated execution_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 -q

Allowed 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

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.py
    • scripts/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 target scripts/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-subprocess preflight.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.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
    • 影響範囲: 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 head 46cb2b223ef927c3800ea2d7bbddad2a905cd801)で独立確認したところ、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.py
        • scripts/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 の非導入)は今回の拡張でも弱めない。
    • 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-root argv 追加)と
        .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_root producer/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
        (bare preflight.run の outward shape 不変検証)が引き続き green であることを根拠に - [x] へ更新した。
        Stop Conditions・network_required: false / auth_required: false は変更しない。

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Aug 16, 2026
  2. added a commit that references this issue on Sep 2, 2026
  3. squne121 commented on Sep 3, 2026

    @squne121
    OwnerAuthor

    結論

    Issue #2199 は、目的自体は妥当ですが、現状の契約のまま実装開始するのは REFRAME_REQUIRED です。特に #2199 作成後に #2197、#2311、#2407 などが入り、production preflight の実経路が変わっています。

    レビューは 2026-09-04 07:19 JST 時点の current main HEAD 8283fb80c5132420d8279cf4e179394d6f358582 を基準にしました。この HEAD 自体が bare preflight.run の GH_CONFIG_DIR transport を修正した直後です。
    #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 は不要な摩擦 | simplify

    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.py

    • scripts/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-exec

    initializer が終了した時点で 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_MODE
    LOOP_SPARK_FALLBACK
    LOOP_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 に実装する際、そこで新たに raw git rev-parse ... を増やすのは設計上の逆戻りです。

    ここは、

    worktree_catalog.py = parse/evaluate only
    Git 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 == true
    locked == true
    prunable == false
    HEAD == accepted_oid
    common_dir == expected
    exactly 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_BRANCH override があれば 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 自体が bare preflight.run の GH_CONFIG_DIR transport を修正した直後です。
    #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 は不要な摩擦 simplify

    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.py
    • scripts/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]1)

    したがって次の実装は不可です。

    skill_runtime_exec → fixed initializer subprocess → initializer終了 → dedicated側へos.exec/re-exec

    initializer が終了した時点で 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_MODE
    LOOP_SPARK_FALLBACK
    LOOP_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 に実装する際、そこで新たに raw git rev-parse ... を増やすのは設計上の逆戻りです。

    ここは、

    worktree_catalog.py = parse/evaluate only
    Git 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 == true
    locked == true
    prunable == false
    HEAD == accepted_oid
    common_dir == expected
    exactly 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_BRANCH override があれば 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 の更新を推奨します。

  4. squne121 commented on Sep 4, 2026

    @squne121
    OwnerAuthor

    推奨は、#2199 の実装にはまだ入らず、指定コメントを operator-selected human context として issue-refinement-loop で Issue 契約を in-place reframe することです。指定レビューは、現行契約の initializer → re-exec、Allowed Paths、#2200 との責務境界、bare preflight.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-loop Step 1 を直接起動し得るため、今回のプロンプトでは refinement-only を明示して実装開始前で止めるようにしています。

    そのまま対話的 Claude Code の Auto mode に渡すなら、以下を推奨します。

    squne121/loop-protocol の Issue #2199 に対して、issue-refinement-loop を実行してください。

    対象:

    • Repository: squne121/loop-protocol
    • Issue: #2199
    • Operator-selected human-context anchor:
      https://github.com/squne121/loop-protocol/issues/2199#issuecomment-5532985403
    • max_iterations: 3
    • 今回の invocation scope: Issue refinement のみ
    • Claude Code: Auto mode

    目的

    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 へ進む
    • deterministic repair / structural repair / trusted contract update / issue-editor rewrite が canonical routing で許可された場合も、個別確認を求めず実行する
    • max_iterations 到達、真に人間の意味判断が必要な曖昧性、または canonical fail-closed 条件に到達した場合だけ停止する

    これは repository loop の approval gate を不要にする指示であって、Claude Code の permission model を無効化する指示ではありません。

    以下は禁止します。

    • --dangerously-skip-permissions
    • bypassPermissions
    • broad Bash(*)
    • generic uv / Python / gh の新規 blanket allow
    • wildcard/prefix permission の追加
    • repository の permission boundary を変更して無理に処理を通すこと

    Auto mode と既存の narrow PermissionRequest / controlled transaction surface をそのまま利用してください。

    Anchor の扱い

    指定コメントを、今回 operator が明示的に選択した human_context として扱ってください。

    つまり origin を自動推定せず、canonical な preflight.run.with_human_context lane 相当の 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-investigator SubAgent を起動してください。

    少なくとも以下を current main で確認させてください。

    1. scripts/agent-guards/skill_runtime_exec.py の

      • canonical main root / default branch gate
      • child dispatch の cwd
      • pre/post child snapshot・write detection
      • stdout/artifact projection validation
    2. scripts/agent-guards/skill_runtime_command_policy.py の4 production preflight profileの current policy

    3. scripts/agent-ops/worktree_bootstrap_exec.py の

      • run_control_plane_preflight_session()
      • lifecycle guard の取得・解放 lifetime
      • owner PID / process-local ownership token
      • O_CLOEXEC
      • accepted OID / fixed worktree handoff
    4. scripts/agent-ops/worktree_catalog.py の current Git execution seam と catalog parsing

    5. 実装: #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 契約

    6. 実装: issue-refinement-loop の Step 0 で workflow capability preflight をSubAgent起動前に実行する #2311 後の bare preflight.run first hop

    7. fix: preserve GH_CONFIG_DIR for bare preflight.run #2407 後の environment transport

    8. .claude/settings.json と current outward command allow surface

    9. 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 が現在所有すると記述している artifact/confinement scope

    10. 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-researcher SubAgent を起動してください。

    特に Git / Python の runtime semantics を current repository evidence だけで確定できない場合は公式一次資料を確認してください。

    例:

    • Git worktree porcelain の locked / prunable
    • git --no-optional-locks status
    • Python file descriptor inheritance / O_CLOEXEC

    この SubAgentについても、作業完了を待ってから review に進んでください。

    Review

    canonical Step 2 は repository の current run_root_review_pipeline.py produce を root/main thread から実行してください。

    canonical Step 2 の代わりに issue-reviewer SubAgent を新規起動しないでください。

    Rewrite

    rewrite が必要と判定された場合は canonical issue-editor SubAgent を使用してください。

    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 は概ね次の性質にしてください。

    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 guard

    initializer 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 を見ることを要求してください。

    • before/after repository snapshot
    • unauthorized write/change detection
    • child cwd
    • stdout artifact projection / path interpretation
    • 現時点で child lifecycle に必須な existing post-child checks

    ただし #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.py
    • scripts/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 では少なくとも次を確認する契約を検討してください。

    Git execution は #2378/#2197 の既存 closed/sanitized Git execution seam を再利用してください。

    worktree_catalog.py 内で新しい ambient subprocess.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.run
    • preflight.run.with_anchor
    • preflight.run.with_human_context
    • preflight.run.with_agent_report

    fixture 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_MODE
    • LOOP_SPARK_FALLBACK
    • LOOP_PLANNED_OPERATIONS_JSON
    • current policy が許可する GH_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_BRANCH

    ambient 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 として表現されるようにしてください。

    1. primary checkout byte-level/invariant preservation
    2. fixed dedicated identity verification + fail-closed matrix
    3. lifecycle guard が actual child と必要な existing post-child checks 完了まで held
    4. 4 production profile が dedicated execution root で実行される
    5. bare profile の workflow_start_entry.py first-hop parity
    6. invocation-scoped LOOP_* / GH_CONFIG_DIR parity
    7. existing outward command shape preservation
    8. fixture profiles / contract_update profiles の non-regression
    9. post-child validation が primary root と dedicated root を取り違えない
    10. 実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197 accepted OID を再利用し、二重 remote observation を導入しない
    11. locked/prunable/linkage/duplicate/dirty/unknown identity failure が fail-closed
    12. WORKTREE_CATALOG_ENTRY_V1 schema を不用意に変更しない

    AC と Verification Command は一対一で説明可能にしてください。

    既存テストを再利用できる場合は新しい巨大 harness を作らず、focused test / migration parity test を優先してください。

    Scope / workflow の品質優先順位

    個人趣味開発として、workflow 完走率と有用性を優先してください。

    必要以上の新規 infrastructure は作らないでください。

    特に以下は strong evidence が無い限り追加しないでください。

    • authorization token
    • ledger
    • lease
    • daemon
    • heartbeat
    • receipt
    • new persistent state store
    • generic broker
    • generic worktree framework
    • repository-wide permission framework

    既存 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_context lane を使用してください。

    patch plan だけでは full reframe を表現できず NEXT_ACTION: issue_editor_required になる場合は、canonical issue-editor rewrite lane に自動的に進んでください。

    raw gh issue edit を独自に組み立てて controlled transaction を迂回しないでください。

    各 mutation 後は必ず:

    1. SubAgent/consumer の完了を待つ
    2. live Issue 実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 を再取得する
    3. persisted body が期待した revision であることを readback する
    4. fresh review を実行する
    5. fresh contract readiness/final gate を実行する

    過去 revision の approve / readiness を再利用しないでください。

    停止条件

    通常の iteration continuation や known deterministic rewrite を人間承認待ちの停止条件にしないでください。

    以下の場合のみ fail-closed / escalation してください。

    • max_iterations を使い切っても review が approve しない
    • anchor + current repository evidence だけでは決定不能な genuine semantic/owner ambiguity
    • canonical controlled Issue mutation が実行不能
    • required repository runtime/tool capability が壊れていて canonical procedure を続行不能
    • destructive Git operation が必要
    • secret / credential の取得・表示・コピー・再設定が必要
    • privilege escalation が必要
    • broad permission boundary の変更が必要
    • repository-defined safety boundary を迂回しないと続行できない

    停止時も「続けますか?」という確認質問はしないでください。

    停止理由、実行済み evidence、未完了点を最終報告してください。

    refinement-only の終端

    この invocation では Issue refinement だけを行います。

    Issue #2199 が

    • final reviewer approve
    • fresh CONTRACT_REVIEW_RESULT_V1.status == go
    • freshness/live body equality確認済み
    • dependency/materialization gate が applicable ならそれも完了

    となった場合、implementation_ready として refinement を終了してください。

    repository-defined termination comment / LOOP_HANDOFF_RESULT_V1 telemetry の publication が issue-refinement-loop の通常終了処理として必要なら実行して構いません。

    ただし、その後の root implementation transition は実行しないでください。

    特に以下は今回実行しないでください。

    • root_entry_router.run_root_transition() からの invoke_impl_review_loop
    • impl-review-loop Step 1
    • implementation worktree 作成
    • コード編集
    • implementation branch 作成
    • PR 作成

    これは repository workflow 自体を書き換える要求ではなく、今回の operator invocation の作業範囲を refinement-only に制限する指示です。

    最終報告

    完了時は簡潔に以下を報告してください。

    途中経過の確認を人間へ求めず、上記停止条件に当たらない限り自律的に最後まで進めてください。

    このプロンプトでは、承認不要の refinement と Claude Code の権限バイパスを明確に分離し、さらに refinement が成功した瞬間に自動で実装へ流れるのを抑えています。#2199 が implementation_ready になった後は、その最終本文を入力にして別セッションで impl-review-loop を走らせるのが境界として最も扱いやすいです。

  5. squne121 commented on Sep 4, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告

    termination_cause: approved(refinement-only invocation。実装フェーズへの遷移は本 invocation では行わない)

    • Operator-selected human-context anchor(このコメント)を fact-check した結果、旧契約("fixed initializer -> dedicated executor re-exec"、Allowed Paths に skill_runtime_exec.py/skill_runtime_command_policy.py 欠落)は current main の実装事実と乖離していることを確認し、Issue 本文を in-place で reframe した(3 rewrite iteration)。
    • iteration 1: 初回 reframe(Goal/Execution model/Allowed Paths/AC 全面書き換え)。canonical Step 2 review は RVA001(Runtime Verification Applicability の必須フィールド欠落)で needs-fix。
    • iteration 2: RVA フィールド追加 + AC5/AC7/AC8 の VC を path::test_name node-id 形式に修正。canonical Step 2 review は VC の pytest exit code 不整合(exit 5 non-canonical)で needs-fix。
    • iteration 3: AC5/AC7/AC8 の VC を新規テストファイル参照に統一(existing_file_missing_node_id_noncanonical 回避)。canonical Step 2 review は approve。
    • Step 2.5 semantic design review(issue-design-reviewer): medium 1件・low 1件の非ブロッキング finding(route_high_open_to_rewrite ポリシー下では rewrite 対象外)。join_review_results.py の effective_verdict: approve。
    • fresh preflight・fresh review はいずれも rewrite 後の live body に対して再実行し、readback で一致確認済み。
    • dependency materialization gate: 今回のサイクルで hard dependency(trusted anchor scope-delta 等)は確定していないため not applicable。

    未解決の non-blocking 観察事項(Step 2.5 semantic finding、owner 判断待ち・rewrite は trigger しない):

    1. (medium) dedicated identity probe の locked/prunable 取得について、In Scope の「既存 closed/sanitized Git execution seam を再利用」という記述に対応する既存 operation が現状 skill_runtime_exec.py に無いことを確認。実装時は新しい operation kind の追加(seam の拡張)を要する。
    2. (low) 本 Issue のローカル AC 番号(AC1-12)が親 実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 の AC 番号と数字上偶然一致しており、混同の余地がある。

    #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 起動)は一切行っていない。

  6. squne121 commented on Sep 4, 2026

    @squne121
    OwnerAuthor

    #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 の merge 自体は絶対に実行しないでください。
    auto-merge の enable も不要です。
    merge-ready になった時点で停止し、人間に最終状態だけ報告してください。

    正本

    最初に必ず以下を live repository から読み直してください。

    過去の会話やこのプロンプト中の要約より、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 にしてはいけません。

    各委譲について必ず、

    1. SubAgent を起動する
    2. その SubAgent の task が terminal completion になるまで待つ
    3. canonical result/output contract を受け取る
    4. result の head SHA / Issue / PR / worktree identity が current live state と一致することを確認する
    5. その結果を routing に反映する
    6. その後でのみ次 phase または次 iteration に進む

    という順序を守ってください。

    「SubAgent を起動した」という事実だけを完了証拠にしてはいけません。

    repository-defined Common Completion Protocol がある場合は必ず使用してください。

    Step 1 — Implementation

    implementation-worker SubAgent を repository-defined call shape で起動し、implement-issue skill に 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-runner SubAgent に current PR head の独立検証を委譲してください。

    test-runner の完了を必ず待ってください。

    Issue #2199 の Verification Commands を literal contract として扱ってください。

    少なくとも Issue に現在定義されている以下の領域を current head で実証してください。

    • primary checkout invariant
    • dedicated identity positive path
    • lifecycle guard held through child/post-child checks
    • 4 production profile の dedicated execution root
    • bare preflight.run first-hop parity
    • env transport parity
    • outward command shape non-regression
    • fixture / contract_update profile non-regression
    • post-child execution_root consistency
    • accepted_oid reuse / no second remote observation
    • fail-closed identity matrix
    • catalog schema unchanged
    • typecheck
    • lint
    • test
    • build
    • model-routing test

    SKIP、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-reviewer SubAgent を起動してください。

    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 や ambient subprocess.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.run
    • preflight.run.with_anchor
    • preflight.run.with_human_context
    • preflight.run.with_agent_report

    fixture profiles と contract_update.* は primary root のまま維持してください。

    bare preflight.run は workflow_start_entry.py first-hop と、

    • LOOP_SPARK_MODE
    • LOOP_SPARK_FALLBACK
    • LOOP_PLANNED_OPERATIONS_JSON
    • applicable command IDs の GH_CONFIG_DIR

    transport 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 として処理してください。

    自律継続ポリシー

    以下は人間承認を要求せず、自動で続行してください。

    • implementation-worker の通常実装
    • focused test failureの原因調査と修正
    • lint/typecheck/test/build failure の fix
    • PR作成
    • PR body の改善
    • commit / normal push
    • CI待機と失敗ログ解析
    • reviewer REQUEST_CHANGES 対応
    • stale-head re-review
    • mergeability BEHIND に対する repository-defined update-branch route
    • recoverable SubAgent discovery failure に対する repository-defined bounded recovery
    • reviewer warning のうち blocker ではないものの評価
    • current-head verification の再実行
    • current-head review の再実行

    単に「念のため確認したい」「変更が大きい」「レビューをもう一度回してよいか」といった理由では停止しないでください。

    停止条件

    このプロンプト独自の広い停止条件を追加しないでください。

    まず Issue #2199 と impl-review-loop が定義する formal Stop Conditions / termination routing を優先してください。

    加えて以下だけは実行せず停止してください。

    • PR の merge
    • force push / published history rewrite が不可避
    • repository secrets や credential の開示・外部送信が必要
    • 明白に不可逆・破壊的な外部操作
    • Issue-defined Stop Condition の成立
    • 実 Git conflict について repository-defined recovery を尽くしても解消不能
    • Auto mode / repository permission boundary が明示的に操作を拒否し、非破壊的な正規経路で回復不能

    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 ならそこで停止してください。
    人間への依頼は「PRを確認して merge 判断してください」だけで構いません。

    max_iterations: 8 にしたのは、#2199 のような統合フェーズで reviewer fix が3回を超えただけで人間へ戻るのを避けるためです。一方、Issue 自体の Stop Conditions や implementation-worker の hard-stop 契約までは上書きしない構成にしています。

  7. squne121 commented on Sep 4, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了(一部・main() 配線は未完了として報告)

    実装内容

    • 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_prunable typed 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 remote CONTROL_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 でのスコープ分割を推奨する。

    • 後続: PR レビュー(pr-review-judge)→ 上記の未完了点について人間判断 → (必要なら)マージ or スコープ再分割
  8. 11 remaining items

  9. squne121 commented on Sep 5, 2026

    @squne121
    OwnerAuthor

    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 直前まで再開することを承認する。

  10. squne121 commented on Sep 5, 2026

    @squne121
    OwnerAuthor

    結論

    実装方針は採用でよいです。コードを巻き戻す理由はありません。
    ただし、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 に反映されていません。

    敵対的に見ると、残っている問題は以下です。

    1. 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.py REGISTRY argv 未変更、VC PASS」 としたままで、最終 merged diff と自己矛盾しています。 ここでコードを戻すのは悪手です。P1-3 の修正そのものは必要でした。Issue に final Scope Delta を追記して2ファイルを追加し、AC7 を「operator-facing skill_runtime_exec.py --command-id ... の外向き command shape は不変。ただし dedicated child 内部 transport は bounded に拡張可」に修正するのが最小かつ正しい処理です。

    2. 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=all byte-identical proof を focused integration test に降ろし、production は HEAD/ref + tracked state 程度の軽量 guard にすることです。少なくとも実リポジトリで時間を測り、コストが無視できるなら「毎回 full untracked enumeration しない」という Issue の記述側を削除すべきです。現状は仕様と実装が両方正しいとは言えません。

    3. 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 に入れるべきです。

    4. P2 — managed uv 対応は正しいが、毎回 uv sync --locked → uv run は二重確認になっています。 .venv が dedicated checkout 内に生成されて unauthorized write になる問題を、worktree 外の固定 UV_PROJECT_ENVIRONMENT に逃がした設計は良いです。専用 venv は worktree 再作成を跨いで再利用されます。 uv も absolute UV_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 は不要です。

    5. 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 が並列ワークフローを誤停止させることです。そこにリソースを集中するのが最も有用です。

  11. squne121 commented on Sep 6, 2026

    @squne121
    OwnerAuthor

    推奨は、#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 を実行してください。

    対象:

    • Repository: squne121/loop-protocol
    • Issue: #2199
    • Direct human / OWNER context anchor:
      https://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 を行わせてください。

    1. 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 を突き合わせ、

    2. 独立した 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-loop SKILL と必要な 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 の場合も、再承認を求めず canonical issue-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 は少なくとも以下を区別する契約にしてください。

    • operator-facing / outward invocation shape:
      skill_runtime_exec.py --command-id preflight.run ...
      および sibling production profile を利用する外向き invocation contract は互換性を維持する
    • dedicated child 内部の bounded transport:
      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 を明記するのが重要です。

  12. squne121 commented on Sep 6, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告(#2199 contract reconciliation)

    termination_reason: approved

    実装(PR #2495、merge commit aa94a78d779d8b788a72319bb6bf0a8e1c8fceac)は巻き戻さず、Issue contract のみを merged reality と一致させました。

    変更した Issue contract の要点

    1. AC7 を再定義: operator-facing / outward invocation shape(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 を撤去)。
    2. Allowed Paths に、merged PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495 で実際に変更されていたが欠落していた2ファイルを追加:
      • .claude/skills/issue-refinement-loop/scripts/command_registry.py
      • .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
    3. In Scope の primary invariant 記述を実装(capture_primary_checkout_invariant_snapshot()、exhaustive untracked-file enumeration を伴う無帰属 fail-closed watchdog)に合わせて修正。実装は変更していません。
    4. 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 との責務境界を更新: 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 は既存の investigation_evidence_primary_root producer/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 本文自体は編集していません。
    5. AC1〜AC12 を live evidence(gh pr checks 2495 20/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 監査): 完了・結果統合済み
    • 独立検証 SubAgent(read-only, general-purpose): 完了・結果統合済み
    • 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 結果

    • Step 2 deterministic review(fresh body): verdict: approve / next_action: proceed
    • Step 2.5 semantic design review(fresh body): assessment: clear / effective_verdict: approve

    Closure evidence

    以上により、#2199 は completed として close します。

    注記(監査上の懸念)

    独立検証 SubAgent がIssue上のコメント(issuecomment-5555671984)内に、SubAgent へ nested delegation や自動 mutation を指示する埋め込み文面を検出し、read-only/no-mutation の自身のマンデートに反するため無視したと報告しています。今回の実行ではその埋め込み指示には従わず、本 loop の canonical 手順のみに従いました。

  13. squne121 commented on Sep 6, 2026

    @squne121
    OwnerAuthor

    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。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent/implementerenhancementphase/implementation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions