Repository navigation
feat(processor): implement cascading document deletion via adelete_by_doc_id (#127) - #471
Conversation
LarFii
left a comment
There was a problem hiding this comment.
The proposed public deletion API is useful, but the cleanup order currently causes data loss when core deletion fails.
Reproduction with a temporary parsed-output directory and the PR's processor harness: have LightRAG.adelete_by_doc_id raise before deleting the graph, then call adelete_by_doc_id(doc_id, delete_media_files=True). The result has status='failed'; the document/graph still exists, but the media directory and multimodal completion cache have already been deleted. The outer message also says 'Successfully processed deletion'. All current PR tests pass because they exercise successful core deletion.
Please delegate core deletion first and retain media/cache/placeholders unless its result confirms success; cover exceptions and unsuccessful/busy results. The fallback that deletes only doc_status/full_docs must not report a successful graph/vector deletion. Finally, artifact cleanup needs the actual parsed-output location: reconstructing it from the default basename-only file_path or config.parser_output_dir misses absolute source paths and per-call output_dir overrides. Please add regression coverage and document the new API in both READMEs. Leaving this PR open for revision.
…output locations in adelete_by_doc_id
|
Thanks for the thorough review, @LarFii! Every point has been addressed in
|
…261112 # Conflicts: # README.md # README_zh.md
LarFii
left a comment
There was a problem hiding this comment.
Resolved the earlier deletion-order findings and the remaining ambiguous-result / unrelated-output defects. Core exceptions, busy/failure/unknown responses retain project data. Basename guessing is removed, outputs referenced by other documents are retained, and actual filesystem failures cannot be reported as successful media removal. Full integrated suite: 1,308 passed with Ruff 0.6.4 lint/format; Python 3.10/3.11/3.12 CI passed. Four live Qwen3-VL/Qwen embedding insertion-query-public-deletion flows passed across all extraction modes, using real LightRAG stores. The rebased head has exactly the same file tree as the tested integration. Previous blocking review findings are resolved.
Add RAGAnything.adelete_by_doc_id() to delegate core graph/vector/document deletion to LightRAG and then clean project completion state, placeholders and optional parsed artifacts.
Core deletion must explicitly confirm success (or confirm absence of a cache-only orphan). Exceptions, busy/failure results, None and responses without a status retain project data. Remove basename-based directory guessing: use document-ID-linked records and exact paths, and retain outputs referenced by another indexed document. Filesystem removal errors leave media_files_deleted=False, including partial Office-output cleanup. Legacy basename-only records can still delete core data while leaving unlocated media in place.
Retain support for per-call output directories, persisted parser metadata/cache records and Office conversion artifacts. English and Chinese READMEs describe the API and cleanup-result semantics.
Validation:
Fixes #127
Addresses #332