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
Integrate file-level corpus sparse selections with recovery coverage
xerj-org0438f46e1768
diff --cc CHANGELOG.mdindex dcc256682,54818ebe3..cca1ef8bf--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -9,80 -9,11 +9,84 @@@ and this project adheres to [Semantic V### Added-- A Corpus Hub manifest's `paths` entry may name a regular file as well as a- directory (#2486). `xerj corpus add --from` checks out exactly that file,- without its siblings, so a pack can take `pandas/core/resample.py` without- the rest of `pandas/core`. A symlink entry is refused. Manifests that name- only directories check out the same tree as before.++- Corpus Hub manifest `paths` entries may name regular files as well as++ directories (#2486). A file selection checks out that file without its++ siblings; symlinks and submodules are refused.+++- MCP `xerj_status` reports node reachability, cluster health and visible+ indices before a search. It distinguishes a missing autoindex catalog from+ other indexed data and preserves failed or malformed probes as errors+ rather than reporting a successful empty node (#2515).++- Empty autoindex maps now explain that managed corpus slugs and autoindex+ dataset/index names belong to separate discovery surfaces. CLI diagnostics,+ MCP empty responses and the `xerj_map` description point to corpus discovery+ without claiming a corpus exists. Missing catalogs remain errors; auth+ refusals and successful dataset maps retain their behavior (#2412).++- Public Agent Skills Discovery v0.2.0 index and a documentation-routing skill+ at `/.well-known/agent-skills/`. The index is generated from the published+ skill's metadata and exact-byte SHA-256, with a CI drift check.++### Fixed++- MCP `xerj_search` advertises plain text in `query` and structured clauses+ in `query_dsl`. Legacy object-valued `query` and omitted-query browsing+ remain supported; conflicting fields fail before HTTP requests (#2549).+- Search payloads and batch retrieval default to 8,000 UAX #29 words when+ `max_tokens` is absent or null (#2491). This is not a byte or model-token+ cap. Explicit larger budgets remain available; errors and mandatory+ search staleness hints stay outside the payload budget.+- GitHub field-report submission uses the supported explicit-repository+ `gh repo fork --clone=false` invocation and adds the fork remote itself+ (#2596). The rollback test now verifies that the report was committed+ before a failed push, rather than passing after an earlier fork failure.+- Local admin-key discovery reports the source of the selected key and warns+ when its directory is outside the working tree (#2578). Packaged installs+ have their own provenance, and MCP guidance names `XERJ_AUTH`. Discovery+ priority and explicit credential overrides are unchanged.++- SQL source extraction no longer slices statement heads inside a UTF-8+ character, so unrecognized CJK statement/comment heads do not panic (#2547).+- Short Markdown files with YAML frontmatter retain their prose body even+ when bullets or `Key: value` lines also parse as YAML (#2447). Existing+ frontmatter-title behavior and structured CSV/JSON body detection remain.+- Empty files keep separate inventory identities instead of being reported+ as content duplicates of unrelated paths (#2449). Non-empty byte-identical+ files still deduplicate.+- A search with both `query` and a top-level `knn` returns `size` hits, not+ `k` (#2561). The page was widened to `k`, so `size: 5, k: 20` returned+ 20 hits. `k` still sets how many nearest neighbours join the candidate+ set, and `from`/`size` page through the union, as in Elasticsearch.+- Index deletion no longer waits for unrelated index statistics while+ resolving its selectors. Index listings and health checks also release+ their index-map locks before awaiting statistics, so a stalled schema+ update does not hold those locks against DELETE (part of #2405; extracted+ from #2489). Merge/flush cancellation and the process memory cap remain+ separate follow-ups.+- `xerj autoindex` compresses per-file phase-B stages with zstd level 1 and+ uses temporary files cleaned up by the operating system when the client+ exits (#2493, part of #2427). It finishes buffered compression before+ deleting previous records, so a stage finalization error preserves the old+ records and an ordinary resume can complete the replacement. Compression+ savings depend on the data; this does not impose a disk or server-memory cap.+- `autoindex` bulk back-pressure patience is now measured since the last+ progress, not since the first round. A window the server drains a few+ records at a time (per-item 429 `resource_exhausted` on an embedding+ deadline or admission refusal) used to abort with `bulk backend failed`+ once the rounds together passed the 600 s `THROTTLE_PATIENCE`, even though+ every round settled records. Each round that settles at least one item now+ restarts the patience clock and the backoff; rounds that settle nothing+ still count, so a server that answers 429 forever fails at the same limits+ as before.+- `xerj autoindex` titles a prose file that opens with YAML frontmatter from+ its `title:` key, or from the first line after the closing `---` when there+ is none (#2556). Every such file (Jekyll, Hugo, Obsidian) used to be titled+ `---`, its opening fence. A leading `---` block that is not parseable+ frontmatter (unclosed, not a YAML mapping, over 64 KiB) takes the first line+ that is not a bare `---`; the body, the frontmatter text in it and+ `start_line` are unchanged. An unchanged file is not re-extracted, so re-index+ with `xerj autoindex --fresh` to retitle documents already in an index.## [1.0.0-rc.100] - 2026-10-26diff --cc engine/crates/xerj-autoindex/src/xc.rsindex ea72f340a,02f8ae215..1490d9910--- a/engine/crates/xerj-autoindex/src/xc.rs+++ b/engine/crates/xerj-autoindex/src/xc.rs@@@ -6315,4 -6351,176 +6359,227 @@@ precedence = ["a", "b""an escaping paths entry is refused before any directory is created");}++ /// #2486: a `paths` entry may name a file. The pandas time-series pack+ /// needs `pandas/core/resample.py` without the rest of `pandas/core`, and+ /// naming the parent directory crowds the documentation out of the top+ /// hits. A file entry checks out that file and nothing beside it: not a+ /// sibling whose name starts the same way, and not a file of the same+ /// name deeper in the tree (the pattern is anchored at the root).+ #[test]+ fn corpus_add_from_paths_harvests_a_named_file() {+ let home = tempfile::tempdir().unwrap();+ let _hold = code_home(home.path());+ let origin = home.path().join("origin");+ init_committed_repo(+ &origin,+ &[+ ("LICENSE", "bsd\n"),+ ("pkg/core/resample.py", "def resample(): pass\n"),+ ("pkg/core/resample.pyx", "cdef int x\n"),+ ("pkg/core/frame.py", "class DataFrame: pass\n"),+ ("other/pkg/core/resample.py", "def other(): pass\n"),+ ("doc/timeseries.rst", "Time series\n"),+ ],+ );+ let sha = head_sha(&origin);+ let url = origin.display().to_string();+ let manifest = home.path().join("pin.json");+ let checkout = home.path().join("corpora/sparse-demo/vulndb");++ write_pin(+ &manifest,+ &url,+ &sha,+ Some(&["pkg/core/resample.py", "doc"]),+ );+ assert_eq!(+ run_corpus_add(&["--from".into(), manifest.display().to_string()]),+ 0,+ "a paths entry naming a file must be harvested"+ );+ assert_eq!(+ worktree_files(&checkout),+ vec![+ "doc/timeseries.rst".to_string(),+ "pkg/core/resample.py".to_string(),+ ]+ );+ let recorded =+ manifest::read_corpus_manifest(&home.path().join("corpora/sparse-demo/corpus.json"))+ .unwrap();+ assert_eq!(+ recorded.repos[0].paths,+ vec!["pkg/core/resample.py".to_string(), "doc".to_string()]+ );+ assert_eq!(recorded.repos[0].files, Some(2));++ // Re-adding over the existing checkout narrows and widens it too.+ write_pin(&manifest, &url, &sha, Some(&["doc"]));+ assert_eq!(+ run_corpus_add(&["--from".into(), manifest.display().to_string()]),+ 0+ );+ assert_eq!(+ worktree_files(&checkout),+ vec!["doc/timeseries.rst".to_string()]+ );+ write_pin(&manifest, &url, &sha, Some(&["pkg/core/frame.py"]));+ assert_eq!(+ run_corpus_add(&["--from".into(), manifest.display().to_string()]),+ 0+ );+ assert_eq!(+ worktree_files(&checkout),+ vec!["pkg/core/frame.py".to_string()]+ );+ }++ /// Each tree entry kind gets its own answer, read from the mode, so a+ /// submodule is not reported as a missing path.+ #[test]+ fn confirm_paths_exist_classifies_each_entry_kind() {+ let home = tempfile::tempdir().unwrap();+ let repo = home.path().join("repo");+ init_committed_repo(&repo, &[("doc/a.rst", "a\n"), ("pkg/m.py", "x = 1\n")]);+ let first = head_sha(&repo);+ let gitlink = format!("160000,{first},vendor/sub");+ let (rc, out) = git(+ Some(&repo),+ &["update-index", "--add", "--cacheinfo", &gitlink],+ )+ .unwrap();+ assert_eq!(rc, 0, "git update-index: {out}");+ let (rc, out) = git(+ Some(&repo),+ &[+ "-c",+ "[email protected]",+ "-c",+ "user.name=xerj-test",+ "commit",+ "--quiet",+ "-m",+ "gitlink",+ ],+ )+ .unwrap();+ assert_eq!(rc, 0, "git commit: {out}");+ let sha = head_sha(&repo);+ let paths = |list: &[&str]| list.iter().map(|p| p.to_string()).collect::<Vec<_>>();++ assert_eq!(+ confirm_paths_exist(&repo, &sha, &paths(&["pkg/m.py", "doc"])).unwrap(),+ vec![PathKind::File, PathKind::Dir]+ );+ let err = confirm_paths_exist(&repo, &sha, &paths(&["vendor/sub"]))+ .unwrap_err()+ .to_string();+ assert!(err.contains("is a submodule"), "{err}");+ let err = confirm_paths_exist(&repo, &sha, &paths(&["doc/nope.rst"]))+ .unwrap_err()+ .to_string();+ assert!(err.contains("has no such path"), "{err}");+ }++ /// A symlink entry is refused end to end. Naming one would hand+ /// `corpus index` a link the manifest author chose, possibly pointing out+ /// of the checkout, so it is refused and no corpus is recorded.+ #[cfg(unix)]+ #[test]+ fn corpus_add_from_paths_refuses_a_symlink_entry() {+ let home = tempfile::tempdir().unwrap();+ let _hold = code_home(home.path());+ let origin = home.path().join("origin");+ init_committed_repo(&origin, &[("LICENSE", "bsd\n")]);+ std::os::unix::fs::symlink("/etc/hostname", origin.join("link")).unwrap();+ let (rc, out) = git(Some(&origin), &["add", "--", "link"]).unwrap();+ assert_eq!(rc, 0, "git add link: {out}");+ let (rc, out) = git(+ Some(&origin),+ &[+ "-c",+ "[email protected]",+ "-c",+ "user.name=xerj-test",+ "commit",+ "--quiet",+ "-m",+ "link",+ ],+ )+ .unwrap();+ assert_eq!(rc, 0, "git commit: {out}");+ let sha = head_sha(&origin);+ let manifest = home.path().join("pin.json");+ write_pin(+ &manifest,+ &origin.display().to_string(),+ &sha,+ Some(&["link"]),+ );+ assert_eq!(+ run_corpus_add(&["--from".into(), manifest.display().to_string()]),+ 1+ );+ assert!(+ !home.path().join("corpora/sparse-demo/corpus.json").exists(),+ "a refused symlink entry must not record a corpus"+ );+ assert!(!home+ .path()+ .join("corpora/sparse-demo/vulndb/LICENSE")+ .exists());+ }++ #[test]++ fn corpus_bad_sparse_path_preserves_existing_checkout_and_manifest() {++ let home = tempfile::tempdir().unwrap();++ let _hold = code_home(home.path());++ let origin = home.path().join("origin");++ init_committed_repo(++ &origin,++ &[++ ("doc/keep.txt", "retained content\n"),++ ("pkg/code.rs", "fn f() {}\n"),++ ],++ );++ let sha = head_sha(&origin);++ let pin = home.path().join("pin.json");++ let url = origin.display().to_string();++ write_pin(&pin, &url, &sha, Some(&["doc"]));++ let args = vec!["--from".to_string(), pin.display().to_string()];++ assert_eq!(run_corpus_add(&args), 0);++ let checkout = home.path().join("corpora/sparse-demo/vulndb");++ let manifest = home.path().join("corpora/sparse-demo/corpus.json");++ let before = std::fs::read(&manifest).unwrap();++ let index_before = std::fs::read(checkout.join(".git/index")).unwrap();++ let sparse_before = std::fs::read(checkout.join(".git/info/sparse-checkout")).unwrap();++ std::fs::write(checkout.join("local-note.txt"), "uncommitted local note").unwrap();++ write_pin(&pin, &url, &sha, Some(&["pkg/code.rs", "missing.txt"]));++ assert_eq!(run_corpus_add(&args), 1);++ assert_eq!(std::fs::read(&manifest).unwrap(), before);++ assert_eq!(++ std::fs::read(checkout.join(".git/index")).unwrap(),++ index_before++ );++ assert_eq!(++ std::fs::read(checkout.join(".git/info/sparse-checkout")).unwrap(),++ sparse_before++ );++ assert_eq!(++ std::fs::read_to_string(checkout.join("doc/keep.txt")).unwrap(),++ "retained content\n"++ );++ assert_eq!(++ std::fs::read_to_string(checkout.join("local-note.txt")).unwrap(),++ "uncommitted local note"++ );++ assert!(!checkout.join("pkg/code.rs").exists());++ assert_eq!(head_sha(&checkout), sha);++ // Correcting the path performs the requested narrower harvest.++ write_pin(&pin, &url, &sha, Some(&["pkg/code.rs"]));++ assert_eq!(run_corpus_add(&args), 0);++ assert!(checkout.join("pkg/code.rs").is_file());++ assert!(!checkout.join("doc/keep.txt").exists());++ }}