@quikit/quikpilot-runner 9.3.0-rc.17 → 9.3.0-rc.19
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 +4 -0
- package/dist/index.js +239 -35
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -150,6 +150,10 @@ 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.19 — when no old test broke, the test answer says so (test-expectations plan, Part 0).** Checking 11 runs of one pagination bug, every give-up was a test the AI had written itself with a wrong expectation (which item is first, in what order) over code that was already right; where its test data had no explicit date the code stamped the current time, records tied within a millisecond and the order of tied records depended on the clock. The `run_tests` answer for a failed run now carries one more fixed sentence when `regressions` is 0, `newFailures` is above 0 and a baseline was compared with: no test that passed before the change fails now, and the failures counted in `newFailures` are tests that were not in the test run before it. It names no test and quotes no text, changes no key of the answer, and the log line `codegen.run_tests` gains `ownOnly` (a flag). What to do with it is said in the AI Runtime's prompt, which is deployed FIRST (its loop-2 text moved); without that prompt the sentence is only a fact. **Also in rc.19 - a fix may correct a test written in this run, but not empty it (test-expectations plan, Part 4).** The AI Runtime's fix instruction (§24.12f) now lets a fix correct a test the run itself wrote when no test that passed before fails. Wording cannot stop a model from making a test pass by emptying it, so during a fix attempt an edit that removes a test written in this run, renames it away from its `[QP-...]` token, skips it (`it.skip`, `xit`, `it.todo`) or leaves it with fewer `expect`/`assert` checks is refused with the ordinary `protected` answer and the closed reason `test_removed` or `test_emptied`; the AI edits again. Tests that existed before the run stay locked exactly as before, and a first attempt or a clean retry is not touched. JavaScript test files only (like the existing-test rule; TypeScript is QUIKTR-1547); a file it cannot read is never refused. When a fix was made and the change then passed every check, the run also reports which tests written in this run the fix changed, as paths and line numbers only (`testsCorrected`), so the run page and the pull request can say so; `QUIKPILOT_TESTS_CORRECTED=off` stops that report. The rail cannot judge whether a changed expectation is right; it only closes the way of passing by saying nothing. QuikProjects must be deployed first (it validates the new field); an older one ignores it. Nothing else changes, and the sentence about no old test breaking has no switch: a revert of this release restores the old sentence.
|
|
154
|
+
|
|
155
|
+
**9.3.0-rc.18 — an honest "I cannot finish" no longer throws away a change that is one fix away (QUIKSPL-139).** The AI wrote the fix and its tests, ran the project's tests until its runs were used (4 failing, then 3, then 3) and answered `CANNOT_COMPLETE`; the whole change was thrown away and a second attempt started from nothing, which did worse. Had it said `DONE`, every check would have run and the fix step (QUIKTR-1527) would have continued from the same change. Now a give-up is KEPT when the change would have passed as a `DONE` (something changed, every required test case written, no file cut short or broken) and the AI's LAST test run came back with failing tests that are the change's doing. It is recorded as attempt 1 `kept`, goes through every check like any result, and when only the tests fail the existing fix continues from it (three attempts in all, so at most two fixes). Only in `loop-tests` mode with fixing on (the project's setting above 0); a fix attempt that gives up is not kept again; time-outs, network errors and every other ending behave as before. `QUIKPILOT_KEEP_ON_GIVE_UP=off` restores the clean second attempt without a new release. Nothing new goes to the AI service.
|
|
156
|
+
|
|
153
157
|
**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
158
|
|
|
155
159
|
**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.
|
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, changesNoTestDependsOn, codegenLoop, unresolved } = params;
|
|
848
|
+
const { callbackUrl, runToken, status, branch, warnings, targeting, baselineFindings, vanishedTests, unsuppliedInputs, changesNoTestDependsOn, testsCorrected, 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;
|
|
@@ -855,6 +855,7 @@ async function reportBack(params) {
|
|
|
855
855
|
if (vanishedTests) body.vanishedTests = vanishedTests;
|
|
856
856
|
if (unsuppliedInputs && unsuppliedInputs.length > 0) body.unsuppliedInputs = unsuppliedInputs;
|
|
857
857
|
if (changesNoTestDependsOn && changesNoTestDependsOn.hunks.length > 0) body.changesNoTestDependsOn = changesNoTestDependsOn;
|
|
858
|
+
if (testsCorrected && testsCorrected.files.length > 0) body.testsCorrected = testsCorrected;
|
|
858
859
|
if (codegenLoop) body.codegenLoop = codegenLoop;
|
|
859
860
|
const res = await fetch(callbackUrl, {
|
|
860
861
|
method: "POST",
|
|
@@ -10180,6 +10181,153 @@ function protectedAnswer(verdict) {
|
|
|
10180
10181
|
return { reason: verdict.why, message: protectedMessage(verdict.why) };
|
|
10181
10182
|
}
|
|
10182
10183
|
|
|
10184
|
+
// src/ownTests.ts
|
|
10185
|
+
var TOKEN = /\[(QP-[^\]\s]+)\]/;
|
|
10186
|
+
var TEST_ROOTS2 = /* @__PURE__ */ new Set(["it", "test"]);
|
|
10187
|
+
var X_ROOTS = /* @__PURE__ */ new Set(["xit", "xtest"]);
|
|
10188
|
+
var SKIP_PROPS = /* @__PURE__ */ new Set(["skip", "todo"]);
|
|
10189
|
+
function walk(node, visit) {
|
|
10190
|
+
visit(node);
|
|
10191
|
+
for (const key of Object.keys(node)) {
|
|
10192
|
+
const value = node[key];
|
|
10193
|
+
if (Array.isArray(value)) {
|
|
10194
|
+
for (const child of value) if (child && typeof child.type === "string") walk(child, visit);
|
|
10195
|
+
} else if (value && typeof value.type === "string") {
|
|
10196
|
+
walk(value, visit);
|
|
10197
|
+
}
|
|
10198
|
+
}
|
|
10199
|
+
}
|
|
10200
|
+
function testChain(callee) {
|
|
10201
|
+
let skipped = false;
|
|
10202
|
+
let e = callee;
|
|
10203
|
+
while (e.type === "MemberExpression") {
|
|
10204
|
+
if (e.property.type === "Identifier" && SKIP_PROPS.has(e.property.name)) skipped = true;
|
|
10205
|
+
e = e.object;
|
|
10206
|
+
}
|
|
10207
|
+
if (e.type !== "Identifier") return null;
|
|
10208
|
+
if (X_ROOTS.has(e.name)) return { root: e.name, skipped: true };
|
|
10209
|
+
if (TEST_ROOTS2.has(e.name)) return { root: e.name, skipped };
|
|
10210
|
+
return null;
|
|
10211
|
+
}
|
|
10212
|
+
function titleOf(call) {
|
|
10213
|
+
const a = call.arguments[0];
|
|
10214
|
+
if (!a) return null;
|
|
10215
|
+
if (a.type === "Literal" && typeof a.value === "string") return a.value;
|
|
10216
|
+
if (a.type === "TemplateLiteral" && a.expressions.length === 0) return a.quasis.map((q) => q.value.cooked ?? "").join("");
|
|
10217
|
+
return null;
|
|
10218
|
+
}
|
|
10219
|
+
function isCheck(call) {
|
|
10220
|
+
const callee = call.callee;
|
|
10221
|
+
if (callee.type === "Identifier") return callee.name === "assert";
|
|
10222
|
+
if (callee.type !== "MemberExpression") return false;
|
|
10223
|
+
let o = callee.object;
|
|
10224
|
+
while (o.type === "MemberExpression") o = o.object;
|
|
10225
|
+
if (o.type === "Identifier") return o.name === "assert";
|
|
10226
|
+
return o.type === "CallExpression" && o.callee.type === "Identifier" && o.callee.name === "expect";
|
|
10227
|
+
}
|
|
10228
|
+
function lineAt2(text, offset2) {
|
|
10229
|
+
let line = 1;
|
|
10230
|
+
for (let i2 = 0; i2 < offset2 && i2 < text.length; i2++) if (text.charCodeAt(i2) === 10) line++;
|
|
10231
|
+
return line;
|
|
10232
|
+
}
|
|
10233
|
+
function findTests(path, text) {
|
|
10234
|
+
const parsed = parseProgram(path, text);
|
|
10235
|
+
if (!parsed) return null;
|
|
10236
|
+
const out = [];
|
|
10237
|
+
walk(parsed.ast, (n) => {
|
|
10238
|
+
if (n.type !== "CallExpression") return;
|
|
10239
|
+
const call = n;
|
|
10240
|
+
const chain = testChain(call.callee);
|
|
10241
|
+
if (!chain) return;
|
|
10242
|
+
const title = titleOf(call);
|
|
10243
|
+
if (title === null) return;
|
|
10244
|
+
const token = TOKEN.exec(title);
|
|
10245
|
+
let checks = 0;
|
|
10246
|
+
for (const arg of call.arguments) {
|
|
10247
|
+
if (arg.type !== "ArrowFunctionExpression" && arg.type !== "FunctionExpression") continue;
|
|
10248
|
+
walk(arg.body, (m) => {
|
|
10249
|
+
if (m.type === "CallExpression" && isCheck(m)) checks++;
|
|
10250
|
+
});
|
|
10251
|
+
}
|
|
10252
|
+
out.push({
|
|
10253
|
+
id: token ? `token:${token[1]}` : `title:${title}`,
|
|
10254
|
+
line: lineAt2(text, call.start),
|
|
10255
|
+
text: text.slice(call.start, call.end).replace(/\s+/g, " "),
|
|
10256
|
+
checks,
|
|
10257
|
+
skipped: chain.skipped
|
|
10258
|
+
});
|
|
10259
|
+
});
|
|
10260
|
+
return out;
|
|
10261
|
+
}
|
|
10262
|
+
function groupById(tests) {
|
|
10263
|
+
const map = /* @__PURE__ */ new Map();
|
|
10264
|
+
for (const t of tests) map.set(t.id, [...map.get(t.id) ?? [], t]);
|
|
10265
|
+
return map;
|
|
10266
|
+
}
|
|
10267
|
+
function ownTestsOf(seed, baseline) {
|
|
10268
|
+
const had = new Set(baseline.map((t) => t.id));
|
|
10269
|
+
const seen = /* @__PURE__ */ new Map();
|
|
10270
|
+
const out = [];
|
|
10271
|
+
for (const t of seed) {
|
|
10272
|
+
const nth = seen.get(t.id) ?? 0;
|
|
10273
|
+
seen.set(t.id, nth + 1);
|
|
10274
|
+
if (!had.has(t.id)) out.push({ test: t, nth });
|
|
10275
|
+
}
|
|
10276
|
+
return out;
|
|
10277
|
+
}
|
|
10278
|
+
function ownTestFloor(input) {
|
|
10279
|
+
try {
|
|
10280
|
+
const seedTests = findTests(input.path, input.seed);
|
|
10281
|
+
const afterTests = findTests(input.path, input.after);
|
|
10282
|
+
if (!seedTests || seedTests.length === 0 || !afterTests) return { ok: true };
|
|
10283
|
+
const baseTests = input.baseline === "" ? [] : findTests(input.path, input.baseline);
|
|
10284
|
+
if (!baseTests) return { ok: true };
|
|
10285
|
+
const own = ownTestsOf(seedTests, baseTests);
|
|
10286
|
+
if (!own || own.length === 0) return { ok: true };
|
|
10287
|
+
const after = groupById(afterTests);
|
|
10288
|
+
const before = input.before !== void 0 ? findTests(input.path, input.before) : null;
|
|
10289
|
+
const beforeById = before ? groupById(before) : null;
|
|
10290
|
+
for (const { test, nth } of own) {
|
|
10291
|
+
const found = after.get(test.id)?.[nth];
|
|
10292
|
+
const line = beforeById?.get(test.id)?.[nth]?.line ?? test.line;
|
|
10293
|
+
if (!found) return { ok: false, why: "test_removed", line };
|
|
10294
|
+
if (found.skipped && !test.skipped || found.checks < test.checks) return { ok: false, why: "test_emptied", line };
|
|
10295
|
+
}
|
|
10296
|
+
return { ok: true };
|
|
10297
|
+
} catch {
|
|
10298
|
+
return { ok: true };
|
|
10299
|
+
}
|
|
10300
|
+
}
|
|
10301
|
+
function ownTestMessage(why, line) {
|
|
10302
|
+
const keep = "Correct its expectation instead, and keep its name, its [id] and a real check of the case.";
|
|
10303
|
+
if (why === "test_removed") return `Your edit removes a test that was written earlier in this run (line ${line}). ${keep}`;
|
|
10304
|
+
return `Your edit leaves a test that was written earlier in this run with fewer checks, or skips it (line ${line}). ${keep}`;
|
|
10305
|
+
}
|
|
10306
|
+
var MAX_PATHS = 10;
|
|
10307
|
+
var MAX_LINES = 20;
|
|
10308
|
+
function correctedOwnTests(input) {
|
|
10309
|
+
const keptByPath = new Map(input.kept.map((r) => [r.targetPath, r.newContent]));
|
|
10310
|
+
const out = [];
|
|
10311
|
+
for (const f of input.final) {
|
|
10312
|
+
try {
|
|
10313
|
+
const keptText = keptByPath.get(f.targetPath);
|
|
10314
|
+
if (keptText === void 0) continue;
|
|
10315
|
+
const keptTests = findTests(f.targetPath, keptText);
|
|
10316
|
+
const finalTests = findTests(f.targetPath, f.newContent);
|
|
10317
|
+
const baseText = input.baselineOf(f.targetPath);
|
|
10318
|
+
const baseTests = baseText === null || baseText === "" ? [] : findTests(f.targetPath, baseText);
|
|
10319
|
+
if (!keptTests || !finalTests || !baseTests) continue;
|
|
10320
|
+
const own = ownTestsOf(keptTests, baseTests);
|
|
10321
|
+
if (!own) continue;
|
|
10322
|
+
const finalById = groupById(finalTests);
|
|
10323
|
+
const lines = own.map(({ test, nth }) => ({ test, found: finalById.get(test.id)?.[nth] })).filter((x) => x.found !== void 0 && x.found.text !== x.test.text).map((x) => x.found.line).sort((a, b) => a - b).slice(0, MAX_LINES);
|
|
10324
|
+
if (lines.length > 0) out.push({ path: f.targetPath, lines });
|
|
10325
|
+
} catch {
|
|
10326
|
+
}
|
|
10327
|
+
}
|
|
10328
|
+
return out.sort((a, b) => a.path.localeCompare(b.path)).slice(0, MAX_PATHS);
|
|
10329
|
+
}
|
|
10330
|
+
|
|
10183
10331
|
// src/nameScope.ts
|
|
10184
10332
|
var estraverse4 = __toESM(require_estraverse());
|
|
10185
10333
|
|
|
@@ -11825,6 +11973,7 @@ function createCodegenWorkspace(args) {
|
|
|
11825
11973
|
if (key.startsWith("read_file:") || key.startsWith("grep:") || key.startsWith("list_files:")) ledger.seen.delete(key);
|
|
11826
11974
|
}
|
|
11827
11975
|
};
|
|
11976
|
+
const seedTexts = /* @__PURE__ */ new Map();
|
|
11828
11977
|
for (const kept of args.seed ?? []) {
|
|
11829
11978
|
const n = normaliseToolPath(kept.targetPath);
|
|
11830
11979
|
if (!n.ok || matchesDeniedPath(n.path, args.deniedPaths)) throw new SeedRefused();
|
|
@@ -11833,8 +11982,10 @@ function createCodegenWorkspace(args) {
|
|
|
11833
11982
|
if (!loaded.ok) throw new SeedRefused();
|
|
11834
11983
|
const text = kept.newContent.charCodeAt(0) === 65279 ? kept.newContent.slice(1) : kept.newContent;
|
|
11835
11984
|
overlay.setEdited(n.path, toLf(text), { ending: loaded.ending, bom: loaded.bom, originalLf: loaded.lf });
|
|
11985
|
+
seedTexts.set(n.path, toLf(text));
|
|
11836
11986
|
} else {
|
|
11837
11987
|
overlay.setCreated(n.path, toLf(kept.newContent));
|
|
11988
|
+
seedTexts.set(n.path, toLf(kept.newContent));
|
|
11838
11989
|
noteCreated(n.path);
|
|
11839
11990
|
}
|
|
11840
11991
|
}
|
|
@@ -11897,6 +12048,11 @@ function createCodegenWorkspace(args) {
|
|
|
11897
12048
|
return { result: { status: "protected", reason: answer.reason, message: answer.message } };
|
|
11898
12049
|
}
|
|
11899
12050
|
}
|
|
12051
|
+
const seeded = seedTexts.get(path);
|
|
12052
|
+
if (seeded !== void 0) {
|
|
12053
|
+
const floor = ownTestFloor({ path, baseline: overlay.isCreated(path) ? "" : base.originalLf, seed: seeded, after: applied.content, before: lf });
|
|
12054
|
+
if (!floor.ok) return { result: { status: "protected", reason: floor.why, message: ownTestMessage(floor.why, floor.line) } };
|
|
12055
|
+
}
|
|
11900
12056
|
overlay.setEdited(path, applied.content, base);
|
|
11901
12057
|
cl.writeChars += replace.length;
|
|
11902
12058
|
edits.set(path, (edits.get(path) ?? 0) + 1);
|
|
@@ -11932,6 +12088,11 @@ function createCodegenWorkspace(args) {
|
|
|
11932
12088
|
return { result: { status: "budget_exhausted", reason: "write_chars", message: "The limit on text written has been reached; finish with what you have." } };
|
|
11933
12089
|
}
|
|
11934
12090
|
const lf = toLf(content);
|
|
12091
|
+
const seeded = seedTexts.get(path);
|
|
12092
|
+
if (seeded !== void 0) {
|
|
12093
|
+
const floor = ownTestFloor({ path, baseline: "", seed: seeded, after: lf, before: overlay.get(path)?.lf });
|
|
12094
|
+
if (!floor.ok) return { result: { status: "protected", reason: floor.why, message: ownTestMessage(floor.why, floor.line) } };
|
|
12095
|
+
}
|
|
11935
12096
|
overlay.setCreated(path, lf);
|
|
11936
12097
|
noteCreated(path);
|
|
11937
12098
|
cl.writeChars += content.length;
|
|
@@ -12678,6 +12839,7 @@ var MESSAGES = {
|
|
|
12678
12839
|
tests_unavailable: "The tests could not be run here.",
|
|
12679
12840
|
tests_too_slow: "This project's test suite is too slow to run inside this loop."
|
|
12680
12841
|
};
|
|
12842
|
+
var TESTS_FAILED_NO_OLD_TEST_BROKE = "Some tests failed. No test that passed before your change fails now: the failures counted in newFailures are tests that were not in the test run before your change. For a test you wrote in this run, messages gives the first line of why it failed.";
|
|
12681
12843
|
var sha = (s) => (0, import_node_crypto2.createHash)("sha256").update(s).digest("hex");
|
|
12682
12844
|
function firstLine(text) {
|
|
12683
12845
|
const line = text.split(LINE_BREAK).map((l) => l.replace(CONTROL_CHARS, "").trim()).find((l) => l.length > 0);
|
|
@@ -12761,7 +12923,7 @@ function testAnswerFrom(args) {
|
|
|
12761
12923
|
timedOut: false,
|
|
12762
12924
|
truncated: ordered.length > names.length
|
|
12763
12925
|
};
|
|
12764
|
-
return { output, failingKey: failingKeyOf(ordered, messages, failed), messageCount };
|
|
12926
|
+
return { output, failingKey: failingKeyOf(ordered, messages, failed), messageCount, comparable: Boolean(args.baseline?.results) };
|
|
12765
12927
|
}
|
|
12766
12928
|
var RunTestsTool = class {
|
|
12767
12929
|
constructor(deps) {
|
|
@@ -12795,7 +12957,7 @@ var RunTestsTool = class {
|
|
|
12795
12957
|
name: RUN_TESTS_TOOL,
|
|
12796
12958
|
status,
|
|
12797
12959
|
...parts.reason ? { reason: parts.reason } : {},
|
|
12798
|
-
message: MESSAGES[status] ?? "",
|
|
12960
|
+
message: parts.ownOnly === true ? TESTS_FAILED_NO_OLD_TEST_BROKE : MESSAGES[status] ?? "",
|
|
12799
12961
|
...parts.output !== void 0 ? { output: parts.output } : {}
|
|
12800
12962
|
};
|
|
12801
12963
|
if (status !== "no_change_since_last_run" && status !== "tests_exhausted") {
|
|
@@ -12824,6 +12986,8 @@ var RunTestsTool = class {
|
|
|
12824
12986
|
newFailures: entry.newFailures,
|
|
12825
12987
|
// How many failure messages the AI was shown: a COUNT, never the text.
|
|
12826
12988
|
messages: parts.messageCount ?? 0,
|
|
12989
|
+
// Whether the answer said that no old test broke (a flag, never a name): so the effect of saying it can be counted.
|
|
12990
|
+
ownOnly: parts.ownOnly === true,
|
|
12827
12991
|
timedOut: entry.timedOut,
|
|
12828
12992
|
seconds: entry.seconds
|
|
12829
12993
|
});
|
|
@@ -12896,7 +13060,7 @@ var RunTestsTool = class {
|
|
|
12896
13060
|
this.lastFailingKey = null;
|
|
12897
13061
|
return this.answer(callId, "no_report", { seconds });
|
|
12898
13062
|
}
|
|
12899
|
-
const { output, failingKey, messageCount } = testAnswerFrom({
|
|
13063
|
+
const { output, failingKey, messageCount, comparable } = testAnswerFrom({
|
|
12900
13064
|
baseline: baseline?.snapshot ?? null,
|
|
12901
13065
|
after: ran.snapshot,
|
|
12902
13066
|
changedPaths: files.map((f) => f.path),
|
|
@@ -12910,7 +13074,8 @@ var RunTestsTool = class {
|
|
|
12910
13074
|
return this.answer(callId, "no_progress", { output, counts, seconds, messageCount });
|
|
12911
13075
|
}
|
|
12912
13076
|
this.lastFailingKey = failingKey;
|
|
12913
|
-
|
|
13077
|
+
const ownOnly = comparable && output.regressions === 0 && output.newFailures > 0;
|
|
13078
|
+
return this.answer(callId, green ? "tests_passed" : "tests_failed", { output, counts, seconds, messageCount, ownOnly });
|
|
12914
13079
|
}
|
|
12915
13080
|
};
|
|
12916
13081
|
async function executeRunTestsCall(call, tool, ledger, limits) {
|
|
@@ -13393,6 +13558,36 @@ async function runCodegenLoop(args, deps) {
|
|
|
13393
13558
|
if (!fits) throw new CodegenLoopFailure("token_ceiling");
|
|
13394
13559
|
return reason;
|
|
13395
13560
|
};
|
|
13561
|
+
const handOverRefusal = (turn, quiet) => {
|
|
13562
|
+
const changed = overlay.changedPaths();
|
|
13563
|
+
if (changed.length === 0 || changed.length === seededText.size && changed.every((p) => seededText.get(p) === overlay.get(p)?.lf)) {
|
|
13564
|
+
return new CodegenLoopFailure("no_writes");
|
|
13565
|
+
}
|
|
13566
|
+
const texts = changed.map((p) => overlay.get(p)?.lf ?? "");
|
|
13567
|
+
const missing = args.requiredAutomationIds.filter((id) => !texts.some((t) => t.includes(`[${id}]`)));
|
|
13568
|
+
if (missing.length > 0) {
|
|
13569
|
+
if (!quiet) log({ event: "codegen.loop_refused", turn, reason: "coverage_missing", missing: missing.length });
|
|
13570
|
+
return new CodegenLoopFailure("coverage_missing", void 0, void 0, `${missing.length} required test case(s) not written`, coverageSentence(missing));
|
|
13571
|
+
}
|
|
13572
|
+
const planSteps = args.targets.flatMap((t) => t.planStepsImplemented);
|
|
13573
|
+
for (const path of changed) {
|
|
13574
|
+
const entry = overlay.get(path);
|
|
13575
|
+
if (!entry || entry.created || entry.originalLf === null) continue;
|
|
13576
|
+
const pseudo = { path, kind: "EXISTING", planStepsImplemented: planSteps };
|
|
13577
|
+
const suspect = looksLikeTruncatedRewrite(pseudo, entry.originalLf, entry.lf);
|
|
13578
|
+
if (suspect) {
|
|
13579
|
+
if (!quiet) log({ event: "codegen.loop_refused", turn, reason: "truncation_guard", path });
|
|
13580
|
+
return new CodegenLoopFailure("truncation_guard", void 0, void 0, `${path}: ${suspect}`, truncationSentence(path, suspect));
|
|
13581
|
+
}
|
|
13582
|
+
}
|
|
13583
|
+
const broken = ws.syntaxProblems()[0];
|
|
13584
|
+
if (broken) {
|
|
13585
|
+
if (!quiet) log({ event: "codegen.loop_refused", turn, reason: "syntax_error", path: broken.path, kind: broken.problem.kind, line: broken.problem.line });
|
|
13586
|
+
const sentence = `${broken.path}: ${describeSyntaxProblem(broken.problem)}`;
|
|
13587
|
+
return new CodegenLoopFailure("syntax_error", void 0, void 0, sentence, sentence.slice(0, MAX_PREVIOUS_DETAIL_CHARS));
|
|
13588
|
+
}
|
|
13589
|
+
return null;
|
|
13590
|
+
};
|
|
13396
13591
|
log({ event: "codegen.loop_start", maxTurns: limits.maxTurns, maxToolCalls: limits.maxToolCalls, listingFiles: args.listing.length });
|
|
13397
13592
|
try {
|
|
13398
13593
|
for (let turn = 1; turn <= limits.maxTurns; turn++) {
|
|
@@ -13456,37 +13651,17 @@ async function runCodegenLoop(args, deps) {
|
|
|
13456
13651
|
if (body.outcome === "CANNOT_COMPLETE") {
|
|
13457
13652
|
log({ event: "codegen.loop_turn", turn, outcome: "cannot_complete", requestTokens, elapsedMs: now() - turnStarted, calls: [] });
|
|
13458
13653
|
const said = typeof body.summary === "string" ? body.summary.slice(0, MAX_SUMMARY_CHARS) : void 0;
|
|
13654
|
+
const last = lastTestAnswer;
|
|
13655
|
+
if (args.keepOnGiveUp === true && last !== void 0 && last.regressions + last.newFailures > 0 && handOverRefusal(turn, true) === null) {
|
|
13656
|
+
log({ event: "codegen.loop_kept", files: overlay.changedPaths().length, regressions: last.regressions, newFailures: last.newFailures });
|
|
13657
|
+
return { results: overlay.results(), summary: snapshot("gave_up_kept"), doneSummary: said ?? "", gaveUp: true };
|
|
13658
|
+
}
|
|
13459
13659
|
throw new CodegenLoopFailure("cannot_complete", void 0, void 0, said, said);
|
|
13460
13660
|
}
|
|
13461
13661
|
if (body.outcome === "DONE") {
|
|
13462
13662
|
log({ event: "codegen.loop_turn", turn, outcome: "done", requestTokens, elapsedMs: now() - turnStarted, calls: [] });
|
|
13463
|
-
const
|
|
13464
|
-
if (
|
|
13465
|
-
throw new CodegenLoopFailure("no_writes");
|
|
13466
|
-
}
|
|
13467
|
-
const texts = changed.map((p) => overlay.get(p)?.lf ?? "");
|
|
13468
|
-
const missing = args.requiredAutomationIds.filter((id) => !texts.some((t) => t.includes(`[${id}]`)));
|
|
13469
|
-
if (missing.length > 0) {
|
|
13470
|
-
log({ event: "codegen.loop_refused", turn, reason: "coverage_missing", missing: missing.length });
|
|
13471
|
-
throw new CodegenLoopFailure("coverage_missing", void 0, void 0, `${missing.length} required test case(s) not written`, coverageSentence(missing));
|
|
13472
|
-
}
|
|
13473
|
-
const planSteps = args.targets.flatMap((t) => t.planStepsImplemented);
|
|
13474
|
-
for (const path of changed) {
|
|
13475
|
-
const entry = overlay.get(path);
|
|
13476
|
-
if (!entry || entry.created || entry.originalLf === null) continue;
|
|
13477
|
-
const pseudo = { path, kind: "EXISTING", planStepsImplemented: planSteps };
|
|
13478
|
-
const suspect = looksLikeTruncatedRewrite(pseudo, entry.originalLf, entry.lf);
|
|
13479
|
-
if (suspect) {
|
|
13480
|
-
log({ event: "codegen.loop_refused", turn, reason: "truncation_guard", path });
|
|
13481
|
-
throw new CodegenLoopFailure("truncation_guard", void 0, void 0, `${path}: ${suspect}`, truncationSentence(path, suspect));
|
|
13482
|
-
}
|
|
13483
|
-
}
|
|
13484
|
-
const broken = ws.syntaxProblems()[0];
|
|
13485
|
-
if (broken) {
|
|
13486
|
-
log({ event: "codegen.loop_refused", turn, reason: "syntax_error", path: broken.path, kind: broken.problem.kind, line: broken.problem.line });
|
|
13487
|
-
const sentence = `${broken.path}: ${describeSyntaxProblem(broken.problem)}`;
|
|
13488
|
-
throw new CodegenLoopFailure("syntax_error", void 0, void 0, sentence, sentence.slice(0, MAX_PREVIOUS_DETAIL_CHARS));
|
|
13489
|
-
}
|
|
13663
|
+
const refusal = handOverRefusal(turn, false);
|
|
13664
|
+
if (refusal) throw refusal;
|
|
13490
13665
|
const stopReason = isFinal ? `forced_${finalReason}` : "model_done";
|
|
13491
13666
|
const doneSummary = typeof body.summary === "string" ? body.summary.slice(0, MAX_SUMMARY_CHARS) : "";
|
|
13492
13667
|
log({ event: "codegen.loop_done", turns, toolCalls: ledger.toolCalls, edits: ws.edits.size, created: ws.created.size, stopReason });
|
|
@@ -13626,7 +13801,8 @@ function buildCodegenLoopArgs(p, context = collectLoopContext({ targets: p.targe
|
|
|
13626
13801
|
protectedTestPaths,
|
|
13627
13802
|
// The files already shown are evidence for the parse check that the project parses (`syntaxCheck.ts`).
|
|
13628
13803
|
syntaxSeed: context.entries.map((e) => ({ path: e.path, text: e.content })),
|
|
13629
|
-
...p.mode === "loop-tests" && p.tests ? { tests: p.tests } : {}
|
|
13804
|
+
...p.mode === "loop-tests" && p.tests ? { tests: p.tests } : {},
|
|
13805
|
+
...p.mode === "loop-tests" && p.tests && p.keepOnGiveUp ? { keepOnGiveUp: true } : {}
|
|
13630
13806
|
};
|
|
13631
13807
|
}
|
|
13632
13808
|
var NO_SUMMARY = {
|
|
@@ -13663,6 +13839,10 @@ async function oneTestRunMs(tests) {
|
|
|
13663
13839
|
const limit = testTimeLimitMs(timed?.durationMs ?? null);
|
|
13664
13840
|
return limit === "too_slow" ? MAX_TEST_LIMIT_MS : limit;
|
|
13665
13841
|
}
|
|
13842
|
+
function keptAttempt(n, summary) {
|
|
13843
|
+
return { n, outcome: "kept", reason: "cannot_complete", turns: summary.turns, toolCalls: summary.toolCalls };
|
|
13844
|
+
}
|
|
13845
|
+
var keptWarning = (n) => `The ${n === 1 ? "first" : "second"} attempt said it could not finish, but its change passed every check the AI is held to apart from the project's tests, so QuikPilot kept it and let the checks decide.`;
|
|
13666
13846
|
function failedAttempt(n, failure) {
|
|
13667
13847
|
return { n, outcome: "failed", reason: failure.reason, turns: failure.summary?.turns ?? 0, toolCalls: failure.summary?.toolCalls ?? 0 };
|
|
13668
13848
|
}
|
|
@@ -13724,6 +13904,11 @@ async function runCodegenStep(p) {
|
|
|
13724
13904
|
const first = await attempt2();
|
|
13725
13905
|
const firstMs = now() - firstStarted;
|
|
13726
13906
|
if ("done" in first) {
|
|
13907
|
+
if (first.done.gaveUp) {
|
|
13908
|
+
log({ event: "codegen.attempt_end", attempt: 1, outcome: "kept", reason: "cannot_complete", turns: first.done.summary.turns, toolCalls: first.done.summary.toolCalls, durationMs: firstMs });
|
|
13909
|
+
warn(p, keptWarning(1));
|
|
13910
|
+
return finish(first.done, [keptAttempt(1, first.done.summary)]);
|
|
13911
|
+
}
|
|
13727
13912
|
log({ event: "codegen.attempt_end", attempt: 1, outcome: "finished", turns: first.done.summary.turns, toolCalls: first.done.summary.toolCalls, durationMs: firstMs });
|
|
13728
13913
|
return finish(first.done);
|
|
13729
13914
|
}
|
|
@@ -13759,6 +13944,11 @@ async function runCodegenStep(p) {
|
|
|
13759
13944
|
const second = await attempt2(previous);
|
|
13760
13945
|
const secondMs = now() - secondStarted;
|
|
13761
13946
|
if ("done" in second) {
|
|
13947
|
+
if (second.done.gaveUp) {
|
|
13948
|
+
log({ event: "codegen.attempt_end", attempt: 2, outcome: "kept", reason: "cannot_complete", turns: second.done.summary.turns, toolCalls: second.done.summary.toolCalls, durationMs: secondMs });
|
|
13949
|
+
warn(p, keptWarning(2));
|
|
13950
|
+
return finish(second.done, [firstRecord, keptAttempt(2, second.done.summary)]);
|
|
13951
|
+
}
|
|
13762
13952
|
log({ event: "codegen.attempt_end", attempt: 2, outcome: "finished", turns: second.done.summary.turns, toolCalls: second.done.summary.toolCalls, durationMs: secondMs });
|
|
13763
13953
|
return finish(second.done, [firstRecord, { n: 2, outcome: "finished", turns: second.done.summary.turns, toolCalls: second.done.summary.toolCalls }]);
|
|
13764
13954
|
}
|
|
@@ -13822,7 +14012,9 @@ async function runHealAttempt(i2) {
|
|
|
13822
14012
|
const now = p.deps?.now ?? Date.now;
|
|
13823
14013
|
try {
|
|
13824
14014
|
const done = await runCodegenLoop(
|
|
13825
|
-
|
|
14015
|
+
// `keepOnGiveUp` is off on purpose, whatever the step says: only a first attempt keeps a give-up. A fix that gives up ends as `heal_failed`
|
|
14016
|
+
// with the earlier failure, so a hopeless change cannot be carried from fix to fix.
|
|
14017
|
+
{ ...args, keepOnGiveUp: false, seed: i2.results, previousAttempt: healPreviousAttempt(i2.attempt, i2.answer) },
|
|
13826
14018
|
{
|
|
13827
14019
|
post: (contextData, signal) => postCodegenTurn(p.gateway, contextData, signal),
|
|
13828
14020
|
...p.deps,
|
|
@@ -15124,7 +15316,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
|
|
|
15124
15316
|
var REPORT_COPY = "final-test-report.xml";
|
|
15125
15317
|
var MAX_REPORT_BYTES = 5 * 1024 * 1024;
|
|
15126
15318
|
var MAX_FILES = 200;
|
|
15127
|
-
var RUNNER_VERSION = true ? "9.3.0-rc.
|
|
15319
|
+
var RUNNER_VERSION = true ? "9.3.0-rc.19" : "dev";
|
|
15128
15320
|
function safeDestination(base, repoPath) {
|
|
15129
15321
|
if (!repoPath || (0, import_node_path14.isAbsolute)(repoPath)) return null;
|
|
15130
15322
|
const destination = (0, import_node_path14.resolve)(base, repoPath);
|
|
@@ -15681,6 +15873,7 @@ async function run(env2) {
|
|
|
15681
15873
|
let vanishedTests;
|
|
15682
15874
|
let unsuppliedInputs;
|
|
15683
15875
|
let changesNoTestDependsOn;
|
|
15876
|
+
let testsCorrected;
|
|
15684
15877
|
const contextLog = [];
|
|
15685
15878
|
const codegenOut = {};
|
|
15686
15879
|
let pendingBaseline;
|
|
@@ -15778,8 +15971,10 @@ async function run(env2) {
|
|
|
15778
15971
|
targeting.skippedCases ?? []
|
|
15779
15972
|
);
|
|
15780
15973
|
const codegenMode = resolveCodegenMode();
|
|
15974
|
+
const keepOnGiveUp = codegenMode === "loop-tests" && packet.guardrails.maxHealIterations > 0 && process.env.QUIKPILOT_KEEP_ON_GIVE_UP?.trim().toLowerCase() !== "off";
|
|
15781
15975
|
const stepParams = {
|
|
15782
15976
|
mode: codegenMode,
|
|
15977
|
+
...keepOnGiveUp ? { keepOnGiveUp: true } : {},
|
|
15783
15978
|
tests: {
|
|
15784
15979
|
root: process.cwd(),
|
|
15785
15980
|
command: packet.commands.test,
|
|
@@ -15853,6 +16048,14 @@ async function run(env2) {
|
|
|
15853
16048
|
const suffix = healFailureSuffix(fixed.heal);
|
|
15854
16049
|
throw suffix ? new Error(`${final.error.message}${suffix}`) : final.error;
|
|
15855
16050
|
}
|
|
16051
|
+
if (codegenMode === "loop-tests" && fixed.heal && fixed.heal.made > 0 && process.env.QUIKPILOT_TESTS_CORRECTED?.trim().toLowerCase() !== "off") {
|
|
16052
|
+
try {
|
|
16053
|
+
const files = correctedOwnTests({ kept: results, final: fixed.results, baselineOf: (path) => readCommittedText(process.cwd(), path) });
|
|
16054
|
+
console.log(JSON.stringify({ event: "tests_corrected", files: files.length, tests: files.reduce((n, f) => n + f.lines.length, 0) }));
|
|
16055
|
+
if (files.length > 0) testsCorrected = { files };
|
|
16056
|
+
} catch {
|
|
16057
|
+
}
|
|
16058
|
+
}
|
|
15856
16059
|
if (codegenMode === "loop-tests" && process.env.QUIKPILOT_HUNK_CHECK?.trim().toLowerCase() !== "off") {
|
|
15857
16060
|
const deadlineAtMs = Math.min(jobStopAtMs - HUNK_CHECK_END_BEFORE_STOP_MS, Date.now() + HUNK_CHECK_MAX_MS);
|
|
15858
16061
|
if (deadlineAtMs - Date.now() >= HUNK_CHECK_MIN_BUDGET_MS) {
|
|
@@ -15957,6 +16160,7 @@ async function run(env2) {
|
|
|
15957
16160
|
vanishedTests,
|
|
15958
16161
|
unsuppliedInputs,
|
|
15959
16162
|
changesNoTestDependsOn,
|
|
16163
|
+
testsCorrected,
|
|
15960
16164
|
codegenLoop: codegenOut.loop,
|
|
15961
16165
|
unresolved: failureReasons.length > 0 ? failureReasons : void 0
|
|
15962
16166
|
});
|