aKode fase 2b-2: rimosso login ChatGPT e tutti i sottosistemi solo-ChatGPT

- Login: resta solo chiave API (+ header, Bedrock). Rimossi OAuth/browser,
  device code, refresh/revoke su auth.openai.com, PAT, agent/workload identity,
  runtime agent instance, backend-client e openapi-models, workspace routing.
- Rimossi: generazione immagini (ext + skill imagegen), history notes, plugin
  remoti (catalogo, sync, share), cyber access program, daybreak, cloud config
  e requirements (config_server ora fail-closed), attestation, frozen cloud
  skills, EMA MCP auth, Codex Apps/connettori, ricerca ospitata, header/zstd/
  routing/cookie del backend Codex, fallback OPENAI_API_KEY del realtime.
- Messaggi d'errore senza link a chatgpt.com.
- Chiavi di config legacy accettate e ignorate; feature rimosse = Stage::Removed.
- Test: cancellati solo quelli del codice rimosso; test di sicurezza
  (sandbox estensioni, permessi, redazione, auth storage, requirements)
  adattati. Restano solo fallimenti d'ambiente (code-mode-host/V8, ~/.agents).
- Istruzioni di sistema invariate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-10 16:20:15 +01:00
parent 82347a58ed
commit 6089fbde91
1573 changed files with 10289 additions and 177679 deletions

View File

