@diffci.com/diffci 0.3.46 → 0.3.47
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/verify.d.ts +1 -1
- package/dist-client/src/client/verify.js +3 -6
- package/dist-client/src/client/working-tree.d.ts +1 -12
- package/dist-client/src/client/working-tree.js +60 -40
- package/node_modules/@diffci.com/core/README.md +34 -5
- package/node_modules/@diffci.com/core/dist/repo/adapters/rust.d.ts +23 -0
- package/node_modules/@diffci.com/core/dist/repo/adapters/rust.js +180 -0
- package/node_modules/@diffci.com/core/dist/repo/adapters/rust.js.map +1 -0
- package/node_modules/@diffci.com/core/dist/repo/adapters/types.d.ts +5 -0
- package/node_modules/@diffci.com/core/dist/repo/adapters/types.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/file-references.js +43 -6
- package/node_modules/@diffci.com/core/dist/repo/file-references.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/impact-types.d.ts +1 -1
- package/node_modules/@diffci.com/core/dist/repo/impact.d.ts +5 -0
- package/node_modules/@diffci.com/core/dist/repo/impact.js +22 -0
- package/node_modules/@diffci.com/core/dist/repo/impact.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/types.d.ts +9 -0
- package/node_modules/@diffci.com/core/src/repo/adapters/rust.ts +195 -0
- package/node_modules/@diffci.com/core/src/repo/adapters/types.ts +2 -0
- package/node_modules/@diffci.com/core/src/repo/file-references.ts +41 -6
- package/node_modules/@diffci.com/core/src/repo/impact-types.ts +1 -0
- package/node_modules/@diffci.com/core/src/repo/impact.ts +22 -0
- package/node_modules/@diffci.com/core/src/repo/types.ts +6 -0
- package/package.json +2 -2
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
3
|
+
import { dirname, isAbsolute, relative, resolve } from "node:path";
|
|
4
|
+
import { contribution, type AdapterContext, type AdapterContribution, type RepositoryAdapter } from "./types.js";
|
|
5
|
+
|
|
6
|
+
export interface CargoTarget {
|
|
7
|
+
name: string;
|
|
8
|
+
kind: string[];
|
|
9
|
+
src_path: string;
|
|
10
|
+
test: boolean;
|
|
11
|
+
doctest: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface CargoPackage {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
manifest_path: string;
|
|
18
|
+
targets: CargoTarget[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface CargoMetadata {
|
|
22
|
+
packages: CargoPackage[];
|
|
23
|
+
workspace_members: string[];
|
|
24
|
+
workspace_root: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function object(value: unknown): value is Record<string, unknown> {
|
|
28
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function strings(value: unknown): value is string[] {
|
|
32
|
+
return Array.isArray(value) && value.every(item => typeof item === "string");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Metadata is external input: incomplete output is not an empty successful graph. */
|
|
36
|
+
export function parseCargoMetadata(output: string): CargoMetadata {
|
|
37
|
+
const value: unknown = JSON.parse(output);
|
|
38
|
+
if (!object(value) || !Array.isArray(value.packages) || !strings(value.workspace_members)
|
|
39
|
+
|| !value.workspace_members.length || typeof value.workspace_root !== "string" || !isAbsolute(value.workspace_root)) {
|
|
40
|
+
throw new Error("Invalid Cargo workspace metadata");
|
|
41
|
+
}
|
|
42
|
+
for (const pkg of value.packages) {
|
|
43
|
+
if (!object(pkg) || typeof pkg.id !== "string" || !pkg.id || typeof pkg.name !== "string"
|
|
44
|
+
|| !/^[A-Za-z0-9_][A-Za-z0-9_-]*$/.test(pkg.name) || typeof pkg.manifest_path !== "string"
|
|
45
|
+
|| !isAbsolute(pkg.manifest_path) || !Array.isArray(pkg.targets) || !pkg.targets.length) {
|
|
46
|
+
throw new Error("Invalid Cargo package metadata");
|
|
47
|
+
}
|
|
48
|
+
for (const target of pkg.targets) {
|
|
49
|
+
if (!object(target) || typeof target.name !== "string" || !/^[A-Za-z0-9_][A-Za-z0-9_-]*$/.test(target.name)
|
|
50
|
+
|| !strings(target.kind) || !target.kind.length || typeof target.src_path !== "string"
|
|
51
|
+
|| !isAbsolute(target.src_path) || typeof target.test !== "boolean" || typeof target.doctest !== "boolean") {
|
|
52
|
+
throw new Error("Invalid Cargo target metadata");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const ids = value.packages.map(pkg => (pkg as CargoPackage).id);
|
|
57
|
+
if (new Set(ids).size !== ids.length || new Set(value.workspace_members).size !== value.workspace_members.length
|
|
58
|
+
|| value.workspace_members.some(id => !ids.includes(id))) throw new Error("Incomplete Cargo workspace membership");
|
|
59
|
+
return value as unknown as CargoMetadata;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function internalPath(root: string, path: string): string | undefined {
|
|
63
|
+
const rel = relative(root, path).replace(/\\/g, "/");
|
|
64
|
+
return rel === ".." || rel.startsWith("../") || isAbsolute(rel) ? undefined : rel;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Resolve a metadata or checkout path against a realpath'd workspace root. */
|
|
68
|
+
function resolvedPath(root: string, path: string): string | undefined {
|
|
69
|
+
try {
|
|
70
|
+
return internalPath(root, realpathSync(path));
|
|
71
|
+
} catch { return undefined; }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Refuse symlink escapes as well as lexical escapes before using a metadata path. */
|
|
75
|
+
function repositoryPath(root: string, path: string, known: ReadonlySet<string>): string | undefined {
|
|
76
|
+
const rel = resolvedPath(root, path);
|
|
77
|
+
return rel && known.has(rel) ? rel : undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function under(path: string, directory: string): boolean {
|
|
81
|
+
return directory === "" || path.startsWith(`${directory}/`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function analyzeRustMetadata(context: AdapterContext, output: string): AdapterContribution {
|
|
85
|
+
const result = contribution(rustAdapter);
|
|
86
|
+
// This first milestone only establishes ownership. Keep it fail-closed until
|
|
87
|
+
// workspace dependency edges are added, even if called before registration.
|
|
88
|
+
result.blockers.push("Rust crate dependency analysis is not available; full validation required");
|
|
89
|
+
try {
|
|
90
|
+
const metadata = parseCargoMetadata(output);
|
|
91
|
+
const root = realpathSync(resolve(context.repoPath));
|
|
92
|
+
if (realpathSync(metadata.workspace_root) !== root) {
|
|
93
|
+
result.blockers.push("Rust support requires a Cargo workspace or crate at the repository root");
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
const known = new Set(context.files);
|
|
97
|
+
const members = metadata.packages.filter(pkg => metadata.workspace_members.includes(pkg.id));
|
|
98
|
+
if (new Set(members.map(pkg => pkg.name)).size !== members.length) {
|
|
99
|
+
result.blockers.push("Ambiguous Cargo workspace package names require full validation");
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
const packages: Array<{ pkg: CargoPackage; directory: string; manifest: string }> = [];
|
|
103
|
+
for (const pkg of members) {
|
|
104
|
+
const manifest = repositoryPath(root, pkg.manifest_path, known);
|
|
105
|
+
if (!manifest || !/(?:^|\/)Cargo\.toml$/.test(manifest)) {
|
|
106
|
+
result.blockers.push(`Rust package ${pkg.name} has an unavailable or external manifest`);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const directory = dirname(manifest) === "." ? "" : dirname(manifest);
|
|
110
|
+
packages.push({ pkg, manifest, directory });
|
|
111
|
+
result.sourcePaths.push(manifest);
|
|
112
|
+
}
|
|
113
|
+
// Deepest package wins, regardless of Cargo's package ordering.
|
|
114
|
+
packages.sort((a, b) => b.directory.length - a.directory.length || a.directory.localeCompare(b.directory));
|
|
115
|
+
const manifests = new Set(packages.map(pkg => pkg.manifest));
|
|
116
|
+
const unmodeledManifests = context.files.filter(file => /(?:^|\/)Cargo\.toml$/.test(file)
|
|
117
|
+
&& file !== "Cargo.toml" && !manifests.has(file));
|
|
118
|
+
if (unmodeledManifests.length) result.blockers.push(`Cargo manifests outside workspace membership require full validation: ${unmodeledManifests.join(", ")}`);
|
|
119
|
+
if (manifests.size !== packages.length) result.blockers.push("Cargo packages share a manifest; ownership is ambiguous");
|
|
120
|
+
const owner = (file: string) => {
|
|
121
|
+
const candidate = packages.find(pkg => under(file, pkg.directory));
|
|
122
|
+
if (!candidate || unmodeledManifests.some(manifest => {
|
|
123
|
+
const boundary = manifest.slice(0, -"/Cargo.toml".length);
|
|
124
|
+
return boundary.length > candidate.directory.length && under(file, boundary);
|
|
125
|
+
})) return undefined;
|
|
126
|
+
return candidate;
|
|
127
|
+
};
|
|
128
|
+
for (const file of context.files.filter(file => file.endsWith(".rs"))) {
|
|
129
|
+
if (!owner(file) || !repositoryPath(root, resolve(root, file), known)) {
|
|
130
|
+
result.blockers.push(`Rust file has no verified Cargo package: ${file}`);
|
|
131
|
+
} else result.sourcePaths.push(file);
|
|
132
|
+
}
|
|
133
|
+
result.rustTestTargets = {};
|
|
134
|
+
for (const { pkg } of packages) {
|
|
135
|
+
for (const target of pkg.targets) {
|
|
136
|
+
const path = repositoryPath(root, target.src_path, known);
|
|
137
|
+
if (!path || owner(path)?.pkg.id !== pkg.id) {
|
|
138
|
+
result.blockers.push(`Rust target ${pkg.name}/${target.name} has an unavailable, external or differently owned source`);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (target.kind.includes("custom-build")) continue;
|
|
142
|
+
const kind = target.kind.includes("test") ? "test"
|
|
143
|
+
: target.kind.includes("bin") ? "bin"
|
|
144
|
+
: target.kind.includes("example") ? "example"
|
|
145
|
+
: target.kind.includes("bench") ? "bench"
|
|
146
|
+
: target.kind.some(kind => ["lib", "rlib", "dylib", "cdylib", "staticlib", "proc-macro"].includes(kind)) ? "lib" : undefined;
|
|
147
|
+
if (!kind) {
|
|
148
|
+
result.blockers.push(`Unsupported Cargo target kind: ${pkg.name}/${target.name}`);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
result.sourcePaths.push(path);
|
|
152
|
+
// Cargo's test/doctest flags are authoritative. A crate's lib/bin root
|
|
153
|
+
// represents its unit tests, including #[cfg(test)] modules in other files.
|
|
154
|
+
if (!target.test && !target.doctest) continue;
|
|
155
|
+
if (Object.hasOwn(result.rustTestTargets, path)) {
|
|
156
|
+
result.blockers.push(`Multiple Cargo test targets share a source path: ${path}`);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
result.testFiles.push(path);
|
|
160
|
+
result.testPackages[path] = pkg.name;
|
|
161
|
+
result.rustTestTargets[path] = { name: target.name, kind };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
result.sourcePaths = [...new Set(result.sourcePaths)].sort();
|
|
165
|
+
result.testFiles.sort();
|
|
166
|
+
if (!result.testFiles.length) result.blockers.push("Cargo metadata found no supported test targets");
|
|
167
|
+
} catch {
|
|
168
|
+
result.blockers.push("Invalid or incomplete Cargo metadata requires full validation");
|
|
169
|
+
}
|
|
170
|
+
return result;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export const rustAdapter: RepositoryAdapter = {
|
|
174
|
+
id: "rust", version: "1", kind: "language",
|
|
175
|
+
detect: ({ files }) => files.some(file => /(?:^|\/)Cargo\.toml$/.test(file) || file.endsWith(".rs")),
|
|
176
|
+
analyze(context) {
|
|
177
|
+
const failure = contribution(this);
|
|
178
|
+
if (!context.files.includes("Cargo.toml")) {
|
|
179
|
+
failure.blockers.push("Rust support requires a root Cargo.toml");
|
|
180
|
+
return failure;
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
// Metadata does not execute repository code. Offline + locked prevents
|
|
184
|
+
// dependency downloads and changes to the repository's Cargo.lock.
|
|
185
|
+
const output = execFileSync("cargo", ["metadata", "--format-version", "1", "--no-deps", "--offline", "--locked"], {
|
|
186
|
+
cwd: context.repoPath, encoding: "utf8", timeout: 60_000, maxBuffer: 64 * 1024 * 1024,
|
|
187
|
+
windowsHide: true, stdio: ["ignore", "pipe", "pipe"],
|
|
188
|
+
});
|
|
189
|
+
return analyzeRustMetadata(context, output);
|
|
190
|
+
} catch {
|
|
191
|
+
failure.blockers.push("Cargo metadata unavailable: install Rust and repository dependencies; offline, locked metadata must succeed");
|
|
192
|
+
return failure;
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
};
|
|
@@ -20,6 +20,8 @@ export interface AdapterContribution {
|
|
|
20
20
|
virtualSources: Array<{ path: string; source: string }>;
|
|
21
21
|
testFiles: string[];
|
|
22
22
|
testPackages: Record<string, string>;
|
|
23
|
+
/** Cargo target roots; a lib/bin root represents the crate's unit tests. */
|
|
24
|
+
rustTestTargets?: Record<string, { name: string; kind: "lib" | "bin" | "test" | "bench" | "example" }>;
|
|
23
25
|
executionEnv?: Record<string, string>;
|
|
24
26
|
/** The interpreter the adapter analysed with and its runner should use, such as ["python3"]. */
|
|
25
27
|
interpreter?: string[];
|
|
@@ -288,6 +288,7 @@ const CONTENT_PATH_WORD = /[A-Za-z0-9._\-/@+~*?{}[\]!,$]+/g;
|
|
|
288
288
|
|
|
289
289
|
/** Keys whose list names files a tool skips: tsconfig and Vitest `exclude`, knip `ignore`, ESLint-style
|
|
290
290
|
* `ignores` and `ignorePatterns`, Jest `testPathIgnorePatterns` and its siblings. */
|
|
291
|
+
const EXCLUSION_LOOKBACK = 4096;
|
|
291
292
|
const EXCLUSION_KEY = /^(?:ignored?|ignores|excluded?|excludes|ignorePatterns|\w*PathIgnorePatterns)$/;
|
|
292
293
|
|
|
293
294
|
/**
|
|
@@ -302,7 +303,11 @@ function inExclusionList(content: string, index: number): boolean {
|
|
|
302
303
|
// Closers seen so far, so a balanced `{x,}` or `[!d]` in an earlier glob of the same list is skipped.
|
|
303
304
|
const open: Record<string, number> = { "[": 0, "{": 0, "(": 0 };
|
|
304
305
|
const opener: Record<string, string> = { "]": "[", "}": "{", ")": "(" };
|
|
305
|
-
|
|
306
|
+
// Bounded (2026-11-15): scanning back to the start for every matching word was quadratic in large
|
|
307
|
+
// JSON files. A list opened further back than this is not recognised, so the word still counts as a
|
|
308
|
+
// reference, the conservative answer.
|
|
309
|
+
const stop = Math.max(0, index - EXCLUSION_LOOKBACK);
|
|
310
|
+
for (let i = index - 1; i >= stop; i--) {
|
|
306
311
|
const char = content[i]!;
|
|
307
312
|
if (char in opener) { open[opener[char]!]!++; continue; }
|
|
308
313
|
if (!(char in open)) continue;
|
|
@@ -548,6 +553,39 @@ function packageJsonNames(content: string, pattern: RegExp, target: string, ance
|
|
|
548
553
|
return "no";
|
|
549
554
|
}
|
|
550
555
|
|
|
556
|
+
/**
|
|
557
|
+
* Searches already made in this analysis, keyed by the analysis's `read` function (2026-11-15). On
|
|
558
|
+
* diffci.com, 55 changed research files each followed up to 50 readers through the same handful of
|
|
559
|
+
* manifests, and every hop re-read all ~2,800 repository files: verify spent 6-25 minutes here while the
|
|
560
|
+
* full suite takes under 2. Which files name a target depends only on the target and the repository at
|
|
561
|
+
* HEAD, so each target is searched once per analysis.
|
|
562
|
+
*/
|
|
563
|
+
const namerCache = new WeakMap<(path: string) => string | undefined, Map<string, Set<string>>>();
|
|
564
|
+
|
|
565
|
+
/** Files whose content names `target` (contentNamesPath), among those resolveFileReferences reads as text. */
|
|
566
|
+
function namersOf(target: string, ancestors: boolean, input: ReferenceResolutionInput, read: (path: string) => string | undefined): Set<string> {
|
|
567
|
+
let cache = namerCache.get(input.read);
|
|
568
|
+
if (!cache) namerCache.set(input.read, cache = new Map());
|
|
569
|
+
const key = `${ancestors ? "a" : "f"}:${target}`;
|
|
570
|
+
const cached = cache.get(key);
|
|
571
|
+
if (cached) return cached;
|
|
572
|
+
const pattern = referencePattern(referenceTokens(target, { ancestors }));
|
|
573
|
+
const targetIsCode = input.isCodeFile(target);
|
|
574
|
+
const found = new Set<string>();
|
|
575
|
+
for (const candidate of input.files) {
|
|
576
|
+
const base = posix.basename(candidate);
|
|
577
|
+
if (candidate === target || LOCKFILES.has(base) || base === "package.json" || PATH_LIST_CONFIG.test(base) || input.isDocumentation(candidate)) continue;
|
|
578
|
+
const content = read(candidate);
|
|
579
|
+
// A test runner's include and exclude globs select test files, so one matching a data file does not
|
|
580
|
+
// make the runner read it; an exact path in the config still counts (2026-11-05: LobeHub's
|
|
581
|
+
// packages/alint/vitest.config.mts excludes fixture directories under scripts/).
|
|
582
|
+
const globsSelectTests = loadsWithoutNaming(candidate) && !targetIsCode;
|
|
583
|
+
if (content !== undefined && contentNamesPath(content, candidate, target, pattern, ancestors, !globsSelectTests)) found.add(candidate);
|
|
584
|
+
}
|
|
585
|
+
cache.set(key, found);
|
|
586
|
+
return found;
|
|
587
|
+
}
|
|
588
|
+
|
|
551
589
|
/** Resolves who reads `filePath`. See the module comment for the rule and its limits. */
|
|
552
590
|
export function resolveFileReferences(filePath: string, input: ReferenceResolutionInput): ReferenceResolution {
|
|
553
591
|
const resolution: ReferenceResolution = { tests: [], code: [], unresolvable: [], blockers: [], readers: [], phases: [] };
|
|
@@ -565,6 +603,7 @@ export function resolveFileReferences(filePath: string, input: ReferenceResoluti
|
|
|
565
603
|
let transitiveCount = 0;
|
|
566
604
|
const contents = new Map<string, string | undefined>();
|
|
567
605
|
const read = (path: string) => { if (!contents.has(path)) contents.set(path, input.read(path)); return contents.get(path); };
|
|
606
|
+
const namers = (target: string, ancestors: boolean) => namersOf(target, ancestors, input, read);
|
|
568
607
|
|
|
569
608
|
for (let depth = 0; depth < MAX_DEPTH && frontier.length > 0; depth++) {
|
|
570
609
|
const next: Array<{ path: string; via: string; lint?: boolean }> = [];
|
|
@@ -608,11 +647,7 @@ export function resolveFileReferences(filePath: string, input: ReferenceResoluti
|
|
|
608
647
|
block(`${candidate} could not be read`, target.path);
|
|
609
648
|
continue;
|
|
610
649
|
}
|
|
611
|
-
|
|
612
|
-
// make the runner read it; an exact path in the config still counts (2026-11-05: LobeHub's
|
|
613
|
-
// packages/alint/vitest.config.mts excludes fixture directories under scripts/).
|
|
614
|
-
const globsSelectTests = loadsWithoutNaming(candidate) && !input.isCodeFile(target.path);
|
|
615
|
-
if (content === undefined || !contentNamesPath(content, candidate, target.path, pattern, ancestors, !globsSelectTests)) continue;
|
|
650
|
+
if (content === undefined || !namers(target.path, ancestors).has(candidate)) continue;
|
|
616
651
|
visited.add(candidate);
|
|
617
652
|
if (input.allowNoReaders && /^dockerfile/i.test(base) && copiesOnly(content, target.path)) {
|
|
618
653
|
// The caller modelled what the file does when installed (dependency selection); a Dockerfile
|
|
@@ -301,6 +301,11 @@ export class ImpactAnalyzer {
|
|
|
301
301
|
private unresolved: readonly UnresolvedDependency[] = [];
|
|
302
302
|
/** Why each changed file the reference resolver could not narrow is unresolvable, for fallbackDetails. */
|
|
303
303
|
private referenceBlockers = new Map<string, string[]>();
|
|
304
|
+
/** This analysis's fallback reasons so far. They are only ever added to, so once there is one the plan
|
|
305
|
+
* runs the full suite whatever else is found, and resolveByReference stops searching (2026-11-15). */
|
|
306
|
+
private fallbackSoFar: readonly string[] = [];
|
|
307
|
+
/** Changed files whose readers were not searched because the full suite was already required. */
|
|
308
|
+
private readersNotSearched = new Set<string>();
|
|
304
309
|
private walkerTests: string[] | undefined;
|
|
305
310
|
private knownTests: string[] | undefined;
|
|
306
311
|
private declaredCovered = new Set<string>();
|
|
@@ -560,6 +565,8 @@ export class ImpactAnalyzer {
|
|
|
560
565
|
}
|
|
561
566
|
this.unresolved = graphResult.unresolved ?? [];
|
|
562
567
|
this.referenceBlockers = new Map();
|
|
568
|
+
this.fallbackSoFar = [];
|
|
569
|
+
this.readersNotSearched = new Set();
|
|
563
570
|
this.sortedRepositoryFiles = options.repositoryFiles ? [...options.repositoryFiles].sort() : [];
|
|
564
571
|
this.compiledProjectCache = undefined;
|
|
565
572
|
// One read per file per analysis, however many changed files ask who reads them.
|
|
@@ -664,6 +671,7 @@ export class ImpactAnalyzer {
|
|
|
664
671
|
const affectedTests = new Map<string, TestImpact>();
|
|
665
672
|
const affectedScripts = new Map<string, ImpactEvidence[]>();
|
|
666
673
|
|
|
674
|
+
this.fallbackSoFar = fallbackReasons;
|
|
667
675
|
for (const changedImpact of changedImpacts) {
|
|
668
676
|
for (const path of allChangePaths(changedImpact.file)) {
|
|
669
677
|
this.processChangedPath(path, changedImpact, graph, profile, affectedSources, affectedAssets, affectedEntryPoints, affectedTests, affectedScripts, evidence, riskSignals, fallbackReasons);
|
|
@@ -720,6 +728,10 @@ export class ImpactAnalyzer {
|
|
|
720
728
|
}
|
|
721
729
|
}
|
|
722
730
|
|
|
731
|
+
if (this.readersNotSearched.size > 0) {
|
|
732
|
+
const paths = [...this.readersNotSearched].sort();
|
|
733
|
+
riskSignals.push({ level: "info", reason: "READERS_NOT_SEARCHED", message: `Readers of ${paths.length} changed file(s) were not searched because full validation was already required`, paths: paths.slice(0, 20) });
|
|
734
|
+
}
|
|
723
735
|
const fallbackRequired = effectiveGraphConfidence === "UNSAFE" || fallbackReasons.length > 0;
|
|
724
736
|
const analysisStatus: ImpactResult["analysisStatus"] = fallbackRequired ? "FALLBACK" : "SAFE_TO_PROPOSE";
|
|
725
737
|
const dedupedRiskSignals = Array.from(
|
|
@@ -1258,6 +1270,16 @@ export class ImpactAnalyzer {
|
|
|
1258
1270
|
): boolean {
|
|
1259
1271
|
if (!this.repositoryFiles || !this.readRepositoryFile) return false;
|
|
1260
1272
|
if (isImplicitlyLoadedFile(changedPath) && !(isWorkerConfig(changedPath) && this.workerConfigsOutsideSuite())) return false;
|
|
1273
|
+
// Searching who reads a file costs a pass over every repository file per reader followed. Once the full
|
|
1274
|
+
// suite is already required, no answer changes the plan (2026-11-15: verify on diffci.com spent 15
|
|
1275
|
+
// minutes resolving ~1,000 changed files after the first fallback reason had decided the run). The
|
|
1276
|
+
// search is skipped and the file adds no reason of its own, since "could not be resolved" would be
|
|
1277
|
+
// untrue; the full suite covers it. Only the affected tests verify runs ahead of the full suite lose
|
|
1278
|
+
// the readers it would have added.
|
|
1279
|
+
if (this.fallbackSoFar.length > 0) {
|
|
1280
|
+
this.readersNotSearched.add(changedPath);
|
|
1281
|
+
return true;
|
|
1282
|
+
}
|
|
1261
1283
|
const layout = this.layout;
|
|
1262
1284
|
const scripts = profile.packageJson.scripts;
|
|
1263
1285
|
const resolution = resolveFileReferences(changedPath, {
|
|
@@ -51,6 +51,12 @@ export interface RepositoryProfile {
|
|
|
51
51
|
goDependencyPaths?: { sources: string[]; embeds: string[] };
|
|
52
52
|
/** Maven/JUnit test file to owning reactor module (repo-relative, "." for root). */
|
|
53
53
|
mavenTestModules?: Record<string, string>;
|
|
54
|
+
/** Cargo target source to owning package name and target, verified by metadata. */
|
|
55
|
+
rustTestPackages?: Record<string, string>;
|
|
56
|
+
rustTestTargets?: Record<string, { name: string; kind: "lib" | "bin" | "test" | "bench" | "example" }>;
|
|
57
|
+
rustSources?: string[];
|
|
58
|
+
/** Set only when the repository's test invocation is supported and reproducible. */
|
|
59
|
+
rustTestInvocation?: "cargo test";
|
|
54
60
|
/** Python files and pytest test files the Python adapter modelled (adapters/python.ts), and the
|
|
55
61
|
* interpreter it found. Only these `.py` files are code; other `.py` files stay unknown files. */
|
|
56
62
|
pythonSources?: string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diffci.com/diffci",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.47",
|
|
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#4fb81d791c8cc6539df8cd1b59eb029be04c295b",
|
|
80
80
|
"saxes": "6.0.0",
|
|
81
81
|
"yaml": "^2.9.0"
|
|
82
82
|
},
|