@diffci.com/diffci 0.3.47 → 0.3.49

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.
Files changed (49) hide show
  1. package/dist-client/src/client/red-builds.d.ts +1 -1
  2. package/dist-client/src/client/red-builds.js +19 -8
  3. package/node_modules/@diffci.com/core/README.md +1 -1
  4. package/node_modules/@diffci.com/core/dist/cache/graph-cache.d.ts +1 -1
  5. package/node_modules/@diffci.com/core/dist/cache/graph-cache.js +2 -1
  6. package/node_modules/@diffci.com/core/dist/cache/graph-cache.js.map +1 -1
  7. package/node_modules/@diffci.com/core/dist/git/git-diff.js +3 -1
  8. package/node_modules/@diffci.com/core/dist/git/git-diff.js.map +1 -1
  9. package/node_modules/@diffci.com/core/dist/planner/rust-command.d.ts +5 -0
  10. package/node_modules/@diffci.com/core/dist/planner/rust-command.js +92 -0
  11. package/node_modules/@diffci.com/core/dist/planner/rust-command.js.map +1 -0
  12. package/node_modules/@diffci.com/core/dist/planner/test-command.js +3 -0
  13. package/node_modules/@diffci.com/core/dist/planner/test-command.js.map +1 -1
  14. package/node_modules/@diffci.com/core/dist/repo/adapters/index.js +5 -3
  15. package/node_modules/@diffci.com/core/dist/repo/adapters/index.js.map +1 -1
  16. package/node_modules/@diffci.com/core/dist/repo/adapters/rust-invocation.d.ts +3 -0
  17. package/node_modules/@diffci.com/core/dist/repo/adapters/rust-invocation.js +97 -0
  18. package/node_modules/@diffci.com/core/dist/repo/adapters/rust-invocation.js.map +1 -0
  19. package/node_modules/@diffci.com/core/dist/repo/adapters/rust.d.ts +51 -1
  20. package/node_modules/@diffci.com/core/dist/repo/adapters/rust.js +528 -16
  21. package/node_modules/@diffci.com/core/dist/repo/adapters/rust.js.map +1 -1
  22. package/node_modules/@diffci.com/core/dist/repo/adapters/types.d.ts +11 -0
  23. package/node_modules/@diffci.com/core/dist/repo/adapters/types.js.map +1 -1
  24. package/node_modules/@diffci.com/core/dist/repo/graph.js +31 -5
  25. package/node_modules/@diffci.com/core/dist/repo/graph.js.map +1 -1
  26. package/node_modules/@diffci.com/core/dist/repo/impact.js +45 -2
  27. package/node_modules/@diffci.com/core/dist/repo/impact.js.map +1 -1
  28. package/node_modules/@diffci.com/core/dist/repo/runner-setup-files.d.ts +11 -0
  29. package/node_modules/@diffci.com/core/dist/repo/runner-setup-files.js +181 -0
  30. package/node_modules/@diffci.com/core/dist/repo/runner-setup-files.js.map +1 -0
  31. package/node_modules/@diffci.com/core/dist/repo/test-discovery.d.ts +1 -0
  32. package/node_modules/@diffci.com/core/dist/repo/test-discovery.js +4 -3
  33. package/node_modules/@diffci.com/core/dist/repo/test-discovery.js.map +1 -1
  34. package/node_modules/@diffci.com/core/dist/repo/types.d.ts +13 -0
  35. package/node_modules/@diffci.com/core/package.json +1 -0
  36. package/node_modules/@diffci.com/core/src/cache/graph-cache.ts +2 -1
  37. package/node_modules/@diffci.com/core/src/git/git-diff.ts +3 -1
  38. package/node_modules/@diffci.com/core/src/planner/rust-command.ts +89 -0
  39. package/node_modules/@diffci.com/core/src/planner/test-command.ts +2 -0
  40. package/node_modules/@diffci.com/core/src/repo/adapters/index.ts +5 -3
  41. package/node_modules/@diffci.com/core/src/repo/adapters/rust-invocation.ts +87 -0
  42. package/node_modules/@diffci.com/core/src/repo/adapters/rust.ts +447 -16
  43. package/node_modules/@diffci.com/core/src/repo/adapters/types.ts +5 -0
  44. package/node_modules/@diffci.com/core/src/repo/graph.ts +29 -5
  45. package/node_modules/@diffci.com/core/src/repo/impact.ts +43 -2
  46. package/node_modules/@diffci.com/core/src/repo/runner-setup-files.ts +164 -0
  47. package/node_modules/@diffci.com/core/src/repo/test-discovery.ts +5 -3
  48. package/node_modules/@diffci.com/core/src/repo/types.ts +7 -0
  49. package/package.json +2 -2
