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:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user