Skip to content

Expand ~ in MDM workspace write roots#15351

Merged
evawong-oai merged 14 commits intomainfrom
codex/mdm-home-guard
Mar 25, 2026
Merged

Expand ~ in MDM workspace write roots#15351
evawong-oai merged 14 commits intomainfrom
codex/mdm-home-guard

Conversation

@evawong-oai
Copy link
Contributor

@evawong-oai evawong-oai commented Mar 20, 2026

Summary

  • Reuse the existing config path resolver for the macOS MDM managed preferences layer so writable_roots = ["~/code"] expands the same way as file backed config
  • keep the change scoped to the MDM branch in config_loader; the current net diff is only config_loader/mod.rs plus focused regression tests in config_loader/tests.rs and config/service_tests.rs
  • research note: resolve_relative_paths_in_config_toml(...) is already used in several existing configuration paths, including CLI overrides, file-backed managed config, normal config-file loading, project .codex/config.toml loading, and role config loading

Validation

  • cargo fmt --all --check
  • cargo test -p codex-core managed_preferences_expand_home_directory_in_workspace_write_roots -- --nocapture
  • cargo test -p codex-core write_value_succeeds_when_managed_preferences_expand_home_directory_paths -- --nocapture

@evawong-oai
Copy link
Contributor Author

@codex review

Copy link
Contributor

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

Choose a reason for hiding this comment

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

💡 Codex Review

let _: ConfigToml = value.clone().try_into()?;

P1 Badge Validate merged config with home-expansion guard

read() now accepts MDM ~/... paths via deserialize_merged_config_toml, but apply_edits() still runs validate_config(), which deserializes with plain try_into() and no AbsolutePathBufGuard. That makes behavior inconsistent: the same managed config can be read successfully, then any write fails with ConfigValidationError (e.g. AbsolutePathBuf deserialized without a base path).

ℹ️ 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".

@evawong-oai
Copy link
Contributor Author

@codex address that feedback

@chatgpt-codex-connector
Copy link
Contributor

Summary

  • Updated ConfigService::apply_edits to validate user config only through the guarded deserialize_config_toml_with_base(...) path before feature checks, removing the redundant unguarded deserialization pass that could reject ~/... path fields during writes. codex-rs/core/src/config/service.rsL336-L364
  • Added a regression test that verifies writes still succeed when config.toml already contains a home-relative path (model_instructions_file = "~/instructions.md"), ensuring this flow remains supported on non-Windows platforms. codex-rs/core/src/config/service_tests.rsL338-L366

Testing

  • just fmt
  • ⚠️ cargo test -p codex-core (failed in this environment due crates.io access errors while resolving dependency v8).
  • ⚠️ just argument-comment-lint (failed because prebuilt linter wrapper requires dotslash in this environment).
  • ⚠️ ./tools/argument-comment-lint/run.sh (failed because cargo-dylint/dylint-link are not installed).
  • ⚠️ cargo install --locked cargo-dylint dylint-link (install failed due crates.io/network access restrictions).

Committed on the current branch and created a follow-up PR message with make_pr.

View task →

@evawong-oai evawong-oai changed the title config: support ~/ paths in MDM config Support home path for CODEX Mar 20, 2026
@evawong-oai evawong-oai force-pushed the codex/mdm-home-guard branch from ee06025 to 2cf2738 Compare March 20, 2026 22:08
@evawong-oai
Copy link
Contributor Author

@codex review

Copy link
Contributor

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

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: 75947d8963

ℹ️ 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".

@evawong-oai
Copy link
Contributor Author

Addressing the earlier Codex review note about apply_edits() still failing on managed ~/... paths: this is fixed in efe354ffb.

apply_edits() still uses validate_config(&user_config) for raw user-file schema checks, but the path-sensitive deserialization during writes now goes through the guarded helpers:

  • deserialize_config_toml_with_base(user_config.clone(), &self.codex_home) before feature validation in codex-rs/core/src/config/service.rs
  • validate_merged_config(&effective, &self.codex_home) on the merged config, which uses deserialize_merged_config_toml(...)

