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.

fix(autoindex): #718 — offer --fresh in the genesis-guard recovery message + document the dry-run refusal

xerj-org2ee3222f2a7b
diff --git a/engine/crates/xerj-autoindex/src/incremental_reconcile_http_tests.rs b/engine/crates/xerj-autoindex/src/incremental_reconcile_http_tests.rs
index 02b20d10b..7c0d046a8 100644
--- a/engine/crates/xerj-autoindex/src/incremental_reconcile_http_tests.rs
+++ b/engine/crates/xerj-autoindex/src/incremental_reconcile_http_tests.rs
@@ -2191,13 +2191,20 @@ fn no_graph_genesis_bootstrap_is_refused_on_the_graph_path() {
let mut graph = no_graph.clone();
graph.no_graph = false;
graph.snapshot_max_bytes = 64 << 30;
- let error = run_index(graph).unwrap_err();
+ let error = run_index(graph.clone()).unwrap_err();
let rendered = format!("{error:#}");
assert!(
rendered.contains("genesis bootstrap") && rendered.contains("different graph authority"),
"#585 case 2: a --no-graph genesis bootstrap must be refused on the graph path with the \
clear message, got: {rendered}"
);
+ // #718: the message must name every valid recovery route, including
+ // `--fresh` — the guard exempts it (nothing is committed past genesis), so
+ // omitting it hides a working recovery from the operator.
+ assert!(
+ rendered.contains("--fresh"),
+ "#718: the recovery message must offer --fresh, which the guard exempts, got: {rendered}"
+ );
// No mutation: nothing indexed, no new durable transaction beyond the
// original sync_bootstrap.
assert_eq!(journal_events(state_dir.path(), "sync_bootstrap"), 1);
@@ -2205,6 +2212,23 @@ fn no_graph_genesis_bootstrap_is_refused_on_the_graph_path() {
assert_eq!(journal_events(state_dir.path(), "sync_commit"), 0);
assert_eq!(endpoint.data_docs().len(), 0);
+ // #718: `--dry-run` does not exempt the refusal. A graph-path dry run over
+ // the pending --no-graph genesis is refused the same way (there is no graph
+ // genesis projection to show), with the same recovery message, and mutates
+ // nothing — a dry run of a refused run is a refusal.
+ let mut graph_dry = graph;
+ graph_dry.dry_run = true;
+ let dry_error = run_index(graph_dry).unwrap_err();
+ let dry_rendered = format!("{dry_error:#}");
+ assert!(
+ dry_rendered.contains("genesis bootstrap") && dry_rendered.contains("--fresh"),
+ "#718: --dry-run over a genesis on the graph path is refused too, got: {dry_rendered}"
+ );
+ assert_eq!(journal_events(state_dir.path(), "sync_bootstrap"), 1);
+ assert_eq!(journal_events(state_dir.path(), "sync_begin"), 0);
+ assert_eq!(journal_events(state_dir.path(), "sync_commit"), 0);
+ assert_eq!(endpoint.data_docs().len(), 0);
+
// Positive control: re-running in the SAME (--no-graph) mode continues
// the interrupted genesis normally.
no_graph.snapshot_max_bytes = 64 << 30;
diff --git a/engine/crates/xerj-autoindex/src/lib.rs b/engine/crates/xerj-autoindex/src/lib.rs
index e34206c83..2415d43b5 100644
--- a/engine/crates/xerj-autoindex/src/lib.rs
+++ b/engine/crates/xerj-autoindex/src/lib.rs
@@ -3472,14 +3472,24 @@ pub fn run_index_report(cfg: IndexCfg) -> Result<(i32, Option<Value>)> {
//
// `--fresh` is deliberately exempt, the same way `blocking_generation`
// above exempts genesis recovery: nothing has been committed past
- // genesis, so discarding and rebuilding in the requested mode is safe.
+ // genesis, so discarding and rebuilding in the requested mode is safe —
+ // which is why `--fresh` is one of the recovery routes the message names.
+ //
+ // #718: this refusal is intentionally NOT gated on `!cfg.dry_run`, unlike
+ // the pending-sync projection above. A dry run previews the run that WOULD
+ // execute, but this graph-path run would itself be refused, and there is no
+ // graph-path genesis projection to show (the `--no-graph` dry-run
+ // projection further below is `!genesis_recovery`-gated). Bailing is
+ // therefore the honest preview, and it precedes every write, so `--dry-run`
+ // reaches it before anything is mutated.
if genesis_recovery && preflight.no_graph_genesis && !cfg.no_graph && !cfg.fresh {
anyhow::bail!(
"a --no-graph generation's genesis bootstrap is pending in {} (nothing beyond \
generation 0 committed); continuing it on the default graph path would proceed \
under a different graph authority and mutate the destination. No remote mutation \
- was attempted. Re-run with --no-graph to finish the pending generation, or rebuild \
- with a new --state-dir and a new --prefix.",
+ was attempted. Re-run with --no-graph to finish the pending generation, re-run with \
+ --fresh to discard generation 0 and rebuild on the graph path, or rebuild with a new \
+ --state-dir and a new --prefix.",
state_dir.join("journal.ndjson").display()
);
}