mirror of
https://github.com/openai/codex.git
synced 2026-11-19 22:30:42 +00:00
Enforce refreshed Guardian policy on running threads (#62585)
## Why A Guardian policy refresh could leave a thread using its previous restrictions if the new policy disallowed its current model. A refresh could also report success after its managed policy source changed before publication. ## What changed - Use the app server's configuration manager to load Guardian policy from current local and managed configuration. Report an error when the policy source changes before publication or a live thread rejects the update. - Apply updated reviewer and model restrictions even when they block the current model. Keep automatic work queued while the model is blocked and wake it when a later refresh permits it. Allow a new turn to supply a compliant replacement model. ## Testing Regression tests cover policy changes during thread startup and live refresh, queued work resuming after a blocking policy is lifted, and updated policy text reaching Guardian reviews without reconnecting MCP. GitOrigin-RevId: c7d3e119aa409342cc2fa18946ce2b6a4392e0e3
This commit is contained in:
@@ -8,6 +8,7 @@ use codex_config::ThreadConfigLoader;
|
||||
use codex_config::apply_default_gcp_auth;
|
||||
use codex_config::loader::load_config_layers_state;
|
||||
use codex_config::loader::load_managed_requirements_state;
|
||||
use codex_core::GuardianPolicyLoader;
|
||||
use codex_core::config::Config;
|
||||
use codex_core::config::ConfigBuilder;
|
||||
use codex_core::config::ConfigOverrides;
|
||||
@@ -24,6 +25,7 @@ use codex_model_provider_info::built_in_model_providers;
|
||||
use codex_model_provider_info::merge_configured_model_providers;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use codex_utils_json_to_toml::json_to_toml;
|
||||
use futures::future::BoxFuture;
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::BTreeSet;
|
||||
use std::collections::HashMap;
|
||||
@@ -808,6 +810,27 @@ impl ConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
impl GuardianPolicyLoader for ConfigManager {
|
||||
fn load_guardian_policy_snapshot(
|
||||
&self,
|
||||
revision: u64,
|
||||
) -> BoxFuture<'_, std::io::Result<codex_config::GuardianPolicySnapshot>> {
|
||||
Box::pin(async move {
|
||||
let policy_load = self.refresh_application_network_policy().await?;
|
||||
let snapshot = codex_config::loader::load_guardian_policy_snapshot(
|
||||
LOCAL_FS.as_ref(),
|
||||
&self.codex_home,
|
||||
&self.loader_overrides,
|
||||
&policy_load.cloud_config,
|
||||
revision,
|
||||
)
|
||||
.await?;
|
||||
self.check_application_policy_load(&policy_load)?;
|
||||
Ok(snapshot)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "application_network_tests.rs"]
|
||||
mod application_network_tests;
|
||||
|
||||
@@ -421,7 +421,8 @@ impl MessageProcessor {
|
||||
thread_state_manager.clone(),
|
||||
)),
|
||||
None,
|
||||
);
|
||||
)
|
||||
.with_guardian_policy_loader(Arc::new(config_manager.clone()));
|
||||
match code_mode_session_provider {
|
||||
Some(provider) => manager.with_code_mode_session_provider(provider),
|
||||
None => manager,
|
||||
|
||||
Reference in New Issue
Block a user