@quikit/quikpilot-runner 9.3.0-rc.46 → 9.3.0-rc.48

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/dist/index.js CHANGED
@@ -26434,7 +26434,7 @@ pp$8.enterClassBody = function() {
26434
26434
  };
26435
26435
  pp$8.exitClassBody = function() {
26436
26436
  var ref2 = this.privateNameStack.pop();
26437
- var declared = ref2.declared;
26437
+ var declared2 = ref2.declared;
26438
26438
  var used = ref2.used;
26439
26439
  if (!this.options.checkPrivateFields) {
26440
26440
  return;
@@ -26443,7 +26443,7 @@ pp$8.exitClassBody = function() {
26443
26443
  var parent = len === 0 ? null : this.privateNameStack[len - 1];
26444
26444
  for (var i2 = 0; i2 < used.length; ++i2) {
26445
26445
  var id = used[i2];
26446
- if (!hasOwn(declared, id.name)) {
26446
+ if (!hasOwn(declared2, id.name)) {
26447
26447
  if (parent) {
26448
26448
  parent.used.push(id);
26449
26449
  } else {
@@ -32817,7 +32817,8 @@ var TestConflictTool = class {
32817
32817
  async check(r) {
32818
32818
  const d = this.deps;
32819
32819
  const key = `${r.path}\0${r.testTitle}`;
32820
- if (d.decided.some((x) => sameFile(x.path, r.path) && x.title === r.testTitle)) return this.reject("already_decided");
32820
+ const revision = d.revisable?.find((x) => sameFile(x.path, r.path) && x.title === r.testTitle);
32821
+ if (!revision && d.decided.some((x) => sameFile(x.path, r.path) && x.title === r.testTitle)) return this.reject("already_decided");
32821
32822
  if (!this.byTest.has(key) && this.byTest.size >= this.max) return this.reject("too_many_conflicts");
32822
32823
  const path = normaliseToolPath(r.path);
32823
32824
  if (!path.ok || !d.existingTests.has(path.path) || !insideWriteRoot(path.path, d.writeRoot) || matchesDeniedPath(path.path, d.deniedPaths) !== null) {
@@ -32825,20 +32826,22 @@ var TestConflictTool = class {
32825
32826
  }
32826
32827
  const loaded = loadTextForEdit(d.fs, path.path, d.fileBytesMax);
32827
32828
  if (!loaded.ok) return this.reject("not_existing_test");
32828
- const located = locateTests(path.path, loaded.lf);
32829
+ const lf = revision ? revision.text : loaded.lf;
32830
+ const located = locateTests(path.path, lf);
32829
32831
  if (!located) return this.reject("unsupported_language");
32830
32832
  const matches = allTests(located).map((t, index2) => ({ t, index: index2 })).filter(({ t }) => t.title === r.testTitle);
32831
32833
  if (matches.length === 0) return this.reject("title_not_found");
32832
32834
  if (matches.length > 1) return this.reject("title_not_unique");
32833
32835
  const { t: test, index } = matches[0];
32834
32836
  const isTable = index >= located.tests.length;
32835
- const applied = applyEdits(loaded.lf, [{ find: r.find, replace: r.replace }]);
32837
+ const applied = applyEdits(lf, [{ find: r.find, replace: r.replace }]);
32836
32838
  if (!applied.ok) return this.reject(applied.refusals[0]?.kind === "ambiguous" ? "ambiguous" : "no_match");
32837
- const at2 = loaded.lf.indexOf(r.find);
32838
- const changeLine = lineAt(loaded.lf, at2);
32839
- const lastLine = lineAt(loaded.lf, at2 + r.find.length - 1);
32839
+ const at2 = lf.indexOf(r.find);
32840
+ const changeLine = lineAt(lf, at2);
32841
+ const lastLine = lineAt(lf, at2 + r.find.length - 1);
32840
32842
  if (changeLine < (test.bodyStartLine ?? test.startLine) || lastLine > test.endLine) return this.reject("find_outside_test");
32841
- if (testEditOverreach({ path: path.path, before: loaded.lf, after: applied.content, indexes: [index] }) !== null) return this.reject("beyond_expectations");
32843
+ if (testEditOverreach({ path: path.path, before: lf, after: applied.content, indexes: [index] }) !== null) return this.reject("beyond_expectations");
32844
+ if (revision) return this.recordRevision(r, revision, { path: path.path, test, index, isTable, changeLine, lf, ending: loaded.ending, bom: loaded.bom }, key);
32842
32845
  const base = await d.baseline().catch(() => null);
32843
32846
  const results = base?.snapshot.results ?? null;
32844
32847
  if (!base || base.snapshot.timedOut === true || !results) return this.reject("baseline_unknown");
@@ -32875,6 +32878,34 @@ var TestConflictTool = class {
32875
32878
  d.log?.({ event: "codegen.conflict_recorded", reading: r.reading, phase: d.phase ?? null, historyAvailable: history.available, ...isTable ? { rows: mine.length } : {} });
32876
32879
  return { status: "conflict_recorded", message: RECORDED_MESSAGE, output: { history } };
32877
32880
  }
32881
+ /** QUIKTR-1844: record a revision of an approved test change that does not fit. */
32882
+ recordRevision(r, revision, at2, key) {
32883
+ const d = this.deps;
32884
+ const scrub = d.scrub ?? ((s) => s);
32885
+ const history = mapHistory((d.history ?? ((p, title) => readTestHistory({ path: p, title })))(at2.path, revision.diskTitle), scrub);
32886
+ const conflict = {
32887
+ ...r,
32888
+ path: at2.path,
32889
+ describes: at2.test.describes,
32890
+ startLine: at2.test.startLine,
32891
+ endLine: at2.test.endLine,
32892
+ changeLine: at2.changeLine,
32893
+ index: at2.index,
32894
+ ...at2.isTable ? { rows: revision.rows } : {},
32895
+ revises: revision.sha,
32896
+ diskTitle: revision.diskTitle,
32897
+ misfit: revision.misfit,
32898
+ history,
32899
+ originalLf: at2.lf,
32900
+ ending: at2.ending,
32901
+ bom: at2.bom,
32902
+ ...d.phase ? { phase: d.phase } : {}
32903
+ };
32904
+ this.byTest.set(key, conflict);
32905
+ this.counts.recorded += 1;
32906
+ d.log?.({ event: "codegen.conflict_recorded", reading: r.reading, phase: d.phase ?? null, historyAvailable: history.available, revision: true, ...at2.isTable ? { rows: revision.rows } : {} });
32907
+ return { status: "conflict_recorded", message: RECORDED_MESSAGE, output: { history } };
32908
+ }
32878
32909
  };
32879
32910
  function fileText(lf, ending, bom) {
32880
32911
  return `${bom ? "\uFEFF" : ""}${fromLf(lf, ending)}`;
@@ -32950,11 +32981,12 @@ function proposalBranchName(issueKey, githubRunId) {
32950
32981
  }
32951
32982
  function lineOf2(c, file) {
32952
32983
  const newTitle = file.newTitles.get(c.index);
32984
+ const title = c.diskTitle ?? c.testTitle;
32953
32985
  return {
32954
32986
  v: 1,
32955
32987
  path: c.path,
32956
- title: c.testTitle,
32957
- ...newTitle !== void 0 && newTitle !== c.testTitle ? { newTitle } : {},
32988
+ title,
32989
+ ...newTitle !== void 0 && newTitle !== title ? { newTitle } : {},
32958
32990
  caseId: c.caseId,
32959
32991
  reading: c.reading,
32960
32992
  startLine: c.startLine,
@@ -32965,9 +32997,16 @@ function lineOf2(c, file) {
32965
32997
  history: c.history,
32966
32998
  oldCodeChecked: c.oldCodeChecked === true,
32967
32999
  ...c.rows !== void 0 ? { rows: c.rows } : {},
32968
- ...file.stale.get(c.index) ? { stale: file.stale.get(c.index) } : {}
33000
+ ...file.stale.get(c.index) ? { stale: file.stale.get(c.index) } : {},
33001
+ ...c.revises !== void 0 ? { revises: c.revises } : {},
33002
+ ...c.misfit !== void 0 ? { misfit: c.misfit } : {}
32969
33003
  };
32970
33004
  }
33005
+ function revisionNote(sha2, m) {
33006
+ const rows = m ? m.totalRows > 1 ? ` It did not fit ${m.failingRows} of the test's ${m.totalRows} rows` : " The test still failed with it" : "";
33007
+ const now = m?.examples[0] ? ` (now: "${oneLine(m.examples[0])}")` : "";
33008
+ return `This revises the change approved in ${sha2.slice(0, 10)}.${rows}${now}${rows ? "." : ""}`;
33009
+ }
32971
33010
  function staleNote(s) {
32972
33011
  const where = [s.inTitle ? "the title" : null, s.commentLines.length > 0 ? `a comment (line${s.commentLines.length === 1 ? "" : "s"} ${s.commentLines.join(", ")})` : null].filter((x) => x !== null).join(" and ");
32973
33012
  return `Note: ${where} of this test still ${s.inTitle || s.commentLines.length === 1 ? "says" : "say"} ${s.tokens.map((t) => `"${oneLine(t)}"`).join(", ")}, which this change replaces. Fix the wording in the repository, or reject the change.`;
@@ -32992,6 +33031,7 @@ function buildProposalMessage(input) {
32992
33031
  ...l.history.sameCommitPaths && l.history.sameCommitPaths.length > 0 ? [` The same change also touched: ${l.history.sameCommitPaths.slice(0, 5).join(", ")}${l.history.sameCommitPaths.length > 5 || l.history.sameCommitMore ? ", ..." : ""}`] : [],
32993
33032
  ...l.oldCodeChecked ? [" With this change the test fails on the code as it is today, so it shows the bug."] : [],
32994
33033
  ...l.stale ? [` ${staleNote(l.stale)}`] : [],
33034
+ ...l.revises ? [` ${revisionNote(l.revises, l.misfit)}`] : [],
32995
33035
  ""
32996
33036
  ]),
32997
33037
  "Machine-readable (read back by QuikPilot; do not edit):",
@@ -33004,6 +33044,12 @@ ${body.join("\n")}
33004
33044
  }
33005
33045
  var isStr = (v, max, min = 1) => typeof v === "string" && v.length >= min && v.length <= max;
33006
33046
  var isLine = (v) => typeof v === "number" && Number.isInteger(v) && v >= 1 && v <= 1e7;
33047
+ function isMisfit(v) {
33048
+ if (typeof v !== "object" || v === null) return false;
33049
+ const m = v;
33050
+ const count3 = (n) => typeof n === "number" && Number.isInteger(n) && n >= 0 && n <= 1e4;
33051
+ return count3(m.failingRows) && count3(m.totalRows) && m.failingRows <= m.totalRows && Array.isArray(m.examples) && m.examples.length <= 3 && m.examples.every((e) => isStr(e, 120));
33052
+ }
33007
33053
  function isStale(v) {
33008
33054
  if (typeof v !== "object" || v === null) return false;
33009
33055
  const s = v;
@@ -33023,7 +33069,7 @@ function parseProposalMessage(message) {
33023
33069
  const o = j;
33024
33070
  const c = o.correction;
33025
33071
  const h = o.history;
33026
- if (o.v !== 1 || !isStr(o.path, 300) || !isStr(o.title, 300) || o.newTitle !== void 0 && !isStr(o.newTitle, 300) || !isStr(o.caseId, 64) || !CONFLICT_READINGS.includes(o.reading) || !isLine(o.startLine) || !isLine(o.endLine) || !isLine(o.changeLine) || !isStr(o.reason, 300) || typeof c !== "object" || c === null || !CONFLICT_CASE_FIELDS.includes(c.field) || !isStr(c.text, 1e3) || !isStr(c.why, 300) || typeof h !== "object" || h === null || typeof h.available !== "boolean" || typeof o.oldCodeChecked !== "boolean" || o.rows !== void 0 && !(typeof o.rows === "number" && Number.isInteger(o.rows) && o.rows >= 1 && o.rows <= 1e4) || o.stale !== void 0 && !isStale(o.stale)) {
33072
+ if (o.v !== 1 || !isStr(o.path, 300) || !isStr(o.title, 300) || o.newTitle !== void 0 && !isStr(o.newTitle, 300) || !isStr(o.caseId, 64) || !CONFLICT_READINGS.includes(o.reading) || !isLine(o.startLine) || !isLine(o.endLine) || !isLine(o.changeLine) || !isStr(o.reason, 300) || typeof c !== "object" || c === null || !CONFLICT_CASE_FIELDS.includes(c.field) || !isStr(c.text, 1e3) || !isStr(c.why, 300) || typeof h !== "object" || h === null || typeof h.available !== "boolean" || typeof o.oldCodeChecked !== "boolean" || o.rows !== void 0 && !(typeof o.rows === "number" && Number.isInteger(o.rows) && o.rows >= 1 && o.rows <= 1e4) || o.stale !== void 0 && !isStale(o.stale) || o.revises !== void 0 && !(typeof o.revises === "string" && /^[0-9a-f]{40}$/.test(o.revises)) || o.misfit !== void 0 && (o.revises === void 0 || !isMisfit(o.misfit))) {
33027
33073
  continue;
33028
33074
  }
33029
33075
  out.push(o);
@@ -33124,7 +33170,7 @@ function loadApprovedTests(input) {
33124
33170
  const decided = (use) => use.map((l) => ({ path: l.path, testTitle: l.newTitle ?? l.title, caseId: l.caseId, decision }));
33125
33171
  const titlesOf = (use) => use.flatMap((l) => [{ path: l.path, title: l.title }, ...l.newTitle !== void 0 ? [{ path: l.path, title: l.newTitle }] : []]);
33126
33172
  if (decision === "TEST_RIGHT") {
33127
- return { approved: { decision, files: [], decided: decided(lines), titles: titlesOf(lines), proposals: [] }, warnings };
33173
+ return { approved: { decision, files: [], decided: decided(lines), titles: titlesOf(lines), proposals: [], approvedTests: [], revises: [] }, warnings };
33128
33174
  }
33129
33175
  const readCurrent = input.readCurrent ?? ((path) => {
33130
33176
  try {
@@ -33171,7 +33217,9 @@ function loadApprovedTests(input) {
33171
33217
  }
33172
33218
  log({ event: "codegen.approval_loaded", decision, files: files.length, tests: kept.length, dropped: lines.length - kept.length });
33173
33219
  const tests = kept.map((l) => ({ path: l.path, line: l.changeLine, caseId: l.caseId }));
33174
- return { approved: { decision, files, decided: decided(kept), titles: titlesOf(kept), proposals: [{ branch, sha: sha2, tests }] }, warnings };
33220
+ const approvedTests = kept.map((l) => ({ path: l.path, diskTitle: l.title, title: l.newTitle ?? l.title, caseId: l.caseId, sha: sha2 }));
33221
+ const revises = [...new Set(kept.filter((l) => l.revises !== void 0).map((l) => l.path))];
33222
+ return { approved: { decision, files, decided: decided(kept), titles: titlesOf(kept), proposals: [{ branch, sha: sha2, tests }], approvedTests, revises }, warnings };
33175
33223
  }
33176
33224
  var gitMergeText = ({ ours, base, theirs }) => {
33177
33225
  const dir = (0, import_node_fs5.mkdtempSync)((0, import_node_path6.join)((0, import_node_os2.tmpdir)(), "qp-merge-"));
@@ -33200,9 +33248,10 @@ function loadApprovals(input) {
33200
33248
  }
33201
33249
  });
33202
33250
  const merge2 = input.merge ?? gitMergeText;
33203
- const decided = [];
33251
+ let decided = [];
33204
33252
  const titles = [];
33205
33253
  const proposals = [];
33254
+ let approvedTests = [];
33206
33255
  const files = /* @__PURE__ */ new Map();
33207
33256
  let any = false;
33208
33257
  for (const change of input.changes.slice(0, MAX_CHANGES_APPLIED)) {
@@ -33211,9 +33260,10 @@ function loadApprovals(input) {
33211
33260
  const a = one.approved;
33212
33261
  if (!a) continue;
33213
33262
  const leftOut = /* @__PURE__ */ new Set();
33263
+ const revising = new Set(a.revises ?? []);
33214
33264
  for (const f of a.files) {
33215
33265
  const earlier = files.get(f.targetPath);
33216
- if (earlier === void 0) {
33266
+ if (earlier === void 0 || revising.has(f.targetPath)) {
33217
33267
  files.set(f.targetPath, f.newContent);
33218
33268
  continue;
33219
33269
  }
@@ -33228,6 +33278,10 @@ function loadApprovals(input) {
33228
33278
  files.set(f.targetPath, `${disk.charCodeAt(0) === 65279 ? "\uFEFF" : ""}${fromLf(merged, ending)}`);
33229
33279
  }
33230
33280
  any = true;
33281
+ const revisedCases = new Set(a.decided.filter((d) => revising.has(d.path)).map((d) => `${d.path}\0${d.caseId}`));
33282
+ decided = decided.filter((d) => !revisedCases.has(`${d.path}\0${d.caseId}`));
33283
+ approvedTests = approvedTests.filter((t) => !revisedCases.has(`${t.path}\0${t.caseId}`));
33284
+ approvedTests.push(...(a.approvedTests ?? []).filter((t) => !leftOut.has(t.path)));
33231
33285
  decided.push(...a.decided.filter((d) => !leftOut.has(d.path)));
33232
33286
  titles.push(...a.titles.filter((t) => !leftOut.has(t.path)));
33233
33287
  for (const p of a.proposals) {
@@ -33243,7 +33297,8 @@ function loadApprovals(input) {
33243
33297
  files: [...files.entries()].map(([targetPath, newContent]) => ({ targetPath, newContent })),
33244
33298
  decided: decided.slice(-MAX_DECIDED_TESTS),
33245
33299
  titles,
33246
- proposals
33300
+ proposals,
33301
+ approvedTests
33247
33302
  },
33248
33303
  warnings
33249
33304
  };
@@ -33461,6 +33516,11 @@ var ALLOWED_NAMES = /* @__PURE__ */ new Set([
33461
33516
  "PIPX_HOME",
33462
33517
  "PIPX_BIN_DIR",
33463
33518
  "POETRY_HOME",
33519
+ // QUIKTR-1699: PHP projects (Composer, set up by shivammathur/setup-php).
33520
+ "COMPOSER_HOME",
33521
+ "COMPOSER_CACHE_DIR",
33522
+ "COMPOSER_NO_INTERACTION",
33523
+ "PHP_INI_SCAN_DIR",
33464
33524
  "PNPM_HOME",
33465
33525
  "BUN_INSTALL",
33466
33526
  "DENO_INSTALL",
@@ -33841,7 +33901,220 @@ var import_node_path9 = require("node:path");
33841
33901
  // src/quiktest.ts
33842
33902
  var import_node_fs6 = require("node:fs");
33843
33903
  var import_node_path8 = require("node:path");
33904
+
33905
+ // src/caseTags.ts
33906
+ var MAX_CASE_TESTS = 50;
33907
+ var MAX_TEXT = 300;
33908
+ var CASE_ID_RE = /^QP-[A-Z][A-Z0-9]*-\d+-\d+$/;
33909
+ var TOKEN_RE = /\[QP-[A-Z][A-Z0-9]*-\d+-\d+\]/;
33910
+ var declared = [];
33911
+ function readCaseTests(value, allowedIds) {
33912
+ if (!Array.isArray(value)) return [];
33913
+ const allowed = new Set(allowedIds);
33914
+ const out = /* @__PURE__ */ new Map();
33915
+ for (const item of value.slice(0, MAX_CASE_TESTS)) {
33916
+ if (typeof item !== "object" || item === null) continue;
33917
+ const o = item;
33918
+ const ok = (v) => typeof v === "string" && v.trim().length > 0 && v.length <= MAX_TEXT;
33919
+ if (!ok(o.caseId) || !ok(o.path) || !ok(o.testName)) continue;
33920
+ const caseId = o.caseId.trim();
33921
+ if (!CASE_ID_RE.test(caseId) || allowed.size > 0 && !allowed.has(caseId)) continue;
33922
+ out.set(caseId, { caseId, path: normalisePath(o.path), testName: o.testName.trim() });
33923
+ }
33924
+ return [...out.values()];
33925
+ }
33926
+ function addCaseTests(list2) {
33927
+ const byId = new Map(declared.map((d) => [d.caseId, d]));
33928
+ for (const d of list2) byId.set(d.caseId, d);
33929
+ declared = [...byId.values()];
33930
+ }
33931
+ function declaredIn(caseId, written) {
33932
+ const d = declared.find((x) => x.caseId === caseId);
33933
+ if (!d) return false;
33934
+ for (const [path, text2] of written) if (samePath(path, d.path) && text2.includes(bareName(d.testName))) return true;
33935
+ return false;
33936
+ }
33937
+ function idCoversCase(testId, caseId) {
33938
+ if (testId.includes(`[${caseId}]`)) return true;
33939
+ const d = declared.find((x) => x.caseId === caseId);
33940
+ if (!d) return false;
33941
+ const at2 = testId.indexOf("::");
33942
+ const c = at2 < 0 ? { name: testId } : { classname: testId.slice(0, at2), name: testId.slice(at2 + 2) };
33943
+ if (!nameMatches(c.name, d.testName)) return false;
33944
+ return placeOf(c) === null || placeMatches(c, d.path);
33945
+ }
33946
+ function declaredFileOf(caseId) {
33947
+ return declared.find((x) => x.caseId === caseId)?.path ?? null;
33948
+ }
33949
+ function sameFile2(a, b) {
33950
+ return samePath(a, b);
33951
+ }
33952
+ function tagNames(cases, list2 = declared) {
33953
+ const names = cases.map((c) => c.name);
33954
+ for (const d of list2) {
33955
+ const matching = [];
33956
+ cases.forEach((c, i2) => {
33957
+ if (!TOKEN_RE.test(names[i2]) && nameMatches(c.name, d.testName)) matching.push(i2);
33958
+ });
33959
+ if (matching.length === 0) continue;
33960
+ const placed = matching.filter((i2) => placeOf(cases[i2]) !== null);
33961
+ let chosen;
33962
+ if (placed.length > 0) chosen = placed.filter((i2) => placeMatches(cases[i2], d.path));
33963
+ else chosen = matching.length === 1 || matching.every((i2) => isRowOf(cases[i2].name, d.testName)) ? matching : [];
33964
+ for (const i2 of chosen) names[i2] = `[${d.caseId}] ${names[i2]}`;
33965
+ }
33966
+ return names;
33967
+ }
33968
+ var SEPARATORS = [" ", " > ", " \u203A ", "::", ".", "/", "#"];
33969
+ function bareName(n) {
33970
+ return n.trim().replace(/\(\)$/, "");
33971
+ }
33972
+ function isRowOf(name, testName) {
33973
+ const n = bareName(name);
33974
+ const t = bareName(testName);
33975
+ return n === t || n.startsWith(`${t}[`) || n.startsWith(`${t}/`);
33976
+ }
33977
+ function nameMatches(name, testName) {
33978
+ const n = bareName(name);
33979
+ const t = bareName(testName);
33980
+ if (!t) return false;
33981
+ if (isRowOf(n, t)) return true;
33982
+ return SEPARATORS.some((s) => n.endsWith(`${s}${t}`) || n.includes(`${s}${t}[`));
33983
+ }
33984
+ function normalisePath(p) {
33985
+ return p.trim().replace(/\\/g, "/").replace(/^(\.\/)+/, "").replace(/^\/+/, "");
33986
+ }
33987
+ function samePath(a, b) {
33988
+ const x = normalisePath(a);
33989
+ const y = normalisePath(b);
33990
+ return x === y || x.endsWith(`/${y}`) || y.endsWith(`/${x}`);
33991
+ }
33992
+ var FILE_EXT_RE = /\.[A-Za-z0-9]{1,6}$/;
33993
+ function placeOf(c) {
33994
+ if (c.file && c.file.trim()) return { file: c.file };
33995
+ const cls = c.classname?.trim();
33996
+ if (!cls) return null;
33997
+ if (/[\\/]/.test(cls) && FILE_EXT_RE.test(cls)) return { file: cls };
33998
+ const parts = cls.split(/[\\/.]|::/).filter(Boolean);
33999
+ return parts.length > 1 ? { parts } : null;
34000
+ }
34001
+ function placeMatches(c, path) {
34002
+ const place = placeOf(c);
34003
+ if (!place) return false;
34004
+ if ("file" in place) return samePath(place.file, path);
34005
+ const segs = normalisePath(path).replace(FILE_EXT_RE, "").split(/[/.]/).filter(Boolean);
34006
+ const cls = place.parts;
34007
+ for (let k2 = Math.min(cls.length, segs.length); k2 >= 1; k2--) {
34008
+ if (cls.slice(0, k2).join("/") === segs.slice(-k2).join("/")) return true;
34009
+ }
34010
+ const dir = segs.slice(0, -1);
34011
+ if (dir.length === 0) return false;
34012
+ const k = Math.min(dir.length, cls.length);
34013
+ return cls.slice(-k).join("/") === dir.slice(-k).join("/");
34014
+ }
34015
+ var TESTCASE_TAG_RE = /<testcase\b([^>]*?)(\/?>)/g;
34016
+ var ATTR = (name) => new RegExp(`\\b${name}="([^"]*)"`);
34017
+ var unescape = (s) => s.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
34018
+ var escape = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
34019
+ function tagReportXml(xml, list2 = declared) {
34020
+ if (list2.length === 0) return xml;
34021
+ const cases = [];
34022
+ for (const m of xml.matchAll(TESTCASE_TAG_RE)) {
34023
+ const attrs = m[1] ?? "";
34024
+ const name = ATTR("name").exec(attrs)?.[1];
34025
+ const classname = ATTR("classname").exec(attrs)?.[1];
34026
+ const file = ATTR("file").exec(attrs)?.[1];
34027
+ cases.push({ name: name === void 0 ? "" : unescape(name), ...classname !== void 0 ? { classname: unescape(classname) } : {}, ...file !== void 0 ? { file: unescape(file) } : {} });
34028
+ }
34029
+ const tagged = tagNames(cases, list2);
34030
+ if (tagged.every((n, i3) => n === cases[i3].name)) return xml;
34031
+ let i2 = 0;
34032
+ return xml.replace(TESTCASE_TAG_RE, (whole4, attrs, close) => {
34033
+ const index = i2++;
34034
+ const name = tagged[index];
34035
+ if (name === cases[index].name || !ATTR("name").test(attrs)) return whole4;
34036
+ return `<testcase${attrs.replace(ATTR("name"), () => `name="${escape(name)}"`)}${close}`;
34037
+ });
34038
+ }
34039
+
34040
+ // src/quiktest.ts
33844
34041
  var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git"]);
34042
+ var DEPENDENCY_DIRS = /* @__PURE__ */ new Set([
34043
+ "node_modules",
34044
+ ".git",
34045
+ ".venv",
34046
+ "venv",
34047
+ "vendor",
34048
+ "site-packages",
34049
+ ".tox",
34050
+ ".gradle",
34051
+ "__pycache__",
34052
+ ".pytest_cache",
34053
+ ".mypy_cache",
34054
+ "bower_components",
34055
+ // The runner's own copy of a failed run's final report (failureArtifact.ts FAILURE_ARTIFACT_DIR): never a report of a test run.
34056
+ "quikpilot-failure"
34057
+ ]);
34058
+ var MAX_REPORTS = 500;
34059
+ function isJUnitXml(path) {
34060
+ let fd = null;
34061
+ try {
34062
+ fd = (0, import_node_fs6.openSync)(path, "r");
34063
+ const buf = Buffer.alloc(2048);
34064
+ const n = (0, import_node_fs6.readSync)(fd, buf, 0, buf.length, 0);
34065
+ const head = buf.subarray(0, n).toString("utf8").replace(/^\uFEFF/, "");
34066
+ const body = head.replace(/<\?[\s\S]*?\?>/g, "").replace(/<!--[\s\S]*?-->/g, "").trimStart();
34067
+ return /^<testsuites?\b/.test(body);
34068
+ } catch {
34069
+ return false;
34070
+ } finally {
34071
+ if (fd !== null) (0, import_node_fs6.closeSync)(fd);
34072
+ }
34073
+ }
34074
+ function findJUnitReports(cwd = process.cwd(), opts = {}) {
34075
+ const found = [];
34076
+ const walk2 = (dir) => {
34077
+ if (found.length >= MAX_REPORTS) return;
34078
+ let entries;
34079
+ try {
34080
+ entries = (0, import_node_fs6.readdirSync)(dir);
34081
+ } catch {
34082
+ return;
34083
+ }
34084
+ for (const entry of entries) {
34085
+ if (DEPENDENCY_DIRS.has(entry)) continue;
34086
+ const full = (0, import_node_path8.join)(dir, entry);
34087
+ let stat;
34088
+ try {
34089
+ stat = (0, import_node_fs6.statSync)(full);
34090
+ } catch {
34091
+ continue;
34092
+ }
34093
+ if (stat.isDirectory()) walk2(full);
34094
+ else if (/\.xml$/i.test(entry) && (opts.freshSinceMs === void 0 || stat.mtimeMs >= opts.freshSinceMs) && isJUnitXml(full)) {
34095
+ found.push(full);
34096
+ if (found.length >= MAX_REPORTS) return;
34097
+ }
34098
+ }
34099
+ };
34100
+ walk2(cwd);
34101
+ const named = (p) => /^junit.*\.xml$/i.test(p.split(/[\\/]/).pop() ?? "") ? 0 : 1;
34102
+ return found.sort((a, b) => named(a) - named(b) || a.localeCompare(b));
34103
+ }
34104
+ function mergeJUnitReports(texts) {
34105
+ if (texts.length === 1) return texts[0];
34106
+ const inner = texts.map((t) => {
34107
+ const body = t.replace(/^\uFEFF/, "").replace(/<\?xml[\s\S]*?\?>/, "").trim();
34108
+ const wrapped = /^<testsuites\b[^>]*>([\s\S]*)<\/testsuites>\s*$/.exec(body);
34109
+ if (wrapped) return wrapped[1].trim();
34110
+ return /^<testsuites\b[^>]*\/>\s*$/.test(body) ? "" : body;
34111
+ });
34112
+ return `<?xml version="1.0" encoding="UTF-8"?>
34113
+ <testsuites>
34114
+ ${inner.filter(Boolean).join("\n")}
34115
+ </testsuites>
34116
+ `;
34117
+ }
33845
34118
  function walkForJUnitByName(dir) {
33846
34119
  let entries;
33847
34120
  try {
@@ -33879,14 +34152,16 @@ function firstXmlIn(dir, namePattern) {
33879
34152
  }
33880
34153
  function readTestReportBytes(cwd = process.cwd()) {
33881
34154
  try {
33882
- const report = findJUnitReport(cwd);
33883
- return report ? (0, import_node_fs6.readFileSync)(report) : null;
34155
+ const reports = findJUnitReports(cwd);
34156
+ if (reports.length === 0) return null;
34157
+ if (reports.length === 1) return (0, import_node_fs6.readFileSync)(reports[0]);
34158
+ return Buffer.from(mergeJUnitReports(reports.map((r) => (0, import_node_fs6.readFileSync)(r, "utf8"))), "utf8");
33884
34159
  } catch {
33885
34160
  return null;
33886
34161
  }
33887
34162
  }
33888
34163
  function findJUnitReport(cwd = process.cwd()) {
33889
- return walkForJUnitByName(cwd) ?? firstXmlIn((0, import_node_path8.join)(cwd, "test-results"), /\.xml$/) ?? firstXmlIn((0, import_node_path8.join)(cwd, "reports"), /^junit.*\.xml$/) ?? firstXmlIn((0, import_node_path8.join)(cwd, "target", "surefire-reports"), /\.xml$/);
34164
+ return walkForJUnitByName(cwd) ?? findJUnitReports(cwd)[0] ?? firstXmlIn((0, import_node_path8.join)(cwd, "test-results"), /\.xml$/) ?? firstXmlIn((0, import_node_path8.join)(cwd, "reports"), /^junit.*\.xml$/) ?? firstXmlIn((0, import_node_path8.join)(cwd, "target", "surefire-reports"), /\.xml$/);
33890
34165
  }
33891
34166
  function buildCiUrl(serverUrl, repository, githubRunId) {
33892
34167
  return `${serverUrl}/${repository}/actions/runs/${githubRunId}`;
@@ -33902,16 +34177,15 @@ async function reportToQuikTest(params) {
33902
34177
  console.log("packet.quikTest is null \u2014 this run has no QuikTest run to report into.");
33903
34178
  return null;
33904
34179
  }
33905
- const report = findJUnitReport(cwd);
33906
- if (!report) {
34180
+ const reports = findJUnitReports(cwd);
34181
+ if (reports.length === 0) {
33907
34182
  console.warn("::warning::QuikPilot found no JUnit report \u2014 no results reported to QuikTest.");
33908
34183
  return null;
33909
34184
  }
33910
34185
  try {
33911
- console.log(`reporting ${report}`);
34186
+ console.log(`reporting ${reports.length === 1 ? reports[0] : `${reports.length} reports`}`);
33912
34187
  const ciUrl = buildCiUrl(githubServerUrl, githubRepository, githubRunId);
33913
- const { readFileSync: readFileSync19 } = await import("node:fs");
33914
- const body = readFileSync19(report);
34188
+ const body = tagReportXml(mergeJUnitReports(reports.map((r) => (0, import_node_fs6.readFileSync)(r, "utf8"))));
33915
34189
  let url = `${resultsUrl}?ciUrl=${encodeURIComponent(ciUrl)}&automationIdFormat=bracket`;
33916
34190
  if (generatedFiles) {
33917
34191
  url += `&generatedFiles=${encodeURIComponent(generatedFiles.join(","))}`;
@@ -33924,7 +34198,7 @@ async function reportToQuikTest(params) {
33924
34198
  if (!res.ok) {
33925
34199
  throw new Error(`QuikTest report POST failed: ${res.status} ${res.statusText}`);
33926
34200
  }
33927
- (0, import_node_fs6.rmSync)(report, { force: true });
34201
+ for (const report of reports) (0, import_node_fs6.rmSync)(report, { force: true });
33928
34202
  let unmatched = [];
33929
34203
  try {
33930
34204
  const json = await res.json();
@@ -34002,9 +34276,9 @@ function withoutLoop7Words(previous) {
34002
34276
  var import_node_fs7 = require("node:fs");
34003
34277
 
34004
34278
  // src/pathShape.ts
34005
- var PATH_EXTENSION_RE = /\.(ts|tsx|js|jsx|mjs|cjs|py|rb|go)$/i;
34279
+ var PATH_EXTENSION_RE = /\.(ts|tsx|js|jsx|mjs|cjs|py|rb|go|java|kt|kts|cs|php|rs|swift|scala|ex|exs|c|cc|cpp|h|hpp|dart|lua|vue|svelte)$/i;
34006
34280
  function looksLikeFilePath(value) {
34007
- return value.includes("/") || PATH_EXTENSION_RE.test(value);
34281
+ return PATH_EXTENSION_RE.test(value.trim());
34008
34282
  }
34009
34283
 
34010
34284
  // src/regressionCheck.ts
@@ -34057,6 +34331,13 @@ function extractFailureDetail(inner) {
34057
34331
  if (!text2) return null;
34058
34332
  return text2.length > MAX_FAILURE_DETAIL ? `${text2.slice(0, MAX_FAILURE_DETAIL)}\u2026` : text2;
34059
34333
  }
34334
+ var ANY_LOCATION_RE = /(?:File "([^"\r\n]+?\.[A-Za-z0-9]{1,6})", line (\d+))|(?:([^\s"'()\[\]<>]+?\.(?:[cm]?[jt]sx?|py|go|java|rb|rs|cs|php|kt|kts|swift|scala|exs?|c|cc|cpp|h|hpp|dart)):(?:line )?(\d+))/g;
34335
+ var DEPENDENCY_PATH_RE = /(^|\/)(node_modules|site-packages|dist-packages|vendor|\.venv|venv|\.cargo|\.m2|\.gradle|go\/pkg\/mod)\//;
34336
+ function shownPath(raw) {
34337
+ const path = normalizeSlashes(raw).replace(/^#\s*/, "").replace(/^\.\//, "");
34338
+ const root = `${normalizeSlashes(process.cwd()).replace(/\/+$/, "")}/`;
34339
+ return path.startsWith(root) ? path.slice(root.length) : path;
34340
+ }
34060
34341
  function parseAssertionLocation(body) {
34061
34342
  const text2 = unescapeXmlEntities(body);
34062
34343
  STACK_FRAME_RE.lastIndex = 0;
@@ -34069,6 +34350,17 @@ function parseAssertionLocation(body) {
34069
34350
  if (shown.length > MAX_FAILURE_LOCATION) return null;
34070
34351
  return `${shown}:${frame[2]}`;
34071
34352
  }
34353
+ ANY_LOCATION_RE.lastIndex = 0;
34354
+ let any;
34355
+ while (any = ANY_LOCATION_RE.exec(text2)) {
34356
+ const raw = any[1] ?? any[3];
34357
+ const line = any[2] ?? any[4];
34358
+ if (!raw || !line) continue;
34359
+ const shown = shownPath(raw);
34360
+ if (DEPENDENCY_PATH_RE.test(`/${shown}`) || /^(?:https?|file):/i.test(shown)) continue;
34361
+ if (shown.length > MAX_FAILURE_LOCATION) return null;
34362
+ return `${shown}:${line}`;
34363
+ }
34072
34364
  return null;
34073
34365
  }
34074
34366
  function extractFailureText(testcaseBody) {
@@ -34099,15 +34391,27 @@ function parseJUnitOutcomes(xml) {
34099
34391
  const file = FILE_ATTR_RE.exec(suiteMatch[1])?.[1];
34100
34392
  if (file) discoveredFiles.add(normalizeSlashes(file));
34101
34393
  }
34394
+ const cases = [];
34102
34395
  let match;
34103
34396
  TESTCASE_RE.lastIndex = 0;
34104
34397
  while (match = TESTCASE_RE.exec(xml)) {
34105
- const [, attrs, body = ""] = match;
34398
+ const [, attrs = "", body = ""] = match;
34106
34399
  const rawName = NAME_ATTR_RE.exec(attrs)?.[1];
34107
34400
  if (!rawName) continue;
34108
- const name = unescapeXmlEntities(rawName);
34109
34401
  const rawClassname = CLASSNAME_ATTR_RE.exec(attrs)?.[1];
34110
- const classname = rawClassname === void 0 ? void 0 : unescapeXmlEntities(rawClassname);
34402
+ const rawFile = FILE_ATTR_RE.exec(attrs)?.[1];
34403
+ cases.push({
34404
+ attrs,
34405
+ body,
34406
+ name: unescapeXmlEntities(rawName),
34407
+ ...rawClassname !== void 0 ? { classname: unescapeXmlEntities(rawClassname) } : {},
34408
+ ...rawFile !== void 0 ? { file: unescapeXmlEntities(rawFile) } : {}
34409
+ });
34410
+ }
34411
+ const tagged = tagNames(cases);
34412
+ for (const [index, c] of cases.entries()) {
34413
+ const { attrs, body, classname } = c;
34414
+ const name = tagged[index];
34111
34415
  const id = classname ? `${classname}::${name}` : name;
34112
34416
  const failed = FAILURE_CHILD_RE.test(body);
34113
34417
  outcomes.set(id, !failed);
@@ -34136,17 +34440,45 @@ function parseJUnitOutcomes(xml) {
34136
34440
  }
34137
34441
  var FRESH_SLACK_MS = 2e3;
34138
34442
  function readJUnitOutcomes(cwd, freshSinceMs) {
34139
- const report = findJUnitReport(cwd);
34140
- if (!report) return null;
34141
- try {
34142
- if (freshSinceMs !== void 0 && (0, import_node_fs7.statSync)(report).mtimeMs < freshSinceMs) return null;
34143
- return parseJUnitOutcomes((0, import_node_fs7.readFileSync)(report, "utf8"));
34144
- } catch {
34145
- return null;
34443
+ const reports = findJUnitReports(cwd, freshSinceMs === void 0 ? {} : { freshSinceMs });
34444
+ const parsed = [];
34445
+ for (const report of reports) {
34446
+ try {
34447
+ parsed.push(parseJUnitOutcomes((0, import_node_fs7.readFileSync)(report, "utf8")));
34448
+ } catch {
34449
+ }
34146
34450
  }
34451
+ if (parsed.length === 0) return null;
34452
+ return parsed.length === 1 ? parsed[0] : mergeParsed(parsed);
34453
+ }
34454
+ function mergeParsed(all) {
34455
+ const out = {
34456
+ outcomes: /* @__PURE__ */ new Map(),
34457
+ automationIdResults: /* @__PURE__ */ new Map(),
34458
+ failureText: /* @__PURE__ */ new Map(),
34459
+ failureWhere: /* @__PURE__ */ new Map(),
34460
+ failureDetail: /* @__PURE__ */ new Map(),
34461
+ discoveredFiles: /* @__PURE__ */ new Set(),
34462
+ discoveredAutomationIds: /* @__PURE__ */ new Set(),
34463
+ unmappedEntries: 0
34464
+ };
34465
+ for (const p of all) {
34466
+ for (const [id, passed] of p.outcomes) out.outcomes.set(id, (out.outcomes.get(id) ?? true) && passed);
34467
+ for (const [id, r] of p.automationIdResults) {
34468
+ const seen = out.automationIdResults.get(id);
34469
+ if (!seen || RESULT_RANK[r] > RESULT_RANK[seen]) out.automationIdResults.set(id, r);
34470
+ }
34471
+ for (const [k, v] of p.failureText) out.failureText.set(k, v);
34472
+ for (const [k, v] of p.failureWhere) out.failureWhere.set(k, v);
34473
+ for (const [k, v] of p.failureDetail) out.failureDetail.set(k, v);
34474
+ for (const f of p.discoveredFiles) out.discoveredFiles.add(f);
34475
+ for (const id of p.discoveredAutomationIds) out.discoveredAutomationIds.add(id);
34476
+ out.unmappedEntries += p.unmappedEntries;
34477
+ }
34478
+ return out;
34147
34479
  }
34148
- function readAutomationIdResults(cwd = process.cwd()) {
34149
- return readJUnitOutcomes(cwd)?.automationIdResults ?? null;
34480
+ function readAutomationIdResults(cwd = process.cwd(), freshSinceMs) {
34481
+ return readJUnitOutcomes(cwd, freshSinceMs)?.automationIdResults ?? null;
34150
34482
  }
34151
34483
  function snapshotOf(outcome, parsed) {
34152
34484
  return {
@@ -34169,8 +34501,9 @@ async function captureLimited(command, cwd, limitMs) {
34169
34501
  }
34170
34502
  function captureTestSnapshot(command, cwd = process.cwd(), opts) {
34171
34503
  if (opts) return captureLimited(command, cwd, opts.limitMs);
34504
+ const startedAt = Date.now();
34172
34505
  const outcome = runTestCommand(command);
34173
- const parsed = readJUnitOutcomes(cwd);
34506
+ const parsed = readJUnitOutcomes(cwd, startedAt - FRESH_SLACK_MS);
34174
34507
  return {
34175
34508
  outcome,
34176
34509
  results: parsed?.outcomes ?? null,
@@ -34182,8 +34515,8 @@ function captureTestSnapshot(command, cwd = process.cwd(), opts) {
34182
34515
  unmappedEntries: parsed?.unmappedEntries
34183
34516
  };
34184
34517
  }
34185
- function readTestSnapshot(outcome, cwd = process.cwd()) {
34186
- const parsed = readJUnitOutcomes(cwd);
34518
+ function readTestSnapshot(outcome, cwd = process.cwd(), freshSinceMs) {
34519
+ const parsed = readJUnitOutcomes(cwd, freshSinceMs);
34187
34520
  return {
34188
34521
  outcome,
34189
34522
  results: parsed?.outcomes ?? null,
@@ -34207,8 +34540,9 @@ function readTestSnapshotAt(outcome, reportPath) {
34207
34540
  }
34208
34541
  async function captureBaselineSnapshot(command, cwd = process.cwd(), opts) {
34209
34542
  if (opts) return captureLimited(command, cwd, opts.limitMs);
34543
+ const startedAt = Date.now();
34210
34544
  const outcome = await runTestCommandAsync(command);
34211
- const parsed = readJUnitOutcomes(cwd);
34545
+ const parsed = readJUnitOutcomes(cwd, startedAt - FRESH_SLACK_MS);
34212
34546
  return {
34213
34547
  outcome,
34214
34548
  results: parsed?.outcomes ?? null,
@@ -34262,6 +34596,7 @@ function describeRegressions(check, options = {}) {
34262
34596
  return text2 ? `${id} (${text2})` : id;
34263
34597
  };
34264
34598
  const parts = [];
34599
+ if (options.approvedMisfits) parts.push(options.approvedMisfits);
34265
34600
  if (check.regressions.length > 0) {
34266
34601
  parts.push(
34267
34602
  options.existingTestsMayExpectOldBehaviour === true ? `${check.regressions.length} regression(s) (passed before, now fail), ${oldBehaviourSentence(groupRegressions(check.regressions), 700)}` : `${check.regressions.length} regression(s) (passed before, now fail): ${check.regressions.map(withText).join(", ")}`
@@ -34410,6 +34745,7 @@ async function runBaselineCheck(params) {
34410
34745
  const reportBefore = findJUnitReport(cwd);
34411
34746
  const mtimeBefore = reportBefore ? mtimeOf(reportBefore) : null;
34412
34747
  const untrackedBefore = untrackedFiles(cwd);
34748
+ const fileRunStartedAt = Date.now();
34413
34749
  const outcome = await runFile(buildSingleFileCommand(testFileCmd, target.path), BASELINE_CHECK_TIMEOUT_MS);
34414
34750
  if (outcome === "timeout") {
34415
34751
  skip(
@@ -34427,7 +34763,7 @@ async function runBaselineCheck(params) {
34427
34763
  "the single-file command wrote no new JUnit report (it must write the same JUnit report as the test command), so nothing could be checked."
34428
34764
  );
34429
34765
  } else {
34430
- const byId = readAutomationIdResults(cwd);
34766
+ const byId = readAutomationIdResults(cwd, fileRunStartedAt - 2e3);
34431
34767
  for (const id of ids) if (byId?.get(id) === "pass") flagged.push(id);
34432
34768
  }
34433
34769
  }
@@ -36015,6 +36351,8 @@ function testTimeLimitMs(baselineMs) {
36015
36351
  if (baselineMs > MAX_TEST_LIMIT_MS) return "too_slow";
36016
36352
  return Math.min(MAX_TEST_LIMIT_MS, Math.max(MIN_TEST_LIMIT_MS, baselineMs * 3));
36017
36353
  }
36354
+ var FILE_COMMAND_PASSED_SENTENCE = "The Test command passed on this file, but no JUnit report was written to say which tests ran.";
36355
+ var FILE_COMMAND_FAILED_SENTENCE = "The Test command failed on this file; no JUnit report was written to say which test failed. Its output is in the job log.";
36018
36356
  var MESSAGES = {
36019
36357
  tests_passed: "The tests passed.",
36020
36358
  tests_failed: "Some tests failed. output lists their names, regressions first: a regression passed before your change. For a test you wrote in this run, messages gives the first line of why it failed.",
@@ -36060,10 +36398,10 @@ function wholeFailure(text2, where, max) {
36060
36398
  if (firstSafe.length >= max - 1) return firstLine(text2, where, max);
36061
36399
  return `${safe.slice(0, max - 1)}\u2026`;
36062
36400
  }
36063
- var normalisePath = (p) => p.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
36401
+ var normalisePath2 = (p) => p.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
36064
36402
  function samePlace2(a, b) {
36065
- const x = normalisePath(a);
36066
- const y = normalisePath(b);
36403
+ const x = normalisePath2(a);
36404
+ const y = normalisePath2(b);
36067
36405
  return x === y || x.endsWith(`/${y}`) || y.endsWith(`/${x}`);
36068
36406
  }
36069
36407
  function ownFailureIds(newFailures, changedPaths, requiredIds) {
@@ -36106,8 +36444,9 @@ function testAnswerFrom(args) {
36106
36444
  let failureDetail = /* @__PURE__ */ new Map();
36107
36445
  if (args.baseline?.results) {
36108
36446
  const check = checkForRegressions(args.baseline, after);
36109
- regressions = check.regressions;
36110
- newFailures = check.newFailures;
36447
+ const approvedFirst = (ids) => args.approvedIds && args.approvedIds.size > 0 ? [...ids.filter((id) => args.approvedIds.has(id)), ...ids.filter((id) => !args.approvedIds.has(id))] : ids;
36448
+ regressions = approvedFirst(check.regressions);
36449
+ newFailures = approvedFirst(check.newFailures);
36111
36450
  alreadyFailing = check.preExisting;
36112
36451
  own = ownFailureIds(newFailures, [...args.changedPaths], args.requiredIds);
36113
36452
  failureText = check.failureText;
@@ -36125,7 +36464,16 @@ function testAnswerFrom(args) {
36125
36464
  let left = MAX_MESSAGES_TOTAL_CHARS;
36126
36465
  let ownToCome = listed.filter((id) => own.has(id)).length;
36127
36466
  listed.forEach((id, i2) => {
36128
- if (!own.has(id)) return;
36467
+ if (!own.has(id)) {
36468
+ if (args.approvedIds?.has(id) === true) {
36469
+ const line2 = firstLine(failureText.get(id) ?? "", failureWhere.get(id));
36470
+ if (line2 && line2.length <= left) {
36471
+ messages[names[i2]] = line2;
36472
+ left -= line2.length;
36473
+ }
36474
+ }
36475
+ return;
36476
+ }
36129
36477
  ownToCome -= 1;
36130
36478
  const where = failureWhere.get(id);
36131
36479
  const allowance = Math.min(MAX_WHOLE_MESSAGE_CHARS, left - ownToCome * MAX_MESSAGE_CHARS);
@@ -36321,16 +36669,7 @@ var RunTestsTool = class {
36321
36669
  }
36322
36670
  const run2 = await runCommand2(command, file === void 0 || testLimitsOff() ? limit : Math.min(limit, FILE_RUN_LIMIT_MS), d.root);
36323
36671
  if (!run2.started || run2.timedOut) return { run: run2, snapshot: null };
36324
- const report = findReport(d.root);
36325
- let fresh = false;
36326
- if (report) {
36327
- try {
36328
- fresh = (0, import_node_fs14.statSync)(report).mtimeMs >= startedAt - FRESH_SLACK_MS2;
36329
- } catch {
36330
- fresh = false;
36331
- }
36332
- }
36333
- const snapshot = fresh ? readSnapshot(run2.outcome, d.root) : null;
36672
+ const snapshot = readSnapshot(run2.outcome, d.root, startedAt - FRESH_SLACK_MS2);
36334
36673
  return { run: run2, snapshot: snapshot && snapshot.results ? snapshot : null };
36335
36674
  },
36336
36675
  { ...d.tree, preserve }
@@ -36382,7 +36721,8 @@ var RunTestsTool = class {
36382
36721
  this.lastFailingKey = null;
36383
36722
  this.lastFailed = null;
36384
36723
  }
36385
- return this.answer(callId, "no_report", { seconds, scope, ...planInfo(null) ? { plan: planInfo(null) } : {} });
36724
+ const byExitCode = file !== void 0 && ran.run.started && !ran.run.timedOut ? ran.run.outcome === "success" ? { reason: "test_command_passed", extra: FILE_COMMAND_PASSED_SENTENCE } : { reason: "test_command_failed", extra: FILE_COMMAND_FAILED_SENTENCE } : {};
36725
+ return this.answer(callId, "no_report", { seconds, scope, ...byExitCode, ...planInfo(null) ? { plan: planInfo(null) } : {} });
36386
36726
  }
36387
36727
  const answer = testAnswerFrom({
36388
36728
  baseline: baseline?.snapshot ?? null,
@@ -38621,14 +38961,14 @@ function unitOf(text2, starts, node) {
38621
38961
  const base = { line: lineAt2(starts, node.start), names: [], declared: [], children: [], declaration: false };
38622
38962
  if (node.type === "ImportDeclaration") {
38623
38963
  const names = [];
38624
- const declared2 = [];
38964
+ const declared3 = [];
38625
38965
  for (const spec of node.specifiers) {
38626
- declared2.push(spec.local.name);
38966
+ declared3.push(spec.local.name);
38627
38967
  if (spec.type === "ImportSpecifier") names.push(`${spec.imported.type === "Identifier" ? spec.imported.name : String(spec.imported.value)}:${spec.local.name}`);
38628
38968
  else if (spec.type === "ImportDefaultSpecifier") names.push(`default:${spec.local.name}`);
38629
38969
  else names.push(`*:${spec.local.name}`);
38630
38970
  }
38631
- return { ...base, kind: "import", key: `import:${String(node.source.value)}`, names, declared: declared2 };
38971
+ return { ...base, kind: "import", key: `import:${String(node.source.value)}`, names, declared: declared3 };
38632
38972
  }
38633
38973
  if (node.type === "ExpressionStatement" && node.expression.type === "CallExpression") {
38634
38974
  const root = rootName(node.expression);
@@ -38641,16 +38981,16 @@ function unitOf(text2, starts, node) {
38641
38981
  return { ...base, kind: "test", key: text2.slice(node.start, node.end) };
38642
38982
  }
38643
38983
  }
38644
- const declared = [];
38984
+ const declared2 = [];
38645
38985
  let declaration = false;
38646
38986
  if (node.type === "FunctionDeclaration" || node.type === "ClassDeclaration") {
38647
38987
  declaration = true;
38648
- declared.push(node.id.name);
38988
+ declared2.push(node.id.name);
38649
38989
  } else if (node.type === "VariableDeclaration") {
38650
38990
  declaration = true;
38651
- for (const d of node.declarations) patternNames(d.id, declared);
38991
+ for (const d of node.declarations) patternNames(d.id, declared2);
38652
38992
  }
38653
- return { ...base, kind: "other", key: text2.slice(node.start, node.end), declared, declaration };
38993
+ return { ...base, kind: "other", key: text2.slice(node.start, node.end), declared: declared2, declaration };
38654
38994
  }
38655
38995
  function unitsOf(text2, body) {
38656
38996
  const starts = lineStartsOf(text2);
@@ -41146,6 +41486,14 @@ var MAP_SOFT_HEADROOM_TOKENS = 2e4;
41146
41486
  function mapSoftTarget(firstRequestTokens, ceiling) {
41147
41487
  return Math.min(ceiling, Math.max(MAP_SOFT_REQUEST_TOKENS, firstRequestTokens + MAP_SOFT_HEADROOM_TOKENS));
41148
41488
  }
41489
+ function withApprovedText(revisable, approved) {
41490
+ return revisable.flatMap((r) => {
41491
+ const file = approved.find((f) => f.targetPath === r.path);
41492
+ if (!file) return [];
41493
+ const body = file.newContent.charCodeAt(0) === 65279 ? file.newContent.slice(1) : file.newContent;
41494
+ return [{ ...r, text: body.replace(/\r\n/g, "\n") }];
41495
+ });
41496
+ }
41149
41497
  var CodegenLoopFailure = class extends Error {
41150
41498
  reason;
41151
41499
  runtimeCode;
@@ -41296,6 +41644,8 @@ async function runCodegenLoop(args, deps) {
41296
41644
  writeRoot: args.writeRoot ?? "",
41297
41645
  caseIds: args.requiredAutomationIds,
41298
41646
  decided: args.conflicts.titles,
41647
+ // QUIKTR-1844: a test whose approved change does not fit may be reported once more, against its approved text.
41648
+ ...args.conflicts.revisable && args.conflicts.revisable.length > 0 ? { revisable: withApprovedText(args.conflicts.revisable, args.approved ?? []) } : {},
41299
41649
  // The checkout as it is on disk: a report is made against the file as it was before the run, never against this attempt's overlay.
41300
41650
  fs: deps.fs ?? createNodeWriteFs(),
41301
41651
  fileBytesMax: limits.fileBytesMax,
@@ -41339,7 +41689,7 @@ async function runCodegenLoop(args, deps) {
41339
41689
  };
41340
41690
  const anyOwnTestFails = () => {
41341
41691
  const runs = currentRedRuns();
41342
- return args.requiredAutomationIds.some((id) => runs.some((r) => r.failing.some((name) => name.includes(`[${id}]`))));
41692
+ return args.requiredAutomationIds.some((id) => runs.some((r) => failsFor(r, id)));
41343
41693
  };
41344
41694
  const redProblem = () => {
41345
41695
  const ids = args.redCheckIds ?? [];
@@ -41348,9 +41698,8 @@ async function runCodegenLoop(args, deps) {
41348
41698
  const passing = [];
41349
41699
  const unrun = [];
41350
41700
  for (const id of ids) {
41351
- const token = `[${id}]`;
41352
- if (runs.some((r) => r.failing.some((name) => name.includes(token)))) continue;
41353
- const covering = runs.filter((r) => r.file === void 0 || (overlay.get(r.file)?.lf ?? "").includes(token));
41701
+ if (runs.some((r) => failsFor(r, id))) continue;
41702
+ const covering = runs.filter((r) => r.file === void 0 || fileHolds(r.file, id));
41354
41703
  if (covering.length === 0) unrun.push(id);
41355
41704
  else if (covering.every((r) => !r.truncated)) passing.push(id);
41356
41705
  }
@@ -41367,6 +41716,12 @@ async function runCodegenLoop(args, deps) {
41367
41716
  }
41368
41717
  return null;
41369
41718
  };
41719
+ const fileHolds = (file, id) => {
41720
+ if ((overlay.get(file)?.lf ?? "").includes(`[${id}]`)) return true;
41721
+ const declared2 = declaredFileOf(id);
41722
+ return declared2 !== null && sameFile2(declared2, file);
41723
+ };
41724
+ const failsFor = (r, id) => r.failing.some((name) => idCoversCase(name, id)) || r.fileFailed === true && r.file !== void 0 && fileHolds(r.file, id);
41370
41725
  const sentSteps = () => stepsOf(transcript.slice(0, sent.entries), toolResults.slice(0, sent.results));
41371
41726
  let turns = 0;
41372
41727
  let noProgressStreak = 0;
@@ -41481,7 +41836,8 @@ async function runCodegenLoop(args, deps) {
41481
41836
  return new CodegenLoopFailure("no_writes");
41482
41837
  }
41483
41838
  const texts = changed.map((p) => overlay.get(p)?.lf ?? "");
41484
- const missing = args.requiredAutomationIds.filter((id) => !texts.some((t) => t.includes(`[${id}]`)));
41839
+ const written = new Map(changed.map((p) => [p, overlay.get(p)?.lf ?? ""]));
41840
+ const missing = args.requiredAutomationIds.filter((id) => !texts.some((t) => t.includes(`[${id}]`)) && !declaredIn(id, written));
41485
41841
  if (missing.length > 0) {
41486
41842
  if (!quiet) log({ event: "codegen.loop_refused", turn, reason: "coverage_missing", missing: missing.length });
41487
41843
  return new CodegenLoopFailure("coverage_missing", void 0, void 0, `${missing.length} required test case(s) not written`, coverageSentence(missing));
@@ -41601,8 +41957,9 @@ async function runCodegenLoop(args, deps) {
41601
41957
  const redLeft = harness && args.phase === "tests" ? redProblem() : null;
41602
41958
  if (harness && args.phase === "tests" && currentRedRuns().some((r) => r.failing.length > 0) && handOverRefusal(turn, true) === null && (redLeft === null || redLeft.kind === "passing")) {
41603
41959
  log({ event: "codegen.red_check", turn, outcome: "gave_up_but_red", files: overlay.changedPaths().length, ...redLeft ? { unproven: redLeft.ids.length } : {} });
41604
- const red = currentRedRuns().at(-1).answer;
41605
- return { results: overlay.results(), summary: snapshot("gave_up_kept"), doneSummary: said ?? "", steps: sentSteps(), ...redLeft ? { redUnproven: redLeft.ids } : {}, lastTestAnswer: last ?? red };
41960
+ const red = currentRedRuns().filter((r) => r.answer !== void 0).at(-1)?.answer;
41961
+ const kept = last ?? red;
41962
+ return { results: overlay.results(), summary: snapshot("gave_up_kept"), doneSummary: said ?? "", steps: sentSteps(), ...redLeft ? { redUnproven: redLeft.ids } : {}, ...kept ? { lastTestAnswer: kept } : {} };
41606
41963
  }
41607
41964
  if (args.keepOnGiveUp === true && last !== void 0 && last.regressions + last.newFailures > 0 && handOverRefusal(turn, true) === null) {
41608
41965
  log({ event: "codegen.loop_kept", files: overlay.changedPaths().length, regressions: last.regressions, newFailures: last.newFailures });
@@ -41612,6 +41969,11 @@ async function runCodegenLoop(args, deps) {
41612
41969
  }
41613
41970
  if (body.outcome === "DONE") {
41614
41971
  log({ event: "codegen.loop_turn", turn, outcome: "done", requestTokens, elapsedMs: now() - turnStarted, calls: [] });
41972
+ const declaredTests = readCaseTests(body.caseTests, args.requiredAutomationIds);
41973
+ if (declaredTests.length > 0) {
41974
+ addCaseTests(declaredTests);
41975
+ log({ event: "codegen.case_tests", turn, declared: declaredTests.length });
41976
+ }
41615
41977
  if (conflictTool && conflictTool.recorded().length > 0) {
41616
41978
  const said = typeof body.summary === "string" ? body.summary.slice(0, MAX_SUMMARY_CHARS) : void 0;
41617
41979
  throw new TestConflictStop(conflictTool.recorded(), new CodegenLoopFailure("cannot_complete", void 0, void 0, said, said));
@@ -41684,7 +42046,7 @@ async function runCodegenLoop(args, deps) {
41684
42046
  const lane = args.lane;
41685
42047
  if (harness && args.phase === "code" && lane?.kind === "code" && !lane.amend && args.keepOnGiveUp === true) {
41686
42048
  const red2 = currentRedRuns().filter((r) => r.failing.some((name) => lane.frozen.some((p) => samePlace3(name.split("::")[0] ?? "", p)))).at(-1);
41687
- if (red2) {
42049
+ if (red2?.answer) {
41688
42050
  log({ event: "codegen.loop_kept", files: overlay.changedPaths().length, regressions: red2.answer.regressions, newFailures: red2.answer.newFailures, after: "done" });
41689
42051
  return { results: overlay.results(), summary: snapshot("gave_up_kept"), doneSummary, gaveUp: true, steps: sentSteps(), lastTestAnswer: red2.answer };
41690
42052
  }
@@ -41754,6 +42116,8 @@ async function runCodegenLoop(args, deps) {
41754
42116
  if (call.name === RUN_TESTS_TOOL && isTestAnswer(result.output) && result.status !== "duplicate") {
41755
42117
  const file = result.output.scope === "file" && isPlainObject3(call.args) && typeof call.args.file === "string" ? call.args.file : void 0;
41756
42118
  redRuns.push({ version: versionOfFiles(filesOnDisk()), ...file ? { file } : {}, failing: result.output.failingTests, truncated: result.output.truncated, answer: result.output });
42119
+ } else if (call.name === RUN_TESTS_TOOL && result.status === "no_report" && result.reason === "test_command_failed" && isPlainObject3(call.args) && typeof call.args.file === "string") {
42120
+ redRuns.push({ version: versionOfFiles(filesOnDisk()), file: call.args.file, failing: [], truncated: false, fileFailed: true });
41757
42121
  }
41758
42122
  if (read) reads.push(read);
41759
42123
  statusCounts[result.status] = (statusCounts[result.status] ?? 0) + 1;
@@ -43007,6 +43371,20 @@ function healReviewPreviousAttempt(attempt2, blocks, answer) {
43007
43371
  }
43008
43372
 
43009
43373
  // src/codegenHeal.ts
43374
+ var samePlace5 = (a, b) => {
43375
+ const x = a.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
43376
+ const y = b.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
43377
+ return x === y || x.endsWith(`/${y}`) || y.endsWith(`/${x}`);
43378
+ };
43379
+ function withMisfits(conflicts, misfits) {
43380
+ const misfitOf = (path, title) => misfits.find((m) => samePlace5(m.path, path) && m.testTitle === title);
43381
+ const decided = conflicts.decided.map((d) => d.decision === "TEST_CHANGED" && misfitOf(d.path, d.testTitle) ? { ...d, stillFailing: true } : d);
43382
+ const revisable = (conflicts.approvedTests ?? []).flatMap((t) => {
43383
+ const m = misfitOf(t.path, t.title);
43384
+ return m ? [{ path: t.path, title: t.title, diskTitle: t.diskTitle, sha: t.sha, rows: m.totalRows, misfit: { failingRows: m.failingRows, totalRows: m.totalRows, examples: m.examples } }] : [];
43385
+ });
43386
+ return { ...conflicts, decided, revisable };
43387
+ }
43010
43388
  async function runHealAttempt(i2) {
43011
43389
  const p = i2.step;
43012
43390
  const keptText = new Map(i2.results.map((r) => [r.targetPath, r.newContent]));
@@ -43024,6 +43402,7 @@ async function runHealAttempt(i2) {
43024
43402
  );
43025
43403
  const args = buildCodegenLoopArgs({ ...p, targets, workspaceListing }, context);
43026
43404
  if (i2.review !== void 0 || i2.answer.regressions <= 0) delete args.conflicts;
43405
+ if (args.conflicts && i2.misfits && i2.misfits.length > 0) args.conflicts = withMisfits(args.conflicts, i2.misfits);
43027
43406
  args.protectedTestPaths = original.protectedTestPaths;
43028
43407
  if (original.baseContext.protectedTestPaths !== void 0) args.baseContext.protectedTestPaths = original.baseContext.protectedTestPaths;
43029
43408
  else delete args.baseContext.protectedTestPaths;
@@ -43243,7 +43622,13 @@ async function runVerifyAndFix(p) {
43243
43622
  p.log({ event: "heal.start", attempt: attemptsRun, healsRun, ...countsOf(v.answer) });
43244
43623
  const startedAt = p.now();
43245
43624
  try {
43246
- results = await p.heal({ results, answer: v.answer, attempt: attemptsRun - 1, hardStopAtMs: p.jobStopAtMs - v.gateMs });
43625
+ results = await p.heal({
43626
+ results,
43627
+ answer: v.answer,
43628
+ attempt: attemptsRun - 1,
43629
+ hardStopAtMs: p.jobStopAtMs - v.gateMs,
43630
+ ...v.misfits && v.misfits.length > 0 ? { misfits: v.misfits } : {}
43631
+ });
43247
43632
  } catch (err) {
43248
43633
  if (err instanceof SafetyRefusalError) {
43249
43634
  p.onStop?.("refused");
@@ -43786,6 +44171,75 @@ function describeDependencyViolations(check) {
43786
44171
  return check.violations.map((v) => `${v.file} imports ${v.packages.join(", ")}, not a dependency of this repository`).join("; ");
43787
44172
  }
43788
44173
 
44174
+ // src/approvedMisfit.ts
44175
+ var MAX_MISFIT_EXAMPLES = 3;
44176
+ var MAX_MISFIT_EXAMPLE_CHARS = 120;
44177
+ var samePlace6 = (a, b) => {
44178
+ const x = a.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
44179
+ const y = b.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
44180
+ return x === y || x.endsWith(`/${y}`) || y.endsWith(`/${x}`);
44181
+ };
44182
+ function isRowOf2(id, test) {
44183
+ const { file, name } = splitTestId(id);
44184
+ return (file === null || samePlace6(file, test.path)) && nameEndsWithTitle(name, test.testTitle);
44185
+ }
44186
+ function approvedTestsFailing(input) {
44187
+ const approved = input.decided.filter((d) => d.decision === "TEST_CHANGED");
44188
+ if (approved.length === 0) return [];
44189
+ const failing = [...input.check.regressions, ...input.check.newFailures];
44190
+ const after = [...input.afterIds];
44191
+ const out = [];
44192
+ const taken = /* @__PURE__ */ new Set();
44193
+ for (const d of approved) {
44194
+ const failingIds = failing.filter((id) => !taken.has(id) && isRowOf2(id, d));
44195
+ if (failingIds.length === 0) continue;
44196
+ for (const id of failingIds) taken.add(id);
44197
+ const totalRows = Math.max(failingIds.length, after.filter((id) => isRowOf2(id, d)).length);
44198
+ const examples = [];
44199
+ for (const id of failingIds) {
44200
+ if (examples.length >= MAX_MISFIT_EXAMPLES) break;
44201
+ const line = firstLine(input.check.failureText.get(id) ?? "", void 0, MAX_MISFIT_EXAMPLE_CHARS);
44202
+ if (line && !examples.includes(line)) examples.push(line);
44203
+ }
44204
+ out.push({ path: d.path, testTitle: d.testTitle, caseId: d.caseId, failingIds, failingRows: failingIds.length, totalRows, examples });
44205
+ }
44206
+ return out;
44207
+ }
44208
+ var clip3 = (s, max) => s.length <= max ? s : `${s.slice(0, max - 1)}\u2026`;
44209
+ function misfitSentence(misfits, max = 600) {
44210
+ const parts = misfits.map((m) => {
44211
+ const rows = m.totalRows > 1 ? ` does not fit ${m.failingRows} of its ${m.totalRows} rows` : " does not fit: the test still fails";
44212
+ const now = m.examples[0] ? ` (now: "${m.examples[0]}")` : "";
44213
+ return `the test change approved for ${m.path}: "${clip3(m.testTitle, 120)}"${rows}${now}`;
44214
+ });
44215
+ return clip3(parts.join("; "), max);
44216
+ }
44217
+
44218
+ // src/testVerification.ts
44219
+ function verifyTier(i2) {
44220
+ if (!i2.command || i2.command.trim() === "") return { tier: "unverified", reason: "no_command" };
44221
+ const before = i2.baseline.results !== null;
44222
+ const now = i2.after.results !== null;
44223
+ if (before && now) return { tier: "report" };
44224
+ if (before !== now) return { tier: "unverified", reason: "report_one_side" };
44225
+ if (i2.baseline.outcome !== "success") return { tier: "unverified", reason: "failing_before" };
44226
+ return i2.after.outcome === "success" ? { tier: "exit_code", pass: true } : { tier: "exit_code", pass: false };
44227
+ }
44228
+ var UNVERIFIED_PREFIX = "QuikPilot could not check this change against the project's tests";
44229
+ var UNVERIFIED_WHY = {
44230
+ no_command: "the project has no Test command. Set one in the project's QuikPilot settings",
44231
+ failing_before: "the tests already failed before the change and no test report was found, so a failure after it cannot be told apart from the ones that were there",
44232
+ report_one_side: "a test report was written on one side of the change only (before it or after it, not both), so the two runs cannot be compared. Check that the Test command writes its JUnit report the same way every time"
44233
+ };
44234
+ function unverifiedMessage(reason) {
44235
+ return `${UNVERIFIED_PREFIX}: ${UNVERIFIED_WHY[reason]}. Nothing was pushed.`;
44236
+ }
44237
+ var EXIT_CODE_FAILED_PREFIX = "QuikPilot's change made the project's tests fail";
44238
+ function exitCodeFailedMessage() {
44239
+ return `${EXIT_CODE_FAILED_PREFIX} \u2014 the Test command passed before the change and failed after it. No test report was found to say which test, so QuikPilot could not fix it. Nothing was pushed.`;
44240
+ }
44241
+ var EXIT_CODE_ONLY_NOTE = "The change was checked by the Test command's result only: it passed before and after the change, but no test report was found, so QuikPilot could not see individual tests or confirm that its new tests ran.";
44242
+
43789
44243
  // src/testPlacementCheck.ts
43790
44244
  function isDiscovered(targetPath, discoveredFiles) {
43791
44245
  const normalized = targetPath.replace(/\\/g, "/");
@@ -44185,6 +44639,7 @@ async function verifyChange(ctx, results, undoable) {
44185
44639
  runCommand(packet.commands.lint, "Lint");
44186
44640
  timing("lint", lintStartedAt, packet.commands.lint);
44187
44641
  stage = "gate";
44642
+ if (!packet.commands.test || packet.commands.test.trim() === "") return fail(new Error(unverifiedMessage("no_command")));
44188
44643
  const gateStartedAt = now();
44189
44644
  const leftMs = ctx.jobStopAtMs === void 0 ? Number.NaN : ctx.jobStopAtMs - gateStartedAt;
44190
44645
  const limit = testLimitsOff() ? null : gateLimitMs({ baselineMs: ctx.baselineMs, leftMs });
@@ -44206,14 +44661,39 @@ async function verifyChange(ctx, results, undoable) {
44206
44661
  warnings.push(w);
44207
44662
  console.warn(`QuikPilot test warning (not blocking): ${w}`);
44208
44663
  }
44664
+ const verification = verifyTier({ command: packet.commands.test, baseline, after });
44665
+ if (verification.tier === "unverified") return fail(new Error(unverifiedMessage(verification.reason)));
44666
+ if (verification.tier === "exit_code") {
44667
+ outputs.testVerification = "exit_code";
44668
+ console.log(JSON.stringify({ event: "gate.verified_by", tier: "exit_code", pass: verification.pass }));
44669
+ if (!verification.pass) return fail(new Error(exitCodeFailedMessage()));
44670
+ warnings.push(EXIT_CODE_ONLY_NOTE);
44671
+ console.warn(`QuikPilot test warning (not blocking): ${EXIT_CODE_ONLY_NOTE}`);
44672
+ } else {
44673
+ outputs.testVerification = "report";
44674
+ }
44209
44675
  const check = checkForRegressions(baseline, after);
44210
44676
  if (check.blocked) {
44211
44677
  const readable = Boolean(baseline.results && after.results);
44212
- const answered = readable ? testAnswerFrom({ baseline, after, changedPaths: results.map((r) => r.targetPath), requiredIds: ctx.requiredAutomationIds, harness: ctx.harness === true }) : null;
44213
- return fail(new Error(`QuikPilot's generated code introduced test failures \u2014 ${describeRegressions(check, { existingTestsMayExpectOldBehaviour: ctx.conflictsOn === true })}`), {
44678
+ const misfits = readable && ctx.approvedDecided && ctx.approvedDecided.length > 0 ? approvedTestsFailing({ check, afterIds: after.results.keys(), decided: ctx.approvedDecided }) : [];
44679
+ const approvedIds = new Set(misfits.flatMap((m) => m.failingIds));
44680
+ const answered = readable ? testAnswerFrom({
44681
+ baseline,
44682
+ after,
44683
+ changedPaths: results.map((r) => r.targetPath),
44684
+ requiredIds: ctx.requiredAutomationIds,
44685
+ harness: ctx.harness === true,
44686
+ ...approvedIds.size > 0 ? { approvedIds } : {}
44687
+ }) : null;
44688
+ const wording = describeRegressions(check, {
44689
+ existingTestsMayExpectOldBehaviour: ctx.conflictsOn === true,
44690
+ ...misfits.length > 0 ? { approvedMisfits: misfitSentence(misfits) } : {}
44691
+ });
44692
+ return fail(new Error(`QuikPilot's generated code introduced test failures \u2014 ${wording}`), {
44214
44693
  check,
44215
44694
  bothSnapshotsReadable: readable,
44216
- ...answered ? { answer: answered.output, failingKey: answered.failingKey } : {}
44695
+ ...answered ? { answer: answered.output, failingKey: answered.failingKey } : {},
44696
+ ...misfits.length > 0 ? { misfits } : {}
44217
44697
  });
44218
44698
  }
44219
44699
  stage = "coverage";
@@ -44310,7 +44790,7 @@ var MAX_ENTRY_CHARS = 200;
44310
44790
  var inside = (path, root) => root === "" || path === root || path.startsWith(`${root}/`);
44311
44791
  var cap = (s) => s.length <= MAX_ENTRY_CHARS ? s : `${s.slice(0, MAX_ENTRY_CHARS - 1)}\u2026`;
44312
44792
  var parentOf2 = (d) => d.includes("/") ? d.slice(0, d.lastIndexOf("/")) : "";
44313
- function clip3(text2, max) {
44793
+ function clip4(text2, max) {
44314
44794
  if (text2.length <= max) return { text: text2, truncated: false };
44315
44795
  const cut = text2.slice(0, max);
44316
44796
  const nl = cut.lastIndexOf("\n");
@@ -44328,7 +44808,7 @@ function guidanceFiles(i2, perFile2, total) {
44328
44808
  if (!tracked.has(path) || matchesDeniedPath(path, denied)) continue;
44329
44809
  const raw = i2.readText(path);
44330
44810
  if (raw === null || raw.trim() === "") continue;
44331
- const clipped = clip3(i2.scrub(raw.replace(/\r\n/g, "\n")).trim(), Math.min(perFile2, left));
44811
+ const clipped = clip4(i2.scrub(raw.replace(/\r\n/g, "\n")).trim(), Math.min(perFile2, left));
44332
44812
  out.push({ path, ...clipped });
44333
44813
  left -= clipped.text.length;
44334
44814
  }
@@ -44507,7 +44987,7 @@ function workspacePatterns(readText) {
44507
44987
  }
44508
44988
  function globMatcher(pattern) {
44509
44989
  const parts = pattern.replace(/^\.\//, "").replace(/\/+$/, "").split("/");
44510
- const escape = (s) => s.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
44990
+ const escape2 = (s) => s.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
44511
44991
  let re = "";
44512
44992
  parts.forEach((part, i2) => {
44513
44993
  const first = i2 === 0;
@@ -44515,7 +44995,7 @@ function globMatcher(pattern) {
44515
44995
  re += first ? "(?:[^/]+/)*" : "(?:/[^/]+)*";
44516
44996
  return;
44517
44997
  }
44518
- const segment = part.split("*").map(escape).join("[^/]*");
44998
+ const segment = part.split("*").map(escape2).join("[^/]*");
44519
44999
  re += first || i2 === 1 && parts[0] === "**" ? segment : `/${segment}`;
44520
45000
  });
44521
45001
  return new RegExp(`^${re}$`);
@@ -44811,7 +45291,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
44811
45291
  var REPORT_COPY = "final-test-report.xml";
44812
45292
  var MAX_REPORT_BYTES = 5 * 1024 * 1024;
44813
45293
  var MAX_FILES = 200;
44814
- var RUNNER_VERSION = true ? "9.3.0-rc.46" : "dev";
45294
+ var RUNNER_VERSION = true ? "9.3.0-rc.48" : "dev";
44815
45295
  function safeDestination(base, repoPath) {
44816
45296
  if (!repoPath || (0, import_node_path24.isAbsolute)(repoPath)) return null;
44817
45297
  const destination = (0, import_node_path24.resolve)(base, repoPath);
@@ -45605,7 +46085,7 @@ async function run(env2) {
45605
46085
  const stepParams = {
45606
46086
  mode: codegenMode,
45607
46087
  ...keepOnGiveUp ? { keepOnGiveUp: true } : {},
45608
- ...conflictsOn ? { conflicts: { decided, titles: approved?.titles ?? [] } } : {},
46088
+ ...conflictsOn ? { conflicts: { decided, titles: approved?.titles ?? [], approvedTests: approved?.approvedTests ?? [] } } : {},
45609
46089
  ...approved && approved.files.length > 0 ? { approved: approved.files } : {},
45610
46090
  ...callFunction ? { callFunction } : {},
45611
46091
  ...twoPhase ? { twoPhase: true, ...packet.requiredTestTypes ? { requiredTestTypes: packet.requiredTestTypes } : {} } : {},
@@ -45662,6 +46142,8 @@ async function run(env2) {
45662
46142
  harness: codegenMode === "loop-tests" && stepParams.harness !== false,
45663
46143
  // QUIKTR-1827: a regression of an existing test is worded as a test that may expect the old behaviour where a person can be asked.
45664
46144
  conflictsOn,
46145
+ // QUIKTR-1844: and a test a person approved changing that still fails is named as an approved change that does not fit.
46146
+ ...decided.some((d) => d.decision === "TEST_CHANGED") ? { approvedDecided: decided.filter((d) => d.decision === "TEST_CHANGED") } : {},
45665
46147
  // S4: the final run of the project's tests has a clock sized from how long the baseline took and from what is left of the job.
45666
46148
  baselineMs: timedBaseline.durationMs,
45667
46149
  jobStopAtMs,
@@ -45727,10 +46209,19 @@ async function run(env2) {
45727
46209
  return { blocks: checked.unnecessary, testCount, raw: checked };
45728
46210
  }
45729
46211
  } : {},
45730
- heal: async ({ results: kept, answer, attempt: attempt2, hardStopAtMs, review }) => {
46212
+ heal: async ({ results: kept, answer, attempt: attempt2, hardStopAtMs, review, misfits }) => {
45731
46213
  const out = {};
45732
46214
  try {
45733
- return await runHealAttempt({ step: stepParams, results: kept, answer, attempt: attempt2, hardStopAtMs, out, ...review ? { review: { blocks: review.blocks } } : {} });
46215
+ return await runHealAttempt({
46216
+ step: stepParams,
46217
+ results: kept,
46218
+ answer,
46219
+ attempt: attempt2,
46220
+ hardStopAtMs,
46221
+ out,
46222
+ ...review ? { review: { blocks: review.blocks } } : {},
46223
+ ...misfits ? { misfits } : {}
46224
+ });
45734
46225
  } finally {
45735
46226
  healCalls.push({ ...out.summary ? { summary: out.summary } : {}, ...out.failure ? { failureReason: out.failure.reason } : {} });
45736
46227
  }