Skip to content

Commit 4262dda

Browse files
committed
fix(engine-doubles): close the two defects the recovered findOne sweep left, and alias metadata-core in service-datasource
Supersedes the "NOT REVIEWED" disclaimer on 88784b7: the gate half and the 211-file adoption below it have now been run, ablated and re-measured. Three things this commit changes, all of them found by running what that commit never ran. 1. TS2345 in service-messaging. `delivery-headers-at-rest.integration.test.ts` passed the fake's `q: unknown` straight into the predicate, whose parameter is `EngineFindOneQueryInput | null | undefined`. vitest never type-checks, so the suite was green and `tsc --noEmit` was red — the one direction a test-only sweep can go wrong invisibly. Cast at the call, matching the sibling `assertEngineUpdateDispatch(d as any, q as any)` pin three lines below it. 2. service-datasource's engine double reached `@objectstack/metadata-core` through `dist/`. `check:test-source-alias` names the repair and refuses the alternative: alias the specifier in the package's own vitest config, never widen the shrink-only registry. A pin resolved through a build artifact is pinned to whatever was last built rather than to the predicate beside it, which is the single failure a contract pin exists to prevent. 3. Import order in that same test file is now load-bearing, and says so. Aliasing metadata-core to source pulls its import graph into the package's resolution domain, which switches on the clocked-window rule for the whole package — and that rule then misreported a file that has paid its `@objectstack/spec/kernel` load at module top since #10120. Cause is a detector defect filed as #12555: the gate's import regex swallows a bare side-effect import whenever an `import … from …` follows it later in the file. Not worked around in the gate — the fix there needs its own `--self-test` cases — so the statement is placed where the detector reads it correctly, with a comment naming the constraint and the card that removes it.
1 parent ad4203d commit 4262dda

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

‎packages/services/service-datasource/src/__tests__/datasource-admin-plugin.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ import {
88
type DatasourceAdminServicePluginOptions,
99
} from '../datasource-admin-plugin.js';
1010

11+
import { assertEngineFindOnePredicate } from '@objectstack/metadata-core';
12+
1113
// [#10126] Pay the first transform of these dist-resolved workspace deps at MODULE
1214
// LOAD. Each is reached below through a dynamic `import()` inside an `it()` body or a
1315
// hook -- both of which vitest clocks, while collection is clocked against nothing. See
1416
// `scripts/check-test-source-alias.mjs` (the clocked-window rule) and #10115 / PR #10120,
1517
// where the same shape cost 30 ejected merge-queue builds in one night.
18+
//
19+
// ORDER IS LOAD-BEARING until #12555 lands: check-test-source-alias's import regex
20+
// swallows a bare side-effect import whenever an `import … from …` follows it later in
21+
// the file, so this statement must stay BELOW every `from` import or the clocked-window
22+
// rule reports this file as unpaid while the line it asks for is already here.
1623
import '@objectstack/spec/kernel';
17-
import { assertEngineFindOnePredicate } from '@objectstack/metadata-core';
1824

1925
/**
2026
* Minimal PluginContext + in-memory metadata service. Boots the plugin and

‎packages/services/service-datasource/vitest.config.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ export default defineConfig({
3737
// matches by PREFIX, so a bare `@objectstack/core` entry would also swallow
3838
// `@objectstack/core/logger` and resolve it to `core/src/index.ts/logger`
3939
// (ENOTDIR). Same shape as `service-storage` and `service-knowledge`.
40-
alias: [{ find: /^@objectstack\/core$/, replacement: path.resolve(__dirname, '../../core/src/index.ts') }],
40+
// `@objectstack/metadata-core` became a VALUE import of this package's TEST
41+
// layer when its engine double adopted `assertEngineFindOnePredicate`
42+
// (objectstack#12068). Same reasoning as the entry above, and the same
43+
// direction of danger: unaliased it would follow the workspace link to
44+
// `packages/metadata-core/dist/index.js`, so the double would be pinned to
45+
// whatever the last build of that predicate emitted rather than to the
46+
// predicate sitting next to it — a green pin over a stale contract, which is
47+
// the one failure a contract pin exists to make impossible.
48+
alias: [
49+
{ find: /^@objectstack\/core$/, replacement: path.resolve(__dirname, '../../core/src/index.ts') },
50+
{ find: /^@objectstack\/metadata-core$/, replacement: path.resolve(__dirname, '../../metadata-core/src/index.ts') },
51+
],
4152
},
4253
});

‎packages/services/service-messaging/src/delivery-headers-at-rest.integration.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ describe('sys_http_delivery — authored headers vs the data API (#8118)', () =>
288288
// its authored configuration.
289289
const noAccessor = {
290290
find: (o: string, q: unknown) => (eng as any).find(o, q),
291-
findOne: (o: string, q: unknown) => { assertEngineFindOnePredicate(o, q); return (eng as any).findOne(o, q); },
291+
findOne: (o: string, q: unknown) => { assertEngineFindOnePredicate(o, q as any); return (eng as any).findOne(o, q); },
292292
insert: (o: string, d: unknown) => (eng as any).insert(o, d),
293293
update: (o: string, d: unknown, q: unknown) => {
294294
// Engine-double contract: this fake's update() must be exactly

0 commit comments

Comments
 (0)