Require Guardian review for incompatible compaction checkpoints (#42588)

## Why

Guardian can reuse an opaque parent compaction only when the checkpoint's
recorded producer hash matches the scoring model. Missing or incompatible
provenance must not allow an asynchronous score or cached approval to omit
compacted context.

## What changed

- Record the producing model's compatibility hash on compaction history items
  and expose the latest checkpoint hash through conversation snapshots.
- In thread-owned context mode, fail closed and require synchronous review when
  checkpoint reuse is enabled but the latest checkpoint is incompatible or has
  unknown provenance.
- Reject incompatible checkpoints in the sampler while preserving the legacy
  context behavior.

## Testing

Add coverage for local, remote, resumed, compacted, and rolled-back histories,
including matching, mismatched, missing, and empty compatibility hashes.

GitOrigin-RevId: 1ce959cb276edc602fd7dfa442133c7fe5e53857
This commit is contained in:
felixxia-oai authored and copyberry committed 2026-09-03 17:48:15 +00:00
1 parent 1d6727c0b5
commit ad8ee16a5f
17 files changed
+505 -88

No files matched your search

+7 -1
View File
@@ -11,6 +11,7 @@ use crate::session::step_settings::StepSettingsUpdate;
use codex_diagnostics::Gauge;
use codex_diagnostics::GaugeGuard;
use codex_exec_server::SelectedCapabilityRootsStatus;
use codex_extension_api::ConversationHistorySnapshot;
use codex_extension_api::ThreadIdleCause;
use codex_features::Feature;
use codex_history::RolloutItem;
@@ -804,9 +805,14 @@ impl CodexThread {
self.session.multi_agent_version()
}
/// Shares an immutable view of the live parent model context and retained host facts.
pub async fn conversation_history_snapshot(&self) -> Arc<dyn ConversationHistorySnapshot> {
self.session.conversation_history_snapshot().await
}
/// Returns the current user-authorization revision for Guardian.
pub async fn guardian_authorization_version(&self) -> GuardianAuthorizationVersion {
let history = self.session.conversation_history_snapshot().await;
let history = self.conversation_history_snapshot().await;
self.thread_extension_data()
.get_or_init(GuardianReviewEvidence::default)
.authorization_version(history.as_ref())