@diffci.com/diffci 0.3.32 → 0.3.33
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/README.md +23 -0
- package/dist-client/src/client/check-plan-junit.d.ts +25 -0
- package/dist-client/src/client/check-plan-junit.js +215 -0
- package/dist-client/src/client/check-plan.d.ts +42 -0
- package/dist-client/src/client/check-plan.js +143 -0
- package/dist-client/src/client/cli.js +212 -7
- package/dist-client/src/client/command-batches.d.ts +1 -0
- package/dist-client/src/client/command-batches.js +3 -1
- package/dist-client/src/client/enforce-misses-collect.js +6 -1
- package/dist-client/src/client/enforce-misses.d.ts +3 -2
- package/dist-client/src/client/enforce-misses.js +19 -59
- package/dist-client/src/client/failure-baseline.js +0 -0
- package/dist-client/src/client/full-command.d.ts +8 -0
- package/dist-client/src/client/full-command.js +31 -0
- package/dist-client/src/client/job-summary.js +1 -1
- package/dist-client/src/client/observe.d.ts +4 -0
- package/dist-client/src/client/observe.js +31 -2
- package/dist-client/src/client/report.d.ts +4 -0
- package/dist-client/src/client/test-results.js +7 -0
- package/dist-client/src/client/verify.d.ts +18 -0
- package/dist-client/src/client/verify.js +39 -10
- package/dist-client/src/client/watch.d.ts +36 -0
- package/dist-client/src/client/watch.js +76 -0
- package/node_modules/@diffci.com/core/README.md +36 -5
- package/node_modules/@diffci.com/core/dist/cache/graph-cache.d.ts +1 -1
- package/node_modules/@diffci.com/core/dist/cache/graph-cache.js +3 -1
- package/node_modules/@diffci.com/core/dist/cache/graph-cache.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/git/git-diff.d.ts +12 -0
- package/node_modules/@diffci.com/core/dist/git/git-diff.js +86 -0
- package/node_modules/@diffci.com/core/dist/git/git-diff.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/git/types.d.ts +8 -0
- package/node_modules/@diffci.com/core/dist/planner/test-command.js +16 -0
- package/node_modules/@diffci.com/core/dist/planner/test-command.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/index.js +2 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/index.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/python.d.ts +32 -0
- package/node_modules/@diffci.com/core/dist/repo/adapters/python.js +273 -0
- package/node_modules/@diffci.com/core/dist/repo/adapters/python.js.map +1 -0
- package/node_modules/@diffci.com/core/dist/repo/adapters/types.d.ts +2 -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 +21 -0
- package/node_modules/@diffci.com/core/dist/repo/file-references.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/graph.d.ts +4 -0
- package/node_modules/@diffci.com/core/dist/repo/graph.js +182 -21
- package/node_modules/@diffci.com/core/dist/repo/graph.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/impact.d.ts +1 -0
- package/node_modules/@diffci.com/core/dist/repo/impact.js +29 -4
- package/node_modules/@diffci.com/core/dist/repo/impact.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/types.d.ts +5 -0
- package/node_modules/@diffci.com/core/src/cache/graph-cache.ts +3 -1
- package/node_modules/@diffci.com/core/src/git/git-diff.ts +72 -0
- package/node_modules/@diffci.com/core/src/git/types.ts +5 -0
- package/node_modules/@diffci.com/core/src/planner/test-command.ts +14 -0
- package/node_modules/@diffci.com/core/src/repo/adapters/index.ts +2 -1
- package/node_modules/@diffci.com/core/src/repo/adapters/python.ts +252 -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 +19 -0
- package/node_modules/@diffci.com/core/src/repo/graph.ts +154 -20
- package/node_modules/@diffci.com/core/src/repo/impact.ts +27 -4
- package/node_modules/@diffci.com/core/src/repo/types.ts +5 -0
- package/package.json +3 -2
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
* verify fail-closed verification of a working-tree snapshot or commit range
|
|
15
15
|
* gate run a build's whole gate and record what DiffCI would have skipped (observe)
|
|
16
16
|
* check analysis plus automatic paired runtime measurement
|
|
17
|
+
* plan print Core's advisory JSON plan for a commit range (the input check-plan reads)
|
|
18
|
+
* check-plan compare a saved test selection with one full-suite JUnit result
|
|
17
19
|
* observe analyse the checkout and write an observation report
|
|
18
20
|
* verify-savings run a paired full-versus-selected timing check
|
|
19
21
|
* validate-specs block conflicting same-turn change specifications
|
|
@@ -29,7 +31,7 @@
|
|
|
29
31
|
* exits 1 on a BLOCKING finding - it is a pre-install check run by a human, not a step inside a build.
|
|
30
32
|
*/
|
|
31
33
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
32
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
34
|
+
import { closeSync, constants, existsSync, fstatSync, mkdirSync, openSync, readFileSync, readSync, writeFileSync } from "node:fs";
|
|
33
35
|
import { tmpdir } from "node:os";
|
|
34
36
|
import { basename, dirname, join, resolve } from "node:path";
|
|
35
37
|
import { observe, isInsideRepository } from "./observe.js";
|
|
@@ -47,6 +49,8 @@ import { configureTelemetry, readTelemetryPreference, recordUsage } from "./tele
|
|
|
47
49
|
import { formatFeedbackPrompt, markFeedbackPromptShown, shouldShowFeedbackPrompt } from "./feedback-prompt.js";
|
|
48
50
|
import { detectSpecificationConflicts, readSpecificationFile } from "./spec-conflicts.js";
|
|
49
51
|
import { formatVerificationSummary, verificationExitCode, verifyChanged, verifyRange } from "./verify.js";
|
|
52
|
+
import { startWatch } from "./watch.js";
|
|
53
|
+
import { captureWorkingTreeSnapshot } from "./working-tree.js";
|
|
50
54
|
import { decideStop, HOOK_AGENTS, maxAttempts, parseStopPayload, sessionAttempts, stopRepoPath } from "./agent-stop.js";
|
|
51
55
|
import { formatGateSummary, gateExitCode, planGate, runGate } from "./gate.js";
|
|
52
56
|
import { formatGrowthPrompt, formatVerifySavingsSummary, measureCommand, runVerifySavings, writeVerifySavingsReport } from "./verify-savings.js";
|
|
@@ -56,6 +60,7 @@ import { observerIdentity } from "./package-identity.js";
|
|
|
56
60
|
import { buildPilotWorkflow, diffciVerificationWorkflow, diffciWorkflow } from "./workflow-templates.js";
|
|
57
61
|
import { buildMissReport, formatMissReportMarkdown, parseJunit } from "./enforce-misses.js";
|
|
58
62
|
import { appendOutcome, formatOutcomeSummary, outcomeLogPath, readOutcomes, summarizeOutcomes } from "./outcome-log.js";
|
|
63
|
+
import { checkPlan } from "./check-plan.js";
|
|
59
64
|
import { buildCoverageMap, formatCoverageRun } from "./coverage-map.js";
|
|
60
65
|
import { confidenceCurve, formatConfidenceCurve } from "./test-ranking.js";
|
|
61
66
|
import { parseShard, readTimings, timingsFromOutcomes } from "./test-shards.js";
|
|
@@ -82,6 +87,111 @@ function parseArgs(argv) {
|
|
|
82
87
|
}
|
|
83
88
|
return { command, flags };
|
|
84
89
|
}
|
|
90
|
+
const CHECK_PLAN_MAX_INPUT_BYTES = 16 * 1024 * 1024;
|
|
91
|
+
function readCheckPlanInput(path) {
|
|
92
|
+
// Nonblocking open prevents a named pipe from hanging before the regular-file check. The capped
|
|
93
|
+
// read also preserves the limit if a regular file grows after fstat.
|
|
94
|
+
const descriptor = openSync(path, constants.O_RDONLY | constants.O_NONBLOCK);
|
|
95
|
+
try {
|
|
96
|
+
const info = fstatSync(descriptor);
|
|
97
|
+
if (!info.isFile())
|
|
98
|
+
throw new Error(`Input must be a regular file: ${path}`);
|
|
99
|
+
if (info.size > CHECK_PLAN_MAX_INPUT_BYTES)
|
|
100
|
+
throw new Error(`Input exceeds the 16 MiB limit: ${path}`);
|
|
101
|
+
const bytes = Buffer.allocUnsafe(Math.min(info.size, CHECK_PLAN_MAX_INPUT_BYTES) + 1);
|
|
102
|
+
let length = 0;
|
|
103
|
+
while (length < bytes.length) {
|
|
104
|
+
const read = readSync(descriptor, bytes, length, bytes.length - length, null);
|
|
105
|
+
if (read === 0)
|
|
106
|
+
break;
|
|
107
|
+
length += read;
|
|
108
|
+
}
|
|
109
|
+
if (length > CHECK_PLAN_MAX_INPUT_BYTES)
|
|
110
|
+
throw new Error(`Input exceeds the 16 MiB limit: ${path}`);
|
|
111
|
+
if (length > info.size)
|
|
112
|
+
throw new Error(`Input grew while being read: ${path}`);
|
|
113
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(0, length));
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
closeSync(descriptor);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const PLAN_USAGE = "Usage: diffci plan --base <commit> [--head HEAD] [--repo <clean-checkout>]\nPrints Core's advisory JSON plan, the input check-plan reads. Accepts --flag=value. Does not run, skip or cancel tests.";
|
|
120
|
+
/** Same output and exit codes as Core's own `plan` command, so saved plans stay interchangeable. */
|
|
121
|
+
async function runPlanCommand(args) {
|
|
122
|
+
try {
|
|
123
|
+
if (args.length === 1 && (args[0] === "--help" || args[0] === "-h")) {
|
|
124
|
+
console.log(PLAN_USAGE);
|
|
125
|
+
return 0;
|
|
126
|
+
}
|
|
127
|
+
const values = new Map();
|
|
128
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
129
|
+
const token = args[index];
|
|
130
|
+
const equals = token.indexOf("=");
|
|
131
|
+
const flag = equals < 0 ? token : token.slice(0, equals);
|
|
132
|
+
if (!["--repo", "--base", "--head"].includes(flag))
|
|
133
|
+
throw new Error(`Unsupported plan argument: ${flag}`);
|
|
134
|
+
if (values.has(flag))
|
|
135
|
+
throw new Error(`Repeated plan argument: ${flag}`);
|
|
136
|
+
const value = equals < 0 ? args[++index] : token.slice(equals + 1);
|
|
137
|
+
if (!value || value.startsWith("--"))
|
|
138
|
+
throw new Error(`Missing value for ${flag}`);
|
|
139
|
+
values.set(flag, value);
|
|
140
|
+
}
|
|
141
|
+
const base = values.get("--base");
|
|
142
|
+
if (!base)
|
|
143
|
+
throw new Error("Expected: diffci plan --base <commit> [--head HEAD] [--repo <path>]");
|
|
144
|
+
const { analyzeCheckout } = await import("@diffci.com/core/analyze");
|
|
145
|
+
const plan = await analyzeCheckout({ repoPath: values.get("--repo") ?? process.cwd(), base, head: values.get("--head") ?? "HEAD" });
|
|
146
|
+
console.log(JSON.stringify(plan, null, 2));
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
console.error(JSON.stringify({ error: error instanceof Error ? error.message : String(error), recommendation: "RUN_FULL_CI" }));
|
|
151
|
+
return 1;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function runCheckPlanCommand(args) {
|
|
155
|
+
try {
|
|
156
|
+
const files = new Map();
|
|
157
|
+
if (args.length === 1 && args[0] === "--help") {
|
|
158
|
+
console.log("Usage: diffci check-plan --plan <file> --results <file> [--base-results <file>] [--root <reporter-root>] [--repo <checkout-root>] [--base-repo <base-checkout-root>]\nAccepts --flag=value. Without base results, skipped failures are possibleMisses. Exit 1: missed, possibleMisses or unattributed; exit 2: invalid input.");
|
|
159
|
+
return 0;
|
|
160
|
+
}
|
|
161
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
162
|
+
const token = args[index];
|
|
163
|
+
const equals = token.indexOf("=");
|
|
164
|
+
const flag = equals < 0 ? token : token.slice(0, equals);
|
|
165
|
+
if (!["--plan", "--results", "--base-results", "--root", "--repo", "--base-repo"].includes(flag))
|
|
166
|
+
throw new Error(`Unsupported check-plan argument: ${flag}`);
|
|
167
|
+
if (files.has(flag))
|
|
168
|
+
throw new Error(`Repeated check-plan argument: ${flag}`);
|
|
169
|
+
const value = equals < 0 ? args[++index] : token.slice(equals + 1);
|
|
170
|
+
if (!value || value.startsWith("--"))
|
|
171
|
+
throw new Error(`Missing file path for ${flag}`);
|
|
172
|
+
files.set(flag, value);
|
|
173
|
+
}
|
|
174
|
+
const planPath = files.get("--plan");
|
|
175
|
+
const resultsPath = files.get("--results");
|
|
176
|
+
if (!planPath || !resultsPath)
|
|
177
|
+
throw new Error("check-plan requires --plan <file> and --results <file>");
|
|
178
|
+
if (files.has("--base-repo") && !files.has("--base-results"))
|
|
179
|
+
throw new Error("--base-repo requires --base-results");
|
|
180
|
+
const plan = JSON.parse(readCheckPlanInput(planPath));
|
|
181
|
+
const basePath = files.get("--base-results");
|
|
182
|
+
const report = checkPlan(plan, readCheckPlanInput(resultsPath), {
|
|
183
|
+
root: files.get("--root"), repoRoot: resolve(files.get("--repo") ?? process.cwd()),
|
|
184
|
+
baseRepoRoot: files.has("--base-repo") ? resolve(files.get("--base-repo")) : undefined,
|
|
185
|
+
baseResults: basePath === undefined ? undefined : readCheckPlanInput(basePath),
|
|
186
|
+
});
|
|
187
|
+
console.log(JSON.stringify(report));
|
|
188
|
+
return report.summary.missed > 0 || report.summary.possibleMisses > 0 || report.summary.unattributed > 0 ? 1 : 0;
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
console.error(JSON.stringify({ schemaVersion: 1, error: error instanceof Error ? error.message : "Invalid check-plan input" }));
|
|
192
|
+
return 2;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
85
195
|
function defaultReportPath(env) {
|
|
86
196
|
// RUNNER_TEMP is outside GITHUB_WORKSPACE on every GitHub-hosted runner, which is the property that
|
|
87
197
|
// matters: the report cannot become an untracked file in the repository being observed.
|
|
@@ -397,6 +507,52 @@ function readStdin() {
|
|
|
397
507
|
process.stdin.on("error", () => resolveText(text));
|
|
398
508
|
});
|
|
399
509
|
}
|
|
510
|
+
async function runWatchCommand(flags, env) {
|
|
511
|
+
const repoPath = resolve(stringFlag(flags, "repo") ?? process.cwd());
|
|
512
|
+
const identity = observerIdentity();
|
|
513
|
+
const checks = flags.checks === true;
|
|
514
|
+
console.log(`DiffCI watching ${repoPath}: verifies the uncommitted changes after each save${checks ? "" : " (tests only; --checks adds lint, typecheck and other checks)"}. Ctrl+C stops.`);
|
|
515
|
+
const session = startWatch({
|
|
516
|
+
repoPath,
|
|
517
|
+
debounceMs: numberFlag(flags, "debounce-ms") ?? 300,
|
|
518
|
+
currentTree: () => { try {
|
|
519
|
+
return captureWorkingTreeSnapshot(repoPath).treeSha;
|
|
520
|
+
}
|
|
521
|
+
catch {
|
|
522
|
+
return undefined;
|
|
523
|
+
} },
|
|
524
|
+
run: async () => {
|
|
525
|
+
const started = Date.now();
|
|
526
|
+
const report = await verifyChanged({
|
|
527
|
+
repoPath,
|
|
528
|
+
env: env,
|
|
529
|
+
version: identity.version,
|
|
530
|
+
engineSha: identity.sha,
|
|
531
|
+
timeoutMs: numberFlag(flags, "timeout-ms") ?? 30 * 60 * 1000,
|
|
532
|
+
tailBytes: 12_000,
|
|
533
|
+
skipChecks: !checks,
|
|
534
|
+
});
|
|
535
|
+
if (flags["no-log"] !== true)
|
|
536
|
+
appendOutcome(repoPath, report, env);
|
|
537
|
+
console.log(formatWatchRun(report, Date.now() - started));
|
|
538
|
+
return { treeSha: report.snapshot.after_tree_sha ?? report.snapshot.before_tree_sha };
|
|
539
|
+
},
|
|
540
|
+
});
|
|
541
|
+
await new Promise((resolveStop) => process.once("SIGINT", () => { session.stop(); resolveStop(); }));
|
|
542
|
+
return 0;
|
|
543
|
+
}
|
|
544
|
+
/** One line for a pass, the full summary for anything else, so a failure shows what broke. */
|
|
545
|
+
function formatWatchRun(report, wallMs) {
|
|
546
|
+
const time = new Date().toTimeString().slice(0, 8);
|
|
547
|
+
if (report.selection === "none" && report.verification === "passed")
|
|
548
|
+
return `${time} no uncommitted changes`;
|
|
549
|
+
if (report.verification === "passed") {
|
|
550
|
+
const how = report.reused_from ? "reused an earlier pass of this tree" : `${report.selection} ${report.tests_selected} of ${report.tests_available} test files`;
|
|
551
|
+
return `${time} passed ${how} (${(wallMs / 1000).toFixed(1)}s)`;
|
|
552
|
+
}
|
|
553
|
+
return `${time} ${report.verification.toUpperCase()}
|
|
554
|
+
${formatVerificationSummary(report)}`;
|
|
555
|
+
}
|
|
400
556
|
async function runVerifyCommand(flags, env) {
|
|
401
557
|
const changed = flags.changed === true;
|
|
402
558
|
if (changed && (flags.base !== undefined || flags.head !== undefined)) {
|
|
@@ -631,7 +787,11 @@ function summarise(report, executionFollows = false) {
|
|
|
631
787
|
else {
|
|
632
788
|
lines.push(" planned reduction: unavailable (no discovered tests); runtime savings unmeasured");
|
|
633
789
|
}
|
|
634
|
-
|
|
790
|
+
const changeConfidence = result.graph.effectiveConfidence ?? result.graph.confidence;
|
|
791
|
+
lines.push(` graph: ${result.graph.nodes} nodes, confidence ${changeConfidence} for this change`);
|
|
792
|
+
if (result.graph.confidence !== changeConfidence || (result.graph.confidenceReasons?.length && changeConfidence !== "COMPLETE")) {
|
|
793
|
+
lines.push(` repository graph: ${result.graph.confidence}${result.graph.confidenceReasons?.length ? ` (${result.graph.confidenceReasons.join("; ")})` : ""}`);
|
|
794
|
+
}
|
|
635
795
|
if (result.fallbackReasons.length > 0) {
|
|
636
796
|
lines.push(` fallback: ${result.fallbackReasons.join("; ")}`);
|
|
637
797
|
for (const [path, blockers] of Object.entries(result.fallbackDetails ?? {})) {
|
|
@@ -869,6 +1029,17 @@ async function runObserve(flags, env) {
|
|
|
869
1029
|
// Losing the summary is cosmetic; the report on disk is the record.
|
|
870
1030
|
}
|
|
871
1031
|
}
|
|
1032
|
+
// The same Markdown for CI systems without a step summary (the GitLab component exposes it as an artifact).
|
|
1033
|
+
const summaryOut = stringFlag(flags, "summary-out");
|
|
1034
|
+
if (summaryOut) {
|
|
1035
|
+
try {
|
|
1036
|
+
mkdirSync(dirname(resolve(summaryOut)), { recursive: true });
|
|
1037
|
+
writeFileSync(resolve(summaryOut), formatJobSummary(report, summary, delivery), "utf8");
|
|
1038
|
+
}
|
|
1039
|
+
catch {
|
|
1040
|
+
// Cosmetic, as above.
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
872
1043
|
if (env.GITHUB_OUTPUT) {
|
|
873
1044
|
try {
|
|
874
1045
|
writeFileSync(env.GITHUB_OUTPUT, `report-path=${reportPath}\nstatus=${report.status}\n`, { flag: "a" });
|
|
@@ -957,8 +1128,15 @@ function runEnforceMisses(flags, env) {
|
|
|
957
1128
|
console.error(`No full-suite results at ${junitPath}: nothing can be classified, so no miss can be ruled out.`);
|
|
958
1129
|
return 2;
|
|
959
1130
|
}
|
|
1131
|
+
let fullRun;
|
|
1132
|
+
try {
|
|
1133
|
+
fullRun = parseJunit(readCheckPlanInput(junitPath), repoPath);
|
|
1134
|
+
}
|
|
1135
|
+
catch (error) {
|
|
1136
|
+
console.error(`Cannot read full-suite JUnit: ${error instanceof Error ? error.message : String(error)}`);
|
|
1137
|
+
return 2;
|
|
1138
|
+
}
|
|
960
1139
|
const headSha = stringFlag(flags, "head") ?? execFileSync("git", ["rev-parse", "HEAD"], { cwd: repoPath, encoding: "utf8" }).trim();
|
|
961
|
-
const fullRun = parseJunit(readFileSync(junitPath, "utf8"), repoPath);
|
|
962
1140
|
const failing = fullRun.filter((outcome) => outcome.failed);
|
|
963
1141
|
const runUrl = env.GITHUB_RUN_ID ? `${env.GITHUB_SERVER_URL ?? "https://github.com"}/${repository}/actions/runs/${env.GITHUB_RUN_ID}` : undefined;
|
|
964
1142
|
const notes = [];
|
|
@@ -972,9 +1150,14 @@ function runEnforceMisses(flags, env) {
|
|
|
972
1150
|
const rerunJunit = stringFlag(flags, "rerun-junit");
|
|
973
1151
|
const rerunArgs = inferRerunArgs(repoPath);
|
|
974
1152
|
const files = [...new Set(failing.map((outcome) => outcome.file).filter(Boolean))];
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
1153
|
+
let rerun;
|
|
1154
|
+
try {
|
|
1155
|
+
rerun = rerunJunit ? parseJunit(readCheckPlanInput(rerunJunit), repoPath)
|
|
1156
|
+
: rerunArgs && files.length > 0 ? rerunFailingFiles(repoPath, rerunArgs, files) : undefined;
|
|
1157
|
+
}
|
|
1158
|
+
catch (error) {
|
|
1159
|
+
notes.push(`rerun results unavailable: ${error instanceof Error ? error.message : String(error)}`);
|
|
1160
|
+
}
|
|
978
1161
|
if (!rerun)
|
|
979
1162
|
notes.push("failures were not re-run, so none could be ruled flaky; every failure was treated as deterministic");
|
|
980
1163
|
const collect = {
|
|
@@ -1217,6 +1400,7 @@ Pilot a repository: https://diffci.com/#pilot
|
|
|
1217
1400
|
Usage:
|
|
1218
1401
|
diffci init [--repo <path>] [--workflow] [--verification-workflow] [--install] [--no-hook] [--no-mcp] [--no-skill]
|
|
1219
1402
|
[--no-agent-hooks] [--force]
|
|
1403
|
+
diffci watch [--repo <path>] [--checks] [--debounce-ms <ms>] [--no-log]
|
|
1220
1404
|
diffci agent-stop --agent claude|codex|cursor (run by the agent stop hooks init installs; reads the hook JSON on stdin)
|
|
1221
1405
|
diffci mcp
|
|
1222
1406
|
diffci verify [--changed | --base <sha> --head <sha>] [--policy enforce] [--repo <path>] [--out <file>] [--json]
|
|
@@ -1226,11 +1410,13 @@ Usage:
|
|
|
1226
1410
|
diffci telemetry [--mode off|anonymous|installations] [--internal-usage]
|
|
1227
1411
|
diffci check [--repo <path>] [--out <file>] [--base <sha> --head <sha>]
|
|
1228
1412
|
[--redact-paths] [--json] [--quiet] [--fail-on-error] [--timeout-ms <ms>] [--share-usage]
|
|
1413
|
+
diffci plan --base <sha> [--head <sha>] [--repo <path>]
|
|
1414
|
+
diffci check-plan --plan <plan.json> --results <junit.xml>
|
|
1229
1415
|
diffci pilot --full <command> [--selected <command>] [--repo <path>] [--out-dir <dir>] [--label <name>]
|
|
1230
1416
|
diffci pilot-packet [--repo <path>] [--out-dir <dir>] [--base <sha> --head <sha>]
|
|
1231
1417
|
[--label <name>] [--repository-url <https-url>] [--redact-paths]
|
|
1232
1418
|
diffci observe [--repo <path>] [--out <file>] [--base <sha> --head <sha>]
|
|
1233
|
-
[--redact-paths] [--json] [--quiet] [--fail-on-error]
|
|
1419
|
+
[--redact-paths] [--json] [--quiet] [--fail-on-error] [--summary-out <file.md>]
|
|
1234
1420
|
[--api-url <url> --api-token <token>] [--no-send] [--share-usage] [--agent <name|auto>]
|
|
1235
1421
|
[--graph-cache-dir <dir>] [--shared-graph-cache [--graph-cache-url <url>]]
|
|
1236
1422
|
diffci verify-savings --repo <path> --full <command>
|
|
@@ -1271,6 +1457,11 @@ leaves) and stops at the first failure; --no-checks skips them, and they are ski
|
|
|
1271
1457
|
verify without --changed resolves the CI event range (or HEAD^..HEAD locally), requires a clean checkout,
|
|
1272
1458
|
and exits zero only when the analyzed head is the commit that actually passed verification.
|
|
1273
1459
|
check analyzes the change, runs inferred full and selected commands, and shows measured savings.
|
|
1460
|
+
plan prints Core's advisory JSON plan for a clean checkout at --head; save it before the full suite runs.
|
|
1461
|
+
It exits 1 with a RUN_FULL_CI error when it cannot plan. It runs no tests and sends nothing.
|
|
1462
|
+
check-plan reads one saved plan and one full-suite JUnit result, and prints a JSON failure comparison.
|
|
1463
|
+
It exits 1 for missed, possible-miss or unattributed failures, 2 for invalid inputs, and 0 otherwise. It runs no tests,
|
|
1464
|
+
reads no Git state, writes no reports, and sends nothing. Each UTF-8 input must be at most 16 MiB.
|
|
1274
1465
|
pilot runs observe and verify-savings together, writing reports to ../diffci-output by default.
|
|
1275
1466
|
pilot-packet writes a shareable compatibility summary, raw observation, and non-blocking workflow
|
|
1276
1467
|
outside the checkout. It runs no tests, modifies no target-repository files, and sends nothing.
|
|
@@ -1303,6 +1494,8 @@ and a selection that cannot be split run in shard 1.
|
|
|
1303
1494
|
coverage runs the full node:test suite once under a probe and V8 coverage and keeps, per test file, the files
|
|
1304
1495
|
it loaded, read or listed in .git/diffci/coverage-map.json. verify then also runs tests that map connects to a
|
|
1305
1496
|
changed file when the dependency graph did not select them; it only ever adds tests (--no-coverage ignores it).
|
|
1497
|
+
watch verifies the uncommitted changes after each save, as verify --changed would, and prints one line per
|
|
1498
|
+
pass and the full summary on a failure; tests only unless --checks.
|
|
1306
1499
|
outcomes summarises that log: results, selected and full runs, top full-run reasons, agents, and possible
|
|
1307
1500
|
misses (a selected run that passed and a later full run of the same tree that failed). --curve replays the
|
|
1308
1501
|
failing runs to show how soon the first failure is seen, ranked by history against path order. --timings
|
|
@@ -1331,6 +1524,15 @@ function maybeShowFeedbackPrompt(flags, env) {
|
|
|
1331
1524
|
markFeedbackPromptShown(env);
|
|
1332
1525
|
}
|
|
1333
1526
|
async function main() {
|
|
1527
|
+
// This stateless command deliberately bypasses shared flag handling, telemetry and feedback.
|
|
1528
|
+
if (process.argv[2] === "check-plan") {
|
|
1529
|
+
process.exitCode = runCheckPlanCommand(process.argv.slice(3));
|
|
1530
|
+
return;
|
|
1531
|
+
}
|
|
1532
|
+
if (process.argv[2] === "plan") {
|
|
1533
|
+
process.exitCode = await runPlanCommand(process.argv.slice(3));
|
|
1534
|
+
return;
|
|
1535
|
+
}
|
|
1334
1536
|
const { command, flags } = parseArgs(process.argv);
|
|
1335
1537
|
const env = process.env;
|
|
1336
1538
|
if (flags.help === true || command === "help" || command === undefined) {
|
|
@@ -1356,6 +1558,9 @@ async function main() {
|
|
|
1356
1558
|
case "verify":
|
|
1357
1559
|
process.exitCode = await runVerifyCommand(flags, env);
|
|
1358
1560
|
return;
|
|
1561
|
+
case "watch":
|
|
1562
|
+
process.exitCode = await runWatchCommand(flags, env);
|
|
1563
|
+
return;
|
|
1359
1564
|
case "agent-stop":
|
|
1360
1565
|
process.exitCode = await runAgentStopCommand(flags, env);
|
|
1361
1566
|
return;
|
|
@@ -131,7 +131,9 @@ export function measureCommands(commands, options) {
|
|
|
131
131
|
parts.push(part);
|
|
132
132
|
if (part.timedOut)
|
|
133
133
|
break;
|
|
134
|
-
|
|
134
|
+
// `stopOnFailureWithin`: only a failure among the first n parts stops the run (verify's first pass).
|
|
135
|
+
const stops = options.stopOnFailure || parts.length <= (options.stopOnFailureWithin ?? 0);
|
|
136
|
+
if (stops && (part.exitCode !== 0 || part.signal !== null) && parts.length < commands.length) {
|
|
135
137
|
stopped = true;
|
|
136
138
|
break;
|
|
137
139
|
}
|
|
@@ -149,7 +149,12 @@ export function rerunFailingFiles(repoPath, runnerArgs, files) {
|
|
|
149
149
|
});
|
|
150
150
|
if (!existsSync(junit))
|
|
151
151
|
return undefined;
|
|
152
|
-
|
|
152
|
+
try {
|
|
153
|
+
return parseJunit(readFileSync(junit, "utf8"), repoPath);
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
return undefined;
|
|
157
|
+
} // A partial rerun cannot prove a full-run failure flaky.
|
|
153
158
|
}
|
|
154
159
|
finally {
|
|
155
160
|
rmSync(directory, { recursive: true, force: true });
|
|
@@ -8,6 +8,7 @@ export interface TestOutcome {
|
|
|
8
8
|
name: string;
|
|
9
9
|
failed: boolean;
|
|
10
10
|
skipped: boolean;
|
|
11
|
+
suiteLevel?: boolean;
|
|
11
12
|
}
|
|
12
13
|
/** The receipt fields the detector reads; older receipts may lack `selected_tests`. */
|
|
13
14
|
export type ReceiptFields = Pick<VerificationReport, "schema" | "selection" | "selected_tests" | "command" | "enforcement" | "commit_range">;
|
|
@@ -89,9 +90,9 @@ export interface MissReport {
|
|
|
89
90
|
open_unsafe_misses: UnsafeMissEntry[];
|
|
90
91
|
notes: string[];
|
|
91
92
|
}
|
|
92
|
-
/**
|
|
93
|
+
/** Legacy identity normalization: stored v1 detector baselines depend on these exact rules. */
|
|
93
94
|
export declare function normalizeTestPath(path: string, repoRoot: string): string;
|
|
94
|
-
/** Testcases in document order
|
|
95
|
+
/** Testcases in document order. Repeated ids are merged: any failure wins. */
|
|
95
96
|
export declare function parseJunit(xml: string, repoRoot: string): TestOutcome[];
|
|
96
97
|
/**
|
|
97
98
|
* The test files a `selected` receipt ran. Receipts from before `selected_tests` existed fall back to the
|
|
@@ -13,27 +13,12 @@
|
|
|
13
13
|
* Nothing here changes configuration. A miss produces the exact `enforce.openUnsafeMisses` entry for
|
|
14
14
|
* a human to add; re-enabling enforcement is never automatic.
|
|
15
15
|
*/
|
|
16
|
+
import { readJunit, junitFile } from "./check-plan-junit.js";
|
|
16
17
|
import { isAbsolute, relative, resolve } from "node:path";
|
|
17
18
|
export const MISS_REPORT_SCHEMA = "diffci.enforce-misses.v1";
|
|
18
19
|
// ---------------------------------------------------------------------------------------------------
|
|
19
20
|
// JUnit (node:test's `--test-reporter=junit`, which also matches the common Jest/Vitest shape)
|
|
20
|
-
|
|
21
|
-
return text.replace(/&(#x[0-9a-f]+|#\d+|amp|lt|gt|quot|apos);/gi, (_, entity) => {
|
|
22
|
-
const lower = entity.toLowerCase();
|
|
23
|
-
if (lower.startsWith("#x"))
|
|
24
|
-
return String.fromCodePoint(Number.parseInt(lower.slice(2), 16));
|
|
25
|
-
if (lower.startsWith("#"))
|
|
26
|
-
return String.fromCodePoint(Number.parseInt(lower.slice(1), 10));
|
|
27
|
-
return { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'" }[lower];
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
function attributes(source) {
|
|
31
|
-
const result = {};
|
|
32
|
-
for (const match of source.matchAll(/([\w:.-]+)\s*=\s*"([^"]*)"/g))
|
|
33
|
-
result[match[1]] = decodeEntities(match[2]);
|
|
34
|
-
return result;
|
|
35
|
-
}
|
|
36
|
-
/** Repository-relative with forward slashes; paths outside the repository stay absolute. */
|
|
21
|
+
/** Legacy identity normalization: stored v1 detector baselines depend on these exact rules. */
|
|
37
22
|
export function normalizeTestPath(path, repoRoot) {
|
|
38
23
|
const slashed = path.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
39
24
|
if (!slashed)
|
|
@@ -43,53 +28,25 @@ export function normalizeTestPath(path, repoRoot) {
|
|
|
43
28
|
const inside = relative(resolve(repoRoot), resolve(path));
|
|
44
29
|
return inside && !inside.startsWith("..") && !isAbsolute(inside) ? inside.replace(/\\/g, "/") : slashed;
|
|
45
30
|
}
|
|
46
|
-
/** Testcases in document order
|
|
31
|
+
/** Testcases in document order. Repeated ids are merged: any failure wins. */
|
|
47
32
|
export function parseJunit(xml, repoRoot) {
|
|
48
33
|
const byId = new Map();
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const seen = byId.get(current.id);
|
|
34
|
+
readJunit(xml, (test, failed, skipped) => {
|
|
35
|
+
const file = junitFile(test, repoRoot);
|
|
36
|
+
const name = [...test.suiteNames, test.name].filter(Boolean).join(" > ");
|
|
37
|
+
const id = `${normalizeTestPath(test.file ?? "", repoRoot)} > ${name}`;
|
|
38
|
+
const seen = byId.get(id);
|
|
55
39
|
if (seen) {
|
|
56
|
-
seen.failed ||=
|
|
57
|
-
seen.skipped &&=
|
|
40
|
+
seen.failed ||= failed;
|
|
41
|
+
seen.skipped &&= skipped;
|
|
42
|
+
if (test.suiteLevel)
|
|
43
|
+
seen.suiteLevel = true;
|
|
44
|
+
if (seen.file !== file)
|
|
45
|
+
seen.file = "";
|
|
58
46
|
}
|
|
59
47
|
else
|
|
60
|
-
byId.set(
|
|
61
|
-
|
|
62
|
-
};
|
|
63
|
-
// Attribute values may hold a raw `>` (failure messages), so the tag body skips over quoted strings.
|
|
64
|
-
const tags = /<(\/?)(testsuite|testcase|failure|error|skipped)\b((?:[^>"]|"[^"]*")*?)(\/?)>/g;
|
|
65
|
-
for (const [, closing, tag, body, selfClosing] of xml.matchAll(tags)) {
|
|
66
|
-
if (tag === "testsuite") {
|
|
67
|
-
if (closing)
|
|
68
|
-
suites.pop();
|
|
69
|
-
else if (!selfClosing)
|
|
70
|
-
suites.push(attributes(body).name ?? "");
|
|
71
|
-
}
|
|
72
|
-
else if (tag === "testcase") {
|
|
73
|
-
if (closing) {
|
|
74
|
-
finish();
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
finish();
|
|
78
|
-
const attrs = attributes(body);
|
|
79
|
-
const file = normalizeTestPath(attrs.file ?? "", repoRoot);
|
|
80
|
-
const name = [...suites, attrs.name ?? ""].filter(Boolean).join(" > ");
|
|
81
|
-
current = { id: `${file} > ${name}`, file, name, failed: attrs.failure !== undefined, skipped: false };
|
|
82
|
-
if (selfClosing)
|
|
83
|
-
finish();
|
|
84
|
-
}
|
|
85
|
-
else if (current && !closing) {
|
|
86
|
-
if (tag === "skipped")
|
|
87
|
-
current.skipped = true;
|
|
88
|
-
else
|
|
89
|
-
current.failed = true;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
finish();
|
|
48
|
+
byId.set(id, { id, file, name, failed, skipped, ...(test.suiteLevel ? { suiteLevel: true } : {}) });
|
|
49
|
+
});
|
|
93
50
|
return [...byId.values()];
|
|
94
51
|
}
|
|
95
52
|
// ---------------------------------------------------------------------------------------------------
|
|
@@ -141,6 +98,9 @@ export function classifyFailures(input) {
|
|
|
141
98
|
if (baseline.has(outcome.id)) {
|
|
142
99
|
return { ...base, classification: "pre-existing", pull_requests: [], detail: `already failing at the start of the window; ${rerunNote}` };
|
|
143
100
|
}
|
|
101
|
+
if (outcome.suiteLevel || !outcome.file) {
|
|
102
|
+
return { ...base, classification: "unattributed", pull_requests: [], detail: `no testcase file identity; cannot attribute this failure to a pull request; ${rerunNote}` };
|
|
103
|
+
}
|
|
144
104
|
const pullRequests = input.pullRequests.map((pr) => ({
|
|
145
105
|
number: pr.number,
|
|
146
106
|
verdict: verdict(pr, outcome.file),
|
|
Binary file
|
|
@@ -8,6 +8,14 @@ export declare function inferSelectedCommands(repoPath: string, proposed: readon
|
|
|
8
8
|
commands?: string[];
|
|
9
9
|
reason: string;
|
|
10
10
|
};
|
|
11
|
+
/** The planner's commands for `tests` on their own, rebuilt from the repository (a FULL observation
|
|
12
|
+
* reports none): several already split to fit the shell, or one whole command for the caller to check
|
|
13
|
+
* and split. Undefined when the planner refuses them. */
|
|
14
|
+
export declare function inferPlannedCommands(repoPath: string, tests: readonly string[]): {
|
|
15
|
+
commands: string[];
|
|
16
|
+
} | {
|
|
17
|
+
single: string;
|
|
18
|
+
} | undefined;
|
|
11
19
|
/** Rebuild the complete plan locally; never join arbitrary report commands. */
|
|
12
20
|
export declare function inferWorkspaceComparison(repoPath: string, proposed: readonly string[], selectedTests: readonly string[]): {
|
|
13
21
|
full?: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
1
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
3
|
import { join } from "node:path";
|
|
3
4
|
import { readRepositoryConfig } from "@diffci.com/core/repo/repo-config";
|
|
@@ -25,6 +26,21 @@ export function inferSelectedCommands(repoPath, proposed, selectedTests) {
|
|
|
25
26
|
});
|
|
26
27
|
return { commands, reason: `${plan.commands.length} commands from the verified plan` };
|
|
27
28
|
}
|
|
29
|
+
/** The planner's commands for `tests` on their own, rebuilt from the repository (a FULL observation
|
|
30
|
+
* reports none): several already split to fit the shell, or one whole command for the caller to check
|
|
31
|
+
* and split. Undefined when the planner refuses them. */
|
|
32
|
+
export function inferPlannedCommands(repoPath, tests) {
|
|
33
|
+
const plan = planSelectiveTestCommands(analyzeRepository({ repoPath }), tests);
|
|
34
|
+
if (plan.refusalReason || plan.commands.length === 0)
|
|
35
|
+
return undefined;
|
|
36
|
+
const proposed = plan.commands.map(commandSpecToString);
|
|
37
|
+
if (proposed.length > 1) {
|
|
38
|
+
const commands = inferSelectedCommands(repoPath, proposed, tests).commands;
|
|
39
|
+
return commands ? { commands } : undefined;
|
|
40
|
+
}
|
|
41
|
+
const single = inferSelectedCommand(repoPath, proposed[0], tests).command;
|
|
42
|
+
return single ? { single } : undefined;
|
|
43
|
+
}
|
|
28
44
|
/** Rebuild the complete plan locally; never join arbitrary report commands. */
|
|
29
45
|
export function inferWorkspaceComparison(repoPath, proposed, selectedTests) {
|
|
30
46
|
const profile = analyzeRepository({ repoPath });
|
|
@@ -155,5 +171,20 @@ export function inferFullCommand(repoPath) {
|
|
|
155
171
|
}
|
|
156
172
|
if (existsSync(join(repoPath, "go.mod")))
|
|
157
173
|
return { command: "go test ./...", reason: "root Go module" };
|
|
174
|
+
// Python projects run pytest with the interpreter Core's Python adapter would find (2026-11-06).
|
|
175
|
+
if (["pyproject.toml", "setup.py", "setup.cfg", "pytest.ini", "tox.ini", "conftest.py"].some((file) => existsSync(join(repoPath, file)))) {
|
|
176
|
+
const interpreter = pythonInterpreter(repoPath);
|
|
177
|
+
return interpreter
|
|
178
|
+
? { command: `${interpreter} -m pytest`, reason: "Python project tested with pytest" }
|
|
179
|
+
: { reason: "Python project, but no Python 3 interpreter (python3, python or py -3) is on PATH" };
|
|
180
|
+
}
|
|
158
181
|
return { reason: "no supported full test command could be inferred" };
|
|
159
182
|
}
|
|
183
|
+
function pythonInterpreter(cwd) {
|
|
184
|
+
for (const candidate of [["python3"], ["python"], ["py", "-3"]]) {
|
|
185
|
+
const result = spawnSync(candidate[0], [...candidate.slice(1), "-c", "import sys; print(sys.version_info[0])"], { cwd, encoding: "utf8", timeout: 10_000, windowsHide: true });
|
|
186
|
+
if (result.status === 0 && result.stdout.trim() === "3")
|
|
187
|
+
return candidate.join(" ");
|
|
188
|
+
}
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
@@ -73,6 +73,6 @@ export function formatJobSummary(report, textSummary, delivery) {
|
|
|
73
73
|
}
|
|
74
74
|
if (delivery?.startsWith("not sent"))
|
|
75
75
|
lines.push("", `Delivery: ${delivery}`);
|
|
76
|
-
lines.push("", "<details><summary>Full report</summary>", "", "```", `${textSummary}${delivery ? `\n delivery: ${delivery}` : ""}`, "```", "", "</details>", "", "<sub>Observation only: DiffCI ran, skipped and changed nothing in this
|
|
76
|
+
lines.push("", "<details><summary>Full report</summary>", "", "```", `${textSummary}${delivery ? `\n delivery: ${delivery}` : ""}`, "```", "", "</details>", "", "<sub>Observation only: DiffCI ran, skipped and changed nothing in this job. [DiffCI](https://github.com/DiffCI/core) is open source (MIT) and tells AI coding agents what their change breaks.</sub>", "");
|
|
77
77
|
return lines.join("\n");
|
|
78
78
|
}
|
|
@@ -50,3 +50,7 @@ export declare function makeGitRunner(repoPath: string): GitRunner;
|
|
|
50
50
|
*/
|
|
51
51
|
export declare function isInsideRepository(repoPath: string, candidate: string): boolean;
|
|
52
52
|
export declare function observe(options: ObserveOptions): Promise<ObservationReport>;
|
|
53
|
+
/** Why tests outside the full suite cannot run from the root, when they sit in a project with its own
|
|
54
|
+
* lockfile: the root install does not install it (2026-11-06: LobeHub's apps/desktop, a separate pnpm
|
|
55
|
+
* project, left 8 affected tests unrun with only "outside the default runner configuration" to say why). */
|
|
56
|
+
export declare function separateProjectReason(repoPath: string, tests: readonly string[], hashPath?: (path: string) => string): string | undefined;
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { execFileSync } from "node:child_process";
|
|
23
23
|
import { createHash } from "node:crypto";
|
|
24
|
-
import {
|
|
24
|
+
import { existsSync } from "node:fs";
|
|
25
|
+
import { dirname, join, relative, resolve } from "node:path";
|
|
25
26
|
import { economicsContext, evaluateEconomics } from "./economics.js";
|
|
26
27
|
import { readCiEnvironment, resolveCommitRange, } from "./context.js";
|
|
27
28
|
import { OBSERVATION_SCHEMA, readTypeScriptProgramMetrics, redactPath, } from "./report.js";
|
|
@@ -178,9 +179,12 @@ export async function observe(options) {
|
|
|
178
179
|
if (economics.decision === "BYPASS_FULL")
|
|
179
180
|
return finish("REFUSED", "eligibility", { reason: `ECONOMICS_FULL_BYPASS: ${economics.reason}. No selective command is authorized.` });
|
|
180
181
|
}
|
|
181
|
-
const [{ analyzeGitDelta },
|
|
182
|
+
const [{ analyzeGitDelta }, graphEngine, { ImpactAnalyzer }, { runPathBaseline }, { commandSpecToString, planSelectiveTestCommands }, { repositoryFileReader }] = await Promise.all([
|
|
182
183
|
import("@diffci.com/core/git/git-diff"), import("@diffci.com/core/repo/graph"), import("@diffci.com/core/repo/impact"), import("@diffci.com/core/planner/path-baseline"), import("@diffci.com/core/planner/test-command"), import("@diffci.com/core/repo/file-references"),
|
|
183
184
|
]);
|
|
185
|
+
const { classifyRepositoryProject, buildDependencyGraph, hydrateDependencyGraph } = graphEngine;
|
|
186
|
+
// Engines before 2026-11-06 do not explain their confidence; the report then omits the reasons.
|
|
187
|
+
const explainGraphConfidence = graphEngine.explainGraphConfidence;
|
|
184
188
|
markPhase("engineLoad");
|
|
185
189
|
// The eligibility gate is asked of the graph builder itself (classifyRepositoryProject), not of a
|
|
186
190
|
// separate list of conditions that can drift away from it. Phase 01 F3 is what that drift costs.
|
|
@@ -265,6 +269,7 @@ export async function observe(options) {
|
|
|
265
269
|
...(outsideSuite.length ? {
|
|
266
270
|
testsOutsideFullSuite: outsideSuite.map(hashPath),
|
|
267
271
|
outsideSuiteCommands: outsidePlan?.refusalReason ? [] : (outsidePlan?.commands ?? []).map(commandSpecToString),
|
|
272
|
+
...(outsidePlan?.refusalReason ? { outsideSuiteRefusalReason: separateProjectReason(repoPath, outsideSuite, hashPath) ?? outsidePlan.refusalReason } : {}),
|
|
268
273
|
} : {}),
|
|
269
274
|
fallbackReasons: impact.fallbackReasons,
|
|
270
275
|
...(fallbackDetails ? { fallbackDetails } : {}),
|
|
@@ -283,6 +288,7 @@ export async function observe(options) {
|
|
|
283
288
|
edges: graphResult.graph.edges.length,
|
|
284
289
|
confidence: graphResult.confidence,
|
|
285
290
|
effectiveConfidence: impact.effectiveGraphConfidence,
|
|
291
|
+
...(graphResult.confidence !== "COMPLETE" && explainGraphConfidence ? { confidenceReasons: explainGraphConfidence(graphResult) } : {}),
|
|
286
292
|
durationMs: Math.round(graphResult.performance.durationMs),
|
|
287
293
|
phasesMs: graphResult.performance.phasesMs,
|
|
288
294
|
typescriptProgram: readTypeScriptProgramMetrics(graphResult.performance.typescriptProgram),
|
|
@@ -319,3 +325,26 @@ function safeAuditWorkflows(repoPath) {
|
|
|
319
325
|
return [];
|
|
320
326
|
}
|
|
321
327
|
}
|
|
328
|
+
const LOCKFILES = ["pnpm-lock.yaml", "package-lock.json", "npm-shrinkwrap.json", "yarn.lock", "bun.lock", "bun.lockb"];
|
|
329
|
+
/** Why tests outside the full suite cannot run from the root, when they sit in a project with its own
|
|
330
|
+
* lockfile: the root install does not install it (2026-11-06: LobeHub's apps/desktop, a separate pnpm
|
|
331
|
+
* project, left 8 affected tests unrun with only "outside the default runner configuration" to say why). */
|
|
332
|
+
export function separateProjectReason(repoPath, tests, hashPath = (path) => path) {
|
|
333
|
+
const roots = new Set();
|
|
334
|
+
for (const test of tests) {
|
|
335
|
+
let root;
|
|
336
|
+
for (let dir = dirname(test); dir !== "." && dir !== "/" && dir !== ""; dir = dirname(dir)) {
|
|
337
|
+
if (LOCKFILES.some((name) => existsSync(join(repoPath, dir, name)))) {
|
|
338
|
+
root = dir;
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
if (!root)
|
|
343
|
+
return undefined;
|
|
344
|
+
roots.add(root);
|
|
345
|
+
}
|
|
346
|
+
if (roots.size === 0)
|
|
347
|
+
return undefined;
|
|
348
|
+
const names = [...roots].sort().map(hashPath);
|
|
349
|
+
return `${names.join(", ")} ${names.length === 1 ? "is a separate project with its own lockfile" : "are separate projects with their own lockfiles"}, which the root install does not install; run ${tests.length === 1 ? "that test" : `those ${tests.length} tests`} from there after installing it`;
|
|
350
|
+
}
|