mirror of
https://github.com/openai/codex.git
synced 2026-11-16 22:00:36 +00:00
Reduce remote plugin catalog cache probing overhead (#57258)
## Why Cache presence and freshness checks deserialize full plugin records even when callers only need to decide whether a cached catalog is available. ## What changed - Probe cache availability without deserializing plugin records, while still requiring a valid catalog envelope and a `plugins` array. - Let `PreferFreshCache` reject stale catalogs from a 256-byte prefix when the header provides enough information; fall back to a full read otherwise. - Limit discovery cache probes to the user and workspace scopes that need them, skipping the global cache probe. - Serialize cached plugin slices directly without cloning them. ## Testing Add coverage for malformed cache headers and payloads, reordered fields, stale-prefix rejection, and deferring plugin-record validation until a full catalog load. GitOrigin-RevId: 1e5ec95917f38c84bba30dbd3bb8c2f91cc7e3a8
This commit is contained in:
@@ -468,7 +468,8 @@ fn catalog_cache_invalidation_clears_global_collections_and_preserves_other_scop
|
||||
/*product_sku*/ None,
|
||||
);
|
||||
let auth = CodexAuth::create_dummy_chatgpt_auth_for_testing();
|
||||
for scope in [RemotePluginScope::Global, RemotePluginScope::Workspace] {
|
||||
let scopes = [RemotePluginScope::Global, RemotePluginScope::Workspace];
|
||||
for scope in scopes {
|
||||
catalog_cache::write_cached_directory_plugins(
|
||||
codex_home.path(),
|
||||
&config,
|
||||
@@ -480,8 +481,8 @@ fn catalog_cache_invalidation_clears_global_collections_and_preserves_other_scop
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
cached_remote_plugin_catalog_scopes(codex_home.path(), &config, Some(&auth)),
|
||||
BTreeSet::from([RemotePluginScope::Global, RemotePluginScope::Workspace])
|
||||
cached_remote_plugin_catalog_scopes(codex_home.path(), &config, Some(&auth), &scopes),
|
||||
BTreeSet::from(scopes)
|
||||
);
|
||||
catalog_cache::write_cached_directory_plugins(
|
||||
codex_home.path(),
|
||||
@@ -500,16 +501,17 @@ fn catalog_cache_invalidation_clears_global_collections_and_preserves_other_scop
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
cached_remote_plugin_catalog_scopes(codex_home.path(), &config, Some(&auth)),
|
||||
cached_remote_plugin_catalog_scopes(codex_home.path(), &config, Some(&auth), &scopes),
|
||||
BTreeSet::from([RemotePluginScope::Workspace]),
|
||||
);
|
||||
assert!(
|
||||
catalog_cache::load_cached_directory_plugins(
|
||||
catalog_cache::load_cached_directory_plugins::<RemotePluginDirectoryItem>(
|
||||
codex_home.path(),
|
||||
&config,
|
||||
&auth,
|
||||
RemotePluginScope::Global,
|
||||
Some(OPENAI_CURATED_REMOTE_COLLECTION_KEY),
|
||||
RemotePluginCatalogCacheMode::PreferCache,
|
||||
)
|
||||
.is_none()
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user