The deleteDocument() function in src/core/documents.ts only deletes from the documents table and relies on ON DELETE CASCADE for chunks and ratings. However:
chunk_embeddings (vec0 virtual table) has no foreign key — orphaned embedding rows remain after document deletion
chunks_fts has a trigger chunks_ad that fires on chunk deletion, which should cascade from the document delete. But this depends on the trigger being present (migration v2) and the cascade working correctly through the virtual table.
Should explicitly delete from chunk_embeddings before deleting the document, or at least verify the cascade path works end-to-end.