@quikit/quikpilot-runner 9.3.0-rc.15 → 9.3.0-rc.16
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 +2 -0
- package/dist/index.js +404 -133
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -845,7 +845,7 @@ async function describeQuikTrackFailure(res) {
|
|
|
845
845
|
|
|
846
846
|
// src/callback.ts
|
|
847
847
|
async function reportBack(params) {
|
|
848
|
-
const { callbackUrl, runToken, status, branch, warnings, targeting, baselineFindings, vanishedTests, unsuppliedInputs, codegenLoop, unresolved } = params;
|
|
848
|
+
const { callbackUrl, runToken, status, branch, warnings, targeting, baselineFindings, vanishedTests, unsuppliedInputs, changesNoTestDependsOn, codegenLoop, unresolved } = params;
|
|
849
849
|
const body = { status };
|
|
850
850
|
if (branch) body.branch = branch;
|
|
851
851
|
if (warnings && warnings.length > 0) body.warnings = warnings;
|
|
@@ -854,6 +854,7 @@ async function reportBack(params) {
|
|
|
854
854
|
if (baselineFindings) body.baselineFindings = baselineFindings;
|
|
855
855
|
if (vanishedTests) body.vanishedTests = vanishedTests;
|
|
856
856
|
if (unsuppliedInputs && unsuppliedInputs.length > 0) body.unsuppliedInputs = unsuppliedInputs;
|
|
857
|
+
if (changesNoTestDependsOn && changesNoTestDependsOn.hunks.length > 0) body.changesNoTestDependsOn = changesNoTestDependsOn;
|
|
857
858
|
if (codegenLoop) body.codegenLoop = codegenLoop;
|
|
858
859
|
const res = await fetch(callbackUrl, {
|
|
859
860
|
method: "POST",
|
|
@@ -1579,8 +1580,8 @@ var TS_SIBLINGS = { ".js": [".ts", ".tsx"], ".jsx": [".tsx"], ".mjs": [".mts"],
|
|
|
1579
1580
|
function resolveImport(fromPath, specifier, listing) {
|
|
1580
1581
|
if (/^(?:@\/|~\/|#|\$|\/)/.test(specifier)) return { kind: "unresolved", reason: "alias" };
|
|
1581
1582
|
const clean = specifier.replace(/[?#].*$/, "");
|
|
1582
|
-
const
|
|
1583
|
-
if (!
|
|
1583
|
+
const relative10 = clean === "." || clean === ".." || clean.startsWith("./") || clean.startsWith("../");
|
|
1584
|
+
if (!relative10) return { kind: "external" };
|
|
1584
1585
|
const base = import_node_path.posix.normalize(import_node_path.posix.join(import_node_path.posix.dirname(fromPath), clean));
|
|
1585
1586
|
if (base === ".." || base.startsWith("../") || import_node_path.posix.isAbsolute(base)) return { kind: "unresolved", reason: "not found" };
|
|
1586
1587
|
const ext = import_node_path.posix.extname(base);
|
|
@@ -13923,6 +13924,313 @@ async function runVerifyAndFix(p) {
|
|
|
13923
13924
|
}
|
|
13924
13925
|
}
|
|
13925
13926
|
|
|
13927
|
+
// src/hunkCheck.ts
|
|
13928
|
+
var import_node_child_process5 = require("node:child_process");
|
|
13929
|
+
var import_node_fs12 = require("node:fs");
|
|
13930
|
+
var import_node_path10 = require("node:path");
|
|
13931
|
+
|
|
13932
|
+
// src/lineDiff.ts
|
|
13933
|
+
var DEFAULT_MAX_LINES = 4e3;
|
|
13934
|
+
var DEFAULT_MAX_CELLS = 4e6;
|
|
13935
|
+
function diffHunks(oldLf, newLf, limits = {}) {
|
|
13936
|
+
const maxLines = limits.maxLines ?? DEFAULT_MAX_LINES;
|
|
13937
|
+
const maxCells = limits.maxCells ?? DEFAULT_MAX_CELLS;
|
|
13938
|
+
const a = oldLf.split("\n");
|
|
13939
|
+
const b = newLf.split("\n");
|
|
13940
|
+
if (a.length > maxLines || b.length > maxLines) return null;
|
|
13941
|
+
let prefix = 0;
|
|
13942
|
+
while (prefix < a.length && prefix < b.length && a[prefix] === b[prefix]) prefix++;
|
|
13943
|
+
let suffix = 0;
|
|
13944
|
+
while (suffix < a.length - prefix && suffix < b.length - prefix && a[a.length - 1 - suffix] === b[b.length - 1 - suffix]) suffix++;
|
|
13945
|
+
const am = a.slice(prefix, a.length - suffix);
|
|
13946
|
+
const bm = b.slice(prefix, b.length - suffix);
|
|
13947
|
+
if (am.length === 0 && bm.length === 0) return [];
|
|
13948
|
+
if ((am.length + 1) * (bm.length + 1) > maxCells) return null;
|
|
13949
|
+
const n = am.length;
|
|
13950
|
+
const m = bm.length;
|
|
13951
|
+
const width = m + 1;
|
|
13952
|
+
const table = new Uint32Array((n + 1) * width);
|
|
13953
|
+
for (let i3 = n - 1; i3 >= 0; i3--) {
|
|
13954
|
+
for (let j2 = m - 1; j2 >= 0; j2--) {
|
|
13955
|
+
table[i3 * width + j2] = am[i3] === bm[j2] ? table[(i3 + 1) * width + j2 + 1] + 1 : Math.max(table[(i3 + 1) * width + j2], table[i3 * width + j2 + 1]);
|
|
13956
|
+
}
|
|
13957
|
+
}
|
|
13958
|
+
const raw = [];
|
|
13959
|
+
let i2 = 0;
|
|
13960
|
+
let j = 0;
|
|
13961
|
+
let open = null;
|
|
13962
|
+
const close = () => {
|
|
13963
|
+
if (!open) return;
|
|
13964
|
+
raw.push({ oldStart: prefix + open.oi + 1, oldLen: i2 - open.oi, newStart: prefix + open.nj + 1, newLen: j - open.nj });
|
|
13965
|
+
open = null;
|
|
13966
|
+
};
|
|
13967
|
+
while (i2 < n && j < m) {
|
|
13968
|
+
if (am[i2] === bm[j]) {
|
|
13969
|
+
close();
|
|
13970
|
+
i2++;
|
|
13971
|
+
j++;
|
|
13972
|
+
} else {
|
|
13973
|
+
open ??= { oi: i2, nj: j };
|
|
13974
|
+
if (table[(i2 + 1) * width + j] >= table[i2 * width + j + 1]) i2++;
|
|
13975
|
+
else j++;
|
|
13976
|
+
}
|
|
13977
|
+
}
|
|
13978
|
+
if (i2 < n || j < m) {
|
|
13979
|
+
open ??= { oi: i2, nj: j };
|
|
13980
|
+
i2 = n;
|
|
13981
|
+
j = m;
|
|
13982
|
+
}
|
|
13983
|
+
close();
|
|
13984
|
+
const merged = [];
|
|
13985
|
+
for (const h of raw) {
|
|
13986
|
+
const last = merged[merged.length - 1];
|
|
13987
|
+
if (last && h.oldStart - (last.oldStart + last.oldLen) <= 1) {
|
|
13988
|
+
last.oldLen = h.oldStart + h.oldLen - last.oldStart;
|
|
13989
|
+
last.newLen = h.newStart + h.newLen - last.newStart;
|
|
13990
|
+
} else {
|
|
13991
|
+
merged.push({ ...h });
|
|
13992
|
+
}
|
|
13993
|
+
}
|
|
13994
|
+
return merged;
|
|
13995
|
+
}
|
|
13996
|
+
function revertHunk(oldLf, newLf, hunk) {
|
|
13997
|
+
const a = oldLf.split("\n");
|
|
13998
|
+
const b = newLf.split("\n");
|
|
13999
|
+
b.splice(hunk.newStart - 1, hunk.newLen, ...a.slice(hunk.oldStart - 1, hunk.oldStart - 1 + hunk.oldLen));
|
|
14000
|
+
return b.join("\n");
|
|
14001
|
+
}
|
|
14002
|
+
function lineCount(lf) {
|
|
14003
|
+
if (lf === "") return 0;
|
|
14004
|
+
const n = lf.split("\n").length;
|
|
14005
|
+
return lf.endsWith("\n") ? n - 1 : n;
|
|
14006
|
+
}
|
|
14007
|
+
function hunkLines(hunk, totalLines) {
|
|
14008
|
+
const last = Math.max(1, totalLines);
|
|
14009
|
+
const startLine = Math.min(last, Math.max(1, hunk.newStart));
|
|
14010
|
+
const endLine = hunk.newLen > 0 ? Math.min(last, Math.max(startLine, hunk.newStart + hunk.newLen - 1)) : startLine;
|
|
14011
|
+
return { startLine, endLine };
|
|
14012
|
+
}
|
|
14013
|
+
function isWhitespaceOnly(oldLf, newLf, hunk) {
|
|
14014
|
+
const strip = (lines) => lines.join("").replace(/\s+/g, "");
|
|
14015
|
+
const before = strip(oldLf.split("\n").slice(hunk.oldStart - 1, hunk.oldStart - 1 + hunk.oldLen));
|
|
14016
|
+
const after = strip(newLf.split("\n").slice(hunk.newStart - 1, hunk.newStart - 1 + hunk.newLen));
|
|
14017
|
+
return before === after;
|
|
14018
|
+
}
|
|
14019
|
+
|
|
14020
|
+
// src/scopeCheck.ts
|
|
14021
|
+
var import_node_fs11 = require("node:fs");
|
|
14022
|
+
var ROUTE_METHOD_RE = /\b(GET|POST|PUT|PATCH|DELETE)\b/i;
|
|
14023
|
+
var ROUTE_PATH_RE = /\/[A-Za-z0-9_\-{}[\]]+(?:\/[A-Za-z0-9_\-:{}[\]]+)+/;
|
|
14024
|
+
var ROUTE_EXPORT_RE = /\bexport\s+(?:async\s+)?function\s+(GET|POST|PUT|PATCH|DELETE)\s*\(/;
|
|
14025
|
+
var NO_PATH = "(this file's route)";
|
|
14026
|
+
function detectMentions(text) {
|
|
14027
|
+
const found = [];
|
|
14028
|
+
for (const line of text.split("\n")) {
|
|
14029
|
+
const methodMatch = ROUTE_METHOD_RE.exec(line);
|
|
14030
|
+
const pathMatch = ROUTE_PATH_RE.exec(line);
|
|
14031
|
+
if (methodMatch && pathMatch) {
|
|
14032
|
+
found.push({ method: methodMatch[1].toUpperCase(), path: pathMatch[0] });
|
|
14033
|
+
}
|
|
14034
|
+
const exportMatch = ROUTE_EXPORT_RE.exec(line);
|
|
14035
|
+
if (exportMatch) {
|
|
14036
|
+
found.push({ method: exportMatch[1].toUpperCase(), path: NO_PATH });
|
|
14037
|
+
}
|
|
14038
|
+
}
|
|
14039
|
+
return found;
|
|
14040
|
+
}
|
|
14041
|
+
function normalizePath(path) {
|
|
14042
|
+
return path.replace(/:[A-Za-z0-9_]+|\{[^}]+\}|\[[^\]]+\]/g, "*");
|
|
14043
|
+
}
|
|
14044
|
+
function surfaceCovers(surface, mention) {
|
|
14045
|
+
if (!new RegExp(`\\b${mention.method}\\b`, "i").test(surface)) return false;
|
|
14046
|
+
if (mention.path === NO_PATH) return true;
|
|
14047
|
+
const declaredPath = normalizePath(surface);
|
|
14048
|
+
const mentionPath = normalizePath(mention.path);
|
|
14049
|
+
return declaredPath.includes(mentionPath) || mentionPath.includes(declaredPath);
|
|
14050
|
+
}
|
|
14051
|
+
function addedLines(before, after) {
|
|
14052
|
+
const beforeLines = new Set(before.split("\n"));
|
|
14053
|
+
return after.split("\n").filter((line) => !beforeLines.has(line)).join("\n");
|
|
14054
|
+
}
|
|
14055
|
+
var TEST_FILE_RES = [
|
|
14056
|
+
/(^|\/)(__tests__|__mocks__|tests?|specs?)\//i,
|
|
14057
|
+
/\.(test|spec)\.[^/.]+$/i,
|
|
14058
|
+
/(^|\/)test_[^/]+\.py$/i,
|
|
14059
|
+
/_test\.(py|go)$/i,
|
|
14060
|
+
/Tests?\.(java|kt|cs)$/
|
|
14061
|
+
];
|
|
14062
|
+
function isTestFile(path) {
|
|
14063
|
+
return TEST_FILE_RES.some((re) => re.test(path));
|
|
14064
|
+
}
|
|
14065
|
+
function checkApiScope(results, targets, apiChanges) {
|
|
14066
|
+
const targetsByPath = new Map(targets.map((t) => [t.path, t]));
|
|
14067
|
+
const violations = [];
|
|
14068
|
+
for (const { targetPath, newContent } of results) {
|
|
14069
|
+
if (isTestFile(targetPath)) continue;
|
|
14070
|
+
const target = targetsByPath.get(targetPath);
|
|
14071
|
+
const isNewFile = target?.kind === "NEW_FILE";
|
|
14072
|
+
let scanned;
|
|
14073
|
+
if (isNewFile) {
|
|
14074
|
+
scanned = newContent;
|
|
14075
|
+
} else {
|
|
14076
|
+
let currentContent;
|
|
14077
|
+
try {
|
|
14078
|
+
currentContent = (0, import_node_fs11.readFileSync)(targetPath, "utf8");
|
|
14079
|
+
} catch {
|
|
14080
|
+
currentContent = "";
|
|
14081
|
+
}
|
|
14082
|
+
scanned = addedLines(currentContent, newContent);
|
|
14083
|
+
}
|
|
14084
|
+
for (const mention of detectMentions(scanned)) {
|
|
14085
|
+
if (!apiChanges.some((c) => surfaceCovers(c.surface, mention))) {
|
|
14086
|
+
violations.push({ file: targetPath, method: mention.method, path: mention.path });
|
|
14087
|
+
}
|
|
14088
|
+
}
|
|
14089
|
+
}
|
|
14090
|
+
return { blocked: violations.length > 0, violations };
|
|
14091
|
+
}
|
|
14092
|
+
function describeScopeViolations(check) {
|
|
14093
|
+
return check.violations.map((v) => `${v.file} adds ${v.method} ${v.path}, not declared in the design's API changes`).join("; ");
|
|
14094
|
+
}
|
|
14095
|
+
|
|
14096
|
+
// src/hunkCheck.ts
|
|
14097
|
+
var MAX_REPORTED_HUNKS = 20;
|
|
14098
|
+
function toFinding(r) {
|
|
14099
|
+
if (r.unnecessary.length === 0) return void 0;
|
|
14100
|
+
return { hunks: r.unnecessary.slice(0, MAX_REPORTED_HUNKS), total: r.unnecessary.length, checked: r.checked };
|
|
14101
|
+
}
|
|
14102
|
+
var DEFAULT_MAX_HUNKS = 8;
|
|
14103
|
+
var MAX_FILE_BYTES = 1e6;
|
|
14104
|
+
var FRESH_SLACK_MS2 = 2e3;
|
|
14105
|
+
var SAFETY_MS = 6e4;
|
|
14106
|
+
var CODE_EXTENSIONS = /\.(?:[cm]?[jt]sx?|py|go|java|rb|rs|cs|php|kt)$/i;
|
|
14107
|
+
function eligibleForHunkCheck(path) {
|
|
14108
|
+
return CODE_EXTENSIONS.test(path) && !isTestFile(path);
|
|
14109
|
+
}
|
|
14110
|
+
function collectHunkCheckFiles(results, root, readHead = readCommittedText) {
|
|
14111
|
+
const files = [];
|
|
14112
|
+
for (const r of results) {
|
|
14113
|
+
if (safeRelativePath(r.targetPath) === null || !eligibleForHunkCheck(r.targetPath)) continue;
|
|
14114
|
+
const raw = readHead(root, r.targetPath);
|
|
14115
|
+
if (raw === null) continue;
|
|
14116
|
+
files.push({ path: r.targetPath, originalLf: toLf(raw.charCodeAt(0) === 65279 ? raw.slice(1) : raw) });
|
|
14117
|
+
}
|
|
14118
|
+
return files;
|
|
14119
|
+
}
|
|
14120
|
+
function readCommittedText(root, path) {
|
|
14121
|
+
try {
|
|
14122
|
+
return (0, import_node_child_process5.execFileSync)("git", ["show", `HEAD:${path}`], { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], maxBuffer: 8 * 1024 * 1024 });
|
|
14123
|
+
} catch {
|
|
14124
|
+
return null;
|
|
14125
|
+
}
|
|
14126
|
+
}
|
|
14127
|
+
async function runHunkCheck(input) {
|
|
14128
|
+
const now = input.now ?? Date.now;
|
|
14129
|
+
const log = input.log ?? (() => {
|
|
14130
|
+
});
|
|
14131
|
+
const result = { unnecessary: [], checked: 0, total: 0, skipped: { whitespace: 0, tooBig: 0, cap: 0, time: 0, unknown: 0, files: 0 } };
|
|
14132
|
+
if (!input.baseline.results || input.baseline.results.size === 0) return { ...result, stopped: "no_baseline" };
|
|
14133
|
+
const limit = testTimeLimitMs(input.baselineMs);
|
|
14134
|
+
if (limit === "too_slow") return { ...result, stopped: "too_slow" };
|
|
14135
|
+
const perRunMs = input.baselineMs === null ? limit : Math.min(limit, Math.max(3e4, 2 * input.baselineMs));
|
|
14136
|
+
const fs = createNodeWriteFs(input.root);
|
|
14137
|
+
const candidates = [];
|
|
14138
|
+
for (const f of input.files) {
|
|
14139
|
+
const loaded = loadTextForEdit(fs, f.path, MAX_FILE_BYTES);
|
|
14140
|
+
if (!loaded.ok) {
|
|
14141
|
+
result.skipped.files += 1;
|
|
14142
|
+
continue;
|
|
14143
|
+
}
|
|
14144
|
+
const hunks = diffHunks(f.originalLf, loaded.lf, input.maxLines !== void 0 ? { maxLines: input.maxLines } : {});
|
|
14145
|
+
if (hunks === null) {
|
|
14146
|
+
result.skipped.tooBig += 1;
|
|
14147
|
+
continue;
|
|
14148
|
+
}
|
|
14149
|
+
const totalLines = lineCount(loaded.lf);
|
|
14150
|
+
for (const hunk of hunks) {
|
|
14151
|
+
if (isWhitespaceOnly(f.originalLf, loaded.lf, hunk)) {
|
|
14152
|
+
result.skipped.whitespace += 1;
|
|
14153
|
+
continue;
|
|
14154
|
+
}
|
|
14155
|
+
candidates.push({ file: f.path, ending: loaded.ending, bom: loaded.bom, originalLf: f.originalLf, currentLf: loaded.lf, hunk, totalLines });
|
|
14156
|
+
}
|
|
14157
|
+
}
|
|
14158
|
+
result.total = candidates.length;
|
|
14159
|
+
const findReport = input.findReport ?? findJUnitReport;
|
|
14160
|
+
const readSnapshot = input.readSnapshot ?? readTestSnapshot;
|
|
14161
|
+
const runCommand2 = input.runCommand ?? runTestCommandWithLimit;
|
|
14162
|
+
let slowestRunMs = input.baselineMs ?? 3e4;
|
|
14163
|
+
const runOnce = async (c) => {
|
|
14164
|
+
const reportBefore = findReport(input.root);
|
|
14165
|
+
const preserve = reportBefore ? [(0, import_node_path10.relative)(input.root, reportBefore).split("\\").join("/")] : [];
|
|
14166
|
+
const content = `${c.bom ? "\uFEFF" : ""}${fromLf(revertHunk(c.originalLf, c.currentLf, c.hunk), c.ending)}`;
|
|
14167
|
+
const startedWall = Date.now();
|
|
14168
|
+
const startedAt = now();
|
|
14169
|
+
try {
|
|
14170
|
+
const verdict = await withOverlayOnDisk(
|
|
14171
|
+
input.root,
|
|
14172
|
+
[{ path: c.file, content }],
|
|
14173
|
+
async () => {
|
|
14174
|
+
if (reportBefore) (0, import_node_fs12.rmSync)(reportBefore, { force: true });
|
|
14175
|
+
const run2 = await runCommand2(input.command, perRunMs, input.root);
|
|
14176
|
+
if (!run2.started || run2.timedOut) return "unknown";
|
|
14177
|
+
const report = findReport(input.root);
|
|
14178
|
+
if (!report) return "unknown";
|
|
14179
|
+
try {
|
|
14180
|
+
if ((0, import_node_fs12.statSync)(report).mtimeMs < startedWall - FRESH_SLACK_MS2) return "unknown";
|
|
14181
|
+
} catch {
|
|
14182
|
+
return "unknown";
|
|
14183
|
+
}
|
|
14184
|
+
const after = readSnapshot(run2.outcome, input.root);
|
|
14185
|
+
if (!after.results || after.results.size === 0) return "unknown";
|
|
14186
|
+
if (after.results.size < input.finalTestCount) return "needed";
|
|
14187
|
+
return checkForRegressions(input.baseline, after).blocked ? "needed" : "unneeded";
|
|
14188
|
+
},
|
|
14189
|
+
{ ...input.tree, preserve }
|
|
14190
|
+
);
|
|
14191
|
+
slowestRunMs = Math.max(slowestRunMs, now() - startedAt);
|
|
14192
|
+
return verdict;
|
|
14193
|
+
} catch (err) {
|
|
14194
|
+
if (err instanceof DiskWriteRefused) return "unknown";
|
|
14195
|
+
throw err;
|
|
14196
|
+
}
|
|
14197
|
+
};
|
|
14198
|
+
const queue = candidates.slice(0, input.maxHunks ?? DEFAULT_MAX_HUNKS);
|
|
14199
|
+
result.skipped.cap = candidates.length - queue.length;
|
|
14200
|
+
let handled = 0;
|
|
14201
|
+
try {
|
|
14202
|
+
for (const c of queue) {
|
|
14203
|
+
if (now() + slowestRunMs + SAFETY_MS > input.deadlineAtMs) {
|
|
14204
|
+
result.stopped = "out_of_time";
|
|
14205
|
+
break;
|
|
14206
|
+
}
|
|
14207
|
+
handled += 1;
|
|
14208
|
+
result.checked += 1;
|
|
14209
|
+
let verdict = await runOnce(c);
|
|
14210
|
+
if (verdict === "unneeded") verdict = await runOnce(c);
|
|
14211
|
+
log({ event: "hunk_check.block", verdict });
|
|
14212
|
+
if (verdict === "unknown") result.skipped.unknown += 1;
|
|
14213
|
+
else if (verdict === "unneeded") {
|
|
14214
|
+
const { startLine, endLine } = hunkLines(c.hunk, c.totalLines);
|
|
14215
|
+
result.unnecessary.push({ file: c.file, startLine, endLine });
|
|
14216
|
+
}
|
|
14217
|
+
}
|
|
14218
|
+
} catch (err) {
|
|
14219
|
+
if (err instanceof TreeUnverifiableError) {
|
|
14220
|
+
result.checked -= 1;
|
|
14221
|
+
return { ...result, stopped: "tree_unverifiable" };
|
|
14222
|
+
}
|
|
14223
|
+
throw err;
|
|
14224
|
+
}
|
|
14225
|
+
result.skipped.time = queue.length - handled;
|
|
14226
|
+
result.unnecessary.sort((a, b) => a.file.localeCompare(b.file) || a.startLine - b.startLine);
|
|
14227
|
+
return result;
|
|
14228
|
+
}
|
|
14229
|
+
function describeHunkCheck(r) {
|
|
14230
|
+
const n = r.unnecessary.length;
|
|
14231
|
+
return `${n} ${n === 1 ? "change" : "changes"} QuikPilot made ${n === 1 ? "has" : "have"} no test that depends on ${n === 1 ? "it" : "them"} (checked ${r.checked} of ${r.total}). See "What QuikPilot noticed".`;
|
|
14232
|
+
}
|
|
14233
|
+
|
|
13926
14234
|
// src/healRecord.ts
|
|
13927
14235
|
var ZERO = {
|
|
13928
14236
|
turns: 0,
|
|
@@ -13980,9 +14288,9 @@ function healFailureSuffix(heal) {
|
|
|
13980
14288
|
}
|
|
13981
14289
|
|
|
13982
14290
|
// src/baselineCheck.ts
|
|
13983
|
-
var
|
|
13984
|
-
var
|
|
13985
|
-
var
|
|
14291
|
+
var import_node_child_process6 = require("node:child_process");
|
|
14292
|
+
var import_node_fs13 = require("node:fs");
|
|
14293
|
+
var import_node_path11 = require("node:path");
|
|
13986
14294
|
var BASELINE_CHECK_TIMEOUT_MS = 12e4;
|
|
13987
14295
|
function shellQuote(value) {
|
|
13988
14296
|
return `'${value.split("'").join("'\\''")}'`;
|
|
@@ -14001,32 +14309,32 @@ function checkableIds(ids, types2) {
|
|
|
14001
14309
|
});
|
|
14002
14310
|
}
|
|
14003
14311
|
function insideCheckout(cwd, path) {
|
|
14004
|
-
const abs = (0,
|
|
14005
|
-
const rel = (0,
|
|
14006
|
-
return rel === "" || rel.startsWith("..") || (0,
|
|
14312
|
+
const abs = (0, import_node_path11.resolve)(cwd, path);
|
|
14313
|
+
const rel = (0, import_node_path11.relative)(cwd, abs);
|
|
14314
|
+
return rel === "" || rel.startsWith("..") || (0, import_node_path11.isAbsolute)(rel) ? null : abs;
|
|
14007
14315
|
}
|
|
14008
14316
|
function writeForCheck(abs, content) {
|
|
14009
|
-
const original = (0,
|
|
14317
|
+
const original = (0, import_node_fs13.existsSync)(abs) ? (0, import_node_fs13.readFileSync)(abs) : null;
|
|
14010
14318
|
const createdDirs = [];
|
|
14011
14319
|
if (original === null) {
|
|
14012
14320
|
const missing = [];
|
|
14013
|
-
for (let d = (0,
|
|
14321
|
+
for (let d = (0, import_node_path11.dirname)(abs); !(0, import_node_fs13.existsSync)(d); d = (0, import_node_path11.dirname)(d)) missing.push(d);
|
|
14014
14322
|
for (const d of missing.reverse()) {
|
|
14015
|
-
(0,
|
|
14323
|
+
(0, import_node_fs13.mkdirSync)(d);
|
|
14016
14324
|
createdDirs.push(d);
|
|
14017
14325
|
}
|
|
14018
14326
|
}
|
|
14019
|
-
(0,
|
|
14327
|
+
(0, import_node_fs13.writeFileSync)(abs, content);
|
|
14020
14328
|
return { abs, original, createdDirs };
|
|
14021
14329
|
}
|
|
14022
14330
|
function restore(written) {
|
|
14023
14331
|
for (const file of [...written].reverse()) {
|
|
14024
14332
|
try {
|
|
14025
|
-
if (file.original !== null) (0,
|
|
14026
|
-
else (0,
|
|
14333
|
+
if (file.original !== null) (0, import_node_fs13.writeFileSync)(file.abs, file.original);
|
|
14334
|
+
else (0, import_node_fs13.rmSync)(file.abs, { force: true });
|
|
14027
14335
|
for (const d of [...file.createdDirs].reverse()) {
|
|
14028
14336
|
try {
|
|
14029
|
-
(0,
|
|
14337
|
+
(0, import_node_fs13.rmdirSync)(d);
|
|
14030
14338
|
} catch {
|
|
14031
14339
|
}
|
|
14032
14340
|
}
|
|
@@ -14037,7 +14345,7 @@ function restore(written) {
|
|
|
14037
14345
|
}
|
|
14038
14346
|
function untrackedFiles(cwd) {
|
|
14039
14347
|
try {
|
|
14040
|
-
const out = (0,
|
|
14348
|
+
const out = (0, import_node_child_process6.execFileSync)("git", ["ls-files", "--others", "--exclude-standard", "-z"], {
|
|
14041
14349
|
cwd,
|
|
14042
14350
|
encoding: "utf8",
|
|
14043
14351
|
stdio: ["ignore", "pipe", "ignore"],
|
|
@@ -14050,7 +14358,7 @@ function untrackedFiles(cwd) {
|
|
|
14050
14358
|
}
|
|
14051
14359
|
var mtimeOf = (path) => {
|
|
14052
14360
|
try {
|
|
14053
|
-
return (0,
|
|
14361
|
+
return (0, import_node_fs13.statSync)(path).mtimeMs;
|
|
14054
14362
|
} catch {
|
|
14055
14363
|
return null;
|
|
14056
14364
|
}
|
|
@@ -14064,7 +14372,7 @@ function decideCause(targets, results, cwd) {
|
|
|
14064
14372
|
const abs = insideCheckout(cwd, t.path);
|
|
14065
14373
|
if (next === void 0 || abs === null) return "ALREADY_TRUE";
|
|
14066
14374
|
try {
|
|
14067
|
-
if ((0,
|
|
14375
|
+
if ((0, import_node_fs13.readFileSync)(abs, "utf8") !== next) return "ALREADY_TRUE";
|
|
14068
14376
|
} catch {
|
|
14069
14377
|
return "ALREADY_TRUE";
|
|
14070
14378
|
}
|
|
@@ -14140,7 +14448,7 @@ async function runBaselineCheck(params) {
|
|
|
14140
14448
|
for (const file of untrackedAfter) {
|
|
14141
14449
|
if (untrackedBefore.has(file)) continue;
|
|
14142
14450
|
const abs = insideCheckout(cwd, file);
|
|
14143
|
-
if (abs) (0,
|
|
14451
|
+
if (abs) (0, import_node_fs13.rmSync)(abs, { force: true });
|
|
14144
14452
|
}
|
|
14145
14453
|
}
|
|
14146
14454
|
}
|
|
@@ -14161,8 +14469,8 @@ async function runBaselineCheck(params) {
|
|
|
14161
14469
|
}
|
|
14162
14470
|
|
|
14163
14471
|
// src/dependencyCheck.ts
|
|
14164
|
-
var
|
|
14165
|
-
var
|
|
14472
|
+
var import_node_fs14 = require("node:fs");
|
|
14473
|
+
var import_node_path12 = require("node:path");
|
|
14166
14474
|
var SCANNABLE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"];
|
|
14167
14475
|
var IMPORT_RE = /(?:\bimport\b[^'"]*?\bfrom\s*|\bimport\s*\(\s*|\bexport\b[^'"]*?\bfrom\s*|\brequire\s*\(\s*|\bimport\s+)(['"])([^'"]+)\1/g;
|
|
14168
14476
|
var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
@@ -14241,14 +14549,14 @@ function dependencyNames(pkg) {
|
|
|
14241
14549
|
]);
|
|
14242
14550
|
}
|
|
14243
14551
|
function readDeclaredDependencies(results, workspaceRoot) {
|
|
14244
|
-
const packageJsonPath = (0,
|
|
14245
|
-
const generated = results.find((r) => (0,
|
|
14552
|
+
const packageJsonPath = (0, import_node_path12.join)((0, import_node_path12.resolve)(workspaceRoot ?? "."), "package.json");
|
|
14553
|
+
const generated = results.find((r) => (0, import_node_path12.resolve)(r.targetPath) === packageJsonPath);
|
|
14246
14554
|
let raw;
|
|
14247
14555
|
if (generated) {
|
|
14248
14556
|
raw = generated.newContent;
|
|
14249
14557
|
} else {
|
|
14250
14558
|
try {
|
|
14251
|
-
raw = (0,
|
|
14559
|
+
raw = (0, import_node_fs14.readFileSync)(packageJsonPath, "utf8");
|
|
14252
14560
|
} catch {
|
|
14253
14561
|
raw = null;
|
|
14254
14562
|
}
|
|
@@ -14312,16 +14620,16 @@ function stripJsonComments(text) {
|
|
|
14312
14620
|
return out.replace(/,(\s*[}\]])/g, "$1");
|
|
14313
14621
|
}
|
|
14314
14622
|
function resolveAliasPrefixes(results, workspaceRoot) {
|
|
14315
|
-
const root = (0,
|
|
14623
|
+
const root = (0, import_node_path12.resolve)(workspaceRoot ?? ".");
|
|
14316
14624
|
for (const filename of ["tsconfig.json", "jsconfig.json"]) {
|
|
14317
|
-
const configPath = (0,
|
|
14318
|
-
const generated = results.find((r) => (0,
|
|
14625
|
+
const configPath = (0, import_node_path12.join)(root, filename);
|
|
14626
|
+
const generated = results.find((r) => (0, import_node_path12.resolve)(r.targetPath) === configPath);
|
|
14319
14627
|
let raw;
|
|
14320
14628
|
if (generated) {
|
|
14321
14629
|
raw = generated.newContent;
|
|
14322
14630
|
} else {
|
|
14323
14631
|
try {
|
|
14324
|
-
raw = (0,
|
|
14632
|
+
raw = (0, import_node_fs14.readFileSync)(configPath, "utf8");
|
|
14325
14633
|
} catch {
|
|
14326
14634
|
raw = null;
|
|
14327
14635
|
}
|
|
@@ -14342,82 +14650,6 @@ function describeDependencyViolations(check) {
|
|
|
14342
14650
|
return check.violations.map((v) => `${v.file} imports ${v.packages.join(", ")}, not a dependency of this repository`).join("; ");
|
|
14343
14651
|
}
|
|
14344
14652
|
|
|
14345
|
-
// src/scopeCheck.ts
|
|
14346
|
-
var import_node_fs13 = require("node:fs");
|
|
14347
|
-
var ROUTE_METHOD_RE = /\b(GET|POST|PUT|PATCH|DELETE)\b/i;
|
|
14348
|
-
var ROUTE_PATH_RE = /\/[A-Za-z0-9_\-{}[\]]+(?:\/[A-Za-z0-9_\-:{}[\]]+)+/;
|
|
14349
|
-
var ROUTE_EXPORT_RE = /\bexport\s+(?:async\s+)?function\s+(GET|POST|PUT|PATCH|DELETE)\s*\(/;
|
|
14350
|
-
var NO_PATH = "(this file's route)";
|
|
14351
|
-
function detectMentions(text) {
|
|
14352
|
-
const found = [];
|
|
14353
|
-
for (const line of text.split("\n")) {
|
|
14354
|
-
const methodMatch = ROUTE_METHOD_RE.exec(line);
|
|
14355
|
-
const pathMatch = ROUTE_PATH_RE.exec(line);
|
|
14356
|
-
if (methodMatch && pathMatch) {
|
|
14357
|
-
found.push({ method: methodMatch[1].toUpperCase(), path: pathMatch[0] });
|
|
14358
|
-
}
|
|
14359
|
-
const exportMatch = ROUTE_EXPORT_RE.exec(line);
|
|
14360
|
-
if (exportMatch) {
|
|
14361
|
-
found.push({ method: exportMatch[1].toUpperCase(), path: NO_PATH });
|
|
14362
|
-
}
|
|
14363
|
-
}
|
|
14364
|
-
return found;
|
|
14365
|
-
}
|
|
14366
|
-
function normalizePath(path) {
|
|
14367
|
-
return path.replace(/:[A-Za-z0-9_]+|\{[^}]+\}|\[[^\]]+\]/g, "*");
|
|
14368
|
-
}
|
|
14369
|
-
function surfaceCovers(surface, mention) {
|
|
14370
|
-
if (!new RegExp(`\\b${mention.method}\\b`, "i").test(surface)) return false;
|
|
14371
|
-
if (mention.path === NO_PATH) return true;
|
|
14372
|
-
const declaredPath = normalizePath(surface);
|
|
14373
|
-
const mentionPath = normalizePath(mention.path);
|
|
14374
|
-
return declaredPath.includes(mentionPath) || mentionPath.includes(declaredPath);
|
|
14375
|
-
}
|
|
14376
|
-
function addedLines(before, after) {
|
|
14377
|
-
const beforeLines = new Set(before.split("\n"));
|
|
14378
|
-
return after.split("\n").filter((line) => !beforeLines.has(line)).join("\n");
|
|
14379
|
-
}
|
|
14380
|
-
var TEST_FILE_RES = [
|
|
14381
|
-
/(^|\/)(__tests__|__mocks__|tests?|specs?)\//i,
|
|
14382
|
-
/\.(test|spec)\.[^/.]+$/i,
|
|
14383
|
-
/(^|\/)test_[^/]+\.py$/i,
|
|
14384
|
-
/_test\.(py|go)$/i,
|
|
14385
|
-
/Tests?\.(java|kt|cs)$/
|
|
14386
|
-
];
|
|
14387
|
-
function isTestFile(path) {
|
|
14388
|
-
return TEST_FILE_RES.some((re) => re.test(path));
|
|
14389
|
-
}
|
|
14390
|
-
function checkApiScope(results, targets, apiChanges) {
|
|
14391
|
-
const targetsByPath = new Map(targets.map((t) => [t.path, t]));
|
|
14392
|
-
const violations = [];
|
|
14393
|
-
for (const { targetPath, newContent } of results) {
|
|
14394
|
-
if (isTestFile(targetPath)) continue;
|
|
14395
|
-
const target = targetsByPath.get(targetPath);
|
|
14396
|
-
const isNewFile = target?.kind === "NEW_FILE";
|
|
14397
|
-
let scanned;
|
|
14398
|
-
if (isNewFile) {
|
|
14399
|
-
scanned = newContent;
|
|
14400
|
-
} else {
|
|
14401
|
-
let currentContent;
|
|
14402
|
-
try {
|
|
14403
|
-
currentContent = (0, import_node_fs13.readFileSync)(targetPath, "utf8");
|
|
14404
|
-
} catch {
|
|
14405
|
-
currentContent = "";
|
|
14406
|
-
}
|
|
14407
|
-
scanned = addedLines(currentContent, newContent);
|
|
14408
|
-
}
|
|
14409
|
-
for (const mention of detectMentions(scanned)) {
|
|
14410
|
-
if (!apiChanges.some((c) => surfaceCovers(c.surface, mention))) {
|
|
14411
|
-
violations.push({ file: targetPath, method: mention.method, path: mention.path });
|
|
14412
|
-
}
|
|
14413
|
-
}
|
|
14414
|
-
}
|
|
14415
|
-
return { blocked: violations.length > 0, violations };
|
|
14416
|
-
}
|
|
14417
|
-
function describeScopeViolations(check) {
|
|
14418
|
-
return check.violations.map((v) => `${v.file} adds ${v.method} ${v.path}, not declared in the design's API changes`).join("; ");
|
|
14419
|
-
}
|
|
14420
|
-
|
|
14421
14653
|
// src/testPlacementCheck.ts
|
|
14422
14654
|
function isDiscovered(targetPath, discoveredFiles) {
|
|
14423
14655
|
const normalized = targetPath.replace(/\\/g, "/");
|
|
@@ -14647,13 +14879,13 @@ function describeUnsuppliedInputs(found) {
|
|
|
14647
14879
|
}
|
|
14648
14880
|
|
|
14649
14881
|
// src/unsuppliedInputsDisk.ts
|
|
14650
|
-
var
|
|
14882
|
+
var import_node_fs15 = require("node:fs");
|
|
14651
14883
|
var MAX_READ_BYTES = 1e6;
|
|
14652
14884
|
function readCheckoutText(path) {
|
|
14653
14885
|
try {
|
|
14654
|
-
const info = (0,
|
|
14886
|
+
const info = (0, import_node_fs15.statSync)(path);
|
|
14655
14887
|
if (!info.isFile() || info.size > MAX_READ_BYTES) return null;
|
|
14656
|
-
const bytes = (0,
|
|
14888
|
+
const bytes = (0, import_node_fs15.readFileSync)(path);
|
|
14657
14889
|
if (bytes.includes(0)) return null;
|
|
14658
14890
|
return bytes.toString("utf8");
|
|
14659
14891
|
} catch {
|
|
@@ -14682,7 +14914,7 @@ function describeVanishedTests(vanished) {
|
|
|
14682
14914
|
}
|
|
14683
14915
|
|
|
14684
14916
|
// src/verifyChange.ts
|
|
14685
|
-
var
|
|
14917
|
+
var import_node_path13 = require("node:path");
|
|
14686
14918
|
async function verifyChange(ctx, results, undoable) {
|
|
14687
14919
|
const cwd = ctx.cwd ?? process.cwd();
|
|
14688
14920
|
const now = ctx.now ?? Date.now;
|
|
@@ -14751,7 +14983,7 @@ async function verifyChange(ctx, results, undoable) {
|
|
|
14751
14983
|
flushedAt = now();
|
|
14752
14984
|
if (undoable) {
|
|
14753
14985
|
const report = findJUnitReport(cwd);
|
|
14754
|
-
const ignore = report ? [(0,
|
|
14986
|
+
const ignore = report ? [(0, import_node_path13.relative)(cwd, report).split("\\").join("/")] : [];
|
|
14755
14987
|
const flush = undoableFlush(cwd, results, flushCodegenResults, { ignore });
|
|
14756
14988
|
undo = () => flush.undo();
|
|
14757
14989
|
} else {
|
|
@@ -14768,6 +15000,7 @@ async function verifyChange(ctx, results, undoable) {
|
|
|
14768
15000
|
stage = "gate";
|
|
14769
15001
|
const after = captureTestSnapshot(packet.commands.test);
|
|
14770
15002
|
outputs.finalTestReport = readTestReportBytes();
|
|
15003
|
+
outputs.testCount = after.results?.size;
|
|
14771
15004
|
outputs.vanishedTests = findVanishedTests(baseline, after) ?? void 0;
|
|
14772
15005
|
if (outputs.vanishedTests) {
|
|
14773
15006
|
const w = describeVanishedTests(outputs.vanishedTests);
|
|
@@ -14864,34 +15097,34 @@ async function fetchPacket(packetUrl, runToken, githubRunId) {
|
|
|
14864
15097
|
}
|
|
14865
15098
|
|
|
14866
15099
|
// src/phase0.ts
|
|
14867
|
-
var
|
|
15100
|
+
var import_node_fs16 = require("node:fs");
|
|
14868
15101
|
function writePhase0Marker(runId) {
|
|
14869
|
-
(0,
|
|
14870
|
-
(0,
|
|
15102
|
+
(0, import_node_fs16.mkdirSync)(".quikpilot", { recursive: true });
|
|
15103
|
+
(0, import_node_fs16.appendFileSync)(".quikpilot/phase0-marker.txt", `QuikPilot Phase 0 skeleton marker for run ${runId}
|
|
14871
15104
|
`);
|
|
14872
15105
|
}
|
|
14873
15106
|
|
|
14874
15107
|
// src/failureArtifact.ts
|
|
14875
|
-
var
|
|
14876
|
-
var
|
|
15108
|
+
var import_node_fs17 = require("node:fs");
|
|
15109
|
+
var import_node_path14 = require("node:path");
|
|
14877
15110
|
var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
|
|
14878
15111
|
var REPORT_COPY = "final-test-report.xml";
|
|
14879
15112
|
var MAX_REPORT_BYTES = 5 * 1024 * 1024;
|
|
14880
15113
|
var MAX_FILES = 200;
|
|
14881
|
-
var RUNNER_VERSION = true ? "9.3.0-rc.
|
|
15114
|
+
var RUNNER_VERSION = true ? "9.3.0-rc.16" : "dev";
|
|
14882
15115
|
function safeDestination(base, repoPath) {
|
|
14883
|
-
if (!repoPath || (0,
|
|
14884
|
-
const destination = (0,
|
|
14885
|
-
const rel = (0,
|
|
14886
|
-
if (!rel || rel.startsWith("..") || (0,
|
|
15116
|
+
if (!repoPath || (0, import_node_path14.isAbsolute)(repoPath)) return null;
|
|
15117
|
+
const destination = (0, import_node_path14.resolve)(base, repoPath);
|
|
15118
|
+
const rel = (0, import_node_path14.relative)(base, destination);
|
|
15119
|
+
if (!rel || rel.startsWith("..") || (0, import_node_path14.isAbsolute)(rel)) return null;
|
|
14887
15120
|
return destination;
|
|
14888
15121
|
}
|
|
14889
15122
|
function writeFailureArtifact(input) {
|
|
14890
15123
|
if (input.results.length === 0) return { written: false };
|
|
14891
15124
|
try {
|
|
14892
|
-
const base = (0,
|
|
14893
|
-
(0,
|
|
14894
|
-
(0,
|
|
15125
|
+
const base = (0, import_node_path14.resolve)(input.cwd, FAILURE_ARTIFACT_DIR);
|
|
15126
|
+
(0, import_node_fs17.rmSync)(base, { recursive: true, force: true });
|
|
15127
|
+
(0, import_node_fs17.mkdirSync)(base, { recursive: true });
|
|
14895
15128
|
const files = [];
|
|
14896
15129
|
const skipped = [];
|
|
14897
15130
|
for (const result of input.results) {
|
|
@@ -14900,8 +15133,8 @@ function writeFailureArtifact(input) {
|
|
|
14900
15133
|
skipped.push(result.targetPath);
|
|
14901
15134
|
continue;
|
|
14902
15135
|
}
|
|
14903
|
-
(0,
|
|
14904
|
-
(0,
|
|
15136
|
+
(0, import_node_fs17.mkdirSync)((0, import_node_path14.dirname)(destination), { recursive: true });
|
|
15137
|
+
(0, import_node_fs17.writeFileSync)(destination, result.newContent);
|
|
14905
15138
|
files.push({ path: result.targetPath, bytes: Buffer.byteLength(result.newContent) });
|
|
14906
15139
|
}
|
|
14907
15140
|
let testReport = "none";
|
|
@@ -14909,7 +15142,7 @@ function writeFailureArtifact(input) {
|
|
|
14909
15142
|
if (input.testReport.byteLength > MAX_REPORT_BYTES) {
|
|
14910
15143
|
testReport = "too-large";
|
|
14911
15144
|
} else {
|
|
14912
|
-
(0,
|
|
15145
|
+
(0, import_node_fs17.writeFileSync)((0, import_node_path14.join)(base, REPORT_COPY), input.testReport);
|
|
14913
15146
|
testReport = "included";
|
|
14914
15147
|
}
|
|
14915
15148
|
}
|
|
@@ -14929,8 +15162,8 @@ function writeFailureArtifact(input) {
|
|
|
14929
15162
|
failureReasons: input.failureReasons
|
|
14930
15163
|
};
|
|
14931
15164
|
const text = JSON.stringify(manifest, (_key, value) => typeof value === "string" ? scrubSecrets(value, input.secrets) : value, 2);
|
|
14932
|
-
(0,
|
|
14933
|
-
return { written: (0,
|
|
15165
|
+
(0, import_node_fs17.writeFileSync)((0, import_node_path14.join)(base, "manifest.json"), text);
|
|
15166
|
+
return { written: (0, import_node_fs17.existsSync)((0, import_node_path14.join)(base, "manifest.json")) };
|
|
14934
15167
|
} catch (err) {
|
|
14935
15168
|
console.warn(`::warning::Could not keep the failed run's files: ${err instanceof Error ? err.message : String(err)}`);
|
|
14936
15169
|
return { written: false };
|
|
@@ -14938,7 +15171,7 @@ function writeFailureArtifact(input) {
|
|
|
14938
15171
|
}
|
|
14939
15172
|
|
|
14940
15173
|
// src/targeting.ts
|
|
14941
|
-
var
|
|
15174
|
+
var import_node_path15 = require("node:path");
|
|
14942
15175
|
|
|
14943
15176
|
// src/targetingFindings.ts
|
|
14944
15177
|
var isRecord2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -15005,9 +15238,9 @@ function validateTarget(target, workspaceRoot, workspaceListing, deniedPaths) {
|
|
|
15005
15238
|
}
|
|
15006
15239
|
return;
|
|
15007
15240
|
}
|
|
15008
|
-
const root = (0,
|
|
15009
|
-
const rel = (0,
|
|
15010
|
-
if (rel.startsWith("..") || (0,
|
|
15241
|
+
const root = (0, import_node_path15.resolve)(workspaceRoot ?? ".");
|
|
15242
|
+
const rel = (0, import_node_path15.relative)(root, (0, import_node_path15.resolve)(target.path));
|
|
15243
|
+
if (rel.startsWith("..") || (0, import_node_path15.isAbsolute)(rel)) {
|
|
15011
15244
|
throw new Error(
|
|
15012
15245
|
`pilot.targeting named a NEW_FILE path that escapes the workspace root: ${target.path}`
|
|
15013
15246
|
);
|
|
@@ -15317,6 +15550,9 @@ async function exchangeForRunToken(tokenUrl, oidcToken) {
|
|
|
15317
15550
|
|
|
15318
15551
|
// src/run.ts
|
|
15319
15552
|
var JOB_RESERVE_MS = 7 * 6e4;
|
|
15553
|
+
var HUNK_CHECK_MAX_MS = 6 * 6e4;
|
|
15554
|
+
var HUNK_CHECK_MIN_BUDGET_MS = 3 * 6e4;
|
|
15555
|
+
var HUNK_CHECK_END_BEFORE_STOP_MS = 2 * 6e4;
|
|
15320
15556
|
async function run(env2) {
|
|
15321
15557
|
const runStartedAt = Date.now();
|
|
15322
15558
|
let hardFailure = false;
|
|
@@ -15339,6 +15575,7 @@ async function run(env2) {
|
|
|
15339
15575
|
let baselineFindings;
|
|
15340
15576
|
let vanishedTests;
|
|
15341
15577
|
let unsuppliedInputs;
|
|
15578
|
+
let changesNoTestDependsOn;
|
|
15342
15579
|
const contextLog = [];
|
|
15343
15580
|
const codegenOut = {};
|
|
15344
15581
|
try {
|
|
@@ -15446,6 +15683,7 @@ async function run(env2) {
|
|
|
15446
15683
|
baseline,
|
|
15447
15684
|
requiredAutomationIds: claimedAutomationIds(stepParams)
|
|
15448
15685
|
};
|
|
15686
|
+
const jobStopAtMs = runStartedAt + packet.guardrails.maxWallClockMinutes * 6e4 - JOB_RESERVE_MS;
|
|
15449
15687
|
const healCalls = [];
|
|
15450
15688
|
let healStop;
|
|
15451
15689
|
let fixed;
|
|
@@ -15456,7 +15694,7 @@ async function run(env2) {
|
|
|
15456
15694
|
mode: codegenMode,
|
|
15457
15695
|
setting: packet.guardrails.maxHealIterations,
|
|
15458
15696
|
now: Date.now,
|
|
15459
|
-
jobStopAtMs
|
|
15697
|
+
jobStopAtMs,
|
|
15460
15698
|
lastAttemptMs,
|
|
15461
15699
|
verify: (r, undoable) => verifyChange(verifyCtx, r, undoable),
|
|
15462
15700
|
heal: async ({ results: kept, answer, attempt: attempt2, hardStopAtMs }) => {
|
|
@@ -15489,6 +15727,38 @@ async function run(env2) {
|
|
|
15489
15727
|
const suffix = healFailureSuffix(fixed.heal);
|
|
15490
15728
|
throw suffix ? new Error(`${final.error.message}${suffix}`) : final.error;
|
|
15491
15729
|
}
|
|
15730
|
+
if (codegenMode === "loop-tests" && process.env.QUIKPILOT_HUNK_CHECK?.trim().toLowerCase() !== "off") {
|
|
15731
|
+
const deadlineAtMs = Math.min(jobStopAtMs - HUNK_CHECK_END_BEFORE_STOP_MS, Date.now() + HUNK_CHECK_MAX_MS);
|
|
15732
|
+
if (deadlineAtMs - Date.now() >= HUNK_CHECK_MIN_BUDGET_MS) {
|
|
15733
|
+
try {
|
|
15734
|
+
const files = collectHunkCheckFiles(fixed.results, process.cwd());
|
|
15735
|
+
if (files.length > 0) {
|
|
15736
|
+
const checked = await runHunkCheck({
|
|
15737
|
+
root: process.cwd(),
|
|
15738
|
+
command: packet.commands.test,
|
|
15739
|
+
baseline,
|
|
15740
|
+
baselineMs: timedBaseline.durationMs,
|
|
15741
|
+
finalTestCount: final.outputs.testCount ?? 0,
|
|
15742
|
+
files,
|
|
15743
|
+
deadlineAtMs,
|
|
15744
|
+
log: (e) => console.log(JSON.stringify(e))
|
|
15745
|
+
});
|
|
15746
|
+
console.log(JSON.stringify({ event: "hunk_check", checked: checked.checked, total: checked.total, flagged: checked.unnecessary.length, skipped: checked.skipped, stopped: checked.stopped ?? null }));
|
|
15747
|
+
changesNoTestDependsOn = toFinding(checked);
|
|
15748
|
+
if (checked.unnecessary.length > 0) {
|
|
15749
|
+
const w = describeHunkCheck(checked);
|
|
15750
|
+
warnings.push(w);
|
|
15751
|
+
console.warn(`QuikPilot change warning (not blocking): ${w}`);
|
|
15752
|
+
}
|
|
15753
|
+
}
|
|
15754
|
+
} catch (err) {
|
|
15755
|
+
if (err instanceof TreeNotRestoredError) throw err;
|
|
15756
|
+
const message = `The check for changes no test depends on could not run: ${err instanceof Error ? err.message : String(err)}`;
|
|
15757
|
+
console.error(message);
|
|
15758
|
+
warnings.push(message);
|
|
15759
|
+
}
|
|
15760
|
+
}
|
|
15761
|
+
}
|
|
15492
15762
|
}
|
|
15493
15763
|
} catch (err) {
|
|
15494
15764
|
hardFailure = true;
|
|
@@ -15559,6 +15829,7 @@ async function run(env2) {
|
|
|
15559
15829
|
baselineFindings,
|
|
15560
15830
|
vanishedTests,
|
|
15561
15831
|
unsuppliedInputs,
|
|
15832
|
+
changesNoTestDependsOn,
|
|
15562
15833
|
codegenLoop: codegenOut.loop,
|
|
15563
15834
|
unresolved: failureReasons.length > 0 ? failureReasons : void 0
|
|
15564
15835
|
});
|