@quikit/quikpilot-runner 9.3.0-rc.16 → 9.3.0-rc.17
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 +142 -15
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -150,6 +150,8 @@ it, the callback carries it as `unsuppliedInputs` (at most 10 functions, 5 names
|
|
|
150
150
|
noticed" as a check. This is the shape of a change whose new tests pass only because they hand the function the field themselves. It can be
|
|
151
151
|
wrong (a field that arrives from a database row or a request), so it only warns and never blocks. TypeScript is not covered (QUIKTR-1547).
|
|
152
152
|
|
|
153
|
+
**9.3.0-rc.17 — the list of files that hold tests is read from this run's own test run (QUIKTR-1526).** Before the AI picks files, the AI service is given the files the project's test runner discovers and refuses an answer that puts test cases on any other existing file. That list used to come from the last merged QuikPilot run, so a test file added by hand since then was unknown and an honest answer about it was refused (QUIKSPL-140 died at targeting). Now `Setup` and the baseline test run come BEFORE targeting, and the list is built from that run's own report: the files it attributes tests to, put in the form of the file list and kept only if they are in it (the AI service rejects the whole request otherwise); each file that cannot be placed, and each test the report names without a file (a Java class name, a Jest describe title), is counted in `unmappedEntries`, which switches the refusal off. Doubt turns the check off, never on: no test command, no report, a report with no tests, or a wait that ran out sends `ABSENT`. Targeting waits for the baseline at most 90 seconds (`QUIKPILOT_DISCOVERY_WAIT_SECONDS`); past that the run says so in its notes and the baseline carries on beside the code-writing step exactly as before (it is started once). The list QuikProjects stores is no longer used by this runner. The log gets one `test_discovery` line with counts only. No change in the AI service or in QuikProjects.
|
|
154
|
+
|
|
153
155
|
**9.3.0-rc.16 — changes no test depends on are named (QUIKTR-1569).** A green test run only proves what the tests check (QUIKSPL-138: the pagination fix also rewrote the neighbouring `hasMore` line, wrongly, and all 75 tests stayed green). In `loop-tests` mode, after a change has passed every check, each changed block of an existing code file that is not a test is put back as it was, ON ITS OWN, and the project's tests run once more (a block that looks unneeded is run a second time before it is flagged). A block with every test still passing is reported under "What QuikPilot noticed" as a file and line numbers only, never the code: it is a statement about the tests, not about the code, since a block can be right and untested. It warns and never blocks. A run that times out, leaves no report or a stale one counts as unknown and is never flagged; a block put back that makes tests vanish counts as needed; at most 8 blocks are checked, for at most 6 minutes and never in the last 2 minutes before the job's stop; a suite too slow to run again, or a project with no readable baseline, is skipped. Files the run created, tests, documents and configuration are not looked at. The checkout and the final test report are put back after every run; a checkout that does not come back ends the run, as for `run_tests`. Switch it off with `QUIKPILOT_HUNK_CHECK=off`. An older QuikProjects ignores the new field.
|
|
154
156
|
|
|
155
157
|
**9.3.0-rc.15 — QuikPilot fixes its own change when the project's final tests fail (QUIKTR-1527).** In `loop-tests` mode, when the final comparison of the project's tests finds tests that passed before and fail now (or new tests that fail), the run no longer ends Failed at once. It takes the checkout back, starts another attempt FROM the change it just wrote (kept in memory), tells the AI which tests failed (names, and for tests it wrote itself the first line of the error: exactly what `run_tests` shows it), and then runs EVERY check again from scratch (dependencies, scope, placement, format, lint, the project's tests, coverage). At most three attempts at writing the change per run in all (an ordinary retry counts as one); `maxHealIterations` (the project's "fix attempts" setting) can lower it, and 0 turns fixing off. A fix is made only for a failing test comparison (never for lint, scope, dependency, placement or coverage), never after the same tests fail the same way twice in a row, and only if the time left fits it (the job limit less seven minutes for pushing and reporting). Nothing is pushed unless the final code passes every check; an existing test is never edited to make code pass. A run that still fails ends Failed as before, with "; QuikPilot tried to fix it N times (stopped: …)" added to the reason, and the run's record gains the fix attempts and a stop word. Needs the AI service with contract 24.12d (otherwise the fix is refused and the run fails exactly as before). Other modes and a run whose tests pass are unchanged.
|
package/dist/index.js
CHANGED
|
@@ -12464,6 +12464,14 @@ async function reportToQuikTest(params) {
|
|
|
12464
12464
|
|
|
12465
12465
|
// src/regressionCheck.ts
|
|
12466
12466
|
var import_node_fs8 = require("node:fs");
|
|
12467
|
+
|
|
12468
|
+
// src/pathShape.ts
|
|
12469
|
+
var PATH_EXTENSION_RE = /\.(ts|tsx|js|jsx|mjs|cjs|py|rb|go)$/i;
|
|
12470
|
+
function looksLikeFilePath(value) {
|
|
12471
|
+
return value.includes("/") || PATH_EXTENSION_RE.test(value);
|
|
12472
|
+
}
|
|
12473
|
+
|
|
12474
|
+
// src/regressionCheck.ts
|
|
12467
12475
|
var TESTCASE_RE = /<testcase\b([^>]*?)(?:\/>|>([\s\S]*?)<\/testcase>)/g;
|
|
12468
12476
|
var NAME_ATTR_RE = /\bname="([^"]*)"/;
|
|
12469
12477
|
var CLASSNAME_ATTR_RE = /\bclassname="([^"]*)"/;
|
|
@@ -12510,6 +12518,7 @@ function parseJUnitOutcomes(xml) {
|
|
|
12510
12518
|
const failureText = /* @__PURE__ */ new Map();
|
|
12511
12519
|
const discoveredFiles = /* @__PURE__ */ new Set();
|
|
12512
12520
|
const discoveredAutomationIds = /* @__PURE__ */ new Set();
|
|
12521
|
+
let unmappedEntries = 0;
|
|
12513
12522
|
TESTSUITE_OPEN_RE.lastIndex = 0;
|
|
12514
12523
|
let suiteMatch;
|
|
12515
12524
|
while (suiteMatch = TESTSUITE_OPEN_RE.exec(xml)) {
|
|
@@ -12535,6 +12544,7 @@ function parseJUnitOutcomes(xml) {
|
|
|
12535
12544
|
const file = FILE_ATTR_RE.exec(attrs)?.[1];
|
|
12536
12545
|
if (file) discoveredFiles.add(normalizeSlashes(file));
|
|
12537
12546
|
if (classname) discoveredFiles.add(normalizeSlashes(classname));
|
|
12547
|
+
if (!file?.trim() && !(classname && looksLikeFilePath(classname.trim()))) unmappedEntries += 1;
|
|
12538
12548
|
const bracket = QP_TOKEN_BRACKET_RE.exec(name)?.[1];
|
|
12539
12549
|
if (bracket) {
|
|
12540
12550
|
discoveredAutomationIds.add(bracket);
|
|
@@ -12543,7 +12553,7 @@ function parseJUnitOutcomes(xml) {
|
|
|
12543
12553
|
if (!seen || RESULT_RANK[result] > RESULT_RANK[seen]) automationIdResults.set(bracket, result);
|
|
12544
12554
|
}
|
|
12545
12555
|
}
|
|
12546
|
-
return { outcomes, automationIdResults, failureText, discoveredFiles, discoveredAutomationIds };
|
|
12556
|
+
return { outcomes, automationIdResults, failureText, discoveredFiles, discoveredAutomationIds, unmappedEntries };
|
|
12547
12557
|
}
|
|
12548
12558
|
function readJUnitOutcomes(cwd) {
|
|
12549
12559
|
const report = findJUnitReport(cwd);
|
|
@@ -12565,7 +12575,8 @@ function captureTestSnapshot(command, cwd = process.cwd()) {
|
|
|
12565
12575
|
results: parsed?.outcomes ?? null,
|
|
12566
12576
|
failureText: parsed?.failureText,
|
|
12567
12577
|
discoveredFiles: parsed?.discoveredFiles ?? null,
|
|
12568
|
-
discoveredAutomationIds: parsed?.discoveredAutomationIds ?? null
|
|
12578
|
+
discoveredAutomationIds: parsed?.discoveredAutomationIds ?? null,
|
|
12579
|
+
unmappedEntries: parsed?.unmappedEntries
|
|
12569
12580
|
};
|
|
12570
12581
|
}
|
|
12571
12582
|
function readTestSnapshot(outcome, cwd = process.cwd()) {
|
|
@@ -12575,7 +12586,8 @@ function readTestSnapshot(outcome, cwd = process.cwd()) {
|
|
|
12575
12586
|
results: parsed?.outcomes ?? null,
|
|
12576
12587
|
failureText: parsed?.failureText,
|
|
12577
12588
|
discoveredFiles: parsed?.discoveredFiles ?? null,
|
|
12578
|
-
discoveredAutomationIds: parsed?.discoveredAutomationIds ?? null
|
|
12589
|
+
discoveredAutomationIds: parsed?.discoveredAutomationIds ?? null,
|
|
12590
|
+
unmappedEntries: parsed?.unmappedEntries
|
|
12579
12591
|
};
|
|
12580
12592
|
}
|
|
12581
12593
|
async function captureBaselineSnapshot(command, cwd = process.cwd()) {
|
|
@@ -12586,7 +12598,8 @@ async function captureBaselineSnapshot(command, cwd = process.cwd()) {
|
|
|
12586
12598
|
results: parsed?.outcomes ?? null,
|
|
12587
12599
|
failureText: parsed?.failureText,
|
|
12588
12600
|
discoveredFiles: parsed?.discoveredFiles ?? null,
|
|
12589
|
-
discoveredAutomationIds: parsed?.discoveredAutomationIds ?? null
|
|
12601
|
+
discoveredAutomationIds: parsed?.discoveredAutomationIds ?? null,
|
|
12602
|
+
unmappedEntries: parsed?.unmappedEntries
|
|
12590
12603
|
};
|
|
12591
12604
|
}
|
|
12592
12605
|
function checkForRegressions(baseline, after) {
|
|
@@ -13570,10 +13583,10 @@ async function postCodegenTurn(gateway, contextData, signal) {
|
|
|
13570
13583
|
return res.json();
|
|
13571
13584
|
}
|
|
13572
13585
|
function protectedTestFiles(listing, testDiscovery) {
|
|
13573
|
-
const
|
|
13586
|
+
const inListing2 = new Set(listing);
|
|
13574
13587
|
const found = new Set(listing.filter((p) => isTestTarget(p)));
|
|
13575
13588
|
if (testDiscovery.report === "PRESENT") {
|
|
13576
|
-
for (const p of testDiscovery.discoveredTestFiles) if (
|
|
13589
|
+
for (const p of testDiscovery.discoveredTestFiles) if (inListing2.has(p)) found.add(p);
|
|
13577
13590
|
}
|
|
13578
13591
|
return [...found].sort();
|
|
13579
13592
|
}
|
|
@@ -15111,7 +15124,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
|
|
|
15111
15124
|
var REPORT_COPY = "final-test-report.xml";
|
|
15112
15125
|
var MAX_REPORT_BYTES = 5 * 1024 * 1024;
|
|
15113
15126
|
var MAX_FILES = 200;
|
|
15114
|
-
var RUNNER_VERSION = true ? "9.3.0-rc.
|
|
15127
|
+
var RUNNER_VERSION = true ? "9.3.0-rc.17" : "dev";
|
|
15115
15128
|
function safeDestination(base, repoPath) {
|
|
15116
15129
|
if (!repoPath || (0, import_node_path14.isAbsolute)(repoPath)) return null;
|
|
15117
15130
|
const destination = (0, import_node_path14.resolve)(base, repoPath);
|
|
@@ -15170,6 +15183,98 @@ function writeFailureArtifact(input) {
|
|
|
15170
15183
|
}
|
|
15171
15184
|
}
|
|
15172
15185
|
|
|
15186
|
+
// src/testDiscovery.ts
|
|
15187
|
+
var ABSENT = { report: "ABSENT" };
|
|
15188
|
+
var DRIVE_RE = /^[A-Za-z]:\//;
|
|
15189
|
+
function absent(reason) {
|
|
15190
|
+
return { value: { ...ABSENT }, source: "absent", reason, files: 0, unmapped: 0 };
|
|
15191
|
+
}
|
|
15192
|
+
var slashes = (p) => p.replace(/\\/g, "/");
|
|
15193
|
+
var withoutDotSlash = (p) => p.replace(/^(\.\/)+/, "");
|
|
15194
|
+
function relativeToRepository(raw, cwd) {
|
|
15195
|
+
const path = withoutDotSlash(slashes(raw.trim()));
|
|
15196
|
+
let relative10 = path;
|
|
15197
|
+
if (path.startsWith("/") || DRIVE_RE.test(path)) {
|
|
15198
|
+
const root = slashes(cwd).replace(/\/+$/, "");
|
|
15199
|
+
const windows = DRIVE_RE.test(path) || DRIVE_RE.test(root);
|
|
15200
|
+
const a = windows ? path.toLowerCase() : path;
|
|
15201
|
+
const b = windows ? root.toLowerCase() : root;
|
|
15202
|
+
if (!a.startsWith(`${b}/`)) return null;
|
|
15203
|
+
relative10 = path.slice(root.length + 1);
|
|
15204
|
+
}
|
|
15205
|
+
return relative10;
|
|
15206
|
+
}
|
|
15207
|
+
function inListing(raw, listing, cwd, workspaceRoot) {
|
|
15208
|
+
const relative10 = relativeToRepository(raw, cwd);
|
|
15209
|
+
if (relative10 === null) return null;
|
|
15210
|
+
if (listing.has(relative10)) return relative10;
|
|
15211
|
+
if (workspaceRoot) {
|
|
15212
|
+
const root = slashes(workspaceRoot).replace(/\/+$/, "");
|
|
15213
|
+
const joined = `${root}/${relative10}`;
|
|
15214
|
+
if (listing.has(joined)) return joined;
|
|
15215
|
+
}
|
|
15216
|
+
return null;
|
|
15217
|
+
}
|
|
15218
|
+
function buildTestDiscovery(i2) {
|
|
15219
|
+
if (!i2.command || i2.command.trim().length === 0) return absent("no_command");
|
|
15220
|
+
const snapshot = i2.snapshot;
|
|
15221
|
+
if (!snapshot || !snapshot.results || !snapshot.discoveredFiles) return absent("no_report");
|
|
15222
|
+
if (snapshot.results.size === 0) return absent("no_tests");
|
|
15223
|
+
if (snapshot.unmappedEntries === void 0) return absent("no_report");
|
|
15224
|
+
const listing = new Set(i2.listing);
|
|
15225
|
+
const found = /* @__PURE__ */ new Set();
|
|
15226
|
+
const dropped = /* @__PURE__ */ new Set();
|
|
15227
|
+
for (const raw of snapshot.discoveredFiles) {
|
|
15228
|
+
if (!looksLikeFilePath(slashes(raw).trim())) continue;
|
|
15229
|
+
const match = inListing(raw, listing, i2.cwd, i2.workspaceRoot);
|
|
15230
|
+
if (match) found.add(match);
|
|
15231
|
+
else dropped.add(withoutDotSlash(slashes(raw.trim())));
|
|
15232
|
+
}
|
|
15233
|
+
const unmapped = snapshot.unmappedEntries + dropped.size;
|
|
15234
|
+
const files = [...found].sort();
|
|
15235
|
+
return {
|
|
15236
|
+
value: { report: "PRESENT", discoveredTestFiles: files, unmappedEntries: unmapped },
|
|
15237
|
+
source: "live",
|
|
15238
|
+
reason: "ok",
|
|
15239
|
+
files: files.length,
|
|
15240
|
+
unmapped
|
|
15241
|
+
};
|
|
15242
|
+
}
|
|
15243
|
+
var DEFAULT_DISCOVERY_WAIT_MS = 9e4;
|
|
15244
|
+
var MAX_DISCOVERY_WAIT_MS = 36e5;
|
|
15245
|
+
function discoveryWaitMs(env2 = process.env) {
|
|
15246
|
+
const raw = env2.QUIKPILOT_DISCOVERY_WAIT_SECONDS?.trim();
|
|
15247
|
+
if (!raw || !/^\d+(\.\d+)?$/.test(raw)) return DEFAULT_DISCOVERY_WAIT_MS;
|
|
15248
|
+
return Math.min(MAX_DISCOVERY_WAIT_MS, Math.round(Number(raw) * 1e3));
|
|
15249
|
+
}
|
|
15250
|
+
var TIMEOUT_WARNING = "QuikPilot could not list the project's test files in time, so it skipped the early check of where tests are placed.";
|
|
15251
|
+
async function resolveTestDiscovery(i2) {
|
|
15252
|
+
const now = i2.now ?? Date.now;
|
|
15253
|
+
const started = now();
|
|
15254
|
+
const base = { command: i2.command, listing: i2.listing, workspaceRoot: i2.workspaceRoot, cwd: i2.cwd };
|
|
15255
|
+
const done = (result, warning) => {
|
|
15256
|
+
const waitedMs = now() - started;
|
|
15257
|
+
i2.log?.({ event: "test_discovery", source: result.source, reason: result.reason, files: result.files, unmapped: result.unmapped, waitedMs });
|
|
15258
|
+
return { result, waitedMs, ...warning ? { warning } : {} };
|
|
15259
|
+
};
|
|
15260
|
+
if (!i2.command || i2.command.trim().length === 0) return done(buildTestDiscovery({ ...base, snapshot: null }));
|
|
15261
|
+
let timer;
|
|
15262
|
+
const timeout = new Promise((resolve6) => {
|
|
15263
|
+
timer = setTimeout(() => resolve6("timeout"), i2.waitMs);
|
|
15264
|
+
});
|
|
15265
|
+
const settled = i2.baseline.then(
|
|
15266
|
+
(b) => b.snapshot,
|
|
15267
|
+
() => null
|
|
15268
|
+
);
|
|
15269
|
+
try {
|
|
15270
|
+
const first = await Promise.race([settled, timeout]);
|
|
15271
|
+
if (first === "timeout") return done(absent("timeout"), TIMEOUT_WARNING);
|
|
15272
|
+
return done(buildTestDiscovery({ ...base, snapshot: first }));
|
|
15273
|
+
} finally {
|
|
15274
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
15275
|
+
}
|
|
15276
|
+
}
|
|
15277
|
+
|
|
15173
15278
|
// src/targeting.ts
|
|
15174
15279
|
var import_node_path15 = require("node:path");
|
|
15175
15280
|
|
|
@@ -15578,12 +15683,39 @@ async function run(env2) {
|
|
|
15578
15683
|
let changesNoTestDependsOn;
|
|
15579
15684
|
const contextLog = [];
|
|
15580
15685
|
const codegenOut = {};
|
|
15686
|
+
let pendingBaseline;
|
|
15687
|
+
const baselineSettled = async () => {
|
|
15688
|
+
try {
|
|
15689
|
+
await pendingBaseline;
|
|
15690
|
+
} catch {
|
|
15691
|
+
}
|
|
15692
|
+
};
|
|
15581
15693
|
try {
|
|
15582
15694
|
runToken = await exchangeForRunToken(env2.tokenUrl, await fetchGithubOidcToken());
|
|
15583
15695
|
packet = await fetchPacket(env2.packetUrl, runToken, env2.githubRunId);
|
|
15584
15696
|
checkoutTargetBranch(packet.targetBranch);
|
|
15585
15697
|
const workspaceListing = listWorkspaceFiles(packet.workspaceRoot);
|
|
15586
15698
|
const outOfScope = (packet.outOfScope ?? []).map((entry) => entry.trim()).filter((entry) => entry.length > 0);
|
|
15699
|
+
runCommand(packet.commands.setup, "Setup");
|
|
15700
|
+
const baselineStartedAt = Date.now();
|
|
15701
|
+
const baselineRun = captureBaselineSnapshot(packet.commands.test).then((snapshot) => ({
|
|
15702
|
+
snapshot,
|
|
15703
|
+
durationMs: Date.now() - baselineStartedAt
|
|
15704
|
+
}));
|
|
15705
|
+
pendingBaseline = baselineRun;
|
|
15706
|
+
const discovery = await resolveTestDiscovery({
|
|
15707
|
+
command: packet.commands.test,
|
|
15708
|
+
baseline: baselineRun,
|
|
15709
|
+
listing: workspaceListing,
|
|
15710
|
+
workspaceRoot: packet.workspaceRoot,
|
|
15711
|
+
cwd: process.cwd(),
|
|
15712
|
+
waitMs: discoveryWaitMs(),
|
|
15713
|
+
log: (e) => console.log(JSON.stringify(e))
|
|
15714
|
+
});
|
|
15715
|
+
if (discovery.warning) {
|
|
15716
|
+
warnings.push(discovery.warning);
|
|
15717
|
+
console.warn(`QuikPilot targeting warning (not blocking): ${discovery.warning}`);
|
|
15718
|
+
}
|
|
15587
15719
|
const targeting = await runTargeting(
|
|
15588
15720
|
packet.gateway,
|
|
15589
15721
|
packet.design,
|
|
@@ -15591,7 +15723,7 @@ async function run(env2) {
|
|
|
15591
15723
|
workspaceListing,
|
|
15592
15724
|
packet.requiredTests,
|
|
15593
15725
|
packet.guardrails.deniedPaths,
|
|
15594
|
-
|
|
15726
|
+
discovery.result.value,
|
|
15595
15727
|
outOfScope,
|
|
15596
15728
|
...packet.findings ? [{ findings: packet.findings }] : []
|
|
15597
15729
|
);
|
|
@@ -15612,8 +15744,8 @@ async function run(env2) {
|
|
|
15612
15744
|
if (packet.issueKey !== null) {
|
|
15613
15745
|
throw new Error(`QuikPilot found no file to change for this request \u2014 ${targeting.reason?.trim() || "no reason was given."}`);
|
|
15614
15746
|
}
|
|
15747
|
+
await baselineSettled();
|
|
15615
15748
|
writePhase0Marker(env2.runId);
|
|
15616
|
-
runCommand(packet.commands.setup, "Setup");
|
|
15617
15749
|
runCommand(packet.commands.lint, "Lint");
|
|
15618
15750
|
runTestCommand(packet.commands.test);
|
|
15619
15751
|
} else {
|
|
@@ -15640,17 +15772,11 @@ async function run(env2) {
|
|
|
15640
15772
|
`QuikPilot's generated plan gives two files identical instructions \u2014 ${describeOverlapWarnings(blockingOverlaps).join("; ")}`
|
|
15641
15773
|
);
|
|
15642
15774
|
}
|
|
15643
|
-
runCommand(packet.commands.setup, "Setup");
|
|
15644
15775
|
const judgedByPool = buildJudgedByPool(
|
|
15645
15776
|
packet.requiredTests,
|
|
15646
15777
|
targeting.targets,
|
|
15647
15778
|
targeting.skippedCases ?? []
|
|
15648
15779
|
);
|
|
15649
|
-
const baselineStartedAt = Date.now();
|
|
15650
|
-
const baselineRun = captureBaselineSnapshot(packet.commands.test).then((snapshot) => ({
|
|
15651
|
-
snapshot,
|
|
15652
|
-
durationMs: Date.now() - baselineStartedAt
|
|
15653
|
-
}));
|
|
15654
15780
|
const codegenMode = resolveCodegenMode();
|
|
15655
15781
|
const stepParams = {
|
|
15656
15782
|
mode: codegenMode,
|
|
@@ -15768,6 +15894,7 @@ async function run(env2) {
|
|
|
15768
15894
|
console.error("No run token \u2014 the OIDC exchange failed before QuikTrack could be reached.");
|
|
15769
15895
|
return { hardFailure: true };
|
|
15770
15896
|
}
|
|
15897
|
+
await baselineSettled();
|
|
15771
15898
|
const quikTestReport = await reportToQuikTest({
|
|
15772
15899
|
resultsUrl: packet?.quikTest?.resultsUrl,
|
|
15773
15900
|
runToken,
|