Skip to content

Commit b2c0ab1

Browse files
committed
fix(objectql)!: retire the dead ObjectQLEngine.use() plugin path
The engine's own plugin loader — registerApp + an onEnable dispatch over an ObjectQLHostContext — has zero callers repo-wide: kernel plugins go through kernel.use() → init/start, and the manifest path routes through registerApp() directly. The onEnable dispatch is the engine-level twin of the #4212 disease (a lifecycle entry point that reads as a contract and never runs); the app-bundle onEnable module export is a different, real contract and is unchanged. Removed use(), the ObjectQLHostContext type (constructed only inside the dead method; un-exported from both barrels), and the write-only hostContext field — the constructor keeps its signature and its logger extraction, so new ObjectQL({ logger }) and ObjectQLPlugin's hostContext option are unaffected. Verified: objectql 1271 tests green (82 files) after a full turbo build (71 packages) with the change in place; the 42 pre-existing local failures reproduced identically on pristine main with the change stashed and disappeared after rebuilding stale sibling dists — unrelated to this diff. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrRNgrWaRtggzmrHpbomyh
1 parent 7777e8f commit b2c0ab1

4 files changed

Lines changed: 36 additions & 52 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
"@objectstack/objectql": major
3+
---
4+
5+
fix(objectql)!: retire the dead `ObjectQLEngine.use()` plugin path (#4212 follow-up)
6+
7+
`ObjectQLEngine.use(manifestPart, runtimePart)` was the engine's own plugin
8+
loader: register a manifest, then dispatch the runtime part's `onEnable` with
9+
an `ObjectQLHostContext`. **Nothing calls it** — not the kernel (plugins go
10+
through `kernel.use()``init`/`start`), not the CLI, not a test, not an
11+
example, repo-wide. Its `onEnable` dispatch is the engine-level twin of the
12+
#4212 disease: a lifecycle entry point that reads as a contract and never
13+
runs. The *app-bundle* `onEnable` module export is a different, real contract
14+
(dispatched by AppPlugin at boot) and is unchanged.
15+
16+
Removed:
17+
18+
- `ObjectQLEngine.use()`.
19+
- `ObjectQLHostContext` (exported from `@objectstack/objectql` and
20+
`@objectstack/objectql/core`) — constructed only inside the dead method.
21+
- The engine's private `hostContext` field — its only read outside the dead
22+
method was the constructor's `logger` extraction, which stays; the
23+
constructor signature is unchanged (`new ObjectQL({ logger })` keeps
24+
working, as does `ObjectQLPlugin`'s `hostContext` option that feeds it).
25+
26+
FROM → TO:
27+
28+
- `engine.use(manifest)``engine.registerApp(manifest)` (the alive half —
29+
the manifest service and ObjectQLPlugin already route through it).
30+
- `engine.use(_, { onEnable })` → a kernel plugin: `kernel.use({ name,
31+
init(ctx) { … } })`; the engine is `ctx.getService('objectql')`, drivers
32+
register via `engine.registerDriver()`.
33+
- `ObjectQLHostContext` → no replacement; the type described the context of
34+
a hook that never fired.

packages/objectql/src/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export type { CompanionFieldMeta, CompanionObjectMeta } from './search-companion
3737

3838
// Engine
3939
export { ObjectQL, ObjectRepository, ScopedContext } from './engine.js';
40-
export type { ObjectQLHostContext, HookHandler, HookEntry, OperationContext, EngineMiddleware } from './engine.js';
40+
export type { HookHandler, HookEntry, OperationContext, EngineMiddleware } from './engine.js';
4141

4242
// Boot guard: thrown by `ObjectQL.init()` when a registered driver's connect()
4343
// fails (framework#3741). Embedders that boot the engine themselves can catch

packages/objectql/src/engine.ts

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,6 @@ export type EngineMiddleware = (
263263
next: () => Promise<void>
264264
) => Promise<void>;
265265

266-
/**
267-
* Host Context provided to plugins (Internal ObjectQL Plugin System)
268-
*/
269-
export interface ObjectQLHostContext {
270-
ql: ObjectQL;
271-
logger: Logger;
272-
// Extensible map for host-specific globals (like HTTP Router, etc.)
273-
[key: string]: any;
274-
}
275-
276266
/**
277267
* Derive the registry key for a metadata item.
278268
*
@@ -392,9 +382,6 @@ export class ObjectQL implements IDataEngine {
392382
// `engine.registerFunction(...)`.
393383
private functions = new Map<string, FunctionEntry>();
394384

395-
// Host provided context additions (e.g. Server router)
396-
private hostContext: Record<string, any> = {};
397-
398385
// Realtime service for event publishing
399386
private realtimeService?: IRealtimeService;
400387

@@ -423,7 +410,6 @@ export class ObjectQL implements IDataEngine {
423410
private _registry: SchemaRegistry = new SchemaRegistry();
424411

425412
constructor(hostContext: Record<string, any> = {}) {
426-
this.hostContext = hostContext;
427413
// Use provided logger or create a new one
428414
this.logger = hostContext.logger || createLogger({ level: 'info', format: 'pretty' });
429415
// Pick up production hardening switches from env so deployers can
@@ -462,42 +448,6 @@ export class ObjectQL implements IDataEngine {
462448
return this._registry;
463449
}
464450

465-
/**
466-
* Load and Register a Plugin
467-
*/
468-
async use(manifestPart: any, runtimePart?: any) {
469-
this.logger.debug('Loading plugin', {
470-
hasManifest: !!manifestPart,
471-
hasRuntime: !!runtimePart
472-
});
473-
474-
// 1. Validate / Register Manifest
475-
if (manifestPart) {
476-
this.registerApp(manifestPart);
477-
}
478-
479-
// 2. Execute Runtime
480-
if (runtimePart) {
481-
const pluginDef = (runtimePart as any).default || runtimePart;
482-
if (pluginDef.onEnable) {
483-
this.logger.debug('Executing plugin runtime onEnable');
484-
485-
const context: ObjectQLHostContext = {
486-
ql: this,
487-
logger: this.logger,
488-
// Expose the driver registry helper explicitly if needed
489-
drivers: {
490-
register: (driver: IDataDriver) => this.registerDriver(driver)
491-
},
492-
...this.hostContext
493-
};
494-
495-
await pluginDef.onEnable(context);
496-
this.logger.debug('Plugin runtime onEnable completed');
497-
}
498-
}
499-
}
500-
501451
/**
502452
* Register a hook
503453
* @param event The event name (e.g. 'beforeFind', 'afterInsert')

packages/objectql/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export type { CompanionFieldMeta, CompanionObjectMeta } from './search-companion
4747

4848
// Export Engine
4949
export { ObjectQL, ObjectRepository, ScopedContext } from './engine.js';
50-
export type { ObjectQLHostContext, HookHandler, HookEntry, OperationContext, EngineMiddleware } from './engine.js';
50+
export type { HookHandler, HookEntry, OperationContext, EngineMiddleware } from './engine.js';
5151
export { SummaryRecomputeError } from './summary-errors.js';
5252
export type { SummaryRecomputeFailure } from './summary-errors.js';
5353
// Boot guard: thrown by `ObjectQL.init()` when a registered driver's connect()

0 commit comments

Comments
 (0)