6.6 Dedup-on-write and tombstones

Every remember and remember_batch call runs two checks before insert:

  1. Exact normalized-text duplicate (defense-in-depth backed by a unique partial index). If a matching active row exists, the remember call returns that row’s id with message: "Already remembered".
  2. Semantic near-duplicate: run a similarity search at cosine >= 0.90 against active rows in the top-K=5. If any are found, the dedup_policy parameter decides what happens:
    insert

    Skip the check entirely. Always inserts.

    skip_if_near

    Don’t insert. Return the existing memory id.

    ask

    (Default.) Insert anyway. Include the near-duplicates in the response so the calling LLM sees what looked similar.

  3. Tombstone check: same similarity search but restricted to soft-deleted rows. If a near-duplicate tombstone is found, the response includes it as previously_corrected so the calling LLM can warn: “this fact was deleted with reason X.” This check does not block the insert — it’s a signal, not a veto.

Soft-deleted rows are dual-purpose: hidden from recall/list_memories/text_search but consulted by the dedup-on-write check. Hard delete (forget hard_delete=true) is the only way to truly remove a memory’s influence.