fix(memory-core): use all dreaming signals for light confidence

This commit is contained in:
Vincent Koc
2026-04-12 18:30:35 +01:00
parent a24af49100
commit 8a4a63ca07
3 changed files with 31 additions and 1 deletions

View File

@@ -406,6 +406,29 @@ describe("memory-core dreaming phases", () => {
expect(after[0]?.snippet).toContain("Keep retention at 365 days.");
});
it("renders non-zero light-sleep confidence for dreaming-ingested candidates", async () => {
const workspaceDir = await createDreamingWorkspace();
await withDreamingTestClock(async () => {
await writeDailyNote(workspaceDir, [
`# ${DREAMING_TEST_DAY}`,
"",
"- Move backups to S3 Glacier.",
"- Keep retention at 365 days.",
]);
const { beforeAgentReply } = createLightDreamingHarness(workspaceDir);
await triggerLightDreaming(beforeAgentReply, workspaceDir, 5);
const dailyContent = await fs.readFile(
path.join(workspaceDir, "memory", `${DREAMING_TEST_DAY}.md`),
"utf-8",
);
expect(dailyContent).toContain("## Light Sleep");
expect(dailyContent).toContain("confidence: 0.62");
expect(dailyContent).not.toContain("confidence: 0.00");
});
});
it("checkpoints session transcript ingestion and skips unchanged transcripts", async () => {
const workspaceDir = await createDreamingWorkspace();
vi.stubEnv("OPENCLAW_TEST_FAST", "1");

View File

@@ -1241,7 +1241,13 @@ export async function seedHistoricalDailyMemorySignals(params: {
}
function entryAverageScore(entry: ShortTermRecallEntry): number {
return entry.recallCount > 0 ? Math.max(0, Math.min(1, entry.totalScore / entry.recallCount)) : 0;
const signalCount = Math.max(
0,
Math.floor(entry.recallCount ?? 0) +
Math.floor(entry.dailyCount ?? 0) +
Math.floor(entry.groundedCount ?? 0),
);
return signalCount > 0 ? Math.max(0, Math.min(1, entry.totalScore / signalCount)) : 0;
}
function tokenizeSnippet(snippet: string): Set<string> {