Skip to content

実装: Codex 編集ガードから CODEX_ALLOWED_PATHS 系 env を廃止する (#1612) - #1623

Merged
squne121 merged 2 commits into
mainfrom
worktree-issue-1612-codex-allowed-paths-removal
Jul 19, 2026
Merged

squne121 merged 2 commits into
mainfrom
worktree-issue-1612-codex-allowed-paths-removal

Conversation

@squne121

@squne121 squne121 commented Jul 18, 2026 •

Copy link
Copy Markdown
Owner

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)です。

変更内容

新設テストファイル(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 の全ケースで一致することを、実 node subprocess
    経由で検証。
  • test_codex_shadow_removal_regression.py(AC5): Codex shadow writer の
    トークン(appendShadowLog 等)がソースから完全に除去されたことの static
    regression、--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=strict
    • 非該当 CODEX_ALLOWED_PATHS、CODEX_LEGACY_ALLOW_WRITES=1 等)を設定した状態と
      未設定の状態で denyForWriteTool() の判定が完全に一致することの negative test
      (実 node subprocess・実 env 経由)。

AC / Verification Commands 実行結果

AC コマンド 結果
AC1 rg -c "CODEX_ALLOWED_PATHS_MODE" scripts/check-codex-agents.mjs exit 1(no match = 完全除去)
AC2 rg -c "CODEX_ALLOWED_PATHS" scripts/check-codex-agents.mjs exit 1(no match = 完全除去)
AC3 rg -c "CODEX_LEGACY_ALLOW_WRITES" scripts/check-codex-agents.mjs exit 1(no match = 完全除去)
AC4 uv run --locked pytest scripts/agent-guards/tests/test_protected_paths_policy_node_parity.py 18 passed
AC5 uv run --locked pytest scripts/agent-guards/tests/test_codex_shadow_removal_regression.py 4 passed
AC6 uv run --locked pytest scripts/agent-guards/tests/test_check_codex_agents_self_test.py 2 passed
AC7 uv run --locked pytest scripts/agent-guards/tests/test_codex_legacy_env_ignored.py 7 passed
AC8 rg -c "CODEX_ALLOWED_PATHS_MODE" docs/dev/agent-runtime-ops.md exit 1(no match = 完全除去)
AC9 rg -c "rollback" docs/dev/agent-runtime-ops.md exit 0, count 5(Rollback 手順を含む)

AC1/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 validated
  • uv 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: 全 PASS
  • git diff --check: 空出力(whitespace エラーなし)
  • Japanese Check(validate_japanese_content.py --file docs/dev/agent-runtime-ops.md): PASS

Scope Collision Preflight のライブ確認結果

いずれも direct conflict なし。

Checks

  • node --check scripts/check-codex-agents.mjs: PASS(構文エラーなし)
  • node scripts/check-codex-agents.mjs --self-test: 全 assertion PASS
  • node scripts/check-codex-agents.mjs: ok 13 agents validated
  • pnpm typecheck / pnpm lint / pnpm test(1580 passed)/ pnpm build: 全 PASS
  • git diff --check: 空出力(whitespace エラーなし)
  • CI(GitHub Actions): 本 PR head で確認中。

Schema Change Applicability

本 PR の判定は以下の通り。

  • decision: not_schema_change

.guard_shadow_log.jsonl のスキーマ自体は変更していない(Codex 側の書き込み経路を削除しただけで、
他 producer(.claude/hooks/shadow_log.py)の書き込み形式・consumer 側のパース仕様は無変更)。
PROTECTED_PATHS_POLICY_V1 JSON 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_V1 JSON 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

Claim Implemented? Not controlled Evidence Follow-up
CODEX_ALLOWED_PATHS 系 env は編集ガードの authority として一切参照されない yes - test_codex_legacy_env_ignored.py(旧 env 設定時と未設定時で判定が完全一致することを実 subprocess で検証) -
protected paths(assets/LICENSES/.env系/secrets)は引き続き常に deny される yes - test_protected_paths_policy_node_parity.py(Node/Python 両実装の判定一致を検証) -
Codex shadow mode 固有の記録機構除去後も .guard_shadow_log.jsonl への他 producer 書き込みは継続する yes - test_codex_shadow_removal_regression.py(.claude/hooks/shadow_log.py 経由の書き込み成功を regression 確認) -
--self-test が新設計で全 assertion を維持する yes - 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

本 PR のマージにより Issue #1612 を解消する: Closes #1612

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]>
@github-actions

github-actions Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #1623 closed).

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
squne121 marked this pull request as ready for review July 19, 2026 00:20
@squne121
squne121 merged commit bca3e0e into main Jul 19, 2026
18 checks passed
@squne121
squne121 deleted the worktree-issue-1612-codex-allowed-paths-removal branch July 19, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

実装: Codex 編集ガードから CODEX_ALLOWED_PATHS 系 env を廃止する

1 participant