Record root turn IDs in Guardian review analytics (#63837)

## Why

The review's `turn_id` alone can't identify the root turn of the action
being reviewed. For example, a background terminal can request network
access during a later turn.

## What changed

Add an optional `root_turn_id` to `codex_guardian_review` events. When
a verified execution tag ties a network request to a registered tool
call, use the root turn ID captured when the call started. Leave the
field unset when the reviewed action's root turn is unknown.

## Testing

Extend the MCP approval test to check the reported root turn ID. Cover
untagged network requests and verify that a cross-turn network review
reports the active turn's `turn_id` alongside the issuing turn's
`root_turn_id`.

GitOrigin-RevId: f0ae40ec4fc441891b4d843912f823a2385fa36f
This commit is contained in:
Eddie Chen
2026-11-25 06:19:21 +00:00
committed by copyberry
parent c265acf3b1
commit 1ed2a3f22d
13 changed files with 197 additions and 37 deletions
@@ -298,6 +298,7 @@ async fn guardian_review_event_ingests_custom_fact_with_optional_target_item() {
guardian_context_mode: None,
thread_id: "thread-guardian".to_string(),
turn_id: "turn-guardian".to_string(),
root_turn_id: None,
review_id: "review-guardian".to_string(),
target_item_id: None,
approval_request_source: GuardianApprovalRequestSource::DelegatedSubagent,