Support compression for shared rollout lineages (#41357)

## Why

Rollout compression skips files that participate in paginated fork lineages because lineage readers rely on byte offsets into the original JSONL. This prevents shared rollout history from being compressed.

## What changed

- Add a seekable rollout reader that preserves logical JSONL offsets for plain and zstd-compressed files without materializing compressed data beside the rollout.
- Use the reader for lineage validation, model-context replay, and SQLite history projection, including when compression races with a read.
- Add the opt-in `local_thread_store_shared_compression` feature. The default mode continues to leave shared lineages uncompressed for compatibility, while the new mode includes referenced sources and fork pointers.
- Record the uncompressed size in new zstd frames so common prefix-bound checks can avoid decoding the full file.

## Testing

Add coverage for seekable compressed reads, prefix validation across zstd frame shapes, compressed lineage replay and projection, concurrent forks, and compression-mode behavior.

GitOrigin-RevId: 83e519f7eabf7448977eff37c55899858cc17a07
This commit is contained in:
jif authored and copyberry committed 2026-08-28 16:04:26 +00:00
1 parent 39507eea53
commit 1cc81ca89a
14 files changed
+493 -111

No files matched your search

+17 -2
View File
@@ -67,6 +67,7 @@ use codex_protocol::protocol::TurnAbortReason;
use codex_protocol::protocol::TurnAbortedEvent;
use codex_protocol::protocol::TurnEnvironmentSelection;
use codex_protocol::protocol::W3cTraceContext;
use codex_rollout::RolloutCompressionMode;
use codex_rollout::state_db::StateDbHandle;
use codex_skills_extension::HostSkillsService;
use codex_thread_store::InMemoryThreadStore;
@@ -384,6 +385,14 @@ pub fn thread_store_from_config(
let compression_enabled = config
.features
.enabled(Feature::LocalThreadStoreCompression);
let compression_mode = if config
.features
.enabled(Feature::LocalThreadStoreSharedCompression)
{
RolloutCompressionMode::IncludeShared
} else {
RolloutCompressionMode::Standalone
};
let background_migration_enabled = config
.features
.enabled(Feature::BackgroundPaginatedRolloutMigration);
@@ -400,11 +409,17 @@ pub fn thread_store_from_config(
warn!("failed to migrate legacy rollouts on startup: {err}");
}
if compression_enabled {
codex_rollout::spawn_rollout_compression_worker(codex_home);
codex_rollout::spawn_rollout_compression_worker(
codex_home,
compression_mode,
);
}
});
} else if compression_enabled {
codex_rollout::spawn_rollout_compression_worker(config.codex_home.to_path_buf());
codex_rollout::spawn_rollout_compression_worker(
config.codex_home.to_path_buf(),
compression_mode,
);
}
store
}