Skip to content

fix(codex): dedupe archive mirrors and adopt 0.81 caches - #1

Merged
BananaIIya merged 1 commit into
BananaIIya:fix/codex-zst-sessionsfrom
kali113:fix/codex-zst-followup
Oct 27, 2026
Merged

BananaIIya merged 1 commit into
BananaIIya:fix/codex-zst-sessionsfrom
kali113:fix/codex-zst-followup

Conversation

@kali113

@kali113 kali113 commented Oct 26, 2026 •

Copy link
Copy Markdown

This is a follow-up to steipete#4534, based on @BananaIIya's request.

While testing the original PR against CodexBar 0.81.0 and the latest main, I ran into a couple of issues that needed fixing. This PR addresses those issues and applies cleanly to fix/codex-zst-sessions at 2914f1a.

What I fixed

  • Duplicate token counts during paged refreshes: When Codex archives a rollout, the old plain file and its archived copy could both end up being counted. This happened because paged discovery skipped the usual cleanup. I added dropCodexPlainRowsSupersededByScannedArchives so the old entry is removed once the archived version has been fully processed. In the regression test, this brought the count down from 660 tokens to the correct 330.
  • Cache compatibility with 0.81.0: Added 4e1358d00a4a47b5 to the list of compatible predecessor hashes. This lets users upgrading from 0.81.0 keep their existing cache instead of rebuilding it. I verified that the cache was reused without changing its inode or triggering a rebuild.
  • Tests and parser hash: Added regression coverage for the archive migration and cache compatibility fixes, along with an updated parser hash (634d9513ef18c251).

Testing

All 103 focused tests passed, and Scripts/regenerate-codex-parser-hash.sh --check completed successfully.

I also tested the changes against a real 0.81.0 cache. It was reused successfully, and the recovered token count increased from 595,497,788 to 3,681,203,325. The scan covered 32 days, 382 files, and 62 daily aggregates, with full coverage established after eight refreshes.

The patch applies cleanly to 2914f1a. I also resolved the three conflicts against upstream main locally.

All verification was done without modifying any live ~/.codex data, the installed app, or the original cache.

I left the vendored zstd dependency and decoded-mirror storage approach unchanged, since those are still decisions for the maintainers.

Paged discovery skips the missing-file cleanup that removes a plain row
after Codex archives it, so a cached plain rollout and its newly scanned
mirror could both contribute. Drop the plain row once its mirror has been
fully processed.

Also accept the 0.81.0 parser hash so existing caches are adopted in place
instead of rebuilt, add regression coverage for both behaviors, and
regenerate the parser hash.
Copilot AI balanced review requested due to automatic review settings October 26, 2026 08:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@BananaIIya
BananaIIya merged commit 1537865 into BananaIIya:fix/codex-zst-sessions Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants