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
Merge pull request #266 from xerj-org/fix/issue-206-failed-index-recovery
xerj-org2d303bfef43a
diff --cc CHANGELOG.mdindex 504acdc2f,930cd5dd8..73d7ca4b6--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -7,55 -7,58 +7,105 @@@ and this project adheres to [Semantic V## [Unreleased]+### Changed++- **BREAKING — `server.bind_address` now defaults to `127.0.0.1`, and a+ cleartext node refuses to publish itself to the network**+ ([#228](https://github.com/xerj-org/xerj/issues/228)). The old default was+ `0.0.0.0` while TLS is off by default, so an out-of-the-box node accepted its+ admin API key over plain HTTP on every interface the host had — verified on a+ stock boot, where `curl -H "Authorization: ApiKey …" http://<lan-ip>:9200/…`+ answered `200` and the same URL over `https` had no listener to hand shake+ with. Auth being on did not help: the credential *is* the thing on the wire.++ A fresh node is now reachable from its own host and nowhere else. Exposing it+ is two statements, not zero: set `server.bind_address` (or `--bind` /+ `XERJ_BIND_ADDRESS`), and — while `tls.enabled = false` — also set+ `server.allow_insecure_network_bind = true` (env+ `XERJ_ALLOW_INSECURE_NETWORK_BIND`). Without the second, startup exits+ non-zero before the data directory is created or a first-run admin key is+ minted. `--insecure` does not evade it; it clears `tls.enabled`, which is+ exactly what the check keys on. Same fail-closed shape as+ [#229](https://github.com/xerj-org/xerj/issues/229), whose TLS-on gRPC check+ is untouched and cannot be relaxed by this opt-out.++ **Upgrading:** a deployment that relied on the old default becomes+ unreachable from other hosts until it sets both; one that already wrote+ `bind_address = "0.0.0.0"` without TLS now fails to start with a message+ naming the setting that unblocks it. The shipped Docker image, compose file+ and Helm chart set both, because a container's network namespace is the+ boundary and its published port is where TLS belongs.++ Two documentation claims that were false as written are now true: the CLI and+ security pages both said `--insecure` "refuses to run with a non-loopback+ bind", and it did not — a `--insecure` node on `0.0.0.0` accepted an+ unauthenticated `PUT /leak/_doc/1` from the LAN (`201`). The startup banner+ also prints the bind address on every listener line, so a loopback node and a+ world-facing one no longer look identical.++ A `bind_address` that is not an IP literal is rejected first, ahead of both+ exposure checks, with the fault it actually has. Host names have never been+ resolved — the pre-#228 code parsed `"{bind}:{port}"` as a socket address and+ failed on them too — but the exposure predicates fail closed on anything they+ cannot parse, so without that ordering `bind_address = "localhost"` was+ refused with a message asserting that localhost "is not loopback" and would+ "serve plain HTTP on a network-reachable interface", and pointed at an opt-out+ that fixed nothing: setting it let the boot run on to the bind and fail there+ instead, after the data directory, the `.xerj_*` system indices, the master+ key and a printed first-run `admin.key` already existed.+### Fixed+ - **A failed index can now be inspected, deleted and retried without stopping+ the server** ([#206](https://github.com/xerj-org/xerj/issues/206)). An index+ directory that refused to open at boot was recorded in a map that only+ `Engine::health` ever read. Live-reproduced with a corrupt `snapshot.json`:+ it was absent from `_cat/indices` and `_cluster/state`, `DELETE /{index}`+ answered `404 index_not_found` and left the bytes on disk, and the only+ recovery was to stop the server and edit the data directory by hand. A+ failed index is now a real state: listed as `red` in `_cat/indices`, present+ in `_cluster/state` as an `UNASSIGNED` primary with `ALLOCATION_FAILED` and+ the verbatim open error, enumerated with its reason by+ `GET /_cluster/indices/failed`, reopenable via+ `POST /_cluster/indices/failed/{name}/_retry` once the cause is fixed, and+ deletable through the ordinary `DELETE /{index}`. Searches, writes and+ creates against it return `503 no_shard_available_action_exception` carrying+ the reason instead of a `404` that claimed it did not exist, while the+ metadata surfaces — `GET /{index}`, `HEAD /{index}` (the `indices.exists()`+ every ES client calls), `_mapping`, `_settings`, `_cat/indices` — report it+ as an index that exists, the way ES answers those from cluster metadata+ rather than from a shard. Before this, `HEAD` said the name was free and the+ following `PUT` said it was unavailable.++ Two related defects in the same report are fixed with it. **Readiness no+ longer hard-fails on a partly degraded node** — `/health/ready` returned+ `503` for any red status, so one broken index pulled a pod holding 200+ healthy ones out of service permanently; it now reports `200 ready+ (degraded)` while the node can still serve something and `503` only when+ every index it holds failed to open. And **`_cat/health` no longer prints a+ hardcoded `green`** — the one health surface an existing ES dashboard points+ at was the one that could not report a broken node; it and `_cluster/health`+ now count an unopenable index as an unassigned primary, agreeing with+ `/v1/health` and `/v1/cluster/health`.++ Because `red` is now reachable on `_cluster/health` for the first time, the+ two conditions that gate on it are consulted rather than assumed:+ `wait_for_active_shards=all` and `wait_for_status=green|yellow` both answer+ `408` with `timed_out: true` on a red node instead of `200 timed_out: false`.+ `GET /_cluster/health?wait_for_status=green&timeout=30s` is the bootstrap gate+ every docker healthcheck, CI wait loop and Kibana startup uses; a red node+ used to sail straight through it. A green or yellow cluster is unaffected.++ - **A `DELETE /{index}` that could not remove the bytes no longer strands the+ index.** The open-index path pulled the handle out of the engine before+ `remove_dir_all`, so a removal that failed (read-only mount, `EACCES`) freed+ the name while the directory survived: no handle, no failed-index entry,+ nothing on `_cat/indices`, and the next `DELETE` answered `404` — the same+ dead end as [#206](https://github.com/xerj-org/xerj/issues/206), reached from+ the other side. The handle is now restored on failure, so the index stays in+ service and addressable and the operator can retry the delete once the cause+ is fixed.+- **`autoindex` no longer leaves immortal catalog entries for skipped files**([#238](https://github.com/xerj-org/xerj/issues/238)). A file added after theresume plan was frozen is skipped and reported in the catalog — but that