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): name junk files in the map headline (#1668)

xerj-orgc9480127034c
diff --git a/engine/crates/xerj-autoindex/src/catalog.rs b/engine/crates/xerj-autoindex/src/catalog.rs
index 69f629999..f5ae7e181 100644
--- a/engine/crates/xerj-autoindex/src/catalog.rs
+++ b/engine/crates/xerj-autoindex/src/catalog.rs
@@ -697,15 +697,29 @@ pub fn render_map_page(
} else {
format!(", wall {wall}s")
};
+ // `junk_records_total` is records that failed extraction. A run can
+ // list junk *files* (css, fonts, encrypted PDFs, "no records
+ // extracted") while that counter stays 0. The headline has to name
+ // the files the section below lists, and stay byte-identical when
+ // the list is empty.
+ let junk_records = g("junk_records_total");
+ let junk_clause = if junk_files.is_empty() {
+ format!("{junk_records} junk records")
+ } else {
+ format!(
+ "{junk_records} junk records, {} junk/skipped files",
+ junk_files.len()
+ )
+ };
s.push_str(&format!(
- "run `{}` — root `{}` — {} paths ({} unique content, {} duplicate aliases), {} records indexed, {} junk records{}\n\n",
+ "run `{}` — root `{}` — {} paths ({} unique content, {} duplicate aliases), {} records indexed, {}{}\n\n",
g("run_id"),
g("root"),
g("files_total"),
g("unique_content_files"),
g("duplicate_files"),
g("records_total"),
- g("junk_records_total"),
+ junk_clause,
wall_clause,
));
}
@@ -1106,6 +1120,33 @@ mod duplicate_tests {
);
}
+ /// The summary used to say "0 junk records" on a map whose later section
+ /// listed 17 skipped files. The file count belongs in the headline when
+ /// the list is non-empty, and only then.
+ #[test]
+ fn the_summary_names_junk_files_when_the_list_is_nonempty() {
+ let run = json!({
+ "doc_kind": "run",
+ "run_id": "nb",
+ "root": "/corpus",
+ "files_total": 36,
+ "unique_content_files": 36,
+ "duplicate_files": 0,
+ "records_total": 286,
+ "junk_records_total": 0
+ });
+ let junk = vec![
+ json!({"path": "style.css", "status": "skipped", "reason": "no records extracted"}),
+ json!({"path": "font.woff", "status": "skipped", "reason": "no records extracted"}),
+ ];
+ let rendered = render_map(Some(&run), &[], &[], &junk, &[], junk.len() as u64);
+ assert!(
+ rendered.contains("286 records indexed, 0 junk records, 2 junk/skipped files\n\n"),
+ "{rendered}"
+ );
+ assert!(rendered.contains("## Junk / skipped (2 files recorded"));
+ }
+
#[test]
fn prefix_scoping_disambiguates_hyphenated_prefixes_across_catalog_doc_kinds() {
let tantivy_ds = json!({