Repository navigation
Commit f672e0d
refactor(objectql): move 36 hand-series private docblocks out of engine.ts with the codemod's third pass (slice 1 of 2) (#30341)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg1KEKUvnWZ8oYQ388cWv3dF)_
Refs #30053
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:`scripts/codemod-split-engine.mjs` 加了第三遍
`--hand-docs`:手写系列(#25522 等)私有桩的 docblock 从 `engine.ts`
的类上搬到手写模块里它调用的那个函数上,替换原来的占位注释;公有 / protected 的 docblock 留在类上。本 PR
是两片中的第一片:8 个手写模块、36 块、929 行。生成物未手改。
- 为什么改:维护者在 #30012 上说「我觉得文件还是太长,还有进一步的拆分优化空间吗」「可以后续立卡处理」「合并之后再继续」。整卡约
4,100 行改动,超过 3,000 行线,所以席位定为拆两个串行 PR、不申请冻结窗口。
- 风险与回滚:只搬注释。撤销证明逐字节还原 base `engine.ts` 和 21 个手写模块;公有 `.d.ts`
相等;objectql 测试 base 550 文件 / 10,951 = head;回滚就是 revert。
- 先看:① 下方「留在类上的」表;② `engine.ts` 顶部被剪掉的 5 个 import 绑定(只被搬走的 docblock 的
`{@link}` 引用);③ 任一手写模块头部新增的一段说明。
- 两分钟验证:`pnpm install --frozen-lockfile` 后运行 `node
scripts/codemod-split-engine.mjs --hand-docs --verify --base
a26abbc`,应看到 `36 moved (929 lines) across 8 module(s)`、`13550 -> 12618
lines`,退出码 0;`--self-test` 105 例通过。
- 需要你做的:改动共 2,573 行(未超 3,000 行线),本 PR 保持草稿,按席位安排落地。第二片(其余 10 个模块,`Fixes
#30053`)在本 PR 合并后从同一分支名接着开。
## What changes
- **`scripts/codemod-split-engine.mjs`: a third pass, `--hand-docs`.**
The hand series moved its bodies out of `engine.ts` before the codemod
existed and kept every docblock on the class; each hand-module function
carries the placeholder `/** The body of \`ObjectQL#x\`; the method's
docblock there is its contract. */`. The codemod's own rule moves a
private method's docblock with its body and keeps a public or protected
one on the class. This pass applies that rule to the hand series and
touches nothing else.
- **Which stubs.** A method whose body opens with a hand marker:
`[#25522 cut N]` (83), `[#27495]` (2) or the untagged `The body lives
in` of `serveReferenceNames` (1). 86 in all.
- **The move.** A private stub's docblock leaves the class and replaces
its function's placeholder, one level out (the hand series re-indented
every body it moved, so the functions stand at column 0). The stub's
marker gains `, its docblock with it`, the phrase the codemod's own
stubs use. The module's header docblock gains one paragraph saying
private docblocks moved here, because each header says the docblock
stays on the class.
- **The import prune.** `noUnusedLocals` counts a JSDoc `{@link X}` as a
read, so five `engine.ts` import bindings went unused once their
docblocks moved: `RelatedFieldBinding`, `collectReferenceTraversals`,
`optionVisibilityReadsPermissions`, `readsPermissionPredicate` and
`READABLE_IDS_MAX_CHAIN_DEPTH`. The pass prunes them with the first
pass's `pruneImports`. The last one was a whole `import type` that
existed only for those links, so it goes with the two `//` lines
directly above it (a new `dropAttachedComments` option; the first pass
keeps its default and its output is unchanged).
- **Slices.** `--modules a.ts,b.ts` moves only the named modules' stubs,
and a stub already moved is skipped, so the next slice runs on this
one's output.
- **The proof.** It undoes every move in the head and in the base (each
docblock back on its stub, re-indented; the placeholder back; the marker
phrase and the header note out) and requires the two to be equal,
`engine.ts` and each hand module byte for byte. The import prune is
recomputed from the head and applied to the base, and every pruned name
must be linked by a moved docblock. A base no slice touched undoes to
itself, so against `main` this is "the undo rebuilds the base"; against
a base an earlier slice landed in, it proves only the new slice.
`--hand-docs --verify --base <ref>` re-proves a tree on disk.
- **`--self-test`**: 105 cases in 8 batteries (was 86 in 7). The new
battery "hand-series docblocks (third pass)" (floor 19) covers the
verdicts, the move, the marker, the header note, determinism, slices
composing, the prune, and feeds the proof what it must refuse: one
character edited in a moved docblock, one edited elsewhere in a hand
module, a moved docblock dropped, a staying docblock dropped, a public
docblock moved, a marker over a docblock still on the class, a missing
header note, a dropped binding no moved docblock links, and an unknown
`--modules` name.
- **The generated slice.** `--hand-docs --modules <the 8 below> --write`
on `main` `a26abbc6`, unedited (the branch merged `main` and its tree
equals a fresh `--write` there).
### What moved in this slice (8 modules, 36 docblocks, 929 lines)
| Hand module | Docblocks | Lines | Before → after |
|:--|--:|--:|--:|
| `engine-secret-internal-fields.ts` | 8 | 276 | 605 → 878 |
| `engine-master-detail-related.ts` | 4 | 184 | 512 → 697 |
| `engine-readable-ids-permission-formula.ts` | 7 | 171 | 362 → 531 |
| `engine-delete-cascade.ts` | 5 | 169 | 498 → 667 |
| `engine-execution-plumbing.ts` | 4 | 56 | 128 → 185 |
| `engine-migration-flags.ts` | 3 | 32 | 295 → 329 |
| `engine-datasource-routing.ts` | 3 | 25 | 185 → 212 |
| `engine-package-registration.ts` | 2 | 16 | 212 → 231 |
`packages/objectql/src/engine.ts`: 13,550 → 12,618 lines.
### What stays on the class
| Stubs | Why |
|:--|:--|
| 20 public stubs (`validate`, `count`, `execute`, `resolveSecret`,
`checkDriversHealth`, the compatibility API, …) | the docblock is the
contract and stays on the facade |
| `validationMessageContext` | its function already carries a docblock
with more than the placeholder (an ADR-0029 D9.2a note); merging two
docblocks is an edit, not a move |
| `noteAdmittedValueShapeViolation` | it has no docblock |
### The second slice
10 modules, 28 docblocks, 858 lines: `engine-count-aggregate.ts`,
`engine-driver-options.ts`, `engine-execute-transactions.ts`,
`engine-file-reference-hydration.ts`, `engine-hook-dispatch.ts`,
`engine-query-lowering.ts`, `engine-realtime-publish.ts`,
`engine-reference-name-visible.ts`, `engine-referential-integrity.ts`,
`engine-validation-messages.ts`. The plan on this head prints exactly
that list (`--hand-docs` with no `--modules`), and its in-run proof
against this slice passes. It opens after this PR merges and carries
`Fixes #30053`.
## Verification
All at head `b09479c5` unless stated.
- **Proof.** `node scripts/codemod-split-engine.mjs --hand-docs --verify
--base a26abbc`: exit 0. `36 moved (929 lines) across 8 module(s), 0
already moved at base; engine.ts 13550 -> 12618 lines; undoing every
move rebuilds the base, undone the same way, for engine.ts and its 21
hand module(s) byte-for-byte, once the 5 import binding(s) only a moved
docblock linked are pruned`.
- **Determinism.** The head's script, run with `--write` in a separate
worktree at `a26abbc6`, writes `engine.ts` and the 8 modules
byte-identical to the committed head (`cmp`, all 9), output tree sha256
`7883ed99…8ea5`.
- **`.d.ts`.** `packages/objectql/dist` built at base `a26abbc6` twice
and at head twice. Base 1 = base 2 and head 1 = head 2, byte for byte.
Base against head: `core` and `index` (`.d.ts` and `.d.mts`) are
byte-identical; `util-HASH` has 193/193 statements and 334/334 private
members, and its public surface (each class's private members removed
with their docblocks) is **EQUAL**. The raw difference is the 929 lines
of moved private docblocks (tsc emits a private member's docblock).
Control: dropping one public docblock from the head's `.d.ts` is caught
(`DIFFERS`).
- **Ablation.** Three single-line ablations through
`scripts/ablation-replace.mjs`, each restored to the HEAD blob: the
per-module comparison off → "one edited character elsewhere in a hand
module fails" goes red (this ablation first stayed green, which is why
that case exists); the `engine.ts` comparison off → "one edited
character in a moved docblock fails" and "a staying docblock dropped
from the class fails" go red; the pruned-name link check off → "a
binding the head dropped that no moved docblock links fails" goes red.
- **Suites.** objectql `test`: base `a26abbc6` 550 files / 10,951
passed, head 550 / 10,951. objectql `typecheck` (tsc +
check:test-typecheck): exit 0.
- **Readers of these files by path.** core
`second-object-read-exposure.pin.test.ts` and
`row-serving-door-exposure.pin.test.ts` (7/7), types
`driver-error-classification.callers.test.ts` (11/11),
`check-facade-delegation-only` (OK, registry unchanged),
`check:adr-anchors` (OK; `engine.ts` still names ADR-0057, ADR-0067 and
ADR-0119), eslint on every changed file: exit 0.
- **Gates.** `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 72 commands, each run after a full
`turbo run build --filter='!@objectstack/docs'` (exit 0). All 72 exit 0;
`--ran`: 72 derived, 72 run, 0 NOT-MEASURED, 0 UNRUN.
## Acceptance notes
- `{@link}`s inside a moved docblock now sit in the hand module, where a
name the class declares (`{@link getDriver}` and the like) resolves to
the module's function of that name or to nothing. The text is unchanged
by design: the pass moves bytes, it does not rewrite them. No gate reads
those links.
- A changeset (`patch`, `@objectstack/objectql`) is included, as
#30052's was.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(not touched)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes on the changed files.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request. (the designated thread branch, as the Claim records; first of
two slices)
- [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.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Utp6CYHBS7P5hkUQrNHkHZ
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 8589756 commit f672e0d
11 files changed
Lines changed: 1567 additions & 1010 deletions
File tree
- .changeset
- packages/objectql/src
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
48 | 53 | | |
49 | 54 | | |
50 | 55 | | |
| |||
68 | 73 | | |
69 | 74 | | |
70 | 75 | | |
71 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
72 | 91 | | |
73 | 92 | | |
74 | 93 | | |
| |||
131 | 150 | | |
132 | 151 | | |
133 | 152 | | |
134 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
135 | 159 | | |
136 | 160 | | |
137 | 161 | | |
| |||
173 | 197 | | |
174 | 198 | | |
175 | 199 | | |
176 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
177 | 204 | | |
178 | 205 | | |
179 | 206 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
| |||
120 | 125 | | |
121 | 126 | | |
122 | 127 | | |
123 | | - | |
| 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 | + | |
124 | 187 | | |
125 | 188 | | |
126 | 189 | | |
| |||
141 | 204 | | |
142 | 205 | | |
143 | 206 | | |
144 | | - | |
| 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 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
145 | 249 | | |
146 | 250 | | |
147 | 251 | | |
| |||
247 | 351 | | |
248 | 352 | | |
249 | 353 | | |
250 | | - | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
251 | 383 | | |
252 | 384 | | |
253 | 385 | | |
| |||
312 | 444 | | |
313 | 445 | | |
314 | 446 | | |
315 | | - | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
316 | 479 | | |
317 | 480 | | |
318 | 481 | | |
| |||
396 | 559 | | |
397 | 560 | | |
398 | 561 | | |
399 | | - | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
400 | 569 | | |
401 | 570 | | |
402 | 571 | | |
| |||
0 commit comments