From 33926ecef15f3efe1afed61002bb76aa3f824056 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 6 Apr 2026 05:17:19 +0100 Subject: [PATCH] test(memory-core): align dreaming expectations --- extensions/memory-core/index.test.ts | 2 +- extensions/memory-core/src/cli.test.ts | 2 +- .../memory-core/src/dreaming-markdown.test.ts | 31 ++++++++++++------- .../memory-core/src/dreaming-phases.test.ts | 7 +++-- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/extensions/memory-core/index.test.ts b/extensions/memory-core/index.test.ts index 2093c524ec6..bc2da73a859 100644 --- a/extensions/memory-core/index.test.ts +++ b/extensions/memory-core/index.test.ts @@ -84,7 +84,7 @@ describe("buildMemoryFlushPlan", () => { expect(plan?.prompt).toContain("memory/2026-02-16.md"); expect(plan?.prompt).toContain( - "Current time: Monday, February 16th, 2026 — 10:00 AM (America/New_York) / 2026-02-16 15:00 UTC", + "Current time: Monday, February 16th, 2026 - 10:00 AM (America/New_York) / 2026-02-16 15:00 UTC", ); expect(plan?.relativePath).toBe("memory/2026-02-16.md"); }); diff --git a/extensions/memory-core/src/cli.test.ts b/extensions/memory-core/src/cli.test.ts index 275a6a62235..17a409237fe 100644 --- a/extensions/memory-core/src/cli.test.ts +++ b/extensions/memory-core/src/cli.test.ts @@ -373,7 +373,7 @@ describe("memory cli", () => { await runMemoryCli(["status"]); expect(log).toHaveBeenCalledWith(expect.stringContaining("Recall store: 1 entries")); - expect(log).toHaveBeenCalledWith(expect.stringContaining("Dreaming: 0 3 * * *")); + expect(log).toHaveBeenCalledWith(expect.stringContaining("Dreaming: off")); expect(close).toHaveBeenCalled(); }); }); diff --git a/extensions/memory-core/src/dreaming-markdown.test.ts b/extensions/memory-core/src/dreaming-markdown.test.ts index 63d59731fbd..f479fd8297f 100644 --- a/extensions/memory-core/src/dreaming-markdown.test.ts +++ b/extensions/memory-core/src/dreaming-markdown.test.ts @@ -17,32 +17,39 @@ afterEach(async () => { }); describe("dreaming markdown storage", () => { - it("writes inline light dreaming output into top-level DREAMS.md", async () => { + const nowMs = Date.parse("2026-04-05T10:00:00Z"); + const timezone = "UTC"; + + it("writes inline light dreaming output into the daily memory file", async () => { const workspaceDir = await createTempWorkspace(); const result = await writeDailyDreamingPhaseBlock({ workspaceDir, phase: "light", bodyLines: ["- Candidate: remember the API key is fake"], + nowMs, + timezone, storage: { mode: "inline", separateReports: false, }, }); - expect(result.inlinePath).toBe(path.join(workspaceDir, "DREAMS.md")); + expect(result.inlinePath).toBe(path.join(workspaceDir, "memory", "2026-04-05.md")); const content = await fs.readFile(result.inlinePath!, "utf-8"); expect(content).toContain("## Light Sleep"); expect(content).toContain("- Candidate: remember the API key is fake"); }); - it("keeps multiple inline phases in the shared top-level DREAMS.md file", async () => { + it("keeps multiple inline phases in the shared daily memory file", async () => { const workspaceDir = await createTempWorkspace(); await writeDailyDreamingPhaseBlock({ workspaceDir, phase: "light", bodyLines: ["- Candidate: first block"], + nowMs, + timezone, storage: { mode: "inline", separateReports: false, @@ -52,13 +59,15 @@ describe("dreaming markdown storage", () => { workspaceDir, phase: "rem", bodyLines: ["- Theme: `focus` kept surfacing."], + nowMs, + timezone, storage: { mode: "inline", separateReports: false, }, }); - const dreamsPath = path.join(workspaceDir, "DREAMS.md"); + const dreamsPath = path.join(workspaceDir, "memory", "2026-04-05.md"); const content = await fs.readFile(dreamsPath, "utf-8"); expect(content).toContain("## Light Sleep"); expect(content).toContain("## REM Sleep"); @@ -66,7 +75,7 @@ describe("dreaming markdown storage", () => { expect(content).toContain("- Theme: `focus` kept surfacing."); }); - it("reuses existing lowercase dreams.md when present", async () => { + it("keeps daily phase output separate from lowercase dreams.md diaries", async () => { const workspaceDir = await createTempWorkspace(); const lowercasePath = path.join(workspaceDir, "dreams.md"); await fs.writeFile(lowercasePath, "# Scratch\n\n", "utf-8"); @@ -75,16 +84,19 @@ describe("dreaming markdown storage", () => { workspaceDir, phase: "rem", bodyLines: ["- Theme: `glacier` kept surfacing."], + nowMs, + timezone, storage: { mode: "inline", separateReports: false, }, }); - expect(result.inlinePath).toBe(lowercasePath); - const content = await fs.readFile(lowercasePath, "utf-8"); + expect(result.inlinePath).toBe(path.join(workspaceDir, "memory", "2026-04-05.md")); + const content = await fs.readFile(result.inlinePath!, "utf-8"); expect(content).toContain("## REM Sleep"); expect(content).toContain("- Theme: `glacier` kept surfacing."); + await expect(fs.readFile(lowercasePath, "utf-8")).resolves.toBe("# Scratch\n\n"); }); it("still writes deep reports to the per-phase report directory", async () => { @@ -106,9 +118,6 @@ describe("dreaming markdown storage", () => { expect(content).toContain("# Deep Sleep"); expect(content).toContain("- Promoted: durable preference"); - const dreamsPath = path.join(workspaceDir, "DREAMS.md"); - const dreamsContent = await fs.readFile(dreamsPath, "utf-8"); - expect(dreamsContent).toContain("## Deep Sleep"); - expect(dreamsContent).toContain("- Promoted: durable preference"); + await expect(fs.access(path.join(workspaceDir, "DREAMS.md"))).rejects.toThrow(); }); }); diff --git a/extensions/memory-core/src/dreaming-phases.test.ts b/extensions/memory-core/src/dreaming-phases.test.ts index 1e668d90026..5bcaf2f11bb 100644 --- a/extensions/memory-core/src/dreaming-phases.test.ts +++ b/extensions/memory-core/src/dreaming-phases.test.ts @@ -478,14 +478,15 @@ describe("memory-core dreaming phases", () => { minUniqueQueries: 0, nowMs, }); - expect(reinforced).toHaveLength(1); - expect(reinforced[0]!.score).toBeGreaterThan(baselineScore); + const reinforcedCandidate = reinforced.find((candidate) => candidate.key === baseline[0]!.key); + expect(reinforcedCandidate).toBeDefined(); + expect(reinforcedCandidate!.score).toBeGreaterThan(baselineScore); const phaseSignalPath = resolveShortTermPhaseSignalStorePath(workspaceDir); const phaseSignalStore = JSON.parse(await fs.readFile(phaseSignalPath, "utf-8")) as { entries: Record; }; - expect(phaseSignalStore.entries[reinforced[0]!.key]).toMatchObject({ + expect(phaseSignalStore.entries[baseline[0]!.key]).toMatchObject({ lightHits: 1, remHits: 1, });