@@ -118,7 +118,7 @@ use rmcp::model::ElicitationCapability;
use rmcp::model::FormElicitationCapability;
use rmcp::model::UrlElicitationCapability;
use codex_config::test_support::CloudConfigBundleFixture;
use codex_config::test_support::ManagedConfigFixture;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::path::Path;
@@ -766,7 +766,6 @@ auto_compact_fallback_prompt = " Write notes immediately. "
auto_compact_fallback_buffer_tokens = 8000
"#,
Some(TokenBudgetConfig {
use_history_notes_extension: true,
reminder_threshold_tokens: Some(16_000),
reminder_message_template: "Custom reminder: {n_remaining} tokens.".to_string(),
guidance_message: Some("Preserve important state before compaction.".to_string()),
@@ -2200,18 +2199,6 @@ respect_system_proxy = true
.outbound_proxy_policy(),
codex_http_client::OutboundProxyPolicy::RespectSystemProxy
);
assert_eq!(
config
.plugins_config_input()
.remote_plugin_service_config(/*runtime_auth*/ None),
codex_core_plugins::remote::RemotePluginServiceConfig::new(
config.chatgpt_base_url,
codex_http_client::HttpClientFactory::new(
codex_http_client::OutboundProxyPolicy::RespectSystemProxy,
),
/*product_sku*/ None,
)
);
Ok(())
}
@@ -2369,10 +2356,12 @@ async fn system_proxy_fallback_honors_feature_requirements() -> std::io::Result<
)?;
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(format!(
.loader_overrides(
(ManagedConfigFixture::requirements(format!(
"[features]\nsystem_proxy_fallback = {required}\n"
)),
)))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -2411,13 +2400,15 @@ async fn experimental_network_requirements_enable_proxy_without_feature() -> std
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
r#"
[experimental_network]
enabled = true
"#,
),
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -2506,8 +2497,10 @@ trust_level = "trusted"
cwd: Some(workspace.path().to_path_buf()),
..Default::default()
})
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(requirements),
.loader_overrides(
(ManagedConfigFixture::requirements(requirements))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -2918,11 +2911,13 @@ async fn persisted_permissions_initialize_proxy_with_expandable_managed_allowlis
persisted_permission_profile: Some(PermissionProfile::read_only()),
..Default::default()
})
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
"[experimental_network]\nenabled = true\n[experimental_network.domains]\n'managed.example' = 'allow'\n",
),
)
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
assert_eq!(
@@ -5849,7 +5844,6 @@ async fn rebuild_with_session_layers_refreshes_requirements() -> std::io::Result
),
]);
let requirements_toml = codex_config::ConfigRequirementsToml {
config_server: Some(service_config.clone()),
mcp_servers: Some(mcp_requirements.clone()),
..Default::default()
};
@@ -5896,8 +5890,7 @@ async fn rebuild_with_session_layers_refreshes_requirements() -> std::io::Result
requirements,
requirements_toml,
)
.map_err(std::io::Error::other)?
.with_applied_config_server(Some(service_config));
.map_err(std::io::Error::other)?;
let thread_layer_stack = ConfigLayerStack::new(
vec![
ConfigLayerEntry::new(
@@ -5972,24 +5965,36 @@ async fn rebuild_with_session_layers_refreshes_requirements() -> std::io::Result
codex_home.abs(),
)
.await?;
assert_eq!(
config.config_layer_stack.applied_config_server(),
refreshed_layer_stack.applied_config_server()
);
// User-only refreshes keep this policy; managed refreshes must supply it.
let mut missing_policy = config.clone();
missing_policy.config_layer_stack = missing_policy
// aKode cannot fetch remote configuration: a managed refresh whose
// requirements demand a config server must be rejected, while user-only
// refreshes keep the current managed policy.
let mut demands_config_server = config.clone();
let mut demanding_requirements = demands_config_server
.config_layer_stack
.with_applied_config_server(/*service_config*/ None);
.requirements_toml()
.clone();
demanding_requirements.config_server = Some(service_config);
demands_config_server.config_layer_stack = ConfigLayerStack::new(
demands_config_server
.config_layer_stack
.all_layers_low_to_high()
.cloned()
.collect(),
demands_config_server
.config_layer_stack
.requirements()
.clone(),
demanding_requirements,
)
.map_err(std::io::Error::other)?;
assert!(
config
.resolve_runtime_refresh(&missing_policy, RuntimeConfigRefresh::User)
.resolve_runtime_refresh(&demands_config_server, RuntimeConfigRefresh::User)
.is_ok()
);
assert!(
config
.resolve_runtime_refresh(&missing_policy, RuntimeConfigRefresh::Mcp)
.resolve_runtime_refresh(&demands_config_server, RuntimeConfigRefresh::Mcp)
.is_err()
);
@@ -6230,13 +6235,15 @@ enabled = true
let config = ConfigBuilder::default()
.codex_home(codex_home.path().to_path_buf())
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
r#"
[plugins."sample@test".mcp_servers.sample.identity]
url = "https://sample.example/mcp"
"#,
),
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -6258,9 +6265,12 @@ url = "https://sample.example/mcp"
Some((
false,
Some(McpServerDisabledReason::Requirements {
source: RequirementSource::EnterpriseManaged {
id: "req_1".to_string(),
name: "Base requirements".to_string(),
source: RequirementSource::SystemRequirementsToml {
file: codex_home
.path()
.join("managed-config-fixture")
.join("requirements.toml")
.abs(),
},
})
))
@@ -6335,12 +6345,14 @@ enabled = true
let config = ConfigBuilder::default()
.codex_home(codex_home.path().to_path_buf())
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
r#"
[mcp_servers]
"#,
),
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -6356,9 +6368,12 @@ enabled = true
Some((
false,
Some(McpServerDisabledReason::Requirements {
source: RequirementSource::EnterpriseManaged {
id: "req_1".to_string(),
name: "Base requirements".to_string(),
source: RequirementSource::SystemRequirementsToml {
file: codex_home
.path()
.join("managed-config-fixture")
.join("requirements.toml")
.abs(),
},
})
))
@@ -6490,7 +6505,7 @@ async fn managed_sqlite_home_preserves_configured_log_dir() -> std::io::Result<(
),
] {
std::fs::write(home.path().join(CONFIG_TOML_FILE), user_config)?;
let config = load_with_enterprise_requirement(&home, requirements).await?;
let config = load_with_managed_requirement(&home, requirements).await?;
assert_eq!(
(
config.sqlite.logs_db_path().parent(),
@@ -6768,50 +6783,6 @@ async fn chatgpt_backend_url_defaults_follow_captured_auth() -> std::io::Result<
Ok(())
}
#[tokio::test]
async fn project_cannot_be_the_only_xaa_opt_in_source() -> std::io::Result<()> {
let codex_home = TempDir::new()?;
let config_layer_stack = ConfigLayerStack::new(
vec![ConfigLayerEntry::new(
ConfigLayerSource::Project {
dot_codex_folder: codex_home.path().join("project/.codex").abs(),
},
toml::toml! {
[features]
use_xaa = true
}
.into(),
)],
Default::default(),
Default::default(),
)?;
let cfg = config_layer_stack
.effective_config()
.try_into()
.map_err(|error| std::io::Error::new(std::io::ErrorKind::InvalidInput, error))?;
let error = Config::load_config_with_layer_stack(
LOCAL_FS.as_ref(),
cfg,
ConfigOverrides {
cwd: Some(codex_home.path().to_path_buf()),
..Default::default()
},
codex_home.abs(),
config_layer_stack,
)
.await
.expect_err("project-only XAA opt-in must fail");
assert_eq!(error.kind(), std::io::ErrorKind::InvalidInput);
assert!(
error
.to_string()
.contains("must be selected in a non-project config layer")
);
Ok(())
}
#[tokio::test]
async fn config_resolves_default_oauth_store_mode() -> std::io::Result<()> {
let codex_home = TempDir::new()?;
@@ -7608,34 +7579,6 @@ pane = { selected = "console", expanded = false }
Ok(())
}
#[tokio::test]
async fn to_mcp_config_preserves_apps_feature_from_config() -> std::io::Result<()> {
let codex_home = TempDir::new()?;
let mut config = Config::load_from_base_config_with_overrides(
ConfigToml::default(),
ConfigOverrides::default(),
codex_home.abs(),
)
.await?;
let plugins_manager =
plugins_manager_for_config(&config, auth_manager_from_optional_auth(/*auth*/ None));
config.apps_mcp_product_sku = Some("tpp".to_string());
let mcp_config = config.to_mcp_config(&plugins_manager).await;
assert!(mcp_config.apps_enabled);
assert_eq!(mcp_config.apps_mcp_product_sku.as_deref(), Some("tpp"));
let _ = config.features.disable(Feature::Apps);
let mcp_config = config.to_mcp_config(&plugins_manager).await;
assert!(!mcp_config.apps_enabled);
let _ = config.features.enable(Feature::Apps);
let mcp_config = config.to_mcp_config(&plugins_manager).await;
assert!(mcp_config.apps_enabled);
Ok(())
}
#[tokio::test]
async fn to_mcp_config_flows_mcp_tool_prefix_from_feature() -> std::io::Result<()> {
let codex_home = TempDir::new()?;
@@ -7686,43 +7629,16 @@ async fn to_mcp_config_flows_independent_mcp_2026_features() -> std::io::Result<
plugins_manager_for_config(&config, auth_manager_from_optional_auth(/*auth*/ None));
let mcp_config = config.to_mcp_config(&plugins_manager).await;
assert_eq!(
(
mcp_config.protocol_mode,
mcp_config.host_owned_apps_protocol_mode,
),
(
codex_mcp::McpProtocolMode::Legacy,
codex_mcp::McpProtocolMode::Legacy,
)
);
assert_eq!(mcp_config.protocol_mode, codex_mcp::McpProtocolMode::Legacy);
let _ = config.features.enable(Feature::Mcp20260728);
let mcp_config = config.to_mcp_config(&plugins_manager).await;
assert_eq!(
(
mcp_config.protocol_mode,
mcp_config.host_owned_apps_protocol_mode,
),
(
codex_mcp::McpProtocolMode::V20260728,
codex_mcp::McpProtocolMode::Legacy,
)
);
assert_eq!(mcp_config.protocol_mode, codex_mcp::McpProtocolMode::V20260728);
let _ = config.features.disable(Feature::Mcp20260728);
let _ = config.features.enable(Feature::CodexAppsMcp20260728);
let mcp_config = config.to_mcp_config(&plugins_manager).await;
assert_eq!(
(
mcp_config.protocol_mode,
mcp_config.host_owned_apps_protocol_mode,
),
(
codex_mcp::McpProtocolMode::Legacy,
codex_mcp::McpProtocolMode::V20260728,
)
);
assert_eq!(mcp_config.protocol_mode, codex_mcp::McpProtocolMode::Legacy);
Ok(())
}
@@ -11301,27 +11217,18 @@ apps_mcp_product_sku = "tpp"
}
#[tokio::test]
async fn config_loads_cloud_skills_with_legacy_noop() -> std::io::Result<()> {
async fn config_accepts_removed_cloud_skills_settings() -> std::io::Result<()> {
let codex_home = TempDir::new()?;
for (settings, expected) in [
("", true),
("[cloud.skills]", true),
("[cloud.skills]\nenabled = false", false),
("[cloud.skills]\nenabled = true", true),
("[orchestrator.skills]\nenabled = false", true),
("[orchestrator.skills]\nenabled = true", true),
(
"[orchestrator.skills]\nenabled = false\n[cloud.skills]",
true,
),
(
"[orchestrator.skills]\nenabled = true\n[cloud.skills]\nenabled = false",
false,
),
(
"[orchestrator.skills]\nenabled = false\n[cloud.skills]\nenabled = true",
true,
),
for settings in [
"",
"[cloud.skills]",
"[cloud.skills]\nenabled = false",
"[cloud.skills]\nenabled = true",
"[orchestrator.skills]\nenabled = false",
"[orchestrator.skills]\nenabled = true",
"[orchestrator.skills]\nenabled = false\n[cloud.skills]",
"[orchestrator.skills]\nenabled = true\n[cloud.skills]\nenabled = false",
"[orchestrator.skills]\nenabled = false\n[cloud.skills]\nenabled = true",
] {
let cfg: ConfigToml = toml::from_str(&format!(
"model = \"gpt-5.4\"\n{settings}\n[orchestrator.mcp]\nenabled = false"
@@ -11334,11 +11241,7 @@ async fn config_loads_cloud_skills_with_legacy_noop() -> std::io::Result<()> {
)
.await?;
assert_eq!(
(config.cloud_skill_enabled, config.orchestrator_mcp_enabled),
(expected, false),
"{settings}"
);
assert!(!config.orchestrator_mcp_enabled, "{settings}");
}
Ok(())
}
@@ -11366,10 +11269,7 @@ enabled = false
)
.await?;
assert_eq!(
(config.cloud_skill_enabled, config.orchestrator_mcp_enabled),
(true, false)
);
assert!(!config.orchestrator_mcp_enabled);
Ok(())
}
@@ -11497,10 +11397,12 @@ async fn oversized_managed_developer_instructions_are_rejected_during_config_loa
let error = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(format!(
.loader_overrides(
(ManagedConfigFixture::requirements(format!(
"additional_developer_instructions = {instructions:?}"
)),
)))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await
@@ -11509,9 +11411,14 @@ async fn oversized_managed_developer_instructions_are_rejected_during_config_loa
assert_eq!(error.kind(), std::io::ErrorKind::InvalidInput);
let message = error.to_string();
assert!(
message.starts_with(
"`additional_developer_instructions` from enterprise-managed requirements Base requirements (req_1) exceeds the model-context limit of 10000 estimated tokens"
),
message.starts_with(&format!(
"`additional_developer_instructions` from {} exceeds the model-context limit of 10000 estimated tokens",
codex_home
.path()
.join("managed-config-fixture")
.join("requirements.toml")
.display()
)),
"unexpected config-load error: {message}"
);
Ok(())
@@ -11524,10 +11431,10 @@ async fn requirements_disallowing_default_sandbox_falls_back_to_required_default
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
r#"allowed_sandbox_modes = ["read-only"]"#,
),
.loader_overrides(
(ManagedConfigFixture::requirements(r#"allowed_sandbox_modes = ["read-only"]"#))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -11550,10 +11457,10 @@ async fn explicit_sandbox_mode_falls_back_when_disallowed_by_requirements() -> s
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
r#"allowed_sandbox_modes = ["read-only"]"#,
),
.loader_overrides(
(ManagedConfigFixture::requirements(r#"allowed_sandbox_modes = ["read-only"]"#))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -11599,10 +11506,12 @@ async fn local_mxc_preference_preserves_configured_backend(
let loaded = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(format!(
.loader_overrides(
(ManagedConfigFixture::requirements(format!(
"[windows]\nallow_mxc = {allow_mxc}\nrequire_mxc = {require_mxc}\n"
)),
)))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -11725,12 +11634,14 @@ sandbox = "unelevated"
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
r#"[windows]
allowed_sandbox_implementations = ["elevated"]
"#,
),
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -11762,10 +11673,10 @@ sandbox_mode = "danger-full-access"
let err = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
r#"allowed_sandbox_modes = ["read-only"]"#,
),
.loader_overrides(
(ManagedConfigFixture::requirements(r#"allowed_sandbox_modes = ["read-only"]"#))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await
@@ -11796,10 +11707,10 @@ default_permissions = "dev"
let err = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
r#"allowed_sandbox_modes = ["read-only"]"#,
),
.loader_overrides(
(ManagedConfigFixture::requirements(r#"allowed_sandbox_modes = ["read-only"]"#))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await
@@ -11828,10 +11739,10 @@ async fn permission_profile_override_falls_back_when_disallowed_by_requirements(
permission_profile: Some(PermissionProfile::Disabled),
..Default::default()
})
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
r#"allowed_sandbox_modes = ["read-only"]"#,
),
.loader_overrides(
(ManagedConfigFixture::requirements(r#"allowed_sandbox_modes = ["read-only"]"#))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -11875,10 +11786,10 @@ async fn active_profile_is_cleared_when_requirements_force_fallback() -> std::io
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.harness_overrides(overrides)
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
r#"allowed_sandbox_modes = ["read-only"]"#,
),
.loader_overrides(
(ManagedConfigFixture::requirements(r#"allowed_sandbox_modes = ["read-only"]"#))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -11996,10 +11907,10 @@ async fn requirements_web_search_mode_overrides_danger_full_access_default() ->
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
r#"allowed_web_search_modes = ["cached"]"#,
),
.loader_overrides(
(ManagedConfigFixture::requirements(r#"allowed_web_search_modes = ["cached"]"#))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -12035,10 +11946,10 @@ trust_level = "untrusted"
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(workspace.path().to_path_buf()))
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
r#"allowed_approval_policies = ["on-request"]"#,
),
.loader_overrides(
(ManagedConfigFixture::requirements(r#"allowed_approval_policies = ["on-request"]"#))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -12080,22 +11991,22 @@ async fn feature_requirements_normalize_effective_feature_values() -> std::io::R
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
r#"
[features]
view_image = true
shell_tool = false
use_xaa = true
"#,
),
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
assert!(config.features.enabled(Feature::ViewImage));
assert!(!config.features.enabled(Feature::ShellTool));
assert!(config.features.enabled(Feature::UseXaa));
assert!(
!config
.startup_warnings
@@ -12113,27 +12024,27 @@ async fn feature_requirements_can_still_disable_unified_exec() -> std::io::Resul
let codex_home = TempDir::new()?;
std::fs::write(
codex_home.path().join(CONFIG_TOML_FILE),
"[features]\nuse_xaa = true\n",
"[features]\nunified_exec = true\n",
)?;
let mut config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
r#"
[features]
unified_exec = false
shell_tool = true
use_xaa = false
"#,
),
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
assert!(!config.features.enabled(Feature::UnifiedExec));
assert!(config.features.enabled(Feature::ShellTool));
assert!(!config.features.enabled(Feature::UseXaa));
assert!(
!config
.startup_warnings
@@ -12159,13 +12070,15 @@ async fn feature_requirements_auto_review_disables_guardian_approval() -> std::i
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
r#"
[features]
auto_review = false
"#,
),
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -12181,8 +12094,8 @@ async fn browser_feature_requirements_are_valid() -> std::io::Result<()> {
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
r#"
[features]
in_app_browser = false
@@ -12190,7 +12103,9 @@ browser_annotation_api = false
browser_use = false
browser_use_full_cdp_access = false
"#,
),
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -12209,13 +12124,15 @@ async fn in_app_chat_feature_requirements_are_valid() -> std::io::Result<()> {
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
r#"
[features]
in_app_chat = false
"#,
),
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -12231,13 +12148,15 @@ async fn in_app_dictation_feature_requirements_are_valid() -> std::io::Result<()
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
r#"
[features]
in_app_dictation = false
"#,
),
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -12253,13 +12172,15 @@ async fn in_app_local_automation_feature_requirements_are_valid() -> std::io::Re
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
r#"
[features]
in_app_local_automation = false
"#,
),
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -12284,14 +12205,16 @@ shell_tool = true
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
r#"
[features]
view_image = true
shell_tool = false
"#,
),
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -12333,9 +12256,9 @@ fn retired_feature_requirements_do_not_pin_configured_values(
]),
..Default::default()
},
RequirementSource::EnterpriseManaged {
id: "enterprise-id".to_string(),
name: "enterprise".to_string(),
RequirementSource::MdmManagedPreferences {
domain: "com.openai.codex".to_string(),
key: "requirements_toml_base64".to_string(),
},
);
validate_feature_requirements_for_config_toml(&cfg, Some(&requirement))?;
@@ -12370,7 +12293,7 @@ fn retired_feature_requirements_do_not_pin_configured_values(
assert!(
warnings[0].contains(&format!("Ignoring removed `features` requirement `{key}`"))
);
assert!(warnings[0].contains("enterprise"));
assert!(warnings[0].contains("MDM"));
assert!(warnings[0].contains("availability no longer depends on this feature flag"));
}
}
@@ -12472,10 +12395,12 @@ async fn requirements_disallowing_default_approvals_reviewer_falls_back_to_requi
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
r#"allowed_approvals_reviewers = ["guardian_subagent"]"#,
),
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -12497,10 +12422,12 @@ async fn root_approvals_reviewer_falls_back_when_disallowed_by_requirements() ->
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
r#"allowed_approvals_reviewers = ["guardian_subagent"]"#,
),
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -12531,15 +12458,19 @@ async fn profile_approvals_reviewer_falls_back_when_disallowed_by_requirements()
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.loader_overrides(LoaderOverrides {
user_config_path: Some(selected_config.abs()),
user_config_profile: Some("default".parse().expect("profile-v2 name")),
..LoaderOverrides::without_managed_config_for_tests()
})
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
ManagedConfigFixture::requirements(
r#"allowed_approvals_reviewers = ["guardian_subagent"]"#,
),
)
.loader_overrides(
codex_home.path(),
LoaderOverrides {
user_config_path: Some(selected_config.abs()),
user_config_profile: Some("default".parse().expect("profile-v2 name")),
..LoaderOverrides::without_managed_config_for_tests()
},
)
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -12561,10 +12492,12 @@ async fn approvals_reviewer_preserves_valid_user_choice_when_allowed_by_requirem
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
r#"allowed_approvals_reviewers = ["user", "guardian_subagent"]"#,
),
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -13309,14 +13242,16 @@ async fn feature_requirements_normalize_runtime_feature_mutations() -> std::io::
let mut config = ConfigBuilder::default()
.codex_home(codex_home.path().to_path_buf())
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
r#"
[features]
view_image = true
shell_tool = false
"#,
),
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -13343,13 +13278,15 @@ async fn feature_requirements_warn_on_collab_legacy_alias() -> std::io::Result<(
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
r#"
[features]
collab = true
"#,
),
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -13373,13 +13310,15 @@ async fn feature_requirements_warn_and_ignore_unknown_feature() -> std::io::Resu
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
.loader_overrides(
(ManagedConfigFixture::requirements(
r#"
[features]
made_up_feature = true
"#,
),
))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await?;
@@ -13911,15 +13850,17 @@ fn test_tui_notification_condition_rejects_unknown_value() {
);
}
async fn load_with_enterprise_requirement(
async fn load_with_managed_requirement(
codex_home: &TempDir,
requirements: impl Into<String>,
) -> std::io::Result<Config> {
ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(requirements),
.loader_overrides(
(ManagedConfigFixture::requirements(requirements))
.loader_overrides_for_tests(codex_home.path())
.expect("write managed config fixture"),
)
.build()
.await
@@ -13975,7 +13916,7 @@ enabled = false
required_log_dir.display(),
catalog_path.display(),
);
let config = load_with_enterprise_requirement(&codex_home, requirements).await?;
let config = load_with_managed_requirement(&codex_home, requirements).await?;
assert_eq!(
config.sqlite,
@@ -14073,7 +14014,7 @@ async fn otel_requirements_resolve_config(
) -> std::io::Result<()> {
let codex_home = TempDir::new()?;
std::fs::write(codex_home.path().join(CONFIG_TOML_FILE), user_config)?;
let config = load_with_enterprise_requirement(&codex_home, requirements).await?;
let config = load_with_managed_requirement(&codex_home, requirements).await?;
let expected: ConfigToml =
toml::from_str(expected_config).expect("expected OTEL config should deserialize");
assert_eq!(
@@ -14086,9 +14027,18 @@ async fn otel_requirements_resolve_config(
.iter()
.find(|warning| warning.contains("Configured values under `otel` are overridden"))
.map(String::as_str),
expect_override_warning.then_some(
"Configured values under `otel` are overridden by requirements from enterprise-managed requirements Base requirements (req_1).",
),
expect_override_warning
.then(|| {
format!(
"Configured values under `otel` are overridden by requirements from {}.",
codex_home
.path()
.join("managed-config-fixture")
.join("requirements.toml")
.display()
)
})
.as_deref(),
);
assert!(
config
@@ -14110,7 +14060,7 @@ enabled = false
"#,
)?;
let config = load_with_enterprise_requirement(
let config = load_with_managed_requirement(
&codex_home,
r#"
[otel]
@@ -14126,7 +14076,7 @@ metrics_exporter = { otlp-http = { endpoint = "http://127.0.0.1:1/v1/metrics", p
#[tokio::test]
async fn absent_allow_login_shell_does_not_report_an_override() -> std::io::Result<()> {
let codex_home = TempDir::new()?;
let config = load_with_enterprise_requirement(&codex_home, "allow_login_shell = false").await?;
let config = load_with_managed_requirement(&codex_home, "allow_login_shell = false").await?;
assert!(!config.permissions.allow_login_shell);
assert!(