Skip to content

test(extension): derive vat krefs in the e2e rather than hardcoding them - #1024

Merged
sirtimid merged 1 commit into
mainfrom
sirtimid/e2e-stable-vat-krefs
Aug 13, 2026
Merged

test(extension): derive vat krefs in the e2e rather than hardcoding them#1024
sirtimid merged 1 commit into
mainfrom
sirtimid/e2e-stable-vat-krefs

Conversation

@sirtimid

@sirtimid sirtimid commented Aug 13, 2026

Copy link
Copy Markdown
Member

Fixes a pre-existing e2e flake on main, surfaced while rebasing the #1020#1023 stack. Small and self-contained so the whole stack inherits it.

The defect

control-panel.test.tsshould collect garbage asserted that Carol's root object is ko6 and Bob's is ko5, and that their promises are kp4 and kp3:

'{"key":"ko6.owner","value":"v3"}',
'{"key":"v3.c.ko6","value":"R o+0"}',

Since #983, subcluster vats launch in parallel. Each vat's root is exported when its own launch finishes, so which of ko5/ko6 belongs to Bob and which to Carol changes between runs. When they come back the other way round, the test fails — and database-inspector.test.ts fails alongside it, because it reads the same kv dump.

Observed directly: a failing run had ko6.owner = v2 and ko5.owner = v3, the exact inverse of what is asserted.

The vat ids themselves are stable — they are handed out in config order, so alice is always v1 — so only the object and promise krefs need deriving.

Approach

Three small helpers read the dump and look up what the assertions used to hardcode: rootKrefOf(dump, vatId) by owner, promiseKrefOf(dump, vatId) by c-list entry, and erefOf(dump, vatId, kref).

The erefs are derived in full rather than matched by prefix. A c-list entry's reverse direction is keyed by eref and valued by kref, so a loose ,"value":"ko5"} also matches the owning vat's own v2.c.o+0 entry. That passed while both vats were alive and broke the negative assertions the moment one outlived the other — which is what the test checks after terminating v3.

Testing

yarn lint clean. Extension e2e run three times: the kref failure is gone, and the two clean runs finish in ~50s rather than ~2.7m because no retries are needed.

What this does not fix. The extension e2e suite has separate instability that this change does not touch and does not claim to: object-registry.test.ts failures, and a UI timing flake where Terminated vat "v1" does not render because the panel is still showing query output. One of the three runs hit those. They are unrelated to kref assignment and were present before this change.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, README.md, CHANGELOG.md) as appropriate — test-only change, no changelog entry

Note

Low Risk
Test-only change to e2e assertions and helpers; no production or runtime behavior is modified.

Overview
Fixes flaky should collect garbage assertions in control-panel.test.ts that assumed fixed kernel refs (ko5/ko6, kp3/kp4) for Bob and Carol. Parallel subcluster launches mean those object and promise krefs can swap between runs while vat ids (v2/v3) stay stable.

Adds helpers to parse the Database Inspector kv dump and derive root krefs (via .owner), promise krefs (via c-list), and v1’s erefs (full c-list lookup so reverse entries don’t false-match). The garbage-collection expectations are built from those values instead of literals.

Reviewed by Cursor Bugbot for commit d8e81f7. Bugbot is set up for automated code reviews on this repo. Configure here.

`should collect garbage` asserted that Carol's root is `ko6` and Bob's is
`ko5`, and that their promises are `kp4` and `kp3`. Since #983 launches
subcluster vats in parallel, each root is exported when its own vat's launch
finishes, so those assignments swap between runs and the test failed whenever
they came back the other way round. The vat ids are stable — they are handed out
in config order — so the krefs are now looked up from the dump by owner.

The erefs are derived too, in full rather than by prefix: a c-list entry's
reverse direction is keyed by eref and valued by kref, so matching on the kref
alone also hits the owning vat's own entry for the same object, which broke the
negative assertions once that vat outlived the one under test.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sirtimid
sirtimid requested a review from a team as a code owner August 13, 2026 17:04
@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 72.06%
⬆️ +0.01%
9353 / 12979
🔵 Statements 71.9%
⬆️ +0.01%
9507 / 13222
🔵 Functions 72.87%
🟰 ±0%
2227 / 3056
🔵 Branches 65.82%
⬆️ +0.02%
3788 / 5755
File CoverageNo changed files found.
Generated in workflow #4638 for commit d8e81f7 by the Vitest Coverage Report Action

@sirtimid
sirtimid added this pull request to the merge queue Aug 13, 2026
Merged via the queue into main with commit 180e6ac Aug 13, 2026
33 checks passed
@sirtimid
sirtimid deleted the sirtimid/e2e-stable-vat-krefs branch August 13, 2026 17:33
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