Skip to content

Commit c05d912

Browse files
committed
fix(objectql): keep the overridable baseline off the published index; read it by the door's package id
The booted flow-family pin now holds the baseline's spelling by behaviour: it reads the package the email plugin registered the built-in templates under from the registry, and an app overriding a built-in template must install, which it cannot if the engine's vocabulary spells that package any other way. OVERRIDABLE_BASELINE_PACKAGES leaves the objectql index, so the package's published surface does not widen, and the changeset no longer says it is exported. declaredBareNames reads the baseline by artifactPackageId (id, else name), the identity the package door judges, so the door and the seam agree on a manifest with no id. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5pr7Ua2kPRCMZNupZg
1 parent 6bbbb4a commit c05d912

5 files changed

Lines changed: 22 additions & 24 deletions

File tree

‎.changeset/30803-bare-name-flow-family.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Skills-docs: none — `skills/**` does not teach that two packages may share a f
1515
- **Why.** Measured on a booted showcase with two packages sharing one bare name per type, in both registration orders: the automation engine armed ONE flow per name — the lexicographically-first package's, whichever registered first, with a warning — while `/meta/flow/NAME` served the first-registered package's declaration; the webhook dispatcher's declared reader kept the first-registered package's webhook and never subscribed the other; `/meta/connector/NAME` (the connector picker's read) served the first-registered package's descriptor, and two provider-bound instances under one name already refused the boot (ADR-0097); a send's `template: NAME` resolved the first-registered package's email template. Each answer flipped with registration order; only the flow precedence warned, and it armed one of them all the same. A third package installed after the boot under any of those names installed (`200`) and was shadowed.
1616
- **Before.** Two installed packages could each ship a flow, webhook, connector or email template under one name, at boot or by a later install; every caller was served one of them, chosen by registration order.
1717
- **Now.** After the cold boot (the engine plugin seals the registry at `kernel:bootstrapped`, once every package of the boot has registered), a package registration declaring a flow, webhook, connector or email template under a name another installed package holds is refused ahead of every mutation, so it leaves no record behind. The envelope is the first family's: `code: 'NAMESPACE_CONFLICT'`, `status: 422`, `install-local` answering `422 PLUGIN_REGISTER_FAILED`, every conflicting name in one refusal, both holders named, the rename (the incoming package's namespace prefixed) carried, `conflicts[]` structured. An email template's name holds its whole `(name, locale)` bundle: two members of one package's bundle are one holder, and another package's member of that name — another locale included — is refused on the name.
18-
- **The overridable baseline.** The platform's built-in auth templates are declared under the email service's own package (`com.objectstack.service.email`), and an app's same-named template overrides them by contract (ADR-0131 D6). That package is an overridable baseline for `email_template` (`OVERRIDABLE_BASELINE_PACKAGES`, exported): it neither holds a template name nor is refused one, so an app overriding `auth.password_reset` still installs; the first OTHER package to take a built-in name holds it, and a second is refused naming the first.
18+
- **The overridable baseline.** The platform's built-in auth templates are declared under the email service's own package (`com.objectstack.service.email`), and an app's same-named template overrides them by contract (ADR-0131 D6). That package is an overridable baseline for `email_template` (`OVERRIDABLE_BASELINE_PACKAGES`, private to the engine): it neither holds a template name nor is refused one, so an app overriding `auth.password_reset` still installs; the first OTHER package to take a built-in name holds it, and a second is refused naming the first.
1919
- **The cold boot.** A deployment whose installed packages already share such a name still boots: the one warning line names every such name, both holders and the rename, and changes nothing about which holder each caller is served; the flow precedence warning keeps naming both packages and arming one. The maintainer ruled this on 2026-11-06: the boot warns, and only a new holder is refused (`BARE_NAME_COLD_BOOT_MODE` stays `'warn'`).
2020
- **Who moves.** An author whose package declares a flow, webhook, connector or email template under a name another package installed beside it already ships, at the next install or upgrade into a running deployment. **The one-line fix: rename the item in one of the two packages — the refusal names the namespace-prefixed name — or uninstall one of them.** A flow, trigger, picker binding, activation row or send that named the old name must name the new one; nothing rewrites stored references.
2121
- **Unchanged.** The same package registering its own name again. An environment item under a package's name (never judged, never a holder: the ADR-0005 overlay), a paired `.custom` package's declared override of a base flow among them (ADR-0146 D9: a stored row). The email service's built-in templates (above). The automation service's own duplicate refusal of two provider-bound connector instances in one boot (ADR-0097). A job keyed `appId:jobName`, an action bound to an object, every type the rule does not list (ADR-0048 §3.4 as written). `OS_METADATA_COLLISION=warn` does not downgrade the refusal.

