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): reconcile the rerun-refusal work with #240/#241/#248/#249

xerj-org1b0cfe0212c6
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cd45b230f..ef625a381 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -29,6 +29,56 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
`pdf_extraction_reuse` block so the behaviour is observable rather than
inferred from timing. Original work by Leonid Bugaev (@buger).
+### Changed — autoindex refuses reruns that would strand documents
+
+- **Deleting an indexed file and rerunning `xerj autoindex` now fails instead
+ of exiting 0.** Nothing in the pipeline removes the documents, aliases,
+ graph edges or catalog entries that the deleted file published, so a rerun
+ that ignored the deletion left them live and searchable with no source file
+ behind them. The rerun is now refused before any remote call other than the
+ endpoint-readiness ping: no mapping, delete-by-query, bulk, refresh, graph
+ or catalog write is attempted, and the journal is not appended to. The error
+ names the removed files and their content keys — the first ten, then an
+ `… and N more` tail, since a whole unmounted subtree can vanish at once —
+ and gives three recovery routes: restore the files and rerun, rebuild in
+ place by deleting the named indices and the state directory, or rebuild
+ under a new state directory, prefix and brain. `--fresh` is refused for the
+ same case, because it does not delete those documents either. `--json` emits
+ the same facts — every removed entry, uncapped — as
+ `xerj.autoindex.unsupported_sync_delta.v1` on stdout with exit 1. Deleting a
+ file that was only ever *skipped* is not refused: a junk file publishes no
+ documents, and the stale junk-catalog sweep removes its one catalog row, so
+ nothing is stranded.
+- **Files added after a plan was frozen are now called out on stderr.** They
+ are still not indexed by a rerun that resumes an existing plan — the plan is
+ a crash-resume boundary, not a folder-sync generation — but the run now
+ lists them, records them as skipped (exit 3, completed-with-junk) and points
+ at `--fresh`, which rebuilds the plan in place and picks them up. Adding or
+ changing files and rerunning keeps working; only removals are refused.
+- **`xerj brain` no longer turns an absent or zero node-count probe into an
+ automatic reset.** Journal/server disagreement now fails with the journal,
+ URL, prefix, and brain identity plus recovery instructions, including the
+ explicit `--fresh` rerun for a genuinely wiped data directory. Probe
+ transport and malformed-response failures remain errors instead of being
+ reported as an empty destination. A nodes index that was deleted out from
+ under a surviving brain meta doc reads as absence and reaches that recovery
+ text, rather than surfacing as a raw HTTP 404.
+- **`--fresh` still recovers a state directory whose journal cannot be
+ parsed.** The rerun gate reads the durable plan before the run starts, and a
+ plan that is malformed, or recorded for a different root/URL/prefix, is fatal
+ to a resume — but not to `--fresh`, which deletes that journal unread. The
+ preflight is now no more fatal than the open it precedes: under `--fresh` the
+ unreadable plan is reported on stderr and rebuilt from the current folder.
+ Without `--fresh` the refusal is unchanged. Because the removal gate has no
+ comparison basis in that case, the warning says so: documents already
+ published for files that are now gone cannot be identified from an unreadable
+ plan and are not deleted.
+- **Refusal and skip listings are capped at ten entries plus an "and N more"
+ tail.** Unmounting a bind mount under an indexed root vanishes every content
+ group at once, so the uncapped listing was one rendered entry per journalled
+ file. `--json` still carries every entry.
+
+
## [1.0.0-rc.14] - 2026-08-10
### Changed
@@ -529,53 +579,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
`/v1/embedding/identity` reports `lexical` — the backend the server will
really use — rather than `proxy`.
-### Changed — autoindex refuses reruns that would strand documents
-
-- **Deleting an indexed file and rerunning `xerj autoindex` now fails instead
- of exiting 0.** Nothing in the pipeline removes the documents, aliases,
- graph edges or catalog entries that the deleted file published, so a rerun
- that ignored the deletion left them live and searchable with no source file
- behind them. The rerun is now refused before any remote call other than the
- endpoint-readiness ping: no mapping, delete-by-query, bulk, refresh, graph
- or catalog write is attempted, and the journal is not appended to. The error
- names every removed file and its content key and gives three recovery
- routes — restore the files and rerun, rebuild in place by deleting the named
- indices and the state directory, or rebuild under a new state directory,
- prefix and brain. `--fresh` is refused for the same case, because it does
- not delete those documents either. `--json` emits the same facts as
- `xerj.autoindex.unsupported_sync_delta.v1` on stdout with exit 1. Deleting a
- file that was only ever *skipped* is not refused: a junk file publishes no
- documents, and the stale junk-catalog sweep removes its one catalog row, so
- nothing is stranded.
-- **Files added after a plan was frozen are now called out on stderr.** They
- are still not indexed by a rerun that resumes an existing plan — the plan is
- a crash-resume boundary, not a folder-sync generation — but the run now
- lists them, records them as skipped (exit 3, completed-with-junk) and points
- at `--fresh`, which rebuilds the plan in place and picks them up. Adding or
- changing files and rerunning keeps working; only removals are refused.
-- **`xerj brain` no longer turns an absent or zero node-count probe into an
- automatic reset.** Journal/server disagreement now fails with the journal,
- URL, prefix, and brain identity plus recovery instructions, including the
- explicit `--fresh` rerun for a genuinely wiped data directory. Probe
- transport and malformed-response failures remain errors instead of being
- reported as an empty destination. A nodes index that was deleted out from
- under a surviving brain meta doc reads as absence and reaches that recovery
- text, rather than surfacing as a raw HTTP 404.
-- **`--fresh` still recovers a state directory whose journal cannot be
- parsed.** The rerun gate reads the durable plan before the run starts, and a
- plan that is malformed, or recorded for a different root/URL/prefix, is fatal
- to a resume — but not to `--fresh`, which deletes that journal unread. The
- preflight is now no more fatal than the open it precedes: under `--fresh` the
- unreadable plan is reported on stderr and rebuilt from the current folder.
- Without `--fresh` the refusal is unchanged. Because the removal gate has no
- comparison basis in that case, the warning says so: documents already
- published for files that are now gone cannot be identified from an unreadable
- plan and are not deleted.
-- **Refusal and skip listings are capped at ten entries plus an "and N more"
- tail.** Unmounting a bind mount under an indexed root vanishes every content
- group at once, so the uncapped listing was one rendered entry per journalled
- file. `--json` still carries every entry.
-
## [1.0.0-rc.10] - 2026-08-03
### Security
@@ -652,6 +655,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
caveats. They are tracked for the following release rather than rushed into
this one.
+
### Changed — runtime-field types (can break existing mappings)
- **`mappings.runtime` is now validated against ES's runtime-field type
diff --git a/engine/crates/xerj-autoindex/src/failure_resume_http_tests.rs b/engine/crates/xerj-autoindex/src/failure_resume_http_tests.rs
index 62082ab0a..6cc7a4f29 100644
--- a/engine/crates/xerj-autoindex/src/failure_resume_http_tests.rs
+++ b/engine/crates/xerj-autoindex/src/failure_resume_http_tests.rs
@@ -1119,11 +1119,20 @@ fn deleted_path_bytes_remain_while_its_documents_remain_live() {
assert_eq!(endpoint.state.lock().unwrap().docs.len(), 4);
fs::remove_file(&removed).unwrap();
- // Current autoindex semantics do not reconcile a missing canonical path:
- // its indexed documents and FileDone remain live. Dataset bytes must
- // describe that durable live index rather than silently pretend deletion.
+ // Autoindex still does not reconcile a missing canonical path: its indexed
+ // documents and FileDone stay live, so dataset bytes must keep describing
+ // that durable live index rather than silently pretend deletion (#249).
+ // What changed is the exit: the rerun that used to return 0 while leaving
+ // those documents stranded now refuses before any remote mutation. Run
+ // twice — a refusal is a stop, not a state change, so the second attempt
+ // must see exactly what the first one saw.
for _ in 0..2 {
- assert_eq!(run_index(config.clone()).unwrap(), 0);
+ assert_unsupported_delta_without_remote_mutation(
+ &endpoint,
+ config.clone(),
+ &[],
+ &["removed.csv"],
+ );
assert_eq!(endpoint.state.lock().unwrap().docs.len(), 4);
assert_eq!(
dataset_catalog_docs(&endpoint)[0]["bytes"],
diff --git a/engine/crates/xerj-autoindex/src/lib.rs b/engine/crates/xerj-autoindex/src/lib.rs
index e2a8e3c34..4563c6ada 100644
--- a/engine/crates/xerj-autoindex/src/lib.rs
+++ b/engine/crates/xerj-autoindex/src/lib.rs
@@ -2074,25 +2074,28 @@ pub fn run_index_report(cfg: IndexCfg) -> Result<(i32, Option<Value>)> {
});
}
}
- if !new_unplanned.is_empty() && !cfg.quiet {
+ if !new_unplanned.is_empty() {
// The frozen plan cannot absorb files discovered after it was written.
// Say so on stderr rather than leaving it to the catalog: a rerun that
// quietly ignores new files is the bug this gate exists to surface.
- eprintln!(
+ // Routed through the progress surface, which owns stderr (#241): a raw
+ // eprintln! here would break `--progress json`'s single parseable
+ // stream, and `--quiet` already selects `--progress none`.
+ pr.note(&format!(
"autoindex: {} file(s) appeared after the resume plan was frozen and were NOT \
indexed:",
new_unplanned.len()
- );
+ ));
for jf in new_unplanned.iter().take(REFUSAL_LIST_CAP) {
- eprintln!(" not in plan, skipped: {}", jf.rel);
+ pr.note(&format!(" not in plan, skipped: {}", jf.rel));
}
let remaining = new_unplanned.len().saturating_sub(REFUSAL_LIST_CAP);
if remaining > 0 {
- eprintln!(" … and {remaining} more");
+ pr.note(&format!(" … and {remaining} more"));
}
- eprintln!(
+ pr.note(
"autoindex: re-run with --fresh to rebuild the plan in place and index them (ids \
- stay idempotent)"
+ stay idempotent)",
);
}
if resumed_with_plan {