mirror of
https://github.com/openai/codex.git
synced 2026-11-22 07:13:50 +00:00
Propagate remote plugin IDs to skill metadata (#35261)
## What changed - Carry a plugin's local and remote identities together from plugin loading into `SkillMetadata`. - Resolve remote IDs from the installed-plugin snapshot when available, falling back to persisted install metadata only when no snapshot exists. - Include plugin identity in skill cache keys so identity changes refresh cached skill metadata. ## Testing - Cover snapshot and persisted identity resolution, local marketplace isolation, cached skill refreshes, and propagation through plugin skill snapshots. GitOrigin-RevId: aabeeb631a43361fe817358ace7f1ea8ba5db708
This commit is contained in:
1 parent
32329b289d
commit
07fd04abb1
28 files changed
+550
-170
No files matched your search
@@ -861,6 +861,7 @@ async fn load_plugins_loads_default_skills_and_mcp_servers() {
|
||||
outcome.plugins(),
|
||||
vec![LoadedPlugin {
|
||||
config_name: "sample@test".to_string(),
|
||||
remote_plugin_id: None,
|
||||
manifest_name: Some("sample".to_string()),
|
||||
plugin_namespace: Some("sample".to_string()),
|
||||
manifest_description: Some(
|
||||
@@ -1139,6 +1140,26 @@ async fn installed_plugin_telemetry_metadata_resolves_persisted_remote_identity(
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn plugin_telemetry_ignores_local_marketplace_sidecars() {
|
||||
let codex_home = TempDir::new().unwrap();
|
||||
write_cached_plugin(codex_home.path(), "test", "sample");
|
||||
let plugin_id = PluginId::parse("sample@test").expect("plugin id should parse");
|
||||
PluginStore::new(codex_home.path().to_path_buf())
|
||||
.write_remote_plugin_id(&plugin_id, "plugins~Plugin_sample")
|
||||
.expect("persist remote plugin id");
|
||||
let manager = PluginsManager::new(codex_home.path().to_path_buf());
|
||||
|
||||
assert_eq!(
|
||||
manager.telemetry_metadata_for_plugin_id(&plugin_id),
|
||||
PluginTelemetryMetadata {
|
||||
plugin_id: Some(plugin_id),
|
||||
remote_plugin_id: None,
|
||||
capability_summary: None,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn installed_plugin_telemetry_metadata_prefers_remote_snapshot_identity() {
|
||||
let codex_home = TempDir::new().unwrap();
|
||||
@@ -2292,6 +2313,7 @@ async fn load_plugins_preserves_disabled_plugins_without_effective_contributions
|
||||
outcome.plugins(),
|
||||
vec![LoadedPlugin {
|
||||
config_name: "sample@test".to_string(),
|
||||
remote_plugin_id: None,
|
||||
manifest_name: None,
|
||||
plugin_namespace: None,
|
||||
manifest_description: None,
|
||||
@@ -2462,6 +2484,7 @@ fn capability_index_filters_inactive_and_zero_capability_plugins() {
|
||||
};
|
||||
let plugin = |config_name: &str, dir_name: &str, manifest_name: &str| LoadedPlugin {
|
||||
config_name: config_name.to_string(),
|
||||
remote_plugin_id: None,
|
||||
manifest_name: Some(manifest_name.to_string()),
|
||||
plugin_namespace: Some(
|
||||
config_name
|
||||
@@ -2648,52 +2671,98 @@ async fn plugin_cache_ignores_unrelated_session_overrides() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn skills_service_reuses_skills_parsed_during_plugin_load() {
|
||||
let codex_home = TempDir::new().unwrap();
|
||||
let codex_home_abs = codex_home.path().to_path_buf().abs();
|
||||
let plugin_root = codex_home
|
||||
.path()
|
||||
.join("plugins/cache")
|
||||
.join("test/sample/local");
|
||||
write_plugin(
|
||||
codex_home.path().join("plugins/cache/test").as_path(),
|
||||
"sample/local",
|
||||
"sample",
|
||||
);
|
||||
let skill_path = plugin_root.join("skills/SKILL.md");
|
||||
write_file(&skill_path, "---\nname: search\ndescription: first\n---\n");
|
||||
write_file(
|
||||
&codex_home.path().join(CONFIG_TOML_FILE),
|
||||
&plugin_config_toml(/*enabled*/ true, /*plugins_feature_enabled*/ true),
|
||||
);
|
||||
async fn skill_snapshots_resolve_remote_plugin_identity_from_authoritative_source() {
|
||||
let mut duplicate_plugin = remote_installed_plugin("sample");
|
||||
duplicate_plugin.id = "plugins~Plugin_duplicate".to_string();
|
||||
|
||||
let config = load_config(codex_home.path(), codex_home.path()).await;
|
||||
let manager = PluginsManager::new(codex_home.path().to_path_buf());
|
||||
let plugin_outcome = manager.plugins_for_config(&config).await;
|
||||
let plugin_skill_snapshots = manager.plugin_skill_snapshots_for_config(&config);
|
||||
write_file(&skill_path, "---\nname: search\ndescription: second\n---\n");
|
||||
for (installed_plugins, expected_remote_plugin_id) in [
|
||||
(None, Some("plugins~Plugin_persisted")),
|
||||
(Some(Vec::new()), None),
|
||||
(
|
||||
Some(vec![remote_installed_plugin("sample"), duplicate_plugin]),
|
||||
Some("plugins~Plugin_sample"),
|
||||
),
|
||||
] {
|
||||
let codex_home = TempDir::new().unwrap();
|
||||
let codex_home_abs = codex_home.path().to_path_buf().abs();
|
||||
let plugin_root = codex_home
|
||||
.path()
|
||||
.join("plugins/cache/openai-curated-remote/sample/local");
|
||||
write_plugin(
|
||||
codex_home
|
||||
.path()
|
||||
.join("plugins/cache/openai-curated-remote")
|
||||
.as_path(),
|
||||
"sample/local",
|
||||
"sample",
|
||||
);
|
||||
let skill_path = plugin_root.join("skills/SKILL.md");
|
||||
write_file(&skill_path, "---\nname: search\ndescription: first\n---\n");
|
||||
write_file(
|
||||
&codex_home.path().join(CONFIG_TOML_FILE),
|
||||
r#"[features]
|
||||
plugins = true
|
||||
remote_plugin = true
|
||||
|
||||
let skills_input = SkillsLoadInput::new(
|
||||
codex_home_abs.clone(),
|
||||
plugin_outcome.effective_plugin_skill_roots(),
|
||||
config.config_layer_stack.clone(),
|
||||
/*bundled_skills_enabled*/ false,
|
||||
)
|
||||
.with_plugin_skill_snapshots(plugin_skill_snapshots);
|
||||
let skills_service = SkillsService::new(codex_home_abs, /*bundled_skills_enabled*/ false);
|
||||
let cached = skills_service
|
||||
.snapshot_for_config(&skills_input, /*fs*/ None)
|
||||
.await;
|
||||
[plugins."sample@openai-curated-remote"]
|
||||
enabled = true
|
||||
"#,
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
cached
|
||||
.outcome()
|
||||
.skills
|
||||
.iter()
|
||||
.map(|skill| skill.description.as_str())
|
||||
.collect::<Vec<_>>(),
|
||||
vec!["first"]
|
||||
);
|
||||
let plugin_id =
|
||||
PluginId::parse("sample@openai-curated-remote").expect("remote plugin id should parse");
|
||||
PluginStore::new(codex_home.path().to_path_buf())
|
||||
.write_remote_plugin_id(&plugin_id, "plugins~Plugin_persisted")
|
||||
.expect("persist remote plugin id");
|
||||
let config = load_config(codex_home.path(), codex_home.path()).await;
|
||||
let manager = PluginsManager::new(codex_home.path().to_path_buf());
|
||||
if let Some(installed_plugins) = installed_plugins {
|
||||
manager.write_remote_installed_plugins_cache(installed_plugins);
|
||||
}
|
||||
|
||||
let plugin_outcome = manager.plugins_for_config(&config).await;
|
||||
assert_eq!(
|
||||
manager
|
||||
.telemetry_metadata_for_plugin_id(&plugin_id)
|
||||
.remote_plugin_id
|
||||
.as_deref(),
|
||||
expected_remote_plugin_id
|
||||
);
|
||||
write_file(&skill_path, "---\nname: search\ndescription: second\n---\n");
|
||||
|
||||
let skills_input = SkillsLoadInput::new(
|
||||
codex_home_abs.clone(),
|
||||
plugin_outcome.effective_plugin_skill_roots(),
|
||||
config.config_layer_stack.clone(),
|
||||
/*bundled_skills_enabled*/ false,
|
||||
)
|
||||
.with_plugin_skill_snapshots(manager.plugin_skill_snapshots_for_config(&config));
|
||||
let skills_service =
|
||||
SkillsService::new(codex_home_abs, /*bundled_skills_enabled*/ false);
|
||||
let snapshot = skills_service
|
||||
.snapshot_for_config(&skills_input, /*fs*/ None)
|
||||
.await;
|
||||
|
||||
assert_eq!(
|
||||
snapshot
|
||||
.outcome()
|
||||
.skills
|
||||
.iter()
|
||||
.map(|skill| {
|
||||
(
|
||||
skill.description.as_str(),
|
||||
skill.plugin_id.as_deref(),
|
||||
skill.remote_plugin_id.as_deref(),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
vec![(
|
||||
"first",
|
||||
Some("sample@openai-curated-remote"),
|
||||
expected_remote_plugin_id,
|
||||
)]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -6030,7 +6099,7 @@ async fn load_plugins_ignores_project_config_files() {
|
||||
|
||||
let plugins = load_plugins_from_layer_stack(
|
||||
&stack,
|
||||
std::collections::HashMap::new(),
|
||||
crate::remote_plugin_id_resolver::RemoteInstalledPluginsSnapshot::default(),
|
||||
&PluginStore::new(codex_home.path().to_path_buf()),
|
||||
/*plugin_skill_snapshots*/ None,
|
||||
Some(Product::Codex),
|
||||
|
||||
Reference in new issue
Block a user