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
+32 -3
View File
@@ -8,8 +8,9 @@ describe("captureCompletedTurn", () => {
const captured = await captureCompletedTurn({
store,
scopeKey: "scope_abc",
infer: true,
metadata: { source: "eve" },
operationId: "op_1",
infer: false,
metadata: { source: "eve", operation_id: "op_1" },
turnInput: [{ role: "user", content: "I am vegetarian" }],
messages: [
{ role: "user", content: "I am vegetarian" },
@@ -21,6 +22,8 @@ describe("captureCompletedTurn", () => {
expect(store.added).toEqual([
{
userId: "scope_abc",
infer: false,
metadata: { source: "eve", operation_id: "op_1" },
messages: [
{ role: "user", content: "I am vegetarian" },
{ role: "assistant", content: "Got it." },
@@ -34,12 +37,38 @@ describe("captureCompletedTurn", () => {
const captured = await captureCompletedTurn({
store,
scopeKey: "scope_abc",
operationId: "op_1",
infer: true,
metadata: {},
metadata: { operation_id: "op_1" },
turnInput: [],
messages: [],
});
expect(captured).toBe(false);
expect(store.added).toEqual([]);
});
it("skips add when the operation id was already captured", async () => {
const store = createFakeStore([
{
id: "mem_existing",
memory: "already stored",
metadata: { operation_id: "op_replay" },
},
]);
const captured = await captureCompletedTurn({
store,
scopeKey: "scope_abc",
operationId: "op_replay",
infer: true,
metadata: { operation_id: "op_replay" },
turnInput: [{ role: "user", content: "I am vegetarian" }],
messages: [
{ role: "user", content: "I am vegetarian" },
{ role: "assistant", content: "Got it." },
],
});
expect(captured).toBe(false);
expect(store.added).toEqual([]);
});
});