mirror of https://github.com/openclaw/openclaw.git
test(memory-core): align dreaming expectations
This commit is contained in:
parent
b682202016
commit
33926ecef1
|
|
@ -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");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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<string, { lightHits: number; remHits: number }>;
|
||||
};
|
||||
expect(phaseSignalStore.entries[reinforced[0]!.key]).toMatchObject({
|
||||
expect(phaseSignalStore.entries[baseline[0]!.key]).toMatchObject({
|
||||
lightHits: 1,
|
||||
remHits: 1,
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue