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:
andrea.difonzo
2026-11-10 16:07:22 +01:00
parent 231e8cd136
commit 5afc7e9f7f
1223 changed files with 6225 additions and 113722 deletions

View File

@@ -37,7 +37,6 @@ use codex_protocol::models::PermissionProfile;
use codex_protocol::models::PermissionProfileSnapshot;
use codex_protocol::models::ResponseItem;
use codex_protocol::openai_models::AutoReviewMessages;
use codex_protocol::openai_models::MODEL_SPECIALTY_CYBER;
use codex_protocol::openai_models::ModelTokenBudgetConfig;
use codex_protocol::openai_models::ModelsResponse;
use codex_protocol::permissions::FileSystemAccessMode;
@@ -356,7 +355,7 @@ async fn guardian_custom_gateway_selects_reviewer_by_catalog_origin(
sse(vec![ev_completed("done")]),
]).await;
let test = test_codex()
.with_catalog_discovery_api_key()
.with_header_auth()
.with_config(move |config| {
config.model = Some("gateway-main".to_string());
config.model_catalog = (origin == ModelOrigin::ExplicitConfig).then_some(catalog);
@@ -596,7 +595,6 @@ async fn guardian_review_recovers_after_compaction(
.expect("model messages")
.token_budget = Some(ModelTokenBudgetConfig {
enabled: !with_parent_checkpoint,
use_history_notes_extension: true,
reminder_threshold_tokens: 6_144,
reminder_message_template: "{n_remaining} tokens remain.".to_string(),
guidance_message: "Save state before resetting context.".to_string(),
@@ -1531,7 +1529,7 @@ async fn guardian_refreshes_missing_default_reviewer_once(
let catalog_url = format!("{}/v1/models", server.uri());
let configured_catalog = initial_catalog.clone();
let mut builder = test_codex()
.with_catalog_discovery_api_key()
.with_header_auth()
.with_model("guardian-parent-a")
.with_config(move |config| {
config.permissions.approval_policy = Constrained::allow_any(AskForApproval::OnRequest);
@@ -2826,7 +2824,7 @@ impl codex_extension_api::ApprovalReviewContributor for AttemptCachedApproval {
#[test_case(ApprovalPath::SynchronousFallback; "synchronous_fallback")]
#[test_case(ApprovalPath::CachedContributor; "cached_result_requires_fresh_review")]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn cyber_model_guardian_denial_interrupts_turn_immediately(
async fn guardian_denial_blocks_command_without_interrupting_turn(
approval_path: ApprovalPath,
) -> Result<()> {
skip_if_no_network!(Ok(()));
@@ -2846,16 +2844,12 @@ async fn cyber_model_guardian_denial_interrupts_turn_immediately(
};
let sandbox_policy_for_config = sandbox_policy.clone();
let mut builder = test_codex()
.with_model_info_override("gpt-5.4", |model| {
model.model_specialty = Some(MODEL_SPECIALTY_CYBER.to_string());
})
.with_config(move |config| {
config.permissions.approval_policy = Constrained::allow_any(approval_policy);
config
.set_legacy_sandbox_policy(sandbox_policy_for_config)
.expect("set sandbox policy");
});
let mut builder = test_codex().with_config(move |config| {
config.permissions.approval_policy = Constrained::allow_any(approval_policy);
config
.set_legacy_sandbox_policy(sandbox_policy_for_config)
.expect("set sandbox policy");
});
let cached_calls = Arc::new(std::sync::atomic::AtomicUsize::new(/*v*/ 0));
if matches!(approval_path, ApprovalPath::CachedContributor) {
let mut extensions = ExtensionRegistryBuilder::default();
@@ -2866,30 +2860,30 @@ async fn cyber_model_guardian_denial_interrupts_turn_immediately(
}
let test = builder.build_with_auto_env(&server).await?;
let output_file = test.cwd.path().join("cyber-guardian-denied.txt");
let output_file = test.cwd.path().join("guardian-denied.txt");
let command = format!("printf should-not-run > {}", output_file.display());
let tool_args = json!({
"cmd": command,
"yield_time_ms": 1_000_u64,
"sandbox_permissions": SandboxPermissions::RequireEscalated,
"justification": "Exercise immediate Guardian interruption for cyber models.",
"justification": "Exercise a single Guardian denial.",
});
let responses = mount_sse_sequence(
&server,
vec![
sse(vec![
ev_response_created("resp-cyber-parent-tool-denied"),
ev_response_created("resp-parent-tool-denied"),
ev_function_call(
"exec-cyber-call-denied",
"exec-call-denied",
"exec_command",
&serde_json::to_string(&tool_args)?,
),
ev_completed("resp-cyber-parent-tool-denied"),
ev_completed("resp-parent-tool-denied"),
]),
sse(vec![
ev_response_created("resp-cyber-guardian-denied"),
ev_response_created("resp-guardian-denied"),
ev_assistant_message(
"msg-cyber-guardian-denied",
"msg-guardian-denied",
&json!({
"risk_level": "high",
"user_authorization": "low",
@@ -2898,7 +2892,12 @@ async fn cyber_model_guardian_denial_interrupts_turn_immediately(
})
.to_string(),
),
ev_completed("resp-cyber-guardian-denied"),
ev_completed("resp-guardian-denied"),
]),
sse(vec![
ev_response_created("resp-parent-after-denial"),
ev_assistant_message("msg-parent-after-denial", "denied"),
ev_completed("resp-parent-after-denial"),
]),
],
)
@@ -2907,7 +2906,7 @@ async fn cyber_model_guardian_denial_interrupts_turn_immediately(
test.codex
.start_or_steer_turn(
TurnInputRequest::user_input(vec![UserInput::Text {
text: "run a command that Guardian should deny for a cyber model".into(),
text: "run a command that Guardian should deny".into(),
text_elements: Vec::new(),
}])
.with_thread_settings(ThreadSettingsOverrides {
@@ -2920,17 +2919,18 @@ async fn cyber_model_guardian_denial_interrupts_turn_immediately(
.await?;
let mut assessments = Vec::new();
let warning = wait_for_event(&test.codex, |event| {
let mut warnings = Vec::new();
wait_for_event(&test.codex, |event| {
match event {
EventMsg::GuardianAssessment(event) => assessments.push(event.clone()),
EventMsg::GuardianWarning(warning)
if warning.message.contains("too many approval requests") =>
{
return true;
}
EventMsg::TurnComplete(_) | EventMsg::TurnAborted(_) => {
panic!("turn ended without Guardian's denial warning")
panic!("a single denial must not trip the circuit breaker: {warning:?}")
}
EventMsg::GuardianWarning(warning) => warnings.push(warning.message.clone()),
EventMsg::TurnAborted(_) => panic!("a single denial must not interrupt the turn"),
EventMsg::TurnComplete(_) => return true,
_ => {}
}
false
@@ -2947,6 +2947,14 @@ async fn cyber_model_guardian_denial_interrupts_turn_immediately(
]
);
assert_eq!(assessments[0].id, assessments[1].id);
// The denial itself is still reported to the user.
assert_eq!(
warnings,
vec![
"Automatic approval review denied (risk: high, authorization: low): The requested command has unacceptable test risk."
.to_string()
]
);
assert_eq!(
cached_calls.load(std::sync::atomic::Ordering::SeqCst),
match approval_path {
@@ -2954,27 +2962,10 @@ async fn cyber_model_guardian_denial_interrupts_turn_immediately(
ApprovalPath::CachedContributor => 1,
}
);
let EventMsg::GuardianWarning(warning) = warning else {
unreachable!("wait_for_event returned a non-warning event")
};
assert!(
warning
.message
.contains("1 consecutive, 1 in the last 50 reviews")
);
let aborted = wait_for_event(&test.codex, |event| {
matches!(event, EventMsg::TurnAborted(_))
})
.await;
let EventMsg::TurnAborted(aborted) = aborted else {
unreachable!("wait_for_event returned a non-abort event")
};
assert_eq!(aborted.reason, TurnAbortReason::Interrupted);
assert_eq!(responses.requests().len(), 2);
assert_eq!(responses.requests().len(), 3);
assert!(
!output_file.exists(),
"Guardian-denied cyber-model command unexpectedly executed"
"Guardian-denied command unexpectedly executed"
);
Ok(())