Commit 180e6ac
test(extension): derive vat krefs in the e2e rather than hardcoding them (#1024)
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.ts` › `should collect garbage` asserted that Carol's
root object is `ko6` and Bob's is `ko5`, and that their promises are
`kp4` and `kp3`:
```js
'{"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
- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, `README.md`, `CHANGELOG.md`) as
appropriate — test-only change, no changelog entry
<!-- CURSOR_SUMMARY -->
---
> [!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.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
d8e81f7. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 494fb5e commit 180e6ac
1 file changed
Lines changed: 105 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
43 | 125 | | |
44 | 126 | | |
45 | 127 | | |
| |||
157 | 239 | | |
158 | 240 | | |
159 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
160 | 247 | | |
161 | 248 | | |
162 | 249 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
170 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
171 | 263 | | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
176 | 268 | | |
177 | 269 | | |
178 | 270 | | |
179 | | - | |
| 271 | + | |
180 | 272 | | |
181 | 273 | | |
182 | 274 | | |
| |||
241 | 333 | | |
242 | 334 | | |
243 | 335 | | |
244 | | - | |
| 336 | + | |
245 | 337 | | |
246 | 338 | | |
247 | 339 | | |
| |||
0 commit comments