`index(action="build", force=true)` cannot migrate a SQLite-vec index across embedding dimensions
$## Summary\nindex(action="build", force=true) does not recover from an existing SQLite-vec index whose vector dimension differs from the configured embedder.\n\n## Reproduction\n1. Build a project index with an embedder that returns 768-dimensional vectors.\n2. Configure an embedder that returns 384-dimensional vectors.\n3. Run index(action="build", force=true).\n4. Query index(action="status").\n\n## Actual behavior\nThe tool initially returns status: started, but the background job fails with the original dimension mismatch. The immutable code_vec table remains at 768 dimensions; no replacement index is created.\n\n## Expected behavior\nWith force=true, the tool should make the documented recovery path work: remove/recreate the incompatible project vector table and rebuild it at the configured dimension, while leaving unrelated projects intact. The outcome must be visible in final status.\n\n## Root cause\nRetrievalClient::sync_project calls guard_index_dim before it reaches the force-reindex work in stream_index. guard_index_dim rejects a mismatch unconditionally, so force_reindex cannot affect a dimension migration.\n\nRelevant locations:\n- src/retrieval/sync.rs: sync_project calls guard_index_dim before stream_index;\n- src/retrieval/client.rs: guard_index_dim returns the mismatch error;\n- src/retrieval/sqlite_code_store.rs: the vector table dimension is immutable.\n\n## Regression coverage requested\nUse a temporary SQLite-vec store to build at one dimension, then call the project-level forced rebuild with another. Assert: the old table is replaced, the final dimension matches the new embedder, all current files are searchable, and a non-forced rebuild still rejects the mismatch.\n\n## Impact\nChanging embedding models requires manual database manipulation despite force=true advertising a full reindex.
Fixed — thanks for the precise root-cause analysis; the diagnosis was exactly right and made this a one-commit fix.
Fix: 8504b1cf (patch-id be0fdace04f3c4aacef68af3efc7338056629a07) — "let force=true migrate a SQLite-vec index across embedding dimensions".
sync_project no longer calls guard_index_dim directly. It calls migrate_or_guard_index_dim, which delegates unchanged to guard_index_dim when force == false, and on force == true warns and calls code_store.reset_project_index(...) (DROP TABLE IF EXISTS code_vec + a project-scoped DELETE FROM code_chunk) before the rebuild. ensure_collection is a no-op for sqlite and the vec0 width is inferred from the first upsert, so the table comes back at the new dimension.
Regression coverage:
reset_then_reindex_migrates_the_vector_table_to_a_new_dimension— realvec0table, 3 dims → reset → 5 dims, and the query returns the migrated row. Assertscollection_dim == Noneafter reset (gone, not merely emptied), which also guards the shadow-table cleanup.sync_project_force_migrates_a_dimension_mismatch_instead_of_refusing— reportsdim_migration == Some((999, 3)).a_forced_sync_at_a_matching_dimension_reports_no_migration— stops the field becoming noise.guard_index_dim_errors_in_both_mismatch_directionsandguard_index_dim_catches_an_unpinned_local_model_switch— a non-forced rebuild still rejects.
Two things your issue asked for that are NOT fully met, so you know before you hit them:
- "The outcome must be visible in final status." It isn't, on the MCP surface.
SyncReport'sDisplayrendersdim_migrated={from}->{to}, but thatDisplayis only used by the CLI. Theindex(action="build")background task composes its owndetailstring and dropsreport.dim_migration, soindex(action="status")never names the migration. Tracked. - Qdrant still refuses by design.
force=truecannot migrate dimensions on aserver-stackbuild — collection width is a collection-level property shared across projects. Your issue is scoped to SQLite-vec so this is in-spec, but it's worth knowing if you switch backends.
Internally tracked as docs/issues/archive/2026-08-26-force-reindex-cannot-migrate-embedding-dimensions.md.