Track window and fork positions in turn metadata (#40987)

## What changed

- Add the zero-based `window_number` to Responses turn metadata and include it in prewarm requests.
- Persist `forked_from_ordinal_exclusive` separately from the physical history base so fork lineage remains accurate after reverts and cold resumes.
- Report context-inheriting subagents through `parent_thread_id` without also emitting fork lineage.
- Reserve the new metadata keys while accepting and filtering previously valid configured values so Codex-owned values take precedence.

## Testing

- Cover window numbering across compaction, resume, and fork operations.
- Cover fork cutoff persistence across direct forks, legacy rollouts, reverts into inherited history, and cold resumes.

GitOrigin-RevId: 288f6cd632254814c1f166668b33828082d799a1
This commit is contained in:
Brandon Zhang authored and copyberry committed 2026-08-26 22:37:59 +00:00
1 parent 102ae5e2e6
commit 0d654e6536
33 files changed
+562 -44

No files matched your search

+17
View File
@@ -103,6 +103,7 @@ pub enum RolloutRecorderParams {
/// thread ID stable while creating a new immutable rollout file.
rollout_id_override: Option<RolloutId>,
forked_from_id: Option<ThreadId>,
forked_from_ordinal_exclusive: Option<u64>,
parent_thread_id: Option<ThreadId>,
source: Box<SessionSource>,
thread_source: Option<ThreadSource>,
@@ -199,6 +200,7 @@ impl RolloutRecorderParams {
conversation_id,
rollout_id_override: None,
forked_from_id,
forked_from_ordinal_exclusive: None,
parent_thread_id,
source: Box::new(source),
thread_source,
@@ -283,6 +285,18 @@ impl RolloutRecorderParams {
self
}
/// Set the logical fork boundary independently of the physical history base.
pub fn with_forked_from_ordinal_exclusive(mut self, cutoff: Option<u64>) -> Self {
if let Self::Create {
forked_from_ordinal_exclusive,
..
} = &mut self
{
*forked_from_ordinal_exclusive = cutoff;
}
self
}
pub fn with_subagent_history_start_ordinal(
mut self,
subagent_history_start_ordinal: Option<u64>,
@@ -830,6 +844,7 @@ impl RolloutRecorder {
conversation_id,
rollout_id_override,
forked_from_id,
forked_from_ordinal_exclusive,
parent_thread_id,
source,
thread_source,
@@ -860,6 +875,8 @@ impl RolloutRecorder {
session_id,
id: conversation_id,
forked_from_id,
forked_from_ordinal_exclusive: forked_from_ordinal_exclusive
.filter(|_| forked_from_id.is_some()),
parent_thread_id,
timestamp,
cwd: cwd.clone(),