Initialize Guardian evidence cursors from thread history state (#60670)

## What changed

Expose history initialization and the effective history mode to thread-ready contributors. Add `EvidenceCursor::at_thread_ready` with paginated-history validation:

- Start new or cleared threads at position zero without requiring an existing rollout.
- Start resumed, forked, or supplied-history threads at the durable tail to avoid backfilling existing evidence.
- Skip the initial `SessionMeta` header when capturing evidence from position zero.

## Testing

Extend evidence tests to cover initialization before a rollout exists, capture of the first original record, rejection of resume without a rollout, and exclusion of existing records on resume.

GitOrigin-RevId: 32aa8e2afb71eb4e882b5f1fb107ac8616b33c8e
This commit is contained in:
felixxia-oai
2026-11-10 22:00:08 +00:00
committed by copyberry
parent 39f422522e
commit fad8b3d5bc
7 changed files with 101 additions and 10 deletions
+4 -1
View File
@@ -433,12 +433,15 @@ impl CodexThread {
if contributors.is_empty() {
return;
}
let config = self.config().await;
let (config, history_initialization, history_mode) =
self.session.thread_ready_config().await;
for contributor in contributors {
contributor
.on_thread_ready(codex_extension_api::ThreadReadyInput {
config: config.as_ref(),
session_source: &self.session_source,
history_initialization,
history_mode,
session_store: &self.session.services.session_extension_data,
thread_store: &self.session.services.thread_extension_data,
})
+12
View File
@@ -2473,6 +2473,18 @@ impl Session {
)
}
pub(crate) async fn thread_ready_config(
&self,
) -> (Arc<Config>, HistoryInitialization, ThreadHistoryMode) {
let state = self.state.lock().await;
let config = &state.session_configuration;
(
Arc::clone(&config.original_config_do_not_use),
self.history_initialization,
config.history_mode,
)
}
pub(crate) async fn get_config(&self) -> std::sync::Arc<Config> {
let state = self.state.lock().await;
state