Skip to content

The engine-registration path is still unreached by the introspection compile channel: IDataDriver declares no introspectSchema, and IDataEngine.introspectDatasource() returns Promise<unknown> #11493

Description

@os-steve

Found while implementing #11381 (option C of the #11123 ruling — tightening DatasourceDriverHandle.introspectSchema to the spec IntrospectedSchema, PR #11492). Out of scope there by the ruling's own boundary: the ruling names the DatasourceDriverHandle seam; this is the other road into the same runtime read. Filed unassigned, measured at b6d9432d1a.

The gap

#11492 wires the compiler channel for drivers that cross DatasourceDriverHandle — the host-factory path. But a custom driver has a second documented entry: constructed by the host and handed to IDataEngine.registerDriver() (directly, or via the handle's driver: unknown escape hatch that the connection service registers for it). On that path nothing types the introspection result:

  • packages/spec/src/contracts/data-driver.tsIDataDriver declares nointrospectSchema member at all, so a driver author implementing the interface gets no signature to mis-match against.
  • packages/objectql/src/engine.tsintrospectDatasource(datasource: string): Promise<unknown> duck-types the call (this.drivers.get(datasource) as anydriver.introspectSchema()), and its Promise<unknown> return then forces every consumer to re-narrow (the one in-tree consumer, service-datasource/src/plugin.ts, declares its own structural DataEngineLike with the spec type to get around it).

So a mis-shaped driver registered through the engine still compiles clean and is absorbed only by the PR #11001 runtime shim — exactly the population/channel argument recorded in #11123, one seam over.

Candidate shape (needs its own ruling — both are public-surface changes)

  1. Add introspectSchema?(): Promise<IntrospectedSchema> (spec contract) to IDataDriver — an optional-member addition on the central driver contract; audit the in-tree drivers' declared return types (driver-sql / objectql types already extend the spec contract post-fix(driver-sql): introspectSchema() emits the spec introspection contract — primaryKey, dialect, introspectedAt (#10676, #10998) #11124/spec: withdraw the never-honored introspection indexes promise; widen defaultValue/maxLength to the measured emitted types #11270).
  2. Tighten introspectDatasource(): Promise<unknown> to the spec type in objectql, which then lets plugin.ts drop its structural re-declaration.

Blast radius is wider than #11381's (the engine and the central driver contract vs one handle member), so it wants its own four-axis pass, not a rider.

Refs: #11123 (ruling + analysis) · #11381 / PR #11492 (the handle-side tightening) · PR #11001 (the runtime shim both channels fall back to)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions