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 5f99582
Browse filesBrowse the repository at this point in the historyBrowse files
fix(metadata-protocol)!: a package commit's plan and revert address the committing package's own row; a deleted row's restore asks the package-less close (#29797)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ86dqPUQ7umCq81TqWVdRR92)_Fixes#29414
domain:server#5 · os-warren · session_01JQwxbZ5jYNfPGLvPV8LYRe
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none needed — `skills/objectstack-platform/SKILL.md`
already says the package-less save, reset and rollback of a movable row
are refused once movable (D11), and places every customization of an
installed base in its paired `.custom`; nothing it says becomes false.
> **Freeze:** the #27737 freeze (6594835694) lifted when #29788 merged
as 339f63d; main 0e4b0fa was merged at 7a6e6cd, clean, with the
protocol.ts hunks at their symbols. The later §3b freeze (6599581744)
was lifted at 6599690891 before any §3b work began. Head f74094f merges
main at c5ddbea, clean.
## 维护者速读
- 改了什么:包提交的撤销计划(`publish-drafts` 记录的
`existedBefore`/`prevVersion`)只读发布包自己的那一行;按提交撤销(`POST
/packages/:id/commits/:commitId/revert`,整包回滚经它)的删除与恢复两支都只针对提交所属包自己的行。恢复绑定恒为提交所属包:该包的行已删时
`restoreVersion` 按所述包重建,本门永不写无包行;只读基础包自身的提交由 #29390 的具名基础关闭拒掉。恢复写入基础包的
`.custom` 配对行时,经
`restoreWriteFor`(与逐项回滚共用的同一推导)由覆盖写入闸判定;未声明覆盖的版本逐项拒绝(`NOT_OVERRIDABLE`),不写任何东西。
- 为什么改:实测 main 上,基础包旧行旁边的 `.custom` 配对包首次发布,被记成"编辑了基础行的版本
10";撤销这次提交时去找基础行,被 #29390 的关闭拒掉,配对包的覆盖仍在服务、撤销答
`success:false`。另一路:基础行删除后撤销其编辑提交,会插入一条无包行(#28576 关闭的那种写入)。
- 风险与回滚:只改提交门的寻址与恢复写入判定;删除行后撤销从"静默写无包行"变为按提交所属包重建或逐项拒绝(收窄,故 `Clause-②:
no (narrowing)`)。回滚即撤销本 PR。
- 先看:`packages/metadata-protocol/src/protocol.ts` 的
`revertCommit`(`commitPackageId`、`restoreWriteFor`)、`publishPackageDrafts`
计划读、`sys-metadata-repository.ts` 的 `restoreVersion` 新增 `packageId`。
- 两分钟验证:`pnpm --filter @objectstack/metadata-protocol exec vitest run
src/protocol.named-base-overlay-write.test.ts`,预期 28 个全过。
- 需要你做的:无,席位落地。
## What changes
- **The plan names the publishing package's row.**
`publishPackageDrafts` reads each item's pre-publish active row with
`package_id: request.packageId`. Every draft it promotes is listed under
that package and promoted into that package's row, so another package's
row of the name is not the item's pre-publish state.
- **Both revert limbs name the committing package's row.**
`revertCommit` reads `commitPackageId` off the commit row and states it
on the soft-remove limb's read and delete, and on the restore limb's
read and `restoreVersion`. A pair creation commit beside a row bound to
its read-only base now removes the pair's row, and the base row is
served again.
- **The restore binding is always the committing package.**
`SysMetadataRepository.restoreVersion` takes `packageId` (a local
extension, as on `delete`). When stated, it writes that package's row,
and creates it again when it is gone. When omitted, behaviour is
unchanged. This door therefore never writes a package-less row. A
read-only base's own commit whose row is gone is refused by the #29390
named-base close.
- **M1: a restore into the base's paired `.custom` row is judged by the
override write gate** through `restoreWriteFor`, the derivation the
per-item rollback now shares. A version declaring no override (a legacy
plan naming the base row's version) is refused per item with
`NOT_OVERRIDABLE`, and nothing is written.
- **Spec entry text.** The `packageless-overlay-write-closed` entry
names the two commit doors (`POST
/api/v1/packages/:id/commits/:commitId/revert` and `POST
/api/v1/packages/:id/rollback`). It is a text change only, with no new
id or key, per claim amendment 6596154325.
- **Fixtures.** Seven suites seeded a package's commit over package-less
rows, or served a commit row with no `package_id`, a shape no publish
produces. Each now binds its rows to the commit's package, with no
assertion changed. The publish audit harness arms its rival write on the
second package-scoped read of the name. The objectql
`protocol-publish-package-drafts.test.ts` capture-read pins (:159, :209)
gain `package_id: 'app.edu'`, the plan read's new scope (52e2569).
## Tests
- Red first through the real door
(`packages/qa/dogfood/test/package-commit-revert-path-package.dogfood.test.ts`,
booted showcase, `origin/main` 7dae3b3): the pair-beside-base case
failed on the plan (`items: [{ existedBefore: true, prevVersion: 10
}]`), and the deleted-row case failed (`success: true`, the package-less
row written).
- Unit (`src/protocol.named-base-overlay-write.test.ts`) 28/28. The new
legacy-pair-commit case is refused `NOT_OVERRIDABLE`, and the pair row
stays declared and served. Two new gone-row controls restore into the
pair's row and into the writable package's row. The deleted-base-row
case asserts the named-base rollback sentence. Those 4 fail with
`protocol.ts` and `sys-metadata-repository.ts` restored from 55837b7 (4
failed, 24 passed) and pass with the rework.
- Dogfood `package-commit-revert-path-package` 12/12.
## Acceptance notes
- **`rollbackMetaItem` shares the addressing defect (measured, not fixed
here; filed as #29848).** The per-item rollback beside a base-bound row
and the pair's override answers `403 NOT_OVERRIDABLE` naming the base
row.
- **`commitPackageId` is an unchecked read** (`const commitPackageId:
string = row.package_id` on an `any` row whose column is `required:
false`). No producer or door reaches a package-less commit row: the one
writer always stamps it, and both REST doors refuse a row whose package
is not the path's. Only an in-process `revertCommit({ commitId })` on a
hand-made row could pass `null`. Recorded by the contract review as
should-fix S1 and accepted at this landing.
## Verification
<details><summary>Local gates (head f74094f, tree identical to
af63aa9f)</summary>
- Build, plus the full suites of metadata-protocol, objectql, rest,
runtime, metadata, service-automation, service-datasource, lint and
client: all exit 0 under os-verify-lock.
- `pnpm --filter @objectstack/metadata-protocol typecheck`: exit 0.
- Spec: `check:generated`, migrations, `check:spec-changes`,
`check:upgrade-guide`: exit 0.
- `dispatch-gates --commands`: 84 run, 0 NOT MEASURED in the `--ran`
reconciliation.
- `pnpm lint`: exit 0.
- Full dogfood battery on f74094f: Test Files 407 passed, 3 skipped;
Tests 3362 passed, 28 skipped; 0 failures (35m03s, os-verify-lock
VERDICT command-exit 0). Report addendum on #29414: 6600686902.
- CI check-runs on f74094f: 64 in total, 55 success, 9 skipped, 0
failed.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbZ5jYNfPGLvPV8LYRe)_
<!-- signed: domain:server#5 · os-warren ·
session_01JQwxbZUR3xvHyDPCjNL5P4 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(metadata-protocol)!: a package commit's revert plan and its revert address the committing package's own row, and a restore into a `.custom` pair's row is judged by the override write gate
7
+
8
+
Clause-②: no (narrowing) — the commit revert (`POST /api/v1/packages/:id/commits/:commitId/revert`) and the package rollback (`POST /api/v1/packages/:id/rollback`) no longer restore a stored version into a `<base>.custom` pair's row unless the version declares the override the pair's save requires, and no longer restore into another package's row of the name, or into a package-less row, when the committing package's own row was deleted since: they restore into the committing package's row, so a commit of an installed read-only package itself whose row is gone is refused by the close naming the pair. They restored into whichever row of the name the store returned first, or inserted a package-less row, before.
9
+
10
+
Metadata-protocol: none
11
+
12
+
Skills-docs: none needed — `skills/objectstack-platform/SKILL.md` places every customization of an installed base in its paired `.custom`, declaring `overrides`, and says a pair row is honoured only when declared; nothing it says becomes false.
13
+
14
+
<!-- adr-0087: not-required (already-registered packageless-overlay-write-closed) That entry, unreleased and shipping in the same release, already prescribes this change's TO for every customization of an installed package: write it into the base's paired `<base>.custom` with `PUT /api/v1/meta/<type>/<name>?package=<base>.custom` and the `overrides` declaration (its replacement), because the customization lives there (its reason, ADR-0146 D1, D2, D11). Its surface and reason now name the commit doors as further addresses of the rollback it closes (text only, no new id). No stored row is rewritten or moved, so `objectstack migrate meta` has nothing new to do. -->
15
+
16
+
**BREAKING** write narrowing at the commit doors (`@objectstack/metadata-protocol`), shipped as `patch` (`Metadata-protocol: none`). `@objectstack/spec` carries the text widening of the `packageless-overlay-write-closed` upgrade entry.
17
+
18
+
The plan a package publish records (`POST /api/v1/packages/:id/publish-drafts`, the commit's `existedBefore` and `prevVersion` per item) now reads the publishing package's own active row, and the revert removes or restores that row only. Before, both read any package's active row of the name: the first publish of a `<base>.custom` pair's declared override beside a row bound to the base (stored before the write naming the base was closed) was recorded as an edit of the base row's version, and its revert addressed the base row and was refused there instead of removing the pair's row. It now removes the pair's row, and the row bound to the base is served again.
19
+
20
+
A pair commit recorded before this change beside such a row still names the base row's version as the pair's pre-commit state. Its revert now restores into the pair's own row, so the restored body meets the override write gate exactly as the pair's per-item rollback does: the base row's body declares no override, so the item is refused per item (`403 NOT_OVERRIDABLE`, the save door's sentence) and the pair's declared row stays as it is.
21
+
22
+
### Migration: FROM → TO
23
+
24
+
FROM, undoing a pair commit recorded before this change beside a row bound to the installed package `com.acme.crm`:
25
+
26
+
```http
27
+
POST /api/v1/packages/com.acme.crm.custom/commits/cmt_123/revert
28
+
```
29
+
30
+
It answers `200` with `success: false`, and the item in `failed[]` with `code: NOT_OVERRIDABLE`; nothing is written. TO, write the version you want into the pair, declaring what it overrides, or remove the pair's row to serve what is under it:
31
+
32
+
```http
33
+
PUT /api/v1/meta/view/account_list?package=com.acme.crm.custom
FROM, undoing a commit of `com.acme.crm` itself (recorded before the write naming it was closed) that edited a customization whose row was deleted since: the restore wrote a package-less row. It now restores into the row bound to `com.acme.crm`, which the close refuses (`NOT_OVERRIDABLE`, the rollback sentence naming the pair); TO, the same `PUT …?package=com.acme.crm.custom` with the `overrides` declaration.
40
+
41
+
-**Now refused, per item.** A restore into a `<base>.custom` pair's row of a version that does not declare the override the pair's save requires (the override write gate). A restore of a commit of a read-only package itself into its row bound to the package, now also when that row was deleted since (the close naming the pair). The commit's other items still revert, and `POST /api/v1/packages/<id>/rollback` reports each refused item in its `failed[]` and continues.
42
+
-**Now restored into the committing package's row.** A commit whose row was deleted since, of a writable package or of the pair (a declared version): the row is created again under that package, never as a package-less row.
43
+
-**Still open.** Every restore into a row the committing package holds that the gate admits (a writable package's in place, the pair's declared version in place), and every removal.
it('[#29414] the pair\'s first commit beside a row bound to the base records a create, and its revert removes the pair row; the base row is served again',async()=>{
it('[#29414] a revert of the base\'s edit commit whose row was since deleted restores into the base\'s own row, so the named-base close refuses it; nothing is written',async()=>{
it('[#29414] a pair commit recorded before #29414 beside a row bound to the base names the base row\'s version: its revert is refused by the override write gate, and the pair\'s declared row is unchanged',async()=>{
it('[#29414] CONTROL: a writable package\'s edit commit whose row was since deleted restores into that package\'s row, never a package-less one',async()=>{
0 commit comments