Skip to content

Commit e01df46

Browse files
committed
test(objectql): pin the flow family's baseline spelling on the booted showcase and the bundled holder reading
- `OVERRIDABLE_BASELINE_PACKAGES` is exported from `@objectstack/objectql`, so the dogfood pin can hold its spelling of the email service's package equal to the package the email plugin registers the built-in templates under on this boot (read back from the registry: the two spellings are pinned together across the package boundary without either package importing the other). - Two unit cells read an email template's holder from its member key alone: a package registering a bundle member through the registry directly (no install claim) holds the name, and the cold boot reads such a clash from the member keys as one conflict on the name. Claude-Session: https://claude.ai/code/session_017xRBcTJTE7kSbcMoJQ4Txf Co-authored-by: Claude <noreply@anthropic.com>
1 parent 664f51c commit e01df46

3 files changed

Lines changed: 59 additions & 6 deletions

File tree

‎packages/objectql/src/index.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ export {
9696
// stay private to the engine.
9797
export { findPackageHeldSecurityCatalogNames } from './registry.js';
9898

99+
// [#30803] The bare-name rule's overridable baseline (ADR-0048 P1.8): per
100+
// covered type, the packages whose items any other package's same-named item
101+
// is served over by contract — today the email service's built-in templates.
102+
// Exported so the booted dogfood pin can hold this vocabulary's spelling of
103+
// that package equal to the email plugin's own `BUILTIN_EMAIL_TEMPLATES_PACKAGE_ID`
104+
// across the package boundary; the rule's other vocabulary stays private to
105+
// the engine.
106+
export { OVERRIDABLE_BASELINE_PACKAGES } from './bare-name-one-holder.js';
107+
99108
// [#15204 W2] Every `(type, name)` a manifest declares, read from the sources
100109
// the engine's registration seams read. Exported for the install-local door
101110
// (`@objectstack/cloud-connection`), which refuses a catalog-carrying package

‎packages/objectql/src/registry-bare-name-one-holder-flow-family.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,34 @@ describe('email_template — the name holds the bundle, and the built-in templat
344344
);
345345
});
346346

