@quikit/quikpilot-runner 9.3.0-rc.84 → 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;
@@ -49621,6 +49651,92 @@ function partMissingSentence(missing, opts = {}) {
49621
49651
  return `${start3} ${missing[0] ? item(missing[0], true) : ""}`.slice(0, MAX_REFUSED_SENTENCE_CHARS);
49622
49652
  }
49623
49653
 
49654
+ // src/ticketHints.ts
49655
+ var CRITERIA_WORDING_KEY = "criteriaWording";
49656
+ var MAX_HINT_FILES = 20;
49657
+ var MAX_HINT_ROUTES = 10;
49658
+ var MAX_ROUTE_FILES = 3;
49659
+ var MAX_ADDRESS_CHARS = 200;
49660
+ var MAX_HINT_NAMES = 20;
49661
+ var MAX_NAME_CHARS4 = 120;
49662
+ var MAX_HINT_TESTS = 10;
49663
+ var MAX_TEST_CHARS = 200;
49664
+ var MAX_CRITERIA = 20;
49665
+ var MAX_CRITERION_ID_CHARS = 40;
49666
+ var MAX_STATEMENT_CHARS = 500;
49667
+ var MAX_QUOTE_CHARS2 = 200;
49668
+ var METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
49669
+ var isRecord5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
49670
+ var strings = (v) => Array.isArray(v) ? v.filter((s) => typeof s === "string") : [];
49671
+ var oneLine2 = (s, max) => s.trim() !== "" && s.length <= max && !/[\r\n]/.test(s);
49672
+ var unique3 = (xs) => [...new Set(xs)];
49673
+ var MAX_PATH_CHARS5 = 300;
49674
+ function cleanPath2(p) {
49675
+ return p !== "" && p.length <= MAX_PATH_CHARS5 && !p.startsWith("/") && !p.includes("\\") && !/[\u0000-\u001f\u007f]/.test(p) && p.split("/").every((seg) => seg !== "" && seg !== "." && seg !== "..");
49676
+ }
49677
+ function cleanAddress(a) {
49678
+ return oneLine2(a, MAX_ADDRESS_CHARS) && a.startsWith("/") && !a.startsWith("//") && !/\s/.test(a);
49679
+ }
49680
+ function prepareTicketHints(raw, listing, deniedPaths) {
49681
+ const counts = { files: 0, routes: 0, routeFiles: 0, names: 0, tests: 0, dropped: 0 };
49682
+ if (!isRecord5(raw)) return { counts };
49683
+ const listed = listing instanceof Set ? listing : new Set(listing);
49684
+ const denied = [...deniedPaths];
49685
+ const usable = (p) => cleanPath2(p) && listed.has(p) && matchesDeniedPath(p, denied) === null;
49686
+ const named2 = unique3(strings(raw.paths).map((p) => p.trim()));
49687
+ const files = named2.filter(usable).slice(0, MAX_HINT_FILES);
49688
+ counts.dropped = named2.filter((p) => !usable(p)).length;
49689
+ const routeFiles = [];
49690
+ for (const file of [...listed].sort()) {
49691
+ const address = routeAddressOf(file);
49692
+ if (address !== null && usable(file)) routeFiles.push({ file, address });
49693
+ }
49694
+ const routes = [];
49695
+ const seen = /* @__PURE__ */ new Set();
49696
+ for (const r of Array.isArray(raw.routes) ? raw.routes : []) {
49697
+ if (routes.length >= MAX_HINT_ROUTES) break;
49698
+ if (!isRecord5(r) || typeof r.address !== "string") continue;
49699
+ const address = r.address.trim();
49700
+ if (!cleanAddress(address)) continue;
49701
+ const method = typeof r.method === "string" && METHODS.has(r.method.toUpperCase()) ? r.method.toUpperCase() : void 0;
49702
+ const key = `${method ?? ""} ${address}`;
49703
+ if (seen.has(key)) continue;
49704
+ seen.add(key);
49705
+ const answering = routeFiles.filter((f) => addressMatches(f.address, address));
49706
+ answering.sort((a, b) => Number(b.address === address) - Number(a.address === address) || a.file.localeCompare(b.file));
49707
+ const filesOf = answering.slice(0, MAX_ROUTE_FILES).map((f) => f.file);
49708
+ routes.push({ address, ...method ? { method } : {}, files: filesOf });
49709
+ }
49710
+ const names = unique3(strings(raw.names).map((s) => s.trim())).filter((s) => oneLine2(s, MAX_NAME_CHARS4)).slice(0, MAX_HINT_NAMES);
49711
+ const tests = unique3(strings(raw.tests).map((s) => s.trim())).filter((s) => oneLine2(s, MAX_TEST_CHARS)).slice(0, MAX_HINT_TESTS);
49712
+ counts.files = files.length;
49713
+ counts.routes = routes.length;
49714
+ counts.routeFiles = routes.reduce((n, r) => n + r.files.length, 0);
49715
+ counts.names = names.length;
49716
+ counts.tests = tests.length;
49717
+ const hints = {
49718
+ ...files.length > 0 ? { files } : {},
49719
+ ...routes.length > 0 ? { routes } : {},
49720
+ ...names.length > 0 ? { names } : {},
49721
+ ...tests.length > 0 ? { tests } : {}
49722
+ };
49723
+ return Object.keys(hints).length > 0 ? { hints, counts } : { counts };
49724
+ }
49725
+ function prepareCriteriaWording(raw) {
49726
+ if (!Array.isArray(raw)) return void 0;
49727
+ const out2 = [];
49728
+ for (const c of raw) {
49729
+ if (out2.length >= MAX_CRITERIA) break;
49730
+ if (!isRecord5(c) || typeof c.id !== "string" || typeof c.statement !== "string") continue;
49731
+ const id = c.id.trim();
49732
+ const statement = c.statement.trim().slice(0, MAX_STATEMENT_CHARS).trim();
49733
+ if (!oneLine2(id, MAX_CRITERION_ID_CHARS) || statement === "") continue;
49734
+ const quote = typeof c.quote === "string" ? c.quote.trim().slice(0, MAX_QUOTE_CHARS2).trim() : "";
49735
+ out2.push({ id, statement, ...quote !== "" ? { quote } : {} });
49736
+ }
49737
+ return out2.length > 0 ? out2 : void 0;
49738
+ }
49739
+
49624
49740
  // src/sameFailureHint.ts
