Skip to content

objectql/protocol-batch-atomic.test.ts mock driver advertises the retired supports.transactions bit — invisible because the mock is : any #6546

Description

@baozhoutao

Found while fixing #4782 (PR #6545). Recorded, not fixed there: #4782's file surface is
packages/metadata/src/loaders/database-loader.test.ts only.

Observation

packages/objectql/src/protocol-batch-atomic.test.ts:46:

const driver: any = {
    name: 'snapshot',
    version: '0.0.0',
    supports: { transactions: true },
    ...

transactions was RETIRED by #4634 and is tombstoned in DriverCapabilitiesSchema as
retiredKey(...), i.e. never. Authoring it is meant to fail tsc at the authoring site
and to be rejected by a parse with the removal prescription.

Neither channel fires here, and the reason is the annotation: the literal is : any, so
it is never compared against IDataDriver, and nothing in this test parses the driver
through DriverInterfaceSchema. The bit is inert — transaction use gates on METHOD
presence (driver.beginTransaction), which this mock does implement, so the test passes
for the right reason and would pass identically with the bit deleted.

This is the same family as #4782 but a different failure mode, which is why it is worth a
separate line: #4782's block was at least partly VISIBLE to tsc (its four retired keys
were four real TS2322 in the @objectstack/metadata DEBT ledger). Here the : any erases
the diagnostic entirely.

Why this is observation-class, not a defect

Nothing a user hits, no gate is red, and no behaviour depends on it. The concrete harm is
the one #4782 names: it is a mock, and mocks get copied. A future author who copies this
one inherits a retired bit plus the : any that hides it.

Deliberately NOT flagged: packages/spec/src/data/driver.test.ts:317 spells
supports: { transactions: true, streaming: true } on purpose — it is the rejection
fixture (it('REJECTS a driver whose supports still authors a retired bit')) and asserts
the tombstone prescription. That one is correct as written.

Suggestion

Drop the bit (supports: {}), and consider whether const driver: any should be
const driver: IDataDriver — the any is what turned a compile error into silence, so
the annotation is the part that actually prevents recurrence. Whether that retyping is
cheap depends on how the rest of the literal lines up with IDataDriver; it was not
measured here.

A repo-wide grep for other supports: literals spelling retired or invented capability
keys found no further instances in packages/ or examples/ beyond this one, #4782's,
and the spec rejection fixture above.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions