You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6cc3f97
Browse filesBrowse the repository at this point in the historyBrowse files
fix(metadata-protocol,rest,runtime): beside a disabled package, the bare read, /layers and /published serve the one enabled holder of a doc, view or other type the registry does not read by package (#34354)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbNTugWasvhTMrtCZiFGrZYK)_Fixes#34041
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:同名元数据由“一个启用包 + 一个停用包”同时发布时,不带包名的读取、`/layers` 和 `/published`
现在都返回启用包的条目。覆盖 doc、view、translation、hook
等所有“注册表不按包读取”的类型(object、action、package 除外)。
- 为什么改:ADR-0150 D3
规定停用的包不持有名字。原来这些类型按名字取第一层(元数据服务里最后注册的副本,或注册表的第一个组合项),如果取到的是停用包的,普通读取返回
404,`/layers` 甚至把停用包的正文当作 effective 返回。
- 风险与回滚:只在“名字的持有者里有停用包、且只剩一个启用持有者”时改变答案。两个启用持有者照旧 409,全部停用照旧 404,action
与保存门不变。回滚即 revert 本 PR。
-
先看:`packages/metadata-protocol/src/protocol-meta-item-face.ts`(`servedHolderAddressOf`
去掉 readsByPackage 门槛,新增
`SERVED_HOLDER_JUDGED_ELSEWHERE`);`packages/rest/src/meta-item-history-routes.ts`
与 `packages/runtime/src/domains/meta.ts` 中 `/published` 的 mixed-owner
分支(同一条件,两处孪生)。
- 两分钟验证:`pnpm --filter @objectstack/runtime exec vitest run
src/domains/meta-disabled-holder-artifact-door.test.ts`,预期 23
passed,`[#34041]` 组在两种注册顺序下全部为绿。
- 需要你做的:无,席位落地。
## What changes
ADR-0150 D3 says a disabled package holds no name. For a type the
registry reads by package, the read naming no package already took the
served holder's address when a disabled package also holds the name
(`servedHolderAddressOf`, #32183). Every other type read the layer it
finds by name alone. That layer is the metadata service's copy, which
belongs to the package registered last, or else the registry's first
composite. Either one could be the disabled holder's. The face then
withheld it, so the plain read answered 404, and `/layers` served the
disabled body as `effective`.
- **`servedHolderAddressOf`** (`protocol-meta-item-face.ts`) no longer
requires `readsByPackage(type)`. It re-addresses every type except those
`SERVED_HOLDER_JUDGED_ELSEWHERE` names: `object` (one owner, refused
with its disabled package), `action` (its bare judge
`judgeBareActionRead` already serves the one enabled holder; measured
unchanged) and `package`. Read at the served holder's address, the read
is that holder's exact read, which never answers another package's
service copy (`serviceCopyOfAnotherPackage`, #34241). Its callers in
`protocol-meta-item-reads.ts` and `protocol-meta-layered-reads.ts`
needed no edit.
- **The `/published` door twins**
(`rest/src/meta-item-history-routes.ts`, `runtime/src/domains/meta.ts`):
the mixed-owner arm's `readsByPackage(type) === true` conjunct becomes
"type is not `action`" (`object` and `package` are excluded there
already). Without this, once the plain read served the enabled holder,
the snapshot exit served the metadata service's `getPublished` copy,
which is the disabled holder's body (measured: 200 `beta doc` on both
transports). The claim amendment (comment 6908475841) widened the file
surface to these two files.
## FROM → TO
One enabled holder (alpha) and one disabled holder (beta) of a name, for
each of `doc`, `view`, `translation`, `field`, `seed`, `datasource`,
`external_catalog`, `object_extension`, `hook`, `job`, `sharing_rule`,
`queue` and `assignment_rule`:
| Door | FROM (main) | TO |
|---|---|---|
| bare `GET /meta/TYPE/NAME`, when the layer read by name is beta's (the
service copy with beta registered last, or the registry's first
composite with beta registered first and no copy) | 404 | 200, alpha's
item |
| bare `/layers`, same states | 200, `effective` = beta's body | 200,
`effective` = alpha's item |
| bare `/published` (doc, composed rig, beta registered last) | 404 |
200, alpha's doc |
| the same doors when the layer read by name is already alpha's | 200,
alpha | unchanged |
| two enabled holders of a doc | 409 naming both | unchanged |
| both holders disabled | 404 | unchanged |
| `action`, `object`, `package`; a name no disabled package holds | as
on main | unchanged |
| bare `PUT /meta/doc/NAME` beside a disabled holder | 403
`NOT_OVERRIDABLE` (sealed) | unchanged |
Nothing served becomes refused, so `Clause-②: no` holds as claimed. No
authorable key, value or type moves, so `Metadata-protocol: none` holds
too.
## Tests
- `packages/objectql/src/package-scoped-exact-qualifier.test.ts`, a new
top-level describe `[#34041]` beside the #34040 type enumeration. It
holds an enumeration pin (every type the registry does not read by
package is pinned, one-holder, or judged elsewhere). Per type, in both
orders, with beta disabled, the plain read and `/layers` serve alpha in
each of three service states (no copy, alpha's copy, beta's copy), and
with both disabled there is no item. CONTROLs: a doc with two enabled
holders is refused 409 naming both, before and after a disable and
re-enable; an action is unchanged; a view with no disabled holder reads
as before.
-
`packages/runtime/src/domains/meta-disabled-holder-artifact-door.test.ts`,
a new `describe.each` `[#34041]` on the composed artifact rig (the
`MetadataPlugin` artifact door plus `AppPlugin`), on both transports and
in both orders. With beta disabled, the plain read, `/layers` (code and
effective) and `/published` serve `alpha doc` and never `# beta`.
CONTROL: with both disabled, every door answers 404; with both
re-enabled, every door refuses 409 naming both.
<details><summary>Reverse verification against origin/main 01598d9
(before the fix)</summary>
- objectql describe: `Tests 28 failed | 4 passed`. Example, view with
beta registered last and the service keeping beta's copy: Received
`[undefined, "beta view"]`, Expected `["alpha view", "alpha view"]`.
- Composed rig: the dispatcher plain read Received `404 undefined`,
Expected `200 "alpha doc"`.
- With only the face fix (before the door half): the rig's only red rows
were `dispatcher doc/shared_doc/published` and `rest
doc/shared_doc/published`, Received `200 "beta doc"`.
</details>
<details><summary>Ablation (ablation-replace; restore blob equals HEAD;
git diff HEAD empty; tree clean)</summary>
- Leg 1, the `readsByPackage` gate put back in `servedHolderAddressOf`
(metadata-protocol resolves through `dist/` in both suites, so it was
rebuilt; `ablation-dist-preflight` found the marker in 2 built files,
and after restore and rebuild `--absent` found it in none of 24).
objectql: `Tests 28 failed | 352 passed (380)`, e.g. Received
`undefined, "beta view"`. Rig: `1 failed | 22 passed`, with all six door
rows red. The first attempt at this leg was a no-op: the build folded
its string marker away, preflight reported it ABSENT, and nothing ran.
It was redone with a marker that reaches `dist/`.
- Leg 2, the gate put back in the RestServer `/published` arm (runtime
aliases `@objectstack/rest` to `src`): rig `1 failed | 22 passed`, the
only red row `rest doc/shared_doc/published`, Received `"beta doc"`.
- Leg 3, the gate put back in the dispatcher `/published` arm: rig `1
failed | 22 passed`, the only red row `dispatcher
doc/shared_doc/published`, Received `"beta doc"`.
</details>
## Acceptance notes
- `servedPackagelessSaveAddress` (`protocol-save.ts`, not edited) asks
the same judgment. For a doc beside a disabled holder, the bare save is
refused 403 `NOT_OVERRIDABLE` (a sealed managed package) both before and
after this change, in both orders, so the save is unchanged. This was
measured with a scratch probe on the composed rig.
- The light harness also shows the second state on main: with no service
copy and the disabled holder registered first, the registry's first
composite was the disabled body. The fix covers that state too, and the
pin enumerates it.
## Verification
- **Head 662c7c9** (origin/main 35c9a30 merged in, which brings
#33995's edits to the same face and door files; merge-tree was clean and
the merge had no conflict): rebuilt; `typecheck` exit 0 for
metadata-protocol, objectql, rest and runtime. **NOT MEASURED at this
head**: the suites, the two pin files and the derived gates. Reason: a
maintainer order to hand off now stopped that run, so the readings below
are from the previous head. The next seat (or CI) re-runs them.
<details><summary>Suites, typecheck and gates at the previous head
42610dc (origin/main 3b1307e merged in), under the shared verify
lock</summary>
Touched packages and their direct dependents:
- metadata-protocol: Test Files 345 passed, 9 skipped (354); Tests 22956
passed, 45 skipped.
- objectql: Test Files 599 passed (599); Tests 13398 passed.
- rest: Test Files 413 passed (413); Tests 8497 passed, 350 skipped.
- runtime: Test Files 607 passed (607); Tests 11106 passed, 19 skipped.
- cli `--project unit`: 421 passed and 2 failed on the first run,
because `packages/cli` itself was not built. After `pnpm --filter
@objectstack/cli build`, those 2 files pass (29 tests).
- client: 812 tests passed. cloud-connection: 1227 passed.
plugin-approvals: 1652 passed. plugin-email: 1020 passed.
- plugin-security: 6723 passed. service-automation: 4040 passed.
service-messaging: 991 passed. service-package: 144 passed.
- verify: 439 passed. organizations: 252 passed. plugin-auth: 5646
passed. plugin-dev: 89 passed. hono: 258 passed. http-conformance: 292
passed.
The rest:
- `typecheck`: metadata-protocol, objectql, rest and runtime all exit 0.
- `check:type-check-debt`: exit 0.
- eslint `--no-inline-config` on the 5 touched source and test files:
exit 0.
- `dispatch-gates --commands`: 73 derived, all 73 run. 72 exit 0.
`check:query-options-erasure` exit 0, on a rerun after a 300 s local
timeout under contention. `check:dual-build-cjs-loads` answered
PREREQUISITE NOT MET: it needs every package built, so it is NOT
MEASURED locally and is left to CI.
- `--ran` reconciliation: 73 derived, 73 run, 0 UNRUN.
- `git merge-tree --write-tree`: clean against origin/main,
origin/claude/area-E1-32849-nomember (884050f, then 013010a) and
PR #33995 (0f5f95d, the one open PR that touched these files; it has
since merged). PR #33995 first conflicted on an adjacent insertion in
`protocol-meta-item-face.ts`. Moving the new constant below
`servedHolderAddressOf` made it clean.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jTkZnXtRhuEiiyidvJ)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(metadata-protocol,rest,runtime): beside a disabled package, the read naming no package, `/layers` and `/published` serve the one enabled holder of a `doc`, `view` or any other type the registry does not read by package
8
+
9
+
Clause-②: no
10
+
Metadata-protocol: none
11
+
12
+
A disabled package holds no name (ADR-0150 D3). Take a name that one enabled and one disabled package both ship. For a type the registry reads by package, the bare read (`GET /api/v1/meta/TYPE/NAME`), `/layers` and `/published` already served the enabled holder. For every other type they read the layer they find by name alone. That layer is the metadata service's copy, which belongs to the package registered last, or else the registry's first composite. Either one could be the disabled holder's.
13
+
14
+
- The plain read answered `404` (the disabled body, withheld) although an enabled package ships the name. FROM `404`, TO the enabled holder's item.
15
+
-`/layers` served the disabled holder's body as `effective`. FROM that body, TO the enabled holder's item.
16
+
-`/published` answered `404` on both transports. FROM `404`, TO the enabled holder's item.
17
+
18
+
This covers `doc`, `view`, `translation`, `field`, `seed`, `datasource`, `external_catalog`, `object_extension`, `hook`, `job`, `sharing_rule`, `queue` and `assignment_rule`. `object`, `action` and `package` are not changed: an `action`'s own bare judge already serves the enabled holder.
19
+
20
+
Unchanged: no answer that was served becomes refused. Two enabled holders of a doc are still refused `409` naming both. A name only disabled packages hold still answers `404`. A name no disabled package holds reads as before. The bare save door is unchanged.
Copy file name to clipboardExpand all lines: packages/objectql/src/package-scoped-exact-qualifier.test.ts
+94Lines changed: 94 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -830,6 +830,100 @@ describe('[#34040] the exact read never serves the service\'s copy of another pa
830
830
});
831
831
});
832
832
833
+
/**
834
+
* [#34041, ADR-0150 D3] A disabled package holds no name, of any type: beside
835
+
* one enabled holder, the read naming no package serves that holder's item, and
836
+
* so does `/layers`. For a type the registry does not read by package, the read
837
+
* reached the layer it reads by name alone (the service's copy, kept for the
838
+
* package registered last, else the registry's first composite) and the face
839
+
* withheld it when it was the disabled holder's.
840
+
*
841
+
* BASE (measured before the fix, origin/main 01598d93, this fixture): with
842
+
* beta disabled, every type below answered no item whenever that layer was
843
+
* beta's (the service keeping beta's copy, or no service copy and beta
844
+
* registered first), and `/layers` served beta's body as `effective`.
845
+
*/
846
+
describe('[#34041] the read naming no package serves the one enabled holder beside a disabled one, for every type the registry does not read by package',()=>{
0 commit comments