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
@@ -2,8 +2,10 @@ use std::sync::Arc;
use crate::ExtensionData;
use crate::ExtensionMetrics;
use codex_history::HistoryInitialization;
use codex_mcp::McpResourceClient;
use codex_protocol::protocol::SessionSource;
use codex_protocol::protocol::ThreadHistoryMode;
use codex_protocol::protocol::TurnEnvironmentSelection;
/// Trusted, host-resolved billing attribution for a thread.
@@ -40,6 +42,10 @@ pub struct ThreadReadyInput<'a, C> {
pub config: &'a C,
/// Source that created the session for this thread.
pub session_source: &'a SessionSource,
/// How the host initialized the history for this runtime.
pub history_initialization: HistoryInitialization,
/// The effective history mode, including the persisted mode on resume.
pub history_mode: ThreadHistoryMode,
/// Store scoped to the host session runtime.
pub session_store: &'a ExtensionData,
/// Store scoped to this thread runtime.
+1
View File
@@ -26,6 +26,7 @@ pub use capabilities::ResponseItemInjector;
pub use capabilities::record_catalog_entries;
pub use catalog_refresh::CatalogRefreshBackoff;
pub use codex_context_fragments::ContextualUserFragment;
pub use codex_history::HistoryInitialization;
pub use codex_mcp::McpProtocolMode;
pub use codex_mcp::ToolInfo as McpToolInfo;
pub use codex_protocol::models::ContentItem;