@diffci.com/diffci 0.3.55 → 0.3.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/src/client/cli.js +4 -3
- package/dist-client/src/client/context.d.ts +2 -0
- package/dist-client/src/client/context.js +19 -0
- package/dist-client/src/client/full-command.js +5 -2
- package/dist-client/src/client/gate-checks.d.ts +5 -2
- package/dist-client/src/client/gate-checks.js +60 -5
- package/dist-client/src/client/gate.js +24 -10
- package/dist-client/src/client/job-summary.d.ts +1 -1
- package/dist-client/src/client/job-summary.js +2 -1
- package/dist-client/src/client/observe.js +1 -1
- package/dist-client/src/client/report.d.ts +7 -0
- package/dist-client/src/client/report.js +11 -0
- package/dist-client/src/client/workflow-guard.js +27 -6
- package/dist-client/src/client/workflow-templates.d.ts +11 -1
- package/dist-client/src/client/workflow-templates.js +43 -2
- package/node_modules/@diffci.com/core/README.md +6 -6
- package/node_modules/@diffci.com/core/dist/ci-inference/resolve.js +20 -2
- package/node_modules/@diffci.com/core/dist/ci-inference/resolve.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/git/git-diff.js +49 -12
- package/node_modules/@diffci.com/core/dist/git/git-diff.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/planner/python-checks.d.ts +55 -0
- package/node_modules/@diffci.com/core/dist/planner/python-checks.js +258 -0
- package/node_modules/@diffci.com/core/dist/planner/python-checks.js.map +1 -0
- package/node_modules/@diffci.com/core/dist/repo/adapters/maven.js +51 -8
- package/node_modules/@diffci.com/core/dist/repo/adapters/maven.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/python.js +111 -14
- package/node_modules/@diffci.com/core/dist/repo/adapters/python.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/rust-invocation.d.ts +3 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/rust-invocation.js +44 -6
- package/node_modules/@diffci.com/core/dist/repo/adapters/rust-invocation.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/rust.js +158 -9
- package/node_modules/@diffci.com/core/dist/repo/adapters/rust.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/types.d.ts +3 -0
- package/node_modules/@diffci.com/core/dist/repo/adapters/types.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/graph.js +1 -1
- package/node_modules/@diffci.com/core/dist/repo/graph.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/impact.js +5 -1
- package/node_modules/@diffci.com/core/dist/repo/impact.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/yarn-berry-lockfile.d.ts +11 -0
- package/node_modules/@diffci.com/core/dist/repo/yarn-berry-lockfile.js +208 -0
- package/node_modules/@diffci.com/core/dist/repo/yarn-berry-lockfile.js.map +1 -0
- package/node_modules/@diffci.com/core/dist/repo/yarn-lockfile.d.ts +3 -0
- package/node_modules/@diffci.com/core/dist/repo/yarn-lockfile.js +2 -2
- package/node_modules/@diffci.com/core/dist/repo/yarn-lockfile.js.map +1 -1
- package/node_modules/@diffci.com/core/src/ci-inference/resolve.ts +20 -2
- package/node_modules/@diffci.com/core/src/git/git-diff.ts +44 -12
- package/node_modules/@diffci.com/core/src/planner/python-checks.ts +244 -0
- package/node_modules/@diffci.com/core/src/repo/adapters/maven.ts +55 -8
- package/node_modules/@diffci.com/core/src/repo/adapters/python.ts +86 -14
- package/node_modules/@diffci.com/core/src/repo/adapters/rust-invocation.ts +44 -6
- package/node_modules/@diffci.com/core/src/repo/adapters/rust.ts +129 -9
- package/node_modules/@diffci.com/core/src/repo/adapters/types.ts +3 -0
- package/node_modules/@diffci.com/core/src/repo/graph.ts +1 -1
- package/node_modules/@diffci.com/core/src/repo/impact.ts +3 -1
- package/node_modules/@diffci.com/core/src/repo/yarn-berry-lockfile.ts +178 -0
- package/node_modules/@diffci.com/core/src/repo/yarn-lockfile.ts +2 -2
- package/package.json +2 -2
|
@@ -199,7 +199,7 @@ function completeRustInventory(root: string, files: ReadonlySet<string>, trees:
|
|
|
199
199
|
|
|
200
200
|
/** A small lexer, not a Rust parser: ignore comments/strings, but never guess
|
|
201
201
|
* a computed include. Nested comments and raw strings must not hide an input. */
|
|
202
|
-
function rustInputs(source: string): { inputs: Array<{ path: string; code: boolean }>; paths: string[]; compiles: boolean; navigates: boolean; documentation: boolean; runsPrograms: boolean } | undefined {
|
|
202
|
+
function rustInputs(source: string): { inputs: Array<{ path: string; code: boolean; module?: string[] }>; paths: string[]; compiles: boolean; navigates: boolean; documentation: boolean; runsPrograms: boolean } | undefined {
|
|
203
203
|
const tokens: Array<{ value: string; literal?: string }> = [];
|
|
204
204
|
for (let i = 0; i < source.length;) {
|
|
205
205
|
if (/\s/.test(source[i]!)) { i++; continue; }
|
|
@@ -242,24 +242,54 @@ function rustInputs(source: string): { inputs: Array<{ path: string; code: boole
|
|
|
242
242
|
// dependency edge cannot see is code that reaches another crate's modelled Rust inputs at run or
|
|
243
243
|
// build time. Report literal paths (the caller checks which crates they reach) and Cargo/rustc
|
|
244
244
|
// invocations; ordinary identifiers such as `fs`, `process`, `unsafe` or `metadata` are not inputs.
|
|
245
|
-
const inputs: Array<{ path: string; code: boolean }> = [];
|
|
245
|
+
const inputs: Array<{ path: string; code: boolean; module?: string[] }> = [];
|
|
246
|
+
// Inline `mod name { ... }` blocks open around each token, for `#[path]` (null: any other brace).
|
|
247
|
+
const blocks: Array<string | null> = [];
|
|
246
248
|
const paths: string[] = [];
|
|
247
249
|
let compiles = false;
|
|
248
250
|
let runsPrograms = false;
|
|
249
251
|
const includeArguments = new Set<number>();
|
|
250
252
|
for (let i = 0; i < tokens.length; i++) {
|
|
251
253
|
if (tokens[i]!.value === "mod" && tokens[i + 1]?.value === "target" && tokens[i + 2]?.value === ";") return undefined;
|
|
254
|
+
if (tokens[i]!.value === "{") blocks.push(tokens[i - 2]?.value === "mod" && /^[A-Za-z_]/.test(tokens[i - 1]?.value ?? "") ? tokens[i - 1]!.value : null);
|
|
255
|
+
if (tokens[i]!.value === "}") blocks.pop();
|
|
252
256
|
if (tokens[i]!.value === "#") {
|
|
253
257
|
let j = i + 1;
|
|
254
258
|
if (tokens[j]?.value === "!") j++;
|
|
255
259
|
if (tokens[j]?.value === "[") {
|
|
256
260
|
let depth = 1;
|
|
261
|
+
const paths: string[] = [];
|
|
257
262
|
for (j++; j < tokens.length && depth; j++) {
|
|
258
263
|
if (tokens[j]!.value === "[") depth++;
|
|
259
264
|
if (tokens[j]!.value === "]") depth--;
|
|
260
|
-
if (tokens[j]!.value === "path" && tokens[j + 1]?.value === "=")
|
|
265
|
+
if (tokens[j]!.value === "path" && tokens[j + 1]?.value === "=") {
|
|
266
|
+
// `#[path = "x.rs"]` or `#[cfg_attr(pred, path = "x.rs")]` with a plain literal.
|
|
267
|
+
const literal = tokens[j + 2]?.literal;
|
|
268
|
+
if (tokens[i + 1]?.value === "!" || !["[", ","].includes(tokens[j - 1]?.value ?? "") || literal === undefined
|
|
269
|
+
|| !["]", ",", ")"].includes(tokens[j + 3]?.value ?? "") || /[\0\r\n]/.test(literal)) return undefined;
|
|
270
|
+
paths.push(literal);
|
|
271
|
+
}
|
|
261
272
|
}
|
|
262
273
|
if (depth) return undefined;
|
|
274
|
+
if (paths.length) {
|
|
275
|
+
// Only on a file module (`mod name;`), after any other attributes and visibility: on an
|
|
276
|
+
// inline module the path would move every module declared inside it.
|
|
277
|
+
let k = j;
|
|
278
|
+
for (;;) {
|
|
279
|
+
if (tokens[k]?.value === "#" && tokens[k + 1]?.value === "[") {
|
|
280
|
+
let nested = 1;
|
|
281
|
+
for (k += 2; k < tokens.length && nested; k++) nested += tokens[k]!.value === "[" ? 1 : tokens[k]!.value === "]" ? -1 : 0;
|
|
282
|
+
} else if (tokens[k]?.value === "pub" && tokens[k + 1]?.value === "(") {
|
|
283
|
+
k = tokens.findIndex((token, index) => index > k && token.value === ")") + 1;
|
|
284
|
+
if (!k) return undefined;
|
|
285
|
+
} else if (tokens[k]?.value === "pub") k++;
|
|
286
|
+
else break;
|
|
287
|
+
}
|
|
288
|
+
if (tokens[k]?.value !== "mod" || !/^[A-Za-z_]/.test(tokens[k + 1]?.value ?? "") || tokens[k + 2]?.value !== ";") return undefined;
|
|
289
|
+
const module = blocks.filter((name): name is string => name !== null);
|
|
290
|
+
if (blocks.length !== module.length) return undefined;
|
|
291
|
+
for (const path of paths) inputs.push({ path, code: true, module });
|
|
292
|
+
}
|
|
263
293
|
}
|
|
264
294
|
}
|
|
265
295
|
if (tokens[i]!.value === "use") {
|
|
@@ -429,6 +459,7 @@ export function analyzeRustMetadata(context: AdapterContext, output: string, res
|
|
|
429
459
|
const defaults = metadata.workspace_default_members;
|
|
430
460
|
if (!defaults) result.blockers.push("Cargo metadata without default workspace members requires full validation; use Cargo 1.71 or later");
|
|
431
461
|
const tested = new Set(defaults ?? []);
|
|
462
|
+
result.rustAllMembersTested = defaults !== undefined && metadata.workspace_members.every(id => tested.has(id));
|
|
432
463
|
if (new Set(members.map(pkg => pkg.name)).size !== members.length) {
|
|
433
464
|
result.blockers.push("Ambiguous Cargo workspace package names require full validation");
|
|
434
465
|
return result;
|
|
@@ -465,7 +496,16 @@ export function analyzeRustMetadata(context: AdapterContext, output: string, res
|
|
|
465
496
|
// package outside the workspace appears, no member depends on these crates: they are fixtures or
|
|
466
497
|
// excluded crates. Their files stay unmodelled, so changing one keeps the full suite (impact.ts)
|
|
467
498
|
// without blocking changes elsewhere. Otherwise the repository-wide fallback stays.
|
|
468
|
-
|
|
499
|
+
// Local path packages that are not workspace members. Inside the repository they are unmodelled
|
|
500
|
+
// boundaries like fixture crates: a change to one keeps the full suite, and dependency edges
|
|
501
|
+
// through them are followed below. Outside the repository their changes are invisible to the diff.
|
|
502
|
+
const localNonMembers = metadata.packages.filter(pkg => !metadata.workspace_members.includes(pkg.id) && (pkg.source === undefined || pkg.source === null));
|
|
503
|
+
const localInside = new Map<string, string>();
|
|
504
|
+
for (const pkg of localNonMembers) {
|
|
505
|
+
const manifest = repositoryPath(root, pkg.manifest_path, known);
|
|
506
|
+
if (manifest && /(?:^|\/)Cargo\.toml$/.test(manifest) && manifest !== "Cargo.toml" && unmodeledManifests.includes(manifest)) localInside.set(pkg.id, manifest);
|
|
507
|
+
}
|
|
508
|
+
const localDependencyOutside = localNonMembers.some(pkg => !localInside.has(pkg.id));
|
|
469
509
|
const unmodeledBoundary = (file: string) => !localDependencyOutside
|
|
470
510
|
&& unmodeledManifests.some(manifest => under(file, manifest.slice(0, -"/Cargo.toml".length)));
|
|
471
511
|
if (unmodeledManifests.length && localDependencyOutside) result.blockers.push(`Cargo manifests outside workspace membership require full validation: ${unmodeledManifests.join(", ")}`);
|
|
@@ -532,6 +572,9 @@ export function analyzeRustMetadata(context: AdapterContext, output: string, res
|
|
|
532
572
|
const moduleTrees = packages.flatMap(({ pkg }) => pkg.targets.map(target => resolvedPath(root, target.src_path)))
|
|
533
573
|
.filter((path): path is string => path !== undefined).map(path => dirname(path) === "." ? "" : dirname(path));
|
|
534
574
|
if (!completeRustInventory(root, known, moduleTrees)) result.blockers.push("Incomplete Rust source inventory or symlinked inputs require full validation");
|
|
575
|
+
// Crate roots, for `#[path]` inside inline modules; directories of `#[path]` modules, checked below.
|
|
576
|
+
const targetRoots = new Set(packages.flatMap(({ pkg }) => pkg.targets.map(target => resolvedPath(root, target.src_path))));
|
|
577
|
+
const pathModuleTrees: string[] = [];
|
|
535
578
|
result.sourcePaths = [...new Set(result.sourcePaths)].sort();
|
|
536
579
|
result.testFiles.sort();
|
|
537
580
|
if (!result.testFiles.length) result.blockers.push("Cargo metadata found no supported test targets");
|
|
@@ -546,6 +589,46 @@ export function analyzeRustMetadata(context: AdapterContext, output: string, res
|
|
|
546
589
|
const anchor = owner(file)?.manifest;
|
|
547
590
|
if (anchor && anchor !== file) result.edges.push({ from: anchor, to: file, kind: "import" }, { from: file, to: anchor, kind: "import" });
|
|
548
591
|
}
|
|
592
|
+
// Every in-repository local package that is not a workspace member (a vendored or excluded
|
|
593
|
+
// "bridge" crate) is scanned up front, whether or not a member reaches it. Its build scripts and
|
|
594
|
+
// documentation readers count as readers, as members' do, so a docs change keeps the full suite;
|
|
595
|
+
// code that runs programs turns off crate scoping; and code that could read other crates' files
|
|
596
|
+
// makes the members that reach it depend on every workspace crate (below). What cannot be scanned
|
|
597
|
+
// counts as all three.
|
|
598
|
+
const bridgeOpaque = new Map<string, boolean>();
|
|
599
|
+
for (const [id, manifest] of localInside) {
|
|
600
|
+
const directory = manifest.slice(0, -"/Cargo.toml".length);
|
|
601
|
+
const pkg = localNonMembers.find(candidate => candidate.id === id)!;
|
|
602
|
+
const bridgeRoots = new Set(pkg.targets.map(target => resolvedPath(root, target.src_path)));
|
|
603
|
+
let isOpaque = false;
|
|
604
|
+
for (const target of pkg.targets.filter(target => target.kind.includes("custom-build"))) {
|
|
605
|
+
isOpaque = true;
|
|
606
|
+
(result.rustDocumentationReaders ??= []).push(repositoryPath(root, target.src_path, known) ?? manifest);
|
|
607
|
+
}
|
|
608
|
+
for (const file of context.files.filter(file => file.endsWith(".rs") && under(file, directory))) {
|
|
609
|
+
let scanned: ReturnType<typeof rustInputs>;
|
|
610
|
+
try { scanned = rustInputs(readFileSync(resolve(root, file), "utf8")); } catch { scanned = undefined; }
|
|
611
|
+
if (!scanned) {
|
|
612
|
+
isOpaque = true;
|
|
613
|
+
(result.rustDocumentationReaders ??= []).push(file);
|
|
614
|
+
result.rustRunsPrograms = true;
|
|
615
|
+
continue;
|
|
616
|
+
}
|
|
617
|
+
if (scanned.documentation) (result.rustDocumentationReaders ??= []).push(file);
|
|
618
|
+
if (scanned.runsPrograms) result.rustRunsPrograms = true;
|
|
619
|
+
// `#[path]` is relative to the file's directory, and inside inline modules to their names as
|
|
620
|
+
// well, which is only resolvable from a crate root or mod.rs (as for members, below).
|
|
621
|
+
const modRs = bridgeRoots.has(file) || /(?:^|\/)mod\.rs$/.test(file);
|
|
622
|
+
if (scanned.compiles || scanned.navigates || scanned.documentation || scanned.paths.length > 0
|
|
623
|
+
|| scanned.inputs.some(input => {
|
|
624
|
+
if (input.module?.length && !modRs) return true;
|
|
625
|
+
const base = input.module ? posix.join(dirname(file), ...input.module) : dirname(file);
|
|
626
|
+
const path = repositoryPath(root, resolve(root, base, input.path), known);
|
|
627
|
+
return !path || !under(path, directory);
|
|
628
|
+
})) isOpaque = true;
|
|
629
|
+
}
|
|
630
|
+
bridgeOpaque.set(id, isOpaque);
|
|
631
|
+
}
|
|
549
632
|
// Cargo resolves all target platforms unless --filter-platform is supplied.
|
|
550
633
|
// --all-features below unions optional dependencies too; cfg(feature) code
|
|
551
634
|
// stays crate-granular and does not itself make the graph unsafe.
|
|
@@ -557,21 +640,42 @@ export function analyzeRustMetadata(context: AdapterContext, output: string, res
|
|
|
557
640
|
|| metadata.workspace_members.some(id => !nodes.some(node => node.id === id))) {
|
|
558
641
|
result.blockers.push("Cargo dependency resolution is missing or incomplete; full validation required");
|
|
559
642
|
} else {
|
|
643
|
+
// A member can depend on another member through packages outside the workspace (a local path
|
|
644
|
+
// package that itself depends on a member, or a `[patch]`ed crate). Follow dependencies through
|
|
645
|
+
// non-members until they reach members. An in-repository local package whose own code could
|
|
646
|
+
// read other crates' files (a build script, Cargo or program runs, climbing out of its
|
|
647
|
+
// directory, path literals or includes) makes the member depend on every workspace crate.
|
|
648
|
+
const byId = new Map(nodes.map(node => [node.id, node]));
|
|
649
|
+
const opaque = new Map([...localInside.keys()].map(id => [id, bridgeOpaque.get(id) === true]));
|
|
650
|
+
const opaqueLocal = (id: string) => opaque.get(id) === true;
|
|
560
651
|
for (const node of nodes) {
|
|
561
652
|
const anchor = anchors.get(node.id);
|
|
562
653
|
if (!anchor) continue;
|
|
563
|
-
|
|
654
|
+
const reached = new Set<string>();
|
|
655
|
+
let everything = false;
|
|
656
|
+
const seen = new Set<string>([node.id]);
|
|
657
|
+
const pending = [...node.dependencies];
|
|
658
|
+
while (pending.length) {
|
|
659
|
+
const dependency = pending.pop()!;
|
|
660
|
+
if (seen.has(dependency)) continue;
|
|
661
|
+
seen.add(dependency);
|
|
564
662
|
const target = anchors.get(dependency);
|
|
565
|
-
if (target
|
|
663
|
+
if (target) { reached.add(target); continue; }
|
|
664
|
+
if (opaqueLocal(dependency)) everything = true;
|
|
665
|
+
pending.push(...(byId.get(dependency)?.dependencies ?? []));
|
|
566
666
|
}
|
|
667
|
+
if (everything) for (const other of packages) reached.add(other.manifest);
|
|
668
|
+
reached.delete(anchor);
|
|
669
|
+
for (const target of reached) result.edges.push({ from: anchor, to: target, kind: "import" });
|
|
567
670
|
}
|
|
568
671
|
}
|
|
569
672
|
// Registry and Git dependencies are locked and immutable unless Cargo.lock changes, and a
|
|
570
673
|
// Cargo.lock change keeps the full suite. Their build scripts and procedural macros run the same
|
|
571
674
|
// code for the selected and the full invocation; anything they read from this repository outside
|
|
572
675
|
// modelled Rust sources is a changed path that keeps the full suite. A local path dependency that
|
|
573
|
-
// is not a workspace member
|
|
574
|
-
|
|
676
|
+
// is not a workspace member and lives outside the repository can change without the diff showing it,
|
|
677
|
+
// so it still blocks the repository; one inside the repository is an unmodelled boundary (above).
|
|
678
|
+
const localOutside = localNonMembers.filter(pkg => !localInside.has(pkg.id));
|
|
575
679
|
if (localOutside.length) {
|
|
576
680
|
result.blockers.push(`Local Cargo path dependencies outside the workspace require full validation: ${localOutside.map(pkg => pkg.name).sort().join(", ")}`);
|
|
577
681
|
}
|
|
@@ -619,7 +723,15 @@ export function analyzeRustMetadata(context: AdapterContext, output: string, res
|
|
|
619
723
|
reached.delete(sourceOwner.manifest);
|
|
620
724
|
for (const manifest of reached) result.edges.push({ from: sourceOwner.manifest, to: manifest, kind: "import" });
|
|
621
725
|
for (const input of scanned.inputs) {
|
|
622
|
-
|
|
726
|
+
// A `#[path]` is relative to the file's directory; inside inline modules, also to their
|
|
727
|
+
// names, below the file's stem unless it is a crate root or mod.rs.
|
|
728
|
+
const modRs = targetRoots.has(source) || /(?:^|\/)mod\.rs$/.test(source);
|
|
729
|
+
if (input.module?.length && !modRs) {
|
|
730
|
+
result.blockers.push(`Rust computed includes or path attributes require full validation: ${source}`);
|
|
731
|
+
continue;
|
|
732
|
+
}
|
|
733
|
+
const base = input.module ? posix.join(dirname(source), ...input.module) : dirname(source);
|
|
734
|
+
const path = repositoryPath(root, resolve(root, base, input.path), known);
|
|
623
735
|
if (!path || owner(path)?.pkg.id !== sourceOwner.pkg.id) {
|
|
624
736
|
result.blockers.push(`Rust include outside its crate or unavailable requires full validation: ${source}`);
|
|
625
737
|
continue;
|
|
@@ -628,10 +740,18 @@ export function analyzeRustMetadata(context: AdapterContext, output: string, res
|
|
|
628
740
|
result.blockers.push(`Rust include code with a non-Rust extension requires full validation: ${source}`);
|
|
629
741
|
continue;
|
|
630
742
|
}
|
|
743
|
+
if (input.module) {
|
|
744
|
+
// Module source of the same crate: already a source of it. What it declares is looked up
|
|
745
|
+
// from its own directory, so that tree must be complete too.
|
|
746
|
+
pathModuleTrees.push(dirname(path) === "." ? "" : dirname(path));
|
|
747
|
+
result.edges.push({ from: source, to: path, kind: "import" });
|
|
748
|
+
continue;
|
|
749
|
+
}
|
|
631
750
|
if (!result.sourcePaths.includes(path)) result.assetPaths.push(path);
|
|
632
751
|
result.edges.push({ from: source, to: path, kind: "asset" });
|
|
633
752
|
}
|
|
634
753
|
}
|
|
754
|
+
if (pathModuleTrees.length && !completeRustInventory(root, known, pathModuleTrees)) result.blockers.push("Incomplete Rust source inventory or symlinked inputs require full validation");
|
|
635
755
|
result.assetPaths = [...new Set(result.assetPaths)].sort();
|
|
636
756
|
result.rustCrateDirectories = [...new Set(packages.map(({ directory }) => directory))].sort();
|
|
637
757
|
result.rustRunsPrograms ??= false;
|
|
@@ -31,6 +31,9 @@ export interface AdapterContribution {
|
|
|
31
31
|
/** Whether any workspace Rust source starts an external program other than Cargo, rustc or the
|
|
32
32
|
* package's own binaries. Such a program could read any file, so nothing can be confined to a crate. */
|
|
33
33
|
rustRunsPrograms?: boolean;
|
|
34
|
+
/** Cargo's default workspace members cover every member (so `--workspace`/`--all` is equivalent to
|
|
35
|
+
* plain `cargo test`). Missing evidence is deliberately false. */
|
|
36
|
+
rustAllMembersTested?: boolean;
|
|
34
37
|
/** Packages whose Cargo features change when a tested crate runs without the rest of the full invocation. */
|
|
35
38
|
rustFeatureCoverage?: { deficits: Record<string, string[]>; units: Array<{ crates: string[]; covers: string[] }> };
|
|
36
39
|
executionEnv?: Record<string, string>;
|
|
@@ -1127,7 +1127,7 @@ export async function buildDependencyGraph(
|
|
|
1127
1127
|
profile.rustTestTargets = { ...rustContribution.rustTestTargets };
|
|
1128
1128
|
profile.rustSources = [...new Set(rustContribution.sourcePaths)].sort();
|
|
1129
1129
|
profile.rustAssets = [...new Set(rustContribution.assetPaths)].sort();
|
|
1130
|
-
profile.rustTestInvocation = rustTestInvocation(repoPath, files);
|
|
1130
|
+
profile.rustTestInvocation = rustTestInvocation(repoPath, files, { allMembersTested: rustContribution.rustAllMembersTested });
|
|
1131
1131
|
if (rustContribution.rustFeatureCoverage) profile.rustFeatureCoverage = rustContribution.rustFeatureCoverage;
|
|
1132
1132
|
profile.rustDocumentationReaders = [...new Set(rustContribution.rustDocumentationReaders ?? [])].sort();
|
|
1133
1133
|
}
|
|
@@ -67,6 +67,8 @@ function toolConfigurationSubject(filePath: string): string | undefined {
|
|
|
67
67
|
if (base === ".npmrc") return "package manager settings";
|
|
68
68
|
if (/^tsconfig\.[^/]+\.json$/.test(base) || /^jsconfig\.[^/]+\.json$/.test(base)) return "TypeScript configuration";
|
|
69
69
|
if (base === ".mocharc" || base.startsWith(".mocharc.")) return "Mocha settings";
|
|
70
|
+
if (base === ".tool-versions" || base === "mise.toml" || base === ".mise.toml") return "tool versions";
|
|
71
|
+
if (base === ".bun-version") return "Bun version";
|
|
70
72
|
return undefined;
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -935,7 +937,7 @@ export class ImpactAnalyzer {
|
|
|
935
937
|
return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0]!;
|
|
936
938
|
};
|
|
937
939
|
if (yarnCandidates) {
|
|
938
|
-
//
|
|
940
|
+
// Yarn's node-modules linkers can hoist packages that repository code imports without declaring them.
|
|
939
941
|
// All-root widening covers peers, but cannot attribute these additional importers to a root.
|
|
940
942
|
const undeclared = [...new Set(graphResult.references.filter((ref) => ref.resolution === "external-package")
|
|
941
943
|
.map((ref) => packageRoot(ref.specifier)).filter((name) => !packages.includes(name)))].sort();
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
/**
|
|
3
|
+
* Conservative Berry npm candidates, gated separately on an explicit node-modules linker.
|
|
4
|
+
* Like Classic, a semantic change widens to every direct dependency: the lockfile does not record
|
|
5
|
+
* the installed hoisting layout. Unknown formats, protocols, fields and missing edges fail closed.
|
|
6
|
+
* A lone workspace:. record describes the project itself, not a workspace dependency; when present
|
|
7
|
+
* it must agree with the manifest. All other workspace records and edges are unsupported.
|
|
8
|
+
*/
|
|
9
|
+
import { parseDocument, visit } from "yaml";
|
|
10
|
+
import { lstatSync, readFileSync, realpathSync } from "node:fs";
|
|
11
|
+
import { dirname, join } from "node:path";
|
|
12
|
+
import { homedir } from "node:os";
|
|
13
|
+
import { isExactVersion, isRegistryRequest } from "./yarn-lockfile.js";
|
|
14
|
+
|
|
15
|
+
type Direct = Readonly<Record<string, string>>;
|
|
16
|
+
type RecordMap = Map<string, unknown>;
|
|
17
|
+
interface Entry { edges: string[]; fingerprint: string }
|
|
18
|
+
interface Lock { entries: Map<string, Entry>; metadata: string; project?: string }
|
|
19
|
+
const NAME = /^(?:@[a-zA-Z0-9][a-zA-Z0-9._-]*\/)?[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
20
|
+
const record = (value: unknown): value is RecordMap => value instanceof Map && [...value.keys()].every((key) => typeof key === "string");
|
|
21
|
+
|
|
22
|
+
function yaml(content: string | undefined): RecordMap | undefined {
|
|
23
|
+
if (!content || content.length > 8 * 1024 * 1024) return undefined;
|
|
24
|
+
const lines = content.split(/\r?\n/);
|
|
25
|
+
if (lines.length > 100_000 || lines.some((line) => line.length > 16_384)) return undefined;
|
|
26
|
+
try {
|
|
27
|
+
const doc = parseDocument(content, { uniqueKeys: true });
|
|
28
|
+
if (doc.errors.length || doc.warnings.length) return undefined;
|
|
29
|
+
let unsupported = false;
|
|
30
|
+
visit(doc, { Node(_key, node, path) { if (node.anchor || node.tag || path.length > 20) unsupported = true; }, Alias() { unsupported = true; } });
|
|
31
|
+
if (unsupported) return undefined;
|
|
32
|
+
const value: unknown = doc.toJS({ mapAsMap: true, maxAliasCount: 0 });
|
|
33
|
+
return record(value) ? value : undefined;
|
|
34
|
+
} catch { return undefined; }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Do not interpolate environment-dependent settings or silently ignore additional configuration.
|
|
38
|
+
* Yarn reads environment keys case-insensitively, including YARN_RC_FILENAME and plugin overrides.
|
|
39
|
+
* The caller must analyze in the environment in which the selected tests will run. */
|
|
40
|
+
export function berryNodeModulesConfig(content: string | undefined, env: NodeJS.ProcessEnv = process.env): boolean {
|
|
41
|
+
if (Object.keys(env).some((key) => /^yarn_/i.test(key) && env[key] !== undefined)) return false;
|
|
42
|
+
const config = yaml(content);
|
|
43
|
+
return !!config && config.size === 1 && config.get("nodeLinker") === "node-modules";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The project file overrides the linker, but inherited config can still inject plugins or change
|
|
47
|
+
* resolution. This first subset requires a standalone checkout without those additional inputs. */
|
|
48
|
+
export function berryRuntimeConfig(repoPath: string | undefined): boolean {
|
|
49
|
+
try {
|
|
50
|
+
const root = realpathSync(repoPath ?? process.cwd());
|
|
51
|
+
const configPath = join(root, ".yarnrc.yml");
|
|
52
|
+
const configStat = lstatSync(configPath);
|
|
53
|
+
if (!configStat.isFile() || configStat.size > 65_536 || !berryNodeModulesConfig(readFileSync(configPath, "utf8"))) return false;
|
|
54
|
+
const extra = new Set([join(root, ".env.yarn"), join(homedir(), ".yarnrc.yml")]);
|
|
55
|
+
let parent = dirname(root);
|
|
56
|
+
while (true) {
|
|
57
|
+
extra.add(join(parent, ".yarnrc.yml"));
|
|
58
|
+
if (dirname(parent) === parent) break;
|
|
59
|
+
parent = dirname(parent);
|
|
60
|
+
}
|
|
61
|
+
extra.delete(join(root, ".yarnrc.yml"));
|
|
62
|
+
for (const path of extra) {
|
|
63
|
+
try { lstatSync(path); return false; }
|
|
64
|
+
catch (error) { if ((error as NodeJS.ErrnoException).code !== "ENOENT") return false; }
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
} catch { return false; }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function descriptor(name: string, request: string): string | undefined {
|
|
71
|
+
const range = request.startsWith("npm:") ? request.slice(4) : request;
|
|
72
|
+
return NAME.test(name) && isRegistryRequest(range) ? `${name}@npm:${range}` : undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function selectors(key: string): string[] | undefined {
|
|
76
|
+
const values = key.split(/, */);
|
|
77
|
+
let packageName: string | undefined;
|
|
78
|
+
for (const value of values) {
|
|
79
|
+
const separator = value.indexOf("@", value.startsWith("@") ? 1 : 0);
|
|
80
|
+
const name = value.slice(0, separator);
|
|
81
|
+
const request = value.slice(separator + 1);
|
|
82
|
+
if (separator < 1 || !request.startsWith("npm:") || descriptor(name, request) !== value || (packageName !== undefined && packageName !== name)) return undefined;
|
|
83
|
+
packageName = name;
|
|
84
|
+
}
|
|
85
|
+
return values;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function dependencies(value: unknown): Map<string, string> | undefined {
|
|
89
|
+
if (value === undefined) return new Map();
|
|
90
|
+
if (!record(value)) return undefined;
|
|
91
|
+
const result = new Map<string, string>();
|
|
92
|
+
for (const [name, request] of value) {
|
|
93
|
+
if (typeof request !== "string") return undefined;
|
|
94
|
+
const key = descriptor(name, request);
|
|
95
|
+
if (!key) return undefined;
|
|
96
|
+
result.set(name, key);
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const sorted = (map: Map<string, unknown>) => [...map].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
102
|
+
function parse(content: string | undefined, direct: Direct, projectName?: string): Lock | undefined {
|
|
103
|
+
const raw = yaml(content);
|
|
104
|
+
if (!raw) return undefined;
|
|
105
|
+
const metadata = raw.get("__metadata");
|
|
106
|
+
const cacheKey = record(metadata) ? metadata.get("cacheKey") : undefined;
|
|
107
|
+
// Known Berry formats only; a future serializer needs a separate review.
|
|
108
|
+
if (!record(metadata) || ![4, 6, 8].includes(metadata.get("version") as number)
|
|
109
|
+
|| [...metadata.keys()].some((key) => key !== "version" && key !== "cacheKey")
|
|
110
|
+
|| (metadata.has("cacheKey") && !["string", "number"].includes(typeof metadata.get("cacheKey")))
|
|
111
|
+
|| (typeof cacheKey === "number" && (!Number.isSafeInteger(cacheKey) || cacheKey < 0))
|
|
112
|
+
|| (metadata.has("cacheKey") && !/^[a-zA-Z0-9]+$/.test(String(metadata.get("cacheKey"))))) return undefined;
|
|
113
|
+
const entries = new Map<string, Entry>();
|
|
114
|
+
let project: string | undefined;
|
|
115
|
+
for (const [key, value] of raw) {
|
|
116
|
+
if (key === "__metadata") continue;
|
|
117
|
+
if (!record(value) || [...value.keys()].some((field) => !["version", "resolution", "checksum", "languageName", "linkType", "dependencies", "bin"].includes(field))) return undefined;
|
|
118
|
+
const deps = dependencies(value.get("dependencies"));
|
|
119
|
+
if (!deps) return undefined;
|
|
120
|
+
if (key.endsWith("@workspace:.")) {
|
|
121
|
+
if (project || !projectName || !NAME.test(projectName) || key !== `${projectName}@workspace:.`
|
|
122
|
+
|| value.get("resolution") !== key || value.get("version") !== "0.0.0-use.local" || value.get("linkType") !== "soft"
|
|
123
|
+
|| value.has("checksum") || value.has("bin")
|
|
124
|
+
|| (value.has("languageName") && !["node", "unknown"].includes(value.get("languageName") as string))
|
|
125
|
+
|| deps.size !== Object.keys(direct).length
|
|
126
|
+
|| Object.entries(direct).some(([name, request]) => deps.get(name) !== descriptor(name, request))) return undefined;
|
|
127
|
+
project = JSON.stringify([key, value.get("languageName")]);
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
const keys = selectors(key);
|
|
131
|
+
const version = value.get("version");
|
|
132
|
+
if (!keys || typeof version !== "string" || !isExactVersion(version) || value.get("languageName") !== "node" || value.get("linkType") !== "hard") return undefined;
|
|
133
|
+
const name = keys[0]!.slice(0, keys[0]!.indexOf("@", keys[0]!.startsWith("@") ? 1 : 0));
|
|
134
|
+
if (value.get("resolution") !== `${name}@npm:${version}`) return undefined;
|
|
135
|
+
const checksum = value.get("checksum");
|
|
136
|
+
if (checksum !== undefined && (typeof checksum !== "string" || !/^(?:[a-zA-Z0-9]+\/)?[a-f0-9]{128}$/.test(checksum))) return undefined;
|
|
137
|
+
const bin = value.get("bin");
|
|
138
|
+
if (bin !== undefined && (!record(bin) || [...bin.values()].some((path) => typeof path !== "string"))) return undefined;
|
|
139
|
+
const entry: Entry = { edges: [...deps.values()], fingerprint: JSON.stringify([version, value.get("resolution"), checksum ?? null, sorted(deps), bin ? sorted(bin as RecordMap) : null]) };
|
|
140
|
+
for (const selector of keys) {
|
|
141
|
+
if (entries.has(selector) || entries.size >= 100_000) return undefined;
|
|
142
|
+
entries.set(selector, entry);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if ([...entries.values()].some((entry) => entry.edges.some((edge) => !entries.has(edge)))) return undefined;
|
|
146
|
+
return { entries, metadata: JSON.stringify(sorted(metadata)), project };
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function reachable(lock: Lock, direct: Direct): Set<Entry> | undefined {
|
|
150
|
+
const queue: Entry[] = [];
|
|
151
|
+
for (const [name, request] of Object.entries(direct)) {
|
|
152
|
+
const key = descriptor(name, request);
|
|
153
|
+
const entry = key ? lock.entries.get(key) : undefined;
|
|
154
|
+
if (!entry) return undefined;
|
|
155
|
+
queue.push(entry);
|
|
156
|
+
}
|
|
157
|
+
const seen = new Set<Entry>();
|
|
158
|
+
while (queue.length) {
|
|
159
|
+
const entry = queue.pop()!;
|
|
160
|
+
if (seen.has(entry)) continue;
|
|
161
|
+
seen.add(entry);
|
|
162
|
+
for (const key of entry.edges) queue.push(lock.entries.get(key)!);
|
|
163
|
+
}
|
|
164
|
+
return seen;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Possible affected roots, or undefined to retain full validation. Call only after linker proof. */
|
|
168
|
+
export function berryLockAffectedDependencies(oldContent: string | undefined, newContent: string | undefined, beforeDirect: Direct, afterDirect: Direct, beforeName?: string, afterName?: string): string[] | undefined {
|
|
169
|
+
const before = parse(oldContent, beforeDirect, beforeName);
|
|
170
|
+
const after = parse(newContent, afterDirect, afterName);
|
|
171
|
+
if (!before || !after || before.metadata !== after.metadata || before.project !== after.project) return undefined;
|
|
172
|
+
const oldReachable = reachable(before, beforeDirect);
|
|
173
|
+
const newReachable = reachable(after, afterDirect);
|
|
174
|
+
if (!oldReachable || !newReachable) return undefined;
|
|
175
|
+
const changed = [...new Set([...before.entries.keys(), ...after.entries.keys()])].filter((key) => before.entries.get(key)?.fingerprint !== after.entries.get(key)?.fingerprint);
|
|
176
|
+
if (changed.some((key) => !oldReachable.has(before.entries.get(key)!) && !newReachable.has(after.entries.get(key)!))) return undefined;
|
|
177
|
+
return changed.length ? [...new Set([...Object.keys(beforeDirect), ...Object.keys(afterDirect)])].sort() : [];
|
|
178
|
+
}
|
|
@@ -39,7 +39,7 @@ const IDENTIFIERS = "[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*";
|
|
|
39
39
|
const EXACT_VERSION = new RegExp(`^${NUMERIC_PART}\\.${NUMERIC_PART}\\.${NUMERIC_PART}(?:-${IDENTIFIERS})?(?:\\+${IDENTIFIERS})?$`);
|
|
40
40
|
const RANGE_VERSION = new RegExp(`^v?(?:${NUMERIC_PART}|[xX*])(?:\\.(?:${NUMERIC_PART}|[xX*])){0,2}$`);
|
|
41
41
|
|
|
42
|
-
function isExactVersion(value: string): boolean {
|
|
42
|
+
export function isExactVersion(value: string): boolean {
|
|
43
43
|
if (!EXACT_VERSION.test(value)) return false;
|
|
44
44
|
const prerelease = /^[^-]+-([^+]+)/.exec(value)?.[1];
|
|
45
45
|
return !prerelease || prerelease.split(".").every((part) => !/^0[0-9]+$/.test(part));
|
|
@@ -56,7 +56,7 @@ function isRangeVersion(value: string): boolean {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/** A deliberately limited registry semver grammar; tags and protocol requests remain unsupported. */
|
|
59
|
-
function isRegistryRequest(value: string): boolean {
|
|
59
|
+
export function isRegistryRequest(value: string): boolean {
|
|
60
60
|
if (!value || value.length > 512 || value !== value.trim()) return false;
|
|
61
61
|
return value.split("||").every((alternative) => {
|
|
62
62
|
const range = alternative.trim();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diffci.com/diffci",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.57",
|
|
4
4
|
"description": "Verification for AI coding agents: runs the tests and checks a change affects, with full fallback and a receipt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ci",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"test": "node scripts/run-tests.mjs"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@diffci.com/core": "git+https://github.com/DiffCI/core.git#
|
|
79
|
+
"@diffci.com/core": "git+https://github.com/DiffCI/core.git#e1460bb168210fdff038926bd9bfee338a5f6ee2",
|
|
80
80
|
"saxes": "6.0.0",
|
|
81
81
|
"yaml": "^2.9.0"
|
|
82
82
|
},
|