Fix duplicate/mislabeled document entities from repo imports - #11
Merged
Conversation
…b imports _document_name() only checked metadata keys `path`/`file`/`filename`/ `document`/`title_path`, but local_files.py and github.py write `file_path`/`relative_path`/`file_name` instead. The mismatch made every document entity fall back to the first line of its content as its name/key, which collides across unrelated files and chunks (shared license headers, imports, blank lines) and silently merges them into one mislabeled graph node on reindex — the "everything in the graph looks the same/fake" symptom after a whole-repo import. Add the actual connector metadata keys, with relative_path preferred over the absolute file_path.
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
local_files/github, the knowledge graph showed many nodes that looked duplicated/fake, all displaying the same text.server/core/entities.py's_document_name()looked for metadata keyspath/file/filename/document/title_path, but thelocal_filesandgithubconnectors actually writefile_path/relative_path/file_name. The mismatch meant no memory ever matched, so every document entity fell back to using the first line of its content as its name/key — which collides across unrelated files and chunks (shared license headers,importlines, blank lines), silently merging many distinct files into one mislabeled graph node.relative_path,file_path,file_name) to the lookup list, preferring the repo-relative path.Test plan
python -m pytest tests/test_entity_graph.py tests/test_connector_sync.py -q— 21 passedGenerated by Claude Code