Repository navigation
refactor(driver-sql): put SqlDriver into facade form with the sql-driver codemod (sql-driver.ts 18,334 -> 10,979, body-identical) - #30139
objectstack-fleet[bot] wants to merge 4 commits into
Conversation
…ation Claude-Session: https://claude.ai/code/session_01WGufzhBZia3VxBbmZ7wCkS Co-authored-by: Claude <noreply@anthropic.com>
…tyFailure on the class The facade registry gains the sql-driver.ts / SqlDriver row and one exception row per member that keeps a body (28). The codemod gains a PATH_READER_PINS row for logDurabilityFailure: check-durability-degradation- log-level judges the two staying MySQL widening catches by following that helper to its body in the same file, and a one-call stub there reads as "swallowed, no log". Regenerated: 158/254 methods move; sql-driver.ts 18,334 -> 10,979 lines. Claude-Session: https://claude.ai/code/session_01WGufzhBZia3VxBbmZ7wCkS Co-authored-by: Claude <noreply@anthropic.com>
…or dispatch-gates The gate scans every sql-driver-*.ts module and its self-test requires each scanned file to be named in DECLARED_WATCH_HINTS. The facade split adds sql-driver-class-head.ts, sql-driver-deferred-ddl.ts, sql-driver-facet-hosts.ts and sql-driver-transactions-section.ts. The readings are unchanged (24 bindings, 21 read doors, 3 insert builders, 4 tenant predicates, 0 D8 arms; 34 -> 38 files). Claude-Session: https://claude.ai/code/session_01WGufzhBZia3VxBbmZ7wCkS Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 36 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 12 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 13 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 40849b0a2f99ef9c25ccbb8414f606f44a07011a && git checkout 40849b0a2f99ef9c25ccbb8414f606f44a07011a
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin a9fb14bdeeb5e09fec341ead4e0fffd8d8ed00bb 61c98d18b4957164bb4d3e2fe56dd37712ec4675 && git checkout -B drift-repro a9fb14bdeeb5e09fec341ead4e0fffd8d8ed00bb && git merge --no-ff 61c98d18b4957164bb4d3e2fe56dd37712ec4675
node scripts/docs-audit/affected-docs.mjs --json a9fb14bdeeb5e09fec341ead4e0fffd8d8ed00bb
|
…#30147 The accessor, computed-parameter-default, path-reader, knex field-call, inferred-return-type and comment-in-parameters rows move from #30020 to #30147, the card filed for them. The three state-owning rows (constructor, logger, static DIALECT_CONNECT_TIMEOUT) stay on #30020. Claude-Session: https://claude.ai/code/session_01WGufzhBZia3VxBbmZ7wCkS Co-authored-by: Claude <noreply@anthropic.com>
Requested by Yibo Wang · project thread
Part of #30105
维护者速读
scripts/codemod-split-sql-driver.mjs(Codemod split pilot: generate the sql-driver.ts split with a deterministic script, verified byte-identical #29520 的试点脚本)加上engine.ts/protocol.ts已有的门面层,并重新生成sql-driver.ts。SqlDriver成为门面:158 个方法体移入 21 个无状态 facet 类(静态方法,this是一个具名 host),类上各留一行.call(xHost.of(this), …)委派;私有方法的文档块随方法体移走(21 个),公开和受保护方法的文档块留在门面;状态全部留在门面。生成文件未手改。.d.ts门槛按 6624345766 取「公开面相等」。sql-driver.ts;两次--write输出树 sha256 相同。公开面.d.ts相等(对照抓到)。driver-sql 测试 base 与 head 都是 3,859 通过;turso、sqlite-wasm 两个子类驱动计数不变。回滚即 revert。CLASS_HEAD_SECTION和新加的logDurabilityFailurepin;③check-tenant-chokepoint.mjs新登记的 4 个模块。pnpm install --frozen-lockfile后运行node scripts/codemod-split-sql-driver.mjs --verify --base 21510bba,预期158/158 moved bodies identical to base、sql-driver.ts 18334 -> 10979 lines,退出码 0;--self-test67 例通过;node scripts/check-facade-delegation-only.mjs退出码 0。sql-driver.ts;本 PR 保持草稿。Clause-②: no
Metadata-protocol: none
What changes
scripts/codemod-split-sql-driver.mjsgains the facade layerscripts/codemod-split-engine.mjscarries (refactor(objectql): generate the engine.ts section split with a deterministic codemod #30012, refactor(objectql): one shared host per facet in the engine.ts codemod stubs (body-identical; engine.ts 14,140 -> 13,548) #30083):sql-driver-crud.ts→CrudFacet), at class indentation, unedited. Theirthisis one named host interface typed AS the class members (SqlDriver['x']), so a private member is reached like a public one.asyncis dropped) and makes one call:return CrudFacet.x.call(crudHost.of(this), …). Each host is built once per driver by a factory the class's static block installs intosql-driver-facet-hosts.ts(types-only module). Methods go as closures called on the driver at call time, so a subclass override or an instance spy is still the one reached;getBuildergoes as a bound getter (BOUND_HOST_METHODS) socheck-tenant-chokepointstill counts the binding in the moved body; fields and accessors go as getters, assigned fields with a setter.SqlDriverStatics, which a facet module imports ASSqlDriver(private-static-through-host, 6624174693).CLASS_HEAD_SECTION→sql-driver-class-head.ts). Three sections whose hand-series seam exists already take a-sectionsuffix;sql-driver-deferred-ddl.tsandsql-driver-transactions-section.tsare new.noUnusedLocals, so an import only a moved body reads stays, as the pilot left them.--dtsbyte-equality reading is dropped: a facade cannot meet it by construction (the bundled.d.tsprints every private member). The bar is now the public-surface reading below, taken outsidescripts/(6441032442 item 3).parameter-shadowsnow fires only for a parameter named like the stub's facet class or host variable (it freed 4 methods).PATH_READER_PINSrow,logDurabilityFailure(see readers below).--self-test: 67 cases in 5 pinned batteries (class-head section, the bound getter and two banner refusals added; the import-prune battery removed).--writeon the unsplitsql-driver.tsof21510bba(the parent of the pilot's landing), unedited. 158/254 methods move into 21 facet modules;sql-driver.tsgoes 18,334 → 10,979 lines (12,460 onmain). The leafsql-driver-top-level.tsis byte-identical tomain.index.tsre-exports none of the new modules.scripts/facade-delegation-registry.json: thesql-driver.ts/SqlDriverfacade row (card Codemod split: put driver-sql sql-driver.ts into facade form with a deterministic script, like protocol.ts and engine.ts #30105) and 28 exception rows, all carded refactor: move shared state out of the protocol.ts and engine.ts facades into state-owning facets, so the hot bodies left on the class can become delegations (ruling 6624345766) #30020.check-durability-degradation-log-leveljudges the two MySQL widening catches that stay on the class (migrateMysqlDatetimeColumns,migrateMysqlTimeColumns) by followingthis.logDurabilityFailure(…)to its body in the same file. A one-call stub there cannot be followed, so both read "swallowed, no log" (measured red). The helper is pinned to stay rather than widening the gate's same-file helper walk across files; the gate's readings are then equal to base.check-tenant-chokepoint'sDECLARED_WATCH_HINTSnames the four newsql-driver-*.tsmodules (its self-test requires every scanned file to be declared).sql-driver.tsby path (thepackages/cligenerate pins,check-keyed-text-bounds,sql-driver-compile-refusal-seam.test.ts, the liveness and checklist anchors, the ADR anchors) reads text the codemod keeps on the class through its existing pin and needle tables, and passes unchanged.skip-changeset): no published behaviour or surface changes.Tests
No test file changes. The suites below ran at base
f68b47caand at head; the counts are equal.vitest run)SqlDriver)SqlDriver)clean.operator-text-21418)check-liveness.testAcceptance notes
sql-driver.tsis frozen for a window. At landing the script runs on the latestmain's unsplit text (regenerate, never rebase, ruling A on [Decision] Large source files: replace the hand-cut split with a script-generated split per file, so the remaining monoliths split in days, not months #29465).rotateShards/ensureRotation(a computed parameter default stays in the byte-for-byte signature); the path-reader pins (ensureShardTable,initObjects,migrateMysqlDatetimeColumns,migrateMysqlTimeColumns,resolveWithheldFilterRefusal,createAuditTimestampColumn,varcharColumnChars,createColumn,logDurabilityFailure), which move once their readers read the facet modules; and thefield-call: knex,inferred-return-typeandcomment-in-parametersstays.dts-public.mjs's built-in--private-controlfails on this dist: it deletes the firstprivate x;line but leaves that member's docblock, which then attaches to the next (public) member. Dropping the whole private member with its docblock passes (reading below).Verification
sql-driver.tslines21510bba) · 12,460 (main)--write, and--verify --base 21510bba, exit 0)--writeruns: output tree sha256eab675141cad9efdb5217f65f044a246474c973777c575d9f5ee00b8c63d8154both times; regeneration reproduces the committed treedriver-sql typecheckcheck:facade-delegation-only(+--self-test36)SqlDriver352 members, 244 delegations, 80 fields, 28 named exceptionscheck:tenant-chokepointcheck:durability-log-levelpnpm build(whole repo, 119 tasks)pnpm lintdispatch-gates --commands(67)--ran: 67 derived, 0 NOT-MEASURED, 0 UNRUN.d.ts: ruling 6624345766 item 1, "public surface EQUAL"Read with
dts-public.mjs(project filesissue-29985/dts-public.mjs, sha256211b32062250606e658acd7fb8880e0079b4043121fb7b970c658b4b57bf5020, the reading #29985 used). driver-sql's.d.tsbuild is deterministic on both sides (two builds each, byte-identical), so one pair is read.index.d.tsindex.d.mts69d9162d…/ headfac28979…)fileColumnsMovedDeclaredwith its docblock) passes..d.ts.Facade reading
The 28 exception rows (all #30020):
constructor,logger,static DIALECT_CONNECT_TIMEOUTget supports,get insertReturnsStoredRows,get dateGranularityCapabilities,get supportsWalJournal,get dialectNamerotateShards,ensureRotationlogDurabilityFailure,ensureShardTable,initObjects,migrateMysqlDatetimeColumns,migrateMysqlTimeColumns,resolveWithheldFilterRefusal,createAuditTimestampColumn,varcharColumnChars,createColumnlistPhysicalColumns,getBuilder,explainUnkeyableTextColumn,explainHashShadowDuplicateapplyFilters,applyFilterCondition,ensureDatabaseExists,createDatabaseassertOperatorAppliesToColumnThe 78 hand-series stubs stay as they were (their modules are the hand series', not facets) and read as delegations.
🤖 Generated with Claude Code
https://claude.ai/code/session_01WGufzhBZia3VxBbmZ7wCkS