Repository navigation
Commit 9b8a586
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBWMEECkfNfe2VjW9rMJG3n7)_
Part of #30147 (phase 2a of 2a-2d: the sql-driver codemod learns six
mechanisms and retires 15 exception rows. 2b, 2c and 2d, then the phase
3 measurement, stay open on the card.)
## 维护者速读
- 改了什么:`scripts/codemod-split-sql-driver.mjs` 新增六种机制(knex
调用、写出返回类型、参数列表里的注释、getter、计算型参数默认值、`logger` 字段默认值),用它重新生成
`sql-driver.ts` 和 9 个模块(新增 `sql-driver-schema-introspection.ts`),登记表删去
15 条 sql-driver.ts 例外(88 → 73)。
- 为什么改:#30147 要求 codemod 自己移走这些"能力不足"的例外,而不是手改生成结果。
- 风险与回滚:方法体逐字节不变(171/171),公开 `.d.ts` 与 base 逐字节相同;回滚即 revert 本 PR。
- 先看:codemod 里四张新表 `RECEIVER_FREE_FIELDS` / `EXPLICIT_RETURN_TYPES` /
`MOVED_ACCESSORS` / `MOVED_FIELD_DEFAULTS`,以及 `verify` 里对应的撤销逻辑。
- 两分钟验证:`node scripts/codemod-split-sql-driver.mjs --verify --base
21510bb`,预期 `171/171 moved bodies identical to base`、`sql-driver.ts
18334 -> 10717 lines`,退出 0;`node
scripts/check-facade-delegation-only.mjs` 打印 73 条具名例外,退出 0。
- 需要你做的:无,席位审阅并落地。
Clause-②: no
Metadata-protocol: none
## What changes
The sql-driver codemod (`scripts/codemod-split-sql-driver.mjs`) learns
six mechanisms. Each one is regenerated from the unsplit `sql-driver.ts`
at `21510bba` and re-proved by `--verify` (undoing the split rebuilds
the base byte for byte). No generated file is edited by hand.
| mechanism | table or rule | members it moves |
|:--|:--|:--|
| a body may call `this.knex(...)` | `RECEIVER_FREE_FIELDS` (a Knex
instance is the `function knex(tableName, options)` closure, which reads
`knex.context`, never `this`) | `listPhysicalColumns`,
`explainUnkeyableTextColumn`, `explainHashShadowDuplicate` (and
`getBuilder`'s field-call half) |
| the stub writes the return type the base leaves inferred |
`EXPLICIT_RETURN_TYPES` (types copied from `dist/index.d.ts` built at
base) | `getBuilder`, `applyFilters`, `ensureDatabaseExists`,
`createDatabase` |
| a comment between the parentheses moves with the base list verbatim |
rule (the `comment-in-parameters` stay reason is gone) |
`assertOperatorAppliesToColumn` |
| a get accessor keeps its signature; its body moves | `MOVED_ACCESSORS`
| `insertReturnsStoredRows`, `dateGranularityCapabilities`,
`supportsWalJournal`, `dialectName` |
| a computed parameter default is written optional on the stub (`nowMs?:
number`) and stays where the body is | rule (the gate's own data-default
reading, mirrored) | `rotateShards`, `ensureRotation` (hand-series
stubs: the default stays in the seam function) |
| a field initializer becomes a facet member typed as the field |
`MOVED_FIELD_DEFAULTS` (instance fields only) | `logger` |
`sql-driver.ts` goes from 10,979 to 10,717 lines. Moved bodies go from
158 to 171.
Registry (`scripts/facade-delegation-registry.json`): the 15 rows those
members held are deleted (the gate refuses a row whose member is already
a delegation). Five rows that stay get their reason rewritten for the
half that remains:
- `applyFilterCondition`: inferred-return-type only (2d).
- `ensureShardTable` and `initObjects`: path-reader only (their knex
half is retired).
- `get supports`: an accessor whose object type the base leaves
inferred, with a docblock on each key.
- `static DIALECT_CONNECT_TIMEOUT`: a static initializer runs while the
class is evaluated, so a facet call there could meet its module in the
temporal dead zone.
| card | before | after |
|:--|--:|--:|
| #30020 | 17 | 17 |
| #30054 | 16 | 16 |
| #30055 | 6 | 6 |
| #30147 | 49 | 34 (sql-driver.ts 27 → 12) |
| total | 88 | 73 |
`scripts/check-tenant-chokepoint.mjs` lists the new
`sql-driver-schema-introspection.ts` in `DECLARED_WATCH_HINTS`, as its
self-test requires for every scanned module.
## Tests
- The codemod's `--self-test` gains a sixth pinned battery,
"codemod-limit retirements (#30147)", with 31 cases: each mechanism
moves only when its table names it; the generated text; two runs give
one tree; the generated split proves; one edit per mechanism fails the
proof (an unlisted return type, an edited written type, an edited
comment, an edited getter body, an optional parameter spelled with
another type, a facet member or seam that drops the default, a missing
seam, an edited initializer, a field calling another member); every
stale or wrong table row refuses. 98 cases in 6 batteries pass (67 in 5
before). The battery floor goes from 5 to 6.
- No test file changes. The suites below ran at base `f2a9007e` and at
head; the counts are equal.
| suite | base | head |
|:--|:--|:--|
| driver-sql (`vitest run`) | 238 files passed, 12 skipped; 3,859
passed, 216 skipped | the same |
| driver-turso (subclasses `SqlDriver`) | 97 files; 2,514 passed, 34
skipped | the same |
| driver-sqlite-wasm (subclasses `SqlDriver`) | 40 files; 750 passed |
the same |
| cli by-path pins (9 files: generate-* pins,
`clean.operator-text-21418`, migrate, schema-migrate) | 9 files; 116
passed | the same |
| types / metadata / metadata-protocol by-path tests, spec
`check-liveness.test` | 53 / 11 / 33 / 74 passed | the same |
## Acceptance notes
- The four written return types came from the base's declaration output
(`dist/index.d.ts` of `@objectstack/driver-sql` built at base), not from
reading the source.
- `get supports` and `static DIALECT_CONNECT_TIMEOUT` stay on #30147
with no sub-phase planned yet; 2b-2d cover the path-reader rows,
`createColumn` and `applyFilterCondition`.
- No changeset, as #30139 (`skip-changeset`): no published behaviour or
surface changes (the public `.d.ts` is byte-identical).
## Verification
Head `34fc09d0`, base `origin/main` `f2a9007e`.
<details><summary>Proof readings</summary>
- Byte-identity: `node scripts/codemod-split-sql-driver.mjs --verify
--base 21510bb` exit 0: "171/171 moved bodies identical to base (body,
parameters, return type, async); 127/127 moved top-level declarations
identical to base; sql-driver.ts 18334 -> 10717 lines; undoing the split
does rebuild the base byte-for-byte".
- Determinism: two `--write` runs from the unsplit input give output
tree sha256
`07b3a5053a23098c2754bb36caefb96532bbc4c7497ae29ab5dd357aff036454` both
times (input sha256 `2d2ebebd…`).
- Public `.d.ts`: `dts-public.mjs` over the base and head `dist` exit 0,
`pass: true`, both files raw-equal (`index.d.ts` sha256 `92e2cfb2…` on
both sides). `rotateShards` and `ensureRotation` read the same at base
and head, `nowMs?: number` in both (signature hashes `c8bded77…` and
`d0ab9226…` on both sides); so do `getBuilder` and `get dialectName`.
- Typecheck: `pnpm --filter @objectstack/driver-sql typecheck` exit 0.
- `check-tenant-chokepoint`: base and head both read 24 `getBuilder()`
bindings, 21 read doors, 3 insert builders, 4 tenant predicates, 0 D8
arms (38 files at base, 39 at head: the new module); `--self-test` exit
0.
- Facade gate: `node scripts/check-facade-delegation-only.mjs` exit 0,
"3 facade file(s) hold delegations only, 73 named exception(s)";
`--self-test` exit 0, 36 cases (gate script and its cases untouched).
- `node scripts/pm/dispatch-gates.mjs --commands`: 67 derived commands,
each run, all exit 0; `--ran` reconciles 67 derived, 67 run, 0
NOT-MEASURED. Two first exited 3 on prerequisites (the shallow clone
lacked the `check-plugin-teardown-shape` fixture commit;
`check:dual-build-cjs-loads` needed unbuilt dists): after fetching that
commit and building those packages, both exit 0.
- Also run: the codemod, `check-tenant-chokepoint` and facade gate
`--self-test`s (exit 0), `check:lean-entry-closure` (exit 0), eslint
over the changed scripts and driver-sql sources (exit 0).
- Changed lines 1,551 (+1,052 / -499), under the 3,000 threshold.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzj4B2cbnRLVdgtLcDZ)_
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1d41037 commit 9b8a586
13 files changed
Lines changed: 1052 additions & 499 deletions
File tree
- packages/drivers/driver-sql/src
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| 64 | + | |
| 65 | + | |
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
| |||
68 | 71 | | |
69 | 72 | | |
70 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
71 | 82 | | |
72 | 83 | | |
73 | 84 | | |
| |||
90 | 101 | | |
91 | 102 | | |
92 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
93 | 109 | | |
94 | 110 | | |
95 | 111 | | |
96 | 112 | | |
97 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
98 | 135 | | |
99 | 136 | | |
100 | 137 | | |
| |||
| 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 | 11 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
| 63 | + | |
61 | 64 | | |
62 | 65 | | |
| 66 | + | |
63 | 67 | | |
64 | 68 | | |
65 | 69 | | |
| |||
89 | 93 | | |
90 | 94 | | |
91 | 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 | + | |
92 | 191 | | |
93 | 192 | | |
94 | 193 | | |
| |||
277 | 376 | | |
278 | 377 | | |
279 | 378 | | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 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 | + | |
| 456 | + | |
| 457 | + | |
280 | 458 | | |
281 | 459 | | |
282 | 460 | | |
| |||
0 commit comments