49625
49741
  var MAX_NAMES = 2;
49626
49742
  var MAX_HINT_CHARS = 300;
@@ -49726,6 +49842,8 @@ var CodegenLoopFailure = class extends Error {
49726
49842
  featureKey;
49727
49843
  /** QUIKTR-2445: the AI Runtime refused a request that carried `databaseChange` (the step then stops `needs_database_change`). */
49728
49844
  databaseKey;
49845
+ /** QUIKTR-2509: the AI Runtime refused a request that carried `criteriaWording` (the step then asks again without it). Wire only. */
49846
+ criteriaKey;
49729
49847
  /** QUIKTR-2468: the refusal came on a later turn, not the loop's first request: about that request, never the version. */
49730
49848
  late;
49731
49849
  constructor(reason, runtimeCode, cause, detail, told) {
@@ -50082,7 +50200,7 @@ async function runCodegenLoop(args2, deps) {
50082
50200
  refused: ledger.refused,
50083
50201
  stopReason,
50084
50202
  reads: [...reads],
50085
- edits: [...ws.edits.entries()].map(([path, count3]) => ({ path, count: count3 })),
50203
+ edits: [...ws.edits.entries()].map(([path, count4]) => ({ path, count: count4 })),
50086
50204
  created: [...ws.created.entries()].map(([path, chars]) => ({ path, chars })),
50087
50205
  statusCounts: { ...statusCounts },
50088
50206
  syntaxWarnings: ws.syntaxWarnings,
@@ -50321,6 +50439,7 @@ async function runCodegenLoop(args2, deps) {
50321
50439
  const blames = (key) => !late || refusalText.includes(key);
50322
50440
  if (code === "CONTRACT_REJECTED" && contextData[FEATURE_TEST_UPDATES_KEY] === true && blames(FEATURE_TEST_UPDATES_KEY)) failure.featureKey = true;
50323
50441
  if (code === "CONTRACT_REJECTED" && contextData[DATABASE_CHANGE_KEY] !== void 0 && blames(DATABASE_CHANGE_KEY)) failure.databaseKey = true;
50442
+ if (code === "CONTRACT_REJECTED" && contextData[CRITERIA_WORDING_KEY] !== void 0 && blames(CRITERIA_WORDING_KEY)) failure.criteriaKey = true;
50324
50443
  throw failure;
50325
50444
  }
50326
50445
  if (envelope?.success === false) {
@@ -50809,6 +50928,22 @@ async function runCodegenLoop(args2, deps) {
50809
50928
  }
50810
50929
  }
50811
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
+
50812
50947
  // src/codegenPhases.ts
50813
50948
  var QP_TOKEN = /\[QP-[^\]\s]+\]/;
50814
50949
  function frozenFailingTarget(failingTests, frozen, textOf2) {
@@ -50922,7 +51057,7 @@ async function runPhases(i3) {
50922
51057
  } catch (err2) {
50923
51058
  const f = asFailure(err2);
50924
51059
  phases.push(record("tests", "failed", f.summary));
50925
- 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) });
50926
51061
  return { failure: recorded(f, "tests"), phases };
50927
51062
  }
50928
51063
  phases.push(record("tests", "finished", d1.summary, d1.redUnproven?.length));
@@ -50961,7 +51096,7 @@ async function runPhases(i3) {
50961
51096
  } catch (err2) {
50962
51097
  const f = asFailure(err2);
50963
51098
  phases.push(record("code", "failed", f.summary));
50964
- 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) });
50965
51100
  return { failure: recorded(f, "code"), tests, phases };
50966
51101
  }
50967
51102
  summaries.push({ phase: "code", summary: d2.summary });
