Skip to content

import "replace" wipes KV but leaves search indices stale #938

Description

@abhinav-m22

After a replace-import, search returns memories that were just deleted and misses everything just imported, until a server restart.

  • mem::import with strategy: "replace" deletes existing data across every namespace in src/functions/export-import.ts: observations (L274), memories (L279), and the rest
  • But the file never touches the search indices: no getSearchIndex().remove(), vectorIndexRemove(), or rebuildIndex() anywhere
  • After the wipe, BM25 and vector still hold the old entries
  • The freshly imported data never gets indexed
  • smart-search returns ghosts of deleted records and misses the imported ones for the whole process lifetime; only a restart fixes it

Fix

  • Call rebuildIndex(kv) (exported from search.ts) at the end of import. It clears both indices and repopulates from KV, which is exactly the right post-import state

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions