Repository navigation
Commit 0bbb211
fix(metadata-protocol): revertCommit reports a restored non-object item whose registry write-through faults (#33979)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbNTugWasvhTMrtCZiFGrZYK)_
Fixes #33851
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
改了什么:撤销提交(revertCommit)现在对所有类型如实上报两类故障。第一类是恢复视图、权限、对象扩展等条目时,写入运行时注册表出错;这时该条目列入
failed[],写明「行已恢复到版本 N」。第二类是撤销删除条目后注册表修复(heal)中途停止;这时写明「行已从 sys_metadata
移除,注册表可能仍在提供被删的行」。两类都带出错原因和 code,success 为 false,和对象条目的处理一致。
- 为什么改:以前这些故障只记日志,撤销照样报 success:true,但进程实际还在使用旧内容,违反 revertCommit
自己的契约「success 即进程已生效」(ADR-0067 D3)。
- 风险与回滚:只有 revertCommit
读这两个新返回值。保存、发布、删除等其他调用方都忽略它们,同样的故障下仍答成功,日志也不变(有对照测试,另有消融证明对照测试能变红)。回滚即
revert 本 PR。
- 先看:`protocol-registry-hydration.ts` 中 `applyRegistryWriteThrough` 的两个
catch 和 `restoreArtifactRegistryView` 的外层
catch、剩余行循环;`protocol-package-commits.ts` 的 revertCommit
两个分支;`protocol.ts` 中两个转发方法的类型。
- 两分钟验证:`pnpm --filter @objectstack/metadata-protocol exec vitest run
src/protocol.revert-commit-honest-outcome.test.ts`,预期 31 个用例全绿(§3 共 12
个,§4 共 9 个)。
- 需要你做的:无,席位落地。#33563 那条变更说明里的一句旧话,在单独的纯文本 PR 中更正。
## What changes
`applyRegistryWriteThrough` has three branches. The `object` branch has
answered the registry's refusal since #33805. The two non-object
branches caught their faults and logged them at `warn`. The first is the
overlay hydration, which every type except `object` and
`object_extension` takes. The second is the `object_extension`
registration. The registry heal that a removal runs
(`restoreArtifactRegistryView`) logged its stop at `error` and returned
nothing.
- `protocol-registry-hydration.ts`, write-through. The request has its
own exported type, `RegistryWriteThroughRequest`, with one new optional
field, `answerFaults`. When it is `true`, a non-object branch that
throws still logs the same `warn` line, and then returns the fault in
the `ObjectRegistryRefusal` shape (`{ error }`). When it is unset, the
answer is `undefined`, as before.
- `protocol-registry-hydration.ts`, heal. `restoreArtifactRegistryView`
now returns a `RegistryHealStop` (`{ error }`) in two cases. The first
is when its outer catch stopped the walk; the `error` line it logs is
unchanged. The second is when a row still stored under another package,
which the heal registers again (with `answerFaults: true`), is refused
or faults; every remaining row is still tried. Otherwise it returns
`undefined`, and that includes the designed outcomes: a refused baseline
read that retires the entry, and a degraded read that keeps it.
- `protocol-package-commits.ts`, `revertCommit`. The restore limb sets
`answerFaults: true`. The soft-remove limb reads the heal's stop, but
only where a row was actually removed; with no row removed, the heal is
a self-heal and stays logged. Both feed the existing `notApplied` /
`settle` path, so the item lands in `failed[]` with the row state, the
reason and its `code`. The revert's own commit still records the row
change. `rollbackToPackageCommit` carries the item through its existing
per-item channel.
- `protocol.ts`, two private forwarders. The
`restoreArtifactRegistryView` forwarder now returns `Promise` of
`RegistryHealStop | undefined` (`ProtocolHost` derives its type from
it). The `applyRegistryWriteThrough` forwarder's parameter is now
`RegistryWriteThroughRequest`, in place of its inline copy. The
`revertCommit` docblock sentence that said a non-object write-through
fault "is not seen here" now says that every type, and a stopped heal,
is reported. The `.d.ts` carries that docblock, so this change takes a
`patch` changeset.
- Every other caller ignores the new answers. Save and publish
(`protocol-save.ts`, `protocol-history-and-publish.ts`) do not set
`answerFaults`. They would report any returned refusal as an object's
(`object-registry-refused`), which ablation A4 shows. The delete door, a
publish's undo and a peer's convergence `await` the heal and discard its
answer.
- Changeset: `.changeset/33851-revert-non-object-write-through-fault.md`
(`patch`). It says that it supersedes the sentence of the #33563 note
claiming such a fault "is still not seen by the revert". The #33563 note
itself is unchanged here: its one sentence is corrected in a separate
text-only PR (DELIBERATE CORRECTION).
## Tests
`packages/metadata-protocol/src/protocol.revert-commit-honest-outcome.test.ts`,
the revert harness, gains two top-level describes. They go there as
AGENTS.md requires (ruling record 6583487846).
- §3 has 12 cases, 4 each for `view`, `permission` and
`object_extension`: a clean restore control, which reaches the registry
verb as a non-vacuity check; a write-through throw that goes to
`failed[]` with `code`, "its row was restored to the body of version 1",
the reason and `success: false`; a save control; and a publish control.
The two controls hold under the same fault: `success: true`, no
advisories, and the same `warn` line.
- §4 has 9 cases, 4 each for `view` and `permission`: a clean
soft-remove control; a heal stop that goes to `failed[]` with `code`,
"its row was removed from sys_metadata", "may still serve the removed
row", `success: false` and the heal's `error` line kept; a delete
control (`success: true`, `error` line kept); and a save-and-publish
control (both `success: true`, no advisories). The ninth case is an
`action` row still stored under another package that the registry
refuses: it goes to `failed[]`. As a non-vacuity check, the stop is the
remaining row's write-through `warn`, not the heal's outer-catch
`error`.
Premise, measured on the code before each half. On the write-through
half (source at `63e47feeca`), §3's 3 fault cases were red: each
answered `success: true`. On the heal half (source at `2d23b49dd1`),
§4's 3 fault cases were red, with 28 cases green.
<details><summary>Ablations (scripts/ablation-replace.mjs, each landed,
run, then restored to blob == HEAD with git diff HEAD empty)</summary>
| Ablation | Red | Green |
| --- | --- | --- |
| A1: the overlay branch does not answer | 2 (§3 view, permission fault)
| 20 of 22 |
| A2: the extension branch does not answer | 1 (§3 object_extension
fault) | 21 of 22 |
| A3: revertCommit does not set `answerFaults` | 3 (every §3 fault case)
| 19 of 22 |
| A4: the overlay branch answers every caller | 4 (view and permission
save and publish controls; the save answered an
`object-registry-refused` advisory, "object 'ticket.grid' was published,
but the runtime registry refused it") | 18 of 22 |
| A5: the extension branch answers every caller | 2 (object_extension
save and publish controls) | 20 of 22 |
| B1: the heal's outer catch does not return its stop | 2 (§4 view,
permission heal stop: "expected true to be false" on `success`) | 29 of
31 |
| B2: the remaining row's refusal is dropped | 1 (§4 remaining-row case)
| 30 of 31 |
| B3: revertCommit does not read the heal's stop | 3 (every §4 fault
case) | 28 of 31 |
My first A1 to A3 attempt was a no-op: the replacement was a substring
of the anchor, `ablation-replace` refused it, and no test ran. They were
re-run with distinct markers, and the table shows those runs. A1 to A5
were run before §4 existed (22 cases). B1 to B3 were run on all 31
cases.
</details>
## Acceptance notes
- Out of scope, left as it is: in the heal, the object owner branch's
`unregisterObject` refusal ("object 'x' was deleted from sys_metadata
but stays registered") is still a `warn` line that answers no stop. It
is an object-only path, and the card's ruling covered the outer catch
and the remaining rows.
## Verification
<details><summary>Readings, local, at head 999b09d</summary>
- One locked run, at `999b09d9c3` with `origin/main` `68e726d631` merged
in (lock VERDICT command-exit 0; queued 6m18s, after a first attempt's
queue-timeout exit 99). It ran: the metadata-protocol dependency closure
build; `typecheck` exit 0; `test` 342 files passed and 9 skipped, 22923
tests passed; the metadata-protocol build; and the objectql suite, 597
of 597 files and 13177 of 13177 tests.
- The other direct dependents (runtime, cli, service-automation,
cloud-connection) were not run locally. CI runs them (Test Core). The
only type that moved is on private forwarders; `RegistryHealStop` and
`RegistryWriteThroughRequest` are not exported from the package entry.
- `pnpm lint`: exit 0.
- `dispatch-gates --ran`: 73 derived families, each with its exit code
recorded. 70 exit 0. 3 are NOT MEASURED, because each needs the whole
workspace built: `check:dual-build-cjs-loads`,
`check:lean-entry-closure` and `check:type-check-debt`, all exit 3
(PREREQUISITE NOT MET). CI runs them. The body gates (closing-keyword
parity, Part-of, changeset no-major, ADR-0087 registration) exit 0.
- `git merge-tree --write-tree --name-only`: clean against `origin/main`
`68e726d631`, against #33885's head `fa7fb66a7c`, and against S5's
`claude/area-E1b-33832` head `9c4f75f36e`. No open PR for #33308 was
found. No other open PR touches `protocol.ts`,
`protocol-registry-hydration.ts`, `protocol-package-commits.ts` or the
harness file.
- Dogfood: not run, because the title has no `!` and Clause-② has no
(narrowing) arm.
</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 b4ce310 commit 0bbb211
5 files changed
Lines changed: 423 additions & 37 deletions
File tree
- .changeset
- packages/metadata-protocol/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 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1567 | 1567 | | |
1568 | 1568 | | |
1569 | 1569 | | |
1570 | | - | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
1571 | 1583 | | |
1572 | 1584 | | |
1573 | 1585 | | |
| |||
1744 | 1756 | | |
1745 | 1757 | | |
1746 | 1758 | | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
1747 | 1763 | | |
1748 | 1764 | | |
1749 | 1765 | | |
| |||
1757 | 1773 | | |
1758 | 1774 | | |
1759 | 1775 | | |
| 1776 | + | |
1760 | 1777 | | |
1761 | 1778 | | |
1762 | 1779 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1458 | 1458 | | |
1459 | 1459 | | |
1460 | 1460 | | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
1461 | 1467 | | |
1462 | | - | |
1463 | | - | |
1464 | | - | |
1465 | | - | |
1466 | | - | |
1467 | | - | |
1468 | | - | |
1469 | | - | |
1470 | | - | |
1471 | | - | |
1472 | | - | |
1473 | | - | |
1474 | | - | |
1475 | | - | |
| 1468 | + | |
1476 | 1469 | | |
1477 | 1470 | | |
1478 | 1471 | | |
| |||
1527 | 1520 | | |
1528 | 1521 | | |
1529 | 1522 | | |
| 1523 | + | |
| 1524 | + | |
1530 | 1525 | | |
1531 | 1526 | | |
1532 | 1527 | | |
| |||
1546 | 1541 | | |
1547 | 1542 | | |
1548 | 1543 | | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
1549 | 1548 | | |
1550 | 1549 | | |
1551 | 1550 | | |
| |||
1734 | 1733 | | |
1735 | 1734 | | |
1736 | 1735 | | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
1737 | 1745 | | |
1738 | 1746 | | |
1739 | 1747 | | |
| |||
1755 | 1763 | | |
1756 | 1764 | | |
1757 | 1765 | | |
1758 | | - | |
| 1766 | + | |
1759 | 1767 | | |
1760 | 1768 | | |
1761 | 1769 | | |
| |||
1895 | 1903 | | |
1896 | 1904 | | |
1897 | 1905 | | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
1898 | 1910 | | |
1899 | | - | |
| 1911 | + | |
1900 | 1912 | | |
1901 | 1913 | | |
1902 | 1914 | | |
1903 | 1915 | | |
1904 | 1916 | | |
| 1917 | + | |
1905 | 1918 | | |
| 1919 | + | |
1906 | 1920 | | |
1907 | | - | |
| 1921 | + | |
1908 | 1922 | | |
1909 | 1923 | | |
1910 | 1924 | | |
| |||
2074 | 2088 | | |
2075 | 2089 | | |
2076 | 2090 | | |
| 2091 | + | |
| 2092 | + | |
2077 | 2093 | | |
| 2094 | + | |
2078 | 2095 | | |
2079 | 2096 | | |
2080 | 2097 | | |
| |||
2473 | 2490 | | |
2474 | 2491 | | |
2475 | 2492 | | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
2476 | 2496 | | |
2477 | 2497 | | |
2478 | 2498 | | |
2479 | 2499 | | |
2480 | 2500 | | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
| 2504 | + | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
| 2520 | + | |
| 2521 | + | |
| 2522 | + | |
| 2523 | + | |
| 2524 | + | |
| 2525 | + | |
| 2526 | + | |
| 2527 | + | |
| 2528 | + | |
| 2529 | + | |
| 2530 | + | |
| 2531 | + | |
| 2532 | + | |
| 2533 | + | |
| 2534 | + | |
| 2535 | + | |
| 2536 | + | |
| 2537 | + | |
| 2538 | + | |
| 2539 | + | |
| 2540 | + | |
| 2541 | + | |
| 2542 | + | |
| 2543 | + | |
| 2544 | + | |
| 2545 | + | |
2481 | 2546 | | |
2482 | 2547 | | |
2483 | 2548 | | |
| |||
0 commit comments