8000 mcp: xerj_map — per-index FieldSpec field map from the autoindex catalog (#1055) by xerj-org · Pull Request #1074 · xerj-org/xerj · GitHub
[go: up one dir, main page]

Skip to content

mcp: xerj_map — per-index FieldSpec field map from the autoindex catalog (#1055) - #1074

Merged
xerj-org merged 4 commits into
mainfrom
xerj-map
Sep 30, 2026
Merged

xerj-org merged 4 commits into
mainfrom
xerj-map

Conversation

@xerj-org
Copy link
Copy Markdown
Owner

Closes #1055 (plan item 1 of 10, discussion #1054).

What

An agent writing query DSL against a xerj autoindex node had no way to learn
field names, types, or ranges from MCP — the catalog that holds them
(autoindex-catalog) was CLI-only (xerj autoindex map). So agents guessed
field names and ate unknown-field 400s on the searches they then issued.

Two halves:

1. FieldSpec carries the sampled numeric range (xerj-autoindex/src/infer/mod.rs).
FieldAcc has tracked int_min/int_max since the beginning (:78-79, populated
in track_int); the spec never exposed them. num_min/num_max are Option<i64>,
populated exactly when the elected es_type is long (which also covers epoch
candidates kept long pending corroboration and epoch fields a sibling date range
flips to date, where they land beside the RFC3339 date_min/date_max).

Deliberately None on double: the accumulator only tracks the i64-parseable
subset, so on a fractional column the pair would state the range of the integers
within it — a wrong range presented as fact. An absent range is honest; a partial
one is not. #[serde(default)] keeps every pre-#1055 catalog fields_json and
state plan deserializing (pinned by test).

2. The xerj_map MCP tool (xerj-mcp/src/map.rs, twelfth tool).
POST /autoindex-catalog/_search for doc_kind:dataset — the same read the CLI's
run_map performs, with sample_queries_json (the doc's largest field) projected
out of _source — then renders, per index: records, time field and range, semantic
field, and every FieldSpec field: name, es_type, date_enc, semantic,
cardinality_est, coverage, up to 5 examples, date and numeric min-max.
null_ratio (= 1−coverage), avg_len, and date_evidence are projected out.

The 4 KB cap (acceptance: "default response ≤ 4 KB per index"). max_bytes
argument, default 4096, floor 1024. Trim ladder, documented in the tool
description and reported in each entry's trimmed array:

  1. per-field examples cut to the first;
  2. examples dropped;
  3. per-field notes dropped;
  4. lowest-coverage fields dropped from the end (fields sort coverage desc),
    counted in fields_omitted.

A single field that alone exceeds the cap is dropped whole — that guarantees
termination. An exact index filters engine-side (term on index_name); a
*-glob filters client-side with an anchored glob (no engine wildcard-query
assumption). A missing catalog (node never ran autoindex) is an isError
naming the fix; an empty catalog is a normal empty result with a hint; a
corrupt fields_json renders an empty field list, not a failure.

The catalog index name is repeated as a constant in xerj-mcp rather than
taking a dependency on xerj-autoindex, which would pull the
tree-sitter/SQLite/AWS stack into this thin proxy — safe because that name is
a frozen on-disk contract (hashed into index_identity) that cannot be
renamed in place.

Schema: landing/docs/agents/schemas/mcp-tools.json regenerated with
scripts/mcp-schema-check.sh --write (12 tools; check PASS);
tests/published_schema_drift.rs green. Style follows #1067's max_tokens
pattern: constants quoted into the schema, the floor stated, and the
description carrying the honesty — bounded-sample scope, untracked double
ranges, cap semantics, indexes_omitted.

Does not touch analyzer election (sibling #1070's ground); autoindex edits are
confined to FieldSpec (infer/mod.rs) and mechanical constructor fixes.

Tests (scoped)

  • cargo test --release -p xerj-autoindex --lib — 1135 passed, 0 failed,
    including 5 new: long range populated (negative bounds included);
    fields_json round-trip pinned literally; pre-agents: xerj_map MCP tool — per-index FieldSpec from the autoindex catalog #1055 JSON deserialises to
    None (never an error, never a fabricated Some(0)); double states no
    range; keyword/date omit the keys entirely.
  • cargo test --release -p xerj-mcp — 67 lib + 4 drift passed, 0 failed,
    including 12 new: untrimmed render + projection; the 4 KB cap with
    full-ladder accounting and coverage-ordered survival; ladder order
    examples→notes→fields with no-op stages unreported; a single oversized field
    dropped whole; exact-vs-glob filtering with deterministic order; dataset
    notes; indexes_omitted; corrupt fields_json; argument validation;
    dispatch and transport error paths.
  • cargo fmt + cargo clippy clean on both touched crates.

Honest claims

Measured here: everything above (unit-level, on hand-built catalog responses).
Not measured: the issue's "unknown-field 400s down ≥ 80 % on the
reference-coding harness" — that needs a live multi-corpus node, which this
sandbox does not have; no benchmarks/xerj-map or blog post yet (follow-up
before rc.79 ships, per the plan's packaging rule). The catalog facts
themselves remain bounded-sample estimates, and the tool description says so.

Reference-code note

Peer corpora are unavailable in this sandbox (no xerj code server), so no
peer retrieval; in-repo precedent followed instead — #1067's max_tokens
schema/constant pattern, xerj_code_search's dispatch shape (return-a-tool-
result rather than a BuiltRequest), and the CLI catalog read (run_map) plus
render_map's coverage-desc field ordering in xerj-autoindex.

#1074 (xerj_map) and #1076 (xerj_plan, merged) both extended xerj-mcp: the
tool table, the dispatch match, HELP_BODY's list, mcp-tools.json and the
count test. The textual rebase merged the JSON and the list cleanly but
left #1076's count assertions and prose at twelve. Resolution is the union:

- tools_list_has_all_twelve -> tools_list_has_all_thirteen (13 specs: the
  12 from main incl. xerj_plan, plus xerj_map; list already had both names)
- module doc, HELP_BODY and tool_specs doc now say thirteen
- xerj-mcp tests: 70 passed / 0 failed (incl. published_schema_drift on
  the union mcp-tools.json, which carries both xerj_map and xerj_plan)

Verified locally with cargo test -p xerj-mcp; cargo fmt applied.
Adds the CHANGELOG entry under Added for PR #1074 (issue #1055): the
twelfth MCP tool rendering the per-index FieldSpec field map from the
autoindex catalog under a 4 KB-per-index trim ladder, and the
num_min/num_max FieldSpec extension (long fields only; double honestly
absent; serde-default for pre-existing catalogs).
The inventory test flags any new file under engine/crates/*/src that names
a network-client constructor. map.rs's runtime code reuses the proxy's
shared reqwest client (xerj-mcp/src/lib.rs, already classified as the
`xerj mcp` client); only its unit tests construct one — a throwaway client
pointed at an unroutable address, to pin the transport-error path. That is
the TestOnly role, which the marker-position check in the test itself
verifies (the constructor sits inside #[cfg(test)]).

Caught by the Build + Test job on PR #1074 — exactly the workflow the
guard exists for.
…num_max

Both #1070 (stemming, main) and #1074 (xerj_map, this branch) add code that
constructs or extends infer::FieldSpec; the textual merge left #1070's test
initializer without the two fields #1074 added, which cargo check catches
(E0063) but git cannot. Compile-verified with cargo check -p xerj-autoindex
--all-targets.
@cla-bot cla-bot Bot added the cla-signed label Sep 30, 2026
@xerj-org
xerj-org merged commit f0b96d6 into main Sep 30, 2026
23 checks passed
neoneye pushed a commit to agent-memory-atlas-archive/xerj-org--xerj that referenced this pull request Oct 1, 2026
The MCP registry grew twice without llms.txt or llms-full.txt noticing:
xerj_code_search + xerj_plan landed via xerj-org#1005/xerj-org#1076 and xerj_map via
xerj-org#1074 (merge f0b96d6). Both files still said the mcp-tools.json
registry holds 'ten tools (the six HTTP operations plus the four brain
tools)' and llms-full's own verify example printed the wrong count
(jq '.tools | length' -> 10). The 'seventh canonical operation'
arithmetic in the anthropic-tools.json line leaned on a seven-op
numbering that no longer describes the surface (/_ask is HTTP since
xerj-org#1076; the catalog read always was).

What changed, all outside the generated article tree (hand-written
regions per scripts/seo/README.md):

- llms.txt: mcp-tools.json line says thirteen and names all seven
  additions; anthropic line states the six-op files are the HTTP-core
  surface BY DESIGN (not 'everything else is CLI-only') and says
  'xerj mcp' serves all thirteen
- llms.txt: endpoint map gains POST /_ask (validated DSL out, 422
  naming ungrounded phrases, deterministic not-LLM) — it was entirely
  undocumented
- llms.txt: llms-full section pointer no longer claims 'all seven
  operations'
- llms-full.txt: section 3 retitled 'THE CORE AGENT OPERATIONS' (TOC
  + header; 'NOT an eighth operation' ordinals de-numbered), the
  schema paragraph carries thirteen + the full composition, and the
  jq verify example now reads -> 13

Checked against what is released, not asserted: the 13 names in
landing/docs/agents/schemas/mcp-tools.json (pinned to tool_specs() by
tests/published_schema_drift.rs) are exactly the 13 both files now
name; all 13 appear by name across the two files; seo_lint 0 gate
violations (30 pre-existing warnings, same as main).

Scope deliberately excluded (the queued llms rewrite, one job per PR):
the obligation-language block in llms-full section 9, capability
branching, last-updated stamp. The first-time-agent harness rerun
binds that rewrite, not an inventory correction.

Follow-up from plan xerj-org#1054 items xerj-org#1055/xerj-org#1056.
neoneye pushed a commit to agent-memory-atlas-archive/xerj-org--xerj that referenced this pull request Oct 1, 2026
The packaging half of the ten-item program's rule (discussion xerj-org#1054): a
benchmarks/<name> directory with raw results plus a blog post with the
losses left in. The gate directories landed through xerj-org#1079, xerj-org#1085, xerj-org#1086,
xerj-org#1087, xerj-org#1088 and xerj-org#1090; this is the post.

Structure follows the Jev posts (verdict first, wins then losses with
readings, then what the next window does about each loss). Every number is
verbatim from the committed gate artifacts:

- PASS: /_ask macro-F1 0.9975 over 230 pairs, 0 invalid DSL, 3-run
  determinism, wall-clock p50 1.129 ms vs the 300 ms bar (xerj-org#1076, xerj-org#1079);
  xerj_map unknown-field 400s 20/30 guessed -> 0/30 map-informed, 100%
  vs the >=80% bar (xerj-org#1074, xerj-org#1086); calibration FiQA pair-level ECE
  0.3109 raw -> 0.0088 held-out vs the <=0.10 bar, temperature 0.3163
  published as the failing comparison arm, $0.2125 of provider calls
  over 648 queries (xerj-org#1080, xerj-org#1087).
- FAIL, published as such: the lexical judge loses to its own first
  stage everywhere measured (0.7045->0.5967, 0.3419->0.2924,
  0.2382->0.1650 vs the 0.30 FiQA bar) and stays opt-in with no quality
  claim per its own rule (xerj-org#1077, xerj-org#1090); the flywheel freezes as
  shipped (12 of 2,000 cached, xerj-org#1094) and forces 19.72% coverage at
  0.9953 accuracy vs the 80%/0.97 bars (xerj-org#1075, xerj-org#1088); the tier-2
  decide head misses SMS 0.9193/0.287 vs 0.95/0.05 and AG News 0.2599
  vs 0.85, latency 8.4 ms PASS, ships behind the flag with the numbers
  published (xerj-org#1072/xerj-org#1073, xerj-org#1088).
- SPLIT: stemming +0.0160/+0.0179 BM25 nDCG@10 PASS, zero-hit 25->15
  vs <=10 FAIL — the 15 have no stem anywhere in the corpus (xerj-org#1070,
  xerj-org#1085).
- The gate that caught the stock release binary built without the
  decide-local cargo feature (flag a no-op, stock-binary-noop.txt) is
  told with the fix queued ahead of the cut, not claimed as done.
- Honest gaps stated, not smoothed: the /_ask token arm designed not
  run, the _watcher detection gate not yet measured, no HF URL for
  xerj-decide-v1. Four issues filed from the measurements: xerj-org#1091-xerj-org#1094.

Mechanics: hand-written page at landing/blog/the-rc80-gates.html,
registered in scripts/seo/pagedata.py (published/updated 2026-09-30),
card prepended to the blog hub (hub dateModified bumped), head and
footer owned by fix_heads/fix_links, og falls back to the site card.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agents: xerj_map MCP tool — per-index FieldSpec from the autoindex catalog

1 participant

0