Thread store resolves stale session_index entries to missing rollout files (state db returned stale rollout path)

Open 💬 5 comments Opened Jul 4, 2026 by ViperJuice
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

Summary

The local session index (~/.codex/session_index.jsonl) retains entries whose rollout
JSONL no longer exists in either the live sessions tree or archived_sessions/. When the
app/thread store resolves such a thread id, it returns a path to a missing file and errors
instead of falling back to the archived copy or self-healing the index. On a
long-lived, high-session-volume host this accumulates: 113 of 283 indexed entries (40%)
had no backing rollout file anywhere.

Evidence

Codex's own log reports the inconsistency from inside codex_rollout::list:

ERROR codex_rollout::list: state db returned stale rollout path for thread
019f2339-9299-7e51-b192-9751a0a03586:
/home/USER/.codex/sessions/2026/07/02/rollout-2026-07-02T14-26-43-019f2339-...jsonl

That file is not in live sessions/, not in archived_sessions/ (507 archived JSONLs
present), and not found by a recursive basename search.

Audit of the index on the affected host:

index entries: 283 | present (live or archived): 170 | STALE (no backing file): 113

A second, related failure mode also seen: a rollout file that exists but is misfiled —
stored under sessions/2026/05/09/ while its contents begin with 2026-07-03 data and do
not start with a session_meta record. So the index/path bookkeeping and the on-disk
partitioning can disagree in both directions (missing file; misplaced/malformed file).

How it likely arises

The index write and the rollout file lifecycle (create / archive-move / delete) are not
crash-consistent. If the process is interrupted between updating the index and finalizing
the file — e.g. an ENOSPC disk-full (our trigger: root fs hit 100%), a SIGKILL, or an
archival move that half-completes — the index keeps an entry the filesystem can't satisfy.
Nothing later reconciles it.

Impact

  • App/thread resolution errors when opening or listing affected threads.
  • Users cannot cleanly resume or reference historical sessions that are actually still

recoverable from durable artifacts.

  • Grows unbounded on active hosts; 40% stale observed.

Expected behavior (any of)

  1. On resolve-miss, fall back to archived_sessions/ (and a basename search) before erroring.
  2. Self-heal the index: drop or flag entries whose rollout file is absent from both live

and archived locations, rather than repeatedly resolving to a dead path.

  1. Make the index update + rollout finalize crash-consistent (write file first / fsync +

atomic rename, update index only after), so an interrupted write can't orphan an entry.

  1. Provide a codex subcommand to verify/repair the session index.

Workaround in use

Local reconciliation script: back up session_index.jsonl, drop entries with no backing
rollout file in live or archived sessions (never deletes rollout files). Mitigates the
resolve error until a first-class fix lands.

Related issues (adjacent but distinct)

Several open issues touch "stale rollout path," but each is tied to a specific Desktop UI
flow rather than the crash/interruption-consistency root cause and the systemic 40%
accumulation reported here (observed via codex-cli / app-server, not a UI action):

  • #26201 / #26174 — stale archived rollout path after archive/unarchive
  • #30924 — "failed to resolve rollout path" on new conversations (Windows Desktop)
  • #23991 — delete leaves session-index residue
  • #21663 — missing rollout path → macOS SIGABRT

This report is about the index and rollout-file lifecycle becoming inconsistent when a
write is interrupted (ENOSPC / SIGKILL / half-completed archival move), independent of
any UI flow, and the index then never self-reconciling. Please link/dedupe as appropriate.

Environment

  • codex-cli 0.142.5, Linux (Ubuntu 22.04), standalone install
  • ~/.codex on local disk; hundreds of live + 507 archived sessions
  • Trigger correlated with a root-filesystem ENOSPC event (0 bytes free) during an archival burst

View original on GitHub ↗

5 Comments

github-actions[bot] contributor · 1 month ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #30924
  • #29868
  • #31004
  • #30163

Powered by Codex Action

ideajoker · 1 month ago

版本 26.623.141536 • 发布于 2026年7月7日

no rollout found for thread id

Odezra · 1 month ago

Additional macOS evidence showing a one-for-one state transition after a legacy filesystem-level archive move:

  • Standalone CLI: 0.143.0
  • Desktop-bundled CLI: 0.144.0-alpha.4
  • SQLite integrity checks: all OK
  • A legacy local archive helper moved 118 rollout JSONL files from the active sessions tree to the archived sessions tree. Every file was preserved; there was no hard deletion. That helper is now paused.

Before and after codex doctor --json counts changed exactly with the moved set:

archived rollout files missing state DB rows: 1,028 -> 1,146 (+118)
stale state DB rows pointing at former active paths: 668 -> 786 (+118)
duplicate thread IDs: 7
archive path mismatches: 0

This supports the report's hypothesis that filesystem-level archival can leave both sides of the inventory inconsistent: the preserved archived rollout is unindexed, while the DB row remains at the old active path.

No manual SQLite repair or speculative filesystem rollback has been attempted. The archive workflow is paused pending a supported recovery path.

Could Codex expose a previewable reconcile/reindex command that:

  1. Recognizes preserved rollouts relocated between the active and archived trees.
  2. Updates thread metadata without deleting history.
  3. Reports duplicate thread IDs and planned changes before applying them.
  4. Can be verified by rerunning codex doctor --json.

A full redacted Doctor report can be provided privately if useful.

xiaodeng2025 · 10 days ago

Windows Desktop confirmation, with a newer app package.

  • Platform: Windows x64
  • App package: OpenAI.Codex_26.814.5167.0_x64
  • Onset: immediately after updating on 2026-08-18
  • At least three local Codex threads are affected.

Observed behavior:

  • The threads remain visible in the sidebar.
  • Opening at least one shows thread not found and it cannot be continued.
  • Archiving fails, which also blocks cleanup/deletion.

Exact archive error:

failed to archive session: thread-store internal error:
failed to archive thread: The system cannot find the file specified. (os error 2)

One affected thread ID:
01a013b2-9800-75d0-ae83-35e9dbc50a8e

The task record is still readable through the local task listing, and its workspace directory still exists. I have not performed a filesystem or SQLite audit, so I cannot confirm that this is the same missing-rollout mechanism as the original report; it is a symptom-level match. I have deliberately not reset the app, cleared .codex, or deleted the workspace, to avoid making recoverable local history less recoverable.

A safe, previewable reconcile/reindex tool or an option to remove an orphaned sidebar entry would be especially useful here.

shleder · 9 days ago

This index-vs-filesystem drift (session_index.jsonl pointing to non-existent or relocated rollouts after interrupted writes/ENOSPC) is specifically what Codex Rescue models in its inventory discovery. It treats the filesystem as truth, identifies DB-only orphaned pointers without touching them in-place, and correlates misfiled session dates.

You can inspect the entire session inventory and check divergence diagnostics using the read-only Alpha6 release on npm:

npx --yes codex-rescue doctor --all

It runs completely locally without network calls or modifying your sessions. If you try it, sharing the sanitized finding codes or inventory discrepancy counts would be very helpful.