@feigi/fleet-ctl 3.23.36 → 3.23.37

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 (204) hide show
  1. package/package.json +1 -1
  2. package/scripts/main-checkout.mjs +1 -1
  3. package/scripts/member-write-guard.mjs +1 -1
  4. package/scripts/repo-root.mjs +1 -1
  5. package/skills/run-team/references/reaping.md +1 -1
  6. package/scripts/agent-test-dir-prose.test.mjs +0 -59
  7. package/scripts/agent-test.test.mjs +0 -1640
  8. package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
  9. package/scripts/ambient-git-vars-prose.test.mjs +0 -192
  10. package/scripts/ancestry-check-position-prose.test.mjs +0 -175
  11. package/scripts/apply-ruleset.test.mjs +0 -421
  12. package/scripts/arg-header-probes-prose.test.mjs +0 -394
  13. package/scripts/arg.test.mjs +0 -1354
  14. package/scripts/board-cli.test.mjs +0 -710
  15. package/scripts/board-identity.test.mjs +0 -429
  16. package/scripts/board-liveness-banner.test.mjs +0 -119
  17. package/scripts/board-prev-shape.test.mjs +0 -228
  18. package/scripts/board-tryparse-null.test.mjs +0 -119
  19. package/scripts/board.test.mjs +0 -3121
  20. package/scripts/brief-after-cut-prose.test.mjs +0 -53
  21. package/scripts/candidates-exit3-prose.test.mjs +0 -302
  22. package/scripts/candidates.test.mjs +0 -2312
  23. package/scripts/caveat-unification-prose.test.mjs +0 -98
  24. package/scripts/cell-readout.test.mjs +0 -615
  25. package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
  26. package/scripts/ci-completes-premise-prose.test.mjs +0 -257
  27. package/scripts/ci-state-prose.test.mjs +0 -113
  28. package/scripts/ci-state.test.mjs +0 -1933
  29. package/scripts/ci-vacuous-green.test.mjs +0 -368
  30. package/scripts/citation-sweep-prose.test.mjs +0 -1712
  31. package/scripts/claim-lifecycle.test.mjs +0 -187
  32. package/scripts/claim-ticket.test.mjs +0 -1122
  33. package/scripts/closing-keyword-prose.test.mjs +0 -193
  34. package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
  35. package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
  36. package/scripts/compute-board.test.mjs +0 -1214
  37. package/scripts/compute-spend.test.mjs +0 -517
  38. package/scripts/consumer-technology-prose.test.mjs +0 -126
  39. package/scripts/cross-repo-citation-prose.test.mjs +0 -155
  40. package/scripts/cwd-isolation-pins.mjs +0 -83
  41. package/scripts/dedupe-guard-prose.test.mjs +0 -243
  42. package/scripts/delete-merged-branch.test.mjs +0 -576
  43. package/scripts/derive-testcmd.test.mjs +0 -595
  44. package/scripts/diff-stats.test.mjs +0 -404
  45. package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
  46. package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
  47. package/scripts/dispositions-check.test.mjs +0 -936
  48. package/scripts/dispositions-gate-prose.test.mjs +0 -129
  49. package/scripts/drop-merged-label.test.mjs +0 -479
  50. package/scripts/exec-stub.mjs +0 -93
  51. package/scripts/exec-stub.test.mjs +0 -69
  52. package/scripts/expected-jobs-prose.test.mjs +0 -80
  53. package/scripts/fan-out-authorization-prose.test.mjs +0 -80
  54. package/scripts/filing-bar-seat-prose.test.mjs +0 -242
  55. package/scripts/filing-claim-bar-prose.test.mjs +0 -166
  56. package/scripts/finisher-died-prose.test.mjs +0 -31
  57. package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
  58. package/scripts/finisher-halt-prose.test.mjs +0 -106
  59. package/scripts/finisher-name-prose.test.mjs +0 -134
  60. package/scripts/finisher-own-tree-prose.test.mjs +0 -299
  61. package/scripts/finisher-pin-race-prose.test.mjs +0 -339
  62. package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
  63. package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
  64. package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
  65. package/scripts/fleet-bootstrap.test.mjs +0 -75
  66. package/scripts/fleet-heartbeat.test.mjs +0 -450
  67. package/scripts/fleet-provenance.test.mjs +0 -138
  68. package/scripts/fleet-run.test.mjs +0 -90
  69. package/scripts/fleet-state.test.mjs +0 -460
  70. package/scripts/fleet-tick-prose.test.mjs +0 -300
  71. package/scripts/fleet-tick.test.mjs +0 -2444
  72. package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
  73. package/scripts/frontmatter-check.test.mjs +0 -436
  74. package/scripts/git-env.test.mjs +0 -149
  75. package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
  76. package/scripts/gone-walk.test.mjs +0 -213
  77. package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
  78. package/scripts/head-moved-after-label-prose.test.mjs +0 -233
  79. package/scripts/immutable-body-claim-prose.test.mjs +0 -204
  80. package/scripts/implementer-model-tier.test.mjs +0 -235
  81. package/scripts/inflight-citation-prose.test.mjs +0 -144
  82. package/scripts/inflight-exit2-prose.test.mjs +0 -81
  83. package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
  84. package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
  85. package/scripts/inflight.test.mjs +0 -2882
  86. package/scripts/injection-control-prose.test.mjs +0 -404
  87. package/scripts/install-root-audit.test.mjs +0 -464
  88. package/scripts/instrument-check-prose.test.mjs +0 -235
  89. package/scripts/instruments.test.mjs +0 -787
  90. package/scripts/is-cli.test.mjs +0 -99
  91. package/scripts/issue-tracker-prose.test.mjs +0 -71
  92. package/scripts/json.test.mjs +0 -364
  93. package/scripts/ledger-dispatch.test.mjs +0 -927
  94. package/scripts/ledger-grammar.test.mjs +0 -227
  95. package/scripts/ledger-read-require-file.test.mjs +0 -197
  96. package/scripts/ledger-rotate.test.mjs +0 -142
  97. package/scripts/ledger.test.mjs +0 -3436
  98. package/scripts/line-distance-prose.test.mjs +0 -245
  99. package/scripts/liveness-rationale-prose.test.mjs +0 -83
  100. package/scripts/locale-pin-prose.test.mjs +0 -189
  101. package/scripts/main-checkout.test.mjs +0 -332
  102. package/scripts/member-outcome-prose.test.mjs +0 -167
  103. package/scripts/member-outcomes-header.test.mjs +0 -129
  104. package/scripts/member-outcomes-prose.test.mjs +0 -63
  105. package/scripts/member-outcomes.test.mjs +0 -638
  106. package/scripts/member-prompt-prose.test.mjs +0 -165
  107. package/scripts/member-record.test.mjs +0 -541
  108. package/scripts/member-write-guard.test.mjs +0 -214
  109. package/scripts/merge-commit-probe-prose.test.mjs +0 -122
  110. package/scripts/merge-gate.test.mjs +0 -613
  111. package/scripts/muted-git-guard-sweep.test.mjs +0 -493
  112. package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
  113. package/scripts/net-watchdog-prose.test.mjs +0 -79
  114. package/scripts/net.test.mjs +0 -211
  115. package/scripts/no-ci-gate-prose.test.mjs +0 -108
  116. package/scripts/no-undo-audit.test.mjs +0 -3961
  117. package/scripts/no-wave.test.mjs +0 -138
  118. package/scripts/node-floor-sweep.test.mjs +0 -611
  119. package/scripts/pointer-target-prose.test.mjs +0 -186
  120. package/scripts/pr-cost.test.mjs +0 -521
  121. package/scripts/pr-overlap.test.mjs +0 -692
  122. package/scripts/printf-die-sweep.test.mjs +0 -384
  123. package/scripts/prompt-renderer.mjs +0 -40
  124. package/scripts/prompt-renderer.test.mjs +0 -68
  125. package/scripts/prose-pin.mjs +0 -807
  126. package/scripts/prose-pin.test.mjs +0 -1034
  127. package/scripts/prove-merge.test.mjs +0 -995
  128. package/scripts/pull-table-relabel-prose.test.mjs +0 -60
  129. package/scripts/quiet-payload-prose.test.mjs +0 -222
  130. package/scripts/reap-cherry-check-prose.test.mjs +0 -80
  131. package/scripts/reap.test.mjs +0 -4432
  132. package/scripts/reaping-prose.test.mjs +0 -239
  133. package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
  134. package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
  135. package/scripts/recipe-derivation-prose.test.mjs +0 -112
  136. package/scripts/recipe-prove.test.mjs +0 -1042
  137. package/scripts/refuter-scratch-prose.test.mjs +0 -135
  138. package/scripts/release-label-required-prose.test.mjs +0 -71
  139. package/scripts/release-label-split-prose.test.mjs +0 -184
  140. package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
  141. package/scripts/release-ticket.test.mjs +0 -5099
  142. package/scripts/renovate-release-contract.test.mjs +0 -379
  143. package/scripts/repo-root.test.mjs +0 -873
  144. package/scripts/reporter-output-rule-prose.test.mjs +0 -208
  145. package/scripts/review-agent-report-only.test.mjs +0 -49
  146. package/scripts/review-core-booking.test.mjs +0 -35
  147. package/scripts/review-core-cwd-isolation.test.mjs +0 -374
  148. package/scripts/review-core-reads.test.mjs +0 -478
  149. package/scripts/review-core-refuter-scratch.test.mjs +0 -148
  150. package/scripts/review-core-scratch-refusal.test.mjs +0 -64
  151. package/scripts/review-core-shared-test-run.test.mjs +0 -275
  152. package/scripts/review-core-snapshot-path.test.mjs +0 -830
  153. package/scripts/review-core-specialist-scratch.test.mjs +0 -191
  154. package/scripts/review-core-testcmd.test.mjs +0 -335
  155. package/scripts/review-core-unrun.test.mjs +0 -566
  156. package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
  157. package/scripts/review-eval-resolver-path.test.mjs +0 -55
  158. package/scripts/review-host-fixture.mjs +0 -89
  159. package/scripts/review-in-run-retry.test.mjs +0 -211
  160. package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
  161. package/scripts/review-path-default.test.mjs +0 -796
  162. package/scripts/review-runner-spawns.test.mjs +0 -95
  163. package/scripts/review-runner.test.mjs +0 -166
  164. package/scripts/review-tier-audit.test.mjs +0 -140
  165. package/scripts/run-artifact-pr-prose.test.mjs +0 -341
  166. package/scripts/run-merge-bot-prose.test.mjs +0 -1413
  167. package/scripts/run-team-local-hook.test.mjs +0 -442
  168. package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
  169. package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
  170. package/scripts/section-between-guard-prose.test.mjs +0 -379
  171. package/scripts/select-dimensions.test.mjs +0 -674
  172. package/scripts/shared-refusal.test.mjs +0 -388
  173. package/scripts/shell-traps-prose.test.mjs +0 -504
  174. package/scripts/shortlist.test.mjs +0 -380
  175. package/scripts/slow-transport.mjs +0 -72
  176. package/scripts/snapshot-repo.test.mjs +0 -1006
  177. package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
  178. package/scripts/spend-view.test.mjs +0 -312
  179. package/scripts/staleness-qualifier-prose.test.mjs +0 -251
  180. package/scripts/staleness-verdict-prose.test.mjs +0 -142
  181. package/scripts/staleness.test.mjs +0 -893
  182. package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
  183. package/scripts/stash-prohibition-prose.test.mjs +0 -313
  184. package/scripts/strip-comments.mjs +0 -44
  185. package/scripts/temp-dir.mjs +0 -47
  186. package/scripts/ticket-router.test.mjs +0 -981
  187. package/scripts/tier-check.test.mjs +0 -828
  188. package/scripts/tier-outcomes-header.test.mjs +0 -518
  189. package/scripts/tier-outcomes.test.mjs +0 -572
  190. package/scripts/tier-roles.test.mjs +0 -535
  191. package/scripts/tracker-block-copy-prose.test.mjs +0 -288
  192. package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
  193. package/scripts/unattended-git-sweep.test.mjs +0 -142
  194. package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
  195. package/scripts/verify-sha.test.mjs +0 -692
  196. package/scripts/watcher-degraded-block.test.mjs +0 -369
  197. package/scripts/watcher-key-prose.test.mjs +0 -106
  198. package/scripts/within-run-pair-prose.test.mjs +0 -212
  199. package/scripts/worktree-audit.test.mjs +0 -1408
  200. package/scripts/worktree-head-prose.test.mjs +0 -276
  201. package/scripts/worktree-listing-sweep.test.mjs +0 -217
  202. package/scripts/worktree-model-prose.test.mjs +0 -216
  203. package/scripts/worktree-porcelain.mjs +0 -35
  204. package/scripts/worktree-porcelain.test.mjs +0 -102
