@quikit/quikpilot-runner 9.3.0-rc.66 → 9.3.0-rc.68

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
@@ -172,6 +172,10 @@ wrong (a field that arrives from a database row or a request), so it only warns
172
172
 
173
173
  **9.3.0-rc.62 - an approved test that is reported again is refused with what to do (QUIKTR-1951).** When a person has approved a change to an existing test and the AI reports that test again before the final test run (a second row of a table test that still expects the old behaviour), the answer was only `already_decided`: "Do not report it again". It now also says what the AI can do: finish the code first, and if rows of that test still fail in the final test run, the fix step that follows may report the test once more (QUIKTR-1844). Nothing about WHEN a test can be reported changes, so a person is still asked only when there is evidence; a test a person judged right, or reported in another file, keeps the bare refusal exactly. A new log event `codegen.conflict_refused_approved` (phase only) counts how often it happens. No change to the contract with the AI service. The AI Runtime's QUIKTR-1952 (a hung OpenRouter call is cut at 150 s for QuikPilot calls, so the backup model answers inside the runner's turn limit) ships with this version and needs no runner setting.
174
174
 
175
+ **9.3.0-rc.68 - the switch `QUIKPILOT_KEEP_WORKING_FILES=on` no longer gets a request refused, and a refusal says why in the log (QUIKTR-1963).** The first live run with the switch on (QuikIT bug 4, run QTRIA-37, 4 Nov 2026) was refused by the AI Runtime four times (`CONTRACT_REJECTED`), each time costing the run a contract version (`codegen.version_fallback`) and a restart of the phase. Cause, reproduced by reading requests this runner built with the AI Runtime's own shape check: under the switch a repeat's copy of an earlier answer (status `duplicate`, carrying the earlier text) was shrunk to the stub `{dropped: true, note}` by the three-turn rule and by the make-room drop, and the AI Runtime takes that stub only on an `ok` look result (`check_look_output_3`). Now a repeat's copy is shrunk by leaving its text out (a `duplicate` with no `output` is a shape the AI Runtime already takes), and its message says it was shrunk and to read it again if needed; every other answer is shrunk as before. The re-read report (`codegen.reread`) reads such a copy as `stubbed`. New log line `codegen.contract_rejected` `{turn, version, reason}` on any refused code-writing request, whatever the switch: `reason` is the AI Runtime's one fixed sentence (the job's secrets taken out, one line, at most 300 characters). With the switch off nothing the AI Runtime receives changes. Also in rc.68: everything in rc.67.
176
+
177
+ **9.3.0-rc.67 - before its tests are frozen, the AI is asked once to check WHY each bug test fails on the old code (QUIKTR-2058; off unless `QUIKPILOT_RED_REVIEW=on`).** Phase 1 ends only once each bug case's own test is seen failing on the code before any change (QUIKTR-1608), and any failure counted. In QuikIT run QTRIA-34 (3 Nov) two bug tests failed there with "expected 500 to be 409" because they never set up a mock the code needs, so the code crashed while the old code really answers 200; the check accepted them, the tests were frozen, and the code phase could never make them pass. In QTRIA-35 (same bug) the AI saw this in the failure text by itself and fixed its test. With the switch on, the first phase-1 DONE that gets past the red check (whatever that check found: in QTRIA-34 its one send-back went to a test that must keep working) is sent back once, as a refused turn with rule word `done_rule`, quoting the first line of each bug case's failure on the code as it is (`[id] fails on the code as it is with: ...`, the job's secrets scrubbed, at most 7 cases) and asking the AI to confirm each shows the bug, not a broken test (a missing mock or stub, an error in the test's own set-up, a crash the bug does not cause); a broken one is fixed and run again, otherwise the AI answers DONE again. It is never sent on a final turn, nor when no failure text is there to quote (`no_message`: a one-file run with no report, no baseline run), nor when no test run is left to show a corrected test failing (`no_runs_left`); a give-up with red tests is not reviewed. The red check and its own counter are unchanged. Logs (counts, never text): `codegen.red_check` `review_sent`, `review_skipped` (with `reason`), and `review_answered` (`testsChanged`, `rerun`, `linesChanged`, `linesSame`, `linesGone`) at the next answer; `red_review.on` once per job. Only with two phases; a fix and the review fix never get it. With the switch off every request is byte-for-byte what rc.66 sent. Nothing changes on the AI Runtime (it never reads a refused sentence's text) or in QuikProjects (the run record keeps rule words only). Also in rc.67: everything in rc.66.
178
+
175
179
  **9.3.0-rc.66 - the early look's report is tried again when QuikProjects cannot take it (QUIKTR-1999).** On 2 Nov two early looks (QuikIT Q2, QuikSplit S5) finished their work and then logged `investigate.failed report_failed`: the one report to QuikProjects failed once, while several runs overlapped and its database was busy, and was never tried again, so the look was lost and the run waited out its 200 s. The report now follows the rule the main callback got in rc.43, with a longer wait: a server error (500/502/503/504) or a dropped connection is tried again, 6 tries in all, waiting 2, 5, 10, 20 and 30 s (about 67 s, because the database stalls seen on 2 Nov and in the stress test lasted over 75 s), sending the same bytes each time; any other answer (a refusal such as 403) is final. When it still fails, the job log says which status the server last answered (`status`) or which connection error it was (`error`), next to the same closed reason as before. The main callback (`reportBack`) is unchanged. Needs the QuikProjects change from the same ticket to be most useful (it answers a busy database with 503 + Retry-After instead of a bare 500 or a 403), but works without it. Also in rc.66: everything in rc.65.
176
180
 
177
181
  **9.3.0-rc.65 - the one correction of QuikPilot's own test now works on Python and Go (QUIKTR-2000).** When the code phase gives up because exactly one of the tests QuikPilot wrote itself still fails, it gets one chance to correct that test's expected value (QUIKTR-1608). Until now the runner recognised the failing test only by its file path, but pytest names a test by its module (`tests.test_grouping`) and gotestsum by its package, so on those languages the correction never ran: sqlparse run QTPY-15 (2 Nov) logged `frozenFailing: 0, amendFiles: 0` with exactly one of its own tests failing, and failed with no PR. Both places that match failing tests to the run's frozen tests (the amendment and the hand-over of a DONE whose own test still fails) now use the rule QUIKTR-1950 uses for the same names (`idPlaceMatches`); a path name is matched exactly as before. When several frozen files share the test's place (a Go or Java package), the one whose text defines the test is chosen, and when that is not exactly one file nothing is amended. The give-up log line also says how many failing tests the last run listed (`failingSeen`). Nothing changes on the AI Runtime or in QuikProjects; `QUIKPILOT_ROW_NAMES=js` gives back the old path-only matching. Also in rc.65: everything in rc.64.
package/dist/index.js CHANGED
@@ -42362,6 +42362,15 @@ function stubNoteFor(call) {
42362
42362
  function isStubbed(output) {
42363
42363
  return typeof output === "object" && output !== null && output.dropped === true;
42364
42364
  }
42365
+ function shrunkAnswer(r, marker) {
42366
+ if (r.status !== "duplicate") return { ...r, output: marker };
42367
+ const copy = {
42368
+ ...r,
42369
+ message: `Same call as ${r.reason ?? "an earlier one"}: its text has since been shrunk to keep the request small. Read it again if you need it.`
42370
+ };
42371
+ delete copy.output;
42372
+ return copy;
42373
+ }
42365
42374
  function stubOldLooks(i3) {
42366
42375
  let shrunk = 0;
42367
42376
  for (let index = 0; index < i3.results.length; index++) {
@@ -42373,7 +42382,7 @@ function stubOldLooks(i3) {
42373
42382
  if (turn === void 0 || turn > i3.currentTurn - KEEP_TURNS) continue;
42374
42383
  const call = i3.callOf(r.id);
42375
42384
  if (!call) continue;
42376
- i3.results[index] = { ...r, output: { dropped: true, note: stubNoteFor(call) } };
42385
+ i3.results[index] = shrunkAnswer(r, { dropped: true, note: stubNoteFor(call) });
42377
42386
  const key = i3.ledger.keys?.get(r.id);
42378
42387
  if (key !== void 0 && i3.ledger.seen.get(key) === r.id) i3.ledger.seen.delete(key);
42379
42388
  i3.ledger.answers?.delete(r.id);
@@ -47207,6 +47216,7 @@ function overlapOf(a, b) {
47207
47216
  }
47208
47217
  function stateOf(output, writtenSince, dropNotes) {
47209
47218
  if (writtenSince) return "after_write";
47219
+ if (output === void 0) return "stubbed";
47210
47220
  if (!isStubbed(output)) return "whole";
47211
47221
  const note = output.note;
47212
47222
  return typeof note === "string" && dropNotes.has(note) ? "dropped" : "stubbed";
@@ -47297,6 +47307,40 @@ var ReadTracker = class {
47297
47307
  }
47298
47308
  };
47299
47309
 
47310
+ // src/redReview.ts
47311
+ var RED_REVIEW_ENV = "QUIKPILOT_RED_REVIEW";
47312
+ function redReviewOn(env2 = process.env) {
47313
+ return env2[RED_REVIEW_ENV]?.trim().toLowerCase() === "on";
47314
+ }
47315
+ var MAX_REVIEW_CASES = MAX_REFUSED_SENTENCES - 1;
47316
+ var REVIEW_MESSAGE = "Before your tests are frozen, check why each one fails on the code as it is. Each sentence but the last quotes the first line of a bug case's failure there. This check is made once.";
47317
+ var REVIEW_CLOSING = "For each one, confirm the failure shows the bug its case describes and not a broken test (a missing mock or stub, an error in the test's own set-up, a crash the bug does not cause). Fix and run again any test that fails for another reason; otherwise answer DONE again.";
47318
+ var MAX_QUOTE_CHARS = 200;
47319
+ var MIN_QUOTE_CHARS = 20;
47320
+ function failureFor(id, runs, covers) {
47321
+ for (let i3 = runs.length - 1; i3 >= 0; i3 -= 1) {
47322
+ const run3 = runs[i3];
47323
+ const messages = run3.answer?.messages;
47324
+ if (!messages) continue;
47325
+ for (const name2 of run3.failing) {
47326
+ if (!covers(name2, id)) continue;
47327
+ const text3 = messages[name2];
47328
+ if (typeof text3 === "string" && text3.trim().length > 0) return text3;
47329
+ }
47330
+ }
47331
+ return null;
47332
+ }
47333
+ function reviewLine(id, text3) {
47334
+ const prefix = `[${id}] fails on the code as it is with: `;
47335
+ const room = Math.min(MAX_QUOTE_CHARS, MAX_REFUSED_SENTENCE_CHARS - prefix.length);
47336
+ if (room < MIN_QUOTE_CHARS) return null;
47337
+ const line = firstLine(text3, void 0, room);
47338
+ return line.length > 0 ? `${prefix}${line}` : null;
47339
+ }
47340
+ function reviewAnswer(lines) {
47341
+ return { rules: ["done_rule"], violations: [...lines.slice(0, MAX_REVIEW_CASES), REVIEW_CLOSING], message: REVIEW_MESSAGE };
47342
+ }
47343
+
47300
47344
  // src/codegenLoop.ts
47301
47345
  var CODEGEN_LOOP_CONTRACT_VERSION = "codegen-loop-1";
47302
47346
  var CODEGEN_LOOP_2_CONTRACT_VERSION = "codegen-loop-2";
@@ -47544,6 +47588,9 @@ async function runCodegenLoop(args2, deps) {
47544
47588
  let proofSendBacks = 0;
47545
47589
  let giveUpRefusals = 0;
47546
47590
  let redUnproven;
47591
+ const reviewOn = harness && args2.phase === "tests" && args2.redReview === true && (args2.redCheckIds ?? []).length > 0;
47592
+ let reviewed = null;
47593
+ let reviewAnswered = false;
47547
47594
  const currentRedRuns = () => {
47548
47595
  const now2 = versionOfFiles(filesOnDisk());
47549
47596
  return redRuns.filter((r) => r.version === now2);
@@ -47583,6 +47630,36 @@ async function runCodegenLoop(args2, deps) {
47583
47630
  return declared2 !== null && sameFile(declared2, file);
47584
47631
  };
47585
47632
  const failsFor = (r, id) => r.failing.some((name2) => idCoversCase(name2, id)) || r.fileFailed === true && r.file !== void 0 && fileHolds(r.file, id);
47633
+ const reviewQuote = (id) => {
47634
+ const text3 = failureFor(id, currentRedRuns(), idCoversCase);
47635
+ return text3 === null ? null : reviewLine(id, scrub(text3));
47636
+ };
47637
+ const noteReviewAnswer = (turn, answer) => {
47638
+ if (reviewed === null || reviewAnswered) return;
47639
+ reviewAnswered = true;
47640
+ const current2 = versionOfFiles(filesOnDisk());
47641
+ let linesChanged = 0;
47642
+ let linesSame = 0;
47643
+ let linesGone = 0;
47644
+ for (const [id, line] of reviewed.quoted) {
47645
+ const again = reviewQuote(id);
47646
+ if (again === null) linesGone += 1;
47647
+ else if (again === line) linesSame += 1;
47648
+ else linesChanged += 1;
47649
+ }
47650
+ log({
47651
+ event: "codegen.red_check",
47652
+ turn,
47653
+ outcome: "review_answered",
47654
+ answer,
47655
+ afterTurns: turn - reviewed.turn,
47656
+ testsChanged: current2 !== reviewed.version,
47657
+ rerun: redRuns.slice(reviewed.runs).some((r) => r.version === current2),
47658
+ linesChanged,
47659
+ linesSame,
47660
+ linesGone
47661
+ });
47662
+ };
47586
47663
  const sentSteps = () => stepsOf(transcript.slice(0, sent.entries), toolResults.slice(0, sent.results));
47587
47664
  let turns = 0;
47588
47665
  let noProgressStreak = 0;
@@ -47657,7 +47734,7 @@ async function runCodegenLoop(args2, deps) {
47657
47734
  if (keep?.has(r.id)) continue;
47658
47735
  const stale = READ_TOOLS.has(r.name) && (r.status === "ok" || keepOn && r.status === "duplicate" && r.output !== void 0) || r.name === RUN_TESTS_TOOL && i3 !== lastTestRun && r.output !== void 0 || r.name === CALL_FUNCTION_TOOL && i3 !== lastCall && r.output !== void 0 || r.name === RUN_SCRATCH_TOOL && i3 !== lastScratch && r.output !== void 0;
47659
47736
  if (!stale) continue;
47660
- toolResults[i3] = { ...r, output };
47737
+ toolResults[i3] = shrunkAnswer(r, output);
47661
47738
  dropped++;
47662
47739
  }
47663
47740
  return dropped;
@@ -47783,6 +47860,13 @@ async function runCodegenLoop(args2, deps) {
47783
47860
  try {
47784
47861
  checkHardFailure(envelope, "pilot.codegen");
47785
47862
  } catch (err2) {
47863
+ if (code === "CONTRACT_REJECTED") {
47864
+ const said = envelope;
47865
+ const text3 = typeof said?.error === "string" ? said.error : typeof said?.normalizedText === "string" ? said.normalizedText : "";
47866
+ const reason = text3.trim() ? firstLine(scrub(text3), void 0, 300) : "";
47867
+ const version2 = contextData.contractVersion;
47868
+ log({ event: "codegen.contract_rejected", turn, ...typeof version2 === "string" ? { version: version2 } : {}, ...reason ? { reason } : {} });
47869
+ }
47786
47870
  throw new CodegenLoopFailure(code === "CONTRACT_REJECTED" ? "contract_rejected" : "semantic_mismatch", String(code), err2);
47787
47871
  }
47788
47872
  if (envelope?.success === false) {
@@ -47831,6 +47915,7 @@ async function runCodegenLoop(args2, deps) {
47831
47915
  }
47832
47916
  if (body2.outcome === "CANNOT_COMPLETE") {
47833
47917
  log({ event: "codegen.loop_turn", turn, outcome: "cannot_complete", requestTokens, elapsedMs: now() - turnStarted, calls: [] });
47918
+ if (reviewOn) noteReviewAnswer(turn, "gave_up");
47834
47919
  const said = typeof body2.summary === "string" ? body2.summary.slice(0, MAX_SUMMARY_CHARS) : void 0;
47835
47920
  if (conflictTool && conflictTool.recorded().length > 0) {
47836
47921
  markNotChecked();
@@ -47855,6 +47940,7 @@ async function runCodegenLoop(args2, deps) {
47855
47940
  const last = lastTestAnswer;
47856
47941
  const redLeft = harness && args2.phase === "tests" ? redProblem() : null;
47857
47942
  if (harness && args2.phase === "tests" && currentRedRuns().some((r) => r.failing.length > 0) && handOverRefusal(turn, true) === null && (redLeft === null || redLeft.kind === "passing")) {
47943
+ if (reviewOn && reviewed === null) log({ event: "codegen.red_check", turn, outcome: "review_skipped", reason: "gave_up", cases: (args2.redCheckIds ?? []).length });
47858
47944
  log({ event: "codegen.red_check", turn, outcome: "gave_up_but_red", files: overlay.changedPaths().length, ...redLeft ? { unproven: redLeft.ids.length } : {} });
47859
47945
  const red = currentRedRuns().filter((r) => r.answer !== void 0).at(-1)?.answer;
47860
47946
  const kept = last ?? red;
@@ -47876,6 +47962,7 @@ async function runCodegenLoop(args2, deps) {
47876
47962
  addCaseTests(declaredTests);
47877
47963
  log({ event: "codegen.case_tests", turn, declared: declaredTests.length });
47878
47964
  }
47965
+ if (reviewOn) noteReviewAnswer(turn, "done");
47879
47966
  if (conflictTool && conflictTool.recorded().length > 0) {
47880
47967
  const said = typeof body2.summary === "string" ? body2.summary.slice(0, MAX_SUMMARY_CHARS) : void 0;
47881
47968
  if (args2.fixFirst !== true) throw new TestConflictStop(conflictTool.recorded(), new CodegenLoopFailure("cannot_complete", void 0, void 0, said, said));
@@ -47932,6 +48019,35 @@ async function runCodegenLoop(args2, deps) {
47932
48019
  if (red.kind === "passing") redUnproven = red.ids;
47933
48020
  log({ event: "codegen.red_check", turn, outcome: red.kind === "passing" ? "ended_unproven" : "ended_unrun", cases: red.ids.length });
47934
48021
  }
48022
+ if (reviewOn && reviewed === null) {
48023
+ const ids = args2.redCheckIds ?? [];
48024
+ const quoted2 = /* @__PURE__ */ new Map();
48025
+ for (const id of ids) {
48026
+ const line = reviewQuote(id);
48027
+ if (line !== null) quoted2.set(id, line);
48028
+ }
48029
+ const skip = isFinal ? "final_turn" : quoted2.size === 0 ? "no_message" : tests !== null && tests.runsLeft + tests.fileRunsLeft === 0 ? "no_runs_left" : null;
48030
+ if (skip !== null) {
48031
+ log({ event: "codegen.red_check", turn, outcome: "review_skipped", reason: skip, cases: ids.length, quoted: quoted2.size });
48032
+ } else {
48033
+ reviewed = { turn, version: versionOfFiles(filesOnDisk()), runs: redRuns.length, quoted: quoted2 };
48034
+ const answer = reviewAnswer([...quoted2.values()]);
48035
+ refusedStreak += 1;
48036
+ refusedTurns.push({ turn, rules: answer.rules });
48037
+ log({
48038
+ event: "codegen.red_check",
48039
+ turn,
48040
+ outcome: "review_sent",
48041
+ cases: Math.min(quoted2.size, MAX_REVIEW_CASES),
48042
+ unquoted: ids.length - quoted2.size,
48043
+ notShown: Math.max(0, quoted2.size - MAX_REVIEW_CASES)
48044
+ });
48045
+ transcript.push({ turn, toolCalls: [], refused: answer });
48046
+ if (refusedStreak >= REFUSED_STREAK_LIMIT) forced = "refused_repeatedly";
48047
+ forced = settleNextTurn(turn, forced);
48048
+ continue;
48049
+ }
48050
+ }
47935
48051
  if (harness && args2.phase !== "tests") {
47936
48052
  const onDisk = (p) => {
47937
48053
  if (matchesDeniedPath(p, args2.deniedPaths) !== null) return false;
@@ -48256,6 +48372,7 @@ async function runPhases(i3) {
48256
48372
  phase: "tests",
48257
48373
  lane: { kind: "tests", testPaths: i3.testPaths },
48258
48374
  redCheckIds: i3.redCheckIds,
48375
+ ...i3.redReview === true ? { redReview: true } : {},
48259
48376
  keepOnGiveUp: false,
48260
48377
  ...i3.previous ? { previousAttempt: i3.previous } : {}
48261
48378
  });
@@ -49502,6 +49619,7 @@ async function runCodegenStep(p) {
49502
49619
  ...resume ? { resume } : {},
49503
49620
  testPaths: testTargetPaths(p.targets, discoveredTestsOf(p.testDiscovery)),
49504
49621
  redCheckIds: checkableIds(args2.requiredAutomationIds, p.requiredTestTypes),
49622
+ ...p.redReview === true ? { redReview: true } : {},
49505
49623
  run: (a) => runCodegenLoop(a, loopDeps),
49506
49624
  ...args2.tests ? { onOldCode: oldCodeRunner(args2, log, now) } : {},
49507
49625
  log
@@ -51633,7 +51751,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
51633
51751
  var REPORT_COPY = "final-test-report.xml";
51634
51752
  var MAX_REPORT_BYTES = 5 * 1024 * 1024;
51635
51753
  var MAX_FILES = 200;
51636
- var RUNNER_VERSION = true ? "9.3.0-rc.66" : "dev";
51754
+ var RUNNER_VERSION = true ? "9.3.0-rc.68" : "dev";
51637
51755
  function safeDestination(base, repoPath) {
51638
51756
  if (!repoPath || (0, import_node_path26.isAbsolute)(repoPath)) return null;
51639
51757
  const destination = (0, import_node_path26.resolve)(base, repoPath);
@@ -52438,6 +52556,8 @@ async function run2(env2) {
52438
52556
  const runScratch = runScratchWanted && runScratchCommand ? { root: process.cwd(), secrets: [runToken, packet.gateway.token].filter((s) => typeof s === "string" && s.length > 0) } : void 0;
52439
52557
  const twoPhaseWanted = codegenMode === "loop-tests" && process.env.QUIKPILOT_TWO_PHASE?.trim().toLowerCase() !== "off";
52440
52558
  const twoPhase = twoPhaseWanted && twoPhaseSkip === null;
52559
+ const redReview = twoPhase && redReviewOn();
52560
+ if (redReview) console.log(JSON.stringify({ event: "red_review.on" }));
52441
52561
  if (twoPhaseWanted && twoPhaseSkip !== null) {
52442
52562
  warnings.push(TWO_PHASE_SKIPPED_NOTE);
52443
52563
  console.log(JSON.stringify({ event: "two_phase.off", reason: twoPhaseSkip }));
@@ -52468,6 +52588,7 @@ async function run2(env2) {
52468
52588
  ...callFunction ? { callFunction } : {},
52469
52589
  ...runScratch ? { runScratch } : {},
52470
52590
  ...twoPhase ? { twoPhase: true, ...packet.requiredTestTypes ? { requiredTestTypes: packet.requiredTestTypes } : {} } : {},
52591
+ ...redReview ? { redReview: true } : {},
52471
52592
  tests: {
52472
52593
  root: process.cwd(),
52473
52594
  command: packet.commands.test,