8000 fix(mcp): resolve xerj_search prefix the way autoindex stores it by xerj-org · Pull Request #2235 · xerj-org/xerj · GitHub
[go: up one dir, main page]

Skip to content

fix(mcp): resolve xerj_search prefix the way autoindex stores it - #2235

Merged
xerj-org merged 1 commit into
mainfrom
cursor/mcp-search-prefix-resolve-4fe1
Oct 23, 2026
Merged

xerj-org merged 1 commit into
mainfrom
cursor/mcp-search-prefix-resolve-4fe1

Conversation

@xerj-org
Copy link
Copy Markdown
Owner

Written by an AI coding agent (Cursor Grok 4.7).

What this changes, and why

Agents pass the --prefix they used with xerj autoindex. MCP xerj_search gained a prefix argument in #2137, but it built {prefix}-* from the raw string. Autoindex stores a sanitized prefix (My_Proj becomes my-proj), so those characters search a pattern that does not exist. xerj search and xerj def had the same gap: three copies of format!("{prefix}-*"), and none of them called dataset::sanitize_prefix / index_prefix_error, which is how xerj autoindex --prefix names indices.

resolve_prefix in xerj-autoindex is now the one function. xerj search, xerj def, and MCP xerj_search call it.

  • project searches project-*. My_Proj searches my-proj-*. A trailing -* copied off an index name is not part of the prefix.
  • A prefix with no [a-z0-9] character, or one that cannot name an index, is an error before any request.
  • Passing both index and prefix is an error. They name different scopes.
  • Passing neither still searches ax-*, the CLI default when --prefix is omitted. Refusing that case would break every caller of the default corpus (xerj_search requires an index argument and no agent-facing doc says to pass ax-* #962). The tool description says so.

The published MCP schema, README, and README.zh-CN describe that contract. xerj_def is not added here; that tool is #2166.

Refs #2080

Evidence

rustc 1.97.1, from engine/, cargo --locked -j 4:

  • cargo test -p xerj-autoindex --lib: 1619 passed, 0 failed, 2 ignored
  • cargo test -p xerj-mcp: 117 lib tests, hub_tools, published_schema_drift (4), search_exact_phrase, and search_prefix, 0 failed. The node test seeds project-docs, my-proj-docs, and ax-other and checks prefix: project, prefix: My_Proj, prefix: project-*, the default, and an explicit index, for a plain string and a DSL query.
  • cargo clippy -p xerj-autoindex --lib -- -D warnings: exit 0
  • cargo clippy -p xerj-mcp --all-targets -- -D warnings: exit 0
  • cargo fmt --all with rustfmt 1.97.1

Checks

  • cargo fmt --all (CI runs rustfmt --check and clippy -D warnings)
  • Scoped release build of the crates touched: cargo build --release -j 32 -p <crate>
  • cargo test -p <crate> passes (cargo check is not sufficient — test code is interleaved with production code)
  • ES-YAML conformance suite at 0 failed — not applicable: the client requests a different index pattern; the engine wire protocol is unchanged
  • New ES-compatible behaviour has a matching YAML case — not applicable, same reason
  • Docs updated if user-visible behaviour changed
  • For non-trivial changes: the applicable audit in docs/CONTRIBUTION_REVIEW.md. Ancestry is main plus this commit. No durable state, migration, or recovery path changes. Existing explicit-index and default ax-* search behavior is preserved. Failure of a bad prefix happens before HTTP, so no partial write.
  • Operational-recipe audit: N/A. No install, deploy, or runnable recipe changed.

Not run: a release build of xerj-mcp / xerj-autoindex, and the ES-YAML suite. Debug tests and clippy cover the crates that changed. The CLI binary was not invoked against a live node; run_search_cli and run_def_cli call resolve_prefix, which the unit test and the MCP node test exercise.

Provenance

  • Written by: AI agent (Cursor Grok 4.7)
  • Verified (commands run, output observed): the cargo test, clippy, and fmt commands listed under Evidence, on this machine, rustc 1.97.1.
  • Assumed (not tested, and what would falsify it): a release build and ES-YAML stay green. A failure in either would falsify the "no wire change" claim only if this diff is what broke them. Other MCP hosts were not exercised; the schema drift test compares the published file to tool_specs.
Open in Web Open in Cursor 

@cla-bot cla-bot Bot added the cla-signed label Oct 23, 2026
Motivation: issue #2080. Agents pass the --prefix they used with
xerj autoindex. MCP xerj_search grew a prefix argument in #2137, but
it built {prefix}-* from the raw string. Autoindex stores a sanitized
prefix (My_Proj becomes my-proj), so the typed characters search a
pattern that does not exist. xerj search and xerj def had the same gap.

Root cause: three copies of format!("{prefix}-*"), and none of them
called dataset::sanitize_prefix / index_prefix_error, which is how
xerj autoindex --prefix names indices.

Change: resolve_prefix in xerj-autoindex is the one function. xerj
search, xerj def, and MCP xerj_search call it. My_Proj searches
my-proj-*, and a trailing -* is not part of the prefix. A prefix that
cannot name an index is refused before any request. Passing both
index and prefix is still an error. Passing neither still searches
ax-*, the CLI default when --prefix is omitted. Refusing that case
would break every caller of the default corpus (#962). The tool
description says so.

Evidence (rustc 1.97.1, from engine/, cargo --locked -j 4):
- cargo test -p xerj-autoindex --lib: 1619 passed, 0 failed, 2 ignored
- cargo test -p xerj-mcp: 117 lib tests, hub_tools, published_schema_drift
  (4), search_exact_phrase, and search_prefix, 0 failed
- cargo clippy -p xerj-autoindex --lib -- -D warnings: exit 0
- cargo clippy -p xerj-mcp --all-targets -- -D warnings: exit 0
- cargo fmt --all with rustfmt 1.97.1

Not run: a release build, and the ES-YAML suite. This does not change
the engine wire protocol; the client requests a different index pattern.

Refs #2080. The xerj_def MCP tool is #2166.

Co-authored-by: xerj-org <xerj-org@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/mcp-search-prefix-resolve-4fe1 branch from 4a225f6 to aa87fbc Compare October 23, 2026 04:24
@xerj-org
xerj-org merged commit 5ad8572 into main Oct 23, 2026
25 checks passed
@xerj-org
Copy link
Copy Markdown
Owner Author

Xerj Merger made the fix: xerj search --prefix, xerj def --prefix and MCP xerj_search's prefix now resolve through one function (resolve_prefix) that applies the same sanitizing autoindex uses, so My_Proj searches my-proj-* and an unusable prefix is refused up front. Diff reviewed; Build + Test passed on the merged head. Fixes #2080.

cursor Bot pushed a commit that referenced this pull request Oct 23, 2026
The only conflict was CHANGELOG.md. Both sides added an Unreleased
Fixed entry at the top of the section. Keep both: main's corpus-index
journal resume (#2239) and this branch's Windows commit-space memory
cap (#1122). The prefix-resolution Fixed entry from #2235 merged
without a marker. Engine and common sources were not touched on main
since the last merge and stayed as this branch left them.

Co-authored-by: xerj-org <xerj-org@users.noreply.github.com>
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.

2 participants

0