Module embed_cmd

Module embed_cmd 

Source
Expand description

Embedding CLI commands: ctx embed pending and ctx embed rebuild.

Manages the embedding lifecycle:

§Staleness Detection

Each chunk’s text is hashed (SHA-256). When the hash in the embeddings table differs from the chunk’s current hash, the embedding is considered stale and will be re-generated by embed pending.

§Batching

Embeddings are generated in batches (configurable via embedding.batch_size or --batch-size flag). Each batch is a single API call to the embedding provider. Failed batches are logged but don’t abort the entire operation.

Structs§

PendingChunk 🔒
A chunk that needs embedding (missing or stale).

Functions§

embed_chunks_inline
Embed chunks during sync (inline). Non-fatal on failure.
find_pending_chunks 🔒
Find chunks that are missing embeddings or have stale hashes.
hash_text 🔒
Compute SHA-256 hash of text content (hex-encoded).
run_embed_pending
Backfill embeddings for chunks that are missing or have stale hashes.
run_embed_rebuild
Delete all embeddings and regenerate for all chunks.
upsert_embedding 🔒
Upsert an embedding into both embeddings (metadata) and chunk_vectors (blob).