@@ -4,6 +4,8 @@ import { isBuiltin } from "node:module";
4
4
  import { dirname, extname, isAbsolute, join, normalize, posix, relative, resolve, sep } from "node:path";
5
5
  import ts from "typescript";
6
6
  import { adapterFiles, REPOSITORY_ADAPTERS } from "./adapters/index.js";
7
+ import { rustAdapter } from "./adapters/rust.js";
8
+ import { rustTestInvocation } from "./adapters/rust-invocation.js";
7
9
  import { pythonAdapter } from "./adapters/python.js";
8
10
  import { analyzeRepository, type AnalyzeRepositoryOptions } from "./analyzer.js";
9
11
  import { applyVueScope, inVuePackage } from "./vue-scope.js";
@@ -620,7 +622,13 @@ class DependencyGraphImpl implements DependencyGraph {
620
622
  export function hydrateDependencyGraph(graph: DependencyGraph, repoPath: string, testPatterns?: readonly string[]): DependencyGraph {
621
623
  const sourcePaths = new Set(graph.nodes.filter((n) => n.isSource).map((n) => n.path));
622
624
  const assetPaths = new Set(graph.nodes.filter((n) => n.isAsset).map((n) => n.path));
623
- return new DependencyGraphImpl(sourcePaths, assetPaths, graph.edges, repoPath, testPatterns ? createTestFileMatcher(testPatterns) : DEFAULT_TEST_FILE_MATCHER);
625
+ // Cargo target roots such as src/lib.rs are tests by metadata, not by file name. Only Rust nodes
626
+ // are added here so other languages keep their pattern-based test identity.
627
+ const declaredTests = new Set(graph.nodes.filter(node => node.isTest && node.path.endsWith(".rs")).map(node => node.path));
628
+ const baseMatcher = testPatterns ? createTestFileMatcher(testPatterns) : DEFAULT_TEST_FILE_MATCHER;
629
+ const matcher = ((path: string) => declaredTests.has(path) || baseMatcher(path)) as TestFileMatcher;
630
+ Object.defineProperty(matcher, "patterns", { value: baseMatcher.patterns });
631
+ return new DependencyGraphImpl(sourcePaths, assetPaths, graph.edges, repoPath, matcher);
624
632
  }
625
633
 
626
634
  /**
@@ -1076,8 +1084,12 @@ export async function buildDependencyGraph(
1076
1084
  if (contributions.some((item) => item.id === "go") && files.some((file) => /\.(?:[cm]?[jt]sx?|vue)$/.test(file))) {
1077
1085
  adapterBlockers.push("Mixed Go/JavaScript repositories require explicit cross-language dependencies; full validation required");
1078
1086
  }
1087
+ const rustModeled = contributions.some((item) => item.id === "rust");
1088
+ if (rustModeled && files.some(file => /\.(?:[cm]?[jt]sx?|vue|go|py|java|kt|cs|svelte|astro|c|h|cpp|cc|cxx)$/.test(file))) {
1089
+ adapterBlockers.push("Mixed Rust/language repositories require explicit cross-language dependencies; full validation required");
1090
+ }
1079
1091
  const pythonModeled = contributions.some((item) => item.id === "python");
1080
- const unmodeledLanguageFiles = contributions.length ? files.filter((file) => (!pythonModeled && /\.py$/.test(file)) || /\.(?:rs|cs|svelte|astro)$/.test(file) || !contributions.some((item) => item.id === "maven") && /\.(?:java|kt)$/.test(file)) : [];
1092
+ const unmodeledLanguageFiles = contributions.length ? files.filter((file) => (!pythonModeled && /\.py$/.test(file)) || (!rustModeled && /\.rs$/.test(file)) || /\.(?:cs|svelte|astro)$/.test(file) || !contributions.some((item) => item.id === "maven") && /\.(?:java|kt)$/.test(file)) : [];
1081
1093
  if (unmodeledLanguageFiles.length) {
1082
1094
  const reason = "Unmodeled languages alongside an adapter require full validation";
1083
1095
  adapterBlockers.push(reason);
@@ -1086,7 +1098,8 @@ export async function buildDependencyGraph(
1086
1098
  for (const file of unmodeledLanguageFiles) addScope(reason, packageScope(file) || (/^\.[^/]+\//.test(file) && !file.startsWith(".github/") ? file.slice(0, file.indexOf("/")) : ""));
1087
1099
  }
1088
1100
  profile.adapters = contributions.map(({ id, version, blockers }) => ({ id, version, blockers }));
1089
- profile.goTestPackages = Object.assign({}, ...contributions.map((item) => item.testPackages));
1101
+ // Rust test targets are not Go packages; other adapters keep their existing routing here.
1102
+ profile.goTestPackages = Object.assign({}, ...contributions.filter((item) => item.id !== "rust").map((item) => item.testPackages));
1090
1103
  profile.goTestEnvironment = contributions.find((item) => item.id === "go")?.executionEnv;
1091
1104
  const goContribution = contributions.find((item) => item.id === "go");
1092
1105
  profile.goDependencyPaths = goContribution ? {
@@ -1094,6 +1107,16 @@ export async function buildDependencyGraph(
1094
1107
  embeds: [...new Set(goContribution.assetPaths)].sort(),
1095
1108
  } : undefined;
1096
1109
  profile.mavenTestModules = Object.assign({}, ...contributions.filter((item) => item.id === "maven").map((item) => item.testPackages));
1110
+ const rustContribution = contributions.find(item => item.id === "rust");
1111
+ if (rustContribution) {
1112
+ profile.rustTestPackages = { ...rustContribution.testPackages };
1113
+ profile.rustTestTargets = { ...rustContribution.rustTestTargets };
1114
+ profile.rustSources = [...new Set(rustContribution.sourcePaths)].sort();
1115
+ profile.rustAssets = [...new Set(rustContribution.assetPaths)].sort();
1116
+ profile.rustTestInvocation = rustTestInvocation(repoPath, files);
1117
+ if (rustContribution.rustFeatureCoverage) profile.rustFeatureCoverage = rustContribution.rustFeatureCoverage;
1118
+ profile.rustDocumentationReaders = [...new Set(rustContribution.rustDocumentationReaders ?? [])].sort();
1119
+ }
1097
1120
  const pythonContribution = contributions.find((item) => item.id === "python");
1098
1121
  if (pythonContribution) {
1099
1122
  profile.pythonSources = [...new Set(pythonContribution.sourcePaths)].sort();
@@ -1104,7 +1127,7 @@ export async function buildDependencyGraph(
1104
1127
  profile.testFilePaths = [...new Set([...profile.testFilePaths, ...adapterTests])].sort();
1105
1128
  if (profile.testUniverse) {
1106
1129
  profile.testUniverse.discoveredTestFiles = profile.testFilePaths.length;
1107
- profile.testUniverse.blindSpot = (profile.testUniverse.declaredFrameworks.length > 0 || contributions.some((item) => item.id === "go" || item.id === "maven" || item.id === "python")) && profile.testFilePaths.length === 0;
1130
+ profile.testUniverse.blindSpot = (profile.testUniverse.declaredFrameworks.length > 0 || contributions.some((item) => item.id === "go" || item.id === "maven" || item.id === "python" || item.id === "rust")) && profile.testFilePaths.length === 0;
1108
1131
  }
1109
1132
  const entryPointPaths = new Set(profile.entryPoints.map((e) => e.path));
1110
1133
 
@@ -1760,8 +1783,9 @@ export function classifyRepositoryProject(repoPath: string): { capable: boolean;
1760
1783
  if (files.includes("go.mod")) return { capable: true, reason: "Go module (package-level analysis)" };
1761
1784
  if (files.some((file) => file.endsWith(".vue"))) return { capable: true, reason: "Vue single-file components" };
1762
1785
  if (files.includes("pom.xml") && files.some((file) => file.endsWith(".java") || file.endsWith(".kt"))) return { capable: true, reason: "Maven reactor (module-level Java analysis)" };
1786
+ if (rustAdapter.detect({ repoPath, files, profile: {} as RepositoryProfile })) return { capable: true, reason: "Cargo workspace (crate-level Rust analysis)" };
1763
1787
  if (pythonAdapter.detect({ repoPath, files, profile: {} as RepositoryProfile })) return { capable: true, reason: "Python project tested with pytest (file-level import analysis)" };
1764
- return { capable: false, reason: "No TypeScript project, Vue components, root Go module, Maven reactor, or Python project found" };
1788
+ return { capable: false, reason: "No TypeScript project, Vue components, root Go module, Maven reactor, Python project, or Cargo workspace found" };
1765
1789
  }
1766
1790
 
1767
1791
  export interface TypeScriptProjectCapability {
@@ -15,6 +15,7 @@ import { compiledProjects, type CompiledProject } from "./compiled-projects.js";
15
15
  import { isPlaywrightSpec, nextAppRoute, routeMatches, visitedRoutes } from "./route-visits.js";
16
16
  import { exportLevelReach } from "./export-reach.js";
17
17
  import { LOCKFILE } from "./lockfiles.js";
18
+ import { runnerSetupFiles } from "./runner-setup-files.js";
18
19
 
19
20
  const SOURCE_EXTENSIONS = new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".mts",".cts",".vue",".go",".java",".kt"]);
20
21
  const ASSET_EXTENSIONS = new Set([".css",".scss",".sass",".less",".json",".jsonc",".svg",".png",".jpg",".jpeg",".gif",".webp",".ico",".bmp",".woff",".woff2",".ttf",".otf",".eot",".wasm",".md",".txt"]);
@@ -61,7 +62,7 @@ function isConfigFile(filePath: string): boolean {
61
62
  if (base.startsWith("postcss.config")) return true;
62
63
  if (base.startsWith("eslint.config")) return true;
63
64
  if (base.startsWith(".eslintrc")) return true;
64
- if (base.startsWith("vitest.config")) return true;
65
+ if (base.startsWith("vitest.config") || base.startsWith("vitest.workspace") || base.startsWith("vitest.projects")) return true;
65
66
  if (base.startsWith("jest.config")) return true;
66
67
  if (base.startsWith("babel.config") || base.startsWith(".babelrc")) return true;
67
68
  if (base.startsWith("prettier.config")) return true;
@@ -582,7 +583,7 @@ export class ImpactAnalyzer {
582
583
  this.packageJsonSpecifiersOnly = delta.analysis.packageJsonSpecifiersOnly === true;
583
584
  this.specifiersOnlyManifests = new Set(delta.analysis.specifiersOnlyManifests ?? []);
584
585
  this.exportsRemaps = new Map(Object.entries(delta.analysis.exportsRemaps ?? {}));
585
- const changedImpacts: ChangedImpact[] = delta.files.map((file) => ({ file, category: classifyChangedFile(file, this.isTestFile, this.layout, options.repositoryFiles, referenceResolved, new Set(profile.pythonSources ?? [])), reasons: changedFileReasons(file) }));
586
+ const changedImpacts: ChangedImpact[] = delta.files.map((file) => ({ file, category: classifyChangedFile(file, this.isTestFile, this.layout, options.repositoryFiles, referenceResolved, new Set([...(profile.pythonSources ?? []), ...(profile.rustSources ?? [])])), reasons: changedFileReasons(file) }));
586
587
  const evidence: ImpactEvidence[] = [];
587
588
  const riskSignals: ImpactRiskSignal[] = [];
588
589
  const fallbackReasons: string[] = [...(graphResult.adapterBlockers ?? []), ...testDiscoveryErrors(profile)];
@@ -592,6 +593,37 @@ export class ImpactAnalyzer {
592
593
  const setupDependencies = new Set((profile.vueSetupPaths ?? []).flatMap(path => [path, ...graph.transitiveDependenciesOf(path)]));
593
594
  if (delta.files.some(file => allChangePaths(file).some(path => setupDependencies.has(path)))) fallbackReasons.push("Vue suite configuration or shared setup dependency changed; full validation required");
594
595
  }
596
+ // A file a Jest or Vitest configuration runs around every test, or one it imports, reaches every test
597
+ // that configuration covers; nothing imports it, so the graph alone selected no tests (issue #139).
598
+ if (this.readRepositoryFile && this.sortedRepositoryFiles.length > 0) {
599
+ const changedPaths = [...new Set(delta.files.flatMap(allChangePaths))];
600
+ const setup = runnerSetupFiles([...new Set([...this.sortedRepositoryFiles, ...changedPaths])], this.readRepositoryFile);
601
+ let imported: Map<string, string> | undefined;
602
+ const importedBySetup = () => imported ??= new Map([...setup.named].flatMap(([file, config]) =>
603
+ graph.transitiveDependenciesOf(file).map((dependency) => [dependency, config] as const)).reverse());
604
+ for (const path of changedPaths) {
605
+ const config = setup.named.get(path) ?? importedBySetup().get(path);
606
+ const message = config !== undefined
607
+ ? `Test setup file or a module it imports changed: ${path} (setup from ${config}); full validation required`
608
+ : setup.unreadable.length > 0 && isSourceFilePath(path) && !this.isTestFile(path)
609
+ ? `Test setup files in ${setup.unreadable.join(", ")} could not be read statically, so ${path} may be one; full validation required`
610
+ : undefined;
611
+ if (message === undefined || fallbackReasons.includes(message)) continue;
612
+ evidence.push(makeEvidence("CONFIG_GLOBAL", path, message));
613
+ riskSignals.push({ level: "critical", reason: "CONFIG_GLOBAL", message, paths: [path] });
614
+ fallbackReasons.push(message);
615
+ }
616
+ }
617
+ if (profile.adapters?.some(adapter => adapter.id === "rust")) {
618
+ const modeledPaths = new Set([...(profile.rustSources ?? []), ...(profile.rustAssets ?? [])]);
619
+ // Documentation follows the shared classification (as for the other adapters) unless Rust code
620
+ // includes it (then it is a modelled asset), names it, or a workspace build script could read it.
621
+ const documentation = (path: string) => !profile.rustDocumentationReaders?.length
622
+ && (this.layout.isDocumentationPath(path) || isAgentConfigurationPath(path));
623
+ const unmodeledPaths = [...new Set(delta.files.flatMap(allChangePaths))]
624
+ .filter(path => path === "Cargo.toml" || /(?:^|\/)Cargo\.lock$/.test(path) || (!modeledPaths.has(path) && !documentation(path)));
625
+ if (unmodeledPaths.length) fallbackReasons.push(`Rust runtime inputs outside crate metadata or workspace configuration require full validation: ${unmodeledPaths.slice(0, 20).join(", ")}`);
626
+ }
595
627
  const hasGoAdapter = profile.adapters?.some(adapter => adapter.id === "go");
596
628
  this.goEmbedPaths = new Set(hasGoAdapter ? profile.goDependencyPaths?.embeds : []);
597
629
  const goPackageTestDataOwner = hasGoAdapter ? this.mapGoPackageTestData(delta, profile) : new Map<string, string>();
@@ -1022,6 +1054,15 @@ export class ImpactAnalyzer {
1022
1054
  if (!fallbackReasons.includes(message)) fallbackReasons.push(message);
1023
1055
  }
1024
1056
  }
1057
+ if (profile.rustAssets?.includes(changedPath)) {
1058
+ this.processAssetChange(changedPath, graph, profile, affectedAssets, affectedEntryPoints, affectedTests, affectedSources, evidence);
1059
+ return;
1060
+ }
1061
+ if (profile.rustSources?.includes(changedPath)) {
1062
+ this.processSourceChange(changedPath, graph, profile, affectedSources, affectedEntryPoints, affectedTests, affectedScripts, evidence);
1063
+ if (this.isTestFile(changedPath)) this.addAffectedTest(changedPath, changedPath, graph, affectedTests, "DIRECT_CHANGE", evidence);
1064
+ return;
1065
+ }
1025
1066
  // Go's embed metadata is ownership evidence regardless of suffix or documentation naming.
1026
1067
  // Traverse it before generic unknown/docs classification can discard the dependency.
1027
1068
  if (this.goEmbedPaths.has(changedPath)) {
@@ -0,0 +1,164 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * Files a Jest or Vitest configuration runs around every test (2026-11-16, issue #139).
4
+ *
5
+ * `setupFiles`, `setupFilesAfterEnv`, `globalSetup` and their siblings are named only by the runner
6
+ * configuration, never imported, so the dependency graph saw a changed setup file as source with no
7
+ * dependents and selected no tests. A broken setup file fails the whole suite, so a change to one runs
8
+ * every test.
9
+ *
10
+ * Each configuration's setup values are read statically: every string literal inside the value counts,
11
+ * resolved against the configuration's directory (Jest's `<rootDir>` included), with or without an
12
+ * extension. A setup key whose value holds no string literal at all (`setupFiles: files`) cannot be
13
+ * read, and then any changed source file might be a setup file, so the caller falls back to the full suite.
14
+ */
15
+ import { posix } from "node:path";
16
+ import ts from "typescript";
17
+
18
+ /** Configuration keys whose values are files the runner loads around every test. */
19
+ const SETUP_KEYS = new Set([
20
+ "setupFiles", "setupFilesAfterEnv", "globalSetup", "globalTeardown", "testEnvironment",
21
+ "snapshotSerializers", "snapshotResolver", "testSequencer", "testResultsProcessor", "reporters",
22
+ ]);
23
+
24
+ const RUNNER_CONFIG = /^(?:jest\.config|vitest\.config|vite\.config|vitest\.workspace|vitest\.projects)\.(?:[cm]?[jt]s|json)$/;
25
+ const CODE_EXTENSION = /\.(?:[cm]?[jt]sx?)$/;
26
+
27
+ export interface RunnerSetupFiles {
28
+ /** Repo-relative setup file -> the configuration that names it. */
29
+ readonly named: ReadonlyMap<string, string>;
30
+ /** Configurations with a setup key DiffCI could not read. */
31
+ readonly unreadable: readonly string[];
32
+ }
33
+
34
+ function isRunnerConfig(path: string): boolean {
35
+ return !path.split("/").includes("node_modules") && RUNNER_CONFIG.test(posix.basename(path));
36
+ }
37
+
38
+ /** String literals inside one setup value, or `undefined` when there are none to read. */
39
+ function literalsIn(node: ts.Node): string[] | undefined {
40
+ const values: string[] = [];
41
+ const visit = (child: ts.Node): void => {
42
+ if (ts.isStringLiteral(child) || ts.isNoSubstitutionTemplateLiteral(child)) values.push(child.text);
43
+ // `path.join(__dirname, "test", "setup.ts")` and `resolve(...)`: the literal arguments joined are the path.
44
+ if (ts.isCallExpression(child)) {
45
+ const parts = child.arguments.filter((a) => ts.isStringLiteral(a) || ts.isNoSubstitutionTemplateLiteral(a)).map((a) => (a as ts.StringLiteral).text);
46
+ if (parts.length > 1) values.push(parts.join("/"));
47
+ }
48
+ ts.forEachChild(child, visit);
49
+ };
50
+ visit(node);
51
+ return values.length > 0 ? values : undefined;
52
+ }
53
+
54
+ /** Setup values of a JS/TS configuration; `undefined` marks one it could not read. */
55
+ function codeConfigValues(path: string, content: string): Array<string[] | undefined> {
56
+ const source = ts.createSourceFile(path, content, ts.ScriptTarget.Latest, false, ts.ScriptKind.TS);
57
+ const found: Array<string[] | undefined> = [];
58
+ const visit = (node: ts.Node): void => {
59
+ if (ts.isPropertyAssignment(node) && (ts.isIdentifier(node.name) || ts.isStringLiteral(node.name)) && SETUP_KEYS.has(node.name.text)) {
60
+ found.push(literalsIn(node.initializer));
61
+ } else if (ts.isShorthandPropertyAssignment(node) && SETUP_KEYS.has(node.name.text)) {
62
+ found.push(undefined);
63
+ }
64
+ ts.forEachChild(node, visit);
65
+ };
66
+ visit(source);
67
+ return found;
68
+ }
69
+
70
+ /** Setup values of a JSON configuration or `package.json#jest`. */
71
+ function jsonConfigValues(value: unknown): string[][] {
72
+ const found: string[][] = [];
73
+ const visit = (node: unknown): void => {
74
+ if (Array.isArray(node)) { node.forEach(visit); return; }
75
+ if (!node || typeof node !== "object") return;
76
+ for (const [key, child] of Object.entries(node)) {
77
+ if (SETUP_KEYS.has(key)) {
78
+ const strings: string[] = [];
79
+ const collect = (item: unknown): void => {
80
+ if (typeof item === "string") strings.push(item);
81
+ else if (Array.isArray(item)) item.forEach(collect);
82
+ else if (item && typeof item === "object") Object.values(item).forEach(collect);
83
+ };
84
+ collect(child);
85
+ found.push(strings);
86
+ } else visit(child);
87
+ }
88
+ };
89
+ visit(value);
90
+ return found;
91
+ }
92
+
93
+ /** Repo-relative candidates a literal may name, relative to the configuration's directory. */
94
+ function candidatePaths(configDir: string, literal: string): string[] {
95
+ const cleaned = literal.replace(/^<rootDir>\/?/, "").trim();
96
+ if (!cleaned || cleaned.startsWith("/") || /^[a-z]+:/i.test(cleaned)) return [];
97
+ const joined = posix.normalize(posix.join(configDir, cleaned));
98
+ if (joined.startsWith("../") || joined === "..") return [];
99
+ return [joined.replace(/^\.\//, "")];
100
+ }
101
+
102
+ /**
103
+ * Setup files named by every runner configuration in `files` (repository paths at HEAD). `read` returns
104
+ * a file's text, or `undefined` when it cannot be read.
105
+ */
106
+ export function runnerSetupFiles(files: readonly string[], read: (path: string) => string | undefined): RunnerSetupFiles {
107
+ const fileSet = new Set(files);
108
+ const named = new Map<string, string>();
109
+ const unreadable: string[] = [];
110
+ const byStem = new Map<string, string[]>();
111
+ for (const file of files) {
112
+ if (!CODE_EXTENSION.test(file)) continue;
113
+ const stem = file.replace(CODE_EXTENSION, "");
114
+ byStem.set(stem, [...(byStem.get(stem) ?? []), file]);
115
+ if (posix.basename(stem) === "index") {
116
+ const dir = posix.dirname(stem);
117
+ byStem.set(dir, [...(byStem.get(dir) ?? []), file]);
118
+ }
119
+ }
120
+ const record = (config: string, literals: string[]) => {
121
+ const configDir = posix.dirname(config) === "." ? "" : posix.dirname(config);
122
+ for (const literal of literals) {
123
+ for (const candidate of candidatePaths(configDir, literal)) {
124
+ const matches = fileSet.has(candidate) ? [candidate] : byStem.get(candidate) ?? [];
125
+ for (const match of matches) if (!named.has(match)) named.set(match, config);
126
+ }
127
+ }
128
+ };
129
+ for (const file of files) {
130
+ const isManifest = posix.basename(file) === "package.json" && !file.split("/").includes("node_modules");
131
+ if (!isManifest && !isRunnerConfig(file)) continue;
132
+ const content = read(file);
133
+ if (content === undefined) continue;
134
+ if (isManifest || file.endsWith(".json")) {
135
+ let parsed: unknown;
136
+ try { parsed = JSON.parse(content); } catch { continue; }
137
+ const scope = isManifest ? (parsed as { jest?: unknown } | null)?.jest : parsed;
138
+ for (const literals of jsonConfigValues(scope)) record(isManifest ? `${file}#jest` : file, literals);
139
+ continue;
140
+ }
141
+ for (const literals of codeConfigValues(file, content)) {
142
+ if (literals === undefined) { if (!unreadable.includes(file)) unreadable.push(file); continue; }
143
+ record(file, literals);
144
+ }
145
+ }
146
+ // Setup files often sit outside the dependency graph's source roots (`test/setup.ts`), so the modules
147
+ // they import are followed here too: relative specifiers only, resolved like the graph resolves them.
148
+ const queue = [...named.keys()];
149
+ for (let next = queue.shift(); next !== undefined; next = queue.shift()) {
150
+ const content = read(next);
151
+ if (content === undefined) continue;
152
+ for (const match of content.matchAll(/(?:\bfrom\s*|\bimport\s*\(?\s*|\brequire\s*\(\s*)["'](\.{1,2}\/[^"']+)["']/g)) {
153
+ const target = posix.normalize(posix.join(posix.dirname(next), match[1]!));
154
+ const stem = target.replace(/\.[cm]?js$/, "");
155
+ const resolved = fileSet.has(target) ? [target] : byStem.get(stem) ?? [];
156
+ for (const file of resolved) {
157
+ if (named.has(file)) continue;
158
+ named.set(file, named.get(next)!);
159
+ queue.push(file);
160
+ }
161
+ }
162
+ }
163
+ return { named, unreadable: unreadable.sort() };
164
+ }
@@ -658,15 +658,17 @@ export function createTestFileMatcher(
658
658
  * impact classification cannot disagree about what a test is. */
659
659
  export function testFileMatcherForProfile(profile: {
660
660
  goTestPackages?: Record<string, string>;
661
+ rustTestPackages?: Record<string, string>;
661
662
  testPatterns?: readonly string[];
662
663
  testExcludePatterns?: readonly string[];
663
664
  testAuthoritativePatterns?: readonly string[];
664
665
  testIgnoreRegexSources?: readonly string[];
665
666
  testRoots?: readonly string[];
666
667
  }): TestFileMatcher {
667
- if (profile.goTestPackages && Object.keys(profile.goTestPackages).length) {
668
- const jsMatcher = testFileMatcherForProfile({ ...profile, goTestPackages: undefined });
669
- const matcher = ((path: string) => Object.hasOwn(profile.goTestPackages!, path) || jsMatcher(path)) as TestFileMatcher;
668
+ const adapterTests = new Set([...Object.keys(profile.goTestPackages ?? {}), ...Object.keys(profile.rustTestPackages ?? {})]);
669
+ if (adapterTests.size) {
670
+ const jsMatcher = testFileMatcherForProfile({ ...profile, goTestPackages: undefined, rustTestPackages: undefined });
671
+ const matcher = ((path: string) => adapterTests.has(path) || jsMatcher(path)) as TestFileMatcher;
670
672
  Object.defineProperty(matcher, "patterns", { value: jsMatcher.patterns });
671
673
  return matcher;
672
674
  }
@@ -55,6 +55,13 @@ export interface RepositoryProfile {
55
55
  rustTestPackages?: Record<string, string>;
56
56
  rustTestTargets?: Record<string, { name: string; kind: "lib" | "bin" | "test" | "bench" | "example" }>;
57
57
  rustSources?: string[];
58
+ /** Rust files that may read documentation (adapters/rust.ts). While one exists, documentation
59
+ * changes keep the full suite; otherwise they follow the shared documentation classification. */
60
+ rustDocumentationReaders?: string[];
61
+ /** Cargo feature resolution per tested crate (adapters/rust.ts). Absent means a selective command
62
+ * cannot be shown to keep the full invocation's features. */
63
+ rustFeatureCoverage?: { deficits: Record<string, string[]>; units: Array<{ crates: string[]; covers: string[] }> };
64
+ rustAssets?: string[];
58
65
  /** Set only when the repository's test invocation is supported and reproducible. */
59
66
  rustTestInvocation?: "cargo test";
60
67
  /** Python files and pytest test files the Python adapter modelled (adapters/python.ts), and the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diffci.com/diffci",
3
- "version": "0.3.47",
3
+ "version": "0.3.49",
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#4fb81d791c8cc6539df8cd1b59eb029be04c295b",
79
+ "@diffci.com/core": "git+https://github.com/DiffCI/core.git#8fa0a1655c5aa56e31c803a8154ce690bf49fc9a",
80
80
  "saxes": "6.0.0",
81
81
  "yaml": "^2.9.0"
82
82
  },