@feigi/fleet-ctl 0.0.0 → 3.16.2

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.
Files changed (152) hide show
  1. package/agents/{fleet-implementer.agent.md → fleet-implementer-slow-high.agent.md} +23 -2
  2. package/agents/fleet-implementer-slow-medium.agent.md +231 -0
  3. package/agents/fleet-implementer-smol-high.agent.md +231 -0
  4. package/agents/{fleet-implementer-alt.agent.md → fleet-implementer-task-high.agent.md} +23 -2
  5. package/agents/fleet-implementer-task-max.agent.md +231 -0
  6. package/agents/fleet-review-comments.agent.md +4 -2
  7. package/agents/fleet-review-correctness.agent.md +2 -1
  8. package/agents/fleet-review-runner.agent.md +14 -10
  9. package/agents/fleet-review-silent-failure.agent.md +4 -3
  10. package/agents/fleet-review-simplify.agent.md +2 -1
  11. package/agents/fleet-review-snapshot.agent.md +2 -1
  12. package/agents/fleet-review-test-run.agent.md +29 -0
  13. package/agents/fleet-review-tests.agent.md +10 -5
  14. package/agents/fleet-review-types.agent.md +4 -2
  15. package/agents/fleet-review-verifier.agent.md +4 -3
  16. package/commands/review-and-fix.md +7 -6
  17. package/commands/run-merge-bot.md +14 -4
  18. package/package.json +4 -2
  19. package/scripts/agent-test.test.mjs +36 -32
  20. package/scripts/ambient-git-vars-mjs-prose.test.mjs +23 -13
  21. package/scripts/apply-ruleset.test.mjs +4 -3
  22. package/scripts/arg-header-probes-prose.test.mjs +1 -0
  23. package/scripts/arg.test.mjs +18 -18
  24. package/scripts/board-cli.test.mjs +18 -21
  25. package/scripts/board-identity.test.mjs +9 -9
  26. package/scripts/board-liveness-banner.test.mjs +6 -6
  27. package/scripts/board-prev-shape.test.mjs +12 -13
  28. package/scripts/board-tryparse-null.test.mjs +7 -7
  29. package/scripts/board.mjs +4 -7
  30. package/scripts/board.test.mjs +57 -61
  31. package/scripts/candidates.test.mjs +228 -17
  32. package/scripts/ci-completes-premise-prose.test.mjs +1 -1
  33. package/scripts/ci-state-prose.test.mjs +2 -2
  34. package/scripts/ci-state.mjs +389 -187
  35. package/scripts/ci-state.test.mjs +458 -165
  36. package/scripts/claim-lifecycle.test.mjs +2 -1
  37. package/scripts/claim-ticket.test.mjs +35 -34
  38. package/scripts/closing-keyword-prose.test.mjs +1 -1
  39. package/scripts/cockpit-tick-nonblocking.test.mjs +8 -8
  40. package/scripts/compute-board.mjs +13 -3
  41. package/scripts/compute-board.test.mjs +64 -1
  42. package/scripts/compute-spend.mjs +46 -8
  43. package/scripts/compute-spend.test.mjs +64 -10
  44. package/scripts/cross-repo-citation-prose.test.mjs +18 -19
  45. package/scripts/delete-merged-branch.sh +218 -0
  46. package/scripts/delete-merged-branch.test.mjs +576 -0
  47. package/scripts/derive-testcmd.sh +18 -7
  48. package/scripts/derive-testcmd.test.mjs +9 -8
  49. package/scripts/diff-stats.mjs +2 -2
  50. package/scripts/diff-stats.test.mjs +7 -11
  51. package/scripts/dispatch-block-golden-prose.test.mjs +111 -6
  52. package/scripts/dispatch-block-pins-prose.test.mjs +5 -5
  53. package/scripts/dispositions-check.mjs +507 -0
  54. package/scripts/dispositions-check.test.mjs +843 -0
  55. package/scripts/dispositions-gate-prose.test.mjs +114 -0
  56. package/scripts/drop-merged-label.test.mjs +3 -4
  57. package/scripts/exec-stub.mjs +93 -0
  58. package/scripts/exec-stub.test.mjs +69 -0
  59. package/scripts/filing-bar-seat-prose.test.mjs +1 -1
  60. package/scripts/finisher-test-verdict-prose.test.mjs +102 -0
  61. package/scripts/fix-applier-correction-rules-prose.test.mjs +11 -10
  62. package/scripts/fleet-bootstrap +5 -20
  63. package/scripts/fleet-bootstrap.test.mjs +75 -0
  64. package/scripts/fleet-heartbeat.mjs +2 -2
  65. package/scripts/fleet-provenance +15 -24
  66. package/scripts/fleet-provenance.test.mjs +86 -12
  67. package/scripts/fleet-run.test.mjs +5 -5
  68. package/scripts/fleet-state.mjs +33 -11
  69. package/scripts/fleet-state.test.mjs +90 -3
  70. package/scripts/fleet-tick.mjs +346 -70
  71. package/scripts/fleet-tick.test.mjs +566 -16
  72. package/scripts/force-with-lease-reason-prose.test.mjs +1 -1
  73. package/scripts/frontmatter-check.mjs +3 -2
  74. package/scripts/frontmatter-check.test.mjs +6 -6
  75. package/scripts/immutable-body-claim-prose.test.mjs +53 -262
  76. package/scripts/implementer-model-tier.test.mjs +98 -506
  77. package/scripts/inflight.test.mjs +18 -127
  78. package/scripts/is-cli.mjs +26 -0
  79. package/scripts/is-cli.test.mjs +99 -0
  80. package/scripts/json.test.mjs +3 -3
  81. package/scripts/ledger-dispatch.test.mjs +368 -7
  82. package/scripts/ledger-grammar.mjs +85 -1
  83. package/scripts/ledger-grammar.test.mjs +86 -1
  84. package/scripts/ledger-read-require-file.test.mjs +7 -7
  85. package/scripts/ledger-rotate.test.mjs +142 -0
  86. package/scripts/ledger.mjs +181 -17
  87. package/scripts/ledger.test.mjs +12 -130
  88. package/scripts/main-checkout.mjs +312 -0
  89. package/scripts/main-checkout.test.mjs +332 -0
  90. package/scripts/member-outcomes-header.test.mjs +3 -3
  91. package/scripts/member-outcomes.mjs +4 -5
  92. package/scripts/member-outcomes.test.mjs +92 -18
  93. package/scripts/member-prompt-prose.test.mjs +17 -13
  94. package/scripts/member-record.mjs +8 -3
  95. package/scripts/member-record.test.mjs +5 -5
  96. package/scripts/member-write-guard.mjs +5 -5
  97. package/scripts/member-write-guard.test.mjs +6 -3
  98. package/scripts/no-undo-audit.sh +24 -21
  99. package/scripts/no-undo-audit.test.mjs +9 -13
  100. package/scripts/pointer-target-prose.test.mjs +1 -1
  101. package/scripts/pr-overlap.test.mjs +6 -9
  102. package/scripts/prompt-renderer.mjs +10 -9
  103. package/scripts/prose-pin.mjs +10 -11
  104. package/scripts/prove-merge.test.mjs +3 -3
  105. package/scripts/quiet-payload-prose.test.mjs +1 -1
  106. package/scripts/reap.test.mjs +3 -4
  107. package/scripts/release-label-split-prose.test.mjs +17 -2
  108. package/scripts/release-ticket.test.mjs +35 -44
  109. package/scripts/review-core-cwd-isolation.test.mjs +7 -6
  110. package/scripts/review-core-reads.test.mjs +1 -1
  111. package/scripts/review-core-scratch-refusal.test.mjs +64 -0
  112. package/scripts/review-core-shared-test-run.test.mjs +238 -0
  113. package/scripts/review-core-snapshot-path.test.mjs +59 -12
  114. package/scripts/review-core-specialist-scratch.test.mjs +12 -10
  115. package/scripts/review-core-testcmd.test.mjs +76 -45
  116. package/scripts/review-core-unrun.test.mjs +154 -168
  117. package/scripts/review-core.mjs +250 -56
  118. package/scripts/review-eval.mjs +11 -4
  119. package/scripts/review-host-fixture.mjs +12 -3
  120. package/scripts/review-in-run-retry.test.mjs +27 -3
  121. package/scripts/review-runner-spawns.test.mjs +5 -3
  122. package/scripts/review-runner.test.mjs +14 -3
  123. package/scripts/review-tier-audit.test.mjs +1 -1
  124. package/scripts/run-merge-bot-prose.test.mjs +29 -6
  125. package/scripts/scratch-partition-invariant-prose.test.mjs +1 -1
  126. package/scripts/section-between-guard-prose.test.mjs +4 -3
  127. package/scripts/select-dimensions.test.mjs +1 -1
  128. package/scripts/shell-traps-prose.test.mjs +6 -9
  129. package/scripts/shortlist.mjs +4 -1
  130. package/scripts/shortlist.test.mjs +30 -16
  131. package/scripts/snapshot-repo.test.mjs +177 -4
  132. package/scripts/stash-prohibition-prose.test.mjs +1 -1
  133. package/scripts/temp-dir.mjs +47 -0
  134. package/scripts/tier-check.mjs +95 -28
  135. package/scripts/tier-check.test.mjs +131 -29
  136. package/scripts/tier-outcomes-header.test.mjs +11 -54
  137. package/scripts/tier-outcomes.mjs +34 -12
  138. package/scripts/tier-outcomes.test.mjs +157 -4
  139. package/scripts/tier-roles.mjs +118 -29
  140. package/scripts/tier-roles.test.mjs +226 -61
  141. package/scripts/tracker-block-copy-prose.test.mjs +3 -3
  142. package/scripts/verify-sha.test.mjs +4 -5
  143. package/scripts/watcher-degraded-block.test.mjs +5 -8
  144. package/scripts/within-run-pair-prose.test.mjs +43 -75
  145. package/scripts/worktree-audit.test.mjs +2 -1
  146. package/skills/next-ticket/SKILL.md +2 -2
  147. package/skills/run-team/SKILL.md +433 -303
  148. package/skills/run-team/references/ci-and-staleness.md +7 -6
  149. package/skills/run-team/references/correction-tickets.md +3 -3
  150. package/skills/run-team/references/isolation.md +1 -1
  151. package/skills/sizing-a-ticket/SKILL.md +8 -8
  152. package/scripts/tier-guard-gate-prose.test.mjs +0 -216
