mirror of
https://github.com/openai/codex.git
synced 2026-12-02 00:31:03 +00:00
Track whether Guardian v3 shadow verdicts are ready by v2 (#64836)
## What changed Add the `v3_ready` tag to the `codex.guardian_v3.shadow.pair` counter so paired verdicts can be grouped by whether the v3 shadow verdict was validated at or before the live v2 verdict. ## Testing Extend the shadow comparison test to check the tag when v3 validates before, at the same time as, and after v2. GitOrigin-RevId: dffc58458d8eb6e7f6062ebc5eb8ccea36edb9f7
This commit is contained in:
@@ -369,8 +369,10 @@ mod tests {
|
||||
.with_metrics_without_metadata_tags(metrics)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shadow_comparison_reports_each_sample_once() {
|
||||
#[test_case(1, "true"; "shadow validated earlier")]
|
||||
#[test_case(2, "true"; "simultaneous verdicts")]
|
||||
#[test_case(3, "false"; "shadow validated later")]
|
||||
fn shadow_comparison_reports_each_sample_once(shadow_ms: u64, expected_ready: &str) {
|
||||
use crate::CohortSample;
|
||||
use crate::GuardianReviewOutcome;
|
||||
use crate::ReviewDeadline;
|
||||
@@ -387,10 +389,11 @@ mod tests {
|
||||
);
|
||||
let [live, shadow] = CohortSample::start(&telemetry, GuardianScope::Mcp, started);
|
||||
let mut analytics = GuardianReviewAnalyticsResult::without_session();
|
||||
analytics.verdict_validated_at = Some(started);
|
||||
shadow.finish(&allow, &analytics);
|
||||
analytics.verdict_validated_at = Some(started + Duration::from_millis(shadow_ms));
|
||||
shadow.finish(&deny, &analytics);
|
||||
analytics.verdict_validated_at = Some(started + Duration::from_millis(2));
|
||||
analytics.context_changed = true;
|
||||
live.finish(&deny, &analytics);
|
||||
live.finish(&allow, &analytics);
|
||||
|
||||
let [live, shadow] = CohortSample::start(&telemetry, GuardianScope::Mcp, started);
|
||||
live.preparation_failed(&ReviewDecision::TimedOut, ReviewDeadline::Unlimited);
|
||||
@@ -399,8 +402,9 @@ mod tests {
|
||||
let snapshot = telemetry.snapshot_metrics().unwrap();
|
||||
let (pair, count) = counter_point(&snapshot, "codex.guardian_v3.shadow.pair");
|
||||
assert_eq!(count, 1);
|
||||
assert_eq!(pair["v2_outcome"], "deny");
|
||||
assert_eq!(pair["v3_outcome"], "allow");
|
||||
assert_eq!(pair["v2_outcome"], "allow");
|
||||
assert_eq!(pair["v3_outcome"], "deny");
|
||||
assert_eq!(pair["v3_ready"], expected_ready);
|
||||
assert_eq!(pair["context_changed"], "true");
|
||||
|
||||
let reviews = find_metric(&snapshot, "codex.guardian_v3.shadow.review");
|
||||
|
||||
@@ -155,10 +155,11 @@ impl Comparison {
|
||||
// GV2 may retry with new evidence after GV3 finishes. Disagreement rates
|
||||
// should use only pairs with context_changed=false.
|
||||
let changed = ("context_changed", bool_tag(live.context_changed));
|
||||
let ready = ("v3_ready", bool_tag(shadow.elapsed <= live.elapsed));
|
||||
self.telemetry.counter(
|
||||
"codex.guardian_v3.shadow.pair",
|
||||
/*inc*/ 1,
|
||||
&[scope, v2, v3, changed],
|
||||
&[scope, v2, v3, changed, ready],
|
||||
);
|
||||
for side in [live, shadow] {
|
||||
self.telemetry.record_duration(
|
||||
|
||||
Reference in New Issue
Block a user