Skip to content

feat(codex): apply the secret path policy to the guarded filesystem - #233

Merged
furedea merged 13 commits into
mainfrom
feat/apply-secret-path-policy-to-codex
Nov 12, 2026
Merged

furedea merged 13 commits into
mainfrom
feat/apply-secret-path-policy-to-codex

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Closes #232

計画:https://github.com/furedea/agent-harness/issues/232#issuecomment-6813519563(レーン secrets)
lookups レーンの #234 はマージ済みで,これで #232 の受け入れ条件が揃う.

概要

秘密パスのポリシー(hooks/rules/secret_path_policy.json)を Codex の [permissions.guarded.filesystem] にも反映する.
これまで Codex ではフックの検査だけが効いており,フックを通らないシェルからの読み取りは設定では止まらなかった.

変換規則

ポリシーのルール Codex の値
読み取りを禁止する(access に read を含む) "none"
書き込みのみ禁止(access が ["write"] だけ) Codex には出さない(警告もしない)
  • ~/ と //x(絶対パス)はトップレベルのキー,相対パターンは [permissions.guarded.filesystem.":workspace_roots"] の下に置く.
  • 先頭が単独の / は Claude ではプロジェクト相対で曖昧なのでエラー./ を含まない相対パターン(.env*)は **/ を前置して任意の深さに一致させる.
  • 保護パス(ハーネス自身のファイル)のエントリ("read")は変えない.

