Feat v0.8.3 vector column type (#70)
Some checks failed
CI/CD / detect-changes (pull_request) Successful in 4s
CI/CD / test-frontend (pull_request) Has been skipped
CI/CD / test-runners (pull_request) Has been skipped
CI/CD / e2e-smoke (pull_request) Has been skipped
CI/CD / build-and-deploy (pull_request) Has been cancelled
CI/CD / test-sqlite (pull_request) Has been cancelled
CI/CD / test-go-pg (pull_request) Has been cancelled

Add vector(N) column type to db_tables manifests with three-tier
progressive enhancement: native pgvector on Postgres, JSONB fallback
without pgvector, TEXT fallback on SQLite. New db.query_similar()
Starlark builtin with dual-path dispatch.

- parseVectorDim validates 1..4096 dimensions
- mapColType gains hasPgvector parameter for tier selection
- HNSW index auto-created on pgvector backends
- starlarkToGoValue extended with list→JSON serialization
- cosineDistance helper for Go-side fallback computation
- ExtensionHandler gains SetCapabilities for install-time DDL
- Roadmap updated: v0.8.4 docs refresh + surface sizing fix

13 new tests (5 schema + 8 db module), all passing with -race.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-03 09:40:38 +00:00
parent 00ef970163
commit 4fed810dd5
16 changed files with 909 additions and 52 deletions

View File

@@ -2,6 +2,40 @@
All notable changes to Armature are documented here.
## v0.8.3 — Vector Column Type
Extensions can now declare vector columns and perform similarity search.
Three-tier progressive enhancement: native pgvector on Postgres, JSONB
fallback without pgvector, TEXT fallback on SQLite.
**Manifest: `db_tables` vector columns**
- Declare `"vector(N)"` as a column type (N = dimension, 14096).
- On Postgres with pgvector: native `vector(N)` type with auto-created
HNSW index (`vector_cosine_ops`).
- On Postgres without pgvector: `JSONB` column.
- On SQLite: `TEXT` column (JSON-encoded float arrays).
**Starlark API**
- `db.query_similar(table, column, vector=[], limit=10, filters={}, metric="cosine")`
— returns rows ordered by ascending cosine distance with injected `_distance` key.
- `db.insert()` now accepts list values (serialized as JSON strings) for
vector column storage.
**Internal**
- Modified: `handlers/ext_db_schema.go``parseVectorDim`, `mapColType`
gains `hasPgvector` parameter, HNSW index creation for vector columns.
- Modified: `sandbox/db_module.go``HasPgvector` in `DBModuleConfig`,
list support in `starlarkToGoValue`, `dbQuerySimilar` with pgvector and
fallback paths, `cosineDistance` helper.
- Modified: `sandbox/runner.go` — wire `HasPgvector` from capabilities.
- Modified: `handlers/extensions.go``SetCapabilities` on `ExtensionHandler`.
- Modified: `server/main.go` — wire capabilities to extension handler.
- Updated: `docs/STARLARK-REFERENCE.md` — vector similarity section.
- New tests: 5 schema tests + 8 db module tests (13 total).
## v0.8.2 — Capability Negotiation
Extensions declare environment requirements in their manifest. The kernel