Plan · ox session import · performance
Summarize imported sessions in parallel
An import spends nearly all its time waiting on the summarizer CLI, one session at a time. Run a small, capped pool of summaries at once, and keep the Ledger writes exactly as serialized as they are today.
TL;DR
TL;DR ProblemEach session runs prepare → summarize → upload → commit before the next starts. Summarizing is ~1 minute per session. In local testing on 2026-10-08, 3 Codex sessions took 1m 54s and 4 Claude sessions 3m 09s. ApproachA bounded worker pool (default 3, --parallel N) prepares and summarizes. A single committer uploads and commits finished sessions, so Ledger writes and batched pushes stay serialized. GainSummary time drops to roughly a third with 3 workers. A 7-session import goes from about 6–7 minutes to about 2–3. Biggest riskSummarizer rate limits and cost: several claude or codex runs at once draw on the coworker's own subscription. A low default, the existing per-session retry, and --parallel 1 as an escape hatch bound it. Decision neededThe default worker count (3 proposed), and whether the flag is --parallel or --jobs.
Today versus parallel
The same 7 sessions, scheduled each way. Gold is summarizing (minutes); sage is upload and commit (seconds). The timing is illustrative, scaled to the 2026-10-08 local run.
Today: one at a timeProposed: 3 workers Today the summaries queue behind each other, so total time is the sum of every summary. With 3 workers, a new summary starts whenever one finishes. Commits still happen one at a time; they take seconds, so they never become the bottleneck.
Design
Design: a pool feeding one committer
Workers do everything that's slow and independent. The committer does everything that touches the Ledger, in the same order of checks as today.
The split follows what's safe today. Each session already gets its own staging folder and its own temporary folder for the summarizer. Each summary is its own CLI process. The commit step already takes gitutil.WithRepoLock.
Shared state
What has to change to be safe
| Shared piece | Today | Change |
|---|---|---|
| Saved verdicts (sessions kept local or skipped) | The map is updated and the file rewritten on every verdict, with no lock. | Guard the record with a mutex. |
| Summarizer cache, one per CLI | Filled lazily into a plain map. | Create both up front, or guard the map. The runners themselves are stateless (a binary path and a logger), so concurrent runs are safe. |
| Commits waiting for a push | A slice updated by the loop. | Owned only by the committer goroutine. |
| Progress output | Printed in list order, [i/n]. | One writer. Lines appear as sessions start and finish; the final report stays sorted in list order. |
| Interrupt (Ctrl-C) | The running summary stops, nothing new starts, and finished work is pushed. | The same promise across the pool: cancel every in-flight summary, start none, drain the committer, push. |
Risks and alignment
Risks and how they're bounded
Rate limits and cost
Parallel summaries draw on the coworker's own Claude or Codex plan faster. The default stays low at 3, and failures keep today's per-session retry, so a failure holds that one session with its retry command. --parallel 1 restores today's behavior exactly.
Machine load
Each summary is a full CLI process. The cap also keeps a laptop responsive during a large import.
ADR-016 alignment
ADR-016 has the daemon's queue run summaries one at a time with rate limiting. The import summarizes inline by design, so it needs its own bound. This plan adds that bound and doesn't route import work through the daemon.
Unchanged guarantees
The preview still comes first, and only previewed sessions upload. The just-in-time check still runs after each summary. The secret scan runs before upload, nothing uploads twice, and pushes stay batched.
Steps
- Lock the shared state. Mutex the verdict record, and create the summarizer cache up front. Add concurrent tests.
- Split the publish function. Separate
publishImportinto a worker half (stage, convert, summarize, the verdict, writing artifacts) and a committer half (just-in-time check, secret scan, LFS upload, commit). - Add the pool and the flag. A bounded worker pool feeds a channel to a single committer goroutine, with
--parallel N(default 3, minimum 1). The flag value is carried into the printed upload and retry commands, as--summarizeris. - Keep interrupts and progress honest. The context cancels every worker, the committer drains and pushes, and progress lines go through one writer.
- Tests. Update the order-dependent tests: interrupt, "changes before its turn", and JSON progress. Add tests for: Run with
-race.
- the pool running at most N summaries at once;
- commits staying serialized;
- an interrupt mid-pool;
- verdicts saved from concurrent workers.
- Measure. Rerun the local Tilt import of the Math Blitz fixture with
--parallel 1and3, and record the wall times in the PR.
Implementation notes
Implementation notes
- Loop:
cmd/ox/session_import.gofor i, c := range selected(~line 530) callspublishImportsequentially. Pushes are batched byimportPushBatch = 10. - Per-session work:
publishImportincmd/ox/session_import_publish.go. Summarizing is insummarizeImport, with up toimportSummaryAttemptstries andimportSummaryTimeoutper try. - Verdict cache:
importVerdicts.recordincmd/ox/session_import_index.gochangesSessionsand callsfileutil.AtomicWriteJSON. - Summarizer cache:
productionImportDepsbuildsrunners := map[nativeimport.Agent]agentwork.Runner{}lazily.ClaudeRunnerandCodexRunnerhold onlybinaryPathandlogger. - Commit:
commitImportruns undergitutil.WithRepoLock. - Fixture support:
importFixture.runners(per-CLI fake summarizers, added in #1250) lets a test count concurrent calls per CLI.
enriched by

