Add lightweight code context indexing#1
Merged
Conversation
71adc78 to
f92c4a0
Compare
wuwangzhang1216
added a commit
that referenced
this pull request
Jun 9, 2026
Extend OpenDB's memory from strong retrieval to the 2026 SOTA: three-signal hybrid recall + an offline temporal knowledge graph — kept local, deterministic, and auditable (the differentiator the cloud frontier can't offer). Three-signal hybrid recall (entity leg): - opendb_core/entities.py: deterministic, local entity extraction (identifiers, tech vocab, proper nouns, dates, numbers-with-units). No LLM/NER. - SQLite hybrid recall now fuses FTS + dense vectors + entity matching (the Mem0-class multi-signal recipe), FTS-first so exact-match never regresses. memory_entities table + entity leg in _recall_hybrid; written on store, removed on delete. R@5 stays 100% on LongMemEval and CodeMemEval. Bi-temporal knowledge graph (the breakthrough): - opendb_core/temporal_kg.py: extract (subject|attribute|value|date) facts, then DETERMINISTIC bi-temporal invalidation (older value's valid_to = next value's valid_from; newest stays CURRENT). render_facts() emits a structured "CURRENT (since DATE) + history" block. Only extraction uses an LLM; parsing/invalidation/query are pure, testable, and keep source provenance. - opendb_core/consolidate.py: consolidate_kg() (+ consolidate_reflect/timeline) as offline "sleep-time" passes; raw episodes are kept (additive, no dilution). Results (LongMemEval, full 470, fixed model — ablation isolates the system): - Retrieval is already 100% sufficient (all answer sessions in top-15) — so E2E gains are about *presenting* evidence, not finding it. - hybrid retrieval +6.3; bi-temporal KG +4.5 over hybrid-only (preference +23.4, knowledge-update +9.7, multi-session +4.1; temporal -0.8 within noise). - Strong-reader peak (Opus 4.8) beat the #1 system OMEGA on 5/6 categories. Benchmark: benchmark/dreaming_e2e_bench.py (KG=1 / ADDITIVE_CONSOLIDATE=1, --per-cat N for fast subset iteration, --concurrency 20). Docs: README + REPORT Parts 9-10. Tests: tests/test_temporal_kg.py (deterministic logic). All 286 tests pass. Default install/behavior unchanged; everything opt-in. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
Verification
Notes
This intentionally avoids tree-sitter, graph databases, or a full call graph. It only adds the minimal indexed structure needed for targeted code context.