書き込みのみのルールを Codex に出さない理由

  • Codex のファイルシステム権限は,エージェントが起動するすべてのプロセスに効く.Claude の Edit(...) の deny は Edit ツールにしか効かない.
  • 書き込みのみのルールが守るのは,ハーネスのスクリプト自身が書き込む状態である.たとえば verification_session.py は **/agent-harness/{verification,trusted-owners,audit}/** に書く.
  • Codex のサンドボックスでこれらの書き込みを禁止すると,スクリプトが壊れる.フックが書き込みのみのルールを引き続き強制する.
  • Claude Code のサンドボックスが,こうしたパスの読み取りは禁止し,~/.local/state/agent-harness への書き込みは許すのと同じ扱い.
  • 結果として,秘密パスのルールから「弱い("read")エントリ」は生成されない.弱いエントリは保護パスだけになる.

競合の検出(書き換えはしない)

Codex は具体的なエントリを優先する.そのため secrets/** = "none" の下に secrets/key = "read" があると,読み取りが開く.逆に,ソースが意図的に開けた例外(:root = "deny" の下の ~/.codex = "read")を自動で閉じるのも誤りになる.どちらの意図かを推測して書き換えると,レビューで互いに逆向きの指摘が出たため,ガード用のエントリは書き換えず,競合を検出して生成を失敗させる.

  • 競合:厳しいエントリが,より緩いエントリを覆う組(同じパス,祖先ディレクトリ,マッチするグロブ).緩いエントリが厳しいエントリの配下にある場合だけを競合とする.厳しいエントリが緩いエントリの配下にある通常の配置(:workspace_roots = "write" の下に **/secrets/** = "none")は競合ではない.
  • 検査する組:生成されたエントリどうし,生成されたエントリとソースの codex/config.toml(:workspace_roots の入れ子の表を含む).ソースどうしの組は,ソースの作者のものなので検査しない.
  • エラーには,両方のエントリ,それぞれのアクセス,宣言された場所(生成側,またはソースのファイル)を出す.
  • generation/guarded_path.rs:GuardedEntry は Deny(パターン可)か Looser(正規化済みの具体的パスのみ)で,パターンを持つ Looser は作れない.パスは一度だけ正規化する(~,.,重複する /,..,ドライブレター).
  • generation/guarded_conflict.rs:上の判定を生成側とソースの表に適用する.
  • グロブ照合は自前の小さな実装(*,**,?)にした.globset などを足すと regex 系の依存が増え,このリポジトリは依存を完全固定しているため.[...] と {...} は取りうる範囲に広げて扱い,覆う範囲が広がる方向(より厳しい側)にだけ誤る.
  • 読み取りを禁止するルールが波括弧のパターンを持つときは,Codex が波括弧を展開しないため,パターン名を示して生成を失敗させる(実際の agent-config のポリシーに該当するルールはない).バックスラッシュは区切りとして扱う.
  • 既知の制限:プロジェクト内インストール(--runtime-root がプロジェクト)の絶対パスの保護エントリは,ソースの :workspace_roots とは照合しない(ルールごとにルートを分けて比べるため).競合検出は安全網で,秘密ポリシーはフックが実行時に強制する.グロブどうしの包含は比べない(別のグロブより緩いグロブは検出できない).:tmpdir は実行環境で決まるためモデル化していない(:slash_tmp は /tmp).~ は生成時にホームが分からないため記号のまま扱い,~/x と同じ場所を指す /Users/.../x は別のルートとして比べる.
  • ソースがスカラーの :workspace_roots = "write" を持ち,生成側が入れ子の表を出すときは,マージで消えないよう "." = "write" にする(意味は変えない).

Codex のソースでの確認(根拠)

openai/codex の 6bfdc75f0d9e6fae313234f694839866d7c63c39(main)を gh api で読んだ.

  • codex-rs/protocol/src/permissions.rs:FileSystemAccessMode は Read/Write/Deny.Deny は #[serde(alias = "none")] なので "none" は受理される.ただし「legacy input alias retained temporarily」と注記されている.同じ具体性の衝突では deny が勝つ.
  • codex-rs/config/src/permissions_toml.rs:filesystem 表は glob_scan_max_depth と,キーごとの FileSystemAccessMode または入れ子の表.
  • codex-rs/core/src/config/permissions.rs:グロブを含むキーは deny のときだけパターンとして扱われる.read/write のグロブは末尾の /** だけ許され,それ以外はエラー.非 macOS で ** を使う deny グロブは glob_scan_max_depth(すでに 5 を出力)が必要.
  • codex-rs/core/src/config/permission_path.rs:トップレベルのキーは絶対パスか ~/... か : 始まりで,相対パスはエラー.相対パターンは :workspace_roots の下の入れ子の表なら許される(.・.. を含まない子孫パス).

判断・注意点

  • 計画の決定どおり "none" を出力した.alias が外れると設定の読み込みが失敗する(黙って緩むことはない).その場合は "deny" に切り替える.
  • Linux などの非 macOS では,** の deny グロブは glob_scan_max_depth(既存の 5)までしか展開されない.それより深い秘密ファイルは設定では止まらず,フックの検査に頼る.
  • 相対パターンは :workspace_roots の起点(プロジェクトルート)からの一致になる.

テスト

  • 競合の各形が,両方のエントリを示してエラーになる:同じパス,祖先,グロブ,:workspace_roots の入れ子,生成側どうし(保護パスと読み取り禁止ルール).
  • 書き込みのみのルールは Codex のエントリを生まない(ルールの有無で出力が同じ).読み取り禁止のルールは "none" になる.
  • 重ならない組と,同じアクセスの重なりは通る.
  • レビューで出た,ソースの :root = "deny" の下の例外は,書き換えではなくエラーになる.
  • guarded_path の単体テスト:型の不変条件,正規化,祖先とグロブ,ルート間の独立,:root,波括弧,ドライブパス.
  • golden:tests/golden/complete_source/.codex/config.toml に [permissions.guarded.filesystem.":workspace_roots"] と "**/secrets/**" = "none" が末尾に加わっただけ.他のプロバイダの生成物は変わらない.

検証

  • cargo test:全件成功.ただし tests/pi_provider.rs の pi_bash_tool_runs_only_through_srt(pi_sandbox_smoke)は,この環境では origin/main でも失敗する.
  • cargo clippy -- -D warnings,cargo fmt --check:成功
  • 実際の agent-config(/Users/kaito/ghq/github.com/furedea/agent-config/agents,読み取りのみ)で generate-codex-config-source を実行:成功(競合なし,"none" が 26 件,書き込みのみのルールは出力に含まれない).

フォローアップ(最終ラウンドの指摘.このPRでは直さない)

#235 で扱う.

  • guarded_path.rs(P2):間にある例外の判定は,緩いエントリと同じアクセスだけを受け入れる(==).より緩い間のエントリ(:root = "deny" の下の ~ = "write")でも,生成された read は何も開かないのに「開く」というエラーになる.<= にして,テストを足す.
  • guarded_path.rs(P1):Windows のドライブ付きパスを大文字小文字を区別して比べている(C:/Work と C:/work).ドライブとコンポーネントを正規化して比べる.
  • guarded_path.rs(P2):バックスラッシュを Unix でも区切りとして扱うため(直前の対応で入った),/work/project\\name のようなファイル名の文字としてのバックスラッシュが区切りになり,兄弟パスが重なると誤判定する.Windows 形式のパスのときだけ区切りにする.

対象外(フォローアップ)

#235 で扱う.

  • Pi のサンドボックスに秘密パスのポリシーが入っていない(src/generation/pi_sandbox.rs).
  • pi_sandbox_smoke(tests/pi_provider.rs の pi_bash_tool_runs_only_through_srt)が,この環境では main でも失敗する.
  • src/generation/assets/pi/bash_sandbox.ts の jev-lint の指摘.

🤖 Generated with Claude Code

@furedea

furedea commented Nov 12, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T08:03:28.079660Z ab4dc15 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Comment thread src/generation/protection.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Review summary

Blocking findings (P0/P1): none.

P2 (one inline comment, src/generation/protection.rs:78): The rule that the stricter access wins is only applied between protected paths and secret paths. Entries already declared in the source codex/config.toml are skipped. merge_item replaces scalars, so a write-only secret rule can turn a "none" declared in the source config into "read". Also, a scalar ":workspace_roots" in the source config gets replaced by the generated table.

Checked and found correct:

  • Read-deny rules become none and write-only rules become read.
  • A trailing /** is stripped from read-only keys, and other write-only globs are rejected.
  • Paths are split correctly between top-level keys and keys under :workspace_roots.
  • When a protected path and a secret path share a key, the stricter value wins.
  • Tests cover the new mapping and the rejection path. The golden diff contains only the added :workspace_roots section.

The PR already notes that relative patterns only match under the workspace root. That is narrower than the hook's matching, but the hook still covers those paths, so I didn't flag it.

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8feff6a130

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/generation/protection.rs Resolved
@furedea

furedea commented Nov 12, 2026

Copy link
Copy Markdown
Owner

@codex review

Comment thread src/generation/codex_config.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Review summary

No blocking findings (P0/P1: 0).

  • P2 src/generation/codex_config.rs:57: the code that keeps the source's access on a path only checks top-level scalar entries. A stricter source entry inside [permissions.guarded.filesystem.":workspace_roots"] (for example "none") can be overwritten by a less strict generated "read" from a write-only policy rule. See the inline comment.

What I checked and found correct: converting read denials to none and write-only denials to read, removing duplicates against protected paths so the stricter access wins, rejecting write-only globs and ambiguous /x patterns at generation time, turning a scalar :workspace_roots grant into ".", and the golden diff. The existing profiles (profiles/minimal and the complete-source fixture) still generate under the new rules.

I did not check this against Codex itself. The assumption that Codex accepts :workspace_roots and "." comes from the PR description.

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4762f1ea45

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/generation/codex_config.rs Resolved
Comment thread src/generation/codex_config.rs Resolved
Comment thread src/generation/permission_rule.rs Resolved
@furedea

furedea commented Nov 12, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown
Contributor

Review summary (read-only): no findings.

I checked:

  • How secret rules map to Codex: read-denied becomes none, write-only becomes read. I also checked the scope and path resolution for //x, /x, ~/, relative patterns, and slash-free patterns, and that write-only globs Codex can't express are rejected.
  • Merging duplicate entries with the protected paths: the stricter access wins.
  • Merging with the source codex/config.toml (reconcile_guarded_filesystem + merge_item):
    • A stricter source access is kept.
    • A scalar :workspace_roots grant becomes a "." entry next to the scoped children.
    • Non-string keys such as glob_scan_max_depth are skipped safely.
  • The bundled profiles/minimal policy has no rules, so the new error paths can't break the default generation.

Tests cover each new branch, and the golden diff is limited to the expected :workspace_roots table. No blocking issues.

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f52b8799b1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/generation/codex_config.rs Resolved
Comment thread src/generation/codex_config.rs Resolved
furedea and others added 4 commits November 12, 2026 13:17
Denied reads become none and write-only denials become read.
The stricter access wins when a path is also protected.
Relative patterns go under :workspace_roots.
Rules Codex cannot express fail generation instead of emitting a rejected config.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Keep the stricter of a source-declared and a generated access for one path.
Keep a scalar :workspace_roots grant as a . entry beside scoped rules.
Read // as absolute, reject a single leading /, and match slash-free
patterns at any depth as Claude does.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Compare source entries inside scoped tables with the generated ones.
Raise generated children to a scalar source denial of their scope.
Keep a write-only subtree rule such as secrets/** anchored at the root.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Raise each generated entry to the strictest source access that covers it:
:root, :workspace_roots (scalar or dot entry), or a parent directory.
Move the reconciliation into its own module.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea-agent
furedea-agent Bot force-pushed the feat/apply-secret-path-policy-to-codex branch from f52b879 to 5ca5865 Compare November 12, 2026 04:18
@furedea

furedea commented Nov 12, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown
Contributor

Review summary

No blocking issues (0 P0/P1).

  • P2 src/generation/codex_config/reconcile.rs: a source denial on a workspace-relative parent (e.g. ":workspace_roots".secrets = "deny") is not applied to a more specific generated read entry (e.g. secrets/file). The read entry then overrides the denial, so the file becomes readable. Absolute/~ parents and the workspace-wide "." entry are handled correctly.

I checked the rest and it looks right: the policy-to-Codex value mapping (none/read), the //, / and slash-free pattern handling, the error for write-only globs, merging overlaps with protected paths, the conversion of a scalar :workspace_roots into a "." table, and the golden output. Tests cover the main paths well.

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ca58656a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/generation/protection.rs Resolved
… paths

Model a guarded entry so only a denial may hold a pattern and a looser entry
is one concrete path. Normalize ~, ., .. and separators once, then raise each
looser entry to the strictest source or generated entry that covers it,
by ancestor directory or by glob match. Replace the ad-hoc ancestor logic.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 12, 2026

Copy link
Copy Markdown
Owner

@codex review

Comment thread src/generation/guarded_path.rs Resolved
Comment thread src/generation/guarded_path.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Review summary

I found no P0/P1 issues. The conversion rules, the none/read ordering, workspace scoping, and the reconciliation that raises a looser entry to the denial covering it all look right, and the tests cover them well (rule conversion, rejecting write-only globs, source-vs-generated reconciliation, normalization).

Two P2s, posted inline:

  • P2 guarded_path.rs:129: on Windows, RuntimeRoot::directory paths (C:/...) are rejected by GuardedPath::absolute. Because raise_covered runs on every protected path, Codex config generation now fails there even with an empty secret policy.
  • P2 guarded_path.rs:245: source read/write keys ending in /** (which Codex accepts) are skipped instead of being raised. Such an entry under a generated denial can reopen access to the denied secret path.

Blocking findings: 0

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3a6562ca85

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/generation/permission_rule.rs Resolved
…roups

Reject braces in write-only rules, error on a generated looser entry that is not
a concrete path, and widen a brace group that spans a slash to everything below.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 12, 2026

Copy link
Copy Markdown
Owner

@codex review

…tries

Treat C:/ paths as absolute so Windows runtime roots generate.
Read a looser entry ending in /** as its directory so it is raised like any other.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aebf34efbd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/generation/guarded_path.rs Resolved
Comment thread src/generation/guarded_path.rs Resolved
A rule that only denies writes is not rendered for Codex: its permissions apply to
every process the agent starts, and harness scripts write the paths such rules
guard. Hooks keep enforcing them. Remove the write-only rendering and its errors.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 12, 2026

Copy link
Copy Markdown
Owner

@codex review

Comment thread src/generation/guarded_path.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Review summary (read-only)

I found no P0 or P1 issues.

  • P2 in src/generation/guarded_path.rs (conflicts): the conflict check compares each pair of entries on its own and ignores any more specific entry between them. A source config with :root = "deny" and a ~/.codex = "read" exception therefore fails generation, even though the generated protected read entries match the closer exception and reopen nothing.

Everything else matched the PR description: write-only rules are left out of the Codex config, read-denying rules become none, relative patterns go under :workspace_roots (slash-free ones get **/), a scalar :workspace_roots grant is kept as ., and the new behaviour has tests. The known limitations (glob against glob, ~ vs. a resolved home path, workspace vs. absolute roots) are documented.

