fix(eve): scope forget, persist capture idempotency, and fail closed

Review findings: delete was not partitioned by scope.key, capture
replay after restart could double-write, and Mem0 errors were swallowed
as empty recall.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Himanshu-Sangshetti
2026-09-09 10:48:26 +08:00
co-authored by Cursor
parent 1d83bb0835
commit 10d6717068
24 changed files with 1013 additions and 165 deletions
+26 -5
View File
@@ -3,11 +3,12 @@ import { formatRecallMessages, recallMemories } from "../src/recall.js";
import { createFakeStore } from "./helpers.js";
describe("formatRecallMessages", () => {
it("drops empty memories", () => {
it("drops empty memories and empty ids", () => {
expect(
formatRecallMessages([
{ id: "1", memory: " likes tea " },
{ id: "2", memory: " " },
{ id: " ", memory: "kept text" },
]),
).toEqual([{ id: "1", content: "likes tea" }]);
});
@@ -20,13 +21,19 @@ describe("recallMemories", () => {
store,
scopeKey: "scope_abc",
query: "What does the user drink?",
topK: 5,
threshold: 0.1,
rerank: false,
topK: 3,
threshold: 0.5,
rerank: true,
});
expect(store.searched).toEqual([
{ query: "What does the user drink?", userId: "scope_abc" },
{
query: "What does the user drink?",
userId: "scope_abc",
topK: 3,
threshold: 0.5,
rerank: true,
},
]);
expect(result).toEqual({
messages: [{ id: "mem_1", content: "User likes tea" }],
@@ -47,4 +54,18 @@ describe("recallMemories", () => {
).resolves.toBeNull();
expect(store.searched).toEqual([]);
});
it("returns null when search has no usable hits", async () => {
const store = createFakeStore([{ id: " ", memory: " " }]);
await expect(
recallMemories({
store,
scopeKey: "scope_abc",
query: "tea",
topK: 5,
threshold: 0.1,
rerank: false,
}),
).resolves.toBeNull();
});
});