Repository navigation
Graph history looks up successor facts within the knowledge base - #1501
Merged
WaylandYang merged 2 commits intoNov 16, 2026
Merged
WaylandYang merged 2 commits into
WaylandYang merged 2 commits into
Conversation
Signed-off-by: Maya Kid <BinjunYann@gmail.com>
WaylandYang
approved these changes
Nov 16, 2026
WaylandYang
left a comment
Contributor
There was a problem hiding this comment.
Thanks, LGTM. Optional follow-up: add_evidence_located (graph.rs, the supersedes = $1 walk) and the recursive successor chains in resolution.rs also look up supersedes without kb_id. Merging.
2 tasks done
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.
Why
Graph changes and entity history look for successors to distinguish a correction from a rejection. The outer queries already select a single knowledge base, but the successor lookups omit that condition. PostgreSQL cannot narrow the scan by the leading column of the existing
(kb_id, supersedes)index.What changes
Add
s.kb_id = $1to both successor lookups. The existing composite foreign key ensures a successor belongs to the same knowledge base as its predecessor. The entity history page and count share the same lookup.How it was checked
On Linux with PostgreSQL 16.15 and the repository migrations applied, run the complete statements extracted from
f33f9fc9andd4899715against the same synthetic data set of 100 knowledge bases, 500,000 facts, and 100,000 successor links. Medians are from six warm pairs ofEXPLAIN (ANALYZE, BUFFERS)runs, alternating the order of the queries.Graph changes scanned 100,000 successor index entries before the change and 1,000 after. The history page and count both began constraining index lookups by
kb_idandsupersedes. Results matched byte for byte in order for first and later pages, a filtered query with corrections and rejections, and empty cases. Entity history returned the same totals for the populated entity (216) and a missing entity (0).cargo fmt --all --checkpassed.cargo clippy --workspace --all-targets -- -D warningspassed on Linux.Before review
git commit -s).UTOPIA_DATABASE_URLset andUTOPIA_TEST_REQUIRE_DB=1.