Commit Graph

1 Commits

Author SHA1 Message Date
rUv 4abef4b83f fix(memory): schema vector_indexes dim 768→384 + CI guard (#1947, #1942, #1952) (#1956)
* fix(memory): schema vector_indexes dim 768→384 (#1947, #1942, #1952)

The bundled SQL schema initialises the `default` and `patterns` rows in
`vector_indexes` with `dimensions = 768`, but the default ONNX embedding
model (`Xenova/all-MiniLM-L6-v2`) produces **384-dim** vectors. HNSW rejects
every insert with the mismatched dim — so on a fresh install
`memory_store --vector` prints success while `memory_search` always returns
0 hits, and `memory_stats` reads 0 vectors.

Root cause is a single inline schema literal in `memory-initializer.ts`'s
`getInitialMetadata()`. That string is run against the user's DB at init
time and is the canonical writer of the `vector_indexes` rows (the
`.swarm/schema.sql` files some packages ship are stale artifacts, not the
runtime source).

Fix: change the two literals to 384 (matching the default model).

CI guard: `scripts/audit-vector-dim.mjs` scans `v3/` and `ruflo/` for any
`INSERT … INTO vector_indexes (id, name, dimensions) VALUES
('default'|'patterns', …, N)` row and fails the build if `N !== 384`.
Wired into `vector-dim-audit` job (gates `witness-verify`). Verified to
catch a deliberately-reverted regression and to pass on the fixed tree
(24 matching rows scanned, all 384).

Resolves #1947 root cause #1 (the dim mismatch).
Resolves #1942 (Bridge search index 768 vs imported 384-dim embeddings).
Resolves #1952 (Windows: store ok, search returns 0, stats shows 0) — same
  root cause, Windows is just where the reporter observed it.

Follow-ups (not in this PR):
- #1947 root cause #2: `embeddings index -a build` defaults to `-c default`
  even when entries are in another namespace.
- #1947 "additional": `embeddings init --force` model-ID validator rejects
  the default model's own name (`Xenova/all-MiniLM-L6-v2`) because of `/`.
- #1941: claude-memories import doesn't provision a vector_indexes row.
- #1940: `memory_bridge_status` reports 0 despite persisted rows.
- Several published `@claude-flow/*` packages have no `files:` / `.npmignore`
  and ship stale `.swarm/` binary state (memory.db, hnsw.index, etc.).

Co-Authored-By: RuFlo <ruv@ruv.net>

* fix(memory-initializer): drop backticks from SQL comment (TS template-literal compile error)

The earlier fix included a comment block with backticks (\`Xenova/all-MiniLM-L6-v2\`,
\`memory_store --vector\`, \`memory_search\`) inside a TypeScript template literal —
the backticks terminated the template string and tsc errored with TS1005/TS1443
on lines 989/991. Build V3 failed across ubuntu / macOS / windows.

Replace the backticks with parens / plain prose. The schema literals are
unchanged (still 384).

Co-Authored-By: RuFlo <ruv@ruv.net>

---------

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
2026-05-13 09:02:02 -04:00