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:
@@ -40,7 +40,6 @@ use codex_extension_api::ExtensionRegistry;
|
||||
use codex_extension_api::ExtensionRegistryBuilder;
|
||||
use codex_features::Feature;
|
||||
use codex_history::RolloutItem;
|
||||
use codex_image_generation_extension::install as install_image_generation_extension;
|
||||
use codex_login::CodexAuth;
|
||||
use codex_models_manager::bundled_models_response;
|
||||
use codex_protocol::capabilities::CapabilityRootLocation;
|
||||
@@ -56,7 +55,6 @@ use codex_protocol::models::ImageDetail;
|
||||
use codex_protocol::models::ImageReference;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
use codex_protocol::openai_models::CodeModeToolMessages;
|
||||
use codex_protocol::openai_models::InputModality;
|
||||
use codex_protocol::openai_models::ReasoningEffort;
|
||||
use codex_protocol::openai_models::ToolMessage;
|
||||
use codex_protocol::openai_models::ToolMode;
|
||||
@@ -67,7 +65,6 @@ use codex_protocol::protocol::EventMsg;
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
use codex_protocol::protocol::MultiAgentVersion;
|
||||
use codex_protocol::protocol::Op;
|
||||
use codex_protocol::protocol::TurnEnvironmentSelection;
|
||||
use codex_protocol::protocol::TurnSettingsUpdate;
|
||||
use codex_protocol::protocol::TurnSettingsUpdateOutcome;
|
||||
use codex_protocol::request_user_input::RequestUserInputAnswer;
|
||||
@@ -189,21 +186,12 @@ mod guardian_extra_policy;
|
||||
#[path = "scenarios_guardian_reconsideration.rs"]
|
||||
mod guardian_reconsideration;
|
||||
|
||||
#[path = "scenarios_guardian_orchestrator_connector.rs"]
|
||||
mod guardian_orchestrator_connector;
|
||||
|
||||
#[path = "scenarios_guardian_conversation_history_tests.rs"]
|
||||
mod guardian_conversation_history;
|
||||
|
||||
#[path = "scenarios_indirect_namespace_prefixes.rs"]
|
||||
mod indirect_namespace_prefixes;
|
||||
|
||||
#[path = "scenarios_mcp_resource_messages.rs"]
|
||||
mod mcp_resource_messages;
|
||||
|
||||
#[path = "scenarios_mcp_ema.rs"]
|
||||
mod mcp_ema;
|
||||
|
||||
#[path = "scenarios_mcp_sharing.rs"]
|
||||
mod mcp_sharing;
|
||||
|
||||
@@ -245,9 +233,6 @@ mod tools_namespace_budget;
|
||||
#[path = "scenarios_skill_catalog_dedup.rs"]
|
||||
mod skill_catalog_dedup;
|
||||
|
||||
#[path = "scenarios_frozen_cloud_skills.rs"]
|
||||
mod frozen_cloud_skills;
|
||||
|
||||
#[path = "scenarios_compaction_tests.rs"]
|
||||
mod compaction;
|
||||
|
||||
@@ -267,7 +252,6 @@ fn skills_extensions() -> Arc<ExtensionRegistry<Config>> {
|
||||
.enabled(codex_features::Feature::OmitSkillDescriptions),
|
||||
max_context_tokens: config.skill_max_context_tokens,
|
||||
bundled_skills_enabled: config.bundled_skills_enabled(),
|
||||
cloud_skill_enabled: config.cloud_skill_enabled,
|
||||
shadow_selection_enabled: config.features.enabled(Feature::SkillSearch),
|
||||
});
|
||||
Arc::new(extensions.build())
|
||||
@@ -371,10 +355,8 @@ pub(super) fn configure_scenario_catalog(config: &mut Config) {
|
||||
stack.requirements().clone(),
|
||||
stack.requirements_toml().clone(),
|
||||
)
|
||||
.expect("fixture config layers")
|
||||
.with_cloud_config_binding(stack.cloud_config_binding().cloned());
|
||||
.expect("fixture config layers");
|
||||
config.model_catalog = Some(bundled_models_response().expect("bundled model catalog"));
|
||||
config.cloud_skill_enabled = false;
|
||||
}
|
||||
|
||||
fn configure_catalog_plugin_scenario(config: &mut Config) {
|
||||
@@ -394,116 +376,7 @@ fn configure_catalog_plugin_scenario(config: &mut Config) {
|
||||
stack.requirements().clone(),
|
||||
stack.requirements_toml().clone(),
|
||||
)
|
||||
.expect("isolated plugin scenario config")
|
||||
.with_cloud_config_binding(stack.cloud_config_binding().cloned());
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn gif_generation_preserves_animation_and_replays_a_still_preview() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
// Two one-pixel frames, red then blue, with a 200 ms frame duration.
|
||||
let gif = "R0lGODlhAQABAIEAAP8AAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQAFAAAACwAAAAAAQABAAAIBAABBAQAIfkEARQAAQAsAAAAAAEAAQCBAAD/AAAAAAAAAAAACAQAAQQEADs=";
|
||||
let server = start_mock_server().await;
|
||||
wiremock::Mock::given(wiremock::matchers::method("POST"))
|
||||
.and(wiremock::matchers::path("/v1/images/generations"))
|
||||
.and(wiremock::matchers::body_json(json!({
|
||||
"prompt": "A pixel alternating between red and blue.",
|
||||
"background": "opaque",
|
||||
"model": "gpt-image-2",
|
||||
"quality": "auto",
|
||||
"size": "auto",
|
||||
"output_format": "gif",
|
||||
"frame_count": 2,
|
||||
"frame_duration_ms": 200,
|
||||
})))
|
||||
.respond_with(wiremock::ResponseTemplate::new(200).set_body_json(json!({
|
||||
"created": 1,
|
||||
"data": [{"b64_json": gif}],
|
||||
})))
|
||||
.expect(1)
|
||||
.mount(&server)
|
||||
.await;
|
||||
|
||||
let auth = CodexAuth::from_api_key("Test API Key");
|
||||
let mut extensions = ExtensionRegistryBuilder::<Config>::new();
|
||||
install_image_generation_extension(
|
||||
&mut extensions,
|
||||
codex_core::test_support::auth_manager_from_auth(auth.clone()),
|
||||
|_config| None,
|
||||
);
|
||||
let image_store = Arc::new(RecordingFileAttachmentStore::default());
|
||||
let test = test_codex()
|
||||
.with_auth(auth)
|
||||
.with_extensions(Arc::new(extensions.build()))
|
||||
.with_image_store(image_store.clone())
|
||||
.with_config(|config| {
|
||||
configure_scenario_catalog(config);
|
||||
config
|
||||
.features
|
||||
.enable(Feature::ImageGenerationAnimation)
|
||||
.unwrap();
|
||||
})
|
||||
.with_model_info_override("gpt-5.4", |model| {
|
||||
model.use_responses_lite = true;
|
||||
model.input_modalities = vec![InputModality::Text, InputModality::Image];
|
||||
})
|
||||
.build_with_auto_env(&server)
|
||||
.await?;
|
||||
let mock = mount_sse_sequence(
|
||||
&server,
|
||||
vec![
|
||||
sse(vec![
|
||||
ev_function_call_with_namespace(
|
||||
"gif-generation",
|
||||
"image_gen",
|
||||
"imagegen",
|
||||
&json!({
|
||||
"prompt": "A pixel alternating between red and blue.",
|
||||
"gif": {"frame_count": 2, "frame_duration_ms": 200},
|
||||
})
|
||||
.to_string(),
|
||||
),
|
||||
ev_completed("generated"),
|
||||
]),
|
||||
sse(vec![
|
||||
ev_assistant_message("preview", "Here is the two-frame GIF."),
|
||||
ev_completed("previewed"),
|
||||
]),
|
||||
sse(vec![
|
||||
ev_assistant_message("timing", "Each frame lasts 200 ms."),
|
||||
ev_completed("answered"),
|
||||
]),
|
||||
],
|
||||
)
|
||||
.await;
|
||||
test.submit_text_turn("Generate a two-frame GIF of a pixel alternating red and blue.")
|
||||
.await?;
|
||||
test.submit_text_turn("How long does each frame last?")
|
||||
.await?;
|
||||
|
||||
let uploads = image_store.uploads.lock().expect("uploads lock");
|
||||
let [animation, preview] = uploads.as_slice() else {
|
||||
panic!("expected an animated artifact and a separate model preview");
|
||||
};
|
||||
assert_eq!(animation.data, BASE64_STANDARD.decode(gif)?);
|
||||
assert_eq!(image::guess_format(&preview.data)?, image::ImageFormat::Png);
|
||||
assert_eq!(
|
||||
image::load_from_memory(&preview.data)?
|
||||
.to_rgba8()
|
||||
.get_pixel(0, 0)
|
||||
.0,
|
||||
[255, 0, 0, 255]
|
||||
);
|
||||
let requests = mock.requests();
|
||||
assert_eq!(requests.len(), 3);
|
||||
insta::assert_snapshot!(context_snapshot::format_request_history_snapshot(
|
||||
"GIF generation exposes animation controls and guidance, preserves the animated artifact, and replays a still preview through a follow-up turn.",
|
||||
&requests,
|
||||
&ContextSnapshotOptions::default()
|
||||
.rewrite_known_segments()
|
||||
.include_request_settings(),
|
||||
));
|
||||
Ok(())
|
||||
.expect("isolated plugin scenario config");
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
@@ -1360,41 +1233,19 @@ async fn astra_plugin_policy_limits_visible_skills(omit_descriptions: bool) -> R
|
||||
let server = start_mock_server().await;
|
||||
let home = Arc::new(TempDir::new()?);
|
||||
write_scenario_capabilities(&home)?;
|
||||
fs::rename(
|
||||
home.path().join("plugins/cache/test"),
|
||||
home.path().join("plugins/cache/openai-curated-remote"),
|
||||
)?;
|
||||
// Both plugins are installed in the cache, but policy permits only calendar.
|
||||
fs::write(
|
||||
home.path().join("config.toml"),
|
||||
r#"[features]
|
||||
plugins = true
|
||||
remote_plugin = true
|
||||
[skills.bundled]
|
||||
enabled = false
|
||||
[plugins._default]
|
||||
enabled = false
|
||||
[plugins."calendar@openai-curated-remote"]
|
||||
[plugins."calendar@test"]
|
||||
enabled = true
|
||||
"#,
|
||||
)?;
|
||||
let installed_plugins = ["calendar", "notes"].map(|name| json!({
|
||||
"id": format!("plugins~Plugin_{name}"),
|
||||
"name": name,
|
||||
"scope": "GLOBAL",
|
||||
"status": "ENABLED",
|
||||
"installation_policy": "AVAILABLE",
|
||||
"authentication_policy": "ON_USE",
|
||||
"release": { "version": "local", "display_name": name, "description": name, "interface": {} },
|
||||
"enabled": true,
|
||||
}));
|
||||
wiremock::Mock::given(wiremock::matchers::method("GET"))
|
||||
.and(wiremock::matchers::path("/ps/plugins/installed"))
|
||||
.respond_with(wiremock::ResponseTemplate::new(200).set_body_json(json!({
|
||||
"plugins": installed_plugins,
|
||||
"pagination": { "next_page_token": null },
|
||||
})))
|
||||
.mount(&server)
|
||||
.await;
|
||||
let mock = mount_sse_sequence(
|
||||
&server,
|
||||
vec![sse(vec![
|
||||
@@ -1404,7 +1255,6 @@ enabled = true
|
||||
])],
|
||||
)
|
||||
.await;
|
||||
let chatgpt_base_url = server.uri();
|
||||
let test = test_codex()
|
||||
.with_model("gpt-6-astra")
|
||||
.with_home(home)
|
||||
@@ -1416,16 +1266,10 @@ enabled = true
|
||||
.features
|
||||
.set_enabled(Feature::OmitSkillDescriptions, omit_descriptions)
|
||||
.expect("set omit_skill_descriptions feature");
|
||||
config.chatgpt_base_url = chatgpt_base_url;
|
||||
config.workspace_roots = vec![config.cwd.clone()];
|
||||
})
|
||||
.build_with_auto_env(&server)
|
||||
.await?;
|
||||
let auth = test.thread_manager.auth_manager().auth().await;
|
||||
test.thread_manager
|
||||
.plugins_manager()
|
||||
.reconcile_remote_installed_plugins(&test.config.plugins_config_input(), auth.as_ref())
|
||||
.await?;
|
||||
test.submit_turn("Plan a team kickoff. Which planning skills are available?")
|
||||
.await?;
|
||||
|
||||
@@ -1549,7 +1393,6 @@ async fn astra_omits_disabled_executor_and_plugin_skills_from_model_context(
|
||||
.enabled(codex_features::Feature::OmitSkillDescriptions),
|
||||
max_context_tokens: config.skill_max_context_tokens,
|
||||
bundled_skills_enabled: false,
|
||||
cloud_skill_enabled: false,
|
||||
shadow_selection_enabled: false,
|
||||
},
|
||||
);
|
||||
@@ -1656,9 +1499,15 @@ async fn astra_omits_disabled_executor_and_plugin_skills_from_model_context(
|
||||
codex_core::ConfigRefreshOutcome::Published
|
||||
);
|
||||
}
|
||||
// Refresh shared MCP for the new roots (there is no Apps server in this test), then
|
||||
// replace its plugin list before the next step captures it or needs another refresh.
|
||||
let _ = thread.refresh_codex_apps_tools().await;
|
||||
// Refresh shared MCP for the new roots, then replace its plugin list before the next
|
||||
// step captures it or needs another refresh.
|
||||
let _ = thread
|
||||
.mcp_server_status_snapshot(
|
||||
"missing",
|
||||
codex_mcp::McpSnapshotDetail::ToolsAndAuthOnly,
|
||||
/*expected_registration*/ None,
|
||||
)
|
||||
.await;
|
||||
let shared = thread.thread_extension_data();
|
||||
assert_eq!(
|
||||
shared
|
||||
@@ -1917,263 +1766,6 @@ async fn child_completion_wakes_parent_after_final_answer() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn skill_read_recovers_omitted_installation_and_reads_selected_environment() -> Result<()> {
|
||||
use codex_skills_extension::SkillProvider;
|
||||
use codex_skills_extension::catalog::SkillAuthority;
|
||||
use codex_skills_extension::catalog::SkillCatalog;
|
||||
use codex_skills_extension::catalog::SkillCatalogEntry;
|
||||
use codex_skills_extension::catalog::SkillPackageId;
|
||||
use codex_skills_extension::catalog::SkillReadResult;
|
||||
use codex_skills_extension::catalog::SkillResourceId;
|
||||
use codex_skills_extension::catalog::SkillSearchResult;
|
||||
use codex_skills_extension::catalog::SkillSourceKind;
|
||||
use codex_skills_extension::catalog::SkillSourceLocation;
|
||||
use codex_skills_extension::provider::SkillListQuery;
|
||||
use codex_skills_extension::provider::SkillProviderFuture;
|
||||
use codex_skills_extension::provider::SkillReadRequest;
|
||||
use codex_skills_extension::provider::SkillSearchRequest;
|
||||
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
// Supply already-reconciled catalog fixtures; exercise production preparation and reads.
|
||||
struct InstallationSkills(SkillCatalog);
|
||||
impl SkillProvider for InstallationSkills {
|
||||
fn list<'a>(&'a self, _query: SkillListQuery<'a>) -> SkillProviderFuture<'a, SkillCatalog> {
|
||||
Box::pin(async { Ok(self.0.clone()) })
|
||||
}
|
||||
|
||||
fn read<'a>(
|
||||
&'a self,
|
||||
request: SkillReadRequest<'a>,
|
||||
) -> SkillProviderFuture<'a, SkillReadResult> {
|
||||
Box::pin(async move {
|
||||
assert!(
|
||||
self.0
|
||||
.entries
|
||||
.iter()
|
||||
.any(|entry| entry.id == request.package)
|
||||
);
|
||||
Ok(SkillReadResult {
|
||||
resource: request.resource,
|
||||
contents: "# Deployment\nRun scripts/check.py from an available installation."
|
||||
.to_string(),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fn search(
|
||||
&self,
|
||||
_request: SkillSearchRequest,
|
||||
) -> SkillProviderFuture<'_, SkillSearchResult> {
|
||||
Box::pin(async { Ok(SkillSearchResult::default()) })
|
||||
}
|
||||
}
|
||||
|
||||
let executor =
|
||||
core_test_support::exec_server::ExecServerProcess::start_with_version("0.164.0").await?;
|
||||
// Keep byte-budget decisions stable across host temporary-directory lengths.
|
||||
let temp_root = fs::canonicalize(std::env::temp_dir())?;
|
||||
let workspace = tempfile::Builder::new()
|
||||
.rand_bytes(185_usize.saturating_sub(temp_root.to_string_lossy().len()))
|
||||
.tempdir_in(temp_root)?;
|
||||
let workspace_path = fs::canonicalize(workspace.path())?;
|
||||
let deployment_root = workspace_path.join("skills/deploy");
|
||||
fs::create_dir_all(&deployment_root)?;
|
||||
let deployment_path = PathUri::from_host_native_path(&deployment_root)?;
|
||||
let executor_contents = "# Deployment in env-04\nRun scripts/check.py from this installation.";
|
||||
fs::write(deployment_root.join("SKILL.md"), executor_contents)?;
|
||||
|
||||
let mut catalog = SkillCatalog::default();
|
||||
for (name, installation_count) in [("review", 2), ("deploy", 5)] {
|
||||
let package = format!("skill://deployment/{name}");
|
||||
let mut entry = SkillCatalogEntry::new(
|
||||
SkillPackageId(package.clone()),
|
||||
SkillAuthority::new(SkillSourceKind::Cloud, "codex_apps"),
|
||||
name,
|
||||
"Check an installed deployment before proceeding.",
|
||||
SkillResourceId::new(format!("{package}/SKILL.md")),
|
||||
);
|
||||
for index in 0..installation_count {
|
||||
let environment_id = format!("env-{index:02}");
|
||||
let package = format!("skill://executor-{index:02}/{name}");
|
||||
entry.sources.push(SkillSourceLocation {
|
||||
authority: SkillAuthority::new(
|
||||
SkillSourceKind::Executor,
|
||||
format!("executor-{index:02}"),
|
||||
),
|
||||
package: SkillPackageId(package.clone()),
|
||||
main_prompt: SkillResourceId::environment(
|
||||
format!("{package}/SKILL.md"),
|
||||
environment_id,
|
||||
if name == "deploy" && index == 4 {
|
||||
PathUri::from_host_native_path(deployment_root.join("SKILL.md"))?
|
||||
} else {
|
||||
PathUri::parse(&format!("file:///opt/skills/{name}/SKILL.md"))?
|
||||
},
|
||||
),
|
||||
display_path: None,
|
||||
plugin_id: None,
|
||||
enabled: true,
|
||||
alias_root: None,
|
||||
prompt_visible: true,
|
||||
});
|
||||
}
|
||||
catalog.entries.push(entry);
|
||||
}
|
||||
let mut extensions = ExtensionRegistryBuilder::<Config>::new();
|
||||
install_with_providers(
|
||||
&mut extensions,
|
||||
SkillProviders::new()
|
||||
.with_cloud_provider(Arc::new(InstallationSkills(catalog)))
|
||||
.with_executor_provider(Arc::new(
|
||||
ExecutorSkillProvider::new_with_restriction_product(
|
||||
/*restriction_product*/ None,
|
||||
),
|
||||
)),
|
||||
|config: &Config| SkillsExtensionConfig {
|
||||
include_instructions: config.include_skill_instructions,
|
||||
catalog_deltas_enabled: config.features.enabled(Feature::SkillCatalogDeltas),
|
||||
omit_descriptions: config
|
||||
.features
|
||||
.enabled(codex_features::Feature::OmitSkillDescriptions),
|
||||
max_context_tokens: config.skill_max_context_tokens,
|
||||
bundled_skills_enabled: false,
|
||||
cloud_skill_enabled: true,
|
||||
shadow_selection_enabled: false,
|
||||
},
|
||||
);
|
||||
let server = start_mock_server().await;
|
||||
let mock = mount_sse_sequence(
|
||||
&server,
|
||||
vec![
|
||||
sse(vec![
|
||||
ev_function_call_with_namespace(
|
||||
"read-review",
|
||||
"skills",
|
||||
"read",
|
||||
r#"{"package":"skill://executor-00/review","source":{"kind":"cloud"}}"#,
|
||||
),
|
||||
ev_completed("review-response"),
|
||||
]),
|
||||
sse(vec![
|
||||
ev_function_call_with_namespace(
|
||||
"read-deploy",
|
||||
"skills",
|
||||
"read",
|
||||
r#"{"package":"skill://deployment/deploy"}"#,
|
||||
),
|
||||
ev_completed("deploy-response"),
|
||||
]),
|
||||
sse(vec![
|
||||
ev_function_call_with_namespace(
|
||||
"find-deploy",
|
||||
"skills",
|
||||
"installations",
|
||||
r#"{"package":"skill://deployment/deploy"}"#,
|
||||
),
|
||||
ev_completed("installation-response"),
|
||||
]),
|
||||
sse(vec![
|
||||
ev_function_call_with_namespace(
|
||||
"read-env-04",
|
||||
"skills",
|
||||
"read",
|
||||
r#"{"package":"skill://deployment/deploy","source":{"kind":"executor","environment_id":"env-04"}}"#,
|
||||
),
|
||||
ev_completed("executor-response"),
|
||||
]),
|
||||
sse(vec![
|
||||
ev_assistant_message(
|
||||
"done",
|
||||
"I found the omitted env-04 installation and read its deployment instructions.",
|
||||
),
|
||||
ev_completed("done-response"),
|
||||
]),
|
||||
],
|
||||
)
|
||||
.await;
|
||||
let test = test_codex()
|
||||
.with_model("gpt-6-astra")
|
||||
.with_auth(CodexAuth::from_api_key("Test API Key"))
|
||||
// Start without a local attachment so Cloud skills remain available.
|
||||
.with_exec_server_url("none")
|
||||
.with_extensions(Arc::new(extensions.build()))
|
||||
.with_config(|config| {
|
||||
configure_scenario_catalog(config);
|
||||
config.cloud_skill_enabled = true;
|
||||
config
|
||||
.features
|
||||
.enable(Feature::ExecutorCapabilityDiscoveryV2)
|
||||
.expect("enable discovery V2");
|
||||
})
|
||||
.with_model_info_override("gpt-6-astra", |model| {
|
||||
model.truncation_policy =
|
||||
codex_protocol::openai_models::TruncationPolicyConfig::bytes(/*limit*/ 1200);
|
||||
})
|
||||
// The named executor runs on this host and reads the temporary workspace above.
|
||||
.build(&server)
|
||||
.await?;
|
||||
test.thread_manager
|
||||
.environment_manager()
|
||||
.upsert_environment(
|
||||
"env-04".to_string(),
|
||||
executor.websocket_url.clone(),
|
||||
/*connect_timeout*/ None,
|
||||
)?;
|
||||
let cwd = PathUri::from_host_native_path(&workspace_path)?;
|
||||
test.submit_turn_with_environments(
|
||||
"Read the review and deployment instructions, find all deployment installations, then read the instructions from env-04.",
|
||||
Some(vec![TurnEnvironmentSelection {
|
||||
selected_capability_roots: Default::default(),
|
||||
environment_id: "env-04".to_string(),
|
||||
cwd: cwd.clone(),
|
||||
workspace_roots: vec![cwd],
|
||||
config: EnvironmentConfigState::FromThread,
|
||||
}]),
|
||||
)
|
||||
.await?;
|
||||
let requests = mock.requests();
|
||||
assert_eq!(requests.len(), 5);
|
||||
let recovered: serde_json::Value = serde_json::from_str(
|
||||
&mock
|
||||
.function_call_output_text("read-env-04")
|
||||
.expect("executor read output"),
|
||||
)?;
|
||||
assert_eq!(recovered["contents"], executor_contents);
|
||||
assert_eq!(recovered["resource"], "skill://executor-04/deploy/SKILL.md");
|
||||
// Canonicalize JSON only in snapshot copies (Cargo/Bazel differ in map ordering).
|
||||
// Pretty printing keeps installation fields visible rather than hashing one long line.
|
||||
let mut bodies = requests
|
||||
.iter()
|
||||
.map(core_test_support::responses::ResponsesRequest::body_json)
|
||||
.collect::<Vec<_>>();
|
||||
for body in &mut bodies {
|
||||
for item in body["input"].as_array_mut().expect("request input") {
|
||||
if item["type"] == "function_call_output" {
|
||||
let mut output: serde_json::Value =
|
||||
serde_json::from_str(item["output"].as_str().expect("tool output"))?;
|
||||
for location in output["installations"].as_array_mut().into_iter().flatten() {
|
||||
if location["skill_root"] == deployment_path.inferred_native_path_string() {
|
||||
location["skill_root"] = json!("<ENV_04_SKILL_ROOT>");
|
||||
}
|
||||
}
|
||||
output.sort_all_objects();
|
||||
item["output"] = json!(serde_json::to_string_pretty(&output)?);
|
||||
}
|
||||
}
|
||||
}
|
||||
insta::assert_snapshot!(
|
||||
"skill_read_installation_recovery_request_history",
|
||||
context_snapshot::format_context_snapshot(
|
||||
"Astra reads Cloud instructions, discovers an omitted deployment installation, and reads its instructions from env-04.",
|
||||
&bodies.iter().map(SnapshotEntry::body).collect::<Vec<_>>(),
|
||||
&ContextSnapshotOptions::default().rewrite_known_segments(),
|
||||
)
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case::test_case(false, ReasoningEffort::Low; "native_tools")]
|
||||
#[test_case::test_case(true, ReasoningEffort::Low; "host_tools")]
|
||||
#[test_case::test_case(true, ReasoningEffort::Ultra; "host_tools_ultra")]
|
||||
@@ -2715,14 +2307,13 @@ async fn code_mode_catalog_messages(ranked_search: bool) -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
let server = start_mock_server().await;
|
||||
let apps =
|
||||
core_test_support::apps_test_server::AppsTestServer::mount_searchable(&server).await?;
|
||||
core_test_support::mcp_test_server::McpTestServer::mount_searchable(&server).await?;
|
||||
let test = test_codex()
|
||||
.with_model("gpt-6-astra")
|
||||
.with_auth(CodexAuth::from_api_key("Test API Key"))
|
||||
.with_config(move |config| {
|
||||
configure_scenario_catalog(config);
|
||||
config.chatgpt_base_url = apps.chatgpt_base_url;
|
||||
config.features.enable(Feature::Apps).expect("enable apps");
|
||||
core_test_support::mcp_test_server::configure_mcp_test_server(config, &apps.base_url);
|
||||
config.features.set_enabled(Feature::CodeModeToolSearch, ranked_search)
|
||||
.expect("set ranked tool search");
|
||||
config.workspace_roots = vec![config.cwd.clone()];
|
||||
@@ -3001,7 +2592,7 @@ async fn subagent_browser_auth_resolves_user_prompt() -> Result<()> {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[tokio::test]
|
||||
async fn guardian_elastic_budgeting_request_history() -> Result<()> {
|
||||
use codex_config::test_support::CloudConfigBundleFixture;
|
||||
use codex_config::test_support::ManagedConfigFixture;
|
||||
use codex_protocol::config_types::ApprovalsReviewer;
|
||||
use codex_protocol::protocol::AskForApproval;
|
||||
use core_test_support::responses;
|
||||
@@ -3070,8 +2661,8 @@ async fn guardian_elastic_budgeting_request_history() -> Result<()> {
|
||||
.replace("[sections.", "[features.guardianv2.sync_elastic_sections.")
|
||||
);
|
||||
let test = test_codex()
|
||||
.with_cloud_config_bundle(
|
||||
CloudConfigBundleFixture::enterprise_config(settings).into_loader(),
|
||||
.with_managed_config(
|
||||
ManagedConfigFixture::config(settings),
|
||||
)
|
||||
.with_config(|config| {
|
||||
configure_scenario_catalog(config);
|
||||
@@ -3128,64 +2719,6 @@ async fn guardian_elastic_budgeting_request_history() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn guardian_code_mode_messaging_request_history() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
skip_if_wine_exec!(
|
||||
Ok(()),
|
||||
"Guardian approval actions require host-native paths"
|
||||
);
|
||||
let mut requests =
|
||||
super::guardian_subagent_authorization::code_mode_guardian_request_history().await?;
|
||||
let root =
|
||||
requests.first().expect("root model request").body_json()["client_metadata"]["thread_id"]
|
||||
.clone();
|
||||
requests.sort_by_key(|request| {
|
||||
let body = request.body_json();
|
||||
let metadata = &body["client_metadata"];
|
||||
if metadata["x-openai-subagent"] == "guardian" {
|
||||
2
|
||||
} else {
|
||||
usize::from(metadata["thread_id"] != root)
|
||||
}
|
||||
});
|
||||
let mut snapshot = context_snapshot::format_request_history_snapshot(
|
||||
"A root uses Code Mode to send a confirmation and receives a real user reply; a worker then requests an action that Guardian reviews with the confirmed question as assistant context. Independent model streams are grouped as root, worker, then Guardian.",
|
||||
&requests,
|
||||
&ContextSnapshotOptions::default().rewrite_known_segments(),
|
||||
);
|
||||
for (pattern, replacement) in [
|
||||
(
|
||||
r#"(?m)^(\s*"environment_id": )"(?:local|remote)""#,
|
||||
"$1\"<ENVIRONMENT>\"",
|
||||
),
|
||||
(
|
||||
r#"(For this action on environment )"(?:local|remote)","#,
|
||||
"$1\"<ENVIRONMENT>\",",
|
||||
),
|
||||
(r#"(?m)^(\s*"cwd": )"[^"]*""#, "$1\"<CWD>\""),
|
||||
(
|
||||
r#""command": \[\s*(?:"[^"]*",\s*)*"true"\s*\]"#,
|
||||
"\"command\": [\"<SHELL>\", \"true\"]",
|
||||
),
|
||||
(
|
||||
r#"\{"type":"text","text":"Message sent\."\}"#,
|
||||
r#"{"text":"Message sent.","type":"text"}"#,
|
||||
),
|
||||
(
|
||||
r#"\{"cmd":"true","sandbox_permissions":"require_escalated","justification":"Review the production deployment\."\}"#,
|
||||
r#"{"cmd":"true","justification":"Review the production deployment.","sandbox_permissions":"require_escalated"}"#,
|
||||
),
|
||||
] {
|
||||
snapshot = regex_lite::Regex::new(pattern)?
|
||||
.replace_all(&snapshot, replacement)
|
||||
.into_owned();
|
||||
}
|
||||
insta::assert_snapshot!("guardian_code_mode_messaging", snapshot);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn subagent_waits_for_its_inherited_environment_configuration() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
@@ -3473,27 +3006,6 @@ async fn guardian_checkpoint_migration_request_history() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn app_tool_exposure_request_history() -> Result<()> {
|
||||
let requests = super::app_tool_exposure::connector_exposure_requests(
|
||||
super::app_tool_exposure::ExposureCase::non_deferred(
|
||||
codex_protocol::openai_models::ToolMode::CodeModeOnly,
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
insta::assert_snapshot!(
|
||||
"app_tool_exposure_CodeModeOnly",
|
||||
context_snapshot::format_request_history_snapshot(
|
||||
"A non-deferred connector is called through code mode while another connector stays deferred.",
|
||||
&requests,
|
||||
&ContextSnapshotOptions::default()
|
||||
.rewrite_known_segments()
|
||||
.include_request_settings(),
|
||||
)
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn model_catalog_refresh_preserves_tools_and_history() -> Result<()> {
|
||||
@@ -4623,22 +4135,6 @@ async fn async_compaction_reuses_pending_work(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn unshared_apps_catalog_across_turns() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
let requests =
|
||||
super::mcp_tool_cache::apps_requests_during_peer_discovery(/*share*/ false).await?;
|
||||
let snapshot = context_snapshot::format_request_history_snapshot(
|
||||
"A peer finishes Apps discovery during submit. The thread uses its own catalog on its first and second model requests.",
|
||||
&requests,
|
||||
&ContextSnapshotOptions::default()
|
||||
.rewrite_known_segments()
|
||||
.include_request_settings(),
|
||||
);
|
||||
insta::assert_snapshot!("unshared_apps_catalog_across_turns", snapshot);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn catalog_plugin_guidance_follows_model_and_survives_resume() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
@@ -4878,7 +4374,7 @@ async fn catalog_selected_plugin_wording_preserves_capability_policy(
|
||||
skip_if_no_network!(Ok(()));
|
||||
core_test_support::skip_if_remote!(Ok(()), "plugin MCP fixture uses a host-local executable");
|
||||
let server = start_mock_server().await;
|
||||
let apps = core_test_support::apps_test_server::AppsTestServer::mount(&server).await?;
|
||||
let apps = core_test_support::mcp_test_server::McpTestServer::mount(&server).await?;
|
||||
let home = Arc::new(TempDir::new()?);
|
||||
write_scenario_capabilities(&home)?;
|
||||
let plugin_root = home.path().join("plugins/cache/test/notes/local");
|
||||
@@ -4905,11 +4401,14 @@ async fn catalog_selected_plugin_wording_preserves_capability_policy(
|
||||
.with_extensions(skills_extensions())
|
||||
.with_config(move |config| {
|
||||
configure_catalog_plugin_scenario(config);
|
||||
config.chatgpt_base_url = apps.chatgpt_base_url;
|
||||
config
|
||||
.features
|
||||
.enable(Feature::Apps)
|
||||
.expect("enable Apps for selected-plugin scenario");
|
||||
// The calendar MCP server stands in for the plugin's app, so it is only
|
||||
// registered when that app is enabled.
|
||||
if apps_enabled {
|
||||
core_test_support::mcp_test_server::configure_mcp_test_server(
|
||||
config,
|
||||
&apps.base_url,
|
||||
);
|
||||
}
|
||||
config
|
||||
.features
|
||||
.set_enabled(Feature::SimplifiedSelectionHints, simplified_selection)
|
||||
@@ -5078,85 +4577,3 @@ async fn catalog_selected_plugin_wording_preserves_capability_policy(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn catalog_selected_plugin_omission_bounds_runtime_capabilities() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
let server = start_mock_server().await;
|
||||
let apps = core_test_support::apps_test_server::AppsTestServer::mount_with_connector_name(
|
||||
&server,
|
||||
&"Calendar café ".repeat(400),
|
||||
)
|
||||
.await?;
|
||||
let home = Arc::new(TempDir::new()?);
|
||||
write_scenario_capabilities(&home)?;
|
||||
fs::write(
|
||||
home.path().join("plugins/cache/test/notes/local/.app.json"),
|
||||
json!({"apps": {"notes_app": {"id": "calendar"}}}).to_string(),
|
||||
)?;
|
||||
let test = test_codex()
|
||||
.with_model("gpt-5.5")
|
||||
.with_home(home)
|
||||
.with_auth(CodexAuth::from_api_key("Test API Key"))
|
||||
.with_extensions(skills_extensions())
|
||||
.with_config(move |config| {
|
||||
configure_catalog_plugin_scenario(config);
|
||||
config.chatgpt_base_url = apps.chatgpt_base_url;
|
||||
config.features.enable(Feature::Apps).unwrap();
|
||||
config
|
||||
.features
|
||||
.disable(Feature::SimplifiedSelectionHints)
|
||||
.unwrap();
|
||||
let model = config
|
||||
.model_catalog
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.models
|
||||
.iter_mut()
|
||||
.find(|model| model.slug == "gpt-5.5")
|
||||
.unwrap();
|
||||
model.include_plugin_usage_instructions = false;
|
||||
model.model_messages = Some(
|
||||
serde_json::from_value(json!({"plugins": {"selected": {
|
||||
"intro": "Catalog selected {{ plugin_name }}.",
|
||||
"apps": "Catalog apps {{ apps }}.",
|
||||
"omitted": "Catalog capability list omitted here.",
|
||||
}}}))
|
||||
.unwrap(),
|
||||
);
|
||||
})
|
||||
.build_with_auto_env(&server)
|
||||
.await?;
|
||||
let mock = mount_sse_sequence(&server, vec![sse(vec![ev_completed("bounded-plugin")])]).await;
|
||||
test.codex
|
||||
.start_or_steer_turn(TurnInputRequest::user_input(vec![
|
||||
text("Use the selected plugin."),
|
||||
plugin("notes"),
|
||||
]))
|
||||
.await?;
|
||||
wait_for_event(&test.codex, |event| {
|
||||
matches!(event, EventMsg::TurnComplete(_))
|
||||
})
|
||||
.await;
|
||||
let request = mock.single_request();
|
||||
let selected = request
|
||||
.message_input_texts("developer")
|
||||
.into_iter()
|
||||
.filter(|text| text.starts_with("Catalog selected notes."))
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(selected.len(), 1);
|
||||
assert!(selected[0].contains("Catalog apps `Calendar café "));
|
||||
assert!(selected[0].ends_with("\nCatalog capability list omitted here."));
|
||||
assert!(
|
||||
selected[0].len() <= 4096,
|
||||
"the bound applies after runtime capability substitution"
|
||||
);
|
||||
insta::assert_snapshot!(
|
||||
"catalog_selected_plugin_omission_bounds_runtime_capabilities",
|
||||
context_snapshot::format_request_history_snapshot(
|
||||
"A catalog omission suffix is reserved within the final selected-plugin bound after substituting a long Unicode runtime capability name.",
|
||||
&mock.requests(),
|
||||
&ContextSnapshotOptions::default().include_request_settings(),
|
||||
)
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user