Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#2190"
goal_ref: "#2197 の remote default-ref OID protocol を実装可能にする closed typed Git builder と fail-closed hardening を提供する"
change_kind: codeParent Issue
Parent Goal Ref
- Goal: 実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 は control-plane preflight を sanitized、detached、remote-default-ref-pinned dedicated worktree に束縛する。
- Desired Destination: 実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 の shared sanitized Git subprocess layer を、実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197 が消費できる remote-protocol 専用 closed builder surface へ狭く harden する。
Current Validated Scope
- remote protocol を実装せず、実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197 が remote observe、fetch、pin、verify を配線するための closed typed builder/hardening と focused behavioral tests だけを変更する。
scripts/agent-guards/skill_runtime_command_policy.pyは literal URL、allowed ref、repository object-format OID の structural validation と closed-builder argument policy の single authority として必要である。generic argv allowlist にはしない。
Current-main確認根拠
current main 9f3b2fb7a48354661de325e42b0239a6903c3899 の skill_runtime_exec.py は generic run_control_plane_git_ls_remote(repo)、fetch(repo, refspec)、cat_file(object_id)、update_ref(ref, new_oid)、variadic worktree(action, *args) だけを持つ。この surface は effective remote URL readback、exact git ls-remote --exit-code --symref <literal-url> HEAD、fixed private-ref fetch、CAS delete、fixed-reason detached worktree を表現できない。内部 runner は per-call subprocess.run timeout であり、dedicated Git process-group cleanup と shared deadline plus cleanup reserve を持たない。command policy は global Git option を拒否するが、remote-protocol ref/OID/literal-URL validation を提供していない。
Remaining Parent Gaps
- 実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197 が本 Issue の builder を消費して
scripts/agent-opsに remote observe to fetch to pin to verify protocol を実装する。 - 実装: control-plane preflight lifecycle 用 git-common-dir スコープ排他ロックを実装する #2198 の lifecycle lock、identity and dispatch migration、artifact confinement は別 scope のまま残る。
Outcome
Updated scripts/agent-guards/skill_runtime_exec.py and scripts/agent-guards/skill_runtime_command_policy.py provide the closed typed, fail-closed Git builder contract required by #2197, and focused behavioral pytest passes without restoring raw argv or list[str] authority.
Runtime Verification Applicability
decision: immediate
reason: "All builder semantics, validation failures, process-group cleanup, and deadline reserve can be exercised in isolated temporary Git fixtures."
applicable_acs: [AC1, AC2, AC3, AC4, AC5, AC6, AC7]
execution_environment:
cli_tools: [python3, uv, git]
auth_required: false
network_required: false
skip_conditions:
- "If git is unavailable, record environment_blocked; do not pass via a fallback."
fallback_policy:
fallback_success_is_pass: false
notes: "Raw argv, lazy fetch, unbounded subprocess, or uncleaned process-group fallback is a failure."
artifact_requirements:
- "pytest output for both focused test files"
- "fixture trace of exact Git argv, process-group cleanup, and deadline reserve"In Scope
- Replace remote-protocol-relevant generic builders with closed typed semantic operations. No public or production-reachable internal API may accept arbitrary argv, variadic args, or
list[str]authority. - Add an effective remote URL readback and whitelist comparison builder, and an exact builder for
git ls-remote --exit-code --symref <literal-url> HEAD; validate the literal URL structurally before execution and retain existing sanitized environment and rewrite rejection. - Add a fixed private-ref fetch builder that internally fixes
--no-tags --no-recurse-submodules --no-write-fetch-headand no-lazy-fetch behavior. The caller cannot choose fetch flags, refspec shape, or private-ref name. - Add closed readback builders for private-ref OID and worktree HEAD, a CAS-only private-ref delete builder requiring expected OID, and typed validation for permitted refs, repository object-format OIDs, and an existing commit object before detached worktree input.
- Add a closed detached locked worktree builder whose lock reason is a fixed internal constant. It may receive only typed validated path and commit OID data; it cannot receive a Git action, flags, or lock reason.
- Run every builder invocation in a dedicated Git process group. On timeout, probe failure, or exception, terminate and reap the group before returning or raising.
- Replace independent per-call timeout authority with one shared protocol deadline object that reserves nonzero cleanup time and refuses terminal command spawn when the reserve would be consumed.
- Extend only the focused tests with behavioral fixtures for exact argv, invalid data rejection, no-side-effect/no-lazy-fetch constraints, CAS mismatch, commit and object-format validation, detached locked fixed-reason worktree plus HEAD readback, group cleanup, and deadline reserve.
Out of Scope
- Implementing or wiring the remote observe to fetch to pin to verify protocol in
scripts/agent-ops/worktree_bootstrap_exec.pyorscripts/agent-ops/worktree_catalog.py; 実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197 is the sole consumer. - Lifecycle locking, invocation or dedicated-worktree identity, profile migration, primary-checkout invariant, artifact confinement, and
WORKTREE_CATALOG_ENTRY_V1schema changes. - A generic Git wrapper, new production command dispatch path, or any raw argv or
list[str]authority.
Acceptance Criteria
- AC1: Focused tests prove effective remote URL readback runs
git ls-remote --get-urland compares the exact whitelist literal; mismatch or rewrite attempt fails closed before remote operation. - AC2: Focused tests prove the symref builder issues exactly
git ls-remote --exit-code --symref <literal-url> HEADand rejects option-like, non-literal, or rewriteable URL input. - AC3: Focused tests prove fixed private-ref fetch emits
--no-tags --no-recurse-submodules --no-write-fetch-headand no-lazy-fetch constraints, and exposes no caller-controlled flags, refspec, or private-ref name. - AC4: Focused tests prove policy accepts only allowed refs and repository object-format OIDs, reads private-ref OID and worktree HEAD through closed builders, and requires an existing commit object before worktree construction.
- AC5: Focused tests prove cleanup emits only CAS delete
git update-ref -d <private-ref> <expected-oid>and rejects mismatch and generic update or write semantics. - AC6: Focused tests prove the worktree builder emits only detached, locked, fixed-reason semantics and accepts success only when post-add HEAD readback equals the validated commit OID.
- AC7: Focused tests prove every builder uses a dedicated Git process group, terminates and reaps descendants on timeout, probe failure, and exception, and shares one deadline with nonzero cleanup reserve that prevents terminal spawn.
Verification Commands
# AC1
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_control_plane_policy.py -q# AC2
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_control_plane_exec.py -q# AC3
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_control_plane_exec.py -q# AC4
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_control_plane_policy.py -q# AC5
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_control_plane_exec.py -q# AC6
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_control_plane_exec.py -q# AC7
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_control_plane_exec.py -q$ pnpm typecheck$ pnpm lint$ pnpm test$ pnpm build$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py -qAllowed Paths
scripts/agent-guards/skill_runtime_exec.pyscripts/agent-guards/skill_runtime_command_policy.pyscripts/agent-guards/tests/test_skill_runtime_control_plane_exec.pyscripts/agent-guards/tests/test_skill_runtime_control_plane_policy.py
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- Semantic builder が exact command shape を表現できない、実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197 consumer または Allowed Paths 外の変更が必要、または raw argv authority の復活が必要と判明した場合は停止して blocker を記録する。
Required Skills
なし
Required Design References
docs/dev/agent-skill-boundaries.mddocs/dev/workflow.md- 実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 / 実装: control-plane preflight 用 sanitized Git subprocess 実行基盤を新設する #2196 / 実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197 / 実装: control-plane preflight lifecycle 用 git-common-dir スコープ排他ロックを実装する #2198
- https://git-scm.com/docs/git-ls-remote
- https://git-scm.com/docs/git-fetch
- https://git-scm.com/docs/git-update-ref.html
- https://git-scm.com/docs/git-worktree.html
Dependency / #2197 handoff
- This Issue is the hard predecessor of 実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197. Only after it merges may 実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197 wire the semantic builders to its remote observe to fetch to pin to verify protocol.
- Handoff artifact: closed typed builder contract and focused behavioral tests only; no bootstrap or catalog mutation is delivered here.
- Scope collision record: 実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 literally overlaps all Allowed Paths. This edit intent is narrower than 実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 lifecycle delivery, and 実装: control-plane preflight の remote default-ref OID observe/fetch/pin/verify プロトコルを実装する #2197 is explicitly blocked by this Issue; do not parallel-edit an overlapping PR.
Delivery Rule
1 Issue = 1 PR. Use a dedicated worktree and Draft PR. Keep the native blocking dependency to #2197 and do not start #2197 implementation on these paths until this PR and focused tests are in main.
Scope Delta(任意)
N/A
Activity
fix: fail closed on escaped Git descendants (#2378)
feat(#2197): control-plane remote default-ref observe/fetch/pin/verif…