Repository navigation
Commit f2e7083
test(runtime,client): pay the reader-contexts pin's first loads at module scope and share one auth server across the rotated-token cases (#26227)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XP5yokEzFQq2X7EXPg3PnHb)_
Part of #23181 (slice 13, `domain:server` seat 1). The card stays open
for its other rows and for the refresh that judges these two.
Clause-②: no
Metadata-protocol: none
Test-only diff: two test files, nothing published, so `skip-changeset`
rides the create.
## The reading this slice used
The newest refresh run, not a landed refresh PR (none has landed since
the card's table): `shard-timings-refresh` run `40275747937` (schedule,
2026-10-26T05:43Z, head `2a728ba2a`, 14 hourly full-battery runs
`40200279306`..`40272142430`), whose `--diff` step logs every test file
over budget. Of this slice's six named files it still lists two:
| file | before (CI, slowest run in window) |
|:--|--:|
| `@objectstack/runtime`
`src/stored-metadata-reader-contexts.pin.test.ts` (local) | 16.31 s
(`40200279306`) |
| `@objectstack/client` `src/auth-rotated-session-token.test.ts` | 13.62
s (`40200279306`) |
No longer listed (earlier slices closed them): runtime
`declared-capability-absence-warn-once.test.ts` and
`stored-metadata-body-boundary.pin.test.ts`, rest
`import-template-route.test.ts`, client
`auth-login-register-envelope.test.ts`. Not touched.
## What changed
**`runtime/src/stored-metadata-reader-contexts.pin.test.ts`.** The file
already booted once per file. What its `beforeAll` paid was first use:
measured in one process, the first boot took 1962 ms and a second
identical boot 673 ms, because the boot `import()`s better-auth and the
services' entries lazily and runs every path cold. The boot is now one
function (`bootKernel`), and a module-scope `warmUpFirstLoads()` runs it
once on a throwaway app (its own manifest, object and database), signs
the dev administrator in and runs one sandboxed body, then stops it
before `beforeAll`. That is the repo's convention (AGENTS.md: clocked
windows measure behaviour, never loading), the same shape as
`@objectstack/verify`'s `boot-warm-up.testkit.ts` and rest's
`import-template-route.test.ts`. A failed warm-up throws during
collection, so it cannot pass silently. `NODE_ENV` is put back as found.
**`client/src/auth-rotated-session-token.test.ts`.** Every case built a
fresh engine, schema sync and `AuthManager` (about 150 ms each,
measured) before signing a user up. The cases now share one engine and
one `AuthManager` (`fileServer()`, built by the first case, destroyed in
`afterAll`). Each case still signs up a user of its own through a client
of its own, and every assertion is about that user's credential. Because
the default audience posture is `invite_only`, each user enters through
a pending `sys_invitation` row, the lane `@objectstack/verify`'s signUp
and the runtime pin above take. The module-scope warm-up keeps its own
server and destroys it before the first case, as before; case ④'s pins
(one module-scope `await signedIn();`, one `before*` hook, no widened
clock) hold unchanged.
## Measurements (local, 4 vCPU, shared box, through `os-verify-lock`)
Module-line milliseconds (the number the timing table reads), a copy of
each file at base `601c77384` interleaved with the file at `453c7e3ae`
(this diff before the merge with `origin/main`), three runs each:
| file | before | after | median |
|:--|:--|:--|:--|
| runtime pin | 5126 / 4957 / 4922 | 3712 / 3750 / 4008 | 4957 → 3750
(−24 %) |
| client rotated-token | 3874 / 4561 / 4161 | 3085 / 3116 / 3371 | 4161
→ 3116 (−25 %) |
- **Isolation:** `--sequence.shuffle` with seeds 101, 202 and 303 on
both files: 27/27 and 8/8 pass every run, and the verbose order confirms
the cases ran shuffled (seed 101 runs client case ③ first).
- **Assertions unchanged:** the `it`/`describe` title lines hash equal
at base `601c77384` and head (runtime 28 lines `451ebc4925fbeaaf`,
client 12 lines `36683f1bc93a4451`); `expect(` counts 50 = 50 and 43 =
43. No timeout, budget, project or roster entry moved; nothing deleted.
- **What it costs.** The client change removes work (seven fewer engine
and auth-manager builds per run). The runtime change moves first-load
cost out of the clocked window and adds one warm boot (about 0.7 s of
CPU during collection): the whole vitest run's wall is unchanged (33.1 /
33.6 s before, 33.3 / 32.9 s after, two runs on a loaded box).
## Does it close the rows?
Not proven. On the before ratio of each file (CI 16.31 s against 4957 ms
local, 13.62 s against 4161 ms), the projections are about 12.3 s for
the runtime pin and 10.2 s for the client file. The next landed refresh
decides; this PR claims no row as closed.
What is left is behaviour:
- runtime pin: about 40 sandboxed body runs, each of which instantiates
a fresh QuickJS WASM module by design (`sandbox/quickjs-runner.ts`,
ADR-0102 D2), with a major GC roughly every third run (single runs of
the same action measured 28 to 142 ms). The `/meta`-authored actions
bind on the first poll (measured: 1 poll each), so no wait is left to
cut.
- client file: the real scrypt derivations (each case's sign-up plus its
password checks) at production parameters.
## Acceptance notes
- Other runtime rows in the same reading, outside this slice's file
surface and untouched:
`src/domains/mcp-package-object-discovery.test.ts` (local) 14.93 s and
`src/domains/meta-list-projection-parity.test.ts` (repo) 13.60 s, both
run `40200279306`.
- `packages/runtime` typecheck needs `@objectstack/driver-turso` built
(`organization-ownership-boot-guard.turso-remote.kernel.test.ts` imports
it) even though it is outside `@objectstack/runtime^...`; a closure-only
build reports TS2307 there. Local setup, not a defect.
## Verification
Run at head `df1b49998` (the branch merged with `origin/main`; the two
test files are unchanged by the merge), all through `os-verify-lock`
except the gates and eslint:
- `pnpm --filter @objectstack/runtime test`: Test Files 455 passed
(455), Tests 7408 passed | 19 skipped (7427).
- `pnpm --filter @objectstack/client test`: Test Files 52 passed (52),
Tests 671 passed (671).
- `pnpm --filter @objectstack/runtime typecheck` and `pnpm --filter
@objectstack/client typecheck`: exit 0, `check:test-typecheck: OK` for
both; each changed file is in its package's `tsconfig.test.json` program
(`tsc --listFilesOnly`, 1 hit each).
- `eslint --no-inline-config packages/runtime packages/client`: exit 0.
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 56 commands; each ran with its exit
code captured before any pipe, all 56 exit 0. `--ran`: "Run
reconciliation — 56 derived, 56 run, 0 NOT-MEASURED, 0 UNRUN", exit 0.
- `--sequence.shuffle` (seeds 101, 202, 303) re-run on this head: 27/27
and 8/8 every run.
No ablation: no tested behaviour changed. The diff changes how the two
files arrange their servers, not what any case asserts.
---
_Generated by [Claude
Code](https://claude.ai/code/session_017YG7VcjjNVTjKQp5HhS3TU)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent f42b55f commit f2e7083
2 files changed
Lines changed: 126 additions & 23 deletions
File tree
- packages
- client/src
- runtime/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
86 | | - | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| |||
200 | 201 | | |
201 | 202 | | |
202 | 203 | | |
203 | | - | |
204 | | - | |
| 204 | + | |
| 205 | + | |
205 | 206 | | |
206 | 207 | | |
207 | 208 | | |
208 | 209 | | |
209 | 210 | | |
210 | 211 | | |
211 | 212 | | |
| 213 | + | |
| 214 | + | |
212 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
213 | 232 | | |
214 | 233 | | |
215 | 234 | | |
| |||
220 | 239 | | |
221 | 240 | | |
222 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
223 | 258 | | |
224 | 259 | | |
225 | 260 | | |
| |||
304 | 339 | | |
305 | 340 | | |
306 | 341 | | |
307 | | - | |
| 342 | + | |
308 | 343 | | |
| 344 | + | |
309 | 345 | | |
310 | 346 | | |
311 | 347 | | |
| |||
326 | 362 | | |
327 | 363 | | |
328 | 364 | | |
329 | | - | |
| 365 | + | |
330 | 366 | | |
331 | | - | |
332 | 367 | | |
| 368 | + | |
333 | 369 | | |
334 | 370 | | |
335 | 371 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
419 | 498 | | |
420 | 499 | | |
421 | 500 | | |
422 | 501 | | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
| 502 | + | |
436 | 503 | | |
437 | 504 | | |
438 | 505 | | |
| |||
0 commit comments