Skip to content

armgit / xerj

Public Imported from GitHub
0

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.

test(brain): pin new-note probe bypass

buger3845f75eca52
diff --git a/engine/crates/xerj-server/src/brain.rs b/engine/crates/xerj-server/src/brain.rs
index 1217b67fc..8e8e62e48 100644
--- a/engine/crates/xerj-server/src/brain.rs
+++ b/engine/crates/xerj-server/src/brain.rs
@@ -279,7 +279,7 @@ fn run(cfg: BrainCfg) -> Result<i32> {
};
// `records_total` is run-scoped: a resumed re-run over an already-indexed
// folder legitimately reports 0. Server truth decides what that means.
- if run_u64(&run_doc, "records_total") == 0 {
+ if needs_live_node_probe(run_u64(&run_doc, "records_total")) {
let live_nodes = live_node_docs(&es, &brain)?;
if journal_server_disagrees(run_u64(&run_doc, "files_indexed"), live_nodes, cfg.fresh) {
bail!("{}", journal_server_disagreement(&cfg, &brain));
@@ -441,6 +441,10 @@ fn journal_server_disagrees(files_indexed: u64, live_nodes: Option<u64>, fresh:
files_indexed > 0 && matches!(live_nodes, None | Some(0)) && !fresh
}
+fn needs_live_node_probe(records_total: u64) -> bool {
+ records_total == 0
+}
+
fn index_cfg(cfg: &BrainCfg, brain: &str, api_key: Option<String>) -> IndexCfg {
// Same resource policy as `xerj autoindex` itself — `xerj brain` composes
// autoindex, so it must not invent its own worker counts (#240).
@@ -720,6 +724,11 @@ mod tests {
#[test]
fn disagreement_decision_refuses_absent_and_zero_but_not_positive_server_truth() {
+ assert!(
+ !needs_live_node_probe(1),
+ "a run that indexed a new note must not enter resume probing"
+ );
+ assert!(needs_live_node_probe(0));
assert!(journal_server_disagrees(1, None, false));
assert!(journal_server_disagrees(1, Some(0), false));
assert!(!journal_server_disagrees(1, Some(7), false));