Repository navigation
Commit 01598d9
fix(metadata-protocol): an exact
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbBePzY6g11h3hyWk5ud4vWy)_
Fixes #34040
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:带 `?package=X` 的精确读取(doc、view、translation
等精确限定符不判定的类型),不再把元数据服务里“另一个包”的副本当作 X 的内容返回,而是改由注册表返回 X 自己的条目。
- 为什么改:元数据服务对这些类型只按名字保存(后注册的包覆盖先注册的),两个包发布同名 doc 时,`?package=先注册的包`
会拿到后注册包的正文,还套着 X 的包信封(ADR-0150 D3:精确地址应回答该持有者)。Console
文档阅读器的“选择包”链接正是按包名读取,修复后链接打开的才是对应包的文档。
- 风险与回滚:只在“精确地址 + 服务副本带有另一个已安装包的戳”时改变行为;单一持有者、无包戳副本、对象类型、不带包名的读取均不变。回滚即
revert 本 PR。
-
先看:`packages/metadata-protocol/src/protocol-meta-item-reads.ts`(`serviceCopyOfAnotherPackage`
与 step 2 / step 3
的两处改动)、`packages/runtime/src/domains/meta-disabled-holder-artifact-door.test.ts`(组合装配下的
doc 钉子与 item 4
钉子)、`packages/objectql/src/package-scoped-exact-qualifier.test.ts`(按类型枚举的钉子)。
- 两分钟验证:`pnpm --filter @objectstack/runtime exec vitest run
--maxWorkers=2
src/domains/meta-disabled-holder-artifact-door.test.ts`,预期 17 个测试全部通过,其中
`[#34040]` 组在两种注册顺序下 `?package=alpha` 返回 alpha doc、`?package=beta` 返回
beta doc。
- 需要你做的:无,席位落地。
## What changes
`readMetaItem` step 2 asked the MetadataService before the registry. For
a type the service keeps by name alone, its copy is the item of the
package registered last. At an exact address (`?package=X`) of a type
the exact qualifier (ADR-0150 D5) does not judge, nothing below the
layers replaced that copy, so X's address answered the other package's
body, wrapped in X's own envelope (`_packageId: X`).
- **Step 2** declines the service's copy at such an address when it is
stamped with another installed package: one that is not X, not a
customization pair of X, and not a package X is the pair of
(`serviceCopyOfAnotherPackage`). A copy bound to no package, a copy
stamped X, a stamp the registry does not know, and `object` (one owner,
read by `getObject`) are served as before.
- **Step 3**, after such a decline, reads the registry's package slot
for X (`getPackageScopedItem`) before `getItem`. `getItem` answers the
bare slot first, so a package-less entry of a name two packages hold
would answer at the address of the package registered first, and the
package registered last would answer its own copy. When X holds no item
of the name, `getItem` answers as before.
- The bare doc refusal's docblock (PR #34036) no longer says a
package-less bare entry is served: the item-4 pins measure that the
layers serve the holder's service copy (registered last) instead. The
docblock now says so. The answer itself is a loose end (below), not
changed here.
The family is enumerated in one pin. Every declared metadata type the
registry does not read by package is either covered by the exact
qualifier (`action`, `hook`, `job`, `sharing_rule`, `queue`,
`assignment_rule`: already right, pinned as such), outside it and fixed
here (`doc`, `view`, `translation`, `field`, `seed`, `datasource`,
`external_catalog`, `object_extension`), one-holder (`position`,
`capability`: a second holder is refused), or not judged (`object`). A
new type fails the enumeration until it is placed.
## FROM → TO
| Read | FROM (main) | TO |
|---|---|---|
| `GET /meta/doc/NAME?package=X`, X and Y ship NAME, Y registered last
(dispatcher and REST) | 200, Y's doc body under X's envelope
(`_packageId: X`) | 200, X's doc |
| same, X registered last | 200, X's doc | 200, X's doc (unchanged) |
| `?package=X` of `view`, `translation`, `field`, `seed`, `datasource`,
`external_catalog`, `object_extension`, two holders, service keeping Y's
copy | 200, Y's body | 200, X's body |
| `?package=X` of a doc beside a stamp-less bare entry or a hydrated
package-less row, X registered first | 200, Y's doc | 200, X's doc |
| `?package=X` of a covered type (`action`, `hook`, `job`,
`sharing_rule`, `queue`, `assignment_rule`) | 200, X's body | unchanged
|
| one holder; a service copy bound to no package; a copy stamped X;
`object`; any read naming no package | as on main | unchanged |
| `?package=X` of a doc only Y ships | 200, Y's doc | unchanged (see
Acceptance notes) |
No served answer becomes a refusal or a 404, so `Clause-②: no` holds as
claimed.
## Tests
- `packages/objectql/src/package-scoped-exact-qualifier.test.ts`: a new
top-level describe after the `#32069` one. The enumeration pin, then one
case per type outside one-holder and `object`: both holders, the service
keeping each holder's copy in turn, `?package=` of each holder answers
its own body. CONTROLs: the service's copy at its own holder, and a copy
bound to no package at any address, are served. One-holder types refuse
a second holder.
-
`packages/runtime/src/domains/meta-disabled-holder-artifact-door.test.ts`
(the composed artifact rig: `MetadataPlugin` artifact door plus
`AppPlugin`, both transports). `bootArtifactKernel` takes a body
factory. New describes: the doc's exact address in both registration
orders, a one-holder CONTROL, and acceptance item 4. Item 4 pins three
things: the bare doc refusal (409 naming both) at the plain read,
`/layers` and `/published`; a package-less row with no registry copy is
still refused; and, measured and unresolved, a stamp-less bare entry and
a hydrated package-less row, where the bare doors serve the holder
registered last. Each item-4 state also pins that each exact address
reads its own doc.
## Acceptance notes
- **Loose end (item 4, measured):** with a stamp-less bare entry, or a
hydrated package-less doc row (stored row plus its
`sys_metadata`-stamped bare entry), beside two enabled holders, PR
#34036's refusal is exempted, but the layers do not serve the
package-less entry. The bare plain read and `/published` serve the
holder the MetadataService registered last. `/layers` reports the row as
`overlay` over that holder's `effective`. This is a registration-order
pick on a public door. It is pinned as measured, and the docblock is
corrected. Changing the answer is a behaviour change outside this card.
- **Open (cell C):** `?package=X` for a doc X does not ship but Y does
still answers Y's doc (the registry's first composite). Making it 404
would move 200 → 404, a narrowing the claim does not declare, so it is
not done here.
- `/layers?package=X` and the carry-forward code-layer read also ask
`readItemFromMetadataService(type, name, X)`
(`protocol-meta-layered-reads.ts`, `protocol-discovery-and-bases.ts`).
They are outside this card's file surface and were not measured here.
## Verification
All readings below are on head `32a489c698` (origin/main `dfb8ed3570`
merged in), unless a line names another head.
<details><summary>Suites and typechecks (head 32a489c, under
os-verify-lock)</summary>
- `pnpm --filter @objectstack/metadata-protocol test`: exit 0, Test
Files 344 passed, 9 skipped; Tests 22940 passed, 45 skipped.
- `pnpm --filter @objectstack/objectql test`: exit 0, Test Files 598
passed; Tests 13298 passed.
- `pnpm --filter @objectstack/rest test`: exit 0, Test Files 413 passed;
Tests 8473 passed, 332 skipped.
- `pnpm --filter @objectstack/runtime test`: exit 0, Test Files 605
passed; Tests 11081 passed, 19 skipped.
- `typecheck` of metadata-protocol, objectql and runtime: exit 0 each.
- Pin files alone: `package-scoped-exact-qualifier.test.ts` 342 passed;
`meta-disabled-holder-artifact-door.test.ts` 17 passed.
- `eslint --no-inline-config` on the three touched source files: exit 0.
The repo-wide `pnpm lint` is left to CI.
</details>
<details><summary>Ablations (each through scripts/ablation-replace.mjs,
metadata-protocol rebuilt, marker proved in dist/ by
ablation-dist-preflight, restore proved by blob equal to HEAD and an
empty git diff HEAD)</summary>
- **A: step 2's decline removed** (head 9ea243e). Red: the objectql
enumeration, 8 failed (`doc`, `view`, `translation`, `field`, `seed`,
`datasource`, `external_catalog`, `object_extension`), for example `doc
at com.acme.beta, the service keeping com.acme.alpha's: expected 'alpha
doc' to be 'beta doc'`. The covered types stayed green, which confirms
they were already right. The runtime rig went red on every exact-address
pin, both orders and both transports. The FROM answer it shows is
`{"item":{"label":"beta doc","content":"#
beta","_packageId":"com.qa.alpha",...},"packageId":"com.qa.alpha"}`:
beta's body under alpha's envelope.
- **B: step 3's package-slot read removed** (head 9ea243e). Red: the
runtime rig's stamp-less and hydrated states, at the address of the
package registered first, which answered the package-less entry
(`"label":"bare entry"` / `"environment doc"` under `_packageId:
com.qa.alpha`). The objectql enumeration stayed green: it lays no
bare-slot entry.
- **C: PR #34036's bare doc refusal call removed** (head 5783d98).
Red: the item-4 refusal pins in both orders. The plain read answered 200
with the holder registered last (`"label":"beta doc"`), where 409 is
pinned.
</details>
<details><summary>Gates</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 69 families. 67 were run locally on
this head, each exit 0. `--ran` reconciliation: 69 derived, 67 run, 0
NOT-MEASURED, 2 UNRUN. The two are `check:dual-build-cjs-loads` and
`check:type-check-debt`, left to CI (the second needs the verify lock).
- `git merge-tree` against origin/main `dfb8ed3570` and fold PR #33995's
head `69f4887137`: clean.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01QsR2jUcj2x2Wr4UErwBi12
---------
Co-authored-by: Claude <noreply@anthropic.com>?package= read never answers another package's metadata-service copy of a doc, view or other type the exact qualifier does not judge (#34241)1 parent 43dd565 commit 01598d9
4 files changed
Lines changed: 336 additions & 14 deletions
File tree
- .changeset
- packages
- metadata-protocol/src
- objectql/src
- runtime/src/domains
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
324 | 325 | | |
325 | 326 | | |
326 | 327 | | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
332 | 337 | | |
333 | 338 | | |
334 | 339 | | |
| |||
393 | 398 | | |
394 | 399 | | |
395 | 400 | | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
396 | 437 | | |
397 | 438 | | |
398 | 439 | | |
| |||
1105 | 1146 | | |
1106 | 1147 | | |
1107 | 1148 | | |
| 1149 | + | |
| 1150 | + | |
1108 | 1151 | | |
1109 | 1152 | | |
1110 | 1153 | | |
| |||
1119 | 1162 | | |
1120 | 1163 | | |
1121 | 1164 | | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
1122 | 1171 | | |
1123 | 1172 | | |
1124 | | - | |
| 1173 | + | |
| 1174 | + | |
1125 | 1175 | | |
1126 | 1176 | | |
1127 | 1177 | | |
| |||
1185 | 1235 | | |
1186 | 1236 | | |
1187 | 1237 | | |
1188 | | - | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
1189 | 1252 | | |
1190 | 1253 | | |
1191 | 1254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
745 | 746 | | |
746 | 747 | | |
747 | 748 | | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
748 | 833 | | |
749 | 834 | | |
750 | 835 | | |
| |||
0 commit comments