Store security risk scores as a snapshot (#38567)

## What changed

- Replace the single `category` and `score` fields in `SecurityRiskScore` with a
  deterministic map of category names to scores.
- Validate the full Guardian V2 classifier response before storing it as one
  thread extension value and, for non-ephemeral threads, one rollout item.
- Cover serialization and rollout loading with snapshots containing multiple
  score categories.

GitOrigin-RevId: 24525de691f96bd34ccfe04acab2f01aca309837
This commit is contained in:
jif authored and copyberry committed 2026-08-14 12:16:51 +00:00
1 parent 08c48e3700
commit aa905bb962
10 files changed
+41 -32

No files matched your search

@@ -9,6 +9,7 @@ use codex_protocol::protocol::ContextCompactedEvent;
use codex_protocol::protocol::ThreadRolledBackEvent;
use codex_protocol::security_risk::SecurityRiskScore;
use pretty_assertions::assert_eq;
use std::collections::BTreeMap;
#[test]
fn returns_the_missing_suffix_from_its_visible_boundary() {
@@ -64,8 +65,7 @@ fn requires_a_strict_nonempty_model_prefix() {
}
}
let security_risk = RolloutItem::SecurityRiskScore(SecurityRiskScore {
category: "action_risk".to_string(),
score: 0.92,
scores: BTreeMap::from([("action_risk".to_string(), 0.92)]),
});
metadata_changed.push(security_risk.clone());
assert!(model_transcripts_match(&history, &metadata_changed));