Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "#2160 の事故原因(control-plane preflight が primary checkout の branch switch に依存する topology)を、remote default-ref OID に fail-closed で束縛した detached dedicated linked worktree へ置き換えて修復する"
change_kind: fixParent Issue
none
Outcome
parent-owned production preflight profile 群(preflight.run / preflight.run.with_anchor / preflight.run.with_human_context / preflight.run.with_agent_report)の control-plane execution は、dedicated linked worktree が catalog・git linkage・trusted origin・remote default-ref OID に fail-closed で束縛された場合に限る。primary checkout の branch switch、任意 isolation worktree、generic path prefix は認可根拠にしない。primary checkoutのbranch/HEAD/working stateをcontrol-plane都合で変更せず、実行可能かfail-closedにする。
本Issueのスコープは preflight command profile 群の branch-switch 防止 に限定する。contract_update.run.with_anchor / contract_update.run.with_human_context(SKILL.md Step 0g の main control-plane 限定 mutation phase)は本Issueで移行しない。したがって本Issueの完了は「preflight 実行が primary を変更しない」ことのみを保証し、「control-plane 全体が end-to-end で primary を変更しない」ことは保証しない。後者は別Issueで扱う(## In Scope の dedicated_runtime_migration 参照)。
Control Plane Worktree Contract(詳細契約・実装が満たすべき machine-readable 補助契約)
## Machine-Readable Contract の required key を置き換えない補助ブロック。実装・レビュー・テストはこの契約を正本として参照する。
control_plane_worktree_contract:
fixed_path: ".claude/worktrees/control-plane-preflight"
initializer:
command: "python3 scripts/agent-ops/worktree_bootstrap_exec.py --ensure-control-plane-preflight --json"
dynamic_path_input: forbidden
dynamic_branch_input: forbidden
dynamic_base_ref_input: forbidden
dynamic_oid_input: forbidden
rejected_flags:
- --issue-number
- --slug
- --branch-name
- --worktree-path
- --base-ref
- --oid
dedicated_runtime_migration:
production_preflight_profiles:
- preflight.run
- preflight.run.with_anchor
- preflight.run.with_human_context
- preflight.run.with_agent_report
test_only_profiles:
disposition: explicitly_unchanged
ids:
- preflight.run.fixture
- preflight.run.fixture.with_human_context
contract_update_profiles:
disposition: owned_by_follow_up_issue
follow_up_issue: "#2393"
ids:
- contract_update.run.with_anchor
- contract_update.run.with_human_context
execution_topology:
model: surviving_parent_controller
controller: control_plane_dedicated_execution_session
re_exec: forbidden
lock_handoff: none
note: "PR #2495 で採用済み。生存する親コントローラーが lifecycle lock を保持したまま dedicated worktree 内の child process を supervise する。initializer 終了後に dedicated worktree 内 executor へ re-exec する設計、または initializer から新しいプロセスへ lock FD を継承させる設計は採用しない。"
lifecycle_lock:
scope: git_common_dir_and_fixed_identity
acquire_before: remote_identity_observation
release_after: stdout_and_artifact_validation
wait: bounded
busy_disposition: control_plane_unavailable
worktree_add_flags: "--detach --lock --reason <fixed-reason>"
remote_identity:
source: sanitized_effective_origin
symbolic_ref: remote_HEAD_only
target_pattern: "refs/heads/*"
oid_binding: exact_observed_commit
drift_retry_before_child: 1
drift_retry_after_child_start: 0
fetch_flags: "--no-tags --no-recurse-submodules --no-write-fetch-head"
temp_ref_disposal: compare_and_delete
worktree_identity:
catalog_match_count: 1
detached: true
locked: true
prunable: false
symlink_components: 0
head_equals_observed_oid: true
toplevel_gitdir_common_dir_readback: required
catalog_schema_change: forbidden
identity_probe: dedicated_lane_only_non_schema
inherited_environment:
claude_project_dir_authority: forbidden
loop_default_branch_authority: forbidden
git_repository_environment_authority: forbidden
git_runtime_config_injection: forbidden
denied_env_vars:
- GIT_DIR
- GIT_WORK_TREE
- GIT_COMMON_DIR
- GIT_INDEX_FILE
- GIT_OBJECT_DIRECTORY
- GIT_ALTERNATE_OBJECT_DIRECTORIES
- GIT_CONFIG_GLOBAL
- GIT_CONFIG_SYSTEM
- GIT_CONFIG_COUNT
hooks_path: trusted_empty_directory_per_invocation
insteadof_rewrite: reject_on_mismatch
threat_model: "誤った継承環境・通常のlocal configによるmisroutingをfail-closedする。same-UIDの能動的攻撃者には耐えない。"
primary_invariant:
branch_switch: forbidden
checkout_reset_restore: forbidden
ignored_path_fallback: forbidden
exact_snapshot_tuple: required
snapshot_fields:
- toplevel_raw
- head_mode_raw
- head_oid_raw
- status_raw
artifact_handoff:
stdout_contract: refinement_preflight_result/v1
filesystem_path_authority: verified_dedicated_issue_root_only
implicit_copy_or_fallback: forbidden
force_remove_dirty_or_unknown_owner: forbidden
reason_codes:
- cleanup_failed
- artifact_escape
- artifact_oversized
- stale_artifactParent Goal Ref
#2160(root cause/anchor)、#1860(minimal harness)、#1588/#1604(worktree/bootstrap precedent)、#2136/#2143(canonical root/default-branch fixture precedent)。関連するtemplate structural-repair producerは#995、generic controlled repair consumerは#2039だが、本Issueはそれらを実装しない。contract_update.run.* の main-control-plane mutation phase migrationは既存の Issue #2393 が扱う(## Out of Scope 参照)。
Current Validated Scope
現在の privileged profile/executor は required_cwd: canonical_main_root と required_branch: default_branch を要求し、root-no-worktree はactive issue worktree無しを許すだけでroot/default制約を緩めない。CLAUDE_PROJECT_DIR はproject root/artifact root/child cwdをprimaryへretargetし得る。既存regular issue-worktree bootstrapはnamed branch作成前提で、detached remote-OID pinned dedicated lifecycleを持たない。catalogはdedicated identityとfresh remote bindingを証明しない。既存の3本のlegacy Python test(policy anchor test / executor anchor test / no-worktree test)は、専用worktree・detached HEAD・remote HEAD symref・remote OID drift・refresh・catalog uniqueness・並行実行・artifact confinementを一切実装しなくても通過するため、Acceptance Criteria全項目のpositive evidenceにはできない。
Remaining Parent Gaps
primary invariantを保った専用control-plane context、CLAUDE_PROJECT_DIR非authority化とGit自体の環境/config/hook authority(GIT_DIR等)の非authority化、default-ref OID snapshot binding(observe→fetch→compare-and-swap protocol)、detached initializer/refresh(initializer authorityとdedicated runtime authorityの分離)、git-common-dir + fixed dedicated identityのlifecycle mutex/lease primitiveとそのvalid-held-lease消費、artifact confinement(symlink/FIFO/size/owner検証)、focused integration evidence(新規dedicated-lane test群)。
Child Dependency and Handoff Order
この親Issueの child handoff は native parent 関係と下記の順序を正本とする。各 child は 1 Issue = 1 PR を維持し、重複する実装を並行して開始しない。
- 実装: control-plane preflight lifecycle 用 git-common-dir スコープ排他ロックを実装する #2198 が
git-common-dir + fixed dedicated identityの lifecycle mutex/lease primitive を提供し、remote identity observation 前に acquire された valid held lease を発行する。 - 実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197 は 実装: #2197向け remote protocol Git builderを閉鎖型に hardenする #2378 の閉鎖型 builder が main にあること、かつ 実装: control-plane preflight lifecycle 用 git-common-dir スコープ排他ロックを実装する #2198 の valid held lease を必須 prerequisite として、lease を保持したまま remote observe → fetch → pin → verify → detached worktree protocol を一意に実装する。
- 実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 は検証済み worktree を用いる child execution/identity dispatch を引き継ぎ、実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 は artifact processing と最終 validation を引き継ぐ。
- stdout/artifact validation が完了して初めて 実装: control-plane preflight lifecycle 用 git-common-dir スコープ排他ロックを実装する #2198 の lease を release する。timeout、lease invalidation、remote/protocol/validation failure は
control_plane_unavailableとして fail-closed し、release 後の再利用・fallback はしない。
#2198 は mutex/lease primitive のみ、#2197 は remote observe/fetch/pin/verify/worktree protocol のみを所有する。#2197 と #2198 を依存なし又は並行実装可能として扱わない。
In Scope
- fixed dedicated realpath専用のexact command classと、dedicated linked worktree identity検証(
WORKTREE_CATALOG_ENTRY_V1は変更せず、dedicated-lane専用のidentity probeを新設する。P1-1はこの非schema-change方式を採用する) - dedicated laneでは
CLAUDE_PROJECT_DIRをroot authorityに一切使わず、execution rootをinvocation cwdのrealpathとexact executor script所属worktreeから導出し、両者がdedicated catalog entryと一致しなければ停止。継承値がprimary root/別worktree/不一致pathでもretarget/fallbackしない - 専用Git subprocessが参照する
GIT_DIR/GIT_WORK_TREE/GIT_COMMON_DIR/GIT_INDEX_FILE/GIT_OBJECT_DIRECTORY/GIT_ALTERNATE_OBJECT_DIRECTORIES/GIT_CONFIG_GLOBAL/GIT_CONFIG_SYSTEM/GIT_CONFIG_COUNT系環境変数をunsetし、git executable絶対パスを一度解決して再利用し、core.hooksPathをtrusted empty directoryへ固定し、git ls-remote --get-urlのeffective URLを明示whitelistと照合する - regular issue-worktree bootstrapを変更せず、existing bootstrap executor内にfixed dedicated realpathのみを扱うexact initializer/refresh pathを追加。任意path/branch/base-ref/OIDをCLI入力に取らない(initializer command classとdedicated preflight runtime command classを分離する)
- initializerがremote symbolic default-refとOIDを一回観測し、必要object取得後にobserved OIDとfetched/local OID一致を検証してdetached linked worktreeをcreate/refresh。不一致/object unavailable/dirty-or-stale dedicated state/cleanup failureは
control_plane_unavailable - identity: catalog entryがちょうど一件、
--show-toplevel・--git-dir・--git-common-dir・trusted originがprimary repositoryと一致、symlink componentなし、detached HEAD、worktree HEADと同時観測したremote symbolic default-ref OIDが一致 - dedicated laneは
LOOP_DEFAULT_BRANCH、local fallback、origin/HEAD不在時のmain/master/trunk fallbackをidentity sourceにしない - remote OID drift時は開始前にdetached refreshを一回だけ試行し、snapshot bindingを再検証できなければ
control_plane_unavailable。開始後はobserved OIDに固定し常時最新は主張しない - lifecycle全体(catalog検証・remote観測・object取得・refresh・detached worktree作成・preflight child開始・artifact/stdout回収・cleanup)を
git-common-dir + fixed dedicated identityスコープの単一lockで直列化する。lock取得はbounded waitとし、timeout時はcontrol_plane_unavailable - artifact producerはdedicated worktree内に閉じ、primary/agent/別Issue artifactをimplicit read/copy/fallbackしない。handoffは既存
refinement_preflight_result/v1のverified bounded stdoutだけ - isolation agentのdirect executor禁止はtopologyでありsecurity boundaryと呼ばない
dedicated_runtime_migration(## Control Plane Worktree Contract参照)に列挙したproduction preflight 4 profileすべてを本Issueで移行する
Out of Scope
new global enforcing hook、generic worktree強制hook、schema/ledger/digest/checker/global permission planeの追加(WORKTREE_CATALOG_ENTRY_V1スキーマ変更を含む — P1-1はdedicated-lane専用probeで解決し、schema変更は行わない)、agent instructionをsecurity boundaryとして扱うこと、generic repair consumerやGitHub mutation semanticsの変更、regular issue-worktree bootstrapの一般仕様変更、initializer終了後にdedicated worktree内executorへre-execする設計(本Issueが採用するのは生存する親コントローラーが子processをsuperviseする構造であり、re-execや新しいlock protocolへの巻き戻しはOut of Scope)、contract_update.run.with_anchor / contract_update.run.with_human_context(main control-plane mutation phase)のdedicated worktree化 — これは既存の Issue #2393(OPEN、この責務を Current Validated Scope として既に所有)が扱う。本Issueは #2393 を重複して起票せず、本Issueの完了は #2393 をblockしない前提とする。
Allowed Paths
scripts/agent-guards/skill_runtime_command_policy.py
scripts/agent-guards/skill_runtime_exec.py
scripts/agent-ops/worktree_catalog.py
scripts/agent-ops/worktree_bootstrap_exec.py
scripts/agent-guards/worktree_bootstrap_command_policy.py
scripts/agent-guards/local_main_branch_guard.py
scripts/agent-guards/worktree_scope_guard.py
.claude/skills/issue-refinement-loop/scripts/command_registry.py
.claude/skills/issue-refinement-loop/SKILL.md
tests/agent_ops/test_control_plane_worktree_bootstrap.py
tests/agent_ops/test_control_plane_worktree_remote_binding.py
tests/agent_ops/test_control_plane_worktree_concurrency.py
tests/agent_ops/test_control_plane_worktree_cleanup.py
scripts/agent-guards/tests/test_skill_runtime_control_plane_policy.py
scripts/agent-guards/tests/test_skill_runtime_control_plane_exec.py
scripts/agent-guards/tests/test_control_plane_artifact_handoff.py
focused tests only.
Acceptance Criteria
- AC1: primary rootが任意branch/detached/dirty stateでも、bootstrap/refresh/preflightの全成功・失敗経路で、
primary_snapshot(toplevel_raw=git rev-parse --show-toplevel、head_mode_raw=git symbolic-ref -q HEADまたは明示DETACHEDマーカー、head_oid_raw=git rev-parse HEAD、status_raw=git status --porcelain=v2 -z --untracked-files=all)が実行前後でbyte-identicalのまま、dedicated contextとして成功又はcontrol_plane_unavailableでfail-closedする。.claude/worktrees/等gitignoreされたprimary側pathに置いたcanary fileへread/writeが発生しないことをfixtureで実証する。 - AC2: primary-root
CLAUDE_PROJECT_DIRを継承してもprimaryをread/write/child cwdに選ばずdedicated success又はfail-closedする。GIT_DIR/GIT_WORK_TREE/GIT_COMMON_DIR/GIT_INDEX_FILE/GIT_OBJECT_DIRECTORY/GIT_ALTERNATE_OBJECT_DIRECTORIES/GIT_CONFIG_GLOBAL/GIT_CONFIG_SYSTEM/GIT_CONFIG_COUNT系injection、およびurl.<base>.insteadOfによるorigin URL rewriteを同様にfail-closedで拒否する。 - AC3: missing/duplicate catalog entry、linkage mismatch、symlink component、non-detached head、default-ref ambiguity、OID mismatch、
LOOP_DEFAULT_BRANCHoverride、initializer/refresh failure、artifact/cross-issue mismatchはfail-closedしprimary fallbackしない。identity判定はdedicated-lane専用probe(entry自身のcwdから都度git rev-parse --show-toplevel/--absolute-git-dir/--git-common-dir/HEADとgit symbolic-ref -q HEADを取得し、catalog entryがちょうど一件であることを確認)で行い、WORKTREE_CATALOG_ENTRY_V1スキーマは変更しない。 - AC4: observed remote symbolic default-ref OID以外を認可しない。観測プロトコルは (a) lifecycle lock取得、(b) sanitized Git環境で
git ls-remote --get-urlのeffective URLが明示whitelistと一致することを確認、(c)git ls-remote --symref <literal-url> HEADを一度実行しHEAD->refs/heads/の一意性とOIDのvalidityを確認、(d) target refをnonce付きprivate refへ--no-tags --no-recurse-submodules --no-write-fetch-headでfetch、(e) private ref OIDとobserved OIDを比較しmismatch時は一度だけ再観測、(f)git cat-fileでobserved OIDがcommit objectであることを確認、(g) exact OIDでdetached+locked worktreeを作成、(h) worktree HEAD readback後にprivate refをgit update-refのcompare-and-swapでcompare-and-delete、の順で実行する。child開始後は再観測・refreshしない。single refresh後も再検証不能ならcontrol_plane_unavailable。 - AC5:
root-no-worktreeはcwd/contextを緩めない。 - AC6: dedicated artifact cleanupはverified dedicated root内でboundedに破棄できない場合停止し、prior artifactを暗黙reuseしない。dirty/unknown-owner worktreeには
git worktree remove --forceを使わず停止する。cleanup対象はfixed dedicated identityと検証済みartifact rootだけとし、cleanup_failed/artifact_escape/artifact_oversized/stale_artifactのreason codeを固定する。 - AC7: lifecycle全体(catalog検証・remote観測・object取得・refresh・detached worktree作成・preflight child開始・artifact/stdout回収・cleanup)は
git-common-dir + fixed dedicated identityスコープの単一lockで直列化する。lock取得はremote観測前、解放はstdout/artifact検証完了後。lock取得待ちはboundedとし、timeout時はcontrol_plane_unavailable。dedicated worktree自体はgit worktree add --detach --lock --reason <fixed-reason>で作成する。2並行process fixtureで「一方だけ成功、他方はbounded failure、primary不変」を実証する。 - AC8: 専用Git subprocess実行は、git executableの絶対パスを一度解決して全呼び出しで再利用し、
GIT_DIR等のrepository/config環境変数をunsetし、core.hooksPathをtrusted empty directoryへ固定(post-checkouthookが発火しないことをfixtureで実証)し、prompt/credential helper/interactive SSHを無効化する。threat modelは「誤った継承環境・通常のlocal configによるmisroutingをfail-closedする。same-UIDの能動的攻撃者には耐えない」と本文に明記する。 - AC9: initializer/refresh commandとdedicated preflight runtime commandは別command classとして分離する。initializerは
python3 scripts/agent-ops/worktree_bootstrap_exec.py --ensure-control-plane-preflight --json固定argvのみを受理し、--issue-number/--slug/--branch-name/--worktree-path/--base-ref/--oidは拒否する。dedicated preflight runtime commandは、bootstrap完了後にdedicated worktree内executorへre-execするのではなく、生存する親コントローラー(control_plane_dedicated_execution_session()、PR #2495で採用済みのexecution_topology、上記## Control Plane Worktree Contract参照)がlifecycle lockを保持したままdedicated worktree内でchild processをsuperviseする構造を正規architectureとする。invocation cwdとexact executor script所属worktreeの両方がdedicated catalog entryに一致しない限り停止する。 - AC10: 移行対象command IDは
## Control Plane Worktree Contractのdedicated_runtime_migrationで固定する。production preflight 4 profile(preflight.run/preflight.run.with_anchor/preflight.run.with_human_context/preflight.run.with_agent_report)を本Issueで移行し、test-only fixture profileは現状維持し、contract_update.run.with_anchor/contract_update.run.with_human_contextは本Issueの対象外とし、既存の Issue 実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393(この責務を Current Validated Scope として既に所有する OPEN Issue)へ明示的に委譲する。 - AC11: artifact handoffは既存stdout contract
refinement_preflight_result/v1をbyte-for-byte再利用する。parentはunverified pathを直接dereferenceせず、artifact pathはdedicated worktreeのtarget Issue rootのみを許可し、component-wise no-follow・regular-file限定・owner Issue一致・size/count上限を検証する。lifecycle lockはartifact検証完了まで保持する。 - AC12: focused subprocess/integration testsが上記の各Acceptance Criteriaを実証し、normal regular issue-worktree bootstrapの既存positive/negative matrixに回帰がない。新規dedicated-lane test群と既存legacy regression testの両方をVerification Commandsに含める。
Verification Commands
Focused Python tests(新規 dedicated-lane tests、Acceptance Criteria 全項目の positive evidence):
# AC1
# AC2
# AC3
# AC4
# AC5
# AC6
# AC7
# AC8
# AC9
# AC10
# AC11
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py tests/agent_ops/test_control_plane_worktree_remote_binding.py tests/agent_ops/test_control_plane_worktree_concurrency.py tests/agent_ops/test_control_plane_worktree_cleanup.py scripts/agent-guards/tests/test_skill_runtime_control_plane_policy.py scripts/agent-guards/tests/test_skill_runtime_control_plane_exec.py scripts/agent-guards/tests/test_control_plane_artifact_handoff.py -q既存 legacy tests(regression confirmation only、Acceptance Criteria の positive evidence にはしない):
# AC12
$ uv run --locked pytest tests/agent_ops/test_worktree_bootstrap_exec.py tests/codex/test_worktree_bootstrap_command_policy.py scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py -qRepository-wide gates:
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.pyRequired Skills
- worktree-bootstrap
Runtime Verification Applicability
decision: immediate
reason: "isolated linked-worktree fixtureでbootstrap/refresh/preflightの成功・失敗経路とprimary snapshot不変性を実証する。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 bare-origin git fixture(tmp directory + `git init --bare`)を構築できない実行環境ではSKIPではなくenvironment blockedとして扱う"
fallback_policy:
fallback_success_is_pass: false
notes: "fallback経由(例: primary checkoutの一時的な切替や許容緩和)での成功をPASSに変換しない。fail-closedな`control_plane_unavailable`はPASSと区別する。"
artifact_requirements:
- "pytest output(新規dedicated-lane test群 + 既存legacy regression test群)"
- "2並行processのconcurrency fixture output(AC7)"
- "primary_snapshotのbefore/after比較ログ(AC1)"Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- dedicated identityを証明できない、remote symbolic default-ref/OIDを観測・検証できない、primary fallbackまたはartifact escapeが必要、primary snapshot不変性を実証できない、既存regular bootstrapの互換性を維持できない、lifecycle lockを
git-common-dir + fixed dedicated identityスコープで実装できない、Git環境変数/insteadOf/hooksPathのsanitizationを実装できない場合は停止してcontrol_plane_unavailable又はfollow-upを記録する。
Required Design References
- docs/dev/agent-skill-boundaries.md
- docs/dev/workflow.md
- docs/dev/current-focus.md
- docs/product/playable-roadmap.md
.claude/skills/issue-refinement-loop/SKILL.md(Step 0g: main control-plane 限定 mutation phase の既存契約)- https://git-scm.com/docs/git-worktree.html(`--detach --lock --reason`、porcelain identity fields)
- https://git-scm.com/docs/git-config(`GIT_CONFIG_*` / repository discovery authority)
- https://git-scm.com/docs/git-ls-remote(`--symref` /
--get-url/insteadOfrewrite semantics) - https://git-scm.com/docs/githooks(`post-checkout` hook /
core.hooksPath) - https://git-scm.com/docs/git-fetch(`--no-write-fetch-head` /
--atomic) - https://git-scm.com/docs/git-update-ref.html(compare-and-swap ref update)
Activity
squne121 commentedon Aug 16, 2026
判定
VERDICT: REQUEST_CHANGES
implementation_allowed: false
Issue #2190 の方向性は妥当です。primary checkout を control-plane の都合で default branch に切り替えず、remote default-ref の観測 OID に固定した detached linked worktree だけを実行主体にする設計は、#2160 の事故原因に対する直接的な修復になっています。また、agent instruction や任意の path prefix を security boundary にしない点も、#1860 の minimal harness 方針と整合します。
ただし、現契約には 実装ゼロでも Verification Commands が成功し得る false-green、並行実行時の破壊的 race、Git 自体の環境・config・hook authority の未定義があります。2026年8月16日時点で Issue はコメント0件で、#2190を参照するPRも検索上0件です。そのため、今回は実装レビューではなく contract/現行資産に対する敵対的レビューです。パッチやCIは存在しないため、テスト実行による検証は行っていません。
P0-1: Verification Commands が全ACに対して false-green
Issue は「focused subprocess/integration tests」によって bootstrap・refresh・preflight・primary不変性を実証するとしていますが、指定されているPythonテストは既存の次の3本だけです。
policy anchor test は
canonical_main_root/default_branchからの実行を正常系として固定しているexecutor anchor test は
worktree_catalog.list_worktrees()を空配列でstubするno-worktree test は、まさにprimary root/active worktreeなしでの成功を正常系としている
つまり、専用worktree、detached HEAD、remote HEAD symref、remote OID drift、refresh、catalog uniqueness、並行実行、artifact confinementを一切実装しなくても、現在列挙されたテストは通過できます。実際のbootstrapテストである
tests/agent_ops/test_worktree_bootstrap_exec.pyすら Verification Commands に含まれていません。末尾のGemini model routing testも、本IssueのACとの因果関係がありません。必須修正
Issue本文に、新規テストファイルとACごとの対応を固定してください。最低限、次が必要です。
既存3テストは回帰確認として残せますが、ACのpositive evidenceにはできません。
P0-2: lifecycle全体を直列化する排他契約がない
現在の契約では、次の処理が別々に書かれています。
catalog検証
remote default-ref/OID観測
object取得
stale dedicated worktreeのrefresh
detached worktreeの作成
preflight child開始
artifact/stdout回収
cleanup
しかし、これらを同一transactionとして直列化するlockがありません。
このまま2つのparent sessionが同時に実行すると、一方がpreflight中のworktreeを、もう一方がremote driftとしてremove/refreshする経路が成立します。これでは「開始後はobserved OIDに固定」が保証されません。
Gitの
worktree add --lockは作成後のworktreeをprune・move・deleteから保護し、add後に別途lockする場合のraceも避けられます。ただし、これは 本Issueのremote観測・refresh・child実行全体を相互排他にするprocess lockではありません。したがって、別のrepository-common-dir単位のlockが必要です。(Git)必須修正
lockのscopeを
git-common-dir + fixed dedicated identityに固定するremote観測前に取得する
refresh/create/identity readback/child実行/stdoutとartifact検証完了まで保持する
lock取得待ちはboundedとし、timeout時は
control_plane_unavailableにするdedicated worktree自体は
git worktree add --detach --lock --reason <fixed-reason>で作る2並行process fixtureで「一方だけ成功、他方はbounded failure、primary不変」を実証する
P0-3:
CLAUDE_PROJECT_DIRだけを非authority化してもGitの実体選択は閉じない現行
resolve_project_root()はCLAUDE_PROJECT_DIRを最優先し、default branchはLOOP_DEFAULT_BRANCH、localorigin/HEAD、main/master/trunkの順で解決します。scope guardとlocal-main guardもCLAUDE_PROJECT_DIRをproject root authorityとして参照します。Issueがこの環境変数を排除する方向は正しいですが、Gitにはそれ以外のauthorityがあります。具体的には、以下がrepository、worktree、index、object database、configを変更します。
GIT_DIRGIT_WORK_TREEGIT_COMMON_DIRGIT_INDEX_FILEGIT_OBJECT_DIRECTORYGIT_ALTERNATE_OBJECT_DIRECTORIESGIT_CONFIG_GLOBALGIT_CONFIG_SYSTEMGIT_CONFIG_COUNT/GIT_CONFIG_KEY_*/GIT_CONFIG_VALUE_*Git公式仕様上、これらはrepository discoveryやobject/configの解決先を変更します。また
GIT_CONFIG_COUNT系はconfig fileをoverrideできます。(Git)さらに、canonicalなGitHub URLを設定していても
url.<base>.insteadOfによって別URLやcustom remote helperへ書き換えられます。git ls-remote --get-url自体が、このrewrite後のeffective URLを返す仕様です。(Git)現行bootstrap executorは各Git呼び出しで
shutil.which("git")を解決し、明示的なsanitized envを渡さずprocess environmentを継承しています。したがって、Issue本文の「trusted origin」は現状のままでは実装契約になっていません。加えて、
git worktree addは、--no-checkoutを付けない限りpost-checkouthookを実行します。repository/globalcore.hooksPathに依存したhookがprimaryやartifactへ副作用を出す可能性があります。(Git)必須修正
専用initializerとruntimeが実行する全Git subprocessについて、次を契約化してください。
Git executableの絶対パスを一度だけ解決し、全呼び出しで同じものを使用
上記
GIT_*repository/config変数をunsetsystem/global configの扱いを固定
HOME/global configからのURL rewriteを排除または検出git ls-remote --get-urlのeffective URLが明示whitelistと完全一致しない場合は停止Git commandごとに
core.hooksPathをtrusted empty directoryへ固定prompt、credential helper、interactive SSHを無効化
threat modelを「誤った継承環境・通常のlocal configによるmisroutingをfail-closedする。same-UIDの能動的攻撃者には耐えない」と明記
P0-4: 移行対象command IDが曖昧で、後段に同じbranch-switch誘因が残る
現行registryには、production preflightだけでも次があります。
分類 | command ID -- | -- production | preflight.run production | preflight.run.with_anchor production | preflight.run.with_human_context production | preflight.run.with_agent_report test-only | preflight.run.fixture test-only | preflight.run.fixture.with_human_contextproduction 4 profileはいずれも
canonical_main_root/default_branchを要求しています。さらに、後続のcontract_update.run.with_anchorとcontract_update.run.with_human_contextも同じroot/default invariantを持ち、SKILL.mdのStep 0gで「main control-plane限定」と明記されています。Issue #2190 がplain
preflight.runだけを移行した場合、human-contextやagent-report経路はprimary-boundのままです。またpreflight後にcontract updateへ進むと、再び「default branchへ戻せば実行できる」という誘因が発生します。必須修正
Issue本文に以下のmatrixを追加してください。
contract_update.run.を本Issueで扱わない場合は、Outcomeを「preflightだけのbranch-switch防止」に狭め、後段のmain-control-plane問題をfollow-upとして明示する必要があります。end-to-endでprimaryを変更しない、とは主張できません。P0-5: initializer authorityとdedicated runtime authorityが混同されている
専用runtimeについて、「invocation cwdとexact executor script所属worktreeの両方がdedicated catalog entryに一致しなければ停止」という契約は妥当です。
一方で、専用worktreeがまだ存在しない初回initializerは、そのworktree内のscriptから実行できません。現行bootstrap executorはinvocation cwdをproject rootとして採用し、primary worktreeであること、current branchがdefault branchであることを要求します。
Issueは「existing bootstrap executor内にinitializer/refresh pathを追加」としていますが、以下が未定義です。
initializerはどのworktreeから実行可能か
initializerがprimary上のPython sourceを読むことはAC2違反か
作成後にどのようにdedicated copyへre-execするか
refresh時に古いdedicated sourceと新しいremote OIDのどちらをauthorityにするか
exact initializer argvは何か
fixed pathのliteral値は何か
必須修正
二つのcommand classを分離してください。
bootstrap/refresh command
fixed pathを作るためだけの最小executor。任意path、branch、base ref、OIDを入力に取らない。
dedicated preflight runtime command
bootstrap完了後、dedicated worktree内のexecutorへre-execし、cwdとscript ownerの両方をcatalog entryへ束縛する。
推奨するinitializer grammarは、現在のgeneric branch/path入力を再利用せず、次のような独立形状です。
--issue-number、--slug、--branch-name、--worktree-path、--base-ref、--oidは受理しない形にするべきです。P1-1: 現行worktree catalogだけではAC3のidentityを証明できない
現行catalogには次の問題があります。
pathを即座に
realpath化するため、元のpath componentにsymlinkがあったかという証拠を失うlocked、prunable、bareをparseしないgit_common_dirをproject rootから一度だけ取得し、全entryに同じ値を代入するfind_by_realpath()は最初の一致だけを返し、exactly-oneを証明しないissue worktree selectorはbranch名とbasenameの両方を要求するため、fixed detached worktreeにはそのまま適用できない
Gitのporcelain形式にはdetached、locked、prunable等が含まれ、
--porcelain -zはscript向けのstable formatです。dedicated identity checkerはこれらを消費するべきです。(Git)必須修正
次のどちらかをIssue本文で選択してください。
WORKTREE_CATALOG_ENTRY_V1は変更せず、dedicated lane専用のidentity probeを新設するcatalogに必要fieldを追加するversioned schema changeをIn Scopeへ入れ、全consumer inventoryを作る
現在はOut of Scopeで「schema追加」を禁止している一方、必要なcatalog evidenceがV1に存在しません。
Schema Change Applicabilityセクションが必要です。専用probeでは、fixed pathの各componentを
lstatし、entry自身のcwdからそれぞれ次を取得する必要があります。「project rootから一度得たcommon-dirを全entryへコピーした値」はidentity evidenceに使えません。
P1-2: remote default-ref観測とfetchのprotocolが未決定
git ls-remote --symrefはremote HEADのsymbolic targetとOIDを観測できます。ただしupload-packがsymrefとして提示するのは現状HEADだけです。また--get-urlはinsteadOf適用後のURLを返します。(Git)Issue本文には「一回観測」「必要object取得」「observed OIDとfetched/local OID一致」とありますが、次が決まっていません。
remote nameを使うのかliteral URLを使うのか
target refをfetchするのかobserved OIDをfetchするのか
remote branchが観測とfetchの間に進んだ場合の判定
FETCH_HEAD、remote-tracking ref、temporary refのどれを変更するのかtag auto-follow、submodule、maintenanceを許可するか
temporary ref cleanupが失敗した場合の扱い
Git fetchはデフォルトで
FETCH_HEADを書きますが、--no-write-fetch-headで抑制できます。またlocal ref updateは--atomicでall-or-nothingにできます。(Git)推奨protocol
lifecycle lock取得
sanitized Git環境でeffective URLを検証
ls-remote --symref <literal-url> HEADを一度実行HEAD -> refs/heads/<name>が一意で、OIDがGit object nameとしてvalidであることを確認target refをnonce付きprivate refへ、no-tags/no-submodule/no-FETCH_HEADでfetch
private ref OIDとobserved OIDを比較
mismatchならremote driftとして観測から一度だけ再実行
cat-fileでobserved OIDがcommit objectとして利用可能なことを確認exact OIDでdetached/locked worktreeを作成
worktree HEAD readback後、private refをcompare-and-delete
child開始後は再観測・refreshしない
compare-and-swapを使う場合、Gitの
update-ref <ref> <new> <old>はold OID一致を検証して更新でき、transaction modeでは全ref lock取得失敗時に全体をabortできます。(Git)P1-3: primary不変性の観測面が曖昧で、ignored pathへの書込みを検出できない
AC1の「primary path/branch/HEAD/statusがbitwise-equivalent」は、何のcommand出力を比較するかが定義されていません。
さらに、このrepositoryでは
.claude/worktrees/、.claude/tmp/、artifacts/、.cache/などがgitignoreされています。したがってgit statusがbyte-identicalでも、primary側のignored pathへ書き込んだ事実は検出できません。加えて、現行executorのrepo snapshotは
.claude/worktreesと.claude/artifacts/issue-refinement-loopを「peer sessionによる変更と区別不能」として除外しています。#2190が使おうとしている場所が、既存のgeneric write auditからちょうど除外されています。linked worktreeはHEADとindexをworktree固有に持ちますが、
refs/やobject database等は共通です。したがって「repository全体がbitwise不変」は成立せず、「primary working-tree observable stateが不変」と「共有Git metadataに許される変更」を分ける必要があります。(Git)必須修正
primary snapshotを次のexact tupleとして定義してください。
さらに、primary側のignored pathへcanaryを置き、そこへのread/writeが起きないことをfixtureで検証する必要があります。
P1-4: artifact handoffとcleanupが具体的なI/O契約になっていない
registry上の既存stdout contractは
refinement_preflight_result/v1であり、SKILL.mdではSTATUS、NEXT_ACTION、MUST_READ、ARTIFACT等のline-oriented出力が定義されています。Issue #2190の「verified bounded stdout」は、これを再利用するのか、新しいenvelopeを導入するのか明記されていません。未定義なのは次です。
stdout最大byte数
UTF-8/newline/extra bytesの扱い
stderrをauthorityにするか
ARTIFACTpathをparentがいつ、どのroot基準で解決するかsymlink/FIFO/device/cross-Issue path
stdout検証とartifact読出しの間のTOCTOU
lifecycle lockをいつ解放するか
stale artifactを削除できない場合の具体的reason code
またGitはclean worktreeだけを通常removeでき、dirty/untracked worktreeのremoveにはforceが必要です。専用worktreeのartifactを理由に
--forceを使うと、予期しないfileを破棄する危険があります。(Git)必須修正
既存
refinement_preflight_result/v1をbyte-for-byte再利用するか、versioned envelopeを導入するか決定parentはunverified pathを直接dereferenceしない
artifact pathはdedicated worktreeのtarget Issue rootだけを許可
component-wise no-follow、regular-file限定、owner Issue一致、size/count上限を検証
artifact検証完了までlifecycle lockを保持
dirty/unknown-owner worktreeには
git worktree remove --forceを使わず停止cleanup対象はfixed dedicated identityと検証済みartifact rootだけ
cleanup_failed、artifact_escape、artifact_oversized、stale_artifact等のreason codeを固定推奨するIssue契約差分
Issue本文には最低限、次の機械可読contractを追加するべきです。
最低限必要なruntime test matrix
isolated bare-origin fixtureを使い、少なくとも以下を実Git subprocessで通す必要があります。
primaryがdefault以外のnamed branch、detached、dirtyの各状態でも成功またはfail-closedし、primary snapshot不変
CLAUDE_PROJECT_DIRがprimary、別worktree、存在しないpathでもretargetしないGIT_DIR、GIT_WORK_TREE、GIT_COMMON_DIR、GIT_CONFIG_COUNTinjectionを拒否insteadOfで別URL/custom helperへrewriteされた場合に拒否post-checkoutcanary hookが発火しないremote HEAD absent、non-symbolic、target absent、renamed default branch
remote refが観測とfetchの間に進むケースで一度だけ再観測
duplicate catalog entry、symlink component、non-detached、wrong common-dir、locked reason mismatch、prunable entry
2process同時bootstrap/refresh
primary/別Issue/別worktree artifact、symlink、FIFO、oversize stdout
dirty dedicated worktreeでforce removeせず停止
normal regular issue-worktree bootstrapの既存positive/negative matrixが全て維持される
推奨Verification Commandsは、少なくとも次の形です。
最終評価
#2190は、事故後の「今後は専用worktreeを使う」という行動宣言を、実行不能なtopologyへ変換しようとしている点では正しいです。しかし現状は、専用worktreeが存在しなくても通るテスト、remote identityを迂回できるGit環境、実行中worktreeをrefreshできるrace、後続command profileの取り残しが残っています。
#1588がlauncher/no-project-mutation、#1604がremote base identityを別scopeとして扱った precedentを踏まえると、#2190は少なくとも内部的に次の二層へ分離すべきです。
dedicated worktree initializer/remote binding/locking/cleanup
preflight command profile migration/artifact handoff/orchestrator cutover
PR #2143でも、単一のtest-only sibling profile追加に対してexact argv、symlink、artifact confinement、real subprocess、environment canaryまで検証しています。#2190はそれより大きいtrust-boundary変更なので、現在の3本のlegacy testだけで完了扱いにすることはできません。
# 判定VERDICT: REQUEST_CHANGES
implementation_allowed: false
Issue #2190 の方向性は妥当です。primary checkout を control-plane の都合で default branch に切り替えず、remote default-ref の観測 OID に固定した detached linked worktree だけを実行主体にする設計は、#2160 の事故原因に対する直接的な修復になっています。また、agent instruction や任意の path prefix を security boundary にしない点も、#1860 の minimal harness 方針と整合します。
ただし、現契約には 実装ゼロでも Verification Commands が成功し得る false-green、並行実行時の破壊的 race、Git 自体の環境・config・hook authority の未定義があります。2026年8月16日時点で Issue はコメント0件で、#2190を参照するPRも検索上0件です。そのため、今回は実装レビューではなく contract/現行資産に対する敵対的レビューです。パッチやCIは存在しないため、テスト実行による検証は行っていません。
P0-1: Verification Commands が全ACに対して false-green
Issue は「focused subprocess/integration tests」によって bootstrap・refresh・preflight・primary不変性を実証するとしていますが、指定されているPythonテストは既存の次の3本だけです。
canonical_main_root/default_branchからの実行を正常系として固定しているworktree_catalog.list_worktrees()を空配列でstubするつまり、専用worktree、detached HEAD、remote HEAD symref、remote OID drift、refresh、catalog uniqueness、並行実行、artifact confinementを一切実装しなくても、現在列挙されたテストは通過できます。実際のbootstrapテストである
tests/agent_ops/test_worktree_bootstrap_exec.pyすら Verification Commands に含まれていません。末尾のGemini model routing testも、本IssueのACとの因果関係がありません。必須修正
Issue本文に、新規テストファイルとACごとの対応を固定してください。最低限、次が必要です。
既存3テストは回帰確認として残せますが、ACのpositive evidenceにはできません。
P0-2: lifecycle全体を直列化する排他契約がない
現在の契約では、次の処理が別々に書かれています。
しかし、これらを同一transactionとして直列化するlockがありません。
このまま2つのparent sessionが同時に実行すると、一方がpreflight中のworktreeを、もう一方がremote driftとしてremove/refreshする経路が成立します。これでは「開始後はobserved OIDに固定」が保証されません。
Gitの
worktree add --lockは作成後のworktreeをprune・move・deleteから保護し、add後に別途lockする場合のraceも避けられます。ただし、これは 本Issueのremote観測・refresh・child実行全体を相互排他にするprocess lockではありません。したがって、別のrepository-common-dir単位のlockが必要です。([Git]1)必須修正
git-common-dir + fixed dedicated identityに固定するcontrol_plane_unavailableにするgit worktree add --detach --lock --reason <fixed-reason>で作るP0-3:
CLAUDE_PROJECT_DIRだけを非authority化してもGitの実体選択は閉じない現行
resolve_project_root()はCLAUDE_PROJECT_DIRを最優先し、default branchはLOOP_DEFAULT_BRANCH、localorigin/HEAD、main/master/trunkの順で解決します。scope guardとlocal-main guardもCLAUDE_PROJECT_DIRをproject root authorityとして参照します。Issueがこの環境変数を排除する方向は正しいですが、Gitにはそれ以外のauthorityがあります。具体的には、以下がrepository、worktree、index、object database、configを変更します。
GIT_DIRGIT_WORK_TREEGIT_COMMON_DIRGIT_INDEX_FILEGIT_OBJECT_DIRECTORYGIT_ALTERNATE_OBJECT_DIRECTORIESGIT_CONFIG_GLOBALGIT_CONFIG_SYSTEMGIT_CONFIG_COUNT/GIT_CONFIG_KEY_*/GIT_CONFIG_VALUE_*Git公式仕様上、これらはrepository discoveryやobject/configの解決先を変更します。また
GIT_CONFIG_COUNT系はconfig fileをoverrideできます。(Git)さらに、canonicalなGitHub URLを設定していても
url.<base>.insteadOfによって別URLやcustom remote helperへ書き換えられます。git ls-remote --get-url自体が、このrewrite後のeffective URLを返す仕様です。([Git]3)現行bootstrap executorは各Git呼び出しで
shutil.which("git")を解決し、明示的なsanitized envを渡さずprocess environmentを継承しています。したがって、Issue本文の「trusted origin」は現状のままでは実装契約になっていません。加えて、
git worktree addは、--no-checkoutを付けない限りpost-checkouthookを実行します。repository/globalcore.hooksPathに依存したhookがprimaryやartifactへ副作用を出す可能性があります。([Git]4)必須修正
専用initializerとruntimeが実行する全Git subprocessについて、次を契約化してください。
GIT_*repository/config変数をunsetHOME/global configからのURL rewriteを排除または検出git ls-remote --get-urlのeffective URLが明示whitelistと完全一致しない場合は停止core.hooksPathをtrusted empty directoryへ固定P0-4: 移行対象command IDが曖昧で、後段に同じbranch-switch誘因が残る
現行registryには、production preflightだけでも次があります。
preflight.runpreflight.run.with_anchorpreflight.run.with_human_contextpreflight.run.with_agent_reportpreflight.run.fixturepreflight.run.fixture.with_human_contextproduction 4 profileはいずれも
canonical_main_root/default_branchを要求しています。さらに、後続のcontract_update.run.with_anchorとcontract_update.run.with_human_contextも同じroot/default invariantを持ち、SKILL.mdのStep 0gで「main control-plane限定」と明記されています。Issue #2190 がplain
preflight.runだけを移行した場合、human-contextやagent-report経路はprimary-boundのままです。またpreflight後にcontract updateへ進むと、再び「default branchへ戻せば実行できる」という誘因が発生します。必須修正
Issue本文に以下のmatrixを追加してください。
contract_update.run.*を本Issueで扱わない場合は、Outcomeを「preflightだけのbranch-switch防止」に狭め、後段のmain-control-plane問題をfollow-upとして明示する必要があります。end-to-endでprimaryを変更しない、とは主張できません。P0-5: initializer authorityとdedicated runtime authorityが混同されている
専用runtimeについて、「invocation cwdとexact executor script所属worktreeの両方がdedicated catalog entryに一致しなければ停止」という契約は妥当です。
一方で、専用worktreeがまだ存在しない初回initializerは、そのworktree内のscriptから実行できません。現行bootstrap executorはinvocation cwdをproject rootとして採用し、primary worktreeであること、current branchがdefault branchであることを要求します。
Issueは「existing bootstrap executor内にinitializer/refresh pathを追加」としていますが、以下が未定義です。
必須修正
二つのcommand classを分離してください。
bootstrap/refresh command
fixed pathを作るためだけの最小executor。任意path、branch、base ref、OIDを入力に取らない。
dedicated preflight runtime command
bootstrap完了後、dedicated worktree内のexecutorへre-execし、cwdとscript ownerの両方をcatalog entryへ束縛する。
推奨するinitializer grammarは、現在のgeneric branch/path入力を再利用せず、次のような独立形状です。
--issue-number、--slug、--branch-name、--worktree-path、--base-ref、--oidは受理しない形にするべきです。P1-1: 現行worktree catalogだけではAC3のidentityを証明できない
現行catalogには次の問題があります。
realpath化するため、元のpath componentにsymlinkがあったかという証拠を失うlocked、prunable、bareをparseしないgit_common_dirをproject rootから一度だけ取得し、全entryに同じ値を代入するfind_by_realpath()は最初の一致だけを返し、exactly-oneを証明しないGitのporcelain形式にはdetached、locked、prunable等が含まれ、
--porcelain -zはscript向けのstable formatです。dedicated identity checkerはこれらを消費するべきです。(Git)必須修正
次のどちらかをIssue本文で選択してください。
WORKTREE_CATALOG_ENTRY_V1は変更せず、dedicated lane専用のidentity probeを新設する現在はOut of Scopeで「schema追加」を禁止している一方、必要なcatalog evidenceがV1に存在しません。
Schema Change Applicabilityセクションが必要です。専用probeでは、fixed pathの各componentを
lstatし、entry自身のcwdからそれぞれ次を取得する必要があります。「project rootから一度得たcommon-dirを全entryへコピーした値」はidentity evidenceに使えません。
P1-2: remote default-ref観測とfetchのprotocolが未決定
git ls-remote --symrefはremote HEADのsymbolic targetとOIDを観測できます。ただしupload-packがsymrefとして提示するのは現状HEADだけです。また--get-urlはinsteadOf適用後のURLを返します。([Git]3)Issue本文には「一回観測」「必要object取得」「observed OIDとfetched/local OID一致」とありますが、次が決まっていません。
FETCH_HEAD、remote-tracking ref、temporary refのどれを変更するのかGit fetchはデフォルトで
FETCH_HEADを書きますが、--no-write-fetch-headで抑制できます。またlocal ref updateは--atomicでall-or-nothingにできます。([Git]5)推奨protocol
ls-remote --symref <literal-url> HEADを一度実行HEAD -> refs/heads/<name>が一意で、OIDがGit object nameとしてvalidであることを確認cat-fileでobserved OIDがcommit objectとして利用可能なことを確認compare-and-swapを使う場合、Gitの
update-ref <ref> <new> <old>はold OID一致を検証して更新でき、transaction modeでは全ref lock取得失敗時に全体をabortできます。([Git]6)P1-3: primary不変性の観測面が曖昧で、ignored pathへの書込みを検出できない
AC1の「primary path/branch/HEAD/statusがbitwise-equivalent」は、何のcommand出力を比較するかが定義されていません。
さらに、このrepositoryでは
.claude/worktrees/、.claude/tmp/、artifacts/、.cache/などがgitignoreされています。したがってgit statusがbyte-identicalでも、primary側のignored pathへ書き込んだ事実は検出できません。加えて、現行executorのrepo snapshotは
.claude/worktreesと.claude/artifacts/issue-refinement-loopを「peer sessionによる変更と区別不能」として除外しています。#2190が使おうとしている場所が、既存のgeneric write auditからちょうど除外されています。linked worktreeはHEADとindexをworktree固有に持ちますが、
refs/*やobject database等は共通です。したがって「repository全体がbitwise不変」は成立せず、「primary working-tree observable stateが不変」と「共有Git metadataに許される変更」を分ける必要があります。(Git)必須修正
primary snapshotを次のexact tupleとして定義してください。
さらに、primary側のignored pathへcanaryを置き、そこへのread/writeが起きないことをfixtureで検証する必要があります。
P1-4: artifact handoffとcleanupが具体的なI/O契約になっていない
registry上の既存stdout contractは
refinement_preflight_result/v1であり、SKILL.mdではSTATUS、NEXT_ACTION、MUST_READ、ARTIFACT等のline-oriented出力が定義されています。Issue #2190の「verified bounded stdout」は、これを再利用するのか、新しいenvelopeを導入するのか明記されていません。未定義なのは次です。
ARTIFACTpathをparentがいつ、どのroot基準で解決するかまたGitはclean worktreeだけを通常removeでき、dirty/untracked worktreeのremoveにはforceが必要です。専用worktreeのartifactを理由に
--forceを使うと、予期しないfileを破棄する危険があります。(Git)必須修正
refinement_preflight_result/v1をbyte-for-byte再利用するか、versioned envelopeを導入するか決定git worktree remove --forceを使わず停止cleanup_failed、artifact_escape、artifact_oversized、stale_artifact等のreason codeを固定推奨するIssue契約差分
Issue本文には最低限、次の機械可読contractを追加するべきです。
最低限必要なruntime test matrix
isolated bare-origin fixtureを使い、少なくとも以下を実Git subprocessで通す必要があります。
CLAUDE_PROJECT_DIRがprimary、別worktree、存在しないpathでもretargetしないGIT_DIR、GIT_WORK_TREE、GIT_COMMON_DIR、GIT_CONFIG_COUNTinjectionを拒否insteadOfで別URL/custom helperへrewriteされた場合に拒否post-checkoutcanary hookが発火しない推奨Verification Commandsは、少なくとも次の形です。
最終評価
#2190は、事故後の「今後は専用worktreeを使う」という行動宣言を、実行不能なtopologyへ変換しようとしている点では正しいです。しかし現状は、専用worktreeが存在しなくても通るテスト、remote identityを迂回できるGit環境、実行中worktreeをrefreshできるrace、後続command profileの取り残しが残っています。
#1588がlauncher/no-project-mutation、#1604がremote base identityを別scopeとして扱った precedentを踏まえると、#2190は少なくとも内部的に次の二層へ分離すべきです。
dedicated worktree initializer/remote binding/locking/cleanup
preflight command profile migration/artifact handoff/orchestrator cutover
PR #2143でも、単一のtest-only sibling profile追加に対してexact argv、symlink、artifact confinement、real subprocess、environment canaryまで検証しています。#2190はそれより大きいtrust-boundary変更なので、現在の3本のlegacy testだけで完了扱いにすることはできません。
squne121 commentedon Aug 16, 2026
issue-refinement-loop 終了報告
approvedapprove(blockers 0)sha256:8503780ac304bcfd5fce89092feeb0e121d201d6754560281822f001de5976b1反映内容(コメント #issuecomment-5304990703 を踏まえた rewrite)
adversarial review コメント(
VERDICT: REQUEST_CHANGES,implementation_allowed: false)で指摘された P0-1〜P0-5 / P1-1〜P1-4 を Issue 本文へ反映した。git-common-dir + fixed dedicated identityスコープの lifecycle lock(AC7)を In Scope / AC に追加GIT_DIR等 Git 環境変数・insteadOfrewrite・core.hooksPathの sanitization 契約(AC2 / AC8)を追加contract_update.run.*は fail-closed follow-up へ明示的に委譲(AC10、Outcome を preflight branch-switch 防止に narrow化)WORKTREE_CATALOG_ENTRY_V1は変更せず、dedicated-lane 専用 identity probe を新設する非 schema-change 方式を採用(AC3、Out of Scope に明記)primary_snapshotの exact tuple(toplevel_raw/head_mode_raw/head_oid_raw/status_raw)と gitignored path への canary fixture を AC1 に明記コメントが提案した
control_plane_worktree_contractmachine-readable block は## Control Plane Worktree Contractセクションとして本文に追加した(## Machine-Readable Contractの required key は置き換えていない)。併せて、本 refinement 中に検出した既存 fail-closed blocker(
Machine-Readable Contract節欠落、Parent Issue節欠落、Required Design References節欠落、Stop Conditions 定型6項目欠落、Runtime Verification Applicability のapplicable_acs等5フィールド欠落、AC⇔VC番号整合、Required Skills のワークフロースキル混入)も同一 rewrite で解消した。次アクション
issue-contract-reviewは本 loop 内では実行していない(CONTRACT_REVIEW_RESULT_V1未生成)。実装着手前にissue-contract-reviewを実行し、freshgo判定を得ること。[-]fix: bind issue-refinement control-plane preflight to a dedicated linked worktree[/-][+]実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree[/+]feat: sanitized Git subprocess execution utility for control-plane pr…
squne121 commentedon Aug 16, 2026
追加の live 再現証跡(Issue #2195 refinement loop 実行中に観測)
2026-08-16、Issue #2195 の issue-refinement-loop 実行中に、canonical main root checkout(
/home/squne/projects/LOOP_PROTOCOL)の branch/HEAD が、本セッションが能動的にgit checkoutを発行していないにもかかわらず2回意図せず変化しました。main→ detached HEAD(commit3862fa28、worktree-issue-2204-codex-transport-httpへの merge commit)git checkout main && git reset --hard origin/mainで復旧後、2回目:main→ named branchtest-pr-head(commit6cc0c559、PR 実装: repair_action.apply の controlled Issue transaction consumer を追加する #2202 の head と一致)git reflogには他にもpr-2205-review-tmp-check/test-pr-2205/worktree-issue-2204-codex-transport-httpなど、本セッションが発行していない複数の branch checkout 履歴が残っており、同一 root checkout を複数の並行 agent セッション(本Issueが指摘する #2160 の topology、または他の並行 issue-refinement-loop / impl-review-loop 実行)が共有していることを示唆します。read-only 調査(SubAgent、causal script search)では、これらの branch 名をハードコードするスクリプトは repo 内に見つからず(
reproducible_causal_path_found: false)、代わりにgit worktree listで ~45 の linked worktree が確認され、root 自体を共有 mutable state として使う topology 上の構造的リスクであることが裏付けられました。local_main_branch_guard(#1014 が導入、#1691 で意図的に無効化)はこの class の事故を fail-closed に防止する目的の hook でしたが、false-positive block(Write拒否・gh issue comment拒否・read-only compound command 誤ブロック)のため撤去されています。本Issueが提案する「primary checkout の branch switch に依存しないtopology」への移行は、hook を復活させることなくこの根本原因を解消するアプローチとして妥当と考えます。参考: 本件により Issue #2195 の review pipeline 実行(
run_root_review_pipeline.py produce)が一時的に不安定な環境で実行される結果となりました(別の diagnosis で timeout の主因ではないと判定済みですが、寄与要因として記録します)。squne121 commentedon Aug 28, 2026
Dependency rationale: #2198 owns only the lifecycle mutex/lease primitive; #2197 is the single remote-protocol owner after #2378 and a valid held lease. The parent handoff order is now explicit.
squne121 commentedon Sep 7, 2026
Delivery Step: #2190 全AC最終検証・親issueクローズ(#2200 Delivery Rule)
Issue #2200 の
## Delivery Ruleに従い、#2200 merge 後の delivery step として #2190 の残る AC evidence を記録する。Child Issue / PR evidence(既存 Child1-4 + 関連PR)
contract_update.run.*委譲分)全7 child issueはCLOSED(stateReason: COMPLETED)であることを
gh api graphql(subIssues)で確認済み。Fresh critical regression(本Issue #2200 PR #2557 で取得、head
9e968e6ef146941546dcc9d874a880a8b2f67a79)AC12(「新規dedicated-lane test群と既存legacy regression testの両方がPASSし、既存positive/negative matrixに回帰がない」)に対応する fresh evidence:
tests/agent_ops/test_control_plane_worktree_bootstrap.py/test_control_plane_worktree_remote_binding.py/test_control_plane_worktree_concurrency.py/test_control_plane_worktree_cleanup.pyscripts/agent-guards/tests/test_skill_runtime_control_plane_policy.py/test_skill_runtime_control_plane_exec.py/test_control_plane_artifact_handoff.pytests/agent_ops/test_worktree_bootstrap_exec.py/tests/codex/test_worktree_bootstrap_command_policy.py/scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py/test_skill_runtime_exec_anchor.py(PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520/#2533由来のcontract_update inner-transaction regression testを含む)/test_skill_runtime_preflight_no_worktree.pypnpm typecheck/lint/test(1920 passed)/build)とgemini-cli-headless-delegationmodel_routing pytest: すべてPASS9e968e6eで全20チェックPASS(required checks含む)結論
#2190 の全AC(AC1-AC12)は、既存 Child1-4/#2378/#2393 PR evidence と、本 delivery step で取得した fresh critical regression(AC12対応、304 passed/0 failed)により満たされていることを確認した。Delivery Rule に従い、#2190 の historical child test 全件の毎回再演は要求しない(既存 PR evidence + fresh critical regression で足りるとする既定方針に従う)。
本issueをクローズする。