@@ -50992,7 +51127,7 @@ async function runPhases(i3) {
50992
51127
  } catch (err2) {
50993
51128
  const f = asFailure(err2);
50994
51129
  phases.push(record("amend", "failed", f.summary));
50995
- 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) });
50996
51131
  const disagree = new CodegenLoopFailure("test_case_disagree", void 0, f, `${amend.length} test file(s) and the approved cases still disagree`, f.told);
50997
51132
  disagree.summary = f.summary ?? d2.summary;
50998
51133
  return { failure: recorded(disagree, "amend"), tests, phases, final: true };
@@ -51055,7 +51190,7 @@ function mergePhaseSummaries(parts2, phases) {
51055
51190
  toolCalls: parts2.reduce((s, p) => s + p.summary.toolCalls, 0),
51056
51191
  refused: parts2.reduce((s, p) => s + p.summary.refused, 0),
51057
51192
  reads: parts2.flatMap((p) => p.summary.reads),
51058
- edits: [...edits.entries()].map(([path, count3]) => ({ path, count: count3 })),
51193
+ edits: [...edits.entries()].map(([path, count4]) => ({ path, count: count4 })),
51059
51194
  created: [...created.entries()].map(([path, chars]) => ({ path, chars })),
51060
51195
  statusCounts,
51061
51196
  syntaxWarnings: parts2.reduce((s, p) => s + (p.summary.syntaxWarnings ?? 0), 0),
@@ -52023,6 +52158,7 @@ function buildCodegenLoopArgs(p, context = collectLoopContext({
52023
52158
  );
52024
52159
  }
52025
52160
  if (p.outOfScope.length > 0) baseContext.outOfScope = p.outOfScope;
52161
+ if (p.criteriaWording && p.criteriaWording.length > 0) baseContext[CRITERIA_WORDING_KEY] = p.criteriaWording;
52026
52162
  return {
52027
52163
  baseContext,
52028
52164
  targets: p.targets,
@@ -52236,6 +52372,13 @@ async function runCodegenStep(p) {
52236
52372
  log({ event: "codegen.attempt_start", attempt: 1 });
52237
52373
  const firstStarted = now();
52238
52374
  let first = await attempt2();
52375
+ if ("failure" in first && first.failure.reason === "contract_rejected" && first.failure.criteriaKey === true && p.criteriaWording) {
52376
+ log({ event: "codegen.version_fallback", from: "criteria_wording" });
52377
+ p.criteriaWording = void 0;
52378
+ const kept = "tests" in first ? first.tests : void 0;
52379
+ args2 = buildCodegenLoopArgs(p, context);
52380
+ first = await attempt2(void 0, 1, kept);
52381
+ }
52239
52382
  if ("failure" in first && first.failure.reason === "contract_rejected" && first.failure.featureKey === true && p.featureTestUpdates === true) {
52240
52383
  log({ event: "codegen.version_fallback", from: "feature_test_updates" });
52241
52384
  p.featureTestUpdates = false;
@@ -52310,7 +52453,7 @@ async function runCodegenStep(p) {
52310
52453
  return finish(first.done);
52311
52454
  }
52312
52455
  const f1 = first.failure;
52313
- 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 });
52314
52457
  const said = f1.detail ? `: ${f1.detail}` : "";
52315
52458
  if (f1.reason === "contract_rejected" && f1.late !== true) {
52316
52459
  p.out.loop = buildCodegenLoopRecord({ ...f1.summary ?? NO_SUMMARY, stopReason: "fallback", fellBack: true, fallbackReason: f1.reason });
@@ -52352,7 +52495,7 @@ async function runCodegenStep(p) {
52352
52495
  return finish(second.done, [firstRecord, { n: 2, outcome: "finished", turns: second.done.summary.turns, toolCalls: second.done.summary.toolCalls }]);
52353
52496
  }
52354
52497
  const f2 = second.failure;
52355
- 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 });
52356
52499
  throw lose(p, f2.summary, [firstRecord, failedAttempt(2, f2)], f2.reason === "out_of_time" ? "out_of_time" : "failed", f2.unreportable, [f1, f2]);
52357
52500
  }
52358
52501
 
@@ -53307,7 +53450,7 @@ function describeAutomationCoverageViolations(check) {
53307
53450
  var estraverse5 = __toESM2(require_estraverse());
53308
53451
  var MAX_UNSUPPLIED_ENTRIES = 10;
53309
53452
  var MAX_UNSUPPLIED_NAMES = 5;
53310
- var MAX_NAME_CHARS4 = 80;
53453
+ var MAX_NAME_CHARS5 = 80;
53311
53454
  var MAX_FUNCTION_CHARS = 120;
53312
53455
  var FUNCTION_TYPES = /* @__PURE__ */ new Set(["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"]);
53313
53456
  var IDENTIFIER_NAME = /^[A-Za-z_$][\w$]*$/;
@@ -53448,7 +53591,7 @@ function findUnsuppliedInputs(input) {
53448
53591
  if (isCallback(site)) continue;
53449
53592
  const names = [];
53450
53593
  for (const { name: name2 } of readsOf(site)) {
53451
- if (!IDENTIFIER_NAME.test(name2) || name2.length > MAX_NAME_CHARS4) continue;
53594
+ if (!IDENTIFIER_NAME.test(name2) || name2.length > MAX_NAME_CHARS5) continue;
53452
53595
  if (known.has(name2) || supplied.has(name2) || names.includes(name2)) continue;
53453
53596
  names.push(name2);
53454
53597
  }
@@ -54331,7 +54474,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
54331
54474
  var REPORT_COPY = "final-test-report.xml";
54332
54475
  var MAX_REPORT_BYTES = 5 * 1024 * 1024;
54333
54476
  var MAX_FILES = 200;
54334
- var RUNNER_VERSION = true ? "9.3.0-rc.84" : "dev";
54477
+ var RUNNER_VERSION = true ? "9.3.0-rc.86" : "dev";
54335
54478
  function safeDestination(base, repoPath) {
54336
54479
  if (!repoPath || (0, import_node_path28.isAbsolute)(repoPath)) return null;
54337
54480
  const destination = (0, import_node_path28.resolve)(base, repoPath);
@@ -54611,8 +54754,8 @@ function buildTestDiscovery(i3) {
54611
54754
  }
54612
54755
  function placeUnmapped(cases, listing, workspaceRoot, readText) {
54613
54756
  const files = /* @__PURE__ */ new Set();
54614
- let count3 = 0;
54615
- if (cases.length === 0) return { files, count: count3 };
54757
+ let count4 = 0;
54758
+ if (cases.length === 0) return { files, count: count4 };
54616
54759
  const root = workspaceRoot ? withoutDotSlash(slashes(workspaceRoot)).replace(/\/+$/, "") : "";
54617
54760
  const inListing2 = (p) => listing.has(p) ? p : root && listing.has(`${root}/${p}`) ? `${root}/${p}` : null;
54618
54761
  const isTest = testRule(null);
@@ -54674,10 +54817,10 @@ function placeUnmapped(cases, listing, workspaceRoot, readText) {
54674
54817
  const hit = pythonFile(classname) ?? goFile(classname, c.name);
54675
54818
  if (hit) {
54676
54819
  files.add(hit);
54677
- count3 += 1;
54820
+ count4 += 1;
54678
54821
  }
54679
54822
  }
54680
- return { files, count: count3 };
54823
+ return { files, count: count4 };
54681
54824
  }
54682
54825
  var DEFAULT_DISCOVERY_WAIT_MS = 9e4;
54683
54826
  var MAX_DISCOVERY_WAIT_MS = 36e5;
@@ -54740,12 +54883,12 @@ async function resolveTestDiscovery(i3) {
54740
54883
  }
54741
54884
 
54742
54885
  // src/targetingFindings.ts
54743
- var isRecord5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
54886
+ var isRecord6 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
54744
54887
  function prepareTargetingFindings(raw, listing, deniedPaths) {
54745
- if (!isRecord5(raw)) return void 0;
54888
+ if (!isRecord6(raw)) return void 0;
54746
54889
  const { verdict, files, callPath, evidence, searches } = raw;
54747
54890
  if (typeof verdict !== "string" || !Array.isArray(files) || !Array.isArray(callPath) || !Array.isArray(evidence)) return void 0;
54748
- const keep = (entry) => isRecord5(entry) && typeof entry.path === "string" && listing.has(entry.path) && matchesDeniedPath(entry.path, deniedPaths) === null;
54891
+ const keep = (entry) => isRecord6(entry) && typeof entry.path === "string" && listing.has(entry.path) && matchesDeniedPath(entry.path, deniedPaths) === null;
54749
54892
  const kept = {
54750
54893
  files: files.filter(keep),
54751
54894
  callPath: callPath.filter(keep),
@@ -54799,7 +54942,7 @@ function validateTarget(target, workspaceRoot, workspaceListing, deniedPaths) {
54799
54942
  );
54800
54943
  }
54801
54944
  }
54802
- function buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck = false, storedProposals = false) {
54945
+ function buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck = false, storedProposals = false, ticketHints) {
54803
54946
  const contextData = {
54804
54947
  // NESTED, NOT FLATTENED — a second vocabulary for the design shape is exactly what
54805
54948
  // QUIKTR-1034 cost.
@@ -54828,6 +54971,9 @@ function buildContextData(design, workspaceListing, requiredTests, deniedPaths,
54828
54971
  if (partsCheck && storedProposals) {
54829
54972
  contextData[STORED_PROPOSALS_KEY] = true;
54830
54973
  }
54974
+ if (ticketHints) {
54975
+ contextData.ticketHints = ticketHints;
54976
+ }
54831
54977
  return contextData;
54832
54978
  }
54833
54979
  async function postTargeting(gateway, contextData, signal) {
@@ -54877,16 +55023,24 @@ function finalizeTargeting(body2, workspaceRoot, workspaceListing, deniedPaths)
54877
55023
  ...correctedKinds.length > 0 ? { correctedKinds } : {}
54878
55024
  };
54879
55025
  }
54880
- async function runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope = [], findings, partsCheck = false, storedProposals = false) {
54881
- const contextData = buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals);
55026
+ async function runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope = [], findings, partsCheck = false, storedProposals = false, ticketHints) {
55027
+ const contextData = buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals, ticketHints);
54882
55028
  let envelope = await postTargeting(gateway, contextData);
54883
55029
  let warnings;
54884
- if (findings && envelope?.errorCode === "CONTRACT_REJECTED") {
55030
+ const refused2 = () => envelope?.errorCode === "CONTRACT_REJECTED";
55031
+ if (ticketHints && refused2()) {
55032
+ envelope = await postTargeting(
55033
+ gateway,
55034
+ buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals)
55035
+ );
55036
+ warnings = [TICKET_HINTS_REFUSED_WARNING];
55037
+ }
55038
+ if (findings && refused2()) {
54885
55039
  envelope = await postTargeting(
54886
55040
  gateway,
54887
55041
  buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, void 0, partsCheck, storedProposals)
54888
55042
  );
54889
- warnings = ["QuikPilot's targeting ran without the early look's findings (the AI service did not accept them)."];
55043
+ warnings = [...warnings ?? [], "QuikPilot's targeting ran without the early look's findings (the AI service did not accept them)."];
54890
55044
  }
54891
55045
  checkHardFailure(envelope, "pilot.targeting");
54892
55046
  const body2 = unwrapExecute(envelope, "pilot.targeting");
@@ -54929,29 +55083,44 @@ async function runTargeting(gateway, design, workspaceRoot, workspaceListing, re
54929
55083
  }
54930
55084
  const mode = options.mode ?? resolveTargetingMode();
54931
55085
  const findings = prepareTargetingFindings(options.findings, new Set(workspaceListing), deniedPaths);
55086
+ const logEvent = options.loopDeps?.log ?? ((e) => console.log(JSON.stringify(e)));
55087
+ let ticketHints = hintsFor(options.ticketHints, workspaceListing, deniedPaths, logEvent);
54932
55088
  if (mode !== "loop") {
54933
- return runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals);
55089
+ return runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals, ticketHints);
54934
55090
  }
