Publish Guardian cached scores and coverage atomically (#46245)

## Why

Asynchronous score publication updated the risk score, authorization, and tool-call coverage separately. Approval checks could therefore read inconsistent evidence when deciding whether to reuse a cached score.

## What changed

Keep Guardian's cached score and observation state under one lock, and use consistent snapshots for approval checks. Publish successful scores together with their authorization and classified tool-call index. Preserve timestamp ordering, fail-closed precedence on timestamp ties, and per-call oversized-action tracking.

## Testing

Add regression coverage for rejected delayed results and timestamp ties. Add a gated integration test showing that a delayed score becomes stale after intervening tool calls, while a sufficiently fresh score permits cached approval.

GitOrigin-RevId: 8df6fafd5e0ee59aa0f78f541eac562efce3d4d0
This commit is contained in:
felixxia-oai authored and copyberry committed 2026-09-17 16:06:11 +00:00
1 parent 2833985d88
commit fcf05456bb
12 files changed
+833 -401

No files matched your search

+5 -1
View File
@@ -742,7 +742,11 @@ impl TestCodexBuilder {
.or_else(|| codex_utils_cargo_bin::cargo_bin("codex-code-mode-host").ok());
let thread_manager = Arc::new_cyclic(|manager| {
let mut extensions = self.extensions.to_builder();
codex_guardian_v2::install_reviewer(&mut extensions, manager.clone());
if config.features.enabled(Feature::GuardianV2) {
codex_guardian_v2::install(&mut extensions, auth_manager.clone(), manager.clone());
} else {
codex_guardian_v2::install_reviewer(&mut extensions, manager.clone());
}
let thread_manager = ThreadManager::new(
&config,
auth_manager.clone(),