@quikit/quikpilot-runner 9.3.0-rc.22 → 9.3.0-rc.23

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
@@ -150,6 +150,8 @@ it, the callback carries it as `unsuppliedInputs` (at most 10 functions, 5 names
150
150
  noticed" as a check. This is the shape of a change whose new tests pass only because they hand the function the field themselves. It can be
151
151
  wrong (a field that arrives from a database row or a request), so it only warns and never blocks. TypeScript is not covered (QUIKTR-1547).
152
152
 
153
+ **9.3.0-rc.23 — the red check counts one-file runs (QUIKTR-1608, live run QUIKSPL-208).** On rc.22 the first two-phase run opened a correct pull request (#112), but phase 1 proved the bug with a run of its test file (4 failing on the old code), the red check counted whole-suite runs only, sent the DONE back twice and ended phase 1 marked 5 cases unproven, so the reviewer was wrongly warned. Every run of phase 1 is now evidence, with the change it ran on: a case is FAILING when a run on the change as it stands lists its test failing; PASSING when such a run covered its test (the whole suite, or the one file that holds its `[QP-...]` token) and it did not fail; NOT RUN when nothing covered it. A test seen passing is sent back as before; one not run is sent back with a sentence naming it, and if phase 1 ends anyway it is logged (`ended_unrun`) but never shown to the reviewer as unproven: only a test seen passing on the old code is. A cut failing list still cannot tell. The next phase is told about the latest run on the change as it stands, a one-file run included. Runner only.
154
+
153
155
  **9.3.0-rc.22 — phase 1 after the first live run (QUIKTR-1608, live run QUIKSPL-207).** On rc.21 the first live two-phase run failed in phase 1 in both attempts: the AI fought the existing-test rule for ten turns, then made its red tests pass and gave up. (1) In phase `tests`, a give-up (`CANNOT_COMPLETE`) whose change passes every hand-over check (every case covered, tests only) and whose tests were seen failing on the untouched code, in a whole-suite run on the change as it stands, is phase 1 done: the code phase follows (log `codegen.red_check` `gave_up_but_red`). (2) A failed two-phase attempt now records the phases it went through and their counts, as a finished one does. The AI Runtime's phase-1 paragraph (contract §33.4, amended) says failing is the goal (DONE then) and to put new tests and their helpers in a new test file when an existing one sends additions back; deploy it first.
154
156
 
155
157
  **9.3.0-rc.21 (harness 6 of 7) — reproduce first, then fix (QUIKTR-1608, contract §33).** One step could change the tests and the code at once; when they disagreed the AI changed both (G18, G20, G23; fixes rescued 2 of 6 kept give-ups). Under the harness version an attempt is now written in phases, each held to its files by the runner (`codegenTools.ts` lane, answered `protected` before any budget is touched): (1) `loop.phase: "tests"` - only test files may change (the code answers `code_locked`); before the phase may end, each own test for a case with a known, non-Regression label must be seen FAILING in a whole-suite run on the untouched code. Otherwise the DONE is sent back as a refused turn (rule word `done_rule`, a fixed sentence naming the cases), at most twice; then the phase ends and the reviewer is warned (record `phases[].redUnproven`). (2) `loop.phase: "code"` - the phase-1 tests are frozen (`test_frozen`, also for any new or existing test file); the request carries them as a kept change (`endedWith: "tests_written"`, the red run, §32's steps). (3) When the code phase gives up while frozen tests of this run still fail: ONE amendment, a short code-phase loop with `loop.amend` (those files only, `edit_file` only, never emptied); the change then goes on with a warning naming the files. If the amendment fails too, the attempt fails `test_case_disagree` and is not tried again; no pull request. A second attempt after a failed code phase starts from the same frozen tests; fixes after the project's checks and the review fix are code-only with the tests frozen. The run record gains `phases` (phase, outcome, counts) and each test run its `phase`; the record now keeps 20 test runs and a run's `scope` (two gaps of the 1604 build). **`QUIKPILOT_TWO_PHASE=off` writes the change in one phase, as before.** AI Runtime contract §33 and QuikProjects (record schema) first. **Not published: waits for all seven harness tickets.**
package/dist/index.js CHANGED
@@ -14293,22 +14293,38 @@ async function runCodegenLoop(args, deps) {
14293
14293
  const refusedTurns = [];
14294
14294
  let refusedStreak = 0;
14295
14295
  let sent = { entries: 0, results: 0 };
14296
- let lastTestVersion = null;
14296
+ const redRuns = [];
14297
14297
  let redRefusals = 0;
14298
14298
  let redUnproven;
14299
+ const currentRedRuns = () => {
14300
+ const now2 = versionOfFiles(filesOnDisk());
14301
+ return redRuns.filter((r) => r.version === now2);
14302
+ };
14299
14303
  const redProblem = () => {
14300
14304
  const ids = args.redCheckIds ?? [];
14301
14305
  if (ids.length === 0) return null;
14302
- if (!lastTestAnswer || lastTestVersion !== versionOfFiles(filesOnDisk())) {
14303
- return { ids, sentence: "Run the tests with run_tests before finishing phase 1: each new test must fail on the code before any change." };
14304
- }
14305
- if (lastTestAnswer.truncated) return null;
14306
- const failing = lastTestAnswer.failingTests;
14307
- const passing = ids.filter((id) => !failing.some((name) => name.includes(`[${id}]`)));
14308
- if (passing.length === 0) return null;
14309
- const named = passing.slice(0, 6).map((id) => `[${id}]`).join(", ");
14310
- const sentence = `${named} ${passing.length === 1 ? "passes" : "pass"} on the code before any change, so ${passing.length === 1 ? "it does" : "they do"} not show the bug: revise ${passing.length === 1 ? "it" : "them"} so ${passing.length === 1 ? "it fails" : "each fails"} for the reason its case gives.`;
14311
- return { ids: passing, sentence: sentence.slice(0, 300) };
14306
+ const runs = currentRedRuns();
14307
+ const passing = [];
14308
+ const unrun = [];
14309
+ for (const id of ids) {
14310
+ const token = `[${id}]`;
14311
+ if (runs.some((r) => r.failing.some((name) => name.includes(token)))) continue;
14312
+ const covering = runs.filter((r) => r.file === void 0 || (overlay.get(r.file)?.lf ?? "").includes(token));
14313
+ if (covering.length === 0) unrun.push(id);
14314
+ else if (covering.every((r) => !r.truncated)) passing.push(id);
14315
+ }
14316
+ if (passing.length > 0) {
14317
+ const one = passing.length === 1;
14318
+ const named = passing.slice(0, 6).map((id) => `[${id}]`).join(", ");
14319
+ const sentence = `${named} ${one ? "passes" : "pass"} on the code before any change, so ${one ? "it does" : "they do"} not show the bug: revise ${one ? "it" : "them"} so ${one ? "it fails" : "each fails"} for the reason its case gives.`;
14320
+ return { ids: passing, sentence: sentence.slice(0, 300), kind: "passing" };
14321
+ }
14322
+ if (unrun.length > 0) {
14323
+ const named = unrun.slice(0, 6).map((id) => `[${id}]`).join(", ");
14324
+ const sentence = `Run the tests with run_tests (the whole suite, or the file that holds them) before finishing phase 1: ${named} ${unrun.length === 1 ? "has" : "have"} not been run on the code as it is now.`;
14325
+ return { ids: unrun, sentence: sentence.slice(0, 300), kind: "unrun" };
14326
+ }
14327
+ return null;
14312
14328
  };
14313
14329
  const sentSteps = () => stepsOf(transcript.slice(0, sent.entries), toolResults.slice(0, sent.results));
14314
14330
  let turns = 0;
@@ -14485,9 +14501,10 @@ async function runCodegenLoop(args, deps) {
14485
14501
  log({ event: "codegen.loop_turn", turn, outcome: "cannot_complete", requestTokens, elapsedMs: now() - turnStarted, calls: [] });
14486
14502
  const said = typeof body.summary === "string" ? body.summary.slice(0, MAX_SUMMARY_CHARS) : void 0;
14487
14503
  const last = lastTestAnswer;
14488
- if (harness && args.phase === "tests" && last !== void 0 && lastTestVersion === versionOfFiles(filesOnDisk()) && handOverRefusal(turn, true) === null && redProblem() === null) {
14504
+ if (harness && args.phase === "tests" && currentRedRuns().length > 0 && handOverRefusal(turn, true) === null && redProblem() === null) {
14489
14505
  log({ event: "codegen.red_check", turn, outcome: "gave_up_but_red", files: overlay.changedPaths().length });
14490
- return { results: overlay.results(), summary: snapshot("gave_up_kept"), doneSummary: said ?? "", steps: sentSteps(), lastTestAnswer: last };
14506
+ const red = currentRedRuns().at(-1).answer;
14507
+ return { results: overlay.results(), summary: snapshot("gave_up_kept"), doneSummary: said ?? "", steps: sentSteps(), lastTestAnswer: last ?? red };
14491
14508
  }
14492
14509
  if (args.keepOnGiveUp === true && last !== void 0 && last.regressions + last.newFailures > 0 && handOverRefusal(turn, true) === null) {
14493
14510
  log({ event: "codegen.loop_kept", files: overlay.changedPaths().length, regressions: last.regressions, newFailures: last.newFailures });
@@ -14512,13 +14529,14 @@ async function runCodegenLoop(args, deps) {
14512
14529
  forced = settleNextTurn(turn, forced);
14513
14530
  continue;
14514
14531
  }
14515
- redUnproven = red.ids;
14516
- log({ event: "codegen.red_check", turn, outcome: "ended_unproven", cases: red.ids.length });
14532
+ if (red.kind === "passing") redUnproven = red.ids;
14533
+ log({ event: "codegen.red_check", turn, outcome: red.kind === "passing" ? "ended_unproven" : "ended_unrun", cases: red.ids.length });
14517
14534
  }
14518
14535
  const stopReason = isFinal ? `forced_${finalReason}` : "model_done";
14519
14536
  const doneSummary = typeof body.summary === "string" ? body.summary.slice(0, MAX_SUMMARY_CHARS) : "";
14520
14537
  log({ event: "codegen.loop_done", turns, toolCalls: ledger.toolCalls, edits: ws.edits.size, created: ws.created.size, stopReason });
14521
- return { results: overlay.results(), summary: snapshot(stopReason), doneSummary, steps: sentSteps(), ...redUnproven ? { redUnproven } : {}, ...lastTestAnswer ? { lastTestAnswer } : {} };
14538
+ const told = lastTestAnswer ?? (args.phase === "tests" ? currentRedRuns().at(-1)?.answer : void 0);
14539
+ return { results: overlay.results(), summary: snapshot(stopReason), doneSummary, steps: sentSteps(), ...redUnproven ? { redUnproven } : {}, ...told ? { lastTestAnswer: told } : {} };
14522
14540
  }
14523
14541
  if (body.outcome !== "TOOL_CALLS") throw new CodegenLoopFailure("bad_reply");
14524
14542
  if (isFinal) throw new CodegenLoopFailure("final_not_produced");
@@ -14570,9 +14588,10 @@ async function runCodegenLoop(args, deps) {
14570
14588
  }
14571
14589
  }
14572
14590
  results.push(result);
14573
- if (call.name === RUN_TESTS_TOOL && isTestAnswer(result.output) && result.output.scope === void 0) {
14574
- lastTestAnswer = result.output;
14575
- lastTestVersion = versionOfFiles(filesOnDisk());
14591
+ if (call.name === RUN_TESTS_TOOL && isTestAnswer(result.output) && result.output.scope === void 0) lastTestAnswer = result.output;
14592
+ if (call.name === RUN_TESTS_TOOL && isTestAnswer(result.output) && result.status !== "duplicate") {
14593
+ const file = result.output.scope === "file" && isPlainObject3(call.args) && typeof call.args.file === "string" ? call.args.file : void 0;
14594
+ redRuns.push({ version: versionOfFiles(filesOnDisk()), ...file ? { file } : {}, failing: result.output.failingTests, truncated: result.output.truncated, answer: result.output });
14576
14595
  }
14577
14596
  if (read) reads.push(read);
14578
14597
  statusCounts[result.status] = (statusCounts[result.status] ?? 0) + 1;
@@ -16544,7 +16563,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
16544
16563
  var REPORT_COPY = "final-test-report.xml";
16545
16564
  var MAX_REPORT_BYTES = 5 * 1024 * 1024;
16546
16565
  var MAX_FILES = 200;
16547
- var RUNNER_VERSION = true ? "9.3.0-rc.22" : "dev";
16566
+ var RUNNER_VERSION = true ? "9.3.0-rc.23" : "dev";
16548
16567
  function safeDestination(base, repoPath) {
16549
16568
  if (!repoPath || (0, import_node_path15.isAbsolute)(repoPath)) return null;
16550
16569
  const destination = (0, import_node_path15.resolve)(base, repoPath);