Repository navigation
Commit 26f5719
feat(scripts): codemod-split-protocol --members moves the bodies E1 refuses, unedited, and retires nineteen protocol.ts facade rows (#30954)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DKNzscdiyWjPUtwr9RQB2g1)_
Part of #30147
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:`scripts/codemod-split-protocol.mjs --members`
新增三种不改写方法体的搬移形式(`.call(host)` 接收者、statics 转发器、无接收者的 plain
形式)外加静态表搬到叶子模块,并用它把 protocol.ts 上 19 个还留着方法体的成员搬进各自的 facet。
- 为什么改:这 19 个成员是 facade 门禁登记里引用 #30147 的例外行;E1 改写(`this.x` →
`host.x`)搬不了它们,只能当例外留在类上。
- 风险与回滚:纯搬移,方法体逐字节不变(撤销证明重建 base 树);公开 `index.d.ts` 的表面不变,只有 14 个
private 成员的 docblock 随方法体搬走;回滚即 revert 本 PR。
- 先看:`packages/metadata-protocol/src/protocol.ts` 顶部新增的
`ObjectStackProtocolImplementationStatics` 与类尾的 static
block;`scripts/codemod-split-protocol.mjs` 的 receiver forms
一节;`scripts/check-durability-degradation-log-level.mjs` 的 stub 解析。
- 两分钟验证:`node scripts/codemod-split-protocol.mjs --members --verify
--base 616311c`,预期输出 `forms: e1 2, plain 5, statics 5, receiver 3,
table 4` 与 `undoing the moves does rebuild … byte-for-byte`,退出码 0。
- 需要你做的:无,席位落地。
## What changes
**The tool.** The members pass (#30518) moved a member only when E1's
rewrite could carry it, so it refused a local named `host`, a body that
reads no member, and every private static that reads the class. It now
ports the two mechanisms the sql-driver codemod grew (#30249, #30306),
for
those reasons only (`RECEIVER_SOLVES`), and moves the body unedited:
- **receiver**: the facet member's `this` is typed as the `Pick` of
`ProtocolHost`
it reads, and the stub runs it on the host: `return
FACET.x.call(protocolHost(this), …)`.
- **statics**: `ObjectStackProtocolImplementationStatics`, declared
ahead of
the class and filled by a static block at its end, forwards each static
a
moved body reads. A facet module imports it AS the class name, so a body
that names the class reads it unedited; a private static that reads
`this` runs on it:
`FACET.x.call(ObjectStackProtocolImplementationStatics, …)`.
- **plain**: a body that reads nothing of the class: `return
FACET.x(…)`.
- **table**: a private static readonly field's initializer moves to its
section's leaf, `protocol-write-gates-tables.ts`, which imports no
relative module (an initializer runs while the class is evaluated).
- A predicate a moved body reaches through the host gets a host entry
typed
as the predicate, so the narrowing survives the hop.
The undo proof covers every form: from the head alone each stub, facet
member, forwarder entry, host entry and leaf is undone and the result is
the base tree byte for byte.
**The moves.** Nineteen members, all in sections that already have a
facet:
`reconcileViewExpansions`, `packagelessOverlayWriteRefusal`,
`namedBaseOverlayWriteRefusal`, `mergesOverlayAtRead`,
`registryAllowsOverlay`, `isOverlayAllowed`, `isRuntimeCreateAllowed`,
`codeOnlySourceHint`, `codeOnlyCreateError`, `codeOnlyOverrideError`,
`refuseOrganizationScopedWrite`, `overlayPackageMismatchError`,
`rethrowUnlessMetadataStoreUnprovisioned`, `objectExtensionItemRefusal`,
`packagedBaseRefusal` and the four tables `OVERLAY_ALLOWED_TYPES`,
`STATIC_REGISTRY_TYPES`, `RUNTIME_CREATE_ALLOWED_TYPES`,
`OVERLAY_CAPABLE_TYPES`. Forms: e1 2, plain 5, statics 5, receiver 3,
table 4. `protocol.ts` goes from 13,007 to 12,577 lines.
**The registry.** The nineteen rows are deleted (46 to 27 exceptions).
`triggerAutomation` stays, its reason rewritten as an accepted
exception:
its body is one `throw`, and its section has no facet module, which this
pass never starts. `getDiscovery` (a hand move) and the engine.ts and
sql-driver.ts rows are the later PRs of this card.
**Followers of the moved bodies.**
- `check-durability-degradation-log-level.mjs` resolved a stub only in
the
E1 and facade-host shapes, so three read seams whose catch delegates to
the moved `rethrowUnlessMetadataStoreUnprovisioned` read as inventing an
answer. Its resolver now follows the receiver, statics and plain stubs
to
the facet member, and a facet member's `this.x()` through the imported
host or forwarder interface. Its output on this tree is byte-identical
to
the base's.
- Three source-reading pins in `packages/metadata-protocol` follow the
moved
bodies: the bracketed-opener scan's producer floors, the `registerItem(`
call site's file, and the view-expansion record's forwarder read.
- One platform-checklist citation (`protocol.ts#refusal`) points at
`protocol-write-gates.ts`.
## Why
Ruling 6624345766 item 3 wants every facade-gate exception row to name
the
card that moves it, and #30147 phase 3 measured that one codemod port
would
retire about 19 of its 21 protocol.ts rows (comment 6653253380). The
rows
that stay are named in this card's report.
## Tests
- `node scripts/codemod-split-protocol.mjs --self-test`: 112 cases in 13
batteries pass (85 in 10 before). The three new batteries generate each
form on a fixture, fail ten mutations of the proof, and refuse seven
inputs no form carries.
- `check-durability-degradation-log-level.mjs --self-test`: 86 read-seam
cases pass (81 before). Ablation: the five new cases against the base
resolver fail the three positive ones; the two negative controls pass on
both.
- `@objectstack/metadata-protocol` vitest: base `4d56914aaa` 320 files
passed, 4 skipped; 22,487 tests passed, 26 skipped. Head `ae519e3e99`:
320
files and 22,489 tests pass, 26 skipped (the two new producer rows of
the
bracketed-opener pin are the +2; one file first read a `spec` dist built
before the rebase onto `616311c126` and passes, 18/18, once rebuilt).
- `packages/rest` vitest at `7d49cfc21` (this branch before its rebase
onto four unrelated `main` commits): 398 files, 7,752 tests passed, 354
skipped. At base the local worktree loaded 383 of 398 files (15 import a
sibling package's `src` that the worktree had no `node_modules` for),
all
of them passing. `discovery-search-capability-agreement.test.ts` 4/4 at
base and
head.
## Acceptance notes
- **The `.d.ts` bar.** The public surface of `dist/index.d.ts` and
`dist/index.d.cts` is equal. The files are not byte-equal: 14 private
members' docblocks changed, because a private member's docblock moves
with
its body (docblock ownership, as in #29985). Stripped of docblocks the
two
sides are identical (sha256 `5cf3216a10daa533…` base,
`9cab7eb90040d456…`
head).
- **The one difference a body could see.** A static reached through the
forwarder runs with the class as `this`, never a subclass; every static
it forwards is private, so no subclass reaches one.
- **Doc hover.** `{@link ObjectStackProtocolImplementation.x}` in a
facet
module that imports the forwarder now resolves to the forwarder.
- No open pull request touches
`packages/metadata-protocol/src/protocol*.ts`
(checked against all open pulls at the time of writing).
## Verification
<details><summary>Undo proof</summary>
`node scripts/codemod-split-protocol.mjs --members --verify --base
616311c` at `ae519e3e99`: exit 0.
```text
undo proof (#30518, #30147): 19 moved member(s) (objectExtensionItemRefusal, rethrowUnlessMetadataStoreUnprovisioned, mergesOverlayAtRead, registryAllowsOverlay, isOverlayAllowed, isRuntimeCreateAllowed, codeOnlySourceHint, codeOnlyCreateError, codeOnlyOverrideError, refuseOrganizationScopedWrite, packagedBaseRefusal, packagelessOverlayWriteRefusal, namedBaseOverlayWriteRefusal, overlayPackageMismatchError, reconcileViewExpansions, OVERLAY_ALLOWED_TYPES, STATIC_REGISTRY_TYPES, RUNTIME_CREATE_ALLOWED_TYPES, OVERLAY_CAPABLE_TYPES); forms: e1 2, plain 5, statics 5, receiver 3, table 4; host-split check: 2/2 E1 move(s) pass (the receiver forms move bodies unedited, proved byte-equal); protocol.ts 13007 -> 12577 lines; undoing the moves does rebuild the base protocol.ts, protocol-host.ts and section modules byte-for-byte once the 9 import binding(s) only moved bodies read are pruned from the base (OBJECT_EXTENSION_TYPE, ObjectExtensionRegistry, SINGULAR_TO_PLURAL, metadataReadFailureError, namedBaseCloseSubject, objectExtensionItemRefusal, packagedBaseRegimeRow, packagelessCloseSubject, packagelessOverlayWriteRefusal)
```
</details>
<details><summary>Facade gate and companions</summary>
`node scripts/check-facade-delegation-only.mjs`: exit 0, 27 named
exceptions. `pnpm --filter @objectstack/metadata-protocol typecheck`
exit 0,
`build` exit 0. `pnpm check:platform-checklist` exit 0.
`pnpm --filter @objectstack/spec check:liveness` exit 0. eslint on the
changed files: clean.
</details>
<details><summary>dispatch-gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at `ae519e3e99`: 86 families derived, all 86
run, all exit 0 (codes captured before any pipe). `--ran`: 86 derived,
86 run, 0 NOT-MEASURED, 0 UNRUN. Four gates first answered PREREQUISITE
NOT MET or red on a partial build or a shallow clone
(`check-plugin-teardown-shape --self-test`,
`check:dual-build-cjs-loads`, `check:lean-entry-closure`) or before the
durability resolver fix (`check:durability-log-level`); each exit 0 on
the re-run after a full `pnpm build`.
</details>
<details><summary>Changed lines</summary>
2,459 changed lines (+1,720 / −739, 15 files, changeset included), under
the 3,000 budget.
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016WV4cxm997Tr9c3JFQTKGj
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 7569fb5 commit 26f5719
16 files changed
Lines changed: 1725 additions & 740 deletions
File tree
- .changeset
- docs/qa/platform-checklist/areas
- packages
- metadata-protocol/src
- spec/src/kernel
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2068 | 2068 | | |
2069 | 2069 | | |
2070 | 2070 | | |
2071 | | - | |
| 2071 | + | |
2072 | 2072 | | |
2073 | 2073 | | |
2074 | 2074 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| |||
201 | 202 | | |
202 | 203 | | |
203 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
204 | 226 | | |
205 | 227 | | |
206 | 228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| 59 | + | |
| 60 | + | |
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| |||
233 | 236 | | |
234 | 237 | | |
235 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
236 | 316 | | |
237 | 317 | | |
238 | 318 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| 140 | + | |
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
| |||
163 | 164 | | |
164 | 165 | | |
165 | 166 | | |
| 167 | + | |
166 | 168 | | |
167 | 169 | | |
168 | 170 | | |
| |||
0 commit comments