Commit 6a940e4
Every content-changing write ran the auto-embed synchronously post-commit
(62x latency, ~145 writes/s single-writer ceiling). Deferral is within the
path's own contract: the embed already ran after tx.commit() and failures
were explicitly non-fatal.
- remember() now enqueues (id, plaintext) to a bounded queue (1024, drop-new
on overflow + rate-limited warning) served by a dedicated worker thread
that drains up to 32 jobs per wake; embedding happens with NO pooled
connection held, the store draws one briefly (#397 discipline).
- Stale guard: the store is a single atomic conditional UPDATE that only
lands while the entity's current FTS plaintext still equals the enqueued
text (the #377/#379/#381 writer-family rule: no read-decide-write on stale
data; FTS holds plaintext, entities.body_json may be per-write GCM
ciphertext). A changed or forgotten row refuses the write; the newer body
enqueued its own job.
- Write path no longer consults the #219 session cache (new/changed bodies
are unique by definition — up to 256 full-body compares per write for a
guaranteed miss, and each insert evicted query entries that COULD hit).
Sync callers (query embedding, explicit mimir_embed) keep it.
- Misconfigured-backend logging (enabled, model missing, no endpoint) is
rate-limited to 1/min per site instead of one eprintln per write.
- Drop for Database: signal, disconnect, wait <=5s for the worker (in-flight
embed finishes, queued jobs dropped), detach if wedged in a slow remote
call. mimir_embed stays synchronous.
- Determinism seam: doc-hidden embed_queue_flush(timeout) blocks until the
queue drains; embedding-dependent tests flush instead of sleeping.
Tests: regression (write returns <400ms against a 500ms fake embed backend +
embedding absent at return, lands after flush — fails pre-fix at 502.7ms);
stale guard unit (changed/forgotten body refused, current body lands) + e2e
(change body mid-flight, surviving vector is the newest body's); overflow
(cap=1, drop-new, flush still terminates). Fake Ollama-format HTTP server
exercises the endpoint path in both default and lite builds; existing
bundled-ONNX tests updated to flush.
Measured (debug, 1KB bodies, bundled ONNX, n=40): write median 7,714us ->
~159us median-of-5 (~48x); full default suite 281 passed / 0 failed, lite
build green on the new tests.
Closes #393
Co-authored-by: tcconnally <hermes@perseus.observer>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 2278daf commit 6a940e4
2 files changed
Lines changed: 734 additions & 44 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
17 | 40 | | |
18 | 41 | | |
19 | 42 | | |
| |||
0 commit comments