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

+2 -2
View File
@@ -675,6 +675,7 @@ mod tests {
use codex_protocol::protocol::InterAgentCommunication;
use codex_protocol::security_risk::SecurityRiskScore;
use pretty_assertions::assert_eq;
use std::collections::BTreeMap;
#[test]
fn serializes_memory_rollout_with_agents_removed_but_environment_kept() {
@@ -725,8 +726,7 @@ mod tests {
RolloutItem::ResponseItem(mixed_contextual_message.into()),
RolloutItem::ResponseItem(skill_message.into()),
RolloutItem::SecurityRiskScore(SecurityRiskScore {
category: "action_risk".to_string(),
score: 0.92,
scores: BTreeMap::from([("action_risk".to_string(), 0.92)]),
}),
RolloutItem::ResponseItem(subagent_message.clone().into()),
])