Simplify managed requirements handling

This commit is contained in:
Abhinav Vedmala
2026-06-12 05:51:47 +00:00
parent d6de75a466
commit f639e012bc
8 changed files with 529 additions and 856 deletions
@@ -38,6 +38,7 @@ use codex_config::ManagedHooksRequirementsToml;
use codex_config::MatcherGroup as CoreMatcherGroup;
use codex_config::ResidencyRequirement as CoreResidencyRequirement;
use codex_config::SandboxModeRequirement as CoreSandboxModeRequirement;
use codex_config::types::AuthCredentialsStoreMode as CoreAuthCredentialsStoreMode;
use codex_core::ThreadManager;
use codex_features::canonical_feature_for_key;
use codex_features::feature_for_key;
@@ -384,9 +385,14 @@ fn map_requirements_toml_to_api(requirements: ConfigRequirementsToml) -> ConfigR
network: requirements.network.map(map_network_requirements_to_api),
allowed_login_methods: requirements.allowed_login_methods,
allowed_chatgpt_workspaces: requirements.allowed_chatgpt_workspaces,
cli_auth_credentials_store: requirements
.cli_auth_credentials_store
.map(map_auth_credentials_store_mode_to_api),
cli_auth_credentials_store: requirements.cli_auth_credentials_store.map(
|mode| match mode {
CoreAuthCredentialsStoreMode::File => ApiAuthCredentialsStoreMode::File,
CoreAuthCredentialsStoreMode::Keyring => ApiAuthCredentialsStoreMode::Keyring,
CoreAuthCredentialsStoreMode::Auto => ApiAuthCredentialsStoreMode::Auto,
CoreAuthCredentialsStoreMode::Ephemeral => ApiAuthCredentialsStoreMode::Ephemeral,
},
),
chatgpt_base_url: requirements.chatgpt_base_url,
sqlite_home: requirements.sqlite_home,
log_dir: requirements.log_dir,
@@ -404,21 +410,6 @@ fn map_requirements_toml_to_api(requirements: ConfigRequirementsToml) -> ConfigR
}
}
fn map_auth_credentials_store_mode_to_api(
mode: codex_config::types::AuthCredentialsStoreMode,
) -> ApiAuthCredentialsStoreMode {
match mode {
codex_config::types::AuthCredentialsStoreMode::File => ApiAuthCredentialsStoreMode::File,
codex_config::types::AuthCredentialsStoreMode::Keyring => {
ApiAuthCredentialsStoreMode::Keyring
}
codex_config::types::AuthCredentialsStoreMode::Auto => ApiAuthCredentialsStoreMode::Auto,
codex_config::types::AuthCredentialsStoreMode::Ephemeral => {
ApiAuthCredentialsStoreMode::Ephemeral
}
}
}
fn map_computer_use_requirements_to_api(
computer_use: codex_config::ComputerUseRequirementsToml,
) -> ComputerUseRequirements {
@@ -707,7 +698,7 @@ mod tests {
}
#[test]
fn requirements_api_preserves_complex_config_values_and_otel_headers() {
fn requirements_api_preserves_otel_headers_and_shell_environment_policy() {
let headers = HashMap::from([("Authorization".to_string(), "Bearer secret".to_string())]);
let shell_set = HashMap::from([("MANAGED".to_string(), "true".to_string())]);
@@ -738,27 +729,11 @@ mod tests {
});
assert_eq!(
mapped.otel,
Some(json!({
"log_user_prompt": false,
"environment": "production",
"exporter": {
"otlp-http": {
"endpoint": "https://otel.example.com/v1/logs",
"headers": {
"Authorization": "Bearer secret"
},
"protocol": "json",
"tls": null
}
},
"trace_exporter": null,
"metrics_exporter": null,
"span_attributes": {
"team": "codex"
},
"tracestate": null
}))
mapped
.otel
.as_ref()
.and_then(|otel| otel.pointer("/exporter/otlp-http/headers")),
Some(&json!({"Authorization": "Bearer secret"}))
);
assert_eq!(
mapped.shell_environment_policy,
+37 -356
View File
@@ -1206,28 +1206,19 @@ impl ConfigRequirementsToml {
&& self.log_dir.is_none()
&& self.model_catalog_json.is_none()
&& self.check_for_update_on_startup.is_none()
&& self.otel.as_ref().is_none_or(|otel| {
otel.log_user_prompt.is_none()
&& otel.environment.is_none()
&& otel.exporter.is_none()
&& otel.trace_exporter.is_none()
&& otel.metrics_exporter.is_none()
&& otel.span_attributes.is_none()
&& otel.tracestate.is_none()
})
&& self
.otel
.as_ref()
.is_none_or(|otel| otel == &OtelConfigToml::default())
&& self.allow_login_shell.is_none()
&& self.shell_environment_policy.as_ref().is_none_or(|policy| {
policy.inherit.is_none()
&& policy.ignore_default_excludes.is_none()
&& policy.exclude.is_none()
&& policy.r#set.is_none()
&& policy.include_only.is_none()
&& policy.experimental_use_profile.is_none()
})
&& self
.shell_environment_policy
.as_ref()
.is_none_or(|policy| policy == &ShellEnvironmentPolicyToml::default())
&& self
.feedback
.as_ref()
.is_none_or(|feedback| feedback.enabled.is_none())
.is_none_or(|feedback| feedback == &FeedbackConfigToml::default())
&& self.allowed_approval_policies.is_none()
&& self.allowed_approvals_reviewers.is_none()
&& self.allowed_sandbox_modes.is_none()
@@ -1722,94 +1713,9 @@ mod tests {
}
fn with_unknown_source(toml: ConfigRequirementsToml) -> ConfigRequirementsWithSources {
let ConfigRequirementsToml {
allowed_login_methods,
allowed_chatgpt_workspaces,
cli_auth_credentials_store,
chatgpt_base_url,
sqlite_home,
log_dir,
model_catalog_json,
check_for_update_on_startup,
otel,
allow_login_shell,
shell_environment_policy,
feedback,
allowed_approval_policies,
allowed_approvals_reviewers,
allowed_sandbox_modes,
allowed_permission_profiles,
default_permissions,
remote_sandbox_config: _,
allowed_web_search_modes,
allow_managed_hooks_only,
allow_appshots,
computer_use,
windows,
feature_requirements,
hooks,
mcp_servers,
plugins,
apps,
rules,
enforce_residency,
network,
permissions,
guardian_policy_config,
} = toml;
ConfigRequirementsWithSources {
allowed_login_methods: allowed_login_methods
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
allowed_chatgpt_workspaces: allowed_chatgpt_workspaces
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
cli_auth_credentials_store: cli_auth_credentials_store
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
chatgpt_base_url: chatgpt_base_url
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
sqlite_home: sqlite_home.map(|value| Sourced::new(value, RequirementSource::Unknown)),
log_dir: log_dir.map(|value| Sourced::new(value, RequirementSource::Unknown)),
model_catalog_json: model_catalog_json
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
check_for_update_on_startup: check_for_update_on_startup
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
otel: otel.map(|value| Sourced::new(value, RequirementSource::Unknown)),
allow_login_shell: allow_login_shell
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
shell_environment_policy: shell_environment_policy
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
feedback: feedback.map(|value| Sourced::new(value, RequirementSource::Unknown)),
allowed_approval_policies: allowed_approval_policies
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
allowed_approvals_reviewers: allowed_approvals_reviewers
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
allowed_sandbox_modes: allowed_sandbox_modes
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
allowed_permission_profiles: allowed_permission_profiles
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
default_permissions: default_permissions
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
allowed_web_search_modes: allowed_web_search_modes
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
allow_managed_hooks_only: allow_managed_hooks_only
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
allow_appshots: allow_appshots
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
computer_use: computer_use.map(|value| Sourced::new(value, RequirementSource::Unknown)),
windows: windows.map(|value| Sourced::new(value, RequirementSource::Unknown)),
feature_requirements: feature_requirements
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
hooks: hooks.map(|value| Sourced::new(value, RequirementSource::Unknown)),
mcp_servers: mcp_servers.map(|value| Sourced::new(value, RequirementSource::Unknown)),
plugins: plugins.map(|value| Sourced::new(value, RequirementSource::Unknown)),
apps: apps.map(|value| Sourced::new(value, RequirementSource::Unknown)),
rules: rules.map(|value| Sourced::new(value, RequirementSource::Unknown)),
enforce_residency: enforce_residency
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
network: network.map(|value| Sourced::new(value, RequirementSource::Unknown)),
permissions: permissions.map(|value| Sourced::new(value, RequirementSource::Unknown)),
guardian_policy_config: guardian_policy_config
.map(|value| Sourced::new(value, RequirementSource::Unknown)),
}
let mut sourced = ConfigRequirementsWithSources::default();
sourced.merge_unset_fields(RequirementSource::Unknown, toml);
sourced
}
#[test]
@@ -1946,109 +1852,6 @@ mod tests {
Ok(())
}
#[test]
fn deserialize_managed_config_replacement_requirements() -> Result<()> {
let sqlite_home = std::env::temp_dir().join("codex-sqlite");
let log_dir = std::env::temp_dir().join("codex-logs");
let model_catalog_json = std::env::temp_dir().join("models.json");
let requirements: ConfigRequirementsToml = from_str(&format!(
r#"
allowed_login_methods = {{ chatgpt = true, api = false }}
allowed_chatgpt_workspaces = {{ workspace_1 = true, workspace_2 = false }}
cli_auth_credentials_store = "keyring"
chatgpt_base_url = "https://chatgpt.example.com"
sqlite_home = {:?}
log_dir = {:?}
model_catalog_json = {:?}
check_for_update_on_startup = false
allow_login_shell = false
[otel]
log_user_prompt = false
environment = "prod"
span_attributes = {{ team = "codex" }}
[shell_environment_policy]
ignore_default_excludes = false
set = {{ MANAGED_ENV = "1" }}
[feedback]
enabled = false
[windows]
sandbox_private_desktop = false
"#,
sqlite_home.display().to_string(),
log_dir.display().to_string(),
model_catalog_json.display().to_string(),
))?;
assert_eq!(
requirements.allowed_login_methods,
Some(BTreeMap::from([
("api".to_string(), false),
("chatgpt".to_string(), true),
]))
);
assert_eq!(
requirements.allowed_chatgpt_workspaces,
Some(BTreeMap::from([
("workspace_1".to_string(), true),
("workspace_2".to_string(), false),
]))
);
assert_eq!(
requirements.cli_auth_credentials_store,
Some(AuthCredentialsStoreMode::Keyring)
);
assert_eq!(
requirements.chatgpt_base_url.as_deref(),
Some("https://chatgpt.example.com")
);
assert_eq!(
requirements.sqlite_home.as_deref(),
Some(sqlite_home.as_path())
);
assert_eq!(requirements.log_dir.as_deref(), Some(log_dir.as_path()));
assert_eq!(
requirements.model_catalog_json.as_deref(),
Some(model_catalog_json.as_path())
);
assert_eq!(requirements.check_for_update_on_startup, Some(false));
assert_eq!(requirements.allow_login_shell, Some(false));
assert_eq!(
requirements
.otel
.as_ref()
.and_then(|otel| otel.span_attributes.as_ref()),
Some(&BTreeMap::from([("team".to_string(), "codex".to_string())]))
);
assert_eq!(
requirements
.shell_environment_policy
.as_ref()
.and_then(|policy| policy.r#set.as_ref())
.and_then(|set| set.get("MANAGED_ENV"))
.map(String::as_str),
Some("1")
);
assert_eq!(
requirements.feedback,
Some(FeedbackConfigToml {
enabled: Some(false),
})
);
assert_eq!(
requirements.windows,
Some(WindowsRequirementsToml {
allowed_sandbox_implementations: None,
sandbox_private_desktop: Some(false),
})
);
assert!(!requirements.is_empty());
Ok(())
}
#[test]
fn normalize_rejects_unknown_login_method() -> Result<()> {
let config: ConfigRequirementsToml = from_str(
@@ -2093,7 +1896,7 @@ mod tests {
}
#[test]
fn merge_unset_fields_copies_every_field_and_sets_sources() {
fn merge_unset_fields_copies_every_field() {
let mut target = ConfigRequirementsWithSources::default();
let source = RequirementSource::LegacyManagedConfigTomlFromMdm;
@@ -2136,36 +1939,35 @@ mod tests {
enabled: Some(false),
};
let enforce_residency = ResidencyRequirement::Us;
let enforce_source = source.clone();
let guardian_policy_config = "Use the company-managed guardian policy.".to_string();
// Intentionally constructed without `..Default::default()` so adding a new field to
// `ConfigRequirementsToml` forces this test to be updated.
let other = ConfigRequirementsToml {
allowed_login_methods: Some(allowed_login_methods.clone()),
allowed_chatgpt_workspaces: Some(allowed_chatgpt_workspaces.clone()),
allowed_login_methods: Some(allowed_login_methods),
allowed_chatgpt_workspaces: Some(allowed_chatgpt_workspaces),
cli_auth_credentials_store: Some(AuthCredentialsStoreMode::Keyring),
chatgpt_base_url: Some("https://chatgpt.example.com".to_string()),
sqlite_home: Some(sqlite_home.clone()),
log_dir: Some(log_dir.clone()),
model_catalog_json: Some(model_catalog_json.clone()),
sqlite_home: Some(sqlite_home),
log_dir: Some(log_dir),
model_catalog_json: Some(model_catalog_json),
check_for_update_on_startup: Some(false),
otel: Some(otel.clone()),
otel: Some(otel),
allow_login_shell: Some(false),
shell_environment_policy: Some(shell_environment_policy.clone()),
feedback: Some(feedback.clone()),
allowed_approval_policies: Some(allowed_approval_policies.clone()),
allowed_approvals_reviewers: Some(allowed_approvals_reviewers.clone()),
allowed_sandbox_modes: Some(allowed_sandbox_modes.clone()),
shell_environment_policy: Some(shell_environment_policy),
feedback: Some(feedback),
allowed_approval_policies: Some(allowed_approval_policies),
allowed_approvals_reviewers: Some(allowed_approvals_reviewers),
allowed_sandbox_modes: Some(allowed_sandbox_modes),
allowed_permission_profiles: Some(BTreeMap::from([("managed".to_string(), true)])),
default_permissions: Some("managed".to_string()),
remote_sandbox_config: None,
allowed_web_search_modes: Some(allowed_web_search_modes.clone()),
allowed_web_search_modes: Some(allowed_web_search_modes),
allow_managed_hooks_only: Some(true),
allow_appshots: Some(false),
computer_use: Some(computer_use.clone()),
computer_use: Some(computer_use),
windows: None,
feature_requirements: Some(feature_requirements.clone()),
feature_requirements: Some(feature_requirements),
hooks: None,
mcp_servers: None,
plugins: None,
@@ -2174,81 +1976,20 @@ mod tests {
enforce_residency: Some(enforce_residency),
network: None,
permissions: None,
guardian_policy_config: Some(guardian_policy_config.clone()),
guardian_policy_config: Some(guardian_policy_config),
};
let expected = other.clone();
target.merge_unset_fields(source.clone(), other);
assert_eq!(
target,
ConfigRequirementsWithSources {
allowed_login_methods: Some(Sourced::new(allowed_login_methods, source.clone(),)),
allowed_chatgpt_workspaces: Some(Sourced::new(
allowed_chatgpt_workspaces,
source.clone(),
)),
cli_auth_credentials_store: Some(Sourced::new(
AuthCredentialsStoreMode::Keyring,
source.clone(),
)),
chatgpt_base_url: Some(Sourced::new(
"https://chatgpt.example.com".to_string(),
source.clone(),
)),
sqlite_home: Some(Sourced::new(sqlite_home, source.clone())),
log_dir: Some(Sourced::new(log_dir, source.clone())),
model_catalog_json: Some(Sourced::new(model_catalog_json, source.clone(),)),
check_for_update_on_startup: Some(Sourced::new(
/*value*/ false,
source.clone(),
)),
otel: Some(Sourced::new(otel, source.clone())),
allow_login_shell: Some(Sourced::new(/*value*/ false, source.clone())),
shell_environment_policy: Some(Sourced::new(
shell_environment_policy,
source.clone(),
)),
feedback: Some(Sourced::new(feedback, source.clone())),
allowed_approval_policies: Some(Sourced::new(
allowed_approval_policies,
source.clone()
)),
allowed_approvals_reviewers: Some(Sourced::new(
allowed_approvals_reviewers,
source.clone(),
)),
allowed_sandbox_modes: Some(Sourced::new(allowed_sandbox_modes, source.clone(),)),
allowed_permission_profiles: Some(Sourced::new(
BTreeMap::from([("managed".to_string(), true)]),
source.clone(),
)),
default_permissions: Some(Sourced::new("managed".to_string(), source.clone(),)),
allowed_web_search_modes: Some(Sourced::new(
allowed_web_search_modes,
enforce_source.clone(),
)),
allow_managed_hooks_only: Some(Sourced::new(
/*value*/ true,
enforce_source.clone(),
)),
allow_appshots: Some(Sourced::new(/*value*/ false, enforce_source.clone(),)),
computer_use: Some(Sourced::new(computer_use, enforce_source.clone())),
windows: None,
feature_requirements: Some(Sourced::new(
feature_requirements,
enforce_source.clone(),
)),
hooks: None,
mcp_servers: None,
plugins: None,
apps: None,
rules: None,
enforce_residency: Some(Sourced::new(enforce_residency, enforce_source)),
network: None,
permissions: None,
guardian_policy_config: Some(Sourced::new(guardian_policy_config, source)),
}
target
.allowed_login_methods
.as_ref()
.map(|required| &required.source),
Some(&source)
);
assert_eq!(target.into_toml(), expected);
}
#[test]
@@ -2269,41 +2010,11 @@ mod tests {
assert_eq!(
empty_target,
ConfigRequirementsWithSources {
allowed_login_methods: None,
allowed_chatgpt_workspaces: None,
cli_auth_credentials_store: None,
chatgpt_base_url: None,
sqlite_home: None,
log_dir: None,
model_catalog_json: None,
check_for_update_on_startup: None,
otel: None,
allow_login_shell: None,
shell_environment_policy: None,
feedback: None,
allowed_approval_policies: Some(Sourced::new(
vec![AskForApproval::OnRequest],
source_location,
)),
allowed_approvals_reviewers: None,
allowed_sandbox_modes: None,
allowed_permission_profiles: None,
default_permissions: None,
allowed_web_search_modes: None,
allow_managed_hooks_only: None,
allow_appshots: None,
computer_use: None,
windows: None,
feature_requirements: None,
hooks: None,
mcp_servers: None,
plugins: None,
apps: None,
rules: None,
enforce_residency: None,
network: None,
permissions: None,
guardian_policy_config: None,
..Default::default()
}
);
Ok(())
@@ -2334,41 +2045,11 @@ mod tests {
assert_eq!(
populated_target,
ConfigRequirementsWithSources {
allowed_login_methods: None,
allowed_chatgpt_workspaces: None,
cli_auth_credentials_store: None,
chatgpt_base_url: None,
sqlite_home: None,
log_dir: None,
model_catalog_json: None,
check_for_update_on_startup: None,
otel: None,
allow_login_shell: None,
shell_environment_policy: None,
feedback: None,
allowed_approval_policies: Some(Sourced::new(
vec![AskForApproval::Never],
existing_source,
)),
allowed_approvals_reviewers: None,
allowed_sandbox_modes: None,
allowed_permission_profiles: None,
default_permissions: None,
allowed_web_search_modes: None,
allow_managed_hooks_only: None,
allow_appshots: None,
computer_use: None,
windows: None,
feature_requirements: None,
hooks: None,
mcp_servers: None,
plugins: None,
apps: None,
rules: None,
enforce_residency: None,
network: None,
permissions: None,
guardian_policy_config: None,
..Default::default()
}
);
Ok(())
@@ -13,7 +13,7 @@ pub(super) fn merge(
incoming: Option<OtelConfigToml>,
source: &RequirementSource,
) {
let Some(incoming) = incoming.filter(|value| !is_empty(value)) else {
let Some(incoming) = incoming.filter(|value| value != &OtelConfigToml::default()) else {
return;
};
let Some(output) = output.as_mut() else {
@@ -77,13 +77,3 @@ fn merge_nested_map(
}
}
}
fn is_empty(value: &OtelConfigToml) -> bool {
value.log_user_prompt.is_none()
&& value.environment.is_none()
&& value.exporter.is_none()
&& value.trace_exporter.is_none()
&& value.metrics_exporter.is_none()
&& value.span_attributes.is_none()
&& value.tracestate.is_none()
}
@@ -292,52 +292,30 @@ approval_mode = "approve"
}
#[test]
fn managed_config_replacement_tables_merge_recursively() {
fn managed_config_table_is_composed_and_sourced() {
let high_source = RequirementSource::EnterpriseManaged {
id: "req_high".to_string(),
name: "High".to_string(),
};
let low_source = RequirementSource::EnterpriseManaged {
id: "req_low".to_string(),
name: "Low".to_string(),
};
let composed = compose_requirements_for_hostname(
vec![
layer(
"req_low",
"Low",
RequirementsLayerEntry::from_toml(
low_source.clone(),
r#"
[allowed_login_methods]
chatgpt = true
api = true
[allowed_chatgpt_workspaces]
workspace_a = true
workspace_b = true
[otel.span_attributes]
region = "us"
team = "low"
[shell_environment_policy.set]
LOW = "1"
SHARED = "low"
[windows]
sandbox_private_desktop = true
"#,
),
layer(
"req_high",
"High",
RequirementsLayerEntry::from_toml(
high_source.clone(),
r#"
[allowed_login_methods]
api = false
[allowed_chatgpt_workspaces]
workspace_b = false
[otel.span_attributes]
team = "high"
[shell_environment_policy.set]
HIGH = "1"
SHARED = "high"
[feedback]
enabled = false
"#,
),
],
@@ -347,48 +325,11 @@ enabled = false
.expect("requirements present");
assert_eq!(
composed.clone().into_toml(),
expected_requirements(
r#"
[allowed_login_methods]
chatgpt = true
api = false
[allowed_chatgpt_workspaces]
workspace_a = true
workspace_b = false
[otel.span_attributes]
region = "us"
team = "high"
[shell_environment_policy.set]
LOW = "1"
HIGH = "1"
SHARED = "high"
[feedback]
enabled = false
[windows]
sandbox_private_desktop = true
"#,
)
);
assert_eq!(
composed.allowed_login_methods.map(|sourced| sourced.source),
Some(RequirementSource::Composite {
sources: vec![
RequirementSource::EnterpriseManaged {
id: "req_high".to_string(),
name: "High".to_string(),
},
RequirementSource::EnterpriseManaged {
id: "req_low".to_string(),
name: "Low".to_string(),
},
],
})
composed.allowed_login_methods,
Some(Sourced::new(
BTreeMap::from([("api".to_string(), false), ("chatgpt".to_string(), true),]),
RequirementSource::composite([high_source, low_source]),
))
);
}
+14
View File
@@ -9322,6 +9322,10 @@ allow_login_shell = true
ignore_default_excludes = true
exclude = ["USER_*"]
[shell_environment_policy.set]
CONFIGURED = "kept"
MANAGED = "old"
[otel]
environment = "user"
@@ -9359,6 +9363,9 @@ api = false
ignore_default_excludes = false
experimental_use_profile = true
[shell_environment_policy.set]
MANAGED = "required"
[otel]
log_user_prompt = false
environment = "managed"
@@ -9390,6 +9397,10 @@ sandbox_private_desktop = false
ignore_default_excludes: Some(false),
exclude: Some(vec!["USER_*".to_string()]),
experimental_use_profile: Some(true),
r#set: Some(HashMap::from([
("CONFIGURED".to_string(), "kept".to_string()),
("MANAGED".to_string(), "required".to_string()),
])),
..Default::default()
}
.into();
@@ -9430,6 +9441,9 @@ sandbox_private_desktop = false
("managed".to_string(), "required".to_string()),
])
);
assert!(config.startup_warnings.iter().any(|warning| {
warning.contains("Configured leaves under `shell_environment_policy` are overridden")
}));
Ok(())
}
+40 -348
View File
@@ -111,9 +111,7 @@ use rmcp::model::FormElicitationCapability;
use rmcp::model::UrlElicitationCapability;
use serde::Deserialize;
use serde::Serialize;
use serde::de::DeserializeOwned;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::HashMap;
use std::collections::HashSet;
use std::io::ErrorKind;
@@ -144,6 +142,7 @@ mod managed_features;
mod network_proxy_spec;
mod otel;
mod permissions;
mod requirements;
mod resolved_permission_profile;
#[cfg(test)]
mod schema;
@@ -1857,179 +1856,6 @@ where
Ok(false)
}
fn apply_exact_requirement<T>(
field_name: &'static str,
configured_value: &mut Option<T>,
requirement: Option<Sourced<T>>,
startup_warnings: &mut Vec<String>,
) where
T: Clone + PartialEq + std::fmt::Debug,
{
let Some(Sourced { value, source }) = requirement else {
return;
};
if configured_value
.as_ref()
.is_some_and(|configured| configured != &value)
{
tracing::warn!(
?source,
?value,
"configured value is overridden by an exact requirement for {field_name}"
);
startup_warnings.push(format!(
"Configured value for `{field_name}` is overridden by the required value {value:?} from {source}."
));
}
*configured_value = Some(value);
}
fn merge_exact_requirement<T>(
field_name: &'static str,
configured_value: T,
requirement: Option<Sourced<T>>,
startup_warnings: &mut Vec<String>,
) -> std::io::Result<T>
where
T: Clone + PartialEq + std::fmt::Debug + Serialize + DeserializeOwned,
{
let Some(Sourced { value, source }) = requirement else {
return Ok(configured_value);
};
let mut configured_toml = TomlValue::try_from(configured_value).map_err(|err| {
std::io::Error::new(
std::io::ErrorKind::InvalidData,
format!("failed to serialize configured `{field_name}` value: {err}"),
)
})?;
let required_toml = TomlValue::try_from(value).map_err(|err| {
std::io::Error::new(
std::io::ErrorKind::InvalidData,
format!("failed to serialize required `{field_name}` value: {err}"),
)
})?;
if toml_values_conflict(&configured_toml, &required_toml) {
tracing::warn!(
?source,
"configured value contains leaves overridden by exact requirements for {field_name}"
);
startup_warnings.push(format!(
"Configured leaves under `{field_name}` are overridden by requirements from {source}."
));
}
codex_config::merge_toml_values(&mut configured_toml, &required_toml);
configured_toml.try_into().map_err(|err| {
std::io::Error::new(
std::io::ErrorKind::InvalidData,
format!("failed to deserialize required `{field_name}` value: {err}"),
)
})
}
fn toml_values_conflict(configured: &TomlValue, required: &TomlValue) -> bool {
match (configured, required) {
(TomlValue::Table(configured), TomlValue::Table(required)) => {
required.iter().any(|(key, required)| {
configured
.get(key)
.is_some_and(|configured| toml_values_conflict(configured, required))
})
}
_ => configured != required,
}
}
fn validate_otel_requirement(
requirement: &codex_config::types::OtelConfigToml,
) -> std::io::Result<()> {
if let Some(span_attributes) = requirement.span_attributes.as_ref() {
codex_otel::validate_span_attributes(span_attributes).map_err(|err| {
std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!("invalid required `otel.span_attributes`: {err}"),
)
})?;
}
if let Some(tracestate) = requirement.tracestate.as_ref() {
codex_otel::validate_tracestate_entries(tracestate).map_err(|err| {
std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!("invalid required `otel.tracestate`: {err}"),
)
})?;
}
Ok(())
}
fn apply_otel_requirement(
configured: &mut Option<codex_config::types::OtelConfigToml>,
requirement: Sourced<codex_config::types::OtelConfigToml>,
startup_warnings: &mut Vec<String>,
) {
let Sourced {
value: required,
source,
} = requirement;
let configured = configured.get_or_insert_default();
let mut conflict = false;
macro_rules! replace_leaf {
($field:ident) => {
if let Some(required) = required.$field {
conflict |= configured
.$field
.as_ref()
.is_some_and(|configured| configured != &required);
configured.$field = Some(required);
}
};
}
replace_leaf!(log_user_prompt);
replace_leaf!(environment);
replace_leaf!(exporter);
replace_leaf!(trace_exporter);
replace_leaf!(metrics_exporter);
if let Some(required) = required.span_attributes {
let configured = configured.span_attributes.get_or_insert_default();
conflict |= required
.iter()
.any(|(key, value)| configured.get(key).is_some_and(|current| current != value));
configured.extend(required);
}
if let Some(required) = required.tracestate {
let configured_tracestate = configured.tracestate.take().unwrap_or_default();
conflict |= required.iter().any(|(member, required_fields)| {
configured_tracestate
.get(member)
.is_some_and(|configured_fields| {
required_fields.iter().any(|(key, value)| {
configured_fields
.get(key)
.is_some_and(|current| current != value)
})
})
});
configured.tracestate = Some(otel::merge_required_tracestate(
configured_tracestate,
required,
&source,
startup_warnings,
));
}
if conflict {
tracing::warn!(
?source,
"configured OTEL leaves are overridden by exact requirements"
);
startup_warnings.push(format!(
"Configured leaves under `otel` are overridden by requirements from {source}."
));
}
}
fn mcp_server_matches_requirement(
requirement: &McpServerRequirement,
server: &McpServerConfig,
@@ -2794,27 +2620,39 @@ impl Config {
validate_model_providers(&cfg.model_providers)
.map_err(|message| std::io::Error::new(std::io::ErrorKind::InvalidInput, message))?;
// Ensure that every field of ConfigRequirements is applied to the final
// Config.
let mut startup_warnings = config_layer_stack
.startup_warnings()
.unwrap_or_default()
.to_vec();
let applied_config_requirements = requirements::apply_to_config(
&mut cfg,
config_layer_stack.requirements(),
&mut startup_warnings,
)?;
let configured_auth_restrictions =
requirements::ConfiguredAuthRestrictions::from_config(&cfg);
// Destructure every field to ensure ConfigRequirements additions are
// either applied above or handled while constructing the final Config.
let ConfigRequirements {
approval_policy: mut constrained_approval_policy,
approvals_reviewer: mut constrained_approvals_reviewer,
permission_profile: mut constrained_permission_profile,
windows_sandbox_mode: mut constrained_windows_sandbox_mode,
web_search_mode: mut constrained_web_search_mode,
allowed_login_methods,
allowed_chatgpt_workspaces,
cli_auth_credentials_store: required_cli_auth_credentials_store,
chatgpt_base_url: required_chatgpt_base_url,
sqlite_home: required_sqlite_home,
log_dir: required_log_dir,
model_catalog_json: required_model_catalog_json,
check_for_update_on_startup: required_check_for_update_on_startup,
otel: required_otel,
allow_login_shell: required_allow_login_shell,
shell_environment_policy: required_shell_environment_policy,
feedback: required_feedback,
windows_sandbox_private_desktop: required_windows_sandbox_private_desktop,
allowed_login_methods: _,
allowed_chatgpt_workspaces: _,
cli_auth_credentials_store: _,
chatgpt_base_url: _,
sqlite_home: _,
log_dir: _,
model_catalog_json: _,
check_for_update_on_startup: _,
otel: _,
allow_login_shell: _,
shell_environment_policy: _,
feedback: _,
windows_sandbox_private_desktop: _,
allow_managed_hooks_only: _,
allow_appshots: _,
computer_use: _,
@@ -2829,82 +2667,6 @@ impl Config {
guardian_policy_config_source: _,
} = config_layer_stack.requirements().clone();
let mut startup_warnings = config_layer_stack
.startup_warnings()
.unwrap_or_default()
.to_vec();
let cli_auth_credentials_store_is_required =
required_cli_auth_credentials_store.is_some();
apply_exact_requirement(
"cli_auth_credentials_store",
&mut cfg.cli_auth_credentials_store,
required_cli_auth_credentials_store,
&mut startup_warnings,
);
apply_exact_requirement(
"chatgpt_base_url",
&mut cfg.chatgpt_base_url,
required_chatgpt_base_url,
&mut startup_warnings,
);
apply_exact_requirement(
"sqlite_home",
&mut cfg.sqlite_home,
required_sqlite_home,
&mut startup_warnings,
);
apply_exact_requirement(
"log_dir",
&mut cfg.log_dir,
required_log_dir,
&mut startup_warnings,
);
apply_exact_requirement(
"model_catalog_json",
&mut cfg.model_catalog_json,
required_model_catalog_json,
&mut startup_warnings,
);
apply_exact_requirement(
"check_for_update_on_startup",
&mut cfg.check_for_update_on_startup,
required_check_for_update_on_startup,
&mut startup_warnings,
);
apply_exact_requirement(
"allow_login_shell",
&mut cfg.allow_login_shell,
required_allow_login_shell,
&mut startup_warnings,
);
cfg.shell_environment_policy = merge_exact_requirement(
"shell_environment_policy",
cfg.shell_environment_policy,
required_shell_environment_policy,
&mut startup_warnings,
)?;
if let Some(required_otel) = required_otel {
validate_otel_requirement(&required_otel.value)?;
apply_otel_requirement(&mut cfg.otel, required_otel, &mut startup_warnings);
}
if let Some(required_feedback) = required_feedback {
cfg.feedback = Some(merge_exact_requirement(
"feedback",
cfg.feedback.take().unwrap_or_default(),
Some(required_feedback),
&mut startup_warnings,
)?);
}
if let Some(required) = required_windows_sandbox_private_desktop {
let windows = cfg.windows.get_or_insert_default();
apply_exact_requirement(
"windows.sandbox_private_desktop",
&mut windows.sandbox_private_desktop,
Some(required),
&mut startup_warnings,
);
}
// Destructure ConfigOverrides fully to ensure all overrides are applied.
let ConfigOverrides {
model,
@@ -3480,80 +3242,16 @@ impl Config {
let use_experimental_unified_exec_tool = features.enabled(Feature::UnifiedExec);
let forced_chatgpt_workspace_id = cfg
.forced_chatgpt_workspace_id
.clone()
.map(codex_config::config_toml::ForcedChatgptWorkspaceIds::into_vec)
.map(|values| {
values
.into_iter()
.map(|value| value.trim().to_string())
.filter(|value| !value.is_empty())
.collect::<Vec<_>>()
})
.filter(|values| !values.is_empty());
let forced_chatgpt_workspace_id = match allowed_chatgpt_workspaces {
Some(requirement) => {
let allowed = requirement
.value
.into_iter()
.filter_map(|(workspace, allowed)| allowed.then_some(workspace))
.collect::<BTreeSet<_>>();
Some(match forced_chatgpt_workspace_id {
Some(configured) => configured
.into_iter()
.filter(|workspace| allowed.contains(workspace))
.collect(),
None => allowed.into_iter().collect(),
})
}
None => forced_chatgpt_workspace_id,
};
let forced_login_method = match allowed_login_methods {
Some(requirement) => {
let chatgpt_allowed = requirement
.value
.get("chatgpt")
.copied()
.unwrap_or(false);
let api_allowed = requirement
.value
.get("api")
.copied()
.unwrap_or(false);
match cfg.forced_login_method {
Some(ForcedLoginMethod::Chatgpt) if chatgpt_allowed => {
Some(ForcedLoginMethod::Chatgpt)
}
Some(ForcedLoginMethod::Api) if api_allowed => Some(ForcedLoginMethod::Api),
Some(configured) => {
return Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!(
"configured `forced_login_method = \"{configured}\"` conflicts with `allowed_login_methods` from {}",
requirement.source
),
));
}
None => match (chatgpt_allowed, api_allowed) {
(true, true) => None,
(true, false) => Some(ForcedLoginMethod::Chatgpt),
(false, true) => Some(ForcedLoginMethod::Api),
(false, false) => {
return Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!(
"`allowed_login_methods` from {} does not allow any login method",
requirement.source
),
));
}
},
}
}
None => cfg.forced_login_method,
};
let requirements::ResolvedAuthRestrictions {
forced_login_method,
forced_chatgpt_workspace_id,
} = requirements::resolve_auth_restrictions(
configured_auth_restrictions,
config_layer_stack.requirements(),
)?;
let requirements::AppliedConfigRequirements {
auth_credentials_store,
} = applied_config_requirements;
let model = model.or(cfg.model);
let notices = cfg.notice.unwrap_or_default();
@@ -3813,14 +3511,8 @@ impl Config {
include_environment_context,
// The config.toml omits "_mode" because it's a config file. However, "_mode"
// is important in code to differentiate the mode from the store implementation.
cli_auth_credentials_store_mode: {
let configured = cfg.cli_auth_credentials_store.unwrap_or_default();
if cli_auth_credentials_store_is_required {
configured
} else {
resolve_cli_auth_credentials_store_mode(configured, env!("CARGO_PKG_VERSION"))
}
},
cli_auth_credentials_store_mode: auth_credentials_store
.resolve(cfg.cli_auth_credentials_store.unwrap_or_default()),
mcp_servers,
// The config.toml omits "_mode" because it's a config file. However, "_mode"
// is important in code to differentiate the mode from the store implementation.
+402
View File
@@ -0,0 +1,402 @@
use codex_config::ConfigRequirements;
use codex_config::RequirementSource;
use codex_config::Sourced;
use codex_config::config_toml::ConfigToml;
use codex_config::types::AuthCredentialsStoreMode;
use codex_config::types::FeedbackConfigToml;
use codex_config::types::OtelConfigToml;
use codex_config::types::ShellEnvironmentPolicyToml;
use codex_protocol::config_types::ForcedLoginMethod;
use super::otel;
pub(super) struct AppliedConfigRequirements {
pub auth_credentials_store: AuthCredentialsStoreRequirement,
}
pub(super) enum AuthCredentialsStoreRequirement {
Exact,
UserConfigured,
}
impl AuthCredentialsStoreRequirement {
pub fn resolve(self, configured: AuthCredentialsStoreMode) -> AuthCredentialsStoreMode {
match self {
Self::Exact => configured,
Self::UserConfigured => super::resolve_cli_auth_credentials_store_mode(
configured,
env!("CARGO_PKG_VERSION"),
),
}
}
}
pub(super) struct ResolvedAuthRestrictions {
pub forced_login_method: Option<ForcedLoginMethod>,
pub forced_chatgpt_workspace_id: Option<Vec<String>>,
}
pub(super) struct ConfiguredAuthRestrictions {
forced_login_method: Option<ForcedLoginMethod>,
forced_chatgpt_workspace_id: Option<Vec<String>>,
}
impl ConfiguredAuthRestrictions {
pub fn from_config(config: &ConfigToml) -> Self {
let forced_chatgpt_workspace_id = config
.forced_chatgpt_workspace_id
.clone()
.map(codex_config::config_toml::ForcedChatgptWorkspaceIds::into_vec)
.map(|values| {
values
.into_iter()
.map(|value| value.trim().to_string())
.filter(|value| !value.is_empty())
.collect::<Vec<_>>()
})
.filter(|values| !values.is_empty());
Self {
forced_login_method: config.forced_login_method,
forced_chatgpt_workspace_id,
}
}
}
pub(super) fn apply_to_config(
config: &mut ConfigToml,
requirements: &ConfigRequirements,
startup_warnings: &mut Vec<String>,
) -> std::io::Result<AppliedConfigRequirements> {
macro_rules! apply_exact {
($field:ident) => {
apply_exact_requirement(
stringify!($field),
&mut config.$field,
requirements.$field.as_ref(),
startup_warnings,
);
};
}
apply_exact!(cli_auth_credentials_store);
apply_exact!(chatgpt_base_url);
apply_exact!(sqlite_home);
apply_exact!(log_dir);
apply_exact!(model_catalog_json);
apply_exact!(check_for_update_on_startup);
apply_exact!(allow_login_shell);
apply_shell_environment_policy_requirement(
&mut config.shell_environment_policy,
requirements.shell_environment_policy.as_ref(),
startup_warnings,
);
if let Some(requirement) = requirements.otel.as_ref() {
validate_otel_requirement(&requirement.value)?;
apply_otel_requirement(&mut config.otel, requirement, startup_warnings);
}
apply_feedback_requirement(
&mut config.feedback,
requirements.feedback.as_ref(),
startup_warnings,
);
if let Some(requirement) = requirements.windows_sandbox_private_desktop.as_ref() {
apply_exact_requirement(
"windows.sandbox_private_desktop",
&mut config
.windows
.get_or_insert_default()
.sandbox_private_desktop,
Some(requirement),
startup_warnings,
);
}
Ok(AppliedConfigRequirements {
auth_credentials_store: if requirements.cli_auth_credentials_store.is_some() {
AuthCredentialsStoreRequirement::Exact
} else {
AuthCredentialsStoreRequirement::UserConfigured
},
})
}
fn apply_exact_requirement<T>(
field_name: &'static str,
configured_value: &mut Option<T>,
requirement: Option<&Sourced<T>>,
startup_warnings: &mut Vec<String>,
) where
T: Clone + PartialEq + std::fmt::Debug,
{
let Some(Sourced { value, source }) = requirement else {
return;
};
if configured_value
.as_ref()
.is_some_and(|configured| configured != value)
{
tracing::warn!(
?source,
?value,
"configured value is overridden by an exact requirement for {field_name}"
);
startup_warnings.push(format!(
"Configured value for `{field_name}` is overridden by the required value {value:?} from {source}."
));
}
*configured_value = Some(value.clone());
}
fn apply_shell_environment_policy_requirement(
configured: &mut ShellEnvironmentPolicyToml,
requirement: Option<&Sourced<ShellEnvironmentPolicyToml>>,
startup_warnings: &mut Vec<String>,
) {
let Some(Sourced { value, source }) = requirement else {
return;
};
let ShellEnvironmentPolicyToml {
inherit,
ignore_default_excludes,
exclude,
r#set: required_set,
include_only,
experimental_use_profile,
} = value;
let mut conflict = false;
macro_rules! replace_leaf {
($field:ident) => {
if let Some(required) = $field.as_ref() {
conflict |= configured
.$field
.as_ref()
.is_some_and(|configured| configured != required);
configured.$field = Some(required.clone());
}
};
}
replace_leaf!(inherit);
replace_leaf!(ignore_default_excludes);
replace_leaf!(exclude);
replace_leaf!(include_only);
replace_leaf!(experimental_use_profile);
if let Some(required) = required_set.as_ref() {
let configured_set = configured.r#set.get_or_insert_default();
conflict |= required.iter().any(|(key, value)| {
configured_set
.get(key)
.is_some_and(|current| current != value)
});
configured_set.extend(required.clone());
}
push_leaf_override_warning(
"shell_environment_policy",
conflict,
source,
startup_warnings,
);
}
fn apply_feedback_requirement(
configured: &mut Option<FeedbackConfigToml>,
requirement: Option<&Sourced<FeedbackConfigToml>>,
startup_warnings: &mut Vec<String>,
) {
let Some(Sourced { value, source }) = requirement else {
return;
};
let FeedbackConfigToml { enabled } = value;
let configured = configured.get_or_insert_default();
let conflict = if let Some(required) = *enabled {
let conflict = configured
.enabled
.is_some_and(|configured| configured != required);
configured.enabled = Some(required);
conflict
} else {
false
};
push_leaf_override_warning("feedback", conflict, source, startup_warnings);
}
fn validate_otel_requirement(requirement: &OtelConfigToml) -> std::io::Result<()> {
if let Some(span_attributes) = requirement.span_attributes.as_ref() {
codex_otel::validate_span_attributes(span_attributes).map_err(|err| {
std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!("invalid required `otel.span_attributes`: {err}"),
)
})?;
}
if let Some(tracestate) = requirement.tracestate.as_ref() {
codex_otel::validate_tracestate_entries(tracestate).map_err(|err| {
std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!("invalid required `otel.tracestate`: {err}"),
)
})?;
}
Ok(())
}
fn apply_otel_requirement(
configured: &mut Option<OtelConfigToml>,
requirement: &Sourced<OtelConfigToml>,
startup_warnings: &mut Vec<String>,
) {
let Sourced {
value: required,
source,
} = requirement;
let OtelConfigToml {
log_user_prompt,
environment,
exporter,
trace_exporter,
metrics_exporter,
span_attributes,
tracestate,
} = required;
let configured = configured.get_or_insert_default();
let mut conflict = false;
macro_rules! replace_leaf {
($field:ident) => {
if let Some(required) = $field.as_ref() {
conflict |= configured
.$field
.as_ref()
.is_some_and(|configured| configured != required);
configured.$field = Some(required.clone());
}
};
}
replace_leaf!(log_user_prompt);
replace_leaf!(environment);
replace_leaf!(exporter);
replace_leaf!(trace_exporter);
replace_leaf!(metrics_exporter);
if let Some(required) = span_attributes.as_ref() {
let configured = configured.span_attributes.get_or_insert_default();
conflict |= required
.iter()
.any(|(key, value)| configured.get(key).is_some_and(|current| current != value));
configured.extend(required.clone());
}
if let Some(required) = tracestate.as_ref() {
let configured_tracestate = configured.tracestate.take().unwrap_or_default();
conflict |= required.iter().any(|(member, required_fields)| {
configured_tracestate
.get(member)
.is_some_and(|configured_fields| {
required_fields.iter().any(|(key, value)| {
configured_fields
.get(key)
.is_some_and(|current| current != value)
})
})
});
configured.tracestate = Some(otel::merge_required_tracestate(
configured_tracestate,
required.clone(),
source,
startup_warnings,
));
}
if conflict {
tracing::warn!(
?source,
"configured OTEL leaves are overridden by exact requirements"
);
startup_warnings.push(format!(
"Configured leaves under `otel` are overridden by requirements from {source}."
));
}
}
fn push_leaf_override_warning(
field_name: &str,
conflict: bool,
source: &RequirementSource,
startup_warnings: &mut Vec<String>,
) {
if !conflict {
return;
}
tracing::warn!(
?source,
"configured value contains leaves overridden by exact requirements for {field_name}"
);
startup_warnings.push(format!(
"Configured leaves under `{field_name}` are overridden by requirements from {source}."
));
}
pub(super) fn resolve_auth_restrictions(
configured: ConfiguredAuthRestrictions,
requirements: &ConfigRequirements,
) -> std::io::Result<ResolvedAuthRestrictions> {
let forced_chatgpt_workspace_id = match requirements.allowed_chatgpt_workspaces.as_ref() {
Some(requirement) => Some(match configured.forced_chatgpt_workspace_id {
Some(configured) => configured
.into_iter()
.filter(|workspace| requirement.value.get(workspace).copied().unwrap_or(false))
.collect(),
None => requirement
.value
.iter()
.filter_map(|(workspace, allowed)| allowed.then_some(workspace.clone()))
.collect(),
}),
None => configured.forced_chatgpt_workspace_id,
};
let forced_login_method = match requirements.allowed_login_methods.as_ref() {
Some(requirement) => {
let chatgpt_allowed = requirement.value.get("chatgpt").copied().unwrap_or(false);
let api_allowed = requirement.value.get("api").copied().unwrap_or(false);
match configured.forced_login_method {
Some(ForcedLoginMethod::Chatgpt) if chatgpt_allowed => {
Some(ForcedLoginMethod::Chatgpt)
}
Some(ForcedLoginMethod::Api) if api_allowed => Some(ForcedLoginMethod::Api),
Some(configured) => {
return Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!(
"configured `forced_login_method = \"{configured}\"` conflicts with `allowed_login_methods` from {}",
requirement.source
),
));
}
None => match (chatgpt_allowed, api_allowed) {
(true, true) => None,
(true, false) => Some(ForcedLoginMethod::Chatgpt),
(false, true) => Some(ForcedLoginMethod::Api),
(false, false) => {
return Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!(
"`allowed_login_methods` from {} does not allow any login method",
requirement.source
),
));
}
},
}
}
None => configured.forced_login_method,
};
Ok(ResolvedAuthRestrictions {
forced_login_method,
forced_chatgpt_workspace_id,
})
}
+2 -24
View File
@@ -744,18 +744,6 @@ mod tests {
};
let requirements_toml = ConfigRequirementsToml {
allowed_login_methods: None,
allowed_chatgpt_workspaces: None,
cli_auth_credentials_store: None,
chatgpt_base_url: None,
sqlite_home: None,
log_dir: None,
model_catalog_json: None,
check_for_update_on_startup: None,
otel: None,
allow_login_shell: None,
shell_environment_policy: None,
feedback: None,
allowed_approval_policies: Some(vec![AskForApproval::OnRequest.to_core()]),
allowed_approvals_reviewers: Some(vec![ApprovalsReviewer::AutoReview]),
allowed_sandbox_modes: Some(vec![SandboxModeRequirement::ReadOnly]),
@@ -786,6 +774,7 @@ mod tests {
enforce_residency: Some(ResidencyRequirement::Us),
network: None,
permissions: None,
..ConfigRequirementsToml::default()
};
let user_file = if cfg!(windows) {
@@ -1115,18 +1104,6 @@ approval_policy = "never"
};
let requirements_toml = ConfigRequirementsToml {
allowed_login_methods: None,
allowed_chatgpt_workspaces: None,
cli_auth_credentials_store: None,
chatgpt_base_url: None,
sqlite_home: None,
log_dir: None,
model_catalog_json: None,
check_for_update_on_startup: None,
otel: None,
allow_login_shell: None,
shell_environment_policy: None,
feedback: None,
allowed_approval_policies: None,
allowed_approvals_reviewers: None,
allowed_sandbox_modes: None,
@@ -1148,6 +1125,7 @@ approval_policy = "never"
enforce_residency: None,
network: None,
permissions: None,
..ConfigRequirementsToml::default()
};
let stack = ConfigLayerStack::new(Vec::new(), requirements, requirements_toml)