Repository navigation
test(lint): load the linked @objectstack/spec dist with Node, not vite's transform - #24048
Conversation
…e's transform packages/lint's vitest inlined the pnpm-linked spec dist (about 33 MB of built .mjs) because vitest's default external pattern is node_modules-only and a workspace link's realpath is packages/spec/dist. Externalise it with a realpath pattern, and add a positive control that proves the pattern matches: the spec module the tests import must be the very instance Node's loader holds, which goes red when the dist is inlined. Claude-Session: https://claude.ai/code/session_019oKRRCxbLy3xARM3CH99sf Co-authored-by: Claude <noreply@anthropic.com>
… lines With the spec dist externalised, lazy-deps.test.ts and runtime-lazy-deps.test.ts each run in 6.5-6.8 s alone (15.0-15.2 s and 14.2-14.6 s before, same box, under os-verify-lock), under the 10 s file line, and the lines' stated reason, vite's transform of the inlined spec dist, no longer holds. No post-change CI reading exists to re-measure a budget from, so the files return to the 10 s line. Claude-Session: https://claude.ai/code/session_019oKRRCxbLy3xARM3CH99sf Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift Check
What this run could not see
Coarse fallback — 4 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): |
The root namespace import broke the repo's no-restricted-imports rule for @objectstack/spec. Import defineStack from the root and ObjectSchema from the data subpath by name; the identity check is unchanged. Claude-Session: https://claude.ai/code/session_019oKRRCxbLy3xARM3CH99sf Co-authored-by: Claude <noreply@anthropic.com>
席位核对 · ACCEPT · PR #24048 @
|
Fixes #23900
Clause-②: no
What
packages/lint's vitest now loads the pnpm-linked@objectstack/specdist with Node instead of inlining it through vite's transform:packages/lint/vitest.config.ts: onetest.server.deps.externalentry,/[\\/]packages[\\/]spec[\\/]dist[\\/]/, which matches the module's realpath. Vitest's defaultexternalcovers only node_modules, and a workspace link's realpath ispackages/spec/dist/..., so before this every file whose graph reaches spec inlined about 33 MB of built.mjs. The header now says the config carries two settings and why each is package-wide.packages/lint/src/vitest-spec-external.test.ts(new) is the positive control the card asks for. It checks that the spec module the tests import (root and/data, resolved frompackages/lintexactly as the sources resolve it) is the same instance Node's own loader holds. It loads the ESM entry theexportsmap names withcreateRequire(Node 22's require(esm) shares the ESM loader's module map) and asserts export identity. When the dist is inlined, vite evaluates its own copy, so the identity assertions go red.// test-budget: 30 — whole-package importlines onlazy-deps.test.tsandruntime-lazy-deps.test.tsare dropped (see the measurement below).The import resolves through
exportstodist/either way, so this changes only who evaluates the dist, never which bytes are under test.Mock census (before the change)
git grep -nE "vi\.(mock|doMock|hoisted|unmock|importActual|importMock|spyOn)\b" -- packages/lintat2b274600b1: 0vi.mock/vi.doMock/vi.hoistedsites. The only hits are twovi.spyOn(console, ...), which spy on a global and are unaffected. Control leg: the samevi.mock(spelling finds 30 files inpackages/cli/src, so the zero is a real reading.Positive control: what it proves and how it goes red
Both ablations ran through
scripts/ablation-replace.mjson the committed fixbe2f7c34, with the anchor hit and the blob change proven on disk:vitest-spec-external.test.tsexternalentry deletedtypeof/toBeDefinedlines pass/@objectstack[\\/]spec/(the trappackages/cli/vitest.config.tsrecords)Restore proof: the
vitest.config.tsblob on disk equals HEAD's (4ecbe245f449), andgit diff HEADis empty.Measurement (paired, same box, under
os-verify-lock.sh; shared-box seconds)2b274600b1)be2f7c34, 54 s at77f016c5(142 files / 6804 tests, green; +1 file / +2 cases = the control)transform/importlazy-deps.test.tsalone, two runsruntime-lazy-deps.test.tsalone, two runsBudget lines dropped, not re-measured. Both files now run in 6.5 to 6.8 s alone, under the 10 s
FILE_BUDGET_SECONDSline. The lines' stated reason ("vitest's transform of ... every inlined @objectstack/spec dist bundle") is no longer true. A budget is a CI reading x 1.25, and no CI reading after the change exists yet to re-measure from. If an hourly reading later puts either file over 10 s, that reading is the measurement a re-declaration needs (ruling6181973363item 2).Acceptance notes
@objectstack/formulaand@objectstack/sdui-parser(lint's other two workspace deps) are still inlined. The card scopes only spec, and they are not measured here.vi.mocked. A later test that needs to mock spec has to move the entry.Verification
e0d24934(patch round): the control now importsdefineStackfrom@objectstack/specandObjectSchemafrom@objectstack/spec/databy name. The root namespace import broke the repo'sno-restricted-importsrule for@objectstack/spec. The identity check is unchanged.node --stack-size=4000 node_modules/eslint/bin/eslint.js --no-inline-config ...: exit 1 on77f016c5(oneno-restricted-importserror atvitest-spec-external.test.ts:29:8), exit 0 one0d24934.e0d24934throughscripts/ablation-replace.mjs. With theexternalentry deleted, and with the name-shaped/@objectstack[\\/]spec/, the control is 2/2 red at:48:25and:54:26(Object.isidentity). Restore: the disk blob equals the HEAD blob4ecbe245f449, andgit diff HEADis empty.pnpm --filter @objectstack/lint testate0d24934: 142/142 files, 6804/6804 tests (VERDICT command-exit 0, lock held 54 s).pnpm --filter @objectstack/lint typecheck(includingcheck:test-typecheck) ate0d24934:VERDICT command-exit 0; the debt ledger is unchanged (2 files / 6 errors).node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --ran ...ate0d24934: 51 derived, 50 run with exit 0, 1 NOT-MEASURED (pnpm check:dual-build-cjs-loadsexited 3 because it needs a full-repo build; CI measures it), 0 unrun. Also rannode scripts/check-console-intercept-disarm.mjs: exit 0.@objectstack/lint'sfiles[]isdist, README, CHANGELOG. None of the changed text is in the builtdist/(0 hits), while a shipped symbol (validateStackExpressions) has 8 hits as the positive control.Written by the
os-devcloud sessionsession_019oKRRCxbLy3xARM3CH99sf, dispatched bydomain:specseat 1 (claim6224227197).Generated by Claude Code