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.
Rust agent-memoryai-agentsbm25claude-codeclicode-searchcursordatabaseelasticsearchfull-text-searchhybrid-searchjsonllocal-firstmcpmcp-servermodel-context-protocolragrustsearch-enginevector-search
fix(api): make the failed-index recovery path real on the ES-compat port (#202)
xerj-org084f24084796
diff --git a/engine/crates/xerj-api/src/es_compat.rs b/engine/crates/xerj-api/src/es_compat.rsindex 91c93f51d..0b8e3b724 100644--- a/engine/crates/xerj-api/src/es_compat.rs+++ b/engine/crates/xerj-api/src/es_compat.rs@@ -248,6 +248,25 @@ async fn cluster_health_inner(selected};+ // Indices that failed to open (issue #202) are absent from `list_indices`,+ // so the selector above cannot see them — yet they are exactly why+ // `Engine::health` answers red. Reporting green here while the engine says+ // red would leave the corruption invisible on the one endpoint every ES+ // client, Kibana and monitoring dashboard polls. Resolve them against the+ // same selector so `/_cluster/health/{other_index}` is not dragged red by+ // an unrelated failure.+ let failed_selected: Vec<String> = state+ .engine+ .failed_index_names()+ .into_iter()+ .filter(|name| match &index_filter {+ None => true,+ Some(sel) => sel.split(',').map(str::trim).any(|s| {+ s == "_all" || s == "*" || s == name.as_str() || glob_match_simple(s, name)+ }),+ })+ .collect();+// Per-index shard count helper — defaults to 1 when unset.let shard_count = |name: &str| -> u32 {state@@ -319,7 +338,15 @@ async fn cluster_health_inner(// keep the *cluster* status driven by replicas only. Our tests cover// both — we currently only track a single "closed" flag per index and// don't differentiate the closed-replication mode.- let status = if unassigned_replicas > 0 {+ // An index that failed to open has an unassigned primary — there is no+ // copy of its data being served anywhere — which is red in ES's own+ // vocabulary and red in `Engine::health`. It dominates the replica-driven+ // yellow. When nothing failed, `failed_selected` is empty and every number+ // below is byte-identical to before.+ let failed_primaries: u32 = failed_selected.iter().map(|n| shard_count(n)).sum();+ let status = if !failed_selected.is_empty() {+ "red"+ } else if unassigned_replicas > 0 {"yellow"} else {"green"@@ -412,13 +439,13 @@ async fn cluster_health_inner("active_shards": active,"relocating_shards": 0,"initializing_shards": 0,- "unassigned_shards": unassigned_replicas,- "unassigned_primary_shards": 0,+ "unassigned_shards": unassigned_replicas + failed_primaries,+ "unassigned_primary_shards": failed_primaries,"delayed_unassigned_shards": 0,"number_of_pending_tasks": 0,"number_of_in_flight_fetch": 0,"task_max_waiting_in_queue_millis": 0,- "active_shards_percent_as_number": if idx_count == 0 { 100.0 } else { (active as f64) / (idx_count as f64) * 100.0 },+ "active_shards_percent_as_number": if idx_count + failed_primaries == 0 { 100.0 } else { (active as f64) / ((idx_count + failed_primaries) as f64) * 100.0 },});// `level=indices` or `level=shards` — include a per-index breakdown.@@ -475,6 +502,37 @@ async fn cluster_health_inner(}indices_map.insert(info.name.clone(), idx_obj);}+ // …and the ones that never opened, so `level=indices` names the index+ // the operator has to repair instead of leaving a red cluster with no+ // red index in it.+ for name in &failed_selected {+ let shards = shard_count(name);+ let mut idx_obj = json!({+ "status": "red",+ "number_of_shards": shards,+ "number_of_replicas": 0,+ "active_primary_shards": 0,+ "active_shards": 0,+ "relocating_shards": 0,+ "initializing_shards": 0,+ "unassigned_shards": shards,+ "unassigned_primary_shards": shards,+ });+ if level == "shards" {+ idx_obj["shards"] = json!({+ "0": {+ "status": "red",+ "primary_active": false,+ "active_shards": 0,+ "relocating_shards": 0,+ "initializing_shards": 0,+ "unassigned_shards": shards,+ "unassigned_primary_shards": shards,+ }+ });+ }+ indices_map.insert(name.clone(), idx_obj);+ }resp["indices"] = Value::Object(indices_map);}@@ -1334,7 +1392,20 @@ pub async fn delete_index(.unwrap_or(true);let all = state.engine.list_indices().await;- let all_names: Vec<String> = all.iter().map(|i| i.name.clone()).collect();+ let mut all_names: Vec<String> = all.iter().map(|i| i.name.clone()).collect();+ // An index that failed to open (issue #202) is not in `indices` and so+ // never appears in `list_indices`. Both branches below — the literal name+ // and the `_all`/wildcard expansion — resolve out of `all_names`, so+ // without this union `DELETE /{index}` answered 404 with the directory+ // still on disk and `DELETE /_all` answered a bare+ // `{"acknowledged": true}` while the corrupt index survived. Delete is the+ // documented recovery path; it has to reach `Engine::delete_index`, which+ // has the branch that removes a failed index's directory.+ for name in state.engine.failed_index_names() {+ if !all_names.contains(&name) {+ all_names.push(name);+ }+ }let mut to_delete: Vec<String> = Vec::new();let parts: Vec<&str> = index@@ -1395,12 +1466,26 @@ pub async fn delete_index(}}+ // A delete that did not happen must never answer `{"acknowledged": true}`+ // (the accepted-and-ignored class tracked in #204). The loop used to+ // discard every error with `let _ =`; the case that makes it matter is a+ // failed index whose directory cannot be removed — `delete_index` puts the+ // failure back so health stays red, and the operator needs to be told why.+ let mut first_error: Option<xerj_common::XerjError> = None;for name in &to_delete {- let _ = state.engine.delete_index(name).await;+ if let Err(e) = state.engine.delete_index(name).await {+ tracing::error!(index = %name, error = %e, "delete index failed");+ if first_error.is_none() {+ first_error = Some(e.into());+ }+ }// RC4-W4 item 5: drop the index's per-index metric label series so it// doesn't linger for the process lifetime after the index is gone.state.metrics.prune_index_labels(name);}+ if let Some(e) = first_error {+ return ApiError::new(e).into_response();+ }Json(EsDeleteIndexResponse::ok()).into_response()}diff --git a/engine/crates/xerj-api/src/native.rs b/engine/crates/xerj-api/src/native.rsindex 824dc13b3..059422c65 100644--- a/engine/crates/xerj-api/src/native.rs+++ b/engine/crates/xerj-api/src/native.rs@@ -708,12 +708,24 @@ pub async fn embedding_execution_identity(State(state): State<AppState>) -> impl// be a no-op — checking the engine here would create a feedback loop// where a slow engine flapping flush causes constant pod restarts.//-// - **readiness**: returns 200 only when the engine reports a non-`red`-// cluster status (i.e. at least one index is queryable). kubelet uses-// this to decide whether to send traffic. Until ready, the Service-// removes the pod from rotation but doesn't restart it — appropriate-// for "still replaying WAL" or "still loading 50 K segments" startup-// states that are transient but visible.+// - **readiness**: returns 200 while this node can serve *something*.+// kubelet uses this to decide whether to send traffic. Until ready, the+// Service removes the pod from rotation but doesn't restart it —+// appropriate for "still replaying WAL" or "still loading 50 K segments"+// startup states that are transient but visible.+//+// Readiness is a traffic gate, not an alarm channel, and the two must not+// be conflated. Since issue #202 `Engine::health` is red whenever *any*+// index failed to open, and that condition is not transient: one+// unparseable `schema.json` out of a hundred indices would take the pod out+// of rotation permanently while the other ninety-nine still answer+// perfectly — turning one broken index into a full-node outage, and+// (because `xerj brain` gates on this probe, `xerj-server/src/brain.rs:215`)+// breaking tooling that has nothing to do with the corrupt index. So the+// probe fails only when the node genuinely has nothing to serve: red with+// no index open. The alarm for a partial failure is+// `GET /_cluster/health` → `red`, which names the index, and the write path,+// which refuses by name.// ─────────────────────────────────────────────────────────────────────────────pub async fn liveness() -> impl IntoResponse {@@ -722,10 +734,13 @@ pub async fn liveness() -> impl IntoResponse {pub async fn readiness(State(state): State<AppState>) -> impl IntoResponse {let h = state.engine.health().await;- if h.status == "red" {+ // `index_count` is the number of indices that actually opened, so+ // `red && index_count == 0` is exactly "every index on this node failed"+ // (or "the only index there is failed"). Anything else can still serve.+ if h.status == "red" && h.index_count == 0 {(axum::http::StatusCode::SERVICE_UNAVAILABLE,- format!("not ready: cluster status = {}", h.status),+ "not ready: cluster status = red and no index is serving".to_string(),).into_response()} else {diff --git a/engine/crates/xerj-api/tests/corrupt_index_http.rs b/engine/crates/xerj-api/tests/corrupt_index_http.rsnew file mode 100644index 000000000..4608c0cd8--- /dev/null+++ b/engine/crates/xerj-api/tests/corrupt_index_http.rs@@ -0,0 +1,410 @@+//! Issue #202, from the outside — the recovery story for a failed index has to+//! exist on the surface operators actually use.+//!+//! Refusing to open an index whose metadata is unparseable is only useful if+//! the ES-compat API (`:9200`, the port every ES client, Kibana and monitoring+//! dashboard talks to) then tells the truth about it and offers a way out. The+//! engine-level tests in `xerj-engine/tests/corrupt_index_metadata.rs` call+//! `engine.delete_index` / `engine.health()` directly and therefore cannot see+//! the HTTP layer at all. Measured over `build_es_compat_router` with one torn+//! `schema.json`, that layer was wrong in three ways:+//!+//! 1. `DELETE /{index}` answered `404 index_not_found_exception` and left the+//! directory on disk — the handler resolves names from+//! `engine.list_indices()`, which iterates `indices` only, so a failed index+//! never reaches `engine.delete_index`. Combined with the create gate the+//! name was unopenable, uncreatable *and* undeletable on `:9200`.+//! 2. `DELETE /_all` answered `200 {"acknowledged": true}` while the corrupt+//! index survived — the wildcard branch expands over the same list.+//! 3. `GET /_cluster/health` answered `status: "green"` while+//! `engine.health()` answered `"red"`, because it too is built from+//! `list_indices()`.+//!+//! And one consequence that had to be decided rather than inherited: readiness+//! was `engine.health() == "red"`, which after #202 means "any index failed",+//! so a single unparseable sidecar would have taken the whole node out of+//! kubelet rotation permanently while its other indices kept serving. Readiness+//! is a traffic gate, not an alarm channel, so it is now scoped to "this node+//! has nothing to serve". Both halves of that are pinned below.++use axum::body::Body;+use axum::http::{Request, StatusCode};+use serde_json::{json, Value};+use tower::ServiceExt;+use xerj_common::types::{FieldConfig, FieldType, Schema};++fn config_for(dir: &tempfile::TempDir) -> xerj_common::config::Config {+ let mut config = xerj_common::config::Config::default();+ config.server.data_dir = dir.path().to_string_lossy().into_owned();+ config.storage.wal_sync = xerj_common::config::WalSync::Async;+ config+}++fn mapped_schema() -> Schema {+ let mut schema = Schema::empty();+ schema+ .add_field(FieldConfig::new("code", FieldType::Keyword))+ .unwrap();+ schema+}++/// Boot a node over `dir`, create `names` with an explicit mapping and one+/// flushed document each, then drop the engine so every file is closed.+async fn seed_indices(dir: &tempfile::TempDir, names: &[&str]) {+ let engine = xerj_engine::Engine::new(config_for(dir)).expect("engine");+ for name in names {+ engine+ .create_index(name, mapped_schema())+ .expect("create_index");+ let idx = engine.get_index(name).expect("get_index");+ idx.index_document(Some("d1".into()), json!({ "code": "A-1" }))+ .await+ .expect("index_document");+ idx.flush().await.expect("flush");+ }+ drop(engine);+}++/// Truncate `schema.json` to half its bytes — the torn write this PR refuses.+fn tear_schema(dir: &tempfile::TempDir, name: &str) {+ let path = dir.path().join(name).join("schema.json");+ let good = std::fs::read(&path).expect("read schema.json");+ std::fs::write(&path, &good[..good.len() / 2]).expect("write torn schema.json");+}++/// A node booted over a data dir that already contains a corrupt index.+async fn app_over(dir: &tempfile::TempDir) -> axum::Router {+ let config = config_for(dir);+ let metrics = xerj_common::metrics::Metrics::new().expect("metrics");+ let engine = xerj_engine::Engine::new(config.clone()).expect("engine");+ let state = xerj_api::state::AppState::new(config, engine, metrics);+ xerj_api::router::build_es_compat_router(state)+}++async fn send(app: &axum::Router, req: Request<Body>) -> (StatusCode, Value) {+ let response = app.clone().oneshot(req).await.expect("response");+ let status = response.status();+ let bytes = axum::body::to_bytes(response.into_body(), usize::MAX)+ .await+ .expect("body");+ let value: Value = serde_json::from_slice(&bytes).unwrap_or(Value::Null);+ (status, value)+}++async fn get(app: &axum::Router, path: &str) -> (StatusCode, Value) {+ send(+ app,+ Request::get(path).body(Body::empty()).expect("request"),+ )+ .await+}++async fn delete(app: &axum::Router, path: &str) -> (StatusCode, Value) {+ send(+ app,+ Request::delete(path).body(Body::empty()).expect("request"),+ )+ .await+}++// ── must-fix 1: DELETE /{index} is the documented escape hatch ────────────────++/// The PR body's recovery story ("restore the file, restore from snapshot, or+/// DELETE the index") has to hold on the ES-compat port. Pre-fix this answered+/// 404 and left the directory on disk.+#[tokio::test]+async fn delete_removes_a_failed_index_over_the_es_api() {+ let dir = tempfile::tempdir().unwrap();+ seed_indices(&dir, &["victim"]).await;+ tear_schema(&dir, "victim");++ let app = app_over(&dir).await;+ let (status, body) = delete(&app, "/victim").await;+ assert_eq!(+ status,+ StatusCode::OK,+ "DELETE on a failed index must succeed on :9200, got {status} {body}"+ );+ assert_eq!(body["acknowledged"], json!(true));+ assert!(+ !dir.path().join("victim").exists(),+ "the acknowledgement must mean the directory is gone"+ );++ // The name is usable again — that is the whole point of the escape hatch.+ let (status, body) = send(+ &app,+ Request::put("/victim")+ .header("content-type", "application/json")+ .body(Body::from(json!({}).to_string()))+ .unwrap(),+ )+ .await;+ assert!(+ status.is_success(),+ "the name must be re-creatable after the delete, got {status} {body}"+ );+}++/// Deleting the failed index must clear the failure, not just the directory:+/// health has to come back.+#[tokio::test]+async fn health_recovers_after_the_failed_index_is_deleted() {+ let dir = tempfile::tempdir().unwrap();+ seed_indices(&dir, &["victim", "healthy"]).await;+ tear_schema(&dir, "victim");++ let app = app_over(&dir).await;+ assert_eq!(+ get(&app, "/_cluster/health").await.1["status"],+ json!("red")+ );+ assert_eq!(delete(&app, "/victim").await.0, StatusCode::OK);++ let (status, body) = get(&app, "/_cluster/health").await;+ assert_eq!(status, StatusCode::OK);+ assert_ne!(+ body["status"],+ json!("red"),+ "health must leave red once the corrupt index is gone, got {body}"+ );+ // The healthy index is untouched by the recovery.+ assert!(dir.path().join("healthy").exists());+}++// ── must-fix 2: DELETE /_all must not acknowledge a no-op ─────────────────────++/// `DELETE /_all` expanded only over `list_indices()`, so it answered+/// `200 {"acknowledged": true}` with the corrupt index still on disk — the+/// accepted-and-ignored class tracked in #204.+#[tokio::test]+async fn delete_all_actually_removes_a_failed_index() {+ let dir = tempfile::tempdir().unwrap();+ seed_indices(&dir, &["victim", "healthy"]).await;+ tear_schema(&dir, "victim");++ let app = app_over(&dir).await;+ let (status, body) = delete(&app, "/_all").await;+ assert_eq!(status, StatusCode::OK, "got {status} {body}");+ assert!(+ !dir.path().join("victim").exists(),+ "DELETE /_all acknowledged while the failed index survived on disk: {body}"+ );+ assert!(+ !dir.path().join("healthy").exists(),+ "DELETE /_all must still delete the healthy indices too"+ );+}++/// A wildcard that matches the failed index resolves it as well.+#[tokio::test]+async fn delete_wildcard_resolves_a_failed_index() {+ let dir = tempfile::tempdir().unwrap();+ seed_indices(&dir, &["vic-1", "healthy"]).await;+ tear_schema(&dir, "vic-1");++ let app = app_over(&dir).await;+ let (status, body) = delete(&app, "/vic-*").await;+ assert_eq!(status, StatusCode::OK, "got {status} {body}");+ assert!(+ !dir.path().join("vic-1").exists(),+ "a wildcard delete must reach the failed index: {body}"+ );+ assert!(+ dir.path().join("healthy").exists(),+ "and must not touch anything it did not match"+ );+}++// ── must-fix 3: GET /_cluster/health is the surface monitoring polls ──────────++/// The PR's headline claim is "the operator sees red". `engine.health()` said+/// red; `GET /_cluster/health` — what every ES client and dashboard actually+/// polls — said green, because it is built from `list_indices()`.+#[tokio::test]+async fn cluster_health_reports_red_for_a_failed_index() {+ let dir = tempfile::tempdir().unwrap();+ seed_indices(&dir, &["victim", "healthy"]).await;+ tear_schema(&dir, "victim");++ let app = app_over(&dir).await;+ let (status, body) = get(&app, "/_cluster/health").await;+ assert_eq!(status, StatusCode::OK);+ assert_eq!(+ body["status"],+ json!("red"),+ "GET /_cluster/health must agree with engine.health(), got {body}"+ );+ // A red status with 100% active shards and no unassigned primary is an+ // internally inconsistent answer that a dashboard cannot act on.+ assert_eq!(+ body["unassigned_primary_shards"],+ json!(1),+ "the failed index's primary must count as unassigned, got {body}"+ );+ assert!(+ body["active_shards_percent_as_number"].as_f64().unwrap() < 100.0,+ "active_shards_percent must reflect the unserved shard, got {body}"+ );++ // `level=indices` has to name the index the operator must repair.+ let (_, body) = get(&app, "/_cluster/health?level=indices").await;+ assert_eq!(+ body["indices"]["victim"]["status"],+ json!("red"),+ "level=indices must name the failed index, got {body}"+ );+ assert_eq!(body["indices"]["healthy"]["status"], json!("green"));+}++/// An intact node is unaffected — the red must come from the failure, not from+/// the code that reports it.+#[tokio::test]+async fn cluster_health_is_not_red_without_a_failed_index() {+ let dir = tempfile::tempdir().unwrap();+ seed_indices(&dir, &["healthy"]).await;++ let app = app_over(&dir).await;+ let (status, body) = get(&app, "/_cluster/health").await;+ assert_eq!(status, StatusCode::OK);+ assert_ne!(+ body["status"],+ json!("red"),+ "a node with no failed index must not report red, got {body}"+ );+}++/// A per-index health call for a *healthy* index must not inherit another+/// index's failure — red is scoped to the selector.+#[tokio::test]+async fn per_index_health_is_scoped_to_the_selector() {+ let dir = tempfile::tempdir().unwrap();+ seed_indices(&dir, &["victim", "healthy"]).await;+ tear_schema(&dir, "victim");++ let app = app_over(&dir).await;+ let (_, body) = get(&app, "/_cluster/health/healthy").await;+ assert_ne!(+ body["status"],+ json!("red"),+ "GET /_cluster/health/healthy must report on `healthy` alone, got {body}"+ );+ let (_, body) = get(&app, "/_cluster/health/victim").await;+ assert_eq!(+ body["status"],+ json!("red"),+ "GET /_cluster/health/victim must be red, got {body}"+ );+}++// ── must-fix 4: readiness is a traffic gate, not an alarm channel ────────────++/// `native::readiness` is mounted on BOTH routers (`router.rs:113` and+/// `router.rs:225`) and used to be `health() == "red"`. After #202 red means+/// "any index failed", which is permanent — so one unparseable sidecar out of+/// N indices would have removed the pod from kubelet rotation for good while+/// the other N-1 answered perfectly, and would have bricked `xerj brain`, which+/// gates on this probe. A node that is still serving must stay in rotation; the+/// alarm belongs on `_cluster/health`, asserted here alongside it.+#[tokio::test]+async fn a_partially_failed_node_stays_in_rotation_and_keeps_serving() {+ let dir = tempfile::tempdir().unwrap();+ seed_indices(&dir, &["victim", "healthy"]).await;+ tear_schema(&dir, "victim");++ let app = app_over(&dir).await;++ let (status, body) = get(&app, "/health/ready").await;+ assert_eq!(+ status,+ StatusCode::OK,+ "one failed index must not take a still-serving node out of rotation, got {status} {body}"+ );+ let (status, _) = get(&app, "/health/live").await;+ assert_eq!(+ status,+ StatusCode::OK,+ "liveness must stay 200 — a failed index must not restart the pod"+ );+ // The alarm is on cluster health, not on the traffic gate.+ assert_eq!(+ get(&app, "/_cluster/health").await.1["status"],+ json!("red")+ );++ // …and the healthy index really is serving while that is true.+ let (status, body) = send(+ &app,+ Request::post("/healthy/_search")+ .header("content-type", "application/json")+ .body(Body::from(json!({"query": {"match_all": {}}}).to_string()))+ .unwrap(),+ )+ .await;+ assert_eq!(+ status,+ StatusCode::OK,+ "the healthy index must keep serving, got {status} {body}"+ );+}++/// The other half of the chosen semantics: when nothing on the node opened,+/// there is nothing to send traffic to and the probe must say so.+#[tokio::test]+async fn a_node_whose_every_index_failed_reports_not_ready() {+ let dir = tempfile::tempdir().unwrap();+ seed_indices(&dir, &["victim"]).await;+ tear_schema(&dir, "victim");++ let app = app_over(&dir).await;+ let (status, _) = get(&app, "/health/ready").await;+ assert_eq!(+ status,+ StatusCode::SERVICE_UNAVAILABLE,+ "a node with no index serving must be out of rotation"+ );+}++/// And an empty node — no indices at all, none failed — is ready, as it was+/// before this change. (A fresh pod must join the Service.)+#[tokio::test]+async fn an_empty_node_is_ready() {+ let dir = tempfile::tempdir().unwrap();+ let app = app_over(&dir).await;+ assert_eq!(get(&app, "/health/ready").await.0, StatusCode::OK);+}++// ── the create gate, over HTTP ───────────────────────────────────────────────++/// `PUT /{index}` and `_bulk` auto-create used to run `Index::create` over the+/// corrupt directory. They are now refused — and the refusal must name the file+/// and the way out rather than being an opaque 500.+#[tokio::test]+async fn create_over_a_failed_index_is_refused_over_http() {+ let dir = tempfile::tempdir().unwrap();+ seed_indices(&dir, &["victim"]).await;+ tear_schema(&dir, "victim");++ let app = app_over(&dir).await;+ let (status, body) = send(+ &app,+ Request::put("/victim")+ .header("content-type", "application/json")+ .body(Body::from(json!({}).to_string()))+ .unwrap(),+ )+ .await;+ assert!(+ !status.is_success(),+ "creating over a failed index must be refused, got {status} {body}"+ );+ let text = body.to_string();+ assert!(+ text.contains("failed to open") && text.contains("DELETE"),+ "the refusal must explain the state and the way out, got {status} {text}"+ );+ assert!(+ dir.path().join("victim").join("schema.json").exists(),+ "a refused create must not have rewritten the evidence"+ );+}diff --git a/engine/crates/xerj-engine/src/engine.rs b/engine/crates/xerj-engine/src/engine.rsindex d412d8db7..2c4e4aa8b 100644--- a/engine/crates/xerj-engine/src/engine.rs+++ b/engine/crates/xerj-engine/src/engine.rs@@ -1456,6 +1456,31 @@ impl Engine {list}+ /// Names of the indices that failed to open, filtered to the current+ /// request's visible set exactly like [`Engine::list_indices`].+ ///+ /// A failed index is deliberately *not* in `indices`, so every handler that+ /// resolves names through `list_indices` is blind to it. For read paths+ /// that is correct — there is nothing to read. For two surfaces it is not:+ ///+ /// * `DELETE /{index}` — the operator's escape hatch. Resolving it from+ /// `list_indices` alone made the name unopenable, uncreatable *and*+ /// undeletable over the ES API, the exact state+ /// [`Engine::delete_index`]'s own comment says must not happen.+ /// * cluster health — a failed index is why [`Engine::health`] answers+ /// red, so the endpoint clients and dashboards poll has to see it.+ ///+ /// The visibility filter is applied here for the same reason it is applied+ /// in `list_indices`: a scoped credential must not learn that an index it+ /// cannot see exists, and `delete_index` re-checks the guard anyway.+ pub fn failed_index_names(&self) -> Vec<String> {+ self.failed_indices+ .iter()+ .map(|entry| entry.key().clone())+ .filter(|name| crate::index_guard::visible(name))+ .collect()+ }+/// Get the stats for a single index.pub async fn index_stats(&self, name: &str) -> Result<IndexStats> {let idx = self.get_index(name)?;