Skip to content

Conversation

@bolinfest
Copy link
Collaborator

@bolinfest bolinfest commented Dec 16, 2025

This attempts to tighten up the types related to "config layers." Currently, ConfigLayerEntry is defined as follows:

#[derive(Debug, Clone)]
pub struct ConfigLayerEntry {
pub name: ConfigLayerName,
pub source: PathBuf,
pub config: TomlValue,
pub version: String,
}

but the source field is a bit of a lie, as:

  • for ConfigLayerName::Mdm, it is "com.openai.codex/config_toml_base64"
  • for ConfigLayerName::SessionFlags, it is "--config"
  • for ConfigLayerName::User, it is "config.toml" (just the file name, not the path to the config.toml on disk that was read)
  • for ConfigLayerName::System, it seems like it is usually /etc/codex/managed_config.toml in practice, though on Windows, it is %CODEX_HOME%/managed_config.toml:

https://github.com/openai/codex/blob/bef36f4ae765f471d7cd69372fcf1b92c8f0367a/codex-rs/core/src/config_loader/layer_io.rs#L84-L101

All that is to say, in three out of the four ConfigLayerName, source is a PathBuf that is not an absolute path (or even a true path).

This PR tries to uplevel things by eliminating source from ConfigLayerEntry and turning ConfigLayerName into a disjoint union named ConfigLayerSource that has the appropriate metadata for each variant, favoring the use of AbsolutePathBuf where appropriate:

pub enum ConfigLayerSource {
    /// Managed preferences layer delivered by MDM (macOS only).
    #[serde(rename_all = "camelCase")]
    #[ts(rename_all = "camelCase")]
    Mdm { domain: String, key: String },
    /// Managed config layer from a file (usually `managed_config.toml`).
    #[serde(rename_all = "camelCase")]
    #[ts(rename_all = "camelCase")]
    System { file: AbsolutePathBuf },
    /// Session-layer overrides supplied via `-c`/`--config`.
    SessionFlags,
    /// User config layer from a file (usually `config.toml`).
    #[serde(rename_all = "camelCase")]
    #[ts(rename_all = "camelCase")]
    User { file: AbsolutePathBuf },
}

@gt-oai
Copy link
Contributor

gt-oai commented Dec 16, 2025

override_keys on the SessionFlags variant doesn't feel right to me

Do you need it at all? Are the keys (and values) already in the ConfigLayerEntry.config?

ConfigLayerName now feels like it should be ConfigLayerLocation or something.

ConfigSource or ConfigLayerSource sound reasonable to me, as the source field is the one you've removed and whose information is now in the union.

@owenlin0
Copy link
Contributor

+1 to ConfigLayerSource

@bolinfest bolinfest marked this pull request as ready for review December 17, 2025 03:32
@bolinfest bolinfest requested review from gt-oai and jif-oai December 17, 2025 03:32
Copy link
Collaborator

@jif-oai jif-oai left a comment

Choose a reason for hiding this comment

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

I like it

@bolinfest bolinfest merged commit de3fa03 into main Dec 17, 2025
26 checks passed
@bolinfest bolinfest deleted the pr8095 branch December 17, 2025 16:14
@github-actions github-actions bot locked and limited conversation to collaborators Dec 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants