Tie network approval reviews to their originating execution (#44575)

## Why

Background commands can outlive their launching turn. Their network reviews need the original execution environment even when current turn settings change, and pending reviews must stop when the execution is cancelled.

## What changed

- Capture the execution's environment snapshot for Guardian network reviews while continuing to use current review settings.
- Deny requests from already cancelled executions before checking session host grants, and resolve pending approvals as denied when execution cancellation interrupts review.
- Preserve accepted review results and session grants when cancellation happens after acceptance.

## Testing

Add regression coverage for same-turn and later-turn settings changes, the original review working directory, cancellation before and after review acceptance, late callbacks, background process termination, and reuse of accepted session grants by new executions.

GitOrigin-RevId: 29487488da9ab43700ba6684c61eea86f30a03a8
This commit is contained in:
Abhinav authored and copyberry committed 2026-09-10 16:17:49 +00:00
1 parent 6bb5be869f
commit bfca0335fa
7 files changed
+586 -172

No files matched your search

+2 -1
View File
@@ -94,13 +94,14 @@ impl GuardianReviewContext {
pub(crate) fn from_resolved_settings(
turn: Arc<TurnContext>,
settings: &ResolvedStepSettings,
environments: &TurnEnvironmentSnapshot,
) -> Self {
Self {
parent_response_id: turn
.extension_data
.get::<codex_api::ResponseId>()
.map(|id| id.0.clone()),
environments: turn.environments.clone(),
environments: environments.clone(),
model_info: Arc::clone(&settings.model_info),
reasoning_effort: settings.reasoning_effort().cloned(),
reasoning_summary: settings.reasoning_summary,