Skip to content

Commit 4bab1b1

Browse files
committed
test(runtime,metadata-protocol,objectql): import a lint-root preload testkit at module top instead of a setup file
A setup file made every test file pay the lint root's load, measured at about +200 s of worker time in metadata-protocol and runtime and +330 s in objectql. A testkit per package, imported at module top by only the files whose traced run showed the first load inside a case, moves exactly that load into collection. objectql declares @objectstack/lint as a devDependency so the import type-checks, and keeps the anchored source alias that check:test-source-alias requires for it. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2gLghEqeDKTbDTC7Zd
1 parent a89a1cc commit 4bab1b1

77 files changed

Lines changed: 236 additions & 137 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
//
3+
// Import this at module top in a test file whose cases make a served `view`
4+
// read or an object publish, so the file pays the first load of the
5+
// `@objectstack/lint` package ROOT during collection, never inside a clocked
6+
// case. Test-only: no product module imports it.
7+
//
8+
// The protocol loads the lint root lazily, on first use, in two places: a
9+
// served `view` read decorates its `_diagnostics` with the form-layout
10+
// warnings (`loadFormLayoutLint`, metadata-diagnostics.ts), and an object
11+
// publish runs its build probes (`runBuildProbes`, build-probes.ts). The lazy
12+
// shape is product design: the kernel boot path never reaches the root.
13+
// Under vitest the first such load in a file is a cold transform of the lint
14+
// module graph, paid inside whichever case gets there first. A module-top
15+
// import is paid during collection, which neither `testTimeout` nor
16+
// `hookTimeout` clocks, and the protocol's later `import()` gets the same
17+
// module instance back (AGENTS.md § Build & Test, the clocked-window rule).
18+
//
19+
// Here the root resolves to `lint/dist/index.js`: this package's row in
20+
// `check:test-source-alias` lists `@objectstack/lint` as still read from
21+
// `dist/`.
22+
//
23+
// Who imports it: every test file in which a traced run of the whole suite
24+
// saw that first load inside a case. A new file whose cases reach a view read
25+
// or an object publish imports it too. It is not a `setupFiles` entry,
26+
// because then every test file in the package pays the load, including the
27+
// many that never reach it: measured, that added about 200 s of worker time
28+
// and about a third to the suite's wall time.
29+
import '@objectstack/lint';

‎packages/metadata-protocol/src/protocol-publish-drafts-closure.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
* `saveMetaItem` / `publishPackageDrafts` run.
5757
*/
5858

59+
// Pays the lint root's first load at collection, never inside a clocked case.
60+
import './lint-root-preload.testkit.js';
5961
import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest';
6062
// The producer's OWN write-verb dispatch decisions, so the fake engine below
6163
// cannot accept a call ObjectQL refuses. From `@objectstack/metadata-core`,

‎packages/metadata-protocol/src/protocol-publish-drafts-endpoint-gate.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
22

3+
// Pays the lint root's first load at collection, never inside a clocked case.
4+
import './lint-root-preload.testkit.js';
35
import { describe, expect, it } from 'vitest';
46
// [#5619] The producer's OWN write-verb dispatch decisions (#4550 delete /
57
// #5480 update), so the fake engine below cannot accept a call ObjectQL

‎packages/metadata-protocol/src/protocol-publish-drafts-object-field-refs.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
* `publishPackageDrafts`; nothing on the gate path is stubbed.
4242
*/
4343

44+
// Pays the lint root's first load at collection, never inside a clocked case.
45+
import './lint-root-preload.testkit.js';
4446
import { describe, expect, it } from 'vitest';
4547
import { assertEngineDeleteDispatch, assertEngineUpdateDispatch, assertEngineFindOnePredicate } from '@objectstack/metadata-core';
4648
import { ObjectStackProtocolImplementation } from './protocol.js';

‎packages/metadata-protocol/src/protocol-publish-drafts-org-scope.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
22

3+
// Pays the lint root's first load at collection, never inside a clocked case.
4+
import './lint-root-preload.testkit.js';
35
import { describe, expect, it } from 'vitest';
46
// [#5619] The producer's OWN write-verb dispatch decisions (#4550 delete /
57
// #5480 update), so the fake engine below cannot accept a call ObjectQL

‎packages/metadata-protocol/src/protocol-publish-drafts-package-scope.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
22

3+
// Pays the lint root's first load at collection, never inside a clocked case.
4+
import './lint-root-preload.testkit.js';
35
import { describe, expect, it } from 'vitest';
46
// [#5619] The producer's OWN write-verb dispatch decisions (#4550 delete /
57
// #5480 update), so the fake engine below cannot accept a call ObjectQL

‎packages/metadata-protocol/src/protocol.app-package-id-key.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
* `findOne` over `sys_metadata` rows, and a registry answering a
3030
* package-scoped lookup with that package's items only.
3131
*/
32+
// Pays the lint root's first load at collection, never inside a clocked case.
33+
import './lint-root-preload.testkit.js';
3234
import { afterEach, describe, expect, it, vi } from 'vitest';
3335
import { assertEngineFindOnePredicate, isCodeArtifactBody } from '@objectstack/metadata-core';
3436
import { ObjectStackProtocolImplementation } from './protocol.js';

‎packages/metadata-protocol/src/protocol.draft-publish-verdict.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
* shape). Nothing on the save, read or publish path is stubbed.
2929
*/
3030

31+
// Pays the lint root's first load at collection, never inside a clocked case.
32+
import './lint-root-preload.testkit.js';
3133
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3234
import { assertEngineDeleteDispatch, assertEngineUpdateDispatch, assertEngineFindOnePredicate } from '@objectstack/metadata-core';
3335
import { ObjectStackProtocolImplementation } from './protocol.js';

‎packages/metadata-protocol/src/protocol.extension-field-suffix.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
* as a row stored before the rule (`residueField()`).
3131
*/
3232

33+
// Pays the lint root's first load at collection, never inside a clocked case.
34+
import './lint-root-preload.testkit.js';
3335
import { afterEach, describe, expect, it, vi } from 'vitest';
3436
// [#5619] The producer's OWN write-verb dispatch decisions, imported from
3537
// `@objectstack/metadata-core` and NOT from `@objectstack/objectql`: objectql

‎packages/metadata-protocol/src/protocol.flow-by-name-shipped-name.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
* caller naming an organization reads as the environment does, and a type in
2828
* the overlay regime keeps its overlay.
2929
*/
30+
// Pays the lint root's first load at collection, never inside a clocked case.
31+
import './lint-root-preload.testkit.js';
3032
import { describe, expect, it, vi } from 'vitest';
3133
import { assertEngineFindOnePredicate, isCodeArtifactBody } from '@objectstack/metadata-core';
3234
import type { FlowRegistration } from '@objectstack/spec/api';

0 commit comments

Comments
 (0)