Add cloud-managed config layer support (#24620)

## Summary

PR 3 of 5 in the cloud-managed config client stack.

Adds enterprise-managed cloud config as a first-class config layer
source. The layer metadata is preserved through config loading,
diagnostics, debug output, hook attribution, and app-server protocol
surfaces.

## Details

- Enterprise-managed config becomes a normal config layer source with
backend-supplied `id` and display `name` attached for provenance.
- These layers are designed to behave like non-file managed config: they
can surface syntax/type diagnostics by layer name even though there is
no physical config file.
- Relative path settings are resolved from a stored config base so
cloud-delivered config remains consistent with existing MDM-delivered
config semantics.
- Hook attribution distinguishes config-delivered hooks from
requirements-delivered hooks via `HookSource::CloudManagedConfig`.
- This remains pull-based and snapshot-oriented; the PR adds layer
identity/diagnostics, not dynamic reload behavior.

## Validation

Validated through the targeted stack checks after rebasing onto current
`main`:

- Rust crate tests for
config/hooks/cloud-config/backend-client/app-server-protocol
- Filtered `codex-core` and `codex-app-server` `cloud_config_bundle`
tests
- Python generated-file contract test
- `cargo shear --deny-warnings`
- Targeted `argument-comment-lint` for config/hooks
This commit is contained in:
joeflorencio-openai authored and GitHub committed 2026-05-31 15:54:31 -07:00
1 parent 20debf746b
commit 8a556296f0
27 files changed
+644 -48

No files matched your search

+27 -6
View File
@@ -97,33 +97,47 @@ impl LoaderOverrides {
pub struct ConfigLayerEntry {
pub name: ConfigLayerSource,
pub config: TomlValue,
pub raw_toml: Option<String>,
pub version: String,
pub disabled_reason: Option<String>,
raw_toml: Option<RawTomlLayer>,
hooks_config_folder_override: Option<AbsolutePathBuf>,
}
#[derive(Debug, Clone, PartialEq)]
struct RawTomlLayer {
contents: String,
base_dir: AbsolutePathBuf,
}
impl ConfigLayerEntry {
pub fn new(name: ConfigLayerSource, config: TomlValue) -> Self {
let version = version_for_toml(&config);
Self {
name,
config,
raw_toml: None,
version,
disabled_reason: None,
raw_toml: None,
hooks_config_folder_override: None,
}
}
pub fn new_with_raw_toml(name: ConfigLayerSource, config: TomlValue, raw_toml: String) -> Self {
pub fn new_with_raw_toml(
name: ConfigLayerSource,
config: TomlValue,
raw_toml: String,
raw_toml_base_dir: AbsolutePathBuf,
) -> Self {
let version = version_for_toml(&config);
Self {
name,
config,
raw_toml: Some(raw_toml),
version,
disabled_reason: None,
raw_toml: Some(RawTomlLayer {
contents: raw_toml,
base_dir: raw_toml_base_dir,
}),
hooks_config_folder_override: None,
}
}
@@ -137,9 +151,9 @@ impl ConfigLayerEntry {
Self {
name,
config,
raw_toml: None,
version,
disabled_reason: Some(disabled_reason.into()),
raw_toml: None,
hooks_config_folder_override: None,
}
}
@@ -149,7 +163,13 @@ impl ConfigLayerEntry {
}
pub fn raw_toml(&self) -> Option<&str> {
self.raw_toml.as_deref()
self.raw_toml
.as_ref()
.map(|raw_toml| raw_toml.contents.as_str())
}
pub fn raw_toml_base_dir(&self) -> Option<&AbsolutePathBuf> {
self.raw_toml.as_ref().map(|raw_toml| &raw_toml.base_dir)
}
pub(crate) fn with_hooks_config_folder_override(
@@ -181,6 +201,7 @@ impl ConfigLayerEntry {
match &self.name {
ConfigLayerSource::Mdm { .. } => None,
ConfigLayerSource::System { file } => file.parent(),
ConfigLayerSource::EnterpriseManaged { .. } => None,
ConfigLayerSource::User { file, .. } => file.parent(),
ConfigLayerSource::Project { dot_codex_folder } => Some(dot_codex_folder.clone()),
ConfigLayerSource::SessionFlags => None,