Skip to content

Commit 8925d5b

Browse files
fix(metadata-protocol): a seed resolves a lookup another package adds through objectExtensions to the target's id (#36272)
Fixes #35254 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:应用作者在模块里给别的包的对象加的关联字段,演示数据现在能正确连上目标记录;以前在本地开发和正式部署启动时,这类字段里存的是目标的名称文字,记录页上显示“受限记录”。 - 为什么做:模块扩展对象是垂直模块的标准做法,两个下游应用的演示数据因此连错,其中一个连带算错了客户评级和订单利润判断。 - 出错会怎样:只影响种子数据读取对象定义的方式;万一有问题,表现为某个演示数据的关联没连上或启动日志报出无法解析的引用,撤回本次改动即恢复原样。以前已存成文字的记录不会被自动改写,重新跑一次种子数据即可修正。 - 要你做什么:无 ## What changes `SeedLoaderService.resolveObjectDefinition` (`packages/metadata-protocol/src/seed-loader.ts`) is the one place the seed loader reads an object definition. Every per-field decision of a load goes through it: the reference graph, natural-key resolution, required-on-insert, the tenant column, the roll-up strip, the replay comparands and the undeclared-column warning. - **Before:** it took the metadata service's copy whenever that copy had `fields`, and fell back to the engine's schema only when the metadata service had none. A boot that loads a compiled artifact (`os dev`, `os serve`, the cloud runtime) gives the metadata service each object as its own package wrote it. The fields another package adds through `objectExtensions` (ADR-0130 D5) live only in the ObjectQL registry's fold. So a lookup that an extension adds was never a reference. It had no graph edge, and its natural key was written verbatim into the foreign-key column. - **After:** it reads the engine's registered schema first. That is the object as served, with extensions folded in. It falls back to the metadata service's copy only when the engine has no schema for the name, or exposes no schema registry (`IDataEngine` does not require one). The loader merges no extension itself: the registry's fold is the one source. The marketplace case the old fallback existed for (an object only the engine registry knows) is still served: it is now found on the first read. - The #35655 roll-up strip (PR #36118) used to take the union of the resolved definition and `engineSchemaOf`. The resolved definition now IS the engine's schema whenever the engine has one, so the union collapses to `summaryFieldNames(objectDefinition)`. Its pins are unchanged and green. - Docblocks that named the old order are corrected: `resolveObjectDefinition`, `seedReferenceGraphFields`, `declaresNameColumn`, and the #35655 extension pin's header in `seed-loader-summary-stale.test.ts`. - `.changeset/35254-seed-extension-lookup.md`: `@objectstack/metadata-protocol` patch. The in-process boot (`@objectstack/verify` without an artifact) bridges the metadata service from the folded registry, so the metadata copy and the engine copy already agreed there. This change makes the artifact boot read what that boot already read. ## Tests New pins in `packages/metadata-protocol/src/seed-loader-engine-schema-fallback.test.ts`, as a top-level `describe('[#35254] …')` on that file's engine double, which is already pinned. The metadata double serves the authored `ext_order` without `quote_ref`. The engine double's `getSchema` serves the folded object with `quote_ref → ext_quote`. Every case has a CONTROL: `account_ref`, a lookup the owner authored on the same object. - `upsert` and `ignore` (the inserting modes; `insert` itself is a retired `SeedMode`): `quote_ref` stores the quote's id. `insertOrder` puts `ext_quote` (and `ext_account`) before `ext_order`. The `ext_order` node's `dependsOn` is `[ext_account, ext_quote]`, and its references include `quote_ref->ext_quote` beside `account_ref->ext_account`. - `update`: the existing order row gets the quote's id and the account's id, and no second order is inserted. - A cycle (`ext_quote.order_ref` back to the order): the cycle is detected, one side waits for pass 2, and both links resolve. The pass-2 writes and the `insertOrder` are identical to the CONTROL, where `quote_ref` is authored. - An unknown natural key: both the extension lookup and the authored lookup are refused the same way (one errored record, the same error with the field and target names normalised, no raw key stored), and the extension's error names `ext_order.quote_ref`. - `falls back to the metadata service definition when the engine has no schema for the object` (renamed from `prefers the metadata service definition …`): the engine is asked first for every seeded object, and the metadata service is read for each. <details> <summary>Premise on the real boot path: os dev on a two-package artifact</summary> A fixture of the card's shape, not committed: app package `qx_app` owns `qx_account` and `qx_order` (with the authored `account_ref`). Module `qx_mod` (built with `artifactObjects`) owns `qx_quote`, adds `quote_ref` (→ `qx_quote`) to `qx_order`, seeds `O-1` in `update` mode and inserts `O-2` in `upsert` mode, both with `quote_ref` by the quote's name. The `os dev --fresh` boot came from this branch's CLI closure build, and the rows were read with `GET /api/v1/data/qx_order` as the seeded dev admin. | leg | `O-1.quote_ref` (update) | `O-2.quote_ref` (upsert) | `account_ref` (CONTROL) | |:--|:--|:--|:--| | origin/main resolver put back (blob 2713d6f4cb) | `"Acme Annual Renewal Quote"` | `"Acme Annual Renewal Quote"` | the account's id | | this branch (blob fdbca4a) | the quote's id | the quote's id | the account's id | `[SeedLoader] Dependency graph built` read `insertOrder: [qx_account, qx_quote, qx_order]` on both legs. That reading does not tell the legs apart on this fixture; the unit pins assert the edge itself. </details> <details> <summary>Ablation of the resolver order</summary> The fix was committed first. `node scripts/ablation-replace.mjs --hold` replaced the three-line engine-first body with `origin/main`'s metadata-first body: anchor x1 → x0, replacement x0 → x1, blob fdbca4a → 2713d6f4cbe4. Then `pnpm --filter @objectstack/metadata-protocol build` ran, and `ablation-dist-preflight.mjs @objectstack/metadata-protocol 'fromMetadata?.fields'` read the marker present in `dist/`. - Unit pins (source import): `Tests 7 failed | 15 passed (22)`. All five #35254 pins were red (for example `expected 'Q-ACME' to be 'gen-1'`). So were the renamed fallback pin (`expected [] to deeply equal [ 'crm_account', … ]`, metadata read first) and the #35655 extension roll-up pin (`expected [ 'name', 'total', 'ext_refunds' ] to not include 'ext_refunds'`, because the union is gone). The throwing-schema CONTROL stayed green. - `os dev` on that build: the raw names in the table above. - Restore: `git checkout HEAD -- ABS_PATH` in a trap. Blob after restore fdbca4a equals the HEAD blob, `git diff HEAD` is empty, and `git status --porcelain -- packages/` is empty. After a rebuild, the `--absent` dist reading passed. The tree reading reported only the uncommitted `os dev` fixture (since deleted). Green again: `Tests 22 passed (22)`, and `os dev` stored the ids. The pins were later moved from a new file into `seed-loader-engine-schema-fallback.test.ts` unchanged (see Acceptance notes). `seed-loader.ts` did not change after the ablation. </details> <details> <summary>Suite and gate readings</summary> - `pnpm --filter @objectstack/metadata-protocol test` at e3d3340: `Test Files 363 passed | 9 skipped (372)`, `Tests 23325 passed | 45 skipped (23370)`. `typecheck`: VERDICT command-exit 0. At the head (dd69776, a test-file move only), the two edited test files read `Tests 22 passed (22)` and `typecheck` exits 0. - `dispatch-gates.mjs --commands` derived 67 families, and the list is identical at the head. All 67 ran locally, with each exit captured before any pipe: - 65 exited 0. - `check:engine-double-contract` exited 1 at e3d3340 (RETAINED: the new file's pinned double was not in the pinned ledger). The pins moved onto the file's already-pinned double, and the gate exits 0 at dd69776. - `check:dual-build-cjs-loads` exited 3 (PREREQUISITE NOT MET: no local `dist/` for packages outside this diff). NOT MEASURED locally; CI runs it. - `--ran` reconciliation: "67 derived, 67 run, 0 NOT-MEASURED, 0 UNRUN", exit 0. - `overlap-check` at dd69776: VERDICT clean, exit 0. </details> ## Acceptance notes - **The pins live in an existing file.** The dispatch asked for a new file named after the card, unless `check:engine-double-contract` refused a new engine double. The gate asked for its pinned ledger to be regenerated (`--write`), and that ledger write was refused in this session. So the pins were folded into `seed-loader-engine-schema-fallback.test.ts`, whose engine double is already pinned and is the same double the new file had copied. - **The test harness boot does not reproduce the defect.** It was measured: a dogfood test booting `bootStack` from `@objectstack/verify` with `MetadataPlugin({ artifactSource })` over the same two-package artifact read the extension field absent from `metadata.getObject('qa_ext_order')` and present in `getSchema`. Yet it stored the quote's id on BOTH legs of the ablation, so it could not pin this defect, and it is not committed. Only the real `os dev` boot showed the raw key. Why the harness's seed load sees a different definition was not established. This is reported as a finding, not fixed here. Carried by #36274. - Rows an earlier load stored with the raw key are not rewritten. Re-running the seed in `update` or `upsert` mode replaces the key with the id (the replay compare sees a difference). The changeset says so. - The basic-insert fallback seeder in `packages/runtime/src/app-plugin.ts` (no metadata service, or the loader threw) does not go through this resolver, as #36118's notes already record. ## Verification Two-minute check: `pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2 src/seed-loader-engine-schema-fallback.test.ts`. Expect `Tests 8 passed`, including five `[#35254]` cases. Read first, by risk: 1. `packages/metadata-protocol/src/seed-loader.ts`, the `resolveObjectDefinition` hunk: the order flip that every per-field read inherits. 2. The same file, the `summaryFields` hunk in `loadDataset`: #36118's union collapsed onto the single source. 3. `packages/metadata-protocol/src/seed-loader-engine-schema-fallback.test.ts`: the probe assertion of the renamed fallback pin, and the new `[#35254]` block. --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5miLqNucRZevceHwNh)_ <!-- signed: repo:objectstack#4 · os-project-manager · session_01FEkQ5miLqNucRZevceHwNh --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4ab1218 commit 8925d5b

