mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Replace Sites migration state with a runtime compatibility guard (#46108)
## Why Older Desktop clients can still provide bundled Sites to an independently updated SSH app-server. A cached remote Sites install must take precedence, even when disabled, while a missing remote bundle must preserve the bundled fallback. ## What changed - Remove persisted bundled-plugin exclusions, Sites migration checks, and the migration wait when loading local plugin configuration. - Suppress `sites@openai-bundled` during plugin loading when the remote global catalog is active and a cached remote Sites install is available. - Remove exclusion-based catalog filtering and read/install guards, and simplify `install_plugin` to accept `ConfigLayerStack`. ## Testing Expand the agent-turn Sites test to cover enabled remote precedence, disabled remote suppression of bundled Sites, and fallback when the remote bundle is missing. GitOrigin-RevId: e2758596e5493ccee051cdfbf6b4afbe4f98948c
This commit is contained in:
1 parent
77c1feb00e
commit
108e6a6dbe
15 files changed
+41
-727
No files matched your search
@@ -72,7 +72,6 @@ use wiremock::matchers::header;
|
||||
use wiremock::matchers::method;
|
||||
use wiremock::matchers::path;
|
||||
use wiremock::matchers::query_param;
|
||||
use wiremock::matchers::query_param_is_missing;
|
||||
|
||||
const MAX_CAPABILITY_SUMMARY_DESCRIPTION_LEN: usize = 1024;
|
||||
|
||||
@@ -83,17 +82,6 @@ fn unrestricted_config_layer_stack() -> ConfigLayerStack {
|
||||
ConfigLayerStack::default()
|
||||
}
|
||||
|
||||
fn unrestricted_plugins_config_input() -> PluginsConfigInput {
|
||||
PluginsConfigInput::new(
|
||||
unrestricted_config_layer_stack(),
|
||||
String::new(),
|
||||
/*plugins_enabled*/ true,
|
||||
/*remote_plugin_enabled*/ false,
|
||||
String::new(),
|
||||
test_http_client_factory(),
|
||||
)
|
||||
}
|
||||
|
||||
fn config_layer_stack_with_requirements(
|
||||
codex_home: &Path,
|
||||
user_config: &str,
|
||||
@@ -3168,7 +3156,6 @@ fn loaded_plugins_cache_evicts_least_recently_used_configuration() {
|
||||
skill_config_rules: SkillConfigRules::default(),
|
||||
remote_global_catalog_active: false,
|
||||
auth_identity: None,
|
||||
excluded_plugin_ids: BTreeSet::new(),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let generation = manager.loaded_plugins_cache_generation();
|
||||
@@ -3213,7 +3200,6 @@ fn loaded_plugins_cache_invalidation_rejects_stale_load_completion() {
|
||||
skill_config_rules: SkillConfigRules::default(),
|
||||
remote_global_catalog_active: false,
|
||||
auth_identity: None,
|
||||
excluded_plugin_ids: BTreeSet::new(),
|
||||
};
|
||||
let stale_generation = manager.loaded_plugins_cache_generation();
|
||||
|
||||
@@ -3352,7 +3338,7 @@ async fn install_plugin_updates_config_with_relative_path_and_plugin_key() {
|
||||
|
||||
let result = test_plugins_manager(tmp.path().to_path_buf())
|
||||
.install_plugin(
|
||||
&unrestricted_plugins_config_input(),
|
||||
&unrestricted_config_layer_stack(),
|
||||
PluginInstallRequest {
|
||||
plugin_name: "sample-plugin".to_string(),
|
||||
marketplace_path: AbsolutePathBuf::try_from(
|
||||
@@ -3410,7 +3396,7 @@ source = "local"
|
||||
path = {marketplace_root:?}
|
||||
"#
|
||||
);
|
||||
let config = plugins_config_input_with_requirements(codex_home.path(), "", &requirements);
|
||||
let config = config_layer_stack_with_requirements(codex_home.path(), "", &requirements);
|
||||
let marketplace_path =
|
||||
AbsolutePathBuf::try_from(marketplace_root.join(".agents/plugins/marketplace.json"))
|
||||
.expect("absolute marketplace path");
|
||||
@@ -3442,7 +3428,7 @@ source = {marketplace_root:?}
|
||||
);
|
||||
write_file(&codex_home.path().join(CONFIG_TOML_FILE), &user_config);
|
||||
let config =
|
||||
plugins_config_input_with_requirements(codex_home.path(), &user_config, &requirements);
|
||||
config_layer_stack_with_requirements(codex_home.path(), &user_config, &requirements);
|
||||
let outcome = manager
|
||||
.install_plugin(
|
||||
&config,
|
||||
@@ -3468,7 +3454,7 @@ async fn install_openai_curated_plugin_uses_short_sha_cache_version() {
|
||||
|
||||
let result = test_plugins_manager(tmp.path().to_path_buf())
|
||||
.install_plugin(
|
||||
&unrestricted_plugins_config_input(),
|
||||
&unrestricted_config_layer_stack(),
|
||||
PluginInstallRequest {
|
||||
plugin_name: "slack".to_string(),
|
||||
marketplace_path: AbsolutePathBuf::try_from(
|
||||
@@ -3529,7 +3515,7 @@ async fn install_plugin_uses_manifest_version_for_non_curated_plugins() {
|
||||
|
||||
let result = test_plugins_manager(tmp.path().to_path_buf())
|
||||
.install_plugin(
|
||||
&unrestricted_plugins_config_input(),
|
||||
&unrestricted_config_layer_stack(),
|
||||
PluginInstallRequest {
|
||||
plugin_name: "sample-plugin".to_string(),
|
||||
marketplace_path: AbsolutePathBuf::try_from(
|
||||
@@ -3597,7 +3583,7 @@ async fn install_plugin_writes_marketplace_manifest_fallback_when_missing_plugin
|
||||
|
||||
let result = test_plugins_manager(tmp.path().to_path_buf())
|
||||
.install_plugin(
|
||||
&unrestricted_plugins_config_input(),
|
||||
&unrestricted_config_layer_stack(),
|
||||
PluginInstallRequest {
|
||||
plugin_name: "quality-review".to_string(),
|
||||
marketplace_path: AbsolutePathBuf::try_from(
|
||||
@@ -3697,7 +3683,7 @@ async fn install_plugin_supports_git_subdir_marketplace_sources() {
|
||||
|
||||
let result = test_plugins_manager(tmp.path().to_path_buf())
|
||||
.install_plugin(
|
||||
&unrestricted_plugins_config_input(),
|
||||
&unrestricted_config_layer_stack(),
|
||||
PluginInstallRequest {
|
||||
plugin_name: "toolkit".to_string(),
|
||||
marketplace_path: AbsolutePathBuf::try_from(
|
||||
@@ -3751,7 +3737,7 @@ async fn install_plugin_supports_relative_git_subdir_marketplace_sources() {
|
||||
|
||||
let result = test_plugins_manager(tmp.path().to_path_buf())
|
||||
.install_plugin(
|
||||
&unrestricted_plugins_config_input(),
|
||||
&unrestricted_config_layer_stack(),
|
||||
PluginInstallRequest {
|
||||
plugin_name: "toolkit".to_string(),
|
||||
marketplace_path: AbsolutePathBuf::try_from(
|
||||
@@ -7001,7 +6987,6 @@ async fn load_plugins_uses_project_config_files() {
|
||||
Some(Product::Codex),
|
||||
/*remote_global_catalog_active*/ false,
|
||||
test_skill_root_loader().as_ref(),
|
||||
&BTreeSet::new(),
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -7289,255 +7274,6 @@ remote_plugin = true
|
||||
server.verify().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn sites_migration_throttles_absence_without_blocking_normal_sync() {
|
||||
let home = TempDir::new().unwrap();
|
||||
write_file(
|
||||
&home.path().join(CONFIG_TOML_FILE),
|
||||
"[features]\nplugins = true\nremote_plugin = true\n",
|
||||
);
|
||||
let server = MockServer::start().await;
|
||||
let mut config = load_config(home.path(), home.path()).await;
|
||||
config.chatgpt_base_url = format!("{}/backend-api", server.uri());
|
||||
let manager = test_plugins_manager_with_options(
|
||||
home.path().to_path_buf(),
|
||||
Some(Product::Codex),
|
||||
Some(AuthMode::Chatgpt),
|
||||
);
|
||||
let auth = manager.auth_manager.auth_cached().unwrap();
|
||||
let installed_path = "/backend-api/ps/plugins/installed";
|
||||
let failed_check = Mock::given(method("GET"))
|
||||
.and(path(installed_path))
|
||||
.respond_with(ResponseTemplate::new(503))
|
||||
.mount_as_scoped(&server)
|
||||
.await;
|
||||
assert!(
|
||||
manager
|
||||
.ensure_sites_migration_ready(&config, Some(&auth))
|
||||
.await
|
||||
.is_err()
|
||||
);
|
||||
drop(failed_check);
|
||||
Mock::given(method("GET"))
|
||||
.and(path(installed_path))
|
||||
.and(query_param_is_missing("includeDownloadUrls"))
|
||||
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
|
||||
"plugins": [], "pagination": {"next_page_token": null}
|
||||
})))
|
||||
.expect(1)
|
||||
.mount(&server)
|
||||
.await;
|
||||
// An unrelated startup download must not block a successful Sites-absence check.
|
||||
let unrelated_sync = manager
|
||||
.acquire_remote_installed_plugin_sync_guard()
|
||||
.await
|
||||
.unwrap();
|
||||
for _ in 0..2 {
|
||||
assert!(
|
||||
tokio::time::timeout(
|
||||
Duration::from_secs(1),
|
||||
manager.ensure_sites_migration_ready(&config, Some(&auth)),
|
||||
)
|
||||
.await
|
||||
.expect("Sites absence must not wait for unrelated bundle downloads")
|
||||
.unwrap()
|
||||
.is_none()
|
||||
);
|
||||
}
|
||||
drop(unrelated_sync);
|
||||
Mock::given(method("GET"))
|
||||
.and(path(installed_path))
|
||||
.and(query_param("includeDownloadUrls", "true"))
|
||||
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
|
||||
"plugins": [], "pagination": {"next_page_token": null}
|
||||
})))
|
||||
.expect(1)
|
||||
.mount(&server)
|
||||
.await;
|
||||
manager
|
||||
.reconcile_remote_installed_plugins(&config, Some(&auth))
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn sites_migration_persists_only_exclusion_without_repeating_rollout() {
|
||||
let home = TempDir::new().unwrap();
|
||||
let marketplace_root = home.path().join(".tmp/bundled-marketplaces/openai-bundled");
|
||||
write_file(
|
||||
&home.path().join(CONFIG_TOML_FILE),
|
||||
&format!(
|
||||
"[features]\nplugins = true\nremote_plugin = true\n[plugins.\"sites@openai-bundled\"]\nenabled = true\n[marketplaces.openai-bundled]\nsource_type = \"local\"\nsource = {marketplace_root:?}\n"
|
||||
),
|
||||
);
|
||||
write_cached_plugin(home.path(), "openai-bundled", "sites");
|
||||
write_plugin(&marketplace_root, "sites", "sites");
|
||||
write_file(
|
||||
&marketplace_root.join(".agents/plugins/marketplace.json"),
|
||||
r#"{"name":"openai-bundled","plugins":[{"name":"sites","source":{"source":"local","path":"./sites"}}]}"#,
|
||||
);
|
||||
let server = MockServer::start().await;
|
||||
let mut config = load_config(home.path(), home.path()).await;
|
||||
config.chatgpt_base_url = format!("{}/backend-api", server.uri());
|
||||
let auth_manager = test_auth_manager(Some(AuthMode::Chatgpt));
|
||||
let auth = auth_manager.auth_cached().unwrap();
|
||||
Mock::given(method("GET"))
|
||||
.and(path("/backend-api/ps/plugins/installed"))
|
||||
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
|
||||
"plugins": [{
|
||||
"id": "plugins~plugin_connector_1p_689987207de08191979cf68eca2941c6",
|
||||
"name": "sites", "scope": "GLOBAL", "enabled": false,
|
||||
"installation_policy": "AVAILABLE", "authentication_policy": "ON_USE",
|
||||
"release": {"version": "local", "display_name": "Sites", "description": "Sites", "interface": {}}
|
||||
}],
|
||||
"pagination": {"next_page_token": null}
|
||||
})))
|
||||
.mount(&server).await;
|
||||
let manager = test_plugins_manager_with_auth_manager(
|
||||
home.path().to_path_buf(),
|
||||
Some(Product::Codex),
|
||||
auth_manager.clone(),
|
||||
);
|
||||
let has_bundled_sites = |manager: &PluginsManager| {
|
||||
manager
|
||||
.list_marketplaces_for_config(&config, &[], /*include_openai_curated*/ false)
|
||||
.unwrap()
|
||||
.marketplaces
|
||||
.into_iter()
|
||||
.flat_map(|marketplace| marketplace.plugins)
|
||||
.any(|plugin| plugin.id == "sites@openai-bundled")
|
||||
};
|
||||
// An installed remote entry without local files must preserve the bundled runtime fallback.
|
||||
manager
|
||||
.reconcile_remote_installed_plugins(&config, Some(&auth))
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(has_bundled_sites(&manager));
|
||||
assert_eq!(
|
||||
loaded_plugin_names(&manager, &config).await,
|
||||
vec!["sites@openai-bundled"]
|
||||
);
|
||||
write_cached_plugin(home.path(), REMOTE_GLOBAL_MARKETPLACE_NAME, "sites");
|
||||
let read_request = PluginReadRequest {
|
||||
plugin_name: "sites".to_string(),
|
||||
marketplace_path: AbsolutePathBuf::try_from(
|
||||
marketplace_root.join(".agents/plugins/marketplace.json"),
|
||||
)
|
||||
.unwrap(),
|
||||
};
|
||||
let install_request = PluginInstallRequest {
|
||||
plugin_name: read_request.plugin_name.clone(),
|
||||
marketplace_path: read_request.marketplace_path.clone(),
|
||||
};
|
||||
let (first, concurrent) = tokio::join!(
|
||||
manager.ensure_sites_migration_ready(&config, Some(&auth)),
|
||||
manager.ensure_sites_migration_ready(&config, Some(&auth)),
|
||||
);
|
||||
assert!(first.unwrap().is_some() ^ concurrent.unwrap().is_some());
|
||||
assert!(!manager.remote_installed_plugin_configs()["sites@openai-curated-remote"].enabled);
|
||||
assert!(
|
||||
server
|
||||
.received_requests()
|
||||
.await
|
||||
.unwrap()
|
||||
.iter()
|
||||
.all(|request| request.method == "GET")
|
||||
);
|
||||
let config_before_rejected_install = fs::read(home.path().join(CONFIG_TOML_FILE)).unwrap();
|
||||
assert!(matches!(
|
||||
manager.read_plugin_for_config(&config, &read_request).await,
|
||||
Err(MarketplaceError::PluginNotFound { plugin_name, marketplace_name })
|
||||
if plugin_name == "sites" && marketplace_name == "openai-bundled"
|
||||
));
|
||||
assert!(matches!(
|
||||
manager.install_plugin(&config, install_request.clone()).await,
|
||||
Err(PluginInstallError::Marketplace(MarketplaceError::PluginNotFound { plugin_name, marketplace_name }))
|
||||
if plugin_name == "sites" && marketplace_name == "openai-bundled"
|
||||
));
|
||||
assert_eq!(
|
||||
fs::read(home.path().join(CONFIG_TOML_FILE)).unwrap(),
|
||||
config_before_rejected_install
|
||||
);
|
||||
let exclusion_file = std::fs::read_dir(home.path().join("cache/bundled_plugin_exclusions"))
|
||||
.unwrap()
|
||||
.next()
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.path();
|
||||
assert_eq!(
|
||||
serde_json::from_slice::<serde_json::Value>(&std::fs::read(exclusion_file).unwrap())
|
||||
.unwrap(),
|
||||
serde_json::json!({"disabled-bundled-plugin-ids": ["sites@openai-bundled"]})
|
||||
);
|
||||
let requests = server.received_requests().await.unwrap().len();
|
||||
let restarted = test_plugins_manager_with_auth_manager(
|
||||
home.path().to_path_buf(),
|
||||
Some(Product::Codex),
|
||||
auth_manager.clone(),
|
||||
);
|
||||
assert!(
|
||||
restarted
|
||||
.ensure_sites_migration_ready(&config, Some(&auth))
|
||||
.await
|
||||
.unwrap()
|
||||
.is_none()
|
||||
);
|
||||
assert_eq!(server.received_requests().await.unwrap().len(), requests);
|
||||
assert!(!has_bundled_sites(&restarted));
|
||||
assert!(restarted.remote_installed_plugin_configs().is_empty());
|
||||
assert!(
|
||||
!loaded_plugin_names(&restarted, &config)
|
||||
.await
|
||||
.contains(&"sites@openai-bundled".to_string())
|
||||
);
|
||||
|
||||
// A warm runtime/skill cache must not carry this backend's exclusion into another backend.
|
||||
let mut other_backend = config.clone();
|
||||
other_backend.chatgpt_base_url = format!("{}/other-backend", server.uri());
|
||||
assert!(
|
||||
restarted
|
||||
.excluded_bundled_plugin_ids(&other_backend)
|
||||
.is_empty()
|
||||
);
|
||||
assert!(
|
||||
restarted
|
||||
.plugin_skill_snapshots_for_config(&config)
|
||||
.is_some()
|
||||
);
|
||||
assert!(
|
||||
restarted
|
||||
.plugin_skill_snapshots_for_config(&other_backend)
|
||||
.is_none()
|
||||
);
|
||||
assert_eq!(
|
||||
loaded_plugin_names(&restarted, &other_backend).await,
|
||||
vec!["sites@openai-bundled"]
|
||||
);
|
||||
assert!(loaded_plugin_names(&restarted, &config).await.is_empty());
|
||||
|
||||
server.reset().await;
|
||||
Mock::given(method("GET"))
|
||||
.and(path("/backend-api/ps/plugins/installed"))
|
||||
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
|
||||
"plugins": [], "pagination": {"next_page_token": null}
|
||||
})))
|
||||
.mount(&server)
|
||||
.await;
|
||||
restarted
|
||||
.reconcile_remote_installed_plugins(&config, Some(&auth))
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(has_bundled_sites(&restarted));
|
||||
restarted
|
||||
.read_plugin_for_config(&config, &read_request)
|
||||
.await
|
||||
.unwrap();
|
||||
restarted
|
||||
.install_plugin(&config, install_request)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn reconcile_remote_installed_plugins_reports_cached_state_changes() {
|
||||
let codex_home = TempDir::new().unwrap();
|
||||
@@ -7797,7 +7533,6 @@ fn reconciliation_fences_refresh_publication_and_recovers_after_cancellation() {
|
||||
stale_refresh_generation,
|
||||
Vec::new(),
|
||||
/*auth*/ None,
|
||||
"",
|
||||
RemoteInstalledPluginsCachePublication::Refresh,
|
||||
),
|
||||
None
|
||||
@@ -7807,7 +7542,6 @@ fn reconciliation_fences_refresh_publication_and_recovers_after_cancellation() {
|
||||
reconcile_generation,
|
||||
vec![remote_installed_linear_plugin()],
|
||||
/*auth*/ None,
|
||||
"",
|
||||
RemoteInstalledPluginsCachePublication::Reconcile,
|
||||
),
|
||||
Some(true)
|
||||
@@ -7831,7 +7565,6 @@ fn reconciliation_fences_refresh_publication_and_recovers_after_cancellation() {
|
||||
refresh_generation,
|
||||
vec![remote_installed_plugin("beta")],
|
||||
/*auth*/ None,
|
||||
"",
|
||||
RemoteInstalledPluginsCachePublication::Refresh,
|
||||
),
|
||||
Some(true)
|
||||
@@ -7844,7 +7577,6 @@ fn reconciliation_fences_refresh_publication_and_recovers_after_cancellation() {
|
||||
retry_generation,
|
||||
vec![remote_installed_plugin("beta")],
|
||||
/*auth*/ None,
|
||||
"",
|
||||
RemoteInstalledPluginsCachePublication::Reconcile,
|
||||
),
|
||||
Some(true)
|
||||
|
||||
Reference in new issue
Block a user