Repository navigation
Commit 5055b10
fix(metadata-protocol): a dependent package's same-named row no longer replaces the base package's item on the read naming no package (#28304)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X5bnPyhuoRnXAyyEN1Y3CwG)_
Part of #28238
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么:** 不指定包读取一个视图(以及分层读取的
effective)时,若某个代码包自带这个名字,就从该代码包取内容:它自己的存储行,否则无包覆盖行(Setup
写的那种,仍然优先于代码),否则代码原件。依赖包用同名存的那一行不再顶替基础包。
- **为什么改:** showcase 实测:依赖包 `com.default.acme-custom` 存了 2 列的
`showcase_task.default`,不指定包读取就答 2 列,还挂着基础包的 `_packageId`;Studio 按基础包读看到
7 列,用户看到 2 列。
- **风险与回滚:** 只改读取取内容的地址;不指定包的保存、删除和读取返回的 `version`
仍落在依赖包那一行(写地址不动,已钉住)。回滚即还原 `packagelessContentPackage` 的两个调用点。
- **先看:** `packages/metadata-protocol/src/protocol-environment-rows.ts`
的 `packagelessContentPackage`;`protocol.ts` 里 `readMetaItem` 的
`contentPackageId` 一段;新测试
`packages/objectql/src/protocol-packageless-read-dependent-package.test.ts`。
- **两分钟验证:** `pnpm --filter @objectstack/metadata-protocol build && pnpm
--filter @objectstack/objectql exec vitest run
src/protocol-packageless-read-dependent-package.test.ts`,应见 5 passed。
- **需要你做的:** 卡片还差一半没修:console 应用仍渲染 2
列,因为它读的是不带包的视图列表(每个包一条、同名取最后一条)。这一半要你在卡片的决策里拍板,本 PR 只修三个按名读取。
## What changes
The by-name read (`getMetaItem`) and the layered read
(`getMetaItemLayered`) that name no package now take their stored
content from `packagelessContentPackage` (new,
`protocol-environment-rows.ts`). It adds the code packages that ship the
name as candidates beside the stored rows' bindings:
- No code package ships the name, or the one stored binding is a package
that ships it: unchanged, the write address's package (#23291).
- Exactly one code package ships it: that package. Its own stored row,
else the package-unbound row, else the code item. A row bound to another
package is never served for it.
- Several ship it and no stored row is bound to one of them: `null`, the
package-unbound row alone, else the code item. Several ship it and a row
is bound to one: unchanged (`undefined`, best effort).
`readMetaItem` applies it to the active rows it already read;
`packagelessReadAddress` (the layered read's address) applies it after
`packagelessAddress`, and its host gains `shippedArtifactsOf`.
`packagelessAddress` itself is untouched, so the package-less save,
delete and the read's `version` resolve exactly as before. Three content
spreads now test `!== undefined`, so `null` reaches
`findServedOverlayRow` as the package-unbound row.
Files: `protocol-environment-rows.ts`, `protocol-lock-version-gates.ts`,
`protocol.ts` (the `readMetaItem` lines, the `packagelessReadAddress`
host and docblock, two spreads in `getMetaItem` and one in
`getMetaItemLayered`), the new test, a `patch` changeset.
## Tests
`packages/objectql/src/protocol-packageless-read-dependent-package.test.ts`,
over the real `ObjectQL` engine, its `SchemaRegistry` and an in-memory
driver. The dependent package is installed through the package door with
`dependencies: { com.example.showcase: '*' }`, and its row is written
through the draft save and the per-item publish naming it, as the card's
steps wrote it.
1. The card's three reads answer base / dependent / base (6 / 2 / 6
columns), the package-less answer carries `_packageId:
com.example.showcase`, the layered read's `effective` is the base's with
`overlay: null`, and the list scoped to the base serves the base's
columns.
2. The write address does not move: `packagelessAddress` still answers
the dependent package, a package-less save writes the dependent
package's row and mints no other, and the read naming no package still
serves the base.
3. CONTROL: a writable package's own item (a name no code package ships)
is served to the read naming no package, with its own `_packageId`
(#23291).
4. CONTROL: a package-unbound row wins over the code package on the read
naming no package and the read naming the base.
5. Beside the dependent package's row, the package-unbound row is what
the read naming no package and the layered read serve (the dependent
package's row was, before), and the read naming the dependent package
serves its own row.
<details><summary>Red on base 69ce01d: 3 failed, 1 passed (cases 1, 2,
5 red; 3 green; 4 added after)</summary>
The three production files written back to their base blobs,
`@objectstack/metadata-protocol` rebuilt, the pin file run (4 cases
then), then restored with `git checkout HEAD --` (`git diff HEAD` empty)
and rebuilt.
```
× the card's three steps answer base / dependent / base, and the layered read and the base's list agree
× the write address does not move: a save naming no package still writes the dependent package's row
× CONTROL: a package-unbound row still wins over the code package, beside the dependent package's row too
AssertionError: expected [ 'title', 'status' ] to deeply equal [ Array(6) ]
AssertionError: expected [ 'title' ] to deeply equal [ Array(6) ]
AssertionError: expected [ 'title', 'status' ] to deeply equal [ 'title', 'priority' ]
Tests 3 failed | 1 passed (4)
```
The third was named CONTROL then; the red showed it is a changed answer,
so it was split into the plain control (case 4) and case 5.
</details>
<details><summary>Ablation: the old one-shipper answer restored reds 3
of 5; the restore leg is green</summary>
`node scripts/ablation-replace.mjs` on `protocol-environment-rows.ts`,
anchor `if (shippers.size === 1) return [...shippers][0];` → `return
(globalThis as any).ABL28238 ?? (address.packageId ?? undefined);` (the
write address's package, as before). Anchor 1 → 0, blob `1a530197d936` →
`992e059d588a`; `ablation-dist-preflight` found the marker in
`dist/index.js` and `dist/index.cjs`.
```
× the card's three steps answer base / dependent / base, and the layered read and the base's list agree
× the write address does not move: a save naming no package still writes the dependent package's row
× beside the dependent package's row, the package-unbound row is what the read naming no package serves
Tests 3 failed | 2 passed (5)
ablation-replace: ok restored: blob == HEAD (1a53019) and `git diff HEAD` is empty
```
Restore leg: rebuild, `ablation-dist-preflight --absent` (marker absent
from all 24 built files), `Tests 5 passed (5)`.
</details>
<details><summary>Package suites</summary>
- `@objectstack/metadata-protocol`: `Test Files 284 passed | 4 skipped
(288)`, `Tests 21860 passed | 26 skipped`. Includes
`protocol.item-read-overlay-cache.test.ts`, `meta-overlay-cache.test.ts`
and `protocol.packageless-save-address.test.ts` (the #23291 / #23165 /
#23495 / #23715 pins).
- `@objectstack/objectql` (`--project local`): `Test Files 501 passed
(501)`, `Tests 9755 passed`.
- `typecheck` of both packages (objectql's includes
`check:test-typecheck`): exit 0.
- `eslint --no-inline-config` on `packages/metadata-protocol` and the
new test: exit 0.
</details>
## Acceptance notes
**The card's acceptance is half met.** Live on `examples/app-showcase`
(`pnpm dev -- --fresh`), the card's steps (the showcase's list now has 7
columns, not 6):
| | base 69ce01d | this branch |
|---|---|---|
| `?package=com.example.showcase` | 7 | 7 |
| `?package=com.default.acme-custom` | 2 | 2 |
| no `package` | **2** | **7** |
| `?layers=true` `effective` | 2 | 7 |
| `GET /meta/view?package=com.example.showcase` | one item, 7 | one
item, 7 |
| `GET /meta/view` (no package), items named `showcase_task.default` | 7
and 2, both `_packageId: com.example.showcase` | unchanged |
| `/_console/apps/com.example.showcase/showcase_task` headers
(Playwright) | Title, Status | **Title, Status** |
The app still renders 2. The console reads views only from the list
naming no package
(`ui/packages/app-shell/src/providers/MetadataProvider.tsx`,
`EAGER_TYPES` and `composeObjects(..., readType('view'))`), and
`mergeViewsIntoObjects` keys each view by name, so the last item of a
name wins: the dependent package's slot. That list keeps one slot per
package that holds a name by design (`readFlattenedMetaItems`, #21934:
the env-wide list "holds every package's body of a name"), and the
dependent package's slot wears the base's `_packageId` (the artifact
envelope `mergeArtifactProtection` grafts). Changing either is a choice
between a server list rule and a console merge rule, so it goes to the
card as a decision; this PR does not touch the list.
- **Write address unchanged, by order.** A package-less save of this
name still lands in the dependent package's row, and the package-less
read's `version` is `null` when no row is served (the base has no row).
So a package-less save followed by a package-less read does not read
back what it wrote, for this one shape. The epic's write gate (N-09:
undeclared same-name refused at publish) closes the shape at its source.
- **Declared override: nothing to pin.** `main` has no override
declaration yet (N-08), so "no change to declared overrides" holds
trivially.
- **Draft reads unchanged.** The strict draft read and `previewDrafts`
naming no package still follow the draft address
(`packagelessDraftAddress`), which is the write side.
- **A disabled base.** `shippedArtifactsOf` includes a disabled
package's artifact, so a disabled base's name now resolves to the base
on the package-less read, which the read then withholds as a disabled
package's item, where it used to serve the dependent package's row (read
from the code, not measured).
## Verification
<details><summary>Derived gates on 21fa3e7 (62 commands,
`dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`)</summary>
`dispatch-gates --ran`: 62 derived, 62 run, 0 NOT-MEASURED; every one
exit 0. `check-plugin-teardown-shape --self-test` first answered 3 (its
positive control commit was outside this shallow clone); after `git
fetch --depth=1 origin 621a487…` it answered 0, and that is the code
recorded.
```
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-adoption.mjs :: exit 0
node scripts/check-comment-mask-adoption.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-dts-emitted.mjs --self-test :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-engine-split-ratio.mjs --self-test :: exit 0
node scripts/check-issue-citations.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs --self-test :: exit 0
node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0
node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0
node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0
node scripts/docs-audit/check-affected-docs.mjs :: exit 0
node scripts/docs-audit/check-drift-comment.mjs :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:ci-filter-parity :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:doc-authoring :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:dts-closure :: exit 0
pnpm check:dual-build-cjs-loads :: exit 0
pnpm check:durability-log-level :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:error-status-conformance :: exit 0
pnpm check:filter-alias-parity :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:issue-citations :: exit 0
pnpm check:keyed-text-bounds :: exit 0
pnpm check:lean-entry-closure :: exit 0
pnpm check:logger-receiver-detach :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:objectql-double-limit :: exit 0
pnpm check:org-identifier :: exit 0
pnpm check:page-declaration-shape :: exit 0
pnpm check:platform-object-tenancy-census :: exit 0
pnpm check:pm-changeset-deadline-census :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:slot-lookup :: exit 0
pnpm check:sourcemap-no-sources-content :: exit 0
pnpm check:system-context-census :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
```
Not run locally, declared to CI: `test:repo` (Test Core), the
artifact-roster and wide-population families, the type-check lanes.
`pnpm lint` scoped to the two touched packages: exit 0.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5nQHuymasPwjX3mAr2)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent b1e1dcf commit 5055b10
5 files changed
Lines changed: 394 additions & 12 deletions
File tree
- .changeset
- packages
- metadata-protocol/src
- objectql/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 | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
| |||
159 | 164 | | |
160 | 165 | | |
161 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| 115 | + | |
114 | 116 | | |
115 | 117 | | |
116 | 118 | | |
| |||
437 | 439 | | |
438 | 440 | | |
439 | 441 | | |
440 | | - | |
441 | | - | |
442 | | - | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
443 | 446 | | |
444 | 447 | | |
445 | 448 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
438 | 438 | | |
439 | 439 | | |
440 | 440 | | |
441 | | - | |
| 441 | + | |
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
| |||
10844 | 10844 | | |
10845 | 10845 | | |
10846 | 10846 | | |
10847 | | - | |
10848 | | - | |
| 10847 | + | |
| 10848 | + | |
10849 | 10849 | | |
10850 | | - | |
| 10850 | + | |
10851 | 10851 | | |
10852 | | - | |
| 10852 | + | |
| 10853 | + | |
| 10854 | + | |
| 10855 | + | |
| 10856 | + | |
| 10857 | + | |
| 10858 | + | |
10853 | 10859 | | |
10854 | 10860 | | |
10855 | 10861 | | |
| |||
10868 | 10874 | | |
10869 | 10875 | | |
10870 | 10876 | | |
10871 | | - | |
| 10877 | + | |
10872 | 10878 | | |
10873 | 10879 | | |
10874 | 10880 | | |
| |||
10928 | 10934 | | |
10929 | 10935 | | |
10930 | 10936 | | |
10931 | | - | |
| 10937 | + | |
10932 | 10938 | | |
10933 | 10939 | | |
10934 | 10940 | | |
| |||
11559 | 11565 | | |
11560 | 11566 | | |
11561 | 11567 | | |
11562 | | - | |
| 11568 | + | |
11563 | 11569 | | |
11564 | 11570 | | |
11565 | 11571 | | |
| |||
17077 | 17083 | | |
17078 | 17084 | | |
17079 | 17085 | | |
| 17086 | + | |
| 17087 | + | |
| 17088 | + | |
| 17089 | + | |
| 17090 | + | |
| 17091 | + | |
17080 | 17092 | | |
17081 | | - | |
| 17093 | + | |
17082 | 17094 | | |
17083 | 17095 | | |
17084 | 17096 | | |
| 17097 | + | |
17085 | 17098 | | |
17086 | 17099 | | |
17087 | 17100 | | |
| |||
0 commit comments