Repository navigation
Commit 69c9f7c
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XUSbzmMRfCQ13hL4Jffkmqp)_
Fixes #28831
Clause-②: no
Metadata-protocol: none
Skills-docs: none — no file under `skills/**` teaches the per-package
layer or its envelope (0 hits for `getMetaItemsPerPackage` and
`per-package layer`).
## 维护者速读
-
**改了什么**:「按包分层」读取(`getMetaItemsPerPackage`,包导出和匿名表单撤回层用它)里,一个包存在基础包条目名下的行,不再借用基础包的
`_packageId` / `_packageVersion` / `_provenance`。依赖包的行、`.custom`
配对包未声明覆盖的行,现在都标自己的包;配对包**声明了**覆盖的行照旧标基础包。
-
**为什么改**:信封嫁接(#22024)在该包没有同名制品时,制品查找会退回到第一个发布该名字的代码包,于是把别人的行标成基础包的(#28828
合同审查发现)。
- **风险与回滚**:低。实测 CRM、showcase 新启动 0 行,`packages/qa/**` 0 行;导出会去掉所有 `_`
开头的键,表单撤回按视图名判断,两个读者都不读这个标记,所以没有公开门的答复变化。共享的制品查找(`registry.getArtifactItem`
的回退)对其它调用者不变。回滚即 revert。
- **先看**:`packages/metadata-protocol/src/protocol.ts` 的
`perPackageLayerEnvelope` 和 `readFlattenedMetaItems` 里 `[#28831]`
那一处;`packages/objectql/src/protocol-per-package-layer-provenance.test.ts`。
- **两分钟验证**:先 `pnpm --filter @objectstack/metadata-protocol build`,再
`pnpm --filter @objectstack/objectql exec vitest run
src/protocol-per-package-layer-provenance.test.ts`,预期 `Tests 4 passed
(4)`(main 上 2 红,2 条对照两边都绿)。
- **需要你做的**:无,席位落地。
## What changes
- **The graft on the per-package layer** (`readFlattenedMetaItems`,
`layer: 'per-package'`). After the artifact is looked up at the item's
package (`envelopePackageId`, unchanged), `perPackageLayerEnvelope`
keeps it only when it is that package's OWN artifact (`_packageId` equal
to the item's bound package). Otherwise the item wears no artifact
envelope and keeps its own binding.
- **The one exception keeps today's stamp:** a stored row of the item's
package that is the served override of the artifact's package. It is
judged by `isServedOverrideRowOf` on the row's own `package_id` (never a
body `_packageId`), at the item's bundle member, over the active rows
the read already holds for the lock (`lockRowsByName`).
- **An item bound to no package** keeps the lookup's answer, as before
(a package-less row standing in for a base's slot is seated with the
base's id by the merge, so it matches its own package anyway).
- **Not touched:** `lookupArtifactItem` / `registry.getArtifactItem` and
their fallback for every other caller; the effective list, the by-name
read and the execution list (the new call is inside `layer ===
'per-package'` only); the two readers. No new error code, no
`packages/spec/**`, no new gate.
- **Changeset** `.changeset/28831-per-package-layer-own-envelope.md`:
`patch` on `@objectstack/metadata-protocol`, both declaration lines.
**Why `Clause-②: no`.** Measured through the real doors (step 1 below):
the package export drops every `_`-prefixed key before it answers, and
the anonymous form doors' withdrawal judgement
(`anonymousFormIntakeWithdrawnIn`) matches by view name and reads no
stamp. So the stamp this changes is on an internal layer only, and no
public door's served answer moves.
## Tests
New
`packages/objectql/src/protocol-per-package-layer-provenance.test.ts`, 4
tests, on the real protocol over the real `ObjectQL` engine and an
in-memory driver (the harness of #28828's
`protocol-bundle-member-base-address.test.ts`, whose view control it
sits beside). Legacy rows are laid down as stored before the override
write gate, the way that control does. Each case asserts `[columns,
_packageId, _packageVersion, _provenance]` row by row.
- **The withdrawal layer's read (unscoped):** the base's view reads
`com.example.showcase · 1.0.0 · package`; a dependent's row under the
same name reads its own package with no artifact envelope; the pair's
undeclared row reads the pair.
- **CONTROL:** the pair's declared override keeps the base's envelope,
beside the base's own view.
- **The export's read (scoped to each package):** the dependent's layer
reads the dependent, the pair's reads the pair, the base's reads the
base.
- **CONTROL:** the pair's scoped layer keeps the base's envelope on its
declared override.
- **The form withdrawal leg at the door** is not pinned separately: the
door reaches the layer (step 1: a dependent's withdrawal closes
`/forms/contact-us`, 200 → 404), but its answer reads no stamp, so no
door assertion can be red on base. The layer read it asks is the first
case.
<details><summary>Red on base, green on head; ablation</summary>
- **Base** (`protocol.ts` from `1920e480`, the new file at head,
metadata-protocol rebuilt): `Tests 2 failed | 2 passed (4)`. Both reds
are the dependent's and the pair's rows reading `com.example.showcase ·
1.0.0 · package`. The two declared-override controls are green both
ways. Restored with `git checkout HEAD -- protocol.ts`, `git diff HEAD`
empty, rebuilt.
- **Head:** `Tests 4 passed (4)`.
- **Ablation** via `node scripts/ablation-replace.mjs` from committed
HEAD: the graft's condition `if (layer === 'per-package') {` replaced
with `if (layer === 'per-package' && (globalThis as any).ABLATE_28831
=== 1) {` (the fallback restored), anchor 1 → 0, blob `17bb3db36eed` →
`393a0475ef93`; metadata-protocol rebuilt; `Tests 2 failed | 2 passed
(4)`, the same two. Restored: blob == HEAD `17bb3db36eed`, `git diff
HEAD` empty.
</details>
## Acceptance notes
- **Step 1 measurement:** `pm-orders/server/28831-step1-measurement.md`
in the project files. A temporary census probe at the graft (never
committed), run over the full dogfood battery and the objectql, rest,
runtime and metadata-protocol suites: fresh CRM and showcase boots 0
rows, `packages/qa/**` seed sites 0 rows, and 3 unit-test fixtures that
lay legacy rows down on purpose. No `object` item reached it. No reader
depends on the base's stamp, so the order's stop condition did not hold.
- **The export leg is pinned at the read the export asks**
(`getMetaItemsPerPackage({ type, packageId })`), not at the door: the
door's manifest carries no `_` key, so its body is the same on base and
head.
- **A draft preview** (`previewDrafts`) on the per-package layer is not
covered: the exception reads active rows. Neither reader asks for
drafts.
## Verification
All readings at head `c7b62f42` (the fix `b7f9b13e`, changeset
`533db7df`, merged once with `origin/main` `7f4cbc9d`, a clean merge).
Full `pnpm turbo run build --concurrency=2` at the head: 118/118.
<details><summary>Package suites, typecheck, lint</summary>
- `@objectstack/metadata-protocol` test: `Tests 22093 passed | 26
skipped`, lock VERDICT command-exit 0.
- `@objectstack/objectql` test: `Tests 10015 passed`, command-exit 0.
- `@objectstack/rest` test: `Tests 6920 passed | 332 skipped`,
command-exit 0.
- `@objectstack/runtime` test: `Tests 8252 passed | 19 skipped`,
command-exit 0.
- `typecheck` of metadata-protocol and objectql (objectql's test layer
included): exit 0.
- `eslint --no-inline-config` on the two touched source files: exit 0;
the repo's `pnpm lint` command scoped to `packages/metadata-protocol`
and `packages/objectql`: exit 0.
</details>
<details><summary>Derived gates (`dispatch-gates.mjs --commands`, 62
families)</summary>
- All 62 exit 0 at `c7b62f42`; `dispatch-gates --ran`: `62 derived, 62
run, 0 NOT-MEASURED, 0 UNRUN`. Record:
`pm-orders/server/28831-gates-ran.txt`.
- `check:type-check-debt`: OK, `--re-measure: OK`.
- Repo-wide `pnpm lint` and the CI-only families are CI's; see the PR's
check-runs.
</details>
<details><summary>Full dogfood battery (not owed: no `!` and no
narrowing arm; run anyway)</summary>
- Head `c7b62f42`: `Test Files 4 failed | 376 passed | 3 skipped (383)`,
`Tests 4 failed | 3123 passed | 28 skipped (3155)`.
- **The 4 failures are main's, not this PR's.** They are the 18.0
upgrade-harness files `audit-key-material`, `audit-mail-bodies`,
`identity-mail-read-gate` and `upgrade-18x-harness`. Re-run alone on the
head: the same 4 red. Re-run with `protocol.ts` checked out from
`origin/main` and metadata-protocol rebuilt: the same 4 red (restored,
`git diff HEAD` empty). `main`'s own push run at `7f4cbc9d` (CI run
`41366661242`) has every Dogfood Regression Gate shard red, with
`identity-mail-read-gate` named in shard 2's log.
- The battery was green (3121 passed, 0 failed) at the pre-merge base
`1920e480` during the step 1 census run.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5mTYb1BTJNRqf3bdJ8)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 45efba2 commit 69c9f7c
3 files changed
Lines changed: 355 additions & 1 deletion
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 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2595 | 2595 | | |
2596 | 2596 | | |
2597 | 2597 | | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
| 2630 | + | |
| 2631 | + | |
| 2632 | + | |
| 2633 | + | |
| 2634 | + | |
| 2635 | + | |
| 2636 | + | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
| 2643 | + | |
| 2644 | + | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + | |
2598 | 2648 | | |
2599 | 2649 | | |
2600 | 2650 | | |
| |||
10793 | 10843 | | |
10794 | 10844 | | |
10795 | 10845 | | |
10796 | | - | |
| 10846 | + | |
| 10847 | + | |
| 10848 | + | |
| 10849 | + | |
| 10850 | + | |
| 10851 | + | |
| 10852 | + | |
| 10853 | + | |
| 10854 | + | |
10797 | 10855 | | |
10798 | 10856 | | |
10799 | 10857 | | |
| |||
| 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 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 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 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
0 commit comments