Add workspace metadata protection policy primitive#19846
Add workspace metadata protection policy primitive#19846evawong-oai wants to merge 1 commit intomainfrom
Conversation
a99da8c to
5b59ee3
Compare
01771db to
11fa852
Compare
5b8dd2e to
0f697bc
Compare
11fa852 to
ab4b378
Compare
There was a problem hiding this comment.
💡 Codex Review
codex/codex-rs/protocol/src/permissions.rs
Lines 726 to 728 in ab4b378
needs_direct_runtime_enforcement decides compatibility by comparing semantic signatures, but preserved-name write denials are enforced in can_write_path_with_cwd and are not represented in the bridged legacy model. This can return false and skip direct enforcement even when .git/.agents/.codex writes should be blocked.
ℹ️ 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".
| fn first_preserved_component(path: &Path) -> Option<(AbsolutePathBuf, &'static str)> { | ||
| let mut candidate = PathBuf::new(); | ||
| for component in path.components() { | ||
| candidate.push(component.as_os_str()); | ||
| if let Some(preserved_name) = preserved_path_name(component.as_os_str()) { | ||
| let absolute = AbsolutePathBuf::from_absolute_path(candidate).ok()?; | ||
| return Some((absolute, preserved_name)); |
There was a problem hiding this comment.
Restrict preserved-name blocking to root-level metadata
can_write_path_with_cwd calls first_preserved_component, which scans all path components and denies writes whenever any component is .git, .agents, or .codex unless there is a deeper explicit rule. This blocks legitimate nested repo writes (e.g. /tmp/repo/.git/...) under otherwise writable roots, so common flows like cloning in /tmp regress.
Useful? React with 👍 / 👎.
ab4b378 to
8e60a50
Compare
8e60a50 to
0b263d0
Compare
Summary
Add a policy primitive for protected workspace metadata names so writable roots can reserve
.git,.codex, and.agentsbefore platform sandbox code consumes the policy.Scope
protected_metadata_namestoWritableRoot..git,.codex, and.agents.Reviewer Focus
Stack
Validation
cargo test --manifest-path codex-rs/Cargo.toml -p codex-protocol permissionscargo fmt --manifest-path codex-rs/Cargo.toml --package codex-protocol --package codex-linux-sandboxgit diff --check