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): skip the work-order rule when nothing is pending (#1715)

xerj-orgf63a26492b6b
diff --git a/engine/crates/xerj-autoindex/src/lib.rs b/engine/crates/xerj-autoindex/src/lib.rs
index fc80d7deb..d1ba82bc5 100644
--- a/engine/crates/xerj-autoindex/src/lib.rs
+++ b/engine/crates/xerj-autoindex/src/lib.rs
@@ -7098,26 +7098,7 @@ fn run_index_report_inner(
for exclude in &run_estimate.excludes {
pr.note(&format!(" estimate excludes: {exclude}"));
}
- pr.note(&format!(
- "work order: {} — {} inside each band at {} worker(s); a file that outlasts everything \
- above it starts first regardless of band",
- bands
- .iter()
- .map(|band| format!(
- "{} ({} files, {})",
- band.band,
- band.files,
- estimate::human_bytes(band.bytes)
- ))
- .collect::<Vec<_>>()
- .join(" → "),
- if cfg.workers == 1 {
- "smallest first"
- } else {
- "biggest first"
- },
- cfg.workers,
- ));
+ pr.note(&order::work_order_line(&bands, cfg.workers));
for band in &bands {
pr.note(&format!(" {:<16} {}", band.band, band.why));
}
diff --git a/engine/crates/xerj-autoindex/src/order.rs b/engine/crates/xerj-autoindex/src/order.rs
index dac58ab90..4ae3ff6f5 100644
--- a/engine/crates/xerj-autoindex/src/order.rs
+++ b/engine/crates/xerj-autoindex/src/order.rs
@@ -315,6 +315,38 @@ pub struct BandSummary {
pub bytes: u64,
}
+/// The `work order:` plan line.
+///
+/// An empty queue is a no-op resume: every file is already in the journal.
+/// The old line was `work order: — biggest first ...`, which names a
+/// scheduling rule for work that does not exist.
+pub fn work_order_line(bands: &[BandSummary], workers: usize) -> String {
+ if bands.is_empty() {
+ return "work order: nothing to index".to_string();
+ }
+ let inside = if workers == 1 {
+ "smallest first"
+ } else {
+ "biggest first"
+ };
+ let listed = bands
+ .iter()
+ .map(|band| {
+ format!(
+ "{} ({} files, {})",
+ band.band,
+ band.files,
+ crate::estimate::human_bytes(band.bytes)
+ )
+ })
+ .collect::<Vec<_>>()
+ .join(" → ");
+ format!(
+ "work order: {listed} — {inside} inside each band at {workers} worker(s); a file that \
+ outlasts everything above it starts first regardless of band"
+ )
+}
+
pub fn summarize(items: &[Item]) -> Vec<BandSummary> {
Band::ALL
.iter()
@@ -343,6 +375,36 @@ mod tests {
Item { index, band, bytes }
}
+ /// A no-op resume has no pending files. The plan line used to be
+ /// `work order: — biggest first inside each band ...`.
+ #[test]
+ fn empty_work_order_does_not_announce_a_scheduling_rule() {
+ let line = work_order_line(&[], 4);
+ assert_eq!(line, "work order: nothing to index");
+ assert!(!line.contains("biggest first"), "{line}");
+ assert_eq!(
+ work_order_line(&[], 1),
+ "work order: nothing to index",
+ "one worker is still nothing to index"
+ );
+
+ let bands = [BandSummary {
+ band: "config",
+ why: Band::Config.why(),
+ files: 31,
+ bytes: 1021,
+ }];
+ let line = work_order_line(&bands, 4);
+ assert_eq!(
+ line,
+ "work order: config (31 files, 1021 B) — biggest first inside each band at 4 \
+ worker(s); a file that outlasts everything above it starts first regardless of band"
+ );
+ let single = work_order_line(&bands, 1);
+ assert!(single.contains("smallest first"), "{single}");
+ assert!(single.contains("config (31 files, 1021 B)"), "{single}");
+ }
+
#[test]
fn source_and_docs_drain_before_vendored_whatever_the_size() {
// The pre-#242 rule was size alone, so the 100 MB vendored blob went