mirror of
https://github.com/openai/codex.git
synced 2026-09-20 12:47:38 +00:00
## Why Paginated forks can retain a `history_base` pointer to another rollout. Deleting or compressing either side of that relationship can leave the fork without the rollout history it references. ## What changed - Add a rollout reference index that scans active, archived, and compressed rollout metadata. - Reject deletion when a rollout is still referenced by a fork outside the requested deletion set. - Delete spawned thread subtrees as one store operation so internal references do not block deleting the complete subtree, while external references preflight the request before any files are removed. - Skip referenced rollouts, fork-pointer rollouts, and rollouts with unreadable metadata during background compression. ## Testing - Cover reference indexing across active, archived, compressed, duplicate, and self-referencing rollouts. - Verify deletion rejects external references without partially deleting a subtree and permits batch deletion of internally referenced threads. - Verify compression preserves fork pointer chains and continues past unreadable metadata. GitOrigin-RevId: a8672727f8706e743d7fb3ca895a1d9ceac98a3c
91 lines
3.1 KiB
Rust
91 lines
3.1 KiB
Rust
//! Rollout persistence and discovery for Codex session files.
|
|
|
|
use std::sync::LazyLock;
|
|
|
|
use codex_protocol::protocol::SessionSource;
|
|
|
|
pub(crate) mod compression;
|
|
pub(crate) mod config;
|
|
pub(crate) mod list;
|
|
pub(crate) mod metadata;
|
|
mod model_context;
|
|
mod ordinal;
|
|
mod persistence_metrics;
|
|
pub(crate) mod policy;
|
|
pub(crate) mod recorder;
|
|
mod reverse_jsonl_scanner;
|
|
mod rollout_reference_index;
|
|
pub(crate) mod search;
|
|
pub(crate) mod session_index;
|
|
mod sqlite_metrics;
|
|
pub mod state_db;
|
|
|
|
pub(crate) use codex_protocol::protocol;
|
|
|
|
pub const SESSIONS_SUBDIR: &str = "sessions";
|
|
pub const ARCHIVED_SESSIONS_SUBDIR: &str = "archived_sessions";
|
|
pub static INTERACTIVE_SESSION_SOURCES: LazyLock<Vec<SessionSource>> = LazyLock::new(|| {
|
|
vec![
|
|
SessionSource::Cli,
|
|
SessionSource::VSCode,
|
|
SessionSource::Custom("atlas".to_string()),
|
|
SessionSource::Custom("chatgpt".to_string()),
|
|
]
|
|
});
|
|
|
|
pub use codex_protocol::protocol::SessionMeta;
|
|
pub use compression::RolloutLineReader;
|
|
pub use compression::existing_rollout_path;
|
|
pub use compression::open_rollout_line_reader;
|
|
pub use compression::plain_rollout_path;
|
|
pub use compression::spawn_rollout_compression_worker;
|
|
pub use config::Config;
|
|
pub use config::RolloutConfig;
|
|
pub use config::RolloutConfigView;
|
|
pub use list::Cursor;
|
|
pub use list::SortDirection;
|
|
pub use list::ThreadItem;
|
|
pub use list::ThreadListConfig;
|
|
pub use list::ThreadListLayout;
|
|
pub use list::ThreadSortKey;
|
|
pub use list::ThreadsPage;
|
|
pub use list::find_archived_thread_path_by_id_str;
|
|
pub use list::find_thread_path_by_id_str;
|
|
#[deprecated(note = "use find_thread_path_by_id_str")]
|
|
pub use list::find_thread_path_by_id_str as find_conversation_path_by_id_str;
|
|
pub use list::get_threads;
|
|
pub use list::get_threads_in_root;
|
|
pub use list::parse_cursor;
|
|
pub use list::read_head_for_summary;
|
|
pub use list::read_session_meta_line;
|
|
pub use list::read_thread_item_from_rollout;
|
|
pub use list::rollout_date_parts;
|
|
pub use metadata::builder_from_items;
|
|
pub use model_context::ModelContextScan;
|
|
pub use model_context::ModelContextScanProgress;
|
|
pub use persistence_metrics::RolloutPersistenceBatchMeasurement;
|
|
pub use persistence_metrics::RolloutPersistenceTelemetry;
|
|
pub use persistence_metrics::measure_and_filter_rollout_items;
|
|
pub use policy::is_persisted_rollout_item;
|
|
pub use policy::persisted_rollout_items;
|
|
pub use policy::should_persist_response_item_for_memories;
|
|
pub use recorder::RolloutRecorder;
|
|
pub use recorder::RolloutRecorderParams;
|
|
pub use recorder::append_rollout_item_to_path;
|
|
pub use reverse_jsonl_scanner::ReverseJsonlScanner;
|
|
pub use reverse_jsonl_scanner::ScanOutcome;
|
|
pub use rollout_reference_index::RolloutReferenceIndex;
|
|
pub use search::first_rollout_content_match_snippet;
|
|
pub use search::search_rollout_matches;
|
|
pub use search::search_rollout_paths;
|
|
pub use session_index::append_thread_name;
|
|
pub use session_index::find_thread_meta_by_name_str;
|
|
pub use session_index::find_thread_name_by_id;
|
|
pub use session_index::find_thread_names_by_ids;
|
|
pub use session_index::remove_thread_name_entries;
|
|
pub use state_db::StateDbHandle;
|
|
pub use state_db::sqlite_telemetry_recorder;
|
|
|
|
#[cfg(test)]
|
|
mod tests;
|