@quikit/quikpilot-runner 9.3.0-rc.41 → 9.3.0-rc.42

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
@@ -156,6 +156,8 @@ wrong (a field that arrives from a database row or a request), so it only warns
156
156
 
157
157
  **9.3.0-rc.38 — a loop turn waits as long as its own clock says (QUIKTR-1582, S7).** Node's built-in `fetch` gives up on any reply whose headers take longer than 300 seconds, whatever limit the caller passes ("fetch failed", cause `UND_ERR_HEADERS_TIMEOUT`; measured on Node 20 and 24). So the 420 seconds a loop's first turn was given (9.3.0-rc.34) never happened: when the AI service's first answer of the day took more than 300 seconds, the call failed as "transport", and in map mode that ended the run (S7 trial QTRIA-8). Now every AI call that brings its own clock (each turn of the targeting, code-writing and early-look loops) goes through Node's own `http`/`https` client, which has no such limit, with TCP keep-alive as `fetch` sets it; the clock is the only thing that ends it, and a timed-out turn still reads as `turn_timeout`. Calls without a clock (the single targeting and code-writing calls) keep `fetch` exactly as before, 300 seconds included, and the retry rules are unchanged. No new dependency.
158
158
 
159
+ **9.3.0-rc.42 — the review check runs only the related tests first (QUIKTR-1812).** After a change passes every check, each changed block is put back on its own to ask whether any test notices. Every one of those runs was the whole suite (on QuikIT about 4 min 50 s, so the 6-minute review checked one block in bug 5's run). Now, where the S4 planner trusts related tests (a suite of three minutes or more, a vitest project), a block's first run is only the tests related to its file: a related test that fails settles "needed" in tens of seconds; anything else goes on exactly as before (the whole suite, and once more before "unneeded"), so every verdict, warning and fix attempt is the same. Each related run gets no more than the time left before the review's deadline, a related run that took as long as the whole suite switches related runs off for the rest of the check, and the `hunk_check` line counts `relatedRuns` and `wholeRuns`. `QUIKPILOT_RELATED_TESTS=off` restores whole-suite runs. Nothing else changes.
160
+
159
161
  **9.3.0-rc.41 — a test written once for many rows is said plainly, and the run stops (QUIKTR-1823).** Live run QTRIA-12: after a person approved one test change, the fix broke `still rejects an unauthenticated request`, ONE test inside `describe.each` that runs for 11 routes. The AI reported it four times and was told `title_not_found` each time, because tests inside `describe.each` / `it.each` are left out of the title search on purpose (their names are made at run time); the AI had copied the title right, guessed the shape of its report was wrong, and gave up, and the run said only that the AI could not make the change. Now such a report is turned away with its own word, `generated_test`, whose message tells the AI to answer CANNOT_COMPLETE and name the test. However the loop then ends, it ends `test_conflict_unreportable`: no change is kept for the checks and no second attempt is made (it would meet the same test), and the run says where the test is and which case it contradicts (file, line, case id; never a title) and that a person must change that test or correct the case. If a report of another test stands, the run stops for a decision as before and warns about the generated test. A title in no test of the file is still `title_not_found`. Also in rc.41 (QUIKTR-1824): an answer the AI Service cut off at the output limit (`CODEGEN_OUTPUT_TOO_LARGE`, `OUTPUT_TRUNCATED`) ends the attempt `output_too_large`, "the AI's answer was too long and was cut off", in the code-writing and the targeting loops, instead of `runtime_failed`, "the AI service failed" (live run QTRIA-12: a turn wrote to the limit for 193 s). Every failed attempt keeps the AI Service's own error code in the run's record (`runtimeCode`, a closed word; `other` when it is not shaped like a code), and the run's message names it. Nothing else changes.
160
162
 
161
163
  **9.3.0-rc.40 — the early look is allowed to finish.** The look's first AI call now waits up to 420 seconds (it was 150) and the whole look up to 10 minutes (it was 210 seconds), the same first-call allowance every other loop already has. Measured 22 Oct: a cold first look call took 219 seconds, so the look was cut off whenever the AI service was cold, the service never kept the response format, and the next run started cold again; a specification written without the code carried a wrong criterion far more often (9 of 24 benchmark samples, against 1 of 24 with the code). QuikProjects now keeps findings that arrive after its own wait ran out, so the later steps of the run read the code. Nothing else changes.
package/dist/index.js CHANGED
@@ -42910,6 +42910,7 @@ var DEFAULT_MAX_HUNKS = 8;
42910
42910
  var MAX_FILE_BYTES = 1e6;
42911
42911
  var FRESH_SLACK_MS3 = 2e3;
42912
42912
  var SAFETY_MS = 6e4;
42913
+ var MIN_RELATED_RUN_MS = 3e4;
42913
42914
  var CODE_EXTENSIONS = /\.(?:[cm]?[jt]sx?|py|go|java|rb|rs|cs|php|kt)$/i;
42914
42915
  function eligibleForHunkCheck(path) {
42915
42916
  return CODE_EXTENSIONS.test(path) && !isTestFile(path);
@@ -42935,7 +42936,14 @@ async function runHunkCheck(input) {
42935
42936
  const now = input.now ?? Date.now;
42936
42937
  const log = input.log ?? (() => {
42937
42938
  });
42938
- const result = { unnecessary: [], checked: 0, total: 0, skipped: { whitespace: 0, tooBig: 0, cap: 0, time: 0, unknown: 0, files: 0 } };
42939
+ const result = {
42940
+ unnecessary: [],
42941
+ checked: 0,
42942
+ total: 0,
42943
+ skipped: { whitespace: 0, tooBig: 0, cap: 0, time: 0, unknown: 0, files: 0 },
42944
+ relatedRuns: 0,
42945
+ wholeRuns: 0
42946
+ };
42939
42947
  if (!input.baseline.results || input.baseline.results.size === 0) return { ...result, stopped: "no_baseline" };
42940
42948
  const limit = testTimeLimitMs(input.baselineMs);
42941
42949
  if (limit === "too_slow") return { ...result, stopped: "too_slow" };
@@ -42966,6 +42974,7 @@ async function runHunkCheck(input) {
42966
42974
  const findReport = input.findReport ?? findJUnitReport;
42967
42975
  const readSnapshot = input.readSnapshot ?? readTestSnapshot;
42968
42976
  const runCommand2 = input.runCommand ?? runTestCommandWithLimit;
42977
+ const readAt = input.readSnapshotAt ?? readTestSnapshotAt;
42969
42978
  let slowestRunMs = input.baselineMs ?? 3e4;
42970
42979
  const runOnce = async (c) => {
42971
42980
  const reportBefore = findReport(input.root);
@@ -42973,6 +42982,7 @@ async function runHunkCheck(input) {
42973
42982
  const content = `${c.bom ? "\uFEFF" : ""}${fromLf(revertHunk(c.originalLf, c.currentLf, c.hunk), c.ending)}`;
42974
42983
  const startedWall = Date.now();
42975
42984
  const startedAt = now();
42985
+ result.wholeRuns += 1;
42976
42986
  try {
42977
42987
  const verdict = await withOverlayOnDisk(
42978
42988
  input.root,
@@ -43002,20 +43012,72 @@ async function runHunkCheck(input) {
43002
43012
  throw err;
43003
43013
  }
43004
43014
  };
43015
+ const runRelated = async (c, plan, limitMs) => {
43016
+ const reportBefore = findReport(input.root);
43017
+ const preserve = reportBefore ? [(0, import_node_path18.relative)(input.root, reportBefore).split("\\").join("/")] : [];
43018
+ const content = `${c.bom ? "\uFEFF" : ""}${fromLf(revertHunk(c.originalLf, c.currentLf, c.hunk), c.ending)}`;
43019
+ const startedAt = now();
43020
+ result.relatedRuns += 1;
43021
+ try {
43022
+ const verdict = await withOverlayOnDisk(
43023
+ input.root,
43024
+ [{ path: c.file, content }],
43025
+ async () => {
43026
+ (0, import_node_fs18.rmSync)(plan.report, { force: true });
43027
+ try {
43028
+ const run2 = await runCommand2(plan.command, limitMs, plan.cwd);
43029
+ if (!run2.started || run2.timedOut) return "unknown";
43030
+ const after = readAt(run2.outcome, plan.report);
43031
+ if (!after.results || after.results.size === 0) return "unknown";
43032
+ return checkForRegressions(input.baseline, after).blocked ? "needed" : "unneeded";
43033
+ } finally {
43034
+ (0, import_node_fs18.rmSync)(plan.report, { force: true });
43035
+ }
43036
+ },
43037
+ { ...input.tree, preserve }
43038
+ );
43039
+ input.planner?.ran({ plan, wallMs: now() - startedAt, baselineMs: input.baselineMs });
43040
+ return verdict;
43041
+ } catch (err) {
43042
+ if (err instanceof DiskWriteRefused) return "unknown";
43043
+ throw err;
43044
+ }
43045
+ };
43005
43046
  const queue = candidates.slice(0, input.maxHunks ?? DEFAULT_MAX_HUNKS);
43006
43047
  result.skipped.cap = candidates.length - queue.length;
43007
43048
  let handled = 0;
43008
43049
  try {
43009
43050
  for (const c of queue) {
43010
- if (now() + slowestRunMs + SAFETY_MS > input.deadlineAtMs) {
43011
- result.stopped = "out_of_time";
43012
- break;
43051
+ const relatedLeftMs = input.deadlineAtMs - now() - SAFETY_MS;
43052
+ const plan = input.planner && relatedLeftMs >= MIN_RELATED_RUN_MS ? input.planner.plan({ overlayPaths: [c.file], baselineMs: input.baselineMs }) : null;
43053
+ let verdict = "unknown";
43054
+ let via = "whole";
43055
+ let started = false;
43056
+ if (plan?.scope === "related") {
43057
+ handled += 1;
43058
+ result.checked += 1;
43059
+ started = true;
43060
+ via = "related";
43061
+ verdict = await runRelated(c, plan, Math.min(plan.limitMs, relatedLeftMs));
43062
+ }
43063
+ if (verdict !== "needed") {
43064
+ if (now() + slowestRunMs + SAFETY_MS > input.deadlineAtMs) {
43065
+ result.stopped = "out_of_time";
43066
+ if (started) {
43067
+ result.skipped.unknown += 1;
43068
+ log({ event: "hunk_check.block", verdict: "unknown", via });
43069
+ }
43070
+ break;
43071
+ }
43072
+ if (!started) {
43073
+ handled += 1;
43074
+ result.checked += 1;
43075
+ }
43076
+ via = "whole";
43077
+ verdict = await runOnce(c);
43078
+ if (verdict === "unneeded") verdict = await runOnce(c);
43013
43079
  }
43014
- handled += 1;
43015
- result.checked += 1;
43016
- let verdict = await runOnce(c);
43017
- if (verdict === "unneeded") verdict = await runOnce(c);
43018
- log({ event: "hunk_check.block", verdict });
43080
+ log({ event: "hunk_check.block", verdict, via });
43019
43081
  if (verdict === "unknown") result.skipped.unknown += 1;
43020
43082
  else if (verdict === "unneeded") {
43021
43083
  const { startLine, endLine } = hunkLines(c.hunk, c.totalLines);
@@ -44311,7 +44373,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
44311
44373
  var REPORT_COPY = "final-test-report.xml";
44312
44374
  var MAX_REPORT_BYTES = 5 * 1024 * 1024;
44313
44375
  var MAX_FILES = 200;
44314
- var RUNNER_VERSION = true ? "9.3.0-rc.41" : "dev";
44376
+ var RUNNER_VERSION = true ? "9.3.0-rc.42" : "dev";
44315
44377
  function safeDestination(base, repoPath) {
44316
44378
  if (!repoPath || (0, import_node_path23.isAbsolute)(repoPath)) return null;
44317
44379
  const destination = (0, import_node_path23.resolve)(base, repoPath);
@@ -45176,6 +45238,15 @@ async function run(env2) {
45176
45238
  const healCalls = [];
45177
45239
  let healStop;
45178
45240
  const testCommand = packet.commands.test;
45241
+ const reviewPlanner = createRelatedPlanner({
45242
+ root: process.cwd(),
45243
+ command: testCommand,
45244
+ listing: workspaceListing,
45245
+ deniedPaths: packet.guardrails.deniedPaths,
45246
+ writeRoot,
45247
+ discoveredTests: discoveredTestsOf(packet.testDiscovery),
45248
+ log: (e) => console.log(JSON.stringify(e))
45249
+ });
45179
45250
  const hunkCheckOver = async (changed, testCount) => {
45180
45251
  if (codegenMode !== "loop-tests" || process.env.QUIKPILOT_HUNK_CHECK?.trim().toLowerCase() === "off") return null;
45181
45252
  const deadlineAtMs = Math.min(jobStopAtMs - HUNK_CHECK_END_BEFORE_STOP_MS, Date.now() + HUNK_CHECK_MAX_MS);
@@ -45185,6 +45256,8 @@ async function run(env2) {
45185
45256
  return runHunkCheck({
45186
45257
  root: process.cwd(),
45187
45258
  command: testCommand,
45259
+ // QUIKTR-1812: each block's first run is only the related tests where the planner trusts them (its own instance, its own state).
45260
+ planner: reviewPlanner,
45188
45261
  baseline,
45189
45262
  baselineMs: timedBaseline.durationMs,
45190
45263
  finalTestCount: testCount,
@@ -45257,7 +45330,7 @@ async function run(env2) {
45257
45330
  const reused = fixed.review && fixed.review.results === fixed.results ? fixed.review.raw : void 0;
45258
45331
  const checked = reused ?? await hunkCheckOver(fixed.results, final.outputs.testCount ?? 0);
45259
45332
  if (checked) {
45260
- if (!reused) console.log(JSON.stringify({ event: "hunk_check", checked: checked.checked, total: checked.total, flagged: checked.unnecessary.length, skipped: checked.skipped, stopped: checked.stopped ?? null }));
45333
+ if (!reused) console.log(JSON.stringify({ event: "hunk_check", checked: checked.checked, total: checked.total, flagged: checked.unnecessary.length, skipped: checked.skipped, stopped: checked.stopped ?? null, relatedRuns: checked.relatedRuns, wholeRuns: checked.wholeRuns }));
45261
45334
  changesNoTestDependsOn = toFinding(checked);
45262
45335
  if (checked.unnecessary.length > 0) {
45263
45336
  const w = describeHunkCheck(checked);