mirror of
https://github.com/openai/codex.git
synced 2026-12-05 01:00:54 +00:00
Persist Guardian review failures for reports across restarts (#51651)
## Why Failed Guardian review evidence was process-local, so restarting Codex lost the context needed for later diagnostic reports. ## What changed - Persist failed-review records in SQLite before reviewer cleanup, retaining at most 64 records globally, eight per thread, and 8 MiB of evidence. Delete persisted evidence when its reviewed thread is deleted. - Recover and deduplicate persisted and in-memory records for the reported task tree when uploading `auto-review-failures.jsonl`. - Bound persistence attempts to 250 ms and retain an in-memory fallback when storage is unavailable. Keep capture gated by user opt-in and non-ephemeral sessions, and export evidence only when logs are included. ## Testing Add coverage for persistence across reopen and process restart, retention limits, cascading deletion, busy-storage fallback, and report uploads with and without logs, including SQLite log failures. GitOrigin-RevId: ea2da1818d4a5da3da29f211042ca45e834342bc
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//! Captures failed-review context for the extension's bounded feedback recorder.
|
||||
//! Captures failed-review context and retains it for opt-in feedback before reviewer cleanup.
|
||||
|
||||
use super::approval_request::format_guardian_action_pretty;
|
||||
use super::approval_request::guardian_request_target_item_id;
|
||||
@@ -27,7 +27,7 @@ pub(super) async fn record_failed_review(
|
||||
};
|
||||
let instructions = reviewer.get_prompt_base_instructions().await;
|
||||
let history = reviewer.clone_history().await;
|
||||
feedback.store(codex_guardian_reviewer::ReviewFeedbackContext {
|
||||
let record = feedback.into_record(codex_guardian_reviewer::ReviewFeedbackContext {
|
||||
reviewed_thread_id: params.parent_session.thread_id(),
|
||||
reviewed_turn_id: guardian_request_turn_id(
|
||||
¶ms.request,
|
||||
@@ -41,4 +41,11 @@ pub(super) async fn record_failed_review(
|
||||
instructions: Some(&instructions.text),
|
||||
history: history.raw_items().collect(),
|
||||
});
|
||||
if let Some(record) = record {
|
||||
codex_feedback::record_guardian_review_failure(
|
||||
params.parent_session.state_db().as_deref(),
|
||||
record,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3813,7 +3813,7 @@ async fn guardian_ephemeral_retry_preserves_parallel_trunk_and_fork_history() ->
|
||||
let refreshed_user_message = last_user_message_text_from_body(&refreshed_request_body);
|
||||
assert!(refreshed_user_message.contains("Now inspect whether pushing is safe."));
|
||||
assert!(refreshed_user_message.contains(&second_action));
|
||||
let feedback = codex_feedback::guardian_review_failures(&[session.thread_id()])
|
||||
let feedback = codex_feedback::guardian_review_failures(session.state_db().as_deref(), &[session.thread_id()]).await
|
||||
.attachment
|
||||
.expect("failed ephemeral review survives cleanup and subsequent allowed reviews");
|
||||
let record: serde_json::Value = serde_json::from_slice(&feedback.buffer)?;
|
||||
|
||||
Reference in New Issue
Block a user