mirror of
https://github.com/openai/codex.git
synced 2026-11-26 07:26:11 +00:00
Preserve Guardian authorization evidence across checkpoint migration (#45782)
## Why Older compaction checkpoints can lack a producer model hash. Enabling thread-owned Guardian context must accommodate those checkpoints without losing user instructions or verified answers. ## What changed - Select review policy from each history snapshot independently of the session's evidence capture policy. - Keep legacy review for checkpoints with missing or empty producer hashes when the transcript preserves the evidence. Preserve strict compatibility checks when review depends on retained-only evidence. - Continue capturing retained instructions and answers during migration, while supplying legacy reviews with runtime answers and subagent reviews with root authorization evidence. - Record producer model hashes on new compactions regardless of context mode. ## Testing Add coverage for checkpoint migration across compaction and resume in both history storage modes, snapshot policy stability, retained-evidence preservation, and authorization revalidation for owning sessions and subagents. GitOrigin-RevId: ec72b4a51d40729173e24ac1b53b7d516ddaa825
This commit is contained in:
1 parent
1427825c40
commit
0c3a14bbc2
20 files changed
+564
-85
No files matched your search
@@ -12,7 +12,6 @@ use super::score::GuardianV2ScoreProgress;
|
||||
use codex_core::CodexThread;
|
||||
use codex_core::ThreadManager;
|
||||
use codex_core::context::GuardianContextMode;
|
||||
use codex_core::context::GuardianReviewEvidence;
|
||||
use codex_extension_api::ApprovalDecision;
|
||||
use codex_extension_api::ApprovalDecisionInput;
|
||||
use codex_extension_api::ApprovalReviewContributor;
|
||||
@@ -160,14 +159,12 @@ async fn cached_evidence(
|
||||
record_fast_decision(metrics, "deferred", "scoring_failure");
|
||||
return Err(GuardianReviewReason::ScoringFailure);
|
||||
}
|
||||
let context_mode = store
|
||||
.get_or_init(GuardianReviewEvidence::default)
|
||||
.context_mode();
|
||||
let history = thread.conversation_history_snapshot().await;
|
||||
let context_mode = GuardianContextMode::from_history(history.as_ref());
|
||||
if context_mode == GuardianContextMode::ThreadOwned {
|
||||
let sampler = store
|
||||
.get::<LunaSampler>()
|
||||
.ok_or(GuardianReviewReason::MissingScore)?;
|
||||
let history = thread.conversation_history_snapshot().await;
|
||||
if select_parent_compaction(
|
||||
context_mode,
|
||||
config,
|
||||
|
||||
@@ -175,6 +175,7 @@ async fn assert_catalog_budget(evidence: BudgetEvidence) -> Result<()> {
|
||||
.await?;
|
||||
let history: Arc<dyn ConversationHistorySnapshot> = match evidence {
|
||||
BudgetEvidence::Checkpoint => Arc::new(TestRetainedHistory {
|
||||
retained_context: None,
|
||||
retained: history.clone(),
|
||||
current: TestConversationHistory(history),
|
||||
compaction_model_hash: Some("budget-checkpoint".to_owned()),
|
||||
|
||||
@@ -411,9 +411,14 @@ struct TestRetainedHistory {
|
||||
current: TestConversationHistory,
|
||||
retained: Vec<ResponseItem>,
|
||||
compaction_model_hash: Option<String>,
|
||||
retained_context: Option<codex_history::RetainedContext>,
|
||||
}
|
||||
|
||||
impl ConversationHistorySnapshot for TestRetainedHistory {
|
||||
fn retained_context(&self) -> Option<&codex_history::RetainedContext> {
|
||||
self.retained_context.as_ref()
|
||||
}
|
||||
|
||||
fn latest_compaction_model_hash(&self) -> Option<&str> {
|
||||
self.compaction_model_hash.as_deref()
|
||||
}
|
||||
@@ -2997,6 +3002,7 @@ async fn assert_parent_compaction_reuse(thread_context_enabled: bool) -> Result<
|
||||
retained,
|
||||
current: conversation_history,
|
||||
compaction_model_hash: parent_model.comp_hash.clone(),
|
||||
retained_context: thread_context_enabled.then(codex_history::RetainedContext::default),
|
||||
};
|
||||
thread_store.insert(parent_model);
|
||||
|
||||
@@ -3091,6 +3097,8 @@ async fn assert_parent_compaction_reuse(thread_context_enabled: bool) -> Result<
|
||||
conversation_history: Arc::new(TestRetainedHistory {
|
||||
current: TestConversationHistory(vec![latest_compaction, oversized_compaction]),
|
||||
retained: Vec::new(),
|
||||
retained_context: thread_context_enabled
|
||||
.then(codex_history::RetainedContext::default),
|
||||
compaction_model_hash: thread_store
|
||||
.get::<ModelInfo>()
|
||||
.and_then(|model| model.comp_hash.clone()),
|
||||
|
||||
@@ -214,7 +214,7 @@ impl GuardianV2Extension {
|
||||
let guardian_evidence = input
|
||||
.thread_store
|
||||
.get_or_init(GuardianReviewEvidence::default);
|
||||
let context_mode = guardian_evidence.context_mode();
|
||||
let context_mode = GuardianContextMode::from_history(input.conversation_history.as_ref());
|
||||
let selected_compaction = match select_parent_compaction(
|
||||
context_mode,
|
||||
&guardian_config,
|
||||
|
||||
Reference in new issue
Block a user