diff --git a/src/context-engine/context-engine.test.ts b/src/context-engine/context-engine.test.ts index 770ab643fd1..0bfb890aed2 100644 --- a/src/context-engine/context-engine.test.ts +++ b/src/context-engine/context-engine.test.ts @@ -360,7 +360,7 @@ describe("Engine contract tests", () => { const resolved = getContextEngineFactory("mock"); expect(resolved).toBe(factory); - const engine = await resolved!(); + const engine = await resolved!({}); expect(engine).toBeInstanceOf(MockContextEngine); expect(engine.info.id).toBe("mock"); }); @@ -706,7 +706,7 @@ describe("Factory context passing", () => { const engineId = `factory-ctx-${Date.now().toString(36)}`; let receivedCtx: ContextEngineFactoryContext | undefined; - const factory: ContextEngineFactory = (ctx?: ContextEngineFactoryContext) => { + const factory: ContextEngineFactory = (ctx: ContextEngineFactoryContext) => { receivedCtx = ctx; return { info: { id: engineId, name: "Ctx Engine" }, @@ -771,7 +771,7 @@ describe("Factory context passing", () => { // Override the default "legacy" engine to intercept the no-config path registerContextEngineForOwner( "legacy", - (ctx?: ContextEngineFactoryContext) => { + (ctx: ContextEngineFactoryContext) => { receivedCtx = ctx; return { info: { id: "legacy", name: "NoConfig Engine", version: "1" }, diff --git a/src/context-engine/registry.ts b/src/context-engine/registry.ts index e257a8e67b5..3ebd1023df4 100644 --- a/src/context-engine/registry.ts +++ b/src/context-engine/registry.ts @@ -19,12 +19,13 @@ export type ContextEngineFactoryContext = { * A factory that creates a ContextEngine instance. * Supports async creation for engines that need DB connections etc. * - * Factories may accept an optional {@link ContextEngineFactoryContext} parameter - * for runtime context. No-arg factories remain supported for backward compatibility - * since the parameter is optional. + * The factory receives a {@link ContextEngineFactoryContext} with runtime + * environment context (config, paths). Existing no-arg factories remain + * backward compatible because TypeScript permits assigning functions with + * fewer parameters to wider signatures. */ export type ContextEngineFactory = ( - ctx?: ContextEngineFactoryContext, + ctx: ContextEngineFactoryContext, ) => ContextEngine | Promise; export type ContextEngineRegistrationResult = { ok: true } | { ok: false; existingOwner: string };