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: repair three merge-skew compile/test breaks on main (autoindex + hub) (#1778)

xerj-org93664623ea30
diff --git a/.github/workflows/hub-e2e.yml b/.github/workflows/hub-e2e.yml
index d4aaca028..455a30dcc 100644
--- a/.github/workflows/hub-e2e.yml
+++ b/.github/workflows/hub-e2e.yml
@@ -63,7 +63,7 @@ jobs:
e2e:
name: whole-hub end-to-end
runs-on: ubuntu-latest
- timeout-minutes: 300
+ timeout-minutes: 90
permissions:
contents: write # only used when commit_report is set
steps:
diff --git a/engine/crates/xerj-autoindex/src/init.rs b/engine/crates/xerj-autoindex/src/init.rs
index 3121ebf09..904afcfcb 100644
--- a/engine/crates/xerj-autoindex/src/init.rs
+++ b/engine/crates/xerj-autoindex/src/init.rs
@@ -494,7 +494,7 @@ fn write_codex_config(path: &Path, url: &str, dry: bool) -> Result<String, Strin
}
};
if existing.as_deref().is_some_and(codex_has_xerj) {
- return Ok(report("kept", path));
+ return Ok(report("kept", path, dry));
}
let block = codex_mcp_block(url);
let merged = match existing {
@@ -513,7 +513,7 @@ fn write_codex_config(path: &Path, url: &str, dry: bool) -> Result<String, Strin
};
let had = backup(path, dry)?;
write_file(path, &merged, dry).map_err(|e| e.to_string())?;
- Ok(report(if had { "appended" } else { "wrote" }, path))
+ Ok(report(if had { "appended" } else { "wrote" }, path, dry))
}
/// One detected surface, written. Returns the human line to print.
diff --git a/engine/crates/xerj-autoindex/src/search.rs b/engine/crates/xerj-autoindex/src/search.rs
index 954b14d6e..ae431fd42 100644
--- a/engine/crates/xerj-autoindex/src/search.rs
+++ b/engine/crates/xerj-autoindex/src/search.rs
@@ -732,6 +732,10 @@ struct ParsedSearch {
#[derive(Debug)]
enum SearchCli {
Help,
+ /// A flag the command refuses (e.g. `--mode`): the one-line reason is
+ /// already printed to stderr, and the caller exits 2 without the USAGE
+ /// dump the generic `Err` path adds.
+ Refuse,
Query(ParsedSearch),
}
@@ -759,7 +763,7 @@ fn parse_search_cli(
"--mode" => {
let asked = it.next().unwrap_or_default();
eprintln!("{}", search_mode_refusal(&asked));
- return 2;
+ return Ok(SearchCli::Refuse);
}
other if !other.starts_with('-') && query.is_none() => query = Some(other.to_string()),
other => return Err(format!("unexpected argument '{other}'")),
@@ -794,6 +798,8 @@ pub fn run_search_cli() -> i32 {
print!("{USAGE}");
return 0;
}
+ // The refusal line is already on stderr; exit 2 without a USAGE dump.
+ Ok(SearchCli::Refuse) => return 2,
Ok(SearchCli::Query(parsed)) => parsed,
Err(e) => {
eprintln!("xerj search: {e}\n\n{USAGE}");
diff --git a/engine/crates/xerj-hub/src/catalogue.rs b/engine/crates/xerj-hub/src/catalogue.rs
index c99548d66..fb1bc6900 100644
--- a/engine/crates/xerj-hub/src/catalogue.rs
+++ b/engine/crates/xerj-hub/src/catalogue.rs
@@ -1125,7 +1125,7 @@ mod tests {
#[test]
fn an_older_signed_catalogue_is_refused_as_a_rollback() {
- let _guard = ENV_LOCK.lock().unwrap();
+ let env = HubPubkeyEnv::lock();
let fx = tempfile::tempdir().unwrap();
let inputs = two_inputs(fx.path());
let (seed, public) = keypair();
@@ -1142,13 +1142,13 @@ mod tests {
let (old_cat, old_sig) = build_catalogue(&inputs, "2026-10-01T00:00:00Z", &seed).unwrap();
let old_bytes = canonical_json(&old_cat).unwrap();
- std::env::set_var("XERJ_HUB_PUBKEY", &public);
+ env.set(&public);
let (url, handle) = spawn_hub(old_bytes.clone(), old_sig.clone());
let err = refresh_catalogue(&url, cache.path()).expect_err("a rollback is refused");
handle.join().unwrap();
let (url, handle) = spawn_hub(old_bytes, old_sig);
let served = load_catalogue(&url, cache.path(), false).expect("cached copy kept");
- std::env::remove_var("XERJ_HUB_PUBKEY");
+ env.remove();
handle.join().unwrap();
assert!(format!("{err:#}").contains("rollback"), "{err:#}");
diff --git a/engine/crates/xerj-hub/tests/ask_flow.rs b/engine/crates/xerj-hub/tests/ask_flow.rs
index 325f74c58..af2de4162 100644
--- a/engine/crates/xerj-hub/tests/ask_flow.rs
+++ b/engine/crates/xerj-hub/tests/ask_flow.rs
@@ -988,8 +988,6 @@ async fn ask_end_to_end() {
// for half an hour, with no owner recorded. It is an OS lock now.
#[cfg(unix)]
{
- use std::os::unix::ffi::OsStrExt;
-
let hub = work.join("hub-f");
let code = work.join("code-f");
publish(&archive, &sig, &work.join("net-f"), &hub);
@@ -997,15 +995,19 @@ async fn ask_end_to_end() {
set_env(&hub, &code, &scratch_home, &public);
let url = spawn_node(&work.join("data-f"), allowlist.clone()).await;
- // A pack URL that never delivers a byte: a FIFO with no writer. The pull takes
- // its lock, starts "downloading" and blocks in open(2).
- let fifo = work.join("net-f").join("never.fifo");
- let fifo_c = std::ffi::CString::new(fifo.as_os_str().as_bytes()).unwrap();
- assert_eq!(unsafe { libc::mkfifo(fifo_c.as_ptr(), 0o600) }, 0, "mkfifo");
+ // A pack URL that never delivers a byte: a listener that is never
+ // accepted. The kernel completes the handshake, the request is sent, and
+ // no response comes, so the pull takes its lock, starts "downloading" and
+ // blocks reading the reply. (A FIFO no longer works: since #1733 a
+ // file:// pack must be a regular file, so the pull fails before it blocks.)
+ let silent = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
set_catalogue_field(
&hub,
"pack_url",
- json!(format!("file://{}", fifo.display())),
+ json!(format!(
+ "http://{}/never.hubpack.tar.zst",
+ silent.local_addr().unwrap()
+ )),
);
// The victim is a separate process running `xerj hub pull` (this binary).
@@ -1084,7 +1086,7 @@ async fn ask_end_to_end() {
.join(PIN8)
.join("pack.json")
.is_file());
- let _ = std::fs::remove_file(&fifo);
+ drop(silent);
}
}
diff --git a/engine/crates/xerj-server/src/main.rs b/engine/crates/xerj-server/src/main.rs
index c5af4c167..8b23321e6 100644
--- a/engine/crates/xerj-server/src/main.rs
+++ b/engine/crates/xerj-server/src/main.rs
@@ -1333,7 +1333,12 @@ fn bind_listener(addr: SocketAddr, name: &str) -> Result<std::net::TcpListener>
let listener = match std::net::TcpListener::bind(addr) {
Ok(listener) => listener,
Err(e) if e.kind() == std::io::ErrorKind::AddrInUse => {
- anyhow::bail!("{}", addr_in_use_message(name, addr));
+ // The hint first, then the OS reason and the `bind {addr}` wording
+ // the #465 process test (`taken_port_fails_startup`) relies on.
+ anyhow::bail!(
+ "{} ({name}: bind {addr}: {e})",
+ addr_in_use_message(name, addr)
+ );
}
Err(e) => return Err(e).with_context(|| format!("{name}: bind {addr}")),
};
@@ -1360,7 +1365,11 @@ mod bind_listener_tests {
assert!(msg.contains("--auto-port"), "{msg}");
assert!(msg.contains("xerj --help"), "{msg}");
assert!(msg.contains(&addr.to_string()), "{msg}");
- assert_eq!(msg, addr_in_use_message("ES-compat", addr));
+ assert!(
+ msg.starts_with(&addr_in_use_message("ES-compat", addr)),
+ "{msg}"
+ );
+ assert!(msg.contains(&format!("bind {addr}")), "{msg}");
}
}
@@ -2167,6 +2176,14 @@ fn main() -> Result<()> {
#[cfg(unix)]
raise_nofile_limit();
+ // Dispatch before creating Tokio's pool so each PDF worker stays small.
+ // Before the flag hoist below, too: the hoist reads `std::env::args()`,
+ // which panics on a non-UTF-8 argument, and a worker's PDF path may be
+ // one. Only `args_os` is read here.
+ if std::env::args_os().nth(1).as_deref() == Some(std::ffi::OsStr::new("__extract-pdf")) {
+ std::process::exit(xerj_autoindex::extract::pdf::run_worker_cli());
+ }
+
// `xerj --url URL corpus index name` used to die here as an unknown
// server flag. Move those flags behind the subcommand before any
// dispatch reads argv.
@@ -2175,14 +2192,6 @@ fn main() -> Result<()> {
is_top_level_command,
));
- // Dispatch before creating Tokio's pool so each PDF worker stays small.
- if matches!(
- xerj_common::argv::subcommand().as_deref(),
- Some("__extract-pdf")
- ) {
- std::process::exit(xerj_autoindex::extract::pdf::run_worker_cli());
- }
-
// The isolated legacy-`.xls` BIFF reader. calamine 0.26.1 panics on crafted
// records (short `Lbl`/`ExternSheet`) and the release profile is
// `panic = abort`, so the read runs here, in a short-lived rlimit-capped
diff --git a/landing/for-agents.html b/landing/for-agents.html
index 1606b0fde..3150829d0 100644
--- a/landing/for-agents.html
+++ b/landing/for-agents.html
@@ -427,6 +427,7 @@ $ curl -sXPOST localhost:9200/docfolder/_search \
<a href="/docs/agents/schemas/openai-tools.json"><code class="inline">/docs/agents/schemas/openai-tools.json</code></a> (OpenAI function-calling),
<a href="/docs/agents/schemas/mcp-tools.json"><code class="inline">/docs/agents/schemas/mcp-tools.json</code></a> (MCP <code class="inline">tools</code> list).
Each carries the full JSON-Schema input shape plus the same caveats as this page. They describe the HTTP surface only — <code class="inline">xerj_autoindex</code> is not in them, and you still need a running node to call.</li>
+ <li><a href="/docs/agents/schemas/field-report.json"><code class="inline">/docs/agents/schemas/field-report.json</code></a> — the request body for <code class="inline">POST /api/field-report</code>, the field-report fallback for an agent with no GitHub account. Show your user the report (<code class="inline">xerj feedback --dry-run</code>) and ask before sending.</li>
<li><a href="/use-cases/second-brain">Second brain — the runnable MCP server</a> — <code class="inline">xerj brain</code> over a folder of notes, exposing four verbs (<code class="inline">xerj_brain_ego</code>, <code class="inline">xerj_brain_link</code>, <code class="inline">xerj_brain_unlink</code>, <code class="inline">xerj_brain_overview</code>) under <code class="inline">contract: xerj-second-brain/1</code>, with the verification run that exercised them.</li>
</ul>
</section>
diff --git a/landing/sitemap.xml b/landing/sitemap.xml
index bc905ba91..733f8cc6c 100644
--- a/landing/sitemap.xml
+++ b/landing/sitemap.xml
@@ -2,11 +2,11 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://xerj.org/</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/agent-search/</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/aise-demo</loc>
@@ -334,15 +334,15 @@
</url>
<url>
<loc>https://xerj.org/blog/</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/blog/cutting-the-index-28-percent</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/blog/does-xerj-beat-jev</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/blog/eval-scars-from-agent-memory</loc>
@@ -350,11 +350,11 @@
</url>
<url>
<loc>https://xerj.org/blog/jev-vs-a-bm25-vote</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/blog/one-vulnerability-three-names</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/blog/the-corpus-hub</loc>
@@ -366,7 +366,7 @@
</url>
<url>
<loc>https://xerj.org/blog/the-rc80-gates</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/brand</loc>
@@ -470,119 +470,119 @@
</url>
<url>
<loc>https://xerj.org/docs/</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/agents/</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/agents/endpoints</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/agents/quickstart</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/aggregations</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/analyzers</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/api-es-compat</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/api-native</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/backup-restore</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/cli</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/clustering</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/compression</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/config</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/corpus-hub</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/env</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/ingest</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/install</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/metrics</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/migration-from-es</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/operations</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/playbooks/full-text</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/playbooks/log-analytics</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/playbooks/observability</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/playbooks/siem</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/playbooks/vector-search</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/queries</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/quickstart</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/recipes/</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/recipes/agentic-memory</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/recipes/air-gapped-deployment</loc>
@@ -590,71 +590,71 @@
</url>
<url>
<loc>https://xerj.org/docs/recipes/anomaly-detection</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/recipes/continuous-anomaly-datafeeds</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/recipes/document-folder-index</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/recipes/hybrid-search</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/recipes/log-analytics</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/recipes/migrate-from-elasticsearch</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/recipes/passage-retrieval</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/recipes/semantic-search-rag</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/recipes/vector-quantization</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/recipes/vector-search-knn</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/recipes/zero-config-autoindex</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/security</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/storage</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/troubleshooting</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/upgrades</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/docs/vectors</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/for-agents</loc>
- <lastmod>2026-10-17</lastmod>
+ <lastmod>2026-10-18</lastmod>
</url>
<url>
<loc>https://xerj.org/industries/</loc>