@quikit/quikpilot-runner 9.3.0-rc.67 → 9.3.0-rc.69

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.69 - a GitHub server error on push is tried again, and a commit that could not be pushed is kept beside the files (QUIKTR-1963 follow-up, QTRIA-39).** Run QTRIA-39 (4 Nov 2026) wrote and checked its change, then lost it: `git push` got "remote: Internal Server Error" from GitHub during a GitHub incident, the run failed, and there was no branch and no pull request. Now a push answered with a server error (500, Bad Gateway, Service Unavailable, Gateway Timeout) is tried again after 5, 15, 30 and 60 seconds; before, only "Repository not found" was retried, and that retry is unchanged. A failed run's folder (`quikpilot-failure/`, uploaded as the `quikpilot-failed-run` artifact) also holds `quikpilot-change.bundle`: the run's last commit as a git bundle, and the manifest's `bundle` entry says how to restore it (`git fetch quikpilot-change.bundle HEAD:refs/heads/<branch>`). The bundle is written only when the run's branch is checked out and its commit changes a file. With a push that works, the run is the same as in rc.68.
176
+
177
+ **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.
178
+
175
179
  **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.
176
180
 
177
181
  **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.
package/dist/index.js CHANGED
@@ -28771,12 +28771,16 @@ function clearCheckoutExtraHeader() {
28771
28771
  }
28772
28772
  var PUSH_RETRY_DELAYS_MS = [3e3, 6e3, 12e3];
28773
28773
  var REPOSITORY_NOT_FOUND_RE = /Repository not found/i;
28774
+ var SERVER_ERROR_DELAYS_MS = [5e3, 15e3, 3e4, 6e4];
28775
+ var SERVER_ERROR_RE = /Internal Server Error|Bad Gateway|Service Unavailable|Gateway Timeout|returned error: 5\d\d/i;
28774
28776
  function sleepSync(ms) {
28775
28777
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
28776
28778
  }
