Track inherited paginated rollout prefixes (#33930)

## What changed

- Add `HistoryPosition` to identify a source thread and an exclusive rollout
  prefix by ordinal and JSONL byte offset.
- Add optional `history_base` metadata to `SessionMeta` so a thread can record
  an inherited prefix of another paginated rollout.
- Default missing `history_base` metadata to `None` and omit it when unset to
  preserve compatibility with existing rollout metadata.

## Testing

- Verify that legacy session metadata without `history_base` deserializes with
  no inherited history position.

GitOrigin-RevId: 3b2b07a2dfee793d3b37b0a60529f856f167dbc1
This commit is contained in:
Owen Lin
2026-07-18 00:06:49 +00:00
committed by copyberry
parent 15d7d2a733
commit bcdc695877
14 changed files with 33 additions and 0 deletions
@@ -606,6 +606,7 @@ fn write_rollout(path: &std::path::Path, thread_id: ThreadId, message: &str) ->
selected_capability_roots: Vec::new(),
memory_mode: None,
history_mode: Default::default(),
history_base: None,
subagent_history_start_ordinal: None,
multi_agent_version: None,
context_window: None,
+3
View File
@@ -53,6 +53,7 @@ async fn extract_metadata_from_rollout_uses_session_meta() {
selected_capability_roots: Vec::new(),
memory_mode: None,
history_mode: ThreadHistoryMode::Paginated,
history_base: None,
subagent_history_start_ordinal: None,
multi_agent_version: None,
context_window: None,
@@ -150,6 +151,7 @@ async fn extract_metadata_from_rollout_returns_latest_memory_mode() {
selected_capability_roots: Vec::new(),
memory_mode: None,
history_mode: Default::default(),
history_base: None,
subagent_history_start_ordinal: None,
multi_agent_version: None,
context_window: None,
@@ -424,6 +426,7 @@ fn write_rollout_in_sessions_with_cwd(
selected_capability_roots: Vec::new(),
memory_mode: None,
history_mode: Default::default(),
history_base: None,
subagent_history_start_ordinal: None,
multi_agent_version: None,
context_window: None,
+1
View File
@@ -831,6 +831,7 @@ impl RolloutRecorder {
selected_capability_roots,
memory_mode: (!config.generate_memories()).then_some("disabled".to_string()),
history_mode,
history_base: None,
subagent_history_start_ordinal,
multi_agent_version,
context_window: initial_window_id.map(SessionContextWindow::new),
+1
View File
@@ -178,6 +178,7 @@ async fn state_db_init_backfills_before_returning() -> anyhow::Result<()> {
selected_capability_roots: Vec::new(),
memory_mode: None,
history_mode: Default::default(),
history_base: None,
subagent_history_start_ordinal: None,
multi_agent_version: None,
context_window: None,
@@ -45,6 +45,7 @@ fn write_rollout_with_metadata(path: &Path, thread_id: ThreadId) -> std::io::Res
selected_capability_roots: Vec::new(),
memory_mode: None,
history_mode: Default::default(),
history_base: None,
subagent_history_start_ordinal: None,
multi_agent_version: None,
context_window: None,
+1
View File
@@ -178,6 +178,7 @@ fn write_rollout_with_user_message(
selected_capability_roots: Vec::new(),
memory_mode: None,
history_mode: Default::default(),
history_base: None,
subagent_history_start_ordinal: None,
multi_agent_version: None,
context_window: None,
+1
View File
@@ -1336,6 +1336,7 @@ async fn test_updated_at_uses_file_mtime() -> Result<()> {
selected_capability_roots: Vec::new(),
memory_mode: None,
history_mode: Default::default(),
history_base: None,
subagent_history_start_ordinal: None,
multi_agent_version: None,
context_window: None,