Skip to content

Fix duplicate/mislabeled document entities from repo imports - #11

Merged
ali-ulu merged 1 commit into
mainfrom
claude/remove-demo-data-xdwh4x
Jul 29, 2026
Merged

Fix duplicate/mislabeled document entities from repo imports#11
ali-ulu merged 1 commit into
mainfrom
claude/remove-demo-data-xdwh4x

Conversation

@ali-ulu

@ali-ulu ali-ulu commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • After importing a whole repo via local_files/github, the knowledge graph showed many nodes that looked duplicated/fake, all displaying the same text.
  • Root cause: server/core/entities.py's _document_name() looked for metadata keys path/file/filename/document/title_path, but the local_files and github connectors actually write file_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, import lines, blank lines), silently merging many distinct files into one mislabeled graph node.
  • Fix: add the real connector metadata keys (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 passed

Generated by Claude Code

…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.
@ali-ulu
ali-ulu merged commit 880ac9c into main Jul 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants