8000 fix(corpus): harvest a repo pin's paths, not the whole tree by xerj-org · Pull Request #2228 · xerj-org/xerj · GitHub
[go: up one dir, main page]

Skip to content

fix(corpus): harvest a repo pin's paths, not the whole tree - #2228

Merged
xerj-org merged 1 commit into
mainfrom
cursor/corpus-paths-harvest-cbd2
Oct 23, 2026
Merged

xerj-org merged 1 commit into
mainfrom
cursor/corpus-paths-harvest-cbd2

Conversation

@xerj-org
@xerj-org xerj-org commented Oct 23, 2026 •
Copy link
Copy Markdown
Owner

What this changes, and why

A repo-pin hub manifest could not name a subdirectory. xerj corpus add --from on go-vulndb therefore cloned all of golang/vulndb, and corpus index walked that whole tree. The field report on #1842 records the result: 11,019 files and one 1,209,646-doc dataset, instead of the 4,577 per-advisory files under data/osv. Parts 1 and 2 of that issue (the rejected pin, the 404 corpus) are already fixed on corpus-hub by #1641. This is the remaining part.

A repo entry may now set "paths" to relative directories, for example "paths": ["data/osv"]. corpus add --from sparse-checks out only those directories. Cone mode would also materialize every file in ancestor directories (LICENSE, go.mod, root tests), and corpus index walks whatever is on disk, so the checkout uses a non-cone pattern /{path}/: that directory and everything under it, and not a sibling whose name merely shares the prefix (data/osv-extra). Omitting paths still harvests the whole pin.

The list is validated before git runs (.., absolute paths, globs, gitignore negations, and : are refused) and again before the worktree changes (the pin must contain each entry as a tree). A re-add of the same sha narrows a previous full checkout; dropping paths restores it. The list is written back into corpus.json, so a shared manifest rebuilds the same limited tree.

The go-vulndb manifest itself lives on corpus-hub and is updated in #2229.

Evidence

Dev-profile tests on Rust 1.97.1 (the CI toolchain). The new checkout test builds a local pin with LICENSE, data/osv (including a nested file), data/osv-extra, data/reports, and cmd, then asserts the worktree.

cargo +1.97.1 test -p xerj-common --lib xccode:: -- --test-threads=8
test result: ok. 107 passed; 0 failed; 0 ignored; 0 measured; 180 filtered out

cargo +1.97.1 test -p xerj-autoindex --lib corpus_add -- --test-threads=8
test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 1621 filtered out
  corpus_add_from_paths_harvests_only_those_directories
  corpus_add_from_paths_refuses_a_missing_or_escaping_directory

cargo +1.97.1 clippy -p xerj-common -p xerj-autoindex --lib --tests -- -D warnings
Finished `dev` profile, exit 0

corpus_add_from_paths_harvests_only_those_directories passed, which asserts: no paths checks out all 6 files; paths: ["data/osv"] on the same sha narrows the existing checkout to the 2 files under data/osv (not data/osv-extra, not LICENSE); corpus.json records that list and files: 2; a second add stays narrow; data/osv plus cmd is 3 files; dropping paths restores LICENSE and data/reports. The refusal test passed, which asserts a missing directory exits 1 with no corpus.json and no full checkout, and ../secret exits 2 before the corpus directory is created.

Checks

  • cargo fmt with the 1.97.1 rustfmt on the four touched files (rustfmt --check clean)
  • Scoped release build of the crates touched: cargo build --release -j 32 -p <crate>
  • cargo test -p xerj-common --lib xccode:: and cargo test -p xerj-autoindex --lib corpus_add (dev profile, not ci-test)
  • ES-YAML conformance suite at 0 failed — not applicable: this change does not touch the query engine or the ES wire protocol. It is the corpus add --from checkout and the hub-manifest parser.
  • New ES-compatible behaviour has a matching YAML case — not applicable, same reason
  • Docs updated: tools/xerj-code/hub/README.md describes paths
  • Applicable audit in docs/CONTRIBUTION_REVIEW.md: ancestry is one commit on current main; the whole-pin path is preserved when paths is absent; a bad path fails before the worktree is narrowed; an existing full checkout at the same sha is narrowed on re-add and restored when paths is removed. No durable index or mapping migration.
  • Operational-recipe audit: N/A. No shell recipe, service unit, or publish step was added. The new behaviour is covered by the library tests above.

Not run: cargo build --release and cargo test --profile ci-test. Those profiles rebuild the crate graph at opt-level 3 / fat LTO; the assertions above do not depend on codegen. CI Build + Test is the profile gate. ES-YAML was not run because this diff does not change search behaviour.

Provenance

  • Written by: AI agent (Cursor Grok 4.7), on behalf of the account that opens this pull request
  • Verified (commands run, output observed): the three commands in Evidence, on Rust 1.97.1, against a local git fixture. git sparse-checkout set --no-cone -- /data/osv/ was also checked by hand on git 2.43.0 before the implementation: it materialized data/osv only, and git sparse-checkout disable restored the full tree.
  • Assumed (not tested, and what would falsify it): GitHub-hosted ubuntu-latest git still accepts sparse-checkout set --no-cone. A git that rejects --no-cone fails the checkout (the repo is skipped, the whole pin is not harvested). That assumption is false if CI's git errors on --no-cone and corpus_add_from_paths_harvests_only_those_directories fails.

