Skip to content

fix: merge per-path Codex filesystem rules across read/edit/write categories#2291

Merged
dyoshikawa merged 2 commits into
mainfrom
resolve-scrap-issue-2283-codex-rw-merge
Jul 16, 2026
Merged

fix: merge per-path Codex filesystem rules across read/edit/write categories#2291
dyoshikawa merged 2 commits into
mainfrom
resolve-scrap-issue-2283-codex-rw-merge

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Summary

Codex CLI models a single filesystem access level per path (deny < read < write), while rulesync's canonical model has separate read/edit/write categories. convertRulesyncToCodexProfile iterated the categories independently and wrote each rule with a plain assignment, so when the same pattern appeared in multiple categories the last-processed category silently overwrote the earlier one — read: allow + write: deny emitted "{path}" = "deny", blocking reads the user explicitly allowed, when the intended "readable but not writable" is exactly what Codex's "read" level expresses.

Changes

  • New mergeFilesystemCategoryRules collects the three categories and emits one access level per pattern, order-independently:
    • edit/write collapse onto Codex's write side; when both carry the same pattern, the more restrictive action wins (deny > ask > allow).
    • read: allow + write-side allow"write"
    • read: allow + write-side non-allow → "read" (the issue's headline case)
    • read non-allow → "deny"; a contradictory write-side allow ("writable but not readable" is not expressible in Codex) emits a warning.
    • Single-category patterns keep the existing mapReadAction/mapWriteAction mappings — no behavior change for configs without cross-category overlaps.
  • Round-trip asymmetry documented (issue step 4): "{path}" = "read" imports back as read: allow only; the write-side deny is implied by Codex's access level and deliberately not re-materialized (synthesizing write: deny on import would pollute round-trips of plain single-category read rules). Recorded in the merge function's doc comment.
  • Unit tests cover the merge matrix (read+write allow/deny combinations, contradiction warning, edit-vs-write restrictive collapse).

Closes #2283

🤖 Generated with Claude Code

cm-dyoshikawa and others added 2 commits July 16, 2026 01:14
…egories

Codex models a single access level per path (deny < read < write) while
the canonical model has separate read/edit/write categories. The
generator previously wrote each category's rules into the filesystem
table with plain assignments, so the last-processed category silently
overwrote earlier ones — read: allow + write: deny emitted "deny",
blocking reads the user explicitly allowed.

Rules are now merged per pattern before emission:
- edit/write collapse onto Codex's write side, restrictive action wins
- read allow + write-side allow -> "write"
- read allow + write-side non-allow -> "read" (readable, not writable)
- read non-allow -> "deny"; a contradictory write-side allow (not
  expressible in Codex) warns
- single-category patterns keep the existing mappings

The merge is one-way and documented: "read" imports back as read:allow
only, since the write-side deny is implied by Codex's access level.

Closes #2283

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dyoshikawa
dyoshikawa merged commit 01aa622 into main Jul 16, 2026
9 checks passed
@dyoshikawa

Copy link
Copy Markdown
Owner Author

@dyoshikawa Thank you!

@dyoshikawa
dyoshikawa deleted the resolve-scrap-issue-2283-codex-rw-merge branch July 16, 2026 08: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 CLI: merge per-path read/write rules — read: allow + write: deny should emit "{path}" = "read"

2 participants