add symmetric delete helpers for incremental kuzu rebuild (PR-T2)#266
Merged
Merged
Conversation
12 delete_*_for_file helpers + delete_all_for_file composite that delete nodes/edges keyed by source file. Each helper returns deleted row count. Kuzu enforces that nodes with connected edges cannot be deleted, so delete_symbols_for_file is comprehensive (cleans all edge types in both directions before deleting Symbol nodes). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
delete_*_for_filehelpers tobuild_ast_graph.pythat delete nodes/edges keyed by source file pathdelete_all_for_filecomposite that calls all helpers in correct dependency order, returns{helper_name: count}dict(conn: kuzu.Connection, file_path: str) -> intand returns deleted row counttests/test_symmetric_delete.pycovering each helper, cascade semantics, idempotency, and unknown-file edge caseDesign notes
The plan assumed "Kuzu does not cascade rel-table deletes". In practice, Kuzu raises RuntimeError when deleting a node that has connected edges. So
delete_symbols_for_filemust be comprehensive — it deletes ALL edge types connected to symbols in the file (both FROM and TO directions) before deleting Symbol nodes. Similarly,delete_routes_for_file,delete_clients_for_file, anddelete_producers_for_fileclean up their incoming edges first.Individual edge helpers (extends, implements, injects, calls, overrides) are source-only — they delete edges where the source symbol is in the file. This matches the pass emission model (each pass associates edges with a source file). Cross-file target-side edges are handled by
delete_symbols_for_file's comprehensive cleanup and by PR-T3's closure expansion.Implements PR-T2 from
plans/active/PLAN-TIER2-INCREMENTAL-REBUILD.md.Test plan
ruff check .clean🤖 Generated with Claude Code