Skip to content

Commit 55bbefc

Browse files
os-zhuangclaude
andauthored
fix(objectql)!: retire the dead ObjectQLEngine.use() plugin path (#4242)
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. Claude-Session: https://claude.ai/code/session_01HrRNgrWaRtggzmrHpbomyh Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3aef718 commit 55bbefc

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
@@ -264,16 +264,6 @@ export type EngineMiddleware = (
264264
next: () => Promise<void>
265265
) => Promise<void>;
266266

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

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

@@ -424,7 +411,6 @@ export class ObjectQL implements IDataEngine {
424411
private _registry: SchemaRegistry = new SchemaRegistry();
425412

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

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