Skip to content

host: Add indexing drain after restoring cached realm - #5796

Draft
backspace wants to merge 5 commits into
mainfrom
cs-12514-drain-after-restore
Draft

host: Add indexing drain after restoring cached realm#5796
backspace wants to merge 5 commits into
mainfrom
cs-12514-drain-after-restore

Conversation

@backspace

Copy link
Copy Markdown
Contributor

Claude: A restored index does not stop the realm indexing. Each test's adapter stamps its fixtures with the current second while the restored rows carry the first test's, and discover-invalidations compares those for equality, so realm.start() invalidates the lot and re-indexes. The work is cheap — the snapshot also restored the transpile and prerender caches — but it is asynchronous, and a test that reads index-derived state races it. That is how ai-assistant's code-mode test lost the cursor position it clicks a definition to reach: the lookup ran while indexing was still in flight.

So settle the realms before returning, the way setupLocalIndexing's afterEach already does between tests.

Deliberately not fixed by making the mtimes match. That comparison is what rebuilds the index when a module's fixtures diverge from its snapshot under an unchanged cache key — the only protection this helper has against silently serving the wrong fixtures. Content-derived mtimes would keep the protection in principle, but fixture content includes live card instances that are serialized later and carry a per-construction id, so they cannot be hashed at construction.

ai-assistant moves back to the shared cache here, so the run either proves the drain fixes that race or says the diagnosis was wrong.

A restored index does not stop the realm indexing. Each test's adapter stamps
its fixtures with the current second while the restored rows carry the first
test's, and `discover-invalidations` compares those for equality, so
`realm.start()` invalidates the lot and re-indexes. The work is cheap — the
snapshot also restored the transpile and prerender caches — but it is
asynchronous, and a test that reads index-derived state races it. That is how
`ai-assistant`'s code-mode test lost the cursor position it clicks a definition
to reach: the lookup ran while indexing was still in flight.

So settle the realms before returning, the way setupLocalIndexing's afterEach
already does between tests.

Deliberately not fixed by making the mtimes match. That comparison is what
rebuilds the index when a module's fixtures diverge from its snapshot under an
unchanged cache key — the only protection this helper has against silently
serving the wrong fixtures. Content-derived mtimes would keep the protection in
principle, but fixture content includes live card instances that are serialized
later and carry a per-construction id, so they cannot be hashed at construction.

ai-assistant moves back to the shared cache here, so the run either proves the
drain fixes that race or says the diagnosis was wrong.

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

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Preview deployments

Host Test Results

  1 files  ±    0    1 suites  ±0   10m 23s ⏱️ - 1h 12m 39s
460 tests  - 2 892  456 ✅  - 2 891  4 💤  - 1  0 ❌ ±0 
461 runs   - 2 906  457 ✅  - 2 905  4 💤  - 1  0 ❌ ±0 

Results for commit 0e0899f. ± Comparison against earlier commit a784f43.

Realm Server Test Results

    1 files  ±0      1 suites  ±0   14m 10s ⏱️ - 2m 3s
2 174 tests ±0  2 174 ✅ ±0  0 💤 ±0  0 ❌ ±0 
2 254 runs  ±0  2 254 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 0e0899f. ± Comparison against earlier commit a784f43.

backspace and others added 4 commits August 17, 2026 17:53
`code mode context sent with message` failed this assertion on CI with no
way to see what it got: the TAP reporter renders a failed deepEqual's
operands as `[object Object]`, and a shard that fails uploads no
test-report artifact to read them from. Put the value in the message.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The failing one turned out to be a later stage of the same test — it
asserts three times, against a cursor position and then a selection in
plant.gts, and only the first was instrumented.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Wrapping the realm setup in `withCachedRealmSetup` indented its body, and
that carried into the template literals holding plant.gts and
broken-card.gts — template-literal content is data, so every line of those
modules gained two leading spaces. `code mode context sent with message`
asserts the cursor position that clicking a definition produces, which is
derived from the module source, so it moved with the fixture: the
instrumented message reported column 47 against an expected 45.

Restore both fixtures to the bytes main has. The expectations were right;
the fixtures had silently changed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
They named the value that identified the shifted fixture; the assertions
go back to their plain messages now that the cause is fixed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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