Repository navigation
Commit bb17350
fix(metadata-protocol)!: the diff door refuses a bare two-holder name and compares one holder by ?package= (#34147)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbNTugWasvhTMrtCZiFGrZYK)_
Fixes #33308
Clause-②: yes (narrowing)
Metadata-protocol: added
Skills-docs: none — no skill under `skills/` names the diff door, and
the docs that do (`content/docs/api/client-sdk.mdx`,
`content/docs/permissions/system-context.mdx`,
`content/docs/ui/apps.mdx`) name the route without teaching how a name
two packages hold is addressed, so no sentence there turns false; the
generated API reference (`content/docs/references/api/protocol.mdx`)
carries the new `DiffMetaItemRequest` with its `packageId`.
Declaration note: the claim (6895872289) first read `Clause-②: no
(narrowing)`, amended on the card (6898947511). Beside
`Metadata-protocol: added` that pair is a `contradiction` in
`check-changeset-no-major.mjs` (`added-under-no`, exit 1), and this PR
widens a published request (the new `DiffMetaItemRequestSchema`, and the
door now takes `?package=`), so the lines above are #33193's (`yes
(narrowing)` + `added`), the precedent this card mirrors. Measured both
ways under Verification.
## 维护者速读
- 改了什么:同名流程等按包存储的条目由两个包各持一份时,版本对比(diff)不再把一家的版本和另一家的版本当成同一条记录来比;不带包的对比在
History 和回滚已拒绝的地方同样返回 409 并列出各家,带 `?package=`
只比较那一家的版本(默认的“当前版本”也取那一家的行)。非按包存储的类型带 `?package=` 返回 400。spec 新增
`DiffMetaItemRequestSchema` 声明这个接口的请求。
- 为什么改:实测 main 上不带包的 `GET /meta/flow/NAME/diff` 返回 200,把 beta 的 v2 和
alpha 的 v3 比成“同一条记录的修改”,管理员据此判断回滚会恢复什么,会选错。
- 风险与回滚:只有“两家同时持有同名”时行为才变(原来 200,现在 409);只有一家持有时不带包的对比与 main 完全一致。直接
revert 本 PR 即可,无数据迁移。
-
先看:`packages/metadata-protocol/src/protocol-diff-delete-load.ts`(`diffMetaItem`
接入 `historySlotOf`,默认 to/from
取本槽)、`packages/rest/src/meta-item-history-routes.ts`(diff 门接
`?package=`)、`packages/qa/dogfood/test/history-diff-two-holders-33308.dogfood.test.ts`。
- 两分钟验证:`pnpm --filter @objectstack/dogfood exec vitest run
--maxWorkers=1 test/history-diff-two-holders-33308.dogfood.test.ts`,9
条全绿。
- 需要你做的:无,席位落地(合入前需一次契约档复核)。
## What changes
**The rule is #33193's, not a second one.** `diffMetaItem`
(`protocol-diff-delete-load.ts`) asks `historySlotOf`
(`protocol-history-slots.ts`, unchanged) which row slot it addresses,
exactly as `historyMetaItem` and `rollbackMetaItem` do:
- **Bare**, a by-package name two or more row slots hold, or one the
bare plain read refuses (`resolveItem`, ADR-0150 D5), is refused `409
RESOURCE_CONFLICT` naming every holder (`details.candidates`) before any
version is read: the default range and a named one alike. A name one
slot holds diffs bare exactly as on `main`.
- **`?package=P`** compares P's slot only: the history rows are filtered
by the same predicate the history door reads (`isVersionOf`, now
exported from `sys-metadata-repository.ts`), so the default `from` side
is P's nearest earlier differing version and the default `to` side is
P's own active row (bound to P, or the package-less row for the
environment's slot), never the name's first active row. A named version
another holder owns, or one attributed to no package while two hold the
name, is refused `404 VERSION_NOT_FOUND` saying whose it is
(`versionOfAnotherSlotError`, one sentence shared with the rollback
door: "Nothing was compared." / "Nothing was restored.").
- **Every other type**: `?package=` is refused `400 VALIDATION_ERROR`
(`param: package`) by the protocol
(`refusePackageSelectorOutsideSlottedTypes`), never accepted and
dropped.
**Door** (`GET /meta/:type/:name/diff`): `package` joins
`META_ITEM_DIFF_PARAMS` and the door's repeat guard, is read through
`historyPackageSelector` / `metaItemPackageBinding` as the history door
reads it (`all` and empty name no package), and the refusal renders
`details.candidates` (`packageScopedCandidates`). The request is
compiled against the new declaration (`TransportScopedMetaRequest` of
`DiffMetaItemRequest`), and both bounds are read through
`DiffMetaItemRequestSchema.shape.fromVersion` / `toVersion`
(`z.number().int()`, the same whole number
`UNDECLARED_WHOLE_NUMBER_PARAM` read: no bound is refused that was
accepted before).
**Spec**: `DiffMetaItemRequestSchema` (`type`, `name`, `fromVersion`,
`toVersion`, `packageId` with the history doors'
`HISTORY_PACKAGE_SELECTOR_DESCRIPTION`), its `DiffMetaItemRequest` /
`DiffMetaItemRequestParsed` types, and the regenerated `api-surface`,
`authorable-surface`, `declaration-map`, `export-origins`,
`json-schema.manifest`, reference docs and strictness-ledger count.
**`protocol.ts`**: only the `diffMetaItem` request type (`packageId?:
string`) and its docblock (`@throws` for the 409, the cross-slot 404 and
the 400), edited after #33898 merged.
**Console**: no `ui/` file changes. `@object-ui/data-objectstack`'s
`MetadataClient.diff()` calls the door but nothing in `ui/` calls
`diff()` (the `engine.layers.diff` tab is the Layers view, not this
door), so there is no diff view to name the package in. See Acceptance
notes.
## Tests
-
`packages/qa/dogfood/test/history-diff-two-holders-33308.dogfood.test.ts`
(new, 9 cases, its own showcase boot with two `AppPlugin` holders and
their `.custom` pairs): bare two-holder 409 with candidates (default
range and named), their order and `kind` pinned at the wire; a package
that neither holds nor ships the name 409 naming the holders; the
environment's slot addressed through a package (the package-less row's
versions alone, its own active row the `to` side, beside a bound row
listed first); a name two packages ship one customized 409 as the bare
read, `?package=` default range and named range inside the slot, another
holder's version and an unattributed one 404, CONTROL one-holder bare
(and `?package=` of its holder answers the same), CONTROL M1 environment
versions, `?package=` on `view` 400 with the protocol's reason.
-
`packages/metadata-protocol/src/protocol-diff-history-slots.33308.test.ts`
(new, 10 cases): the facet against a fake host, each arm alone; the bare
refusal and the `not-held-by-qualifier` refusal read no table; the
environment's slot addressed through a package takes the package-less
row as its `to` side when a bound row is listed first.
- `packages/rest/src/meta-item-history-package-selector.test.ts`: a new
top-level `describe` for the diff door in the family's existing harness
(AGENTS.md, ruling record 6583487846): PRESERVATION under both bound
spellings, CONTROL `all`/empty, REFUSAL repeated `?package=`, 409
candidates, 400 through the real protocol.
`rest-server-meta-door-closed-sets.test.ts`: the measured-set pin takes
`package`.
- `packages/spec/src/api/protocol.test.ts`: a new top-level `describe`
for `DiffMetaItemRequestSchema` beside the rollback request's.
<details><summary>Before the fix (H1 measured on this boot, pre-fix
runtime): 6 of 7 red</summary>
```
× the bare diff of the two-holder name is refused 409 …
{"fromVersion":2,"toVersion":3,"changed":[{"path":"label","from":"com.qa.diff33308.beta.custom r1","to":"com.qa.diff33308.alpha.custom r2"}]}: expected 200 to be 409
× a name two packages ship, one customized, is refused bare … expected 200 to be 409
× ?package= diffs that holder's versions alone … "The \"package\" query parameter is not supported by this endpoint. … Supported parameters: from, fromVersion, to, toVersion.": expected 400 to be 200
× ?package= refuses another holder's version … expected 400 to be 404
× CONTROL: a name one holder holds … (the `?package=` half: unknown parameter)
× ?package= on a type not stored per package … expected '{"error":{"code":"VALIDATION_ERROR",…' to contain 'not stored per package'
Tests 6 failed | 1 passed (7)
```
The bare default range alone answered alpha's v3 against beta's v2: the
cross-holder diff the card measured, without even naming a version.
</details>
<details><summary>Ablations (each leg: `scripts/ablation-replace.mjs`
anchor x1 → x0 and blob change proved, package rebuilt,
`ablation-dist-preflight.mjs` exit 0 on the marker, dogfood file run,
restore to HEAD proved by blob and empty `git diff HEAD`, rebuilt,
preflight `--absent` exit 0)</summary>
| Leg | Mutation (forbidden behaviour put back) | Red |
|:--|:--|:--|
| A1 | `diffMetaItem` skips `historySlotOf` when no package is named
(`__ablate33308_A1`) | 2 of 7: `the bare diff of the two-holder name is
refused 409…`: `{"fromVersion":2,"toVersion":3,…"from":"…beta.custom
r1","to":"…alpha.custom r2"} expected 200 to be 409`; `a name two
packages ship, one customized…`: `expected 200 to be 409` |
| A2 | another slot's history row accepted (`isVersionOf` filter
bypassed, `__ablate33308_A2`) | 2 of 7: `?package= diffs that holder's
versions alone…`: `expected [ 2, 3 ] to deeply equal [ 1, 3 ]`;
`?package= refuses another holder's version…`:
`{"fromVersion":2,"toVersion":1,…} expected 200 to be 404` |
| A3 | the door accepts `?package=` and drops it (`__ablate33308_A3`,
rest) | 3 of 7: the two `?package=` cases `expected 409 to be 200` /
`expected 409 to be 404`; `?package= on a type not stored per package…`:
`{"type":"view",…"fromVersion":null,"toVersion":null,…} expected 200 to
be 400` |
| A4 | a package that neither holds nor ships the name answered an empty
slot instead of the refusal (`__ablate33308_A4`) | dogfood 1 of 9: `a
package that neither holds nor ships the name is refused 409…`:
`{"type":"flow",…"fromVersion":null,"toVersion":null,…} expected 200 to
be 409`; facet 1 of 10: `expected null to be an instance of
PackageScopedNameRefusedError` |
| A5 | the active-row match never takes the package-less row
(`__ablate33308_A5`) | dogfood 1 of 9 and facet 1 of 10, the
environment's-slot case: `expected [ null, null ] to deeply equal [ 1, 2
]`. The first try of this leg was refused by `ablation-replace.mjs` as a
no-op (the replacement contained the anchor, `anchor count moved 1 ->
1`), so it was rerun with an anchor-free replacement |
| A6 | the holders listed in reverse order (`__ablate33308_A6`,
`protocol-history-slots.ts`) | dogfood 3 of 9: the two-holder bare case,
the non-holder case and the environment's-slot case, e.g. `expected [ {
kind: 'environment' }, …(1) ] to deeply equal [ { kind: 'package', …(1)
}, …(1) ]`; facet 3 of 10 |
After the last leg of each round: preflight `--absent` exit 0, tree
clean. At `8ed07410cd` after A4 to A6: the dogfood file 9/9, the facet
file and `protocol-history-slots` tests 25/25.
</details>
## Acceptance notes
- **Console client, not called**: `MetadataClient.diff()`
(`ui/packages/data-objectstack/src/metadata-client.ts`) takes no
`packageId`; no `ui/` code calls it today, so nothing user-facing turns
wrong, but a consumer of `@object-ui/data-objectstack` calling it on a
two-holder name now gets the `409` with no way to name the holder. The
SDK's `client.meta.diffItem` (`packages/client/src/index.ts`) sends only
`from` and `to` as well, so an SDK caller's FROM / TO remedy is a raw
request (the changeset says so). The client half of both is decided not
planned: #33310, which names `meta.diffItem`, was closed as not planned
on 2026-11-15 (record 6897313072) and reopens on need. It is not a
pending follow-up of this PR.
- **A `doc` name two packages hold, at this door**: the changeset's
`400` on `package` for a type not stored per package does not describe a
`doc` name two enabled packages hold. That request is refused `409` with
or without `?package=`, as the doc reads are today. The remedy is #34190
(open), not this PR.
- **Out-of-surface file, and why**:
`packages/metadata-protocol/src/sys-metadata-repository.ts` (not on the
claim's File surface): `isVersionOf` is exported (the order names that
predicate as the one to reuse; it was module-private), and the
rollback's cross-slot `404` sentence moved into
`versionOfAnotherSlotError` so both doors say it once. The rollback's
message is unchanged (the same sentence, with "Nothing was restored."
passed as the outcome).
- **Test placement**: the dogfood and metadata-protocol pins are new
card-named files (the dogfood harness is `showcase-boot.ts`, shared by
every file; the facet pin has its own fake host); the REST and spec pins
are top-level `describe`s in the family's existing harness files, per
AGENTS.md (ruling record 6583487846).
- **Rulings on the surface, kept**: `meta-item-history-routes.ts`
5865708652 (letter B), 5856774816, 6787890900;
`protocol-diff-delete-load.ts` #8833 maintainer ruling (no
`historyUnavailable` key), commit 75e66fc Option B (diff raw, redact
emitted), #20378 / #20451 retriage answers (the from-side walk by this
diff's own equality, now inside the slot). No ruling, `maintainer` or
`⛔` line is edited or removed; one `⛔` comment added (never another
holder's version compared).
## Verification
**Regenerated head `624b7ff393`** (after a merge-queue red on
`scripts/root-index.test.ts`, a stated count stale against main):
`origin/main` `98a4449f87` merged through `scripts/pm/os-regen-merge.sh`
and the reference pages regenerated. The own non-generated patch-id is
`e97b7a9cd143` before and after; only
`content/docs/references/index.mdx` moves, now 1664 schemas.
`scripts/root-index.test.ts` 20/20, `check:generated` up to date, the
dogfood pin 9/9, CI 58 success / 10 skipped. Contract delta PASS
6907048910. The readings below are from `8ed07410cd`.
Head `8ed07410cd`. It is the review's two should-fix items on top of
`71cb83eb36`, a merge of `origin/main` at `b4eea88505`. That main
contains #34104 (`e9fb09871d`), the fix for the `run-date.test.ts`
timeouts behind the `Test Core (7/8)` red at `37fd6054d0`. Every reading
below ran under `scripts/pm/os-verify-lock.sh` and is quoted from its
`VERDICT` line. Every suite and gate is green.
The merge brought only main's changes. This branch's diff against its
base has the same `git patch-id` (`964c6bf182`) before and after the
merge. So the full dogfood battery at `37fd6054d0` still stands: 468
passed and 3 skipped of 471 files, 3966 tests passed. The new commit
adds test pins and changeset prose only.
<details><summary>Readings: suites, typecheck, pins, gates, body gates,
merge-tree</summary>
- **Build** (`turbo run build`, dogfood and scenarios closures):
`VERDICT command-exit 0`.
- **`@objectstack/scenarios` `test/runner/run-date.test.ts`**: 35/35,
`VERDICT command-exit 0`.
- **`@objectstack/metadata-protocol`**: Test Files 343 passed, 9
skipped; Tests 22934 passed, 45 skipped. `VERDICT command-exit 0`.
- **`@objectstack/rest`**: Test Files 418/418; Tests 8762 passed, 355
skipped. `VERDICT command-exit 0`.
- **`@objectstack/spec`**: Test Files 934/934; Tests 28526 passed, 1
todo. `VERDICT command-exit 0`.
- **Typecheck**, each exit echoed: metadata-protocol 0, rest 0, spec 0,
dogfood 0.
- **`check:generated`**: "All 14 generated artifacts are up to date".
- **Pins at `8ed07410cd`, after the A4 to A6 legs**: the dogfood file
9/9; the facet file and `protocol-history-slots` tests 25/25.
- **Derived gates** (`dispatch-gates --commands --repo
objectstack-ai/objectstack`, 122 families at `8ed07410cd`): 122 exit 0,
including `check:skill-examples` and `check:dual-build-cjs-loads`, NOT
MEASURED at the previous head. `--ran`: "122 derived, 122 run, 0
NOT-MEASURED, 0 UNRUN".
- **Body gates** on this body:
- `check-changeset-no-major` exit 0.
- `check-adr-0087-registration` exit 0.
- `check-partof-closing-keyword` exit 0.
- `check-closing-keyword-parity --body` reports the one closing
declaration on this body, bound by 2 of 3 parsers (informational).
- `check:nul-bytes` exit 0.
- **Merge-tree** (`--write-tree --name-only`): no conflicted path
against `origin/main` `b4eea88505` (exit 0), nor against #33885 head
`e57e7c0566` (exit 0).
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jTkZnXtRhuEiiyidvJ)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01QsR2jTkZnXtRhuEiiyidvJ
<!-- signed: domain:server#5 · zhuangjianguo ·
session_01QsR2jTkZnXtRhuEiiyidvJ -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 8898b4e commit bb17350
20 files changed
Lines changed: 771 additions & 53 deletions
File tree
- .changeset
- content/docs/references
- api
- docs/audits/2026-07-unknown-key-strictness-ledger.counts
- packages
- metadata-protocol/src
- qa/dogfood/test
- rest/src
- spec
- api-surface
- authorable-surface
- declaration-map
- export-origins
- json-schema.manifest
- src/api
| 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 | + | |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
0 commit comments