Repository navigation
test(rest): pay the objectql load at module top in the meta write-door enumeration - #30908
Merged
Merged
Conversation
…r enumeration
The record-currency backfill door's capability control was the one case in
meta-write-door-capability-enumeration.test.ts that got past a gate to the
door's guarded `import('@objectstack/objectql')`. That specifier resolves
through `dist/`, so the first load is a cold transform of the engine's module
graph, and it was paid inside the case's 5000 ms window: 3.2 s idle on
4 vCPU, and a timeout on two loaded cores 3 of 3, the Test Core (6/8) red.
A module-top `import '@objectstack/objectql'` moves that load into
collection, which no timeout clocks. The door's own import becomes a cache
hit; the case still drives both bases and both contexts and still expects
501 NOT_IMPLEMENTED past the gate.
Claude-Session: https://claude.ai/code/session_016WV4cyFzEX3mhkfxdV1M8E
Co-authored-by: Claude <noreply@anthropic.com>
Contributor
📓 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): |
3 tasks
Contributor
Author
|
domain:server#1 · os-elon-musk · session_016WV4cytLmJxfAmgPVjUbbW 席位核对 · ACCEPT · 2026-11-06T10:42Z · #30873Head-sha: 73062e5
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Elon · project thread
domain:server#1 · os-elon-musk · session_016WV4cyFzEX3mhkfxdV1M8E
Fixes #30873
Clause-②: no
Metadata-protocol: none
Claim: 6681653863 (re-posted with this branch as 6681707609) · Branch:
claude/project-thread-7l5fxn维护者速读
packages/rest/src/meta-write-door-capability-enumeration.test.ts,在文件顶部加一行import '@objectstack/objectql';和说明注释。没有改任何断言,没有改任何源码。import('@objectstack/objectql')的用例。这个包第一次加载要冷编译整个查询引擎,空闲时 3.2 秒,全算在该用例 5 秒的超时窗口里;机器一忙就超时,Test Core (6/8) 变红,把无关的 PR 踢出合并队列。把第一次加载挪到模块顶部,它就在收集阶段完成,收集阶段不计超时。501 NOT_IMPLEMENTED。回滚即撤 PR。packages/rest/src/meta-write-door-capability-enumeration.test.ts顶部新增的那一行 import 和注释;对照用例本身(文件末尾the control: its own capability)一字未动。pnpm --filter @objectstack/rest exec vitest run --project local src/meta-write-door-capability-enumeration.test.ts,预期 66/66 通过,该用例约 5 ms(之前约 3.3 秒)。What changes
packages/rest/src/meta-write-door-capability-enumeration.test.tsonly, +10 / -0: a module-topimport '@objectstack/objectql';under a comment carrying the measured reason. No assertion, no case and no source file changes.The
#30675control case ("its own capability (andisSystem) passes the gate, on both bases") is the one case in this file that gets past a gate into the record-currency backfill door, which loadsbackfillRecordCurrencyCodesthrough a guardedimport('@objectstack/objectql'). In this package that specifier resolves through the workspace link topackages/objectql/dist/, so the first load is a cold vite transform of the engine's module graph. It was paid inside the case's 5000 mstestTimeout. Loaded at module top, it is paid during collection, which no vitest timeout clocks (the convention in AGENTS.md § Build & Test and inscripts/check-test-source-alias.mjs's clocked-window section;analytics-dataset-body-door.test.tsin this package is the same shape). The door's ownimport()then resolves to the module already loaded.The case is unchanged: it still knocks on both bases (
/api/v1and the scoped/api/v1/environments/:environmentId) as both asetup.writeholder andisSystem, and still expects501 NOT_IMPLEMENTEDwith the nestedNOT_IMPLEMENTEDcode, which is the answer that tells the gate's verdict apart from its refusal.@objectstack/objectqlis already in@objectstack/rest'sKNOWN_UNALIASED_TEST_IMPORTSset (other tests here import it statically), so no ledger moves.Why
Card #30873: Test Core (6/8) on PR #30870 (a translations-only
service-settingsPR) timed out on this case twice, job 127778628692 on9c22c667and job 127785162372 on9e0f2cd6,Test timed out in 5000ms, while every other case in the file passed.Where the time goes, measured on
origin/main98f640d5in this container (4 vCPU) with a throwaway probe test (not committed) that times each step inside a vitest worker of this package:import('@objectstack/objectql')import('@objectstack/objectql')new RestServer(...)+registerRoutes()(scopingauto)So of the case's ~3.3 s idle, about 3.2 s is the cold load; the four boots cost about 13 ms together and the handler past the gate is negligible. The case pays the import on its first knock only, which is why the other three knocks in the same case are cheap.
The other cases in the same describe do not share the cost: the anonymous case and the refusal case are answered 401 / 403 before the door resolves an engine or reaches the import (2-6 ms each, before and after). The route's own test file,
meta-record-currency-backfill-route.test.ts, already importsObjectQLfrom@objectstack/objectqlat module top.No timeout was raised, and none is needed (below).
Tests
Before is
origin/main98f640d5, after is this branch. Same container, 4 CPUs. "Loaded" pins vitest to CPUs 0-1 beside fournode -e 'for(;;){}'busy loops pinned to the same two CPUs (PIDs recorded, killed by a trap). Command:pnpm exec vitest run --project local src/meta-write-door-capability-enumeration.test.tsinpackages/rest.Test timed out in 5000ms, 3 of 3 runsEvery other case is under 20 ms idle before and after (the slowest is the anti-drift enumeration case, 14-19 ms idle, 29-34 ms loaded after).
Where the load went: vitest's own Duration line, one run each
The load is moved out of the clocked window, not removed: the file's total wall is about the same, and the seconds move from
teststoimport(collection).Duration 8.86s (transform 6.43s, setup 0ms, import 5.24s, tests 3.47s), 66 passed.Duration 8.50s (transform 6.23s, setup 0ms, import 8.26s, tests 91ms), 66 passed.Duration 16.05s (transform 12.65s, setup 0ms, import 10.16s, tests 5.31s), 1 failed, 65 passed:FAIL |local| … > the control: its own capability (and isSystem) passes the gate, on both bases,Error: Test timed out in 5000ms.Duration 25.33s (transform 18.05s, setup 0ms, import 24.49s, tests 343ms), 66 passed. The loaded collection is slow and noisy on two contended cores; no vitest timeout covers it.The before-idle Duration run was taken by writing the
98f640d5blob of the test file over the committed fix, running it, and restoring withgit checkout HEAD --; the restored file's hash equals the HEAD blob andgit diff HEADis empty.No ablation: the diff changes no behaviour a test pins (it moves where a module is first loaded; every assertion is byte-identical to
main).Acceptance notes
@objectstack/rest'sfilesisdist,README.mdandCHANGELOG.md, and afterpnpm --filter @objectstack/rest buildthe new comment has 0 hits underpackages/rest/dist(positive control:_migrate-record-currency-codes, 2 hits). Nothing published moves. No changeset, labelledskip-changeset.pnpm check:test-source-aliasdid not flag the old shape and could not: its clocked-window rule reads load sites in TEST files (plus one hop through a same-package helper that imports a non-literal specifier), while this load sat in the door's source, reached from a test's clocked window through a route handler. Reported to the seat as a finding; not changed here (outside this card's file surface).Verification
All on the final head
73062e5028(one commit onorigin/main98f640d5, which had not moved when this PR opened; the delta againstmainis the one file, +10 / -0), after a whole-treeturbo run build --filter=!@objectstack/docs(118/118 tasks, lock VERDICT command-exit 0).pnpm --filter @objectstack/rest test(thelocalproject) under the verify lock: Test Files 393 passed (393), Tests 7456 passed, 332 skipped (7788), VERDICT command-exit 0. Therepoproject (test:repo) is left to CI: this file is not invitest.repo-tests.json.pnpm --filter @objectstack/rest typecheck(tsc --noEmitpluscheck:test-typecheck, which compiles the test layer undertsconfig.test.json): VERDICT command-exit 0, 0 errors.node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 49 families on73062e5028. Each ran sequentially with its exit code captured before any pipe: 48 exit 0 on the first pass andpnpm check:dual-build-cjs-loadsexit 3 (PREREQUISITE NOT MET, no dist for 46 packages); after the whole-tree build it ran again, exit 0.pnpm lint: exit 0.dispatch-gates --ran: "49 derived famil(ies) accounted for — 49 run, 0 NOT-MEASURED", withpnpm lintlisted as outside the derivation.Human Minimum
packages/specholds no runtime logic. (Nopackages/specchange.)pnpm lintpasses.main, one pull request.skip-changeset.)packages/spectouched: its generated artifacts are regenerated and committed. (Not touched.)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code