mirror of
https://github.com/openai/codex.git
synced 2026-11-25 15:24:26 +00:00
Add Guardian V2 analytics events (#42144)
## What changed - Emit `codex_guardian_v2_classification` events with the outcome, risk level, duration, model, and thread attribution. - Emit `codex_guardian_v2_fast_decision` events when Guardian V2 approves an action without a full review. - Add `guardian_v2_enabled` to turn analytics, accounting for review scope and model requirements. ## Testing - Extend the Guardian V2 app-server coverage to verify event payloads, attribution, enablement state, and scoped event emission. GitOrigin-RevId: 0805975f8e8f9d954aa1058ea8c60545a090ae74
This commit is contained in:
1 parent
a876a9e494
commit
86b7d12742
17 files changed
+272
-20
No files matched your search
@@ -0,0 +1,49 @@
|
||||
//! 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 {
|
||||
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,
|
||||
}
|
||||
Reference in new issue
Block a user