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 809c270
Browse filesBrowse the repository at this point in the historyBrowse files
fix(metadata-protocol): withhold the bare history of a name only disabled packages hold (#38625)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9St4eUWHFcCKuRUrCZPperJ)_Fixes#37915
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
管理员停用一个包后,在历史面板查看只归该包所有的元数据(例如邮件模板)时,以前仍列出全部版本,现在与查看条目本身一样显示“未找到”;重新启用后历史照常列出。
- 属于包的停用规则(维护者原则「我觉得停用就该全部消失」),补上读取版本历史这一处遗漏。
- 若判断有误,只会让某个名称的历史在停用期间多显示或少显示;不写任何数据,撤回本改动即恢复原样。
- 无。
## What changes
- `historySlotOf`
(`packages/metadata-protocol/src/protocol-history-slots.ts`) takes a new
`read` flag. When the history read names no package, it first asks
whether only disabled packages hold the name. That judgment is the one
the bare writes already use (`packagelessHolderRefusal`, its
disabled-holders arm). If they do, the read throws `404
RESOURCE_NOT_FOUND` before the two-holder refusal (which would name the
hidden package) and before any version is read. Only `historyMetaItem`
passes `read: true`.
- Why a flag rather than the bare arm itself, as the dispatch suggested:
the bare rollback also calls `historySlotOf`, and it must keep its ruled
`409` "Enable the package … first" refusal. Judging inside the shared
bare arm would have turned that refusal into a `404`. The last control
case below pins it.
- `GET /meta/:type/:name/history`
(`packages/rest/src/meta-item-history-routes.ts`): the catch sends a
bare not-found in the plain read's own body (`sendMetaItemAbsent`). It
recognises one the way the item read's catch does
(`thrownAnswerIsBareNotFound`). So the bare history and the bare item
read answer byte for byte the same 404. Without this fork the
classification door answers the flat dialect, which is what the REST
ablation below shows. This file is outside the claim's declared surface.
It is the renderer half the dispatch named (`handleRouteError` at the
history route), and it changes nothing else in the file.
- Unchanged: `?package=` history reads, the bare rollback's refusal, and
every name that an enabled package or the environment holds.
## Tests
<details><summary>Pins and controls</summary>
- `packages/objectql/src/disabled-holder-packageless-row-doors.test.ts`,
new describe, on the real engine with the card's `com.acme.mail` /
`acme.welcome` / `fr-FR` fixture:
- The package-less row and the package's own row: the bare history is
`404 RESOURCE_NOT_FOUND` while the package is disabled. Re-enabled, it
lists both versions again.
- The history of a deleted package-less row is withheld the same way,
with a re-enable control.
- The history naming the package is unchanged. The package's own row
still lists 2 versions while the named item read serves no item, and the
package-less row keeps its `409`. This is pinned as measured on `main`
ee9fd3d.
- CONTROL: the bare rollback keeps its `409` with the enable as the
remedy.
- `packages/rest/src/meta-disabled-package-doors.test.ts`, new describe,
RestServer over the real ObjectQL engine (better-sqlite3 in memory).
Bare `/history?member=fr-FR`: 200 with 2 events, then 404 with a body
byte-identical to `GET /meta/email_template/acme.welcome?member=fr-FR`,
and not naming the package. `?package=` answers equal before and after.
Re-enabled: 200 with 2 events.
- `packages/metadata-protocol/src/protocol-history-slots.test.ts`, unit
arms: four disabled cells (package-less row, own row, both rows, no row)
answer 404. Controls: enabled, not a read, an enabled row binding (the
two-holder 409 stands), and the named read.
</details>
<details><summary>Suite readings</summary>
- At a1f33b1: `pnpm --filter @objectstack/metadata-protocol test`, 372
files passed with 9 skipped, 23657 tests passed with 45 skipped. `pnpm
--filter @objectstack/objectql test`, 640/640 files, 14544/14544 tests.
`pnpm --filter @objectstack/rest test`, 440 files passed, 9046 tests
passed with 351 skipped.
- `typecheck` for rest and objectql: 0 at a1f33b1. For
metadata-protocol: 0 at e17e5df. At a1f33b1 it was 2, from a TS2345 in
the new test cases, which e17e5df fixes.
`protocol-history-slots.test.ts` reran 25/25 at e17e5df.
</details>
<details><summary>Ablations (rebuild + dist proof)</summary>
- Ablation 1: the read judgment's call site in `historySlotOf` was
mutated through `scripts/ablation-replace.mjs`, and metadata-protocol
was rebuilt. `ablation-dist-preflight` found the marker in
`dist/index.js` and `dist/index.cjs`. Result: 4/25 unit cases red, 3/19
objectql cases red, the REST case red. Then the source was restored
(blob equal to HEAD), metadata-protocol was rebuilt, and the marker was
absent from all 24 dist files with `git diff HEAD` empty.
- Ablation 2: the REST catch fork was deleted and the REST case went
red, with the body in the flat dialect: `{"error":"Metadata item
email_template/acme.welcome not found","code":"RESOURCE_NOT_FOUND"}`.
Then it was restored (blob equal to HEAD).
</details>
<details><summary>Gates</summary>
- Gates come from `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 75 commands, run on e17e5df (the final
head). The result is `--ran` (exit codes recorded) reconciles 75 derived
and 74 run with exit 0. One is NOT MEASURED: `node
scripts/check-plugin-teardown-shape.mjs --self-test`, exit 3,
PREREQUISITE NOT MET, because the shallow clone cannot reach its pinned
fixture commit. CI runs it on a full clone.
- `node scripts/pm/overlap-check.mjs`: `VERDICT clean exit 0` (merges
cleanly with origin/main, and no open PR shares a file).
</details>
## Acceptance notes
- **The named history read (`?package=PKG`, PKG disabled).** The card
asks for two things that disagree once measured. Its expected section
says the named read "follows whatever the named item read does today",
and the named item read today serves no item (REST 404). Its acceptance
section says "Named reads are unchanged". This PR keeps the named
history unchanged and pins it. Note that the bare writes' `?package=`
remedy (the named rollback is admitted while the package is disabled)
relies on that listing to choose a version. The zone ruled on this: the
named history stays as built (option A, unchanged and pinned). Answering
404 there as well (option B) is not part of this PR.
- **Diff door.** `diffMetaItem` calls `historySlotOf` with no
disabled-holders judgment, so the same gap exists in its code. It is not
reproduced on the card's fixture: the diff compares only the canonical
member, which a shipped name's package cannot hold a row at (the save is
`403 NOT_OVERRIDABLE` / `WRITABLE_PACKAGE_REQUIRED`). Turning it on is
one `read: true` plus the same REST catch fork, but it has no pin here,
so it is left for a follow-up.
- **Audit door.** `auditMetaItem` does not call `historySlotOf`, so the
dispatch's mechanism assumption is disproved. It lists the name's audit
rows, including refusals made while the package is disabled. Withholding
a compliance trail is a product decision, so it is not touched here.
- **Types not stored per package** (page, report, analytics_cube and
others). `historySlotOf` answers `undefined` for them, and this change
does not reach them. REST already withholds the gated types (book, doc,
app, view, dashboard) through `eventDoorRefusal`. The other types are
unmeasured.
- **Runtime dispatcher.** `packages/runtime/src/domains/meta.ts` serves
no `/history` route (no route for it at ee9fd3d), so RestServer is the
only HTTP transport here.
## Read first
1. `packages/metadata-protocol/src/protocol-history-slots.ts`: the
`read` arm placed before the two-holder refusal. Risk: the order (a
disabled-only name with two slots now answers 404, not 409).
2. `packages/rest/src/meta-item-history-routes.ts`: the catch fork.
Risk: any other bare not-found thrown on this door now gets the nested
absence body instead of the flat one.
3.
`packages/objectql/src/disabled-holder-packageless-row-doors.test.ts`:
the named-read pin, which records the current behaviour on purpose.
## Verification
Two-minute check: `pnpm --filter @objectstack/objectql exec vitest run
src/disabled-holder-packageless-row-doors.test.ts -t 37915`. Expect 5
passed.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmRar3Kkg6SpwVgaaVE)_
<!-- signed: repo:objectstack#3 · os-steve ·
session_01ADHkmRar3Kkg6SpwVgaaVE -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(metadata-protocol): the history of a name only disabled packages hold is not served
7
+
8
+
Clause-②: no
9
+
Metadata-protocol: none
10
+
11
+
`GET /api/v1/meta/:type/:name/history` naming no package, for a type stored per package (an `email_template`, a `flow`, an `agent`, …), now answers `404 RESOURCE_NOT_FOUND` for a name that only disabled packages hold. The body is the same one `GET /api/v1/meta/:type/:name` gives for that name. A disabled package holds no name, so the item read already answered not found, but the history door kept listing every version of the name, at any `?member=`. That included the history of a row stored under no package, which is that package's customization, and the history of a row that was deleted. In process, `historyMetaItem` throws the same `404`.
12
+
13
+
- Enable the package again and the history is listed as before.
14
+
- The history naming the package (`?package=`) is unchanged.
15
+
- The rollback naming no package keeps its `409` refusal, which says to enable the package first.
16
+
- A name that an enabled package or the environment holds answers as before.
it.each([['the package-less row',undefined],['the package\'s own row',PKG]]asconst)('%s: the bare history is the by-name read\'s absence (404 RESOURCE_NOT_FOUND); re-enabled, it lists the versions again',async(_cell,packageId)=>{
it('the history naming the package is unchanged: the package\'s own row lists its versions, the package-less row keeps its 409, disabled or not',async()=>{
0 commit comments