feat: reuse compressed rollout search snippets (#25814)

## Summary
- teach rollout search to return precomputed snippets for compressed
rollouts
- reuse those snippets in local thread search instead of reopening
matching compressed files
- keep the no-`rg` fallback single-pass and add regression coverage for
the compressed path

## Why
`thread/search` currently decodes matching compressed rollouts twice:
once to discover the matching path and again to extract the snippet
shown in results. That defeats a meaningful part of the compressed-read
optimization work.

## Impact
Compressed rollout hits now pay one decode pass on the search path while
plain `.jsonl` hits keep the existing ripgrep-driven flow.

## Validation
- `just test -p codex-rollout`
- `just test -p codex-thread-store`
- `just fix -p codex-rollout`
- `just fix -p codex-thread-store`
- `just fmt`
This commit is contained in:
jif-oai authored and GitHub committed 2026-06-02 11:32:36 +02:00
1 parent 67b805fc11
commit 45912a6dc6
4 files changed
+93 -32

No files matched your search

+26
View File
@@ -23,6 +23,7 @@ use crate::RolloutConfig;
use crate::RolloutRecorder;
use crate::RolloutRecorderParams;
use crate::append_rollout_item_to_path;
use crate::search_rollout_matches;
#[tokio::test]
async fn load_rollout_items_reads_compressed_rollout() -> anyhow::Result<()> {
@@ -104,6 +105,31 @@ async fn append_rollout_item_materializes_compressed_rollout() -> anyhow::Result
Ok(())
}
#[tokio::test]
async fn search_rollout_matches_returns_compressed_snippet() -> anyhow::Result<()> {
let home = TempDir::new()?;
let uuid = Uuid::from_u128(15);
let thread_id = ThreadId::from_string(&uuid.to_string())?;
let rollout_path = rollout_path(home.path(), "2025-01-03T12-00-00", uuid);
write_rollout(&rollout_path, thread_id, "targeted search term")?;
compress_now(&rollout_path)?;
let compressed_path = compressed_rollout_path(&rollout_path);
let matches = search_rollout_matches(
std::path::Path::new("missing-rg-for-test"),
home.path(),
/*archived*/ false,
"search term",
)
.await?;
assert_eq!(
matches.get(compressed_path.as_path()),
Some(&Some("targeted search term".to_string()))
);
Ok(())
}
#[tokio::test]
async fn worker_compresses_old_archived_rollouts_only() -> anyhow::Result<()> {
let home = TempDir::new()?;