Repository navigation
test(client): the auth envelope suite reads one registration and one sign-in instead of building one per case - #23588
Conversation
…in instead of building one per case auth-login-register-envelope.test.ts judged the result of a register(), a login() or both in 16 cases, and 13 of them built their own fresh engine, AuthManager and real scrypt sign-up (27 production-parameter derivations, 2.7 s) to read a value no case writes to. The cases now read one arrangement, built lazily inside the first case that asks for it, so it stays inside a clock, and its engine closes once after the file. Isolated, at 252775d on a 4-vCPU box shared with sibling agents: the clocked file wall was 4445-4886 ms over five runs; a probe of this arrangement read 441-461 ms. Assertions and it/describe titles unchanged. Part of the @objectstack/client row of the test-budget card (#23181). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FLwgbTSmGMrqsXkBDsiwfG
…-client-test-budget
📓 Docs Drift CheckNothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs. What this run could not see
Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): |
✅ ACCEPT: PR #23588 at
|
Part of #23181
Clause-②: no
Slice 2 of the test-budget card: the
@objectstack/clientrow, which has two files. This PR takes one of them,packages/client/src/auth-login-register-envelope.test.ts. It does not claimpackages/client/src/auth-rotated-session-token.test.ts; see "The rotated-token file" below. Test files only: one file changed, andskip-changesetapplies by its criterion, because nothing in the package'sfiles[]moves.What changed
auth-login-register-envelope.test.tsjudges the result of aregister(), alogin()or both in 16 cases. None of them writes: no case changes the server's state or the returned values. Yet 13 of them built their own fresh engine,AuthManagerand real scrypt sign-up (and a sign-in on top for most) only to read that value. They now read ONE registration and ONE sign-in of that user (theRegistration(),theSignIn()). It is built lazily, inside the first case that asks for it, so the work stays inside a clock. The shared engine is shut down once, inafterAll.Unchanged: the module-scope warm-up and its pin ⑦, every
expect((47 = 47), and every it/describe title (the sha256 of the title lines is identical at252775d1dand9a7f5bd95). The header gains a section that says why, and that a case that writes builds its ownscenario().Where the wall went (measured before changing anything)
Box: 4 vCPU, shared with sibling agents; every run went through
os-verify-lock. "Clocked" is the file line's duration in vitest's default reporter, the one CI'sreport-test-timings.mjsreads: hooks plus tests, collection excluded. Runs hadAI_AGENTandCLAUDECODEunset, so vitest picks that reporter.38319885190)252775d1d)Both files run under 10 s on this box. The card's readings are about 4.5x the isolated median for both files, and 3.5 to 3.7x the whole-package reading. Neither file, nor anything it waits on, has a sleep, timer, retry or network hop. Per test:
node:crypto.scrypt, not committed) counted 27 production-parameter derivations, 2737 ms of the 4819 ms clocked in that run.After
9a7f5bd95)9a7f5bd95); 1027 ms (072fd4241,pnpm --filter @objectstack/client test)The first case now pays the one arrangement (347 to 440 ms). ④'s login case takes 29 to 39 ms, ⑤'s
/get-sessioncase 14 to 18 ms, and the rest 0 to 7 ms. At the card's ratio (about 4.5x isolated), 510 ms projects to about 2.3 s in the hourly battery. That projection is an estimate; the card's own pin, the next refresh list, decides.The after-change whole-package runs were on a busier box: the whole suite took 97.6 to 100.2 s against 61.9 s before. In those runs the unchanged rotated-token file read 7129 to 7276 ms, against 4114 ms before. That 1.7x swing on an untouched file is the same contention the card's seconds carry.
The rotated-token file (row not claimed)
Its cases cannot share an arrangement. Each case changes its own user's credential state, and the first sign-up on an environment shuts self-registration, so each case needs a fresh engine and manager. What remains is the file's own behaviour.
One measured lever exists and is not taken here: plugin-auth's test-only scrypt memo (
packages/plugins/plugin-auth/src/__tests__/scrypt-memo.testkit.ts, from #23184). It answers a repeated derivation with the bytes the real call produced. In a probe it took this file from 3310 ms to 2433 to 2610 ms (9 of 18 derivations answered from the memo), about 24% less. At the card's ratio that still projects to about 11 s. Adopting it needs either a second copy of that testkit inpackages/clientor one shared home for it. That choice belongs to the seat, not to this slice, and the report carries the options.Proof the shared arrangement still fails when its subject breaks
Three ablations at the committed
9a7f5bd95, throughscripts/ablation-replace.mjsin wrap mode. Both subjects load from source: the test imports./index, andvitest.config.tsaliases@objectstack/plugin-authtosrc/. So there is no dist leg. The predicted direction before each run was red.success(packages/client/src/index.ts). Result: 5 red, 11 green (① ×2, ② ×2, and ③'sdata.sessioncase). Predicted 5, observed 5.auth.loginstops armingclient.token. Result: 2 red (④'s login case and ⑤'s same-row case). Predicted 2, observed 2.session-envelope-completion.ts). Result: 7 red (② ×2, ③'ssuccesscase, ⑤ ×4). Predicted 6. The extra one is ③'ssuccesscase: its exhaustive issue list also gainsdata.session, so the red is correct.Each restore was proven: the blob equals HEAD (
29bd23c088af,e701c4763eef) andgit diff HEADis empty.Tests and gates
Every reading below is at
072fd4241(a merge oforigin/mainfa6a6085c), taken after the last commit.pnpm --filter @objectstack/client test: 51 files and 663 tests passed, exit 0. In that run the envelope file read 1027 ms and the rotated-token file 7129 ms.pnpm --filter @objectstack/client typecheck: exit 0.check:test-typecheckis OK, with 0 entries in the debt ledger. The changed file is in thetsconfig.test.jsonprogram (tsc --listFilesOnly: 1 hit).node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 51 commands for the one changed path. 49 exited 0 on the first pass. Two answered exit 3, PREREQUISITE NOT MET, because they read built output (check:skill-examplesandcheck:dual-build-cjs-loads). After a fullturbo run build(76/76 tasks), the same two commands exited 0: 263 prose examples type-check, and 110 require entry points across 68 packages load.--ran: "51 derived, 51 run, 0 NOT-MEASURED, 0 UNRUN."dispatch-gatesdoes not name:eslint packages/client --no-inline-configlinted 57 files, the changed file among them, with 0 errors, 0 warnings and 0 fatal, exit 0. The repo-widepnpm lintis left to CI.Acceptance notes
auth-rotated-session-token.test.tsrow stays open, as described above. The measured lever is plugin-auth's scrypt memo testkit, which currently lives only in that package; the report's open question carries the choice. Not filed.Generated by Claude Code