@quikit/quikpilot-runner 9.3.0-rc.93 → 9.3.0-rc.95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -194,6 +194,10 @@ wrong (a field that arrives from a database row or a request), so it only warns
194
194
 
195
195
  **9.3.0-rc.81 (also) - pytest and go test reports place their tests on files (QUIKTR-2465 item 3).** The Python and Go trial repositories' reports placed no test on a file, so the test-file list was empty and the AI Runtime's early check was off. pytest tests are placed by the longest dotted prefix that is a `.py` file of the listing; Go tests by go.mod's module and the one `_test.go` file of the package's folder that declares the function. Real reports: sqlparse 454 tests on 9 files, decimal 145 tests on 3 files, 0 unmapped each. A report that places none of its tests says so in the run's notes. JavaScript reports are unchanged.
196
196
 
197
+ **9.3.0-rc.95 - the code-writing loop stops asking for the same lines again and again (QUIKTR-2791).** On UAT (17 Nov) a run asked for the same 12 lines of one test file ten times in twelve turns, in both attempts, used all 20 turns of its tests phase twice and wrote nothing; the same request had passed minutes earlier. Counted range by range from the job log (the runner's own re-read counter misses a re-read after a different window), 58 reads: 18 first sight, 17 repeats of text still whole in front of the AI, 23 re-reads of text the three-turn rule had already shrunk away, with no request above 37,587 of 90,000 tokens. The "no progress" guard (three turns in a row of nothing new, then the next turn is the last) counted none of the 40 turns because every turn also held one read of another window, so "every result is a repeat" was never true. Three changes, harness version only. (1) A read that adds no line the AI cannot already see (its lines are all still whole in the conversation, after the file's last edit; an outline covers no lines) counts as nothing new, so a turn that pairs a repeat with such a read counts for the guard. (2) From the second repeat of the same look (read_file, grep, list_files, find_definition, show_changes) the answer keeps its earlier text and status `duplicate` and says plainly to use it, edit, or finish with cannot_complete; the first repeat reads as before. (3) Old looks are no longer shrunk by age while every request stays under the soft target (40,000 tokens, or the first request plus 20,000); once one passes it, shrinking is on as before. New log lines: `codegen.no_new_info` per turn and `repeatsOfSameRange` in `codegen.reread_summary`. Replaying the recorded calls, the guard fires after turn 12 of the failed run's first attempt (it never fires on the passing run); the second attempt's repeats are spread out, so there only (2) and (3) change what the AI sees. Not measured live yet. New: `src/noProgress.ts`; `limits.shrinkAfterTokens` is for tests.
198
+
199
+ **9.3.0-rc.94 - the two reports back to QuikProjects are tried again after any connection failure that brought no answer, and a lost report names its cause (QUIKTR-2790).** On UAT (17 Nov) the early look finished its work and its one report failed with a connection error that was not ECONNRESET or ETIMEDOUT (about 10.5 s later: most likely a connect timeout); it was not tried again, the log said only `report_failed`, and the run went on without the look. The look's report and the run's final report now try again after any fetch that threw with no HTTP answer (a connect timeout, a closed socket, DNS, a refused connection), with the same waits and the same bytes each time; a refusal (4xx), an invalid URL, a certificate problem and the runner's own 60 s limit for a try stay final. Every lost look now logs `report_failed` with the cause: the last HTTP status, or a closed word (an error code or an error name; never the message, the URL, the token or the body). The AI calls keep their old two-code retry on purpose: a repeated AI call that reached the AI service is paid twice. No change to the work packet, the contract or the site.
200
+
197
201
  **9.3.0-rc.93 - a turn the AI service calls too big is not mistaken for a switch that is off (QUIKTR-2712, RT-05).** The AI service refused a loop turn over its per-turn size limit with the same code (`CONTRACT_REJECTED`) it uses for "switch off", "unknown version" and "malformed request", which the run answers by stepping down a version, dropping a key or writing the files one at a time (on a first request it could even end the run as "needs a database change"). The service now sends its own code, `LOOP_TURN_TOO_LARGE`, for that one refusal, and the three loops (code writing, the file search and the early look) end the attempt as `token_ceiling` ("the request grew too large for one step") with the service's code kept in the record: no step down, no key dropped, no per-file fallback. A runner of this version against the older service behaves as before. Release this runner BEFORE the service half.
198
202
 
199
203
  **9.3.0-rc.92 - each loop version's fixed prompt part counted honestly (QUIKTR-2709, RT-01).** A loop turn was sized as 5,000 for the fixed part (instruction, forms, user turn) plus its context, against 90,000; the fixed part is really 7,000 to 23,500 depending on the contract version, so the ceiling allowed ~104,000. The 90,000 is now the whole request: the fixed part comes from one table per version (`PROMPT_OVERHEAD_BY_VERSION`, the AI Runtime's values word for word), and an unknown version is charged the largest. Long runs drop old file contents a little sooner. Release this runner BEFORE the runtime half: it trims sooner, which today's runtime accepts.
package/dist/index.js CHANGED
@@ -38538,6 +38538,10 @@ function createNodeToolFs(rootDir = process.cwd()) {
38538
38538
  }
38539
38539
  };
38540
38540
  }
38541
+ var STEERED_LOOKS = /* @__PURE__ */ new Set(["list_files", "read_file", "grep", "find_definition", "show_changes"]);
38542
+ function repeatedLookMessage(earlier) {
38543
+ return `Same call as ${earlier}: this is its answer again (nothing was run or changed again). You already have it above: use it now, make the change with edit_file or write_file, or finish with cannot_complete and say what is missing.`;
38544
+ }
38541
38545
  function newLedger() {
38542
38546
  return { toolCalls: 0, readChars: 0, resultChars: 0, refused: 0, seen: /* @__PURE__ */ new Map() };
38543
38547
  }
