Skip to content

DELETE /api/v1/memories does not cascade to derived memories (episodic, foresight, event_log) #148

@contextablemark

Description

@contextablemark

Summary

DELETE /api/v1/memories soft-deletes MemCell documents in MongoDB but does not cascade to derived memory types. After deletion, episodic_memory, foresight_record, and event_log_record documents remain in MongoDB, Elasticsearch, and Milvus — and continue to appear in search results.

Steps to Reproduce

  1. Store messages via POST /api/v1/memories until boundary detection triggers extraction
  2. Confirm episodic memories are searchable via GET /api/v1/memories/search
  3. Delete the MemCell: DELETE /api/v1/memories with event_id set to the MemCell _id
  4. Search again — derived memories still appear

Expected Behavior

Deleting a MemCell should cascade to all derived records:

  • episodic_memories — delete from MongoDB, Elasticsearch, and Milvus
  • foresight_records — delete from MongoDB and Milvus
  • event_log_records — delete from MongoDB, Elasticsearch, and Milvus

The repository classes already have the necessary delete methods (EpisodicMemoryEsRepository.delete_by_event_id, ForesightMilvusRepository.delete_by_parent_id, etc.) — they just aren't called from MemCellDeleteService.delete_by_combined_criteria.

Actual Behavior

MemCellDeleteService.delete_by_combined_criteria only calls MemCell.delete_many(filter_dict). No derived memories are touched. The cascade delete infrastructure (repository delete methods) exists but is not wired into the delete service.

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions