Skip to content

ci: Update index cache for host use - #5662

Merged
backspace merged 2 commits into
mainfrom
normalize-realm-mtimes-cs-12399
Aug 4, 2026
Merged

ci: Update index cache for host use#5662
backspace merged 2 commits into
mainfrom
normalize-realm-mtimes-cs-12399

Conversation

@backspace

@backspace backspace commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

As preparation for #5655, which updates host tests in CI to use cached index tables, this tweaks the cache-building job on main to:

  • modify mtimes based on git commit times so newer files get indexed without having to reindex everything
  • have a second cache subset that’s only the realms host tests use (base, skills, openrouter), as excluding bigger ones like catalog and experiments makes the cache download and restoration much faster

backspace and others added 2 commits July 30, 2026 17:48
The index cache records each file's mtime, and a consumer's boot index
decides what to revisit by comparing that against the mtime on disk —
skipping the files where the two agree. `git clone` stamps every file with
the checkout time, so the mtimes in the dump exist nowhere but the runner
that built it, no comparison ever matches, and a consumer re-indexes every
realm it imported.

Derive each file's mtime from a hash of its own content instead, so two
checkouts of the same bytes agree. Same content gives the same mtime and the
file is skipped; different content gives a different one and the file is
revisited along with whatever the invalidation fan-out reaches from it.
Content rather than commit time because CI clones are shallow and the skills
realm is a clone of a separate repo — neither carries the history a
commit-time scheme needs.

Scoped to base, skills and openrouter: the realms a test stack boots without
a SKIP_* flag switching it off. The remaining realms still land in the dump
carrying checkout mtimes.

No consumer changes behavior yet — the dev import flow sets
REALM_SERVER_FULL_INDEX_ON_STARTUP=false and never compares mtimes, so this
only changes what a future consumer can rely on.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A consumer pays the download and the replay of everything in the snapshot it
imports, and the full one covers every realm this job indexes. A host test
shard serves only base, skills and openrouter — the realms it leaves out are
the instance-heavy ones, so on a representative database they are four fifths
of the dump (292 MB of 1487 MB uncompressed). Their rows are pure cost to a
shard, and they put cards from realms it never mounts into its index.

Publish a second artifact holding just those three realms. pg_dump takes no
row filter, so the COPY blocks are assembled from `COPY (SELECT …) TO STDOUT`
with a generated header per table; header and body share one column list so
their order cannot drift, and `-q` keeps psql from writing a command tag into
the data. Verified locally by replaying a generated dump into an empty
database: same row counts and an identical checksum over every row.

The realm filter reads the realm_urls the index actually holds and keeps the
ones whose path names a wanted realm, because they are not uniformly the
serving URL — the base realm registers under its canonical
https://cardstack.com/base/ while the others carry the serving origin, so
building either form from REALM_BASE_URL gets base wrong.

Assert every scoped realm contributed a realm_url. A filter that matches
nothing still produces a structurally valid dump whose COPY blocks are simply
empty, which the verify step accepts, and every consumer would quietly go
back to indexing from scratch with nothing to indicate why.

Additive: the full artifact is built and uploaded exactly as before.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Host Test Results

    1 files      1 suites   2h 32m 50s ⏱️
3 796 tests 3 782 ✅ 14 💤 0 ❌
3 815 runs  3 801 ✅ 14 💤 0 ❌

Results for commit b9dee33.

Realm Server Test Results

    1 files      1 suites   12m 15s ⏱️
2 032 tests 2 032 ✅ 0 💤 0 ❌
2 111 runs  2 111 ✅ 0 💤 0 ❌

Results for commit b9dee33.

@backspace
backspace marked this pull request as ready for review July 31, 2026 16:55
@backspace backspace changed the title ci: Update index cache ci: Update index cache for host use Jul 31, 2026
@backspace
backspace requested a review from a team July 31, 2026 17:36

@FadhlanR FadhlanR left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[Claude Code 🤖] Approving — well-engineered CI change. Verified the load-bearing assumptions: all four cached tables carry realm_url (host filter is valid), the import TRUNCATE list matches CACHE_TABLES, and the host dump's COPY format/column order matches the full pg_dump so either replays unchanged. The content-hash mtime scheme handles shallow/separately-cloned realms and content drift cleanly.

@backspace
backspace merged commit 685729d into main Aug 4, 2026
94 checks passed
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.

2 participants