Skip to content

feat(codexcli): opt-in canonical_matching on bash deny and ask rules - #3817

Merged
dyoshikawa merged 2 commits into
mainfrom
resolve-issue-2496-codex-canonical-matching
Nov 8, 2026
Merged

dyoshikawa merged 2 commits into
mainfrom
resolve-issue-2496-codex-canonical-matching

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Summary

Codex rust-v0.167.0 (openai/codex#59535) added a canonical_matching keyword to prefix_rule(). With canonical_matching = True, pattern tokens are compared after Unicode canonical case-insensitive folding, so a forbidden rule for rm also matches RM or other look-alike spellings. On a case-insensitive filesystem those spellings still run the same binary. Rulesync never wrote the keyword.

This PR adds an opt-in boolean, codexcli.bash_canonical_matching, to the existing Codex CLI tool-scoped permissions override. It does not add a canonical schema field. The option is off by default because the prefix_rule builtin at rust-v0.166.0 has no such parameter: Starlark rejects the unknown keyword, and an older Codex would fail to load the whole rules file.

Changes

  • src/types/permissions.ts: add bash_canonical_matching: z.optional(z.boolean()) to CodexcliPermissionsOverrideSchema and document it.
  • src/features/permissions/codexcli-permissions.ts:
    • When the option is true, buildCodexBashRulesContent writes canonical_matching = True on the forbidden (deny) and prompt (ask) rules in .codex/rules/rulesync.rules.
    • allow rules stay exact, so the option never widens what Codex auto-approves.
    • Like git_write_rules, the key is read by the generator and is not written to config.toml. computeCodexcliOverridePatch skips it without the "not managed" warning.
  • docs/reference/file-formats.md: document the key, the Codex 0.167.0+ requirement, and that it does not round-trip through import. src/generated/docs-content.ts is regenerated from the docs.
  • Unit tests:
    • Nothing is written by default or with false.
    • With true, only the deny and ask rules carry the keyword.
    • The key is not written to config.toml and does not trigger a warning.

Default output is unchanged, so no e2e expectations change.

Verification

  • Checked upstream: prefix_rule in codex-rs/execpolicy/src/parser.rs takes canonical_matching: Option<bool> at rust-v0.167.0 but not at rust-v0.166.0.
  • pnpm cicheck passes (614 test files, 16829 tests; content checks green).

Refs #2496

🤖 Generated with Claude Code

https://claude.ai/code/session_01QUBBebviXSBQtiRAmDopZ7

dyoshikawa and others added 2 commits November 8, 2026 20:58
Add a codexcli.bash_canonical_matching permissions override that writes
canonical_matching = True on the forbidden and prompt prefix rules in
.codex/rules/rulesync.rules (Codex 0.167.0+). Off by default because an
older Codex rejects the unknown keyword and fails to load the rules file.
Allow rules stay exact so the option never widens auto-approval.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QUBBebviXSBQtiRAmDopZ7
…dex-canonical-matching

# Conflicts:
#	src/generated/docs-content.ts
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.

1 participant