evOo-local/apps/api/src/memory-provider-router-wiring.test.ts
cynarAI 0a3ce24797 fix(api): pass actor identity when purging memory after thread clear (#62)
threads/clear called memoryProviders.resolve with a bare spaceId string.
The resolver destructures { spaceId, userId }, so both were undefined and
purgeHistory was silently skipped after every clear.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>
2026-09-22 10:57:40 +02:00

24 lines
987 B
TypeScript

import { readFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
describe("memory provider config router wiring", () => {
const routerSource = readFileSync(
resolve(dirname(fileURLToPath(import.meta.url)), "router.ts"),
"utf8",
);
it("routes providerConfig through owner-gated getMemoryProviderConfig", () => {
expect(routerSource).toContain("getMemoryProviderConfig(deps, context.actor)");
expect(routerSource).not.toMatch(/providerConfig:[\s\S]{0,240}findSpaceMemoryConfig/);
});
it("passes actor space and user when resolving memory after thread clear", () => {
expect(routerSource).not.toMatch(/memoryProviders\.resolve\(context\.actor\.spaceId\)/);
expect(routerSource).toMatch(
/memoryProviders[\s\S]{0,120}\.resolve\(\{[\s\S]{0,120}spaceId: context\.actor\.spaceId[\s\S]{0,120}userId: context\.actor\.userId/,
);
});
});