diff --git a/CHANGELOG.md b/CHANGELOG.md index 68d1dfdb9..0a130bc1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Docs: https://docs.clawd.bot - Auth profiles: keep auto-pinned preference while allowing rotation on failover; user pins stay locked. (#1138) — thanks @cheeeee. - macOS: avoid touching launchd in Remote over SSH so quitting the app no longer disables the remote gateway. (#1105) - Memory: index atomically so failed reindex preserves the previous memory database. (#1151) — thanks @gumadeiras. +- Memory: avoid sqlite-vec unique constraint failures when reindexing duplicate chunk ids. (#1151) — thanks @gumadeiras. ## 2026.1.18-3 diff --git a/extensions/matrix/src/channel.directory.test.ts b/extensions/matrix/src/channel.directory.test.ts index a88216b38..a90b9b79b 100644 --- a/extensions/matrix/src/channel.directory.test.ts +++ b/extensions/matrix/src/channel.directory.test.ts @@ -1,3 +1,5 @@ +import os from "node:os"; + import { beforeEach, describe, expect, it } from "vitest"; import type { PluginRuntime } from "clawdbot/plugin-sdk"; @@ -8,7 +10,11 @@ import { setMatrixRuntime } from "./runtime.js"; describe("matrix directory", () => { beforeEach(() => { - setMatrixRuntime({} as PluginRuntime); + setMatrixRuntime({ + state: { + resolveStateDir: () => os.tmpdir(), + }, + } as PluginRuntime); }); it("lists peers and groups from config", async () => { diff --git a/src/memory/manager.ts b/src/memory/manager.ts index 0e463d4d4..0994c7379 100644 --- a/src/memory/manager.ts +++ b/src/memory/manager.ts @@ -1406,8 +1406,11 @@ export class MemoryIndexManager { now, ); if (vectorReady && embedding.length > 0) { + try { + this.db.prepare(`DELETE FROM ${VECTOR_TABLE} WHERE id = ?`).run(id); + } catch {} this.db - .prepare(`INSERT OR REPLACE INTO ${VECTOR_TABLE} (id, embedding) VALUES (?, ?)`) + .prepare(`INSERT INTO ${VECTOR_TABLE} (id, embedding) VALUES (?, ?)`) .run(id, vectorToBlob(embedding)); } if (this.fts.enabled && this.fts.available) {