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.

feat(autoindex): signed corpus packs — keygen/sign/--verify-sig + scheduled rust-vulns publish (M6)

xerj-orgd3b072fb0b24
diff --git a/.github/workflows/pack-publish.yml b/.github/workflows/pack-publish.yml
new file mode 100644
index 000000000..67d2e0611
--- /dev/null
+++ b/.github/workflows/pack-publish.yml
@@ -0,0 +1,150 @@
+# Scheduled publish of the rust-vulns corpus pack (M6 of the corpus-builder
+# arc). A pack's freshness is whatever its last build fetched — that is an
+# operational promise this workflow keeps, not a README claim: the pack's own
+# 30-day staleness refusal applies to our published corpus exactly as it does
+# to a user's reference corpora, so a build that stops here shows up as a
+# stale badge, not a silently aging artifact.
+#
+# Chain of custody, in job order:
+# build (recipe.toml, committed) → sign (PACK_SIGNING_SEED secret)
+# → verify against the COMMITTED public key → publish
+# The verify step is load-bearing: it proves the secret still matches
+# tools/packs/keys/rust-vulns.pub in the same run that publishes, so a
+# rotated key that forgot to update the .pub fails HERE instead of shipping
+# a pack no consumer can verify.
+#
+# Manual runs welcome: workflow_dispatch built the first release and rebuilds
+# after a recipe change without waiting for the cron tick.
+
+name: pack publish
+
+on:
+ schedule:
+ # daily at 04:23 UTC — off the :00/:30 marks; a vuln pack does not need
+ # minute-level freshness (sources update daily at best)
+ - cron: "23 4 * * *"
+ workflow_dispatch: {}
+
+permissions:
+ contents: write # release assets
+
+# Never two publishes at once: the release tag is rolling, and clobbering
+# uploads from concurrent runs would interleave artifacts from two builds.
+concurrency:
+ group: pack-publish
+ cancel-in-progress: false
+
+jobs:
+ rust-vulns:
+ name: build + sign + publish rust-vulns
+ runs-on: ubuntu-latest
+ timeout-minutes: 45
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b2c4a3267bf # v4.4.0
+
+ - uses: dtolnay/rust-toolchain@stable
+
+ - uses: Swatinem/rust-cache@v2
+ with:
+ workspaces: engine
+
+ # Same profile the toolkit jobs use: opt-level 3, assertions on. The
+ # binary only builds a pack here, and ci-test binaries land in
+ # target/ci-test/ (see the XERJ_BIN note in ci.yml — do not point
+ # anything at target/release/, which this job never builds).
+ - name: Build the xerj binary
+ working-directory: engine
+ run: cargo build --profile ci-test -p xerj-server
+
+ # Build state under the workspace, not /tmp: the same rule the skill
+ # teaches users. The path is fixed by the build command below:
+ # $XERJ_CODE_HOME/builds/<name>/pack/<name>/
+ - name: Build the pack
+ env:
+ XERJ_CODE_HOME: ${{ github.workspace }}/.pack-home
+ run: |
+ engine/target/ci-test/xerj corpus build rust-vulns \
+ --recipe tools/packs/rust-vulns/recipe.toml
+
+ - name: Sign the pack
+ env:
+ XERJ_CODE_HOME: ${{ github.workspace }}/.pack-home
+ PACK_SIGNING_SEED: ${{ secrets.PACK_SIGNING_SEED }}
+ run: |
+ if [ -z "$PACK_SIGNING_SEED" ]; then
+ echo "PACK_SIGNING_SEED secret is not set. Generate a keypair:"
+ echo " xerj corpus keygen --out tools/packs/keys/rust-vulns"
+ echo "commit the .pub, set the secret to the .key's hex line, delete the .key"
+ exit 1
+ fi
+ printf '%s' "$PACK_SIGNING_SEED" > "$RUNNER_TEMP/pack.key"
+ engine/target/ci-test/xerj corpus sign \
+ "$XERJ_CODE_HOME/builds/rust-vulns/pack/rust-vulns" \
+ --key "$RUNNER_TEMP/pack.key"
+ rm -f "$RUNNER_TEMP/pack.key"
+
+ # Prove the published artifact installs AND that the secret matches the
+ # committed .pub — the consumer's exact command, against the key file
+ # exactly as a consumer would fetch it from this repo.
+ - name: Verify + install the signed pack (consumer path)
+ env:
+ XERJ_CODE_HOME: ${{ github.workspace }}/.pack-home-verify
+ run: |
+ engine/target/ci-test/xerj corpus add rust-vulns \
+ --from "$GITHUB_WORKSPACE/.pack-home/builds/rust-vulns/pack/rust-vulns" \
+ --verify-sig tools/packs/keys/rust-vulns.pub
+
+ - name: Pack release metadata (freshness.json)
+ env:
+ XERJ_CODE_HOME: ${{ github.workspace }}/.pack-home
+ run: |
+ cd "$XERJ_CODE_HOME/builds/rust-vulns/pack/rust-vulns"
+ RECORDS=$(python3 -c "import json;print(json.load(open('manifest.json'))['counts']['records'])")
+ BUILT=$(python3 -c "import json;print(json.load(open('manifest.json'))['created_at'])")
+ GEN=$(python3 -c "import json;print(json.load(open('manifest.json'))['generation'])")
+ cat > "$RUNNER_TEMP/rust-vulns-freshness.json" <<EOF
+ {
+ "schemaVersion": 1,
+ "label": "rust-vulns pack",
+ "message": "$RECORDS advisories, built ${BUILT%%T*}, gen $GEN",
+ "color": "blue"
+ }
+ EOF
+
+ - name: Zip the pack
+ env:
+ XERJ_CODE_HOME: ${{ github.workspace }}/.pack-home
+ run: |
+ cd "$XERJ_CODE_HOME/builds/rust-vulns/pack/rust-vulns"
+ zip -qr "$RUNNER_TEMP/rust-vulns-pack.zip" .
+ # the checksums and signature also ship as loose assets, so a
+ # consumer can audit a download without unpacking the zip first
+ cp SHA256SUMS "$RUNNER_TEMP/rust-vulns-SHA256SUMS"
+ cp SHA256SUMS.sig "$RUNNER_TEMP/rust-vulns-SHA256SUMS.sig"
+
+ # Rolling prerelease tag: consumers pin one URL that always carries the
+ # latest build. Versioned history lives in the workflow runs and the
+ # release's previous-assets behavior (clobber replaces same-named files).
+ - name: Publish to the rolling release
+ uses: softprops/action-gh-release@v2
+ with:
+ tag_name: pack-rust-vulns
+ name: "rust-vulns corpus pack (rolling)"
+ prerelease: true
+ body: |
+ The `rust-vulns` corpus pack, built and signed by the scheduled
+ `pack publish` workflow from `tools/packs/rust-vulns/recipe.toml`.
+
+ Install (public key: `tools/packs/keys/rust-vulns.pub` in the repo):
+
+ xerj corpus add rust-vulns --from rust-vulns-pack.zip \
+ --verify-sig rust-vulns.pub
+ xerj corpus index rust-vulns
+
+ `rust-vulns-freshness.json` carries the build date and record
+ count; the badge in `tools/packs/rust-vulns/README.md` reads it.
+ files: |
+ ${{ runner.temp }}/rust-vulns-pack.zip
+ ${{ runner.temp }}/rust-vulns-SHA256SUMS
+ ${{ runner.temp }}/rust-vulns-SHA256SUMS.sig
+ ${{ runner.temp }}/rust-vulns-freshness.json
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 14b42345e..139186bcb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -58,6 +58,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
+- **`xerj corpus build` — portable, signed corpus packs, and the first one:
+ `rust-vulns`.** The records half of the corpus-hub roadmap item (#1030): a
+ declarative TOML recipe (sources with licences, identity edges, merge
+ precedence, derived fields — the tool is domain-agnostic; what a record *is*
+ lives in the recipe, never the code) drives harvest → normalize →
+ content-addressed store (file presence is the skip-already-stored dedup —
+ incremental by construction, no sync mode to get wrong) → union-find
+ identity resolution (alias chains close for free) → merge (declared scalar
+ precedence, array union, most-restrictive licence, auditable `sources[]`)
+ → a deterministic sharded pack whose manifest carries a `format_version`
+ readers refuse when unknown, per-file SHA-256 verified on
+ `xerj corpus add --from <dir|zip>`, the recipe verbatim as provenance, and
+ mapping/relation *suggestions* that are never applied. The showcase pack
+ `tools/packs/rust-vulns/` collapses 4,107 osv.dev + RustSec filings to
+ 1,950 identity-resolved records (1,221 merged from both sources) carrying
+ RustSec's curated vulnerable-function paths, which no export ships; every
+ README number is measured (`pack-stats.json`, `provenance: measured`) and
+ pinned by a test. Publishing is a separate step, never part of a build:
+ `xerj corpus keygen`/`sign` write a raw 64-byte ed25519 detached signature
+ over SHA256SUMS (the public key travels beside the recipe, never inside the
+ pack), `corpus add --verify-sig <pubkey>` checks origin *before* anything is
+ materialized, and a scheduled workflow rebuilds, signs, and publishes the
+ pack to a rolling GitHub Release — verifying its own output against the
+ committed `.pub` first, so a half-rotated key fails the build. The attack
+ the signature exists for is pinned by a test: a self-consistent rebuild
+ (tampered records, honestly rewritten checksums) passes every checksum and
+ fails the signature. No vulnerability database in our prior-art survey
+ ships a consumer-verifiable signature. (PRs
+ [#1046](https://github.com/xerj-org/xerj/pull/1046) and
+ [#1047](https://github.com/xerj-org/xerj/pull/1047) for the builder and
+ showcase; the signing/publish half rides the M6 PR.)
- **An on-disk size harness for force-merged indexes**
(`benchmarks/index-size/`) — the measurement half of the index-size
effort (epic [#1038](https://github.com/xerj-org/xerj/issues/1038)):
diff --git a/ROADMAP.md b/ROADMAP.md
index 4e93c7202..227735bab 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -139,7 +139,7 @@ The 1.0 bar: **every public claim verified against the release binary, and every
- **A real object-storage backend.** *Done in rc.77:* [#965](https://github.com/xerj-org/xerj/issues/965) wired the segment path to object storage — `storage.backend = "s3"` packs each segment family into one immutable ZBM1 bundle object with `snapshot.json` as the publication point, merges publish before retiring inputs, and a fresh node adopts the bucket (see *Shipping today* for the full statement). The client (`s3.rs`, real S3-compatible: Cloudflare R2, MinIO, AWS S3), the read-through segment cache, per-request cost accounting by billing class and the stop-don't-warn budget had landed in rc.75. Separately, `xerj autoindex s3://bucket/prefix` reads documents OUT of a bucket, which is a source, not a home.
- **A block index mode for logs.** An index mode for log-shaped data that stores rows in time-partitioned columnar blocks and skips whole blocks by their min/max metadata, instead of building a per-term inverted index over every field. *Today:* the `xerj-logs` crate implements that design (columnar encoding, log-template extraction, time-range queries with block skipping, retention), is compiled into `xerj-engine` and `xerj-server` as a dependency, and is **called from no non-test code**. Log-shaped analytics run through the general columnar segment format and the aggregation suite. Wire it behind an explicit index setting and measure it against the general path on the same data, or remove it — the *Log-analytics data path* theme below is this same item.
- **User-code ingest plugins.** *Today:* the ingest pipeline's transforms are built-in native Rust plugins — rename, drop, add, JSON parse, timestamp parse, PII redaction, grok, route — and they do run on `_bulk`. The crate is named `xerj-wasm`, but **the wasmtime backend is not in the tree**: there is no `wasmtime` dependency and no `wasm` feature, only a note that one could be added behind the same trait. Planned: a sandboxed runtime for user-supplied transforms with fuel and memory limits and no ambient filesystem or network access. Until then the refusal rule holds: a pipeline naming a processor this build does not implement is stored as unrunnable and every ingest through it is refused, never quietly run as a shorter pipeline.
-- **A corpus hub of signed, pre-indexed packs.** Download a reference corpus — a standard library, a specification set — already indexed, and mount it, instead of every user spending the same CPU-hours indexing the same public text. *Today:* the **records half is built** — `xerj corpus build` (PR [#1046](https://github.com/xerj-org/xerj/pull/1046)) turns a declarative recipe (sources with licences, identity edges, merge precedence, derived fields) into a checksummed portable pack of *records* with a `format_version` readers refuse when unknown, per-file checksums verified on `corpus add --from <pack>`, and licence + provenance on every record; the first real pack is `rust-vulns` (`tools/packs/rust-vulns/`, identity-resolved across osv.dev and RustSec, with a test pinning its README numbers to a measured build). Still unbuilt: the **detached signature** (checksums ship today; signing is the next milestone), the hub itself, and the **pre-indexed** half — [#1030](https://github.com/xerj-org/xerj/issues/1030) remains the tracker for the indexed-segment bundle that is the format this item would distribute, since indexing a records pack still costs each consumer the same CPU-hours. Three risks decide whether the rest ships: **redistribution licence** (an index is a derived copy of its source text — a pack may carry only what its licence lets us redistribute, which excludes much of what people most want indexed; the builder carries licence as record data and the pack author owns the choice); **pack safety** (a pack is untrusted input to the segment readers, so it needs the fuzzing the on-disk formats get, and a signature proves who built a pack, not that it is safe to open); and **format stability** (a published pack outlives the release that built it, so the pack format needs a compatibility promise the internal segment format has never had to make).
+- **A corpus hub of signed, pre-indexed packs.** Download a reference corpus — a standard library, a specification set — already indexed, and mount it, instead of every user spending the same CPU-hours indexing the same public text. *Today:* the **records half is built and signed** — `xerj corpus build` (PR [#1046](https://github.com/xerj-org/xerj/pull/1046)) turns a declarative recipe (sources with licences, identity edges, merge precedence, derived fields) into a checksummed portable pack of *records* with a `format_version` readers refuse when unknown, per-file checksums verified on `corpus add --from <pack>`, and licence + provenance on every record; the first real pack is `rust-vulns` (`tools/packs/rust-vulns/`, identity-resolved across osv.dev and RustSec, with a test pinning its README numbers to a measured build), published by a scheduled workflow as a rolling GitHub Release with a **detached ed25519 signature** over SHA256SUMS (`xerj corpus keygen`/`sign`; `corpus add --verify-sig <pubkey>` checks origin before anything is indexed — the public key travels beside the recipe, never inside the pack; nobody in the prior-art survey signs their database). Still unbuilt: the **hub itself** (a directory of packs beyond this first one) and the **pre-indexed** half — [#1030](https://github.com/xerj-org/xerj/issues/1030) remains the tracker for the indexed-segment bundle that is the format this item would distribute, since indexing a records pack still costs each consumer the same CPU-hours. Three risks decide whether the rest ships: **redistribution licence** (an index is a derived copy of its source text — a pack may carry only what its licence lets us redistribute, which excludes much of what people most want indexed; the builder carries licence as record data and the pack author owns the choice); **pack safety** (a pack is untrusted input to the segment readers, so it needs the fuzzing the on-disk formats get, and a signature proves who built a pack, not that it is safe to open); and **format stability** (a published pack outlives the release that built it, so the pack format needs a compatibility promise the internal segment format has never had to make).
## Beyond 1.0 — themes
diff --git a/docs/CORPUS_PACKS.md b/docs/CORPUS_PACKS.md
new file mode 100644
index 000000000..8a6638311
--- /dev/null
+++ b/docs/CORPUS_PACKS.md
@@ -0,0 +1,178 @@
+# Corpus packs — build, sign, publish, consume
+
+A **corpus pack** is a portable directory of records — advisories, datasets,
+any structured data, not source code — built by a declarative *recipe*, with
+per-file checksums, licence and provenance on every record, and an optional
+**detached ed25519 signature** that proves who built it. Install one with
+`xerj corpus add --from <pack>` and it becomes a reference corpus that
+`xerj code` and plain ES-compat search both query.
+
+This is the records half of the "corpus hub" roadmap item: the pack carries
+*records*, and indexing them still costs each consumer CPU-hours — the
+pre-indexed half is tracked separately ([#1030](https://github.com/xerj-org/xerj/issues/1030)).
+
+The tool is **domain-agnostic by design**: what a record is, which fields are
+identity, and how duplicates merge all live in the recipe, never in the code.
+One recipe indexes advisories, another would index mail or genomes. Licence
+terms ride along as record data; the tool does not enforce them — the pack
+author owns what goes in a pack.
+
+Every statement below points at the code that makes it true:
+
+| Area | File |
+|---|---|
+| Pipeline orchestration, `corpus build` CLI | `engine/crates/xerj-autoindex/src/harvest/mod.rs` |
+| Recipe parsing + strict validation | `engine/crates/xerj-autoindex/src/harvest/recipe.rs` |
+| Source adapters (`dir`, `http-zip`, `git`) | `engine/crates/xerj-autoindex/src/harvest/source.rs` |
+| Input-format normalisation (`osv`, `rustsec-md`, `flat`) | `engine/crates/xerj-autoindex/src/harvest/normalize.rs` |
+| Content-addressed store (presence = dedup) | `engine/crates/xerj-autoindex/src/harvest/store.rs` |
+| Union-find identity resolution | `engine/crates/xerj-autoindex/src/harvest/identity.rs` |
+| Deterministic pack emit + checksums | `engine/crates/xerj-autoindex/src/harvest/pack.rs` |
+| Mapping/relation suggestions | `engine/crates/xerj-autoindex/src/harvest/suggest.rs` |
+| ed25519 keygen / sign / verify | `engine/crates/xerj-autoindex/src/harvest/sign.rs` |
+| `corpus add --from <pack>` + `--verify-sig` | `engine/crates/xerj-autoindex/src/xc.rs` |
+| Claims pinned to a measured build | `engine/crates/xerj-autoindex/tests/pack_claims.rs` |
+| Showcase recipe + stats | `tools/packs/rust-vulns/` |
+| Scheduled build/sign/publish | `.github/workflows/pack-publish.yml` |
+
+## Quick start
+
+```sh
+# consume the published, signed rust-vulns pack (see its README for the
+# exact curl lines) — verification refuses the pack whole on a bad signature:
+xerj corpus add rust-vulns --from rust-vulns-pack.zip --verify-sig rust-vulns.pub
+xerj corpus index rust-vulns
+xerj code rust-vulns "smallvec insert_many buffer overflow"
+
+# or build the same pack yourself — the recipe is the whole build:
+xerj corpus build rust-vulns --recipe tools/packs/rust-vulns/recipe.toml
+xerj corpus add rust-vulns --from ~/.xerj-code/builds/rust-vulns/pack/rust-vulns
+```
+
+## The recipe
+
+A recipe is a commented TOML file — licence reasoning belongs in comments, and
+the recipe ships verbatim inside the pack as provenance. Sections:
+
+- `[[sources]]` — `slug`, `kind` (`dir` | `http-zip` | `git`), `url`/`path`,
+ `format` (the normalisation adapter), `licence`, optional `glob` and
+ watermark. Sources are advisory-listed upstream trees, HTTP zip exports, or
+ git repos fetched shallow at a pinned ref.
+- `[envelope]` — which normalised fields become the universal envelope:
+ `id_from`, `title_from`, `body_join`, `defs_from`. `defs` (space-joined
+ symbol paths) is what feeds `xerj code`'s definition search.
+- `[identity]` — `edges` over field values (`{ field = "id" }`, or
+ `{ field = "aliases", each = true }` to union on every array element) and
+ `canonical_source_order`, which decides the canonical id when sources
+ disagree. Union-find closes alias chains for free: A↔CVE↔B merges A and B
+ even with no direct A↔B edge.
+- `[merge]` — `precedence` (which source wins a disagreeing scalar; arrays are
+ always unioned, never chosen). The merged record's `licence` is the most
+ restrictive of its contributing sources, and `sources[]` names them all.
+- `[[derived]]` — pure post-merge ops (`regex_extract`, `present`, …) for
+ fields like `cve_ids` or `is_withdrawn`.
+- `[emit]` — pack shape (`shards`).
+
+Validation is strict: an unknown key is a loud error, not a silent ignore.
+
+The full example, with per-source licence reasoning in comments, is
+[`tools/packs/rust-vulns/recipe.toml`](../tools/packs/rust-vulns/recipe.toml).
+
+## Incremental by construction
+
+There is no `--sync` mode to get wrong. Every normalised record is stored at
+`store/<slug>.<xxh3-of-canonical-json>.json`; a re-run recomputes the key,
+sees the file, and skips. Only genuinely new or changed records are written,
+and the pack is re-emitted deterministically (fixed shard count, records
+ordered by id, a uniform key set on every record) from whatever the store
+holds. `--fresh` discards the build state for a full re-harvest.
+
+Build state lives under `~/.xerj-code/builds/<name>/` (override the root with
+`XERJ_CODE_HOME`) — persistent across reboots, never under `/tmp`.
+
+## The pack format
+
+```
+pack/<name>/
+ manifest.json # format_version (readers refuse unknown), counts,
+ # sources + watermarks, per-file sha256
+ records-*.jsonl # the records, sharded by hash(id), id-ordered
+ recipe.toml # verbatim, as provenance
+ mapping.suggested.json # suggested field mapping — never applied
+ suggestions.md # human-readable suggestions + join candidates
+ relations.jsonl # candidate relations with cardinality
+ SHA256SUMS # sha256 of every file above
+ SHA256SUMS.sig # optional: raw 64-byte ed25519 over SHA256SUMS
+```
+
+`corpus add --from <pack>` verifies every checksum before anything is
+materialized, and refuses an unknown `format_version` outright — a published
+pack outlives the release that built it, so readers gate on the version they
+were written for. The suggestions are **suggestions, not decisions**: the
+index infers the real mapping at index time, as it does for any folder.
+
+## Signatures
+
+Checksums prove a pack arrived intact. A signature proves **who built it**.
+The two answer different attacks, and the difference is pinned by a test: a
+self-consistent rebuild (tampered records with honestly rewritten checksums)
+passes every checksum and fails the signature — that is the attack the
+signature exists for.
+
+```sh
+# keygen: writes <prefix>.key (SECRET — the seed) and <prefix>.pub
+xerj corpus keygen --out rust-vulns
+
+# sign (CI or wherever the seed lives; the build itself never signs)
+xerj corpus sign <pack-dir> --key rust-vulns.key
+
+# verify on the way in — before anything is materialized or indexed
+xerj corpus add <name> --from <pack> --verify-sig rust-vulns.pub
+```
+
+Design rules, each load-bearing:
+
+- **The public key travels out of band** — committed beside the recipe, listed
+ on the project site, never inside the pack. A key shipped beside its own
+ signature verifies nothing.
+- **Build ≠ publish.** `corpus build` emits; it never signs. The seed exists
+ only where signing happens (a CI secret in our workflow), and the workflow
+ verifies its own output against the committed `.pub` before publishing — a
+ half-rotated key fails the build instead of shipping an unverifiable pack.
+- **The signature covers SHA256SUMS**, which covers every pack file; the
+ signature itself is deliberately not listed in SUMS (it would be circular).
+- **A signature proves origin, not safety.** A verified pack is exactly what
+ the key holder built — indexing it is still your decision, and a pack
+ remains untrusted input to the same degree an indexed folder is.
+
+The released pack is signed with a single v1 release key; the rotation
+procedure is in
+[`tools/packs/rust-vulns/README.md`](../tools/packs/rust-vulns/README.md#signatures-and-key-rotation).
+
+## Publishing
+
+The [pack publish workflow](../.github/workflows/pack-publish.yml) rebuilds
+and signs `rust-vulns` daily and attaches the zip, the loose checksums, the
+signature, and a freshness badge file to a rolling GitHub Release
+([pack-rust-vulns](https://github.com/xerj-org/xerj/releases/tag/pack-rust-vulns)).
+Freshness is an operational promise the schedule keeps, not a README claim:
+the pack's own 30-day staleness refusal applies to our published corpus
+exactly as it does to a user's reference corpora.
+
+Publishing your own pack needs none of this — a pack directory is
+self-contained, and `corpus add --from <dir|zip>` is the whole install. The
+release machinery exists because *our* pack promises freshness.
+
+## Honest limits
+
+- **Indexing still costs each consumer the same CPU-hours.** The pack
+ distributes records, not a built index — the pre-indexed half is
+ [#1030](https://github.com/xerj-org/xerj/issues/1030).
+- **A pack is only as good as its sources and its recipe.** Identity
+ resolution merges what the recipe's edges say to merge; a wrong edge is a
+ wrong merge, visibly, in `sources[]`.
+- **Not a security product.** The showcase pack is a searchable corpus of
+ advisories, not a scanner, and makes no completeness claim beyond "what its
+ sources carried at build time".
+- **The suggester never mutates records.** Field types, joins and relations
+ are hints computed from a sample; the index decides at index time.
diff --git a/engine/Cargo.lock b/engine/Cargo.lock
index c54bca2bf..0989546b2 100644
--- a/engine/Cargo.lock
+++ b/engine/Cargo.lock
@@ -7313,6 +7313,7 @@ dependencies = [
"rayon",
"regex",
"reqwest",
+ "ring",
"rusqlite",
"serde",
"serde_json",
diff --git a/engine/Cargo.toml b/engine/Cargo.toml
index 7630b646b..d36ade267 100644
--- a/engine/Cargo.toml
+++ b/engine/Cargo.toml
@@ -77,6 +77,9 @@ rustc-hash = "2"
crc32fast = "1"
# Crypto/Random
rand = "0.8"
+# ed25519 pack signatures (harvest/sign.rs); same crate the TLS stack uses,
+# so it adds no new native build to the binary.
+ring = "0.17"
# Bytes
bytes = "1"
memmap2 = "0.9"
diff --git a/engine/crates/xerj-autoindex/Cargo.toml b/engine/crates/xerj-autoindex/Cargo.toml
index cf9de8042..7feee60ca 100644
--- a/engine/crates/xerj-autoindex/Cargo.toml
+++ b/engine/crates/xerj-autoindex/Cargo.toml
@@ -58,6 +58,11 @@ reqwest = { workspace = true, features = ["blocking"] }
# needs exactly two S3 verbs. See objwatch/s3.rs for why not the SDK.
sha2 = "0.10"
hmac = "0.12"
+# ed25519 detached signatures over pack SHA256SUMS (`harvest/sign.rs`).
+# Already in the lock file via the TLS stack (rustls→ring 0.17), so this adds
+# no new native build; here it is only a direct dependency of the corpus-pack
+# publish/verify path.
+ring.workspace = true
# --- AST code extraction (tree-sitter). Grammars expose a tree-sitter-language
diff --git a/engine/crates/xerj-autoindex/src/harvest/mod.rs b/engine/crates/xerj-autoindex/src/harvest/mod.rs
index 5886e6d91..279dbb5f9 100644
--- a/engine/crates/xerj-autoindex/src/harvest/mod.rs
+++ b/engine/crates/xerj-autoindex/src/harvest/mod.rs
@@ -10,6 +10,11 @@
//! ─→ merge (precedence + array union + strictest licence)
//! ─→ suggest (mapping + join-key hints from a sample — never applied)
//! ─→ pack (deterministic sharded JSONL + manifest + SUMS)
+//!
+//! Publishing is a separate step, never part of a build:
+//! `xerj corpus sign <pack-dir> --key <seed-file>` writes the detached
+//! ed25519 signature over SHA256SUMS (see `sign.rs`); `xerj corpus add
+//! --from <pack> --verify-sig <pubkey-file>` checks it on the way in.
//! ```
//!
//! Incrementality is not a mode, it is the storage layout: every normalized
@@ -29,6 +34,7 @@ pub mod identity;
pub mod normalize;
pub mod pack;
pub mod recipe;
+pub mod sign;
pub mod source;
pub mod store;
pub mod suggest;
diff --git a/engine/crates/xerj-autoindex/src/harvest/sign.rs b/engine/crates/xerj-autoindex/src/harvest/sign.rs
new file mode 100644
index 000000000..f7fa4184f
--- /dev/null
+++ b/engine/crates/xerj-autoindex/src/harvest/sign.rs
@@ -0,0 +1,439 @@
+//! Detached ed25519 signatures over a pack's SHA256SUMS — the publish half
+//! of the pack format.
+//!
+//! Checksums (M1) prove a pack arrived intact; a signature proves WHO built
+//! it. That distinction is the whole design: SHA256SUMS re-hashing catches
+//! corruption and lazy tampering, but an attacker who rebuilds a pack
+//! self-consistently produces valid checksums for malicious records — the
+//! case `read_manifest`'s tests explicitly left to "a later milestone",
+//! which is this file. Every prior-art vulnerability database surveyed at
+//! design time (Trivy DB, Grype/vunnel, PrimeVul) ships unsigned; this is
+//! the open lane, not table stakes.
+//!
+//! The trust model, stated plainly:
+//!
+//! - The **public** key travels out of band — committed next to the pack
+//! recipe in this repo, and on xerj.org — never inside the pack (a key
+//! shipped beside its own signature verifies nothing).
+//! - The **seed** lives only in CI's secrets; `corpus build` never sees it.
+//! Signing is a separate `corpus sign` step so a local build and a
+//! published build differ by exactly one file.
+//! - v1 is a single release key. Rotation is by re-publishing under a new
+//! key and updating the two public locations; consumers pin the file they
+//! fetched, and the README says so.
+//!
+//! Format, deliberately boring: `SHA256SUMS.sig` is the RAW 64-byte ed25519
+//! signature of SHA256SUMS' exact bytes. No armored envelopes, no trusted
+//! comments — a consumer with any ed25519 implementation can verify the
+//! bytes without this crate. The `.sig` file is intentionally absent from
+//! SHA256SUMS itself (it signs that file; covering it would be circular) —
+//! `read_manifest` only re-hashes files the SUMS names, so the signature
+//! rides in a pack dir or zip without breaking older readers.
+
+use std::path::{Path, PathBuf};
+
+use anyhow::{bail, Context, Result};
+use ring::rand::SecureRandom;
+use ring::signature::{Ed25519KeyPair, KeyPair, UnparsedPublicKey};
+
+/// The signature file name inside a pack directory.
+pub const SIG_NAME: &str = "SHA256SUMS.sig";
+
+/// Generate a fresh ed25519 keypair as (seed_hex, public_hex) — 32 bytes
+/// each, lower-case hex. The seed is everything an attacker needs: it goes
+/// to CI secrets and nowhere else; the public half is published.
+pub fn generate_keypair() -> Result<(String, String)> {
+ let mut seed = [0u8; 32];
+ ring::rand::SystemRandom::new()
+ .fill(&mut seed)
+ .map_err(|_| anyhow::anyhow!("key generation failed (no entropy source?)"))?;
+ let pair = Ed25519KeyPair::from_seed_unchecked(&seed)
+ .map_err(|_| anyhow::anyhow!("a fresh 32-byte seed is always valid — ring disagrees"))?;
+ Ok((hex(&seed), hex(pair.public_key().as_ref())))
+}
+
+/// Sign `<pack>/SHA256SUMS` with a seed file, writing `<pack>/SHA256SUMS.sig`.
+/// Refuses to sign a pack whose SUMS is missing (nothing to sign) and
+/// overwrites a previous `.sig` — re-signing a rebuilt pack is the normal
+/// publish step, and a stale signature would fail verification anyway.
+pub fn sign_pack(pack_dir: &Path, seed_hex: &str) -> Result<()> {
+ let sums = pack_dir.join("SHA256SUMS");
+ let msg = std::fs::read(&sums).with_context(|| format!("read {}", sums.display()))?;
+ let seed = parse_key(seed_hex, 32, "seed")?;
+ let pair = Ed25519KeyPair::from_seed_unchecked(&seed)
+ .map_err(|_| anyhow::anyhow!("seed is not a valid ed25519 key"))?;
+ let sig = pair.sign(&msg);
+ let out = pack_dir.join(SIG_NAME);
+ std::fs::write(&out, sig.as_ref()).with_context(|| format!("write {}", out.display()))?;
+ println!(
+ "signed {} ({} byte signature over SHA256SUMS)",
+ out.display(),
+ sig.as_ref().len()
+ );
+ Ok(())
+}
+
+/// Verify `<pack>/SHA256SUMS.sig` against a public-key file. The signature
+/// chain is: sig → SHA256SUMS → every file the SUMS names, so verifying here
+/// plus `read_manifest`'s re-hashing proves both integrity and origin.
+/// `verify_pack` is called BEFORE the pack is materialized, so a failure
+/// means nothing was indexed.
+pub fn verify_pack(pack_dir: &Path, public_hex: &str) -> Result<()> {
+ let at = |what: &str| format!("{}: {what}", pack_dir.display());
+ let sig_path = pack_dir.join(SIG_NAME);
+ let sig = std::fs::read(&sig_path).with_context(|| at("no SHA256SUMS.sig to verify"))?;
+ if sig.len() != 64 {
+ bail!(at(&format!(
+ "{SIG_NAME} is {} bytes, expected a 64-byte ed25519 signature",
+ sig.len()
+ )));
+ }
+ let public = parse_key(public_hex, 32, "public key")?;
+ let msg =
+ std::fs::read(pack_dir.join("SHA256SUMS")).with_context(|| at("cannot read SHA256SUMS"))?;
+ let key = UnparsedPublicKey::new(&ring::signature::ED25519, &public);
+ key.verify(&msg, &sig).map_err(|_| {
+ anyhow::anyhow!(at(
+ "signature does not verify — the pack is not from the holder of the expected key, \
+ or SHA256SUMS changed after signing"
+ ))
+ })?;
+ Ok(())
+}
+
+/// True when the pack dir carries a signature file (the `corpus add` hint:
+/// "this pack is signed; pass --verify-sig" — presence is public metadata,
+/// verification is the consumer's explicit choice).
+pub fn pack_is_signed(pack_dir: &Path) -> bool {
+ pack_dir.join(SIG_NAME).is_file()
+}
+
+// ── CLI: `xerj corpus keygen`, `xerj corpus sign` ───────────────────────────
+
+const KEYGEN_USAGE: &str = "usage: xerj corpus keygen --out <prefix>
+
+writes <prefix>.key (the 32-byte ed25519 seed, hex — SECRET) and <prefix>.pub
+(the verifying key, hex — publish this). Keep the .key out of the repo and out
+of logs; it goes to CI secrets and nowhere else.";
+
+const SIGN_USAGE: &str = "usage: xerj corpus sign <pack-dir> --key <seed-file>
+
+writes <pack-dir>/SHA256SUMS.sig, a detached ed25519 signature over the pack's
+SHA256SUMS (which covers every pack file). Re-signing overwrites. The pack's
+checksums stay untouched — signing is a publish step, never a rebuild.";
+
+/// Entry point for `xerj corpus keygen|sign <args>` from the dispatcher.
+pub fn run_sign_cli(sub: &str, args: &[String]) -> i32 {
+ match sub {
+ "keygen" => run_keygen(args),
+ "sign" => run_sign(args),
+ _ => unreachable!("dispatcher routes only keygen|sign here"),
+ }
+}
+
+fn run_keygen(args: &[String]) -> i32 {
+ let mut out: Option<PathBuf> = None;
+ let mut i = 0;
+ while i < args.len() {
+ match args[i].as_str() {
+ "-h" | "--help" => {
+ println!("{KEYGEN_USAGE}");
+ return 0;
+ }
+ "--out" => match args.get(i + 1) {
+ Some(v) => {
+ out = Some(PathBuf::from(v));
+ i += 1;
+ }
+ None => {
+ eprintln!("xerj corpus keygen: --out needs a path prefix\n\n{KEYGEN_USAGE}");
+ return 2;
+ }
+ },
+ a => {
+ eprintln!("xerj corpus keygen: unexpected argument '{a}'\n\n{KEYGEN_USAGE}");
+ return 2;
+ }
+ }
+ i += 1;
+ }
+ let Some(prefix) = out else {
+ eprintln!("xerj corpus keygen: --out is required\n\n{KEYGEN_USAGE}");
+ return 2;
+ };
+ match generate_keypair() {
+ Ok((seed, public)) => {
+ let key_path = format!("{}.key", prefix.display());
+ if Path::new(&key_path).exists() {
+ eprintln!(
+ "xerj corpus keygen: {key_path} already exists — refusing to overwrite a key"
+ );
+ return 1;
+ }
+ // the documented first run names a directory that does not exist
+ // yet (`--out tools/packs/keys/<name>`) — create it rather than
+ // make the user mkdir by hand
+ if let Some(parent) = Path::new(&key_path).parent() {
+ if let Err(e) = std::fs::create_dir_all(parent) {
+ eprintln!(
+ "xerj corpus keygen: cannot create {}: {e}",
+ parent.display()
+ );
+ return 1;
+ }
+ }
+ if let Err(e) = std::fs::write(&key_path, format!("{seed}\n")).and_then(|_| {
+ std::fs::write(format!("{}.pub", prefix.display()), format!("{public}\n"))
+ }) {
+ eprintln!("xerj corpus keygen: cannot write key files: {e}");
+ return 1;
+ }
+ println!("wrote {key_path} (SECRET — CI secret material, never commit)");
+ println!(
+ "wrote {}.pub (verifying key — publish next to the pack)",
+ prefix.display()
+ );
+ 0
+ }
+ Err(e) => {
+ eprintln!("xerj corpus keygen: {e:#}");
+ 1
+ }
+ }
+}
+
+fn run_sign(args: &[String]) -> i32 {
+ let mut pack: Option<PathBuf> = None;
+ let mut key: Option<PathBuf> = None;
+ let mut i = 0;
+ while i < args.len() {
+ match args[i].as_str() {
+ "-h" | "--help" => {
+ println!("{SIGN_USAGE}");
+ return 0;
+ }
+ "--key" => match args.get(i + 1) {
+ Some(v) => {
+ key = Some(PathBuf::from(v));
+ i += 1;
+ }
+ None => {
+ eprintln!("xerj corpus sign: --key needs a seed file\n\n{SIGN_USAGE}");
+ return 2;
+ }
+ },
+ a if a.starts_with('-') => {
+ eprintln!("xerj corpus sign: unknown flag '{a}'\n\n{SIGN_USAGE}");
+ return 2;
+ }
+ a => {
+ if pack.is_some() {
+ eprintln!("xerj corpus sign: one <pack-dir>, not two\n\n{SIGN_USAGE}");
+ return 2;
+ }
+ pack = Some(PathBuf::from(a));
+ }
+ }
+ i += 1;
+ }
+ let (Some(pack), Some(key)) = (pack, key) else {
+ eprintln!(
+ "xerj corpus sign: <pack-dir> and --key <seed-file> are both required\n\n{SIGN_USAGE}"
+ );
+ return 2;
+ };
+ let seed = match std::fs::read_to_string(&key) {
+ Ok(s) => s,
+ Err(e) => {
+ eprintln!("xerj corpus sign: cannot read {}: {e}", key.display());
+ return 1;
+ }
+ };
+ match sign_pack(&pack, &seed) {
+ Ok(()) => 0,
+ Err(e) => {
+ eprintln!("xerj corpus sign: {e:#}");
+ 1
+ }
+ }
+}
+
+// ── key encoding helpers ────────────────────────────────────────────────────
+
+/// Decode hex of an exact byte length, with a name for the error message.
+/// The keys are 32 raw bytes in hex (64 chars) — not PEM, not pkcs8 — so a
+/// public key file is copy-pasteable in an issue thread and diffable in a
+/// repo.
+fn parse_key(hex: &str, want: usize, what: &str) -> Result<Vec<u8>> {
+ let t = hex.trim();
+ if t.len() != want * 2 || !t.chars().all(|c| c.is_ascii_hexdigit()) {
+ bail!(
+ "{what} must be {want} bytes as {want}×2 hex chars (got {} chars)",
+ t.len()
+ );
+ }
+ (0..want)
+ .map(|i| u8::from_str_radix(&t[i * 2..i * 2 + 2], 16).map_err(|e| anyhow::anyhow!("{e}")))
+ .collect()
+}
+
+fn hex(bytes: &[u8]) -> String {
+ bytes.iter().map(|b| format!("{b:02x}")).collect()
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::harvest::pack;
+ use crate::harvest::recipe::{Emit, Envelope, Identity, Merge, Suggest};
+ use serde_json::{json, Map};
+ use sha2::Digest;
+
+ fn tiny_pack(dir: &Path) -> PathBuf {
+ let recipe = crate::harvest::recipe::Recipe {
+ name: "t".into(),
+ description: String::new(),
+ envelope: Envelope {
+ id_from: vec!["id".into()],
+ title_from: vec!["id".into()],
+ body_join: vec![],
+ defs_from: vec![],
+ passthrough: false,
+ },
+ sources: vec![],
+ identity: Identity {
+ edges: vec![],
+ canonical_source_order: vec![],
+ },
+ merge: Merge::default(),
+ derived: vec![],
+ emit: Emit { shards: 1 },
+ suggest: Suggest { sample: 64 },
+ };
+ let mut rec = Map::new();
+ rec.insert("id".into(), json!("a"));
+ let records = vec![rec];
+ let stats = pack::RunStats {
+ envelopes: 1,
+ per_source: vec![pack::SourceStat {
+ slug: "s".into(),
+ kind: "dir".into(),
+ path: None,
+ url: None,
+ licence: "CC0-1.0".into(),
+ watermark: None,
+ unchanged: false,
+ records: 1,
+ new: 1,
+ skipped: 0,
+ pruned: 0,
+ }],
+ };
+ let sugg = crate::harvest::suggest::analyze(&records, 64);
+ pack::emit(dir, &recipe, "# r\n", records, &stats, &sugg)
+ .unwrap()
+ .dir
+ }
+
+ #[test]
+ fn sign_then_verify_round_trips_on_a_real_pack() {
+ let tmp = tempfile::tempdir().unwrap();
+ let pack_dir = tiny_pack(tmp.path());
+ let (seed, public) = generate_keypair().unwrap();
+ sign_pack(&pack_dir, &seed).unwrap();
+ assert!(pack_is_signed(&pack_dir));
+ // the signed pack still passes checksum verification (the .sig file
+ // is not SUMS-covered, by design, and read_manifest ignores it)
+ pack::read_manifest(&pack_dir).unwrap();
+ verify_pack(&pack_dir, &public).unwrap();
+ // and a second key does NOT verify it
+ let (_, other) = generate_keypair().unwrap();
+ assert!(verify_pack(&pack_dir, &other)
+ .unwrap_err()
+ .to_string()
+ .contains("does not verify"));
+ }
+
+ #[test]
+ fn a_tampered_sums_fails_verification() {
+ // the whole point of signatures: a self-consistent REBUILD (fresh
+ // checksums over changed records) has valid checksums, and only the
+ // signature catches it.
+ let tmp = tempfile::tempdir().unwrap();
+ let pack_dir = tiny_pack(tmp.path());
+ let (seed, public) = generate_keypair().unwrap();
+ sign_pack(&pack_dir, &seed).unwrap();
+ // replace a record file AND rewrite SUMS so checksums agree — the
+ // scenario read_manifest cannot catch
+ let sums = std::fs::read_to_string(pack_dir.join("SHA256SUMS")).unwrap();
+ let fname = sums
+ .lines()
+ .find(|l| l.ends_with("recipe.toml"))
+ .unwrap()
+ .split_once(" ")
+ .unwrap()
+ .1
+ .to_string();
+ std::fs::write(pack_dir.join(&fname), "# tampered recipe\n").unwrap();
+ let mut new_sums = String::new();
+ for line in sums.lines() {
+ if line.ends_with(&fname) {
+ let d = sha2::Sha256::digest(b"# tampered recipe\n");
+ new_sums.push_str(&hex(&d));
+ new_sums.push_str(" ");
+ new_sums.push_str(&fname);
+ new_sums.push('\n');
+ } else {
+ new_sums.push_str(line);
+ new_sums.push('\n');
+ }
+ }
+ std::fs::write(pack_dir.join("SHA256SUMS"), new_sums).unwrap();
+ pack::read_manifest(&pack_dir).unwrap(); // checksums pass…
+ let err = verify_pack(&pack_dir, &public).unwrap_err().to_string();
+ assert!(err.contains("does not verify"), "{err}");
+ }
+
+ #[test]
+ fn verification_names_its_failure_modes() {
+ let tmp = tempfile::tempdir().unwrap();
+ let pack_dir = tiny_pack(tmp.path());
+ let (seed, public) = generate_keypair().unwrap();
+ // unsigned pack
+ assert!(verify_pack(&pack_dir, &public)
+ .unwrap_err()
+ .to_string()
+ .contains("no SHA256SUMS.sig"));
+ sign_pack(&pack_dir, &seed).unwrap();
+ // truncated signature
+ std::fs::write(pack_dir.join(SIG_NAME), vec![0u8; 10]).unwrap();
+ assert!(verify_pack(&pack_dir, &public)
+ .unwrap_err()
+ .to_string()
+ .contains("10 bytes"));
+ // malformed public key
+ sign_pack(&pack_dir, &seed).unwrap();
+ assert!(verify_pack(&pack_dir, "not-hex!")
+ .unwrap_err()
+ .to_string()
+ .contains("public key"));
+ }
+
+ #[test]
+ fn a_seed_determines_one_public_key() {
+ // the property keygen relies on: seed → keypair is deterministic, so
+ // the .pub derived at keygen time is the same key `sign` uses later
+ let (seed, public) = generate_keypair().unwrap();
+ let pair =
+ Ed25519KeyPair::from_seed_unchecked(&parse_key(&seed, 32, "seed").unwrap()).unwrap();
+ assert_eq!(hex(pair.public_key().as_ref()), public);
+ }
+
+ #[test]
+ fn hex_keys_are_validated_loudly() {
+ for bad in ["", "zz", &"a".repeat(63), &"a".repeat(66)] {
+ assert!(parse_key(bad, 32, "seed").is_err(), "{bad:?}");
+ }
+ assert!(parse_key(&"a".repeat(64), 32, "seed").is_ok());
+ }
+}
diff --git a/engine/crates/xerj-autoindex/src/xc.rs b/engine/crates/xerj-autoindex/src/xc.rs
index 4e60e75cd..2e4fc0e31 100644
--- a/engine/crates/xerj-autoindex/src/xc.rs
+++ b/engine/crates/xerj-autoindex/src/xc.rs
@@ -224,17 +224,21 @@ pub fn run_code_cli(args: &[String]) -> i32 {
// ── xerj corpus add ─────────────────────────────────────────────────────────
const CORPUS_USAGE: &str =
- "usage: xerj corpus add <name> <git-url>... | --from <manifest.json|pack-dir|pack.zip> [--as <name>]
+ "usage: xerj corpus add <name> <git-url>... | --from <manifest.json|pack-dir|pack.zip> [--as <name>] [--verify-sig <pubkey-file>]
xerj corpus build <name> [--recipe <path>] [--fresh]
+ xerj corpus sign <pack-dir> --key <seed-file>
+ xerj corpus keygen --out <prefix>
xerj corpus index <name> [--fresh] [--url URL]
xerj corpus list [--url URL]
clone the repos, detect licences, write corpora/<name>/corpus.json;
--from takes the corpus name from the manifest's 'corpus' field (or the
pack's 'pack' field) unless <name> or --as overrides it; a harvested pack
-also checksum-verifies and materializes records per source; build
-harvests recipe sources into a deterministic pack under builds/<name>/
-(see tools/xerj-code/);
+also checksum-verifies and materializes records per source; --verify-sig
+checks the pack's SHA256SUMS.sig against a public key file first and
+refuses the pack on failure; build harvests recipe sources into a
+deterministic pack under builds/<name>/ (see tools/xerj-code/); sign/keygen
+are the publish step (ed25519 over SHA256SUMS);
index builds/verifies/switches the corpus (exit 3 skips junk — normal);
list shows what is loaded on this node.";
@@ -331,6 +335,7 @@ fn run_corpus_add(args: &[String]) -> i32 {
let mut name: Option<String> = None;
let mut as_name: Option<String> = None;
let mut from: Option<String> = None;
+ let mut verify_sig: Option<String> = None;
let mut urls: Vec<String> = Vec::new();
let mut i = 0;
while i < args.len() {
@@ -349,6 +354,18 @@ fn run_corpus_add(args: &[String]) -> i32 {
return 2;
}
},
+ "--verify-sig" => match args.get(i + 1) {
+ Some(v) => {
+ verify_sig = Some(v.clone());
+ i += 1;
+ }
+ None => {
+ eprintln!(
+ "xerj corpus add: --verify-sig needs a public key file\n\n{CORPUS_USAGE}"
+ );
+ return 2;
+ }
+ },
"--as" => match args.get(i + 1) {
Some(v) => {
as_name = Some(v.clone());
@@ -396,7 +413,7 @@ fn run_corpus_add(args: &[String]) -> i32 {
Ok(FromPack::NotAPack) => {}
Ok(FromPack::Dir(dir)) => {
let share = dir.display().to_string();
- return run_corpus_add_pack(&dir, explicit_name, &share);
+ return run_corpus_add_pack(&dir, explicit_name, &share, verify_sig.as_deref());
}
Ok(FromPack::Zip(zip)) => {
// transient staging, never build state — it dies with this
@@ -428,7 +445,7 @@ fn run_corpus_add(args: &[String]) -> i32 {
}
}
}
- return run_corpus_add_pack(&dir, explicit_name, &zip);
+ return run_corpus_add_pack(&dir, explicit_name, &zip, verify_sig.as_deref());
}
Err(e) => {
eprintln!("xerj corpus add: {e}");
@@ -436,6 +453,12 @@ fn run_corpus_add(args: &[String]) -> i32 {
}
}
}
+ if verify_sig.is_some() {
+ eprintln!(
+ "xerj corpus add: --verify-sig applies to a harvested pack --from, not a clone\n\n{CORPUS_USAGE}"
+ );
+ return 2;
+ }
// The manifest is read BEFORE the name is finalised: with `--from` and
// no explicit <name>/--as, the manifest's own 'corpus' field supplies
// it. Everything downstream (dest, carry, entries) needs the resolved
@@ -698,7 +721,37 @@ fn resolve_pack_source(path: &str) -> Result<FromPack, String> {
/// ([`xccode::passage::locator_repo`]), so `rustsec/records.jsonl` keys the
/// same way a cloned `rustsec/` repo always did and the per-hit licence
/// warnings work unchanged.
-fn run_corpus_add_pack(pack_dir: &Path, explicit_name: Option<String>, share_path: &str) -> i32 {
+fn run_corpus_add_pack(
+ pack_dir: &Path,
+ explicit_name: Option<String>,
+ share_path: &str,
+ verify_sig: Option<&str>,
+) -> i32 {
+ // Origin check first, before a byte of the pack is trusted: checksums
+ // prove integrity, the signature proves who built it. A pack that
+ // fails here is refused whole — nothing is materialized, nothing is
+ // indexed.
+ if let Some(pubfile) = verify_sig {
+ let public = match std::fs::read_to_string(pubfile) {
+ Ok(p) => p,
+ Err(e) => {
+ eprintln!("xerj corpus add: cannot read public key {pubfile}: {e}");
+ return 2;
+ }
+ };
+ if let Err(e) = crate::harvest::sign::verify_pack(pack_dir, &public) {
+ eprintln!("xerj corpus add: {e:#}");
+ return 2;
+ }
+ println!("signature verified against {pubfile}");
+ } else if crate::harvest::sign::pack_is_signed(pack_dir) {
+ // unsigned USE of a signed pack is not an error — the key choice is
+ // the consumer's — but it deserves a nudge, not silence
+ eprintln!(
+ "note: this pack carries a SHA256SUMS.sig — pass --verify-sig <pubkey-file> to check \
+ its origin before indexing"
+ );
+ }
let meta = match crate::harvest::pack::read_manifest(pack_dir) {
Ok(m) => m,
Err(e) => {
@@ -1529,6 +1582,7 @@ pub fn run_corpus_cli(args: &[String]) -> i32 {
match sub.as_str() {
"add" => run_corpus_add(&rest),
"build" => crate::harvest::run_build(&rest),
+ "sign" | "keygen" => crate::harvest::sign::run_sign_cli(sub, &rest),
"index" => run_corpus_index(&rest),
"list" => run_corpus_list(&rest),
"-h" | "--help" | "help" => {
@@ -2306,6 +2360,53 @@ precedence = ["a", "b"]
assert_eq!(add(), 2);
}
+ #[test]
+ fn corpus_add_verifies_the_pack_signature_before_materializing() {
+ let home = tempfile::tempdir().unwrap();
+ let _h = code_home(home.path());
+ let pack = build_demo_pack(home.path());
+ let corpus = home.path().join("corpora/demo");
+
+ // sign the demo pack and publish both halves as key files
+ let (seed, public) = crate::harvest::sign::generate_keypair().unwrap();
+ crate::harvest::sign::sign_pack(&pack, &seed).unwrap();
+ let good = home.path().join("good.pub");
+ std::fs::write(&good, &public).unwrap();
+ let (_, other) = crate::harvest::sign::generate_keypair().unwrap();
+ let wrong = home.path().join("wrong.pub");
+ std::fs::write(&wrong, &other).unwrap();
+
+ let add = |key: &Path| {
+ run_corpus_add(&[
+ "--from".to_string(),
+ pack.display().to_string(),
+ "--verify-sig".to_string(),
+ key.display().to_string(),
+ ])
+ };
+
+ // the wrong key refuses the pack WHOLE: exit 2 and no corpus written
+ // — a signature failure must never leave a half-materialized corpus
+ assert_eq!(add(&wrong), 2);
+ assert!(
+ !corpus.exists(),
+ "a failed verification must not materialize anything"
+ );
+
+ // the right key installs normally
+ assert_eq!(add(&good), 0);
+ assert!(corpus.join("corpus.json").is_file());
+
+ // and the unsigned-pack hint path: rebuild without the .sig, add
+ // without --verify-sig still works (the consumer's key choice is
+ // theirs), the hint goes to stderr where the callers ignore it
+ std::fs::remove_file(pack.join(crate::harvest::sign::SIG_NAME)).unwrap();
+ assert_eq!(
+ run_corpus_add(&["--from".to_string(), pack.display().to_string()]),
+ 0
+ );
+ }
+
#[test]
fn git_arm_refuses_to_clone_onto_a_harvested_name() {
let home = tempfile::tempdir().unwrap();
diff --git a/landing/blog/index.html b/landing/blog/index.html
index 6247ddd07..8eecb0dcb 100644
--- a/landing/blog/index.html
+++ b/landing/blog/index.html
@@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>XERJ.ai — Blog: the engineering log</title>
-<meta name="description" content="Measured results with the losses left in: the Jev decisions study, the JEV rerank verdict, benchmark autopsies, and the storage formats that cut the index 28%.">
+<meta name="description" content="Measured results with the losses left in: the Jev decisions study, the JEV rerank verdict, the storage formats that cut the index 28%, and the signed rust-vulns corpus pack.">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Big+Shoulders+Display:wght@400;700;800;900&family=Inter:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap" rel="stylesheet">
@@ -16,7 +16,7 @@
<meta property="og:site_name" content="XERJ.ai">
<meta property="og:type" content="website">
<meta property="og:title" content="XERJ.ai — Blog: the engineering log">
-<meta property="og:description" content="Measured results with the losses left in: the Jev decisions study, the JEV rerank verdict, benchmark autopsies, and the storage formats that cut the index 28%.">
+<meta property="og:description" content="Measured results with the losses left in: the Jev decisions study, the JEV rerank verdict, the storage formats that cut the index 28%, and the signed rust-vulns corpus pack.">
<meta property="og:url" content="https://xerj.org/blog/">
<meta property="og:image" content="https://xerj.org/og/xerj-card.png">
<meta property="og:image:width" content="1200">
@@ -25,7 +25,7 @@
<meta property="og:locale" content="en_US">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="XERJ.ai — Blog: the engineering log">
-<meta name="twitter:description" content="Measured results with the losses left in: the Jev decisions study, the JEV rerank verdict, benchmark autopsies, and the storage formats that cut the index 28%.">
+<meta name="twitter:description" content="Measured results with the losses left in: the Jev decisions study, the JEV rerank verdict, the storage formats that cut the index 28%, and the signed rust-vulns corpus pack.">
<meta name="twitter:image" content="https://xerj.org/og/xerj-card.png">
<script type="application/ld+json">
{
@@ -59,7 +59,7 @@
"@context": "https://schema.org",
"@type": "CollectionPage",
"name": "XERJ.ai — Blog: the engineering log",
- "description": "Measured results with the losses left in: the Jev decisions study, the JEV rerank verdict, benchmark autopsies, and the storage formats that cut the index 28%.",
+ "description": "Measured results with the losses left in: the Jev decisions study, the JEV rerank verdict, the storage formats that cut the index 28%, and the signed rust-vulns corpus pack.",
"url": "https://xerj.org/blog/",
"image": "https://xerj.org/og/xerj-card.png",
"inLanguage": "en",
@@ -126,6 +126,51 @@
<!-- Reverse-chronological by hand while there is one post; new posts PREPEND.
Move to a generator only past ~10 posts. -->
<ol class="blog-list">
+ <li>
+ <a class="bl-card" href="/blog/one-vulnerability-three-names">
+ <!-- Bar widths share ONE denominator, 4,107 envelopes (the max across
+ all rows), so lengths compare across rows. Neutral bar = what the
+ two sources filed, accent bar = what identity resolution made of
+ it. Figures verbatim from the post: 4,107 envelopes → 1,950
+ records, 1,221 of them merged from both sources. -->
+ <div class="bl-preview" aria-hidden="true">
+ <div class="blp-kicker">CORPUS PACKS · 2 SOURCES · UNION-FIND · ED25519</div>
+ <div class="blp-row">
+ <div class="blp-ds">FILED</div>
+ <div class="blp-pair">
+ <span class="blp-num">4,107 <i>envelopes</i></span><span class="blp-bar b" style="width:100%"></span>
+ <span class="blp-num">osv.dev + RustSec</span><span class="blp-bar b" style="width:100%"></span>
+ </div>
+ </div>
+ <div class="blp-row">
+ <div class="blp-ds">RESOLVED</div>
+ <div class="blp-pair">
+ <span class="blp-num">1,950 <i>records</i> <span class="blp-chip">&minus;52.5%</span></span><span class="blp-bar a" style="width:47.5%"></span>
+ <span class="blp-num">1,221 <i>from both</i></span><span class="blp-bar a" style="width:29.7%"></span>
+ </div>
+ </div>
+ <div class="blp-row">
+ <div class="blp-ds">SIGNED</div>
+ <div class="blp-pair">
+ <span class="blp-num">ed25519 over SHA256SUMS <span class="blp-chip">prior art: 0 of 4</span></span><span class="blp-bar a" style="width:100%"></span>
+ </div>
+ </div>
+ <p class="blp-foot">daily rebuild · rolling release pack-rust-vulns · cold build ~34 s</p>
+ </div>
+ <div class="bl-meta">
+ <p class="bl-date"><time datetime="2026-09-27">2026-09-27</time> · CORPUS PACKS · SECURITY DATA</p>
+ <h2 class="bl-title">One vulnerability, three names, and a pack we sign</h2>
+ <p class="bl-excerpt">The same Rust vulnerability sits in two databases under three ids, and
+ neither database merges them. A three-line identity recipe collapses
+ <strong>4,107 filings to 1,950 records</strong> carrying every field either source knew
+ &mdash; including the curated vulnerable-function paths no export has. Then the part
+ nobody ships: <strong>a signature</strong>, because checksums prove integrity and not
+ origin.</p>
+ <p class="bl-byline">AUTHOR · XERJ ENGINEERING TEAM · PUBLISHED · 2026-09-27</p>
+ <span class="bl-read">READ THE POST &rarr;</span>
+ </div>
+ </a>
+ </li>
<li>
<a class="bl-card" href="/blog/cutting-the-index-28-percent">
<!-- Bar widths share ONE denominator, 2,449 kB (the max across all rows,
diff --git a/landing/blog/one-vulnerability-three-names.html b/landing/blog/one-vulnerability-three-names.html
new file mode 100644
index 000000000..9b940782f
--- /dev/null
+++ b/landing/blog/one-vulnerability-three-names.html
@@ -0,0 +1,411 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="UTF-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<title>One vulnerability, three names — and a pack we sign</title>
+<meta name="description" content="The same Rust vulnerability arrives as RUSTSEC, GHSA and CVE. We collapsed 4,107 advisories to 1,950 identity-resolved records, packed them, and signed the pack — because no vulnerability database we surveyed does.">
+<link rel="preconnect" href="https://fonts.googleapis.com">
+<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
+<link href="https://fonts.googleapis.com/css2?family=Big+Shoulders+Display:wght@400;700;800;900&family=Inter:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=JetBrains+Mono:wght@400;500;700&display=swap" rel="stylesheet">
+<link rel="stylesheet" href="/style.css?v=if9">
+<link rel="stylesheet" href="/blog.css?v=1">
+<!-- seo:begin — generated by scripts/seo/fix_heads.py · do not hand-edit -->
+<link rel="canonical" href="https://xerj.org/blog/one-vulnerability-three-names">
+<meta property="og:site_name" content="XERJ.ai">
+<meta property="og:type" content="article">
+<meta property="og:title" content="One vulnerability, three names — and a pack we sign">
+<meta property="og:description" content="The same Rust vulnerability arrives as RUSTSEC, GHSA and CVE. We collapsed 4,107 advisories to 1,950 identity-resolved records, packed them, and signed the pack — because no vulnerability database we surveyed does.">
+<meta property="og:url" content="https://xerj.org/blog/one-vulnerability-three-names">
+<meta property="og:image" content="https://xerj.org/og/xerj-card.png">
+<meta property="og:image:width" content="1200">
+<meta property="og:image:height" content="630">
+<meta property="og:image:alt" content="XERJ.ai — the search engine built for AI agents">
+<meta property="og:locale" content="en_US">
+<meta name="twitter:card" content="summary_large_image">
+<meta name="twitter:title" content="One vulnerability, three names — and a pack we sign">
+<meta name="twitter:description" content="The same Rust vulnerability arrives as RUSTSEC, GHSA and CVE. We collapsed 4,107 advisories to 1,950 identity-resolved records, packed them, and signed the pack — because no vulnerability database we surveyed does.">
+<meta name="twitter:image" content="https://xerj.org/og/xerj-card.png">
+<script type="application/ld+json">
+{
+ "@context": "https://schema.org",
+ "@type": "Organization",
+ "@id": "https://xerj.org/#organization",
+ "name": "XERJ",
+ "alternateName": "XERJ.ai",
+ "url": "https://xerj.org/",
+ "logo": "https://xerj.org/brandbook/xerj-mark.svg",
+ "sameAs": [
+ "https://github.com/xerj-org/xerj"
+ ]
+}
+</script>
+<script type="application/ld+json">
+{
+ "@context": "https://schema.org",
+ "@type": "WebSite",
+ "@id": "https://xerj.org/#website",
+ "name": "XERJ.ai",
+ "url": "https://xerj.org/",
+ "inLanguage": "en",
+ "publisher": {
+ "@id": "https://xerj.org/#organization"
+ }
+}
+</script>
+<script type="application/ld+json">
+{
+ "@context": "https://schema.org",
+ "@type": "Article",
+ "headline": "One vulnerability, three names — and a pack we sign",
+ "description": "The same Rust vulnerability arrives as RUSTSEC, GHSA and CVE. We collapsed 4,107 advisories to 1,950 identity-resolved records, packed them, and signed the pack — because no vulnerability database we surveyed does.",
+ "url": "https://xerj.org/blog/one-vulnerability-three-names",
+ "image": "https://xerj.org/og/xerj-card.png",
+ "inLanguage": "en",
+ "datePublished": "2026-09-27",
+ "dateModified": "2026-09-27",
+ "author": {
+ "@id": "https://xerj.org/#organization"
+ },
+ "publisher": {
+ "@id": "https://xerj.org/#organization"
+ },
+ "isPartOf": {
+ "@id": "https://xerj.org/#website"
+ },
+ "mainEntityOfPage": {
+ "@type": "WebPage",
+ "@id": "https://xerj.org/blog/one-vulnerability-three-names"
+ }
+}
+</script>
+<script type="application/ld+json">
+{
+ "@context": "https://schema.org",
+ "@type": "BreadcrumbList",
+ "itemListElement": [
+ {
+ "@type": "ListItem",
+ "position": 1,
+ "name": "Home",
+ "item": "https://xerj.org/"
+ },
+ {
+ "@type": "ListItem",
+ "position": 2,
+ "name": "Blog",
+ "item": "https://xerj.org/blog/"
+ },
+ {
+ "@type": "ListItem",
+ "position": 3,
+ "name": "One vulnerability, three names"
+ }
+ ]
+}
+</script>
+<!-- seo:end -->
+</head>
+<body>
+<nav class="nav" aria-label="Primary">
+ <a href="/" class="brand">XERJ</a>
+ <a href="/">HOME</a>
+ <a href="/product">PRODUCT</a>
+ <span class="nav-drop"><a href="/use-cases">USE CASES</a></span>
+ <a href="/case-studies">CASE STUDIES</a>
+ <a href="/benchmarks/">BENCHMARKS</a>
+ <a href="/blog/" class="active">BLOG</a>
+ <span class="spacer"></span>
+ <a href="/for-agents">FOR AGENTS</a>
+ <a href="/docs/">DOCS</a>
+ <a href="/docs/recipes/">RECIPES</a>
+ <a href="/playground">DASHBOARDS</a>
+ <a href="https://github.com/xerj-org/xerj" rel="external">GITHUB</a>
+ <span class="theme"><button type="button" data-theme="day" class="active">DAY</button><span class="dash">·</span><button type="button" data-theme="night">NIGHT</button></span>
+</nav>
+
+<main>
+<div class="uc-hero">
+ <p class="blog-crumb"><a href="/blog/">&larr; ALL POSTS · /BLOG</a></p>
+ <div class="uc-eyebrow">CORPUS PACKS · IDENTITY RESOLUTION · ED25519 · BUILT 2026-09-26/27</div>
+ <h1>ONE VULNERABILITY, THREE NAMES,<br><span class="accent">AND A PACK WE SIGN</span></h1>
+ <p class="blog-byline">XERJ ENGINEERING · PUBLISHED 2026-09-27</p>
+
+ <p class="lede">The same Rust vulnerability arrives as <code class="inline">RUSTSEC-2021-0003</code>,
+ <code class="inline">GHSA-43w2-9j62-hq99</code> and <code class="inline">CVE-2021-25900</code> — three
+ records, in two databases that never talk to each other, none of them carrying everything the other
+ knows. We built a tool that collapses them into one record, packs it into something portable and
+ checksummed, and then signs the pack. The last part is the strangest finding of the project: in our
+ survey of vulnerability databases people pip-install and OCI-pull every day, not one ships a
+ signature a consumer can verify.</p>
+</div>
+
+<section class="scene-section">
+ <div class="kicker">01 · THE PROBLEM</div>
+ <h2 class="scene">Two sources, each sure it is the whole story</h2>
+
+ <p>We started with the sources everyone reaches for, and measured what each one actually carries
+ for the Rust ecosystem:</p>
+
+ <div class="vt-wrap">
+ <table class="vt">
+ <thead><tr><th>Source (both CC0)</th><th>Records</th><th>Has</th><th>Missing</th></tr></thead>
+ <tbody>
+ <tr><td>osv.dev crates.io export</td><td class="n">2,856</td><td class="t">GHSA + RUSTSEC + MAL ids, CVSS scores</td><td class="t l">zero affected-function data; aliases never merged</td></tr>
+ <tr><td>RustSec advisory-db</td><td class="n">1,251</td><td class="t">curated vulnerable-function paths, categories, keywords, full advisory prose</td><td class="t l">no GHSA-only records</td></tr>
+ <tr><td>GitHub advisory-database</td><td class="n">&mdash;</td><td class="t">the same crates.io records</td><td class="t l">its extra fields are marked internal-use-only &mdash; we never read them</td></tr>
+ </tbody>
+ </table>
+ </div>
+
+ <p>The alias problem is the one that hurts an agent most. osv.dev's export lists the same
+ vulnerability twice — once under its GHSA id, once under its RUSTSEC id — with a shared CVE in
+ each record's alias list, and no merge ever performed between them. Search it for
+ &ldquo;smallvec insert_many&rdquo; and you get whichever filing happened to phrase it that way;
+ the other half of the knowledge is a separate record you did not retrieve. RustSec fixes the
+ merge by being one curated database, but it cannot see GHSA-only filings at all.</p>
+
+ <p>HackerOne, the source the original brief asked about, is out of scope for a different reason:
+ report content there is unredistributable under its terms of service. A pack's author owns what
+ goes in the pack, and this pack ships only sources whose licence lets us redistribute them.</p>
+</section>
+
+<section class="scene-section">
+ <div class="kicker">02 · THE RECIPE</div>
+ <h2 class="scene">Identity resolution as a declarative file</h2>
+
+ <p>We did not write a Rust-vulnerability importer. We wrote a <em>corpus builder</em> whose entire
+ domain knowledge lives in a commented TOML recipe — because the next corpus is not advisories.
+ The same tool with a different recipe indexes mailboxes, or code, or genomes; nothing about the
+ pipeline knows what a vulnerability is.</p>
+
+ <p>The identity section is three lines:</p>
+
+ <pre class="code">[identity]
+edges = [{ field = "id" }, { field = "aliases", each = true }]
+canonical_source_order = ["rustsec", "osv"]</pre>
+
+ <p>Union-find over those edge values does the rest, and it closes chains for free: a RustSec
+ filing and a GHSA filing that share a CVE alias merge even with no direct edge between them,
+ because each is transitively bound to the CVE. Measured on the real sources:</p>
+
+ <div class="vt-wrap">
+ <table class="vt">
+ <thead><tr><th>rust-vulns, measured off the committed build</th><th>Count</th></tr></thead>
+ <tbody>
+ <tr><td>source records harvested (envelopes)</td><td class="n">4,107</td></tr>
+ <tr><td>records after identity resolution</td><td class="n w">1,950</td></tr>
+ <tr><td>&hellip;merged from both sources</td><td class="n">1,221</td></tr>
+ <tr><td>canonical id: RUSTSEC / GHSA / MAL</td><td class="n">1,221 / 711 / 18</td></tr>
+ <tr><td>records carrying curated function paths</td><td class="n">270 (663 distinct paths)</td></tr>
+ <tr><td>withdrawn advisories (kept, flagged)</td><td class="n">124</td></tr>
+ <tr><td>packages covered · records JSONL bytes · cold build</td><td class="n">1,813 · 10,140,789 · ~34 s</td></tr>
+ </tbody>
+ </table>
+ </div>
+
+ <p>The function paths are the field no export carries. RustSec's hand-curated
+ <code class="inline">affected.functions</code> — which function in which crate is the vulnerable
+ one — survives the merge unioned across sibling filings: one 2026 CVE filed against three
+ <code class="inline">libcrux-*</code> crates becomes one record carrying all three crates'
+ paths. For an agent asking &ldquo;is <em>this</em> call the dangerous one?&rdquo;, that is the
+ whole difference between a hit and an answer.</p>
+
+ <p>Merge precedence is declared, not discovered: RustSec wins a disagreeing scalar because it
+ owns the curated fields; arrays are always unioned; the merged record's licence is the most
+ restrictive of its sources and <code class="inline">sources[]</code> names every contributor,
+ so a merge is auditable after the fact. Withdrawn advisories are kept and flagged rather than
+ dropped — filtering is the consumer's decision, not the pack's.</p>
+</section>
+
+<section class="scene-section">
+ <div class="kicker">03 · THE PACK</div>
+ <h2 class="scene">A directory you can move, and a machine that refuses surprises</h2>
+
+ <p>The build emits a self-contained directory: sharded records in canonical JSON order, a manifest
+ with per-file SHA-256 checksums, the recipe verbatim as provenance, and suggestions — a proposed
+ field mapping and join candidates computed from a sample, explicitly <em>suggestions, not
+ decisions</em>, because the index infers the real mapping the way it does for any folder.</p>
+
+ <p>Two rules in the format are load-bearing. A manifest carries a
+ <code class="inline">format_version</code> that readers refuse when they do not know it — a
+ published pack outlives the release that built it. And installing one verifies every checksum
+ before anything is materialized, so a truncated or edited pack is refused whole, not half-mounted:</p>
+
+ <pre class="code"><span class="prompt">$</span> xerj corpus add rust-vulns --from rust-vulns-pack.zip --verify-sig rust-vulns.pub
+<span class="prompt">$</span> xerj corpus index rust-vulns
+<span class="prompt">$</span> xerj code rust-vulns "smallvec insert_many buffer overflow"</pre>
+
+ <p>Incremental rebuilds need no mode flag: every normalized record is stored content-addressed,
+ so a re-run recomputes each key, sees the file, and skips. Only new or changed upstream records
+ are written, and the pack re-emits deterministically from whatever the store holds — same bytes
+ in, same pack out, which is what makes a signature over it meaningful.</p>
+</section>
+
+<section class="scene-section">
+ <div class="kicker">04 · THE SIGNATURE</div>
+ <h2 class="scene">Checksums prove integrity. They do not prove origin.</h2>
+
+ <p>Here is the attack that checksums cannot stop. Take a pack. Edit records — flip a
+ <code class="inline">fixed_versions</code> string, say. Recompute every file's checksum and
+ rewrite <code class="inline">SHA256SUMS</code> honestly. The pack now verifies perfectly against
+ its own manifest. Every checksum agrees, because the checksums were never the thing being
+ attacked — the pack's <em>origin</em> was.</p>
+
+ <p>We pinned exactly this in a test: a self-consistent rebuild passes every checksum check and
+ fails the signature. That gap is the entire reason the pack carries one — a raw 64-byte
+ ed25519 signature over <code class="inline">SHA256SUMS</code>, verified by
+ <code class="inline">xerj corpus add --verify-sig &lt;pubkey&gt;</code> before a byte is
+ materialized.</p>
+
+ <p>Before building it we surveyed what the existing ecosystem ships, and found the lane empty.
+ None of these is a criticism of the projects — their data is good and their tooling is real;
+ it is a statement about the format:</p>
+
+ <div class="vt-wrap">
+ <table class="vt">
+ <thead><tr><th>Database (our survey, 2026-09)</th><th>Distribution</th><th>Integrity mechanism</th></tr></thead>
+ <tbody>
+ <tr><td>Trivy DB</td><td class="t">OCI artifact, 6-hour builds</td><td class="t l">checksums in registry metadata &mdash; no consumer-verifiable signature</td></tr>
+ <tr><td>Grype / vunnel</td><td class="t">per-provider feeds</td><td class="t l">unsigned</td></tr>
+ <tr><td>PrimeVul</td><td class="t">Hugging Face dataset</td><td class="t l">unsigned</td></tr>
+ <tr><td>VulnRAG</td><td class="t">research artifact</td><td class="t l">unsigned</td></tr>
+ </tbody>
+ </table>
+ </div>
+
+ <p>The design rules we landed on, each one because its absence would make the signature
+ decorative:</p>
+
+ <ul>
+ <li><strong>The public key travels out of band</strong> — committed beside the recipe in the
+ repository, mirrored on our site, never inside the pack. A key shipped beside its own
+ signature verifies nothing: an attacker who can replace the pack can replace the key.</li>
+ <li><strong>Build and publish are different steps.</strong> <code class="inline">corpus
+ build</code> emits; it never signs. The seed exists only as a CI secret, and the publish
+ workflow signs, then verifies its own output against the committed public key before
+ publishing — a rotated key that forgot to update the committed <code class="inline">.pub</code>
+ fails the build instead of shipping a pack no consumer can verify.</li>
+ <li><strong>The signature covers the checksum file</strong>, which covers every pack file; the
+ signature itself is deliberately absent from the checksum list, because signing a list that
+ contains the signature is circular.</li>
+ </ul>
+
+ <div class="loss">
+ <strong>What the signature does not do.</strong> It proves who built a pack, not that the pack
+ is safe to open — a verified pack is exactly what the key holder built. And it is one release
+ key in v1: rotation means a new keypair, a new CI secret, a committed
+ <code class="inline">.pub</code>, and consumers choosing to trust the new one. We wrote the
+ procedure down before we needed it.
+ </div>
+</section>
+
+<section class="scene-section">
+ <div class="kicker">05 · THE HONEST PART</div>
+ <h2 class="scene">What this is not</h2>
+
+ <p><strong>Not a security product.</strong> It is a searchable corpus of advisories for agents
+ and humans, with no completeness claim beyond what its two sources carried at build time. It is
+ not a scanner and will not tell you what is running in your production.</p>
+
+ <p><strong>Freshness is a cron job, not a promise.</strong> The publish workflow rebuilds daily;
+ between a source updating and the next run, the pack lags by up to a day. The README badge reads
+ the build date off the release itself, and the same 30-day staleness refusal that governs every
+ reference corpus governs ours — a workflow that stops running shows up as a stale pack, not a
+ silently aging artifact.</p>
+
+ <p><strong>Records, not an index.</strong> Installing the pack still costs every consumer the
+ same CPU-minutes to index — the pre-indexed half of the corpus-hub idea is a separate, harder
+ format problem (a published index needs a compatibility promise our internal segment format has
+ never had to make).</p>
+
+ <p><strong>The value hypothesis is unproven.</strong> Trivy's database gets pulled because
+ scanners need it at scan time; an agent-facing vulnerability corpus has weaker daily pull, and
+ the honest analogy is template packs that took years to compound. What we can say is what the
+ pack uniquely carries — identity-resolved clusters, the curated function paths, a signature —
+ and that the numbers above are measured, not projected.</p>
+</section>
+
+<section class="scene-section">
+ <div class="kicker">06 · THE TRACE</div>
+ <h2 class="scene">Every number, pinned to a run</h2>
+
+ <p>The counts in section 02 come from
+ <a href="https://github.com/xerj-org/xerj/tree/main/tools/packs/rust-vulns" rel="external">tools/packs/rust-vulns</a>
+ — a committed <code class="inline">pack-stats.json</code> whose provenance field says
+ <code class="inline">measured</code>, with a test that fails the build if the README's table and
+ the stats file drift apart, and another that fails if the stats describe any recipe other than the one
+ shipped. The builder, the signature code, and the pack format are in the same repository under
+ <code class="inline">engine/crates/xerj-autoindex/src/harvest/</code>, and the format is
+ documented end to end in
+ <a href="https://github.com/xerj-org/xerj/blob/main/docs/CORPUS_PACKS.md" rel="external">docs/CORPUS_PACKS.md</a>.</p>
+
+ <p>The pack itself is a rolling GitHub Release —
+ <a href="https://github.com/xerj-org/xerj/releases/tag/pack-rust-vulns" rel="external">pack-rust-vulns</a>
+ — rebuilt and signed on a schedule, with the zip, the loose checksums, the signature, and a
+ freshness file as assets. Build it yourself instead, from the recipe, if you would rather trust
+ your own machine than our key; that is a supported path, not a workaround. If your agent works
+ with Rust dependencies, point it at the pack and ask it the question a raw export cannot
+ answer: <em>which function is the vulnerable one?</em></p>
+</section>
+
+</main>
+
+<!-- seo:footer-begin — generated by scripts/seo/fix_links.py · do not hand-edit -->
+<nav class="footer-map" aria-label="Site map">
+ <div class="fm-col">
+ <span class="fm-h">PRODUCT</span>
+ <a href="/product">PRODUCT</a>
+ <a href="/architecture/">ARCHITECTURE</a>
+ <a href="/benchmarks/">BENCHMARKS</a>
+ <a href="/pricing/">PRICING</a>
+ <a href="/security/">SECURITY</a>
+ <a href="/playground">DASHBOARDS</a>
+ <a href="/demo/">REAL-DATA DEMO</a>
+ <a href="/aise-demo">PRODUCT TOUR</a>
+ </div>
+ <div class="fm-col">
+ <span class="fm-h">SOLUTIONS</span>
+ <a href="/solutions/">SOLUTIONS</a>
+ <a href="/use-cases">USE CASES</a>
+ <a href="/case-studies">CASE STUDIES</a>
+ <a href="/industries/">INDUSTRIES</a>
+ <a href="/industries/finserv">FINANCIAL SERVICES</a>
+ <a href="/industries/public-sector">PUBLIC SECTOR</a>
+ <a href="/industries/healthcare">HEALTHCARE</a>
+ <a href="/industries/retail">RETAIL</a>
+ <a href="/use-cases/code-security-audit">AI CODE-SECURITY AUDIT</a>
+ <a href="/use-cases/semantic-analytics">SEMANTIC ANALYTICS</a>
+ </div>
+ <div class="fm-col">
+ <span class="fm-h">DOCS</span>
+ <a href="/docs/">DOCUMENTATION</a>
+ <a href="/docs/quickstart">QUICKSTART</a>
+ <a href="/docs/install">INSTALL</a>
+ <a href="/docs/migration-from-es">MIGRATE FROM ELASTICSEARCH</a>
+ <a href="/docs/recipes/">RECIPES</a>
+ <a href="/docs/agents/">DOCS FOR AI</a>
+ <a href="/for-agents">FOR AI AGENTS</a>
+ <a href="/agent-search/">AGENTIC SEARCH DEMO</a>
+ <a href="/answers/">ANSWERS</a>
+ <a href="/compare/">COMPARISONS</a>
+ </div>
+ <div class="fm-col">
+ <span class="fm-h">RESOURCES</span>
+ <a href="/resources/">SALES KIT</a>
+ <a href="/blog/">BLOG</a>
+ <a href="/brand">BRAND</a>
+ <a href="/brandbook/">BRAND BOOK</a>
+ <a href="/llms.txt">LLMS.TXT</a>
+ <a href="https://github.com/xerj-org/xerj" rel="external">GITHUB</a>
+ </div>
+</nav>
+<!-- seo:footer-end -->
+<footer class="footer">
+ <span>XERJ.AI · V1.0.0-RC.77 · 2026</span>
+ <span>SEARCH FOR THE AGENT ERA</span>
+ <span><a href="/product">PRODUCT</a> · <a href="/docs/">DOCS</a> · <a href="/brand">BRAND</a> · <a href="/playground">DASHBOARDS</a> &middot; <a href="/llms.txt">LLMS.TXT</a></span>
+</footer>
+<script src="/interact.js" defer></script>
+</body>
+</html>
diff --git a/landing/sitemap.xml b/landing/sitemap.xml
index 7fd8293df..52f192931 100644
--- a/landing/sitemap.xml
+++ b/landing/sitemap.xml
@@ -348,6 +348,10 @@
<loc>https://xerj.org/blog/jev-vs-a-bm25-vote</loc>
<lastmod>2026-09-27</lastmod>
</url>
+ <url>
+ <loc>https://xerj.org/blog/one-vulnerability-three-names</loc>
+ <lastmod>2026-09-27</lastmod>
+ </url>
<url>
<loc>https://xerj.org/brand</loc>
<lastmod>2026-09-27</lastmod>
diff --git a/scripts/seo/pagedata.py b/scripts/seo/pagedata.py
index 048d72f24..825dd1c60 100755
--- a/scripts/seo/pagedata.py
+++ b/scripts/seo/pagedata.py
@@ -127,10 +127,19 @@ PAGES: dict[str, dict[str, str]] = {
description="Four file-format changes took our 100k-doc index from 5.52 MB to 3.99 MB (−28%), each gated on dissecting real segments first. The losing rows are in the post.",
published="2026-09-27", updated="2026-09-27",
),
+ # Corpus-pack GTM post, 2026-09-27. Every count traces to tools/packs/
+ # rust-vulns/pack-stats.json (provenance "measured", pinned by test); the
+ # prior-art signature table is our 2026-09 survey, phrased as a survey.
+ "blog/one-vulnerability-three-names.html": dict(
+ label="One vulnerability, three names", kind="article",
+ title="One vulnerability, three names — and a pack we sign",
+ description="The same Rust vulnerability arrives as RUSTSEC, GHSA and CVE. We collapsed 4,107 advisories to 1,950 identity-resolved records, packed them, and signed the pack — because no vulnerability database we surveyed does.",
+ published="2026-09-27", updated="2026-09-27",
+ ),
"blog/index.html": dict(
label="Blog", kind="collection",
title="XERJ.ai — Blog: the engineering log",
- description="Measured results with the losses left in: the Jev decisions study, the JEV rerank verdict, benchmark autopsies, and the storage formats that cut the index 28%.",
+ description="Measured results with the losses left in: the Jev decisions study, the JEV rerank verdict, the storage formats that cut the index 28%, and the signed rust-vulns corpus pack.",
updated="2026-09-27",
),
"demo/index.html": dict(
diff --git a/tools/packs/keys/README.md b/tools/packs/keys/README.md
new file mode 100644
index 000000000..2cab6e2d3
--- /dev/null
+++ b/tools/packs/keys/README.md
@@ -0,0 +1,27 @@
+# Pack signing keys
+
+One `.pub` per published pack: the ed25519 **verifying** key a consumer
+passes to `xerj corpus add <pack> --verify-sig <file>`. A key here is the
+out-of-band half of the pack's signature — it must travel by a different
+channel than the pack itself (this repository), never inside the pack.
+
+The matching seed (`.key`) **never** lives in this repository. It exists
+only as the `PACK_SIGNING_SEED` secret in CI; `xerj corpus build` never
+signs, and the publish workflow verifies its own output against the `.pub`
+committed here before publishing — so a seed that does not match the
+committed `.pub` fails the build instead of shipping an unverifiable pack.
+
+Rotating a key (the procedure, before we need it):
+
+```sh
+xerj corpus keygen --out tools/packs/keys/<name> # new pair
+# set the new PACK_SIGNING_SEED secret from the .key, commit the new .pub
+# IN THE SAME CHANGE, delete the local .key
+```
+
+Consumers re-fetch the `.pub` when they choose to trust the new one; the
+next scheduled publish ships under it.
+
+See `docs/CORPUS_PACKS.md` for the full trust model, and
+`tools/packs/rust-vulns/README.md` for the pack these rules were written
+for.
diff --git a/tools/packs/keys/rust-vulns.pub b/tools/packs/keys/rust-vulns.pub
new file mode 100644
index 000000000..920e827a4
--- /dev/null
+++ b/tools/packs/keys/rust-vulns.pub
@@ -0,0 +1 @@
+02d562e19cd7bd9b5ecedcdb6a1214382d41cae659a7ea7d1530058e3cb9ae93
diff --git a/tools/packs/rust-vulns/README.md b/tools/packs/rust-vulns/README.md
index d99ec6aa4..428f798fd 100644
--- a/tools/packs/rust-vulns/README.md
+++ b/tools/packs/rust-vulns/README.md
@@ -1,5 +1,8 @@
# rust-vulns — the showcase corpus pack
+[![pack publish](https://github.com/xerj-org/xerj/actions/workflows/pack-publish.yml/badge.svg)](https://github.com/xerj-org/xerj/actions/workflows/pack-publish.yml)
+[![rust-vulns freshness](https://img.shields.io/endpoint?url=https://github.com/xerj-org/xerj/releases/download/pack-rust-vulns/rust-vulns-freshness.json)](https://github.com/xerj-org/xerj/releases/tag/pack-rust-vulns)
+
Rust vulnerability advisories, **identity-resolved across sources**: the same
vulnerability that arrives as `RUSTSEC-2021-0003`, `GHSA-43w2-9j62-hq99` and
`CVE-2021-25900` is one record, carrying every field any source knew — and
@@ -49,6 +52,32 @@ author owns what goes in a pack.
## Build, consume, query
+The published pack is a rolling GitHub Release
+([pack-rust-vulns](https://github.com/xerj-org/xerj/releases/tag/pack-rust-vulns)),
+rebuilt and signed daily by the
+[pack publish](https://github.com/xerj-org/xerj/actions/workflows/pack-publish.yml)
+workflow.
+
+```sh
+# consume the published, signed pack:
+# 1. fetch the zip and the public key (the key travels OUT of band —
+# next to the recipe in this repo, never inside the pack)
+curl -LO https://github.com/xerj-org/xerj/releases/download/pack-rust-vulns/rust-vulns-pack.zip
+curl -LO https://github.com/xerj-org/xerj/releases/download/pack-rust-vulns/rust-vulns-SHA256SUMS.sig
+curl -LO https://raw.githubusercontent.com/xerj-org/xerj/main/tools/packs/keys/rust-vulns.pub
+
+# 2. install it with signature verification — refuses the pack whole if
+# the signature does not verify, before anything is indexed
+xerj corpus add rust-vulns --from rust-vulns-pack.zip \
+ --verify-sig rust-vulns.pub
+
+# 3. index and query
+xerj corpus index rust-vulns
+xerj code rust-vulns "smallvec insert_many buffer overflow"
+```
+
+Or build it yourself from this directory (the recipe is the whole build):
+
```sh
# build (or incrementally refresh) — fetches both sources, dedups, packs
xerj corpus build rust-vulns --recipe tools/packs/rust-vulns/recipe.toml
@@ -80,14 +109,35 @@ sample. Suggestions, not decisions: the index infers the real mapping.
| `is_withdrawn` / `informational` | lifecycle flags — withdrawn records stay, flagged |
| `licence` / `sources` / `origin` | provenance per record |
+## Signatures and key rotation
+
+`SHA256SUMS.sig` is a raw 64-byte ed25519 signature over the pack's
+SHA256SUMS (which covers every pack file). The verifying key lives at
+[keys/rust-vulns.pub](./keys/rust-vulns.pub) here and on xerj.org — never
+inside the pack, because a key shipped beside its own signature verifies
+nothing. Checksums prove the pack arrived intact; the signature proves who
+built it. A self-consistent rebuild (valid checksums over tampered records)
+passes checksums and fails the signature — that is the attack the signature
+exists for, and a test in `harvest/sign.rs` pins it.
+
+v1 uses a single release key. Rotation: generate a new keypair
+(`xerj corpus keygen`), set the new `PACK_SIGNING_SEED` secret, commit the
+new `.pub` in the same change, and let the next scheduled publish run — the
+workflow verifies its own output against the committed `.pub` before
+publishing, so a half-rotated key fails the build instead of shipping an
+unverifiable pack. Consumers re-fetch the `.pub` when they choose to trust
+the new one.
+
## Honest limits
-- **Freshness is whatever the last build fetched.** Rebuild to refresh;
- a scheduled build with a freshness badge is the next milestone.
+- **Freshness is whatever the last build fetched.** The scheduled workflow
+ rebuilds daily; the badge above shows the last build's date and record
+ count. Between the sources updating and the next cron tick, the pack lags
+ by up to a day — a rebuild you run yourself is always current.
- **Not a security product.** This is a searchable corpus of advisories for
agents and humans; it is not a scanner and makes no completeness claim
beyond "what these two sources carried at build time".
- Withdrawn (124) and informational advisories are kept and flagged, not
dropped — filtering is the consumer's decision.
-- v1 ships checksums (SHA256SUMS verifies on `corpus add`); signing lands
- with the publishing milestone.
+- The signature proves origin, not safety: a verified pack is exactly what
+ the key holder built — indexing it is still your decision.
diff --git a/tools/xerj-code/SKILL.md b/tools/xerj-code/SKILL.md
index e4c315ac4..e5db9b4bc 100644
--- a/tools/xerj-code/SKILL.md
+++ b/tools/xerj-code/SKILL.md
@@ -192,9 +192,13 @@ xerj corpus add rust-vulns --from ~/.xerj-code/builds/rust-vulns/pack/rust-vulns
The recipe declares sources, identity edges (the same vulnerability arriving as
RUSTSEC/GHSA/CVE becomes ONE record), merge precedence and derived fields; the
pack it emits is checksummed and installs with the same `corpus add --from` as
-a corpus definition. The in-repo example is
-[`tools/packs/rust-vulns/`](../packs/rust-vulns/) — see its README for what a
-measured pack looks like.
+a corpus definition. A pack from someone else (e.g. the rolling
+[rust-vulns release](https://github.com/xerj-org/xerj/releases/tag/pack-rust-vulns))
+carries an ed25519 signature over its SHA256SUMS — add it with
+`--verify-sig <pubkey-file>` to check origin before anything is indexed
+(the key ships beside the recipe, never inside the pack). The in-repo example
+is [`tools/packs/rust-vulns/`](../packs/rust-vulns/) — see its README for what
+a measured pack looks like.
### 2. Index it