Repository navigation
feat(retrieval): EXPLAIN and FUSE for retrieval, shared budgets, review fixes - #123
Merged
Merged
Conversation
…iew leftovers EXPLAIN now takes any retrieval statement and prints its family, whether its answer is exact, approximate with a certificate, or may fail, and the plan with the rule and counts that chose it, without running it. FUSE runs two to eight retrieval statements on one snapshot and merges them by reciprocal rank fusion, keeping the provenance of every item and saying when a LIMIT leaves out results of an exact list. DIFFUSE takes READS r and derives epsilon from its work bound. A HYPERMATCH whose first scan alone exceeds the row budget is refused before it starts. Leftovers from earlier reviews: other tenants' members no longer shape DIFFUSE thresholds and pushes or EXPAND FROM weights and damping; the branch snapshot route reports changes to an atom's record; branch statements refuse AT GENERATION and AS OF and show type names; a snapshot released during TRANSITIONS falls back to the feed; validity index reads check type privileges and the feed scan behind wall-clock instants is metered; COUNT of a one-hyperedge pattern reads the signature count, and parallel matching stops siblings after a failure; REFINE caps levels at the depth budget, accepts quoted type names and labels its paths; THROUGH takes WEIGHT or FACTOR in both DIFFUSE and EXPAND FROM; MOTIF accepts a quoted type after HAS ANY. EXPLAIN and FUSE need the same privileges as the statements they contain. No issue tracks this work.
A statement now has one budget, passed down through a scoped value. FUSE splits it in equal shares and shares one page trace across its parts, and SELECT EVIDENCE splits it in thirds. DIFFUSE cost estimates use constant time counts in the default tenant and charge the budget for visible counts otherwise, and READS also caps the row budget. REFINE FROM TYPE streams its roots. TRANSITIONS charges only the reader's own changes, so another tenant's writes cannot use up its budget, and falls back to the feed only when a snapshot was really released. FUSE names parts that ran out of budget and counts them approximate, ranks the atoms and hyperedges of a DIFFUSE part separately, and sums reciprocal ranks in a fixed order. A one-hyperedge HYPERMATCH COUNT is no longer refused by the first-scan rule. EXPLAIN checks atoms and types like the statement, follows SINCE and the common ancestor for branches, and nested EXPLAIN, FUSE or AT GENERATION is refused before parsing recurses. SIMILAR TO charges container sizes, SELECT EVIDENCE keeps expansion order and reports skipped large edges, MOTIFS phases stop at ten seconds each, and the docs now say where an exact statement returns a prefix and that a HYPERMATCH LIMIT does not bound the search. No issue tracks this work.
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.
Stacked on #122. Merge #121 and #122 first, then retarget this to
main.This finishes the retrieval work. It adds the planner layer for the new statements, closes every finding that earlier reviews left open, and fixes what a fresh re-review of the whole retrieval surface found.
Planner (
docs/database/planner.md#retrieval-statements)EXPLAINon any retrieval statement. It prints the family, whether the answer is exact, approximate with a certificate, or may fail, the plan, and the rule that chose it. It checks atoms and types as the statement would, without running it.FUSEruns 2 to 8 retrieval statements on one snapshot and merges them by reciprocal rank fusion (k = 60). It keeps each item's provenance, names parts that ran out of budget, and says when aLIMITleaves out results of an exact list.DIFFUSE … READS rsets epsilon from the walk's work bound and caps the row budget atr.HYPERMATCHrefusal: a pattern whose first scan alone exceeds the row budget is refused before any read. A one-hyperedgeCOUNT, answered from the signature count, is exempt.FUSEandSELECT EVIDENCEsplit it instead of starting fresh ones.Earlier leftovers, now fixed
DIFFUSEandEXPAND FROMvalues.AT GENERATION/AS OFand show type names.TRANSITIONS: falls back to the feed when a snapshot is released mid-diff.REFINE: caps levels at the depth budget and accepts quoted type names. Tied paths come out in the same order in both directions, pinned by a test.THROUGH: takesWEIGHTorFACTORin bothDIFFUSEandEXPAND FROM.Re-review. Two independent reviewers looked at this branch and at the whole retrieval surface. Neither found a critical issue. Their important findings are all fixed:
FUSEandSELECT EVIDENCEpartsDIFFUSEcost estimates doing unmetered workREFINE FROM TYPEloading every root up frontTRANSITIONSFUSEhiding parts that were cut shortCOUNTblocked by the first-scan ruleEXPLAINnot checking atomsEach has a test. The tests for the
COUNT,EXPLAINandREADSfixes fail on the previous commit.HYPERMATCH LIMITstill finds every tuple before cutting, because results are globally sorted; this is now documented rather than changed.Testing
SIMILAR TO50/50 per tenant,HYPERMATCHcounts andBRANCH DELTA.FUSEscores match their parts.DIFFUSE,EXPAND FROM,SELECT EVIDENCE,REFINEandMOTIFoutputs are identical after a SIGKILL and recovery (350 commits replayed).FUSEandEXPLAIN.Not done here
FUSEpart is the sameRANKquery.