AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.
Rust agent-memoryai-agentsbm25claude-codeclicode-searchcursordatabaseelasticsearchfull-text-searchhybrid-searchjsonllocal-firstmcpmcp-servermodel-context-protocolragrustsearch-enginevector-search
merge(rc4-w2): Stream A — doc CRUD wire semantics (items 1-4)
xerj-org2abd45cd2d0a
diff --cc engine/crates/xerj-storage/src/index_store.rsindex f5a37b683,de5685775..e6a213463--- a/engine/crates/xerj-storage/src/index_store.rs+++ b/engine/crates/xerj-storage/src/index_store.rs@@@ -1546,25 -1522,7 +1557,24 @@@ impl IndexStore&entry.doc_id,entry.seq_no,std::sync::Arc::clone(&segment_id_arc),- false,);+ } else {+ // RC4 W2 #14 — repoint the delete's tombstone off+ // `__memtable__` onto the segment that now durably+ // carries it (the ZTB2 section written above; the+ // segment + section were fsynced by `writer.finish`).+ // Guarded (`set_if_latest`): a doc re-indexed while this+ // flush ran has a strictly newer live entry that must+ // not be clobbered back to deleted. Once+ // segment-resident, `sweep_pending_deletes` unpins the+ // WAL shard and `wal_pair_durable` lets the Delete+ // entry prune.+ self.version_map.set_if_latest(+ &entry.doc_id,+ entry.seq_no,+ std::sync::Arc::clone(&segment_id_arc),+ true,+ );}}if prof {diff --cc engine/crates/xerj-storage/src/version_map.rsindex e07134f43,82ac77430..351c599de--- a/engine/crates/xerj-storage/src/version_map.rs+++ b/engine/crates/xerj-storage/src/version_map.rs@@@ -204,19 -237,15 +245,25 @@@ impl VersionMapmatch self.inner.entry(doc_id) {Entry::Occupied(mut occ) => {if seq_no >= occ.get().seq_no {+ // Physical repoint of an already-counted write — the- // per-doc `_version` is carried over unchanged.++ // per-doc `_version` is carried over unchanged (A1-A3).+ let version = occ.get().version;- occ.insert(VersionEntry {++ // Capture the displaced entry for live/ghost accounting++ // (RC4 W2 #14).+ let old = occ.insert(VersionEntry {seq_no,segment_id: segment_id.into(),deleted,+ version,});+ // Mirror `set`: a same-seq repoint is NOT an overwrite+ // (see the flush-repoint note there); a tombstone that+ // REPLACES a live entry is a ghost event.+ let is_overwrite = old.seq_no != seq_no;+ if is_overwrite || (deleted && !old.deleted) {+ self.ghost_events.fetch_add(1, Ordering::Relaxed);+ }+ self.live_delta(!old.deleted, !deleted);}}Entry::Vacant(vac) => {@@@ -224,11 -253,8 +271,12 @@@seq_no,segment_id: segment_id.into(),deleted,+ version: 1,});+ if deleted {+ self.ghost_events.fetch_add(1, Ordering::Relaxed);+ }+ self.live_delta(false, !deleted);}}}