Repository navigation
Commit bfbdeec
refactor(objectql): spell the eight ObjectQL facade methods' inferred return types and move five bodies into their facets (.d.ts byte-equal) (#30571)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgKd8GqhzWbGWABewb5SLGNm)_
domain:server#5 · os-bill · session_01Utp6CYVV6fcAQrNTDQRvPb
## 维护者速读
- 改了什么:`engine.ts` 门面上 8 个因返回类型靠推断而留在类上的 `ObjectQL`
方法把返回类型写明在签名上(逐字取自今天的 `.d.ts`);其中
`getStatus`、`triggerHooks`、`setDatasourceMapping`、`init`、`destroy` 五个再用
codemod 第四遍(#30055 的 `--members`)把方法体搬进各自的 facet 模块,类上只留一行转调;allow-list
删掉这 5 行。
- 为什么改:返回类型写明后,方法体放在哪都不会改变公开类型,门面才能只剩转调(#30054 第二半,第一半是已合并的 #30516)。
- 风险与回滚:没有行为变化;`@objectstack/objectql` 的三个公开 `.d.ts` 改前改后逐字节相同,codemod
的撤销证明逐字节通过。回滚即撤本 PR。
- 先看:`packages/objectql/src/engine.ts` 里 `init` / `destroy` 的新 stub,再看
`engine-secrets-and-routing.ts` 里搬进来的 `init` 方法体。
- 两分钟验证:`node scripts/codemod-split-engine.mjs --members --verify --base
405373c` 预期 exit 0、“5 moved method(s) … does rebuild the base …
byte-for-byte”;`node scripts/check-facade-delegation-only.mjs` 预期 exit
0、56 条具名例外。
- 需要你做的:无,席位落地。`registerApp`、`registerDriver`、`registerHook` 三个 codemod
拒绝搬,留在类上(见 Acceptance notes)。
Part of #30054 (the `engine.ts` half: all eight return types spelled,
five bodies moved; three engine.ts bodies and the eight protocol.ts
bodies stay, see Acceptance notes)
Clause-②: no — the published `index.d.ts`, `core.d.ts` and the shared
declaration chunk of `@objectstack/objectql` are byte-equal before and
after, so no exported member changes.
Metadata-protocol: none
Skills-docs: none — an internal refactor of eight method signatures and
five method bodies' location; no published type or behaviour changes,
and no skill text names them.
## What changes
- **Return types (`engine.ts`).** `registerApp`, `registerHook`,
`registerDriver`, `init`, `triggerHooks`, `destroy`,
`setDatasourceMapping` and `getStatus` declare their return type, copied
from the line the base build printed for each in `dist/util-*.d.ts` (the
`ObjectQL` class), re-indented to the file's two spaces. `getStatus`
spells `name: "data"` with the printer's double quotes, which the
declaration emit keeps.
- **Moves (`--members`).** `node scripts/codemod-split-engine.mjs
--members getStatus,triggerHooks,setDatasourceMapping,init,destroy
--write`: `getStatus` and `triggerHooks` go to
`engine-hooks-and-functions.ts`, `setDatasourceMapping` and `init` to
`engine-secrets-and-routing.ts`, `destroy` to
`engine-migration-state.ts`. Each method stays on the class with its
docblock and signature as a one-call stub. Nothing generated is edited
by hand.
- **Registry.** The five moved members' rows are deleted (the gate
refuses a row whose member is already a delegation). The three rows that
stay keep card #30054 and say why each body stays.
- **Pin.** `engine.facade-return-types.pin.test.ts` parses `engine.ts`
and requires each of the eight methods to carry its exact return type
text.
- **Changeset.** `@objectstack/objectql` patch: the declarations are
byte-equal, but the shipped source maps move.
## Tests
- New pin: 9/9 at head. On `origin/main`'s `engine.ts` (restored
unstaged, then put back from `HEAD`, `git diff HEAD` empty) 8 of 9 fail,
one per method.
- Ablation (once, `scripts/ablation-replace.mjs`): `init`'s stub
annotation removed, anchor 1 → 0, blob `2fa8f560` → `20c28b40`; the pin
goes 1 failed / 8 passed, naming `init`; restored to the `HEAD` blob
with `git diff HEAD` empty.
- The facade gate is the pin for the moves: with the five rows deleted
it is red on `origin/main` (five members with a body and no row) and
green at head.
- `@objectstack/objectql` full suite: 554 files passed, 11,019 tests
passed at head `2ea0deb9d` (and the same counts before the branch moved
onto `c23eafa88`).
- `pnpm --filter @objectstack/objectql typecheck` exit 0 at head.
## Acceptance notes
- **Three bodies the `--members` pass will not move.** `registerApp` and
`registerDriver`: the pass refuses with "engine-registration.ts: its
header is not as the first pass wrote it" (that module's header was
edited by hand when `isExternalWriteForbidden` was written there,
#30370). `registerHook`: the pass writes the move but its undo proof
fails ("undoing the moves out of engine-hooks-and-functions.ts does not
rebuild its base (first difference at line 44)", in that module's import
block). Each is measured alone and together; the order lands only what
is mechanical, so their rows stay with the reason.
- **What #30054 still owes.** `engine.ts`: `registerApp`,
`registerDriver`, `registerHook` (types spelled, bodies stay).
`protocol.ts`: the eight doors typed by #30516, whose move waits on the
protocol codemod's missing facade pass (#30518). The seat decides
whether those eleven rows move to #30518 or a sibling card and the card
closes, or the card stays open.
- **A spelled type is now the published shape** (as on #30516): a later
change to what one of these methods returns edits its signature too,
because a wider body return is not refused and the `.d.ts` prints the
signature.
- **The branch.** #30516 was squash-merged from this same branch. A
force-push to restart it from `main` was refused in this session, so the
branch merges `origin/main` over #30516's old commits (the merged tree
equals `main` exactly: `git diff origin/main` was empty before this PR's
commits), and the PR's commit list shows those old commits. The diff is
this PR's seven files only.
## Verification
Head `2ea0deb9d`, base `origin/main` `c23eafa88`.
<details><summary>Declaration-file proof</summary>
- Base: `origin/main` `c23eafa88`'s `engine.ts` and its three facet
modules restored into the head tree, `turbo run build
--filter=@objectstack/objectql...`, `core.d.ts`, `index.d.ts` and
`util-DJB5AN6K.d.ts` copied aside (byte-equal to the first base build at
`8e5fabe58`, from which the types were copied).
- Head: `pnpm build` in `packages/objectql` (tsup with DTS, then
`check-dts-emitted`); `cmp` against the base copies: all three
byte-equal (`util-DJB5AN6K.d.ts` sha256 `7f1e928b2f3aceac…`). The same
held after the annotation commit alone, before the move.
- The diff of the emitted declarations is empty.
</details>
<details><summary>Codemod proof</summary>
- `--members getStatus,triggerHooks,setDatasourceMapping,init,destroy`
plan, then `--write`: output tree sha256 `ebff07ef5c50e416…` both times;
"5 moved method(s) … engine.ts 11321 -> 11223 lines; undoing the moves
does rebuild the base engine.ts and its modules byte-for-byte once the 7
import binding(s) only moved bodies read are pruned from the base".
- `--members --verify --base 405373c` (the annotation commit, on this
base) exit 0 with the same reading.
</details>
<details><summary>Gates</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at head `2ea0deb9d`: 70 derived commands
(change set: 7 paths, +262 / -168, under the 3,000 threshold). Each ran
with its exit code recorded before any pipe; all 70 exit 0. `--ran`
reconciles 70 derived, 70 run, 0 NOT-MEASURED, 0 UNRUN.
- `node scripts/check-facade-delegation-only.mjs`: "5 facade class(es)
in 3 file(s) hold delegations only, 56 named exception(s)", exit 0.
Against `origin/main`'s tree (`--root` a detached `c23eafa88` worktree,
`--registry` this head's): exit 1, five problems, one per moved member.
- eslint `--no-inline-config` over the five changed source files exit 0
at head.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CXZTh9qvT24wTN6dd6)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent c447019 commit bfbdeec
7 files changed
Lines changed: 262 additions & 168 deletions
| 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 | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
| 8 | + | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
81 | 98 | | |
82 | 99 | | |
83 | 100 | | |
| |||
162 | 179 | | |
163 | 180 | | |
164 | 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 | + | |
165 | 225 | | |
166 | 226 | | |
167 | 227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| |||
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| 80 | + | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| |||
427 | 429 | | |
428 | 430 | | |
429 | 431 | | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
430 | 456 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
| |||
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
| 59 | + | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
| |||
264 | 268 | | |
265 | 269 | | |
266 | 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 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
267 | 328 | | |
| 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 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 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 | + | |
0 commit comments