Files
codex/codex-rs/thread-store/src/original_history.rs
T
felixxia-oai ac03f42e1a Capture Guardian evidence incrementally with explicit acknowledgements (#59670)
## Why

Evidence capture previously reloaded the full history without tracking consumer progress. Live consumers need to read new originals from activation onward and acknowledge them after downstream writes succeed.

## What changed

- Add an in-memory `EvidenceCursor` that starts at the current complete tail without backfilling, captures a fixed unread range, and supports partial acknowledgements. Reads leave progress unchanged.
- Add `ThreadStore::read_original_history` to read original records and their source positions through a fixed cutoff. Local storage supports append-only paginated root histories, including compressed rollouts, and defers unfinished records.
- Reject unsupported histories and invalid ranges, and retain source ordinals as evidence IDs.

## Testing

Add coverage for partial records, compressed suffixes, fixed cutoffs, mismatched thread positions, and truncation. Extend evidence tests to cover activation without backfill, partial acknowledgements, later appends, stale captures, and unchanged cursor progress after capture errors.

GitOrigin-RevId: c7a13749fedc4f44fadddc9dd9875043bccebd95
2026-11-05 15:01:44 +00:00

29 lines
1.1 KiB
Rust

//! Fixed ranges of original records for live, forward-only history consumers.
//! Positions identify persisted source records; they do not acknowledge downstream writes.
use codex_protocol::protocol::HistoryPosition;
use codex_rollout::RolloutItem;
/// Capture the current complete tail, optionally reading records after a saved position.
/// This API deliberately provides no implicit backfill or restart recovery.
pub enum OriginalHistoryRequest {
/// Return only the current complete end position.
Tail,
/// Freeze the current complete tail and read originals after this position.
/// Appends beyond that cutoff are excluded from the returned records.
After(HistoryPosition),
}
/// One original record and the exclusive position immediately after it.
pub struct OriginalHistoryItem {
pub item: RolloutItem,
pub end: HistoryPosition,
}
/// Original records in source order and their fixed upper boundary.
/// A tail request returns no items. Reading never advances consumer progress.
pub struct OriginalHistoryRead {
pub items: Vec<OriginalHistoryItem>,
pub end: HistoryPosition,
}