🐾 fix(api): cascade collection and item deletes too #10

Merged
r merged 1 commits from fix/collection-item-cascade into main 2026-08-03 17:13:46 +00:00
Owner

Completes the cascade work from #9 (which was merged while this commit was in flight — this is the collection/item half, rebased onto the merged main).

What

Collection and Item DELETE — the REST endpoints and the HTML views — called bare .delete(), leaking each collection's Items and every item's Chunks/Images/ImageEmbeddings:

  • New delete_collection_cascade(col) and delete_item_cascade(item_uid) in the shared library_delete service, mirroring the library cascade's staged Cypher and returning item_s3_keys/s3_key for future async S3 cleanup.
  • All four paths now use them: DELETE /library/api/collections/{uid}/, DELETE /library/api/items/{uid}/, and the HTML collection_delete / item_delete views. Each logs what was removed.
  • No orphan-Concept GC in either — that invariant deliberately stays library-delete-only, matching the existing ingest supersede path's documented behaviour; Concepts orphaned here are collected on the next library delete.
  • tasks._delete_item_and_chunks now delegates to delete_item_cascade instead of duplicating its Cypher (same query, one home).

Testing

30 tests green across test_library_api (new: collection + item cascade called, 404 skips cascade), test_managed_by, test_tasks — the only error is the pre-existing test_embed_item_failure (fails identically on clean main). Full library + mcp_server suite matches the known baseline (8F/1E). Live Cypher on the manual e2e checklist per repo policy.

🤖 Generated with Claude Code

Completes the cascade work from #9 (which was merged while this commit was in flight — this is the collection/item half, rebased onto the merged main). ## What Collection and Item DELETE — the REST endpoints **and** the HTML views — called bare `.delete()`, leaking each collection's Items and every item's Chunks/Images/ImageEmbeddings: - New `delete_collection_cascade(col)` and `delete_item_cascade(item_uid)` in the shared `library_delete` service, mirroring the library cascade's staged Cypher and returning `item_s3_keys`/`s3_key` for future async S3 cleanup. - All four paths now use them: `DELETE /library/api/collections/{uid}/`, `DELETE /library/api/items/{uid}/`, and the HTML `collection_delete` / `item_delete` views. Each logs what was removed. - **No orphan-Concept GC** in either — that invariant deliberately stays library-delete-only, matching the existing ingest supersede path's documented behaviour; Concepts orphaned here are collected on the next library delete. - `tasks._delete_item_and_chunks` now delegates to `delete_item_cascade` instead of duplicating its Cypher (same query, one home). ## Testing 30 tests green across `test_library_api` (new: collection + item cascade called, 404 skips cascade), `test_managed_by`, `test_tasks` — the only error is the pre-existing `test_embed_item_failure` (fails identically on clean main). Full `library` + `mcp_server` suite matches the known baseline (8F/1E). Live Cypher on the manual e2e checklist per repo policy. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
r added 1 commit 2026-08-03 17:12:40 +00:00
Collection and Item DELETE — both the REST endpoints and the HTML
views — called bare .delete(), leaking each collection's Items and every
item's Chunks/Images/ImageEmbeddings. New delete_collection_cascade and
delete_item_cascade in the shared library_delete service now back all
four paths. No orphan-Concept GC in either (that invariant stays
library-delete-only, matching the existing supersede path); the ingest
supersede helper in tasks.py now delegates to delete_item_cascade
instead of duplicating its Cypher.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
r merged commit b5fba26d4c into main 2026-08-03 17:13:46 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: r/mnemosyne#10