@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
@@ -6,7 +6,8 @@ import { execFileSync } from "node:child_process";
6
6
  import { join } from "node:path";
7
7
  import { stripComments } from "./strip-comments.mjs";
8
8
  import { between, phrase } from "./prose-pin.mjs";
9
- import { snapshotMissing as snapshotMissingRaw } from "./review-core.mjs";
9
+ import { snapshotMissing as snapshotMissingRaw, runReview } from "./review-core.mjs";
10
+ import { scriptedHost, SNAP as HOST_SNAP, ARGS, pipeline, parallel, review } from "./review-host-fixture.mjs";
10
11
 
11
12
  // `snap.path` used to reach every specialist prompt and every verifier prompt
12
13
  // unchecked: a well-formed string the schema required, but never confirmed to
@@ -187,9 +188,8 @@ test("a lagging PR object does not cancel the review of a tree that matches the
187
188
  // ABSENT `refHead` is not a mismatch: the ref read can still come back empty on
188
189
  // its own — an unreachable `origin`, or a read that failed — so turning missing
189
190
  // input into a refusal would let a network blip cancel a runnable review. That
190
- // is the inversion `usableDiff`'s own comment records for the diff, now with a
191
- // whole review behind it instead of a diff, and the rule `run-team/SKILL.md`'s
192
- // phase-1 compare states as "an empty read is neither equal nor a mismatch".
191
+ // is the rule `run-team/SKILL.md`'s phase-1 compare states as "an empty read is
192
+ // neither equal nor a mismatch", here with a whole review behind it.
193
193
  // Absent and mismatching are different cases and stay different.
194
194
  //
195
195
  // A fork PR is NOT one of the absent cases any more (#1616), and it used to be
@@ -400,10 +400,10 @@ test("the snapshot log line says when the head check was skipped", () => {
400
400
 
401
401
  // Bound at both ends via prose-pin.mjs's between() — an unbounded end lets the
402
402
  // specialist and refuter prompts further down satisfy the assertions instead,
403
- // the defect `review-pr-testcmd.test.mjs`'s "the specialist prompt hands the
403
+ // the defect `review-core-testcmd.test.mjs`'s "the test-run prompt hands the
404
404
  // command over verbatim and rules 'tests 0' a failure" test records having
405
- // shipped. Same two anchors `review-pr-reads.test.mjs`'s `slice()` and
406
- // `review-pr-testcmd.test.mjs` already use.
405
+ // shipped. Same two anchors `review-core-reads.test.mjs`'s `slice()` and
406
+ // `review-core-testcmd.test.mjs` already use.
407
407
  function snapshotBlock() {
408
408
  return between(CODE, "const snap = await agent(", "if (snap) {", "the snapshot agent dispatch");
409
409
  }
@@ -415,7 +415,7 @@ function snapshotBlock() {
415
415
  // `required: [..., "pathVerified"]` still passes, all four tests above still
416
416
  // pass, and the agent has lost the only instruction saying what value to report:
417
417
  // `pathVerified` degrades to a boolean it invents, silently reopening #140 under
418
- // a green suite. That is the exact shape `review-pr-reads.test.mjs`'s "the
418
+ // a green suite. That is the exact shape `review-core-reads.test.mjs`'s "the
419
419
  // snapshot agent asks for the diff facts AND declares them in its schema"
420
420
  // measured on the diff facts — "deleting this paragraph outright left this file
421
421
  // at 12 pass, 0 fail".
@@ -428,7 +428,7 @@ test("the snapshot prompt runs the emptiness probe AND binds pathVerified to its
428
428
  );
429
429
  // These names live inside a template literal, so each backtick is a
430
430
  // BACKSLASH-backtick in the source text — `\\?` matches it either way, the
431
- // idiom review-pr-reads.test.mjs and review-pr-testcmd.test.mjs already use.
431
+ // idiom review-core-reads.test.mjs and review-core-testcmd.test.mjs already use.
432
432
  // `\s+` spans the line wraps so a reflow of the same sentence stays green.
433
433
  const B = "\\\\?`";
434
434
  assert.match(
@@ -538,7 +538,7 @@ test("the snapshot block mints a per-run destination, then extracts, probes, and
538
538
  "the run root is never printed — the agent cannot report a `runRoot` it can no longer read off this prompt, and the caller's containment check has nothing to check",
539
539
  ],
540
540
  [
541
- /find "?\$\{runRootParent\}"?[^\n]*-exec rm -rf \{\} \+ \|\| echo SNAPSHOT_PRUNE_FAILED/,
541
+ /find "?\$\{runRootParent\}"?[^\n]*\|\| echo SNAPSHOT_PRUNE_FAILED/,
542
542
  "the stale-run-root prune is gone or no longer refuses by name — every review leaves a tree nothing removes (#1083), and `snapshot-repo.test.mjs`'s executed prune test is where its behaviour is measured",
543
543
  ],
544
544
  [
@@ -709,8 +709,8 @@ test("a run's artefact root stays under the scratch root the caller provisioned"
709
709
  `a run under ${scratch} writes to ${runRootPrefix}, outside the root the caller provisioned — a caller that cleans up or inspects its own scratch root now finds nothing there`,
710
710
  );
711
711
  // A prefix alone does not settle "under": `/scr/../elsewhere` carries it and
712
- // resolves outside. Same escape review-pr-refuter-scratch.test.mjs asserts
713
- // separately of the refuter paths built on this root.
712
+ // resolves outside. Same escape the "a snapshot path that climbs out of the
713
+ // run root with `..` is refused" test asserts of a reported path.
714
714
  assert.doesNotMatch(runRootPrefix, /\/\.\.(\/|$)/, `${runRootPrefix} climbs out of the provisioned root with a \`..\` segment`);
715
715
  }
716
716
  });
@@ -775,3 +775,50 @@ test("runReview actually calls snapshotMissing and throws on its result", () =>
775
775
  assert.ok(schemaAt < callAt, "the guard runs above the schema that produces pathVerified");
776
776
  assert.ok(callAt < testCmdAt, "resolveTestCmd reads snap before the guard has cleared it");
777
777
  });
778
+
779
+ // `usableDiff` carries no head check of its own (#1132), so a diff for a
780
+ // head/refHead-skewed snapshot is safe only because the refusal above is FATAL
781
+ // before any specialist is dispatched (#2203). The tests above pin the parts:
782
+ // the unit tests red on a `refHead` clause gone from `snapshotMissing`, and the
783
+ // text pin reds on a deleted `throw` or one replaced by a log. Neither notices a
784
+ // throw softened while its text survives — wrapped in a `try` whose `catch`
785
+ // logs — and a text pin on call ORDER would red on a reorder that dispatches
786
+ // nothing while missing that. So this drives the real `runReview` and asserts
787
+ // on what was dispatched.
788
+ //
789
+ // Asserted on `calls`, not only on the rejection: an unscripted label does
790
+ // throw `unexpected dispatch`, but the fixture's `pipeline` swallows a stage
791
+ // throw into `null`, so that throw alone would fail nothing. `scriptedHost`
792
+ // counts a dispatch before it looks the label up, so `calls` sees every one.
793
+ //
794
+ // The fixture's `path` ends in `snapshot-abc123`, and the refusal quotes the
795
+ // path, so a path that does not carry the head keeps `/abc123/` below reading
796
+ // the sha the message reports rather than the path it quotes.
797
+ function runWithRefHead(refHead) {
798
+ const path = `${HOST_SNAP.runRoot}/snapshot-tree`;
799
+ const snap = { ...HOST_SNAP, path, refHead, diffPath: `${HOST_SNAP.runRoot}/pr.diff`, diffLines: 40 };
800
+ const { host, calls } = scriptedHost({ snapshot: [snap], "review:correctness": [review([])] });
801
+ return { run: runReview({ ...host, pipeline, parallel }, ARGS), calls };
802
+ }
803
+
804
+ test("a head/refHead-skewed snapshot is refused before any specialist or refuter is dispatched", async () => {
805
+ assert.equal(HOST_SNAP.head, "abc123", "the fixture's head changed — update this test's expected sha");
806
+ const { run, calls } = runWithRefHead("9e8ee3d");
807
+ await assert.rejects(run, (err) => {
808
+ assert.match(err.message, /abc123/, "the refusal must name the commit the tree is at");
809
+ assert.match(err.message, /9e8ee3d/, "the refusal must name the PR head it was measured against");
810
+ return true;
811
+ });
812
+ assert.equal(calls.snapshot, 1, "the snapshot agent is the one dispatch that precedes the refusal");
813
+ const leaked = Object.keys(calls).filter((label) => /^(review|verify):/.test(label));
814
+ assert.deepEqual(leaked, [], "a skewed snapshot reached a specialist or refuter");
815
+ });
816
+
817
+ // The control: the identical snapshot with the heads agreeing is admitted and
818
+ // reaches the specialist, so the refusal above comes from the head compare and
819
+ // not from some other field of the fixture that `snapshotMissing` refuses.
820
+ test("the same snapshot with refHead matching head reaches the specialist", async () => {
821
+ const { run, calls } = runWithRefHead(HOST_SNAP.head);
822
+ await run;
823
+ assert.equal(calls["review:correctness"], 1, "an admitted snapshot must dispatch its specialist exactly once");
824
+ });
@@ -45,7 +45,7 @@
45
45
  // rules out of the specialist prompt reds all three tests here with the
46
46
  // refuter's copy untouched.
47
47
  //
48
- // THE CEILING, same as review-pr-refuter-scratch.test.mjs's: nothing here
48
+ // THE CEILING, same as review-core-refuter-scratch.test.mjs's: nothing here
49
49
  // reaches the agent's own obedience. These pins settle what a specialist is
50
50
  // TOLD, never where it actually writes.
51
51
  import { test } from "node:test";
@@ -62,11 +62,11 @@ const CODE = stripComments(SOURCE);
62
62
  const TEMPLATE_START = "`Review PR #${pr} (branch ${branch}) for: ";
63
63
  const TEMPLATE_END = "label: `review:";
64
64
 
65
- // The template's free names, in the order `render` binds them. `readRules`,
66
- // `usableDiff` and `environmentNote` are stubs: what they return is not under
67
- // test here, and binding them keeps a render that stops passing one from
68
- // dropping a paragraph silently — it throws a ReferenceError instead.
69
- const SCOPE = ["pr", "branch", "d", "snap", "worktree", "stats", "testCmd", "readRules", "usableDiff", "environmentNote"];
65
+ // The template's free names, in the order `render` binds them. `sharedRunNote`,
66
+ // `readRules`, `usableDiff` and `environmentNote` are stubs: what they return
67
+ // is not under test here, and binding them keeps a render that stops passing
68
+ // one from dropping a paragraph silently — it throws a ReferenceError instead.
69
+ const SCOPE = ["pr", "branch", "d", "snap", "worktree", "stats", "sharedRunNote", "sharedRun", "failureOwner", "readRules", "usableDiff", "environmentNote"];
70
70
 
71
71
  // `between` owns the bounded-slice extraction (and both failure messages);
72
72
  // only the backtick trim below is specific to a template literal and stays
@@ -90,7 +90,9 @@ const render = () =>
90
90
  { path: "/scr/run-1/snapshot-abc1234", head: "abc1234", runRoot: "/scr/run-1" },
91
91
  "/repo/.worktrees/7-x",
92
92
  null,
93
- "node --test",
93
+ () => "SHARED RUN NOTE",
94
+ {},
95
+ "correctness",
94
96
  () => "READ RULES",
95
97
  () => null,
96
98
  () => "TEST ENVIRONMENT",
@@ -144,9 +146,9 @@ test("the rendered specialist prompt chains cd into the git command, never semic
144
146
  // Both directions on the tail itself: an exception clause spliced into its
145
147
  // leading gap ("…your scratch path, except in CI runners — compare resolved
146
148
  // forms…") reds this assertion, where the `.{0,80}`-gapped spelling in
147
- // review-pr-specialist-scratch.test.mjs lets it through; rewrapping the clause
148
- // to one line and to a narrower column stays green, since every gap here is
149
- // `\s+` (all measured).
149
+ // `ed9f2967^:plugin/scripts/review-pr-specialist-scratch.test.mjs` let it
150
+ // through; rewrapping the clause to one line and to a narrower column stays
151
+ // green, since every gap here is `\s+` (all measured).
150
152
  test("the rendered specialist prompt requires a toplevel assertion around git init/commit, including the realpath remedy for macOS's /private/tmp symlink", () => {
151
153
  assert.match(
152
154
  render(),
@@ -18,8 +18,9 @@ import { resolveTestCmd, SNAPSHOT_SCHEMA } from "./review-core.mjs";
18
18
  //
19
19
  // This file covers what remains review-core.mjs's own responsibility:
20
20
  // resolveTestCmd's resolution order and refusal, the snapshot agent's prompt
21
- // and schema actually carrying the derivation, and the specialist prompt
22
- // still handing testCmd over verbatim with the 'tests 0' rule.
21
+ // and schema actually carrying the derivation, and the shared test-run
22
+ // prompt (#2315) handing testCmd over verbatim with the 'tests 0' rule — the
23
+ // one prompt that runs it, since no specialist runs the full suite any more.
23
24
  const REPO = join(import.meta.dirname, "..");
24
25
  const SOURCE = readFileSync(join(REPO, "scripts", "review-core.mjs"), "utf8");
25
26
 
@@ -113,7 +114,7 @@ test("no hardcoded testCmd default remains", () => {
113
114
  // diffPath/diffLines/prHead were added: `additionalProperties: false` drops
114
115
  // an undeclared field silently, so BOTH the prompt asking for it and the
115
116
  // schema declaring it have to be pinned, or the feature disconnects in one
116
- // token exactly like `review-pr-reads.test.mjs`'s "the snapshot agent asks for
117
+ // token exactly like `review-core-reads.test.mjs`'s "the snapshot agent asks for
117
118
  // the diff facts AND declares them in its schema" records happening to the
118
119
  // diff facts.
119
120
  test("the snapshot agent is told to derive testCmd AND the schema declares it", () => {
@@ -155,7 +156,7 @@ test("the snapshot agent is told to derive testCmd AND the schema declares it",
155
156
  );
156
157
  // These names live inside a template literal, so each backtick is a
157
158
  // BACKSLASH-backtick in the source text — `\\?` matches it either way, the
158
- // same idiom `review-pr-reads.test.mjs` uses for diffPath/prHead/diffLines.
159
+ // same idiom `review-core-reads.test.mjs` uses for diffPath/prHead/diffLines.
159
160
  const B = "\\\\?`";
160
161
  assert.match(
161
162
  snapshot,
@@ -198,34 +199,35 @@ test("the snapshot agent is told to derive testCmd AND the schema declares it",
198
199
  );
199
200
  });
200
201
 
201
- // The prompt is what specialists actually obey, so the reading rule has to be
202
- // in it. Without this, a specialist that guesses a glob still reports
202
+ // #2315. The prompt that RUNS the command is the shared test run's — every
203
+ // specialist used to run it, which made one review up to six full sweeps.
204
+ // Bounded at both ends: an unbounded slice runs to EOF, where the specialist
205
+ // and refuter prompts could satisfy the assertions below instead.
206
+ function testRunPrompt() {
207
+ return between(CODE, "`Run this repository's test command ONCE", '{ label: "test-run"', "the shared test-run prompt");
208
+ }
209
+
210
+ // The prompt is what the test-run agent actually obeys, so the reading rule has
211
+ // to be in it. Without this, an agent that guesses a glob still reports
203
212
  // `tests 0` as a pass — the exact failure the derivation alone does not cover.
204
- test("the specialist prompt hands the command over verbatim and rules 'tests 0' a failure", () => {
205
- // indexOf returns -1 when absent and slice(-1) is a truthy one-character
206
- // string, so asserting on the slice passes with the prompt gone. Assert the
207
- // index — and bound the END too: unbounded, this slice ran to EOF and the
208
- // assertions below were satisfiable from the verifier prompt further down.
209
- const prompt = between(CODE, "READ ONLY FROM THE SNAPSHOT", "Scratch files go in", "the specialist prompt");
210
- // The worked example must INTERPOLATE testCmd, not restate it. A hardcoded
213
+ test("the test-run prompt hands the command over verbatim and rules 'tests 0' a failure", () => {
214
+ const prompt = testRunPrompt();
215
+ // The command block must INTERPOLATE testCmd, not restate it. A hardcoded
211
216
  // copy drifts from the resolved value the moment either one changes, and a
212
217
  // caller passing args.testCmd (or the derivation) would be handed the wrong
213
- // command.
218
+ // command. Run from the snapshot's root, its output captured to the log
219
+ // every specialist is pointed at.
214
220
  assert.match(
215
221
  prompt,
216
- /run exactly this[^\n]*\n\s*\$\{testCmd\}/,
217
- "the prompt no longer hands specialists the interpolated command verbatim",
222
+ /\{ cd "\$\{snap\.path\}" && \$\{testCmd\}; \} > "\$\{logPath\}" 2>&1; echo "TEST_RUN_EXIT=\$\?"/,
223
+ "the prompt no longer runs the interpolated command verbatim from the snapshot's root into the log",
218
224
  );
219
225
  // Match the ruling itself, not the phrase `tests 0` — that appears in the
220
226
  // surrounding explanation too, so a looser assertion passes with the rule
221
227
  // deleted (observed: it did).
222
- assert.match(
223
- prompt,
224
- /'tests 0' is a FAILED run/,
225
- "the prompt no longer rules a zero-test run a failure",
226
- );
228
+ assert.match(prompt, /'tests 0' is a FAILED run/, "the prompt no longer rules a zero-test run a failure");
227
229
  // The RULING was pinned and the INSTRUCTION was not, so the sentence telling
228
- // specialists not to swap the command out could be deleted with this suite
230
+ // the agent not to swap the command out could be deleted with this suite
229
231
  // green (#143). Everything around it explains why; this is the only clause
230
232
  // that actually forbids anything.
231
233
  assert.match(
@@ -233,21 +235,48 @@ test("the specialist prompt hands the command over verbatim and rules 'tests 0'
233
235
  /Do not substitute a command of your own\./,
234
236
  "the prompt no longer forbids substituting a command — only explains why one would be wrong",
235
237
  );
238
+ // Once is the whole point of #2315: a retry by the agent is a second full run.
239
+ // The clause, not the phrase — "Run it exactly once, then again when it
240
+ // fails" still contains "Run it exactly once".
241
+ assert.match(
242
+ prompt,
243
+ /Run it exactly once: not again when it fails, and not again when it hits the\s+deadline\./,
244
+ "the prompt no longer forbids running the command a second time",
245
+ );
246
+ });
247
+
248
+ // How the one run is held and read. Each clause is a behavior the agent obeys
249
+ // and nothing downstream re-checks: a backgrounded or polled run is the
250
+ // unbounded load #2315 measured, a deadline that is far too short reads every
251
+ // heavy suite as no counts, a `tail` too short misses the summary, and a 0
252
+ // typed in for a count the log never stated turns "no counts" (every dimension
253
+ // unrun) into "tests 0" or a clean-looking pass — the distinction
254
+ // TEST_RUN_SCHEMA's absent-count rule exists for.
255
+ test("the test-run prompt holds the run in the foreground under a deadline, and never invents a count", () => {
256
+ const prompt = testRunPrompt();
257
+ assert.match(prompt, /ONE blocking foreground command — never backgrounded, never polled —/, "the prompt no longer forbids a backgrounded or polled run");
258
+ assert.match(prompt, /with a command deadline of 1800 seconds:/, "the prompt's command deadline changed — size it against a full suite under fleet load");
259
+ assert.match(prompt, /\\`tail -n 40 "\$\{logPath\}"\\`/, "the prompt no longer reads enough of the log's tail to hold a runner's summary");
260
+ assert.match(
261
+ prompt,
262
+ /omit every count and say what happened in \\`error\\`\. Never\s+write 0 for a count the log does not state/,
263
+ "the prompt no longer forbids writing 0 for a count the log does not state",
264
+ );
236
265
  });
237
266
 
238
- // #143's second correction. The rationale above asserted, present tense and as
267
+ // #143's second correction. The rationale once asserted, present tense and as
239
268
  // fact about the run being described, that a bare runner "tears down a shared
240
269
  // container mid-run for every sibling". Measured against this repo:
241
270
  // this repo's Test entrypoint is a plain `node --test` run and
242
271
  // `commands/review-and-fix.md` records that this repo has no
243
272
  // compose file, no `globalSetup`, and no vitest — so no teardown can happen,
244
- // and a specialist that checks the reason it was given finds it false.
273
+ // and an agent that checks the reason it was given finds it false.
245
274
  //
246
275
  // The rule is still worth carrying, because the review host reviews repos that DO
247
276
  // have a stack. It has to be stated as a conditional about those repos rather
248
277
  // than as a fact about this run.
249
278
  test("the anti-substitution rationale is portable, not a present-tense claim about this run", () => {
250
- const prompt = between(CODE, "READ ONLY FROM THE SNAPSHOT", "Scratch files go in", "the specialist prompt");
279
+ const prompt = testRunPrompt();
251
280
  assert.doesNotMatch(
252
281
  prompt,
253
282
  /tears down a shared container mid-run for every sibling/,
@@ -256,33 +285,35 @@ test("the anti-substitution rationale is portable, not a present-tense claim abo
256
285
  // The conditional that replaced it, and the half that is NOT conditional: a
257
286
  // zero-match glob exits 0 in every repo, so hedging that one would weaken a
258
287
  // rule this repo has actually measured (#142).
288
+ assert.match(prompt, /In a repo that has a shared test stack/, "the container rationale is no longer scoped to the repos it can happen in");
289
+ assert.match(prompt, /a guessed glob is\s+worse in every repo/, "the zero-match-glob half is no longer stated as holding everywhere");
290
+ });
291
+
292
+ // The rule #143 widened, now in the one prompt that runs the suite. The
293
+ // classifier catches the zero-pass case on its own (`review-core-unrun.test.mjs`),
294
+ // but the partial-tree case it CANNOT: `unrunReason` is pure and never learns
295
+ // how many tests the whole tree has, so the only guard is the run itself
296
+ // starting from the snapshot's root. If this instruction goes, that case has no
297
+ // other guard.
298
+ test("the test-run prompt rules a no-work run too: zero passes, and a count below the whole tree", () => {
299
+ const prompt = testRunPrompt();
300
+ assert.match(prompt, /0 passes with no failures is\s+everything skipped/, "the prompt no longer rules an all-skipped run a no-work run (#143)");
259
301
  assert.match(
260
302
  prompt,
261
- /In a repo that has a shared test stack/,
262
- "the container rationale is no longer scoped to the repos it can happen in",
263
- );
264
- assert.match(
265
- prompt,
266
- /a guessed glob is\s+worse in every repo/,
267
- "the zero-match-glob half is no longer stated as holding everywhere",
303
+ /a count well below what the whole tree reports, which means it ran a\s+PARTIAL copy/,
304
+ "the prompt no longer names a partial-tree run — the case nothing downstream can catch (#143)",
268
305
  );
269
306
  });
270
307
 
271
- // The rule #143 widened, in the place specialists actually read. The classifier
272
- // catches the zero-pass case on its own (`review-pr-unrun.test.mjs`), but the
273
- // partial-tree case it CANNOT: `unrunReason` is pure and never learns how many
274
- // tests the whole tree has, so the only reader positioned to notice is the agent
275
- // that ran the command. If this instruction goes, that case has no other guard.
276
- test("the prompt rules a no-work run unrun too: zero passes, and a count below the whole tree", () => {
308
+ // #2315's other half: the specialist prompt must hand the shared run over and
309
+ // never the command to run. A specialist prompt that interpolates `testCmd`
310
+ // again is six full sweeps per review again.
311
+ test("the specialist prompt carries the shared run's note, and never the command to run", () => {
277
312
  const prompt = between(CODE, "READ ONLY FROM THE SNAPSHOT", "Scratch files go in", "the specialist prompt");
313
+ assert.doesNotMatch(prompt, /\$\{testCmd\}/, "the specialist prompt hands out testCmd to run again — one full sweep per dimension");
278
314
  assert.match(
279
315
  prompt,
280
- /0 passes with no failures is\s+everything skipped/,
281
- "the prompt no longer rules an all-skipped run a no-work run (#143)",
282
- );
283
- assert.match(
284
- prompt,
285
- /a count well below what the whole tree reports means you\s+ran a PARTIAL copy/,
286
- "the prompt no longer rules a partial-tree run unrun — the case nothing downstream can catch (#143)",
316
+ /\$\{sharedRunNote\(sharedRun, failureOwner, d\.key\)\}/,
317
+ "the specialist prompt no longer carries the shared run's note",
287
318
  );
288
319
  });