‎packages/objectql/src/bare-name-one-holder.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
*/
136136

137137
import type { ObjectStackManifest } from '@objectstack/spec/kernel';
138+
import { artifactPackageId } from '@objectstack/core';
138139
import { isObjectLessActionKey, standaloneActionOwnerKey } from './action-governance.js';
139140

140141
/**
@@ -244,7 +245,8 @@ export const BUILT_IN_BARE_NAMES: Readonly<Record<BareNameOneHolderType, Readonl
244245
* under its own package id (`EmailServicePlugin.init`, `@objectstack/plugin-email`),
245246
* and its template loader picks any other package's `(name, locale)` member
246247
* before the built-in's (`BUILTIN_EMAIL_TEMPLATES_PACKAGE_ID` there — the
247-
* same spelling, pinned together by the flow family's booted dogfood pin).
248+
* same spelling, held together by the flow family's booted dogfood pin: an
249+
* app overriding a built-in template installs only while the two agree).
248250
*/
249251
export const OVERRIDABLE_BASELINE_PACKAGES: Readonly<Record<BareNameOneHolderType, ReadonlySet<string>>> = Object.freeze({
250252
picklist: new Set<string>(),
@@ -331,14 +333,13 @@ function itemName(item: unknown): string | undefined {
331333
* An action bound to an object declares nothing here ({@link holdsBareName});
332334
* a function is never declared by a manifest — it is code, and its door is
333335
* the hook binder's bind. A package that is a type's overridable baseline
334-
* ({@link isOverridableBaseline}, by the manifest's own id) declares nothing
336+
* ({@link isOverridableBaseline}, by its package id as the door reads it) declares nothing
335337
* of that type. A bundled type (`email_template`) declares its NAME: two
336338
* members of one bundle are one declaration, read twice.
337339
*/
338340
export function declaredBareNames(manifest: ObjectStackManifest | unknown): DeclaredBareName[] {
339341
const out: DeclaredBareName[] = [];
340-
const selfId = (manifest as { id?: unknown } | null | undefined)?.id;
341-
const packageId = typeof selfId === 'string' ? selfId : undefined;
342+
const packageId = artifactPackageId(manifest);
342343
const read = (source: unknown) => {
343344
if (!source || typeof source !== 'object') return;
344345
for (const type of BARE_NAME_REGISTRY_TYPES) {

‎packages/objectql/src/index.ts‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,6 @@ 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-
10899
// [#15204 W2] Every `(type, name)` a manifest declares, read from the sources
109100
// the engine's registration seams read. Exported for the install-local door
110101
// (`@objectstack/cloud-connection`), which refuses a catalog-carrying package

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,11 @@ describe('email_template — the name holds the bundle, and the built-in templat
382382
expect(isOverridableBaseline('email_template', 'com.acme.alpha')).toBe(false);
383383
expect(isOverridableBaseline('email_template', undefined)).toBe(false);
384384
expect(declaredBareNames(emailServicePkg([member('sys', 'auth.welcome', 'en-US')]))).toEqual([]);
385+
// The baseline is read by the package id the door judges (`artifactPackageId`: `id`, else `name`).
386+
expect(declaredBareNames({ name: EMAIL_SERVICE_PKG, emailTemplates: [member('sys', 'auth.welcome', 'en-US')] })).toEqual([]);
387+
expect(declaredBareNames({ name: 'com.acme.alpha', emailTemplates: [member('alpha', 'auth.welcome', 'en-US')] })).toEqual([
388+
{ type: 'email_template', name: 'auth.welcome' },
389+
]);
385390
});
386391

387392
it('CONTROL — an app overriding a built-in template after the boot installs: the baseline holds nothing', async () => {

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
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 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).
28+
// app's template. That install is the spelling pin: the package the email
29+
// plugin registers the built-in templates under on this boot is read back
30+
// from the registry, and had the engine's baseline vocabulary spelled it
31+
// any other way, that package would hold the name and the install would be
32+
// refused naming it. The vocabulary stays private to the engine; neither
33+
// package imports the other.
3234

3335
import { mkdtempSync, rmSync } from 'node:fs';
3436
import { tmpdir } from 'node:os';
@@ -37,7 +39,6 @@ import { describe, it, expect, beforeAll, afterAll } from 'vitest';
3739
import { type VerifyStack } from '@objectstack/verify';
3840
import { AppPlugin } from '@objectstack/runtime';
3941
import { MarketplaceInstallLocalPlugin } from '@objectstack/cloud-connection';
40-
import { OVERRIDABLE_BASELINE_PACKAGES } from '@objectstack/objectql';
4142
import { defineStack } from '@objectstack/spec';
4243
import { PROTOCOL_MAJOR } from '@objectstack/spec/kernel';
4344
import { bootShowcase } from './showcase-boot.js';
@@ -189,11 +190,9 @@ describe('one package holder per flow, webhook, connector and email template nam
189190
for (const name of [FLOW, HOOK, CONN, TPL]) expect(line, `the rename of ${name}`).toContain(`"beta_${name}"`);
190191
expect(line).toContain('package "com.qa.bare.alpha"');
191192
expect(line).toContain('package "com.qa.bare.beta"');
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.
193+
// The platform's built-in templates are the overridable baseline: never named by the warning.
194194
const baseline = builtInTemplatePackage();
195195
expect(baseline, 'the built-in templates are registered under a package').toBeDefined();
196-
expect([...OVERRIDABLE_BASELINE_PACKAGES.email_template]).toEqual([baseline]);
197196
expect(line).not.toContain(BUILT_IN_TPL);
198197
expect(line).not.toContain(baseline!);
199198
expect(await packageIds(), 'both packages booted').toEqual(expect.arrayContaining(['com.qa.bare.alpha', 'com.qa.bare.beta']));
@@ -237,14 +236,16 @@ describe('one package holder per flow, webhook, connector and email template nam
237236

238237
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 () => {
239238
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]);
239+
expect(baseline, 'the built-in templates are registered under a package').toBeDefined();
241240
const { status, body } = await installLocal(inline('epsilon', {
242241
flows: [flow('epsilon', 'epsilon_flow')],
243242
webhooks: [webhook('epsilon', 'epsilon_hook')],
244243
connectors: [connector('epsilon', 'epsilon_conn')],
245244
emailTemplates: [template('epsilon', 'epsilon_tpl'), template('epsilon', BUILT_IN_TPL)],
246245
}));
247-
expect(status, JSON.stringify(body)).toBeLessThan(300);
246+
// The spelling pin: a refusal here would name the package the built-ins are registered under
247+
// as a holder of the built-in name — the engine's baseline vocabulary spelling it otherwise.
248+
expect(status, `the package ${baseline} registered the built-ins under is the baseline, not a holder: ${JSON.stringify(body)}`).toBeLessThan(300);
248249
expect(await packageIds()).toContain('com.qa.bare.epsilon');
249250
const email = (stack.kernel as any).getService('email');
250251
const rendered = await email.renderTemplate({ template: BUILT_IN_TPL, data: {} });

0 commit comments

Comments
 (0)