Fixes #1842

Open in Web Open in Cursor 

A repo-pin hub manifest had no way to name a subdirectory. `xerj corpus
add --from` on go-vulndb therefore cloned all of golang/vulndb, and
corpus index walked that whole tree. The field report on #1842 records
the result: 11,019 files and one 1,209,646-doc dataset, instead of the
4,577 per-advisory files under data/osv.

A repo entry may now set "paths" to relative directories. `corpus add
--from` sparse-checks out only those directories (non-cone, so ancestor
files such as LICENSE are not left for the indexer), refuses `..`,
absolute paths, globs, and a directory the pin does not contain before
it changes the worktree, and writes the list back into corpus.json so a
shared manifest rebuilds the same limited tree. Omitting paths still
harvests the whole pin. Re-adding a pin that gains paths narrows an
existing checkout; dropping paths restores it.

The manifest gate is read_hub_manifest. The checkout is
checkout_at_sha_paths in engine/crates/xerj-autoindex/src/xc.rs.

Fixes #1842

Co-authored-by: xerj-org <xerj-org@users.noreply.github.com>
@cla-bot cla-bot Bot added the cla-signed label Oct 23, 2026
@xerj-org xerj-org mentioned this pull request Oct 23, 2026
3 of 4 tasks
@xerj-org
xerj-org merged commit f7a86a7 into main Oct 23, 2026
24 checks passed
@xerj-org
Copy link
Copy Markdown
Owner Author

Xerj Merger made the fix: repo-pin hub manifests can now set paths, and the checkout uses a validated non-cone sparse checkout so only those directories are harvested (e.g. go-vulndb data/osv instead of the whole tree). Entries are validated against globs, .., absolute paths and colons. Completes the consumer side of #1842.

cursor Bot pushed a commit that referenced this pull request Oct 23, 2026
Motivation: PR #2230 no longer merged after main moved. The only
overlap was engine/crates/xerj-autoindex/src/xc.rs. Main (#2228 and
the commits through ad657c7) added sparse pin harvest
(checkout_at_sha_paths, apply_sparse_limit) and tests for it. This
branch added the #2181 catalog hint when `xerj code` / `xerj corpus
list` see an empty ledger, plus its tests. Git auto-merged the
production functions; both sides had appended tests at the end of
`mod tests`, and that was the conflict.

Resolution: keep both. Main's harvest functions and tests stay. The
hint functions, the call sites in run_code_cli and run_corpus_list,
and the #2181 tests stay. The hint's last test is closed before
main's worktree helpers, and rustfmt 1.97.1 cleaned the trailing
newline. No .github file was edited; main's ci.yml change comes in
with the merge.

Evidence (rustc 1.97.1, from engine/):
cargo +1.97.1 test -p xerj-autoindex
— lib 1639 passed, 0 failed, 2 ignored; every integration target
  0 failed. Includes xc::tests for the catalog hint and
  corpus_add_from_paths_*.
cargo +1.97.1 test -p xerj-rerank --test egress_inventory
— 4 passed, 0 failed.

Co-authored-by: xerj-org <xerj-org@users.noreply.github.com>
cursor Bot pushed a commit that referenced this pull request Oct 23, 2026
Motivation: PR #2243 conflicted with main after #2228 (sparse pin
harvest), #2227 (semantic_text highlight), and #2166 (xerj_def)
landed. The journal-resume fix for #2239 has to stay, and so does
the behavior those commits added.

Conflict: CHANGELOG.md, Unreleased / Fixed. Both entries are kept:
the #2239 corpus-index resume note, then main's #1947 semantic
highlight note. The Added section already had both MCP entries.
engine/crates/xerj-autoindex/src/xc.rs auto-merged. Main's
checkout_at_sha_paths sparse harvest and this branch's
find_unfinished_build / resume mode are both in the file. No
.github file was hand-edited; ci.yml came in as main left it.

Verified from engine/ with rustc 1.97.1:
cargo test --profile ci-test -p xerj-autoindex -j 2
lib 1644 passed, 0 failed, 2 ignored. Integratio
8000
n targets 0 failed.
a_kill_mid_index_resumes_the_journal_and_records_a_verified_build
and corpus_add_from_paths_harvests_only_those_directories both ok.

Co-authored-by: xerj-org <xerj-org@users.noreply.github.com>
jelbirt added a commit to jelbirt/xerj that referenced this pull request Oct 27, 2026
A pack whose key content sits in a few files inside a large directory had
to take the whole directory. For pandas time series, adding all of
pandas/core/arrays to reach arrays/datetimes.py let unrelated definitions
outrank the docs. Nothing in xerj-org#2228 or pathgate required directories only.

Each entry is classified by its mode from one git ls-tree call, which
needs no file content in the blob:none clone: a tree keeps the /{path}/
pattern, a regular file gets /{path}, and the materialize check tests for
a file. A symlink is refused, since it would point corpus index at a
target the manifest author chose; a submodule gets its own message rather
than "no such path". Directory-only manifests check out the same tree.

Tests: a file entry harvests that file and no sibling or same-named file
elsewhere (fails before this change: "is a blob ... not a directory"),
re-adding narrows and widens, each entry kind is classified, and a symlink
entry is refused. Docs: hub README, help text, CHANGELOG.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hub manifests: go-vulndb pin is rejected; crypto-misuse-precedent repo 404; no subpath harvest

2 participants

0