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): say how long a stalled phase has been stuck (#1653)

xerj-orgcd7228f350c3
diff --git a/engine/crates/xerj-autoindex/src/progress.rs b/engine/crates/xerj-autoindex/src/progress.rs
index ae77fb6ce..33fb119b0 100644
--- a/engine/crates/xerj-autoindex/src/progress.rs
+++ b/engine/crates/xerj-autoindex/src/progress.rs
@@ -1211,16 +1211,21 @@ fn bar(percent: Option<f64>, cells: usize) -> String {
}
}
-/// `eta 2m10s`, `eta ~2m10s (rough)`, `eta unknown`, `eta unknown (stalled)`.
+/// `eta 2m10s`, `eta ~2m10s (rough)`, `eta unknown`,
+/// `eta unknown (stalled, no progress for 1m40s)`.
/// The word never disappears: a missing ETA field would read as a rendering
/// fault, while `unknown` is the honest answer and is what the machine line
-/// says too.
-fn display_eta(eta: Eta) -> String {
+/// says too. A stall also says how long, because the machine line's
+/// `since_progress_s` is not on the `xerj-bar` line an agent relays verbatim.
+fn display_eta(eta: Eta, since_progress: f64) -> String {
match eta {
Eta::Good(seconds) => format!("eta {}", fmt_secs(seconds)),
Eta::Rough(seconds) => format!("eta ~{} (rough)", fmt_secs(seconds)),
Eta::Unknown => "eta unknown".to_string(),
- Eta::Stalled => "eta unknown (stalled)".to_string(),
+ Eta::Stalled => format!(
+ "eta unknown (stalled, no progress for {})",
+ fmt_secs(since_progress)
+ ),
}
}
@@ -1269,7 +1274,10 @@ fn render_bar_line(snapshot: &Snapshot, cells: usize) -> String {
Basis::None => {}
}
}
- line.push_str(&format!(" | {}", display_eta(snapshot.eta)));
+ line.push_str(&format!(
+ " | {}",
+ display_eta(snapshot.eta, snapshot.since_progress)
+ ));
if snapshot.waiting_on.len() == 1 {
line.push_str(&format!(
" | waiting on {}",
@@ -1316,10 +1324,10 @@ fn render_tty(snapshot: &Snapshot) -> String {
Basis::None => {}
}
}
- match snapshot.eta.seconds() {
- Some(seconds) => line.push_str(&format!("| eta {}", fmt_secs(seconds))),
- None => line.push_str("| eta unknown"),
- }
+ line.push_str(&format!(
+ "| {}",
+ display_eta(snapshot.eta, snapshot.since_progress)
+ ));
if snapshot.waiting_on.len() == 1 {
line.push_str(&format!(
" | waiting on {}",
@@ -2238,13 +2246,21 @@ mod tests {
state.last_sample_units = 10_248_432;
state.rate = Some(2_545_880.0);
state.shown_eta = Some(10.3);
+ // The opening bar went out at phase start, before this stall.
+ // Age it past the display interval so the tick owes a new one.
+ state.last_bar_at = Some(Instant::now() - Duration::from_secs(20));
}
progress.tick();
- let line = captured(&buffer).lines().last().unwrap().to_string();
+ let text = captured(&buffer);
+ let line = text.lines().last().unwrap().to_string();
assert!(
line.contains("eta_s=unknown") && line.contains("eta_quality=stalled"),
"no completion in 100s is an absence of measurement, not a slow rate: {line}"
);
+ assert!(
+ text.contains("no progress for 1m40s"),
+ "the relayed bar must say how long the phase has been stuck: {text}"
+ );
assert!(line.contains("since_progress_s=100."), "{line}");
assert!(
line.contains("waiting_on=bench/hdfs.jsonl(19.9MB)"),