Repository navigation
実装: Codex 編集ガードから CODEX_ALLOWED_PATHS 系 env を廃止する (#1612) - #1623
Merged
Merged
Conversation
scripts/check-codex-agents.mjs の CODEX_ALLOWED_PATHS_MODE / CODEX_ALLOWED_PATHS / CODEX_LEGACY_ALLOW_WRITES への依存を完全に除去し、編集時 filesystem 境界を native permission profile(.codex/config.toml)+ 共有 PROTECTED_PATHS_POLICY_V1 (scripts/agent-guards/protected_paths_policy.v1.json)の validated mirror (isProtectedPath())へ一本化した。 - parseAllowedPathsMode / parseAllowedPaths / isPathAllowed / appendShadowLog / shadowLogPath を削除し、denyForWriteTool() を protected-path 判定のみに単純化。 Allowed Paths の narrowing は本 hook では行わず、PR review 時の allowed_paths_review_gate(canonical)と controlled_git_change_exec.py (Issue #1611)に委譲する設計へ変更。 - Codex shadow mode 固有の would-block 記録機構を除去。.guard_shadow_log.jsonl ファイル自体・他producer(.claude/hooks/shadow_log.py)・ skill_runtime_exec.py の _SHADOW_LOG_EXACT_REL ポリシーは無変更(回帰テストで確認)。 - --self-test を新設計に合わせて書き換え、--check-protected-path / --check-write-tool のテスト専用 CLI フラグを追加。 - docs/dev/agent-runtime-ops.md の CODEX_ALLOWED_PATHS_MODE セクションを native permission profile + protected paths policy の説明へ置き換え、 Rollback 手順(AC9)を追加。 新設テスト(scripts/agent-guards/tests/、Allowed Paths への Scope Delta): - test_protected_paths_policy_node_parity.py(AC4: Node/Python 判定一致) - test_codex_shadow_removal_regression.py(AC5: shadow writer 除去 + 他producer無傷) - test_check_codex_agents_self_test.py(AC6: --self-test 全PASS) - test_codex_legacy_env_ignored.py(AC7: 旧env設定時も判定不変のnegative test) AC1/AC2/AC3/AC8 は `rg -c` の対象文字列が完全に除去されたことを意味する exit 1(no match)を確認済み(baseline は除去前に文字列がヒットする状態だった)。 全 AC1-9 の Verification Commands 実行結果、pnpm typecheck/lint/test/build、 scripts/agent-guards/tests 全体(939 passed, 1 skipped)、tests/codex 全体 (458 passed)、gemini-cli-headless-delegation の model routing test (21 passed)を確認済み。 Closes #1612 Co-Authored-By: Claude Sonnet 5 <[email protected]>
9 tasks
Contributor
Preview URLPreview removed (PR #1623 closed). |
squne121
commented
Jul 19, 2026
squne121
left a comment
Owner
Author
There was a problem hiding this comment.
LOOP_VERDICT_V2
LOOP_VERDICT_V2:
verdict: APPROVE
reviewed_head_sha: "568f0d1ac8bf5feee560276fc14945cefa39df5a"
merge_ready: true
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "CLEAN"
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
status: ok
producer_role: review_subagent
worker_report_used_as_canonical: false
base_sha: "e678fea0d63da1b6c31cac1379837f9046c369e8"
head_sha: "568f0d1ac8bf5feee560276fc14945cefa39df5a"
changed_files_source: git_diff_name_status_find_renames_z
changed_files:
- "scripts/check-codex-agents.mjs"
- "docs/dev/agent-runtime-ops.md"
- "scripts/agent-guards/tests/test_protected_paths_policy_node_parity.py"
- "scripts/agent-guards/tests/test_codex_shadow_removal_regression.py"
- "scripts/agent-guards/tests/test_check_codex_agents_self_test.py"
- "scripts/agent-guards/tests/test_codex_legacy_env_ignored.py"
violations: []Summary
Issue #1612 の Outcome/AC1-9/Verification Commands/Allowed Paths と PR #1623 の実 diff・証跡を独立照合。
- AC1-3/AC8:
CODEX_ALLOWED_PATHS_MODE/CODEX_ALLOWED_PATHS/CODEX_LEGACY_ALLOW_WRITESがscripts/check-codex-agents.mjs・docs/dev/agent-runtime-ops.mdから完全除去済みを確認。 - AC4:
isProtectedPath()が共有PROTECTED_PATHS_POLICY_V1(JSON SSOT)の validated mirror として実装済み。 - AC5: 他producer(
.claude/hooks/shadow_log.py)無変更・.guard_shadow_log.jsonl書き込み継続成功のregression test実装済み。 - AC7: 旧env設定時と未設定時の判定結果が完全一致するnegative test実装済み。
- AC9: rollback手順が
docs/dev/agent-runtime-ops.mdに具体的に記載済み。 - worktree内で該当4テストファイル31 tests全PASS、
node scripts/check-codex-agents.mjs --self-test全PASS。 - CI: 全required check green(
ci_verdict_summary.pyでstatus: all_pass確認)。mergeStateStatus: CLEAN。
新設4テストファイルはAllowed Paths正式リスト外だが、Issue #1612自身のVerification Commands(AC4/AC5/AC6/AC7)が直接参照する契約上必須の成果物であり、Child A(#1611)でも同一パターンがprecedentとして採用済み。無関係変更の混入ではないためmerge-blockingとしない。
blocker なし。
squne121
marked this pull request as ready for review
July 19, 2026 00:20
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Issue #1612 の実装。
scripts/check-codex-agents.mjsの Codex 編集ガードからCODEX_ALLOWED_PATHS_MODE/CODEX_ALLOWED_PATHS/CODEX_LEGACY_ALLOW_WRITESへの依存を完全に除去し、編集時(apply_patch / Edit / Write)の filesystem 境界を
native permission profile(
.codex/config.toml)+ 共有PROTECTED_PATHS_POLICY_V1(
scripts/agent-guards/protected_paths_policy.v1.json、Child A #1611 で新設・PR #1620 でマージ済み)の validated mirror(
isProtectedPath())へ一本化しました。Child A(#1611、PR #1620)は merge 済みのため、本 PR の base はマージ後の main
(
e678fea0)です。変更内容
parseAllowedPathsMode()/parseAllowedPaths()/isPathAllowed()/appendShadowLog()/shadowLogPathを削除。denyForWriteTool()を protected-path 判定のみへ単純化(mode 分岐なし)。Allowed Paths の narrowing はこの hook では行わず、PR review 時の独立した
git diffベースallowed_paths_review_gate(canonical)と、git staging/commit自体を担う
controlled_git_change_exec.py(Issue 実装: Issue scope snapshot と controlled executor で共通 staging/commit 境界を構築する #1611)に委譲する設計へ変更。.guard_shadow_log.jsonlファイル自体・他 producer(.claude/hooks/shadow_log.py、Issue 実装: 契約実行ラッパーのunauthorized_write_path誤検知が.guard_shadow_log.jsonlでも発生する問題を修正する #1563/PR 実装: 契約実行ラッパーの unauthorized_write_path 誤検知を .guard_shadow_log.jsonl 専用の型付き exact-file ポリシーで解消する #1572)・
scripts/agent-guards/skill_runtime_exec.pyの_SHADOW_LOG_EXACT_RELポリシーは無変更(regression test で確認)。--self-testを新設計に合わせて全面的に書き換え。テスト専用の--check-protected-path <path>/--check-write-tool <tool> <pathOrPatch>CLIフラグを新設し、out-of-process pytest から
denyForWriteTool()/isProtectedPath()の判定を直接駆動できるようにしました。docs/dev/agent-runtime-ops.mdのCODEX_ALLOWED_PATHS_MODEセクションをnative permission profile + protected paths policy の説明へ置き換え、
Rollback 手順(AC9)を新設。
.codex/config.tomlは Child A(実装: Issue scope snapshot と controlled executor で共通 staging/commit 境界を構築する #1611)で既に整合済みだったため変更なし(
CODEX_ALLOWED_PATHS系文字列が存在しないことを確認のみ)。新設テストファイル(Scope Delta)
Issue #1612 の Allowed Paths には明記されていませんが、Issue 本文の Verification
Commands が直接参照するテストファイルであり、実装に必須のため
scripts/agent-guards/tests/配下(他 Issue のテストファイルと同じ規約)へ追加しました(Child A #1611 でも同様のパターンがあったため踏襲)。
test_protected_paths_policy_node_parity.py(AC4): Node 側isProtectedPath()と Python 側
is_protected_path()(protected_paths_policy.py)の判定結果がassets/LICENSES/.env系/secrets の全ケースで一致することを、実
nodesubprocess経由で検証。
test_codex_shadow_removal_regression.py(AC5): Codex shadow writer のトークン(
appendShadowLog等)がソースから完全に除去されたことの staticregression、
--self-test実行が実リポジトリの.guard_shadow_log.jsonlに一切書き込まないことの behavioral regression、他 producer
(
.claude/hooks/shadow_log.py)が引き続き成功することの regression、_SHADOW_LOG_EXACT_RELポリシー文字列が無変更であることの regression。test_check_codex_agents_self_test.py(AC6):node scripts/check-codex-agents.mjs --self-testが新設計で全 PASS することの pytest wrapper。test_codex_legacy_env_ignored.py(AC7): 旧 env(CODEX_ALLOWED_PATHS_MODE=strictCODEX_ALLOWED_PATHS、CODEX_LEGACY_ALLOW_WRITES=1等)を設定した状態と未設定の状態で
denyForWriteTool()の判定が完全に一致することの negative test(実
nodesubprocess・実 env 経由)。AC / Verification Commands 実行結果
rg -c "CODEX_ALLOWED_PATHS_MODE" scripts/check-codex-agents.mjsrg -c "CODEX_ALLOWED_PATHS" scripts/check-codex-agents.mjsrg -c "CODEX_LEGACY_ALLOW_WRITES" scripts/check-codex-agents.mjsuv run --locked pytest scripts/agent-guards/tests/test_protected_paths_policy_node_parity.pyuv run --locked pytest scripts/agent-guards/tests/test_codex_shadow_removal_regression.pyuv run --locked pytest scripts/agent-guards/tests/test_check_codex_agents_self_test.pyuv run --locked pytest scripts/agent-guards/tests/test_codex_legacy_env_ignored.pyrg -c "CODEX_ALLOWED_PATHS_MODE" docs/dev/agent-runtime-ops.mdrg -c "rollback" docs/dev/agent-runtime-ops.mdAC1/AC2/AC3/AC8 について: Issue 本文の指示どおり、これらは「実装後に文字列が
完全に除去された」ことを意図した AC です。除去前(baseline)は
rg -cが該当行数を返し exit 0 でしたが、除去後は該当文字列が 0 件になったため
rg -cは no-match のexit 1 を返します。これは
rgの仕様上の挙動であり、AC の意図(除去済み)としては正しい状態です。
その他の検証
node --check scripts/check-codex-agents.mjs: 構文エラーなしnode scripts/check-codex-agents.mjs --self-test: 全アサーション PASS(TOML parser / PROTECTED_PATHS_POLICY_V1 JSON SSOT mirrors / protected-path
enforcement Edit-Write / protected-path enforcement apply_patch / Bash hook)
node scripts/check-codex-agents.mjs(通常バリデータ):ok 13 agents validateduv run --locked pytest scripts/agent-guards/tests -q: 939 passed, 1 skipped(既存テスト全 regression PASS + 新設 31 テスト)
uv run --locked pytest tests/codex -q: 458 passed(既存 regression)uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py:21 passed
pnpm typecheck/pnpm lint/pnpm test(1580 passed)/pnpm build: 全 PASSgit diff --check: 空出力(whitespace エラーなし)validate_japanese_content.py --file docs/dev/agent-runtime-ops.md): PASSScope Collision Preflight のライブ確認結果
gh pr list --search "1587" --state openで 0 件)。同一関数の並行変更なし。
gh pr list --search "1025" --state openで 0 件)。編集対象関数も異なる。
いずれも direct conflict なし。
Checks
node --check scripts/check-codex-agents.mjs: PASS(構文エラーなし)node scripts/check-codex-agents.mjs --self-test: 全 assertion PASSnode scripts/check-codex-agents.mjs:ok 13 agents validatedpnpm typecheck/pnpm lint/pnpm test(1580 passed)/pnpm build: 全 PASSgit diff --check: 空出力(whitespace エラーなし)Schema Change Applicability
本 PR の判定は以下の通り。
.guard_shadow_log.jsonlのスキーマ自体は変更していない(Codex 側の書き込み経路を削除しただけで、他 producer(
.claude/hooks/shadow_log.py)の書き込み形式・consumer 側のパース仕様は無変更)。PROTECTED_PATHS_POLICY_V1JSON SSOT のスキーマも Child A(#1611)で確定済みのものをそのままNode 側から読み込むのみで、スキーマ自体への変更はない。GitHub 上に永続化される公開 schema
(Issue/PR/comment の machine-readable contract 等)も本 PR で変更しない。
Schema Consumer Inventory
scripts/check-codex-agents.mjs(PROTECTED_PATHS_POLICY_V1JSON SSOT の新規 Node consumer、isProtectedPath())scripts/agent-guards/protected_paths_policy.py(既存 Python consumer、Child A 実装: Issue scope snapshot と controlled executor で共通 staging/commit 境界を構築する #1611 で確定済み、本 PR では無変更)
.claude/hooks/shadow_log.py(.guard_shadow_log.jsonlの既存 producer、本 PR では無変更。regression test(
test_codex_shadow_removal_regression.py)で書き込み継続を確認)Safety Claim Matrix
CODEX_ALLOWED_PATHS系 env は編集ガードの authority として一切参照されないtest_codex_legacy_env_ignored.py(旧 env 設定時と未設定時で判定が完全一致することを実 subprocess で検証)test_protected_paths_policy_node_parity.py(Node/Python 両実装の判定一致を検証).guard_shadow_log.jsonlへの他 producer 書き込みは継続するtest_codex_shadow_removal_regression.py(.claude/hooks/shadow_log.py経由の書き込み成功を regression 確認)--self-testが新設計で全 assertion を維持するtest_check_codex_agents_self_test.py+node scripts/check-codex-agents.mjs --self-test直接実行Threat model の明記: 本変更は Codex 編集ガードの authority を native permission profile と
共有 protected paths policy へ一本化するものであり、repository-local cooperative guardrail の
一部である。同一ユーザーの悪意ある process や candidate-controlled policy 改変から独立した
security boundary であるとは主張しない(
docs/dev/agent-runtime-ops.mdに明記済み)。ロールバック手順(Rollback)
本 PR は
scripts/check-codex-agents.mjsとdocs/dev/agent-runtime-ops.mdの変更、および新設テストファイル追加のみであり、DB migration・破壊的 schema 変更を伴わない。問題が判明した場合、
本 PR の revert のみで安全に戻せる。
docs/dev/agent-runtime-ops.mdの Rollback セクション(AC9)にnative permission profile / policy ファイル障害時の安全側フォールバック手順を明記済み。
Notes
e678fea0)のマージ後に着手した Child B の実装である。本 PR のマージにより Issue #1612 を解消する: Closes #1612