@@ -21,6 +21,7 @@ import { tmpdir } from "node:os";
21
21
  import { dirname, join } from "node:path";
22
22
  import { fileURLToPath } from "node:url";
23
23
  import { slowTransport, SSH_URL } from "./slow-transport.mjs";
24
+ import { writeExecStub } from "./exec-stub.mjs";
24
25
 
25
26
  const SCRIPT = fileURLToPath(new URL("./release-ticket.sh", import.meta.url));
26
27
  const INFLIGHT = fileURLToPath(new URL("./inflight.sh", import.meta.url));
@@ -134,7 +135,7 @@ function repo(t, dir = "w") {
134
135
  const bin = join(root, "bin");
135
136
  execFileSync("mkdir", ["-p", bin]);
136
137
  const log = join(root, "gh.log");
137
- writeFileSync(
138
+ writeExecStub(
138
139
  join(bin, "gh"),
139
140
  `#!/bin/sh
140
141
  printf '%s\\n' "$*" >> "${log}"
@@ -165,7 +166,6 @@ case "$*" in
165
166
  esac
166
167
  exit 0
167
168
  `,
168
- { mode: 0o755 },
169
169
  );
170
170
  writeFileSync(log, "");
171
171
 
@@ -241,7 +241,7 @@ function claim(w, issue, slug, type = "fix") {
241
241
  * binary and then keep going (the #395 case appends a line to its listing).
242
242
  */
243
243
  function gitShim(r, body) {
244
- writeFileSync(join(r.w, "..", "bin", "git"), `#!/bin/sh\n${body}\nexec '${REAL_GIT}' "$@"\n`, { mode: 0o755 });
244
+ writeExecStub(join(r.w, "..", "bin", "git"), `#!/bin/sh\n${body}\nexec '${REAL_GIT}' "$@"\n`);
245
245
  }
246
246
 
247
247
  /**
@@ -251,10 +251,9 @@ function gitShim(r, body) {
251
251
  * several awks over the same listing and only the program text tells them apart.
252
252
  */
253
253
  function awkShim(r, marker) {
254
- writeFileSync(
254
+ writeExecStub(
255
255
  join(r.w, "..", "bin", "awk"),
256
256
  `#!/bin/sh\ncase "$*" in *'${marker}'*) echo "awk: simulated failure" >&2; exit 2 ;; esac\nexec '${REAL_AWK}' "$@"\n`,
257
- { mode: 0o755 },
258
257
  );
259
258
  }
260
259
 
@@ -646,7 +645,7 @@ test("a blocker that cannot be escaped is exit 2 with a cause, never the blocked
646
645
  const bin = mkdtempSync(join(tmpdir(), "release-ticket-esc-"));
647
646
  t.after(() => rmSync(bin, { recursive: true, force: true }));
648
647
  const realSed = execFileSync("sh", ["-c", "command -v sed"], { encoding: "utf8" }).trim();
649
- writeFileSync(join(bin, "sed"), `#!/bin/sh
648
+ writeExecStub(join(bin, "sed"), `#!/bin/sh
650
649
  case " $* " in
651
650
  *:a*)
652
651
  in=$(cat)
@@ -654,7 +653,7 @@ case " $* " in
654
653
  printf '%s\\n' "$in" | exec ${realSed} "$@" ;;
655
654
  esac
656
655
  exec ${realSed} "$@"
657
- `, { mode: 0o755 });
656
+ `);
658
657
 
659
658
  const res = release(r, c, { env: { PATH: `${bin}:${r.env().PATH}` } });
660
659
 
@@ -710,7 +709,7 @@ const REAL_SED = execFileSync("sh", ["-c", "command -v sed"], { encoding: "utf8"
710
709
  function sedShim(t, body) {
711
710
  const bin = mkdtempSync(join(tmpdir(), "release-ticket-sed-shim-"));
712
711
  t.after(() => rmSync(bin, { recursive: true, force: true }));
713
- writeFileSync(join(bin, "sed"), `#!/bin/sh\n${body}\n`, { mode: 0o755 });
712
+ writeExecStub(join(bin, "sed"), `#!/bin/sh\n${body}\n`);
714
713
  return bin;
715
714
  }
716
715
 
@@ -721,7 +720,7 @@ const REAL_GREP = execFileSync("sh", ["-c", "command -v grep"], { encoding: "utf
721
720
  function grepShim(t, body) {
722
721
  const bin = mkdtempSync(join(tmpdir(), "release-ticket-grep-shim-"));
723
722
  t.after(() => rmSync(bin, { recursive: true, force: true }));
724
- writeFileSync(join(bin, "grep"), `#!/bin/sh\n${body}\n`, { mode: 0o755 });
723
+ writeExecStub(join(bin, "grep"), `#!/bin/sh\n${body}\n`);
725
724
  return bin;
726
725
  }
727
726
 
@@ -2575,6 +2574,14 @@ fi`,
2575
2574
  );
2576
2575
  });
2577
2576
 
2577
+ /** A repo whose main is two commits deep and pushed, with ticket 9 claimed off it. */
2578
+ function deepenedClaim(t) {
2579
+ const r = repo(t);
2580
+ for (const n of [1, 2]) commit(r.w, `main ${n}`, `main ${n}\n`);
2581
+ git(r.w, "push", "-q", "origin", "main");
2582
+ return { r, c: claim(r.w, 9, "release-ticket") };
2583
+ }
2584
+
2578
2585
  /**
2579
2586
  * Stop a git operation that DETACHES HEAD in a sibling worktree holding the
2580
2587
  * claim's branch, the claim's own worktree already gone. `git worktree list
@@ -2587,10 +2594,7 @@ fi`,
2587
2594
  * precondition blocker of its own, and would answer before the delete does.
2588
2595
  */
2589
2596
  function heldSibling(t, stop) {
2590
- const r = repo(t);
2591
- for (const n of [1, 2]) commit(r.w, `main ${n}`, `main ${n}\n`);
2592
- git(r.w, "push", "-q", "origin", "main");
2593
- const c = claim(r.w, 9, "release-ticket");
2597
+ const { r, c } = deepenedClaim(t);
2594
2598
  git(r.w, "worktree", "remove", c.wt);
2595
2599
  const sib = join(r.w, "..", "held-wt");
2596
2600
  git(r.w, "worktree", "add", "-q", sib, c.branch);
@@ -2606,12 +2610,17 @@ function heldSibling(t, stop) {
2606
2610
  /** Real git with stdio captured, so a rebase's `Stopped at` prose stays out of the test output. */
2607
2611
  const quietGit = (cwd, ...args) => execFileSync("git", args, { cwd, env: ENV, stdio: "pipe" });
2608
2612
 
2613
+ /** Stop `sib` mid-`rebase -i` at an `edit` on its tip commit. */
2614
+ const stopAtEditRebase = (sib) =>
2615
+ quietGit(sib, "-c", "sequence.editor=sed -i.bak s/^pick/edit/", "rebase", "-i", "HEAD~1");
2616
+
2617
+ /** The claim branch is still a local head. */
2618
+ const branchSurvives = (r, c, msg) =>
2619
+ assert.ok(git(r.w, "for-each-ref", "--format=%(refname:short)", "refs/heads").split("\n").includes(c.branch), msg);
2620
+
2609
2621
  /** What a halted release must leave: the branch, and the sibling still registered. */
2610
2622
  function assertHeldSurvives(r, c, sib) {
2611
- assert.ok(
2612
- git(r.w, "for-each-ref", "--format=%(refname:short)", "refs/heads").split("\n").includes(c.branch),
2613
- "the claim branch survives",
2614
- );
2623
+ branchSurvives(r, c, "the claim branch survives");
2615
2624
  assert.match(git(r.w, "worktree", "list", "--porcelain"), /held-wt\n/, "and the sibling that holds it is still registered");
2616
2625
  assert.ok(existsSync(sib), "with its directory");
2617
2626
  }
@@ -2621,9 +2630,7 @@ test("a sibling worktree stopped mid-`rebase -i` on the claim branch halts the d
2621
2630
  // line, `update-ref -d` went through at exit 0, and the sibling's `git
2622
2631
  // rebase --continue` then failed on `cannot lock ref`, the work left on a
2623
2632
  // detached HEAD with no branch.
2624
- const { r, c, sib } = heldSibling(t, (sib) =>
2625
- quietGit(sib, "-c", "sequence.editor=sed -i.bak s/^pick/edit/", "rebase", "-i", "HEAD~1"),
2626
- );
2633
+ const { r, c, sib } = heldSibling(t, stopAtEditRebase);
2627
2634
 
2628
2635
  const { code, json, stderr } = release(r, c);
2629
2636
  assert.equal(code, 2, stderr);
@@ -2653,13 +2660,10 @@ test("a sibling mid-rebase of a DIFFERENT branch does not hold this claim's rele
2653
2660
  // The false-refusal half: an operation in progress is not by itself a hold.
2654
2661
  // Only the branch that operation names blocks the delete, so a sibling
2655
2662
  // rebasing unrelated work must leave this claim free to release in full.
2656
- const r = repo(t);
2657
- for (const n of [1, 2]) commit(r.w, `main ${n}`, `main ${n}\n`);
2658
- git(r.w, "push", "-q", "origin", "main");
2659
- const c = claim(r.w, 9, "release-ticket");
2663
+ const { r, c } = deepenedClaim(t);
2660
2664
  const sib = join(r.w, "..", "other-wt");
2661
2665
  git(r.w, "worktree", "add", "-q", sib, "-b", "other", "origin/main");
2662
- quietGit(sib, "-c", "sequence.editor=sed -i.bak s/^pick/edit/", "rebase", "-i", "HEAD~1");
2666
+ stopAtEditRebase(sib);
2663
2667
 
2664
2668
  const { code, json, stderr } = release(r, c);
2665
2669
  assert.equal(code, 0, stderr);
@@ -2683,10 +2687,7 @@ test("a detached worktree whose git dir cannot be read halts the delete as unkno
2683
2687
  assert.equal(code, 2, stderr);
2684
2688
  assert.equal(json.released, false);
2685
2689
  assert.match(stderr, /cannot tell whether fix\/9-release-ticket is held by worktree \S*sealed-wt/);
2686
- assert.ok(
2687
- git(r.w, "for-each-ref", "--format=%(refname:short)", "refs/heads").split("\n").includes(c.branch),
2688
- "the branch survives an unanswerable check",
2689
- );
2690
+ branchSurvives(r, c, "the branch survives an unanswerable check");
2690
2691
  });
2691
2692
 
2692
2693
  test("a sibling stopped mid-rebase whose admin HEAD is corrupted still halts the delete, resolved as held (#2218)", (t) => {
@@ -2700,9 +2701,7 @@ test("a sibling stopped mid-rebase whose admin HEAD is corrupted still halts the
2700
2701
  // HEAD file, and the admin dir's rebase-merge state beside it is
2701
2702
  // untouched — so the delete halts on a DEFINITE answer, not merely
2702
2703
  // "unknown".
2703
- const { r, c, sib } = heldSibling(t, (sib) =>
2704
- quietGit(sib, "-c", "sequence.editor=sed -i.bak s/^pick/edit/", "rebase", "-i", "HEAD~1"),
2705
- );
2704
+ const { r, c, sib } = heldSibling(t, stopAtEditRebase);
2706
2705
  const admin = join(r.w, ".git", "worktrees");
2707
2706
  const name = readdirSync(admin).find(
2708
2707
  (n) => readFileSync(join(admin, n, "gitdir"), "utf8").trim() === join(realpathSync(sib), ".git"),
@@ -2747,9 +2746,7 @@ test("a prunable sibling that genuinely holds the claim via a stopped rebase sti
2747
2746
  // stopped rebase naming this branch, `git branch -D` itself still refuses
2748
2747
  // — measured — so the delete must too, even though the worktree behind it
2749
2748
  // no longer exists to be entered.
2750
- const { r, c, sib } = heldSibling(t, (sib) =>
2751
- quietGit(sib, "-c", "sequence.editor=sed -i.bak s/^pick/edit/", "rebase", "-i", "HEAD~1"),
2752
- );
2749
+ const { r, c, sib } = heldSibling(t, stopAtEditRebase);
2753
2750
  rmSync(sib, { recursive: true, force: true });
2754
2751
  assert.match(git(r.w, "worktree", "list", "--porcelain"), /prunable/, "fixture: the sibling's directory must be gone, its registration still there");
2755
2752
 
@@ -2757,10 +2754,7 @@ test("a prunable sibling that genuinely holds the claim via a stopped rebase sti
2757
2754
  assert.equal(code, 2, stderr);
2758
2755
  assert.equal(json.released, false);
2759
2756
  assert.match(stderr, /is held by a rebase or bisect in progress in worktree \S*held-wt — not deleted/);
2760
- assert.ok(
2761
- git(r.w, "for-each-ref", "--format=%(refname:short)", "refs/heads").split("\n").includes(c.branch),
2762
- "the claim branch survives",
2763
- );
2757
+ branchSurvives(r, c, "the claim branch survives");
2764
2758
  });
2765
2759
 
2766
2760
  test("a sibling's rebase-merge admin subdirectory unsearchable halts the delete as unknown, too (#2218)", (t) => {
@@ -2770,9 +2764,7 @@ test("a sibling's rebase-merge admin subdirectory unsearchable halts the delete
2770
2764
  // succeeds — and only the rebase-merge subdirectory this function has to
2771
2765
  // read INTO is chmod'd unsearchable: the second, narrower readability
2772
2766
  // guard `wt_op_state` carries for exactly this shape, untested until now.
2773
- const { r, c, sib } = heldSibling(t, (sib) =>
2774
- quietGit(sib, "-c", "sequence.editor=sed -i.bak s/^pick/edit/", "rebase", "-i", "HEAD~1"),
2775
- );
2767
+ const { r, c, sib } = heldSibling(t, stopAtEditRebase);
2776
2768
  const admin = join(r.w, ".git", "worktrees");
2777
2769
  const name = readdirSync(admin).find(
2778
2770
  (n) => readFileSync(join(admin, n, "gitdir"), "utf8").trim() === join(realpathSync(sib), ".git"),
@@ -4267,10 +4259,9 @@ test("a worktree COUNT that could not run refuses, never a bogus tally (#395)",
4267
4259
  const r = repo(t);
4268
4260
  const c = claim(r.w, 9, "release-ticket");
4269
4261
  const realAwk = execFileSync("/bin/sh", ["-c", "command -v awk"], { encoding: "utf8" }).trim();
4270
- writeFileSync(
4262
+ writeExecStub(
4271
4263
  join(r.w, "..", "bin", "awk"),
4272
4264
  `#!/bin/sh\ncase "$*" in *'{c++}'*) exit 1 ;; esac\nexec '${realAwk}' "$@"\n`,
4273
- { mode: 0o755 },
4274
4265
  );
4275
4266
 
4276
4267
  const { code, json, stderr } = release(r, c);
@@ -59,17 +59,17 @@ const SNAP = { path: "/scr/run-1/snapshot-abc1234", head: "abc1234", runRoot: "/
59
59
 
60
60
  // One specialist's, one refuter's and the snapshot agent's prompt. Every
61
61
  // argument is fixed: these pins are about what the prompts SAY, not about how
62
- // they vary, so nothing here needs to. `readRules`/`usableDiff`/
63
- // `environmentNote` are stubs for the sibling pins' reason — binding them
64
- // keeps a render that stops passing one throwing a ReferenceError instead of
65
- // dropping a paragraph silently.
62
+ // they vary, so nothing here needs to. `sharedRunNote`/`readRules`/
63
+ // `usableDiff`/`environmentNote` are stubs for the sibling pins' reason —
64
+ // binding them keeps a render that stops passing one throwing a
65
+ // ReferenceError instead of dropping a paragraph silently.
66
66
  const specialist = promptRenderer({
67
67
  file: FILE,
68
68
  start: "`Review PR #${pr} (branch ${branch}) for: ",
69
69
  end: "label: `review:",
70
- scope: ["pr", "branch", "d", "snap", "worktree", "stats", "testCmd", "readRules", "usableDiff", "environmentNote"],
70
+ scope: ["pr", "branch", "d", "snap", "worktree", "stats", "sharedRunNote", "sharedRun", "failureOwner", "readRules", "usableDiff", "environmentNote"],
71
71
  what: "review-core.mjs's specialist prompt (opening `Review PR #${pr} (branch ${branch}) for: `, labelled `review:`)",
72
- })(7, "feature/x", { key: "correctness", prompt: "does it do what it says" }, SNAP, "/repo/.worktrees/7-x", null, "node --test", () => "READ RULES", () => null, () => "TEST ENVIRONMENT");
72
+ })(7, "feature/x", { key: "correctness", prompt: "does it do what it says" }, SNAP, "/repo/.worktrees/7-x", null, () => "SHARED RUN NOTE", {}, "correctness", () => "READ RULES", () => null, () => "TEST ENVIRONMENT");
73
73
 
74
74
  const refuter = promptRenderer({
75
75
  file: FILE,
@@ -329,6 +329,7 @@ function fakeReviewHost(scopeSearched) {
329
329
  repoVerified: true,
330
330
  testCmd: "node --test",
331
331
  };
332
+ if (opts.label === "test-run") return { exitCode: 0, tests: 5, pass: 5, fail: 0 };
332
333
  if (opts.label === "review:correctness")
333
334
  return {
334
335
  dimension: "correctness",
@@ -275,7 +275,7 @@ test("every branch carries the bounding rule", () => {
275
275
 
276
276
  // Bounded at both ends in prose-pin.mjs's between() — an unbounded end runs to
277
277
  // EOF where the specialist and refuter prompts satisfy it, the defect
278
- // `review-pr-testcmd.test.mjs`'s "the specialist prompt hands the command over
278
+ // `review-core-testcmd.test.mjs`'s "the test-run prompt hands the command over
279
279
  // verbatim and rules 'tests 0' a failure" records.
280
280
  const slice = (from, to) => between(CODE, from, to, "review-core.mjs");
281
281
 
@@ -0,0 +1,64 @@
1
+ // #2323. `runReview` owns the review side's `pr<N>/` partition: it appends
2
+ // `/pr${pr}` to the scratch it is given. A caller that already did so (the
3
+ // run-team skill once read as telling the controller to pass `<scratch>/pr<N>`)
4
+ // nested every run root at `<root>/pr<N>/pr<N>/run-*`, which a correctly scoped
5
+ // review's prune never reaches. So a scratch whose LAST component — after `.`
6
+ // segments and repeated or trailing slashes collapse — is `pr` followed only
7
+ // by digits is refused before any dispatch, whatever the digits, and never
8
+ // coerced by stripping the suffix. A `..` segment is refused outright: the
9
+ // kernel resolves it through symlinks, so no lexical reading of it is safe.
10
+ //
11
+ // Driven through the real `runReview` and asserted on `calls`, for the reason
12
+ // review-core-snapshot-path.test.mjs states beside its skewed-snapshot test: a
13
+ // rejection alone does not show nothing was dispatched first.
14
+ import { test } from "node:test";
15
+ import assert from "node:assert/strict";
16
+ import { runReview } from "./review-core.mjs";
17
+ import { ARGS, SNAP, pipeline, parallel, review, scriptedHost } from "./review-host-fixture.mjs";
18
+
19
+ const PR = 42;
20
+
21
+ function runWith(scratch) {
22
+ const base = scratch === undefined ? `/tmp/review-pr-${PR}` : scratch.replace(/\/+$/, "");
23
+ const runRoot = `${base}/pr${PR}/run-ab12`;
24
+ const snap = { ...SNAP, runRoot, path: `${runRoot}/snapshot-abc123` };
25
+ const { host, calls, prompts } = scriptedHost({ snapshot: [snap], "review:correctness": [review([])] });
26
+ return { run: runReview({ ...host, pipeline, parallel }, { ...ARGS, pr: PR, scratch }), calls, prompts, base };
27
+ }
28
+
29
+ const PR_SUFFIX = /already ends in a pr<N> directory/;
30
+ const DOTDOT = /has a "\.\." segment/;
31
+ const refused = [
32
+ ...["/x/pr42", "/x/pr42/", "/x/pr7", "/x/pr42//", "pr42", "/x/pr42/.", "/x/pr42/./", "/x/./pr42/."].map((s) => [s, PR_SUFFIX]),
33
+ ...["/x/pr42/..", "/x/a/../pr42", "/x/link/.."].map((s) => [s, DOTDOT]),
34
+ ];
35
+ for (const [scratch, reason] of refused) {
36
+ test(`scratch ${scratch} is refused before any dispatch (${reason.source}), naming the path`, async () => {
37
+ const { run, calls } = runWith(scratch);
38
+ await assert.rejects(run, (err) => {
39
+ assert.ok(err.message.includes(JSON.stringify(scratch)), `the refusal does not name the scratch it was given: ${err.message}`);
40
+ assert.match(err.message, reason, `refused for the wrong reason: ${err.message}`);
41
+ assert.match(err.message, /scratch root/, `the refusal does not say to pass the scratch root: ${err.message}`);
42
+ return true;
43
+ });
44
+ assert.deepEqual(calls, {}, `a refused scratch still dispatched: ${JSON.stringify(calls)}`);
45
+ });
46
+ }
47
+
48
+ // What the guard must ACCEPT: a pr-looking name that is not exactly `pr<digits>`,
49
+ // a `pr<N>` that is not the last component — including behind a `.` segment,
50
+ // which collapses away without changing the last component — a `..` inside a
51
+ // name rather than as a segment, and the default scratch. Each runs the review
52
+ // to its specialist, with the run root at `<scratch>/pr42/` — one level, as
53
+ // before.
54
+ for (const scratch of ["/x/review-pr-42", "/x/pr42x", "/x/apr42", "/x/pr", "/x/prx42", "/x/pr42/root", "/x/pr42/./root", "/x/.pr42", "/x/a..b", undefined]) {
55
+ test(`scratch ${scratch ?? "(omitted)"} is accepted and runs the review under <scratch>/pr42/`, async () => {
56
+ const { run, calls, prompts, base } = runWith(scratch);
57
+ await run;
58
+ assert.equal(calls["review:correctness"], 1, "an accepted scratch must reach its specialist");
59
+ assert.ok(
60
+ prompts.snapshot[0].includes(`mkdir -p "${base}/pr${PR}"`),
61
+ `the snapshot agent was not told to make the run root parent at ${base}/pr${PR}`,
62
+ );
63
+ });
64
+ }
@@ -0,0 +1,238 @@
1
+ // #2315. A review runs the repo's test command ONCE and hands the result to
2
+ // every dimension, instead of every dimension specialist running the full
3
+ // suite itself — up to six full sweeps of one immutable snapshot per review.
4
+ //
5
+ // Driven through runReview over a scripted host, as review-in-run-retry.test.mjs
6
+ // is: `agent`/`pipeline`/`parallel`/`phase`/`log` are exactly what runReview
7
+ // takes off `host`, so the dispatch count, the prompts and the unrun verdicts
8
+ // below are review-core.mjs's own wiring, never a re-derived copy of it.
9
+ //
10
+ // THE CEILING: a scripted host answers for the agents, so nothing here proves
11
+ // a live specialist obeys "do NOT run that full command yourself". What it
12
+ // does prove is that review-core.mjs launches the command once (the first
13
+ // test executes the test-run prompt's command block for real against a
14
+ // counter file) and that no specialist prompt hands the command out to run.
15
+ import { test } from "node:test";
16
+ import assert from "node:assert/strict";
17
+ import { execFileSync } from "node:child_process";
18
+ import { mkdtempSync, mkdirSync, readFileSync, existsSync, rmSync } from "node:fs";
19
+ import { tmpdir } from "node:os";
20
+ import { join } from "node:path";
21
+ import { runReview, DEFAULT_DIMENSIONS, FINDINGS_SCHEMA, CRASHED_REASON } from "./review-core.mjs";
22
+ import { pipeline, parallel, ARGS, SNAP, review, finding, vote, scriptedHost } from "./review-host-fixture.mjs";
23
+
24
+ const ALL = DEFAULT_DIMENSIONS.map((d) => d.key);
25
+ const ALL_ARGS = { ...ARGS, dimensions: ALL };
26
+ const run = (host, args = ALL_ARGS) => runReview({ ...host, pipeline, parallel }, args);
27
+ // Every one of the six specialists returning the same clean review, plus
28
+ // whatever the case under test scripts on top.
29
+ const script = (extra) => ({
30
+ snapshot: [SNAP],
31
+ ...Object.fromEntries(ALL.map((k) => [`review:${k}`, [review([])]])),
32
+ ...extra,
33
+ });
34
+
35
+ // The one command line the test-run prompt hands its agent, run the way that
36
+ // agent is told to: once, in the foreground, through a POSIX shell. The counts
37
+ // come from the log the block wrote, as the agent is told to read them.
38
+ function obeyTestRun(prompt) {
39
+ const block = prompt.split("\n").find((l) => /^ {4}\{ cd /.test(l));
40
+ assert.ok(block, "the test-run prompt carries no `{ cd … }` command block");
41
+ const out = execFileSync("/bin/sh", ["-c", block.trim()], { encoding: "utf8" });
42
+ const exit = Number(/TEST_RUN_EXIT=(\d+)/.exec(out)?.[1]);
43
+ const logPath = /> "([^"]+)" 2>&1/.exec(block)[1];
44
+ const log = readFileSync(logPath, "utf8");
45
+ const count = (k) => Number(new RegExp(`^# ${k} (\\d+)$`, "m").exec(log)?.[1]);
46
+ return { exitCode: exit, tests: count("tests"), pass: count("pass"), fail: count("fail") };
47
+ }
48
+
49
+ test("one review with all six dimensions launches the test command exactly once, from the snapshot's root", async () => {
50
+ const tmp = mkdtempSync(join(tmpdir(), "shared-test-run-"));
51
+ try {
52
+ const runRoot = join(tmp, "pr7", "run-ab12");
53
+ const snap = { ...SNAP, runRoot, path: join(runRoot, "snapshot-abc123") };
54
+ mkdirSync(snap.path, { recursive: true });
55
+ const counter = join(tmp, "launches");
56
+ // The caller-supplied override is what the shared run runs: each launch
57
+ // appends one line (its cwd) to the counter file.
58
+ const testCmd = `pwd >> "${counter}"; echo "# tests 3"; echo "# pass 3"; echo "# fail 0"`;
59
+ const { host, calls, prompts } = scriptedHost(script({ snapshot: [snap] }));
60
+ const scripted = host.agent;
61
+ host.agent = async (prompt, opts) => {
62
+ if (opts.label !== "test-run") return scripted(prompt, opts);
63
+ calls["test-run"] = (calls["test-run"] ?? 0) + 1;
64
+ return obeyTestRun(prompt);
65
+ };
66
+ const result = await run(host, { ...ALL_ARGS, scratch: tmp, testCmd });
67
+
68
+ const launches = readFileSync(counter, "utf8").trim().split("\n");
69
+ assert.equal(launches.length, 1, `one review launched the test command ${launches.length} times`);
70
+ assert.equal(launches[0], execFileSync("/bin/sh", ["-c", `cd "${snap.path}" && pwd`], { encoding: "utf8" }).trim());
71
+ assert.equal(calls["test-run"], 1);
72
+ assert.ok(existsSync(join(runRoot, "test-run.log")), "the shared run's log is not where the specialists are pointed");
73
+ for (const k of ALL) {
74
+ assert.equal(calls[`review:${k}`], 1);
75
+ // No specialist prompt hands the command over as something to run.
76
+ assert.doesNotMatch(prompts[`review:${k}`][0], /run exactly this/);
77
+ assert.match(prompts[`review:${k}`][0], /Do NOT run that full command yourself/);
78
+ }
79
+ assert.deepEqual(result.dimensionsUnrun, []);
80
+ } finally {
81
+ rmSync(tmp, { recursive: true, force: true });
82
+ }
83
+ });
84
+
85
+ test("every dispatched specialist receives the shared run's command, counts and log path", async () => {
86
+ const { host, prompts } = scriptedHost(script({ "test-run": [{ exitCode: 0, tests: 41, pass: 40, fail: 0, skipped: 1 }] }));
87
+ await run(host);
88
+ for (const k of ALL) {
89
+ const p = prompts[`review:${k}`]?.[0];
90
+ assert.ok(p, `the ${k} specialist was never dispatched`);
91
+ assert.match(p, /command: node --test\n/, `${k}'s prompt lacks the shared run's command`);
92
+ assert.match(p, /counts: {2}tests 41, pass 40, fail 0, skipped 1\n/, `${k}'s prompt lacks the shared run's counts`);
93
+ assert.match(p, new RegExp(`log: {5}${SNAP.runRoot}/test-run\\.log\\n`), `${k}'s prompt lacks the shared run's log path`);
94
+ }
95
+ });
96
+
97
+ // The override precedence #142 settled, carried onto the one prompt that runs
98
+ // the command: a caller's override wins, the derivation is used without one.
99
+ test("the shared run runs the caller's override, and the snapshot's derived command only without one", async () => {
100
+ for (const [args, expected] of [
101
+ [{ ...ARGS, testCmd: "npm test -- --ci" }, "npm test -- --ci"],
102
+ [{ ...ARGS, testCmd: undefined }, SNAP.testCmd],
103
+ ]) {
104
+ const { host, prompts } = scriptedHost(script({}));
105
+ await run(host, args);
106
+ assert.ok(prompts["test-run"][0].includes(`&& ${expected}; }`), `the test-run prompt does not run ${expected}`);
107
+ }
108
+ });
109
+
110
+ test("a shared run reporting tests 0 makes every selected dimension unrun", async () => {
111
+ const { host, calls } = scriptedHost(script({ "test-run": [{ exitCode: 0, tests: 0, pass: 0, fail: 0 }] }));
112
+ const result = await run(host);
113
+ assert.deepEqual(result.dimensionsUnrun.map((u) => u.dimension), ALL);
114
+ for (const u of result.dimensionsUnrun) assert.match(u.reason, /produced 0 tests/);
115
+ // Still a review: the specialists were dispatched and their findings verified.
116
+ for (const k of ALL) assert.equal(calls[`review:${k}`], 1);
117
+ });
118
+
119
+ test("a shared run that yields no counts reports every selected dimension unrun, never a pass", async () => {
120
+ for (const answer of [null, new Error("spend limit"), {}, { exitCode: 124, error: "hit the 1800 s deadline" }]) {
121
+ const { host, calls, prompts } = scriptedHost(script({ "test-run": [answer] }));
122
+ const result = await run(host);
123
+ const where = answer instanceof Error ? "a thrown dispatch" : JSON.stringify(answer);
124
+ assert.equal(calls["test-run"], 1, `${where}: the shared run was dispatched again — a second full-suite launch`);
125
+ assert.deepEqual(result.dimensionsUnrun.map((u) => u.dimension), ALL, `${where}: not every dimension is unrun`);
126
+ for (const u of result.dimensionsUnrun) assert.match(u.reason, /no counts/, `${where}: ${u.reason}`);
127
+ assert.match(prompts["review:correctness"][0], /This run is NOT usable/);
128
+ }
129
+ });
130
+
131
+ // Failing tests are the REVIEW's, not each dimension's: the first selected
132
+ // dimension is told to file them and every other one not to duplicate it.
133
+ test("a shared run with failures: one dimension's finding leaves no dimension unrun, and the others are told not to duplicate it", async () => {
134
+ const failing = { exitCode: 1, tests: 10, pass: 8, fail: 2 };
135
+ const { host, prompts } = scriptedHost(
136
+ script({ "test-run": [failing], "review:correctness": [review([finding("suggestion")])] }),
137
+ );
138
+ const result = await run(host);
139
+ assert.deepEqual(result.dimensionsUnrun, [], "a sibling's finding about the failures must satisfy every dimension");
140
+ assert.match(prompts["review:correctness"][0], /filing them is YOUR job/);
141
+ for (const k of ALL.filter((k) => k !== "correctness")) {
142
+ const p = prompts[`review:${k}`][0];
143
+ assert.match(p, /the correctness dimension files the finding\s+about them\. Do not file a duplicate/, `${k} is not told to leave the failures to correctness`);
144
+ assert.doesNotMatch(p, /YOUR job/, `${k} is told to file the failures too — a duplicate per dimension`);
145
+ }
146
+ // The accept side: ownership is a duplicate-avoidance rule, not a verdict
147
+ // key — a finding from a NON-owner satisfies the check just as well.
148
+ const other = scriptedHost(script({ "test-run": [failing], "review:types": [review([finding("suggestion")])] }));
149
+ assert.deepEqual((await run(other.host)).dimensionsUnrun, []);
150
+ });
151
+
152
+ test("a shared run with failures and no finding from any dimension makes every selected dimension unrun", async () => {
153
+ const { host } = scriptedHost(script({ "test-run": [{ exitCode: 1, tests: 10, pass: 8, fail: 2 }] }));
154
+ const result = await run(host);
155
+ assert.deepEqual(result.dimensionsUnrun.map((u) => u.dimension), ALL);
156
+ for (const u of result.dimensionsUnrun) assert.match(u.reason, /2 failing tests and no selected dimension filed a finding/);
157
+ });
158
+
159
+ // The failing-tests check reads what reached the payload, never what a
160
+ // specialist returned before its findings were verified: an unrelated finding
161
+ // the refuters threw out, or the findings of a dimension whose verify stage
162
+ // died, would otherwise stand in for failures nobody reported — and the
163
+ // failures would reach neither the report nor dimensionsUnrun.
164
+ test("a shared run with failures is not satisfied by a refuted finding, nor by a dimension whose verify stage died", async () => {
165
+ const failing = { exitCode: 1, tests: 10, pass: 8, fail: 2 };
166
+ const refuted = scriptedHost(
167
+ script({ "test-run": [failing], "review:correctness": [review([finding("critical")])], "verify:correctness": [vote(true)] }),
168
+ );
169
+ const r1 = await run(refuted.host);
170
+ assert.equal(r1.refuted.length, 1, "the fixture's finding was not refuted — this case tests nothing");
171
+ assert.deepEqual(r1.dimensionsUnrun.map((u) => u.dimension), ALL, "a refuted finding satisfied the failing-tests check");
172
+ for (const u of r1.dimensionsUnrun) assert.match(u.reason, /2 failing tests and no selected dimension filed a finding/);
173
+
174
+ // A malformed finding throws inside the verify stage: the slot dies, so its
175
+ // dimension is crashed and its findings never reach the payload.
176
+ const died = scriptedHost(script({ "test-run": [failing], "review:correctness": [review([null])] }));
177
+ const r2 = await run(died.host);
178
+ assert.equal(r2.dimensionsUnrun.find((u) => u.dimension === "correctness")?.reason, CRASHED_REASON);
179
+ assert.deepEqual(
180
+ r2.dimensionsUnrun.filter((u) => u.dimension !== "correctness").map((u) => u.dimension),
181
+ ALL.filter((k) => k !== "correctness"),
182
+ "a dead dimension's unverified findings satisfied the failing-tests check",
183
+ );
184
+
185
+ // The accept side: a finding that survived its refuters settles it.
186
+ const kept = scriptedHost(
187
+ script({ "test-run": [failing], "review:correctness": [review([finding("critical")])], "verify:correctness": [vote(false)] }),
188
+ );
189
+ assert.deepEqual((await run(kept.host)).dimensionsUnrun, []);
190
+ });
191
+
192
+ // The exit status is the command's verdict: clean-looking counts beside a
193
+ // non-zero or missing exit are not a pass, and every specialist is told so.
194
+ test("a shared run whose exit is non-zero with nothing failing, or missing, makes every selected dimension unrun", async () => {
195
+ for (const answer of [{ exitCode: 137, tests: 5, pass: 5, fail: 0 }, { exitCode: 1, tests: 5, pass: 5 }, { tests: 5, pass: 5, fail: 0 }]) {
196
+ const { host, prompts } = scriptedHost(script({ "test-run": [answer], "review:correctness": [review([finding("suggestion")])] }));
197
+ const result = await run(host);
198
+ const where = JSON.stringify(answer);
199
+ assert.deepEqual(result.dimensionsUnrun.map((u) => u.dimension), ALL, `${where}: not every dimension is unrun`);
200
+ for (const u of result.dimensionsUnrun) assert.match(u.reason, /exited \d+ but reported no failing|no exit status/, `${where}: ${u.reason}`);
201
+ assert.match(prompts["review:tests"][0], /This run is NOT usable/, `${where}: a specialist was not told the run is unusable`);
202
+ }
203
+ });
204
+
205
+ // node's runner counts a test that never finished as `cancelled`, not `fail`,
206
+ // and exits 1: that is a failure for the owner to file, not an unusable run.
207
+ test("a shared run with cancelled tests and no failing count hands the owner the cancelled tests to file", async () => {
208
+ const cancelled = { exitCode: 1, tests: 10, pass: 9, fail: 0, cancelled: 1 };
209
+ const { host, prompts } = scriptedHost(script({ "test-run": [cancelled] }));
210
+ const result = await run(host);
211
+ assert.match(prompts["review:correctness"][0], /It has 0 failing and 1 cancelled tests, and filing them is YOUR job/);
212
+ assert.doesNotMatch(prompts["review:correctness"][0], /NOT usable/);
213
+ assert.deepEqual(result.dimensionsUnrun.map((u) => u.dimension), ALL);
214
+ for (const u of result.dimensionsUnrun) assert.match(u.reason, /1 cancelled tests and no selected dimension filed a finding/);
215
+ const filed = scriptedHost(script({ "test-run": [cancelled], "review:correctness": [review([finding("suggestion")])] }));
216
+ assert.deepEqual((await run(filed.host)).dimensionsUnrun, []);
217
+ });
218
+
219
+ // A crashed specialist is named once, with its own reason — never a second
220
+ // entry for the shared run's verdict on top.
221
+ test("a crashed dimension is listed once, with its crash reason, beside the shared run's verdict for the rest", async () => {
222
+ const { host } = scriptedHost(
223
+ script({ "test-run": [{ exitCode: 0, tests: 0 }], "review:types": [null] }),
224
+ );
225
+ const result = await run(host);
226
+ const keys = result.dimensionsUnrun.map((u) => u.dimension);
227
+ assert.equal(keys.length, new Set(keys).size, `a dimension is listed twice: ${keys.join(", ")}`);
228
+ assert.deepEqual([...keys].sort(), [...ALL].sort());
229
+ assert.equal(result.dimensionsUnrun.find((u) => u.dimension === "types").reason, CRASHED_REASON);
230
+ });
231
+
232
+ // Downstream readers of `test_run` see the shape they always did.
233
+ test("test_run's shape is unchanged: command and tests required, pass and fail optional, nothing else", () => {
234
+ const t = FINDINGS_SCHEMA.properties.test_run;
235
+ assert.deepEqual(Object.keys(t.properties).sort(), ["command", "fail", "pass", "tests"]);
236
+ assert.deepEqual([...t.required].sort(), ["command", "tests"]);
237
+ assert.equal(t.additionalProperties, false);
238
+ });