Wait for Guardian score progress in approval tests (#39007)

## Why

Guardian stores a `SecurityRiskScore` before advancing its scored-tool-call
counter. Waiting only for the score can therefore let the test continue while
the asynchronous sampler is still updating its progress state.

## What changed

Wait for `latest_scored_tool_call` to advance before exercising Guardian v2
approval decisions, and reuse the same progress tracker for the subsequent
assertions.

GitOrigin-RevId: 3d92c9a3ccf52f4f43a2454aac60d2479258c1c8
This commit is contained in:
jif
2026-08-17 13:26:19 +00:00
committed by copyberry
parent 04caa22c82
commit def7ed5572
@@ -464,8 +464,15 @@ max_recent_non_user_entries = 8
let session_store = ExtensionData::new("session-1");
let thread_store = test.codex.thread_extension_data();
let score_progress = thread_store
.get::<GuardianV2ScoreProgress>()
.expect("Guardian v2 should track score progress per thread");
tokio::time::timeout(Duration::from_secs(5), async {
while thread_store.get::<SecurityRiskScore>().is_none() {
while score_progress
.latest_scored_tool_call
.load(Ordering::Acquire)
== 0
{
tokio::task::yield_now().await;
}
})
@@ -491,9 +498,6 @@ max_recent_non_user_entries = 8
Some(ReviewDecision::Approved)
);
let score_progress = thread_store
.get::<GuardianV2ScoreProgress>()
.expect("Guardian v2 should track score progress per thread");
assert_eq!(
score_progress
.latest_scored_tool_call