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
Honor an explicitly disabled single-member alias on every write route
xerj-org651016722eec
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8bf9a8670..7842ee5f7 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Reindex preflights every source alias member before creating or writing thedestination. Aliases cannot hide a source/destination overlap; a missingsource, invalid query or source flush failure leaves destination data intact.+ An alias with `is_write_index: false` refuses writes even with one member.- Corpus cloning validates existing checkouts and serializes writers (#2453).New checkouts are staged before publication. Ambiguous existing directoriesdiff --git a/engine/crates/xerj-api/tests/reindex_alias_semantics.rs b/engine/crates/xerj-api/tests/reindex_alias_semantics.rsindex 9a0a79a4f..242329199 100644--- a/engine/crates/xerj-api/tests/reindex_alias_semantics.rs+++ b/engine/crates/xerj-api/tests/reindex_alias_semantics.rs@@ -357,3 +357,38 @@ async fn later_member_flush_failure_keeps_destination_unchanged_and_can_retry()vec!["existing", "first", "second"]);}++#[tokio::test]+async fn explicitly_disabled_single_member_alias_refuses_writes_and_can_be_enabled() {+ let (app, _dir) = app().await;+ create_keyword_index(&app, "source").await;+ doc(&app, "source", "one", "keep").await;+ create_keyword_index(&app, "destination").await;+ alias(+ &app,+ "destination",+ "disabled",+ json!({"is_write_index": false}),+ )+ .await;+ let (status, body) = reindex(&app, "source", "disabled").await;+ assert_eq!(status, StatusCode::BAD_REQUEST, "{body}");+ assert!(+ body.to_string().contains("no write index is defined"),+ "{body}"+ );+ assert!(ids(&app, "destination").await.is_empty());+ let (status, body) = call(&app, "PUT", "/disabled/_doc/direct", json!({"k":"direct"})).await;+ assert_eq!(status, StatusCode::BAD_REQUEST, "{body}");+ assert!(ids(&app, "destination").await.is_empty());+ alias(+ &app,+ "destination",+ "disabled",+ json!({"is_write_index": true}),+ )+ .await;+ let (status, body) = reindex(&app, "source", "disabled").await;+ assert_eq!(status, StatusCode::OK, "{body}");+ assert_eq!(ids(&app, "destination").await, vec!["one"]);+}diff --git a/engine/crates/xerj-engine/src/engine.rs b/engine/crates/xerj-engine/src/engine.rsindex 0bdfa3c6d..a3d61effc 100644--- a/engine/crates/xerj-engine/src/engine.rs+++ b/engine/crates/xerj-engine/src/engine.rs@@ -3335,7 +3335,7 @@ impl Engine {}/// The concrete index a write to `name` must target when `name` is an- /// alias: a single backing index, or exactly one marked+ /// alias: a single backing index unless explicitly disabled, or exactly one marked/// `is_write_index: true`. `Ok(None)` means `name` is not an alias (a/// concrete index or a name the caller may auto-create). More than one/// candidate is ambiguous and refused with ES's message.@@ -3349,7 +3349,17 @@ impl Engine {let Some(backings) = self.aliases.get(name) else {return Ok(None);};- if backings.len() == 1 {+ let single_write_disabled = backings.len() == 1+ && self+ .index_alias_metadata+ .get(backings[0].as_str())+ .is_some_and(|meta| {+ meta.get(name)+ .and_then(|alias_meta| alias_meta.get("is_write_index"))+ .and_then(serde_json::Value::as_bool)+ == Some(false)+ });+ if backings.len() == 1 && !single_write_disabled {return Ok(Some(backings[0].clone()));}let mut writes = backings.iter().filter(|backing| {