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
docs(console): disclose external data-source connection contract
xerj-org06fbfd2ec938
diff --git a/engine/crates/xerj-console-api/src/data_sources.rs b/engine/crates/xerj-console-api/src/data_sources.rsindex 0ced13b6d..aad1be978 100644--- a/engine/crates/xerj-console-api/src/data_sources.rs+++ b/engine/crates/xerj-console-api/src/data_sources.rs@@ -6,10 +6,18 @@//! in-process Engine. This is enough for the SPA to drop its//! hand-rolled `data-sources.js` overlay.//!-//! Adapter trait, encrypted credentials, write paths (POST/PATCH/DELETE),+//! **External-connection disclosure.** Only the `built-in` connection is+//! backed by a live adapter; its index and field listings are read+//! straight from the running Engine's real schema, never a canned map.+//! No external adapter subsystem exists yet — the adapter trait,+//! encrypted credentials, write paths (POST/PATCH/DELETE) and the//! HTTP-shaped adapters (xerj-remote, elasticsearch, opensearch,-//! prometheus, postgres) come in a follow-up commit. Their stubs return-//! 501 today.+//! prometheus, postgres) all land in a follow-up commit. Until then,+//! listing indices or fields for any non-`built-in` connection id+//! returns `501 Not Implemented` rather than a fabricated answer, and a+//! connection row that is not `built-in` is reported with status+//! `"unknown"` (no live probe is performed) so the UI never shows a+//! green light it cannot stand behind.use axum::{extract::{Path, State},diff --git a/engine/crates/xerj-console-api/tests/phase3_user_state.rs b/engine/crates/xerj-console-api/tests/phase3_user_state.rsindex 31ba98435..5fd0e8c31 100644--- a/engine/crates/xerj-console-api/tests/phase3_user_state.rs+++ b/engine/crates/xerj-console-api/tests/phase3_user_state.rs@@ -14,6 +14,7 @@ use serde_json::{json, Value};use tempfile::TempDir;use tower::ServiceExt;use xerj_common::config::Config;+use xerj_common::types::{FieldConfig, FieldType, Schema};use xerj_console_api::{auth::{sessions, store},state::ClusterMode,@@ -24,6 +25,7 @@ use xerj_engine::Engine;struct TestApp {router: Router,cookie: String,+ engine: Engine,_dir: TempDir,}@@ -63,6 +65,7 @@ async fn boot_with_session() -> TestApp {TestApp {router,cookie,+ engine,_dir: dir,}}@@ -420,6 +423,67 @@ async fn data_sources_unknown_connection_returns_501() {assert_eq!(r.status(), 501);}+#[tokio::test]+async fn data_sources_fields_for_built_in_are_live_schema() {+ // The built-in connection must surface the *real* engine schema for an+ // index — verbatim field names and types, never a fabricated map.+ let app = boot_with_session().await;++ let mut schema = Schema::empty();+ schema+ .add_field(FieldConfig::new("title", FieldType::Keyword))+ .unwrap();+ schema+ .add_field(FieldConfig::new("views", FieldType::Long))+ .unwrap();+ app.engine+ .create_index("catalog", schema)+ .expect("create index");++ let r = app+ .router+ .oneshot(req(+ "GET",+ "/_xerj-console/api/v1/data-sources/connections/built-in/indices/catalog/fields",+ &app.cookie,+ None,+ ))+ .await+ .unwrap();+ let (status, body) = body_json(r).await;+ assert_eq!(status, 200, "{body}");+ let fields = body["data"]["fields"].as_array().unwrap();+ let title = fields+ .iter()+ .find(|f| f["name"] == "title")+ .unwrap_or_else(|| panic!("missing title field: {body}"));+ // Type comes straight from the live engine schema.+ assert_eq!(title["type"], "keyword", "{body}");+ let views = fields+ .iter()+ .find(|f| f["name"] == "views")+ .unwrap_or_else(|| panic!("missing views field: {body}"));+ assert_eq!(views["type"], "long", "{body}");+}++#[tokio::test]+async fn data_sources_fields_unknown_connection_returns_501() {+ // Field listing for any non-built-in connection id must fail loud with+ // 501 — the API never fabricates an external adapter's schema.+ let app = boot_with_session().await;+ let r = app+ .router+ .oneshot(req(+ "GET",+ "/_xerj-console/api/v1/data-sources/connections/elasticsearch-prod/indices/logs/fields",+ &app.cookie,+ None,+ ))+ .await+ .unwrap();+ assert_eq!(r.status(), 501);+}+#[tokio::test]async fn known_routes_include_phase3() {let routes = xerj_console_api::router::known_routes();