28777
28779
  function push(branch, installationToken, sleep = sleepSync) {
28778
28780
  clearCheckoutExtraHeader();
28779
28781
  const basicAuth = Buffer.from(`x-access-token:${installationToken}`).toString("base64");
28782
+ let notFoundRetries = 0;
28783
+ let serverRetries = 0;
28780
28784
  for (let attempt2 = 0; ; attempt2 += 1) {
28781
28785
  try {
28782
28786
  git(["push", "--set-upstream", "origin", branch], {
@@ -28787,10 +28791,22 @@ function push(branch, installationToken, sleep = sleepSync) {
28787
28791
  if (attempt2 > 0) console.log(JSON.stringify({ event: "git.push_retry_ok", attempts: attempt2 + 1 }));
28788
28792
  return;
28789
28793
  } catch (err2) {
28790
- const delay = PUSH_RETRY_DELAYS_MS[attempt2];
28791
28794
  const said = `${err2 instanceof Error ? err2.message : String(err2)} ${String(err2.stderr ?? "")}`;
28792
- if (delay === void 0 || !REPOSITORY_NOT_FOUND_RE.test(said)) throw err2;
28793
- console.log(JSON.stringify({ event: "git.push_retry", attempt: attempt2 + 1, waitMs: delay }));
28795
+ let cause;
28796
+ let delay;
28797
+ if (REPOSITORY_NOT_FOUND_RE.test(said)) {
28798
+ cause = "repository_not_found";
28799
+ delay = PUSH_RETRY_DELAYS_MS[notFoundRetries];
28800
+ if (delay !== void 0) notFoundRetries += 1;
28801
+ } else if (SERVER_ERROR_RE.test(said)) {
28802
+ cause = "server_error";
28803
+ delay = SERVER_ERROR_DELAYS_MS[serverRetries];
28804
+ if (delay !== void 0) serverRetries += 1;
28805
+ } else {
28806
+ throw err2;
28807
+ }
28808
+ if (delay === void 0) throw err2;
28809
+ console.log(JSON.stringify({ event: "git.push_retry", attempt: attempt2 + 1, waitMs: delay, cause }));
28794
28810
  sleep(delay);
28795
28811
  }
28796
28812
  }
@@ -42362,6 +42378,15 @@ function stubNoteFor(call) {
42362
42378
  function isStubbed(output) {
42363
42379
  return typeof output === "object" && output !== null && output.dropped === true;
42364
42380
  }
42381
+ function shrunkAnswer(r, marker) {
42382
+ if (r.status !== "duplicate") return { ...r, output: marker };
42383
+ const copy = {
42384
+ ...r,
42385
+ 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.`
42386
+ };
42387
+ delete copy.output;
42388
+ return copy;
42389
+ }
42365
42390
  function stubOldLooks(i3) {
42366
42391
  let shrunk = 0;
42367
42392
  for (let index = 0; index < i3.results.length; index++) {
@@ -42373,7 +42398,7 @@ function stubOldLooks(i3) {
42373
42398
  if (turn === void 0 || turn > i3.currentTurn - KEEP_TURNS) continue;
42374
42399
  const call = i3.callOf(r.id);
42375
42400
  if (!call) continue;
42376
- i3.results[index] = { ...r, output: { dropped: true, note: stubNoteFor(call) } };
42401
+ i3.results[index] = shrunkAnswer(r, { dropped: true, note: stubNoteFor(call) });
42377
42402
  const key = i3.ledger.keys?.get(r.id);
42378
42403
  if (key !== void 0 && i3.ledger.seen.get(key) === r.id) i3.ledger.seen.delete(key);
42379
42404
  i3.ledger.answers?.delete(r.id);
@@ -47207,6 +47232,7 @@ function overlapOf(a, b) {
47207
47232
  }
47208
47233
  function stateOf(output, writtenSince, dropNotes) {
47209
47234
  if (writtenSince) return "after_write";
47235
+ if (output === void 0) return "stubbed";
47210
47236
  if (!isStubbed(output)) return "whole";
47211
47237
  const note = output.note;
47212
47238
  return typeof note === "string" && dropNotes.has(note) ? "dropped" : "stubbed";
@@ -47724,7 +47750,7 @@ async function runCodegenLoop(args2, deps) {
47724
47750
  if (keep?.has(r.id)) continue;
47725
47751
  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;
47726
47752
  if (!stale) continue;
47727
- toolResults[i3] = { ...r, output };
47753
+ toolResults[i3] = shrunkAnswer(r, output);
47728
47754
  dropped++;
47729
47755
  }
47730
47756
  return dropped;
@@ -47850,6 +47876,13 @@ async function runCodegenLoop(args2, deps) {
47850
47876
  try {
47851
47877
  checkHardFailure(envelope, "pilot.codegen");
47852
47878
  } catch (err2) {
47879
+ if (code === "CONTRACT_REJECTED") {
47880
+ const said = envelope;
47881
+ const text3 = typeof said?.error === "string" ? said.error : typeof said?.normalizedText === "string" ? said.normalizedText : "";
47882
+ const reason = text3.trim() ? firstLine(scrub(text3), void 0, 300) : "";
47883
+ const version2 = contextData.contractVersion;
47884
+ log({ event: "codegen.contract_rejected", turn, ...typeof version2 === "string" ? { version: version2 } : {}, ...reason ? { reason } : {} });
47885
+ }
47853
47886
  throw new CodegenLoopFailure(code === "CONTRACT_REJECTED" ? "contract_rejected" : "semantic_mismatch", String(code), err2);
47854
47887
  }
47855
47888
  if (envelope?.success === false) {
@@ -51728,13 +51761,14 @@ function writePhase0Marker(runId) {
51728
51761
  }
51729
51762
 
51730
51763
  // src/failureArtifact.ts
51764
+ var import_node_child_process11 = require("node:child_process");
51731
51765
  var import_node_fs25 = require("node:fs");
51732
51766
  var import_node_path26 = require("node:path");
51733
51767
  var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
51734
51768
  var REPORT_COPY = "final-test-report.xml";
51735
51769
  var MAX_REPORT_BYTES = 5 * 1024 * 1024;
51736
51770
  var MAX_FILES = 200;
51737
- var RUNNER_VERSION = true ? "9.3.0-rc.67" : "dev";
51771
+ var RUNNER_VERSION = true ? "9.3.0-rc.69" : "dev";
51738
51772
  function safeDestination(base, repoPath) {
51739
51773
  if (!repoPath || (0, import_node_path26.isAbsolute)(repoPath)) return null;
51740
51774
  const destination = (0, import_node_path26.resolve)(base, repoPath);
@@ -51742,6 +51776,26 @@ function safeDestination(base, repoPath) {
51742
51776
  if (!rel || rel.startsWith("..") || (0, import_node_path26.isAbsolute)(rel)) return null;
51743
51777
  return destination;
51744
51778
  }
51779
+ var BUNDLE_FILE = "quikpilot-change.bundle";
51780
+ function keepCommitBundle(repo, folder, branch) {
51781
+ const git3 = (args2) => (0, import_node_child_process11.execFileSync)("git", args2, { cwd: repo, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
51782
+ try {
51783
+ if (git3(["rev-parse", "--abbrev-ref", "HEAD"]) !== branch) return null;
51784
+ if (git3(["diff", "--name-only", "HEAD~1", "HEAD"]) === "") return null;
51785
+ const commit2 = git3(["rev-parse", "HEAD"]);
51786
+ const file = (0, import_node_path26.join)(folder, BUNDLE_FILE);
51787
+ git3(["bundle", "create", file, "HEAD", "^HEAD~1"]);
51788
+ let verified = true;
51789
+ try {
51790
+ git3(["bundle", "verify", file]);
51791
+ } catch {
51792
+ verified = false;
51793
+ }
51794
+ return { file: BUNDLE_FILE, branch, commit: commit2, verified, restore: `git fetch ${BUNDLE_FILE} HEAD:refs/heads/${branch}` };
51795
+ } catch {
51796
+ return null;
51797
+ }
51798
+ }
51745
51799
  function writeFailureArtifact(input) {
51746
51800
  if (input.results.length === 0) return { written: false };
51747
51801
  try {
@@ -51769,6 +51823,7 @@ function writeFailureArtifact(input) {
51769
51823
  testReport = "included";
51770
51824
  }
51771
51825
  }
51826
+ const bundle = input.commitBranch ? keepCommitBundle(input.cwd, base, input.commitBranch) : null;
51772
51827
  const manifest = {
51773
51828
  runId: input.runId,
51774
51829
  issueKey: input.issueKey,
@@ -51782,7 +51837,8 @@ function writeFailureArtifact(input) {
51782
51837
  files,
51783
51838
  skipped,
51784
51839
  testReport,
51785
- failureReasons: input.failureReasons
51840
+ failureReasons: input.failureReasons,
51841
+ bundle
51786
51842
  };
51787
51843
  const text3 = JSON.stringify(manifest, (_key, value) => typeof value === "string" ? scrubSecrets(value, input.secrets) : value, 2);
51788
51844
  (0, import_node_fs25.writeFileSync)((0, import_node_path26.join)(base, "manifest.json"), text3);
@@ -52839,6 +52895,7 @@ async function run2(env2) {
52839
52895
  results: generatedResults,
52840
52896
  testReport: finalTestReport,
52841
52897
  failureReasons,
52898
+ commitBranch: packet?.branch ?? null,
52842
52899
  secrets: runToken ? [runToken] : []
52843
52900
  });
52844
52901
  } catch (err2) {