4 files changed

Lines changed: 274 additions & 48 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
---
4+
5+
fix(metadata-protocol): a seed resolves a lookup that another package adds through `objectExtensions` to the target's id
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
A package can add a lookup to another package's object through `objectExtensions`. A seed that set that lookup by the target's natural key (`externalId`) used to store the raw key in the foreign-key column on a boot that loads a compiled artifact (`os dev`, `os serve`, the cloud runtime). The record then linked to nothing, and the console showed "Restricted record". The same seed resolved correctly under the in-process test harness.
11+
12+
The cause was the seed loader's object read. It took the metadata service's copy of the object, which on an artifact boot is the object as its own package wrote it, without the fields an extension adds. Now the loader reads the object as the engine serves it, with its extensions included. It falls back to the metadata service's copy only when the engine has no schema for the object. So a lookup an extension adds is treated exactly like one the owner wrote, in every mode (`upsert`, `ignore`, `update`):
13+
14+
- it adds a dependency, so the target dataset loads first;
15+
- its natural key is resolved to the target's id;
16+
- it waits for the second pass when the target loads later in the same load;
17+
- an unknown key is refused with the same error.
18+
19+
The same read now drives the loader's other per-field decisions for such a field: the required-on-insert check, the tenant column, the replay compare and the undeclared-column warning.
20+
21+
Rows an earlier load stored with the raw key are not rewritten. Run the seed again (in `update` or `upsert` mode) to store the target's id in place of the key.