54935
- const baseContext = buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals);
55091
+ const baseContext = buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals, ticketHints);
55092
+ let hintsWarning;
54936
55093
  const listingView = repoViewOf(options.scope);
54937
55094
  let summary;
54938
55095
  let runtimeCode;
54939
55096
  let reason;
55097
+ let causeFields = {};
54940
55098
  try {
54941
- const looped = await loopWithTools2(
54942
- { baseContext, listing: workspaceListing, deniedPaths },
54943
- options.tools2,
54944
- { secrets: [gateway.token], ...options.loopDeps, post: (contextData, signal) => postTargeting(gateway, contextData, signal) }
55099
+ const deps = { secrets: [gateway.token], ...options.loopDeps, post: (contextData, signal) => postTargeting(gateway, contextData, signal) };
55100
+ const looped = await withoutHintsIfRefused(
55101
+ ticketHints,
55102
+ (ctx) => loopWithTools2({ baseContext: ctx, listing: workspaceListing, deniedPaths }, options.tools2, deps),
55103
+ baseContext,
55104
+ () => {
55105
+ ticketHints = void 0;
55106
+ hintsWarning = TICKET_HINTS_REFUSED_WARNING;
55107
+ logEvent({ event: "targeting.ticket_hints_refused" });
55108
+ }
54945
55109
  );
54946
55110
  summary = looped.summary;
54947
55111
  const result = finalizeTargeting(looped.body, workspaceRoot, workspaceListing, deniedPaths);
54948
- return { ...result, loop: { ...summary, ...listingView ? { repoView: listingView } : {} } };
55112
+ return {
55113
+ ...result,
55114
+ loop: { ...summary, ...listingView ? { repoView: listingView } : {} },
55115
+ ...hintsWarning ? { warnings: [hintsWarning, ...result.warnings ?? []] } : {}
55116
+ };
54949
55117
  } catch (err2) {
54950
55118
  if (err2 instanceof DeniedPathError || err2 instanceof SafetyRefusalError) throw err2;
54951
55119
  if (err2 instanceof LoopFailure) {
54952
55120
  reason = err2.reason;
54953
55121
  runtimeCode = err2.runtimeCode;
54954
55122
  summary = err2.summary ?? summary;
55123
+ causeFields = internalCause(err2);
54955
55124
  } else {
54956
55125
  reason = "final_invalid";
54957
55126
  }
@@ -54975,11 +55144,12 @@ async function runTargeting(gateway, design, workspaceRoot, workspaceListing, re
54975
55144
  log({
54976
55145
  event: "targeting.loop_fallback",
54977
55146
  reason,
55147
+ ...causeFields,
54978
55148
  turn: fellBack.turns,
54979
55149
  toolCalls: fellBack.toolCalls,
54980
55150
  ...runtimeCode && CODE_LIKE.test(runtimeCode) ? { runtimeCode } : {}
54981
55151
  });
54982
- const single = await runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals);
55152
+ const single = await runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals, ticketHints);
54983
55153
  return {
54984
55154
  ...single,
54985
55155
  loop: fellBack,
@@ -54992,7 +55162,7 @@ function mapTestDiscovery(testDiscovery) {
54992
55162
  if (estimateTokens(JSON.stringify(testDiscovery.discoveredTestFiles, null, 2)) <= MAP_DISCOVERY_MAX_TOKENS) return testDiscovery;
54993
55163
  return { report: "PRESENT", discoveredTestFiles: [], unmappedEntries: Math.max(1, testDiscovery.unmappedEntries + testDiscovery.discoveredTestFiles.length) };
54994
55164
  }
54995
- function buildMapContextData(repoMap, design, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck = false, storedProposals = false) {
55165
+ function buildMapContextData(repoMap, design, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck = false, storedProposals = false, ticketHints) {
54996
55166
  return {
54997
55167
  repoMap,
54998
55168
  design,
@@ -55003,30 +55173,62 @@ function buildMapContextData(repoMap, design, requiredTests, deniedPaths, testDi
55003
55173
  testDiscovery: mapTestDiscovery(testDiscovery),
55004
55174
  ...findings ? { findings } : {},
55005
55175
  ...partsCheck ? { partsCheck: true } : {},
55006
- ...partsCheck && storedProposals ? { [STORED_PROPOSALS_KEY]: true } : {}
55176
+ ...partsCheck && storedProposals ? { [STORED_PROPOSALS_KEY]: true } : {},
55177
+ ...ticketHints ? { ticketHints } : {}
55007
55178
  };
55008
55179
  }
55009
55180
  async function runMapTargeting(gateway, design, workspaceRoot, scope, requiredTests, deniedPaths, testDiscovery, outOfScope, options, partsCheck, storedProposals = false) {
55010
55181
  const findings = prepareTargetingFindings(options.findings, new Set(scope.readListing), deniedPaths);
55011
- const baseContext = buildMapContextData(scope.repoMap, design, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals);
55012
- const repoView = repoViewOf(scope);
55013
55182
  const log = options.loopDeps?.log ?? ((e) => console.log(JSON.stringify(e)));
55183
+ const ticketHints = hintsFor(options.ticketHints, scope.readListing, deniedPaths, log);
55184
+ const baseContext = buildMapContextData(scope.repoMap, design, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals, ticketHints);
55185
+ const repoView = repoViewOf(scope);
55014
55186
  let reason;
55187
+ let causeFields = {};
55188
+ let hintsWarning;
55015
55189
  try {
55016
- const looped = await loopWithTools2(
55017
- { baseContext, listing: scope.readListing, deniedPaths, readRoots: scope.readRoots, contractVersion: MAP_LOOP_CONTRACT_VERSION },
55018
- options.tools2,
55019
- { secrets: [gateway.token], ...options.loopDeps, post: (contextData, signal) => postTargeting(gateway, contextData, signal) }
55190
+ const deps = { secrets: [gateway.token], ...options.loopDeps, post: (contextData, signal) => postTargeting(gateway, contextData, signal) };
55191
+ const looped = await withoutHintsIfRefused(
55192
+ ticketHints,
55193
+ (ctx) => loopWithTools2({ baseContext: ctx, listing: scope.readListing, deniedPaths, readRoots: scope.readRoots, contractVersion: MAP_LOOP_CONTRACT_VERSION }, options.tools2, deps),
55194
+ baseContext,
55195
+ () => {
55196
+ hintsWarning = TICKET_HINTS_REFUSED_WARNING;
55197
+ log({ event: "targeting.ticket_hints_refused" });
55198
+ }
55020
55199
  );
55021
55200
  const result = finalizeTargeting(looped.body, workspaceRoot, scope.writeListing, deniedPaths);
55022
- return { ...result, loop: { ...looped.summary, ...repoView ? { repoView } : {} } };
55201
+ return {
55202
+ ...result,
55203
+ loop: { ...looped.summary, ...repoView ? { repoView } : {} },
55204
+ ...hintsWarning ? { warnings: [hintsWarning, ...result.warnings ?? []] } : {}
55205
+ };
55023
55206
  } catch (err2) {
55024
55207
  if (err2 instanceof DeniedPathError || err2 instanceof SafetyRefusalError) throw err2;
55025
55208
  reason = err2 instanceof LoopFailure ? err2.reason : "final_invalid";
55209
+ if (err2 instanceof LoopFailure) causeFields = internalCause(err2);
55026
55210
  }
55027
- log({ event: "targeting.map_failed", reason });
55211
+ log({ event: "targeting.map_failed", reason, ...causeFields });
55028
55212
  throw new MapModeError("targeting", reason);
55029
55213
  }
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).";
55215
+ function hintsFor(raw, listing, deniedPaths, log) {
55216
+ if (raw === void 0 || raw === null) return void 0;
55217
+ const { hints, counts } = prepareTicketHints(raw, listing, deniedPaths);
55218
+ log({ event: "targeting.ticket_hints", ...counts, sent: hints !== void 0 });
55219
+ return hints;
55220
+ }
55221
+ async function withoutHintsIfRefused(hints, run3, baseContext, onRefused) {
55222
+ try {
55223
+ return await run3(baseContext);
55224
+ } catch (err2) {
55225
+ if (!hints || !(err2 instanceof LoopFailure) || err2.reason !== "contract_rejected") throw err2;
55226
+ onRefused();
55227
+ const without = { ...baseContext };
55228
+ delete without.ticketHints;
55229
+ return run3(without);
55230
+ }
55231
+ }
55030
55232
 
55031
55233
  // src/targetingRecord.ts
55032
55234
  var MAX_TARGETS = 25;
@@ -55036,7 +55238,7 @@ var MAX_ADDED_PATHS = 20;
55036
55238
  var MAX_SKIPPED_CONTEXT = 20;
55037
55239
  var MAX_SKIPPED_CASES = 200;
55038
55240
  var MAX_CONTEXT_RECORDS = 25;
55039
- var MAX_PATH_CHARS5 = 300;
55241
+ var MAX_PATH_CHARS6 = 300;
55040
55242
  var MAX_ID_CHARS3 = 100;
55041
55243
  var MAX_REASON_CHARS3 = 300;
55042
55244
  var MAX_LOOP_READS = 50;
@@ -55067,7 +55269,7 @@ function clampLoop(loop) {
55067
55269
  break;
55068
55270
  }
55069
55271
  const path = typeof r.path === "string" ? r.path.trim() : "";
55070
- if (path.length === 0 || path.length > MAX_PATH_CHARS5) {
55272
+ if (path.length === 0 || path.length > MAX_PATH_CHARS6) {
55071
55273
  cut2 = true;
55072
55274
  continue;
55073
55275
  }
@@ -55121,11 +55323,11 @@ function buildTargetingRecord(targeting, contextLog) {
55121
55323
  break;
55122
55324
  }
55123
55325
  const path = typeof t.path === "string" ? t.path.trim() : "";
55124
- if (path.length === 0 || path.length > MAX_PATH_CHARS5) {
55326
+ if (path.length === 0 || path.length > MAX_PATH_CHARS6) {
55125
55327
  truncated = true;
55126
55328
  continue;
55127
55329
  }
55128
- const contextPaths = clampList(t.contextPaths, MAX_CONTEXT_PATHS, MAX_PATH_CHARS5);
55330
+ const contextPaths = clampList(t.contextPaths, MAX_CONTEXT_PATHS, MAX_PATH_CHARS6);
55129
55331
  const automationIds = clampList(t.automationIds, MAX_IDS_PER_TARGET, MAX_ID_CHARS3);
55130
55332
  note(contextPaths.cut);
55131
55333
  note(automationIds.cut);
@@ -55144,16 +55346,16 @@ function buildTargetingRecord(targeting, contextLog) {
55144
55346
  break;
55145
55347
  }
55146
55348
  const targetPath = typeof entry.targetPath === "string" ? entry.targetPath.trim() : "";
55147
- if (targetPath.length === 0 || targetPath.length > MAX_PATH_CHARS5) {
55349
+ if (targetPath.length === 0 || targetPath.length > MAX_PATH_CHARS6) {
55148
55350
  truncated = true;
55149
55351
  continue;
55150
55352
  }
55151
- const contextPaths = clampList(entry.contextPaths, MAX_CONTEXT_PATHS, MAX_PATH_CHARS5);
55152
- const addedPaths = clampList(entry.addedPaths, MAX_ADDED_PATHS, MAX_PATH_CHARS5);
55353
+ const contextPaths = clampList(entry.contextPaths, MAX_CONTEXT_PATHS, MAX_PATH_CHARS6);
55354
+ const addedPaths = clampList(entry.addedPaths, MAX_ADDED_PATHS, MAX_PATH_CHARS6);
55153
55355
  const skippedPaths = clampList(
55154
55356
  (entry.skipped ?? []).map((s) => s.path),
55155
55357
  MAX_SKIPPED_CONTEXT,
55156
- MAX_PATH_CHARS5
55358
+ MAX_PATH_CHARS6
55157
55359
  );
55158
55360
  note(contextPaths.cut);
55159
55361
  note(addedPaths.cut);
@@ -55346,6 +55548,8 @@ async function run2(env2) {
55346
55548
  // QUIKTR-2325 - and `partsCheck` only when the switch is on and the design has parts.
55347
55549
  {
55348
55550
  ...packet.findings ? { findings: packet.findings } : {},
55551
+ // QUIKTR-2509 - what the person's request names; fitted to this checkout inside runTargeting. Absent: called exactly as before.
55552
+ ...packet.ticketHints ? { ticketHints: packet.ticketHints } : {},
55349
55553
  scope,
55350
55554
  ...tools2 ? { tools2 } : {},
55351
55555
  mode: resolveTargetingMode(process.env, packet.targetingMode),
@@ -55480,6 +55684,7 @@ async function run2(env2) {
55480
55684
  if (approved && approved.proposals.length > 0) approvedApplied = approved.proposals;
55481
55685
  }
55482
55686
  const decided = approved?.decided ?? [];
55687
+ const criteriaWording = prepareCriteriaWording(packet.criteriaWording);
55483
55688
  const stepParams = {
55484
55689
  mode: codegenMode,
55485
55690
  ...keepOnGiveUp ? { keepOnGiveUp: true } : {},
@@ -55488,6 +55693,8 @@ async function run2(env2) {
55488
55693
  ...conflictsOn && packet.fixFirst === true && process.env.QUIKPILOT_FIX_FIRST?.trim().toLowerCase() !== "off" ? { fixFirst: true } : {},
55489
55694
  // QUIKTR-2442: a feature run may propose add-only set-up for an existing test its change breaks.
55490
55695
  ...featureUpdates ? { featureTestUpdates: true } : {},
55696
+ // QUIKTR-2509: the approved criteria in the person's words, when QuikProjects sent them (its switch QUIKPILOT_TICKET_HINTS).
55697
+ ...criteriaWording ? { criteriaWording } : {},
55491
55698
  ...approved && approved.files.length > 0 ? { approved: approved.files } : {},
55492
55699
  ...callFunction ? { callFunction } : {},
55493
55700
  ...runScratch ? { runScratch } : {},
@@ -55947,7 +56154,7 @@ var EvidenceLedger = class {
55947
56154
  return seen;
55948
56155
  }
55949
56156
  };
55950
- function isRecord6(x) {
56157
+ function isRecord7(x) {
55951
56158
  return typeof x === "object" && x !== null && !Array.isArray(x);
55952
56159
  }
55953
56160
  function arrayOf(x) {
@@ -55985,7 +56192,7 @@ function capFindingsSize(findings, max = MAX_FINDINGS_CHARS) {
55985
56192
  function verifyFindings(raw, ledger, ctx) {
55986
56193
  const dropped = emptyDropped();
55987
56194
  const redactions = emptyRedactionCounts();
55988
- if (!isRecord6(raw)) return { findings: emptyFindings(), downgraded: false, dropped, redactions };
56195
+ if (!isRecord7(raw)) return { findings: emptyFindings(), downgraded: false, dropped, redactions };
55989
56196
  const pathOk2 = (p) => typeof p === "string" && ctx.listing.has(p) && matchesDeniedPath(p, ctx.deniedPaths) === null;
55990
56197
  const symbolsOf = (path, list2) => {
55991
56198
  const out2 = [];
@@ -56000,7 +56207,7 @@ function verifyFindings(raw, ledger, ctx) {
56000
56207
  };
56001
56208
  const files = [];
56002
56209
  for (const f of arrayOf(raw.files)) {
56003
- if (!isRecord6(f) || !pathOk2(f.path)) {
56210
+ if (!isRecord7(f) || !pathOk2(f.path)) {
56004
56211
  dropped.files += 1;
56005
56212
  continue;
56006
56213
  }
@@ -56010,7 +56217,7 @@ function verifyFindings(raw, ledger, ctx) {
56010
56217
  }
56011
56218
  const callPath = [];
56012
56219
  for (const s of arrayOf(raw.callPath)) {
56013
- const ok = isRecord6(s) && pathOk2(s.path) && typeof s.symbol === "string" && s.symbol.length > 0 && s.symbol.length <= MAX_SYMBOL_CHARS && isLine2(s.line) && ledger.hasLines(s.path, s.line, s.line) && ledger.textContains(s.path, s.symbol);
56220
+ const ok = isRecord7(s) && pathOk2(s.path) && typeof s.symbol === "string" && s.symbol.length > 0 && s.symbol.length <= MAX_SYMBOL_CHARS && isLine2(s.line) && ledger.hasLines(s.path, s.line, s.line) && ledger.textContains(s.path, s.symbol);
56014
56221
  if (!ok) {
56015
56222
  dropped.callPath += 1;
56016
56223
  continue;
@@ -56019,7 +56226,7 @@ function verifyFindings(raw, ledger, ctx) {
56019
56226
  }
56020
56227
  const evidence = [];
56021
56228
  for (const e of arrayOf(raw.evidence)) {
56022
- const ok = isRecord6(e) && pathOk2(e.path) && isLine2(e.startLine) && isLine2(e.endLine) && e.startLine <= e.endLine && e.endLine - e.startLine + 1 <= MAX_EVIDENCE_LINES && ledger.hasLines(e.path, e.startLine, e.endLine);
56229
+ const ok = isRecord7(e) && pathOk2(e.path) && isLine2(e.startLine) && isLine2(e.endLine) && e.startLine <= e.endLine && e.endLine - e.startLine + 1 <= MAX_EVIDENCE_LINES && ledger.hasLines(e.path, e.startLine, e.endLine);
56023
56230
  if (!ok) {
56024
56231
  dropped.evidence += 1;
56025
56232
  continue;
@@ -56314,7 +56521,7 @@ async function runInvestigateLoop(args2, deps) {
56314
56521
  } catch (err2) {
56315
56522
  const failure = err2 instanceof InvestigateFailure ? err2 : new InvestigateFailure("internal_error", err2);
56316
56523
  failure.summary ??= snapshot("failed");
56317
- 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 });
56318
56525
  throw failure;
56319
56526
  }
56320
56527
  }