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:
Charlie Marsh
2026-10-26 21:13:03 +00:00
committed by copyberry
parent eb3572f9d7
commit a8bca62978
5 changed files with 275 additions and 50 deletions
+7 -2
View File
@@ -2983,15 +2983,20 @@ impl PluginsManager {
if !prefetch_discovery {
return;
}
let scopes_to_probe: &[RemotePluginScope] =
if config_for_remote_sync.remote_plugin_enabled {
&[RemotePluginScope::User, RemotePluginScope::Workspace]
} else {
&[RemotePluginScope::Workspace]
};
let mut scopes = crate::remote::cached_remote_plugin_catalog_scopes(
manager.codex_home.as_path(),
&remote_plugin_service_config(&config_for_remote_sync),
auth.as_ref(),
scopes_to_probe,
);
if config_for_remote_sync.remote_plugin_enabled {
scopes.insert(RemotePluginScope::Global);
} else {
scopes.retain(|scope| *scope == RemotePluginScope::Workspace);
}
manager.maybe_start_remote_catalog_cache_refresh(
&config_for_remote_sync,