Repository navigation
Commit b109659
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
| 273 | + | |
273 | 274 | | |
274 | 275 | | |
275 | 276 | | |
| |||
604 | 605 | | |
605 | 606 | | |
606 | 607 | | |
607 | | - | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
608 | 611 | | |
609 | 612 | | |
610 | 613 | | |
| |||
643 | 646 | | |
644 | 647 | | |
645 | 648 | | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
650 | 692 | | |
651 | 693 | | |
652 | 694 | | |
653 | 695 | | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
660 | 725 | | |
661 | 726 | | |
662 | 727 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
214 | 221 | | |
215 | | - | |
216 | | - | |
| 222 | + | |
217 | 223 | | |
218 | 224 | | |
219 | 225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
561 | 561 | | |
562 | 562 | | |
563 | 563 | | |
564 | | - | |
| 564 | + | |
565 | 565 | | |
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
570 | 570 | | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
576 | 603 | | |
577 | 604 | | |
578 | 605 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
697 | 697 | | |
698 | 698 | | |
699 | 699 | | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
700 | 705 | | |
701 | 706 | | |
702 | 707 | | |
| |||
725 | 730 | | |
726 | 731 | | |
727 | 732 | | |
728 | | - | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
729 | 741 | | |
730 | 742 | | |
731 | 743 | | |
| |||
773 | 785 | | |
774 | 786 | | |
775 | 787 | | |
776 | | - | |
| 788 | + | |
777 | 789 | | |
778 | 790 | | |
779 | 791 | | |
| |||
782 | 794 | | |
783 | 795 | | |
784 | 796 | | |
785 | | - | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
786 | 807 | | |
787 | | - | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
788 | 811 | | |
789 | 812 | | |
790 | 813 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
781 | 781 | | |
782 | 782 | | |
783 | 783 | | |
784 | | - | |
| 784 | + | |
785 | 785 | | |
786 | 786 | | |
787 | 787 | | |
788 | 788 | | |
789 | 789 | | |
790 | 790 | | |
791 | | - | |
792 | | - | |
| 791 | + | |
| 792 | + | |
793 | 793 | | |
794 | 794 | | |
795 | 795 | | |
| |||
0 commit comments