WIP fase 2b-3: rimozione sottosistemi solo-ChatGPT (plugin remoti, image gen, daybreak, cyber, attestation, cloud config, app/connettori) - test in corso
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -531,7 +531,6 @@ async fn selected_root_id_distinguishes_identical_executor_paths() {
|
||||
host_snapshot: None,
|
||||
include_host_skills: false,
|
||||
include_bundled_skills: true,
|
||||
include_cloud_skills: false,
|
||||
mcp_resources: None,
|
||||
executor_capability_discovery: None,
|
||||
executor_capability_discovery_v2: None,
|
||||
@@ -619,7 +618,6 @@ async fn executor_discovery_preserves_posix_and_windows_locator_alias_roots() {
|
||||
host_snapshot: None,
|
||||
include_host_skills: false,
|
||||
include_bundled_skills: true,
|
||||
include_cloud_skills: false,
|
||||
mcp_resources: None,
|
||||
executor_capability_discovery: Some(discovery),
|
||||
executor_capability_discovery_v2: None,
|
||||
@@ -744,7 +742,6 @@ async fn executor_discovery_routes_produce_equivalent_catalog_metadata() {
|
||||
host_snapshot: None,
|
||||
include_host_skills: false,
|
||||
include_bundled_skills: true,
|
||||
include_cloud_skills: false,
|
||||
mcp_resources: None,
|
||||
executor_capability_discovery,
|
||||
executor_capability_discovery_v2: None,
|
||||
@@ -932,7 +929,6 @@ async fn pre_discovered_executor_catalog_snapshot() {
|
||||
host_snapshot: None,
|
||||
include_host_skills: false,
|
||||
include_bundled_skills: true,
|
||||
include_cloud_skills: false,
|
||||
mcp_resources: None,
|
||||
executor_capability_discovery: Some(executor_capability_discovery),
|
||||
executor_capability_discovery_v2: None,
|
||||
@@ -1054,7 +1050,6 @@ async fn direct_executor_discovery_preserves_hidden_nested_and_probed_metadata()
|
||||
host_snapshot: None,
|
||||
include_host_skills: false,
|
||||
include_bundled_skills: true,
|
||||
include_cloud_skills: false,
|
||||
mcp_resources: None,
|
||||
executor_capability_discovery: None,
|
||||
executor_capability_discovery_v2: None,
|
||||
@@ -1118,7 +1113,6 @@ async fn high_level_discovery_reuses_materialized_skill_contents_for_reads() {
|
||||
host_snapshot: None,
|
||||
include_host_skills: false,
|
||||
include_bundled_skills: true,
|
||||
include_cloud_skills: false,
|
||||
mcp_resources: None,
|
||||
executor_capability_discovery: Some(executor_capability_discovery),
|
||||
executor_capability_discovery_v2: None,
|
||||
|
||||
@@ -101,9 +101,6 @@ type TestResult = Result<(), Box<dyn std::error::Error>>;
|
||||
#[path = "skills_extension/shadow_task_context_tests.rs"]
|
||||
mod shadow_task_context_tests;
|
||||
|
||||
#[path = "skills_extension/presentation_dedup_tests.rs"]
|
||||
mod presentation_dedup_tests;
|
||||
|
||||
#[path = "skills_extension/catalog_delta_tests.rs"]
|
||||
mod catalog_delta_tests;
|
||||
|
||||
@@ -274,7 +271,7 @@ async fn skill_world_state_fragments(
|
||||
session_store: &ExtensionData,
|
||||
thread_store: &ExtensionData,
|
||||
turn_id: &str,
|
||||
) -> Result<(RenderedWorldStateFragment, RenderedWorldStateFragment), Box<dyn std::error::Error>> {
|
||||
) -> Result<RenderedWorldStateFragment, Box<dyn std::error::Error>> {
|
||||
let turn_store = ExtensionData::new(turn_id);
|
||||
let selected_roots = [SelectedCapabilityRoot {
|
||||
id: "skills".to_string(),
|
||||
@@ -305,11 +302,7 @@ async fn skill_world_state_fragments(
|
||||
.render_diff(PreviousWorldStateSection::Absent)
|
||||
.1
|
||||
.ok_or("executor skills should render through world state")?;
|
||||
let cloud = world_state_section(§ions, "cloud_skills")
|
||||
.render_diff(PreviousWorldStateSection::Absent)
|
||||
.1
|
||||
.ok_or("cloud skills should render through world state")?;
|
||||
Ok((executor, cloud))
|
||||
Ok(executor)
|
||||
}
|
||||
|
||||
async fn start_registered_turn(
|
||||
@@ -386,7 +379,6 @@ async fn installed_extension_uses_host_service_snapshot() -> TestResult {
|
||||
path_to_skills_md: PathUri::from_abs_path(&skill_path),
|
||||
scope: SkillScope::User,
|
||||
plugin_id: None,
|
||||
remote_plugin_id: None,
|
||||
});
|
||||
let loaded_skills = Arc::new(outcome);
|
||||
let skill_prompt_path = skill_path_string.replace('\\', "/");
|
||||
@@ -468,7 +460,6 @@ async fn host_world_state_records_catalog_metrics_on_publish_and_change() -> Tes
|
||||
path_to_skills_md: PathUri::from_abs_path(&skill_path),
|
||||
scope: SkillScope::User,
|
||||
plugin_id: None,
|
||||
remote_plugin_id: None,
|
||||
});
|
||||
let turn_store = ExtensionData::new("turn-1");
|
||||
turn_store.insert(HostSkillsSnapshot::new(Arc::new(outcome.clone())));
|
||||
@@ -542,7 +533,6 @@ async fn host_world_state_records_catalog_metrics_on_publish_and_change() -> Tes
|
||||
path_to_skills_md: PathUri::from_abs_path(&second_skill_path),
|
||||
scope: SkillScope::User,
|
||||
plugin_id: None,
|
||||
remote_plugin_id: None,
|
||||
});
|
||||
turn_store.insert(HostSkillsSnapshot::new(Arc::new(outcome)));
|
||||
let sections = prepared_world_state(
|
||||
@@ -599,7 +589,6 @@ async fn persisted_host_snapshot_deduplicates_warning_after_reinitialization() -
|
||||
path_to_skills_md: PathUri::from_abs_path(&skill_path),
|
||||
scope: SkillScope::User,
|
||||
plugin_id: None,
|
||||
remote_plugin_id: None,
|
||||
});
|
||||
let host_snapshot = HostSkillsSnapshot::new(Arc::new(outcome));
|
||||
|
||||
@@ -691,12 +680,9 @@ async fn persisted_host_snapshot_deduplicates_warning_after_reinitialization() -
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn executor_cloud_and_host_share_catalog_world_state_flow() -> TestResult {
|
||||
async fn executor_and_host_share_catalog_world_state_flow() -> TestResult {
|
||||
let provider = |mut entry: SkillCatalogEntry| {
|
||||
if matches!(
|
||||
entry.authority.kind,
|
||||
SkillSourceKind::Cloud | SkillSourceKind::Host
|
||||
) {
|
||||
if entry.authority.kind == SkillSourceKind::Host {
|
||||
entry.name = "shared-skill".to_string();
|
||||
}
|
||||
Arc::new(StaticSkillProvider {
|
||||
@@ -717,15 +703,6 @@ async fn executor_cloud_and_host_share_catalog_world_state_flow() -> TestResult
|
||||
"executor/executor-skill",
|
||||
"skill://executor/executor-skill/SKILL.md",
|
||||
)))
|
||||
.with_cloud_provider(provider(
|
||||
test_entry(
|
||||
SkillSourceKind::Cloud,
|
||||
"codex_apps",
|
||||
"cloud/cloud-skill",
|
||||
"skill://cloud/cloud-skill/SKILL.md",
|
||||
)
|
||||
.with_remote_plugin_id(Some("shared-plugin".to_string())),
|
||||
))
|
||||
.with_host_provider(provider(
|
||||
test_entry(
|
||||
SkillSourceKind::Host,
|
||||
@@ -753,7 +730,6 @@ async fn executor_cloud_and_host_share_catalog_world_state_flow() -> TestResult
|
||||
thread_store: &thread_store,
|
||||
})
|
||||
.await;
|
||||
// Host rendering stays separate even when its identity matches a Cloud skill.
|
||||
start_registered_turn(®istry, &session_store, &thread_store, "turn-1").await;
|
||||
|
||||
let selected_roots = [SelectedCapabilityRoot {
|
||||
@@ -791,7 +767,7 @@ async fn executor_cloud_and_host_share_catalog_world_state_flow() -> TestResult
|
||||
.iter()
|
||||
.map(WorldStateSectionContribution::id)
|
||||
.collect::<Vec<_>>(),
|
||||
vec!["skills", "cloud_skills", "host_skills"]
|
||||
vec!["skills", "host_skills"]
|
||||
);
|
||||
assert!(metrics.samples().is_empty());
|
||||
|
||||
@@ -800,10 +776,6 @@ async fn executor_cloud_and_host_share_catalog_world_state_flow() -> TestResult
|
||||
"skills",
|
||||
"- executor-skill: Fix lint errors. (executor package: executor/executor-skill)",
|
||||
),
|
||||
(
|
||||
"cloud_skills",
|
||||
"- shared-skill: Fix lint errors. (cloud package: cloud/cloud-skill)",
|
||||
),
|
||||
(
|
||||
"host_skills",
|
||||
"- shared-skill: Fix lint errors. (file: /skills/host-skill/SKILL.md)",
|
||||
@@ -817,12 +789,8 @@ async fn executor_cloud_and_host_share_catalog_world_state_flow() -> TestResult
|
||||
assert!(body.contains(expected_line));
|
||||
}
|
||||
|
||||
let expected_metrics = [
|
||||
"executor_world_state",
|
||||
"cloud_world_state",
|
||||
"host_world_state",
|
||||
]
|
||||
.into_iter()
|
||||
let expected_metrics = ["executor_world_state", "host_world_state"]
|
||||
.into_iter()
|
||||
.flat_map(|surface| expected_catalog_metric_samples(surface, /*count*/ 1))
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(metrics.samples(), expected_metrics);
|
||||
@@ -1859,7 +1827,6 @@ async fn overlapping_executor_catalogs_render_their_own_roots() -> TestResult {
|
||||
#[tokio::test]
|
||||
async fn default_context_truncates_catalog_descriptions() -> TestResult {
|
||||
let description = "x".repeat(1_025);
|
||||
// A small cloud catalog leaves its unused allowance to filesystem descriptions.
|
||||
let executor_entries = (0..5)
|
||||
.map(|index| {
|
||||
let package_id = format!("executor/executor-long-description-{index}");
|
||||
@@ -1873,13 +1840,6 @@ async fn default_context_truncates_catalog_descriptions() -> TestResult {
|
||||
entry
|
||||
})
|
||||
.collect();
|
||||
let mut cloud_entry = test_entry(
|
||||
SkillSourceKind::Cloud,
|
||||
"codex_apps",
|
||||
"cloud/cloud-long-description",
|
||||
"skill://cloud/cloud-long-description/SKILL.md",
|
||||
);
|
||||
cloud_entry.description = description.clone();
|
||||
let providers = SkillProviders::new()
|
||||
.with_executor_provider(Arc::new(StaticSkillProvider {
|
||||
catalog: SkillCatalog {
|
||||
@@ -1890,16 +1850,6 @@ async fn default_context_truncates_catalog_descriptions() -> TestResult {
|
||||
read_requests: Arc::new(Mutex::new(Vec::new())),
|
||||
list_calls: None,
|
||||
fail_first_list: false,
|
||||
}))
|
||||
.with_cloud_provider(Arc::new(StaticSkillProvider {
|
||||
catalog: SkillCatalog {
|
||||
is_partial: false,
|
||||
entries: vec![cloud_entry],
|
||||
warnings: Vec::new(),
|
||||
},
|
||||
read_requests: Arc::new(Mutex::new(Vec::new())),
|
||||
list_calls: None,
|
||||
fail_first_list: false,
|
||||
}));
|
||||
let mut builder = ExtensionRegistryBuilder::new();
|
||||
install_with_providers(&mut builder, providers, skills_extension_config);
|
||||
@@ -1922,287 +1872,24 @@ async fn default_context_truncates_catalog_descriptions() -> TestResult {
|
||||
.await;
|
||||
start_registered_turn(®istry, &session_store, &thread_store, "turn-1").await;
|
||||
|
||||
let (executor, cloud) =
|
||||
let executor =
|
||||
skill_world_state_fragments(®istry, &session_store, &thread_store, "turn-1").await?;
|
||||
let executor = executor.body().clone().expect_text();
|
||||
let cloud = cloud.body().clone().expect_text();
|
||||
let expected_description = "x".repeat(1_021) + "...";
|
||||
for index in 0..5 {
|
||||
assert!(executor.contains(&format!(
|
||||
"- executor-long-description-{index}: {expected_description} (executor package:"
|
||||
)));
|
||||
}
|
||||
assert!(cloud.contains("- cloud-long-description:"));
|
||||
for rendered in [executor, cloud] {
|
||||
assert!(rendered.contains(&expected_description));
|
||||
assert!(!rendered.contains(&"x".repeat(1_024)));
|
||||
assert!(!rendered.contains(&description));
|
||||
}
|
||||
assert!(!executor.contains(&"x".repeat(1_024)));
|
||||
assert!(!executor.contains(&description));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn catalog_rebalances_only_to_avoid_omissions_and_retains_the_allocation() -> TestResult {
|
||||
enum Phase {
|
||||
Initial,
|
||||
FirstReady,
|
||||
Disconnected,
|
||||
Reconnected,
|
||||
Resumed,
|
||||
CloudCatalogGrew,
|
||||
BudgetChanged,
|
||||
}
|
||||
|
||||
// Description-only pressure, filesystem omissions that can be rescued, and
|
||||
// unavoidable omissions. Check both token and fallback character accounting.
|
||||
for (executor_count, cloud_count, rebalance, all_fit) in [
|
||||
(17, 82, false, true),
|
||||
(40, 5, true, true),
|
||||
(40, 160, false, false),
|
||||
] {
|
||||
for context_window in [None, Some(100_000)] {
|
||||
let description = "x".repeat(1_025);
|
||||
let executor_entries: Vec<_> = (0..executor_count)
|
||||
.map(|index| {
|
||||
let package_id = format!("executor/executor-skill-{index:02}");
|
||||
let mut entry = test_entry(
|
||||
SkillSourceKind::Executor,
|
||||
"env-1",
|
||||
&package_id,
|
||||
&format!("skill://{package_id}/SKILL.md"),
|
||||
);
|
||||
entry.description = description.clone();
|
||||
entry
|
||||
})
|
||||
.collect();
|
||||
let registry_for_cloud_count = |cloud_count| {
|
||||
let cloud_entries = (0..cloud_count)
|
||||
.map(|index| {
|
||||
let package_id = format!("cloud/cloud-skill-{index:02}");
|
||||
let mut entry = test_entry(
|
||||
SkillSourceKind::Cloud,
|
||||
"codex_apps",
|
||||
&package_id,
|
||||
&format!("skill://{package_id}/SKILL.md"),
|
||||
);
|
||||
entry.description = description.clone();
|
||||
entry
|
||||
})
|
||||
.collect();
|
||||
let providers = SkillProviders::new()
|
||||
.with_executor_provider(Arc::new(StaticSkillProvider {
|
||||
catalog: SkillCatalog {
|
||||
is_partial: false,
|
||||
entries: executor_entries.clone(),
|
||||
warnings: Vec::new(),
|
||||
},
|
||||
read_requests: Arc::new(Mutex::new(Vec::new())),
|
||||
list_calls: None,
|
||||
fail_first_list: false,
|
||||
}))
|
||||
.with_cloud_provider(Arc::new(StaticSkillProvider {
|
||||
catalog: SkillCatalog {
|
||||
is_partial: false,
|
||||
entries: cloud_entries,
|
||||
warnings: Vec::new(),
|
||||
},
|
||||
read_requests: Arc::new(Mutex::new(Vec::new())),
|
||||
list_calls: None,
|
||||
fail_first_list: false,
|
||||
}));
|
||||
let mut builder = ExtensionRegistryBuilder::new();
|
||||
install_with_providers(&mut builder, providers, skills_extension_config);
|
||||
builder.build()
|
||||
};
|
||||
let mut registry = registry_for_cloud_count(cloud_count);
|
||||
|
||||
let selected_roots = [SelectedCapabilityRoot {
|
||||
id: "skills".to_string(),
|
||||
location: CapabilityRootLocation::Environment {
|
||||
environment_id: "env-1".to_string(),
|
||||
path: PathUri::parse("file:///skills")?,
|
||||
},
|
||||
}];
|
||||
let mut model = ModelInfo {
|
||||
context_window,
|
||||
..catalog_model_info()
|
||||
};
|
||||
let session_store = ExtensionData::new("session");
|
||||
let mut thread_store = ExtensionData::new("thread");
|
||||
let mut previous = serde_json::Map::new();
|
||||
let mut initial_cloud = None;
|
||||
let mut accepted_cloud = None;
|
||||
let mut phases = vec![
|
||||
Phase::Initial,
|
||||
Phase::FirstReady,
|
||||
Phase::Disconnected,
|
||||
Phase::Reconnected,
|
||||
Phase::Disconnected,
|
||||
Phase::Reconnected,
|
||||
Phase::Resumed,
|
||||
];
|
||||
if rebalance {
|
||||
phases.extend([
|
||||
Phase::CloudCatalogGrew,
|
||||
Phase::Disconnected,
|
||||
Phase::Reconnected,
|
||||
Phase::Resumed,
|
||||
]);
|
||||
}
|
||||
phases.push(Phase::BudgetChanged);
|
||||
for (step, phase) in phases.into_iter().enumerate() {
|
||||
if matches!(phase, Phase::CloudCatalogGrew) {
|
||||
// Refresh the cloud inventory on resume while retaining the saved allocation.
|
||||
registry = registry_for_cloud_count(/*cloud_count*/ 15);
|
||||
}
|
||||
if matches!(
|
||||
phase,
|
||||
Phase::Initial | Phase::Resumed | Phase::CloudCatalogGrew
|
||||
) {
|
||||
thread_store = ExtensionData::new("thread");
|
||||
registry.thread_lifecycle_contributors()[0]
|
||||
.on_thread_start(ThreadStartInput {
|
||||
config: &default_config(),
|
||||
session_source: &SessionSource::Cli,
|
||||
persistent_thread_state_available: true,
|
||||
environments: &[],
|
||||
mcp_resource_client: None,
|
||||
extension_metrics: None,
|
||||
session_store: &session_store,
|
||||
thread_store: &thread_store,
|
||||
})
|
||||
.await;
|
||||
}
|
||||
if matches!(phase, Phase::BudgetChanged) {
|
||||
model.context_window = Some(200_000);
|
||||
}
|
||||
let ready = matches!(
|
||||
phase,
|
||||
Phase::FirstReady
|
||||
| Phase::Reconnected
|
||||
| Phase::Resumed
|
||||
| Phase::CloudCatalogGrew
|
||||
);
|
||||
let turn_id = format!("turn-{step}");
|
||||
let turn_store = ExtensionData::new(&turn_id);
|
||||
start_registered_turn(®istry, &session_store, &thread_store, &turn_id).await;
|
||||
let sections = prepared_world_state(
|
||||
®istry,
|
||||
if ready { &selected_roots } else { &[] },
|
||||
WorldStateContributionInput {
|
||||
previous_world_state: Some(&previous),
|
||||
model_info: &model,
|
||||
thread_id: codex_protocol::ThreadId::new(),
|
||||
turn_id: &turn_id,
|
||||
environments: &[],
|
||||
|
||||
extension_metrics: None,
|
||||
session_store: &session_store,
|
||||
thread_store: &thread_store,
|
||||
turn_store: &turn_store,
|
||||
step_store: &turn_store,
|
||||
},
|
||||
)
|
||||
.await;
|
||||
let rendered = sections
|
||||
.iter()
|
||||
.map(|section| {
|
||||
let prior = previous.get(section.id()).map_or(
|
||||
PreviousWorldStateSection::Absent,
|
||||
PreviousWorldStateSection::Known,
|
||||
);
|
||||
(section.id().to_string(), section.render_diff(prior))
|
||||
})
|
||||
.collect::<std::collections::BTreeMap<_, _>>();
|
||||
let cloud = &rendered["cloud_skills"];
|
||||
let cloud_snapshot = cloud.0.as_ref().expect("cloud snapshot");
|
||||
let cloud_body = cloud_snapshot["body"].as_str().ok_or("cloud catalog")?;
|
||||
match phase {
|
||||
Phase::Initial => initial_cloud = Some(cloud_body.to_string()),
|
||||
Phase::FirstReady => {
|
||||
assert_eq!(initial_cloud.as_deref() != Some(cloud_body), rebalance);
|
||||
accepted_cloud = Some(cloud_snapshot.clone());
|
||||
let executor = rendered["skills"].0.as_ref().expect("executor snapshot");
|
||||
let executor_body = executor["body"].as_str().ok_or("executor catalog")?;
|
||||
assert_eq!(
|
||||
executor_body
|
||||
.lines()
|
||||
.filter(|line| line.starts_with("- executor-skill-"))
|
||||
.count()
|
||||
== executor_count,
|
||||
all_fit
|
||||
);
|
||||
if all_fit {
|
||||
assert_eq!(
|
||||
cloud_body
|
||||
.lines()
|
||||
.filter(|line| line.starts_with("- cloud-skill-"))
|
||||
.count(),
|
||||
cloud_count
|
||||
);
|
||||
}
|
||||
}
|
||||
Phase::CloudCatalogGrew => {
|
||||
let allocation = &cloud_snapshot["allocation"];
|
||||
let previous_limit = previous["cloud_skills"]["allocation"]["cloudLimit"]
|
||||
.as_u64()
|
||||
.ok_or("previous cloud limit")?;
|
||||
assert!(
|
||||
allocation["cloudLimit"].as_u64().ok_or("cloud limit")?
|
||||
> previous_limit
|
||||
);
|
||||
assert_ne!(
|
||||
allocation["cloudCatalogFingerprint"],
|
||||
previous["cloud_skills"]["allocation"]["cloudCatalogFingerprint"]
|
||||
);
|
||||
assert_eq!(
|
||||
cloud_body
|
||||
.lines()
|
||||
.filter(|line| line.starts_with("- cloud-skill-"))
|
||||
.count(),
|
||||
15
|
||||
);
|
||||
let executor = rendered["skills"].0.as_ref().expect("executor snapshot");
|
||||
assert_eq!(
|
||||
executor["body"]
|
||||
.as_str()
|
||||
.ok_or("executor catalog")?
|
||||
.lines()
|
||||
.filter(|line| line.starts_with("- executor-skill-"))
|
||||
.count(),
|
||||
executor_count
|
||||
);
|
||||
accepted_cloud = Some(cloud_snapshot.clone());
|
||||
}
|
||||
Phase::Disconnected | Phase::Reconnected | Phase::Resumed => {
|
||||
assert_eq!(Some(cloud_snapshot), accepted_cloud.as_ref());
|
||||
assert!(cloud.1.is_none());
|
||||
}
|
||||
Phase::BudgetChanged => {
|
||||
// A genuinely different total budget starts a new allocation.
|
||||
assert_eq!(
|
||||
cloud_snapshot["allocation"],
|
||||
serde_json::json!({
|
||||
"totalBudget": {"tokens": 4_000}, "cloudLimit": 3_000,
|
||||
"cloudCatalogFingerprint": previous["cloud_skills"]["allocation"]["cloudCatalogFingerprint"],
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
previous = rendered
|
||||
.into_iter()
|
||||
.map(|(id, (snapshot, _))| (id, snapshot.expect("skills snapshot")))
|
||||
.collect();
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn extreme_budget_pressure_removes_descriptions_before_omitting_entries() -> TestResult {
|
||||
let executor_entries = (0..40)
|
||||
let executor_entries = (0..200)
|
||||
.map(|index| {
|
||||
let package_id = format!("executor/executor-skill-{index:03}");
|
||||
let mut entry = test_entry(
|
||||
@@ -2215,19 +1902,6 @@ async fn extreme_budget_pressure_removes_descriptions_before_omitting_entries()
|
||||
entry
|
||||
})
|
||||
.collect();
|
||||
let cloud_entries = (0..160)
|
||||
.map(|index| {
|
||||
let package_id = format!("cloud/cloud-skill-{index:03}");
|
||||
let mut entry = test_entry(
|
||||
SkillSourceKind::Cloud,
|
||||
"codex_apps",
|
||||
&package_id,
|
||||
&format!("skill://{package_id}/SKILL.md"),
|
||||
);
|
||||
entry.description = format!("cloud-description-{index:03}");
|
||||
entry
|
||||
})
|
||||
.collect();
|
||||
let providers = SkillProviders::new()
|
||||
.with_executor_provider(Arc::new(StaticSkillProvider {
|
||||
catalog: SkillCatalog {
|
||||
@@ -2238,16 +1912,6 @@ async fn extreme_budget_pressure_removes_descriptions_before_omitting_entries()
|
||||
read_requests: Arc::new(Mutex::new(Vec::new())),
|
||||
list_calls: None,
|
||||
fail_first_list: false,
|
||||
}))
|
||||
.with_cloud_provider(Arc::new(StaticSkillProvider {
|
||||
catalog: SkillCatalog {
|
||||
is_partial: false,
|
||||
entries: cloud_entries,
|
||||
warnings: Vec::new(),
|
||||
},
|
||||
read_requests: Arc::new(Mutex::new(Vec::new())),
|
||||
list_calls: None,
|
||||
fail_first_list: false,
|
||||
}));
|
||||
let (event_tx, event_rx) = std::sync::mpsc::channel();
|
||||
let mut builder =
|
||||
@@ -2272,29 +1936,19 @@ async fn extreme_budget_pressure_removes_descriptions_before_omitting_entries()
|
||||
.await;
|
||||
start_registered_turn(®istry, &session_store, &thread_store, "turn-1").await;
|
||||
|
||||
let (executor, cloud) =
|
||||
let executor =
|
||||
skill_world_state_fragments(®istry, &session_store, &thread_store, "turn-1").await?;
|
||||
let executor = executor.body().clone().expect_text();
|
||||
let cloud = cloud.body().clone().expect_text();
|
||||
let included_executor_count = executor
|
||||
.lines()
|
||||
.filter(|line| line.starts_with("- executor-skill-"))
|
||||
.count();
|
||||
let included_cloud_count = cloud
|
||||
.lines()
|
||||
.filter(|line| line.starts_with("- cloud-skill-"))
|
||||
.count();
|
||||
assert!(included_executor_count > 0);
|
||||
assert!(included_executor_count < 40);
|
||||
assert!(included_cloud_count > 0);
|
||||
assert!(included_cloud_count < 160);
|
||||
assert!(included_executor_count < 200);
|
||||
assert!(executor.contains("- executor-skill-000: (executor package:"));
|
||||
assert!(cloud.contains("- cloud-skill-000: (cloud package:"));
|
||||
assert!(!cloud.contains("- cloud-skill-159:"));
|
||||
for (total, included, rendered) in [
|
||||
(40, included_executor_count, executor),
|
||||
(160, included_cloud_count, cloud),
|
||||
] {
|
||||
assert!(!executor.contains("- executor-skill-199:"));
|
||||
{
|
||||
let (total, included, rendered) = (200, included_executor_count, executor);
|
||||
assert!(!rendered.contains("description-"));
|
||||
assert!(rendered.contains("additional skills omitted from this bounded skills list"));
|
||||
let omitted_count = total - included;
|
||||
@@ -2316,28 +1970,37 @@ async fn extreme_budget_pressure_removes_descriptions_before_omitting_entries()
|
||||
#[tokio::test]
|
||||
async fn skills_list_only_returns_model_visible_bounded_metadata() -> TestResult {
|
||||
const OVERSIZED_WARNING: &str = "Some skills were omitted because their metadata is too large.";
|
||||
const PROVIDER_WARNING: &str = "Some cloud skills could not be discovered because the provider disconnected before returning the complete catalog.";
|
||||
const PROVIDER_WARNING: &str = "Some local skills could not be discovered because the provider disconnected before returning the complete catalog.";
|
||||
|
||||
let supplementary_warning = "w".repeat(256);
|
||||
let opaque_suffix = "\\".repeat(1_500);
|
||||
// Executor listings carry a 12-byte longer authority (`{"kind":"executor","id":"e"}`)
|
||||
// than the original single-source fixture, so descriptions are 12 bytes shorter to keep
|
||||
// the same page boundaries.
|
||||
let mut entry = test_entry(
|
||||
SkillSourceKind::Cloud,
|
||||
"codex_apps",
|
||||
&format!("cloud/{opaque_suffix}"),
|
||||
&format!("skill://cloud/{opaque_suffix}/SKILL.md"),
|
||||
SkillSourceKind::Executor,
|
||||
"e",
|
||||
&format!("local/{opaque_suffix}"),
|
||||
&format!("skill://local/{opaque_suffix}/SKILL.md"),
|
||||
);
|
||||
entry.description = "x".repeat(1_025);
|
||||
let [first_entry, mut middle_entry, mut final_entry] = ["p0", "p1", "p2"].map(|name| {
|
||||
entry.main_prompt = SkillResourceId::environment(
|
||||
format!("skill://local/{opaque_suffix}/SKILL.md"),
|
||||
"env-1",
|
||||
PathUri::parse("file:///skills/opaque/SKILL.md")?,
|
||||
);
|
||||
entry.description = "x".repeat(1_012);
|
||||
let [mut first_entry, mut middle_entry, mut final_entry] = ["p0", "p1", "p2"].map(|name| {
|
||||
test_entry(
|
||||
SkillSourceKind::Cloud,
|
||||
"codex_apps",
|
||||
SkillSourceKind::Executor,
|
||||
"e",
|
||||
name,
|
||||
&format!("skill://{name}/SKILL.md"),
|
||||
)
|
||||
});
|
||||
middle_entry.description = "d".repeat(110);
|
||||
final_entry.description = "d".repeat(50);
|
||||
let providers = SkillProviders::new().with_cloud_provider(Arc::new(StaticSkillProvider {
|
||||
first_entry.description = "Fix.".to_string();
|
||||
middle_entry.description = "d".repeat(98);
|
||||
final_entry.description = "d".repeat(38);
|
||||
let providers = SkillProviders::new().with_executor_provider(Arc::new(StaticSkillProvider {
|
||||
catalog: SkillCatalog {
|
||||
is_partial: false,
|
||||
entries: vec![
|
||||
@@ -2346,10 +2009,10 @@ async fn skills_list_only_returns_model_visible_bounded_metadata() -> TestResult
|
||||
middle_entry,
|
||||
final_entry,
|
||||
test_entry(
|
||||
SkillSourceKind::Cloud,
|
||||
"codex_apps",
|
||||
"cloud/hidden",
|
||||
"skill://cloud/hidden/SKILL.md",
|
||||
SkillSourceKind::Executor,
|
||||
"e",
|
||||
"local/hidden",
|
||||
"skill://local/hidden/SKILL.md",
|
||||
)
|
||||
.hidden_from_prompt(),
|
||||
],
|
||||
@@ -2386,9 +2049,16 @@ async fn skills_list_only_returns_model_visible_bounded_metadata() -> TestResult
|
||||
start_registered_turn(®istry, &session_store, &thread_store, "turn-1").await;
|
||||
|
||||
let step_store = ExtensionData::new("step");
|
||||
let selected_roots = [SelectedCapabilityRoot {
|
||||
id: "skills".to_string(),
|
||||
location: CapabilityRootLocation::Environment {
|
||||
environment_id: "env-1".to_string(),
|
||||
path: PathUri::parse("file:///skills")?,
|
||||
},
|
||||
}];
|
||||
prepared_world_state(
|
||||
®istry,
|
||||
&[],
|
||||
&selected_roots,
|
||||
WorldStateContributionInput {
|
||||
previous_world_state: None,
|
||||
step_store: &step_store,
|
||||
@@ -2410,7 +2080,7 @@ async fn skills_list_only_returns_model_visible_bounded_metadata() -> TestResult
|
||||
.find(|tool| tool.tool_name().name == "list")
|
||||
.ok_or("skills.list tool should be registered")?;
|
||||
let payload = ToolPayload::Function {
|
||||
arguments: serde_json::json!({"authority": {"kind": "cloud"}}).to_string(),
|
||||
arguments: serde_json::json!({"authority": {"kind": "executor"}}).to_string(),
|
||||
};
|
||||
let call = ToolCall {
|
||||
turn_id: "turn-1".to_string(),
|
||||
@@ -2435,7 +2105,7 @@ async fn skills_list_only_returns_model_visible_bounded_metadata() -> TestResult
|
||||
.as_array()
|
||||
.ok_or("skills.list should return skills")?;
|
||||
assert_eq!(complete_skills.len(), 4);
|
||||
assert_eq!(complete_skills[0]["description"], "x".repeat(1_021) + "...");
|
||||
assert_eq!(complete_skills[0]["description"], "x".repeat(1_012));
|
||||
assert_eq!(
|
||||
complete_response["warnings"].as_array().map(Vec::len),
|
||||
Some(4)
|
||||
@@ -2480,7 +2150,7 @@ async fn skills_list_only_returns_model_visible_bounded_metadata() -> TestResult
|
||||
{
|
||||
let payload = ToolPayload::Function {
|
||||
arguments: serde_json::json!({
|
||||
"authority": {"kind": "cloud"},
|
||||
"authority": {"kind": "executor"},
|
||||
"cursor": cursor,
|
||||
})
|
||||
.to_string(),
|
||||
@@ -2494,7 +2164,7 @@ async fn skills_list_only_returns_model_visible_bounded_metadata() -> TestResult
|
||||
..call.clone()
|
||||
})
|
||||
.await?;
|
||||
assert!(output.contains_external_context());
|
||||
assert!(!output.contains_external_context());
|
||||
let response = output
|
||||
.post_tool_use_response(&call_id, &payload)
|
||||
.ok_or("skills.list should expose structured output")?;
|
||||
@@ -2525,7 +2195,7 @@ async fn skills_list_only_returns_model_visible_bounded_metadata() -> TestResult
|
||||
.ok_or("cursor should include its budget")?;
|
||||
let legacy_payload = ToolPayload::Function {
|
||||
arguments: serde_json::json!({
|
||||
"authority": {"kind": "cloud"},
|
||||
"authority": {"kind": "executor"},
|
||||
"cursor": legacy_cursor,
|
||||
})
|
||||
.to_string(),
|
||||
@@ -2569,7 +2239,7 @@ async fn skills_list_only_returns_model_visible_bounded_metadata() -> TestResult
|
||||
// The resource fits the 2400-byte budget before escaping, but not after.
|
||||
let insufficient_budget_payload = ToolPayload::Function {
|
||||
arguments: serde_json::json!({
|
||||
"package": format!("cloud/{opaque_suffix}"),
|
||||
"package": format!("local/{opaque_suffix}"),
|
||||
})
|
||||
.to_string(),
|
||||
};
|
||||
@@ -2586,7 +2256,11 @@ async fn skills_list_only_returns_model_visible_bounded_metadata() -> TestResult
|
||||
turn_item_emitter: Arc::new(NoopTurnItemEmitter),
|
||||
attachment_store: Arc::new(InlineAttachmentStore),
|
||||
ephemeral: false,
|
||||
environments: Vec::new(),
|
||||
environments: vec![codex_extension_api::ToolEnvironment::new(
|
||||
"env-1".to_string(),
|
||||
PathUri::parse("file:///skills")?,
|
||||
&FileSystemEnvironmentAccessor::unrestricted(&LOCAL_FS),
|
||||
)],
|
||||
payload: insufficient_budget_payload,
|
||||
})
|
||||
.await
|
||||
@@ -2601,138 +2275,6 @@ async fn skills_list_only_returns_model_visible_bounded_metadata() -> TestResult
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn cloud_discovery_is_gated_and_reports_failures() -> TestResult {
|
||||
for (cloud_skill_enabled, has_cloud_provider) in [(false, true), (true, true), (true, false)] {
|
||||
let list_calls = Arc::new(AtomicUsize::new(0));
|
||||
let mut providers = SkillProviders::new();
|
||||
if has_cloud_provider {
|
||||
providers = providers.with_cloud_provider(Arc::new(StaticSkillProvider {
|
||||
catalog: SkillCatalog::default(),
|
||||
read_requests: Arc::new(Mutex::new(Vec::new())),
|
||||
list_calls: Some(Arc::clone(&list_calls)),
|
||||
fail_first_list: true,
|
||||
}));
|
||||
}
|
||||
let cloud_available = cloud_skill_enabled && has_cloud_provider;
|
||||
let (event_tx, event_rx) = std::sync::mpsc::channel();
|
||||
let mut builder =
|
||||
ExtensionRegistryBuilder::with_event_sink(Arc::new(ChannelEventSink(event_tx)));
|
||||
install_with_providers(&mut builder, providers, skills_extension_config);
|
||||
let registry = builder.build();
|
||||
let session_store = ExtensionData::new("session");
|
||||
let thread_store = ExtensionData::new("thread");
|
||||
let session_source = SessionSource::Cli;
|
||||
let config = TestConfig {
|
||||
cloud_skill_enabled,
|
||||
..default_config()
|
||||
};
|
||||
registry.thread_lifecycle_contributors()[0]
|
||||
.on_thread_start(ThreadStartInput {
|
||||
config: &config,
|
||||
session_source: &session_source,
|
||||
persistent_thread_state_available: true,
|
||||
environments: &[],
|
||||
mcp_resource_client: None,
|
||||
extension_metrics: None,
|
||||
session_store: &session_store,
|
||||
thread_store: &thread_store,
|
||||
})
|
||||
.await;
|
||||
|
||||
assert_eq!(
|
||||
registry
|
||||
.turn_lifecycle_contributors()
|
||||
.iter()
|
||||
.map(|contributor| contributor.turn_start_phase(&thread_store))
|
||||
.collect::<Vec<_>>(),
|
||||
vec![
|
||||
codex_extension_api::TurnStartPhase::BeforeTaskRegistration,
|
||||
if cloud_available {
|
||||
codex_extension_api::TurnStartPhase::RegularTaskStart
|
||||
} else {
|
||||
codex_extension_api::TurnStartPhase::BeforeTaskRegistration
|
||||
},
|
||||
]
|
||||
);
|
||||
assert_eq!(
|
||||
registry
|
||||
.turn_lifecycle_contributors()
|
||||
.iter()
|
||||
.map(|contributor| contributor.requires_mcp_runtime(&thread_store))
|
||||
.collect::<Vec<_>>(),
|
||||
vec![false, cloud_available]
|
||||
);
|
||||
start_registered_turn(®istry, &session_store, &thread_store, "turn-1").await;
|
||||
assert_eq!(
|
||||
list_calls.load(Ordering::Relaxed),
|
||||
usize::from(cloud_available)
|
||||
);
|
||||
for discovery_v2 in [None, Some([].as_slice())] {
|
||||
let step_store = ExtensionData::new("step");
|
||||
if let Some(snapshots) = discovery_v2 {
|
||||
step_store.insert(Vec::<
|
||||
codex_exec_server::ExecutorCapabilityDiscoveryV2Snapshot,
|
||||
>::from(snapshots));
|
||||
}
|
||||
let sections = prepared_world_state(
|
||||
®istry,
|
||||
&[],
|
||||
WorldStateContributionInput {
|
||||
previous_world_state: None,
|
||||
step_store: &step_store,
|
||||
model_info: &catalog_model_info(),
|
||||
thread_id: codex_protocol::ThreadId::new(),
|
||||
turn_id: "turn-1",
|
||||
environments: &[],
|
||||
extension_metrics: None,
|
||||
session_store: &session_store,
|
||||
thread_store: &thread_store,
|
||||
turn_store: &ExtensionData::new("turn-1"),
|
||||
},
|
||||
)
|
||||
.await;
|
||||
if has_cloud_provider {
|
||||
// Resume may retain a catalog even when the new Cloud discovery fails.
|
||||
let previous = serde_json::json!({
|
||||
"body": "Previously advertised Cloud skills",
|
||||
"includeInstructions": true,
|
||||
"enabled": true,
|
||||
});
|
||||
let update = world_state_section(§ions, "cloud_skills")
|
||||
.render_diff(PreviousWorldStateSection::Known(&previous))
|
||||
.1
|
||||
.ok_or("unavailable Cloud skills should withdraw the previous catalog")?;
|
||||
assert_eq!(
|
||||
update.body().clone().expect_text(),
|
||||
"\n## Cloud skills update\nNo cloud skills are currently available.\n"
|
||||
);
|
||||
} else {
|
||||
assert!(
|
||||
sections
|
||||
.iter()
|
||||
.all(|section| section.id() != "cloud_skills")
|
||||
);
|
||||
}
|
||||
}
|
||||
if !cloud_available {
|
||||
assert!(event_rx.try_recv().is_err());
|
||||
let tools = registry.tool_contributors()[0].tools_for_step(
|
||||
&session_store,
|
||||
&thread_store,
|
||||
&ExtensionData::new("step"),
|
||||
);
|
||||
assert!(tools.iter().all(|tool| tool.tool_name().name != "list"));
|
||||
continue;
|
||||
}
|
||||
let warning = event_rx.try_recv()?.into_warning();
|
||||
assert_eq!(warning.thread_id, thread_store.level_id());
|
||||
assert_eq!(warning.turn_id.as_deref(), Some("turn-1"));
|
||||
assert!(warning.message.contains("temporary cloud failure"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn v2_root_aliases_and_read_cache_use_the_captured_environment() -> TestResult {
|
||||
let directory = tempfile::tempdir()?;
|
||||
@@ -3046,17 +2588,7 @@ async fn root_qualified_locator_selects_only_the_matching_executor_skill() -> Te
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn model_context_window_scales_executor_and_cloud_catalogs() -> TestResult {
|
||||
let cloud_entries = (0..40)
|
||||
.map(|index| {
|
||||
test_entry(
|
||||
SkillSourceKind::Cloud,
|
||||
"cloud",
|
||||
&format!("cloud/skill-{index:02}"),
|
||||
&format!("skill-{index:02}/SKILL.md"),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
async fn model_context_window_scales_executor_catalog() -> TestResult {
|
||||
let executor_entries = (0..200)
|
||||
.map(|index| {
|
||||
test_entry(
|
||||
@@ -3067,18 +2599,8 @@ async fn model_context_window_scales_executor_and_cloud_catalogs() -> TestResult
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
let providers = SkillProviders::new()
|
||||
.with_cloud_provider(Arc::new(StaticSkillProvider {
|
||||
catalog: SkillCatalog {
|
||||
is_partial: false,
|
||||
entries: cloud_entries,
|
||||
warnings: Vec::new(),
|
||||
},
|
||||
read_requests: Arc::new(Mutex::new(Vec::new())),
|
||||
list_calls: None,
|
||||
fail_first_list: false,
|
||||
}))
|
||||
.with_executor_provider(Arc::new(StaticSkillProvider {
|
||||
let providers =
|
||||
SkillProviders::new().with_executor_provider(Arc::new(StaticSkillProvider {
|
||||
catalog: SkillCatalog {
|
||||
is_partial: false,
|
||||
entries: executor_entries,
|
||||
@@ -3167,29 +2689,14 @@ async fn model_context_window_scales_executor_and_cloud_catalogs() -> TestResult
|
||||
executor_section.render_diff(PreviousWorldStateSection::Absent);
|
||||
let snapshot = snapshot.unwrap();
|
||||
let executor_fragment = executor_fragment.ok_or("bounded executor catalog should render")?;
|
||||
assert!(
|
||||
!executor_fragment
|
||||
.body()
|
||||
.clone()
|
||||
.expect_text()
|
||||
.contains("skill-39")
|
||||
);
|
||||
let cloud_fragment = world_state_section(§ions, "cloud_skills")
|
||||
.render_diff(PreviousWorldStateSection::Absent)
|
||||
.1
|
||||
.ok_or("bounded cloud catalog should render")?;
|
||||
assert!(
|
||||
cloud_fragment
|
||||
.body()
|
||||
.clone()
|
||||
.expect_text()
|
||||
.contains("additional skills omitted")
|
||||
);
|
||||
let executor_body = executor_fragment.body().clone().expect_text();
|
||||
assert!(!executor_body.contains("skill-199"));
|
||||
assert!(executor_body.contains("additional skills omitted"));
|
||||
let warnings = event_rx
|
||||
.try_iter()
|
||||
.map(CapturedExtensionEvent::into_warning)
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(warnings.len(), 2);
|
||||
assert_eq!(warnings.len(), 1);
|
||||
for warning in warnings {
|
||||
assert_eq!(warning.thread_id, thread_store.level_id());
|
||||
assert_eq!(warning.turn_id.as_deref(), Some("turn-1"));
|
||||
@@ -3663,7 +3170,7 @@ impl SkillProvider for StaticSkillProvider {
|
||||
let catalog = self.catalog.clone();
|
||||
Box::pin(async move {
|
||||
if fail {
|
||||
Err(SkillProviderError::new("temporary cloud failure"))
|
||||
Err(SkillProviderError::new("temporary provider failure"))
|
||||
} else {
|
||||
Ok(catalog)
|
||||
}
|
||||
@@ -3719,7 +3226,6 @@ struct TestConfig {
|
||||
catalog_deltas_enabled: bool,
|
||||
omit_descriptions: bool,
|
||||
bundled_skills_enabled: bool,
|
||||
cloud_skill_enabled: bool,
|
||||
shadow_selection_enabled: bool,
|
||||
}
|
||||
|
||||
@@ -3729,7 +3235,6 @@ fn default_config() -> TestConfig {
|
||||
catalog_deltas_enabled: false,
|
||||
omit_descriptions: false,
|
||||
bundled_skills_enabled: true,
|
||||
cloud_skill_enabled: true,
|
||||
shadow_selection_enabled: false,
|
||||
}
|
||||
}
|
||||
@@ -3741,7 +3246,6 @@ fn skills_extension_config(config: &TestConfig) -> SkillsExtensionConfig {
|
||||
omit_descriptions: config.omit_descriptions,
|
||||
max_context_tokens: None,
|
||||
bundled_skills_enabled: config.bundled_skills_enabled,
|
||||
cloud_skill_enabled: config.cloud_skill_enabled,
|
||||
shadow_selection_enabled: config.shadow_selection_enabled,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,6 @@ async fn skill_sources_spend_the_same_remaining_budget() -> TestResult {
|
||||
render_catalogs(&[("notes", "Edited description.")], &enabled, &mut previous).await?;
|
||||
assert!(emitted.contains("description shown above"), "{emitted}");
|
||||
assert!(!emitted.contains("- executor-notes:"), "{emitted}");
|
||||
assert!(!emitted.contains("- cloud-notes:"), "{emitted}");
|
||||
assert!(!emitted.contains("- host-notes:"), "{emitted}");
|
||||
assert_eq!(
|
||||
render_catalogs(&[("notes", "Edited description.")], &enabled, &mut previous).await?,
|
||||
@@ -277,7 +276,6 @@ async fn render_catalogs_for_step(
|
||||
};
|
||||
let providers = SkillProviders::new()
|
||||
.with_executor_provider(provider(SkillSourceKind::Executor)?)
|
||||
.with_cloud_provider(provider(SkillSourceKind::Cloud)?)
|
||||
.with_host_provider(provider(SkillSourceKind::Host)?);
|
||||
let mut builder = ExtensionRegistryBuilder::new();
|
||||
install_with_providers(&mut builder, providers, skills_extension_config);
|
||||
|
||||
@@ -10,7 +10,6 @@ use codex_skills::SkillDependencies;
|
||||
use codex_skills::SkillPolicy;
|
||||
use codex_skills::SkillToolDependency;
|
||||
use codex_skills_extension::ExecutorSkillProvider;
|
||||
use codex_skills_extension::merge_catalogs;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
fn installation(
|
||||
@@ -22,7 +21,6 @@ fn installation(
|
||||
plugins: vec![ExecutorPlugin {
|
||||
id: "local-name@marketplace".to_string(),
|
||||
display_name: "Local plugin".to_string(),
|
||||
remote_plugin_id: Some("Plugin_123".to_string()),
|
||||
version: "1".to_string(),
|
||||
root: PathUri::parse("file:///plugins/local-name/1")?,
|
||||
files: DiscoveredPluginFiles {
|
||||
@@ -95,7 +93,6 @@ async fn v2_steps_refresh_metadata_and_preserve_separate_environments() -> TestR
|
||||
host_snapshot: None,
|
||||
include_host_skills: false,
|
||||
include_bundled_skills: false,
|
||||
include_cloud_skills: false,
|
||||
mcp_resources: None,
|
||||
executor_capability_discovery: None,
|
||||
executor_capability_discovery_v2: Some(snapshots.clone()),
|
||||
@@ -121,8 +118,7 @@ async fn v2_steps_refresh_metadata_and_preserve_separate_environments() -> TestR
|
||||
);
|
||||
let catalog = provider.list(query).await?;
|
||||
assert_eq!(catalog.entries.len(), 4);
|
||||
let merged = merge_catalogs(/*cloud*/ None, catalog.clone());
|
||||
assert_eq!(merged, catalog);
|
||||
let merged = catalog;
|
||||
for entries in [
|
||||
(&merged.entries[0], &merged.entries[2]),
|
||||
(&merged.entries[1], &merged.entries[3]),
|
||||
@@ -306,7 +302,6 @@ async fn v2_empty_failed_and_partial_results_never_load_legacy_roots() -> TestRe
|
||||
host_snapshot: None,
|
||||
include_host_skills: false,
|
||||
include_bundled_skills: false,
|
||||
include_cloud_skills: false,
|
||||
mcp_resources: None,
|
||||
executor_capability_discovery: None,
|
||||
executor_capability_discovery_v2: Some(snapshots),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,25 +6,24 @@ use pretty_assertions::assert_eq;
|
||||
#[tokio::test]
|
||||
async fn skill_names_preserve_package_and_alias_precedence_in_both_versions() -> TestResult {
|
||||
for discovery_v2 in [false, true] {
|
||||
let cloud = cloud_skill("work").with_alias_root("skill://Plugin_123");
|
||||
let mut hidden = cloud_skill("hidden").hidden_from_prompt();
|
||||
hidden.name = cloud.name.clone();
|
||||
let mut disabled = cloud_skill("disabled").disabled();
|
||||
disabled.name = cloud.name.clone();
|
||||
let skill = executor_skill("work").with_alias_root("skill://Plugin_123");
|
||||
let mut hidden = executor_skill("hidden").hidden_from_prompt();
|
||||
hidden.name = skill.name.clone();
|
||||
let mut disabled = executor_skill("disabled").disabled();
|
||||
disabled.name = skill.name.clone();
|
||||
let disabled_package = disabled.id.0.clone();
|
||||
let mut entries = vec![cloud.clone(), hidden, disabled];
|
||||
let mut entries = vec![skill.clone(), hidden, disabled];
|
||||
for (id, name) in [
|
||||
("package-shadow", cloud.id.0.as_str()),
|
||||
("alias-shadow", "c0/work"),
|
||||
("package-shadow", skill.id.0.as_str()),
|
||||
("alias-shadow", "e0/work"),
|
||||
("disabled-package-shadow", disabled_package.as_str()),
|
||||
("disabled-alias-shadow", "c0/disabled"),
|
||||
("disabled-alias-shadow", "e0/disabled"),
|
||||
] {
|
||||
let mut shadow = cloud_skill(id);
|
||||
let mut shadow = executor_skill(id);
|
||||
shadow.name = name.to_string();
|
||||
entries.push(shadow);
|
||||
}
|
||||
let mut harness =
|
||||
MergeHarness::new(provider(vec![]), provider(entries), default_config()).await?;
|
||||
let mut harness = MergeHarness::new(provider(entries), default_config()).await?;
|
||||
if !discovery_v2 {
|
||||
harness.snapshots = None;
|
||||
}
|
||||
@@ -35,8 +34,8 @@ async fn skill_names_preserve_package_and_alias_precedence_in_both_versions() ->
|
||||
} else {
|
||||
vec!["read"]
|
||||
} {
|
||||
let expected = call_tool(&tools, tool, json!({"package": cloud.id.0})).await?;
|
||||
for package in [cloud.name.as_str(), "c0/work"] {
|
||||
let expected = call_tool(&tools, tool, json!({"package": skill.id.0})).await?;
|
||||
for package in [skill.name.as_str(), "e0/work"] {
|
||||
assert_eq!(
|
||||
call_tool(&tools, tool, json!({"package": package})).await?,
|
||||
expected,
|
||||
@@ -44,9 +43,9 @@ async fn skill_names_preserve_package_and_alias_precedence_in_both_versions() ->
|
||||
);
|
||||
}
|
||||
if tool == "read" {
|
||||
assert_eq!(expected["resource"], cloud.main_prompt.as_str());
|
||||
assert_eq!(expected["resource"], skill.main_prompt.as_str());
|
||||
}
|
||||
for package in [disabled_package.as_str(), "c0/disabled"] {
|
||||
for package in [disabled_package.as_str(), "e0/disabled"] {
|
||||
assert_eq!(
|
||||
call_tool(&tools, tool, json!({"package": package})).await,
|
||||
Err(FunctionCallError::RespondToModel(
|
||||
@@ -59,63 +58,18 @@ async fn skill_names_preserve_package_and_alias_precedence_in_both_versions() ->
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn listed_skill_names_preserve_merged_locations_and_source_filters() -> TestResult {
|
||||
let mut cloud = cloud_skill("work");
|
||||
let mut executor = installed_skill("first", "work")?;
|
||||
// A valid qualified name can exceed the byte limit in skills.list.
|
||||
cloud.name = format!("x:{}", "🦀".repeat(64));
|
||||
executor.name.clone_from(&cloud.name);
|
||||
let harness = MergeHarness::new(
|
||||
provider(vec![executor]),
|
||||
provider(vec![cloud.clone()]),
|
||||
default_config(),
|
||||
)
|
||||
.await?;
|
||||
harness
|
||||
.turn_store
|
||||
.insert(selected_plugins(&[None, Some("env-1:first")], &[]));
|
||||
let tools = harness.tools(&harness.step_store).await;
|
||||
let listed = call_tool(&tools, "list", json!({"authority": {"kind": "cloud"}})).await?;
|
||||
for tool in ["read", "installations"] {
|
||||
for source in [
|
||||
Value::Null,
|
||||
json!({"kind": "cloud"}),
|
||||
json!({"kind": "executor", "environment_id": "env-1"}),
|
||||
] {
|
||||
assert_eq!(
|
||||
call_tool(
|
||||
&tools,
|
||||
tool,
|
||||
json!({"package": listed["skills"][0]["name"], "source": source})
|
||||
)
|
||||
.await?,
|
||||
call_tool(
|
||||
&tools,
|
||||
tool,
|
||||
json!({"package": cloud.id.0, "source": source})
|
||||
)
|
||||
.await?,
|
||||
"{tool}: {source}",
|
||||
);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn ambiguous_skill_names_require_a_package_locator() -> TestResult {
|
||||
let prefix = format!("x:{}", "🦀".repeat(63));
|
||||
let mut first = cloud_skill("work");
|
||||
let mut first = executor_skill("work");
|
||||
first.name = format!("{prefix}🦀");
|
||||
let mut second = cloud_skill("another");
|
||||
let mut second = executor_skill("another");
|
||||
second.name = first.name.clone();
|
||||
let mut shorter = cloud_skill("shorter");
|
||||
let mut shorter = executor_skill("shorter");
|
||||
shorter.name = prefix.clone();
|
||||
let hidden = cloud_skill("hidden").hidden_from_prompt();
|
||||
let disabled = cloud_skill("disabled").disabled();
|
||||
let hidden = executor_skill("hidden").hidden_from_prompt();
|
||||
let disabled = executor_skill("disabled").disabled();
|
||||
let harness = MergeHarness::new(
|
||||
provider(vec![]),
|
||||
provider(vec![first.clone(), second, shorter, hidden, disabled]),
|
||||
default_config(),
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@ use tokio::sync::Notify;
|
||||
struct PausedExecutor {
|
||||
entered: Notify,
|
||||
resume: Notify,
|
||||
queries: Mutex<Vec<(bool, bool)>>,
|
||||
queries: Mutex<Vec<bool>>,
|
||||
}
|
||||
|
||||
impl SkillProvider for PausedExecutor {
|
||||
@@ -16,7 +16,7 @@ impl SkillProvider for PausedExecutor {
|
||||
self.queries
|
||||
.lock()
|
||||
.unwrap_or_else(std::sync::PoisonError::into_inner)
|
||||
.push((query.include_bundled_skills, query.include_cloud_skills));
|
||||
.push(query.include_bundled_skills);
|
||||
self.entered.notify_one();
|
||||
self.resume.notified().await;
|
||||
Ok(SkillCatalog::default())
|
||||
@@ -36,31 +36,13 @@ impl SkillProvider for PausedExecutor {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn config_reload_during_preparation_applies_to_next_step_but_reads_still_check_live_policy()
|
||||
-> TestResult {
|
||||
async fn config_reload_during_preparation_applies_to_next_step() -> TestResult {
|
||||
let executor = Arc::new(PausedExecutor {
|
||||
entered: Notify::new(),
|
||||
resume: Notify::new(),
|
||||
queries: Mutex::default(),
|
||||
});
|
||||
let cloud = test_entry(
|
||||
SkillSourceKind::Cloud,
|
||||
"codex_apps",
|
||||
"cloud/demo",
|
||||
"skill://cloud/demo/SKILL.md",
|
||||
);
|
||||
let cloud_reads = Arc::default();
|
||||
let providers = SkillProviders::new()
|
||||
.with_executor_provider(executor.clone())
|
||||
.with_cloud_provider(Arc::new(StaticSkillProvider {
|
||||
catalog: SkillCatalog {
|
||||
entries: vec![cloud],
|
||||
..Default::default()
|
||||
},
|
||||
read_requests: Arc::clone(&cloud_reads),
|
||||
list_calls: None,
|
||||
fail_first_list: false,
|
||||
}));
|
||||
let providers = SkillProviders::new().with_executor_provider(executor.clone());
|
||||
let mut builder = ExtensionRegistryBuilder::new();
|
||||
install_with_providers(&mut builder, providers, skills_extension_config);
|
||||
let registry = builder.build();
|
||||
@@ -69,7 +51,6 @@ async fn config_reload_during_preparation_applies_to_next_step_but_reads_still_c
|
||||
let turn = ExtensionData::new("turn");
|
||||
let config = default_config();
|
||||
let updated = TestConfig {
|
||||
cloud_skill_enabled: false,
|
||||
bundled_skills_enabled: false,
|
||||
..config.clone()
|
||||
};
|
||||
@@ -96,8 +77,8 @@ async fn config_reload_during_preparation_applies_to_next_step_but_reads_still_c
|
||||
let step = ExtensionData::new("step");
|
||||
let next_step = ExtensionData::new("next-step");
|
||||
let model_info = catalog_model_info();
|
||||
for (store, expected_enabled) in [(&step, true), (&next_step, false)] {
|
||||
let (sections, ()) = tokio::join!(
|
||||
for store in [&step, &next_step] {
|
||||
let (_sections, ()) = tokio::join!(
|
||||
prepared_world_state(
|
||||
®istry,
|
||||
&roots,
|
||||
@@ -121,30 +102,10 @@ async fn config_reload_during_preparation_applies_to_next_step_but_reads_still_c
|
||||
executor.resume.notify_one();
|
||||
}
|
||||
);
|
||||
let rendered = sections
|
||||
.iter()
|
||||
.filter_map(|section| section.render_diff(PreviousWorldStateSection::Absent).1)
|
||||
.map(|fragment| fragment.body().clone().expect_text())
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
assert_eq!(
|
||||
rendered.contains("cloud/demo"),
|
||||
expected_enabled,
|
||||
"{rendered}"
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
*executor.queries.lock().unwrap(),
|
||||
vec![(true, true), (false, false)]
|
||||
vec![true, false]
|
||||
);
|
||||
let tools = registry.tool_contributors()[0].tools_for_step(&session, &thread, &step);
|
||||
let result = merge_catalog_tests::call_tool(
|
||||
&tools,
|
||||
"read",
|
||||
serde_json::json!({"package": "cloud/demo"}),
|
||||
)
|
||||
.await;
|
||||
assert_matches!(result, Err(FunctionCallError::RespondToModel(message)) if message == "failed to read skill resource");
|
||||
assert!(read_request_keys(&cloud_reads).is_empty());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,267 +0,0 @@
|
||||
//! Pre-budget deduplication preserves source packages and aliases across executor readiness changes.
|
||||
|
||||
use super::*;
|
||||
use codex_exec_server::EnvironmentManager;
|
||||
use codex_extension_api::ToolEnvironment;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[tokio::test]
|
||||
async fn cloud_preference_preserves_aliases_reads_and_executor_fallback() -> TestResult {
|
||||
for (cloud_enabled, all_overlap) in [(true, false), (false, false), (true, true)] {
|
||||
let description = format!("{} UNIQUE_DESCRIPTION_END", "Skill guidance. ".repeat(60));
|
||||
let executor_roots = [
|
||||
format!("skill://executor-a/{}", "a".repeat(180)),
|
||||
format!("skill://executor-b/{}", "b".repeat(180)),
|
||||
];
|
||||
let mut executor_entries = Vec::new();
|
||||
for (plugin, root) in ["demo", "other"].into_iter().zip(&executor_roots) {
|
||||
for index in 0..3 {
|
||||
let package = format!("{root}/s{index}");
|
||||
let mut entry = test_entry(
|
||||
SkillSourceKind::Executor,
|
||||
"skills",
|
||||
&package,
|
||||
&format!("{package}/SKILL.md"),
|
||||
);
|
||||
entry.name = format!("{plugin}:s{index}");
|
||||
entry.description = description.clone();
|
||||
entry.main_prompt = SkillResourceId::environment(
|
||||
format!("{package}/SKILL.md"),
|
||||
"local",
|
||||
PathUri::parse(&format!("file:///skills/{plugin}/s{index}/SKILL.md"))?,
|
||||
);
|
||||
executor_entries.push(entry.with_alias_root(root));
|
||||
}
|
||||
}
|
||||
let mut cloud_entries = Vec::new();
|
||||
for plugin in if all_overlap {
|
||||
vec!["demo", "other"]
|
||||
} else {
|
||||
vec!["demo"]
|
||||
} {
|
||||
for index in 0..3 {
|
||||
let mut entry = test_entry(
|
||||
SkillSourceKind::Cloud,
|
||||
"codex_apps",
|
||||
&format!("cloud/{plugin}/s{index}"),
|
||||
&format!("cloud/{plugin}/s{index}/SKILL.md"),
|
||||
);
|
||||
entry.name = format!("{plugin}:s{index}");
|
||||
cloud_entries.push(entry);
|
||||
}
|
||||
}
|
||||
let provider = |entries| {
|
||||
Arc::new(StaticSkillProvider {
|
||||
catalog: SkillCatalog {
|
||||
is_partial: false,
|
||||
entries,
|
||||
warnings: Vec::new(),
|
||||
},
|
||||
read_requests: Arc::new(Mutex::new(Vec::new())),
|
||||
list_calls: None,
|
||||
fail_first_list: false,
|
||||
})
|
||||
};
|
||||
let providers = SkillProviders::new()
|
||||
.with_executor_provider(provider(executor_entries.clone()))
|
||||
.with_cloud_provider(provider(cloud_entries));
|
||||
let mut builder = ExtensionRegistryBuilder::new();
|
||||
install_with_providers(&mut builder, providers, skills_extension_config);
|
||||
let registry = builder.build();
|
||||
let session_store = ExtensionData::new("session");
|
||||
let thread_store = ExtensionData::new("thread");
|
||||
let config = TestConfig {
|
||||
cloud_skill_enabled: cloud_enabled,
|
||||
..default_config()
|
||||
};
|
||||
registry.thread_lifecycle_contributors()[0]
|
||||
.on_thread_start(ThreadStartInput {
|
||||
config: &config,
|
||||
session_source: &SessionSource::Cli,
|
||||
persistent_thread_state_available: true,
|
||||
environments: &[],
|
||||
mcp_resource_client: None,
|
||||
extension_metrics: None,
|
||||
session_store: &session_store,
|
||||
thread_store: &thread_store,
|
||||
})
|
||||
.await;
|
||||
let roots = [SelectedCapabilityRoot {
|
||||
id: "skills".to_string(),
|
||||
location: CapabilityRootLocation::Environment {
|
||||
environment_id: "local".to_string(),
|
||||
path: PathUri::parse("file:///skills")?,
|
||||
},
|
||||
}];
|
||||
let resolved_roots = EnvironmentManager::default_for_tests()
|
||||
.resolve_selected_capability_roots(&roots, &Default::default())
|
||||
.await;
|
||||
assert_eq!(resolved_roots.len(), 1);
|
||||
let access = FileSystemEnvironmentAccessor::unrestricted(&LOCAL_FS);
|
||||
let mut previous = serde_json::Map::new();
|
||||
let mut initial_cloud_body = None;
|
||||
let model_info = ModelInfo {
|
||||
context_window: Some(70_000),
|
||||
..catalog_model_info()
|
||||
};
|
||||
for (stage, ready) in [
|
||||
("before", false),
|
||||
("connected", true),
|
||||
("disconnected", false),
|
||||
] {
|
||||
start_registered_turn(®istry, &session_store, &thread_store, stage).await;
|
||||
let turn_store = ExtensionData::new(stage);
|
||||
let sections = prepared_world_state(
|
||||
®istry,
|
||||
if ready { &roots } else { &[] },
|
||||
WorldStateContributionInput {
|
||||
previous_world_state: Some(&previous),
|
||||
model_info: &model_info,
|
||||
thread_id: codex_protocol::ThreadId::new(),
|
||||
turn_id: stage,
|
||||
environments: &[],
|
||||
|
||||
extension_metrics: None,
|
||||
session_store: &session_store,
|
||||
thread_store: &thread_store,
|
||||
turn_store: &turn_store,
|
||||
step_store: &turn_store,
|
||||
},
|
||||
)
|
||||
.await;
|
||||
let snapshots: serde_json::Map<String, serde_json::Value> = sections
|
||||
.iter()
|
||||
.map(|section| {
|
||||
let previous = previous.get(section.id()).map_or(
|
||||
PreviousWorldStateSection::Absent,
|
||||
PreviousWorldStateSection::Known,
|
||||
);
|
||||
let snapshot = section.render_diff(previous).0.expect("skills snapshot");
|
||||
(section.id().to_string(), snapshot)
|
||||
})
|
||||
.collect();
|
||||
let executor_body = snapshots["skills"]["body"]
|
||||
.as_str()
|
||||
.unwrap_or_default()
|
||||
.to_string();
|
||||
let cloud_body = snapshots["cloud_skills"]["body"]
|
||||
.as_str()
|
||||
.unwrap_or_default()
|
||||
.to_string();
|
||||
for index in 0..3 {
|
||||
let listing = format!("- demo:s{index}:");
|
||||
assert_eq!(executor_body.contains(&listing), ready && !cloud_enabled);
|
||||
assert_eq!(cloud_body.contains(&listing), cloud_enabled);
|
||||
assert_eq!(
|
||||
executor_body.contains(&format!("- other:s{index}:")),
|
||||
ready && !all_overlap
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
executor_body.matches("UNIQUE_DESCRIPTION_END").count(),
|
||||
if ready && cloud_enabled && !all_overlap {
|
||||
3
|
||||
} else {
|
||||
0
|
||||
}
|
||||
);
|
||||
if stage == "before" {
|
||||
initial_cloud_body = Some(cloud_body.clone());
|
||||
} else {
|
||||
assert_eq!(Some(&cloud_body), initial_cloud_body.as_ref());
|
||||
}
|
||||
if !ready || all_overlap {
|
||||
assert!(executor_body.is_empty());
|
||||
} else {
|
||||
assert!(executor_body.contains("(executor package: e1/s0)"));
|
||||
for (index, root) in executor_roots.iter().enumerate() {
|
||||
assert_eq!(
|
||||
executor_body.contains(&format!("- `e{index}` = `{root}`")),
|
||||
index == 1 || !cloud_enabled,
|
||||
);
|
||||
}
|
||||
}
|
||||
previous = snapshots;
|
||||
if !ready {
|
||||
continue;
|
||||
}
|
||||
turn_store.insert(resolved_roots.clone());
|
||||
let tools = registry.tool_contributors()[0].tools_for_step(
|
||||
&session_store,
|
||||
&thread_store,
|
||||
&turn_store,
|
||||
);
|
||||
for (name, arguments, expected_resource) in [
|
||||
(
|
||||
"list",
|
||||
serde_json::json!({"authority": {"kind": "executor"}}),
|
||||
None,
|
||||
),
|
||||
(
|
||||
"read",
|
||||
serde_json::json!({"package": "e0/s0"}),
|
||||
Some(executor_entries[0].main_prompt.as_str()),
|
||||
),
|
||||
(
|
||||
"read",
|
||||
serde_json::json!({"package": "e1/s0"}),
|
||||
Some(executor_entries[3].main_prompt.as_str()),
|
||||
),
|
||||
(
|
||||
"read",
|
||||
serde_json::json!({"package": executor_entries[0].id.0}),
|
||||
Some(executor_entries[0].main_prompt.as_str()),
|
||||
),
|
||||
] {
|
||||
let tool = tools
|
||||
.iter()
|
||||
.find(|tool| tool.tool_name().name == name)
|
||||
.ok_or("missing tool")?;
|
||||
let payload = ToolPayload::Function {
|
||||
arguments: arguments.to_string(),
|
||||
};
|
||||
let output = tool
|
||||
.handle(ToolCall {
|
||||
turn_id: stage.to_string(),
|
||||
call_id: "call".to_string(),
|
||||
tool_name: tool.tool_name(),
|
||||
model: "test".to_string(),
|
||||
codex_turn_metadata: None,
|
||||
truncation_policy: TruncationPolicy::Bytes(20_000),
|
||||
source: ToolCallSource::Direct,
|
||||
conversation_history: ConversationHistory::default(),
|
||||
turn_item_emitter: Arc::new(NoopTurnItemEmitter),
|
||||
attachment_store: Arc::new(InlineAttachmentStore),
|
||||
ephemeral: false,
|
||||
environments: vec![ToolEnvironment::new(
|
||||
"local".to_string(),
|
||||
PathUri::parse("file:///skills")?,
|
||||
&access,
|
||||
)],
|
||||
payload: payload.clone(),
|
||||
})
|
||||
.await?;
|
||||
let response = output
|
||||
.post_tool_use_response("call", &payload)
|
||||
.ok_or("missing response")?;
|
||||
if let Some(resource) = expected_resource {
|
||||
assert_eq!(response["resource"], resource);
|
||||
} else {
|
||||
assert_eq!(
|
||||
response["skills"]
|
||||
.as_array()
|
||||
.ok_or("missing skills")?
|
||||
.iter()
|
||||
.map(|skill| skill["package"].as_str())
|
||||
.collect::<Vec<_>>(),
|
||||
executor_entries
|
||||
.iter()
|
||||
.map(|entry| Some(entry.id.0.as_str()))
|
||||
.collect::<Vec<_>>()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -43,14 +43,11 @@ impl<S: tracing::Subscriber> Layer<S> for ReadEvents {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn source_events_cover_cached_cloud_and_explicit_executor_reads() -> TestResult {
|
||||
let cloud = cloud_skill("work").with_plugin_id(Some("cloud-plugin".into()));
|
||||
async fn source_events_cover_default_and_explicit_executor_reads() -> TestResult {
|
||||
let installed = installed_skill("matching", "work")?;
|
||||
let cloud_provider = provider(vec![cloud.clone()]);
|
||||
let cloud_reads = cloud_provider.read_requests.clone();
|
||||
let executor = provider(vec![installed]);
|
||||
let executor = provider(vec![installed.clone()]);
|
||||
let executor_reads = executor.read_requests.clone();
|
||||
let harness = MergeHarness::new(executor, cloud_provider, default_config()).await?;
|
||||
let harness = MergeHarness::new(executor, default_config()).await?;
|
||||
harness
|
||||
.turn_store
|
||||
.insert(selected_plugins(&[None, Some("env-1:matching")], &[]));
|
||||
@@ -64,16 +61,14 @@ async fn source_events_cover_cached_cloud_and_explicit_executor_reads() -> TestR
|
||||
let _interest_cache_guard =
|
||||
tracing::Dispatch::new(tracing::subscriber::NoSubscriber::default());
|
||||
async {
|
||||
for source in ["cloud", "cloud", "executor", "executor"] {
|
||||
let selector = if source == "executor" {
|
||||
json!({"kind": source, "environment_id": "env-1"})
|
||||
} else {
|
||||
json!({"kind": source})
|
||||
};
|
||||
for selector in [
|
||||
Value::Null,
|
||||
json!({"kind": "executor", "environment_id": "env-1"}),
|
||||
] {
|
||||
call_tool(
|
||||
&tools,
|
||||
"read",
|
||||
json!({"package": cloud.id.0, "source": selector}),
|
||||
json!({"package": installed.id.0, "source": selector}),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
@@ -87,7 +82,7 @@ async fn source_events_cover_cached_cloud_and_explicit_executor_reads() -> TestR
|
||||
.with_subscriber(subscriber)
|
||||
.await?;
|
||||
|
||||
let expected = ["cloud", "cloud", "executor", "executor"].map(|source| {
|
||||
let expected = [(); 2].map(|()| {
|
||||
json!({
|
||||
"message": "Selected skill read source",
|
||||
"event.name": "codex.skill_read.source_selected",
|
||||
@@ -96,21 +91,14 @@ async fn source_events_cover_cached_cloud_and_explicit_executor_reads() -> TestR
|
||||
"call_id": "skill-test",
|
||||
"tool_namespace": "skills",
|
||||
"tool_name": "read",
|
||||
"skill_source": source,
|
||||
"skill_source": "executor",
|
||||
"skill_name": "deploy:work",
|
||||
"skill_plugin_id": if source == "cloud" { "cloud-plugin" } else { "matching" },
|
||||
"skill_plugin_id": "matching",
|
||||
"skill_resource_kind": "main_prompt",
|
||||
"is_continuation": false,
|
||||
})
|
||||
});
|
||||
assert_eq!(*events.0.lock().unwrap(), expected);
|
||||
// Both cloud reads are attributable even though the second needs no provider call.
|
||||
assert_eq!(
|
||||
(
|
||||
read_request_keys(&cloud_reads).len(),
|
||||
read_request_keys(&executor_reads).len()
|
||||
),
|
||||
(1, 2),
|
||||
);
|
||||
assert_eq!(read_request_keys(&executor_reads).len(), 2);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -38,9 +38,9 @@ async fn reads_report_outcomes_for_each_discovery_version() -> TestResult {
|
||||
PathUri::parse("file:///skills/local/SKILL.md")?,
|
||||
);
|
||||
let mut harness = MergeHarness::new(
|
||||
provider(vec![executor]),
|
||||
provider(vec![
|
||||
cloud_skill("work").with_alias_root("skill://Plugin_123"),
|
||||
executor,
|
||||
executor_skill("work").with_alias_root("skill://Plugin_123"),
|
||||
]),
|
||||
default_config(),
|
||||
)
|
||||
@@ -59,7 +59,7 @@ async fn reads_report_outcomes_for_each_discovery_version() -> TestResult {
|
||||
),
|
||||
(json!({}), 10_000, "invalid_arguments"),
|
||||
(json!({"package": "missing"}), 10_000, "package_unavailable"),
|
||||
(json!({"package": "c99/work"}), 10_000, "unresolved_alias"),
|
||||
(json!({"package": "e99/work"}), 10_000, "unresolved_alias"),
|
||||
(
|
||||
json!({"package": "skill://executor/local"}),
|
||||
10_000,
|
||||
@@ -80,27 +80,10 @@ async fn reads_report_outcomes_for_each_discovery_version() -> TestResult {
|
||||
1,
|
||||
"response_budget",
|
||||
),
|
||||
(
|
||||
json!({"package": "skill://Plugin_123/work"}),
|
||||
10_000,
|
||||
"read_failed",
|
||||
),
|
||||
] {
|
||||
if discovery_version == "v1" && outcome != "success" {
|
||||
continue;
|
||||
}
|
||||
if outcome == "read_failed" {
|
||||
let config = default_config();
|
||||
harness.registry.config_contributors()[0].on_config_changed(
|
||||
&harness.session_store,
|
||||
&harness.thread_store,
|
||||
&config,
|
||||
&TestConfig {
|
||||
cloud_skill_enabled: false,
|
||||
..config.clone()
|
||||
},
|
||||
);
|
||||
}
|
||||
let result =
|
||||
call_tool_with_budget(&tools, "read", arguments, TruncationPolicy::Bytes(budget))
|
||||
.await;
|
||||
@@ -110,7 +93,14 @@ async fn reads_report_outcomes_for_each_discovery_version() -> TestResult {
|
||||
"{outcome}: {result:?}"
|
||||
);
|
||||
expected.push(read_result(outcome, discovery_version));
|
||||
assert_eq!(harness.catalog_metrics.counters(), expected);
|
||||
// Successful executor reads also record skill invocations; compare read outcomes only.
|
||||
let read_counters = harness
|
||||
.catalog_metrics
|
||||
.counters()
|
||||
.into_iter()
|
||||
.filter(|counter| counter.name == "codex.skills.read.result")
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(read_counters, expected);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
@@ -119,9 +109,8 @@ async fn reads_report_outcomes_for_each_discovery_version() -> TestResult {
|
||||
#[tokio::test]
|
||||
async fn installations_report_outcomes_for_each_discovery_version() -> TestResult {
|
||||
let harness = MergeHarness::new(
|
||||
provider(Vec::new()),
|
||||
provider(vec![
|
||||
cloud_skill("work").with_alias_root("skill://Plugin_123"),
|
||||
executor_skill("work").with_alias_root("skill://Plugin_123"),
|
||||
]),
|
||||
default_config(),
|
||||
)
|
||||
@@ -137,13 +126,13 @@ async fn installations_report_outcomes_for_each_discovery_version() -> TestResul
|
||||
"all",
|
||||
),
|
||||
(
|
||||
json!({"package": "c0/work", "source": {"kind": "cloud"}}),
|
||||
json!({"package": "e0/work", "source": {"kind": "executor", "environment_id": "env-1"}}),
|
||||
10_000,
|
||||
"success",
|
||||
"cloud",
|
||||
"executor",
|
||||
),
|
||||
(
|
||||
json!({"package": "c0/work", "source": {"kind": "executor", "environment_id": "missing"}}),
|
||||
json!({"package": "e0/work", "source": {"kind": "executor", "environment_id": "missing"}}),
|
||||
10_000,
|
||||
"empty",
|
||||
"executor",
|
||||
@@ -151,30 +140,30 @@ async fn installations_report_outcomes_for_each_discovery_version() -> TestResul
|
||||
(json!({}), 10_000, "invalid_arguments", "unparsed"),
|
||||
(json!({"package": ""}), 10_000, "invalid_package", "all"),
|
||||
(
|
||||
json!({"package": "c0/work", "source": {"kind": "executor", "environment_id": ""}}),
|
||||
json!({"package": "e0/work", "source": {"kind": "executor", "environment_id": ""}}),
|
||||
10_000,
|
||||
"invalid_source",
|
||||
"executor",
|
||||
),
|
||||
(
|
||||
json!({"package": "c0/missing"}),
|
||||
json!({"package": "e0/missing"}),
|
||||
10_000,
|
||||
"package_unavailable",
|
||||
"all",
|
||||
),
|
||||
(
|
||||
json!({"package": "c99/work"}),
|
||||
json!({"package": "e99/work"}),
|
||||
10_000,
|
||||
"unresolved_alias",
|
||||
"all",
|
||||
),
|
||||
(
|
||||
json!({"package": "c0/work", "cursor": "invalid"}),
|
||||
json!({"package": "e0/work", "cursor": "invalid"}),
|
||||
10_000,
|
||||
"invalid_cursor",
|
||||
"all",
|
||||
),
|
||||
(json!({"package": "c0/work"}), 1, "response_budget", "all"),
|
||||
(json!({"package": "e0/work"}), 1, "response_budget", "all"),
|
||||
] {
|
||||
let result = call_tool_with_budget(
|
||||
&tools,
|
||||
|
||||
Reference in New Issue
Block a user