mirror of
https://github.com/openai/codex.git
synced 2026-10-29 19:08:43 +00:00
## Why Guardian review and classification telemetry lacks the context mode needed to distinguish `legacy`, `independent`, and `thread_owned` reviews. ## What changed - Add `guardian_context_mode` to review and classification analytics and `context_mode` to their metrics. - Capture the mode from the conversation history snapshot before review preparation or classification setup so failure metrics retain it, including when review preparation or reviewer startup fails. - Use `unknown` for review metric tags when no context mode is available. ## Testing Update metric assertions to cover `thread_owned` classification tags and the `unknown` review fallback. GitOrigin-RevId: 79f7d11b3e4ccfc53681890d75fbc7c54e1ce7de
51 lines
1.4 KiB
Rust
51 lines
1.4 KiB
Rust
//! Guardian V2 classifier and fast-decision facts, enriched by the existing reducer.
|
|
//! Payloads contain attribution and bounded outcomes, never prompts or tool arguments.
|
|
|
|
use crate::events::CodexAppServerClientMetadata;
|
|
use crate::events::CodexRuntimeMetadata;
|
|
use codex_protocol::protocol::ThreadSource;
|
|
use serde::Serialize;
|
|
|
|
#[derive(Serialize)]
|
|
pub struct GuardianV2Event {
|
|
pub thread_id: String,
|
|
pub turn_id: String,
|
|
pub item_id: Option<String>,
|
|
pub model: Option<String>,
|
|
pub occurred_at_ms: u64,
|
|
#[serde(flatten)]
|
|
pub kind: GuardianV2EventKind,
|
|
}
|
|
|
|
#[derive(Serialize)]
|
|
#[serde(untagged)]
|
|
pub enum GuardianV2EventKind {
|
|
Classification {
|
|
guardian_context_mode: &'static str,
|
|
outcome: &'static str,
|
|
risk_level: Option<&'static str>,
|
|
duration_ms: u64,
|
|
},
|
|
FastDecision {
|
|
decision: &'static str,
|
|
},
|
|
}
|
|
|
|
#[derive(Serialize)]
|
|
pub(crate) struct GuardianV2EventRequest {
|
|
pub(crate) event_type: &'static str,
|
|
pub(crate) event_params: GuardianV2EventParams,
|
|
}
|
|
|
|
#[derive(Serialize)]
|
|
pub(crate) struct GuardianV2EventParams {
|
|
pub(crate) session_id: String,
|
|
pub(crate) app_server_client: CodexAppServerClientMetadata,
|
|
pub(crate) runtime: CodexRuntimeMetadata,
|
|
pub(crate) thread_source: Option<ThreadSource>,
|
|
pub(crate) subagent_source: Option<String>,
|
|
pub(crate) parent_thread_id: Option<String>,
|
|
#[serde(flatten)]
|
|
pub(crate) guardian_v2: GuardianV2Event,
|
|
}
|