Skip to content

DeleteFileData leaves cross-file symbol_references rows pointing at deleted target symbols #1785

Description

@Widthdom

Summary

When DeleteFileData(fileId) (DbWriter.cs:280-287) removes a file's symbols and references, any symbol_references rows in other files that referenced the now-deleted symbols are left in place. These dangling references continue to surface in callers / callees / impact results as "call to symbol that no longer exists", until a full re-index re-derives them. The user-visible effect is that a callees query against caller-in-file-A returns rows whose target symbol's definition returns nothing — phantom edges.

Where

  • src/CodeIndex/Database/DbWriter.cs:280-287 (DeleteFileData scope)

Suggested approach

(1) After deleting the file's own symbols rows, run a follow-up DELETE FROM symbol_references WHERE target_symbol_id IN (<deleted_ids>) to remove edges pointing at the now-gone symbols. (2) Or, model the deletion as a soft-delete (symbols.deleted_at) so cross-file references remain but readers can join with a WHERE deleted_at IS NULL filter and surface stale edges explicitly. (3) Pick option (1) by default since it matches the "fresh re-index" mental model; document the trade-off if (2) is preferred. (4) Add a regression test: index file A (caller), file B (definition); delete file B; assert callees on A's caller does not return the deleted target. (5) Cross-link with #1518 (orphans) and #1728 (prune).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions