AGENT SKILL

memex:embed:reembed

Re-encode EVERY documents row (NULL and non-NULL) using the currently-configured provider. Use after a deliberate provider or model change — old embeddings are dimensionally or semantically incomparable with new ones. Destructive — overwrites existing embeddings. Has a confirmation gate.

License 许可
MIT
所属仓库
nitekeeper/memex
最近更新
2026-09-22
Stars
★ 0
Forks
0

01 前言 Front Matter

name
memex:embed:reembed
description
Re-encode EVERY documents row (NULL and non-NULL) using the currently-configured provider. Use after a deliberate provider or model change — old embeddings are dimensionally or semantically incomparable with new ones. Destructive — overwrites existing embeddings. Has a confirmation gate.

03 SKILL.md 正文

memex:embed:reembed

When to use

You changed MEMEX_EMBEDDING_PROVIDER (e.g., switched from openai → voyage) or the model env var (e.g., MEMEX_OPENAI_MODEL from text-embedding-3-small → text-embedding-3-large). Existing embeddings from the old config are incompatible with the new one — different dimensions, different vector space, different cosine semantics.

This skill regenerates every row's embedding under the current config. Heavier than backfill (touches every row, not just NULL ones), so it's gated by a confirmation prompt.

Inputs

  • (optional) batch_size — commit every N rows. Default 100.
  • (optional) dry_run — preview the change without writes. Default false.
  • (optional) force — skip the model-change-check warning. Default false.

Recipe

Step 1 — Detect drift between active config and what's recorded

from scripts import embeddings
drift = embeddings.detect_model_change()

drift is None if the active provider/model matches what's recorded in registry.json:__embedding_model__, otherwise a dict:

{"active":   {"provider": ..., "model": ..., "dim": ...},
 "recorded": {"provider": ..., "model": ..., "dim": ...},
 "changed":  ["provider"|"model"|"dim", ...]}

If drift is None and force is not set, ask the user: "No model change detected — active provider/model match what's recorded. Re-embed anyway? (y/n)". Only proceed on yes.

If drift is not None, summarize the change for the user:

Model change detected:
  was:  <recorded.provider> / <recorded.model> ({recorded.dim}-dim)
  now:  <active.provider>   / <active.model>   ({active.dim}-dim)
Changed: <changed list>

Re-embedding will overwrite all existing embeddings in
~/.memex/index.db. Continue? (y/n)

Wait for confirmation. STOP on no.

Step 2 — (optional) Dry run

preview = embeddings.reembed_all(dry_run=True)

preview includes previous_recorded so the user can see what's being replaced. Useful for cost-estimating against an API.

Step 3 — Run the reembed

result = embeddings.reembed_all()

Per-row errors are counted in errors; failed rows keep their previous (now-stale) embedding. Re-running picks up retries naturally.

Step 4 — Report

Re-embed complete (provider=<p>, model=<m>, dim=<d>):
  was:        <previous_recorded.provider/model/dim>
  considered: <N>
  encoded:    <M>
  errors:     <E>

If errors > 0, urge the user to investigate — partial re-embeds mean some rows are still on the old model and will return bad cosine scores.

Errors

Same provider-SDK / env-var errors as backfill. Per-row encoding errors are counted, not raised.

Notes

  • Destructive by definition: existing non-NULL embeddings are overwritten. There's no rollback. If you want to keep the old embeddings, snapshot ~/.memex/index.db before running.
  • API cost: encodes every document once. Cost-estimate with dry_run before running on a large Index; Voyage / Local are cheaper / free.
  • If you only want to fill NULL rows (e.g., you just added a key and never had embeddings before), use memex:embed:backfill — it's idempotent and doesn't touch existing data.
  • The recorded __embedding_model__ in registry.json is updated automatically when encode() runs — no separate step needed to sync registry state.

04 同仓库更多 Skills

nitekeeper
nitekeeper/memex

run

Use to invoke any Memex v2.0 operation. Routes user-facing intents (ingest, ask, capture, lint, synthesize, dashboard) and agent-facing CRUD primitives to the right internal procedure.

★ 0
nitekeeper
nitekeeper/memex

memex:steward:reconcile-orphan

Authorized fix-up of a flagged orphan. Four actions — delete-index (remove documents row), repair (backfill row_id when target exists), reindex (re-run Librarian; deferred), note (acknowledge). Raises OrphanNotFoundError when index_id is unknown or, for repair, already linked.

★ 0
nitekeeper
nitekeeper/memex

memex:steward:dashboard

Launch a loopback-only, read-only HTTP dashboard over Memex — per-store summary, the federated index, knowledge communities, the code-navigation graph, and the agent registry, plus keyword search, a click-to-read content overlay, and an interactive 3D knowledge-graph view.

★ 0
nitekeeper
nitekeeper/memex

memex:steward:audit

Run a full integrity audit across the Memex Index and all registered stores. Detects orphans, broken relations, schema drift. Writes a structured audit report to ~/.memex/audits/. Read-only — never auto-fixes.

★ 0
nitekeeper
nitekeeper/memex

memex:steward:audit-store

Run an integrity audit scoped to a single registered store (reverse orphans + schema drift). Lighter than full audit.

★ 0
nitekeeper
nitekeeper/memex

memex:index:write

Direct write to the federated Index — the lower-level primitive that memex:brain:ingest and memex:brain:capture build on. Use when a consumer (Atelier, custom plugin) needs to add a document to its own store and have it indexed by the Librarian, without going through the Brain layer. Routes through Librarian subagent + Memex Core.

★ 0