Repository navigation
refactor(driver-sql): the sql-driver codemod retires 15 facade-gate exception rows (knex calls, spelled return types, comments in parameters, accessors, computed defaults, the logger default) (#30147 phase 2a) - #30249
Conversation
…xception rows (knex calls, spelled return types, comments in parameters, accessors, computed defaults, the logger default) (#30147 phase 2a) The codemod (scripts/codemod-split-sql-driver.mjs) learns six mechanisms, each proved by --verify (undoing the split rebuilds the base byte for byte): - RECEIVER_FREE_FIELDS: a body may call `this.knex(...)`; a Knex instance is a closure that never reads `this`, so the host's getter keeps the call. - EXPLICIT_RETURN_TYPES: four stubs write the return type the base's declaration output prints (copied from dist/index.d.ts built at base). - A comment between a method's parentheses moves with the base list verbatim. - MOVED_ACCESSORS: four get accessors keep their signature; the body moves. - A computed parameter default (`nowMs = Date.now()`) is written optional on the stub (`nowMs?: number`) and stays where the body is, a seam function for the two hand-series stubs. - MOVED_FIELD_DEFAULTS: the `logger` field's initializer becomes a facet member typed as the field. sql-driver.ts 10,979 -> 10,717 lines; 171/171 moved bodies identical to base; public .d.ts byte-identical. 15 sql-driver.ts registry rows deleted (88 -> 73); five reasons rewritten for the halves that remain. check-tenant-chokepoint declares the new sql-driver-schema-introspection.ts. Claude-Session: https://claude.ai/code/session_01WGufzj4B2cbnRLVdgtLcDZ Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 9 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 4 release-owned page(s) also name something this change touched. These are read-only:
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 384caa70fab820126aa7ce2dff98e438c49d8b74 && git checkout 384caa70fab820126aa7ce2dff98e438c49d8b74
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 797f9257c988fbf93cc08cf672b37edf484d75e5 34fc09d0d0b6218425272b6b50530dbe31b1308a && git checkout -B drift-repro 797f9257c988fbf93cc08cf672b37edf484d75e5 && git merge --no-ff 34fc09d0d0b6218425272b6b50530dbe31b1308a
node scripts/docs-audit/affected-docs.mjs --json 797f9257c988fbf93cc08cf672b37edf484d75e5
|
|
domain:devx#1 · os-support-ai · session_01WGufzgBDcBNVmSmo7VFHpj Stamp: 2026-11-05T03:31Z 维护者速读
席位核对
|
Requested by Yibo Wang · project thread
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)。.d.ts与 base 逐字节相同;回滚即 revert 本 PR。RECEIVER_FREE_FIELDS/EXPLICIT_RETURN_TYPES/MOVED_ACCESSORS/MOVED_FIELD_DEFAULTS,以及verify里对应的撤销逻辑。node scripts/codemod-split-sql-driver.mjs --verify --base 21510bba,预期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 unsplitsql-driver.tsat21510bbaand re-proved by--verify(undoing the split rebuilds the base byte for byte). No generated file is edited by hand.this.knex(...)RECEIVER_FREE_FIELDS(a Knex instance is thefunction knex(tableName, options)closure, which readsknex.context, neverthis)listPhysicalColumns,explainUnkeyableTextColumn,explainHashShadowDuplicate(andgetBuilder's field-call half)EXPLICIT_RETURN_TYPES(types copied fromdist/index.d.tsbuilt at base)getBuilder,applyFilters,ensureDatabaseExists,createDatabasecomment-in-parametersstay reason is gone)assertOperatorAppliesToColumnMOVED_ACCESSORSinsertReturnsStoredRows,dateGranularityCapabilities,supportsWalJournal,dialectNamenowMs?: number) and stays where the body isrotateShards,ensureRotation(hand-series stubs: the default stays in the seam function)MOVED_FIELD_DEFAULTS(instance fields only)loggersql-driver.tsgoes 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).ensureShardTableandinitObjects: 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.scripts/check-tenant-chokepoint.mjslists the newsql-driver-schema-introspection.tsinDECLARED_WATCH_HINTS, as its self-test requires for every scanned module.Tests
--self-testgains a sixth pinned battery, "codemod-limit retirements (Facade codemods: retire the codemod-limit exception rows in the facade gate registry (protocol.ts, engine.ts, sql-driver.ts) #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.f2a9007eand at head; the counts are equal.vitest run)SqlDriver)SqlDriver)clean.operator-text-21418, migrate, schema-migrate)check-liveness.testAcceptance notes
dist/index.d.tsof@objectstack/driver-sqlbuilt at base), not from reading the source.get supportsandstatic DIALECT_CONNECT_TIMEOUTstay on Facade codemods: retire the codemod-limit exception rows in the facade gate registry (protocol.ts, engine.ts, sql-driver.ts) #30147 with no sub-phase planned yet; 2b-2d cover the path-reader rows,createColumnandapplyFilterCondition.skip-changeset): no published behaviour or surface changes (the public.d.tsis byte-identical).Verification
Head
34fc09d0, baseorigin/mainf2a9007e.Proof readings
node scripts/codemod-split-sql-driver.mjs --verify --base 21510bbaexit 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".--writeruns from the unsplit input give output tree sha25607b3a5053a23098c2754bb36caefb96532bbc4c7497ae29ab5dd357aff036454both times (input sha2562d2ebebd…)..d.ts:dts-public.mjsover the base and headdistexit 0,pass: true, both files raw-equal (index.d.tssha25692e2cfb2…on both sides).rotateShardsandensureRotationread the same at base and head,nowMs?: numberin both (signature hashesc8bded77…andd0ab9226…on both sides); so dogetBuilderandget dialectName.pnpm --filter @objectstack/driver-sql typecheckexit 0.check-tenant-chokepoint: base and head both read 24getBuilder()bindings, 21 read doors, 3 insert builders, 4 tenant predicates, 0 D8 arms (38 files at base, 39 at head: the new module);--self-testexit 0.node scripts/check-facade-delegation-only.mjsexit 0, "3 facade file(s) hold delegations only, 73 named exception(s)";--self-testexit 0, 36 cases (gate script and its cases untouched).node scripts/pm/dispatch-gates.mjs --commands: 67 derived commands, each run, all exit 0;--ranreconciles 67 derived, 67 run, 0 NOT-MEASURED. Two first exited 3 on prerequisites (the shallow clone lacked thecheck-plugin-teardown-shapefixture commit;check:dual-build-cjs-loadsneeded unbuilt dists): after fetching that commit and building those packages, both exit 0.check-tenant-chokepointand facade gate--self-tests (exit 0),check:lean-entry-closure(exit 0), eslint over the changed scripts and driver-sql sources (exit 0).Generated by Claude Code