Repository navigation
Description
Parent Issue
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1592"
goal_ref: "Issue contract から検証済み scope snapshot を生成し、controlled executor が literal pathspec で stage/commit を単一transactionとして所有する共通境界を構築する"
change_kind: workflowParent Goal Ref
- Goal: Codex 固有の CODEX_ALLOWED_PATHS 入力を repository guard の正規契約から廃止し、Claude/Codex 共通で説明可能な安全な publish 境界へ移行する implementation Issue を起票可能にする。
- Desired Destination: 調査: CODEX_ALLOWED_PATHS を廃止する共通 publish 境界を設計する #1592 の調査結果(issuecomment-5010971038、RESEARCH_RESULT_V1)で採用された設計を実装する 2 件の implementation Issue(Child A: staging/commit 実装、Child B: Codex edit env removal)を起票し、Child A を先行実装する。
Current Validated Scope
- Issue scope snapshot の拡張 schema(repository/Issue/contract source/branch/protected policy hash を bind する private/local artifact)の定義・生成
- controlled stage/commit executor(
scripts/agent-guards/controlled_git_change_exec.py相当)の新規実装 allowed_paths_review_gate.pyの matcher・normalizer・拡張 ChangedFileRecord(mode/OID 込み)を共有 module へ抽出scripts/agent-guards/git_mutation_command_policy.pyの rtk git add/commit classifier を controlled executor 経由のみ許可する形へ変更- protected_paths_policy(
PROTECTED_PATHS_POLICY_V1、言語非依存 JSON SSOT + Python/Node validated mirror)の実装 - Codex 側(
.codex/rules/default.rules・.codex/config.toml・scripts/check-codex-agents.mjs)の rawgit add/git commitallow rule を controlled executor 専用へ整合させる - rename・deletion・type change・submodule gitlink change・特殊文字パス・pathspec magic・directory pathspec・stale snapshot(comment drift 含む)・HEAD/branch race・index race・concurrent agent の negative test
- Issue 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542・実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963 の disposition 記録(Child A マージ後の別ステップとして close 実行、本 Issue 自体は code 実装のみ)
- 旧 env(CODEX_ALLOWED_PATHS 等)と新 snapshot が同時 authority にならない設計(authority version 状態遷移、fail-closed rollback)
Remaining Parent Gaps
- Child B(Codex apply_patch/Edit/Write hook の
CODEX_ALLOWED_PATHS_MODE廃止、native permission profile への全面移行)は本 Issue の対象外であり、別 Issue として後日起票する。本 Issue が触れる Codex 側変更は「raw git add/commit の allow rule 整合」のみに限定する。 - 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542・実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963 の実際の close 実行(本 Issue の code 変更完了後の別ステップ)。
- remote push(LOOP_PUBLISH_* lane)へ snapshot fingerprint を publish evidence として含める拡張(将来 follow-up、本 Issue には含めない)。
ensure_contract_snapshot.pyとの producer 統合は、本 Issue では「新 schema が同等以上の bind 情報を持つこと」を要件とし、既存 producer の廃止・置換自体は別 Issue(follow-up)に委ねる(本 Issue の Allowed Paths をensure_contract_snapshot.pyまで広げないため)。
Outcome
Issue contract から検証済み scope snapshot(拡張 ISSUE_SCOPE_SNAPSHOT_V1)を生成し、controlled executor が literal pathspec で stage・rename/mode/OID-aware 検査・commit を、監査失敗時に自動 rollback する単一の固定 transaction フローとして所有する。raw git add/git commit/rtk git add/rtk git commit は agent lane では controlled executor 外で deny し、Codex 側の static rule(.codex/rules/default.rules)もこの deny と整合させる。matcher/normalizer/ChangedFileRecord は .claude/skills/pr-review-judge/scripts/allowed_paths_review_gate.py から共有 module へ抽出し、staging/commit/review で同一 grammar を使う。protected paths policy は言語非依存 JSON SSOT を正本とし、Issue Allowed Paths より優先させる。remote push(LOOP_PUBLISH_* lane)は変更しない(Out of Scope)。全 AC が実装ファイル・テストファイルに対する検証コマンドで PASS している状態を完了条件とする。
In Scope
- Issue scope snapshot 拡張 schema:
schema: ISSUE_SCOPE_SNAPSHOT_V1、repository_full_name、issue_number、contract_source_kind(issue_body | issue_comment)、contract_source_id、contract_source_body_sha256、issue_body_sha256、issue_updated_at、comments_digest_sha256、allowed_paths(正規化済み一覧)、allowed_paths_normalized_sha256、allowed_paths_matcher_schema(ALLOWED_PATHS_MATCHER_V1)、base_ref、base_sha、branch_ref、worktree_realpath、protected_paths_policy_schema(PROTECTED_PATHS_POLICY_V1)、protected_paths_policy_sha256(version 文字列でなく policy 内容の sha256)、authority_mode(old_only|migration_validation|new_only|new_disabled_fail_closed)を必須フィールドとして bind する。GitHub live readback(issue body・comments digest)を必須とし、取得失敗・rate limit・comment 消失は fail-closed で snapshot 生成を拒否する。 - controlled stage/commit executor(
scripts/agent-guards/controlled_git_change_exec.py相当)の新規実装。固定 transaction フロー(案B: partial commit + audit-then-rollback)を採用する:- live contract 再検証(snapshot の body_sha256/comments_digest/branch/base_sha を現在の GitHub 状態・worktree HEAD と照合、drift があれば deny)
- repository/worktree/branch/HEAD/Issue binding 検証
git --literal-pathspecs add --pathspec-from-file=- --pathspec-file-nulで NUL 区切り literal path のみ stage(directory pathspec・pathspec magic は事前拒否)git diff-index --cached --raw --full-index -z -M <EXPECTED_HEAD>で staged 変更を再取得し、mode/OID/status/path を監査(rename 旧新 path、deletion、type change、submodule gitlink(mode 160000)、unmerged stage、T、未対応 status、provenance 不足を拒否)- staged 集合と requested 集合の一致確認、protected path 拒否
git commit --only --pathspec-from-file=- --pathspec-file-nul -m <message>で、stage 済みかつ指定 path のみを対象に commit する(pre-existing の無関係な staged 変更を commit に含めない)- commit 後、
git diff-index --rawで commit 内容を再監査し、要求集合と不一致なら 即座にgit reset --soft HEAD~1で自動 rollback しstatus: denyを返す(成功して見える commit を残さない) - env sanitization: 子プロセスへ渡す環境から
GIT_DIR/GIT_COMMON_DIR/GIT_WORK_TREE/GIT_INDEX_FILE/GIT_OBJECT_DIRECTORY/GIT_ALTERNATE_OBJECT_DIRECTORIES/GIT_CONFIG_SYSTEM/GIT_CONFIG_GLOBAL/GIT_CONFIG_COUNT/GIT_EXEC_PATH/GIT_CEILING_DIRECTORIESを除去・上書きする - fail-closed 対象: detached HEAD、unborn branch、merge/rebase/cherry-pick 進行中、unmerged index、snapshot/path/message file の symlink・hardlink、snapshot file 過大サイズ、wrong repo/worktree/cwd、shell wrapper・追加 argv、deadline 超過、crash 後の ambiguous 状態
- commit hook:
git commit --onlyは通常の commit hook(pre-commit/prepare-commit-msg/commit-msg)を実行することを明記し、hook 実行有無を暗黙にしない。 - NUL 区切りの path はすべて bytes として扱い、UTF-8 でデコードできない path は明示的に unsupported として fail-closed にする。
allowed_paths_review_gate.pyの matcher・normalizer・拡張ChangedFileRecord(status/path/previous_path/old_mode/new_mode/old_oid/new_oid/provenance_complete)を共有 module へ抽出し、認可 oracle をgit diff-index --cached --raw --full-index -z -Mベースへ統一する(--name-statusは人間向け監査補助としてのみ残してよいが認可 oracle にしない)。scripts/agent-guards/git_mutation_command_policy.pyのrtk git add/rtk git commitclassifier を、controlled executor 経由の呼び出しのみ許可する形に変更し、rawgit add/git commitは agent lane(PreToolUse hook 経由)で deny する。- protected_paths_policy:
scripts/agent-guards/protected_paths_policy.v1.json(言語非依存 JSON SSOT、schema: PROTECTED_PATHS_POLICY_V1、rules: [{"kind": "root_directory", "path": "assets"}, {"kind": "root_directory", "path": "LICENSES"}, {"kind": "basename_glob", "pattern": ".env"}, {"kind": "basename_glob", "pattern": ".env.*"}, {"kind": "root_directory", "path": "secrets"}]相当)を正本とし、scripts/agent-guards/protected_paths_policy.pyはこの JSON を読み込む Python loader として実装する(ハードコードしない)。.codex/config.toml・.claude/settings.json・scripts/check-codex-agents.mjsは既存の deny 実装をこの JSON の内容に対する validated mirror として整合させる(CI または起動時整合性チェックで一致を検証、内容の sha256 を snapshot にも bind する)。 - Codex 側の raw git add/commit allow rule 整合:
.codex/rules/default.rulesがrtk git add/rtk git commit -mを明示的に allow している現状を、controlled executor 経由のみ allow する形に変更する。既存のscripts/ci/codex_execpolicy_matrix.py(Issue 実装: codex execpolicy gate を fail-open から fail-closed へ修正し、execpolicy と hook の責務境界を明確化する (#1137 Blocker10 follow-up) #1150 由来、worktree cleanup lane 用の execpolicy matrix runner。本 Issue で新設しない)のexecpolicy_case_definitions()に、少なくとも次の command × static rule × hook result の組み合わせのケースを追加する:git add x(forbidden/deny)、git commit -m x(forbidden/deny)、rtk git add x(forbidden/deny)、rtk git commit -m x(forbidden/deny)、exact controlled executor invocation(allow/allow)、executor + 余分な argv(forbidden/deny)、executor viabash -lc(forbidden/deny)、executor from main root checkout(forbidden/deny)、wrong Issue/worktree での executor 呼び出し(deny)。 - rename(旧新 path)、deletion、type change、submodule gitlink change(mode 160000 判定)、特殊文字パス(bytes/NUL 区切り、UTF-8 非対応 path の fail-closed)、pathspec magic、directory pathspec、stale snapshot(Issue body および comment 更新後の drift)、HEAD/branch race、index race、concurrent agent の negative test。
- 旧 env(CODEX_ALLOWED_PATHS 等)と新 snapshot が同時 authority にならない設計。authority 状態遷移は
old_only→migration_validation(old: authority、new: shadow comparison のみ)→new_only(snapshot/executor のみが authority)→ 緊急停止時はnew_disabled_fail_closed(add/commit を停止し、旧 env authority への自動 fallback は行わない。復旧は明示的な release rollback 手続きとして扱う)とする。 - Issue 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542・実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963 の disposition 記録(Child A マージ後に 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542 を not_planned で close、実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963 を重複部分 supersede で close/scope reduction)。ただし 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542・実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963 自体の close 実行は Child A の code 変更完了後の別ステップとし、Child A 自体は code 実装のみ行う。
Out of Scope
- remote push(LOOP_PUBLISH_*)lane の再設計・変更
- Codex apply_patch/Edit/Write hook の
CODEX_ALLOWED_PATHS_MODE廃止そのもの(Child B の対象。本 Issue が触れるのは raw git add/commit の Codex static rule 整合のみ) CODEX_ALLOWED_PATHS/CODEX_ALLOWED_PATHS_MODE/CODEX_LEGACY_ALLOW_WRITESenv 自体の削除(Child B の対象、Child A は新 contract を追加して parallel 稼働させる段階に留める)git diff --cached --name-only(rename-unaware、mode/OID 情報なし)を認可 oracle として使うこと- broad staging(
git add -A/git add ./wildcard pathspec)の許可 ensure_contract_snapshot.pyを唯一の producer に統合する実装そのもの(follow-up 対象。本 Issue は新 schema の bind 情報が同等以上であることのみを担保する)- private
GIT_INDEX_FILE+commit-tree+update-refcompare-and-swap(案A)の実装(本 Issue は案B:git commit --only+ audit-then-rollback を固定採用する)
Acceptance Criteria
- AC1: Issue scope snapshot の拡張 schema が定義され、
repository_full_name・issue_number・contract_source_kind・contract_source_id・contract_source_body_sha256・issue_body_sha256・issue_updated_at・comments_digest_sha256・allowed_paths_normalized_sha256・base_ref/base_sha・branch_ref・worktree_realpath・protected_paths_policy_sha256・authority_modeを bind している - AC2: controlled stage/commit executor が、通常の explicit pathspec での stage/commit を許可する
- AC3: controlled stage/commit executor が、rename(旧新 path 両方)を
git diff-index --cached --raw --full-index -z -Mで検査し Allowed Paths 判定する - AC4: deletion, type change, submodule gitlink change(mode 160000)が old/new mode を用いて明示的に分類され、それぞれ Allowed Paths 判定される
- AC5: 特殊文字(Unicode/改行/quote/leading dash)を含む path が NUL 区切り bytes で安全に扱われ、UTF-8 非対応 path は fail-closed になる
- AC6: pathspec magic(top/exclude 指定、glob)と directory pathspec が
--literal-pathspecsと--pathspec-from-file=- --pathspec-file-nulにより拒否される - AC7: staged 集合と requested 集合が不一致の場合に commit 前または commit 後監査で fail-closed に deny し、commit 後監査で不一致が判明した場合は
git reset --soft HEAD~1で自動 rollback する - AC8: stale snapshot(Issue body または comment 更新後の sha256/digest drift)と branch/HEAD race 検出時に deny する
- AC9: raw
git add/git commit/rtk git add/rtk git commitが controlled executor 外で deny される(git_mutation_command_policy.pyの negative test) - AC10: protected paths(JSON SSOT
protected_paths_policy.v1.jsonに定義された assets 配下、LICENSES 配下、dotenv 系ファイル、secrets 配下)が Issue Allowed Paths の記載に関わらず常に deny される - AC11:
allowed_paths_review_gate.pyの matcher/normalizer/拡張 ChangedFileRecord が共有 module へ抽出され、staging/commit/review で同一 grammar を使うことが test で確認できる - AC12: 旧 env(CODEX_ALLOWED_PATHS 等)と新 snapshot が同時に authority にならない(
old_only/migration_validation/new_only/new_disabled_fail_closedの状態遷移 test。new_disabled_fail_closedで add/commit が停止し旧 env へ自動 fallback しないことを含む) - AC13: 新規ファイル(
controlled_git_change_exec.py,changed_file_matcher.py,protected_paths_policy.py,codex_execpolicy_matrix.py)が py_compile 相当の import チェックに成功し、かつ既存test_git_mutation_command_policy.pyとtest_allowed_paths_review_gate.pyの既存 test が全て PASS し続ける(regression gate) - AC14: 既存
scripts/ci/codex_execpolicy_matrix.pyのexecpolicy_case_definitions()に、git add x/git commit -m x/rtk git add x/rtk git commit -m xは forbidden・deny、exact controlled executor invocation は allow・allow、余分な argv・bash -lc経由・main root からの実行・wrong Issue/worktree は deny となるケースが追加され、新設scripts/agent-guards/tests/test_controlled_git_change_exec.pyから当該モジュールを import して該当ケースの存在と decision を検証するテストで確認できる
Verification Commands
# AC1
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_git_change_exec.py -k test_scope_snapshot_binds_required_fields
# AC2
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_git_change_exec.py -k test_explicit_pathspec_stage_commit_allowed
# AC3
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_git_change_exec.py -k test_rename_old_and_new_path_checked
# AC4
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_git_change_exec.py -k test_deletion_type_change_submodule_classified
# AC5
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_git_change_exec.py -k test_special_char_paths_nul_delimited
# AC6
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_git_change_exec.py -k test_pathspec_magic_and_directory_pathspec_rejected
# AC7
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_git_change_exec.py -k test_staged_requested_mismatch_denies_and_rolls_back
# AC8
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_git_change_exec.py -k test_stale_snapshot_comment_drift_and_head_race_denies
# AC9
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_git_change_exec.py -k test_raw_git_add_commit_denied_outside_controlled_executor
# AC10
$ uv run --locked pytest scripts/agent-guards/tests/test_protected_paths_policy.py -k test_protected_paths_deny_regardless_of_allowed_paths
# AC11
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_git_change_exec.py -k test_shared_matcher_used_by_staging_commit_review
# AC12
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_git_change_exec.py -k test_legacy_env_and_new_snapshot_not_simultaneous_authority
# AC13
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_git_change_exec.py -k test_new_modules_compile
$ uv run --locked pytest scripts/agent-guards/tests/test_git_mutation_command_policy.py scripts/agent-guards/tests/test_changed_file_matcher.py .claude/skills/pr-review-judge/tests/test_allowed_paths_review_gate.py
# AC14
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_git_change_exec.py -k test_codex_execpolicy_matrix_includes_git_mutation_cases
# baseline-expect: pass
$ git diff --checkAllowed Paths
- scripts/agent-guards/git_mutation_command_policy.py
- scripts/agent-guards/tests/test_git_mutation_command_policy.py
- scripts/agent-guards/controlled_git_change_exec.py
- scripts/agent-guards/tests/test_controlled_git_change_exec.py
- .claude/skills/pr-review-judge/scripts/allowed_paths_review_gate.py
- .claude/skills/pr-review-judge/tests/test_allowed_paths_review_gate.py
- scripts/agent-guards/changed_file_matcher.py
- scripts/agent-guards/tests/test_changed_file_matcher.py
- scripts/agent-guards/protected_paths_policy.py
- scripts/agent-guards/protected_paths_policy.v1.json
- scripts/agent-guards/tests/test_protected_paths_policy.py
- scripts/ci/codex_execpolicy_matrix.py(既存、Issue 実装: codex execpolicy gate を fail-open から fail-closed へ修正し、execpolicy と hook の責務境界を明確化する (#1137 Blocker10 follow-up) #1150 由来。
execpolicy_case_definitions()へケース追加のみ) - scripts/ci/tests/test_codex_execpolicy_matrix.py(既存。変更が必要になった場合のみ。新規テストは新設ファイル側に置く)
- .codex/rules/default.rules
- .codex/config.toml
- scripts/check-codex-agents.mjs
- .claude/hooks/tests/test_worktree_scope_guard.py(既存)
- .claude/hooks/worktree_scope_guard.py(既存。Scope Delta により追加。controlled executor の
--cwdbinding 検証分岐を追加) - docs/dev/agent-runtime-ops.md
- docs/dev/hook-boundaries.md
(controlled_git_change_exec.py, test_controlled_git_change_exec.py, changed_file_matcher.py, test_changed_file_matcher.py, protected_paths_policy.py, protected_paths_policy.v1.json, test_protected_paths_policy.py は新設ファイル。scripts/ci/codex_execpolicy_matrix.py と scripts/ci/tests/test_codex_execpolicy_matrix.py は既存ファイルへの追記のみで新設しない)
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542・実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963 との direct conflict(同一関数の並行変更)が実装着手直前の live readback で確認された場合は即停止し、状態を記録した上で人間判断を仰ぐ
.claude/settings.jsonの deny rule 変更が protected paths policy との validated mirror 整合のみを超えて必要になった場合
Required Skills
- Python
- pytest
- Node.js
Required Design References
- docs/dev/agent-runtime-ops.md
- docs/dev/hook-boundaries.md
- docs/dev/workflow.md
Scope Delta(該当時のみ記載)
実装中に .claude/hooks/worktree_scope_guard.py(当初 Allowed Paths 外)への変更が必要と判明し、
本改訂で ## Allowed Paths セクションへ正式に追加した(PR レビューの Blocker 指摘を反映)。
AC14 の統合テスト(controlled_executor_exact_invocation_allowed 等、実 PreToolUse hook chain を
replay するケース)で、controlled executor の exact invocation を実際の hook chain が deny する
不具合が発覚したため。原因は同ファイルの汎用 mutation classifier が controlled executor の呼び出し形
(--cwd <worktree> を伴う呼び出し)を認識していなかったこと。scripts/agent-guards/git_mutation_command_policy.py
(Allowed Paths 内)に厳密な exact-argv parser を追加した上で、worktree_scope_guard.py にこれを使う
allow/deny 分岐を追加した(--cwd が active issue worktree の resolved path に一致する場合のみ allow)。
既存 .claude/hooks/tests/test_worktree_scope_guard.py(230 tests)は無変更のまま全て PASS することを
確認済みで、既存の deny/allow 判定への regression はない。詳細は PR #1620 本文の Scope Delta セクションを参照。
Runtime Verification Applicability
本 Issue の変更対象はワークフロー文書・スクリプトのみです。ゲームの実行時動作には影響しません。
decision: not_applicable
reason: "Workflow documentation and script changes only. No runtime game behavior changed."Delivery Rule
1 Issue = 1 PR- dedicated worktree で実装し Draft PR 作成
- 実装前に issue-contract-review で fresh
status: goを取得すること
Notes for Reviewer
- 本 Issue の採用設計は 調査: CODEX_ALLOWED_PATHS を廃止する共通 publish 境界を設計する #1592 の調査コメント(issuecomment-5010971038、RESEARCH_RESULT_V1)に基づく。実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542・実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963 は本 Issue の supersede 対象だが、close 実行は Child A の code 実装完了後に別途行う。remote push lane は変更しない。
- 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542(
git_mutation_command_policy.pyの mode 整合、OPEN)と 実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963(Claude staging hook 新設、OPEN)が同じ対象ファイル領域に触れるため、実装着手前にこの 2 件の状態を live readback し、direct conflict(同一関数の並行変更)がないことを確認してから着手する。 - Scope Collision Preflight(check_issue_overlap.py、C1 判定): scripts/agent-guards/git_mutation_command_policy.py と同 test は 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542(同ファイル、workspace mode 整合)・実装: linked issue worktree の origin/main fast-forward 同期を trusted RTK transaction に追加する #1603(同ファイル、fast-forward 同期)・実装: linked issue worktree の verified fast-forward を RTK guard で許可する #1589(同ファイル、verified fast-forward 許可)と Allowed Paths が重複する。allowed_paths_review_gate.py と同 test は 実装: pr_review_only VC の current-head adjudication を修正する #1540・実装: issue-contract-review fingerprint refresh path を明示する #1329・実装: ci_failure_attribution.py で known infra failure を分類し fix_delta 汚染を防ぐ #965(部分)と重複する。docs/dev/agent-runtime-ops.md は 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542・実装: docs/dev/agent-runtime-ops.md の standalone 実行時ワークアラウンド記述を permission profile 方式と整合させる #1499 と、docs/dev/hook-boundaries.md は 実装: worktree bootstrap の origin/default-branch base ref を保持する #1604・実装: linked issue worktree の origin/main fast-forward 同期を trusted RTK transaction に追加する #1603・実装:scope_rollup.runをskill_runtime_execのsiblingexactprofileへ統合する #1601・実装: launcher command 共有 parser(argv boundary 保持・cwd/project_root 対応)を抽出し全 consumer の invocation contract を移行する #1595・実装: scope_rollup.run の GitHub inventory を完全 pagination で取得する #1593・実装: linked issue worktree の verified fast-forward を RTK guard で許可する #1589・実装: worktree bootstrap を direct Python/no-project-mutation launcher に統一する #1588・実装: session_manifest_coordinator.sh 経由の legacy-state diagnostic e2e 可観測性を検証する #1432・実装: update_branch.py を canonical branch-update executor に統一し、入力・race・postcondition を自己検証する #1429 と重複する(多くは docs セクション追記レベルの broad overlap)。
.codex/config.toml・scripts/check-codex-agents.mjsの Allowed Paths 追加により、この 2 ファイルを含む他 Issue との overlap も実装着手前に live readback で再確認する。 - non_conflict_reason: 本 Issue は Child A 固有の controlled executor 実装であり、実装: linked issue worktree の origin/main fast-forward 同期を trusted RTK transaction に追加する #1603/実装: linked issue worktree の verified fast-forward を RTK guard で許可する #1589/実装:scope_rollup.runをskill_runtime_execのsiblingexactprofileへ統合する #1601/実装: launcher command 共有 parser(argv boundary 保持・cwd/project_root 対応)を抽出し全 consumer の invocation contract を移行する #1595/実装: scope_rollup.run の GitHub inventory を完全 pagination で取得する #1593/実装: worktree bootstrap を direct Python/no-project-mutation launcher に統一する #1588/実装: worktree bootstrap の origin/default-branch base ref を保持する #1604/実装: session_manifest_coordinator.sh 経由の legacy-state diagnostic e2e 可観測性を検証する #1432/実装: update_branch.py を canonical branch-update executor に統一し、入力・race・postcondition を自己検証する #1429 はそれぞれ worktree bootstrap・fast-forward sync・scope_rollup 統合等の独立トピックで同一関数を並行編集する計画ではない。実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542/実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963 のみが実質的な同一関数競合であり、上記の direct conflict 確認 Stop Condition で扱う。
- edit_intent: git_mutation_command_policy.py への変更は rtk git add/commit classifier を controlled executor 経由専用に変更する箇所に限定し、他 Issue が触れる mode 整合・fast-forward 判定ロジックとは別関数を対象にする想定。
.codex/rules/default.rules・.codex/config.toml・scripts/check-codex-agents.mjsへの変更は「raw git add/commit の allow rule を controlled executor 専用へ narrowing する」箇所に限定し、Child B が対象とするCODEX_ALLOWED_PATHS_MODEの edit-guard 全体には踏み込まない。 - dependency ordering: 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542/実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963 は本 Issue マージ後に readback して disposition を確定する。
- controlled executor の信頼境界は既存
scripts/agent-guards/controlled_skill_mutation_exec.pyを先例とし、exact argv・repository/Issue binding・symlink/hardlink 拒否・trusted binary/path・環境変数 sanitization・canonical realpath・postcondition readback を同水準で実装する。 - threat model: 本仕組みは cooperative agent workflow における誤操作・Issue scope 逸脱・無関係変更混入を防ぐ repository-local guardrail であり、同一ユーザーの悪意ある process・candidate-controlled policy 改変・OS-level adversary から独立した security boundary ではないことを実装 docs に明記する。
- VC 修正記録: 初回起票時、AC9/AC11/AC12 が既存ファイルへの
-k参照(pytest exit 5、vc_no_tests_collected)、AC13 がpython3 -m py_compile直接呼び出し(VC preflight allowlist 外、command_not_allowed)とgit diff --checkの baseline unexpected_pass でensure_contract_snapshot.pyの readiness check に blocked していたため、AC9/AC11/AC12/AC13 の VC を新設ファイルtest_controlled_git_change_exec.py参照へ統一し、git diff --checkに# baseline-expect: passannotation を付与した。AC の意図・検証内容は変更していない。 - 契約修正記録(本改訂): OWNER レビュー(本 Issue のコメント参照)の P0-1〜P0-4・P1-1〜P1-4・P2 を反映し、(1) Allowed Paths へ Codex 側ファイルと
protected_paths_policy.v1.json・codex_execpolicy_matrix.pyを追加、(2) snapshot schema を repository/Issue/contract source/branch/policy hash bind へ拡張、(3)ChangedFileRecordへ old/new mode・OID を追加し認可 oracle をgit diff-index --rawベースへ変更、(4) transaction 方式を「案B:git commit --only+ audit-then-rollback」に固定(案A の private index + ref CAS は不採用、Out of Scope に明記)、(5) controlled executor の env sanitization・fail-closed 対象を既存controlled_skill_mutation_exec.py相当に拡張、(6) protected policy を JSON SSOT + Python loader へ変更、(7) AC9 の検証範囲を Codex execpolicy matrix(AC14 新設)まで拡張、(8) rollback authority 状態遷移にnew_disabled_fail_closedを追加しrollback_to_oldという自動 fallback 表現を廃止した。
Scope Collision Preflight
- 既存 OPEN Issue 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542 を確認した。実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542 は
git_mutation_command_policy.py等の実装変更を対象にし、本 Issue は controlled executor 新設と rtk classifier の narrowing を対象にするため、実装着手前に direct conflict(同一関数の並行変更)を live readback で確認する。 - 既存 OPEN Issue 実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963 を確認した。実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963 は staging guard の
git add -A/ Allowed Paths 外 commit 混入防止を対象にしており、本 Issue が supersede する。 .codex/config.toml・scripts/check-codex-agents.mjsを Allowed Paths に追加したことに伴い、これらのファイルを触る他 OPEN Issue(実装: docs/dev/agent-runtime-ops.md の standalone 実行時ワークアラウンド記述を permission profile 方式と整合させる #1499 等)との overlap を実装着手前に再確認する。
Activity
squne121 commentedon Jul 18, 2026
Contract Review Result
squne121 commentedon Jul 18, 2026
判定
REQUEST_CHANGES — #1611 は現状の契約では実装着手不可です。
採用方向である「Issue scope snapshot + 共通 matcher + controlled stage/commit executor」は妥当です。ただし、現在の Issue は次の4点で自己矛盾しており、Issue 自身の Stop Conditions に既に該当しています。
In Scope を満たすために Allowed Paths 外の変更が必須
snapshot schema では AC8 の comment drift を検出不能
--name-statusだけでは submodule gitlink を分類不能private index・ref更新・通常indexを「単一transaction」とする方式が未定義
#1611 は open、コメント0件で、検索時点では #1611 を直接参照する実装PRも検出しませんでした。親 #1592 は #1611 を Child A、#1612 を後続 Child B として確定し、#1542/#963 を #1611 が supersede する方針です。
P0-1: In Scope と Allowed Paths が両立していない
Issue は In Scope で、以下を明示しています。
言語非依存の protected-path policy 単一ファイル
.codex/config.toml.claude/settings.jsonNode/Python consumer
raw/rtk
git add・git commitの controlled executor 外 denyしかし Allowed Paths には次がありません。
.codex/config.toml.codex/rules/default.rules.codex/hooks.json.claude/settings.jsonscripts/check-codex-agents.mjsscripts/ci/codex_execpolicy_matrix.py言語非依存の JSON/TOML policy ファイル
.claude/hooks/tests/test_worktree_scope_guard.pyこれは単なるテスト追加漏れではありません。現在の
.codex/rules/default.rulesはrtk git addとrtk git commit -mを明示的に allow しており、Codex validator もその allow rule の存在を要求しています。したがって AC9 を実装すると、ルールと validator が実装に反する状態になります。Codex の command rule は、低リスク操作の allow、高リスク操作の prompt/denyを定義する正式な制御層です。runtime hookだけを変更し、static ruleとその検証を旧仕様のまま残すのは、説明可能な単一境界にはなりません。(OpenAI)
修正要求
少なくとも Allowed Paths に以下を追加すべきです。
.codex/hooks.jsonの変更要否も実装者任せにせず、exact executor invocation が既存 hook chain を通過するかを契約で確定する必要があります。現在の Codex Bash lane はworktree_scope_guard.pyとcheck-codex-agents.mjsの両方を実行しています。Issue本文の「Allowed Paths 外の変更が必要と判明した場合」という Stop Condition は、既に成立しています。
P0-2: snapshot schema では comment 更新を stale と判定できない
AC8 は次を要求しています。
一方、AC1 の必須フィールドは以下だけです。
Issue body SHA-256
Allowed Paths normalized SHA-256
base branch/SHA
worktree realpath
protected policy version
comment_id、comment body hash、comment digest、contract source kindがないため、Issue commentだけが更新された場合、snapshotからは検出できません。これはAC1とAC8の直接矛盾です。親 #1592 の採用例には、以下が存在していました。
しかし #1611 の固定必須schemaから落ちています。親の設計を実装Issue化する過程で、binding が弱くなっています。
さらにリポジトリには、既に
ensure_contract_snapshot.pyが存在します。これは以下を実装済みです。Issue body SHA
issue_updated_atcomments digest
publication直前の再取得
contract source kind/id
Allowed Paths hash
base ref/SHA
trusted publisher確認
新たな独立snapshot producerを作ると、既存の
CONTRACT_REVIEW_RESULT_V1/ materialized-go とISSUE_SCOPE_SNAPSHOT_V1のどちらが権威なのか不明になります。修正要求
schema を最低でも次まで拡張してください。
実行時には GitHub live readback を必須とし、取得失敗・rate limit・source comment消失は fail-closed にすべきです。
また、次のどちらかを明記する必要があります。
ensure_contract_snapshot.pyを拡張して唯一のproducerとする既存producerを明示的に廃止し、新producerへauthorityを移す
現状の Allowed Paths では前者を実装できません。
P0-3:
--name-status -M -zでは gitlink を識別できないIssue は AC4 で以下を要求しています。
deletion
type change
submodule gitlink change
しかし共有対象となる現在の
ChangedFileRecordは、概ね次の情報しか保持していません。path
status
previous_path
source
provenance completeness
old/new mode と object ID がありません。現在の parser も
git diff --name-status -M -zを使用しています。--name-statusが返すMだけでは、通常ファイルの変更と submodule commit pointer の変更を区別できません。gitlink は mode160000なので、old/new mode を読む必要があります。Git の raw diff は old/new mode、old/new object ID、status、pathを返します。(Git)修正要求
ChangedFileRecordを次のように拡張してください。認可oracleは、例えば次のraw形式に変更する必要があります。
最低限、以下を commit 前に拒否すべきです。
old/new mode のどちらかが
160000unmerged stage
Tparser未対応status
provenance不足
rename/copyで旧新pathが揃わないもの
--name-statusは人間向け監査出力として併用できますが、AC4の認可正本には不足しています。P0-4: 「単一transaction」という主張が成立していない
Issue は次の二案を実装者判断にしています。
private
GIT_INDEX_FILE+commit-tree+update-refCAS通常indexを再取得し、残存raceを文書化
これは同じ安全性ではありません。後者は親Issueが解消しようとしている index TOCTOU を残します。にもかかわらず Outcome は「単一transaction」と断定しています。
Git が提供する機能はそれぞれ独立しています。
GIT_INDEX_FILEは別のindexファイルを選択するだけです。(Git)git update-ref <ref> <new> <old>はrefのcompare-and-swapを提供します。--stdinでは複数refのtransactionとsymref-verifyが利用できます。(Git)ただし ref transaction はindexファイルをtransaction対象にしません。
したがって、private indexからcommit objectを作りbranch refだけを更新すると、通常indexは旧HEAD基準のまま残ります。これは文書化された
GIT_INDEX_FILEとref更新の意味論からの帰結で、通常indexと新HEADの間に逆向きのstaged差分が現れ得ます。さらに現在の手順は、
stage
index監査
commit
commit diff再監査
です。4で不一致を検出しても、branch refは既に更新済みです。これは fail-closed ではなく、違反後検知です。
commit-treeはcommit objectを作る plumbing commandであり、通常のgit commitに紐づく pre-commit・prepare-commit-msg・commit-msg hookの扱いも自動的には同等になりません。Git公式はこれらをgit commitによって実行されるhookとして定義しています。(Git)修正要求
実装者裁量の二択を廃止し、次のいずれかを固定してください。
案A: candidate tree + ref CAS
live contract再検証
branch symbolic ref、pre-HEAD取得
private indexをpre-HEADから作成
NUL区切りliteral pathだけstage
raw diffでmode/OID/pathを監査
write-treecandidate commit objectを作成
candidate commitのtreeを再監査
symref-verify HEAD <branch>とupdate <branch> <new> <old>を同一ref transactionで実行通常indexの整合、crash recovery、journal、reflogを処理
この場合、以下を追加で契約化する必要があります。
通常indexがdirty/stagedの場合の扱い
branch更新後に通常indexをどう同期するか
ref更新後・index同期前にcrashした場合の回復
hookを無効化するか、信頼済みhookを再現するか
CAS失敗で作られたorphan commitの扱い
案B: Git porcelainのpartial commitを使用
Git は
git commit --onlyとNUL区切りの--pathspec-from-file=- --pathspec-file-nulを提供し、指定path以外の既存staged変更をcommit対象から除外できます。(Git)ただし、この案でも次を設計する必要があります。
untracked new fileを事前に「known」にする方法
hookがindexへ追加変更する可能性
commit直前のpath/content race
commit後監査失敗時の回復
exact requested setと実commit setの一致保証
どちらを選ぶ場合も、「可能ならprivate index、過剰なら通常index」ではACを固定できません。
P1-1: controlled executor 自体の信頼境界が不足している
リポジトリ内の既存
controlled_skill_mutation_exec.pyは、controlled executorの先例として以下を実装しています。exact argv
repository binding
Issue binding
symlink/hardlink拒否
trusted binary/path
environment sanitization
canonical realpath
postcondition readback
新executorにも同等の契約が必要ですが、#1611には記載がありません。
最低限、継承envから次を除去・上書きすべきです。
加えて以下をfail-closedにしてください。
detached HEAD
unborn branch
merge/rebase/cherry-pick進行中
unmerged index
snapshot/path/message fileのsymlink・hardlink
snapshot fileの過大サイズ
wrong repo/worktree/cwd
shell wrapper・追加argv
deadline超過
ambiguous crash result
この仕組みは repository-local cooperative guardrail であって、同一ユーザーの悪意あるprocessやcandidate-controlled policyから独立したsecurity boundaryではない、とdocsにも明示すべきです。OpenAIもCodexの安全運用を、sandbox、approval、rules、managed configurationを組み合わせる多層制御として説明しています。(OpenAI)
P1-2: protected policy の「言語非依存SSOT」が存在できない
Issue は言語非依存の単一ファイルを要求しながら、新設可能なのは
protected_paths_policy.pyだけです。Python moduleは言語非依存SSOTではありません。現在のNode実装は、次をハードコードしています。
assets/LICENSES/.env*secrets/**一方、Claude settings側にも別のdeny patternがあります。
推奨形式
version文字列だけでなく、policy内容のSHA-256をsnapshotにbindしてください。versionを変えずに内容だけ変更された場合もstaleにする必要があります。
P1-3: AC9 の検証がunit test止まり
現在の
test_git_mutation_command_policy.pyは、rtk git addとrtk git commitが allow されることを直接テストしています。#1611 はこの挙動を反転させるため、policy単体のテスト更新だけでは不十分です。実際のCodex経路は以下の合成です。
リポジトリには既に Codex execpolicy matrix と worktree guard integration test があるため、ここへ追加するべきです。
必要なmatrixは最低限次です。
P1-4: rollback state が既知の弱いauthorityへ戻る
rollback_to_oldは、TOCTOUを含む旧env authorityへ戻ることを意味します。緊急時に機能を止めるのではなく、既知の弱い経路を再度認可する設計です。推奨状態は次です。
旧実装へ戻す場合はruntime mode切替ではなく、明示的なrelease rollbackとして扱うべきです。agentが変更可能なenvだけでauthorityを切り替えられる設計は避ける必要があります。
P2: 特殊文字pathはbytesで扱うべき
Git の
-zはpathnameをNUL区切りで返し、--pathspec-file-nulは改行やquoteを含む文字をliteralとして扱います。(Git)一方、現在のreview gateは
subprocess(..., text=True)で結果を受け取っています。POSIX上のGit pathはNUL以外の任意byteを含み得るため、localeでdecodeできないpathが例外や不一致になる可能性があります。実装では次のどちらかを固定すべきです。
stdout/stdinをbytesのままNUL parseする
UTF-8以外のpathを明示的にunsupportedとしてfail-closedにする
また、実際のstageには両方を指定するのが安全です。
directory拒否を
os.path.isdir()だけに依存してはいけません。削除済みdirectoryは存在せず、symlinkやcase-insensitive filesystemでも結果が変わります。requested setはGitの変更recordから得たexact repository pathで構築すべきです。Issue本文へ入れるべき最小修正
Allowed Pathsを拡張する。
snapshot producerを既存materialized-goと統合する。
schemaにrepo/Issue/source comment/branch/policy hashを追加する。
ChangedFileRecordへmode/OIDを追加する。candidate tree監査をref更新前に実行する。
private indexと通常indexの整合・crash recoveryを固定する。
commit hookの有効・無効を明文化する。
executorのenv、binary、artifact trustを既存controlled executor相当にする。
Codex rules・validator・execpolicy matrixまで含む統合テストを追加する。
rollback_to_oldを fail-closed rollbackへ変更する。最終評価
設計方針は維持してよいですが、現在の #1611 は「実装Issue」ではなく、まだtransaction semanticsを確定する設計Issue相当です。
特に P0-1 はIssue自身のStop Conditionを即時発火させるため、Allowed Paths修正前の実装開始は契約違反です。P0-2〜P0-4も固定schema・型・実行順序の変更を要求するため、freshな issue-contract-review を取り直す必要があります。
#1542 と #963 は現状のままfreezeし、#1611の契約修正・実装・マージ後に予定どおり supersede 処理するのが妥当です。#1612 は引き続き #1611 blocked-by のまま維持すべきです。
# 判定REQUEST_CHANGES — #1611 は現状の契約では実装着手不可です。
採用方向である「Issue scope snapshot + 共通 matcher + controlled stage/commit executor」は妥当です。ただし、現在の Issue は次の4点で自己矛盾しており、Issue 自身の Stop Conditions に既に該当しています。
--name-statusだけでは submodule gitlink を分類不能#1611 は open、コメント0件で、検索時点では #1611 を直接参照する実装PRも検出しませんでした。親 #1592 は #1611 を Child A、#1612 を後続 Child B として確定し、#1542/#963 を #1611 が supersede する方針です。
P0-1: In Scope と Allowed Paths が両立していない
Issue は In Scope で、以下を明示しています。
.codex/config.toml.claude/settings.jsongit add・git commitの controlled executor 外 denyしかし Allowed Paths には次がありません。
.codex/config.toml.codex/rules/default.rules.codex/hooks.json.claude/settings.jsonscripts/check-codex-agents.mjsscripts/ci/codex_execpolicy_matrix.py.claude/hooks/tests/test_worktree_scope_guard.pyこれは単なるテスト追加漏れではありません。現在の
.codex/rules/default.rulesはrtk git addとrtk git commit -mを明示的に allow しており、Codex validator もその allow rule の存在を要求しています。したがって AC9 を実装すると、ルールと validator が実装に反する状態になります。Codex の command rule は、低リスク操作の allow、高リスク操作の prompt/denyを定義する正式な制御層です。runtime hookだけを変更し、static ruleとその検証を旧仕様のまま残すのは、説明可能な単一境界にはなりません。([OpenAI]1)
修正要求
少なくとも Allowed Paths に以下を追加すべきです。
.codex/hooks.jsonの変更要否も実装者任せにせず、exact executor invocation が既存 hook chain を通過するかを契約で確定する必要があります。現在の Codex Bash lane はworktree_scope_guard.pyとcheck-codex-agents.mjsの両方を実行しています。Issue本文の「Allowed Paths 外の変更が必要と判明した場合」という Stop Condition は、既に成立しています。
P0-2: snapshot schema では comment 更新を stale と判定できない
AC8 は次を要求しています。
一方、AC1 の必須フィールドは以下だけです。
comment_id、comment body hash、comment digest、contract source kindがないため、Issue commentだけが更新された場合、snapshotからは検出できません。これはAC1とAC8の直接矛盾です。親 #1592 の採用例には、以下が存在していました。
しかし #1611 の固定必須schemaから落ちています。親の設計を実装Issue化する過程で、binding が弱くなっています。
さらにリポジトリには、既に
ensure_contract_snapshot.pyが存在します。これは以下を実装済みです。issue_updated_at新たな独立snapshot producerを作ると、既存の
CONTRACT_REVIEW_RESULT_V1/ materialized-go とISSUE_SCOPE_SNAPSHOT_V1のどちらが権威なのか不明になります。修正要求
schema を最低でも次まで拡張してください。
実行時には GitHub live readback を必須とし、取得失敗・rate limit・source comment消失は fail-closed にすべきです。
また、次のどちらかを明記する必要があります。
ensure_contract_snapshot.pyを拡張して唯一のproducerとする現状の Allowed Paths では前者を実装できません。
P0-3:
--name-status -M -zでは gitlink を識別できないIssue は AC4 で以下を要求しています。
しかし共有対象となる現在の
ChangedFileRecordは、概ね次の情報しか保持していません。old/new mode と object ID がありません。現在の parser も
git diff --name-status -M -zを使用しています。--name-statusが返すMだけでは、通常ファイルの変更と submodule commit pointer の変更を区別できません。gitlink は mode160000なので、old/new mode を読む必要があります。Git の raw diff は old/new mode、old/new object ID、status、pathを返します。(Git)修正要求
ChangedFileRecordを次のように拡張してください。認可oracleは、例えば次のraw形式に変更する必要があります。
git diff-index \ --cached \ --raw \ --full-index \ -z \ -M \ "$EXPECTED_HEAD"最低限、以下を commit 前に拒否すべきです。
160000T--name-statusは人間向け監査出力として併用できますが、AC4の認可正本には不足しています。P0-4: 「単一transaction」という主張が成立していない
Issue は次の二案を実装者判断にしています。
GIT_INDEX_FILE+commit-tree+update-refCASこれは同じ安全性ではありません。後者は親Issueが解消しようとしている index TOCTOU を残します。にもかかわらず Outcome は「単一transaction」と断定しています。
Git が提供する機能はそれぞれ独立しています。
GIT_INDEX_FILEは別のindexファイルを選択するだけです。(Git)git update-ref <ref> <new> <old>はrefのcompare-and-swapを提供します。--stdinでは複数refのtransactionとsymref-verifyが利用できます。([Git]4)したがって、private indexからcommit objectを作りbranch refだけを更新すると、通常indexは旧HEAD基準のまま残ります。これは文書化された
GIT_INDEX_FILEとref更新の意味論からの帰結で、通常indexと新HEADの間に逆向きのstaged差分が現れ得ます。さらに現在の手順は、
です。4で不一致を検出しても、branch refは既に更新済みです。これは fail-closed ではなく、違反後検知です。
commit-treeはcommit objectを作る plumbing commandであり、通常のgit commitに紐づく pre-commit・prepare-commit-msg・commit-msg hookの扱いも自動的には同等になりません。Git公式はこれらをgit commitによって実行されるhookとして定義しています。(Git)修正要求
実装者裁量の二択を廃止し、次のいずれかを固定してください。
案A: candidate tree + ref CAS
write-treesymref-verify HEAD <branch>とupdate <branch> <new> <old>を同一ref transactionで実行この場合、以下を追加で契約化する必要があります。
案B: Git porcelainのpartial commitを使用
Git は
git commit --onlyとNUL区切りの--pathspec-from-file=- --pathspec-file-nulを提供し、指定path以外の既存staged変更をcommit対象から除外できます。(Git)ただし、この案でも次を設計する必要があります。
どちらを選ぶ場合も、「可能ならprivate index、過剰なら通常index」ではACを固定できません。
P1-1: controlled executor 自体の信頼境界が不足している
リポジトリ内の既存
controlled_skill_mutation_exec.pyは、controlled executorの先例として以下を実装しています。新executorにも同等の契約が必要ですが、#1611には記載がありません。
最低限、継承envから次を除去・上書きすべきです。
加えて以下をfail-closedにしてください。
この仕組みは repository-local cooperative guardrail であって、同一ユーザーの悪意あるprocessやcandidate-controlled policyから独立したsecurity boundaryではない、とdocsにも明示すべきです。OpenAIもCodexの安全運用を、sandbox、approval、rules、managed configurationを組み合わせる多層制御として説明しています。(OpenAI)
P1-2: protected policy の「言語非依存SSOT」が存在できない
Issue は言語非依存の単一ファイルを要求しながら、新設可能なのは
protected_paths_policy.pyだけです。Python moduleは言語非依存SSOTではありません。現在のNode実装は、次をハードコードしています。
assets/LICENSES/.env*secrets/**一方、Claude settings側にも別のdeny patternがあります。
推奨形式
{ "schema": "PROTECTED_PATHS_POLICY_V1", "rules": [ {"kind": "root_directory", "path": "assets"}, {"kind": "root_directory", "path": "LICENSES"}, {"kind": "basename_glob", "pattern": ".env"}, {"kind": "basename_glob", "pattern": ".env.*"}, {"kind": "root_directory", "path": "secrets"} ] }version文字列だけでなく、policy内容のSHA-256をsnapshotにbindしてください。versionを変えずに内容だけ変更された場合もstaleにする必要があります。
P1-3: AC9 の検証がunit test止まり
現在の
test_git_mutation_command_policy.pyは、rtk git addとrtk git commitが allow されることを直接テストしています。#1611 はこの挙動を反転させるため、policy単体のテスト更新だけでは不十分です。実際のCodex経路は以下の合成です。
リポジトリには既に Codex execpolicy matrix と worktree guard integration test があるため、ここへ追加するべきです。
必要なmatrixは最低限次です。
git add xgit commit -m xrtk git add xrtk git commit -m xbash -lcP1-4: rollback state が既知の弱いauthorityへ戻る
rollback_to_oldは、TOCTOUを含む旧env authorityへ戻ることを意味します。緊急時に機能を止めるのではなく、既知の弱い経路を再度認可する設計です。推奨状態は次です。
旧実装へ戻す場合はruntime mode切替ではなく、明示的なrelease rollbackとして扱うべきです。agentが変更可能なenvだけでauthorityを切り替えられる設計は避ける必要があります。
P2: 特殊文字pathはbytesで扱うべき
Git の
-zはpathnameをNUL区切りで返し、--pathspec-file-nulは改行やquoteを含む文字をliteralとして扱います。(Git)一方、現在のreview gateは
subprocess(..., text=True)で結果を受け取っています。POSIX上のGit pathはNUL以外の任意byteを含み得るため、localeでdecodeできないpathが例外や不一致になる可能性があります。実装では次のどちらかを固定すべきです。
また、実際のstageには両方を指定するのが安全です。
directory拒否を
os.path.isdir()だけに依存してはいけません。削除済みdirectoryは存在せず、symlinkやcase-insensitive filesystemでも結果が変わります。requested setはGitの変更recordから得たexact repository pathで構築すべきです。Issue本文へ入れるべき最小修正
ChangedFileRecordへmode/OIDを追加する。rollback_to_oldを fail-closed rollbackへ変更する。最終評価
設計方針は維持してよいですが、現在の #1611 は「実装Issue」ではなく、まだtransaction semanticsを確定する設計Issue相当です。
特に P0-1 はIssue自身のStop Conditionを即時発火させるため、Allowed Paths修正前の実装開始は契約違反です。P0-2〜P0-4も固定schema・型・実行順序の変更を要求するため、freshな issue-contract-review を取り直す必要があります。
#1542 と #963 は現状のままfreezeし、#1611の契約修正・実装・マージ後に予定どおり supersede 処理するのが妥当です。#1612 は引き続き #1611 blocked-by のまま維持すべきです。
squne121 commentedon Jul 18, 2026
implement-issue: 実装完了・PR 起票は human 待ち
実装は完了し、branch を origin へ push 済みです。AC1〜AC13 の Verification Commands は全て PASS しています。
worktree-issue-1611-v2(origin に push 済み、commitba14efac)-kフィルタ個別実行済み)、既存test_git_mutation_command_policy.py(25件)・test_allowed_paths_review_gate.py(77件)regression 全 PASS、git diff --checkPASS実装ファイル
scripts/agent-guards/controlled_git_change_exec.py(新設)scripts/agent-guards/changed_file_matcher.py(新設)scripts/agent-guards/protected_paths_policy.py(新設)scripts/agent-guards/git_mutation_command_policy.py(classify_agent_lane_add_commit追加).claude/skills/pr-review-judge/scripts/allowed_paths_review_gate.py(共有 module import へリファクタ)scripts/agent-guards/tests/test_controlled_git_change_exec.py(新設、14テスト)scripts/agent-guards/tests/test_changed_file_matcher.py(新設、8テスト)scripts/agent-guards/tests/test_protected_paths_policy.py(新設、4テスト)docs/dev/agent-runtime-ops.md,docs/dev/hook-boundaries.md(更新)PR 起票がブロックされている理由(human 判断が必要)
open_pr.pyの overlap preflight hard gate(phase/implementationラベルにより強制)がroute: human_review_requiredを返すため、gh pr createを自動実行できません。candidates/validation_errorsが空のため、原因はclassify_overlapのparent_collision(policy_class C3)と推測されます。#1611 と #1612(実装: Codex 編集ガードから CODEX_ALLOWED_PATHS
系 env を廃止する)はどちらも
parent_issue: "#1592"を共有しており、かつ #1612 は自身の本文で明示的に
depends_on: 1611を宣言し「Child A(#1611)のmerge後に着手する」と記載しています(direct conflict ではなく意図的な直列化)。つまりこれは false positive の可能性が高い C3 判定です。
OPEN PR なし)。
open_pr.pyの overlap_preflight hard gate はroute: proceed/proceed_with_collision_evidence以外を受け付けない設計のため、CLI からこれを override する経路はありません。以下のいずれかの human
判断をお願いします。
check_implementation_overlap.pyの parent_collision 判定の false positive(sequenced siblingへの対応)を別 Issue で改善してから再実行する、または
gh pr create --repo squne121/loop-protocol --base main --head worktree-issue-1611-v2 --draftで手動起票する。
PR body の下書きは validate_pr_body.py / validate_japanese_content.py を事前に通過確認済みです。
squne121 commentedon Jul 18, 2026
Contract Review Result
実装: Issue scope snapshot と controlled executor の契約拡張(OWNER REQUEST_CH…
fix: controlled_git_change_exec.py の exact invocation を worktree_scop…
fix: classify_overlap に successor dependency 分岐を追加し parent_collision …
fix: codex execpolicy matrix の controlled_executor_extra_argv_denied …
squne121 commentedon Jul 18, 2026
Contract Review Result
test: add adversarial env sanitization coverage to controlled executo…
実装: Codex 編集ガードから CODEX_ALLOWED_PATHS 系 env を廃止する (#1612) (#1623)