Bind permission grants to the originating turn (#49880)

## Why

Background code-mode cells can continue running after a new turn starts. Looking up grants and strict review requirements through the active turn can make those cells lose their approved access or use another turn's permissions.

## What changed

- Keep turn-scoped grants and strict review state in `TurnContext`, retained by captured steps and background cells.
- Record permission responses against the requesting turn, including requests made after a later turn starts.
- Share live session-scoped grants across turns while keeping turn-scoped grants isolated.
- Use the originating turn's permissions and review requirements for tool execution, patches, MCP calls, file uploads, and terminal input.

## Testing

Add regression coverage for background cells retaining grants across turn changes, turn versus session scope, permission requests after the next turn starts, and strict review enabled while `write_stdin` is queued.

GitOrigin-RevId: 641502fbfd43553c2c42424d4aaa53ae8020c850
This commit is contained in:
Adam Perry @ OpenAI
2026-10-01 05:33:36 +00:00
committed by copyberry
parent d2b254fd17
commit 1f52d40704
22 changed files with 914 additions and 415 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
//! Request-scoped settings and capabilities, including the durable context snapshot.
//! Request-scoped settings and capabilities, with live grants bound to the originating turn.
use std::sync::Arc;