Repository navigation
Commit 4dfb9f1
fix(plugin-email): a name an enabled and a disabled package hold sends what it sends when only the enabled one holds it (#33678)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9D3DpgJLtDkE1fR76z3bz5Xm)_
Part of #32670
Clause-②: no
Metadata-protocol: none
The card stays open: its `_env` half is #33385 (area E1, still open).
This PR is the "separate, declared move" that #33361's acceptance notes
and its contract review (record 6882047833, item ③) left owed once
#32354 landed. #32354 landed in #33405 (merged 2026-11-14T22:08Z, before
#33361).
## 维护者速读
-
改了什么:邮件模板名有一个持有包被停用、只剩一个在服务的持有包时,发送(经元数据协议的执行列表)改为读环境级列表,与"只有这一个包持有该名"时完全一致;另把
`servedBundleAddressOf` 中不可达的环境项分支改为"找不到模板"(复审 nit N1)。
- 为什么改:ADR-0150
D3「停用的包不持有任何名字」。#32354(#33405)落地后,环境级列表已不再列出停用包一侧的成员(自身项、定制对行、依赖包追加的语言),所以地址可以只按在服务持有包数量来选;此前读该包自己的地址,会漏掉依赖它的包追加的语言。
-
风险与回滚:只在有持有包被停用、且只剩一个在服务持有包时生效。实测唯一变化:该持有包的定制对行与依赖包追加语言落在同一语言时,答案从定制对行变为依赖包的语言,与停用包根本不持有该名时的答案相同。没有包停用时、或无协议只读注册表时,答案不变。回滚即
revert 本 PR。
- 先看:`packages/plugins/plugin-email/src/template-loader.ts` 的
`servedBundleAddressOf`(`onServedCount` 与 `servedCountDecides` 参数)以及
`readBundle` 中 `viaProtocol` 的传入;`template-loader.test.ts` 中 `two
holders, BETA disabled` 一例的期望与新的 `one holder` CONTROL。
- 两分钟验证:`pnpm --filter @objectstack/plugin-email exec vitest run
src/template-loader.test.ts`,预期 80 个测试全部通过。
- 需要你做的:无,席位落地
## What changes
`packages/plugins/plugin-email/src/template-loader.ts`,
`servedBundleAddressOf` (the branch taken only while a holder of the
name is disabled):
- **The address is chosen on the served count when the bundle is read
from the protocol's execution list.** One served holder ⇒ the
environment-wide list (`undefined`), two or more ⇒ the answering
holder's own address, exactly as `bundleAddressOf` chooses on the holder
count when nothing is disabled. This applies to both answers that read a
package's bundle: the name resolving to a served holder, and the closure
re-resolve (a caller holding an addition only, or the built-ins for an
`auth.*` name).
- **Why it is safe now:** since #33405 (#32354) the environment-wide
execution list holds no member of a disabled holder's side: its own
items were already filtered, and the list naming no package now
withholds its customization pair's rows and a dependent's added bundle
members. So the read beside a disabled holder answers what it answers
when that holder holds nothing of the name.
- **The registry's own list keeps the per-holder address.**
`registry.listItems` (read only when no protocol is registered)
withholds neither, so there the move would leak a dependent's addition
to the disabled holder (measured, see the second ablation). `readBundle`
passes `viaProtocol` into `bundleAddressOf` as `servedCountDecides`.
- **Nit N1:** the environment-item branch (`resolved.holder.kind` other
than `package`) now answers `NO_BUNDLE` instead of the environment-wide
read. It is unreachable while a holder is disabled (a name a package
holds resolves to no environment item), so no answer moves; "no read is
made beside a disabled holder for it" now holds by construction.
- Doc comments on `bundleAddressOf` and `servedBundleAddressOf` restate
the rule. Changeset: `@objectstack/plugin-email` patch.
### Moved answers
Probe: the #33361 world (a real `SchemaRegistry` and the protocol's real
`getMetaItemsForExecution` over stored rows), 8 disabled states × 2
registration orders × 2 reads × 9 callers × 2 locales = 1,152 answers,
on `babd5d4a` (FROM, `main`) and on this branch (TO), plus the same
worlds with the disabled package's side removed instead of disabled
(ABSENT: it ships nothing of the name; for ALPHA also no pair row and no
dependent's addition).
| Read | State | Caller | Locale | FROM | TO | ABSENT |
|:--|:--|:--|:--|:--|:--|:--|
| protocol | two holders, BETA disabled (ALPHA carries a pair row and a
dependent's addition, both fr-FR) | omitted, null, ALPHA, BOTH,
VIA_ALPHA, ADDER | fr-FR | the pair's row (`PAIR fr-FR`) | the
dependent's addition (`ADDER fr-FR`) | `ADDER fr-FR` |
12 answers move (6 callers × 2 orders), all toward the ABSENT answer; 0
of the 1,152 move away from it. The answers that still differ from
ABSENT number 204 (216 on FROM), and every one is a declared row of
#33361: the disabled package's own send (row 36), the environment's item
or a package-less stored row beside a name only a disabled package holds
(row 37), and the registry-only read (below). With nothing disabled the
code path is unchanged (`bundleAddressOf`'s first branch), and the
pinned CONTROLs hold.
## Tests
`packages/plugins/plugin-email/src/template-loader.test.ts`, describe `a
disabled package holds no name at the send (ADR-0150 D3, #32670)`:
- The `two holders, BETA disabled` case's protocol expectations move
fr-FR from `PAIR fr-FR` to `ADDER fr-FR` for the six callers above (its
registry-read override is unchanged: `no template`).
- A new CONTROL, state `one holder` (ALPHA alone holds the name, nothing
disabled), pins the answers the BETA-disabled case must equal for every
caller but BETA itself. 1 case × 2 orders × 2 reads = 4 new tests; the
file runs 80 (76 on `main`).
## Acceptance notes
- **The registry-only read keeps a disabled-vs-absent difference.** With
no protocol registered and BETA disabled, a fr-FR send for ALPHA's
callers answers `no template` (ALPHA's own address, which the registry
list narrows by `_packageId`), where ABSENT answers `ADDER fr-FR`. The
move cannot be applied there because `registry.listItems` still lists a
dependent's addition to a disabled holder (ablation 2 measures the
leak). A host with no protocol has no metadata door; noted, not filed.
- **The moved answer prefers the dependent's addition over the holder's
pair row at the same locale.** That is `main`'s answer for a name one
package holds with nothing disabled (the new CONTROL, both orders, and
#33361's R4-F note), not a rule this PR adds: the move only makes the
disabled case equal to it.
- **Not in this PR:** the `_env` cell of #32183 row 17 (#33385, area E1,
`packages/metadata-protocol/src/**`) and the R4-G flow doors, as #33361
recorded. So `Part of #32670`, not a closing line.
- The probe files were temporary and are not committed.
## Verification
Read at `7612a59d` (the change). The head `9754555c` adds one merge of
`origin/main` (`dd291b83` era, no conflict); the incoming commits touch
no file of `plugin-email` and nothing in the list reads or the
package-scoped resolver the loader calls (they change `objectql`
engine-update, search and validation files and `metadata-protocol`'s
seed loader and registry question), so the readings below are not re-run
on the merge; CI reads the head.
<details><summary>Tests, typecheck and lint (plugin-email), at
7612a59</summary>
```
pnpm --filter @objectstack/plugin-email test Test Files 53 passed (53) · Tests 1018 passed (1018)
pnpm --filter @objectstack/plugin-email typecheck exit 0 · check:test-typecheck OK (0 errors)
pnpm exec eslint (the two changed source files) exit 0
os-verify-lock: VERDICT command-exit 0
```
</details>
<details><summary>Ablation 1: the pins against main's loader
(template-loader.ts restored from babd5d4)</summary>
```
on-disk mutation: servedCountDecides count=0 (HEAD has 6)
× read: protocol > registered as listed > two holders, BETA disabled
× read: protocol > registered reversed > two holders, BETA disabled
Tests 2 failed | 78 passed (80) VERDICT command-exit 1
restored: git checkout HEAD -- the file; blob hash equals HEAD's; git status clean
```
</details>
<details><summary>Ablation 2: the move forced onto the registry read
(servedCountDecides passed as true)</summary>
```
anchor before: 1 · after: 0 · injected: 1
× read: registry > two holders, ALPHA disabled (both orders: ADDER fr-FR leaks)
× read: registry > two holders, BETA disabled (both orders)
× read: registry > an auth name one package overrides, ALPHA disabled (both orders: ADDER fr-FR leaks)
Tests 6 failed | 74 passed (80) VERDICT command-exit 1
restored: blob hash equals HEAD's; git status clean
```
</details>
<details><summary>Gate families</summary>
Derived with `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at 7612a59 (64 commands), each run locally
with its exit code captured before any pipe:
```
61 of 64 exit 0 (check-adr-0087-registration, check-changeset-no-major, check-empty-changeset,
check-issue-citations, check:engine-double-contract, check:test-source-alias,
check:registry-log-declared, check:cross-package-test-inputs, check:nul-bytes,
check:published-files, check:type-check-coverage, the comment-mask corpus and the rest)
NOT MEASURED, 3 (prerequisites of this checkout, not readings of the diff; CI runs each):
check-plugin-teardown-shape --self-test exit 3: shallow clone, positive control commit unreachable
check:dual-build-cjs-loads exit 3: PREREQUISITE NOT MET, reads every package's dist/
check:type-check-debt exit 3 under the 4096 MB heap cap; re-run uncapped, it
began a whole-closure build under the shared lock, stopped (not read)
```
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4cx5ZPCyTk8ckTsx4ut)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <noreply@anthropic.com>1 parent 481f642 commit 4dfb9f1
3 files changed
Lines changed: 79 additions & 29 deletions
File tree
- .changeset
- packages/plugins/plugin-email/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
| 516 | + | |
516 | 517 | | |
517 | 518 | | |
518 | 519 | | |
| |||
630 | 631 | | |
631 | 632 | | |
632 | 633 | | |
633 | | - | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
634 | 637 | | |
635 | 638 | | |
636 | | - | |
637 | | - | |
638 | | - | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
639 | 642 | | |
640 | | - | |
641 | | - | |
| 643 | + | |
| 644 | + | |
642 | 645 | | |
643 | | - | |
| 646 | + | |
644 | 647 | | |
645 | 648 | | |
646 | 649 | | |
| |||
652 | 655 | | |
653 | 656 | | |
654 | 657 | | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
655 | 673 | | |
656 | 674 | | |
657 | 675 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
175 | 177 | | |
176 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
177 | 184 | | |
178 | 185 | | |
179 | 186 | | |
180 | 187 | | |
181 | 188 | | |
182 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
183 | 192 | | |
184 | 193 | | |
185 | 194 | | |
| |||
202 | 211 | | |
203 | 212 | | |
204 | 213 | | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
210 | 226 | | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
217 | 230 | | |
218 | 231 | | |
219 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
220 | 237 | | |
221 | 238 | | |
222 | 239 | | |
223 | | - | |
224 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
225 | 243 | | |
226 | 244 | | |
227 | 245 | | |
228 | 246 | | |
229 | 247 | | |
230 | 248 | | |
231 | 249 | | |
| 250 | + | |
232 | 251 | | |
233 | 252 | | |
234 | 253 | | |
235 | | - | |
236 | | - | |
| 254 | + | |
| 255 | + | |
237 | 256 | | |
238 | | - | |
| 257 | + | |
239 | 258 | | |
240 | 259 | | |
241 | 260 | | |
242 | 261 | | |
243 | 262 | | |
244 | | - | |
| 263 | + | |
245 | 264 | | |
246 | 265 | | |
247 | 266 | | |
| |||
342 | 361 | | |
343 | 362 | | |
344 | 363 | | |
345 | | - | |
| 364 | + | |
| 365 | + | |
346 | 366 | | |
347 | 367 | | |
348 | | - | |
| 368 | + | |
349 | 369 | | |
350 | 370 | | |
351 | 371 | | |
| |||
0 commit comments