@@ -38854,10 +38858,13 @@ function executeToolCall(call, env2, ledger) {
38854
38858
  if (earlier !== void 0) {
38855
38859
  if (env2.serveRepeats === true) {
38856
38860
  const before = ledger.answers?.get(earlier);
38861
+ const repeats = ledger.repeats ?? (ledger.repeats = /* @__PURE__ */ new Map());
38862
+ const times = (repeats.get(earlier) ?? 0) + 1;
38863
+ repeats.set(earlier, times);
38857
38864
  return finish({
38858
38865
  status: "duplicate",
38859
38866
  reason: earlier,
38860
- message: `Same call as ${earlier}: this is its answer again; nothing was run or changed again.`,
38867
+ message: times >= 2 && STEERED_LOOKS.has(call.name) ? repeatedLookMessage(earlier) : `Same call as ${earlier}: this is its answer again; nothing was run or changed again.`,
38861
38868
  ...before?.output !== void 0 ? { output: before.output } : {}
38862
38869
  });
38863
38870
  }
@@ -40130,13 +40137,14 @@ function jobStoppedMessage() {
40130
40137
  }
40131
40138
  var SHORT_CALL_MS = 6e4;
40132
40139
  var LONG_CALL_MS = 5 * 6e4;
40140
+ var STEP_TIMEOUT_CODE = "STEP_TIMEOUT";
40133
40141
  async function fetchWithin(what, url, init2, limitMs) {
40134
40142
  const signal = AbortSignal.timeout(limitMs);
40135
40143
  try {
40136
40144
  return await fetch(url, { ...init2, signal });
40137
40145
  } catch (err2) {
40138
40146
  if (signal.aborted && err2?.name === "TimeoutError") {
40139
- throw new Error(`${what} did not answer within ${minutesOrSeconds(limitMs)} and was stopped`);
40147
+ throw Object.assign(new Error(`${what} did not answer within ${minutesOrSeconds(limitMs)} and was stopped`), { code: STEP_TIMEOUT_CODE });
40140
40148
  }
40141
40149
  throw err2;
40142
40150
  }
@@ -40219,6 +40227,37 @@ function isRetryableNetworkError(err2) {
40219
40227
  const code = networkErrorCode(err2);
40220
40228
  return code !== void 0 && RETRYABLE_NETWORK_ERROR_CODES.has(code);
40221
40229
  }
40230
+ var TRANSPORT_FAILURE_CODES = /* @__PURE__ */ new Set([
40231
+ "ECONNRESET",
40232
+ "ETIMEDOUT",
40233
+ "ECONNREFUSED",
40234
+ "EAI_AGAIN",
40235
+ "ENOTFOUND",
40236
+ "EPIPE",
40237
+ "ENETUNREACH",
40238
+ "EHOSTUNREACH",
40239
+ "UND_ERR_CONNECT_TIMEOUT",
40240
+ "UND_ERR_SOCKET",
40241
+ "UND_ERR_HEADERS_TIMEOUT",
40242
+ "UND_ERR_BODY_TIMEOUT",
40243
+ "UND_ERR_CLOSED"
40244
+ ]);
40245
+ function isTransportFailure(err2) {
40246
+ if (typeof err2 !== "object" || err2 === null) return false;
40247
+ const code = networkErrorCode(err2);
40248
+ if (code !== void 0) return TRANSPORT_FAILURE_CODES.has(code);
40249
+ const e = err2;
40250
+ return e.name === "TypeError" && e.message === "fetch failed";
40251
+ }
40252
+ function describeFailureCause(err2) {
40253
+ const word = (s) => {
40254
+ if (typeof s !== "string") return void 0;
40255
+ const clean = s.replace(/[^A-Za-z0-9_.-]/g, "").slice(0, 40);
40256
+ return clean === "" ? void 0 : clean;
40257
+ };
40258
+ if (typeof err2 !== "object" || err2 === null) return "unknown";
40259
+ return word(networkErrorCode(err2)) ?? word(err2.name) ?? "unknown";
40260
+ }
40222
40261
  async function fetchWithRetry(url, init2, { retries = 2, backoffMs = 250 } = {}) {
40223
40262
  for (let attempt2 = 0; ; attempt2++) {
40224
40263
  try {
@@ -40275,8 +40314,8 @@ async function reportBack(params) {
40275
40314
  signal: AbortSignal.timeout(params.urgent ? URGENT_REPORT_TIMEOUT_MS : SHORT_CALL_MS)
40276
40315
  });
40277
40316
  } catch (err2) {
40278
- if (!isRetryableNetworkError(err2)) throw err2;
40279
- failure = `the connection failed (${networkErrorCode(err2)})`;
40317
+ if (!isTransportFailure(err2)) throw err2;
40318
+ failure = `the connection failed (${describeFailureCause(err2)})`;
40280
40319
  if (attempt2 === tries) throw new Error(`Report back to QuikTrack failed: ${failure} after ${tries} tries`);
40281
40320
  await waitBeforeRetry(failure, attempt2);
40282
40321
  continue;
@@ -49397,6 +49436,13 @@ async function runTargetingLoop(args2, deps) {
49397
49436
  }
49398
49437
  }
49399
49438
 
49439
+ // src/noProgress.ts
49440
+ var NOTHING_NEW = /* @__PURE__ */ new Set(["duplicate", "no_effect", "no_change_since_last_run", "no_match", "ambiguous", "conflict_rejected"]);
49441
+ var HARNESS_NO_PROGRESS_TURNS = 3;
49442
+ function turnAddsNothing(results, addedNothing) {
49443
+ return results.every((r) => NOTHING_NEW.has(r.status) || addedNothing.has(r.id));
49444
+ }
49445
+
49400
49446
  // src/workingFiles.ts
49401
49447
  var KEEP_WORKING_FILES_ENV = "QUIKPILOT_KEEP_WORKING_FILES";
49402
49448
  var MAX_WORKING_PATHS = 3;
@@ -49413,6 +49459,17 @@ function rangeOf(args2) {
49413
49459
  if (typeof a.endLine === "number" && Number.isInteger(a.endLine)) out2.endLine = a.endLine;
49414
49460
  return out2;
49415
49461
  }
49462
+ function servedOf(range, output) {
49463
+ if (range.mode === "outline" || typeof output !== "object" || output === null) return {};
49464
+ const o = output;
49465
+ if (typeof o.startLine === "number" && Number.isInteger(o.startLine) && typeof o.endLine === "number" && Number.isInteger(o.endLine)) {
49466
+ return { servedStart: o.startLine, servedEnd: o.endLine };
49467
+ }
49468
+ return {};
49469
+ }
49470
+ function spanOf(r) {
49471
+ return { start: r.servedStart ?? r.startLine ?? 1, end: r.servedEnd ?? r.endLine ?? Number.POSITIVE_INFINITY };
49472
+ }
49416
49473
  function overlapOf(a, b) {
49417
49474
  if (a.mode === "outline" || b.mode === "outline") return a.mode === b.mode ? "same" : "disjoint";
49418
49475
  const aStart = a.startLine ?? 1;
@@ -49454,6 +49511,30 @@ var ReadTracker = class {
49454
49511
  for (const w of this.writes) if (w.path === path) last = w.seq;
49455
49512
  return last;
49456
49513
  }
49514
+ /**
49515
+ * QUIKTR-2791 - whether reading `entry` would add NOTHING the AI cannot already see, called BEFORE it is noted. True when every line it serves is
49516
+ * held by earlier reads of the same file that are still WHOLE in the conversation (not shrunk to a stub, not dropped to make room) and were made
49517
+ * after the AI last changed the file; an outline is held only by an earlier outline, and lines are never held by an outline. A read of lines whose
49518
+ * earlier copy was shrunk adds something (the AI no longer has them), so the rule stays right under the three-turn shrinking. Never true for the
49519
+ * first read of a file. `outputOf(id)` answers what an earlier answer is now.
49520
+ */
49521
+ addsNothing(entry, outputOf, dropNotes) {
49522
+ const after = this.lastWriteSeq(entry.path);
49523
+ const held = this.reads.filter((r) => r.path === entry.path && r.seq > after && stateOf(outputOf(r.id), false, dropNotes) === "whole");
49524
+ if (entry.mode === "outline") return held.some((r) => r.mode === "outline");
49525
+ const spans = held.filter((r) => r.mode !== "outline").map(spanOf);
49526
+ const want = spanOf(entry);
49527
+ if (want.end < want.start) return spans.length > 0;
49528
+ spans.sort((a, b) => a.start - b.start);
49529
+ let cursor = want.start;
49530
+ for (const s of spans) {
49531
+ if (s.end < cursor) continue;
49532
+ if (s.start > cursor) return false;
49533
+ cursor = s.end + 1;
49534
+ if (cursor > want.end) return true;
49535
+ }
49536
+ return false;
49537
+ }
49457
49538
  /**
49458
49539
  * The re-read report for `entry`, called BEFORE it is noted: null for a path not read before in this loop. `outputOf(id)` answers what the
49459
49540
  * earlier answer is now; `duplicate` is whether this read was answered as a repeat.
@@ -50220,8 +50301,6 @@ function withUnreportable(stop2, tests) {
50220
50301
  return carried;
50221
50302
  }
50222
50303
  var MAX_RED_REFUSALS = 1;
50223
- var NOTHING_NEW = /* @__PURE__ */ new Set(["duplicate", "no_effect", "no_change_since_last_run", "no_match", "ambiguous", "conflict_rejected"]);
50224
- var HARNESS_NO_PROGRESS_TURNS = 3;
50225
50304
  var MAX_SUMMARY_CHARS = 300;
50226
50305
  var READ_TOOLS = /* @__PURE__ */ new Set(["list_files", "read_file", "grep", "find_definition", "show_changes"]);
50227
50306
  var WRITE_TOOLS = /* @__PURE__ */ new Set(["edit_file", "write_file"]);
@@ -50376,8 +50455,9 @@ async function runCodegenLoop(args2, deps) {
50376
50455
  const usage = new TurnUsage();
50377
50456
  let notes = "";
50378
50457
  let stubbed = 0;
50458
+ let shrinkOn = false;
50379
50459
  const tracker = new ReadTracker();
50380
- const rereadCounts = { rereads: 0, rereadsAfterStub: 0, rereadsAfterDrop: 0 };
50460
+ const rereadCounts = { rereads: 0, rereadsAfterStub: 0, rereadsAfterDrop: 0, repeatsOfSameRange: 0 };
50381
50461
  let keptMax = 0;
50382
50462
  let rereadsLogged = false;
50383
50463
  const logRereads = () => {
@@ -50682,8 +50762,8 @@ async function runCodegenLoop(args2, deps) {
50682
50762
  return null;
50683
50763
  }
50684
50764
  };
50685
- const servedOf = (c) => ({ title: c.served.title, describes: c.served.describes, ...c.served.table ? { table: true } : {} });
50686
- const regressedIn = (answer, c) => failsIn(answer, c.served.path, servedOf(c), answer?.regressions ?? 0);
50765
+ const servedOf2 = (c) => ({ title: c.served.title, describes: c.served.describes, ...c.served.table ? { table: true } : {} });
50766
+ const regressedIn = (answer, c) => failsIn(answer, c.served.path, servedOf2(c), answer?.regressions ?? 0);
50687
50767
  const fresh = freshTestAnswer() ?? null;
50688
50768
  let changeAnswer = fresh;
50689
50769
  let ranChange = false;
@@ -50703,7 +50783,7 @@ async function runCodegenLoop(args2, deps) {
50703
50783
  const regressed = regressedIn(changeAnswer, c) === true;
50704
50784
  const file = files.find((f) => f.path === c.path);
50705
50785
  const title = (c.index >= 0 ? file?.newTitles.get(c.index) : void 0) ?? c.served.title;
50706
- const suite = !whole4 ? "not_checked" : suiteAnswer.regressions === 0 && failsIn(suiteAnswer, c.served.path, { ...servedOf(c), title }) === false ? "passes" : "fails";
50786
+ const suite = !whole4 ? "not_checked" : suiteAnswer.regressions === 0 && failsIn(suiteAnswer, c.served.path, { ...servedOf2(c), title }) === false ? "passes" : "fails";
50707
50787
  const fixes = regressed && suite === "passes" && changeAnswer ? fixesOf(c, changeAnswer) : [];
50708
50788
  if (regressed) counts.regressed += 1;
50709
50789
  counts[suite === "passes" ? "passes" : suite === "fails" ? "fails" : "notChecked"] += 1;
@@ -51138,6 +51218,7 @@ async function runCodegenLoop(args2, deps) {
51138
51218
  const calls = parsed.calls;
51139
51219
  for (const c of calls) usedIds.add(c.id);
51140
51220
  const results = [];
51221
+ const addedNothing = /* @__PURE__ */ new Set();
51141
51222
  const logged = [];
51142
51223
  for (const [index, call] of calls.entries()) {
51143
51224
  let result;
@@ -51202,10 +51283,13 @@ async function runCodegenLoop(args2, deps) {
51202
51283
  }
51203
51284
  results.push(result);
51204
51285
  if (call.name === "read_file" && isPlainObject(call.args) && typeof call.args.path === "string" && (result.status === "ok" || result.status === "duplicate")) {
51205
- const entry = { id: call.id, turn, path: call.args.path, ...rangeOf(call.args) };
51286
+ const range = rangeOf(call.args);
51287
+ const entry = { id: call.id, turn, path: call.args.path, ...range, ...servedOf(range, result.output) };
51288
+ if (harness && tracker.addsNothing(entry, (id) => results.find((x) => x.id === id)?.output ?? outputOf(id), DROP_NOTES)) addedNothing.add(call.id);
51206
51289
  const again = tracker.reread(entry, result.status === "duplicate", (id) => results.find((x) => x.id === id)?.output ?? outputOf(id), DROP_NOTES);
51207
51290
  if (again) {
51208
51291
  rereadCounts.rereads += 1;
51292
+ if (again.overlap === "same") rereadCounts.repeatsOfSameRange += 1;
51209
51293
  if (again.prevState === "stubbed") rereadCounts.rereadsAfterStub += 1;
51210
51294
  else if (again.prevState === "dropped") rereadCounts.rereadsAfterDrop += 1;
51211
51295
  log({ event: "codegen.reread", ...again });
@@ -51249,7 +51333,8 @@ async function runCodegenLoop(args2, deps) {
51249
51333
  notes = keepNotes(notes, body2.notes, scrub);
51250
51334
  const kept = keepOn ? tracker.keep(outputOf) : null;
51251
51335
  if (kept) keptMax = Math.max(keptMax, kept.size);
51252
- stubbed += stubOldLooks({
51336
+ if (peakRequestTokens > (limits.shrinkAfterTokens ?? mapSoftTarget(firstRequestTokens, limits.maxRequestTokens))) shrinkOn = true;
51337
+ if (shrinkOn) stubbed += stubOldLooks({
51253
51338
  results: toolResults,
51254
51339
  turnOf: (id) => turnOfId.get(id),
51255
51340
  callOf: (id) => callOfId.get(id),
@@ -51258,7 +51343,13 @@ async function runCodegenLoop(args2, deps) {
51258
51343
  ...kept ? { keep: (id) => kept.has(id), repeats: true } : {}
51259
51344
  });
51260
51345
  }
51261
- noProgressStreak = harness ? results.every((r) => NOTHING_NEW.has(r.status)) ? noProgressStreak + 1 : 0 : results.every((r) => r.status === "duplicate") ? noProgressStreak + 1 : 0;
51346
+ noProgressStreak = harness ? turnAddsNothing(results, addedNothing) ? noProgressStreak + 1 : 0 : results.every((r) => r.status === "duplicate") ? noProgressStreak + 1 : 0;
51347
+ if (harness) {
51348
+ const nothingNew = results.filter((r) => NOTHING_NEW.has(r.status) || addedNothing.has(r.id)).length;
51349
+ if (nothingNew > 0) {
51350
+ log({ event: "codegen.no_new_info", turn, results: results.length, nothingNew, byCoverage: results.filter((r) => !NOTHING_NEW.has(r.status) && addedNothing.has(r.id)).length, streak: noProgressStreak });
51351
+ }
51352
+ }
51262
51353
  if (noProgressStreak >= (harness ? HARNESS_NO_PROGRESS_TURNS : 2)) forced = "no_progress";
51263
51354
  else if (ledger.toolCalls >= limits.maxToolCalls) forced = "tool_budget";
51264
51355
  else if (ledger.writeChars >= limits.writeCharsTotal) forced = "write_budget";
@@ -54918,7 +55009,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
54918
55009
  var REPORT_COPY = "final-test-report.xml";
54919
55010
  var MAX_REPORT_BYTES = 5 * 1024 * 1024;
54920
55011
  var MAX_FILES = 200;
54921
- var RUNNER_VERSION = true ? "9.3.0-rc.93" : "dev";
55012
+ var RUNNER_VERSION = true ? "9.3.0-rc.95" : "dev";
54922
55013
  function safeDestination(base, repoPath) {
54923
55014
  if (!repoPath || (0, import_node_path27.isAbsolute)(repoPath)) return null;
54924
55015
  const destination = (0, import_node_path27.resolve)(base, repoPath);
@@ -57100,8 +57191,10 @@ async function reportInvestigation(callbackUrl, runToken, body2, sleep = (ms) =>
57100
57191
  failure = await describeQuikTrackFailure(res);
57101
57192
  status = res.status;
57102
57193
  } catch (err2) {
57103
- if (!isRetryableNetworkError(err2)) throw err2;
57104
- networkCode = networkErrorCode(err2);
57194
+ networkCode = describeFailureCause(err2);
57195
+ if (!isTransportFailure(err2)) {
57196
+ throw new InvestigationReportError(`Investigation callback failed: the request could not be completed (${networkCode})`, void 0, networkCode);
57197
+ }
57105
57198
  failure = `the connection failed (${networkCode})`;
57106
57199
  }
57107
57200
  if (status !== void 0 && !REPORT_RETRY_STATUSES.has(status)) throw new InvestigationReportError(`Investigation callback failed: ${failure}`, status);