Conversation
…empty (#8456) This is necessary so that `$CODEX_HOME/skills` and `$CODEX_HOME/rules` still get loaded even if `$CODEX_HOME/config.toml` does not exist. See #8453. For now, it is possible to omit this layer when creating a dummy `ConfigLayerStack` in a test. We can revisit that later, if it turns out to be the right thing to do.
d78ca23 to
870cf22
Compare
| for layer in config_stack.get_layers(ConfigLayerStackOrdering::LowestPrecedenceFirst) { | ||
| if let Some(config_folder) = layer.config_folder() { | ||
| #[expect(clippy::expect_used)] | ||
| let policy_dir = config_folder.join(RULES_DIR_NAME).expect("safe join"); |
There was a problem hiding this comment.
(not a blocker - more interested in how this might be avoided in case the assumption is wrong)
So it seems like this would fail if the path can't be resolved against the base path (I'm assuming you've thought through why this happen a bit more than I have here...)
codex/codex-rs/utils/absolute-path/src/lib.rs
Lines 42 to 44 in 14dbd06
Are we missing a small ResolvedAbsolutePath concept here perhaps that would codify this more definitely?
There was a problem hiding this comment.
Something like ResolvedAbsolutePath would avoid the expect(), but given that RULES_DIR_NAME is "rules" and is very, very unlikely to change (since it's now API), I don't see how the join() could fail given that AbsolutePathBuf is already guaranteeing its internal path is a valid absolute path?
| // TODO(mbolin): At a minimum, `cwd` should be configurable via | ||
| // `codex/sandbox-state/update` or some other custom MCP call. |
There was a problem hiding this comment.
Probably worth expanding on this a little (I found myself digging for more context about the call here being unfamiliar with the code).
Something like: We currently don't include cwd in the layers to load exec policy rule from because ... In the future we should ... because ...
There was a problem hiding this comment.
This is still an experimental feature that's on me to get over the finish line. It requires a bit of background to have the full context, I admit:
codex/codex-rs/exec-server/src/posix.rs
Lines 1 to 57 in 14dbd06
#8354 added support for in-repo
.config/files, so this PR updates the logic for loading*.rulesfiles to load*.rulesfiles from all relevant layers. The main change to the business logic isload_exec_policy()incodex-rs/core/src/exec_policy.rs.Note this adds a
config_folder()method toConfigLayerSourcethat returnsOption<AbsolutePathBuf>so that it is straightforward to iterate over the sources and get the associated config folder, if any.