Skip to content

Commit 5c3f7ed

Browse files
committed
fix(memory): preserve cross-day light freshness
1 parent bade273 commit 5c3f7ed

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

extensions/memory-core/src/dreaming-phases.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3029,6 +3029,7 @@ describe("memory-core dreaming phases", () => {
30293029
});
30303030
expect(after1).toHaveLength(1);
30313031
expect(after1[0]?.dailyCount).toBe(1);
3032+
expect(after1[0]?.lastRecalledAt).toBe("2026-04-05T10:00:00.000Z");
30323033

30333034
const day2Ms = Date.parse("2026-04-06T10:00:00.000Z");
30343035
const { beforeAgentReply: reply2 } = createHarness(configForTest, workspaceDir);
@@ -3049,6 +3050,7 @@ describe("memory-core dreaming phases", () => {
30493050
});
30503051
expect(after2).toHaveLength(1);
30513052
expect(after2[0]?.dailyCount).toBe(2);
3053+
expect(after2[0]?.lastRecalledAt).toBe("2026-04-05T10:00:00.000Z");
30523054
});
30533055
});
30543056

extensions/memory-core/src/short-term-promotion.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ describe("short-term promotion", () => {
110110
claimHash?: unknown;
111111
firstRecalledAt?: unknown;
112112
lastRecalledAt?: unknown;
113+
dailyCount?: unknown;
113114
recallCount?: unknown;
114115
snippet?: unknown;
115116
totalScore?: unknown;

extensions/memory-core/src/short-term-promotion.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,8 +1457,13 @@ export async function recordShortTermRecalls(params: {
14571457
const recallDays = mergeRecentDistinct(recallDaysBase, todayBucket, MAX_RECALL_DAYS);
14581458
const conceptTags = deriveConceptTags({ path: normalizedPath, snippet });
14591459

1460-
const unchangedDedupeSignal = dedupeSignal && existing?.snippet === snippet;
1461-
const lastRecalledAt = unchangedDedupeSignal ? (existing?.lastRecalledAt ?? nowIso) : nowIso;
1460+
const unchangedRepeatedSignal =
1461+
Boolean(params.dedupeByQueryPerDay) &&
1462+
queryHashesBase.includes(queryHash) &&
1463+
existing?.snippet === snippet;
1464+
const lastRecalledAt = unchangedRepeatedSignal
1465+
? (existing?.lastRecalledAt ?? nowIso)
1466+
: nowIso;
14621467

14631468
store.entries[key] = {
14641469
key,
@@ -1609,8 +1614,13 @@ export async function recordGroundedShortTermCandidates(params: {
16091614
const recallDays = mergeRecentDistinct(recallDaysBase, dayBucket, MAX_RECALL_DAYS);
16101615
const conceptTags = deriveConceptTags({ path: item.path, snippet: item.snippet });
16111616

1612-
const unchangedDedupeSignal = dedupeSignal && existing?.snippet === item.snippet;
1613-
const lastRecalledAt = unchangedDedupeSignal ? (existing?.lastRecalledAt ?? nowIso) : nowIso;
1617+
const unchangedRepeatedSignal =
1618+
Boolean(params.dedupeByQueryPerDay) &&
1619+
queryHashesBase.includes(queryHash) &&
1620+
existing?.snippet === item.snippet;
1621+
const lastRecalledAt = unchangedRepeatedSignal
1622+
? (existing?.lastRecalledAt ?? nowIso)
1623+
: nowIso;
16141624

16151625
store.entries[key] = {
16161626
key,

0 commit comments

Comments
 (0)