Repository navigation
Commit d8ed2e1
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DEaLDouphrUMvBWbK52b3uh)_
Refs #30518
Refs #30054
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:给 `scripts/codemod-split-protocol.mjs` 加了 `--members` 通道,能在已落地的
protocol.ts 门面上把单个方法体搬进它所在的 facet;并用它搬走了 #30054 的六个门(getData、cloneData
与四个 *MetaItem)。
- 为什么改:原 codemod 拒绝在自己的输出上运行,`--verify` 也因 facet
模块被手改过而无法再证明,八个门的方法体只能留在类上当例外。
- 风险与回滚:纯搬移,方法体逐字节不变,公开 `index.d.ts` / `index.d.cts` 前后字节相等;回滚即 revert 本
PR。
- 先看:`scripts/codemod-split-protocol.mjs` 的 members
一节(生成与逆向证明);`protocol-data-crud.ts` 新增的 import
块;`scripts/facade-delegation-registry.json`。
- 两分钟验证:`node scripts/codemod-split-protocol.mjs --members --verify
--base f4d568b`(本 PR 的基点),预期输出 `undoing the moves does rebuild …
byte-for-byte`、退出码 0。
- 需要你做的:无,席位落地。
## What changes
**The tool.** `scripts/codemod-split-protocol.mjs --members A,B
[--write]` moves named instance methods of the split
`ObjectStackProtocolImplementation` into the facet of their section,
exactly as the first pass would have taken them: the same stay rules
(`plan`, any reason refuses), `host-split.mjs`'s `planMove` and
`insertHostEntries`, the first pass's lift and docblock-ownership rule,
and the lifted one-line stub. `--members --verify --base REF` re-proves
the moves on disk. The first pass is unchanged and still refuses its own
output.
It accepts the hand edits `main`'s facet modules carry (header
paragraphs after the generated first one, imports, top-level
declarations, facet members nobody moved). It grows only: the generated
first header paragraph (the name, re-wrapped), the facet class (the
member in class order), and the import block (a binding joins a
declaration of its specifier and kind in that declaration's own layout,
or becomes a new declaration, in `protocol.ts`'s import order). It
refuses a facet `protocol.ts` does not already import, a body reading a
top-level name the generated export list does not export, a first
paragraph that is not the generated one, and a binding the module holds
under another source or kind. This is the same acceptance rule #30572
asks of the `engine.ts` `--members` pass (hand-edited headers and import
blocks), kept consistent here; the engine codemod is not touched.
**The proof** is the undo against the pre-move tree, not the split's
#29985 base: from the head alone, each moved body (rewrites and
re-indentation undone) and any owned docblock goes back on its stub;
each receiving module loses the moved members, their header names and
the import bindings nothing reads any more; the factory and the
interface lose the entries the base host did not carry. The result must
be the base `protocol.ts` (its import bindings only moved bodies read
pruned, as the first pass prunes them), `protocol-host.ts` and receiving
modules byte for byte, every other section module unchanged, each facet
member its base method's text as the first pass lifts it, and
`host-split.mjs`'s `checkMove` green on the unlifted pair.
**The moves.** `getData`, `cloneData`, `saveMetaItem`,
`publishMetaItem`, `rollbackMetaItem` and `deleteMetaItem` now delegate
to `ProtocolDataCrudFacet`, `ProtocolSaveFacet`,
`ProtocolHistoryAndPublishFacet`, `ProtocolPackageCommitsFacet` and
`ProtocolDiffDeleteLoadFacet`; `protocol-host.ts` gains the eight
entries those bodies read. Their six rows leave
`scripts/facade-delegation-registry.json` (50 named exceptions remain).
Written by `node scripts/codemod-split-protocol.mjs --members
getData,cloneData,saveMetaItem,publishMetaItem,rollbackMetaItem,deleteMetaItem
--write`, no hand edit after it.
`getDiscovery` and `findData` stay for the second PR of #30518: all
eight together come to 3,775 changed lines, over the 3,000-line budget.
Their two rows now name #30518.
## Why
#30054 spelled the eight doors' return types (PR #30516) so their bodies
could leave the facade, but the codemod could not move a member of a
facade that had already landed. #30518 asked for that pass.
## Tests
- `node scripts/codemod-split-protocol.mjs --self-test`: 85 cases in 10
batteries pass. Three new batteries: `members pass` (8: the move proves;
stub; class-order placement before the next member and last; header
paragraph with a hand-written paragraph kept; import joins its
declaration; new declaration ahead of `ProtocolHost`'s with a
hand-written import kept; `protocol.ts` prune; determinism), `members
proof` (12 negative controls, each must change the head and must fail:
an edited moved body, an edited hand-written facet member, a second
blank line, a header missing a name, a changed untouched module, an
edited interface entry, an entry no `Pick` names, a stub calling another
facet, an edited public docblock, an edit elsewhere in `protocol.ts`, a
dropped import no moved body reads, a proof over nothing) and `members
refusals` (10).
- The pass on `main` (`f4d568ba`): `--members` (six names) exits 0 and
`--members --verify --base HEAD~1` at head exits 0: 6 moved, `checkMove`
6/6, `protocol.ts` 13,927 -> 13,743 lines, 9 import bindings pruned.
Measured also with all eight names: exit 0, `checkMove` 8/8, the built
declarations byte-equal too.
- `@objectstack/metadata-protocol` at `c2e3fa7f`: vitest 317 files
passed / 4 skipped, 22,454 tests passed / 26 skipped (exit 0);
`typecheck` exit 0.
- Facade gate negative control: the head registry over `main`'s `src/`:
exit 1, six problems, one per moved door; at head exit 0 (50 named
exceptions).
## Acceptance notes
- Premises re-measured on `main` `f4d568ba`: the first pass still
refuses its own output (exit 2), and `--verify --base 48914fd^` is now
77/85 bodies and 69/78 `checkMove` (the card read 79/85, 71/78; more
hand edits since).
- The second PR (same card thread, `Fixes #30518`) moves `getDiscovery`
and `findData` with this pass. `findData` has a path reader,
`protocol.query-transport-dialect.test.ts` (`the fold names the spec
export at the call site` reads `protocol.ts`), which goes red when only
the body moves (measured); that PR gives the reader the facet module, as
ruling 6597555122 item 3 does. `scripts/check-filter-alias-parity.mjs`
also reads `protocol.ts` and is re-run there.
- `PATH_READER_NEEDLES` is empty in this codemod, so the first pass
would not have kept `findData` for that reader either; not changed here
(it is the first pass's table).
- A lifted public member's return type keeps the method's own line
breaks re-indented one level, as the first pass's lift writes it (the
undo depends on it).
- The `--self-test` of this codemod is not run by a CI workflow (true on
`main` too); run locally above.
## Verification
<details><summary>Declaration files</summary>
`pnpm --filter @objectstack/metadata-protocol build` at base `f4d568ba`
and at head: `dist/index.d.ts` and `dist/index.d.cts` `cmp` byte-equal
(sha256 `726c856a6a748865…` on both sides).
</details>
<details><summary>dispatch-gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands` at `c2e3fa7f`: 78
families derived, each run with its exit code captured before any pipe.
- 77/78 exit 0 (two after their prerequisite:
`check-plugin-teardown-shape.mjs --self-test` exit 3 in the shallow
clone, exit 0 after fetching its pinned commit;
`check:lean-entry-closure` exit 3, exit 0 after `pnpm turbo run build
--filter=@objectstack/objectql`).
- NOT MEASURED: `pnpm check:dual-build-cjs-loads` (exit 3, needs a
whole-tree build; CI runs it).
- `dispatch-gates --ran`: 78 derived, 77 run, 1 NOT-MEASURED, 0 UNRUN.
- `node scripts/check-facade-delegation-only.mjs` exit 0 (50 named
exceptions); `eslint --no-inline-config` over the 9 changed source files
exit 0; `node scripts/codemod-split-protocol.mjs --self-test` exit 0.
</details>
<details><summary>Changed lines</summary>
1,353 changed lines (+1,098 / -255) in 11 files, under 3,000:
`scripts/codemod-split-protocol.mjs` +711/-1, `protocol-data-crud.ts`
+220/-2, `protocol.ts` +19/-203, `protocol-history-and-publish.ts`
+59/-1, `scripts/facade-delegation-registry.json` +4/-40,
`protocol-save.ts` +28/-2, `protocol-diff-delete-load.ts` +19/-2,
`protocol-package-commits.ts` +18/-2, the changeset +10,
`protocol-host.ts` +7, the return-type pin's docblock +3/-2.
</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. (Not touched.)
- [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 by [Claude
Code](https://claude.ai/code/session_016WV4cweKLi1i8z12wPbsnw)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 7da99b7 commit d8ed2e1
11 files changed
Lines changed: 1098 additions & 255 deletions
File tree
- .changeset
- packages/metadata-protocol/src
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
24 | 37 | | |
25 | 38 | | |
26 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 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 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
27 | 245 | | |
28 | 246 | | |
29 | 247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
370 | 371 | | |
371 | 372 | | |
372 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
373 | 390 | | |
374 | 391 | | |
375 | 392 | | |
| |||
0 commit comments