Lightweight coding agent that runs in your terminal
Rust
Allow Guardian cached approvals with incomplete root context (#49257)
felixxia-oai4f16bdc26515
diff --git a/codex-rs/ext/guardian-v2/src/async_scorer/approval.rs b/codex-rs/ext/guardian-v2/src/async_scorer/approval.rsindex 3ec1167df8..1f41cd6cb9 100644--- a/codex-rs/ext/guardian-v2/src/async_scorer/approval.rs+++ b/codex-rs/ext/guardian-v2/src/async_scorer/approval.rs@@ -199,11 +199,8 @@ async fn cached_evidence(record_fast_decision(metrics, "deferred", "scoring_failure");return Err(GuardianReviewReason::ScoringFailure);}- if !current.local.retained_context_complete- || current- .root- .is_some_and(|root| !root.retained_context_complete)- {+ // Root omissions remain visible to the classifier but do not veto a matching cached score.+ if !current.local.retained_context_complete {record_fast_decision(metrics, "deferred", "incomplete_authorization");return Err(GuardianReviewReason::Policy);}diff --git a/codex-rs/ext/guardian-v2/src/async_scorer/extension_cached_delivery_tests.rs b/codex-rs/ext/guardian-v2/src/async_scorer/extension_cached_delivery_tests.rsindex 7c2216a7a4..f9de5e5003 100644--- a/codex-rs/ext/guardian-v2/src/async_scorer/extension_cached_delivery_tests.rs+++ b/codex-rs/ext/guardian-v2/src/async_scorer/extension_cached_delivery_tests.rs@@ -277,6 +277,35 @@ async fn confirmed_root_delivery_invalidates_root_and_worker_cached_approvals()None);}+ // Missing retained root instructions must not permanently veto a matching LOW score.+ ThreadIdle::wait(&test.codex).await;+ ThreadIdle::wait(&worker).await;+ test.codex+ .inject_response_items(+ (0..20)+ .map(|index| user_instruction(&format!("Root instruction {index}.")))+ .collect(),+ )+ .await?;+ let snapshot = worker+ .guardian_root_snapshot()+ .await+ .expect("root snapshot");+ assert!(!snapshot.authorization_version.retained_context_complete);+ assert!(+ snapshot+ .messages+ .contains(&codex_core::GuardianRootMessage::IncompleteRootInstructions)+ );+ let store = worker.thread_extension_data();+ let progress = store.get::<GuardianV2ScoreProgress>().unwrap();+ let authorization = ScoreAuthorization::current(&worker, &Default::default()).await;+ assert!(authorization.local.retained_context_complete);+ seed_cached_score(&progress, store, /*index*/ 1_000, authorization);+ assert_eq!(+ cached_approval(®istry, store, "review action", /*metrics*/ None).await,+ Some(ReviewDecision::Approved)+ );let shutdown = test.thread_manager.shutdown_all_threads_bounded(ASYNC_TEST_TIMEOUT)