Skip to content

Add lightweight code context indexing#1

Merged
wuwangzhang1216 merged 1 commit into
mainfrom
codex/codegraph-context-pr
May 15, 2026
Merged

Add lightweight code context indexing#1
wuwangzhang1216 merged 1 commit into
mainfrom
codex/codegraph-context-pr

Conversation

@wuwangzhang1216

Copy link
Copy Markdown
Contributor

Summary

  • add a small standard-library code intelligence extractor for Python symbols and Python/JS/TS import links
  • persist code symbols in SQLite/Postgres and reuse existing file_links for import backlinks
  • expose compact context lookup via REST, MCP, CLI, and Workspace API

Verification

  • uv run python -m compileall opendb_core mcp_server opendb -q
  • uv run --extra dev pytest tests/test_code_context.py tests/test_eval_capture_links.py tests/test_sqlite_backend.py tests/test_index.py tests/test_parsers.py tests/test_resolve_filename.py tests/test_e2e.py -q

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.

@wuwangzhang1216 wuwangzhang1216 force-pushed the codex/codegraph-context-pr branch from 71adc78 to f92c4a0 Compare May 15, 2026 04:08
@wuwangzhang1216 wuwangzhang1216 merged commit eb052ea into main May 15, 2026
4 checks passed
@wuwangzhang1216 wuwangzhang1216 deleted the codex/codegraph-context-pr branch May 15, 2026 04:12
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant