Skip to content

Develop v0.4.0 - #12

Merged
ldaidone merged 2 commits into
mainfrom
develop
Aug 24, 2026
Merged

Develop v0.4.0#12
ldaidone merged 2 commits into
mainfrom
develop

Conversation

@ldaidone

Copy link
Copy Markdown
Owner

RAG pipeline, search filter DSL, embedder interface + HNSW ANN index

Summary

This PR adds the retrieval layer on top of the existing vector stores: a pure-Go HNSW approximate nearest neighbor index, a RAG pipeline with token-budget prompt assembly, a composable metadata filter DSL, and an embedder abstraction with an offline dummy implementation. It also ships a SQLite-backed store and updates docs/tooling.

What's new

🧠 pkg/ann — HNSW index (new)

  • Pure-Go, CGo-free approximate nearest neighbor search (Malkov & Yashunin, 2016), cosine distance
  • Configurable M, EfConstruction, EfSearch, seed-deterministic builds for reproducible tests/demos
  • Recall@10 measured against exact brute force: 0.95–0.998 at n=2,000 / dim=64 depending on data distribution and ef
  • Perf fix included: node norms are cached instead of recomputed per comparison → search ~2x faster, build ~2.4x faster, results bit-identical
  • Regression floors in CI (recall_test.go) so a recall drop fails the build; benchmarks for build, search (ef=50/100/200) and brute-force baseline

📚 pkg/rag — Retrieval-Augmented Generation building blocks (new)

  • Retriever: query → embedding → store search → scored text chunks, with per-call TopK and metadata filtering
  • FormatContext with token-budget trimming and citation-friendly [n] numbering; BuildPrompt scaffolding
  • End-to-end retrieve over 1k docs runs in ~172µs; prompt assembly is nanosecond-scale (benchmarks included)

🔌 pkg/embedder (new) — Embedder interface + deterministic offline Dummy (FNV-hash, unit-norm) so pipelines are testable without model downloads

🔍 pkg/embedx — Search config + Filter DSL (new) — Searcher interface, WithK/WithFilter options, composable filters (Eq/In/Exists/And/Or/Not)

📦 Storage

  • New public pkg/store facade: single Store interface over all bundled backends
  • New internal SQLite store (~300 LOC + tests) alongside memory/Badger

🛠️ Tooling & docs

  • scripts/ascii-banner (portable, NO_COLOR-aware) + make install-banner
  • README rewritten for v0.4.0 features; ROADMAP updated (v0.2/v0.3 done)

Notes for reviewers

  • ⚠️ models/get-small.gtemodel adds a ~21MB binary asset to the repo — flagging in case we'd rather use Git LFS or a download script
  • ANN results are approximate by design; see pkg/ann/recall_test.go for the accuracy envelope
  • No breaking API changes to existing store/vector packages

Testing

  • go vet ./... clean; full suite passes under -race (12 packages)
  • New coverage: recall regression tests (ANN), RAG unit tests, filter DSL tests, SQLite store tests
  • Benchmarks: go test -bench . ./pkg/ann ./pkg/rag

This adds the core RAG (Retrieval-Augmented Generation) pipeline, a
composable metadata filter DSL, and an embedder interface with a
deterministic dummy implementation for offline testing.

New packages:
  pkg/rag          — Retriever, FormatContext, BuildPrompt with token-budget mgmt
  pkg/embedder     — Embedder interface + Dummy (FNV-hash, unit-norm)
  pkg/embedx       — Searcher interface + Filter DSL (Eq/In/Exists/And/Or/Not)
  pkg/store/store  — Public Store interface facade
  internal/store/sqlite — Internal SQLite implementation
  models/get-small.gtemodel — Binary model asset

Also included:
  scripts/ascii-banner — Portable 3D-shadow ASCII banner with rainbow/solid/
                         per-letter color, NO_COLOR support, make install-banner
  Makefile             — install-banner target, help uses banner script
  README.md            — RAG/Filter/Embedder sections + v0.3.0 changelog
  ROADMAP.md           — v0.2.0-v0.3.0 marked done, v0.4.0 = RAG + Search
pkg/ann/ann.go
- norms are now cached per node instead of being recomputed on every
  distance call -> search ~2x faster, index build ~2.4x faster,
  results bit-identical

pkg/ann/recall_test.go (new)
- recall@10 checks vs exact brute force on clustered + uniform data
- regression floors so a recall drop fails CI
- benchmarks: index build, search at ef=50/100/200, brute-force baseline

pkg/rag/bench_test.go (new)
- end-to-end Retrieve benchmark (embed + search over 1k docs)
- FormatContext and BuildPrompt micro-benchmarks
@codecov

codecov Bot commented Aug 22, 2026

Copy link
Copy Markdown

@ldaidone
ldaidone merged commit bff0f5b into main Aug 24, 2026
2 checks passed
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