Repository navigation
fix(codex): index a new account home before bridging history into it - #22971
brennanb2025 merged 5 commits into
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe account bridge checks the target Codex state DB and backfill status before it links rollout files. When eligible, it can create a state DB. The bridge records thread IDs and timestamps for linked and already-existing rollouts, then calls index healing. The healer reads missing threads in bounded batches and reports outcomes. Tests cover DB creation, readiness checks, rollout linking, index healing, and migration history bridging. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to Bridging large history into an account home that already has some conversations but no Codex database can still slow or time out the first launch. Some bridged conversations may also stay missing from Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to History from one Codex account can now become searchable in another account’s home more reliably. This appears intentional, and no direct external disclosure was established, but the account boundary and failure-recovery behavior merit review. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation The PR implements the main ordering fix for [
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: f260924b-c89e-4de0-80a8-b1e5b9650f8b
📥 Commits
Reviewing files that changed from the base of the PR and between 8d21fdb and 4bcc1903e93fca1c79aa3ac1b6df9064783e0864.
📒 Files selected for processing (10)
src/main/codex-accounts/runtime-home-service-per-account-migration.test.tssrc/main/codex/codex-account-session-bridge.test.tssrc/main/codex/codex-account-session-bridge.tssrc/main/codex/codex-account-session-index-heal.test.tssrc/main/codex/codex-account-session-index-heal.tssrc/main/codex/codex-session-index-heal-state.tssrc/main/codex/codex-session-index-heal.tssrc/main/codex/codex-state-db-test-fixture.tssrc/main/codex/codex-state-db.test.tssrc/main/codex/codex-state-db.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
There was a problem hiding this comment.
Important
The new gate has two fail-open paths: it ignores compressed (.jsonl.zst) history, and it treats a state DB without backfill_state as safe to link into even though Codex will then run a blocking backfill over it.
Reviewed changes
- Bridge gate —
isReadyForBridgedHistorynow runscodex app-serveron an empty home so Codex creates and stamps its state DB before any history is linked, then links and lazily indexes viathread/read. - New per-account heal —
codex-account-session-index-heal.tsaddscreateCodexAccountStateDbandhealCodexAccountSessionIndex, reusing the system-home heal's launch settings and batch limits. - State DB read —
readIndexedCodexThreadIdsreads indexed thread ids read-only from the neweststate_N.sqlite. - Rollout parsing — extracted
parseCodexRolloutThreadIdand exported the heal constants/invocation builder for reuse. - Tests — stub-driven coverage of the gate branches, the heal diff/retry/abort paths, and a new state-DB test fixture.
ℹ️ The gate's core Codex assumption is not pinned by the real-binary contract test
The new gate depends on "an app-server session that sends no RPC still leaves the state DB stamped complete before initialize returns." That holds for Codex 0.156.1, but the repo's codex-index-heal-binary-contract.test.ts exists specifically to catch Codex drift, and it does not assert it. Every new test for the gate stubs createStateDb, so a Codex release that changed this ordering would keep them all green while the gate silently stopped linking.
Technical details
# Pin the empty-session state-DB contract
## Affected sites
- `src/main/codex/codex-index-heal-binary-contract.test.ts:80-88` — `createBackfilledCodexHome` asserts only `readThreadRows(home) === []`, which passes vacuously when `findNewestCodexStateDbPath` returns null (no DB created); it never calls `readCodexStateDbBackfillStatus`.
- `src/main/codex/codex-account-session-index-heal.ts:62-66` — `createCodexAccountStateDb` relies on that contract.
- `src/main/codex/codex-account-session-bridge.ts:71-81` — the gate relies on the resulting `complete` status.
## Required outcome
- The real binary must prove that a no-RPC app-server session on an empty home leaves `readCodexStateDbBackfillStatus(home).kind === 'complete'`, so the gate's ordering assumption is guarded rather than hand-verified.
## Open questions for the human
- The contract job pins `CODEX_CLI_VERSION: 0.150.1` while this change was verified on 0.156.1; is the gate's behavior the same on the CI version?ℹ️ Nitpicks
parseCodexRolloutThreadIdmatches only\.jsonl$, so.jsonl.zstrollouts that the bridge links never enterbridgedThreadIdsand are never healed. If/resumeis DB-driven, that compressed history stays invisible — worth confirming against the real binary.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
4bcc190 to
ec0b6a0
Compare
There was a problem hiding this comment.
ℹ️ No critical issues — prior review feedback is addressed. One optional test-coverage note below.
Reviewed changes
Re-reviewed the increment since the prior pullfrog review at 4bcc1903e9.
- Compressed rollouts recognized —
countCodexSessionFilesUpTocounts.jsonl.zst, and the rollout-id regex accepts the.zstsuffix, so compressed history is both bridged and added tobridgedThreadIdsfor healing. not-trackedgate tightened — a state DB withoutbackfill_state(which Codex migrates topendingbefore a blocking backfill) no longer counts as ready to link history into, matchingisCodexStateDbBackfillPending.- Contract test extended — the real-binary test now asserts an empty no-RPC app-server session leaves
readCodexStateDbBackfillStatus(home).kind === 'complete'. - Tests added — compressed-only bridge + heal, skip-linking on a pre-backfill DB, and compressed-rollout counting.
ℹ️ Compressed thread/read read-repair is a new Codex dependency the contract test doesn't pin
The real-binary contract test exists specifically to catch Codex drift, and this change makes Orca depend on Codex's thread/read read-repair supporting compressed rollouts. A Codex release that dropped compressed repair would leave the stub-driven bridge test green while compressed history silently stopped appearing in /resume. I traced Codex rust-v0.156.1 and the repair path is compression-aware, so this is a coverage gap rather than a defect.
Technical details
# Pin compressed `thread/read` read-repair in the contract test
## Affected sites
- `src/main/codex/codex-session-index-heal-state.ts:25` — regex now accepts `.jsonl.zst`, so compressed threads enter `bridgedThreadIds`.
- `src/main/codex/codex-account-session-index-heal.ts:148` — heals via `thread/read`; correctness of compressed indexing lives in the Codex binary.
- `src/main/codex/codex-index-heal-binary-contract.test.ts:92-121` — `writeRollout` only ever writes `.jsonl`; no arm exercises a compressed rollout.
- `src/main/codex/codex-account-session-bridge.test.ts:284-302` — asserts only that `healIndexStub` was called with the thread id (a double), not that Codex indexes the compressed file.
## Required outcome
- A real-binary arm proving `thread/read` on a `.jsonl.zst`-only rollout inserts the `threads` row, so the new compressed dependency is guarded rather than hand-verified.
## Suggested approach (optional)
- Node 24 exposes `zlib.zstdCompressSync`, so a fixture can write a real `.jsonl.zst` alongside the existing `writeRollout` shape. Codex's own `rollout/compress` RPC could also produce it. Keep it as one narrow arm, consistent with the file's stated "keep it narrow" intent.
## Open questions for the human
- The contract job pins `CODEX_CLI_VERSION: 0.150.1` while the change was verified on 0.156.1; is compressed repair present on the CI version?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
ec0b6a0 to
cfebdde
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 89ffe8ce-6b99-4ce4-8e4c-aecf645b6940
📥 Commits
Reviewing files that changed from the base of the PR and between ec0b6a0e63c31b68b3f64b7b841b4b9bd8eaea91 and cfebddecb4eb3b7a62362fc4d238871a06bd483a.
📒 Files selected for processing (8)
src/main/codex/codex-account-session-bridge.test.tssrc/main/codex/codex-account-session-bridge.tssrc/main/codex/codex-account-session-index-heal.test.tssrc/main/codex/codex-account-session-index-heal.tssrc/main/codex/codex-index-heal-binary-contract.test.tssrc/main/codex/codex-session-index-heal.test.tssrc/main/codex/codex-session-index-heal.tssrc/main/startup/main-process-quit.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| ({ threadId }, outcome) => { | ||
| if (outcome === 'healed') { | ||
| summary.healedThreads += 1 | ||
| return | ||
| } | ||
| failed.add(threadId) | ||
| summary.failedThreads += 1 | ||
| }, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Do not write off missing threads for the whole process lifetime.
The callback adds every non-healed outcome to failed, including missing. A thread read can return missing when the rollout is not present yet or the link was replaced. After that, the thread is never read again until Orca restarts, even after the rollout becomes available. Only this failure is permanent: a thread that stays in the bridge set but is excluded from /resume. Count missing separately and keep it out of the process-wide skip set. As an alternative, keep the skip set only for failed.
Proposed fix
if (outcome === 'healed') {
summary.healedThreads += 1
return
}
- failed.add(threadId)
+ if (outcome === 'failed') {
+ failed.add(threadId)
+ }
summary.failedThreads += 1📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ({ threadId }, outcome) => { | |
| if (outcome === 'healed') { | |
| summary.healedThreads += 1 | |
| return | |
| } | |
| failed.add(threadId) | |
| summary.failedThreads += 1 | |
| }, | |
| ({ threadId }, outcome) => { | |
| if (outcome === 'healed') { | |
| summary.healedThreads += 1 | |
| return | |
| } | |
| if (outcome === 'failed') { | |
| failed.add(threadId) | |
| } | |
| summary.failedThreads += 1 | |
| }, |
There was a problem hiding this comment.
A "no rollout found" read is now reported as missingThreads instead of a failure (a29d8b0)
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
git rev-parse --short HEAD
ast-grep outline src/main/codex/codex-account-session-index-heal.ts --match 'healCodexAccountSessionIndex|failedThreadIdsByHome' || true
sed -n '60,145p' src/main/codex/codex-account-session-index-heal.ts
ast-grep outline src/main/codex/codex-account-session-index-heal.test.ts --match 'missing|failed|healCodexAccountSessionIndex' || true
rg -n -C 5 'missingThreads|failedThreads|resetFailedThreads|missing.*retr|failedThreadIdsByHome' src/main/codex/codex-account-session-index-heal.test.ts src/main/codex/codex-session-index-heal.tsLength of output: 11982
@AmoabaKelvin, missingThreads now reports “no rollout found” separately. The retry issue remains: healCodexAccountSessionIndex still calls failed.add(threadId) before it checks for missing. The next pass therefore excludes that thread ID, even if its rollout becomes available. Please add only failed outcomes to the skip set.
You are interacting with an AI system.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the increment since the prior pullfrog review at ec0b6a0e63 (the branch was rebased onto f5f537ef; 630d59ec5e carries the previously reviewed content and cfebddecb4 is the new commit).
- Kept linking history into homes whose state DB lives elsewhere —
isReadyForBridgedHistorynow runscreateStateDbonly for an empty home (!findNewestCodexStateDbPath && !hasSessionRollouts). A home holding history without a home-local DB (sharedsqlite_home, or a Codex with none) links on every launch instead of being skipped after the first, fixing the post-first-launch stall the prior gate introduced. - Shared the system-home read pass —
healCodexAccountSessionIndexnow delegates to the newly exportedreadCodexThreadsForIndexHeal/CodexSessionIndexHealOptionsinstead of duplicating the batching loop; theHEAL_*constants became module-private andreadOneThreadreturns an outcome rather than mutating counts. - Stop at quit — a
stoppingflag plusstopCodexAccountSessionBridges()wired intomain-process-quit.ts, refusing new bridges and passingshouldStopinto the heal. - Read-only app-servers —
buildNativeHealInvocationnow launches withCODEX_READ_ONLY_APP_SERVER_ARGS(-s read-only -a never), so every background index app-server is read-only. - Contract coverage — the real-binary test now has a compressed-only
thread/readread-repair arm and asserts an empty no-request session leaves the backfillcomplete.
All prior pullfrog threads are resolved. The system-home heal refactor is behavior-preserving (counts, ledger records, marker writes, and abort/unsupported/stopped semantics all carry over), the read-only launch args are exercised by the contract test, and the new tests pass (70 tests across the six touched suites; pnpm tc:node clean).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Codex indexes every rollout present when it first creates its state DB, and the TUI gives up after 30s, so large histories broke a new account's launch. Fixes stablyai#20669
cfebdde to
a29d8b0
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/main/codex/codex-account-session-index-heal.ts (1)
102-107: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winKeep
missingthreads out of the process-wide skip set.The callback adds
missingoutcomes tofailed. Every later pass in the same process then skips that thread. Amissingresult can be transient. For example, the rollout may not be present yet, or the link may have been replaced. After that, the thread stays outside/resumeuntil Orca restarts. Add onlyfailedoutcomes to the skip set.Proposed fix
- failed.add(threadId) if (outcome === 'missing') { summary.missingThreads += 1 } else { + failed.add(threadId) summary.failedThreads += 1 }The test at
src/main/codex/codex-account-session-index-heal.test.tsLine 130-147 must also change to expect a reread.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 70c537f2-ce3f-4f9c-82c3-ed8149c111d4
📥 Commits
Reviewing files that changed from the base of the PR and between cfebddecb4eb3b7a62362fc4d238871a06bd483a and a29d8b0.
📒 Files selected for processing (7)
src/main/codex/codex-account-session-bridge.test.tssrc/main/codex/codex-account-session-bridge.tssrc/main/codex/codex-account-session-index-heal.test.tssrc/main/codex/codex-account-session-index-heal.tssrc/main/codex/codex-index-heal-binary-contract.test.tssrc/main/codex/codex-session-index-heal.test.tssrc/main/codex/codex-session-index-heal.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the increment since the prior pullfrog review at cfebddecb4 (the branch was rebased onto 0697014; the whole PR now arrives as the single commit a29d8b0). All prior pullfrog threads are resolved.
- Injected bridge dependencies —
startCodexAccountSessionBridgeInBackgroundtakes an optional seconddependenciesOverrideargument and threads it intoisReadyForBridgedHistory; the module-global mutable dependency holder and_internals.setBackgroundBridgeDependenciesare removed. Tests inject through astartBridgehelper. The only production caller passes no override, so behavior is unchanged. - Separated missing-thread accounting — the account heal summary gains
missingThreads, counted separately fromfailedThreadsforoutcome === 'missing'; both still enter the process-lifetime skip set, so this is accounting-only and mirrors the system heal. - Plugin-free background app-servers —
buildNativeHealInvocationnow usesCODEX_SHORT_LIVED_PROBE_APP_SERVER_ARGS(-c features.plugins=false … -s read-only -a never app-server), avoiding marketplace clones outliving the one-batch session. - Contract and rollout coverage — the real-binary contract test pins the plugin-free args and asserts an empty no-request session leaves the backfill
complete; a compressed-onlythread/readarm and a compressed-rollout count test cover the.jsonl.zstpath.
Verified locally: the 5 touched suites pass (62 tests) and pnpm tc:node is clean.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…odex binary Selecting an account starts the history bridge, which spawned codex app-server on the fixture homes and raced the test's temp-dir cleanup.
Indexing a large history takes minutes, and Codex's /resume hides unindexed threads once a directory has any indexed one, so recent conversations stayed missing until the heal reached them in directory-listing order.
…ink guards Drop the stop check before creating the state DB: it ran in the same tick as the check at bridge start, so it could never observe a quit.
…ing a real codex Fake invocations now point at a nonexistent binary and a throwaway CODEX_HOME, and cover per-home failure memory and a session that fails during quit.
|
Thanks @AmoabaKelvin, the diagnosis and the fix are right. I reproduced the failure on I pushed four small follow-ups:
Small description note: the PR also starts the default-home indexer's Codex processes with plugins off and read-only, and counts |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟠 Major · Do not treat every missing state DB as ready for history. · codex-account-session-bridge.ts:83
src/main/codex/codex-account-session-bridge.ts:83
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy liftDo not treat every missing state DB as ready for history.
If the target already has rollouts but no state DB, the earlier condition skips
createStateDb, and this return still permits linking all source history. Codex 0.156.1 can create its DB and backfill those rollouts on its next launch; a large bridge can therefore reproduce the first-launch timeout this change aims to prevent. Defer linking in this state unless the installed Codex version is known not to create a state DB. (raw.githubusercontent.com)
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: ebcb495b-5bb5-4a24-b105-866b8cbcf6cb
📒 Files selected for processing (6)
src/main/codex-accounts/runtime-home-service-per-account-migration.test.tssrc/main/codex/codex-account-session-bridge.test.tssrc/main/codex/codex-account-session-bridge.tssrc/main/codex/codex-account-session-index-heal.test.tssrc/main/codex/codex-account-session-index-heal.tssrc/main/codex/codex-session-index-heal.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
|
| // Why: with no DB in the home, Codex keeps none (older CLI) or uses a | ||
| // `sqlite_home` shared by every Orca home, which already indexes these threads. | ||
| const indexed = (options.readIndexedThreadIds ?? readIndexedCodexThreadIds)(codexHomePath) | ||
| if (!indexed) { | ||
| return { ...summary, outcome: 'no-index' } |
There was a problem hiding this comment.
When an account uses a shared sqlite_home, its state DB is outside the account home. This lookup returns null, so the heal skips every thread/read. If the shared DB was indexed before history was linked into the account home, those conversations remain absent from the DB-backed /resume list. The heal needs to find the active shared index or read the linked threads without requiring an in-home DB.
| db = new SyncDatabase(stateDbPath, { readonly: true, fileMustExist: true }) | ||
| const ids = new Set<string>() | ||
| for (const row of db.prepare('SELECT id FROM threads').all()) { | ||
| if (typeof row.id === 'string') { | ||
| ids.add(row.id.toLowerCase()) | ||
| } | ||
| } | ||
| return ids |
There was a problem hiding this comment.
For a large account, this synchronous query loads every thread ID into memory on the main process. The bridge also retains a map of all rollout IDs, so the bounded thread/read batches do not limit this earlier work. Healing a large history can stall the app and increase memory use; avoid taking a full synchronous index snapshot on the main thread.
Comments Outside DiffThese findings could not be posted inline.
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the increment since the prior pullfrog review at a29d8b0 (4 commits: f43a32c973, 375782e86a, 0482f220f3, 278d8516e9).
- Index the newest bridged rollouts first — the bridge summary now carries thread id → rollout stamp (
bridgedThreads: Map<string, string>), andhealCodexAccountSessionIndexsorts the unindexed threads descending by stamp, so recent work appears in/resumebefore a large history finishes indexing. Mirrors the system heal's existing descending sort. existinghardlinks still get healed —bridgeRolloutIntoAccountHomereturns'linked' | 'existing' | 'failed'; onlyfailedrollouts are excluded from the heal set, so a rollout already hardlinked into the target is still repaired into the index. Failure to link is covered by a new test.- Quit guard moved outward — the
stoppingparameter is gone fromisReadyForBridgedHistory;startCodexAccountSessionBridgeInBackgroundreturns early whenstoppingand re-checks after readiness, so a quit during the 15screateStateDbstill links nothing. The production caller passes no dependency override. - Tests fail closed — the account-heal suite's
buildInvocationpoints at a nonexistent binary with an isolatedCODEX_HOME, and the per-account migration test mocks the heal module so selecting an account never spawns the realcodex app-server. - New guard coverage — no-source-history skip, failed-link exclusion, per-home failure memory, stop-during-state-DB-creation, no-start-after-quit, no completion marker when stop flips in the last batch, plugin-free invocation, compressed-rollout counting, and
readIndexedCodexThreadIdslower-casing / null cases.
Verified locally: the 5 touched suites pass (70 tests) and pnpm tc:node is clean.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Validation statusEvery run below used a synthetic managed Codex account (no real credentials), synthetic conversation history, isolated home folders, and the real Codex CLI. "Before" is this PR's parent commit and "after" is this PR. Platforms
Setups
Follow-ups, not blocking
|
…3745, #23783, #22971, #22565, #22846, #23724, #23721, #23693, #23810) into #23059 #23671 (group chat rows by the turn that produced them) is ported onto #23059's turn-scope model, so there is one grouping mechanism, not two: - A host that states each row's turn scope groups by that scope, as before. #23671's journal-order derivation (rows between one turn record and the next belong to it) moves from the timing selector into src/shared/native-chat-turn-grouping.ts and runs only for a host that states no scope, replacing the positional fallback there. - #23671's anchor rules live in structuredAgentTurnAnchors, which membership, settled timing and the live clock all read: a turn whose opener key nothing resolves yet takes the send still in flight ahead of its record (Codex before its echo), else its own record. - The live turn is one key again. #23671 made row liveness follow the owning turn, so the bar key and the liveness key are always the same; nativeChatTurnMembership now returns only liveTurnKey (barTurnKey, activeTurnOpenedBy and turnKeysByItemId are gone). - A turn with no user bubble draws its bar above its first row (nativeChatTurnBarRows, desktop and mobile), and a turn's diff rollup goes under its last row. - The Codex full-history restore writes each record ahead of its items; that also fixes the derived turn scope on #23059's journal. #23026 (Stop from the moment a message is sent) is ported onto #23059's command turns: the cancel paths ask the translator for a command's provider turn instead of the removed compaction tracker, and a Stop that names no turn still ends a running /compact through its child. performCancel moved to structured-agent-session-turns-cancel.ts to keep the turns module under the line limit. #22090's awaitingInput replaces showTurnStatus/showLiveTurnActivity; the waiting-behind-/compact rows are kept.
The WSL history bridge hardlinked every conversation into a new managed account home before Codex had opened it, so Codex's first open had to index all of it and every other Codex on that home gave up after 30s. Apply the native ordering from #22971 inside the distro: Codex brings the home's index to complete first, history is linked after, and the shared thread/read loop indexes it newest first. Windows cannot read the guest's Codex sqlite over 9p, so a marker per linked rollout records the pending indexing work and dies once thread/read settles it.
The WSL history bridge hardlinked every conversation into a new managed account home before Codex had opened it, so Codex's first open had to index all of it and every other Codex on that home gave up after 30s. Apply the native ordering from #22971 inside the distro: Codex brings the home's index to complete first, history is linked after, and the shared thread/read loop indexes it newest first. Windows cannot read the guest's Codex sqlite over 9p, so a marker per linked rollout records the pending indexing work and dies once thread/read settles it.
… it (carries #23843) (#33630) New WSL Codex managed accounts no longer link all past rollouts before Codex first opens the home (which stalled startup past Codex's 30s backfill gate or left later-linked sessions unindexed): Codex opens the home first, then history is linked and indexed in background batches newest-first, resumable across restarts — matching #22971's non-WSL order. Supersedes #23843 Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>

ELI5
Each Codex account in Orca gets its own folder. The first time Codex runs in a folder, it reads every old conversation in it to build its list for
/resume, and a launching Codex gives up if that takes more than 30 seconds. Orca was copying all your old conversations into a new account's folder before Codex had ever run there, so that first read covered your whole history (19 GB for the reporter) and every launch failed. Now Codex runs on the empty folder first, and your history is added afterwards.What Changed
Before: adding a Codex account with a large history made every Codex pane in that account fail for minutes with
timed out waiting for state db backfill ... after 30s (status: running).After: the new account's first launch starts immediately, however big the history is. Old conversations still appear in
/resume. They're indexed in the background, so they show up gradually on very large histories.Mechanism, in the account history bridge (
codex-account-session-bridge.ts):codex app-serveron it once, in read-only mode. App-server finishes creating its database before it answers the first request, so Codex indexes an empty folder in about 100 ms./resumereads only its database. So Orca asks Codex to read each newly linked conversation (thread/read) in small background batches. This goes through the same batch loop Orca already uses for the default Codex folder (codex-session-index-heal.ts), so it has the same limits and stops when the app quits.Linking waits for the next launch in two cases:
A folder that already has conversations but no database inside it gets history linked on every launch, as on main. That happens when Codex keeps its database elsewhere (
sqlite_home, which Orca points at the same place for every account folder) or runs a version with no database. Either way there is nothing in the folder for a launch to wait on.Why
The timeout is only where the problem shows up. The cause is the order: history was added before Codex's first index. Orca can't make Codex's first index cheaper or skip it, and it never writes to Codex's database, so running that index before history arrives is the only thing that removes the wait.
Alternatives considered:
/resumepicker reads only its database. It checks the conversation files on disk only when the database is empty. So linked history would be invisible. I confirmed this against codex 0.156.1.Linked Issue
Fixes #20669
Visual Proof
N/A. This is main-process ordering with no UI change. The evidence is in Testing: startup time and what
/resumecan see, measured with the real Codex binary.Testing
Checked against the real
codex0.156.1 binary on scratchCODEX_HOMEfolders (never the real~/.codex):/resume's database listing showed 1 of 300 conversations./resumelists the history.The real-binary contract test (
codex-index-heal-binary-contract.test.ts) now also checks that an empty first run leaves the index marked complete, and thatthread/readindexes a compressed.jsonl.zstconversation. It passes on both 0.150.1 (the version CI pins) and 0.156.1.The 30-second timeout the reporter hit is in Codex's source:
codex-rs/rollout/src/state_db.rs.Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)