So managed ~/... values are now validated with home expansion on write, not just on read. There is also a regression test in write_value_succeeds_when_managed_preferences_expand_home_directory_paths() in codex-rs/core/src/config/service_tests.rs that sets managed writable_roots = ["~/code"] and verifies write_value(...) succeeds.

@evawong-oai evawong-oai marked this pull request as ready for review March 20, 2026 23:10
@evawong-oai evawong-oai changed the title Support home path for CODEX Support home path for CODEX for workspace-write Mar 20, 2026
@evawong-oai evawong-oai marked this pull request as draft March 23, 2026 15:36
@evawong-oai evawong-oai force-pushed the codex/mdm-home-guard branch from ddfc21a to 0b61e45 Compare March 23, 2026 15:46
@evawong-oai evawong-oai changed the title Support home path for CODEX for workspace-write Support home paths in MDM workspace-write config Mar 23, 2026
@evawong-oai
Copy link
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Can't wait for the next one!

ℹ️ 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".

@evawong-oai evawong-oai marked this pull request as ready for review March 23, 2026 18:07
Copy link
Contributor

@rreichel3-oai rreichel3-oai left a comment

Choose a reason for hiding this comment

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

Few open questions! Looks like the actual logic is functional

})
.await?;

let mut saw_patch_begin = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

What are these changes actually testing with this PR? These seem unnecessary?

Copy link
Contributor Author

@evawong-oai evawong-oai Mar 23, 2026

Choose a reason for hiding this comment

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

These are changes that are needed for CI related to Mac changes to go green. The x86 macOS Bazel failure is stalling because shell_snapshot.rs submits the turn with approval_policy: AskForApproval::Never, but the test process is running under managed config that only allows OnRequest. The turn gets rejected up front in the session settings path in codex.rs line 2319, emits an Error event, and never reaches the shell tool or intercepted apply_patch path. The test then keeps waiting for TurnComplete or patch events until its timeout, which makes it look like a slow shell snapshot problem :(

"once_cell",
"rustix 1.1.3",
"windows-sys 0.61.2",
"windows-sys 0.52.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we downgrading Windows versions here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed from this PR. That lockfile churn came from an unrelated tar bump and re resolution, not from the MDM path fix itself, so I dropped it while narrowing the branch back to the bug fix only.

@evawong-oai evawong-oai force-pushed the codex/mdm-home-guard branch from 176fc97 to 0b61e45 Compare March 23, 2026 18:36
@etraut-openai etraut-openai added the oai PRs contributed by OpenAI employees label Mar 23, 2026
@evawong-oai evawong-oai force-pushed the codex/mdm-home-guard branch 2 times, most recently from efd250f to e6923b1 Compare March 24, 2026 00:31
@evawong-oai evawong-oai force-pushed the codex/mdm-home-guard branch from e6923b1 to d806b22 Compare March 24, 2026 15:18
@evawong-oai evawong-oai changed the title Support home paths in MDM workspace-write config Expand ~ in MDM workspace-write roots Mar 24, 2026
@evawong-oai evawong-oai changed the title Expand ~ in MDM workspace-write roots Expand ~ in MDM workspace write roots Mar 24, 2026
@evawong-oai evawong-oai enabled auto-merge (squash) March 24, 2026 21:07
));
}
if let Some(config) = managed_config_from_mdm {
let managed_config =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, I'm debating whether we should do this or bring back your alternative path guard that honors ~ but not ./.

This is certainly simpler.

I don't know if there's a valid use case to specify a relative path in an MDM config. In the worst case, it could be an attack vector, but because MDM should be set by a trusted person, I guess I'm not that worried about that.

Maybe please just add a comment that we use codex_home as the base so that ~ and ./ are honored using our AbsolutePathBufGuard logic, though in practice, we expect ~ to be used but not ./.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. Following up with a comment.

@evawong-oai evawong-oai merged commit ea3f346 into main Mar 25, 2026
36 checks passed
@evawong-oai evawong-oai deleted the codex/mdm-home-guard branch March 25, 2026 00:55
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

oai PRs contributed by OpenAI employees

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants