Skip to content

Doctor reports duplicate archived rollout thread ID and missing DB row; no safe reconciliation command #55439

Open

Description

@douglaschede

Summary

codex doctor reports an archived rollout missing from the state database and a duplicate rollout thread ID, although the SQLite database passes integrity checks. Two distinct archived rollout files share the same thread ID. There does not appear to be a documented, non-destructive reconciliation command.

Environment

  • Codex CLI: 0.163.0-alpha.10.2
  • macOS arm64 (doctor reports macOS 27.0.1)
  • Desktop app: 26.1013.40934
  • State database: ~/.codex/state_5.sqlite

Observed behavior

⚠ threads 2 issues - rollout files are missing from the state DB; duplicate thread inventory entries found
rollout DB missing archived rows 1
rollout DB duplicate rollout thread ids 1
rollout DB duplicate DB paths 0

Two different .jsonl.zst files in ~/.codex/archived_sessions/ contain the same primary thread ID in their filenames, with one also containing an additional UUID suffix. Both files exist, differ in SHA-256, and were backed up and verified. The threads table has only one row for that thread ID (archived=1), pointing to the file with the additional UUID suffix.

PRAGMA integrity_check; returns ok on the original state database and on the backup.

Running:

codex migrate-rollouts --thread <affected-thread-id> --verbose
Scanned 2 rollout(s): 0 eligible, 2 already paginated, 0 skipped (0 empty, 0 busy), 0 failed.
already paginated <affected-thread-id>
already paginated <affected-thread-id>

codex debug --help and codex debug app-server --help do not expose an inventory repair command.

Expected behavior

The archived rollout inventory should be consistent, or the CLI should provide a supported, non-destructive reconciliation workflow that preserves both histories.

Request

Is there a supported safe way to reconcile the duplicate archived rollout thread ID and missing archived DB row without deleting either rollout or editing SQLite directly?

I have intentionally omitted private paths, conversation contents, credentials, and full diagnostic logs. I can provide a redacted doctor report if needed.

Activity

  1. added
    bug
    CLI
    session
    on Oct 20, 2026
  2. secheverrianogal-beep commented on Oct 20, 2026

    @secheverrianogal-beep

    I would avoid manually editing SQLite or deleting either archive: the report shows a healthy SQLite integrity check but an inventory/identity collision, and the two rollout files have different hashes.

    A safe product-level resolution could be a supported reconciliation command with these properties:

    • Dry-run first: enumerate archive files and DB rows, showing duplicate thread IDs, candidate row-to-file matches, and unmatched files without changing anything.
    • Preserve ambiguous histories: if two distinct files share an ID, do not pick one silently or overwrite either. Require an explicit mapping or report that human resolution is needed.
    • Recoverable write path: create and verify a database backup, apply any approved row changes in one transaction, and keep both original rollout files unchanged.
    • Idempotent validation: rerunning the command should not create duplicate rows; afterward run SQLite integrity checks and verify that every indexed archive has a valid file association.
    • Redacted output: report counts and conflict classes by default, not conversation content or full local paths.

    Until such a command exists, the safest guidance is to retain the verified backup and both files and ask maintainers for a supported recovery procedure rather than attempting direct DB edits.

  3. Zombi3h3art commented on Oct 30, 2026

    @Zombi3h3art

    Same pattern on Windows 11 (build 26300), standalone Codex CLI 0.166.0, Desktop 26.1027.3384.0. Two archived threads, both with source=vscode.

    Doctor:

    rollout DB missing archived rows 2
    rollout DB duplicate rollout thread ids 2
    rollout DB stale rows 0
    

    For each thread, archived_sessions holds two files: rollout-<t1>-<id>.jsonl.zst and rollout-<t2>-<id>_<uuid>.jsonl.zst. The threads row (archived=1) points to the _<uuid> file, and doctor reports the plain-named file as the missing archived row.

    Read-only comparison of line hashes, excluding each file's first session_meta record:

    Thread Plain file lines _<uuid> file lines Lines shared Plain file ends → _<uuid> file starts
    A 8,718 75,118 0 2026-09-23 23:40:53.486Z → 23:40:55.867Z
    B 12 583 0 2026-10-22 01:09:08.849Z → 01:09:40.628Z

    codex migrate-rollouts --thread <id> --verbose (without --apply) reports 2 already paginated for both threads, the same as in the original report.

    So the plain-named file isn't a stray copy. It holds the start of the conversation, and the _<uuid> file picks up seconds after it ends. Removing or "deduplicating" the plain file would drop that history. It looks like the inventory check counts each page as a separate rollout instead of grouping <id> and <id>_<page> files under one thread.

    Suggestion: treat <id> and <id>_<page> files as one thread when any page has a threads row, and flag a thread only when none of its pages does.

    Both files and the state DB are untouched here. I can attach a redacted codex doctor --json report if that helps.

  4. mapleleo-hub commented on Nov 7, 2026

    @mapleleo-hub

    Same pattern on Windows, plus the client-visible consequence: thread/list returns one archived entry per rollout file

    Adding a third data point, because the doctor counts here have a reproducible user-visible effect that the earlier reports only described as inventory warnings.

    Environment

    • Windows 11 26200 (10.0.26200), OpenAI.Codex desktop 26.1103.3517.0
    • Bundled CLI: codex-cli 0.167.0-alpha.3.2
    • CODEX_HOME=C:/Users/LYQ/.codex, state DB state_5.sqlite

    Doctor

    threads 3 issues
    - rollout files are missing from the state DB: measured "32 active, 4 archived"
    - state DB rows point at missing or unusable rollout files: "15 stale rows"
    - duplicate thread inventory entries: "9 duplicate rollout thread ids, 0 duplicate DB paths"
    

    The 4 missing archived files:

    archived_sessions\rollout-2026-10-01T17-41-04-01a0f6d6-c1c1-7910-a638-7fbdbe6d3dd3.jsonl.zst
    archived_sessions\rollout-2026-10-05T21-10-33-01a0f6d6-c1c1-7910-a638-7fbdbe6d3dd3_01a10c2f-f9bc-7fe3-9485-5a522e71277f.jsonl.zst
    archived_sessions\rollout-2026-10-05T22-17-06-01a0f6d6-c1c1-7910-a638-7fbdbe6d3dd3_01a10c6c-ea6e-7873-9e03-fec80eb36595.jsonl.zst
    archived_sessions\rollout-2026-10-08T09-16-04-01a11914-ee0a-7163-b1b0-0596aa976d18.jsonl.zst
    

    Same file layout as @Zombi3h3art's report: the threads row (archived=1) points at the _<uuid> file, and the plain-named root rollout has no row. Here the row for 01a0f6d6-c1c1-7910-a638-7fbdbe6d3dd3 points at ..._01a10c73-6c9d-7842-baef-be7d2037173c.jsonl.zst, i.e. a fork copy, not the thread's own rollout.

    Client-visible consequence

    thread/list with archived: true returns 9 rows for 5 distinct thread ids:

    01a178de-...                        rollout-2026-10-26T23-40-30-01a178de-....jsonl
    01a11914-...                        rollout-2026-10-11T16-21-24-01a11914-..._01a12a0d-....jsonl
    01a11914-...                        rollout-2026-10-08T09-16-04-01a11914-....jsonl
    01a0f6d6-...                        rollout-2026-10-05T22-24-13-01a0f6d6-..._01a10c73-....jsonl
    01a0f6d6-...                        rollout-2026-10-05T22-17-06-01a0f6d6-..._01a10c6c-....jsonl
    01a0f6d6-...                        rollout-2026-10-05T21-10-33-01a0f6d6-..._01a10c2f-....jsonl
    01a10af2-...                        rollout-2026-10-05T15-23-21-01a10af2-....jsonl
    01a0f6d6-...                        rollout-2026-10-01T17-41-04-01a0f6d6-....jsonl
    01a0f104-...                        rollout-2026-09-30T14-33-13-01a0f104-....jsonl
    

    So one archived conversation (01a0f6d6) occupies four rows in the Archived Chats page, and 01a11914 two. Rows whose rollout file has no state DB row carry no usable metadata: the page shows the same conversation repeated, and part of the duplicates cannot be opened. In practice the user reported the conversation as "missing from Archived Chats" even though the archive files are intact, because the list is dominated by duplicates and one entry surface is broken.

    Reproduction without the desktop UI:

    printf '%s\n%s\n%s\n' \
     '{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"clientInfo":{"name":"probe","title":"probe","version":"0.0.1"}}}' \
     '{"jsonrpc":"2.0","method":"initialized"}' \
     '{"jsonrpc":"2.0","id":1,"method":"thread/list","params":{"archived":true,"limit":100}}' \
     | codex app-server

    Filter the data array by id; duplicates appear immediately. PRAGMA integrity_check on the same database returns ok.

    Root cause as I read it

    Forked rollouts copy the parent session_meta, so N archived files can carry the same session_meta.id. The archived listing enumerates rollout files and emits one entry per file, with the state DB supplying metadata only where a row exists. There is no dedupe by thread id and no rule preferring the row's selected rollout_path, so the same thread is listed once per archived file. Doctor is reporting exactly this as "missing archived rows" + "duplicate rollout thread ids".

    Disclosure

    I manually appended .zst to 17 archived rollout_path values in state_5.sqlite before collecting this evidence, because those rows pointed at .jsonl while only .jsonl.zst existed. The duplication described above predates and is unaffected by that edit; the four files without rows were already unindexed. No rollout files were modified or deleted.

    What would fix it

    A reconciliation path that (a) dedupes the archived listing by thread id and prefers the row's selected path, and (b) backfills rows for archived files that have none, instead of leaving them unindexed forever. A read-only codex doctor --fix --dry-run style command covering both would also make this diagnosable without manual SQLite work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIbugsession

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions