Skip to content

Commit ef1ce6f

Browse files
committed
test(integration): align F23 fixture with deriveProvidedInvariants on all invariant ops
The F23 aggregate-schema verify test wrote the test extension's pinned migration with providedInvariants: [] and dropped the head ref's invariants, on the (stale) assumption that deriveProvidedInvariants only counts data-class ops. M2.5b's loader integrity gate (PN-MIG-5002) re-derives providedInvariants from on-disk ops and rejects mismatch; M2.5's deriveProvidedInvariants counts every op carrying an invariantId, regardless of operationClass. The test extension's baseline op is additive but carries an invariantId, so the on-disk fixture must round-trip the same set. Fixture now writes the head ref invariants and migration providedInvariants matching the in-memory metadata, recomputing only the migrationHash (the in-memory placeholder hash isn't valid).
1 parent 4a60028 commit ef1ce6f

1 file changed

Lines changed: 21 additions & 19 deletions

File tree

test/integration/test/cli.db-verify.aggregate-schema.test.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,17 @@ import {
2727
} from './utils/cli-test-helpers';
2828

2929
/**
30-
* `db verify` against a multi-member aggregate (app + extension, both
31-
* claiming live tables) returns zero schema issues.
30+
* F23 lock — `db verify` against a multi-member aggregate (app +
31+
* extension, both claiming live tables) returns zero schema issues.
3232
*
33-
* The aggregate verifier pre-projects the live schema per member
34-
* before running the family's schema-verify, so each member only sees
35-
* the elements it owns. Without the pre-projection, tables claimed by
36-
* extensions would surface in the app's diff as `extras` and trip
37-
* lenient/strict schema verification.
33+
* Pre-aggregate (M2 R6 R1), `db verify` projected the live schema only
34+
* through the app contract. Tables claimed by extensions surfaced as
35+
* `extras` and tripped lenient/strict schema diffs, polluting the
36+
* verify output. The aggregate verifier (M2.5) pre-projects the live
37+
* schema per member before running the family's schema-verify, so each
38+
* member only sees the elements it owns.
3839
*
39-
* Setup:
40+
* Setup mirrors the spec's intent (sub-spec § "Commit 6"):
4041
* - app contract claims `user`
4142
* - extension `test-contract-space` claims `test_box`
4243
* - both tables exist in the live DB and both markers match the
@@ -55,26 +56,27 @@ async function writePinnedExtensionDir(testDir: string): Promise<string> {
5556
const migrationsDir = join(testDir, 'migrations');
5657
await mkdir(migrationsDir, { recursive: true });
5758

58-
// The on-disk head ref's invariants must be derivable from the
59-
// on-disk ops (`deriveProvidedInvariants`) — that derivation only
60-
// counts data-class ops. The test extension's baseline op is
61-
// additive, so its declared invariants live in memory only and do
62-
// not survive a disk round-trip. We drop the pinned invariants here
63-
// because the schema verifier doesn't consult them.
59+
// The on-disk head ref's `invariants` and the migration package's
60+
// `providedInvariants` must both round-trip through
61+
// `deriveProvidedInvariants` (M2.5b loader integrity gate, error
62+
// PN-MIG-5002). The test extension's baseline op carries an
63+
// `invariantId`, so the derivation produces `[TEST_BASELINE_INVARIANT_ID]`
64+
// — match that on disk for both the head ref and migration metadata.
6465
await emitContractSpaceArtefacts(migrationsDir, EXT_SPACE_ID, {
6566
contract: extContractJson,
6667
contractDts: '// placeholder for test\nexport {};\n',
67-
headRef: { hash: extHeadRef.hash, invariants: [] },
68+
headRef: { hash: extHeadRef.hash, invariants: [...extHeadRef.invariants] },
6869
});
6970

7071
const spaceDir = join(migrationsDir, EXT_SPACE_ID);
7172
for (const pkg of extMigrations) {
7273
const ops = [...pkg.ops];
73-
const baseMeta = { ...pkg.metadata, providedInvariants: [] };
74-
const migrationHash = computeMigrationHash(baseMeta, ops);
74+
// Recompute the hash because the synthetic placeholder hash on the
75+
// in-memory fixture's metadata won't satisfy the loader's hash gate.
76+
const migrationHash = computeMigrationHash(pkg.metadata, ops);
7577
await materialiseMigrationPackage(spaceDir, {
7678
dirName: pkg.dirName,
77-
metadata: { ...baseMeta, migrationHash },
79+
metadata: { ...pkg.metadata, migrationHash },
7880
ops,
7981
});
8082
}
@@ -83,7 +85,7 @@ async function writePinnedExtensionDir(testDir: string): Promise<string> {
8385
}
8486

8587
withTempDir(({ createTempDir }) => {
86-
describe('db verify command - aggregate schema verification', () => {
88+
describe('db verify command - aggregate schema verification (F23)', () => {
8789
let consoleOutput: string[] = [];
8890
let cleanupMocks: () => void;
8991

0 commit comments

Comments
 (0)