Repository navigation
Open
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "worktree bootstrap を project environment(.venv/uv.lock)を変更しない direct Python launcher に統一し、malformed input を executor 自身が fail-closed にする"
change_kind: workflow
supersedes:
- "#1209 worktree bootstrap の RTK 一段 envelope 互換契約"
compatibility_change: "RTK 一段 envelope と legacy uv launcher は worktree bootstrap では canonical launcher として扱わない"
migration_required: trueParent Issue
なし(単独改善)
Parent Goal Ref
- Goal: root checkout の default branch を維持したまま、implementation Issue の専用 worktree を
.venv/uv.lockを変更しない direct Python launcher で作成できるようにする。 - Desired Destination:
python3 scripts/agent-ops/worktree_bootstrap_exec.py ... --jsonの direct invocation が production caller(implementation-worker/implement-issue)の canonical supported path になっており、executor 自身が argv・path・branch・repo・default branch を検証し、malformed input を fail-closed にする。
Current Validated Scope
scripts/agent-ops/worktree_bootstrap_exec.py(control-plane がgit show HEAD:で直接確認済み、464行)は既に次を実装している。- repository root 検証(
_validate_repo_root) - slug 妥当性検証(
_is_valid_slug) - branch 名検証(
check-ref-format相当) - symlink escape guard
- worktree 作成後の readback(post-creation の存在確認)
- repository root 検証(
- 現在の production invocation は
uv run --locked python3 scripts/agent-ops/worktree_bootstrap_exec.py ...(.claude/skills/implement-issue/SKILL.md:70)であり、uv run --lockedを経由する。uv run --lockedは.venvの作成を防止せず、stale lock の失敗も保証しない(--lockedは lock file と pyproject の整合を検証するだけで、--no-syncなしでは venv 同期が発生し得る)。 .venv/uv.lockを変更しないことを isolated fixture で実証する既存テストは repo 内に存在しない。- 実装: implement-issue の worktree bootstrap を controlled executor 化し、rtk/raw git policy 衝突を解消する #1209(CLOSED)は direct command と RTK 一段 envelope を同値として許可したが、本 Issue はその互換契約を撤回し、direct
python3単一形状を canonical launcher とする。
Remaining Parent Gaps
なし
Outcome
python3 scripts/agent-ops/worktree_bootstrap_exec.py ... --json が、production caller(implementation-worker/implement-issue)の唯一の canonical supported path となり、project fixture 内で .venv と uv.lock を新規作成・変更しない状態。executor 自身が exact argv・path・branch・repo・default branch を検証し、malformed input(wrong flag、extra positional、path traversal 等)を fail-closed で拒否する。
In Scope
- production caller(
implementation-worker.md/implement-issue/SKILL.md)の Worktree / Branch 手順を、uv run --locked python3 ...から directpython3 scripts/agent-ops/worktree_bootstrap_exec.py ... --jsoninvocation へ変更する。JSON status / worktree path の読取りも direct Python の標準出力から行う。 worktree_bootstrap_exec.pyに、malformed input(unknown flag、duplicate flag、--flag=value形式の混在、想定外の positional 引数、shell metacharacter を含む引数)を executor 自身が起動直後に fail-closed で拒否する入力検証を追加する(現状の repository/branch/path/slug 検証に加えて、CLI 引数 shape の検証を明示的に追加する)。- isolated temporary Git repository で canonical launcher(direct
python3)を実 subprocess として実行し、.venvabsent / existing、uv.lockabsent / stale / existing の各ケースで.venvtree digest、uv.lockSHA-256、git status --porcelain=v1 -zが不変であることを検証する。 - 実装: implement-issue の worktree bootstrap を controlled executor 化し、rtk/raw git policy 衝突を解消する #1209 の RTK 一段 envelope 互換を撤回する caller inventory と migration note を、Skill/Agent 定義内(
docs/dev/hook-boundaries.mdではなく、.claude/skills/implement-issue/SKILL.mdまたはdocs/dev/agent-skill-boundaries.md)に記録する。
Out of Scope
worktree_bootstrap_exec.pyの branch/path/repository validation、JSON schema、worktree 作成以外の domain behavior の変更(既存実装を維持する)。origin/<default-branch>の remote-tracking base identity preservation(実装: worktree bootstrap の origin/default-branch base ref を保持する #1604 の責務)。- Claude Code/Codex CLI Hook(
local_main_branch_guard、worktree_scope_guard等)による raw command の block/allow、Hook parity、Hook wrapper subprocess test の追加・修正。 - RTK launcher・legacy
uv runlauncher を Hook レベルで deny すること(Hook を authority にしないため、この形の deny は実装しない。production caller が directpython3のみを使用することで足りるとする)。 .claude/settings.json/.codex/rules/**の変更。uvoption grammar、toolchain pin の再設計。- raw
git worktree add、RTK wrapper、shell wrapper の Hook レベル許可判定。 uv.lock、.venv、GitHub branch protection の無効化または迂回。
Acceptance Criteria
- AC1:
implementation-worker.md/implement-issue/SKILL.mdの Worktree / Branch 手順が、uv run --locked python3 ...ではなく directpython3 scripts/agent-ops/worktree_bootstrap_exec.py ... --jsonの canonical invocation のみを記載している - AC2:
worktree_bootstrap_exec.pyが起動直後に unknown flag/duplicate flag/--flag=value/想定外 positional/shell metacharacter を含む malformed input を fail-closed で拒否し、git worktree addを実行しない - AC3: isolated project fixture で canonical launcher を実 subprocess として実行し、
.venvabsent / existing とuv.lockabsent / stale / existing の全ケースで.venvtree digest、uv.lockSHA-256、git status --porcelain=v1 -zが不変であることを検証する - AC4: worktree 作成後、executor が作成された worktree の存在・path・branch を readback し、readback 失敗時は success を返さない(既存 postcondition の回帰確認)
- AC5: 実装: implement-issue の worktree bootstrap を controlled executor 化し、rtk/raw git policy 衝突を解消する #1209 の RTK envelope 互換の撤回について caller inventory・migration note が
.claude/skills/implement-issue/SKILL.mdまたはdocs/dev/agent-skill-boundaries.mdに記録されている
Runtime Verification Applicability
runtime_verification_applicability:
decision: immediate
reason: "temporary Git repository と direct Python subprocess を使い、malformed input の fail-closed 拒否と project-file non-mutation を実行境界で決定論的に検証できる。"
applicable_acs: [AC2, AC3, AC4]
execution_environment: "WSL2 Ubuntu 24.04、Python 3.12+、git、pytest"
skip_conditions:
- "python3 または git が利用できず isolated fixture を起動できない場合"
fallback_policy: "static parser test のみを runtime verification 成功として扱わず、実 subprocess test が実行不能なら blocked とする。"
artifact_requirements:
- "tests/agent_ops/test_worktree_bootstrap_exec_argv_validation.py の pytest output"
- "tests/agent_ops/test_worktree_bootstrap_direct_python_nonmutation.py の project-file digest assertions"Verification Commands
# AC1
# baseline-expect: pass
$ rg -n "worktree_bootstrap_exec.py" .claude/agents/implementation-worker.md .claude/skills/implement-issue/SKILL.md
# baseline-expect: pass
$ rg -n "uv run --locked python3 scripts/agent-ops/worktree_bootstrap_exec.py" .claude/skills/implement-issue/SKILL.md# AC2
$ uv run --locked pytest tests/agent_ops/test_worktree_bootstrap_exec_argv_validation.py -v# AC3
$ uv run --locked pytest tests/agent_ops/test_worktree_bootstrap_direct_python_nonmutation.py -v# AC4
# baseline-expect: pass
$ uv run --locked pytest tests/agent_ops/test_worktree_bootstrap_exec.py -v# AC5
$ rg -n "#1209" .claude/skills/implement-issue/SKILL.md docs/dev/agent-skill-boundaries.mdAllowed Paths
scripts/agent-ops/worktree_bootstrap_exec.py.claude/skills/implement-issue/SKILL.md.claude/agents/implementation-worker.mddocs/dev/agent-skill-boundaries.mdtests/agent_ops/test_worktree_bootstrap_exec_argv_validation.pytests/agent_ops/test_worktree_bootstrap_direct_python_nonmutation.pytests/agent_ops/test_worktree_bootstrap_exec.py
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合。
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合。
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)。
- 後続 Phase / 別スコープへの波及が判明した場合。
- nested SubAgent delegation が必要になった場合。
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合。
worktree_bootstrap_exec.pyの branch/path/repository validation や JSON schema の domain behavior 変更が必要と判明した場合。- isolated fixture で
.venv、uv.lock、または project Git status の非変更を実証できない場合。 - Hook、settings、Codex rules の変更が実装に必要と判明した場合(本 Issue のスコープ外であり着手しない)。
origin/<default-branch>の base ref identity 保持が本 Issue の実装対象に含まれると判明した場合(実装: worktree bootstrap の origin/default-branch base ref を保持する #1604 の責務であり、混入させない)。
Required Skills
- Python 3
- Git
- subprocess-based fixture testing
Required Design References
docs/dev/agent-skill-boundaries.md.claude/skills/implement-issue/SKILL.md- Issue 実装: implement-issue の worktree bootstrap を controlled executor 化し、rtk/raw git policy 衝突を解消する #1209 / PR feat(#1209): worktree bootstrap controlled executor #1216
Scope Delta
SCOPE_DELTA_V1:
decision: reframe_in_place
reason: "#1860 Owner Decision により、Claude/Codex Hook を worktree bootstrap の authority にしない executor-only 契約へ改訂したため"
removed_contract:
- "local_main_branch_guard / worktree_scope_guard による raw RTK/legacy launcher の Hook-level deny"
- "Claude/Codex shared guard parity テスト"
- ".claude/settings.json / .codex/rules/** の変更"
- "Hook boundary を completion condition とする AC"
- "#1595(共有 launcher parser、Hook 向け)を blocking dependency とすること"
kept_contract:
- "python3 scripts/agent-ops/worktree_bootstrap_exec.py ... --json を canonical launcher とすること"
- ".venv / uv.lock 非変更の isolated fixture 検証"
- "executor 自身による exact argv / path / branch / repo / default branch validation"
- "malformed input の executor-level fail-closed"
compatibility_impact: "production caller(implementation-worker / implement-issue)の bootstrap invocation は direct python3 canonical shape へ移行する"
rollback: "対象 PR の squash revert で direct-only policy を撤回し、旧 uv run 呼び出しに戻す"Scope Collision Evidence
Scope Collision (C1): related_issue=#1209, #1604; overlapping_paths=.claude/skills/implement-issue/SKILL.md, .claude/agents/implementation-worker.md, scripts/agent-ops/worktree_bootstrap_exec.py(path のみ、domain 分離)。
- non_conflict_reason: 実装: implement-issue の worktree bootstrap を controlled executor 化し、rtk/raw git policy 衝突を解消する #1209 は CLOSED の旧 RTK envelope 契約であり本 Issue が明示的に supersede する。実装: worktree bootstrap の origin/default-branch base ref を保持する #1604 は
origin/<default-branch>の remote-tracking base identity preservation を扱い、本 Issue の launcher 形状(direct python vs uv run/malformed input fail-closed)とは異なる関心事を扱う。実装: worktree bootstrap の origin/default-branch base ref を保持する #1604 は本 Issue の direct executor contract を dependency として参照するが、本 Issue は 実装: worktree bootstrap の origin/default-branch base ref を保持する #1604 の base-ref 解決ロジックに触れない。 - edit_intent: production caller の invocation 形状を direct
python3に統一し、executor 自身の malformed input fail-closed と.venv/uv.lock非変更を実証する。 - dependency ordering: 本 Issue は独立して着手可能(実装: launcher command 共有 parser(argv boundary 保持・cwd/project_root 対応)を抽出し全 consumer の invocation contract を移行する #1595/Hook 関連の blocking dependency は解消済み)。実装: worktree bootstrap の origin/default-branch base ref を保持する #1604 は本 Issue のマージ後、current main を readback してから着手する。
Delivery Rule
- 1 Issue = 1 PR
- 作業前に fresh
CONTRACT_REVIEW_RESULT_V1 status: goを取得する。 - normal commit / push のみを使用し、force push、guard bypass、hook disable を行わない。
Notes for Reviewer
- 本改訂は issue-refinement-loop(実装: Agent/Skill の重複を削減し progressive disclosure へ移行する #1732 Child C 改訂作業の一部)により、旧版(Claude/Codex shared guard parity・local_main_branch_guard/worktree_scope_guard 変更・RTK/legacy launcher の Hook-level deny・Hook wrapper test・実装: launcher command 共有 parser(argv boundary 保持・cwd/project_root 対応)を抽出し全 consumer の invocation contract を移行する #1595 blocking dependency を In Scope としていた版)を全面差し替えしたものである。旧版の historical comment は削除・改変していない。
- 撤回した理由:
#1860Owner Decision により、Hook はこの系列の authority・security boundary・dependency・AC にしないことが確定した。Web research で、Claude Code の Hook は「local workflow guardrail であり security boundary ではない」ことが公式ドキュメントで確認されている。 - 維持した理由:
worktree_bootstrap_exec.py自身の repository/branch/path/slug validation、worktree 作成後の readback、.venv/uv.lock非変更の実証は、Hook の有無に関わらず bootstrap の安全性を担保する実体であり、そのまま維持・強化する。
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Activity
squne121 commentedon Jul 18, 2026
判定: REQUEST_CHANGES / 実装開始不可
方向性自体は妥当です。bare
uv runを privileged bootstrap の canonical launcher にしないこと、unknown flag・順序変更・wrapper を fail-closed にすること、Claude/Codex が同じ policy を参照することは正しい設計です。ただし現契約には、ACを実現できない Allowed Pathsと、採用予定 launcher 自体が AC6 を破る実挙動があります。
P0-1:
uv run --locked --no-syncは.venv非変更を保証しないuv公式仕様では、project 内のuv runは project environment を作成・更新してからコマンドを実行します。--no-syncは environment の同期を省略しますが、project environment の作成まで禁止するとは規定されていません。また--no-syncは--frozenを含意します。([Astral Docs]1)実際に
uv 0.10.0で次を検証しました。pyproject.tomlとuv.lockがある一時 project を作成.venvは存在しない状態pyproject.tomlを変更してuv.lockを stale にするuv run --locked --no-sync python3 -c 'print("ok")'を実行結果は以下です。
0.venvが新規作成された--lockederror にならなかったつまり、Issue の以下の主張は成立しません。
.venvを変更しない--lockedによる lock freshness の担保リポジトリ側も uv executable の明示的な version 入力を持っておらず、patch/version reproducibility の判断を扱う #375 は未完了です。flag の意味を guard policy の安全性根拠にするには不安定です。
必須修正
第一候補は、uv を bootstrap boundary から除外することです。
worktree_bootstrap_exec.pyと、その直接 import 先はここで確認した範囲では標準ライブラリとリポジトリ内モジュールだけで構成されています。リポジトリの Python 要件も 3.12 です。uv を残す必要があるなら、少なくとも project discovery を切る形へ設計し直す必要があります。
ただしこの場合、
--lockedは契約から消えます。Issue のタイトル・Outcome・ACを「project-independent launcher」へ変更すべきです。--offlineは network access、--no-python-downloadsは interpreter の自動取得を止める別の責務です。([Astral Docs]2)P0-2: wrapper deny は現在の Allowed Paths では実装不能
現行 shared policy は先頭の
rtkを明示的に許可しています。しかし、単にこの policy から
rtk対応を削除しても、Codex/local-main 側では拒否できません。local_main_branch_guard.pyは shared policy を呼ぶ前に次の処理を行っています。rtkを検出先頭の
rtkを除去内側の argv から
normalized_cmdを再構築その direct command を worktree bootstrap policy に渡す
したがって、
は policy 到達時には、
へ変換され、Codex/local-main では allow され続けます。
一方、Claude の
worktree_scope_guardは raw command をそのまま shared policy に渡すため、こちらだけ reject されます。つまり現状のままでは、以下を同時に満たせません。
必須の Scope Delta
Allowed Paths に最低でも以下を追加してください。
実装方法は、generic RTK unwrap より前に raw command に対して次の順序で判定するのが安全です。
P1-1: bootstrap 手順には bare
uv runがまだ2回残る現行
implement-issueの Step 3 は executor をuv run --lockedで呼んだ後、JSONを読むために bareuv run python3 -cを2回実行しています。uv runは既定で lock と environment sync を行います。したがって launcher の一行だけを変更しても、worktree bootstrap procedure 全体は lock/sync-free になりません。([docs.astral.sh]1)JSON解析には外部依存が不要なので、次のように direct Python にすべきです。
AC4には次を追加すべきです。
P1-2: #1209 の既存互換契約を無言で破棄している
元の Issue #1209 と merged PR #1216 は、direct command と
rtk一段 envelope を意図的に同値として許可しました。テストも両形状を positive fixture に固定しています。#1588 はこれを破棄しますが、以下がありません。
supersedesまたは migration recordRTK は Bash command を透過的に intercept/rewrite する運用を公式に推奨しています。wrapper 拒否は単なるテスト更新ではなく、既存 agent runtime の互換性変更です。([GitHub]3)
Machine-Readable Contract に、少なくとも次を加えるべきです。
P1-3: 親 #1580 と後続 #1601 の最新契約から既に drift している
#1588 は #1580 を有効化することを Parent Goal としていますが、最新の #1580 / #1601 は canonical launcher を次に固定しています。
さらに #1601 は #1588 を dependency ではなく「path-only overlap」として扱い、shared guard/parser integration の前提を #1595 としています。
#1595 は実際に
local_main_branch_guard.pyとworktree_scope_guard.pyの launcher parsing contract を変更する予定です。#1588 の Scope Collision Evidence に #1595 がなく、dependency ordering も定義されていません。次のいずれかが必要です。
P1-4: AC6 のテストは現状、launcher を一度も実行していない
現在の
tests/agent_ops/test_worktree_bootstrap_exec.pyは、すべてsys.executableで Python script を直接起動しています。uv runの挙動は検証していません。したがって、現在の Verification Command を実行しても次は証明されません。
AC6には具体的な fixture 契約が必要です。
pyproject.toml、uv.lock、.python-versionを持つ project fixture.venvabsent と existing の両ケースuv.lockSHA-256.venvの存在有無と tree digestgit status --porcelain=v1 -zの before/after現 launcher をこの fixture に通すと、少なくとも
.venvabsent ケースは失敗するはずです。P1-5: Verification Command が実際に壊れている
Issue 内の AC5 は次です。
rg -n "--locked --no-sync" docs/dev/hook-boundaries.mdripgrep は
--locked --no-syncを option と解釈します。手元の ripgrep 14.1.1 では次の結果でした。正しくは次です。
rg -n -- "--locked --no-sync" docs/dev/hook-boundaries.mdまた、Issue 内の
CI_TEST_PERFORMANCE_DECISION_V1は Ruff とpnpm buildを required command としていますが、Verification Commands には両方ありません。Issue 内部で gate 定義が一致していません。P2: Hook Boundary SSOT の既存記述が実装と矛盾している
docs/dev/hook-boundaries.mdは、active issue worktree 時に bootstrap allowlist を導入しないと記述しています。しかし実装は、worktree bootstrap executor を明示的に allow しています。
AC5は新しい説明を追記するだけでなく、以下を必須にすべきです。
修正後に必要な最小契約
結論
現状の #1588 は、policy parser の token 差し替え Issue としては実装してはいけません。
最大の問題は、提案 launcher が
.venv非変更を保証せず、さらに Codex guard の前段 unwrap により wrapper deny が成立しないことです。まず launcher を direct Python または project-independent invocation に再設計し、local_main_branch_guard.pyを Allowed Paths に追加した上で、#1209/#1595/#1601 との契約関係を更新する必要があります。squne121 commentedon Jul 18, 2026
Contract Review Result
squne121 commentedon Jul 18, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedsqune121 commentedon Jul 18, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedCorrection: the contract review is fresh
go, but implementation handoff remains blocked until #1595 is merged.squne121 commentedon Jul 18, 2026
impl-review-loop: 人間判断要請(2026-07-18T10:51:00Z)
#1595が OPEN のままです。実装: worktree bootstrap を direct Python/no-project-mutation launcher に統一する #1588 の blocking dependency と Stop Condition により、shared launcher parser の consumer contract が main に反映されるまで Step 1 実装を開始できません。runner_unavailable。ただし上記の依存ブロッカーにより実装は開始していません。squne121 commentedon Aug 5, 2026
#1732 系列 issue-refinement-loop による本文改訂(2026-08-05)
#1860(Minimal harness decision)の Owner Decision を反映し、本 Issue の本文を全面改訂しました。撤回した契約:
local_main_branch_guard/worktree_scope_guardの Hook-level allow/deny 追加uv runlauncher の Hook-level deny.claude/settings.json/.codex/rules/**の変更docs/dev/hook-boundaries.md)を completion condition とする AC#1595(共有 launcher parser、Hook 向け)を blocking dependency とすること理由:
#1860Owner Decision により、Claude/Codex Hook はこの系列の authority・security boundary・dependency・AC にしないことが確定しました。production caller(implementation-worker/implement-issue)が directpython3invocation のみを使用することで足りるとし、Hook レベルの deny は実装しません。維持した契約(executor safety):
python3 scripts/agent-ops/worktree_bootstrap_exec.py ... --jsonを canonical launcher とすること.venv/uv.lock非変更の isolated fixture 検証worktree_bootstrap_exec.pyの repository/branch/path/slug validation と worktree 作成後 readback は既に current main に実装済みであることを control-plane がgit show HEAD:で直接確認済みです。現在の production invocation はuv run --locked python3 ...であり、本 Issue はこれを directpython3 ...へ変更します。本改訂は #1732 系列の issue-refinement-loop の一部です。旧本文は削除せず、上記コメントの下に新本文として反映します。
squne121 commentedon Aug 5, 2026
issue-refinement-loop iteration 2(review needs-fix 対応)
前回改訂に対する issue-reviewer レビューで、Verification Commands の VC 注記に関する human_judgment blocker が指摘されました。以下を修正しました。
# baseline-expect: pass注記を追加-k "readback"フィルタが既存テストに一致しなかったため、フィルタを外して既存test_worktree_bootstrap_exec.py全体を参照する回帰確認 VC に変更し、# baseline-expect: pass注記を追加issue-contract-review の pre-edit static readiness check で
status: goを再確認済みです。[-]実装: worktree bootstrap の locked/no-sync exact launcher を guard policy に統合する[/-][+]実装: worktree bootstrap を direct Python/no-project-mutation launcher に統一する[/+]squne121 commentedon Aug 5, 2026
タイトル更新(issue-refinement-loop 追記)
旧タイトル「実装: worktree bootstrap の locked/no-sync exact launcher を guard policy に統合する」は、本文改訂(Hook/guard policy への統合を撤回)と矛盾していたため、Owner Decision の推奨タイトルへ変更しました。
新タイトル: 実装: worktree bootstrap を direct Python/no-project-mutation launcher に統一する