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.

test(map): publish generated scope schema and auth controls

Jarvis1f03e684cb84
diff --git a/landing/docs/agents/schemas/mcp-tools.json b/landing/docs/agents/schemas/mcp-tools.json
index 7162480bd..9554e9480 100644
--- a/landing/docs/agents/schemas/mcp-tools.json
+++ b/landing/docs/agents/schemas/mcp-tools.json
@@ -639,7 +639,7 @@
},
{
"name": "xerj_map",
- "description": "Per-index FIELD MAP from this node's autoindex catalog — call it BEFORE writing query DSL, so you stop guessing field names. For each catalogued index: record count, time field and time range, semantic body field, and every field the profiler inferred — name, es_type (keyword|text|long|double|boolean|date|semantic_text), date encoding, semantic tag, cardinality estimate, coverage, up to 5 examples, and the sampled date AND numeric min-max (numeric ranges appear on `long` fields only; fractional `double` ranges are not tracked). Reads the catalog index `autoindex-catalog` that `xerj autoindex <folder>` writes; never-autoindexed indexes are not listed. Honesty: every fact is inferred from a bounded sample taken at autoindex time — cardinality is an estimate (with `cardinality_overflow:true` it means AT LEAST that many), and min/max/coverage describe the sample, not the whole index. Up to 100 indexes per call (`indexes_omitted` reports more). When more than 8 indexes match and you did not pass `index`, the answer is a SUMMARY page (index, records, field names) — pass `index` or `detail: true` with `offset`/`limit` for full fields. Never DELETE an index you did not create in this session. A shared default prefix is not a reason to delete one: use `xerj autoindex remove --prefix <name>` (MCP tool `xerj_autoindex_remove` is the same operation). It lists the indices, catalog rows, doc counts and sizes, deletes nothing without confirmation, and never removes another folder under that prefix.",
+ "description": "Per-index FIELD MAP from this node's autoindex catalog — call it BEFORE writing query DSL, so you stop guessing field names. For each catalogued index: record count, time field and time range, semantic body field, and every field the profiler inferred — name, es_type (keyword|text|long|double|boolean|date|semantic_text), date encoding, semantic tag, cardinality estimate, coverage, up to 5 examples, and the sampled date AND numeric min-max (numeric ranges appear on `long` fields only; fractional `double` ranges are not tracked). Reads the catalog index `autoindex-catalog` that `xerj autoindex <folder>` writes; never-autoindexed indexes are not listed. Honesty: every fact is inferred from a bounded sample taken at autoindex time — cardinality is an estimate (with `cardinality_overflow:true` it means AT LEAST that many), and min/max/coverage describe the sample, not the whole index. Up to 100 indexes per call (`indexes_omitted` reports more). When more than 8 indexes match and you did not pass `index`, the answer is a SUMMARY page (index, records, field names) — pass `index` or `detail: true` with `offset`/`limit` for full fields. This map lists autoindex datasets, not the managed corpus registry. A managed corpus slug is not an autoindex dataset/index pattern. Use `xerj corpus list` for this client's configured corpora, then `xerj code <corpus> <query>` (MCP `xerj_code_search`); the node's `_cat/indices` lists indices. An empty map does not establish that managed corpus data is absent; no managed corpus existence was checked. Never DELETE an index you did not create in this session. A shared default prefix is not a reason to delete one: use `xerj autoindex remove --prefix <name>` (MCP tool `xerj_autoindex_remove` is the same operation). It lists the indices, catalog rows, doc counts and sizes, deletes nothing without confirmation, and never removes another folder under that prefix.",
"inputSchema": {
"type": "object",
"properties": {
diff --git a/tools/catalog-map/README.md b/tools/catalog-map/README.md
index 0f5c93efe..ee9a569a3 100644
--- a/tools/catalog-map/README.md
+++ b/tools/catalog-map/README.md
@@ -37,8 +37,8 @@ python3 tools/catalog-map/smoke.py --binary engine/target/release/xerj
The script uses only a private loopback HTTP fixture and temporary client cwd.
It does not run a node, read corpus configuration, index data or contact an
-existing server. Eight CLI/MCP cases cover empty results, missing catalogs,
-403 refusals and populated datasets; CLI also verifies `--json` stdout.
+existing server. Ten CLI/MCP cases cover empty results, missing catalogs,
+401/403 refusals and populated datasets; CLI also verifies `--json` stdout.
Requests must remain reads of `/`, catalog `_search` or dataset `_mapping`.
The client/fixture processes stop and temporary files are removed on completion.
These fixtures do not establish live managed-corpus availability or relevance.
diff --git a/tools/catalog-map/smoke.py b/tools/catalog-map/smoke.py
index a5e34b39a..5a558c946 100644
--- a/tools/catalog-map/smoke.py
+++ b/tools/catalog-map/smoke.py
@@ -42,8 +42,8 @@ def main():
def do_POST(self):
requests.append(('POST', self.path))
body = json.loads(self.rfile.read(int(self.headers['Content-Length'])))
- if mode in ('missing', 'forbidden'):
- status = 404 if mode == 'missing' else 403
+ if mode in ('missing', 'unauthorized', 'forbidden'):
+ status = {'missing': 404, 'unauthorized': 401, 'forbidden': 403}[mode]
kind = 'index_not_found_exception' if status == 404 else 'security_exception'
self.reply(status, {'error': {'type': kind, 'reason': 'fixture refusal'}, 'status': status})
return
@@ -58,7 +58,8 @@ def main():
failures = []
try:
with tempfile.TemporaryDirectory(prefix='xerj-catalog-map-') as temp:
- for mode in ('empty', 'missing', 'forbidden', 'positive'):
+ env.update(HOME=temp, USERPROFILE=temp, XDG_CONFIG_HOME=str(Path(temp) / 'config'), XDG_DATA_HOME=str(Path(temp) / 'data'))
+ for mode in ('empty', 'missing', 'unauthorized', 'forbidden', 'positive'):
for transport in ('cli', 'mcp'):
requests.clear()
try:
@@ -84,7 +85,7 @@ def main():
cwd=temp, env=env, capture_output=True, text=True, timeout=30)
assert result.returncode == 0, result.stderr
reply = next(json.loads(line)['result'] for line in result.stdout.splitlines() if json.loads(line).get('id') == 2)
- assert reply.get('isError', False) == (mode in ('missing', 'forbidden')), reply
+ assert reply.get('isError', False) == (mode in ('missing', 'unauthorized', 'forbidden')), reply
text = reply['content'][0]['text']
if mode == 'empty':
mapped = json.loads(text)
@@ -93,8 +94,8 @@ def main():
assert 'managed corpus' in text, text
assert 'xerj corpus list' in text, text
assert 'not establish' in text, text
- elif mode == 'forbidden':
- assert '403' in text, text
+ elif mode in ('unauthorized', 'forbidden'):
+ assert ('401' if mode == 'unauthorized' else '403') in text, text
assert 'managed corpus' not in text, text
else:
assert 'ax-code' in text, text