Skip guardian prewarm during active reviews

Only run guardian trunk prewarm when the session can immediately acquire
review_lock, and hold that lock through the warmup so a real guardian
review cannot race the same session state in parallel.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Charles Cunningham
2026-03-18 22:38:43 -07:00
co-authored by Codex
parent f6e5a25bb4
commit eb83e6c101
@@ -421,6 +421,10 @@ impl GuardianReviewSessionManager {
}
};
let trunk_guard = match trunk.review_lock.try_lock() {
Ok(trunk_guard) => trunk_guard,
Err(_) => return,
};
if guardian_request_keeps_prompt_cache_warm(
*trunk.last_guardian_request_at.lock().await,
tokio::time::Instant::now(),
@@ -443,6 +447,7 @@ impl GuardianReviewSessionManager {
if prewarm_result.is_ok() {
trunk.record_guardian_request(request_at).await;
}
drop(trunk_guard);
trunk
.prompt_prewarm_in_flight
.store(false, Ordering::Relaxed);