347+
it('a holder is read from its member key alone (no claim): a package registering a bundle member through the registry directly holds the name', async () => {
348+
const registry = new SchemaRegistry();
349+
registry.logLevel = 'silent';
350+
registry.sealBareNameHolders();
351+
// After the seal, alpha's first registration finds no holder and stores `com.acme.alpha:shared_tpl@zh-CN`.
352+
expect(await caught(() => registry.registerItem('email_template', member('alpha', 'shared_tpl', 'zh-CN'), 'name', 'com.acme.alpha'))).toBeUndefined();
353+
expect(registry.getPackage('com.acme.alpha'), 'no package record, so no claim: the slot is the only record').toBeUndefined();
354+
expectRefusal(
355+
await caught(() => registry.registerItem('email_template', member('direct', 'shared_tpl', 'en-US'), 'name', 'com.acme.direct')),
356+
'com.acme.direct', { kind: 'package', packageId: 'com.acme.alpha' },
357+
);
358+
// CONTROL — the same package's second member is its own bundle, not a second holder.
359+
expect(await caught(() => registry.registerItem('email_template', member('alpha', 'shared_tpl', 'en-US'), 'name', 'com.acme.alpha'))).toBeUndefined();
360+
});
361+
362+
it('the cold boot reads a bundled clash from the member keys: two packages\' members of one name, registered directly, are one conflict on the name', () => {
363+
const registry = new SchemaRegistry();
364+
registry.logLevel = 'silent';
365+
registry.registerItem('email_template', member('alpha', 'shared_tpl', 'en-US'), 'name', 'com.acme.alpha');
366+
registry.registerItem('email_template', member('alpha', 'shared_tpl', 'zh-CN'), 'name', 'com.acme.alpha');
367+
registry.registerItem('email_template', member('beta', 'shared_tpl', 'fr-FR'), 'name', 'com.acme.beta');
368+
registry.registerItem('flow', body('flow', 'own_flow', 'alpha'), 'name', 'com.acme.alpha');
369+
const conflicts = registry.sealBareNameHolders();
370+
expect(conflicts.map((c) => `${c.type}/${c.name}: ${c.incomingPackageId} vs ${(c.existingHolder as Holder).packageId}`)).toEqual([
371+
'email_template/shared_tpl: com.acme.beta vs com.acme.alpha',
372+
]);
373+
});
374+
347375
it('the vocabulary names the email service\'s package as the one baseline, for email templates only', () => {
348376
expect([...OVERRIDABLE_BASELINE_PACKAGES.email_template]).toEqual([EMAIL_SERVICE_PKG]);
349377
for (const type of BARE_NAME_ONE_HOLDER_TYPES) {

‎packages/qa/dogfood/test/bare-name-one-holder-flow-family.dogfood.test.ts‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
// - CONTROL: a package declaring fresh names installs — and so does one
2626
// overriding the platform's built-in `auth.password_reset` template, whose
2727
// holder package is the overridable baseline: the send then renders the
28-
// app's template, and the vocabulary's spelling of that package is the
29-
// email plugin's own.
28+
// app's template, and the vocabulary spells that package exactly as the
29+
// email plugin registers the built-in templates on this boot (read back
30+
// from the registry, so the two spellings are pinned together across the
31+
// package boundary without either package importing the other).
3032

3133
import { mkdtempSync, rmSync } from 'node:fs';
3234
import { tmpdir } from 'node:os';
@@ -36,7 +38,6 @@ import { type VerifyStack } from '@objectstack/verify';
3638
import { AppPlugin } from '@objectstack/runtime';
3739
import { MarketplaceInstallLocalPlugin } from '@objectstack/cloud-connection';
3840
import { OVERRIDABLE_BASELINE_PACKAGES } from '@objectstack/objectql';
39-
import { BUILTIN_EMAIL_TEMPLATES_PACKAGE_ID } from '@objectstack/plugin-email';
4041
import { defineStack } from '@objectstack/spec';
4142
import { PROTOCOL_MAJOR } from '@objectstack/spec/kernel';
4243
import { bootShowcase } from './showcase-boot.js';
@@ -149,6 +150,14 @@ describe('one package holder per flow, webhook, connector and email template nam
149150
return (await declared.declaredWebhookNamed(name))?.packageId;
150151
};
151152

153+
/** The package the email plugin registered the built-in `auth.password_reset` bundle under, read from the registry. */
154+
const builtInTemplatePackage = (): string | undefined => {
155+
const ql = (stack.kernel as any).getService('objectql');
156+
const row = (ql.registry.listItems('email_template') as Array<{ name?: string; _packageId?: string }>)
157+
.find((i) => i?.name === BUILT_IN_TPL && i._packageId !== 'com.qa.bare.epsilon');
158+
return row?._packageId;
159+
};
160+
152161
beforeAll(async () => {
153162
storageDir = mkdtempSync(join(tmpdir(), 'dogfood-bare-name-flow-'));
154163
const booted = await captureOutput(() => bootShowcase({
@@ -180,9 +189,13 @@ describe('one package holder per flow, webhook, connector and email template nam
180189
for (const name of [FLOW, HOOK, CONN, TPL]) expect(line, `the rename of ${name}`).toContain(`"beta_${name}"`);
181190
expect(line).toContain('package "com.qa.bare.alpha"');
182191
expect(line).toContain('package "com.qa.bare.beta"');
183-
// The platform's built-in templates beside the showcase's are no clash: the baseline holds nothing.
192+
// The platform's built-in templates are the overridable baseline, and the vocabulary spells
193+
// their package exactly as the email plugin registered them on this boot.
194+
const baseline = builtInTemplatePackage();
195+
expect(baseline, 'the built-in templates are registered under a package').toBeDefined();
196+
expect([...OVERRIDABLE_BASELINE_PACKAGES.email_template]).toEqual([baseline]);
184197
expect(line).not.toContain(BUILT_IN_TPL);
185-
expect(line).not.toContain(BUILTIN_EMAIL_TEMPLATES_PACKAGE_ID);
198+
expect(line).not.toContain(baseline!);
186199
expect(await packageIds(), 'both packages booted').toEqual(expect.arrayContaining(['com.qa.bare.alpha', 'com.qa.bare.beta']));
187200
// Unchanged by the rule: the automation engine's precedence still arms one flow, naming both.
188201
expect(bootLines.some((l) => l.includes(`Flow name collision: '${FLOW}'`) && l.includes('com.qa.bare.alpha') && l.includes('com.qa.bare.beta'))).toBe(true);
@@ -223,7 +236,8 @@ describe('one package holder per flow, webhook, connector and email template nam
223236
});
224237

225238
it('CONTROL — install-local of a package declaring fresh names, and overriding the built-in password-reset template, installs; the send renders the app\'s template', async () => {
226-
expect([...OVERRIDABLE_BASELINE_PACKAGES.email_template], 'the vocabulary spells the email plugin\'s own package id').toEqual([BUILTIN_EMAIL_TEMPLATES_PACKAGE_ID]);
239+
const baseline = builtInTemplatePackage();
240+
expect([...OVERRIDABLE_BASELINE_PACKAGES.email_template], 'the vocabulary spells the package the email plugin registers the built-ins under').toEqual([baseline]);
227241
const { status, body } = await installLocal(inline('epsilon', {
228242
flows: [flow('epsilon', 'epsilon_flow')],
229243
webhooks: [webhook('epsilon', 'epsilon_hook')],
@@ -235,5 +249,7 @@ describe('one package holder per flow, webhook, connector and email template nam
235249
const email = (stack.kernel as any).getService('email');
236250
const rendered = await email.renderTemplate({ template: BUILT_IN_TPL, data: {} });
237251
expect(rendered?.subject).toBe('epsilon subject');
252+
// The built-in bundle is still registered beside the override: overridden, not displaced.
253+
expect(builtInTemplatePackage()).toBe(baseline);
238254
});
239255
});

0 commit comments

Comments
 (0)