@diffci.com/diffci 0.3.45 → 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/red-builds.d.ts +33 -3
- package/dist-client/src/client/red-builds.js +71 -10
- 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
|
@@ -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
|
},
|