Tag Guardian review counts with turn origin (#62225)

## Why

Guardian review counts need a way to distinguish automation-triggered
turns from other turns, including when a subagent requests the review.

## What changed

Add a `turn_origin` tag to the `codex.guardian.review` counter based on
the trigger recorded when the turn started. Recognized automation
triggers map to `automation`, missing or empty triggers map to
`unknown`, and all other values map to `other`. This keeps the set of
metric labels bounded.

## Testing

Cover trigger classification for both allow and deny verdicts and
verify that a later user turn on the same thread is counted separately
from an automation turn in both main and subagent threads.

GitOrigin-RevId: 6a5808798df7d184203cea18e60a94a82d71f036
This commit is contained in:
cazhang-oai
2026-11-18 08:20:26 +00:00
committed by copyberry
parent 24e236514b
commit ca21fe65d1
7 changed files with 266 additions and 0 deletions
@@ -178,6 +178,7 @@ impl ReviewHost for super::super::runtime::ReviewRuntime {
codex_guardian_reviewer::ReviewReport::new(codex_guardian_reviewer::ReviewMetadata {
thread_id: session.thread_id.to_string(),
turn_id: assessment_turn_id,
turn_trigger: turn.turn_metadata_state.current_turn_trigger(),
review_id: review_id.to_owned(),
target_item_id,
plugin_id,