‎packages/metadata-protocol/src/seed-loader-engine-schema-fallback.test.ts‎

Lines changed: 203 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ describe('seed reference graph — engine schema fallback (marketplace objects)'
207207
expect(result.summary.totalReferencesResolved).toBeGreaterThanOrEqual(4);
208208
});
209209

210-
it('prefers the metadata service definition when it exists (the engine is probed only for roll-ups)', async () => {
210+
it('falls back to the metadata service definition when the engine has no schema for the object', async () => {
211211
const { engine, store } = createFaithfulEngine({});
212212
const metadata = createEmptyMetadata();
213213
(metadata.getObject as any).mockImplementation(async (name: string) => ENGINE_SCHEMAS[name]);
@@ -222,16 +222,16 @@ describe('seed reference graph — engine schema fallback (marketplace objects)'
222222
expect(store.crm_contact.find((r) => r.email === 'john.smith@acme.example.com')!.crm_account).toBe(acmeId);
223223
// The engine here registers no schema at all (`createFaithfulEngine({})`),
224224
// so the references above resolved from the metadata service's definition.
225-
// The engine is still asked once per seeded object, for the roll-up strip
226-
// alone (#35655): the metadata copy carries no object extension, so the
227-
// strip also reads the engine's merged schema. (The other engine question
228-
// is the ADR-0131 D9 registration read for `sys_organization`, which this
225+
// [#35254] The engine is asked FIRST for every seeded object: its schema
226+
// is the object as served, object extensions folded in, and the metadata
227+
// copy is read only when it has none. (The other engine question is the
228+
// ADR-0131 D9 registration read for `sys_organization`, which this
229229
// metadata double does not know: does the composition register an
230230
// organization object at all? It answers from the same resolver.)
231-
const probed = (engine as any).getSchema.mock.calls.map((c: unknown[]) => c[0]);
232-
expect(probed.filter((name: string) => name !== 'sys_organization').sort()).toEqual(
233-
['crm_account', 'crm_contact', 'crm_opportunity'],
234-
);
231+
const probed = new Set<string>((engine as any).getSchema.mock.calls.map((c: unknown[]) => c[0] as string));
232+
probed.delete('sys_organization');
233+
expect([...probed].sort()).toEqual(['crm_account', 'crm_contact', 'crm_opportunity']);
234+
for (const name of probed) expect(metadata.getObject).toHaveBeenCalledWith(name);
235235
});
236236

237237
it('survives an engine without getSchema (contract-minimal engines keep the old behavior)', async () => {
@@ -250,3 +250,197 @@ describe('seed reference graph — engine schema fallback (marketplace objects)'
250250
expect(store.crm_contact.every((r) => r.crm_account === 'Acme Corporation')).toBe(true);
251251
});
252252
});
253+
254+
/**
255+
* [#35254] A lookup that one package adds to another package's object through
256+
* `objectExtensions` (ADR-0130 D5) resolves in a seed exactly like a lookup
257+
* the owner authored: it joins the dependency graph, its natural key becomes
258+
* the target's id, it is deferred to pass 2 when the target loads later, and
259+
* an unknown key is refused the same way.
260+
*
261+
* The shape these pins reproduce is the boot that ingests a compiled artifact
262+
* (`os dev`, `os serve`, the cloud runtime). There the metadata service holds
263+
* each object AS ITS PACKAGE AUTHORED IT, and the extension's fields exist only
264+
* in the engine registry's fold. The loader used to prefer the metadata copy
265+
* whenever it had `fields`, so the extension lookup was no reference at all:
266+
* no `ext_order → ext_quote` edge, and the quote's name written verbatim into
267+
* the foreign-key column. Measured with the resolver of `origin/main`
268+
* a5a5312ff4 put back: this harness stores `quote_ref = 'Q-ACME'`, and a real
269+
* `os dev` boot of a two-package artifact of this shape stores the quote's
270+
* name in both an `update` and an `upsert` row.
271+
*
272+
* The metadata double serves the authored `ext_order` (no `quote_ref`); the
273+
* engine double's `getSchema` serves the folded one (with it), as the ObjectQL
274+
* registry does after `registerApp` applies the extension. Every case keeps a
275+
* CONTROL beside it: the same seed through `account_ref`, a lookup the owner
276+
* authored on the same object. The engine double is this file's own
277+
* (`createFaithfulEngine`), already pinned to the engine's dispatch contract.
278+
*/
279+
280+
/** The owner package's objects, as it authored them — what the metadata service holds on an artifact boot. */
281+
function authoredObjects(quoteBacklink: boolean): Record<string, any> {
282+
return {
283+
ext_account: { name: 'ext_account', fields: { name: { type: 'text', required: true } } },
284+
ext_order: {
285+
name: 'ext_order',
286+
fields: {
287+
name: { type: 'text', required: true },
288+
account_ref: { type: 'lookup', reference: 'ext_account' },
289+
},
290+
},
291+
ext_quote: {
292+
name: 'ext_quote',
293+
fields: {
294+
name: { type: 'text', required: true },
295+
...(quoteBacklink ? { order_ref: { type: 'lookup', reference: 'ext_order' } } : {}),
296+
},
297+
},
298+
};
299+
}
300+
301+
/** The same objects as the engine's registry serves them: `ext_order` with the extension's lookup folded in. */
302+
function servedObjects(quoteBacklink: boolean): Record<string, any> {
303+
const authored = authoredObjects(quoteBacklink);
304+
return {
305+
...authored,
306+
ext_order: {
307+
...authored.ext_order,
308+
fields: { ...authored.ext_order.fields, quote_ref: { type: 'lookup', reference: 'ext_quote' } },
309+
},
310+
};
311+
}
312+
313+
function createMetadataServing(objects: Record<string, any>): IMetadataService {
314+
return {
315+
getObject: vi.fn(async (name: string) => objects[name]),
316+
listObjects: vi.fn(async () => Object.values(objects)),
317+
register: vi.fn(async () => {}),
318+
get: vi.fn(async (_t: string, name: string) => objects[name]),
319+
list: vi.fn(async () => []),
320+
unregister: vi.fn(async () => {}),
321+
exists: vi.fn(async () => false),
322+
listNames: vi.fn(async () => []),
323+
} as unknown as IMetadataService;
324+
}
325+
326+
const EXT_ENV = ['prod', 'dev', 'test'];
327+
328+
function loaderFor(quoteBacklink = false) {
329+
const { engine, store } = createFaithfulEngine(servedObjects(quoteBacklink));
330+
const logger = createLogger();
331+
const loader = new SeedLoaderService(engine, createMetadataServing(authoredObjects(quoteBacklink)), logger);
332+
return { loader, store, logger, engine };
333+
}
334+
335+
/** The order dataset first, then the targets — the order a later package's seeds arrive in. */
336+
function seeds(mode: string, order: Record<string, unknown>) {
337+
return [
338+
{ object: 'ext_order', externalId: 'name', mode, env: EXT_ENV, records: [{ name: 'O-1', ...order }] },
339+
{ object: 'ext_quote', externalId: 'name', mode: 'upsert', env: EXT_ENV, records: [{ name: 'Q-ACME' }] },
340+
{ object: 'ext_account', externalId: 'name', mode: 'upsert', env: EXT_ENV, records: [{ name: 'Acme' }] },
341+
] as any[];
342+
}
343+
344+
describe('[#35254] a seed resolves a lookup an object extension adds like an authored one', () => {
345+
for (const mode of ['upsert', 'ignore'] as const) {
346+
it(`${mode} (inserting): the extension lookup stores the quote's id, and the graph loads the quote first`, async () => {
347+
const { loader, store } = loaderFor();
348+
const result = await loader.load({ seeds: seeds(mode, { quote_ref: 'Q-ACME', account_ref: 'Acme' }), config: CONFIG });
349+
350+
expect(result.success).toBe(true);
351+
expect(result.summary.totalErrored).toBe(0);
352+
const quoteId = store.ext_quote.find((r) => r.name === 'Q-ACME')!.id;
353+
const accountId = store.ext_account.find((r) => r.name === 'Acme')!.id;
354+
expect(store.ext_order).toHaveLength(1);
355+
expect(store.ext_order[0].quote_ref).toBe(quoteId);
356+
// CONTROL: the authored lookup on the same row.
357+
expect(store.ext_order[0].account_ref).toBe(accountId);
358+
359+
const order = result.dependencyGraph.insertOrder;
360+
expect(order.indexOf('ext_quote')).toBeLessThan(order.indexOf('ext_order'));
361+
expect(order.indexOf('ext_account')).toBeLessThan(order.indexOf('ext_order'));
362+
const node = result.dependencyGraph.nodes.find((n) => n.object === 'ext_order')!;
363+
expect([...node.dependsOn].sort()).toEqual(['ext_account', 'ext_quote']);
364+
// (The injected `owner_id` → `sys_user` reference rides along on both; it is not this pin's subject.)
365+
expect(node.references.filter((r) => r.targetObject.startsWith('ext_')).map((r) => `${r.field}->${r.targetObject}`).sort())
366+
.toEqual(['account_ref->ext_account', 'quote_ref->ext_quote']);
367+
});
368+
}
369+
370+
it('update: the existing order gets the quote\'s id and no second order is inserted', async () => {
371+
const { loader, store } = loaderFor();
372+
store.ext_order = [{ id: 'ord-existing', name: 'O-1' }];
373+
374+
const result = await loader.load({ seeds: seeds('update', { quote_ref: 'Q-ACME', account_ref: 'Acme' }), config: CONFIG });
375+
376+
expect(result.success).toBe(true);
377+
expect(result.summary.totalErrored).toBe(0);
378+
const quoteId = store.ext_quote.find((r) => r.name === 'Q-ACME')!.id;
379+
const accountId = store.ext_account.find((r) => r.name === 'Acme')!.id;
380+
expect(store.ext_order).toEqual([
381+
expect.objectContaining({ id: 'ord-existing', name: 'O-1', quote_ref: quoteId, account_ref: accountId }),
382+
]);
383+
});
384+
385+
it('a target that loads after the order (a cycle) is deferred to pass 2 and resolved, as an authored lookup is', async () => {
386+
// `ext_quote.order_ref` points back at the order, so the graph has a cycle
387+
// only once the extension lookup is read: one side loads first, its
388+
// reference waits for pass 2, and pass 2 writes it back. CONTROL: the same
389+
// cycle with `quote_ref` authored on the order itself.
390+
const run = async (authoredQuoteRef: boolean) => {
391+
const { engine, store } = createFaithfulEngine(servedObjects(true));
392+
const authored = authoredObjects(true);
393+
if (authoredQuoteRef) authored.ext_order = servedObjects(true).ext_order;
394+
const loader = new SeedLoaderService(engine, createMetadataServing(authored), createLogger());
395+
const result = await loader.load({
396+
seeds: [
397+
{ object: 'ext_order', externalId: 'name', mode: 'upsert', env: EXT_ENV, records: [{ name: 'O-1', quote_ref: 'Q-ACME' }] },
398+
{ object: 'ext_quote', externalId: 'name', mode: 'upsert', env: EXT_ENV, records: [{ name: 'Q-ACME', order_ref: 'O-1' }] },
399+
] as any[],
400+
config: CONFIG,
401+
});
402+
const order = store.ext_order.find((r) => r.name === 'O-1')!;
403+
const quote = store.ext_quote.find((r) => r.name === 'Q-ACME')!;
404+
const backfills = (engine.update as any).mock.calls.map(([object, data]: [string, any]) =>
405+
[object, Object.keys(data).filter((k) => k !== 'id').sort()]);
406+
return { result, order, quote, backfills };
407+
};
408+
const extension = await run(false);
409+
const control = await run(true);
410+
411+
for (const { result, order, quote } of [extension, control]) {
412+
expect(result.summary.totalErrored).toBe(0);
413+
expect(result.dependencyGraph.circularDependencies.length).toBeGreaterThan(0);
414+
expect(order.quote_ref).toBe(quote.id);
415+
expect(quote.order_ref).toBe(order.id);
416+
}
417+
// One side was written in pass 2, and the extension lookup took the same path the authored one does.
418+
expect(extension.backfills.length).toBeGreaterThan(0);
419+
expect(extension.backfills).toEqual(control.backfills);
420+
expect(extension.result.dependencyGraph.insertOrder).toEqual(control.result.dependencyGraph.insertOrder);
421+
});
422+
423+
it('an unknown natural key is refused exactly as the authored lookup refuses it, and no raw key is stored', async () => {
424+
const run = async (field: 'quote_ref' | 'account_ref') => {
425+
const { loader, store } = loaderFor();
426+
const result = await loader.load({ seeds: seeds('upsert', { [field]: 'Ghost' }), config: CONFIG });
427+
return { result, store };
428+
};
429+
const extension = await run('quote_ref');
430+
const authored = await run('account_ref');
431+
432+
for (const { result, store } of [extension, authored]) {
433+
expect(result.success).toBe(false);
434+
expect(result.summary.totalErrored).toBe(1);
435+
expect((store.ext_order ?? []).some((r) => r.quote_ref === 'Ghost' || r.account_ref === 'Ghost')).toBe(false);
436+
}
437+
const shape = (r: typeof extension.result, field: string, target: string) =>
438+
r.errors.map((e: any) => ({
439+
message: String(e.message).split(field).join('FIELD').split(target).join('TARGET'),
440+
recordIndex: e.recordIndex,
441+
attemptedValue: e.attemptedValue,
442+
}));
443+
expect(shape(extension.result, 'quote_ref', 'ext_quote')).toEqual(shape(authored.result, 'account_ref', 'ext_account'));
444+
expect(extension.result.errors.map((e: any) => e.message).join('\n')).toContain('ext_order.quote_ref');
445+
});
446+
});

‎packages/metadata-protocol/src/seed-loader-summary-stale.test.ts‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -455,13 +455,12 @@ describe('a seed never hands the engine a roll-up value (#35655)', () => {
455455

456456
/**
457457
* [#35655] A roll-up an object EXTENSION contributes is never seeded either.
458-
* The loader resolves a definition from the metadata service first and uses
459-
* that copy whenever it has `fields`; the metadata service stores the object
460-
* as registered, with no extension merged in, so its copy can lack a roll-up
461-
* the engine's merged schema declares and computes. The strip therefore reads
462-
* both the resolved definition and the engine's own schema. These pins hand
463-
* the loader a metadata copy WITHOUT the extension's roll-up and an engine
464-
* schema WITH it.
458+
* The metadata service can store the object as registered, with no extension
459+
* merged in, so its copy can lack a roll-up the engine's merged schema
460+
* declares and computes. The strip reads the resolved definition, which is
461+
* the engine's merged schema whenever the engine has one ([#35254]
462+
* `resolveObjectDefinition`). These pins hand the loader a metadata copy
463+
* WITHOUT the extension's roll-up and an engine schema WITH it.
465464
*/
466465
describe('a roll-up an object extension contributes is never seeded either (#35655)', () => {
467466
const METADATA_COPY = {

0 commit comments

Comments
 (0)