@quikit/quikpilot-runner 9.3.0-rc.85 → 9.3.0-rc.86

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
@@ -520,8 +520,8 @@ var require_web_tree_sitter2 = __commonJS2({
520
520
  } else if (subsectionType === WASM_DYLINK_NEEDED) {
521
521
  customSection.neededDynlibs = getStringList();
522
522
  } else if (subsectionType === WASM_DYLINK_EXPORT_INFO) {
523
- var count3 = getLEB();
524
- while (count3--) {
523
+ var count4 = getLEB();
524
+ while (count4--) {
525
525
  var symname = getString();
526
526
  var flags2 = getLEB();
527
527
  if (flags2 & WASM_SYMBOL_TLS) {
@@ -529,8 +529,8 @@ var require_web_tree_sitter2 = __commonJS2({
529
529
  }
530
530
  }
531
531
  } else if (subsectionType === WASM_DYLINK_IMPORT_INFO) {
532
- var count3 = getLEB();
533
- while (count3--) {
532
+ var count4 = getLEB();
533
+ while (count4--) {
534
534
  var modname = getString();
535
535
  var symname = getString();
536
536
  var flags2 = getLEB();
@@ -689,9 +689,9 @@ var require_web_tree_sitter2 = __commonJS2({
689
689
  }
690
690
  return func2;
691
691
  }, "getWasmTableEntry");
692
- var updateTableMap = /* @__PURE__ */ __name((offset2, count3) => {
692
+ var updateTableMap = /* @__PURE__ */ __name((offset2, count4) => {
693
693
  if (functionsInTableMap) {
694
- for (var i22 = offset2; i22 < offset2 + count3; i22++) {
694
+ for (var i22 = offset2; i22 < offset2 + count4; i22++) {
695
695
  var item = getWasmTableEntry(i22);
696
696
  if (item) {
697
697
  functionsInTableMap.set(item, i22);
@@ -2029,12 +2029,12 @@ var require_web_tree_sitter2 = __commonJS2({
2029
2029
  throw new TypeError("Argument must be a Tree");
2030
2030
  }
2031
2031
  C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);
2032
- const count3 = C.getValue(TRANSFER_BUFFER, "i32");
2032
+ const count4 = C.getValue(TRANSFER_BUFFER, "i32");
2033
2033
  const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2034
- const result = new Array(count3);
2035
- if (count3 > 0) {
2034
+ const result = new Array(count4);
2035
+ if (count4 > 0) {
2036
2036
  let address = buffer;
2037
- for (let i22 = 0; i22 < count3; i22++) {
2037
+ for (let i22 = 0; i22 < count4; i22++) {
2038
2038
  result[i22] = unmarshalRange(address);
2039
2039
  address += SIZE_OF_RANGE;
2040
2040
  }
@@ -2045,12 +2045,12 @@ var require_web_tree_sitter2 = __commonJS2({
2045
2045
  /** Get the included ranges that were used to parse the syntax tree. */
2046
2046
  getIncludedRanges() {
2047
2047
  C._ts_tree_included_ranges_wasm(this[0]);
2048
- const count3 = C.getValue(TRANSFER_BUFFER, "i32");
2048
+ const count4 = C.getValue(TRANSFER_BUFFER, "i32");
2049
2049
  const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2050
- const result = new Array(count3);
2051
- if (count3 > 0) {
2050
+ const result = new Array(count4);
2051
+ if (count4 > 0) {
2052
2052
  let address = buffer;
2053
- for (let i22 = 0; i22 < count3; i22++) {
2053
+ for (let i22 = 0; i22 < count4; i22++) {
2054
2054
  result[i22] = unmarshalRange(address);
2055
2055
  address += SIZE_OF_RANGE;
2056
2056
  }
@@ -2580,12 +2580,12 @@ var require_web_tree_sitter2 = __commonJS2({
2580
2580
  childrenForFieldId(fieldId) {
2581
2581
  marshalNode(this);
2582
2582
  C._ts_node_children_by_field_id_wasm(this.tree[0], fieldId);
2583
- const count3 = C.getValue(TRANSFER_BUFFER, "i32");
2583
+ const count4 = C.getValue(TRANSFER_BUFFER, "i32");
2584
2584
  const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2585
- const result = new Array(count3);
2586
- if (count3 > 0) {
2585
+ const result = new Array(count4);
2586
+ if (count4 > 0) {
2587
2587
  let address = buffer;
2588
- for (let i22 = 0; i22 < count3; i22++) {
2588
+ for (let i22 = 0; i22 < count4; i22++) {
2589
2589
  result[i22] = unmarshalNode(this.tree, address);
2590
2590
  address += SIZE_OF_NODE;
2591
2591
  }
@@ -2657,12 +2657,12 @@ var require_web_tree_sitter2 = __commonJS2({
2657
2657
  if (!this._children) {
2658
2658
  marshalNode(this);
2659
2659
  C._ts_node_children_wasm(this.tree[0]);
2660
- const count3 = C.getValue(TRANSFER_BUFFER, "i32");
2660
+ const count4 = C.getValue(TRANSFER_BUFFER, "i32");
2661
2661
  const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2662
- this._children = new Array(count3);
2663
- if (count3 > 0) {
2662
+ this._children = new Array(count4);
2663
+ if (count4 > 0) {
2664
2664
  let address = buffer;
2665
- for (let i22 = 0; i22 < count3; i22++) {
2665
+ for (let i22 = 0; i22 < count4; i22++) {
2666
2666
  this._children[i22] = unmarshalNode(this.tree, address);
2667
2667
  address += SIZE_OF_NODE;
2668
2668
  }
@@ -2680,12 +2680,12 @@ var require_web_tree_sitter2 = __commonJS2({
2680
2680
  if (!this._namedChildren) {
2681
2681
  marshalNode(this);
2682
2682
  C._ts_node_named_children_wasm(this.tree[0]);
2683
- const count3 = C.getValue(TRANSFER_BUFFER, "i32");
2683
+ const count4 = C.getValue(TRANSFER_BUFFER, "i32");
2684
2684
  const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2685
- this._namedChildren = new Array(count3);
2686
- if (count3 > 0) {
2685
+ this._namedChildren = new Array(count4);
2686
+ if (count4 > 0) {
2687
2687
  let address = buffer;
2688
- for (let i22 = 0; i22 < count3; i22++) {
2688
+ for (let i22 = 0; i22 < count4; i22++) {
2689
2689
  this._namedChildren[i22] = unmarshalNode(this.tree, address);
2690
2690
  address += SIZE_OF_NODE;
2691
2691
  }
@@ -3154,12 +3154,12 @@ var require_web_tree_sitter2 = __commonJS2({
3154
3154
  */
3155
3155
  get supertypes() {
3156
3156
  C._ts_language_supertypes_wasm(this[0]);
3157
- const count3 = C.getValue(TRANSFER_BUFFER, "i32");
3157
+ const count4 = C.getValue(TRANSFER_BUFFER, "i32");
3158
3158
  const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3159
- const result = new Array(count3);
3160
- if (count3 > 0) {
3159
+ const result = new Array(count4);
3160
+ if (count4 > 0) {
3161
3161
  let address = buffer;
3162
- for (let i22 = 0; i22 < count3; i22++) {
3162
+ for (let i22 = 0; i22 < count4; i22++) {
3163
3163
  result[i22] = C.getValue(address, "i16");
3164
3164
  address += SIZE_OF_SHORT;
3165
3165
  }
@@ -3171,12 +3171,12 @@ var require_web_tree_sitter2 = __commonJS2({
3171
3171
  */
3172
3172
  subtypes(supertype) {
3173
3173
  C._ts_language_subtypes_wasm(this[0], supertype);
3174
- const count3 = C.getValue(TRANSFER_BUFFER, "i32");
3174
+ const count4 = C.getValue(TRANSFER_BUFFER, "i32");
3175
3175
  const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3176
- const result = new Array(count3);
3177
- if (count3 > 0) {
3176
+ const result = new Array(count4);
3177
+ if (count4 > 0) {
3178
3178
  let address = buffer;
3179
- for (let i22 = 0; i22 < count3; i22++) {
3179
+ for (let i22 = 0; i22 < count4; i22++) {
3180
3180
  result[i22] = C.getValue(address, "i16");
3181
3181
  address += SIZE_OF_SHORT;
3182
3182
  }
@@ -3442,12 +3442,12 @@ ${JSON.stringify(symbolNames, null, 2)}`);
3442
3442
  /** Get the ranges of text that the parser will include when parsing. */
3443
3443
  getIncludedRanges() {
3444
3444
  C._ts_parser_included_ranges_wasm(this[0]);
3445
- const count3 = C.getValue(TRANSFER_BUFFER, "i32");
3445
+ const count4 = C.getValue(TRANSFER_BUFFER, "i32");
3446
3446
  const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3447
- const result = new Array(count3);
3448
- if (count3 > 0) {
3447
+ const result = new Array(count4);
3448
+ if (count4 > 0) {
3449
3449
  let address = buffer;
3450
- for (let i22 = 0; i22 < count3; i22++) {
3450
+ for (let i22 = 0; i22 < count4; i22++) {
3451
3451
  result[i22] = unmarshalRange(address);
3452
3452
  address += SIZE_OF_RANGE;
3453
3453
  }
@@ -4016,14 +4016,14 @@ ${JSON.stringify(symbolNames, null, 2)}`);
4016
4016
  matchLimit,
4017
4017
  maxStartDepth
4018
4018
  );
4019
- const count3 = C.getValue(TRANSFER_BUFFER, "i32");
4019
+ const count4 = C.getValue(TRANSFER_BUFFER, "i32");
4020
4020
  const startAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
4021
4021
  const didExceedMatchLimit = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
4022
4022
  const result = new Array();
4023
4023
  this.exceededMatchLimit = Boolean(didExceedMatchLimit);
4024
4024
  const captures = new Array();
4025
4025
  let address = startAddress;
4026
- for (let i22 = 0; i22 < count3; i22++) {
4026
+ for (let i22 = 0; i22 < count4; i22++) {
4027
4027
  const patternIndex = C.getValue(address, "i32");
4028
4028
  address += SIZE_OF_INT;
4029
4029
  const captureCount = C.getValue(address, "i32");
@@ -16351,7 +16351,7 @@ var require_JSXTransformer = __commonJS2({
16351
16351
  }
16352
16352
  function processEntity(text3, indexAfterAmpersand) {
16353
16353
  let str = "";
16354
- let count3 = 0;
16354
+ let count4 = 0;
16355
16355
  let entity;
16356
16356
  let i3 = indexAfterAmpersand;
16357
16357
  if (text3[i3] === "#") {
@@ -16379,7 +16379,7 @@ var require_JSXTransformer = __commonJS2({
16379
16379
  }
16380
16380
  }
16381
16381
  } else {
16382
- while (i3 < text3.length && count3++ < 10) {
16382
+ while (i3 < text3.length && count4++ < 10) {
16383
16383
  const ch = text3[i3];
16384
16384
  i3++;
16385
16385
  if (ch === ";") {
@@ -34021,11 +34021,11 @@ pp$1.regexp_classStringDisjunctionContents = function(state) {
34021
34021
  return result;
34022
34022
  };
34023
34023
  pp$1.regexp_classString = function(state) {
34024
- var count3 = 0;
34024
+ var count4 = 0;
34025
34025
  while (this.regexp_eatClassSetCharacter(state)) {
34026
- count3++;
34026
+ count4++;
34027
34027
  }
34028
- return count3 === 1 ? CharSetOk : CharSetString;
34028
+ return count4 === 1 ? CharSetOk : CharSetString;
34029
34029
  };
34030
34030
  pp$1.regexp_eatClassSetCharacter = function(state) {
34031
34031
  var start3 = state.pos;
@@ -35194,17 +35194,17 @@ function isOtherCheck(lang, n) {
35194
35194
  return false;
35195
35195
  }
35196
35196
  function countChecks(lang, spec, node) {
35197
- let count3 = 0;
35197
+ let count4 = 0;
35198
35198
  const walk3 = (n) => {
35199
35199
  if (spec.assertion(n)) {
35200
- count3 += 1;
35200
+ count4 += 1;
35201
35201
  return;
35202
35202
  }
35203
- if (isOtherCheck(lang, n)) count3 += 1;
35203
+ if (isOtherCheck(lang, n)) count4 += 1;
35204
35204
  for (const c of n.children) walk3(c);
35205
35205
  };
35206
35206
  walk3(node);
35207
- return count3;
35207
+ return count4;
35208
35208
  }
35209
35209
  var SPECS = {
35210
35210
  python: {
@@ -38413,7 +38413,7 @@ function prepareListFiles(args2, env2) {
38413
38413
  const slash = rest.indexOf("/");
38414
38414
  if (slash > 0) counts.set(rest.slice(0, slash), (counts.get(rest.slice(0, slash)) ?? 0) + 1);
38415
38415
  }
38416
- output.subdirs = [...counts.entries()].map(([name2, count3]) => ({ name: name2, count: count3 })).sort((a, b) => b.count - a.count || (a.name < b.name ? -1 : 1)).slice(0, 50);
38416
+ output.subdirs = [...counts.entries()].map(([name2, count4]) => ({ name: name2, count: count4 })).sort((a, b) => b.count - a.count || (a.name < b.name ? -1 : 1)).slice(0, 50);
38417
38417
  }
38418
38418
  return { result: { status: "ok", output } };
38419
38419
  }
@@ -38762,6 +38762,27 @@ function loadTextForEdit(fs2, path, maxBytes) {
38762
38762
  return { ok: true, lf: toLf(text3), ending, bom };
38763
38763
  }
38764
38764
 
38765
+ // src/redactionMarkers.ts
38766
+ var REDACTION_MARKERS = [
38767
+ "[ACCOUNT_REDACTED]",
38768
+ "[AADHAAR_REDACTED]",
38769
+ "[CARD_REDACTED]",
38770
+ "[PAN_REDACTED]",
38771
+ "[PHONE_REDACTED]"
38772
+ ];
38773
+ var REDACTED_TEXT_MESSAGE = "Not written: your text holds a placeholder such as [ACCOUNT_REDACTED] that the AI service put in place of a long number on the way, so the value is not the one you meant. Send it again with the real value written out.";
38774
+ function count(text3, marker) {
38775
+ let n = 0;
38776
+ for (let at2 = text3.indexOf(marker); at2 !== -1; at2 = text3.indexOf(marker, at2 + marker.length)) n += 1;
38777
+ return n;
38778
+ }
38779
+ function addedMarkers(after, before = "") {
38780
+ if (!after.includes("_REDACTED]")) return 0;
38781
+ let added = 0;
38782
+ for (const marker of REDACTION_MARKERS) added += Math.max(0, count(after, marker) - count(before, marker));
38783
+ return added;
38784
+ }
38785
+
38765
38786
  // src/testConflict.ts
38766
38787
  var REPORT_TEST_CONFLICT_TOOL = "report_test_conflict";
38767
38788
  var MAX_CONFLICTS_PER_STOP = 8;
@@ -38781,7 +38802,8 @@ var REJECT_MESSAGES = {
38781
38802
  still_passes_old_code: "With your replacement that test still passes on the code before this run, so it would not show the bug.",
38782
38803
  already_decided: "A person has already decided about that test. Do not report it again.",
38783
38804
  too_many_conflicts: "Too many tests have been reported already. Finish with what you have.",
38784
- 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."
38805
+ 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.",
38806
+ redacted_text: "Not recorded: replace or caseValueTo holds a placeholder such as [ACCOUNT_REDACTED] that the AI service put in place of a long number on the way, so the value is not the one you meant. Report it again with the real value written out."
38785
38807
  };
38786
38808
  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.";
38787
38809
  var AMBIGUOUS_LINES_SHOWN = 6;
@@ -39084,6 +39106,7 @@ var TestConflictTool = class {
39084
39106
  }
39085
39107
  async check(r) {
39086
39108
  const d = this.deps;
39109
+ if (addedMarkers(r.replace, r.find) + addedMarkers(r.correction.valueTo ?? "", r.correction.valueFrom ?? "") > 0) return this.reject("redacted_text");
39087
39110
  const feature = d.feature;
39088
39111
  const key = `${r.path}\0${r.testTitle}`;
39089
39112
  const helper = feature !== void 0 && r.testPath !== void 0 && !sameFile2(r.testPath, r.path);
@@ -39433,8 +39456,8 @@ var isLine = (v) => typeof v === "number" && Number.isInteger(v) && v >= 1 && v
39433
39456
  function isMisfit(v) {
39434
39457
  if (typeof v !== "object" || v === null) return false;
39435
39458
  const m = v;
39436
- const count3 = (n) => typeof n === "number" && Number.isInteger(n) && n >= 0 && n <= 1e4;
39437
- 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));
39459
+ const count4 = (n) => typeof n === "number" && Number.isInteger(n) && n >= 0 && n <= 1e4;
39460
+ return count4(m.failingRows) && count4(m.totalRows) && m.failingRows <= m.totalRows && Array.isArray(m.examples) && m.examples.length <= 3 && m.examples.every((e) => isStr(e, 120));
39438
39461
  }
39439
39462
  function isStale(v) {
39440
39463
  if (typeof v !== "object" || v === null) return false;
@@ -41865,9 +41888,9 @@ function countRemovedLines(currentContent, newContent) {
41865
41888
  }
41866
41889
  let removed = 0;
41867
41890
  for (const line2 of currentContent.split("\n")) {
41868
- const count3 = remaining.get(line2) ?? 0;
41869
- if (count3 > 0) {
41870
- remaining.set(line2, count3 - 1);
41891
+ const count4 = remaining.get(line2) ?? 0;
41892
+ if (count4 > 0) {
41893
+ remaining.set(line2, count4 - 1);
41871
41894
  } else {
41872
41895
  removed++;
41873
41896
  }
@@ -42201,6 +42224,11 @@ async function runCodegen(gateway, targets, workspaceListing, requiredTests, den
42201
42224
  })
42202
42225
  );
42203
42226
  }
42227
+ if (addedMarkers(newContent, currentContent) > 0) {
42228
+ throw new Error(
42229
+ `Codegen output for ${target.path} holds a placeholder the AI service put in place of a long number (such as [ACCOUNT_REDACTED]) \u2014 refusing to apply it.`
42230
+ );
42231
+ }
42204
42232
  if (!isNewFile) {
42205
42233
  const suspectReason = looksLikeTruncatedRewrite(target, currentContent, newContent);
42206
42234
  if (suspectReason) {
@@ -43525,7 +43553,7 @@ var CodegenAttemptsExhausted = class extends Error {
43525
43553
  }
43526
43554
  };
43527
43555
  var RULE_SHAPE = /^[a-z][a-z0-9_]{0,39}$/;
43528
- function count(n) {
43556
+ function count2(n) {
43529
43557
  return typeof n === "number" && Number.isInteger(n) ? Math.min(MAX_PREVIOUS_COUNT, Math.max(0, n)) : 0;
43530
43558
  }
43531
43559
  function isRecord(x) {
@@ -43537,12 +43565,12 @@ function testRunFrom(answer) {
43537
43565
  if (!numbers.every((k) => typeof answer[k] === "number") || !Array.isArray(answer.failingTests)) return void 0;
43538
43566
  const failingTests = answer.failingTests.filter((n) => typeof n === "string").map((n) => n.slice(0, MAX_PREVIOUS_NAME_CHARS)).filter((n) => n.length > 0).slice(0, MAX_PREVIOUS_TESTS);
43539
43567
  const run3 = {
43540
- passed: count(answer.passed),
43541
- failed: count(answer.failed),
43542
- total: count(answer.total),
43543
- regressions: count(answer.regressions),
43544
- newFailures: count(answer.newFailures),
43545
- alreadyFailing: count(answer.alreadyFailing),
43568
+ passed: count2(answer.passed),
43569
+ failed: count2(answer.failed),
43570
+ total: count2(answer.total),
43571
+ regressions: count2(answer.regressions),
43572
+ newFailures: count2(answer.newFailures),
43573
+ alreadyFailing: count2(answer.alreadyFailing),
43546
43574
  failingTests
43547
43575
  };
43548
43576
  if (isRecord(answer.messages)) {
@@ -43737,11 +43765,11 @@ function foldersAbove(path) {
43737
43765
  function makeGuidanceFinder(i3) {
43738
43766
  const given = new Set(i3.alreadyShown ?? []);
43739
43767
  const done = new Set([...given].map((p) => p.slice(0, Math.max(0, p.lastIndexOf("/")))));
43740
- let count3 = 0;
43768
+ let count4 = 0;
43741
43769
  return {
43742
- shown: () => count3,
43770
+ shown: () => count4,
43743
43771
  forRead(path) {
43744
- if (count3 >= GUIDANCE_PER_RUN) return void 0;
43772
+ if (count4 >= GUIDANCE_PER_RUN) return void 0;
43745
43773
  for (const folder of foldersAbove(path)) {
43746
43774
  if (done.has(folder)) continue;
43747
43775
  for (const name2 of GUIDANCE_NAMES) {
@@ -43753,7 +43781,7 @@ function makeGuidanceFinder(i3) {
43753
43781
  const text3 = cutText2((i3.scrub ? i3.scrub(raw) : raw).trim(), GUIDANCE_TEXT_CHARS);
43754
43782
  if (text3.length === 0) continue;
43755
43783
  done.add(folder);
43756
- count3 += 1;
43784
+ count4 += 1;
43757
43785
  return { path: candidate, text: text3 };
43758
43786
  }
43759
43787
  }
@@ -47465,6 +47493,7 @@ function createCodegenWorkspace(args2) {
47465
47493
  }
47466
47494
  const find = a.find;
47467
47495
  const replace = a.replace;
47496
+ if (addedMarkers(replace, find) > 0) return refused("redacted_text", REDACTED_TEXT_MESSAGE);
47468
47497
  return {
47469
47498
  key: JSON.stringify({ path, find, replace }),
47470
47499
  exec: () => {
@@ -47544,6 +47573,7 @@ function createCodegenWorkspace(args2) {
47544
47573
  for (const p of env3.listing) if (p.startsWith(`${path}/`)) return refused("is_directory", "That path is not allowed.");
47545
47574
  if (!baseFs.parentInside(path)) return refused("outside_workspace", "That path is not allowed.");
47546
47575
  const content = a.content;
47576
+ if (addedMarkers(content, overlay.get(path)?.lf ?? "") > 0) return refused("redacted_text", REDACTED_TEXT_MESSAGE);
47547
47577
  return {
47548
47578
  key: JSON.stringify({ path, content }),
47549
47579
  exec: () => {
@@ -47882,7 +47912,7 @@ var MAX_NOTE_CHARS = 500;
47882
47912
  var MAX_PATH_CHARS3 = 300;
47883
47913
  var MAX_REASON_CHARS = 200;
47884
47914
  var isRecord2 = (x) => typeof x === "object" && x !== null && !Array.isArray(x);
47885
- var count2 = (n) => typeof n === "number" && Number.isInteger(n) ? Math.min(1e5, Math.max(0, n)) : 0;
47915
+ var count3 = (n) => typeof n === "number" && Number.isInteger(n) ? Math.min(1e5, Math.max(0, n)) : 0;
47886
47916
  function callOf(call, result) {
47887
47917
  if (!result) return null;
47888
47918
  const args2 = isRecord2(call.args) ? call.args : {};
@@ -47892,7 +47922,7 @@ function callOf(call, result) {
47892
47922
  if (typeof result.reason === "string" && result.reason.length > 0) out2.reason = result.reason.slice(0, MAX_REASON_CHARS);
47893
47923
  const o = result.output;
47894
47924
  if (call.name === "run_tests" && isRecord2(o) && typeof o.passed === "number" && typeof o.failed === "number") {
47895
- out2.tests = { passed: count2(o.passed), failed: count2(o.failed), regressions: count2(o.regressions), newFailures: count2(o.newFailures) };
47925
+ out2.tests = { passed: count3(o.passed), failed: count3(o.failed), regressions: count3(o.regressions), newFailures: count3(o.newFailures) };
47896
47926
  if (o.scope === "file") out2.scope = "file";
47897
47927
  }
47898
47928
  return out2;
@@ -50170,7 +50200,7 @@ async function runCodegenLoop(args2, deps) {
50170
50200
  refused: ledger.refused,
50171
50201
  stopReason,
50172
50202
  reads: [...reads],
50173
- edits: [...ws.edits.entries()].map(([path, count3]) => ({ path, count: count3 })),
50203
+ edits: [...ws.edits.entries()].map(([path, count4]) => ({ path, count: count4 })),
50174
50204
  created: [...ws.created.entries()].map(([path, chars]) => ({ path, chars })),
50175
50205
  statusCounts: { ...statusCounts },
50176
50206
  syntaxWarnings: ws.syntaxWarnings,
@@ -50898,6 +50928,22 @@ async function runCodegenLoop(args2, deps) {
50898
50928
  }
50899
50929
  }
50900
50930
 
50931
+ // src/errorName.ts
50932
+ var NAME_SHAPE = /^[A-Z][A-Za-z0-9]{0,59}$/;
50933
+ var CODE_SHAPE = /^E[A-Z0-9_]{1,30}$/;
50934
+ function errorName(err2) {
50935
+ if (err2 === void 0) return "none";
50936
+ if (!(err2 instanceof Error)) return "other";
50937
+ const name2 = err2.name === "Error" ? err2.constructor?.name ?? err2.name : err2.name;
50938
+ return typeof name2 === "string" && NAME_SHAPE.test(name2) ? name2 : "other";
50939
+ }
50940
+ function internalCause(failure) {
50941
+ if (failure.reason !== "internal_error") return {};
50942
+ const cause = failure.cause;
50943
+ const code = cause instanceof Error ? cause.code : void 0;
50944
+ return { cause: errorName(cause), ...typeof code === "string" && CODE_SHAPE.test(code) ? { causeCode: code } : {} };
50945
+ }
50946
+
50901
50947
  // src/codegenPhases.ts
50902
50948
  var QP_TOKEN = /\[QP-[^\]\s]+\]/;
50903
50949
  function frozenFailingTarget(failingTests, frozen, textOf2) {
@@ -51011,7 +51057,7 @@ async function runPhases(i3) {
51011
51057
  } catch (err2) {
51012
51058
  const f = asFailure(err2);
51013
51059
  phases.push(record("tests", "failed", f.summary));
51014
- i3.log({ event: "codegen.phase_end", attempt: i3.attempt, phase: "tests", outcome: "failed", reason: f.reason });
51060
+ i3.log({ event: "codegen.phase_end", attempt: i3.attempt, phase: "tests", outcome: "failed", reason: f.reason, ...internalCause(f) });
51015
51061
  return { failure: recorded(f, "tests"), phases };
51016
51062
  }
51017
51063
  phases.push(record("tests", "finished", d1.summary, d1.redUnproven?.length));
@@ -51050,7 +51096,7 @@ async function runPhases(i3) {
51050
51096
  } catch (err2) {
51051
51097
  const f = asFailure(err2);
51052
51098
  phases.push(record("code", "failed", f.summary));
51053
- i3.log({ event: "codegen.phase_end", attempt: i3.attempt, phase: "code", outcome: "failed", reason: f.reason });
51099
+ i3.log({ event: "codegen.phase_end", attempt: i3.attempt, phase: "code", outcome: "failed", reason: f.reason, ...internalCause(f) });
51054
51100
  return { failure: recorded(f, "code"), tests, phases };
51055
51101
  }
51056
51102
  summaries.push({ phase: "code", summary: d2.summary });
@@ -51081,7 +51127,7 @@ async function runPhases(i3) {
51081
51127
  } catch (err2) {
51082
51128
  const f = asFailure(err2);
51083
51129
  phases.push(record("amend", "failed", f.summary));
51084
- i3.log({ event: "codegen.phase_end", attempt: i3.attempt, phase: "amend", outcome: "failed", reason: f.reason });
51130
+ i3.log({ event: "codegen.phase_end", attempt: i3.attempt, phase: "amend", outcome: "failed", reason: f.reason, ...internalCause(f) });
51085
51131
  const disagree = new CodegenLoopFailure("test_case_disagree", void 0, f, `${amend.length} test file(s) and the approved cases still disagree`, f.told);
51086
51132
  disagree.summary = f.summary ?? d2.summary;
51087
51133
  return { failure: recorded(disagree, "amend"), tests, phases, final: true };
@@ -51144,7 +51190,7 @@ function mergePhaseSummaries(parts2, phases) {
51144
51190
  toolCalls: parts2.reduce((s, p) => s + p.summary.toolCalls, 0),
51145
51191
  refused: parts2.reduce((s, p) => s + p.summary.refused, 0),
51146
51192
  reads: parts2.flatMap((p) => p.summary.reads),
51147
- edits: [...edits.entries()].map(([path, count3]) => ({ path, count: count3 })),
51193
+ edits: [...edits.entries()].map(([path, count4]) => ({ path, count: count4 })),
51148
51194
  created: [...created.entries()].map(([path, chars]) => ({ path, chars })),
51149
51195
  statusCounts,
51150
51196
  syntaxWarnings: parts2.reduce((s, p) => s + (p.summary.syntaxWarnings ?? 0), 0),
@@ -52407,7 +52453,7 @@ async function runCodegenStep(p) {
52407
52453
  return finish(first.done);
52408
52454
  }
52409
52455
  const f1 = first.failure;
52410
- 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 });
52456
+ log({ event: "codegen.attempt_end", attempt: 1, outcome: "failed", reason: f1.reason, ...internalCause(f1), ...f1.afterRecovery ? { afterRecovery: true } : {}, turns: f1.summary?.turns ?? 0, toolCalls: f1.summary?.toolCalls ?? 0, durationMs: firstMs });
52411
52457
  const said = f1.detail ? `: ${f1.detail}` : "";
52412
52458
  if (f1.reason === "contract_rejected" && f1.late !== true) {
52413
52459
  p.out.loop = buildCodegenLoopRecord({ ...f1.summary ?? NO_SUMMARY, stopReason: "fallback", fellBack: true, fallbackReason: f1.reason });
@@ -52449,7 +52495,7 @@ async function runCodegenStep(p) {
52449
52495
  return finish(second.done, [firstRecord, { n: 2, outcome: "finished", turns: second.done.summary.turns, toolCalls: second.done.summary.toolCalls }]);
52450
52496
  }
52451
52497
  const f2 = second.failure;
52452
- log({ event: "codegen.attempt_end", attempt: 2, outcome: "failed", reason: f2.reason, ...f2.afterRecovery ? { afterRecovery: true } : {}, turns: f2.summary?.turns ?? 0, toolCalls: f2.summary?.toolCalls ?? 0, durationMs: secondMs });
52498
+ log({ event: "codegen.attempt_end", attempt: 2, outcome: "failed", reason: f2.reason, ...internalCause(f2), ...f2.afterRecovery ? { afterRecovery: true } : {}, turns: f2.summary?.turns ?? 0, toolCalls: f2.summary?.toolCalls ?? 0, durationMs: secondMs });
52453
52499
  throw lose(p, f2.summary, [firstRecord, failedAttempt(2, f2)], f2.reason === "out_of_time" ? "out_of_time" : "failed", f2.unreportable, [f1, f2]);
52454
52500
  }
52455
52501
 
@@ -54428,7 +54474,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
54428
54474
  var REPORT_COPY = "final-test-report.xml";
54429
54475
  var MAX_REPORT_BYTES = 5 * 1024 * 1024;
54430
54476
  var MAX_FILES = 200;
54431
- var RUNNER_VERSION = true ? "9.3.0-rc.85" : "dev";
54477
+ var RUNNER_VERSION = true ? "9.3.0-rc.86" : "dev";
54432
54478
  function safeDestination(base, repoPath) {
54433
54479
  if (!repoPath || (0, import_node_path28.isAbsolute)(repoPath)) return null;
54434
54480
  const destination = (0, import_node_path28.resolve)(base, repoPath);
@@ -54708,8 +54754,8 @@ function buildTestDiscovery(i3) {
54708
54754
  }
54709
54755
  function placeUnmapped(cases, listing, workspaceRoot, readText) {
54710
54756
  const files = /* @__PURE__ */ new Set();
54711
- let count3 = 0;
54712
- if (cases.length === 0) return { files, count: count3 };
54757
+ let count4 = 0;
54758
+ if (cases.length === 0) return { files, count: count4 };
54713
54759
  const root = workspaceRoot ? withoutDotSlash(slashes(workspaceRoot)).replace(/\/+$/, "") : "";
54714
54760
  const inListing2 = (p) => listing.has(p) ? p : root && listing.has(`${root}/${p}`) ? `${root}/${p}` : null;
54715
54761
  const isTest = testRule(null);
@@ -54771,10 +54817,10 @@ function placeUnmapped(cases, listing, workspaceRoot, readText) {
54771
54817
  const hit = pythonFile(classname) ?? goFile(classname, c.name);
54772
54818
  if (hit) {
54773
54819
  files.add(hit);
54774
- count3 += 1;
54820
+ count4 += 1;
54775
54821
  }
54776
54822
  }
54777
- return { files, count: count3 };
54823
+ return { files, count: count4 };
54778
54824
  }
54779
54825
  var DEFAULT_DISCOVERY_WAIT_MS = 9e4;
54780
54826
  var MAX_DISCOVERY_WAIT_MS = 36e5;
@@ -55048,6 +55094,7 @@ async function runTargeting(gateway, design, workspaceRoot, workspaceListing, re
55048
55094
  let summary;
55049
55095
  let runtimeCode;
55050
55096
  let reason;
55097
+ let causeFields = {};
55051
55098
  try {
55052
55099
  const deps = { secrets: [gateway.token], ...options.loopDeps, post: (contextData, signal) => postTargeting(gateway, contextData, signal) };
55053
55100
  const looped = await withoutHintsIfRefused(
@@ -55073,6 +55120,7 @@ async function runTargeting(gateway, design, workspaceRoot, workspaceListing, re
55073
55120
  reason = err2.reason;
55074
55121
  runtimeCode = err2.runtimeCode;
55075
55122
  summary = err2.summary ?? summary;
55123
+ causeFields = internalCause(err2);
55076
55124
  } else {
55077
55125
  reason = "final_invalid";
55078
55126
  }
@@ -55096,6 +55144,7 @@ async function runTargeting(gateway, design, workspaceRoot, workspaceListing, re
55096
55144
  log({
55097
55145
  event: "targeting.loop_fallback",
55098
55146
  reason,
55147
+ ...causeFields,
55099
55148
  turn: fellBack.turns,
55100
55149
  toolCalls: fellBack.toolCalls,
55101
55150
  ...runtimeCode && CODE_LIKE.test(runtimeCode) ? { runtimeCode } : {}
@@ -55135,6 +55184,7 @@ async function runMapTargeting(gateway, design, workspaceRoot, scope, requiredTe
55135
55184
  const baseContext = buildMapContextData(scope.repoMap, design, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals, ticketHints);
55136
55185
  const repoView = repoViewOf(scope);
55137
55186
  let reason;
55187
+ let causeFields = {};
55138
55188
  let hintsWarning;
55139
55189
  try {
55140
55190
  const deps = { secrets: [gateway.token], ...options.loopDeps, post: (contextData, signal) => postTargeting(gateway, contextData, signal) };
@@ -55156,8 +55206,9 @@ async function runMapTargeting(gateway, design, workspaceRoot, scope, requiredTe
55156
55206
  } catch (err2) {
55157
55207
  if (err2 instanceof DeniedPathError || err2 instanceof SafetyRefusalError) throw err2;
55158
55208
  reason = err2 instanceof LoopFailure ? err2.reason : "final_invalid";
55209
+ if (err2 instanceof LoopFailure) causeFields = internalCause(err2);
55159
55210
  }
55160
- log({ event: "targeting.map_failed", reason });
55211
+ log({ event: "targeting.map_failed", reason, ...causeFields });
55161
55212
  throw new MapModeError("targeting", reason);
55162
55213
  }
55163
55214
  var TICKET_HINTS_REFUSED_WARNING = "QuikPilot's targeting ran without the files and routes the request names (the AI service did not accept them).";
@@ -56470,7 +56521,7 @@ async function runInvestigateLoop(args2, deps) {
56470
56521
  } catch (err2) {
56471
56522
  const failure = err2 instanceof InvestigateFailure ? err2 : new InvestigateFailure("internal_error", err2);
56472
56523
  failure.summary ??= snapshot("failed");
56473
- log({ event: "investigate.loop_failed", reason: failure.reason, turns, toolCalls: ledger.toolCalls });
56524
+ log({ event: "investigate.loop_failed", reason: failure.reason, ...internalCause(failure), turns, toolCalls: ledger.toolCalls });
56474
56525
  throw failure;
56475
56526
  }
56476
56527
  }