@@ -1,191 +0,0 @@
1
- // #1550. PR #1084 (implemented as #1530) added two directory-safety rules to
2
- // the (since-retired) `review-pr` WORKFLOW's specialist prompt — chain the
3
- // directory change into the command, and bracket a fixture's own git with
4
- // `git rev-parse --show-toplevel` — mirroring what PR #1082 had already
5
- // added to that same file's REFUTER prompt. `scripts/review-core.mjs`
6
- // carried the same specialist dispatch prompt and, at the time, neither
7
- // rule, while ordering the same kind of work: "Run any mutation or probe
8
- // work inside your own copy of the snapshot." `review-core.mjs` is now the
9
- // only surviving copy of this prompt.
10
- //
11
- // Naming the write area is not the same rule and does not close either failure
12
- // mode. The specialist prompt already said scratch files go in its own
13
- // directory "and nowhere else", and both measured failures happen with that
14
- // sentence obeyed as written: a `cd` that silently fails leaves the following
15
- // `;`-separated `git` running in whatever directory the agent was already in —
16
- // the incident review-core-refuter-scratch.test.mjs records as commit
17
- // 020d6ea reaching the checkout during the PR #488 fix-applier run — and an
18
- // agent that BELIEVES it is already in its scratch copy and is wrong runs
19
- // `git init` / `git commit` against the repository. A rule about where
20
- // writes SHOULD go does not detect either.
21
- //
22
- // INLINED, NOT SHARED: #496's brief rules the shared-source route out — "the
23
- // drift hazard is real and is its own ticket, not this one." That drift
24
- // hazard is exactly what this pin exists to convert into a red: it failed to
25
- // fire once already, which is why this ticket exists at all.
26
- //
27
- // WHY THESE PINS RENDER RATHER THAN GREP. Two reasons, and the second is the
28
- // one a source-text pin cannot reach. The rules live inside a template
29
- // literal, so their backticks are written escaped (`` \` ``); a pin written
30
- // against the source has to tolerate that backslash, and then it passes just
31
- // as happily on a prompt that shows the specialist a literal `\` instead of a
32
- // code span. Rendering settles what the agent actually reads. And a bounded
33
- // slice of the SOURCE would still be satisfied by dead text — the vacuity
34
- // class strip-comments.mjs exists for — whereas a commented-out prompt does
35
- // not render at all.
36
- //
37
- // THE SLICE IS THE PIN. Each rule appears more than once in this file (the
38
- // verify/refuter prompt below carries its own, older copy), so every regex
39
- // here would be satisfied by the refuter's copy alone if it were matched
40
- // against the whole file — which is exactly the defect this ticket reports,
41
- // so a pin that could pass on the refuter's copy would have passed before the
42
- // fix. The extraction is bounded at both ends by the specialist `agent()`
43
- // call's own template and its `review:` label, so the refuter prompt is
44
- // outside it by construction. Both directions were measured: reverting the two
45
- // rules out of the specialist prompt reds all three tests here with the
46
- // refuter's copy untouched.
47
- //
48
- // THE CEILING, same as review-core-refuter-scratch.test.mjs's: nothing here
49
- // reaches the agent's own obedience. These pins settle what a specialist is
50
- // TOLD, never where it actually writes.
51
- import { test } from "node:test";
52
- import assert from "node:assert/strict";
53
- import { readFileSync } from "node:fs";
54
- import { join } from "node:path";
55
- import { stripComments } from "./strip-comments.mjs";
56
- import { between } from "./prose-pin.mjs";
57
-
58
- const REPO = join(import.meta.dirname, "..");
59
- const SOURCE = readFileSync(join(REPO, "scripts", "review-core.mjs"), "utf8");
60
- const CODE = stripComments(SOURCE);
61
-
62
- const TEMPLATE_START = "`Review PR #${pr} (branch ${branch}) for: ";
63
- const TEMPLATE_END = "label: `review:";
64
-
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
-
71
- // `between` owns the bounded-slice extraction (and both failure messages);
72
- // only the backtick trim below is specific to a template literal and stays
73
- // here.
74
- const SLICE = between(
75
- CODE,
76
- TEMPLATE_START,
77
- TEMPLATE_END,
78
- "review-core.mjs's specialist prompt (opening `Review PR #${pr} (branch ${branch}) for: `, labelled `review:`)",
79
- );
80
-
81
- const RENDER = new Function(...SCOPE, "return `" + SLICE.slice(1, SLICE.lastIndexOf("`")) + "`");
82
-
83
- // One specialist's prompt. Every argument is fixed: these pins are about what
84
- // the prompt SAYS, not about how it varies, so nothing here needs to.
85
- const render = () =>
86
- RENDER(
87
- 7,
88
- "feature/x",
89
- { key: "correctness", prompt: "does it do what it says" },
90
- { path: "/scr/run-1/snapshot-abc1234", head: "abc1234", runRoot: "/scr/run-1" },
91
- "/repo/.worktrees/7-x",
92
- null,
93
- () => "SHARED RUN NOTE",
94
- {},
95
- "correctness",
96
- () => "READ RULES",
97
- () => null,
98
- () => "TEST ENVIRONMENT",
99
- );
100
-
101
- // The first of the two rules, in the prompt that was missing it. ONE
102
- // contiguous regex rather than two assertions, for the reason
103
- // refuter-scratch-prose.test.mjs states about the same wording: an unbounded
104
- // gap lets a spliced sentence carve an exception INTO the rule and stay green.
105
- // Both gaps are the literal punctuation the rendered prompt carries around
106
- // "never" ("…`, " before it, a line break plus backtick after) rather than a
107
- // free-text `.{0,N}` span — mutation-tested: an exception clause spliced into
108
- // either gap (e.g. "never except during setup steps") reds this assertion.
109
- //
110
- // Both spellings are required, and the negative one is what carries the rule —
111
- // `cd "$D" && git …` alone reads as a suggestion, and the observed failure is
112
- // an agent writing the other form.
113
- test("the rendered specialist prompt chains cd into the git command, never semicolon", () => {
114
- assert.match(
115
- render(),
116
- /cd\s+"\$D"\s+&&\s+git\s+…`,\s+never\s+`cd\s+"\$D";\s+git\s+…/s,
117
- "review-core.mjs's specialist prompt carries no cd-chaining rule — a silently failed `cd` leaves the following `git` " +
118
- "running in the checkout, which is what produced commit 020d6ea during the PR #488 fix-applier run (#1550)",
119
- );
120
- });
121
-
122
- // The second rule. Both halves, because they have OPPOSITE expected outcomes:
123
- // a lone "resolves to your scratch path" guard is unsatisfiable before `git
124
- // init` — a fresh scratch dir has no toplevel and exits 128 — and a guard that
125
- // cannot pass on the clean path gets ignored. Naming a path alone does not
126
- // catch the observed failure either, which was an agent BELIEVING it was
127
- // already in scratch and being wrong. Gaps are the literal prose between the
128
- // four clauses, typed out rather than left as a free-text `.{0,N}` span —
129
- // mutation-tested: a short exception clause spliced into any of the first,
130
- // third, or fourth gaps (e.g. "except in CI runners," right after the
131
- // leading `:`, or "except during rebase," right after "not a failure;")
132
- // reds this assertion; the same splices pass a `.{0,N}`-gapped version of
133
- // this regex undetected.
134
- //
135
- // The realpath tail is part of the pin, not decoration on it, and carries the
136
- // same typed gaps for the same reason. PR #1567 added that remedy to all four
137
- // copies of this rule but the pin to only the refuter's two, so the clause sat
138
- // unpinned in both specialist prompts: deleting it from both (measured, #1570)
139
- // left this file and its review-pr sibling at 6/6 and the four refuter/prose
140
- // pins at 41/41, all green. It is also the half that makes the rule
141
- // satisfiable in the OTHER direction — `--show-toplevel` answers
142
- // `/private/tmp/…` for a `/tmp` scratch dir on macOS, so a raw string compare
143
- // reports a mismatch on the clean path, and a guard that cannot pass there
144
- // gets ignored exactly as a lone `git init` half would.
145
- //
146
- // Both directions on the tail itself: an exception clause spliced into its
147
- // leading gap ("…your scratch path, except in CI runners — compare resolved
148
- // forms…") reds this assertion, where the `.{0,80}`-gapped spelling in
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).
152
- test("the rendered specialist prompt requires a toplevel assertion around git init/commit, including the realpath remedy for macOS's /private/tmp symlink", () => {
153
- assert.match(
154
- render(),
155
- /`git\s+rev-parse\s+--show-toplevel`:\s+before\s+`git\s+init`\s+it\s+must\s+NOT\s+resolve\s+to\s+the\s+repository,\s+and\s+a\s+fresh\s+scratch\s+dir's\s+`fatal:\s+not\s+a\s+git\s+repository`\s+\(exit\s+128\)\s+is\s+the\s+pass,\s+not\s+a\s+failure;\s+before\s+any\s+`git\s+commit`\s+it\s+must\s+resolve\s+to\s+your\s+scratch\s+path\s+—\s+compare\s+resolved\s+forms\s+\(`realpath`\),\s+since\s+`--show-toplevel`\s+can\s+report\s+`\/private\/tmp\/…`\s+for\s+a\s+`\/tmp`\s+scratch\s+dir\s+on\s+macOS/s,
156
- "review-core.mjs's specialist prompt carries no toplevel assertion around a fixture's own git init/commit, or " +
157
- "dropped the realpath remedy for macOS's /private vs /tmp symlink — an agent that wrongly believes it is " +
158
- "already in its scratch copy runs `git init`/`git commit` against the repository, and a raw compare against " +
159
- "`--show-toplevel` reads a `/private/tmp` answer for a `/tmp` scratch dir as a mismatch on the clean path (#1550, #1570)",
160
- );
161
- });
162
-
163
- // The other direction, and the reason a prose pin on an ADDED rule needs one: a
164
- // prompt that gains rules can displace the instructions those rules exist to
165
- // make safe, and both of the added rules are written in terms of the
166
- // specialist's own scratch area — "your scratch path" names nothing once the
167
- // directory sentence goes, and a rule about a fixture's git is inert if the
168
- // prompt no longer orders mutation work in a copy of its own.
169
- //
170
- // The scratch sentence and the first rule are asserted as one bounded span,
171
- // with the gap between them typed as `\s+` — the rendered prompt carries
172
- // exactly one space there, never a free-text `.{0,N}` — so a sentence spliced
173
- // between them (mutation-tested: "Except for git fixtures, which may live
174
- // anywhere.") reds this assertion instead of leaving both halves present and
175
- // passing.
176
- test("the added rules still sit on a prompt that names a write area and orders work in its own copy", () => {
177
- const prompt = render();
178
- assert.match(
179
- prompt,
180
- /Run any mutation or probe work inside your own copy of the snapshot\./,
181
- "review-core.mjs's specialist is no longer told to do mutation or probe work in a copy of its own — the two " +
182
- "directory rules now guard work the prompt never scopes to a copy at all",
183
- );
184
- assert.match(
185
- prompt,
186
- /Scratch\s+files\s+go\s+in\s+\/scr\/run-1\/correctness\/\s+and\s+nowhere\s+else\.\s+Chain\s+the\s+directory\s+change\s+into\s+the\s+command/s,
187
- "review-core.mjs's specialist prompt no longer names the scratch directory immediately before the cd rule — " +
188
- "either the write area is gone, leaving 'your scratch path' naming nothing, or a sentence between them carves " +
189
- "an exception into it",
190
- );
191
- });
@@ -1,335 +0,0 @@
1
- import { test } from "node:test";
2
- import assert from "node:assert/strict";
3
- import { readFileSync } from "node:fs";
4
- import { join } from "node:path";
5
- import { stripComments } from "./strip-comments.mjs";
6
- import { between } from "./prose-pin.mjs";
7
- import { resolveTestCmd, SNAPSHOT_SCHEMA } from "./review-core.mjs";
8
-
9
- // The review host used to default `testCmd` to a literal string naming THIS
10
- // repo's own test path — silent green everywhere else, since `worktree` is a
11
- // caller-supplied argument and a glob matching nothing exits 0 reporting
12
- // `tests 0` (#142). It is now READ from the repo under review's Recipe cache by
13
- // the snapshot agent (see the "derives this repository's own test command"
14
- // paragraph below), through derive-testcmd.sh — see derive-testcmd.test.mjs
15
- // for that script's own coverage, exercised against fixture repos that are
16
- // NOT this one, which is the guard #142's acceptance criteria required and an
17
- // archive of this repo could not have been.
18
- //
19
- // This file covers what remains review-core.mjs's own responsibility:
20
- // resolveTestCmd's resolution order and refusal, the snapshot agent's prompt
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.
24
- const REPO = join(import.meta.dirname, "..");
25
- const SOURCE = readFileSync(join(REPO, "scripts", "review-core.mjs"), "utf8");
26
-
27
- // Every pin below runs against CODE, not SOURCE — the same policy, and now the
28
- // same stripper, as `review-core-reads.test.mjs`. Written against raw source,
29
- // this file's schema-declaration pin was VACUOUS: wrapping the real
30
- // `testCmd: { type: "string" },` in a `/* */` block left the suite 9 pass / 0
31
- // fail while `additionalProperties: false` silently dropped the field at
32
- // runtime, breaking the very derivation #142 adds. The `^\s*` anchor those
33
- // pins use rejects a leading `//` and nothing else. Measured, #142 review.
34
- const CODE = stripComments(SOURCE);
35
-
36
- test("an explicit override always wins, whatever the snapshot derived", () => {
37
- assert.equal(resolveTestCmd("npm test --", { testCmd: "node --test" }), "npm test --");
38
- assert.equal(resolveTestCmd("npm test --", null), "npm test --");
39
- assert.equal(resolveTestCmd("npm test --", { testCmdError: "refused" }), "npm test --");
40
- });
41
-
42
- test("no override falls back to the snapshot agent's derivation", () => {
43
- assert.equal(resolveTestCmd(undefined, { testCmd: "node --test" }), "node --test");
44
- assert.equal(resolveTestCmd(null, { testCmd: "npm test --" }), "npm test --");
45
- });
46
-
47
- // The whole point of #142: neither an override nor a derivation must REFUSE
48
- // the review, never fall back to a guessed default. The reason passed through
49
- // is derive-testcmd.sh's own, which names the derivation step (ADR 0015).
50
- test("no override and no derivation refuses, naming the snapshot agent's reason", () => {
51
- assert.throws(
52
- () => resolveTestCmd(undefined, { testCmdError: "derive-testcmd: no Recipe cache at /r/.fleet/recipe.json" }),
53
- /no test command for this repository — derive-testcmd: no Recipe cache at \/r\/\.fleet\/recipe\.json/,
54
- );
55
- });
56
-
57
- // With no reason from the snapshot agent, the refusal still has to tell its
58
- // reader what to RUN — the derivation step — rather than only that nothing
59
- // was derived: a controller or reviewer reading it has no other pointer.
60
- test("no override, no snapshot at all, and no testCmdError still refuses, naming the derivation step", () => {
61
- for (const snap of [null, {}]) {
62
- assert.throws(
63
- () => resolveTestCmd(undefined, snap),
64
- /no test command for this repository — the snapshot agent read no Recipe cache; run the Recipe derivation step \(run-team phase 0/,
65
- );
66
- }
67
- });
68
-
69
- // A falsy-but-present override (`""`) is caller error, not "no override" —
70
- // the `||`/truthiness check above only distinguishes explicit from absent,
71
- // and this pins that an empty string does NOT silently pass through as a
72
- // command. It falls to the snapshot the same as `undefined` would.
73
- test("an empty-string override is not treated as an explicit command", () => {
74
- assert.equal(resolveTestCmd("", { testCmd: "node --test" }), "node --test");
75
- });
76
-
77
- // The function is worthless if nothing calls it — pin the CALL SITE, not
78
- // just the lifted copy. select-dimensions.test.mjs's #118 regression is this
79
- // exact defect: replacing the call with a bare default left every test above
80
- // green while the feature disconnected.
81
- test("runReview actually calls resolveTestCmd once the snapshot is validated", () => {
82
- assert.match(
83
- CODE,
84
- /^\s*const testCmd = resolveTestCmd\(A\.testCmd, snap\);$/m,
85
- "the testCmd call site changed — the derivation may be disconnected",
86
- );
87
- // Textually after the snapshot's own validity guard, not before — snap must
88
- // be known good (or the throw above already fired) before this reads it.
89
- // Anchored on the guard's INVOCATION — not its declaration, and not one of
90
- // its return messages. The declaration sits above every top-level statement
91
- // in this file, so ordering against it is near-tautological: measured, it
92
- // stays green with the resolveTestCmd call moved ahead of the guard, which
93
- // is the one regression this assertion's message names. A message anchor is
94
- // reword-fragile instead — #539 split the single "no tree" message into
95
- // three, and the retired literal leaves guardAt at -1, which reds this
96
- // assertion loudly rather than silently, but reds it all the same. The call
97
- // site is the only anchor that is both reword-proof and order-sensitive.
98
- const guardAt = CODE.indexOf("const missingReason = snapshotMissing(snap, runRootPrefix);");
99
- const callAt = CODE.indexOf("const testCmd = resolveTestCmd(");
100
- assert.ok(guardAt !== -1 && callAt !== -1 && callAt > guardAt, "resolveTestCmd is called before snap is validated");
101
- });
102
-
103
- // A hardcoded default anywhere in this file is the exact regression #142
104
- // fixes — `A.testCmd || "<literal>"` is the shape it used to take.
105
- test("no hardcoded testCmd default remains", () => {
106
- assert.doesNotMatch(
107
- CODE,
108
- /A\.testCmd\s*\|\|\s*"/,
109
- "a literal testCmd default reappeared — it must come from resolveTestCmd/derive-testcmd.sh instead",
110
- );
111
- });
112
-
113
- // The snapshot agent's return schema gains testCmd/testCmdError the same way
114
- // diffPath/diffLines/prHead were added: `additionalProperties: false` drops
115
- // an undeclared field silently, so BOTH the prompt asking for it and the
116
- // schema declaring it have to be pinned, or the feature disconnects in one
117
- // token exactly like `review-core-reads.test.mjs`'s "the snapshot agent asks for
118
- // the diff facts AND declares them in its schema" records happening to the
119
- // diff facts.
120
- test("the snapshot agent is told to derive testCmd AND the schema declares it", () => {
121
- const snapshot = between(CODE, "const snap = await agent(", "if (snap) {", "the snapshot agent dispatch");
122
-
123
- assert.match(
124
- snapshot,
125
- /~\/\.fleet\/bin\/fleet-run derive-testcmd\.sh \$\{worktree\} test/,
126
- "the snapshot agent no longer reads the Test entrypoint through derive-testcmd.sh via the Resolver",
127
- );
128
- // Deriving the command is half the job — it also has to RUN where the
129
- // specialists are told to run it. `git archive` carries tracked files only,
130
- // so `npm test --` (the derivation's first branch, for any repo whose
131
- // scripts.test invokes a node_modules binary) exits 127 in the snapshot
132
- // while passing in the worktree the derivation was run against. Measured on
133
- // a synthetic repo during the #142 review: worktree exit 0, archive exit 127.
134
- assert.match(
135
- snapshot,
136
- // `"$SNAP/node_modules"` since #1129: the destination is a per-run shell
137
- // variable now, and the symlink has to land in the tree this run actually
138
- // extracted — a link left at the old bare `${scratch}/snapshot` would
139
- // provision node_modules for a directory no specialist is pointed at.
140
- // Quote-tolerant on purpose. The needle's job is that the symlink lands in
141
- // THIS run's destination — `$SNAP`, never the old bare `${scratch}/snapshot`
142
- // — and `"$SNAP/node_modules"` and `"$SNAP"/node_modules` are the same word
143
- // to any POSIX shell, `/node_modules` carrying no metacharacters. Pinning
144
- // one of the two rejected a behaviour-identical rewrite as a #1129
145
- // regression, which is how a pin teaches its next reader to weaken it.
146
- //
147
- // The `[ -n "$SNAP" ]` half is not decoration either: this is the only
148
- // command in the block whose target no earlier line created, so it is the
149
- // only one that would still act on an empty `$SNAP` — writing a symlink at
150
- // `/node_modules`, outside the run root entirely.
151
- // Order-agnostic between the two `[ ]` tests, for the same reason the
152
- // quotes are optional: swapping them is behaviour-identical, so pinning
153
- // one arrangement would red a correct change.
154
- /if [^\n]*\[ -n "\$SNAP" \][^\n]*; then ln -s \$\{worktree\}\/node_modules "?\$SNAP"?\/node_modules"?/,
155
- "the snapshot no longer provisions node_modules — a derived `npm test --` cannot run in it",
156
- );
157
- // These names live inside a template literal, so each backtick is a
158
- // BACKSLASH-backtick in the source text — `\\?` matches it either way, the
159
- // same idiom `review-core-reads.test.mjs` uses for diffPath/prHead/diffLines.
160
- const B = "\\\\?`";
161
- assert.match(
162
- snapshot,
163
- new RegExp(`Report\\s+${B}testCmd${B}\\s*=\\s*its\\s+stdout\\s+ONLY\\s+if\\s+it\\s+exited\\s+0`),
164
- "testCmd is not bound to the script's stdout and gated on its exit code",
165
- );
166
- assert.match(
167
- snapshot,
168
- new RegExp(`report\\s+${B}testCmdError${B}\\s*=\\s*its\\s+stderr`),
169
- "testCmdError is not bound to the script's stderr on refusal",
170
- );
171
-
172
- // Scoped to `SNAPSHOT_SCHEMA.properties` directly — a real import now,
173
- // never a second copy of its JSON re-parsed from source text. A field
174
- // declared ANYWHERE else is undeclared as far as
175
- // `additionalProperties: false` is concerned.
176
- for (const field of ["testCmd", "testCmdError"]) {
177
- assert.ok(
178
- Object.prototype.hasOwnProperty.call(SNAPSHOT_SCHEMA.properties, field),
179
- `${field} is not declared in SNAPSHOT_SCHEMA.properties — additionalProperties:false drops it`,
180
- );
181
- }
182
- // Both stay OUT of `required`: a network or git failure inside
183
- // derive-testcmd.sh must not abort a snapshot that is otherwise good —
184
- // resolveTestCmd is what turns a missing derivation into a refusal, not a
185
- // required-field validation error one layer down. `pathVerified` joins
186
- // path+head instead (#140): unlike testCmd, its absence must abort. So does
187
- // `repoVerified` (#1056) — whether the snapshot is a repository holding the
188
- // reviewed tree decides what a suite run in there is evidence about.
189
- // `environmentNote`'s strict `=== true` check already guarantees an omitted
190
- // field reads as UNVERIFIED either way, so the risk `required` guards
191
- // against is different: omitted from `required`, the snapshot agent could
192
- // silently drop the field from its structured output — especially under
193
- // omp's permissive schema-retry-exhaustion mode — and the caller would
194
- // never find out the measurement was never taken.
195
- assert.deepEqual(
196
- SNAPSHOT_SCHEMA.required,
197
- ["runRoot", "path", "head", "pathVerified", "repoVerified"],
198
- "required must stay path+head+pathVerified+repoVerified only",
199
- );
200
- });
201
-
202
- // derive-testcmd.sh's exit-3 refusals are about the environment and name no
203
- // derivation step, so the prompt must not tell the snapshot agent that every
204
- // refusal does.
205
- test("the snapshot agent is told a cache refusal names the derivation step and an exit-3 refusal names an environment fault", () => {
206
- const snapshot = between(CODE, "const snap = await agent(", "if (snap) {", "the snapshot agent dispatch");
207
- assert.match(snapshot, /a\s+refusal\s+about\s+the\s+cache\s+names\s+the\s+step\s+that\s+derives\s+it/);
208
- assert.match(snapshot, /an\s+exit-3\s+refusal\s+names\s+an\s+environment\s+fault,\s+and\s+the\s+caller\s+fixes\s+that\s+instead\s+of\s+deriving/);
209
- // The two clauses above are the only places the prompt may speak of a
210
- // refusal: any other sentence about one, however worded or capitalised, is a
211
- // fresh chance to say that every refusal names the derivation step.
212
- const outside = snapshot
213
- .replace(/a\s+refusal\s+about\s+the\s+cache\s+names\s+the\s+step\s+that\s+derives\s+it/, "")
214
- .replace(/an\s+exit-3\s+refusal\s+names\s+an\s+environment\s+fault/, "");
215
- assert.doesNotMatch(outside, /\brefusals?\b/i, "the prompt speaks of a refusal outside the two clauses that say which kind names the derivation step");
216
- });
217
-
218
- // #2315. The prompt that RUNS the command is the shared test run's — every
219
- // specialist used to run it, which made one review up to six full sweeps.
220
- // Bounded at both ends: an unbounded slice runs to EOF, where the specialist
221
- // and refuter prompts could satisfy the assertions below instead.
222
- function testRunPrompt() {
223
- return between(CODE, "`Run this repository's test command ONCE", "{ label: `test-run${forPr}`", "the shared test-run prompt");
224
- }
225
-
226
- // The prompt is what the test-run agent actually obeys, so the reading rule has
227
- // to be in it. Without this, an agent that guesses a glob still reports
228
- // `tests 0` as a pass — the exact failure the derivation alone does not cover.
229
- test("the test-run prompt hands the command over verbatim and rules 'tests 0' a failure", () => {
230
- const prompt = testRunPrompt();
231
- // The command block must INTERPOLATE testCmd, not restate it. A hardcoded
232
- // copy drifts from the resolved value the moment either one changes, and a
233
- // caller passing args.testCmd (or the derivation) would be handed the wrong
234
- // command. Run from the snapshot's root, its output captured to the log
235
- // every specialist is pointed at.
236
- assert.match(
237
- prompt,
238
- /\{ cd "\$\{snap\.path\}" && \$\{testCmd\}; \} > "\$\{logPath\}" 2>&1; echo "TEST_RUN_EXIT=\$\?"/,
239
- "the prompt no longer runs the interpolated command verbatim from the snapshot's root into the log",
240
- );
241
- // Match the ruling itself, not the phrase `tests 0` — that appears in the
242
- // surrounding explanation too, so a looser assertion passes with the rule
243
- // deleted (observed: it did).
244
- assert.match(prompt, /'tests 0' is a FAILED run/, "the prompt no longer rules a zero-test run a failure");
245
- // The RULING was pinned and the INSTRUCTION was not, so the sentence telling
246
- // the agent not to swap the command out could be deleted with this suite
247
- // green (#143). Everything around it explains why; this is the only clause
248
- // that actually forbids anything.
249
- assert.match(
250
- prompt,
251
- /Do not substitute a command of your own\./,
252
- "the prompt no longer forbids substituting a command — only explains why one would be wrong",
253
- );
254
- // Once is the whole point of #2315: a retry by the agent is a second full run.
255
- // The clause, not the phrase — "Run it exactly once, then again when it
256
- // fails" still contains "Run it exactly once".
257
- assert.match(
258
- prompt,
259
- /Run it exactly once: not again when it fails, and not again when it hits the\s+deadline\./,
260
- "the prompt no longer forbids running the command a second time",
261
- );
262
- });
263
-
264
- // How the one run is held and read. Each clause is a behavior the agent obeys
265
- // and nothing downstream re-checks: a backgrounded or polled run is the
266
- // unbounded load #2315 measured, a deadline that is far too short reads every
267
- // heavy suite as no counts, a `tail` too short misses the summary, and a 0
268
- // typed in for a count the log never stated turns "no counts" (every dimension
269
- // unrun) into "tests 0" or a clean-looking pass — the distinction
270
- // TEST_RUN_SCHEMA's absent-count rule exists for.
271
- test("the test-run prompt holds the run in the foreground under a deadline, and never invents a count", () => {
272
- const prompt = testRunPrompt();
273
- assert.match(prompt, /ONE blocking foreground command — never backgrounded, never polled —/, "the prompt no longer forbids a backgrounded or polled run");
274
- 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");
275
- assert.match(prompt, /\\`tail -n 40 "\$\{logPath\}"\\`/, "the prompt no longer reads enough of the log's tail to hold a runner's summary");
276
- assert.match(
277
- prompt,
278
- /omit every count and say what happened in \\`error\\`\. Never\s+write 0 for a count the log does not state/,
279
- "the prompt no longer forbids writing 0 for a count the log does not state",
280
- );
281
- });
282
-
283
- // #143's second correction. The rationale once asserted, present tense and as
284
- // fact about the run being described, that a bare runner "tears down a shared
285
- // container mid-run for every sibling". Measured against this repo:
286
- // this repo's Test entrypoint is a plain `node --test` run and
287
- // `commands/review-and-fix.md` records that this repo has no
288
- // compose file, no `globalSetup`, and no vitest — so no teardown can happen,
289
- // and an agent that checks the reason it was given finds it false.
290
- //
291
- // The rule is still worth carrying, because the review host reviews repos that DO
292
- // have a stack. It has to be stated as a conditional about those repos rather
293
- // than as a fact about this run.
294
- test("the anti-substitution rationale is portable, not a present-tense claim about this run", () => {
295
- const prompt = testRunPrompt();
296
- assert.doesNotMatch(
297
- prompt,
298
- /tears down a shared container mid-run for every sibling/,
299
- "the prompt again asserts a container teardown as fact about a run that cannot have one (#143)",
300
- );
301
- // The conditional that replaced it, and the half that is NOT conditional: a
302
- // zero-match glob exits 0 in every repo, so hedging that one would weaken a
303
- // rule this repo has actually measured (#142).
304
- 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");
305
- assert.match(prompt, /a guessed glob is\s+worse in every repo/, "the zero-match-glob half is no longer stated as holding everywhere");
306
- });
307
-
308
- // The rule #143 widened, now in the one prompt that runs the suite. The
309
- // classifier catches the zero-pass case on its own (`review-core-unrun.test.mjs`),
310
- // but the partial-tree case it CANNOT: `unrunReason` is pure and never learns
311
- // how many tests the whole tree has, so the only guard is the run itself
312
- // starting from the snapshot's root. If this instruction goes, that case has no
313
- // other guard.
314
- test("the test-run prompt rules a no-work run too: zero passes, and a count below the whole tree", () => {
315
- const prompt = testRunPrompt();
316
- 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)");
317
- assert.match(
318
- prompt,
319
- /a count well below what the whole tree reports, which means it ran a\s+PARTIAL copy/,
320
- "the prompt no longer names a partial-tree run — the case nothing downstream can catch (#143)",
321
- );
322
- });
323
-
324
- // #2315's other half: the specialist prompt must hand the shared run over and
325
- // never the command to run. A specialist prompt that interpolates `testCmd`
326
- // again is six full sweeps per review again.
327
- test("the specialist prompt carries the shared run's note, and never the command to run", () => {
328
- const prompt = between(CODE, "READ ONLY FROM THE SNAPSHOT", "Scratch files go in", "the specialist prompt");
329
- assert.doesNotMatch(prompt, /\$\{testCmd\}/, "the specialist prompt hands out testCmd to run again — one full sweep per dimension");
330
- assert.match(
331
- prompt,
332
- /\$\{sharedRunNote\(sharedRun, failureOwner, d\.key\)\}/,
333
- "the specialist prompt no longer carries the shared run's note",
334
- );
335
- });