mirror of
https://github.com/openai/codex.git
synced 2026-12-05 01:00:54 +00:00
core: close Guardian assessment lifecycle on abort
This commit is contained in:
@@ -286,24 +286,28 @@ async fn run_guardian_review(
|
||||
GUARDIAN_REVIEW_TIMEOUT.as_millis() as u64,
|
||||
);
|
||||
let started_at_ms = review_tracking.started_at_ms.try_into().unwrap_or_default();
|
||||
let started_event = GuardianAssessmentEvent {
|
||||
id: review_id.clone(),
|
||||
target_item_id: target_item_id.clone(),
|
||||
turn_id: assessment_turn_id.clone(),
|
||||
started_at_ms,
|
||||
completed_at_ms: None,
|
||||
status: GuardianAssessmentStatus::InProgress,
|
||||
risk_level: None,
|
||||
user_authorization: None,
|
||||
rationale: None,
|
||||
decision_source: None,
|
||||
action: action_summary.clone(),
|
||||
};
|
||||
let abort_fallback = GuardianAssessmentEvent {
|
||||
status: GuardianAssessmentStatus::Aborted,
|
||||
decision_source: Some(GuardianAssessmentDecisionSource::Agent),
|
||||
..started_event.clone()
|
||||
};
|
||||
session
|
||||
.send_event(
|
||||
turn.as_ref(),
|
||||
EventMsg::GuardianAssessment(GuardianAssessmentEvent {
|
||||
id: review_id.clone(),
|
||||
target_item_id: target_item_id.clone(),
|
||||
turn_id: assessment_turn_id.clone(),
|
||||
started_at_ms,
|
||||
completed_at_ms: None,
|
||||
status: GuardianAssessmentStatus::InProgress,
|
||||
risk_level: None,
|
||||
user_authorization: None,
|
||||
rationale: None,
|
||||
decision_source: None,
|
||||
action: action_summary.clone(),
|
||||
}),
|
||||
)
|
||||
.send_event(turn.as_ref(), EventMsg::GuardianAssessment(started_event))
|
||||
.await;
|
||||
review_context.activity.mark_started(abort_fallback);
|
||||
|
||||
if cancellation_token.is_cancelled() {
|
||||
let completed_at_ms = now_unix_timestamp_ms();
|
||||
@@ -338,6 +342,7 @@ async fn run_guardian_review(
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
review_context.activity.mark_terminal();
|
||||
record_guardian_non_denial(&session, &assessment_turn_id).await;
|
||||
return ReviewDecision::Abort;
|
||||
}
|
||||
@@ -457,6 +462,7 @@ async fn run_guardian_review(
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
review_context.activity.mark_terminal();
|
||||
record_guardian_non_denial(&session, &assessment_turn_id).await;
|
||||
return ReviewDecision::TimedOut;
|
||||
}
|
||||
@@ -492,6 +498,7 @@ async fn run_guardian_review(
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
review_context.activity.mark_terminal();
|
||||
record_guardian_non_denial(&session, &assessment_turn_id).await;
|
||||
return ReviewDecision::Abort;
|
||||
}
|
||||
@@ -590,6 +597,8 @@ async fn run_guardian_review(
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
review_context.activity.mark_terminal();
|
||||
|
||||
if count_denial_for_circuit_breaker {
|
||||
record_guardian_denial(&session, &turn, &assessment_turn_id).await;
|
||||
} else {
|
||||
@@ -631,17 +640,20 @@ async fn run_guardian_review_in_task(
|
||||
generation: review_generation,
|
||||
},
|
||||
);
|
||||
let Some(review) = turn.guardian_reviews.spawn(&runtime_handle, async move {
|
||||
tokio::pin!(review);
|
||||
tokio::select! {
|
||||
biased;
|
||||
_ = request_cancel.cancelled() => {
|
||||
cancel_activity.cancel();
|
||||
review.await
|
||||
let Some(review) = turn
|
||||
.guardian_reviews
|
||||
.spawn(&runtime_handle, &review_activity, async move {
|
||||
tokio::pin!(review);
|
||||
tokio::select! {
|
||||
biased;
|
||||
_ = request_cancel.cancelled() => {
|
||||
cancel_activity.cancel();
|
||||
review.await
|
||||
}
|
||||
decision = &mut review => decision,
|
||||
}
|
||||
decision = &mut review => decision,
|
||||
}
|
||||
}) else {
|
||||
})
|
||||
else {
|
||||
return ReviewDecision::Abort;
|
||||
};
|
||||
match review.await {
|
||||
|
||||
@@ -5,6 +5,7 @@ use std::sync::atomic::AtomicBool;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::time::Duration;
|
||||
|
||||
use codex_protocol::protocol::GuardianAssessmentEvent;
|
||||
use tokio::runtime::Handle;
|
||||
use tokio::task::AbortHandle;
|
||||
use tokio::task::JoinHandle;
|
||||
@@ -18,12 +19,41 @@ const GUARDIAN_REVIEW_DRAIN_TIMEOUT: Duration = Duration::from_secs(6);
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub(crate) enum GuardianReviewDrainOutcome {
|
||||
Drained,
|
||||
Forced,
|
||||
Forced(Vec<GuardianAssessmentEvent>),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct TrackedGuardianReview {
|
||||
abort_handle: AbortHandle,
|
||||
lifecycle: GuardianReviewLifecycle,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
struct GuardianReviewLifecycle {
|
||||
fallback: Arc<Mutex<Option<GuardianAssessmentEvent>>>,
|
||||
}
|
||||
|
||||
impl GuardianReviewLifecycle {
|
||||
fn mark_started(&self, fallback: GuardianAssessmentEvent) {
|
||||
*self
|
||||
.fallback
|
||||
.lock()
|
||||
.unwrap_or_else(std::sync::PoisonError::into_inner) = Some(fallback);
|
||||
}
|
||||
|
||||
fn mark_terminal(&self) {
|
||||
self.fallback
|
||||
.lock()
|
||||
.unwrap_or_else(std::sync::PoisonError::into_inner)
|
||||
.take();
|
||||
}
|
||||
|
||||
fn take_fallback(&self) -> Option<GuardianAssessmentEvent> {
|
||||
self.fallback
|
||||
.lock()
|
||||
.unwrap_or_else(std::sync::PoisonError::into_inner)
|
||||
.take()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
@@ -58,12 +88,14 @@ impl GuardianReviewTaskOwner {
|
||||
owner: Arc::clone(self),
|
||||
cancellation_token: self.cancellation_token.child_token(),
|
||||
committed: Arc::new(AtomicBool::new(false)),
|
||||
lifecycle: GuardianReviewLifecycle::default(),
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn spawn<F>(
|
||||
self: &Arc<Self>,
|
||||
runtime_handle: &Handle,
|
||||
activity: &GuardianReviewActivity,
|
||||
future: F,
|
||||
) -> Option<JoinHandle<F::Output>>
|
||||
where
|
||||
@@ -78,6 +110,7 @@ impl GuardianReviewTaskOwner {
|
||||
let mut state = state;
|
||||
state.reviews.push(TrackedGuardianReview {
|
||||
abort_handle: task.abort_handle(),
|
||||
lifecycle: activity.lifecycle.clone(),
|
||||
});
|
||||
drop(state);
|
||||
Some(task)
|
||||
@@ -104,6 +137,7 @@ pub(crate) struct GuardianReviewActivity {
|
||||
owner: Arc<GuardianReviewTaskOwner>,
|
||||
cancellation_token: CancellationToken,
|
||||
committed: Arc<AtomicBool>,
|
||||
lifecycle: GuardianReviewLifecycle,
|
||||
}
|
||||
|
||||
impl GuardianReviewActivity {
|
||||
@@ -111,6 +145,14 @@ impl GuardianReviewActivity {
|
||||
self.cancellation_token.clone()
|
||||
}
|
||||
|
||||
pub(crate) fn mark_started(&self, fallback: GuardianAssessmentEvent) {
|
||||
self.lifecycle.mark_started(fallback);
|
||||
}
|
||||
|
||||
pub(crate) fn mark_terminal(&self) {
|
||||
self.lifecycle.mark_terminal();
|
||||
}
|
||||
|
||||
pub(crate) fn cancel(&self) -> bool {
|
||||
if self.committed.load(Ordering::Acquire) {
|
||||
return false;
|
||||
@@ -164,7 +206,13 @@ impl GuardianReviewDrain {
|
||||
}
|
||||
self.owner.tasks.wait().await;
|
||||
warn!("timed out waiting for Guardian reviews to stop");
|
||||
GuardianReviewDrainOutcome::Forced
|
||||
}
|
||||
let forced_aborts: Vec<_> = reviews
|
||||
.into_iter()
|
||||
.filter_map(|review| review.lifecycle.take_fallback())
|
||||
.collect();
|
||||
if timed_out || !forced_aborts.is_empty() {
|
||||
GuardianReviewDrainOutcome::Forced(forced_aborts)
|
||||
} else {
|
||||
GuardianReviewDrainOutcome::Drained
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
use codex_protocol::protocol::GuardianAssessmentAction;
|
||||
use codex_protocol::protocol::GuardianAssessmentEvent;
|
||||
use codex_protocol::protocol::GuardianAssessmentStatus;
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::oneshot;
|
||||
@@ -6,13 +9,36 @@ use tokio::time::Instant;
|
||||
use super::GuardianReviewDrainOutcome;
|
||||
use super::GuardianReviewTaskOwner;
|
||||
|
||||
fn forced_abort_event() -> GuardianAssessmentEvent {
|
||||
GuardianAssessmentEvent {
|
||||
id: "review-1".to_string(),
|
||||
target_item_id: Some("item-1".to_string()),
|
||||
turn_id: "turn-1".to_string(),
|
||||
started_at_ms: 1,
|
||||
completed_at_ms: None,
|
||||
status: GuardianAssessmentStatus::Aborted,
|
||||
risk_level: None,
|
||||
user_authorization: None,
|
||||
rationale: None,
|
||||
decision_source: None,
|
||||
action: GuardianAssessmentAction::McpToolCall {
|
||||
server: "test-server".to_string(),
|
||||
tool_name: "test-tool".to_string(),
|
||||
connector_id: None,
|
||||
connector_name: None,
|
||||
tool_title: None,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn dropping_review_handle_leaves_cleanup_to_owner() {
|
||||
let owner = Arc::new(GuardianReviewTaskOwner::default());
|
||||
let activity = owner.begin().expect("review should start");
|
||||
let cancellation_token = owner.cancellation_token();
|
||||
let (completed_tx, completed_rx) = oneshot::channel();
|
||||
let task = owner
|
||||
.spawn(&tokio::runtime::Handle::current(), async move {
|
||||
.spawn(&tokio::runtime::Handle::current(), &activity, async move {
|
||||
cancellation_token.cancelled().await;
|
||||
let _ = completed_tx.send(());
|
||||
})
|
||||
@@ -30,9 +56,12 @@ async fn dropping_review_handle_leaves_cleanup_to_owner() {
|
||||
#[tokio::test]
|
||||
async fn forced_drain_aborts_review_task() {
|
||||
let owner = Arc::new(GuardianReviewTaskOwner::default());
|
||||
let activity = owner.begin().expect("review should start");
|
||||
let forced_abort = forced_abort_event();
|
||||
activity.mark_started(forced_abort.clone());
|
||||
let (drop_tx, mut drop_rx) = oneshot::channel::<()>();
|
||||
let task = owner
|
||||
.spawn(&tokio::runtime::Handle::current(), async move {
|
||||
.spawn(&tokio::runtime::Handle::current(), &activity, async move {
|
||||
let _drop_tx = drop_tx;
|
||||
std::future::pending::<()>().await;
|
||||
})
|
||||
@@ -41,13 +70,74 @@ async fn forced_drain_aborts_review_task() {
|
||||
|
||||
let mut drain = owner.close();
|
||||
drain.deadline = Instant::now();
|
||||
assert_eq!(drain.drain().await, GuardianReviewDrainOutcome::Forced);
|
||||
assert_eq!(
|
||||
drain.drain().await,
|
||||
GuardianReviewDrainOutcome::Forced(vec![forced_abort])
|
||||
);
|
||||
assert_eq!(
|
||||
drop_rx.try_recv(),
|
||||
Err(oneshot::error::TryRecvError::Closed)
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn panicked_review_returns_fallback_after_draining() {
|
||||
let owner = Arc::new(GuardianReviewTaskOwner::default());
|
||||
let activity = owner.begin().expect("review should start");
|
||||
let forced_abort = forced_abort_event();
|
||||
activity.mark_started(forced_abort.clone());
|
||||
let task = owner
|
||||
.spawn(&tokio::runtime::Handle::current(), &activity, async move {
|
||||
panic!("guardian review panicked");
|
||||
})
|
||||
.expect("review task should start");
|
||||
drop(task);
|
||||
|
||||
assert_eq!(
|
||||
owner.close().drain().await,
|
||||
GuardianReviewDrainOutcome::Forced(vec![forced_abort])
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn fallback_requires_started_nonterminal_review() {
|
||||
let owner = Arc::new(GuardianReviewTaskOwner::default());
|
||||
let activity = owner.begin().expect("review should start");
|
||||
let task = owner
|
||||
.spawn(
|
||||
&tokio::runtime::Handle::current(),
|
||||
&activity,
|
||||
std::future::pending::<()>(),
|
||||
)
|
||||
.expect("review task should start");
|
||||
drop(task);
|
||||
let mut drain = owner.close();
|
||||
drain.deadline = Instant::now();
|
||||
assert_eq!(
|
||||
drain.drain().await,
|
||||
GuardianReviewDrainOutcome::Forced(Vec::new())
|
||||
);
|
||||
|
||||
let owner = Arc::new(GuardianReviewTaskOwner::default());
|
||||
let activity = owner.begin().expect("review should start");
|
||||
activity.mark_started(forced_abort_event());
|
||||
activity.mark_terminal();
|
||||
let task = owner
|
||||
.spawn(
|
||||
&tokio::runtime::Handle::current(),
|
||||
&activity,
|
||||
std::future::pending::<()>(),
|
||||
)
|
||||
.expect("review task should start");
|
||||
drop(task);
|
||||
let mut drain = owner.close();
|
||||
drain.deadline = Instant::now();
|
||||
assert_eq!(
|
||||
drain.drain().await,
|
||||
GuardianReviewDrainOutcome::Forced(Vec::new())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commit_is_linearized_against_cancellation() {
|
||||
let committed_owner = Arc::new(GuardianReviewTaskOwner::default());
|
||||
|
||||
@@ -550,11 +550,22 @@ impl Session {
|
||||
true
|
||||
}
|
||||
|
||||
async fn drain_guardian_reviews(&self, drain: crate::guardian::GuardianReviewDrain) {
|
||||
if drain.drain().await == crate::guardian::GuardianReviewDrainOutcome::Forced {
|
||||
self.guardian_review_session
|
||||
.shutdown_in_background(&self.services.runtime_handle);
|
||||
async fn drain_guardian_reviews(
|
||||
&self,
|
||||
turn_context: &TurnContext,
|
||||
drain: crate::guardian::GuardianReviewDrain,
|
||||
) {
|
||||
let crate::guardian::GuardianReviewDrainOutcome::Forced(events) = drain.drain().await
|
||||
else {
|
||||
return;
|
||||
};
|
||||
for mut event in events {
|
||||
event.completed_at_ms = Some(crate::turn_timing::now_unix_timestamp_ms());
|
||||
self.send_event(turn_context, EventMsg::GuardianAssessment(event))
|
||||
.await;
|
||||
}
|
||||
self.guardian_review_session
|
||||
.shutdown_in_background(&self.services.runtime_handle);
|
||||
}
|
||||
|
||||
pub async fn on_task_finished(
|
||||
@@ -577,7 +588,7 @@ impl Session {
|
||||
let Some(turn_state) = turn_state else {
|
||||
return;
|
||||
};
|
||||
self.drain_guardian_reviews(turn_context.guardian_reviews.close())
|
||||
self.drain_guardian_reviews(turn_context.as_ref(), turn_context.guardian_reviews.close())
|
||||
.await;
|
||||
let pending_input = self
|
||||
.input_queue
|
||||
@@ -797,7 +808,8 @@ impl Session {
|
||||
let task_already_cancelled = task.cancellation_token.is_cancelled();
|
||||
task.cancellation_token.cancel();
|
||||
if task_already_cancelled {
|
||||
self.drain_guardian_reviews(guardian_drain).await;
|
||||
self.drain_guardian_reviews(task.turn_context.as_ref(), guardian_drain)
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -824,7 +836,8 @@ impl Session {
|
||||
session_task
|
||||
.abort(session_ctx, Arc::clone(&task.turn_context))
|
||||
.await;
|
||||
self.drain_guardian_reviews(guardian_drain).await;
|
||||
self.drain_guardian_reviews(task.turn_context.as_ref(), guardian_drain)
|
||||
.await;
|
||||
|
||||
if reason == TurnAbortReason::Interrupted
|
||||
&& let Some(marker) = interrupted_turn_history_marker(
|
||||
|
||||
@@ -6,6 +6,7 @@ use codex_core::sandboxing::SandboxPermissions;
|
||||
use codex_protocol::config_types::ApprovalsReviewer;
|
||||
use codex_protocol::protocol::AskForApproval;
|
||||
use codex_protocol::protocol::EventMsg;
|
||||
use codex_protocol::protocol::GuardianAssessmentStatus;
|
||||
use codex_protocol::protocol::Op;
|
||||
use codex_protocol::protocol::SandboxPolicy;
|
||||
use codex_protocol::user_input::UserInput;
|
||||
@@ -14,8 +15,10 @@ use core_test_support::responses::ev_assistant_message;
|
||||
use core_test_support::responses::ev_completed;
|
||||
use core_test_support::responses::ev_function_call;
|
||||
use core_test_support::responses::ev_response_created;
|
||||
use core_test_support::responses::mount_response_sequence;
|
||||
use core_test_support::responses::mount_sse_sequence;
|
||||
use core_test_support::responses::sse;
|
||||
use core_test_support::responses::sse_response;
|
||||
use core_test_support::responses::start_mock_server;
|
||||
use core_test_support::skip_if_no_network;
|
||||
use core_test_support::skip_if_sandbox;
|
||||
@@ -30,6 +33,144 @@ use std::os::unix::fs::PermissionsExt;
|
||||
use std::time::Duration;
|
||||
use tempfile::TempDir;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn interrupting_parent_turn_shuts_down_active_guardian_review() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
skip_if_sandbox!(Ok(()));
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let approval_policy = AskForApproval::OnRequest;
|
||||
let sandbox_policy = SandboxPolicy::WorkspaceWrite {
|
||||
writable_roots: vec![],
|
||||
network_access: false,
|
||||
exclude_tmpdir_env_var: true,
|
||||
exclude_slash_tmp: true,
|
||||
};
|
||||
let sandbox_policy_for_config = sandbox_policy.clone();
|
||||
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 test = builder.build(&server).await?;
|
||||
|
||||
let output_file = test.cwd.path().join("guardian-review-after-interrupt.txt");
|
||||
let command = format!("printf guardian-approved > {}", output_file.display());
|
||||
let tool_args = json!({
|
||||
"cmd": command,
|
||||
"yield_time_ms": 1_000_u64,
|
||||
"sandbox_permissions": SandboxPermissions::RequireEscalated,
|
||||
"justification": "Exercise Guardian cancellation.",
|
||||
});
|
||||
let parent_response = sse_response(sse(vec![
|
||||
ev_response_created("resp-parent-tool"),
|
||||
ev_function_call(
|
||||
"exec-call",
|
||||
"exec_command",
|
||||
&serde_json::to_string(&tool_args)?,
|
||||
),
|
||||
ev_completed("resp-parent-tool"),
|
||||
]));
|
||||
let guardian_response = sse_response(sse(vec![
|
||||
ev_response_created("resp-guardian-delayed"),
|
||||
ev_assistant_message(
|
||||
"msg-guardian-delayed",
|
||||
&json!({
|
||||
"risk_level": "low",
|
||||
"user_authorization": "high",
|
||||
"outcome": "allow",
|
||||
"rationale": "The command writes a marker file in the workspace.",
|
||||
})
|
||||
.to_string(),
|
||||
),
|
||||
ev_completed("resp-guardian-delayed"),
|
||||
]))
|
||||
.set_delay(Duration::from_secs(1));
|
||||
let responses =
|
||||
mount_response_sequence(&server, vec![parent_response, guardian_response]).await;
|
||||
|
||||
test.codex
|
||||
.submit(Op::UserInput {
|
||||
items: vec![UserInput::Text {
|
||||
text: "run a command that requires Guardian review".into(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
final_output_json_schema: None,
|
||||
responsesapi_client_metadata: None,
|
||||
additional_context: Default::default(),
|
||||
thread_settings: codex_protocol::protocol::ThreadSettingsOverrides {
|
||||
environments: Some(local_selections(test.config.cwd.clone())),
|
||||
approval_policy: Some(approval_policy),
|
||||
approvals_reviewer: Some(ApprovalsReviewer::AutoReview),
|
||||
sandbox_policy: Some(sandbox_policy),
|
||||
..Default::default()
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
let guardian_started = wait_for_event(&test.codex, |event| {
|
||||
matches!(event, EventMsg::GuardianAssessment(_))
|
||||
})
|
||||
.await;
|
||||
let EventMsg::GuardianAssessment(guardian_started) = guardian_started else {
|
||||
unreachable!("wait predicate only accepts guardian assessments");
|
||||
};
|
||||
assert_eq!(
|
||||
guardian_started.status,
|
||||
GuardianAssessmentStatus::InProgress
|
||||
);
|
||||
tokio::time::timeout(Duration::from_secs(5), async {
|
||||
while responses.requests().len() < 2 {
|
||||
tokio::time::sleep(Duration::from_millis(10)).await;
|
||||
}
|
||||
})
|
||||
.await
|
||||
.expect("guardian review request should be in flight before interrupt");
|
||||
|
||||
test.codex.submit(Op::Interrupt).await?;
|
||||
let statuses = tokio::time::timeout(Duration::from_secs(5), async {
|
||||
let mut statuses = vec![guardian_started.status];
|
||||
loop {
|
||||
match test.codex.next_event().await?.msg {
|
||||
EventMsg::GuardianAssessment(event) => statuses.push(event.status),
|
||||
EventMsg::TurnAborted(_) => return Ok::<_, anyhow::Error>(statuses),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
})
|
||||
.await??;
|
||||
assert_eq!(
|
||||
statuses,
|
||||
vec![
|
||||
GuardianAssessmentStatus::InProgress,
|
||||
GuardianAssessmentStatus::Aborted,
|
||||
]
|
||||
);
|
||||
|
||||
match tokio::time::timeout(Duration::from_secs(2), async {
|
||||
loop {
|
||||
let event = test.codex.next_event().await?;
|
||||
if let EventMsg::GuardianAssessment(assessment) = event.msg {
|
||||
return Ok::<_, anyhow::Error>(assessment);
|
||||
}
|
||||
}
|
||||
})
|
||||
.await
|
||||
{
|
||||
Err(_) => {}
|
||||
Ok(Ok(assessment)) => {
|
||||
panic!("received late Guardian assessment after parent abort: {assessment:?}")
|
||||
}
|
||||
Ok(Err(err)) => return Err(err),
|
||||
}
|
||||
assert!(
|
||||
!output_file.exists(),
|
||||
"Guardian-approved command ran after parent abort"
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn guardian_review_session_does_not_inherit_legacy_notify() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
Reference in New Issue
Block a user