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.

10.5 KB
Raw Blame
{
  "id": "blog-the-corpus-hub",
  "title": "The Corpus Hub: pinned, licenced, signed, contributed by PR",
  "description": "A public registry of corpora for AI agents: reference code pinned to SHAs, record packs ed25519-signed, every source licence-reviewed by a human. The measured use case (2.7× fewer output tokens), the tie we published anyway, and how to contribute yours by PR.",
  "published": "2026-10-01",
  "url": "https://xerj.org/blog/the-corpus-hub",
  "body": "← ALL POSTS · /BLOG \nCORPUS HUB · PINNED · LICENCED · SIGNED · BUILT 2026-10-01 # THE CORPUS HUB: PINNED, LICENCED, SIGNED, # AND CONTRIBUTED BY PULL REQUEST \nXERJ ENGINEERING · PUBLISHED 2026-10-01 \nEvery team that points an AI agent at a body of knowledge re-solves the same four problems in private: which exact version of the sources, under what licence, whether the copy you have is the copy I have, and who vouches for the bytes. We are opening the answers as a registry: the Corpus Hub , a branch on our GitHub where corpora arrive as pull requests — source pinned to SHAs, licences reviewed by a human per source, record packs checksummed and ed25519-signed. It ships with four reference corpora, one signed daily pack, a measured use case, and one result we did not want and are publishing anyway. \nUpdate, 2026-10-06: the registry has outgrown this post. The launch four are now 100 live corpora (119 backlog rows, every live one named in the xerj-code skill's domain-selection table since rc.83) across seven categories — including non-IT domains mined from real demand: eCFR titles 12/26/29 and UK legislation — and the registry has its own site: browse every corpus with its licence verdict, pin, size, use case and measured retrieval scores at hub.xerj.org . What follows is the post as written at launch. \n01 · THE PROBLEM ## Agent context is everyone's private plumbing \nAsk five teams what their coding agent retrieves from and you get five ad-hoc pipelines: a folder of cloned repos of unknown vintage, a wiki dump, a vector store someone seeded months ago. Each works, privately, and none of them can be shared, because a shared corpus needs four things a folder does not carry: \nProperty \nWhy it matters \nHow the Hub does it \n\npinned \ntwo people must retrieve the same bytes or results are incomparable \nevery repo recorded at the full SHA the build used; moving a pin is its own PR with a reason \n\nlicenced \n\"where did this text come from and may I act on it\" is not optional the day someone pastes \na human review block per source — adapt-freely / read-don't-paste / mixed — not a detector's guess \n\nchecksummed \na corpus that silently drifts is a corpus that lies \npacks carry per-file SHA-256; corpus add refuses the pack whole on mismatch \n\nsigned \nchecksums prove integrity; only a signature proves authorship \ndetached ed25519 over SHA256SUMS, verified with --verify-sig before a record is trusted \n\nThat last row was the strangest finding of our pack work : of the vulnerability databases people pip-install and OCI-pull daily, none ships a signature a consumer can verify. The Hub does, because a corpus an agent reasons from is supply chain, and supply chain runs on authorship, not just integrity. \n02 · WHAT IS IN IT ## Two lanes: reference corpora and record packs \nReference corpora are other people's source code, cloned at pinned commits — the material for reference coding , where an agent reads how three other engines solved the problem before writing a fourth. Record packs are structured data you curate — the first is 1,950 Rust vulnerability advisories identity-resolved across osv.dev and RustSec, rebuilt and signed daily. From manifest to answer, with a local node running ( --from reads a local file, so the manifest is downloaded first): \n$ curl -fsSLO https://raw.githubusercontent.com/xerj-org/xerj/corpus-hub/tools/xerj-code/hub/xerj-storage.json $ xerj corpus add --from ./xerj-storage.json $ xerj corpus index xerj-storage $ xerj code xerj-storage \"flush epoch crash recovery\" \ncorpus \nlane \ncontents \nuse it for \n\nxerj-search \nreference \nlucene, tantivy, quickwit, meilisearch, sonic, elasticsearch \nFTS, BM25, merge policy, ES wire semantics \n\nxerj-vector \nreference \nqdrant, usearch, instant-distance, hnswlib \nHNSW construction, quantisation, filtered kNN \n\nxerj-storage \nreference \nsled, fjall, redb \nWAL, crash recovery, compaction \n\nxerj-columnar \nreference \nclickhouse \ncolumnar layout, codecs, vectorised scans \n\nrust-vulns \npack \n1,950 identity-resolved advisories, signed, daily \nvulnerability precedent, affected-function lookup \n\nThe grouping rule is the one design decision that matters: corpora are built by domain, not by language or popularity. A corpus that contains everything retrieves like a search engine with no query. The four reference corpora exist because an agent working on merge policy and an agent working on HNSW construction need different precedent — the same study that shows retrieval winning also shows the win gated by having the right precedent, not more of it. \n03 · THE USE CASE, MEASURED ## Reference coding: the same solve rate, 2.7× fewer output tokens \nThe Hub's reason to exist is the measured one. In a controlled study — 16 tasks across five languages, on libraries written for the study so no training set contains them, each carrying a runtime contract the compiler cannot warn about — an agent with XERJ reference corpora and the same agent with native file access both solved 16/16 . The difference was what it cost: \n\nnative (grep + read files) \nXERJ reference corpora \n\ntasks solved \n16/16 \n16/16 \n\noutput tokens (median) \n26,477 \n9,982 (2.7× fewer) \n\ncost \n$3.27 \n$1.58 (2.1× cheaper) \n\nRead the fine print, because it is the same fine print the next section turns into a whole experiment: on the study's two memorised public controls (tantivy; valkey + memcached), retrieval was neutral-to-harmful — the model reproduces even a 256-value quantisation table from memory. The collapse happened exactly where the agent could not have known the answer — a runtime rule like \"seal before you read\", a recovery order no compiler will tell you. Without retrieval, the same model solved 1 of 21 such tasks and burned $21.9 flailing; with native grep but no retrieval focus, one corpus had ~1.06M input tokens of file content pulled into context. \nThe pack lane answers a differently-shaped question. Reviewing code and wondering whether a pattern has precedent: \n$ xerj code rust-vulns \"smallvec insert_many buffer overflow\" \nreturns the identity-resolved advisory — one record carrying the RustSec prose, the GHSA filing, the CVE, the affected functions, the fixed versions — instead of three half-records in two databases that never talk to each other. \n04 · THE MEASUREMENT WE DID NOT WANT ## We A/B-tested the corpus on our own code. It tied. \nBefore opening a hub we ran the experiment that would justify it: two blinded arms auditing XERJ's own engine for security vulnerabilities — a plain agent, and the same agent with the rust-vulns corpus and XERJ retrieval. Same task, same turn budget, same pinned binary, two independent runs per arm, and a manual gate that re-proved every finding dynamically before counting it. Result, published in full : \n\nplain agent \ncorpus + XERJ \n\nfindings filed \n20 \n18 \n\nconfirmed exploitable (dynamic PoC) \n13 \n16 \n\nfalse positives \n1 — its only CRITICAL claim \n0 \n\ncost / wall clock \n$65.72 · 99.7 min \n$70.55 · 89.8 min \n\nfindings traceable to the corpus \n— \nzero \n\nThe corpus arm was marginally better on precision and it was never queried — one unused sweep call in one run, zero in the other. A tie, published as a tie, and then diagnosed against the pack itself: 1,963 records of advisory prose, only 14% containing any code, nothing that retrieves against a code-shaped question like \"does slicing at a byte offset inside a multi-byte character have precedent?\" — while half the pack was published after 2025, so memorisation was never the whole story. The failure was surface (nothing made retrieval the natural move), then shape (prose cannot match code), and only then size. \nThat diagnosis is now the Hub's roadmap, with pre-registered predictions : the next pack generation is code-shaped — version-pinned vulnerable functions extracted at the fix commit, before/after regression tests as trigger pairs, a bug-class taxonomy seeded from the 33 confirmed defect classes the two arms found — because we measured 9.8 extractable vulnerable functions per advisory and that is what a reviewer's question can actually retrieve against. If the re-test still ties, that gets published too. A registry whose numbers you can check is worth more than a demo. \n05 · CONTRIBUTE ## One pull request, two lanes, a licence table \nThe Hub is a branch: corpus-hub on xerj-org/xerj. Branch from it, open a PR against it, and a stdlib-only validator checks the format on every push — manifest fields, full 40-hex SHAs, licence review blocks, recipe shape, no binaries, no private keys. The full guide with templates lives in /docs/corpus-hub and in the branch's CONTRIBUTING.md . What a reviewer will actually hold you to: \nrule \nwhat it means \n\na nameable domain \nfinish the sentence \"an agent working on ___ would query this for ___\" or it is not ready \n\nun-memorised content \nretrieval's measured win is on niche, private, internal, post-cutoff material — not on famous snippets a model knows by heart \n\nhuman licence review \na review block per source with one of three verdicts: adapt-with-attribution (Apache/MIT/BSD), approach-only (AGPL/SSPL/Elastic/BUSL/GPL — read the design, never paste), or mixed \n\nno binaries in git \nrecipes and manifests only; built packs are signed Release assets a maintainer attaches after review \n\nThe licence row is where we are least flexible, because we have been burned by our own tooling: our licence detector once reported Elasticsearch as Apache-2.0 — the AGPL text contains the phrase «an \"Apache License 2.0\" compatible license» — and a detector's false \"permissive\" is how restricted code ends up pasted into an Apache-2.0 project. So the CI checks that a human review block exists ; only the reviewer's own opened licence file makes it true. \nWhat is next for the Hub itself: the code-shaped pack generation above, and the pre-indexed half — a corpus you mount instead of indexing, so a consumer's CPU is not the price of entry. Both tracked in the open. If you have a domain worth retrieving from — engine internals, protocol specs, incident postmortems, hardware errata — the branch is open."
}