Repository navigation
feat(memory): unified retrieval over memory documents - #127
Conversation
Reader.retrieve and RETRIEVE answer a question in one call. They resolve anchor atoms named in the question, run BM25 over sections, a vector search or a route through a hierarchy, and a confidence-weighted walk from the anchors and the best early candidates, then fuse the three rankings by reciprocal rank. A configured Reranker reorders the best 30. Each candidate is moved to the same section in the revision in force, by the requested valid and recorded time, and dropped if it did not exist then. Hits carry their Markdown, heading path, evidence from the revision's sources and admitted qualifiers, a path from an anchor, the later revisions where the section changed, and whether they are current: a section whose hyperedge memberships all ended is not. The final set keeps the best hit and picks the rest by coverage of the question's rarer words and anchors with the SELECT EVIDENCE objective. DIFFUSE gains VALID DURING [a, b) for memberships overlapping an interval and WEIGHTED BY CONFIDENCE, which scales memberships by their qualifier's confidence on both sides of each hyperedge.
- Each stage gets a share of the statement budget and the time left; a stage that runs out keeps what it found and adds a note, so a tight budget gives a smaller answer instead of an error. - In force means valid at the requested time, or now, as REVISION OF would answer; HISTORY no longer marks superseded sections current, and timed queries search every revision so text in force then is found by its own words. - Hyperedge links, paths and qualifier evidence count over the section and its earlier versions by anchor, so an unrelated edit to a node no longer turns an ended decision current. - THROUGH HIERARCHY keeps the IN type filter. With anchors the walk starts from the anchors only; without them its seed sections are left out of its list. - The reranker runs on the text that will be returned and a failing reranker is skipped with a note. - Payloads, sections and revisions are cached per call, memberships are read by incidence instead of copying member lists, and anchor lookups, incident edges and lineage count against the budget. - `later` follows valid time, coverage weights ignore what the best hit already covers, repeated RETRIEVE options are refused, possessives resolve, short words do not, and EXPLAIN DIFFUSE names the interval and confidence weighting.
|
Pushed fixes from a review pass. Each stage now has its own share of the budget, so a tight budget gives a partial answer with a note instead of an error. In force means valid at the requested time, or now; HISTORY no longer marks superseded sections current; timed queries search every revision. Hyperedge links count over a section's earlier versions, so an unrelated edit no longer makes an ended decision current. THROUGH HIERARCHY keeps the type filter, the walk starts from anchors only when there are anchors, the reranker sees the text it ranks and failures are skipped, and per-hit work is cached and charged. Full build: engine 269, database 374, server 41; each new test fails against the previous Retrieval.java. Live run green before and after SIGKILL, ClaimsBay question 8/8 in both tenants. |
…eature/memory-retrieve
…eature/memory-retrieve
…eature/memory-retrieve
Last part of the memory work, stacked on #126. One call now answers a question from memory documents with evidence attached.
What it does
Reader.retrieve(query, meter)andRETRIEVE 'question' …:ANCHORS, plus atoms of theRESOLVE INtypes whose key matches one to three words of the question.contentvectors, or aROUTEwithTHROUGH HIERARCHY;Rerankerset inDatabaseOptions(for example a cross-encoder run outside the database) then reorders the best 30.currentflag. A section whose hyperedge memberships all ended is not current, so a superseded decision never comes back marked current.SELECT EVIDENCEobjective, with rarer words weighted higher.DIFFUSEalso gains:VALID DURING [a, b), for memberships that overlap an interval;WEIGHTED BY CONFIDENCE, which scales each membership by its qualifier's confidence on both sides of the hyperedge.Syntax
Testing
RetrievalTestruns the first-milestone question from the design, "What did Alice and I decide about ClaimsBay, and what changed afterward?":RetrievalTestalso covers the lexical, semantic and structural lists, type filters, coverage across documents and a reranker hook.DiffusionTestcovers interval overlap and confidence on each side of a hyperedge.RetrieveStatementTestcovers the HQL.SecurityTest#retrievalStaysInsideTheTenantincludes a cross-tenant membership planted directly in storage.ROUTEexact at full mass.Merge order for the memory stack: #128 (CI fix), #124, #125, #126, #127, #129 (online text index rebuild), #130 (starter kit). Retarget each to main once the one below it merges. A private preview image built from #129 merged with #128 is at ghcr.io/metacoglabs/hstore-memory:0.2.0-dec80f2.