Repository navigation
Commit 9951f46
fix(plugin-email)!: the email template send judges the served holders, so a disabled package holds no name at the send (ADR-0150 D3) (#33361)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DDZYUbJbnXUTqZoZ56k4czR)_
Part of #32670
Clause-②: yes (narrowing) — widened: a send of a template name an
enabled and a disabled package hold, made with no package or from a
caller whose closure holds both, is served the enabled holder's template
where it was refused naming both. Narrowed: a send that only a disabled
holder's side answered (its customization pair's row, a dependent's
added locale, the environment's item or a package-less stored row beside
a name only it holds) finds no template; a send of an auth name whose
one overriding package is disabled is served the built-in copy. Refusals
name only the packages that serve the name. With no holder of the name
disabled, every answer is unchanged.
Metadata-protocol: none
Skills-docs: none — no skill under `skills/**` and no page under
`content/docs/**` teaches what an email template send answers when a
package holding the name is disabled.
## 维护者速读
- 改了什么:邮件模板发送(`template-loader.ts` 的
`bundleAddressOf`)在模板名有持有包被停用时,只按"仍在服务的持有包"解析名字,并且只从不含停用包成员的地址读取模板(解析出的持有包自己的地址,或内置模板的地址);停用包自己发送、或没有任何在服务持有包能回答的发送,一律"找不到模板"。没有持有包被停用时,行为与
main 完全相同。
- 为什么改:#32183 让停用包在解析处不再持有名字,但发送门按 R4-A 暂时保持 main
的答案;本卡把发送门也改为判断在服务的持有包,同时不泄露别的包的成员(停用包的定制对行、依赖包追加的语言)。
-
风险与回滚:风险在"收窄"一侧:停用包一侧原本能发出去的模板(定制对行、依赖包追加语言、与单一停用持有包并存的环境项或无包存储行)现在发不出去;auth
模板的唯一覆盖包被停用时改发内置模板。回滚即还原 `template-loader.ts` 一个文件。`_env` 单元格与 R4-G
流程门不在本 PR(见 Acceptance notes)。
-
先看:`packages/plugins/plugin-email/src/template-loader.ts`(`servedBundleAddressOf`,尤其"读哪个地址"的分支);`packages/plugins/plugin-email/src/template-loader.test.ts`(新
describe 的期望表);`.changeset/32670-email-send-served-holders.md`(逐行 FROM →
TO)。
- 两分钟验证:`pnpm --filter @objectstack/plugin-email exec vitest run
src/template-loader.test.ts`,预期 76 个测试全部通过。
- 需要你做的:决定 `_env` 单元格(需要改 `packages/metadata-protocol`,属 E1 区域)与 R4-G
流程门的去向;本 PR 落地须等 #32354。
## What changes
`createRegistryEmailTemplateLoader`'s `bundleAddressOf`
(`packages/plugins/plugin-email/src/template-loader.ts`):
- **No holder of the name disabled**: the code path is `main`'s,
unchanged (resolve, count and the shared view over every holder, which
are the served holders here). Measured: 0 moved answers with nothing
disabled, across the probe matrix below.
- **A holder disabled** (`servedBundleAddressOf`): the name is resolved
over the served holders, so a disabled package is never the answer and a
refusal names only the packages that serve the name. The bundle is read
only where no member of a disabled holder's side is listed:
- resolved to a served holder: that holder's own address (as `main`
already read a name two packages hold);
- resolved to the built-ins (an auth name whose overriding package is
disabled): the built-ins' own address, through the closure re-resolve;
- the caller's own holding is the disabled one, or no served holder
answers: no template (`NO_BUNDLE`, no list is read);
- the caller holds a dependent's addition only: resolved again from its
closure over the served holders, so a dependent of a disabled base never
gets a template from outside its closure.
- **Why the read is chosen and never filtered after the read** (measured
on the real protocol): the environment-wide execution list keeps a
disabled holder's customization-pair rows and a dependent's added
locales listed, and an item's `_packageId` there is the slot it fills,
not the package that stores it. A pair row filling a locale a dependent
also adds wears the dependent's id; the environment's item over a
disabled holder's slot wears the disabled holder's id. So the member
rule of contract review 6819947096 (a send returns only members stored
under the resolved holder, its pair, a dependent whose closure holds it,
or no package) is met by choosing the address, never by filtering
`_packageId`.
The card's rows 27 to 31 (PR #32497's round-3 table, withdrawn under
R4-A) are restored, and rows 36 to 38 are declared. Numbering: 27 to 31
follow the round-3 changeset's order (rows 29 and 30 are the two
refusals naming the enabled holder, per the red-line read 6819956008);
32 to 35 stay #32497's.
| Row | Address / caller | State | FROM (`main`) | TO | Clause-② arm |
|:---|:---|:---|:---|:---|:---|
| 27 | a send with no package (omitted or `null`) | two holders, one
disabled | 409 naming both | the enabled holder's address (its template;
a locale only the disabled side carries: no template) | widening |
| 28 | a caller whose closure holds both | same | 409 naming both | the
enabled holder's address | widening |
| 29 | a caller whose closure reaches the name only through the disabled
holder (a dependent of it included) | same | no template, or the
disabled holder's pair row | 409 `outside-closure` naming the enabled
holder | refusal |
| 30 | a caller that reaches neither (the built-in package as caller
included) | same | 409 `outside-closure` naming both | 409
`outside-closure` naming the enabled holder | names fewer |
| 31 | every caller | every holder disabled | 409 naming them, or the
pair's row | no template | not-found |
| 36 | the disabled holder's own send | two holders, one disabled | its
pair's row | no template | not-found |
| 37 | every caller | one holder, disabled, beside the environment's
item (registered first or last), a package-less stored row, a
dependent's addition or the pair's row | that member (the
environment-wide list), or 409 `outside-closure` naming it for a caller
with no path | no template | not-found |
| 38 | every caller but the package; the dependent | an auth name
(`auth.*`) whose one overriding package is disabled | the
environment-wide list (the disabled package's side, the environment's
item, or the built-in), or 409 naming the dependent and the package |
the built-ins' own address (the built-in template, or a package-less
stored row there); the package's own send: no template | narrowing
(re-targeted) |
First-party count 0 on every row: no first-party composition ships an
email template name two packages hold, or disables a package that holds
one.
## Tests
`packages/plugins/plugin-email/src/template-loader.test.ts`: the R4-A
parity describe (`a disabled holder still counts at the send`), whose
premise this card reverses, is replaced by `a disabled package holds no
name at the send (ADR-0150 D3, #32670)`:
- Real world: a `SchemaRegistry` and the protocol's real
`getMetaItemsForExecution` (`ObjectStackProtocolImplementation`, aliased
to this checkout's source) over stored `sys_metadata` rows: ALPHA's
customization pair `ALPHA.custom` stores an fr-FR member row; ADDER
depends on ALPHA only and adds fr-FR. No double over
`registry.listItems`. The engine double opens `findOne` with
`assertEngineFindOnePredicate`, and carries no write verb.
- 11 cases × 2 registration orders × 2 reads (the protocol's, and the
registry's own list) = 44 tests; each asserts 9 callers × en-US and
fr-FR (792 answers). Callers: omitted, `null`, ALPHA, BETA, a closure
holding both, a closure through ALPHA only, neither, the dependent, the
built-in package.
- Cases: two holders with nothing / ALPHA / BETA / both disabled; two
holders with the dependent disabled and ALPHA disabled; one holder
disabled beside the environment's item registered first, and last; one
holder beside a package-less stored row, nothing disabled and disabled;
an auth name one package overrides, nothing disabled and disabled.
- CONTROLs: all enabled (two holders), one holder (nothing disabled), an
auth name (nothing disabled); and the R4-F CONTROL (the built-in package
as caller) is kept.
- A refusal is asserted by its envelope (`code` `RESOURCE_CONFLICT`,
`status` 409) and its candidates.
## Acceptance notes
- **Landing waits on #32354** (E1's, no PR yet), as the card's order
says. Until then a disabled holder's side stays listed in the
environment-wide list and in the list scoped to a disabled base
(#32354's class, unmoved here). That is why a served holder beside a
disabled one is still read at its own address: the environment-wide list
would hand it the disabled side's members. Once #32354 withholds them,
the address can be chosen on the served count alone (a separate,
declared move).
- **Not in this PR: the `_env` cell of #32183's row 17 (ruling R4-B2)**.
Moving `_env` of a name only disabled packages hold from `main`'s 409 to
row 17's 404 needs `packages/metadata-protocol/src/**`, which this lane
may not edit (area E1): `admitEnvironmentQualifier`
(`protocol-exact-qualifier.ts`) admits the read when no package serves
the name, and the `_env` mark has to reach the item face
(`protocol-meta-item-face.ts`, `disabledOnlyHolderOf`) through both
transports (`packages/runtime/src/domains/meta.ts` at its
`admitEnvironmentQualifier` call, and
`packages/rest/src/meta-qualified-item-route.ts`), so the face answers
the withheld 404 and never the disabled holder's pair row. Raised for
decision in the report; the card stays open (`Part of`).
- **Not in this PR: the R4-G sweep.** #32497 holds the #32507 flow doors
at `main` and carries their served judgment to this card
(`flowServiceForCaller`, `endpointPackageOf`, `flowWalkReads`,
`flowHolderForCaller` in runtime `flow-slot-view.ts`; `bareNameRefusal`
and `admitAutomationAddress`'s shared branch in runtime
`automation-address.ts`; `heldByMany`, `sharedFlowNameRefusal` and
`resolveFlowKey`'s shared branch in service-automation `engine.ts`; and
the dispatch key `flowDispatchHolder`). A runtime disable keeps a
disabled package's engine slot armed, so a served read there moves those
doors both ways; that is a design question, raised for decision in the
report.
- **The environment's item beside a name only a disabled package holds**
(row 37) is withheld as that package's customization: the registry
answers no environment item for a name a package holds
(`getEnvironmentScopedItem` is undefined), and the execution list stamps
the item with the disabled holder's slot. Sending nothing is the
conservative answer (red line: resolution is never loosened); the
reviewer may rule otherwise.
- The environment-item branch of `servedBundleAddressOf` (a resolve to
the environment's own item, read environment-wide as before) is
unreachable in the probe matrix: replaced by no template, 0 of 31,104
answers move. It is kept as `main`'s answer for that resolve.
- `main` answers some one-holder sends beside the environment's item in
an order-dependent way (the en-US slot answers the holder's template in
one registration order and the environment's item in the other), the
same on both trees with nothing disabled. Not moved here; the pins use
no such CONTROL.
- A non-auth name the built-in package holds (unreachable: the built-ins
ship only `auth.*` names) answers like any other package holder;
measured in the matrix, not pinned.
## Verification
All at `4419624c1a` unless named.
<details><summary>Probe matrix (FROM = `main`'s loader, TO = this
head's, one process, same registry per answer)</summary>
31,104 answers: one or two holders with every subset disabled; beside
nothing, the environment's item registered first or last, or a
package-less stored row; with and without the pair's stored fr-FR row;
no dependent, the dependent enabled or disabled; no built-in, the
built-in holding a non-auth name, or an auth name; 9 callers; en-US and
fr-FR; both reads; both orders.
- Moved: 14,681; with nothing disabled: 0.
- A sent member stored outside the member rule (a disabled holder's own,
its pair's row, a disabled or base-disabled dependent's addition, or a
holder outside a package caller's closure): `main` 1,127; this head 107,
all 107 unmoved from `main` and all in nothing-disabled states (the
built-in package as caller of a one-holder non-auth name, R4-F's shape);
new ones: 0.
</details>
<details><summary>Ablations (each through
`scripts/ablation-replace.mjs`, restored to the HEAD blob)</summary>
- A1, the served branch removed (`bundleAddressOf` never calls
`servedBundleAddressOf`): 32 of 76 red, every disabled case in both
orders and both reads; the 12 CONTROL tests and the other 32 stay green.
- A2, not-found reads the environment-wide list instead of no template:
16 of 76 red (rows 31 and 37).
- A4, the disabled caller's own holding falls through to the re-resolve:
16 of 76 red (two holders with ALPHA or with BETA disabled, the
dependent-disabled case, and the auth name; rows 29, 36 and 38).
- A5, the re-resolve counts every holder: 12 of 76 red (two holders with
ALPHA disabled, the dependent-disabled case, and the auth name; rows 29
and 38).
- A6, the re-resolve's built-ins arm removed: 4 of 76 red (row 38).
- A3, a duplicate built-ins check before the re-resolve, ablated: 0 of
76 red, and 0 of 31,104 matrix answers moved; it was deleted
(`26768975c`). A2, A4 and A5 ran at `b82d77303`, whose
`template-loader.ts` differs from the head's only by that deleted line;
A1 ran again at the head.
</details>
<details><summary>Tests and gates</summary>
- `pnpm --filter @objectstack/plugin-email test`: Test Files 53 passed
(53), Tests 1010 passed (1010) (lock VERDICT command-exit 0).
- `pnpm --filter @objectstack/plugin-email typecheck` (tsc, then
`check:test-typecheck`): exit 0, `check:test-typecheck: OK`.
- `eslint --no-inline-config` on the two touched source files: exit 0.
- The derived local gate families (`dispatch-gates.mjs --commands`, 79
commands): 75 exit 0 on the first run; `check-adr-0087-registration`,
`check:engine-double-contract` and `check:test-source-alias` were red on
the first run and are exit 0 after `4419624c1a` (the ADR-0087
disposition, the pinned `findOne` and its ledger line, the protocol's
source alias). `check:dual-build-cjs-loads`: NOT MEASURED, reason:
PREREQUISITE NOT MET (it reads every package's `dist/`; CI runs it).
- Dependents of `@objectstack/plugin-email` (60 downstream packages,
through `rest` and `client`): not run locally; the public surface is
byte-unchanged (no export, type or signature moves; the change is
module-internal), and Test Core runs the affected set. The full dogfood
battery is owed by the narrowing arm and is reported with the dev
report.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent beff1fb commit 9951f46
7 files changed
Lines changed: 465 additions & 135 deletions
File tree
- .changeset
- packages/plugins/plugin-email
- src
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
0 commit comments