feat(FN-3197): refresh qmd after agent dream writes and normalize agent-mem

This merge normalizes agent-memory paths in the core memory backend and ensures the qmd gets refreshed after agent dream writes, fixing a bug where stale paths could persist after memory updates. The engine's agent-tools module was updated to integrate with this fix, and a changeset was included for

Fusion-Task-Id: FN-3197
This commit is contained in:
Fusion
2026-05-05 02:39:14 -07:00
committed by gsxdsm
parent 707139778f
commit 2f40843094
7 changed files with 127 additions and 5 deletions

View File

@@ -14,6 +14,7 @@ import {
processAgentMemoryDreams,
syncMemoryDreamsAutomation,
} from "../memory-dreams.js";
import * as memoryBackend from "../memory-backend.js";
describe("extractDreamProcessorResult", () => {
it("parses dreams and long-term updates from well-formed output", () => {
@@ -151,4 +152,30 @@ describe("memory-dreams automation", () => {
await rm(rootDir, { recursive: true, force: true });
}
});
it("schedules qmd refresh for processed agent memory when qmd backend is enabled", async () => {
const rootDir = await mkdtemp(join(tmpdir(), "agent-dreams-qmd-"));
const refreshSpy = vi.spyOn(memoryBackend, "scheduleQmdAgentMemoryRefresh").mockImplementation(() => {});
try {
const date = new Date("2026-04-17T12:00:00.000Z");
const agent = {
id: "ceo-agent",
name: "CEO",
role: "executor",
state: "idle",
metadata: {},
createdAt: date.toISOString(),
updatedAt: date.toISOString(),
} as any;
await processAgentMemoryDreams(rootDir, [agent], async () => (
"## DREAMS\n\nDream signal.\n\n## LONG_TERM_UPDATES\n\n- Durable update."
), date, { memoryBackendType: "qmd" });
expect(refreshSpy).toHaveBeenCalledWith(rootDir, "ceo-agent");
} finally {
refreshSpy.mockRestore();
await rm(rootDir, { recursive: true, force: true });
}
});
});