Skip to content

fix(cache): dependency versions key the cache, so dependency bumps need no hand edits - #324

Merged
sweepies merged 3 commits into
mainfrom
refactor/state-dep-fingerprint
Nov 14, 2026
Merged

sweepies merged 3 commits into
mainfrom
refactor/state-dep-fingerprint

Conversation

@sweepies

@sweepies sweepies commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

The Count's own dependency PRs on this repository failed CI whenever they bumped a crate a cached state lists (#311 pklr, #313 toml_edit). The state-version guard hashed those crates' locked versions and demanded a hand-edited VERSION bump that a bot can't make.

Change

  • Dependency versions move into the cache key at build time. crates/cache/build.rs reads the workspace Cargo.lock and the two tables (tests/state-versions.tsv, tests/derived-versions.tsv). For every row it emits the current key, name@vN~<fp>, where fp is a short hash of the row's listed crates' locked versions. A dependency bump invalidates exactly the affected cached states and derived bodies, with no hand step. The separator is ~ because migration 014 deletes keys containing +.
  • The guard covers our sources only. A source change still fails until the version is bumped, and every changed row is now reported at once. The deps column is still checked: each listed crate must exist in Cargo.lock, and a malformed table fails the build. The guard and the build share one parser (crates/cache/build_support.rs).
  • Old keys are pruned when the cache opens. One indexed DELETE per table removes rows for a tabled name whose key isn't current, which covers old versions, old fingerprints and the plain keys from before fingerprints. Migration 015 adds the index the HTTP prune needs.
  • Representation keys are built in patchula-cache beside state keys.
  • Docs: internals/cache.md.

User-visible effect

After upgrading, the cache starts cold once, because every tabled key changes format. Two builds that share one cache directory and differ in a version or a locked crate will evict each other's entries for those names, which is documented.

Proof

  • A simulated pklr 5.2.2 → 5.2.3 bump (the Count's chore(deps): update pklr to 5.2.3 #311) passes the parity tests with no hand edits.
  • New tests cover the fingerprint recipe, the build output against the real workspace, the key round trip, the prune (old fingerprint, old version and old plain key pruned; the current key and other names kept), and a query plan showing both prunes search by index.
  • On the VM, mise run test:unit (1435 tests), clippy and build:cli all pass.

This will need a rebase and rehash once #323 merges.

View guided diff Turn on auto-fix

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
count-patchula d509f24 Commit Preview URL

Branch Preview URL
Nov 14 2026, 08:38 AM

…our sources

The first run after upgrading starts with a cold cache: stored extractions,
configs, catalogs, parsed notes and derived registry bodies are fetched and
derived again once.
A dependency bump or version bump no longer leaves the old entries behind:
opening the cache deletes stored values and derived bodies kept under a
key this release no longer reads, so the cache stops growing with each
upgrade.
@sweepies
sweepies force-pushed the refactor/state-dep-fingerprint branch from 1044f3d to dbb5333 Compare November 14, 2026 08:31
@sweepies
sweepies merged commit 9cf061c into main Nov 14, 2026
13 checks passed
@sweepies
sweepies deleted the refactor/state-dep-fingerprint branch November 14, 2026 08:48
@sweepies-ops sweepies-ops Bot mentioned this pull request Nov 14, 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.

1 participant