fix(sf): drop embedding row when memory is superseded
supersedeMemory soft-deleted via superseded_by but left the
memory_embeddings row in place. loadAllEmbeddings already filters
by superseded_by IS NULL, so the orphaned row is harmless functionally
— but it wastes storage, complicates manual SQL audits, and is
inconsistent with updateMemoryContent (which already invalidates the
embedding via 7bec2dc2d).
Best-effort delete; supersede still succeeds even if the embedding
delete raises. Symmetric with the update path.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
aa60821ec3
commit
1b71ddd178
1 changed files with 10 additions and 0 deletions
|
|
@ -343,12 +343,22 @@ export function reinforceMemory(id: string): boolean {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark a memory as superseded by another.
|
* Mark a memory as superseded by another.
|
||||||
|
*
|
||||||
|
* Drops the superseded memory's embedding row too: loadAllEmbeddings()
|
||||||
|
* already filters by superseded_by IS NULL, so the row was dead weight
|
||||||
|
* — keeping it would just waste storage and confuse manual SQL audits.
|
||||||
|
* Best-effort: a missing/failed delete doesn't block the supersede.
|
||||||
*/
|
*/
|
||||||
export function supersedeMemory(oldId: string, newId: string): boolean {
|
export function supersedeMemory(oldId: string, newId: string): boolean {
|
||||||
if (!isDbAvailable()) return false;
|
if (!isDbAvailable()) return false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
supersedeMemoryRow(oldId, newId, new Date().toISOString());
|
supersedeMemoryRow(oldId, newId, new Date().toISOString());
|
||||||
|
try {
|
||||||
|
deleteMemoryEmbedding(oldId);
|
||||||
|
} catch {
|
||||||
|
// Orphaned embedding rows are harmless; supersede still succeeded.
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue