Skip to content

refactor(core): one way to ask for an embedding (#1538) - #1546

Merged
ajianaz merged 2 commits into
developfrom
refactor/embed-one-way
Oct 22, 2026
Merged

ajianaz merged 2 commits into
developfrom
refactor/embed-one-way

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

What

  • New embedding.rs: Uteke::embed (lazy init + retry), embed_once (no retry) and embedder_max_seq_len. The embedder lock is held for one call, never across a loop.
  • The ten call sites (recall, explain, document search, document chunks x2, room recall, update, import, embed_text, writes, reembed) use it; the five expect("embedder ensured above") are gone and nothing outside embedding.rs locks the embedder.
  • Behaviour change: query, document and room embedding now retry a transient failure like writes (3 attempts, 200/400/800 ms). reembed takes the lock per row instead of for the whole loop and still makes one attempt per row. Writes keep their policy: init failure is an error, generation failure is FTS5-only with a warning.
  • The missing-embedder message is now the plain "No embedder configured".

Why

#1538, part of #1543. Four patterns for the same call meant retry on writes only, panics that were safe only by call order, and a lock held across the reembed loop.

Testing

  • New tests with the shared fake (test(core): let tests supply an embedder through the public open path (#1542) #1545): query, document search and embed_text retry once; a persistent failure errors after 3 attempts; embed_once does not retry; a write that cannot embed is FTS5-only with a warning; reembed makes one attempt per row.
  • cargo test --workspace (core lib 877 passed, 0 ignored), clippy -D warnings, fmt.
  • Cora MCP review of the new module: no findings.

Lazy init, the embedder lock and the retry live in embedding.rs; the ten call sites ask it and the five expect() panics are gone. Query, document and room embedding now retry like writes.
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit dfeaaa4 into develop Oct 22, 2026
15 checks passed
@ajianaz
ajianaz deleted the refactor/embed-one-way branch October 29, 2026 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant