fix(extensions): repair matrix contracts and test boundaries

This commit is contained in:
Vincent Koc
2026-03-19 09:06:39 -07:00
parent 0aa4950d21
commit ca74eb37da
5 changed files with 13 additions and 3 deletions

View File

@@ -434,7 +434,7 @@ export const matrixPlugin: ChannelPlugin<ResolvedMatrixAccount> = {
//
// INVARIANT: The import() below cannot hang because:
// 1. It only loads local ESM modules with no circular awaits
// 2. Module initialization is synchronous (no top-level await in ./matrix/index.js)
// 2. Module initialization is synchronous (no top-level await in ./matrix/monitor/index.js)
// 3. The lock only serializes the import phase, not the provider startup
const previousLock = matrixStartupLock;
let releaseLock: () => void = () => {};
@@ -445,9 +445,9 @@ export const matrixPlugin: ChannelPlugin<ResolvedMatrixAccount> = {
// Lazy import: the monitor pulls the reply pipeline; avoid ESM init cycles.
// Wrap in try/finally to ensure lock is released even if import fails.
let monitorMatrixProvider: typeof import("./matrix/index.js").monitorMatrixProvider;
let monitorMatrixProvider: typeof import("./matrix/monitor/index.js").monitorMatrixProvider;
try {
const module = await import("./matrix/index.js");
const module = await import("./matrix/monitor/index.js");
monitorMatrixProvider = module.monitorMatrixProvider;
} finally {
// Release lock after import completes or fails

View File

@@ -104,6 +104,7 @@ function createHandlerHarness() {
directTracker: {
isDirectMessage: vi.fn().mockResolvedValue(true),
},
dropPreStartupMessages: true,
getRoomInfo: vi.fn().mockResolvedValue({
name: "Media Room",
canonicalAlias: "#media:example.org",

View File

@@ -594,6 +594,7 @@ describe("matrix monitor handler pairing account scope", () => {
directTracker: {
isDirectMessage: async () => false,
},
dropPreStartupMessages: true,
getRoomInfo: async () => ({ altAliases: [] }),
getMemberDisplayName: async () => "sender",
needsRoomAliasesForConfig: false,

View File

@@ -119,6 +119,7 @@ describe("createMatrixRoomMessageHandler thread root media", () => {
directTracker: {
isDirectMessage: vi.fn().mockResolvedValue(true),
},
dropPreStartupMessages: true,
getRoomInfo: vi.fn().mockResolvedValue({
name: "Media Room",
canonicalAlias: "#media:example.org",

View File

@@ -0,0 +1,7 @@
export {
__testing as sessionBindingTesting,
registerSessionBindingAdapter,
} from "../../../src/infra/outbound/session-binding-service.js";
export { setActivePluginRegistry } from "../../../src/plugins/runtime.js";
export { resolveAgentRoute } from "../../../src/routing/resolve-route.js";
export { createTestRegistry } from "../../../src/test-utils/channel-plugins.js";