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:
jif authored and copyberry committed 2026-09-01 22:02:42 +00:00
1 parent a876a9e494
commit 86b7d12742
17 files changed
+272 -20

No files matched your search

+7
View File
@@ -33,6 +33,7 @@ use crate::facts::TurnCodexErrorFact;
use crate::facts::TurnProfileFact;
use crate::facts::TurnResolvedConfigFact;
use crate::facts::TurnTokenUsageFact;
use crate::guardian_v2::GuardianV2Event;
use crate::now_unix_millis;
use crate::reducer::AnalyticsReducer;
use crate::reducer::MAX_PLUGIN_MEASUREMENTS_PER_BATCH;
@@ -492,6 +493,12 @@ impl AnalyticsEventsClient {
)));
}
pub fn track_guardian_v2_event(&self, event: GuardianV2Event) {
self.record_fact(AnalyticsFact::Custom(CustomAnalyticsFact::GuardianV2(
Box::new(event),
)));
}
pub fn track_goal_event(&self, event: CodexGoalEvent) {
self.record_fact(AnalyticsFact::Custom(CustomAnalyticsFact::Goal(Box::new(
event,