Repository navigation
fix(graph): a workspace's ontology counts only its live documents - #535
Merged
Merged
Conversation
workspace_ontology joined each relation to its document without asking whether the document, or the chunk the relation came from, was retired, so a retired document's entities, and those of chunks a re-ingest had replaced, kept shaping the ontology. Both queries now require a live document and a live chunk. Within one workspace only; found by the separate review of #527. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KkWPqAcWbxfqz1aCP6Qsdx
|
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.



What
A follow-up from the separate security review of #527 (Low, within one workspace).
EntitiesRepository.workspace_ontologyjoined eachentity_relationsrow to its document but never checkeddeleted_at. A retired document's entities, and those of chunks a re-ingest had retired, therefore kept counting in the workspace's ontology.Change
Both ontology queries now join
documents ... AND d.deleted_at IS NULLanddocument_chunks ... AND c.deleted_at IS NULL. This is the same rule #527 applies to the expansion lookup.Tests
tests/integration/test_ontology_reads_live_documents.pysets up one live document, one retired document and one re-ingested (chunk-retired) document. OnlyLIVEremains among the types. It fails on the old code against Postgres.test_db_entities_memoriespasses: 31 passed in total. ruff is clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01KkWPqAcWbxfqz1aCP6Qsdx