






















@@ -2118,6 +2118,11 @@ describe("memory-core dreaming phases", () => {
21182118it("records light/rem signals that reinforce deep promotion ranking", async () => {
21192119const workspaceDir = await createDreamingWorkspace();
21202120const nowMs = Date.parse("2026-04-05T10:00:00.000Z");
2121+await fs.writeFile(
2122+path.join(workspaceDir, "memory", "2026-04-03.md"),
2123+"Move backups to S3 Glacier.\n",
2124+"utf-8",
2125+);
21212126await recordShortTermRecalls({
21222127 workspaceDir,
21232128query: "glacier backup",
@@ -2126,7 +2131,7 @@ describe("memory-core dreaming phases", () => {
21262131{
21272132path: "memory/2026-04-03.md",
21282133startLine: 1,
2129-endLine: 2,
2134+endLine: 1,
21302135score: 0.92,
21312136snippet: "Move backups to S3 Glacier.",
21322137source: "memory",
@@ -2141,7 +2146,7 @@ describe("memory-core dreaming phases", () => {
21412146{
21422147path: "memory/2026-04-03.md",
21432148startLine: 1,
2144-endLine: 2,
2149+endLine: 1,
21452150score: 0.9,
21462151snippet: "Move backups to S3 Glacier.",
21472152source: "memory",
@@ -2221,6 +2226,93 @@ describe("memory-core dreaming phases", () => {
22212226});
22222227});
222322282229+it("skips REM short-term candidates whose source file disappeared", async () => {
2230+const workspaceDir = await createDreamingWorkspace();
2231+await fs.writeFile(
2232+path.join(workspaceDir, "memory", "2026-04-03.md"),
2233+"Move backups to S3 Glacier.\n",
2234+"utf-8",
2235+);
2236+const nowMs = DREAMING_TEST_BASE_TIME.getTime();
2237+await recordShortTermRecalls({
2238+ workspaceDir,
2239+query: "live backup",
2240+ nowMs,
2241+results: [
2242+{
2243+path: "memory/2026-04-03.md",
2244+startLine: 1,
2245+endLine: 1,
2246+score: 0.91,
2247+snippet: "Move backups to S3 Glacier.",
2248+source: "memory",
2249+},
2250+],
2251+});
2252+await recordShortTermRecalls({
2253+ workspaceDir,
2254+query: "stale provider setup",
2255+ nowMs,
2256+results: [
2257+{
2258+path: "memory/.dreams/session-corpus/2026-04-16.txt",
2259+startLine: 2,
2260+endLine: 2,
2261+score: 0.88,
2262+snippet: "Assistant: Documented Ollama provider setup.",
2263+source: "memory",
2264+},
2265+],
2266+});
2267+const baseline = await rankShortTermPromotionCandidates({
2268+ workspaceDir,
2269+minScore: 0,
2270+minRecallCount: 0,
2271+minUniqueQueries: 0,
2272+ nowMs,
2273+});
2274+const liveKey = baseline.find((candidate) => candidate.path === "memory/2026-04-03.md")?.key;
2275+const staleKey = baseline.find((candidate) =>
2276+candidate.path.includes("session-corpus/2026-04-16.txt"),
2277+)?.key;
2278+expect(liveKey).toBeDefined();
2279+expect(staleKey).toBeDefined();
2280+2281+await withDreamingTestClock(async () => {
2282+setDreamingTestTime();
2283+await __testing.runPhaseIfTriggered({
2284+cleanedBody: __testing.constants.REM_SLEEP_EVENT_TEXT,
2285+trigger: "heartbeat",
2286+ workspaceDir,
2287+logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },
2288+phase: "rem",
2289+eventText: __testing.constants.REM_SLEEP_EVENT_TEXT,
2290+config: {
2291+enabled: true,
2292+lookbackDays: 7,
2293+limit: 10,
2294+minPatternStrength: 0,
2295+timezone: "UTC",
2296+storage: { mode: "inline", separateReports: false },
2297+},
2298+});
2299+});
2300+2301+const phaseSignalPath = resolveShortTermPhaseSignalStorePath(workspaceDir);
2302+const phaseSignalStore = JSON.parse(await fs.readFile(phaseSignalPath, "utf-8")) as {
2303+entries: Record<string, { remHits: number }>;
2304+};
2305+expect(phaseSignalStore.entries[liveKey!]).toMatchObject({ remHits: 1 });
2306+expect(phaseSignalStore.entries[staleKey!]).toBeUndefined();
2307+2308+const remOutput = await fs.readFile(
2309+path.join(workspaceDir, "memory", `${DREAMING_TEST_DAY}.md`),
2310+"utf-8",
2311+);
2312+expect(remOutput).toContain("Move backups to S3 Glacier.");
2313+expect(remOutput).not.toContain("Documented Ollama provider setup");
2314+});
2315+22242316it("passes staged light-dreaming snippets into the narrative pipeline", async () => {
22252317const workspaceDir = await createDreamingWorkspace();
22262318const subagent = createMockNarrativeSubagent("The backup plan glowed like cold storage.");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。