Repository navigation
Commit c4472c8
feat(metadata-protocol): the stored-form ceremony's write half, the --apply the next major's upgrade command runs (#38748)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9SSdM6AYsxMukn8uhMeGEh7)_
Part of #37111 — PR 2 of 2 (the write half). PR 1 is #38613 (merged as
`1d959b0910`). Two owed items stay, each with its reason in the table
below, so this PR does not close the card.
Clause-②: yes (widening)
Metadata-protocol: none
Skills-docs: none — stored-row ceremony, nothing an author writes
changes
## 维护者速读
-
用户能看到什么变化:升级到下一个大版本时,升级命令会把数据库里按旧写法存的表单真正迁成表单行(搬移、合并、删除内部记录表单),公开表单的两扇门在迁移前后应答不变。
-
全有或全无:只要预检还有一行拦着,升级命令一行都不写,所有行逐字节不变;写入在一个事务里做完。不能回滚事务的库上,升级命令在写任何东西之前就拒绝,点名驱动并告诉运维怎么做(换支持事务的库跑,或留在当前版本);`os
migrate stored-forms` 在这种库上也会提前说明升级会被拒。
- 独立的 `os migrate stored-forms` 仍然只读,没有 `--apply`(裁决 7142585849)。
- 要你做什么:本 PR 是 Tier H 的 draft,审核后按受管流程批准。你 2026-11-30 的裁决(7277149723)在本
PR 按规则全量落地:今天没有任何一扇门服务的表单,无论绑在哪个包,升级时都原地不动;ADR-0159 D7 单列一条写明「没有门服务」的含义。
- **需要你在批准时定**(席位 L2 7280142300
上报,不评级):上面这条拒绝意味着「默认驱动不能回滚事务、又有要搬的存量表单」的部署拿不到这个大版本,除非换库。批准本 PR
即接受这一点;否则请指示别的做法。
- 风险:写入走仓储底层(不经保存门),所以每条写入都由两门前后钉子和 ablation 守着;Tier H,draft 不转 ready。
- 卡上还剩:两条欠单写明原因留着(见下表);L2 记录 7277980228 与其 delta 7280142300、L1-b delta
7280063801 的各项已在本 PR 修好(见下)。
## What changes
- **`applyStoredFormsOf(protocol, { actor })`**
(`protocol-stored-form-apply.ts`, exported for the major's upgrade
command only). It runs the census and acts on it:
- **All or nothing.** If the precheck counts any row, it writes nothing;
every stored row stays byte-equal.
- **Order.** Each destination `form` row is written and read back at its
own address. Only then are the old rows deleted or re-saved:
- a view item row is deleted;
- a container is re-saved without the forms that left it (through the
`form` write door's own member removal), its lists byte-equal;
- a container left with nothing is deleted.
- **One transaction.** The `.custom` pairs the moves land in are ensured
first, before it, and stay after a rollback (an empty pair changes no
answer; the next run reuses it). The registry is healed after the
commit.
- **Refused where the database cannot roll back.** On an engine whose
default driver cannot roll a transaction back, a run that would write or
take a row throws before anything is written (no pair is ensured),
naming the driver and the operator's choice: run against a database
whose driver supports transactions, or stay on the current release. A
run with nothing to write is not refused.
- **Idempotent.** A second run writes nothing.
- **What a moved row carries.** Its stored body, without the provenance
a container's expansion wears from the shipping package. A declared
override is written as its pair's own row (the store's runtime intent,
as the save door gives it).
- **Planner readings owed by PR 1:**
- N4 and N16: the fold reads a withdrawal the `view` list or another
pair's layer reads today, so it does not name the form newly closed.
- N14: the pair's own item needs no `basedOn`.
- N5: the refusal names in words why no pair id can be derived.
- **The census and `--apply` agree:**
- **A sealed destination holds the upgrade.** Every destination but a
declared override is written as an edit of the item a package ships at
the name, and the store seals a `form` a managed package ships (ADR-0131
D6). The census now reads that seal the way the run's write meets it:
such a move, or a kept `form` row the run writes because it carries a
withdrawal, holds the upgrade (cause `app_author`), naming the shipping
package, instead of planning a write the run then refuses inside its
transaction.
- **A form no door serves today is left in place by the upgrade**,
whatever package its row is bound to (maintainer ruling record
7277149723). Every plan that would move a row asks the effective `form`
read whether it lists a form of the name at the address the plan is made
at; where it does not, the move is `left_in_place` with reason
`served_by_no_door`: nothing of it moves, nothing is written, and it is
not counted. A hold the plan takes part in still stands. ADR-0159 D7
states the rule as its own bullet; `os migrate stored-forms` prints the
reason. `StoredFormLeftReason` (an exported output union) gains
`served_by_no_door`: the widening the `Clause-②` arm declares.
- **Census pins forced by the new writers:**
- `protocol.view-expansion-reconcile-call-sites.test.ts` records the
three writes, which use the `module callers` route, healed by
`healStoredFormRows`.
- `protocol.object-registry-write-through-spelling.test.ts` records the
write-through's tenth caller.
- Both files are in the File surface by claim amendment 3 (7276366326).
- **Docs.** `content/docs/deployment/stored-forms-upgrade.mdx` gains
"What the upgrade command writes", the L1 nit's wording for the fold,
the served-today rule for every address, the left-in-place sentence, the
pairs created before the transaction, the refusal on a database that
cannot roll back, and a clearing-table row for a sealed destination.
- **A rest test's budget.** The first served `view` read in a worker
loads `@objectstack/lint` lazily (`metadata-diagnostics.ts`), about 1s
on an idle box and past 5s on a loaded CI runner (Test Core 8/12 at
`5ed2329e`). In `public-form-two-type-withdrawal.test.ts` that read was
the `/meta/form` audience test's first `/meta` read. The describe now
takes the load once in `beforeAll`; the test's own reads measure 55ms.
The same file's base and head measured alike for that test (1431–1544ms
at the merge base, 845–1113ms at the head), so the timeout was not this
PR's change to the read.
## Owed by PR 2 (from #38613), reconciled
| Item | Status |
|---|---|
| `pair_form` byte-equal pin (ruling 7250977204), destination drops
`overrides` | done at `68b146c3` — rest "the pair's own item (ruling
7250977204)…" |
| …and seed N11's case | done at `d8c26159` — a form no door serves
today is left in place by the upgrade (maintainer ruling of 2026-11-30):
planner, engine and rest pins (red first; ablation turns all three red);
ADR-0159 D7 sentence; one PR 1 engine pin that planned such a member as
a move now reads it left in place |
| N4 | done at `4c77a1e5` — planner "N4: a `view` row a `form` row
outranks…" (red first; ablation turns exactly it red) |
| N5 | done at `ae532d45` — planner "N5: where no pair id can be
derived…" (red first) |
| N13 / L1-b item 1 | done at `e5dd21b2` — engine "N13: the pair door's
refusals and the draft read, through the real protocol" (the earlier
pair's 409 read as that pair, the other owner's 422, a positive control,
the draft read) |
| N14 | done at `4c77a1e5` — planner "N14: …" (red first; ablation) |
| M3 through both doors | done at `3093ce7e` — rest "M3 through both
doors" (two shapes) |
| N16 | done at `4c77a1e5` — planner "a second pair's override that
withdraws the form…" (red first; ablation) |
| ③ a pair held as booted code | stays — not built this round; not
measured |
| L1 nit (fold wording) | done at `a5985f41` — the page's `kept` and
`moves` rows |
| Both-doors pin for a row served at another address | done at
`3093ce7e` — rest "a row the read serves at another address than the
package it is bound to…" (switched off and open) |
| Ruling 7265816895 step 5 | done at `e5dd21b2` — engine "a held row:
applyStoredForms writes nothing at any address" (every stored row
byte-equal; every address's served read equal before and after); rest
"all or nothing" for the two doors at one address |
| Step 6 (clearing-table row for the contested slot) | done in PR 1
(`1d959b0910`); unchanged here |
| Step 7 (a store that enforces one row per slot) | stays — not built;
the engine pins hold the contested slot before any write |
| N32 | done at `e5dd21b2` — engine "S14 over the real read…" (the first
S14 shape); the second shape's engine half is not built separately |
| N33 | done at `e5dd21b2` — engine "N33: a container member kept as
stored beside a sibling member that moves" |
| N29 | done at `e5dd21b2` — engine "the third-address shape…" |
| List-only labeling note | done at `a5985f41`; re-read after M1 and
replaced at `9ecc15b5` by the served-today rule for every address (L2
N2) |
## Last round's finding, fixed here
- **A destination the store seals** (done at `bedc74f7`): planner pin
and controls, rest pin through `listStoredFormsOf` and `--apply` (red
first: the census planned a move); ablating the census read turns the
planner, engine and rest pins red. One PR 1 engine pin planned such a
row as a move the run could not write; it now reads the hold.
## L2 record 7277980228 (FAIL at `4a67c9f2`), fixed here
| Item | Commit | Pins (red first; ablation) |
|---|---|---|
| M1 — the left-in-place rule for every plan that would move a row |
`906d10a8` | planner "a form no door serves today is left in place by
the upgrade, whatever package its row is bound to" (4 shapes + 4
controls) and "a hold stands where no door serves the row today"; rest
"…whatever package its row is bound to: …" (3 shapes, both doors 404
before and after). Red on `4a67c9f2`: planner 4, rest 3. Ablating the
census read at every plan: planner 5, engine 1, rest 4 red. |
| S2 — a kept row the run writes reads the seal | `d61a32a4` | planner
"a kept `form` row the run writes … reads the seal too" + 2 controls;
rest "the census and the run agree where the store seals a kept row the
run writes". Red on `906d10a8`: planner 1, rest 1. Ablation: exactly
those two red. |
| S3 — refuse `--apply` on an engine that cannot roll back | `85c7eebd`
| rest "on a database that cannot roll back a transaction, --apply is
refused before anything is written" (the refusal names the driver and
what to do; no pair ensured; rows byte-equal; doors unchanged) + a
control (nothing to write is not refused). Red on `d61a32a4`; ablation
turns exactly it red. No undo. |
| S1 — the ADR D7 sentence | `9ecc15b5` | its own bullet: what "no door
serves" means, apart from a withdrawn form and an internal record form,
what "its rows stay as stored" covers, cites `7277149723` |
| N1 — pairs before the transaction | `9ecc15b5` | the page and the
module header |
| N2 — the list-only paragraph | `9ecc15b5` | replaced by the
served-today rule for every address |
| N3 — `Clause-②: yes (widening)` | `9ecc15b5` | this body and the
changeset |
## L1-b delta 7280063801 and L2 delta 7280142300, fixed here
| Item | Commit | Pins (red first; ablation) |
|---|---|---|
| L1-b must-fix 1 / L2 S5 — what the environment's address reads |
`bf56df4e` (pin), `7831394d` (D7 and page) | Measured, then reported as
a fork and accepted: a form stored with no package is served by both
doors where the read seats it, under a package that ships only a list of
the name included, so the census reads every such slot at the
environment's address. Rest "a package-less form at the environment's
own address is served today where the read seats it" (0, 1 and 2
list-shipping packages: both doors serve it before, it moves, both doors
answer the same after). Ablating to "the environment only": the 1- and
2-package pins and one engine pin red, the 0-package control green. |
| L2 S4 — an unserved form does not hold at the pair door or a sealed
destination | `11338180` | planner "a form no door serves today is left
in place before a hold its move would take" (pair door; sealed
destination). Red on the previous head: 2. Ablation: exactly those 2
red. |
| L2 N5 — a row another address serves and moves | `7831394d` | the D7
sentence: such a row goes with that move |
| L2 N6 — the report names a database where the run will be refused |
`74b1cfc8` (pin made load-free at `5f0b99fe` | cli "the census report
says where the upgrade's run will be refused" + 2 controls (`runRefused`
in `--json`). Ablation: exactly the first red. |
| L2 ③ — refusing a deployment that cannot roll back | — | escalated to
the maintainer by the seat, decided at the Tier H approval; named in the
summary above. Nothing built. |
## Verification
Head `5f0b99fe`.
- **This round** (L1-b delta 7280063801, L2 delta 7280142300), at the
head's tree: the planner file 106/106 (with the two census pin files,
131/131), engine 38/38, rest 94/94, cli `stored-forms.test.ts` 3/3.
Derived gates: the same 109 commands; 108 exit 0 on the first run and
`check:test-source-alias` exit 1 on the new cli test (it reached the
stack's dynamic imports); the test now mocks those packages, and that
gate exits 0 at the head; `dispatch-gates --ran` on the final record:
109 run, 0 NOT-MEASURED. `overlap-check` at the head's tree: clean
against `origin/main` (`95a49adb80`); no open pull shares a file. The
change set is 13 paths: the 12 before plus the cli command's own test
file.
Previous round, at `9ecc15b5`:
- **That round** (L2 record 7277980228), at the head's tree: the planner
file 104/104 (with the two census pin files, 129/129), engine 38/38,
rest 91/91; metadata-protocol type-check clean. Derived gates:
`dispatch-gates --commands` derived 109 commands (the same list as last
round); all 109 exit 0, each run with `< /dev/null`; `dispatch-gates
--ran`: 109 run, 0 NOT-MEASURED. `overlap-check` at the head's tree:
clean against `origin/main` (`8426fa0c89`); no open pull shares a file.
Earlier, at `4a67c9f2`:
- **This round** (the sealed destination, the rest test's budget, the
left-in-place rule), at the head's tree:
- The three changed test files: planner 92/92, engine 38/38, rest 85/85;
metadata-protocol and CLI type-check clean.
- **Red first:** the sealed-destination planner pin and rest pin failed
on the old source (the census planned a move); the left-in-place planner
pin and rest pin failed on the old source (the census planned a move).
- **Ablations**, each with `scripts/ablation-replace.mjs`, restored to
`HEAD`:
- The census read of the store's seal: the planner pin, the PR 1 engine
pin it now reads, and the rest pin.
- The census read of the forms served today: the planner pin, the PR 1
engine pin it now reads, and the rest pin.
- The rest audience test measured 55ms with the load taken in the hook
(1974ms before, in the same file run).
- **Derived gates at `d8c26159`:** `dispatch-gates --commands` derived
109 commands; all 109 exit 0, each run with `< /dev/null`.
`dispatch-gates --ran`: 109 run, 0 NOT-MEASURED. The changeset commit
after it changes no path in the change set.
- **`overlap-check`** at `4a67c9f2`: clean against `origin/main`
(`db2273d5c4`); no open pull shares a file.
- **Earlier rounds** (head `5ed2329e`): 97 derived gates, all exit 0;
the ablations listed below each turned exactly their own pins red:
- Ignoring the precheck: exactly the 10 all-or-nothing pins (9 engine, 1
rest).
- Keeping the read's provenance on the moved body: the container
withdrawal pin.
- Keeping an emptied container: the same pin, through its second run.
- Judging a declared override's write as an edit of the shipped item:
the base-ships-a-`form`-item pin.
- Dropping the folded row's switch: the three fold pins.
- N4, N16 and N14 each: exactly its own planner pin.
- Reading a row only at the package it is bound to: the two "another
address" pins.
- Planning the pair's override at the pair's own address: the two M3
pins.
- **Not measured locally, CI owns:** the CLI integration tier, the
type-check lanes, and the dogfood and live-database jobs the derivation
names as CI-only.
## Deviations
- **File surface.** The two census pin files and the ADR file were
outside the claim; claim amendment 3 (7276366326) names them. The rounds
after the claim add no path but the cli command's own test file
(`stored-forms.test.ts`). The census pins are forced (each new
stored-row writer is recorded there); the ADR file carries the D7
sentence of the 2026-11-30 ruling.
- **Two PR 1 engine pins change their expected plan.** Each planned a
row as a move that the rules of this round do not move: one into a
destination the store seals (now a hold), one a form no door serves
today (now left in place). Their reads of today are unchanged.
- **Changeset.** It names `@objectstack/metadata-protocol` and
`@objectstack/cli` (the CLI prints the new left-in-place reason); every
other change is tests and docs.
- **No `protocol-stored-form-apply.test.ts`.** The write half is pinned
over the real protocol in `objectql` and through both doors in `rest`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmQrGTjSRSiwWSe6AhK
<!-- signed: repo:objectstack#3 · os-steve ·
session_01ADHkmQrGTjSRSiwWSe6AhK -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 94b3463 commit c4472c8
13 files changed
Lines changed: 1748 additions & 31 deletions
File tree
- .changeset
- content/docs/deployment
- docs/adr
- packages
- cli/src/commands/migrate
- metadata-protocol/src
- objectql/src
- rest/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 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
| 38 | + | |
| 39 | + | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
44 | 53 | | |
45 | 54 | | |
46 | 55 | | |
| |||
73 | 82 | | |
74 | 83 | | |
75 | 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 | + | |
76 | 123 | | |
77 | 124 | | |
78 | 125 | | |
| |||
82 | 129 | | |
83 | 130 | | |
84 | 131 | | |
| 132 | + | |
85 | 133 | | |
86 | 134 | | |
87 | 135 | | |
| |||
0 commit comments