Skip to content

Commit 03b22f1

Browse files
committed
feat(runtime,cli)!: retire the inert DriverPluginOptions (#4320)
new DriverPlugin(driver, { datasourceName, registerAsDefault }) never did what it promised: both options configured the start() datasource block that probed metadata.addDatasource — a method no metadata service implements — so they were dead weight on every boot since inception. Routing to a named auxiliary driver never came from the option: it keys off the DRIVER name (init registers driver.<name>, ObjectQL's discovery loop adopts it, the engine's lifecycle resolution looks the name up — engine.ts LIFECYCLE_DATASOURCE), which is why serve's telemetry split worked all along despite the option doing nothing. - DriverPlugin constructor narrowed to (driver, driverName?); the options interface (module-local, never exported from the package root) is gone. - serve.ts drops the options argument; the telemetry wiring comment now states the driver-name mechanism explicitly. - Major changeset for @objectstack/runtime carries the FROM -> TO migration; behavior is unchanged by construction (the code the options configured never ran). Verified: full turbo build green (71 packages); runtime 954/67 and cli 628/64 tests pass; pnpm lint clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AWW5xEALZNU5VBXfGyWPGz
1 parent 76ca106 commit 03b22f1

3 files changed

Lines changed: 56 additions & 34 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
"@objectstack/runtime": major
3+
"@objectstack/cli": patch
4+
---
5+
6+
feat(runtime)!: retire the inert `DriverPluginOptions``DriverPlugin` takes `(driver, driverName?)` (#4320)
7+
8+
`new DriverPlugin(driver, { datasourceName, registerAsDefault })` never did
9+
what it promised: both options configured a datasource-registration block in
10+
`start()` gated on `metadata.addDatasource`, a method **no metadata service
11+
implements** — so the block early-returned on every boot since inception and
12+
the options were dead weight (found while typing service lookups for #4251).
13+
14+
**Migration** — delete the options argument; nothing changes at runtime
15+
because nothing ever happened:
16+
17+
- FROM `new DriverPlugin(driver, { datasourceName: 'x', registerAsDefault: false })`
18+
TO `new DriverPlugin(driver)`
19+
- FROM `new DriverPlugin(driver, 'name', options)` TO `new DriverPlugin(driver, 'name')`
20+
- The string second argument (`new DriverPlugin(driver, 'memory')`) is unchanged.
21+
22+
If you passed `datasourceName` expecting routing to a named auxiliary driver:
23+
that routing never came from the option. It keys off the **driver name**
24+
`DriverPlugin.init()` registers `driver.<name>`, ObjectQL's discovery loop
25+
adopts it, and the engine's lifecycle/datasource resolution looks the name up
26+
(see the telemetry provision in `os serve` for the pattern: stamp
27+
`driver.name`, register the plugin, done). For Setup → Datasources visibility,
28+
declare the datasource through `DatasourceConnectionService` /
29+
`registerInMemory('datasource', …)` (ADR-0062).
30+
31+
The `DriverPluginOptions` interface was module-local (never exported from the
32+
package root), so the only public break is the constructor's second/third
33+
argument shape.

packages/cli/src/commands/serve.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,9 +1003,15 @@ export default class Serve extends Command {
10031003
});
10041004
if (telemetry.engine !== 'memory') {
10051005
// The engine keys datasources by driver name — the
1006-
// lifecycle router looks this exact name up.
1006+
// lifecycle router looks this exact name up. The driver
1007+
// name is the WHOLE wiring: DriverPlugin.init registers
1008+
// `driver.telemetry`, ObjectQL's discovery loop adopts
1009+
// it, and lifecycle-classed objects route to it. (An
1010+
// options bag once also asked for `datasourceName:
1011+
// 'telemetry'` metadata registration — inert since
1012+
// inception, retired in #4320.)
10071013
Object.defineProperty(telemetry.driver, 'name', { value: 'telemetry' });
1008-
await kernel.use(new DriverPlugin(telemetry.driver, { datasourceName: 'telemetry', registerAsDefault: false }));
1014+
await kernel.use(new DriverPlugin(telemetry.driver));
10091015
trackPlugin('TelemetryDatasource');
10101016
console.log(chalk.dim(` telemetry datasource: ${telemetryPath} (lifecycle-classed system data; OS_TELEMETRY_DB=0 to disable)`));
10111017
}

packages/runtime/src/driver-plugin.ts

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,42 +16,24 @@ import { Plugin, PluginContext } from '@objectstack/core';
1616
* const driverPlugin = new DriverPlugin(memoryDriver, 'memory');
1717
* kernel.use(driverPlugin);
1818
*/
19-
/**
20-
* ⚠️ Both options are INERT. They configured start()'s datasource
21-
* registration, which probed `metadata.addDatasource` — a method no metadata
22-
* service implements — so the guarded block never ran on any boot and was
23-
* removed when typing the lookup surfaced it (#4251). The one live caller
24-
* that passes them (`serve.ts`, `datasourceName: 'telemetry'`) has never
25-
* gotten the registration it asks for. Kept only for source compatibility;
26-
* revive-or-remove is tracked in #4320.
27-
*/
28-
export interface DriverPluginOptions {
29-
/**
30-
* If set, registers a named datasource so packages declaring
31-
* `defaultDatasource: '<name>'` resolve to this driver.
32-
*/
33-
datasourceName?: string;
34-
/**
35-
* If `true` (default), registers this driver as the `default` datasource
36-
* when none exists. Set to `false` for proxy drivers (e.g. cloud proxy)
37-
* that should never become the default.
38-
*/
39-
registerAsDefault?: boolean;
40-
}
41-
4219
export class DriverPlugin implements Plugin {
4320
name: string;
4421
type = 'driver';
4522
version = '1.0.0';
4623

4724
private driver: any;
4825

49-
// Options are accepted (source compatibility for existing callers) but no
50-
// longer stored — nothing reads them since the dead datasource block left
51-
// start(); see the DriverPluginOptions doc.
52-
constructor(driver: any, driverNameOrOptions?: string | DriverPluginOptions, _options?: DriverPluginOptions) {
26+
// A `DriverPluginOptions` bag (`datasourceName` / `registerAsDefault`)
27+
// used to be accepted here. Both options configured start()'s datasource
28+
// registration, which probed `metadata.addDatasource` — a method no
29+
// metadata service implements — so they were inert on every boot since
30+
// inception; retired via #4320 (found by #4251). Routing to a named
31+
// auxiliary driver needs only the DRIVER name: init() registers
32+
// `driver.<name>`, ObjectQL's discovery loop adopts it, and the engine's
33+
// lifecycle/datasource resolution keys off that name (see serve.ts's
34+
// telemetry provision for the pattern).
35+
constructor(driver: any, driverName?: string) {
5336
this.driver = driver;
54-
const driverName = typeof driverNameOrOptions === 'string' ? driverNameOrOptions : undefined;
5537
this.name = `com.objectstack.driver.${driverName || driver.name || 'unknown'}`;
5638
}
5739

@@ -68,10 +50,11 @@ export class DriverPlugin implements Plugin {
6850
// start() used to hold a named/default datasource registration block,
6951
// gated on `metadata.addDatasource` — a method no metadata service
7052
// implements, here or anywhere in the repo — so the guard's early return
71-
// made every line behind it (and the options above) unreachable on every
72-
// boot. Typing the lookup (#4251) surfaced that; the dead block is gone
73-
// rather than typed against a phantom shape. Datasource declaration and
74-
// visibility live in ADR-0062's DatasourceConnectionService +
53+
// made every line behind it (and the options that configured it)
54+
// unreachable on every boot. Typing the lookup (#4251) surfaced that; the
55+
// dead block is gone rather than typed against a phantom shape, and the
56+
// options followed it (#4320). Datasource declaration and visibility live
57+
// in ADR-0062's DatasourceConnectionService +
7558
// `registerInMemory('datasource', …)` path — see DefaultDatasourcePlugin.
7659
start = async (ctx: PluginContext) => {
7760
ctx.logger.debug('Driver plugin started', { driverName: this.driver.name || 'unknown' });

0 commit comments

Comments
 (0)