Skip to main content

Module reembed

Module reembed 

Source
Expand description

v0.7.0 #1598 — ai-memory reembed CLI subcommand.

The operator-facing vector-space migration tool for the API-wired embeddings train: re-embeds EVERY live memory (optionally namespace-filtered) with the currently-resolved embedding backend + model, REPLACING each stored vector. Unlike the boot backfill (which only fills embedding IS NULL rows), reembed rewrites rows that already carry vectors — it is the tool that moves a corpus from one model/dim to another (e.g. local MiniLM 384-dim → an OpenAI-compatible API model at 768/1536-dim).

§Resolution contract

The embedder is resolved through the SAME path as daemon/MCP boot: crate::config::AppConfig::resolve_embeddings + crate::embeddings::Embedder::from_resolved, with the tier model gated exactly like crate::daemon_runtime::build_embedder (API backends bypass the local model picker; the tier preset only gates whether embeddings are enabled at all). A keyword-only tier errors out with a clear message (EXIT_NO_EMBEDDER).

§Failure isolation

Per-chunk embedding routes through the shared #1595 primitive ([crate::mcp::embed_rows_with_fallback]): a chunk-level embed_batch fault falls back to per-row embeds; rows that still fail (or exceed the client-side crate::embeddings::EMBED_MAX_BYTES cap) are skipped with a WARN naming the row id + reason and KEEP their previous vector. Writes go through crate::db::set_embeddings_batch_reembed, the replace-semantics writer that legitimately bypasses the G4 namespace-dim invariant mid-migration (the H7 recall read-guards skip dim-mismatched vectors during the transition).

Structs§

ReembedArgs
CLI args for ai-memory reembed.

Constants§

EXIT_EMBEDDER_INIT_FAILED
Exit code when an embedder is configured but its construction failed (502-equivalent — dead endpoint, bad key, unknown dim).
EXIT_NO_EMBEDDER
Exit code when no embedding-capable tier/backend is configured (503-equivalent — the embedding surface is unreachable by config).

Functions§

cmd_reembed
ai-memory reembed dispatch entry. Resolves the embedder through the boot ladder, prints the loud pre-flight dim disclosure, then either prints the plan (--dry-run) or runs the replace sweep.