Files
zeekayandHanzo Dev 6c2b324a68 go: a self-contained cgo binding, importable straight from the fork
github.com/hanzoai/sqlite-vec/cgo compiles the extension into the binary and
registers it process-wide (sqlite3_auto_extension) for every connection csqlite
opens — one SQLite in the binary, one extension object, no shared library.

Layout is dictated by how the C is written: sqlite-vec.c #include's its
-diskann/-ivf/-ivf-kmeans/-rescore siblings, so compiling the repo root as a Go
package would hand cgo each fragment as its own unit (measured: rescore fails on
its first type). cgo/wrapper.c textually includes ../sqlite-vec.c instead — the
root stays a plain C tree that upstream merges land on untouched.

Differences from upstream's own Go bindings, both deliberate:
- sqlite3.h is COMMITTED, copied byte-for-byte from hanzoai/csqlite's
  sqlite3-binding.h (SQLite 3.53.2) — upstream leaves the include to whatever
  the system has, so its build only works when libsqlite3-dev happens to be
  installed, at whatever version it happens to be. The header here can never
  drift from the library that links.
- sqlite-vec.h is generated from sqlite-vec.h.tmpl and committed, so the module
  is go-gettable without running make.

Verified end-to-end with csqlite v0.1.2, not just compiled:
  vec_version() = v0.1.10-alpha.4
  vec0 KNN over float[4] returns exact Euclidean order —
  [1,0,0,0]->0.0000, [0.9,0.1,0,0]->0.1414 (sqrt .02), [0,1,0,0]->1.4142 (sqrt 2).

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-31 11:22:34 -07:00
..