I couldn't confirm against the Codex source whether * in Codex deny globs can match across /. If it can, this PR's matcher (where * stops at /) would miss some conflicts.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 1b406fc734

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

… looser one

Codex uses the most specific entry. A looser entry that resolves through an
in-between entry of the same access reopens nothing, so it is no longer a conflict.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 12, 2026

Copy link
Copy Markdown
Owner

@codex review

Comment thread src/generation/permission_rule.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Review summary

I reviewed this by reading the code. I could not run cargo test in this environment.

Blocking findings (P0/P1): none.

P2 (1): codex_location rejects a pattern starting with ./ (e.g. ./secrets/**, Claude's documented project-relative form) or ending in a trailing /. The error stops the whole config generation, so a policy that used to produce working Claude rules no longer generates at all. Details are in the inline comment.

Checked and found no problems in:

  • turning read-denying rules into none entries and leaving out write-only rules;
  • splitting entries between top-level keys and the :workspace_roots table;
  • turning a scalar :workspace_roots into a "." entry before the merge;
  • the coverage and exception logic in guarded_path::conflicts and has_exception_between, including :root and the trailing /** on looser entries.

One behaviour change to be aware of: a source config with :root = \"deny\" and no broader read exception now fails generation, because it covers the generated protected-path read entries. The tests and PR description say this is intended.

Tests cover the conflict shapes, write-only rules, entries that don't overlap, and path normalization well.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cdd10c4c8b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/generation/guarded_path.rs Resolved
Match {a,b} and [a-c] by their members instead of widening them.
Let / cover ~ entries. Drop a leading ./ and a trailing / before rendering for Codex.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 12, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown
Contributor

Automated review summary

I found no blocking issues, and nothing reached the bar for an inline comment.

What I checked:

  • Mapping secret rules to Codex. A rule that denies reads becomes "none". A write-only rule is left out of the Codex config. ~/ and // paths go at the top level; relative patterns go under :workspace_roots. A leading single / is rejected.
  • Merging over a source config. If the source has a scalar :workspace_roots = "write" and the generated config adds a :workspace_roots table, the scalar is kept as "." = "write" so the write grant isn't lost.
  • Conflict detection. I traced how paths are compared within each root, how ** and glob matching work, and the exception rule for an entry in between. I checked the cases a reviewer could plausibly flip: ~/.codex/** = none against ~/.codex = read, and :root = deny with a ~ exception. Both behave as the PR describes.
  • Tests. The unit tests, codex_config tests and golden update cover the behavior that changed.

Minor notes, none blocking:

  • generate-codex-config-fragment can now emit a [permissions.guarded.filesystem.":workspace_roots"] table. A consumer that merges this fragment over a config with a scalar :workspace_roots would need the same "." preservation that codex_config.rs does.
  • widen_braces only looks at the first {...} group. A later group that contains / is not widened, so a conflict hidden behind it could be missed. This is unlikely in real policies.
  • There is no test for the :project_roots branch of keep_scalar_workspace_grants.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5e0a1d18c2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/generation/permission_rule.rs Resolved
Comment thread src/generation/guarded_path.rs Resolved
Comment thread src/generation/guarded_path.rs Resolved
Codex does not expand braces, so a read-denying rule with one fails generation.
Treat a backslash as a path separator when normalizing guarded keys.
Document that a project-local runtime root is not matched against the workspace.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 12, 2026

Copy link
Copy Markdown
Owner

@codex review

Comment thread src/generation/guarded_path.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Review summary

Blocking findings (P0/P1): 0

  • P2 src/generation/guarded_path.rs:398: the exception check in has_exception_between only counts an in-between entry with the same access as the inner entry (==). It should also count a looser one (<=). Example: a source with :root = "deny" and ~ = "write" fails generation with a false "would reopen" conflict on the generated ~/.codex/... read entries. Those entries are actually stricter than their nearest covering entry, ~ = "write". The failure is fail-closed (no permissions are loosened), but the error is misleading. A test for this case is missing.

Things I checked that look correct:

  • Write-only rules are left out of Codex. Read-deny rules render as none.
  • /x is rejected, //x becomes absolute, and slash-free patterns get a **/ prefix.
  • Brace patterns are rejected.
  • A scalar :workspace_roots grant becomes "." = "write" and survives the merge.
  • Glob/ancestor coverage is checked separately for each root.
  • Source-only pairs are skipped.

The known limitations are documented in the PR body: project-runtime absolute protected paths are not compared against the workspace, and glob-vs-glob coverage is not checked. Since the secret policy is still enforced by hooks, I don't consider these blocking.

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ab4dc154ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/generation/guarded_path.rs Resolved
Comment thread src/generation/guarded_path.rs Resolved
@furedea

furedea commented Nov 12, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ab4dc154ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/generation/guarded_path.rs Resolved
@furedea
furedea merged commit 0830fd9 into main Nov 12, 2026
32 of 36 checks passed
@furedea
furedea deleted the feat/apply-secret-path-policy-to-codex branch November 12, 2026 08:13
furedea pushed a commit that referenced this pull request Nov 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.9.13](agent-harness-v0.9.12...agent-harness-v0.9.13)
(2026-11-12)


