Skip to content

[finding][drivers] 27 dead { bypassTenantAudit: true } as any options-gate casts in driver-sql / driver-sqlite-wasm tests — unlike turso's, these sit on a REAL typed gate #6754

Description

@os-zhuang

Measured during #6394 (removing the single as never on date-bucket-parity.test.ts's driver.create options gate). The dispatch for #6394 asked for a same-shape scan of other drivers' test options-gate casts as read-only — this is that scan's result, filed rather than fixed. Observation-class, no pm:queue, please grade in a triage round.

The inventory

Same shape as #6394's cast, spelled as any instead of as never, on driver.create(…) / driver.find(…) options arguments in test files:

Package Sites
driver-sqlite-wasm 17
driver-sql 10
Total 27 across 12 files

(driver-turso has 2 more, in turso-temporal-conformance.test.ts — see the split below for why they are a different animal.)

Reproduce the inventory:

grep -rnE "\{ *bypassTenantAudit: true *\} as (any|never)" packages/drivers/*/src --include=*.test.ts

Measured: all 27 are dead

Baseline origin/main @ 64d764e, dependency closures built first so the verdict is not read off stale dist/*.d.ts. Stripped all 27 casts, then:

@objectstack/driver-sql        typecheck → EXIT=0
@objectstack/driver-sqlite-wasm typecheck → EXIT=0

Zero output both. bypassTenantAudit is a declared key on DriverOptionsSchema (packages/spec/src/data/driver.zod.ts:99), so no cast was ever needed — identical to #6394's finding on the as never.

Why this is worth more than #6394 was

These 27 sit on a genuinely typed gate, and #6394's does not. That is the whole point of filing it separately.

SqlDriver.create declares options?: DriverOptions (packages/drivers/driver-sql/src/sql-driver.ts:2961), and SqliteWasmDriver does not override it, so both inherit real checking. Removing a cast there restores it — measured, by misspelling one key after the strip:

src/sql-driver-runtime-token-default.test.ts(111,73): error TS2561: Object literal may only
specify known properties, but 'bypassTenantAuditt' does not exist in type '{ transaction?:
unknown; timeout?: number | undefined; … bypassTenantAudit?: boolean | undefined; }'.
Did you mean to write 'bypassTenantAudit'?

TursoDriver, by contrast, overrides create with options?: any (see #6402 and my comment there), so at #6394's call site the same typo compiles clean with or without the cast. That is why #6394 was correctly graded a noise removal with no restored check, and why these 27 are not the same trade.

So the ordering matters: fixing these 27 buys real compile-time checking today, whereas the turso family (#6402) has to narrow options?: any first before its casts are worth touching.

Not a defect

No known bug has come out of this. Every affected suite is green; the cost is dormant — a misspelled or wrong-typed options key in these 27 test call sites goes unreported. Nobody has tripped on it.

If it gets done

Mechanical: delete as any at the 27 sites, then pnpm --filter @objectstack/driver-sql typecheck and pnpm --filter @objectstack/driver-sqlite-wasm typecheck. Both were measured green with the casts already gone, so the change is expected to be zero-error. Tests-only, no changeset.

Worth doing in one pass across both packages rather than piecemeal, for the reason #6402 gives about its own five: a partial fix reads to the next reader as a judgment about the sites left behind.

Related

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions