Skip to content

Commit b109659

Browse files
fix(objectql): the bare-name refusal states the namespace rule for a narrowed type (#33902)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbTGhxJSYAmQXU7efVdNqrpw)_ Fixes #33507 Part of #33670 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:包重名被拒(安装时的 `Bare-name conflict` 与启动告警)给出的原因句,对已按命名空间收窄的类型改为说明新规则;另改 hook-binder 一段过时注释。 - 为什么改:原因句仍说「每个部署只能有一个同名项、按注册顺序选一个」,而 main 上 13 个受管类型都已收窄到命名空间,管理员读到的是一条不再成立的规则,不知道该改哪个名字。 - 风险与回滚:只改文案和注释,拒绝的判定、错误码 `NAMESPACE_CONFLICT` 与 422 状态都不变;回滚即撤销本 PR。 - 先看:`packages/objectql/src/bare-name-one-holder.ts` 的 `bareNameReason`;其次 `registry-bare-name-one-holder-ai-family.test.ts` 里模拟未收窄类型的新用例。 - 两分钟验证:`pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/registry-bare-name-one-holder-flow-family.test.ts`,预期全绿,其中 flow 的原因句整句命中新文案。 - 需要你做的:无,席位落地。 ## What changes - **#33507** `bareNameReason` (`packages/objectql/src/bare-name-one-holder.ts`) branches on `isNamespaceScopedBareNameType`. A narrowed type is told its rule: "A flow holds one name per namespace: a package of another namespace may ship the same name, but within one namespace, or beside a package that declares no namespace, a name has one holder, and a bare name two holders share is refused naming both." A type not yet narrowed keeps today's one-name-per-deployment sentence with its consumers' clause; a list carrying both gets one sentence per rule, narrowed first. The doors' refusal and the cold-boot warning (`registry.ts`, untouched) both read this one function. - Measured on origin/main 1e65a38: `NAMESPACE_SCOPED_BARE_NAME_TYPES` holds all 13 covered types (`BARE_NAME_ONE_HOLDER_TYPES`), connector included since PR #33431. So no real type reaches the per-deployment sentence today; the branch is kept per the card's ruling and core's documented path (a type joining the covered list keeps one holder per deployment until its own narrowing lists it). - **#33670 item 1** `packages/objectql/src/hook-binder.ts`: the function-bind comment no longer says the refusal "stays until the trailing backstop child (ADR-0150 D9) narrows it". It says what happens now: the rule is narrowed to the namespace, `claimBareNameFunctions` throws after the seal, the throw is not caught in the binder, and the runtime's `bindAppArtifactHandlers` catches it per owner group and logs at `error`, leaving that group's functions and hooks unbound. Comment only; no bind behaviour changes. Item 2 (`registry.ts` `bareNameColdBootWarning`) stays open on #33670. - Changeset `.changeset/33507-bare-name-reason-namespace.md`, `@objectstack/objectql` patch. ## Tests - Three unit pins that quoted the old sentence moved to the new one (`registry-bare-name-one-holder-{ai,flow,request}-family.test.ts`, describe retitled "states the rule of the types it lists"). - Narrowed type: `bareNameReason(['flow'])` pinned as the whole sentence, plus `bareNameReason()` (every covered type) never says "one name per deployment" or "chosen by registration order". - Unnarrowed type: no covered type is unnarrowed on main, so the pin reads `tool` as not narrowed through `vi.doMock('@objectstack/core')` on a fresh module copy and pins the per-deployment sentence, and the two-sentence order for a mixed list. - No dogfood pin quotes the reason (they match only the `Bare-name conflict` prefix), so none moved. ## Update at 3036245 - Seat review, changeset item: `.changeset/33507-bare-name-reason-namespace.md` gains one sentence. For an email template, the reason also names, after "save the exceptions below", the two holdings that still meet whatever the namespaces: a platform-requested bare name (the `auth.*` mails) keeps one holder per deployment, and a dependent package's addition to its base's template is refused as before. The wording matches `bareNameReason`. No code change. `check-changeset-no-major`, `check-empty-changeset` (and its `--self-test`), `check:changeset-gate-self-tests`, `check:doc-authoring`, `check-adr-0087-registration` and `check:nul-bytes` each exit 0. ## Update at 8284267 Review-a (comment 6895373233) must-fix 1, route (a). The delta changes `packages/objectql/src/bare-name-one-holder.ts` and adds pins to `registry-bare-name-one-holder-flow-family.test.ts`. `registry.ts` is untouched. - Under a narrowed type, two holdings still meet across namespaces. One is a name the platform requests by its bare spelling (`PLATFORM_REQUESTED_BARE_NAMES_BY_TYPE`, as `bareNameHoldersMeet` asks it). The other is a bundle addition (`isBundleAdditionPair`, for a type keyed by an `ITEM_KEY_DISCRIMINATORS` entry). Today both apply to `email_template` only. - A new helper, `crossNamespaceExceptionClauses(type)`, reads the same tables. When a listed narrowed type has either exception, the narrowed sentence says "may ship the same name, save the exceptions below". It is followed by: "For an email template, whatever the namespaces: a name the platform requests by its bare spelling ("auth.password_reset", "auth.verify_email", "auth.magic_link", "auth.invitation", "auth.account_invitation", "auth.two_factor_otp", "auth.email_change_notice" and "auth.existing_account_sign_up") keeps one holder per deployment and a package that depends on the name's holder (which does not depend on it back) and ships the name only in locales the holder does not ship is refused as an addition to the holder's email template." A type with neither exception (the flow, for example) keeps the sentence unchanged. - Pins: the cross-namespace refusal of `auth.password_reset` asserts the qualified claim and the platform-requested clause. The bundle addition's package-door refusal asserts the qualified claim and the addition clause. - Ablations, each through `scripts/ablation-replace.mjs`, each "ok mutation landed", then "ok restored: blob == HEAD (e721889) and `git diff HEAD` is empty": - Platform-requested clause removed: 1 failed, 86 passed; the failure was `expected 'Bare-name conflict: package "com.acme…' to match /For an email template, whatever the n…/`. - Bundle-addition clause removed: 1 failed, 86 passed; the failure was `expected 'Bare-name conflict: package "com.acme…' to contain 'a package that depends on the name\'s…'`. - At 8284267: closure build exit 0; the four bare-name files plus `hook-binder.test.ts` gave Test Files 5 passed and Tests 366 passed; objectql typecheck exit 0; `pnpm lint` exit 0. Derived gates: 67 derived; the 65 run locally all exited 0. `check:type-check-debt` ran under the lock and exited 0. `check:dual-build-cjs-loads` was left to CI. - CI: the "TypeScript Type Check" red at f1706ea (run 43721033546) was the aggregator reading lane `typecheck-workspace` as `cancelled`. That lane logged "The operation was canceled." at 13:59:03Z, 13 s after the push of 8284267 started new runs (13:58:50Z). The cause was the cancel of a superseded run, not this diff. ## Acceptance notes - The card's "pin the sentence for one unnarrowed type" has no real subject on main (every covered type is narrowed); the pin is simulated, see above. - `CONSUMER_CLAUSE` is now read only by the per-deployment branch, so on main it is unreachable from a real type. Kept with the branch. - (Resolved at 8284267, see the update below.) The first version's "another namespace may ship the same name" was false for a platform-requested name and a bundle addition. ## Verification Readings on objectstack-ai/objectstack. Tests and typecheck re-run on the merged head `f1706ea92` (origin/main 45dee17 merged in); the gate sweep ran on `fe90b7362` (same diff before the merge, derivation identical on both), with the ratchet and changeset gates re-run on `f1706ea92`. <details><summary>objectql suite and typecheck</summary> - `pnpm --filter @objectstack/objectql test` (fe90b73): Test Files 596 passed (596), Tests 13138 passed (13138), exit 0. - `pnpm --filter @objectstack/objectql typecheck`: exit 0 on fe90b73 and on f1706ea. - f1706ea, the four bare-name files plus `hook-binder.test.ts`: Test Files 5 passed (5), Tests 366 passed (366). - Direct dependents: no package outside objectql quotes the reason (`git grep` over packages for the old and new phrases). Spot check `@objectstack/cloud-connection` `marketplace-install-local-bare-name-conflict.test.ts`: 11 passed. The other dependents' suites are left to CI's Test Core. </details> <details><summary>Ablation (the narrowed-type pin)</summary> `node scripts/ablation-replace.mjs` on `bare-name-one-holder.ts`, the two filter lines replaced by `narrowed = []` and `perDeployment = listed` (every type gets the old sentence back): "ok mutation landed: anchor 1 -> 0". Three family files: Tests 5 failed, 245 passed. One failure reads `expected 'A flow holds one name per deployment:…' to be 'A flow holds one name per namespace: …'`. Restore: "blob == HEAD (f94389a) and `git diff HEAD` is empty". A first ablation emptied both filters, so the function returned an empty string, not the old sentence. It also went red (5 failed), but it did not test the intended mutation, so it is not counted. </details> <details><summary>Gates</summary> - `dispatch-gates --ran`: 67 derived, 66 run, each with exit code 0, 0 NOT-MEASURED. 1 UNRUN: `pnpm check:dual-build-cjs-loads`, left to CI. - `pnpm lint`: exit 0. `node scripts/check-nul-bytes.mjs`: exit 0. - Re-run on f1706ea, each exit 0: durability-log-level, issue-citations, doc-authoring, test-source-alias, cross-package-test-inputs, type-check-coverage, changeset-no-major, adr-0087-registration, empty-changeset, nul-bytes, registry-log-declared. - Dogfood: no `!` in the title and no `(narrowing)` arm, so the full battery is not run. No dogfood pin quotes the reason. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QsR2jTEivi2wogPpeo3xd5 <!-- signed: domain:server#5 · zhuangjianguo · session_01QsR2jTEivi2wogPpeo3xd5 --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent 61ded62 commit b109659

6 files changed

Lines changed: 163 additions & 32 deletions
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/objectql': patch
3+
---
4+
5+
fix(objectql): the bare-name refusal and cold-boot warning say a narrowed type holds one name per namespace
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The reason a `Bare-name conflict` refusal and the `Bare-name conflict at boot` warning carry (`bareNameReason`) said, for every covered type, that it "holds one name per deployment ... with no package to tell two definitions apart, so with two holders every caller is served the same one, chosen by registration order". Every covered type (picklist, mapping, dataset, API, object-less action, function, flow, webhook, connector, email template, agent, skill, tool) has since narrowed to the namespace (ADR-0150 D2/D9, `NAMESPACE_SCOPED_BARE_NAME_TYPES`), so an administrator refused for one of them was told a rule the doors no longer apply. The reason for a narrowed type now states its rule: a package of another namespace may ship the same name, but within one namespace, or beside a package that declares no namespace, a name has one holder, and a bare name two holders share is refused naming both. For an email template the reason also names the two holdings that still meet whatever the namespaces, after "save the exceptions below": a name the platform requests by its bare spelling (the `auth.*` mails, such as `auth.password_reset`) keeps one holder per deployment, and a package that depends on the name's holder (which does not depend on it back) and ships the name only in locales the holder does not ship is refused as an addition to the holder's email template, as before. A type that joins the covered list before its own narrowing keeps the one-name-per-deployment sentence. No rule changes: the refusals fire where they did, with the same `NAMESPACE_CONFLICT` code and `422` status.

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

Lines changed: 76 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ import {
270270
BARE_NAME_ONE_HOLDER_TYPES,
271271
isPackageScopedType,
272272
isPlatformRequestedBareName,
273+
PLATFORM_REQUESTED_BARE_NAMES_BY_TYPE,
273274
OVERRIDABLE_BASELINE_PACKAGES,
274275
isBareNameOneHolderType,
275276
isOverridableBaseline,
@@ -604,7 +605,9 @@ export function bareNameTypeLabel(type: BareNameOneHolderType): string {
604605

605606
/**
606607
* How each covered type's consumer names it with no package — the clause a
607-
* refusal's reason carries for the types it lists.
608+
* refusal's reason carries for a type still held one name per deployment (not
609+
* in {@link NAMESPACE_SCOPED_BARE_NAME_TYPES}; a narrowed type's reason states
610+
* the namespace rule instead).
608611
*/
609612
const CONSUMER_CLAUSE: Readonly<Record<BareNameOneHolderType, string>> = Object.freeze({
610613
picklist: 'a field names its picklist',
@@ -643,20 +646,82 @@ const joinList = (parts: readonly string[]): string =>
643646
parts.length <= 1 ? (parts[0] ?? '') : `${parts.slice(0, -1).join(', ')} and ${parts[parts.length - 1]}`;
644647

645648
/**
646-
* Why a second holder is refused, in one sentence a reader can act on — for
647-
* the covered types `types` lists (every covered type when none), in the
648-
* order {@link BARE_NAME_ONE_HOLDER_TYPES} lists them. Shared by the doors'
649-
* refusal and the cold boot's warning.
649+
* The holdings of a narrowed type that still meet whatever their namespaces
650+
* ("Two holdings still meet under a narrowed type", above), as the clauses a
651+
* reason states them in — empty for a type with neither. Read from the same
652+
* tables {@link bareNameHoldersMeet} and the registry's bundle-addition read
653+
* ask: the names the platform requests by their bare spelling
654+
* (`PLATFORM_REQUESTED_BARE_NAMES_BY_TYPE`), and a bundle's addition
655+
* ({@link isBundleAdditionPair}), for a type whose items are keyed by a
656+
* discriminator (`ITEM_KEY_DISCRIMINATORS`).
657+
*/
658+
function crossNamespaceExceptionClauses(type: BareNameOneHolderType): string[] {
659+
const clauses: string[] = [];
660+
const requested = isPackageScopedType(type) ? (PLATFORM_REQUESTED_BARE_NAMES_BY_TYPE[type] ?? []) : [];
661+
if (requested.length > 0) {
662+
clauses.push(
663+
`a name the platform requests by its bare spelling (${joinList(requested.map((n) => `"${n}"`))}) keeps one ` +
664+
'holder per deployment',
665+
);
666+
}
667+
const disc = ITEM_KEY_DISCRIMINATORS[type];
668+
if (disc !== undefined && isBareNameRegistryType(type)) {
669+
const noun = TYPE_NOUN[type].replace(/^an? /, '');
670+
clauses.push(
671+
`a package that depends on the name's holder (which does not depend on it back) and ships the name only in ` +
672+
`${disc.field}s the holder does not ship is refused as an addition to the holder's ${noun}`,
673+
);
674+
}
675+
return clauses;
676+
}
677+
678+
/**
679+
* Why a second holder is refused, in one sentence a reader can act on per
680+
* rule — for the covered types `types` lists (every covered type when none),
681+
* in the order {@link BARE_NAME_ONE_HOLDER_TYPES} lists them. Shared by the
682+
* doors' refusal and the cold boot's warning.
683+
*
684+
* A narrowed type ({@link NAMESPACE_SCOPED_BARE_NAME_TYPES}, "The narrowing")
685+
* is told its own rule: one holder per namespace, another namespace may ship
686+
* the name, and a bare name two holders share is refused naming both; a
687+
* narrowed type whose holdings can still meet across namespaces is told
688+
* those exceptions too ({@link crossNamespaceExceptionClauses}). A type
689+
* not yet narrowed keeps the one-name-per-deployment sentence and its
690+
* consumers' clause. A list carrying both gets one sentence per rule, the
691+
* narrowed one first.
650692
*/
651693
export function bareNameReason(types: readonly BareNameOneHolderType[] = BARE_NAME_ONE_HOLDER_TYPES): string {
652694
const present = BARE_NAME_ONE_HOLDER_TYPES.filter((t) => types.includes(t));
653695
const listed = present.length > 0 ? present : BARE_NAME_ONE_HOLDER_TYPES;
654-
const nouns = joinList(listed.map((t) => TYPE_NOUN[t]));
655-
return (
656-
`${nouns.charAt(0).toUpperCase()}${nouns.slice(1)} ${listed.length === 1 ? 'holds' : 'each hold'} one name per ` +
657-
`deployment: ${joinList(listed.map((t) => CONSUMER_CLAUSE[t]))}, with no package to tell two definitions ` +
658-
'apart, so with two holders every caller is served the same one, chosen by registration order.'
659-
);
696+
const subject = (group: readonly BareNameOneHolderType[]): string => {
697+
const nouns = joinList(group.map((t) => TYPE_NOUN[t]));
698+
return `${nouns.charAt(0).toUpperCase()}${nouns.slice(1)} ${group.length === 1 ? 'holds' : 'each hold'}`;
699+
};
700+
const narrowed = listed.filter((t) => isNamespaceScopedBareNameType(t));
701+
const perDeployment = listed.filter((t) => !isNamespaceScopedBareNameType(t));
702+
const sentences: string[] = [];
703+
if (narrowed.length > 0) {
704+
const exceptions = narrowed
705+
.map((t) => ({ t, clauses: crossNamespaceExceptionClauses(t) }))
706+
.filter(({ clauses }) => clauses.length > 0);
707+
sentences.push(
708+
`${subject(narrowed)} one name per namespace: a package of another namespace may ship the same name` +
709+
`${exceptions.length > 0 ? ', save the exceptions below' : ''}, but within one namespace, or beside a ` +
710+
'package that declares no namespace, a name has one holder, and a bare name two holders share is refused ' +
711+
'naming both.',
712+
);
713+
for (const { t, clauses } of exceptions) {
714+
sentences.push(`For ${TYPE_NOUN[t]}, whatever the namespaces: ${joinList(clauses)}.`);
715+
}
716+
}
717+
if (perDeployment.length > 0) {
718+
sentences.push(
719+
`${subject(perDeployment)} one name per deployment: ` +
720+
`${joinList(perDeployment.map((t) => CONSUMER_CLAUSE[t]))}, with no package to tell two definitions ` +
721+
'apart, so with two holders every caller is served the same one, chosen by registration order.',
722+
);
723+
}
724+
return sentences.join(' ');
660725
}
661726

662727
/** A stable identity for de-duplicating holders. */

‎packages/objectql/src/hook-binder.ts‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,21 @@ export function bindHooksToEngine(
205205
// named 'x' is registered", naming the one thing the author had actually
206206
// done.
207207
if (opts.functions && typeof (engine as any).registerFunction === 'function') {
208-
// [#30803] One name, one package holder for a function
209-
// (`bare-name-one-holder.ts`, phase 1 of ADR-0150): once the cold boot
210-
// has sealed the registry a bind bringing a function another package
211-
// holds is refused here, ahead of every registration below, naming both
212-
// holders. Before the seal the claims are only recorded, for the cold
213-
// boot to read. The engine keeps every holder of a name
208+
// [#30803] The bare-name one-holder rule for a function
209+
// (`bare-name-one-holder.ts`), narrowed to the namespace (ADR-0150 D2/D9:
210+
// `function` is in `NAMESPACE_SCOPED_BARE_NAME_TYPES`). Before the seal
211+
// the claims are only recorded, for the cold boot to read. Once the cold
212+
// boot has sealed the registry, `claimBareNameFunctions` throws a
213+
// `BareNameConflictError` naming both holders when this bind brings a
214+
// function a package of its own namespace, a package with no namespace,
215+
// or the platform already holds; a package of another namespace may hold
216+
// the same name. The throw comes ahead of every registration below and is
217+
// not caught here: the runtime's `bindAppArtifactHandlers` catches it per
218+
// owner group and logs "Failed to bind declarative hooks" at `error`, so
219+
// the package still installs and every function and hook of that owner
220+
// group stays unbound. The engine keeps every holder of a name
214221
// (`functionHoldersOf`) and a flow `script` node resolves it in the
215-
// calling flow's package (#32073); this refusal stays until the trailing
216-
// backstop child (ADR-0150 D9) narrows it.
222+
// calling flow's package (#32073).
217223
const claimable = Object.entries(opts.functions)
218224
.filter(([, entry]) => normalizeFlowFunctionEntry(entry) !== undefined)
219225
.map(([name]) => name);

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

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -561,18 +561,45 @@ describe('what the AI family leaves alone', () => {
561561
});
562562
});
563563

564-
describe('the refusal\'s reason names the consumers of the types it lists', () => {
564+
describe('the refusal\'s reason states the rule of the types it lists', () => {
565565
it('one sentence per refusal, naming only the types it carries', async () => {
566566
const { register } = await boot();
567567
expect(await register(pkg('com.acme.alpha', { agent: ['a1'], skill: ['s1'] }))).toBeUndefined();
568568
const err = await register(rival('agent', 'com.acme.beta', { agent: ['a1'], skill: ['s1'] }));
569569
expect(err!.conflicts!.map((c) => `${c.type}/${c.name}`)).toEqual(['agent/a1', 'skill/s1']);
570570
expect(err!.message).toContain(bareNameReason(['agent', 'skill']));
571-
expect(bareNameReason(['agent', 'skill'])).toMatch(
572-
/^An agent and a skill each hold one name per deployment: `\/meta\/agent\/NAME` serves one agent per name and an MCP client fetches a skill's prompt by its name, /,
573-
);
574-
expect(bareNameReason(['skill'])).toMatch(/^A skill holds one name per deployment: an MCP client fetches a skill's prompt by its name, /);
575-
expect(bareNameReason(['tool'])).toMatch(/^A tool holds one name per deployment: a skill's `tools` and an MCP client name a tool, /);
571+
expect(bareNameReason(['agent', 'skill'])).toMatch(/^An agent and a skill each hold one name per namespace: /);
572+
expect(bareNameReason(['skill'])).toMatch(/^A skill holds one name per namespace: /);
573+
expect(bareNameReason(['tool'])).toMatch(/^A tool holds one name per namespace: /);
574+
});
575+
576+
// No covered type is held one name per deployment on main any more, so the
577+
// per-deployment sentence is reached only by a type that joins the covered
578+
// list before its own narrowing: simulated here by reading `tool` as not
579+
// narrowed, in a fresh copy of the module.
580+
it('a type not yet narrowed keeps the one-name-per-deployment sentence, after the narrowed one', async () => {
581+
vi.resetModules();
582+
vi.doMock('@objectstack/core', async (importOriginal) => {
583+
const core = await importOriginal<typeof import('@objectstack/core')>();
584+
return {
585+
...core,
586+
isNamespaceScopedBareNameType: (type: unknown) => type !== 'tool' && core.isNamespaceScopedBareNameType(type),
587+
};
588+
});
589+
try {
590+
const { bareNameReason: reasonWithToolUnnarrowed } = await import('./bare-name-one-holder.js');
591+
expect(reasonWithToolUnnarrowed(['tool'])).toBe(
592+
"A tool holds one name per deployment: a skill's `tools` and an MCP client name a tool, with no package "
593+
+ 'to tell two definitions apart, so with two holders every caller is served the same one, chosen by '
594+
+ 'registration order.',
595+
);
596+
expect(reasonWithToolUnnarrowed(['skill', 'tool'])).toMatch(
597+
/^A skill holds one name per namespace: .+ A tool holds one name per deployment: /,
598+
);
599+
} finally {
600+
vi.doUnmock('@objectstack/core');
601+
vi.resetModules();
602+
}
576603
});
577604

578605
it('a built-in name is refused to a package at the package door, naming the platform', async () => {

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

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,11 @@ describe('the narrowing — an email template holds one name per namespace (ADR-
697697
const err = await register(ofBeta({ emailTemplates: [member('beta', RESET, 'zh-CN')] }));
698698
expectRefusal(err, 'com.acme.beta', { kind: 'package', packageId: 'com.acme.alpha' }, `beta_${RESET}`);
699699
expect(err!.message).not.toContain(EMAIL_SERVICE_PKG);
700+
// The reason states the exception that refused it: another namespace may NOT ship this name.
701+
expect(err!.message).toContain('may ship the same name, save the exceptions below');
702+
expect(err!.message).toMatch(
703+
/For an email template, whatever the namespaces: a name the platform requests by its bare spelling \([^)]*"auth\.password_reset"[^)]*\) keeps one holder per deployment/,
704+
);
700705
expect(await register(pkg('com.acme.beta'))).toBeUndefined();
701706
expectRefusal(
702707
await caught(() => registry.registerItem(type, member('beta', RESET, 'zh-CN'), 'name', 'com.acme.beta')),
@@ -725,7 +730,14 @@ describe('the narrowing — an email template holds one name per namespace (ADR-
725730
it('at the package door, naming the base', async () => {
726731
const { register } = await boot();
727732
expect(await register(pkg('com.acme.alpha', {}, { emailTemplates: [member('alpha', name, 'en-US')] }))).toBeUndefined();
728-
expectRefusal(await register(dependent()), 'com.acme.beta', { kind: 'package', packageId: 'com.acme.alpha' }, `beta_${name}`);
733+
const err = await register(dependent());
734+
expectRefusal(err, 'com.acme.beta', { kind: 'package', packageId: 'com.acme.alpha' }, `beta_${name}`);
735+
// The reason states the exception that refused it: another namespace may NOT ship this addition.
736+
expect(err!.message).toContain('may ship the same name, save the exceptions below');
737+
expect(err!.message).toContain(
738+
"a package that depends on the name's holder (which does not depend on it back) and ships the name only in "
739+
+ "locales the holder does not ship is refused as an addition to the holder's email template",
740+
);
729741
});
730742

731743
it('at the item seam, naming the base', async () => {
@@ -773,7 +785,7 @@ describe('the narrowing — an email template holds one name per namespace (ADR-
773785

774786
});
775787

776-
describe('the refusal\'s reason names the consumers of the types it lists', () => {
788+
describe('the refusal\'s reason states the rule of the types it lists', () => {
777789
it('one sentence per refusal, naming only the types it carries', async () => {
778790
const { register } = await boot();
779791
expect(await register(pkg('com.acme.alpha', { flow: ['f1'], webhook: ['w1'], connector: ['c1'], email_template: ['e1'] }))).toBeUndefined();
@@ -782,9 +794,20 @@ describe('the refusal\'s reason names the consumers of the types it lists', () =
782794
expect(err!.conflicts!.map((c) => `${c.type}/${c.name}`)).toEqual(['flow/f1', 'webhook/w1', 'connector/c1', 'email_template/e1']);
783795
expect(err!.message).toContain(bareNameReason(['flow', 'webhook', 'connector', 'email_template']));
784796
expect(bareNameReason(['flow', 'webhook', 'connector', 'email_template'])).toMatch(
785-
/^A flow, a webhook, a connector and an email template each hold one name per deployment: the automation engine arms one flow per name, the webhook dispatcher subscribes one declared webhook per name, /,
797+
/^A flow, a webhook, a connector and an email template each hold one name per namespace: /,
798+
);
799+
expect(bareNameReason(['email_template'])).toMatch(/^An email template holds one name per namespace: /);
800+
});
801+
802+
it('a narrowed type is told the namespace rule, never one name per deployment', () => {
803+
expect(bareNameReason(['flow'])).toBe(
804+
'A flow holds one name per namespace: a package of another namespace may ship the same name, but within '
805+
+ 'one namespace, or beside a package that declares no namespace, a name has one holder, and a bare name '
806+
+ 'two holders share is refused naming both.',
786807
);
787-
expect(bareNameReason(['email_template'])).toMatch(/^An email template holds one name per deployment: a send names its email template, /);
808+
// Every covered type has narrowed, so no reason says the old rule.
809+
expect(bareNameReason()).not.toContain('one name per deployment');
810+
expect(bareNameReason()).not.toContain('chosen by registration order');
788811
});
789812

790813
it('a built-in name is refused to a package at the package door, naming the platform', async () => {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -781,15 +781,15 @@ describe('function — the engine function registry, through the hook binder\'s
781781
});
782782
});
783783

784-
describe('the refusal\'s reason names the consumers of the types it lists', () => {
784+
describe('the refusal\'s reason states the rule of the types it lists', () => {
785785
it('one sentence per refusal, naming only the types it carries', async () => {
786786
const { register } = await boot();
787787
expect(await register(pkg('com.acme.alpha', { api: ['a1'], action: ['r1'] }))).toBeUndefined();
788788
const err = await register(coOwner('com.acme.alpha', 'com.acme.beta', { api: ['a1'], action: ['r1'] }));
789789
expect(err!.conflicts!.map((c) => `${c.type}/${c.name}`)).toEqual(['api/a1', 'action/r1']);
790790
expect(err!.message).toContain(bareNameReason(['api', 'action']));
791-
expect(bareNameReason(['api', 'action'])).toMatch(/^An API and an object-less action each hold one name per deployment: /);
792-
expect(bareNameReason(['function'])).toMatch(/^A function holds one name per deployment: /);
791+
expect(bareNameReason(['api', 'action'])).toMatch(/^An API and an object-less action each hold one name per namespace: /);
792+
expect(bareNameReason(['function'])).toMatch(/^A function holds one name per namespace: /);
793793
});
794794

795795
it('a built-in name is refused to a package at the package door, naming the platform', async () => {

0 commit comments

Comments
 (0)