From d6cd46d5f216e7af9affb16db1e3d73a23f4dd04 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Tue, 17 Nov 2026 23:33:43 +0700 Subject: [PATCH 1/3] fix(rust): resolve literal paths from the workspace root too --- src/repo/adapters/rust.ts | 6 +++++- tests/repo/rust-adapter.test.ts | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/repo/adapters/rust.ts b/src/repo/adapters/rust.ts index 76aa08e2..6cabb731 100644 --- a/src/repo/adapters/rust.ts +++ b/src/repo/adapters/rust.ts @@ -492,10 +492,14 @@ export function analyzeRustMetadata(context: AdapterContext, output: string, res const clean = literal.replace(/\\/g, "/").replace(/^(?:[A-Za-z]:)?\/+/, ""); const glob = clean.search(/[*?[{]/); const prefix = glob < 0 ? clean : clean.slice(0, clean.lastIndexOf("/", glob) + 1); - for (const base of new Set([sourceOwner.directory, dirname(source) === "." ? "" : dirname(source)])) { + // Also from the workspace root: rustc and proc macros run there, and `[env]` paths such as + // CARGO_WORKSPACE_DIR start there. From the root, only a path below it names a crate. + const bases = [sourceOwner.directory, dirname(source) === "." ? "" : dirname(source)]; + for (const [index, base] of [...bases, ""].entries()) { const joined = posix.normalize(posix.join(base || ".", prefix || ".")); if (joined === ".." || joined.startsWith("../")) continue; const rel = joined === "." ? "" : joined.replace(/\/+$/, ""); + if (index === bases.length && !rel) continue; const inside = rel ? owner(rel) ?? owner(`${rel}/`) : packages.find(pkg => pkg.directory === ""); if (inside) reached.add(inside.manifest); for (const other of packages) if (other.directory && (rel === "" || under(other.directory, rel) || other.directory === rel)) reached.add(other.manifest); diff --git a/tests/repo/rust-adapter.test.ts b/tests/repo/rust-adapter.test.ts index 9675ceba..068e9365 100644 --- a/tests/repo/rust-adapter.test.ts +++ b/tests/repo/rust-adapter.test.ts @@ -336,6 +336,28 @@ mod tests { } finally { rmSync(root, { recursive: true, force: true }); } }); +test("literal paths from the workspace root reach the crate they name", () => { + const files = { "Cargo.toml": '[workspace]\nmembers=["crates/app", "crates/other", "crates/third"]\n', + ".cargo/config.toml": '[env]\nCARGO_WORKSPACE_DIR = { value = "", relative = true }\n', + "crates/app/Cargo.toml": manifest("app"), "crates/app/src/lib.rs": "", "crates/other/Cargo.toml": manifest("other"), "crates/other/src/lib.rs": "", + "crates/third/Cargo.toml": manifest("third"), "crates/third/src/lib.rs": "" }; + const root = fixture(files); + try { + const context = { repoPath: root, files: Object.keys(files), profile: analyzeRepository({ repoPath: root }) }; + const output = metadata(root, [pkg(root, "crates/app", "app"), pkg(root, "crates/other", "other"), pkg(root, "crates/third", "third")]); + const reads = (source: string) => { + writeFileSync(join(root, "crates/app/src/lib.rs"), source); + const result = analyzeRustMetadata(context, output); + assert.deepEqual(result.blockers, [], source); + return result.edges.filter(edge => edge.from === "crates/app/Cargo.toml" && edge.to.endsWith("Cargo.toml")).map(edge => edge.to).sort(); + }; + assert.deepEqual(reads('#[test] fn header() { let p = std::path::Path::new(env!("CARGO_WORKSPACE_DIR")).join("crates/other/src/lib.rs"); std::fs::read_to_string(p).unwrap(); }'), ["crates/other/Cargo.toml"]); + assert.deepEqual(reads('#[test] fn all() { let _ = std::fs::read_dir(concat!(env!("CARGO_WORKSPACE_DIR"), "crates/")); }'), ["crates/other/Cargo.toml", "crates/third/Cargo.toml"]); + // The root itself, or a path that only makes sense inside the crate, is not a read of another crate. + assert.deepEqual(reads('#[test] fn local() { let _ = std::fs::read("tests/data/input.bin"); let _ = format!("{}/{}", "a", "b"); let _ = std::path::Path::new("/"); }'), []); + } finally { rmSync(root, { recursive: true, force: true }); } +}); + test("registry dependencies narrow; local outside path dependencies, symlinked modules and discovery-excluded Rust sources fail closed", (t) => { const files = { "Cargo.toml": manifest("app"), "src/lib.rs": "mod helper;", "src/helper.rs": "pub fn helper() {}" }; const root = fixture(files); From 28b49a3ddb4b8969ad51261735b92b5d2cad7061 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Wed, 18 Nov 2026 00:17:56 +0700 Subject: [PATCH 2/3] ci: re-run checks after an unrelated flaky failure From 42a254c75d94074836f880710e0bb79b17a4fbcb Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Wed, 18 Nov 2026 07:44:57 +0700 Subject: [PATCH 3/3] chore: DCO remediation for d6cd46d, 28b49a3 I, FredApps <153173854+FredApps@users.noreply.github.com>, hereby add my Signed-off-by to this commit: d6cd46d5f216e7af9affb16db1e3d73a23f4dd04 I, FredApps <153173854+FredApps@users.noreply.github.com>, hereby add my Signed-off-by to this commit: 28b49a3ddb4b8969ad51261735b92b5d2cad7061 Signed-off-by: FredApps <153173854+FredApps@users.noreply.github.com>