Skip to content

cache: date-ranged queries republish the month shards they skipped, byte-identical, on every run #1032

Closed

Description

@iamtoruk

Found by the upgrade-path verification harness (hardening track B), reproduced 3× in a row on main.

A date-ranged query — e.g. status --format json (the statusline/menubar fast path) — republishes the month shards its range skipped (claude.2026-05, claude.2026-06, codex.2026-05, codex.2026-06) with new nonce filenames every run, with nothing changed. Content is byte-identical (same bytes, same entry counts), so it is wasted I/O, not history loss — but on a real 6 GB corpus those are the big shards, and it partially defeats #1007's "a warm launch rewrites only the month that changed."

Mechanism: the deferred-merge path in saveCache (src/session-cache.ts:~1080-1088) — the unloaded buckets come out dirty despite no change and go through read-modify-republish. Likely the per-file dirty marking on a scoped load touching a bucket that wasn't loaded (or markCacheDirty for a bucket the entry was "last saved in" being set for untouched files).

Fix: unloaded, unchanged buckets must be carried by envelope reference (as #1007 intended); only buckets with an actual entry mutation may be dirty. Add an assertion to the upgrade-path harness (currently a note) that a warm ranged run changes zero shard filenames when nothing changed.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions