Repository navigation
feat(rust): select tests through Cargo crate dependencies - #92
Conversation
Signed-off-by: FredApps <[email protected]>
Signed-off-by: FredApps <[email protected]>
adityankale190895
left a comment
There was a problem hiding this comment.
Reviewed the incremental diff on top of #91. I found nothing that could skip a needed test. The concern is the opposite: as written, no real crate can narrow. Your glob replay and the note in #95 ("no verified public workspace meeting all current gates") point the same way.
Blockers that fire on almost every real repo
1. External dependencies block the whole repo. The checks for dependencies outside the workspace, build scripts and procedural macros run over all of metadata.packages, which now includes every resolved registry and Git dependency. serde_derive (proc-macro) or libc (build script) anywhere in the graph is enough. Locked registry and Git dependencies are immutable unless Cargo.lock changes, and #94 already sends any Cargo.lock change to a full run. Could these three blockers apply only to workspace members and local path dependencies?
2. The feature-unification blocker fires on any features = [...] or default-features = false. Almost every crate has one. The risk you describe is narrower: a shared dependency whose requested features differ between the selected -p set and the rest of the workspace. That can be computed from resolve.nodes[].features and each member's dependency declarations. Could the blocker fire only when a subset would actually change unification?
3. The rustInputs denylist is very broad. Any identifier fs, process, unsafe, extern, exists, metadata, is_file and so on blocks the file, and so the repo. Ordinary code like extern crate foo;, std::process::exit(1), a field named metadata or a small unsafe block trips it. The Python adapter doesn't treat open() as a blocker, so the two adapters are inconsistent. Could this target path-taking calls with non-literal paths, or follow the existing adapters' runtime-read policy?
Smaller notes
completeRustInventoryblocks on any symlink anywhere in the repo, Rust or not, and on more than 50,000 entries.- The Cargo config check covers the repo's
.cargo/config(.toml), but not$CARGO_HOME/config.tomlor parent-directory configs. The environment check skipsRUSTDOCFLAGS, which affects doctests, andCARGO_BUILD_TARGET. That's a small inconsistency given how strict the rest is. - The symlinked-root path issue from my #91 review applies to all the new
repositoryPathandownercalls here.
Resolve the DiffCI#91 squash merge: keep main's symlinked-checkout fix, grouped fallback-reason rows and maintainer line, and reapply this milestone's crate dependency analysis on top. Signed-off-by: FredApps <[email protected]>
Review on DiffCI#92: the checks were so broad that no real crate could select fewer tests. Keep failing closed where a subset can actually differ. - Locked registry/Git dependencies (including build scripts and proc macros) no longer block; Cargo.lock changes keep the full suite. Local path dependencies outside the workspace still block. - A workspace crate with a build script depends on every workspace crate: it and its dependents run for any Rust change, other crates narrow. - Feature requests no longer block. Cargo (`cargo tree`) resolves each tested crate alone and with its dependents; the coverage is recorded for the planner to check each selected set. Missing evidence blocks. - Drop the fs/process/unsafe/extern keyword denylist. Literal paths that reach another crate, and code that runs Cargo/rustc, become crate dependencies instead of blockers. - Check only module trees for symlinks and unlisted sources (no 50k cap; linked LICENSE/README files are fine). - Read parent-directory and $CARGO_HOME Cargo config, block only build-changing keys, and include RUSTDOCFLAGS and CARGO_BUILD_TARGET. Signed-off-by: FredApps <[email protected]>
|
@FredApps thanks for bringing #92–#95 up to date after #91 landed. All four merge cleanly and CI is green on Linux and Windows. Before we merge, here's where the stack stands. The 11 November review points don't seem to have changed yet, so I've gathered the open items in one place: Must change before merge
Please reply, even if the answer is "follow-up"
Items 2–4 and 6 don't have to block this stack. I've opened #131 to track real-repository selectivity, so a short answer here plus a pointer to #131 is fine. On your #91 proposal (narrow the out-of-workspace Once item 1 is done and item 5 is in the description, please mark #92 ready and we'll squash-merge #92 → #95 in order. #62 will be closed when they merge, and the remaining work continues in #131. |
… per command Review on DiffCI#93: plain `cargo test` tests only the root package of a non-virtual workspace, or `default-members`. Register test targets only for `workspace_default_members`, so a selective run stays a subset of the full one; other members remain sources that reach tested dependents. Metadata without default members (Cargo < 1.71) falls back. With DiffCI#92's feature coverage, every synthesized Cargo invocation must contain a unit Cargo resolved with the full run's features for each package a selected crate would otherwise build differently; otherwise the plan is refused. Profiles without coverage are refused. Also keep release-files.json alphabetical. Signed-off-by: FredApps <[email protected]>
|
@FredApps thanks for Blocking: tests that read another crate's files can be missed (
|
How a's test reaches b/src/lib.rs |
Depends on b? |
|---|---|
Path::new(env!("CARGO_MANIFEST_DIR")).join("../b/src/lib.rs") |
yes |
.parent().unwrap().join("b").join("src").join("lib.rs") |
no |
.parent().unwrap().join("b/src/lib.rs") |
no |
.ancestors().nth(2) followed by walking the directory tree |
no |
In the three failing cases there's no blocker and no dependency, so a change to b skips a's test.
Reproduction (node:test, synthetic metadata, no Cargo needed)
const manifest = (n: string) => `[package]\nname = "${n}"\nversion = "0.1.0"\nedition = "2021"\n`;
const files = {
"Cargo.toml": '[workspace]\nmembers = ["crates/a", "crates/b"]\nresolver = "2"\n',
"crates/a/Cargo.toml": manifest("a"), "crates/a/src/lib.rs": "",
"crates/a/tests/scan.rs": 'use std::path::Path;\n#[test] fn t() { let p = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap().join("b").join("src").join("lib.rs"); assert!(std::fs::read_to_string(p).unwrap().contains("fn")); }',
"crates/b/Cargo.toml": manifest("b"), "crates/b/src/lib.rs": "pub fn f() {}",
};
// a: lib + test target "scan"; b: lib. Both are workspace (default) members with no resolve dependencies.
// Expected: an edge crates/a/Cargo.toml -> crates/b/Cargo.toml, or a blocker.
// Actual: blockers = [] and no edge.Suggested fix that keeps the narrowing: treat this like the compiles case. A source file that combines file access with CARGO_MANIFEST_DIR, current_dir, .parent() or .ancestors() should depend on every workspace crate. That puts the cost only on the crates that do it, not on the whole repository. Please add the three failing cases as regression tests.
Non-blocking
cargo treecost. It runs up to twice per tested crate (capped at 400 runs, each with a 60 s timeout) on every analysis. On a workspace with about 100 crates and dependency features, that could take minutes. Can the coverage be cached byCargo.lockplus the member manifests?- Package key in
parseCargoFeatureTree. Packages are identified only byname vX.Y.Z. A path dependency and a registry crate with the same name and version would collide. The{p}output includes the source, which could go into the key.
Looks good
- Workspace scope (
ee9617b). Registering test targets only forworkspace_default_memberskeeps selective runs within what plaincargo testcovers, and older Cargo versions get a full run. This resolves the earlier feat(rust): synthesize conservative cargo test commands #93 point. - Planner feature check. It's sound: feature unification only adds features, so a unit inside the selection that already matches the full run gives the selected command the full run's features. Missing coverage refuses the plan.
- Dependencies. Locked registry and Git dependencies no longer block, and a
Cargo.lockchange still runs everything. Crates with build scripts and code that runscargonow depend on every crate. - Cargo config and symlinks. Only build-changing config keys block, wherever Cargo reads them. Symlinks outside module directories no longer block.
From the earlier comment, #94 and #95 still need the rust-replay.yml trigger change and the description of the changes that affect other adapters. #131 will be trimmed to what's left once the stack merges.
|
@adityankale190895 thanks, agreed that the old checks left nothing real able to narrow. I merged 1. External dependencies. Locked registry and Git packages no longer block, including their build scripts and proc macros.
Workspace proc-macro crates are ordinary edges now. Tests: 2. Feature unification.
That way host and target feature sets aren't merged. The result goes into the profile as feature coverage. #93 refuses any 3. 4. Inventory. The 50,000 cap is gone, and only Rust module trees are checked. Symlinked 5. Config and environment. Cargo config is now read from parent directories and 6. Symlinked root. This is fixed by the #91 change that came in with the Local results: typecheck, build, boundary audit and agent check pass, and the full suite has 1011 passing tests. Hosted Linux/Windows × Node 22/24 is green on this head. |
|
@adityankale190895 #92–#95 are updated from |
Review on DiffCI#92: a test that reads another crate's files only counted as depending on it when the code held a literal path to that crate. Tests that check every crate's files usually build the path instead, through .parent(), .ancestors(), PathBuf::pop or a formatted '..' path, so a change to the other crate skipped them. Treat such code like code that runs Cargo: its crate depends on every workspace crate. It only fires where the file also works with paths, so tree parent() methods and Vec::pop keep narrowing. Crate-local paths built from CARGO_MANIFEST_DIR stay narrow; the literal pass resolves them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: adityankale190895 <[email protected]>
* feat(rust): map Cargo packages and test targets (#58) Signed-off-by: FredApps <[email protected]> * feat(rust): select workspace tests by crate dependencies (#59) Signed-off-by: FredApps <[email protected]> * feat(rust): synthesize conservative Cargo test commands (#60) Signed-off-by: FredApps <[email protected]> * fix(rust): narrow dependency, feature and runtime-input blockers Review on #92: the checks were so broad that no real crate could select fewer tests. Keep failing closed where a subset can actually differ. - Locked registry/Git dependencies (including build scripts and proc macros) no longer block; Cargo.lock changes keep the full suite. Local path dependencies outside the workspace still block. - A workspace crate with a build script depends on every workspace crate: it and its dependents run for any Rust change, other crates narrow. - Feature requests no longer block. Cargo (`cargo tree`) resolves each tested crate alone and with its dependents; the coverage is recorded for the planner to check each selected set. Missing evidence blocks. - Drop the fs/process/unsafe/extern keyword denylist. Literal paths that reach another crate, and code that runs Cargo/rustc, become crate dependencies instead of blockers. - Check only module trees for symlinks and unlisted sources (no 50k cap; linked LICENSE/README files are fine). - Read parent-directory and $CARGO_HOME Cargo config, block only build-changing keys, and include RUSTDOCFLAGS and CARGO_BUILD_TARGET. Signed-off-by: FredApps <[email protected]> * fix(rust): select only crates plain cargo test covers; check features per command Review on #93: plain `cargo test` tests only the root package of a non-virtual workspace, or `default-members`. Register test targets only for `workspace_default_members`, so a selective run stays a subset of the full one; other members remain sources that reach tested dependents. Metadata without default members (Cargo < 1.71) falls back. With #92's feature coverage, every synthesized Cargo invocation must contain a unit Cargo resolved with the full run's features for each package a selected crate would otherwise build differently; otherwise the plan is refused. Profiles without coverage are refused. Also keep release-files.json alphabetical. Signed-off-by: FredApps <[email protected]> * fix(rust): paths that climb out of a crate in code depend on every crate Review on #92: a test that reads another crate's files only counted as depending on it when the code held a literal path to that crate. Tests that check every crate's files usually build the path instead, through .parent(), .ancestors(), PathBuf::pop or a formatted '..' path, so a change to the other crate skipped them. Treat such code like code that runs Cargo: its crate depends on every workspace crate. It only fires where the file also works with paths, so tree parent() methods and Vec::pop keep narrowing. Crate-local paths built from CARGO_MANIFEST_DIR stay narrow; the literal pass resolves them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: adityankale190895 <[email protected]> --------- Signed-off-by: FredApps <[email protected]> Signed-off-by: adityankale190895 <[email protected]> Co-authored-by: adityankale190895 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
…#94) * feat(rust): map Cargo packages and test targets (#58) Signed-off-by: FredApps <[email protected]> * feat(rust): select workspace tests by crate dependencies (#59) Signed-off-by: FredApps <[email protected]> * feat(rust): synthesize conservative Cargo test commands (#60) Signed-off-by: FredApps <[email protected]> * feat(rust): register conservative Cargo adapter and document boundaries Signed-off-by: FredApps <[email protected]> * fix(rust): narrow dependency, feature and runtime-input blockers Review on #92: the checks were so broad that no real crate could select fewer tests. Keep failing closed where a subset can actually differ. - Locked registry/Git dependencies (including build scripts and proc macros) no longer block; Cargo.lock changes keep the full suite. Local path dependencies outside the workspace still block. - A workspace crate with a build script depends on every workspace crate: it and its dependents run for any Rust change, other crates narrow. - Feature requests no longer block. Cargo (`cargo tree`) resolves each tested crate alone and with its dependents; the coverage is recorded for the planner to check each selected set. Missing evidence blocks. - Drop the fs/process/unsafe/extern keyword denylist. Literal paths that reach another crate, and code that runs Cargo/rustc, become crate dependencies instead of blockers. - Check only module trees for symlinks and unlisted sources (no 50k cap; linked LICENSE/README files are fine). - Read parent-directory and $CARGO_HOME Cargo config, block only build-changing keys, and include RUSTDOCFLAGS and CARGO_BUILD_TARGET. Signed-off-by: FredApps <[email protected]> * fix(rust): select only crates plain cargo test covers; check features per command Review on #93: plain `cargo test` tests only the root package of a non-virtual workspace, or `default-members`. Register test targets only for `workspace_default_members`, so a selective run stays a subset of the full one; other members remain sources that reach tested dependents. Metadata without default members (Cargo < 1.71) falls back. With #92's feature coverage, every synthesized Cargo invocation must contain a unit Cargo resolved with the full run's features for each package a selected crate would otherwise build differently; otherwise the plan is refused. Profiles without coverage are refused. Also keep release-files.json alphabetical. Signed-off-by: FredApps <[email protected]> * fix(rust): keep registration Rust-only; narrow docs, invocation and fixture fallbacks Review on #94: 1. Documentation changes follow the shared classification (no tests, no fallback) unless Rust code names a documentation path or a workspace build script exists; include_str!'d docs stay modelled assets. .github/** keeps the full suite: it is the invocation evidence. 2. Leave Maven, Python and Go behaviour as on main: the test matcher adds only Rust targets, goTestPackages only drops Rust contributions, and hydrated graphs only trust declared test identities for .rs nodes. 3. Accept ordinary CI around a plain `cargo test`: checkout, toolchain and cache actions, a matrix, output-only env, and build/clippy/fmt/doc/ rustup steps or jobs. Test flags, other runners, compiler env, conditional or relocated test steps and unknown actions stay advisory. 4. Label Rust support experimental in the docs. From #91 (point 2): Cargo manifests outside the workspace no longer block the repository when metadata shows no member depends on them; their files stay unmodelled, so changing one keeps the full suite. Also pass Cargo feature coverage and documentation readers to the profile. Signed-off-by: FredApps <[email protected]> * fix(rust): paths that climb out of a crate in code depend on every crate Review on #92: a test that reads another crate's files only counted as depending on it when the code held a literal path to that crate. Tests that check every crate's files usually build the path instead, through .parent(), .ancestors(), PathBuf::pop or a formatted '..' path, so a change to the other crate skipped them. Treat such code like code that runs Cargo: its crate depends on every workspace crate. It only fires where the file also works with paths, so tree parent() methods and Vec::pop keep narrowing. Crate-local paths built from CARGO_MANIFEST_DIR stay narrow; the literal pass resolves them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: adityankale190895 <[email protected]> * fix(rust): find documentation reads through relative and walked paths Review on #94: a test that reached docs/ through "../docs", concat!(env!("CARGO_MANIFEST_DIR"), "/../docs") or a directory walk that matched the "md" extension was not recorded as reading documentation, so a docs-only change ran no tests and kept no fallback. Match a documentation directory anywhere in a path, a Markdown name or a bare md/mdx extension, and count code that climbs out of its crate as a documentation reader too. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: adityankale190895 <[email protected]> --------- Signed-off-by: FredApps <[email protected]> Signed-off-by: adityankale190895 <[email protected]> Co-authored-by: adityankale190895 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
* feat(rust): map Cargo packages and test targets (#58) Signed-off-by: FredApps <[email protected]> * feat(rust): select workspace tests by crate dependencies (#59) Signed-off-by: FredApps <[email protected]> * feat(rust): synthesize conservative Cargo test commands (#60) Signed-off-by: FredApps <[email protected]> * feat(rust): register conservative Cargo adapter and document boundaries Signed-off-by: FredApps <[email protected]> * test(rust): add pinned public glob replay on hosted CI Signed-off-by: FredApps <[email protected]> * docs(rust): publish measured glob replay and fallback limits Signed-off-by: FredApps <[email protected]> * test(rust): execute selections from real Git changes Signed-off-by: FredApps <[email protected]> * docs(rust): publish Linux selective execution evidence Signed-off-by: FredApps <[email protected]> * fix(rust): narrow dependency, feature and runtime-input blockers Review on #92: the checks were so broad that no real crate could select fewer tests. Keep failing closed where a subset can actually differ. - Locked registry/Git dependencies (including build scripts and proc macros) no longer block; Cargo.lock changes keep the full suite. Local path dependencies outside the workspace still block. - A workspace crate with a build script depends on every workspace crate: it and its dependents run for any Rust change, other crates narrow. - Feature requests no longer block. Cargo (`cargo tree`) resolves each tested crate alone and with its dependents; the coverage is recorded for the planner to check each selected set. Missing evidence blocks. - Drop the fs/process/unsafe/extern keyword denylist. Literal paths that reach another crate, and code that runs Cargo/rustc, become crate dependencies instead of blockers. - Check only module trees for symlinks and unlisted sources (no 50k cap; linked LICENSE/README files are fine). - Read parent-directory and $CARGO_HOME Cargo config, block only build-changing keys, and include RUSTDOCFLAGS and CARGO_BUILD_TARGET. Signed-off-by: FredApps <[email protected]> * fix(rust): select only crates plain cargo test covers; check features per command Review on #93: plain `cargo test` tests only the root package of a non-virtual workspace, or `default-members`. Register test targets only for `workspace_default_members`, so a selective run stays a subset of the full one; other members remain sources that reach tested dependents. Metadata without default members (Cargo < 1.71) falls back. With #92's feature coverage, every synthesized Cargo invocation must contain a unit Cargo resolved with the full run's features for each package a selected crate would otherwise build differently; otherwise the plan is refused. Profiles without coverage are refused. Also keep release-files.json alphabetical. Signed-off-by: FredApps <[email protected]> * fix(rust): keep registration Rust-only; narrow docs, invocation and fixture fallbacks Review on #94: 1. Documentation changes follow the shared classification (no tests, no fallback) unless Rust code names a documentation path or a workspace build script exists; include_str!'d docs stay modelled assets. .github/** keeps the full suite: it is the invocation evidence. 2. Leave Maven, Python and Go behaviour as on main: the test matcher adds only Rust targets, goTestPackages only drops Rust contributions, and hydrated graphs only trust declared test identities for .rs nodes. 3. Accept ordinary CI around a plain `cargo test`: checkout, toolchain and cache actions, a matrix, output-only env, and build/clippy/fmt/doc/ rustup steps or jobs. Test flags, other runners, compiler env, conditional or relocated test steps and unknown actions stay advisory. 4. Label Rust support experimental in the docs. From #91 (point 2): Cargo manifests outside the workspace no longer block the repository when metadata shows no member depends on them; their files stay unmodelled, so changing one keeps the full suite. Also pass Cargo feature coverage and documentation readers to the profile. Signed-off-by: FredApps <[email protected]> * ci(rust): run glob replay on demand, execution proof in one Linux job Signed-off-by: FredApps <[email protected]> * fix(rust): paths that climb out of a crate in code depend on every crate Review on #92: a test that reads another crate's files only counted as depending on it when the code held a literal path to that crate. Tests that check every crate's files usually build the path instead, through .parent(), .ancestors(), PathBuf::pop or a formatted '..' path, so a change to the other crate skipped them. Treat such code like code that runs Cargo: its crate depends on every workspace crate. It only fires where the file also works with paths, so tree parent() methods and Vec::pop keep narrowing. Crate-local paths built from CARGO_MANIFEST_DIR stay narrow; the literal pass resolves them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: adityankale190895 <[email protected]> * fix(rust): find documentation reads through relative and walked paths Review on #94: a test that reached docs/ through "../docs", concat!(env!("CARGO_MANIFEST_DIR"), "/../docs") or a directory walk that matched the "md" extension was not recorded as reading documentation, so a docs-only change ran no tests and kept no fallback. Match a documentation directory anywhere in a path, a Markdown name or a bare md/mdx extension, and count code that climbs out of its crate as a documentation reader too. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: adityankale190895 <[email protected]> --------- Signed-off-by: FredApps <[email protected]> Signed-off-by: adityankale190895 <[email protected]> Co-authored-by: adityankale190895 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Fixes #59. Part 2 of #62, after #91 (merged).
#91 has landed and
mainis merged in, so this PR's diff is only this milestone. The milestone is 580285d plus the review fixes in a2255f6. It stays unregistered until the integration milestone (#94).Changes
Cargo.lockchanges, and aCargo.lockchange keeps the full suite. Workspace proc-macro crates are ordinary dependency edges.features = [...]anddefault-features = falseare fine. The adapter asks Cargo itself (cargo tree --offline --locked -e normal,build,dev -f "{p}|{f}") how each tested crate resolves on its own and together with its dependents, compared with the full workspace. It records that as feature coverage, and feat(rust): synthesize conservative cargo test commands #93 refuses any command that would build a package with different features than the full run.fs,process,unsafe,extern crate,metadatafields and similar are ordinary code, as in the other adapters. Literal paths that reach another crate become crate edges, and so does code that runscargo/rustc.$CARGO_HOME. Only build-changing keys block (build.*,target.*,env,[patch]/[source]/pathsand similar), not[profile]or[term]. The compiler environment check includesRUSTDOCFLAGSandCARGO_BUILD_TARGET.Remaining full-run fallbacks
pathdependencies outside the workspace, which can change withoutCargo.lockchanging.cargo treeevidence missing or invalid).include!/#[path]arguments, includes outside the crate, and included non-.rscode..rsfiles or directories inside module trees, unlisted or discovery-excluded Rust sources, and incomplete ownership.The selective boundary is still local workspace crates, not arbitrary Cargo projects.
cfg(feature)source alone is not a blocker.Validation
Typecheck, build, release-boundary audit and agent check pass, and the full suite passes locally on Linux (1011 tests). Each loosened case and each remaining fallback has an adapter test. Real-Cargo tests cover workspaces, optional/dev dependencies, unchanged lockfiles, feature-unified unit tests, and a realistic workspace with a build script, a local derive crate, feature requests and file I/O that now narrows. Hosted Linux/Windows Node 22/24 checks, CLI packaging, Observer Action smoke and CodeQL pass on this head.
DCO signed off. Review replies: #92 (comment)