### Features

* **codex:** apply the secret path policy to the guarded filesystem
([#233](#233))
([0830fd9](0830fd9))
* **pi:** run Pi shell and file tools inside srt
([#228](#228))
([37de3ac](37de3ac))


### Bug Fixes

* dedupe the Nix socket in Pi's srt policy and name the failed sidecar
write ([#237](#237))
([1ccafe0](1ccafe0))
* fail on missing HOME, bound GitHub API waits, reject unknown hook keys
([#218](#218))
([c0b936d](c0b936d))
* **install:** publish atomically and keep Claude settings keys the
harness does not own
([#219](#219))
([c914c76](c914c76))
* **pi:** confirm ask decisions and deliver skills, instructions, and
settings ([#223](#223))
([2e755af](2e755af))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: furedea-release[bot] <353651101+furedea-release[bot]@users.noreply.github.com>
furedea added a commit that referenced this pull request Nov 12, 2026
## Issue

Refs #235(レーン `guarded`).#233 で範囲外とした Codex の guarded パス照合の端のケースを直す.

## Plan


#235 (comment)

## 変更

- 中間の例外:パスは「最も近い被覆エントリ」で解決する.`:root = "deny"` の下の `~ = "write"`
は,その下の生成エントリの例外になる.
- Windows 形式(ドライブ,UNC,Windows ホスト上のすべてのパス)は大文字と小文字を区別せずに比べ,`\`
を区切りとする.それ以外では `\` はファイル名の文字.
- 文字クラス末尾のハイフン(`[a-]`)を文字として残す(globset の `parse_class` に合わせた).
- プロジェクト内インストールでは,ワークスペース内の絶対パスと `:workspace_roots`
のエントリを同じ場所として照合する.`RuntimeRoot::project_directory` から渡し,ファイルシステムは読まない.
- UNC を別のルートにした.照合のグロブ部分を `guarded_path/pattern.rs`
に分離し,`docs/DESIGN*.md` を更新した.

各ケースを先にテストとして書いてから実装した.

## 検証

- `cargo test` 全件成功,`cargo clippy -- -D warnings`,`cargo fmt --check`
通過.
- 実ソース(`agent-config/agents`)で,変更前(origin/main)と変更後の
`install`(ホーム,`--runtime-root /work/proj`)の出力 370 ファイルが `diff -r` で完全一致.
- CI:再レビューの上限(3 回)に達したため,`codex-review`
は最後の指摘で失敗のまま(下記のフォローアップ).他のチェックは通過.

## 計画からの変更点

なし.

## フォローアップ(再レビューの上限で保留)

- UNC のプロジェクトルートで,`rewritten_for` が `Root::Unc` を変換せず,`below` が常に
`Root::Absolute` を作る.そのため UNC のプロジェクト内インストールでは `:workspace_roots`
との照合が効かない.
- Windows ホストで UNC の接頭辞を `\\` と `//`
以外の混在(`\/`,`/\`)でも認識する(自動セキュリティレビューの指摘).

---------

Co-authored-by: furedea <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
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.

refactor: derive remaining provider lookups from spec and apply secret path policy to Codex

1 participant