@quikit/quikpilot-runner 9.3.0-rc.80 → 9.3.0-rc.82
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 +347 -337
- package/dist/index.js +179 -31
- package/dist/index.js.map +2 -2
- package/package.json +30 -30
package/dist/index.js
CHANGED
|
@@ -38769,7 +38769,7 @@ var REJECT_MESSAGES = {
|
|
|
38769
38769
|
title_not_found: "No test with that title was found in that file. Copy the title exactly as the file writes it. For a test written once for each row of a table, that is the title in the file with its $name or %s placeholders as they are, not the name of one row.",
|
|
38770
38770
|
title_not_unique: "More than one test in that file has that title, so it cannot be told which one you mean.",
|
|
38771
38771
|
no_match: "find was not found in that file. Copy it exactly as read_file shows it.",
|
|
38772
|
-
ambiguous: "find matches more than once in that file. Make it longer so it matches once.",
|
|
38772
|
+
ambiguous: "find matches more than once in that file. Make it longer so it matches once, with lines of this test just before or just after it.",
|
|
38773
38773
|
find_outside_test: "find is not inside that test. It must be lines of that test.",
|
|
38774
38774
|
beyond_expectations: "replace changes more than the test's expected values. Only the expect(...) statements (and the title) may differ from find; the set-up and the call the test makes must stay as they are.",
|
|
38775
38775
|
not_passing_before: "That test did not pass on the code before this run, so it does not assert how the code behaves today. It is not a conflict.",
|
|
@@ -38780,6 +38780,39 @@ var REJECT_MESSAGES = {
|
|
|
38780
38780
|
generated_test: "That test is written once and run for each row of a table (describe.each or it.each), and its rows were not found in the test run made before your change, so it cannot be checked. Do not report it again: answer CANNOT_COMPLETE, and in your summary name the test and the case it contradicts. A person will change it."
|
|
38781
38781
|
};
|
|
38782
38782
|
var OTHER_LANGUAGE_EXPECTATIONS = "In this language only literal values (text, numbers, true/false), assertion statements, comments and the test's name may differ from find; everything else the test does must stay as it is.";
|
|
38783
|
+
var AMBIGUOUS_LINES_SHOWN = 6;
|
|
38784
|
+
var AMBIGUOUS_GROW_MAX = 8;
|
|
38785
|
+
function occurrences2(text3, part, cap2) {
|
|
38786
|
+
const at2 = [];
|
|
38787
|
+
for (let i3 = text3.indexOf(part); i3 !== -1 && at2.length < cap2; i3 = text3.indexOf(part, i3 + 1)) at2.push(i3);
|
|
38788
|
+
return at2;
|
|
38789
|
+
}
|
|
38790
|
+
function ambiguityHint(lf, find, test) {
|
|
38791
|
+
const found = occurrences2(lf, find, 100);
|
|
38792
|
+
if (found.length < 2) return "";
|
|
38793
|
+
const lines = found.map((i3) => lineAt(lf, i3));
|
|
38794
|
+
const shown = lines.slice(0, AMBIGUOUS_LINES_SHOWN).join(", ") + (lines.length > AMBIGUOUS_LINES_SHOWN ? ", ..." : "");
|
|
38795
|
+
const first = test.bodyStartLine ?? test.startLine;
|
|
38796
|
+
const inside3 = found.filter((i3) => lineAt(lf, i3) >= first && lineAt(lf, i3 + find.length - 1) <= test.endLine);
|
|
38797
|
+
const where = `(lines ${shown}).`;
|
|
38798
|
+
if (inside3.length === 0) return `It matches at ${where} None of them is inside that test; the test is at lines ${test.startLine} to ${test.endLine}.`;
|
|
38799
|
+
if (inside3.length > 1) return `It matches ${where} It matches more than once inside this test, so no extra line from the test can tell the copies apart; copy the lines of the one you mean together with what stands next to it.`;
|
|
38800
|
+
const at2 = inside3[0];
|
|
38801
|
+
const startLine = lineAt(lf, at2);
|
|
38802
|
+
const endLine = lineAt(lf, at2 + find.length - 1);
|
|
38803
|
+
const starts = [0];
|
|
38804
|
+
for (let i3 = 0; i3 < lf.length; i3++) if (lf.charCodeAt(i3) === 10) starts.push(i3 + 1);
|
|
38805
|
+
const head = `It matches at ${where} The copy in this test is at line ${startLine}.`;
|
|
38806
|
+
for (let k = 1; k <= AMBIGUOUS_GROW_MAX && endLine + k <= test.endLine; k++) {
|
|
38807
|
+
const stop2 = endLine + k < starts.length ? starts[endLine + k] - 1 : lf.length;
|
|
38808
|
+
if (occurrences2(lf, lf.slice(at2, stop2), 2).length === 1) return `${head} Add the next ${k} line(s) after it (up to line ${endLine + k}) so it matches once.`;
|
|
38809
|
+
}
|
|
38810
|
+
for (let k = 1; k <= AMBIGUOUS_GROW_MAX && startLine - k >= first; k++) {
|
|
38811
|
+
const from = starts[startLine - k - 1];
|
|
38812
|
+
if (occurrences2(lf, lf.slice(from, at2 + find.length), 2).length === 1) return `${head} Add the ${k} line(s) before it (from line ${startLine - k}) so it matches once.`;
|
|
38813
|
+
}
|
|
38814
|
+
return `${head} Add lines of this test around it until it matches once.`;
|
|
38815
|
+
}
|
|
38783
38816
|
var NOT_FOUND_LEAD = "The tests in that file are: ";
|
|
38784
38817
|
var NOT_FOUND_TAIL = ". The title is the name of the test function.";
|
|
38785
38818
|
function titlesHint(tests, room = Number.POSITIVE_INFINITY) {
|
|
@@ -39042,7 +39075,10 @@ var TestConflictTool = class {
|
|
|
39042
39075
|
const { t: test, index } = matches[0];
|
|
39043
39076
|
const isTable = index >= located.tests.length;
|
|
39044
39077
|
const applied = applyEdits(lf, [{ find: r.find, replace: r.replace }]);
|
|
39045
|
-
if (!applied.ok)
|
|
39078
|
+
if (!applied.ok) {
|
|
39079
|
+
if (applied.refusals[0]?.kind !== "ambiguous") return this.reject("no_match");
|
|
39080
|
+
return this.reject("ambiguous", helper ? void 0 : ambiguityHint(lf, r.find, test) || void 0);
|
|
39081
|
+
}
|
|
39046
39082
|
const at2 = lf.indexOf(r.find);
|
|
39047
39083
|
const changeLine = lineAt(lf, at2);
|
|
39048
39084
|
const lastLine = lineAt(lf, at2 + r.find.length - 1);
|
|
@@ -40684,6 +40720,7 @@ function parseJUnitOutcomes(xml) {
|
|
|
40684
40720
|
const discoveredFiles = /* @__PURE__ */ new Set();
|
|
40685
40721
|
const discoveredAutomationIds = /* @__PURE__ */ new Set();
|
|
40686
40722
|
let unmappedEntries = 0;
|
|
40723
|
+
const unmappedCases = [];
|
|
40687
40724
|
TESTSUITE_OPEN_RE.lastIndex = 0;
|
|
40688
40725
|
let suiteMatch;
|
|
40689
40726
|
while (suiteMatch = TESTSUITE_OPEN_RE.exec(xml)) {
|
|
@@ -40726,7 +40763,10 @@ function parseJUnitOutcomes(xml) {
|
|
|
40726
40763
|
const file = FILE_ATTR_RE.exec(attrs)?.[1];
|
|
40727
40764
|
if (file) discoveredFiles.add(normalizeSlashes(file));
|
|
40728
40765
|
if (classname && looksLikeFilePath(classname.trim())) discoveredFiles.add(normalizeSlashes(classname));
|
|
40729
|
-
if (!file?.trim() && !(classname && looksLikeFilePath(classname.trim())))
|
|
40766
|
+
if (!file?.trim() && !(classname && looksLikeFilePath(classname.trim()))) {
|
|
40767
|
+
unmappedEntries += 1;
|
|
40768
|
+
unmappedCases.push({ ...classname !== void 0 ? { classname } : {}, name: c.name });
|
|
40769
|
+
}
|
|
40730
40770
|
const bracket = QP_TOKEN_BRACKET_RE.exec(name2)?.[1];
|
|
40731
40771
|
if (bracket) {
|
|
40732
40772
|
discoveredAutomationIds.add(bracket);
|
|
@@ -40735,7 +40775,7 @@ function parseJUnitOutcomes(xml) {
|
|
|
40735
40775
|
if (!seen || RESULT_RANK[result] > RESULT_RANK[seen]) automationIdResults.set(bracket, result);
|
|
40736
40776
|
}
|
|
40737
40777
|
}
|
|
40738
|
-
return { outcomes, automationIdResults, failureText, failureWhere, failureDetail, discoveredFiles, discoveredAutomationIds, unmappedEntries };
|
|
40778
|
+
return { outcomes, automationIdResults, failureText, failureWhere, failureDetail, discoveredFiles, discoveredAutomationIds, unmappedEntries, unmappedCases };
|
|
40739
40779
|
}
|
|
40740
40780
|
var FRESH_SLACK_MS = 2e3;
|
|
40741
40781
|
function readJUnitOutcomes(cwd, freshSinceMs) {
|
|
@@ -40759,7 +40799,8 @@ function mergeParsed(all) {
|
|
|
40759
40799
|
failureDetail: /* @__PURE__ */ new Map(),
|
|
40760
40800
|
discoveredFiles: /* @__PURE__ */ new Set(),
|
|
40761
40801
|
discoveredAutomationIds: /* @__PURE__ */ new Set(),
|
|
40762
|
-
unmappedEntries: 0
|
|
40802
|
+
unmappedEntries: 0,
|
|
40803
|
+
unmappedCases: []
|
|
40763
40804
|
};
|
|
40764
40805
|
for (const p of all) {
|
|
40765
40806
|
for (const [id, passed] of p.outcomes) out2.outcomes.set(id, (out2.outcomes.get(id) ?? true) && passed);
|
|
@@ -40773,6 +40814,7 @@ function mergeParsed(all) {
|
|
|
40773
40814
|
for (const f of p.discoveredFiles) out2.discoveredFiles.add(f);
|
|
40774
40815
|
for (const id of p.discoveredAutomationIds) out2.discoveredAutomationIds.add(id);
|
|
40775
40816
|
out2.unmappedEntries += p.unmappedEntries;
|
|
40817
|
+
out2.unmappedCases.push(...p.unmappedCases);
|
|
40776
40818
|
}
|
|
40777
40819
|
return out2;
|
|
40778
40820
|
}
|
|
@@ -40788,7 +40830,8 @@ function snapshotOf(outcome, parsed) {
|
|
|
40788
40830
|
failureDetail: parsed?.failureDetail,
|
|
40789
40831
|
discoveredFiles: parsed?.discoveredFiles ?? null,
|
|
40790
40832
|
discoveredAutomationIds: parsed?.discoveredAutomationIds ?? null,
|
|
40791
|
-
unmappedEntries: parsed?.unmappedEntries
|
|
40833
|
+
unmappedEntries: parsed?.unmappedEntries,
|
|
40834
|
+
unmappedCases: parsed?.unmappedCases
|
|
40792
40835
|
};
|
|
40793
40836
|
}
|
|
40794
40837
|
async function captureLimited(command, cwd, limitMs) {
|
|
@@ -40811,7 +40854,8 @@ function captureTestSnapshot(command, cwd = process.cwd(), opts) {
|
|
|
40811
40854
|
failureDetail: parsed?.failureDetail,
|
|
40812
40855
|
discoveredFiles: parsed?.discoveredFiles ?? null,
|
|
40813
40856
|
discoveredAutomationIds: parsed?.discoveredAutomationIds ?? null,
|
|
40814
|
-
unmappedEntries: parsed?.unmappedEntries
|
|
40857
|
+
unmappedEntries: parsed?.unmappedEntries,
|
|
40858
|
+
unmappedCases: parsed?.unmappedCases
|
|
40815
40859
|
};
|
|
40816
40860
|
}
|
|
40817
40861
|
function readTestSnapshot(outcome, cwd = process.cwd(), freshSinceMs) {
|
|
@@ -40824,7 +40868,8 @@ function readTestSnapshot(outcome, cwd = process.cwd(), freshSinceMs) {
|
|
|
40824
40868
|
failureDetail: parsed?.failureDetail,
|
|
40825
40869
|
discoveredFiles: parsed?.discoveredFiles ?? null,
|
|
40826
40870
|
discoveredAutomationIds: parsed?.discoveredAutomationIds ?? null,
|
|
40827
|
-
unmappedEntries: parsed?.unmappedEntries
|
|
40871
|
+
unmappedEntries: parsed?.unmappedEntries,
|
|
40872
|
+
unmappedCases: parsed?.unmappedCases
|
|
40828
40873
|
};
|
|
40829
40874
|
}
|
|
40830
40875
|
function readTestSnapshotAt(outcome, reportPath) {
|
|
@@ -40850,7 +40895,8 @@ async function captureBaselineSnapshot(command, cwd = process.cwd(), opts) {
|
|
|
40850
40895
|
failureDetail: parsed?.failureDetail,
|
|
40851
40896
|
discoveredFiles: parsed?.discoveredFiles ?? null,
|
|
40852
40897
|
discoveredAutomationIds: parsed?.discoveredAutomationIds ?? null,
|
|
40853
|
-
unmappedEntries: parsed?.unmappedEntries
|
|
40898
|
+
unmappedEntries: parsed?.unmappedEntries,
|
|
40899
|
+
unmappedCases: parsed?.unmappedCases
|
|
40854
40900
|
};
|
|
40855
40901
|
}
|
|
40856
40902
|
function checkForRegressions(baseline, after) {
|
|
@@ -47261,7 +47307,17 @@ function createCodegenWorkspace(args2) {
|
|
|
47261
47307
|
if (amendable.has(path) && tool === "edit_file") return null;
|
|
47262
47308
|
return { fail: { status: "protected", reason: isTestPath(path) ? "test_frozen" : "code_locked", message: "Only the named failing test may change in this step, and only by edit_file." } };
|
|
47263
47309
|
}
|
|
47264
|
-
|
|
47310
|
+
if (!isTestPath(path)) return null;
|
|
47311
|
+
if (frozen.has(path) && !looksLikeTest(path) && !protectedTests.has(path)) {
|
|
47312
|
+
return {
|
|
47313
|
+
fail: {
|
|
47314
|
+
status: "protected",
|
|
47315
|
+
reason: "test_frozen",
|
|
47316
|
+
message: `If the code must change in ${path}, answer CANNOT_COMPLETE and name it: it is frozen in this phase because phase 1 wrote this change's test cases into it.`
|
|
47317
|
+
}
|
|
47318
|
+
};
|
|
47319
|
+
}
|
|
47320
|
+
return { fail: { status: "protected", reason: "test_frozen", message: "The tests are frozen in this phase: change the code, not the tests." } };
|
|
47265
47321
|
};
|
|
47266
47322
|
const edits = /* @__PURE__ */ new Map();
|
|
47267
47323
|
const created = /* @__PURE__ */ new Map();
|
|
@@ -49418,8 +49474,8 @@ function partMissingSentence(missing, opts = {}) {
|
|
|
49418
49474
|
var MAX_NAMES = 2;
|
|
49419
49475
|
var MAX_HINT_CHARS = 300;
|
|
49420
49476
|
var MIN_NAME_CHARS = 8;
|
|
49421
|
-
var SAME_FAILURE_TAIL = " If it should now pass, check the code; if
|
|
49422
|
-
var SAME_FAILURE_TAIL_SHORT = " If it should now pass, check the code; if
|
|
49477
|
+
var SAME_FAILURE_TAIL = " If it should now pass, check the code; if the test itself looks wrong (say, a 500 from set-up it lacks), name it in CANNOT_COMPLETE.";
|
|
49478
|
+
var SAME_FAILURE_TAIL_SHORT = " If it should now pass, check the code; if the test itself looks wrong, name it in CANNOT_COMPLETE.";
|
|
49423
49479
|
var collapse = (text3) => text3.replace(/\s+/g, " ").trim();
|
|
49424
49480
|
var line = (text3) => collapse(
|
|
49425
49481
|
(text3.split("\n").find((l) => l.trim() !== "") ?? "").replace(/\s*\[at [^\]]*\]/g, "")
|
|
@@ -49519,6 +49575,8 @@ var CodegenLoopFailure = class extends Error {
|
|
|
49519
49575
|
featureKey;
|
|
49520
49576
|
/** QUIKTR-2445: the AI Runtime refused a request that carried `databaseChange` (the step then stops `needs_database_change`). */
|
|
49521
49577
|
databaseKey;
|
|
49578
|
+
/** QUIKTR-2468: the refusal came on a later turn, not the loop's first request: about that request, never the version. */
|
|
49579
|
+
late;
|
|
49522
49580
|
constructor(reason, runtimeCode, cause, detail, told) {
|
|
49523
49581
|
super(`pilot.codegen loop failed: ${reason}${runtimeCode ? ` (${runtimeCode})` : ""}`);
|
|
49524
49582
|
this.name = "CodegenLoopFailure";
|
|
@@ -50097,16 +50155,21 @@ async function runCodegenLoop(args2, deps) {
|
|
|
50097
50155
|
checkHardFailure(envelope, "pilot.codegen");
|
|
50098
50156
|
} catch (err2) {
|
|
50099
50157
|
if (code === "CONTRACT_REJECTED") {
|
|
50100
|
-
const
|
|
50101
|
-
const rule = typeof
|
|
50102
|
-
const text3 = rule || (typeof
|
|
50158
|
+
const said2 = envelope;
|
|
50159
|
+
const rule = typeof said2?.normalizedText === "string" && said2.normalizedText.trim() ? said2.normalizedText : "";
|
|
50160
|
+
const text3 = rule || (typeof said2?.error === "string" ? said2.error : "");
|
|
50103
50161
|
const reason = text3.trim() ? firstLine(scrub(text3), void 0, 300) : "";
|
|
50104
50162
|
const version2 = contextData.contractVersion;
|
|
50105
|
-
log({ event: "codegen.contract_rejected", turn, ...typeof version2 === "string" ? { version: version2 } : {}, ...reason ? { reason } : {} });
|
|
50163
|
+
log({ event: "codegen.contract_rejected", turn, ...typeof version2 === "string" ? { version: version2 } : {}, ...reason ? { reason } : {}, ...turn > 1 || args2.lane?.kind === "code" ? { late: true } : {} });
|
|
50106
50164
|
}
|
|
50107
50165
|
const failure = new CodegenLoopFailure(code === "CONTRACT_REJECTED" ? "contract_rejected" : "semantic_mismatch", String(code), err2);
|
|
50108
|
-
|
|
50109
|
-
if (
|
|
50166
|
+
const late = code === "CONTRACT_REJECTED" && (turn > 1 || args2.lane?.kind === "code");
|
|
50167
|
+
if (late) failure.late = true;
|
|
50168
|
+
const said = envelope;
|
|
50169
|
+
const refusalText = `${typeof said?.normalizedText === "string" ? said.normalizedText : ""} ${typeof said?.error === "string" ? said.error : ""}`;
|
|
50170
|
+
const blames = (key) => !late || refusalText.includes(key);
|
|
50171
|
+
if (code === "CONTRACT_REJECTED" && contextData[FEATURE_TEST_UPDATES_KEY] === true && blames(FEATURE_TEST_UPDATES_KEY)) failure.featureKey = true;
|
|
50172
|
+
if (code === "CONTRACT_REJECTED" && contextData[DATABASE_CHANGE_KEY] !== void 0 && blames(DATABASE_CHANGE_KEY)) failure.databaseKey = true;
|
|
50110
50173
|
throw failure;
|
|
50111
50174
|
}
|
|
50112
50175
|
if (envelope?.success === false) {
|
|
@@ -52038,37 +52101,37 @@ async function runCodegenStep(p) {
|
|
|
52038
52101
|
if ("failure" in first && first.failure.reason === "contract_rejected" && first.failure.databaseKey === true && p.databaseChange && p.databaseChange.length > 0) {
|
|
52039
52102
|
throw databaseStop(first.failure, "key_refused");
|
|
52040
52103
|
}
|
|
52041
|
-
if ("failure" in first && first.failure.reason === "contract_rejected" && p.runScratch && args2?.runScratch) {
|
|
52104
|
+
if ("failure" in first && first.failure.reason === "contract_rejected" && first.failure.late !== true && p.runScratch && args2?.runScratch) {
|
|
52042
52105
|
log({ event: "codegen.version_fallback", from: "codegen-loop-9", to: "codegen-loop-8" });
|
|
52043
52106
|
p.runScratch = void 0;
|
|
52044
52107
|
args2 = buildCodegenLoopArgs(p, context);
|
|
52045
52108
|
first = await attempt2();
|
|
52046
52109
|
}
|
|
52047
|
-
if ("failure" in first && first.failure.reason === "contract_rejected" && p.fixFirst === true && args2?.fixFirst === true) {
|
|
52110
|
+
if ("failure" in first && first.failure.reason === "contract_rejected" && first.failure.late !== true && p.fixFirst === true && args2?.fixFirst === true) {
|
|
52048
52111
|
log({ event: "codegen.version_fallback", from: "codegen-loop-8", to: "codegen-loop-7" });
|
|
52049
52112
|
p.fixFirst = false;
|
|
52050
52113
|
args2 = buildCodegenLoopArgs(p, context);
|
|
52051
52114
|
first = await attempt2();
|
|
52052
52115
|
}
|
|
52053
|
-
if ("failure" in first && first.failure.reason === "contract_rejected" && p.conflicts && args2?.conflicts) {
|
|
52116
|
+
if ("failure" in first && first.failure.reason === "contract_rejected" && first.failure.late !== true && p.conflicts && args2?.conflicts) {
|
|
52054
52117
|
log({ event: "codegen.version_fallback", from: "codegen-loop-7", to: "codegen-loop-6" });
|
|
52055
52118
|
p.conflicts = void 0;
|
|
52056
52119
|
args2 = buildCodegenLoopArgs(p, context);
|
|
52057
52120
|
first = await attempt2();
|
|
52058
52121
|
}
|
|
52059
|
-
if ("failure" in first && first.failure.reason === "contract_rejected" && p.tools2?.notes === true && args2?.harness === true) {
|
|
52122
|
+
if ("failure" in first && first.failure.reason === "contract_rejected" && first.failure.late !== true && p.tools2?.notes === true && args2?.harness === true) {
|
|
52060
52123
|
log({ event: "codegen.version_fallback", from: "codegen-loop-6", to: "codegen-loop-5" });
|
|
52061
52124
|
p.tools2 = { ...p.tools2, notes: false };
|
|
52062
52125
|
args2 = buildCodegenLoopArgs(p, context);
|
|
52063
52126
|
first = await attempt2();
|
|
52064
52127
|
}
|
|
52065
|
-
if ("failure" in first && first.failure.reason === "contract_rejected" && p.tools2 && args2?.harness === true) {
|
|
52128
|
+
if ("failure" in first && first.failure.reason === "contract_rejected" && first.failure.late !== true && p.tools2 && args2?.harness === true) {
|
|
52066
52129
|
log({ event: "codegen.version_fallback", from: "codegen-loop-5", to: p.scope?.view === "map" ? "codegen-loop-4" : "codegen-loop-3" });
|
|
52067
52130
|
p.tools2 = void 0;
|
|
52068
52131
|
args2 = buildCodegenLoopArgs(p, context);
|
|
52069
52132
|
first = await attempt2();
|
|
52070
52133
|
}
|
|
52071
|
-
if ("failure" in first && first.failure.reason === "contract_rejected" && p.scope?.view === "map") {
|
|
52134
|
+
if ("failure" in first && first.failure.reason === "contract_rejected" && first.failure.late !== true && p.scope?.view === "map") {
|
|
52072
52135
|
const view = repoViewOf(p.scope);
|
|
52073
52136
|
p.out.loop = buildCodegenLoopRecord({
|
|
52074
52137
|
...first.failure.summary ?? NO_SUMMARY,
|
|
@@ -52078,7 +52141,7 @@ async function runCodegenStep(p) {
|
|
|
52078
52141
|
log({ event: "codegen.map_failed", reason: "contract_rejected" });
|
|
52079
52142
|
throw new MapModeError("codegen", "contract_rejected");
|
|
52080
52143
|
}
|
|
52081
|
-
if ("failure" in first && first.failure.reason === "contract_rejected" && args2?.harness === true) {
|
|
52144
|
+
if ("failure" in first && first.failure.reason === "contract_rejected" && first.failure.late !== true && args2?.harness === true) {
|
|
52082
52145
|
if (p.databaseChange && p.databaseChange.length > 0) throw databaseStop(first.failure, "no_harness");
|
|
52083
52146
|
log({ event: "codegen.version_fallback", from: "codegen-loop-3", to: "codegen-loop-2" });
|
|
52084
52147
|
p.harness = false;
|
|
@@ -52098,7 +52161,7 @@ async function runCodegenStep(p) {
|
|
|
52098
52161
|
const f1 = first.failure;
|
|
52099
52162
|
log({ event: "codegen.attempt_end", attempt: 1, outcome: "failed", reason: f1.reason, ...f1.afterRecovery ? { afterRecovery: true } : {}, turns: f1.summary?.turns ?? 0, toolCalls: f1.summary?.toolCalls ?? 0, durationMs: firstMs });
|
|
52100
52163
|
const said = f1.detail ? `: ${f1.detail}` : "";
|
|
52101
|
-
if (f1.reason === "contract_rejected") {
|
|
52164
|
+
if (f1.reason === "contract_rejected" && f1.late !== true) {
|
|
52102
52165
|
p.out.loop = buildCodegenLoopRecord({ ...f1.summary ?? NO_SUMMARY, stopReason: "fallback", fellBack: true, fallbackReason: f1.reason });
|
|
52103
52166
|
warn(p, `The code-writing loop could not finish (${f1.reason}${said}), so the files were written one at a time instead.`);
|
|
52104
52167
|
await guardTree();
|
|
@@ -54117,7 +54180,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
|
|
|
54117
54180
|
var REPORT_COPY = "final-test-report.xml";
|
|
54118
54181
|
var MAX_REPORT_BYTES = 5 * 1024 * 1024;
|
|
54119
54182
|
var MAX_FILES = 200;
|
|
54120
|
-
var RUNNER_VERSION = true ? "9.3.0-rc.
|
|
54183
|
+
var RUNNER_VERSION = true ? "9.3.0-rc.82" : "dev";
|
|
54121
54184
|
function safeDestination(base, repoPath) {
|
|
54122
54185
|
if (!repoPath || (0, import_node_path28.isAbsolute)(repoPath)) return null;
|
|
54123
54186
|
const destination = (0, import_node_path28.resolve)(base, repoPath);
|
|
@@ -54383,7 +54446,9 @@ function buildTestDiscovery(i3) {
|
|
|
54383
54446
|
if (match) found.add(match);
|
|
54384
54447
|
else dropped.add(withoutDotSlash(slashes(raw.trim())));
|
|
54385
54448
|
}
|
|
54386
|
-
const
|
|
54449
|
+
const placed = placeUnmapped(snapshot.unmappedCases ?? [], listing, i3.workspaceRoot, i3.readText);
|
|
54450
|
+
for (const f of placed.files) found.add(f);
|
|
54451
|
+
const unmapped = snapshot.unmappedEntries - placed.count + dropped.size;
|
|
54387
54452
|
const files = [...found].sort();
|
|
54388
54453
|
return {
|
|
54389
54454
|
value: { report: "PRESENT", discoveredTestFiles: files, unmappedEntries: unmapped },
|
|
@@ -54393,6 +54458,76 @@ function buildTestDiscovery(i3) {
|
|
|
54393
54458
|
unmapped
|
|
54394
54459
|
};
|
|
54395
54460
|
}
|
|
54461
|
+
function placeUnmapped(cases, listing, workspaceRoot, readText) {
|
|
54462
|
+
const files = /* @__PURE__ */ new Set();
|
|
54463
|
+
let count3 = 0;
|
|
54464
|
+
if (cases.length === 0) return { files, count: count3 };
|
|
54465
|
+
const root = workspaceRoot ? withoutDotSlash(slashes(workspaceRoot)).replace(/\/+$/, "") : "";
|
|
54466
|
+
const inListing2 = (p) => listing.has(p) ? p : root && listing.has(`${root}/${p}`) ? `${root}/${p}` : null;
|
|
54467
|
+
const isTest = testRule(null);
|
|
54468
|
+
const pythonFile = (classname) => {
|
|
54469
|
+
if (!/^[A-Za-z_][\w.]*$/.test(classname)) return null;
|
|
54470
|
+
const parts2 = classname.split(".");
|
|
54471
|
+
for (let k = parts2.length; k > 0; k--) {
|
|
54472
|
+
const hit = inListing2(`${parts2.slice(0, k).join("/")}.py`);
|
|
54473
|
+
if (hit) return isTest(hit) ? hit : null;
|
|
54474
|
+
}
|
|
54475
|
+
return null;
|
|
54476
|
+
};
|
|
54477
|
+
const texts = /* @__PURE__ */ new Map();
|
|
54478
|
+
const text3 = (p) => {
|
|
54479
|
+
if (!texts.has(p)) texts.set(p, readText ? readText(p) : null);
|
|
54480
|
+
return texts.get(p) ?? null;
|
|
54481
|
+
};
|
|
54482
|
+
const dirOf3 = (p) => p.includes("/") ? p.slice(0, p.lastIndexOf("/")) : "";
|
|
54483
|
+
let modules = null;
|
|
54484
|
+
const goModules = () => {
|
|
54485
|
+
if (modules) return modules;
|
|
54486
|
+
const found = [];
|
|
54487
|
+
for (const p of listing) {
|
|
54488
|
+
if (p !== "go.mod" && !p.endsWith("/go.mod")) continue;
|
|
54489
|
+
const m = /^\s*module\s+"?([^"\s]+)"?/m.exec(text3(p) ?? "");
|
|
54490
|
+
if (m) found.push({ module: m[1], dir: dirOf3(p) });
|
|
54491
|
+
}
|
|
54492
|
+
found.sort((a, b) => b.module.length - a.module.length);
|
|
54493
|
+
modules = found;
|
|
54494
|
+
return found;
|
|
54495
|
+
};
|
|
54496
|
+
let goTests = null;
|
|
54497
|
+
const goTestsIn = (dir) => {
|
|
54498
|
+
if (!goTests) {
|
|
54499
|
+
goTests = /* @__PURE__ */ new Map();
|
|
54500
|
+
for (const p of listing) {
|
|
54501
|
+
if (!p.endsWith("_test.go")) continue;
|
|
54502
|
+
const d = dirOf3(p);
|
|
54503
|
+
goTests.set(d, [...goTests.get(d) ?? [], p]);
|
|
54504
|
+
}
|
|
54505
|
+
}
|
|
54506
|
+
return goTests.get(dir) ?? [];
|
|
54507
|
+
};
|
|
54508
|
+
const goFile = (pkg, name2) => {
|
|
54509
|
+
if (!readText) return null;
|
|
54510
|
+
const owner = goModules().find((m) => pkg === m.module || pkg.startsWith(`${m.module}/`));
|
|
54511
|
+
if (!owner) return null;
|
|
54512
|
+
const rest = pkg === owner.module ? "" : pkg.slice(owner.module.length + 1);
|
|
54513
|
+
const dir = [owner.dir, rest].filter(Boolean).join("/");
|
|
54514
|
+
const fn = name2.split("/")[0] ?? "";
|
|
54515
|
+
if (!/^\w+$/.test(fn)) return null;
|
|
54516
|
+
const declares = new RegExp(`^func\\s+${fn}\\s*\\(`, "m");
|
|
54517
|
+
const hits = goTestsIn(dir).filter((p) => declares.test(text3(p) ?? ""));
|
|
54518
|
+
return hits.length === 1 ? hits[0] : null;
|
|
54519
|
+
};
|
|
54520
|
+
for (const c of cases) {
|
|
54521
|
+
const classname = c.classname?.trim();
|
|
54522
|
+
if (!classname) continue;
|
|
54523
|
+
const hit = pythonFile(classname) ?? goFile(classname, c.name);
|
|
54524
|
+
if (hit) {
|
|
54525
|
+
files.add(hit);
|
|
54526
|
+
count3 += 1;
|
|
54527
|
+
}
|
|
54528
|
+
}
|
|
54529
|
+
return { files, count: count3 };
|
|
54530
|
+
}
|
|
54396
54531
|
var DEFAULT_DISCOVERY_WAIT_MS = 9e4;
|
|
54397
54532
|
var MAX_DISCOVERY_WAIT_MS = 36e5;
|
|
54398
54533
|
function discoveryWaitMs(env2 = process.env) {
|
|
@@ -54416,10 +54551,13 @@ var TIMEOUT_WARNING = "QuikPilot could not list the project's test files in time
|
|
|
54416
54551
|
function lateReportWarning(waitedSeconds, namedTestFiles) {
|
|
54417
54552
|
return `The project's test report was not ready after ${waitedSeconds} seconds, so QuikPilot skipped the early check of where tests are placed. ${namedTestFiles} files look like tests by their names; the names were counted, not used for that check.`;
|
|
54418
54553
|
}
|
|
54554
|
+
function unplacedWarning(tests) {
|
|
54555
|
+
return `The project's test report named ${tests} tests, but QuikPilot could not place any of them on a file, so it skipped the early check of where tests are placed.`;
|
|
54556
|
+
}
|
|
54419
54557
|
async function resolveTestDiscovery(i3) {
|
|
54420
54558
|
const now = i3.now ?? Date.now;
|
|
54421
54559
|
const started = now();
|
|
54422
|
-
const base = { command: i3.command, listing: i3.listing, workspaceRoot: i3.workspaceRoot, cwd: i3.cwd };
|
|
54560
|
+
const base = { command: i3.command, listing: i3.listing, workspaceRoot: i3.workspaceRoot, cwd: i3.cwd, ...i3.readText ? { readText: i3.readText } : {} };
|
|
54423
54561
|
const done = (result, warning) => {
|
|
54424
54562
|
const waitedMs = now() - started;
|
|
54425
54563
|
const named2 = i3.namedTestFiles ?? 0;
|
|
@@ -54442,7 +54580,9 @@ async function resolveTestDiscovery(i3) {
|
|
|
54442
54580
|
const named2 = i3.namedTestFiles ?? 0;
|
|
54443
54581
|
return done(absent("timeout"), named2 > 0 ? lateReportWarning(Math.round(i3.waitMs / 1e3), named2) : TIMEOUT_WARNING);
|
|
54444
54582
|
}
|
|
54445
|
-
|
|
54583
|
+
const built = buildTestDiscovery({ ...base, snapshot: first });
|
|
54584
|
+
const unplaced = first?.unmappedCases?.length ?? 0;
|
|
54585
|
+
return done(built, built.source === "live" && built.files === 0 && unplaced > 0 ? unplacedWarning(unplaced) : void 0);
|
|
54446
54586
|
} finally {
|
|
54447
54587
|
if (timer !== void 0) clearTimeout(timer);
|
|
54448
54588
|
}
|
|
@@ -55021,7 +55161,15 @@ async function run2(env2) {
|
|
|
55021
55161
|
waitMs: discoveryWaitMs(),
|
|
55022
55162
|
// QUIKTR-1854 - how many files look like tests by their names, so a late report is described as what it was.
|
|
55023
55163
|
namedTestFiles: workspaceListing.filter(testRule(null)).length,
|
|
55024
|
-
log: (e) => console.log(JSON.stringify(e))
|
|
55164
|
+
log: (e) => console.log(JSON.stringify(e)),
|
|
55165
|
+
// QUIKTR-2465 item 3: Go's tests are placed by the file that declares them (and go.mod's module). Listing paths are relative to the checkout.
|
|
55166
|
+
readText: (p) => {
|
|
55167
|
+
try {
|
|
55168
|
+
return (0, import_node_fs29.readFileSync)(p, "utf8");
|
|
55169
|
+
} catch {
|
|
55170
|
+
return null;
|
|
55171
|
+
}
|
|
55172
|
+
}
|
|
55025
55173
|
});
|
|
55026
55174
|
const settledBaseline = discovery.result.reason === "timeout" || discovery.result.reason === "no_command" ? void 0 : await baselineRun.then((b) => b.snapshot, () => null);
|
|
55027
55175
|
const twoPhaseSkip = twoPhaseSkipReason(discovery.result.reason, settledBaseline);
|