Repository navigation
fix(corpus): harvest a repo pin's paths, not the whole tree - #2228
Merged
Merged
Conversation
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>
3 of 4 tasks
Owner
Author
|
Xerj Merger made the fix: repo-pin hub manifests can now set |
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>
This was referenced Oct 27, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes, and why
A repo-pin hub manifest could not name a subdirectory.
xerj corpus add --fromon go-vulndb therefore cloned all of golang/vulndb, andcorpus indexwalked 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 underdata/osv. Parts 1 and 2 of that issue (the rejected pin, the 404 corpus) are already fixed oncorpus-hubby #1641. This is the remaining part.A repo entry may now set
"paths"to relative directories, for example"paths": ["data/osv"].corpus add --fromsparse-checks out only those directories. Cone mode would also materialize every file in ancestor directories (LICENSE, go.mod, root tests), andcorpus indexwalks 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). Omittingpathsstill 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; droppingpathsrestores it. The list is written back intocorpus.json, so a shared manifest rebuilds the same limited tree.The go-vulndb manifest itself lives on
corpus-huband 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, andcmd, then asserts the worktree.corpus_add_from_paths_harvests_only_those_directoriespassed, which asserts: nopathschecks out all 6 files;paths: ["data/osv"]on the same sha narrows the existing checkout to the 2 files underdata/osv(notdata/osv-extra, not LICENSE);corpus.jsonrecords that list andfiles: 2; a second add stays narrow;data/osvpluscmdis 3 files; droppingpathsrestores LICENSE anddata/reports. The refusal test passed, which asserts a missing directory exits 1 with nocorpus.jsonand no full checkout, and../secretexits 2 before the corpus directory is created.Checks
cargo fmtwith the 1.97.1 rustfmt on the four touched files (rustfmt --checkclean)cargo build --release -j 32 -p <crate>cargo test -p xerj-common --lib xccode::andcargo test -p xerj-autoindex --lib corpus_add(dev profile, notci-test)corpus add --fromcheckout and the hub-manifest parser.tools/xerj-code/hub/README.mddescribespathsdocs/CONTRIBUTION_REVIEW.md: ancestry is one commit on currentmain; the whole-pin path is preserved whenpathsis 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 whenpathsis removed. No durable index or mapping migration.Not run:
cargo build --releaseandcargo 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
git sparse-checkout set --no-cone -- /data/osv/was also checked by hand on git 2.43.0 before the implementation: it materializeddata/osvonly, andgit sparse-checkout disablerestored the full tree.ubuntu-latestgit still acceptssparse-checkout set --no-cone. A git that rejects--no-conefails the checkout (the repo is skipped, the whole pin is not harvested). That assumption is false if CI's git errors on--no-coneandcorpus_add_from_paths_harvests_only_those_directoriesfails.Fixes #1842