mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
Switch runtime to cloud config bundle (#24622)
## Summary - Adapts the moved `codex-cloud-config` crate from the legacy cloud requirements endpoint to the new config bundle endpoint. - Switches runtime consumers from `CloudRequirementsLoader` to `CloudConfigBundleLoader` so one shared bundle supplies cloud-delivered config and requirements. - Removes the legacy cloud requirements domain loader path. ## Details This intentionally keeps `codex-cloud-config` monolithic for review lineage: the previous PR establishes the crate move, and this PR shows the behavior change against that moved implementation. A follow-up PR splits the module back into focused files. The new bundle path preserves the important cloud requirements loader semantics where intended: account-scoped signed cache, 30 minute TTL, 5 minute refresh cadence, retry/backoff, auth recovery, and fail-closed startup loading. The cached payload changes from a single requirements TOML string to the backend-delivered bundle, and validation rejects malformed config or requirements fragments before cache write/use.
This commit is contained in:
@@ -274,9 +274,6 @@ fn fallback_managed_hooks_source_path(
|
||||
Some(RequirementSource::MdmManagedPreferences { domain, key }) => {
|
||||
synthetic_layer_path(&format!("<mdm:{domain}:{key}>/requirements.toml"))
|
||||
}
|
||||
Some(RequirementSource::CloudRequirements) => {
|
||||
synthetic_layer_path("<cloud-requirements>/requirements.toml")
|
||||
}
|
||||
Some(RequirementSource::Composite { .. }) => {
|
||||
synthetic_layer_path("<requirements-composition>/requirements.toml")
|
||||
}
|
||||
@@ -635,7 +632,6 @@ fn hook_source_for_requirement_source(source: Option<&RequirementSource>) -> Hoo
|
||||
Some(RequirementSource::LegacyManagedConfigTomlFromMdm) => {
|
||||
HookSource::LegacyManagedConfigMdm
|
||||
}
|
||||
Some(RequirementSource::CloudRequirements) => HookSource::CloudRequirements,
|
||||
Some(RequirementSource::Composite { sources }) => {
|
||||
// Requirements hook composition preserves contributing sources in
|
||||
// priority order, but discovery only carries one source for the
|
||||
|
||||
@@ -120,12 +120,12 @@ fn requirements_with_managed_hooks_only(
|
||||
ConfigRequirements {
|
||||
allow_managed_hooks_only: Some(Sourced::new(
|
||||
allow_managed_hooks_only,
|
||||
RequirementSource::CloudRequirements,
|
||||
RequirementSource::LegacyManagedConfigTomlFromMdm,
|
||||
)),
|
||||
managed_hooks: managed_hooks.clone().map(|hooks| {
|
||||
ConstrainedWithSource::new(
|
||||
Constrained::allow_any(hooks),
|
||||
Some(RequirementSource::CloudRequirements),
|
||||
Some(RequirementSource::LegacyManagedConfigTomlFromMdm),
|
||||
)
|
||||
}),
|
||||
..ConfigRequirements::default()
|
||||
@@ -183,7 +183,7 @@ with Path(r"{log_path}").open("a", encoding="utf-8") as handle:
|
||||
ConfigRequirements {
|
||||
managed_hooks: Some(ConstrainedWithSource::new(
|
||||
Constrained::allow_any(managed_hooks.clone()),
|
||||
Some(RequirementSource::CloudRequirements),
|
||||
Some(RequirementSource::LegacyManagedConfigTomlFromMdm),
|
||||
)),
|
||||
..ConfigRequirements::default()
|
||||
},
|
||||
@@ -208,7 +208,10 @@ with Path(r"{log_path}").open("a", encoding="utf-8") as handle:
|
||||
|
||||
assert!(engine.warnings().is_empty());
|
||||
assert_eq!(engine.handlers.len(), 1);
|
||||
assert_eq!(engine.handlers[0].source, HookSource::CloudRequirements);
|
||||
assert_eq!(
|
||||
engine.handlers[0].source,
|
||||
HookSource::LegacyManagedConfigMdm
|
||||
);
|
||||
let listed = crate::list_hooks(crate::HooksConfig {
|
||||
legacy_notify_argv: None,
|
||||
feature_enabled: true,
|
||||
@@ -286,7 +289,7 @@ async fn requirements_managed_hooks_execute_windows_command_override() {
|
||||
ConfigRequirements {
|
||||
managed_hooks: Some(ConstrainedWithSource::new(
|
||||
Constrained::allow_any(managed_hooks.clone()),
|
||||
Some(RequirementSource::CloudRequirements),
|
||||
Some(RequirementSource::LegacyManagedConfigTomlFromMdm),
|
||||
)),
|
||||
..ConfigRequirements::default()
|
||||
},
|
||||
@@ -447,7 +450,7 @@ fn user_disablement_filters_non_managed_hooks_but_not_managed_hooks() {
|
||||
ConfigRequirements {
|
||||
managed_hooks: Some(ConstrainedWithSource::new(
|
||||
Constrained::allow_any(managed_hooks.clone()),
|
||||
Some(RequirementSource::CloudRequirements),
|
||||
Some(RequirementSource::LegacyManagedConfigTomlFromMdm),
|
||||
)),
|
||||
..ConfigRequirements::default()
|
||||
},
|
||||
@@ -471,7 +474,10 @@ fn user_disablement_filters_non_managed_hooks_but_not_managed_hooks() {
|
||||
);
|
||||
|
||||
assert_eq!(engine.handlers.len(), 1);
|
||||
assert_eq!(engine.handlers[0].source, HookSource::CloudRequirements);
|
||||
assert_eq!(
|
||||
engine.handlers[0].source,
|
||||
HookSource::LegacyManagedConfigMdm
|
||||
);
|
||||
let discovered = super::discovery::discover_handlers(
|
||||
Some(&config_layer_stack),
|
||||
Vec::new(),
|
||||
@@ -671,7 +677,7 @@ fn requirements_managed_hooks_load_when_managed_dir_is_missing() {
|
||||
ConfigRequirements {
|
||||
managed_hooks: Some(ConstrainedWithSource::new(
|
||||
Constrained::allow_any(managed_hooks.clone()),
|
||||
Some(RequirementSource::CloudRequirements),
|
||||
Some(RequirementSource::LegacyManagedConfigTomlFromMdm),
|
||||
)),
|
||||
..ConfigRequirements::default()
|
||||
},
|
||||
@@ -1237,7 +1243,12 @@ print(json.dumps({
|
||||
|
||||
assert_eq!(outcome.hook_events.len(), 1);
|
||||
assert_eq!(outcome.hook_events[0].run.source, HookSource::Plugin);
|
||||
assert_eq!(outcome.hook_events[0].run.status, HookRunStatus::Completed);
|
||||
assert_eq!(
|
||||
outcome.hook_events[0].run.status,
|
||||
HookRunStatus::Completed,
|
||||
"hook entries: {:#?}",
|
||||
outcome.hook_events[0].run.entries
|
||||
);
|
||||
assert_eq!(outcome.hook_events[0].run.entries.len(), 1);
|
||||
assert_eq!(
|
||||
outcome.hook_events[0].run.entries[0].kind,
|
||||
|
||||
Reference in New Issue
Block a user