@feigi/fleet-ctl 0.0.0

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 (245) hide show
  1. package/.claude-plugin/plugin.json +9 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +18 -0
  4. package/agents/fleet-finisher.agent.md +7 -0
  5. package/agents/fleet-implementer-alt.agent.md +210 -0
  6. package/agents/fleet-implementer.agent.md +210 -0
  7. package/agents/fleet-merge-bot.agent.md +7 -0
  8. package/agents/fleet-review-comments.agent.md +40 -0
  9. package/agents/fleet-review-correctness.agent.md +43 -0
  10. package/agents/fleet-review-runner.agent.md +73 -0
  11. package/agents/fleet-review-silent-failure.agent.md +49 -0
  12. package/agents/fleet-review-simplify.agent.md +46 -0
  13. package/agents/fleet-review-snapshot.agent.md +24 -0
  14. package/agents/fleet-review-tests.agent.md +46 -0
  15. package/agents/fleet-review-types.agent.md +41 -0
  16. package/agents/fleet-review-verifier.agent.md +29 -0
  17. package/commands/review-and-fix.md +98 -0
  18. package/commands/run-merge-bot.md +357 -0
  19. package/commands/run-team-help.md +17 -0
  20. package/package.json +23 -0
  21. package/scripts/agent-test-dir-prose.test.mjs +59 -0
  22. package/scripts/agent-test.test.mjs +1636 -0
  23. package/scripts/ambient-git-vars-mjs-prose.test.mjs +354 -0
  24. package/scripts/ambient-git-vars-prose.test.mjs +192 -0
  25. package/scripts/ancestry-check-position-prose.test.mjs +175 -0
  26. package/scripts/apply-ruleset.test.mjs +420 -0
  27. package/scripts/arg-header-probes-prose.test.mjs +393 -0
  28. package/scripts/arg.mjs +600 -0
  29. package/scripts/arg.test.mjs +1354 -0
  30. package/scripts/board-cli.test.mjs +694 -0
  31. package/scripts/board-identity.test.mjs +429 -0
  32. package/scripts/board-liveness-banner.test.mjs +119 -0
  33. package/scripts/board-prev-shape.test.mjs +229 -0
  34. package/scripts/board-tryparse-null.test.mjs +119 -0
  35. package/scripts/board.html +471 -0
  36. package/scripts/board.mjs +2037 -0
  37. package/scripts/board.test.mjs +3086 -0
  38. package/scripts/brief-after-cut-prose.test.mjs +53 -0
  39. package/scripts/candidates-exit3-prose.test.mjs +302 -0
  40. package/scripts/candidates.mjs +674 -0
  41. package/scripts/candidates.test.mjs +2101 -0
  42. package/scripts/caveat-unification-prose.test.mjs +98 -0
  43. package/scripts/ci-comment-rot-prose.test.mjs +2025 -0
  44. package/scripts/ci-completes-premise-prose.test.mjs +257 -0
  45. package/scripts/ci-state-prose.test.mjs +113 -0
  46. package/scripts/ci-state.mjs +761 -0
  47. package/scripts/ci-state.test.mjs +1640 -0
  48. package/scripts/ci-vacuous-green.test.mjs +368 -0
  49. package/scripts/citation-sweep-prose.test.mjs +1572 -0
  50. package/scripts/claim-lifecycle.test.mjs +185 -0
  51. package/scripts/claim-ticket.sh +417 -0
  52. package/scripts/claim-ticket.test.mjs +1121 -0
  53. package/scripts/closing-keyword-prose.test.mjs +193 -0
  54. package/scripts/cockpit-launch-idempotent-prose.test.mjs +165 -0
  55. package/scripts/cockpit-tick-nonblocking.test.mjs +210 -0
  56. package/scripts/compute-board.mjs +579 -0
  57. package/scripts/compute-board.test.mjs +1060 -0
  58. package/scripts/compute-spend.mjs +329 -0
  59. package/scripts/compute-spend.test.mjs +451 -0
  60. package/scripts/cross-repo-citation-prose.test.mjs +156 -0
  61. package/scripts/cwd-isolation-pins.mjs +83 -0
  62. package/scripts/dedupe-guard-prose.test.mjs +243 -0
  63. package/scripts/derive-testcmd.sh +239 -0
  64. package/scripts/derive-testcmd.test.mjs +380 -0
  65. package/scripts/diff-stats.mjs +231 -0
  66. package/scripts/diff-stats.test.mjs +408 -0
  67. package/scripts/dispatch-block-golden-prose.test.mjs +1024 -0
  68. package/scripts/dispatch-block-pins-prose.test.mjs +615 -0
  69. package/scripts/drop-merged-label.sh +173 -0
  70. package/scripts/drop-merged-label.test.mjs +480 -0
  71. package/scripts/expected-jobs-prose.test.mjs +80 -0
  72. package/scripts/filing-bar-seat-prose.test.mjs +242 -0
  73. package/scripts/filing-claim-bar-prose.test.mjs +166 -0
  74. package/scripts/finisher-dispatch-premise-prose.test.mjs +312 -0
  75. package/scripts/finisher-halt-prose.test.mjs +106 -0
  76. package/scripts/finisher-name-prose.test.mjs +134 -0
  77. package/scripts/finisher-own-tree-prose.test.mjs +285 -0
  78. package/scripts/finisher-pin-race-prose.test.mjs +339 -0
  79. package/scripts/fix-applier-correction-rules-prose.test.mjs +201 -0
  80. package/scripts/fix-applier-result-file-prose.test.mjs +100 -0
  81. package/scripts/fleet-bootstrap +155 -0
  82. package/scripts/fleet-heartbeat.mjs +272 -0
  83. package/scripts/fleet-heartbeat.test.mjs +450 -0
  84. package/scripts/fleet-provenance +207 -0
  85. package/scripts/fleet-provenance.test.mjs +64 -0
  86. package/scripts/fleet-run +148 -0
  87. package/scripts/fleet-run.test.mjs +90 -0
  88. package/scripts/fleet-state.mjs +400 -0
  89. package/scripts/fleet-state.test.mjs +373 -0
  90. package/scripts/fleet-tick-prose.test.mjs +299 -0
  91. package/scripts/fleet-tick.mjs +832 -0
  92. package/scripts/fleet-tick.test.mjs +1332 -0
  93. package/scripts/force-with-lease-reason-prose.test.mjs +184 -0
  94. package/scripts/frontmatter-allowlist.json +64 -0
  95. package/scripts/frontmatter-check.mjs +256 -0
  96. package/scripts/frontmatter-check.test.mjs +436 -0
  97. package/scripts/git-env.mjs +124 -0
  98. package/scripts/git-env.test.mjs +149 -0
  99. package/scripts/git-status-untracked-mode-sweep.test.mjs +216 -0
  100. package/scripts/gone-walk.test.mjs +213 -0
  101. package/scripts/gp-sep-invariant-prose.test.mjs +188 -0
  102. package/scripts/head-moved-after-label-prose.test.mjs +233 -0
  103. package/scripts/immutable-body-claim-prose.test.mjs +413 -0
  104. package/scripts/implementer-model-tier.test.mjs +643 -0
  105. package/scripts/inflight-citation-prose.test.mjs +144 -0
  106. package/scripts/inflight-exit2-prose.test.mjs +81 -0
  107. package/scripts/inflight-probe-guard-prose.test.mjs +109 -0
  108. package/scripts/inflight-scan-scope-prose.test.mjs +57 -0
  109. package/scripts/inflight.sh +1106 -0
  110. package/scripts/inflight.test.mjs +2984 -0
  111. package/scripts/injection-control-prose.test.mjs +404 -0
  112. package/scripts/install-root-audit.test.mjs +464 -0
  113. package/scripts/instrument-check-prose.test.mjs +235 -0
  114. package/scripts/instruments.sh +394 -0
  115. package/scripts/instruments.test.mjs +787 -0
  116. package/scripts/issue-tracker-prose.test.mjs +71 -0
  117. package/scripts/json.sh +248 -0
  118. package/scripts/json.test.mjs +364 -0
  119. package/scripts/ledger-dispatch.test.mjs +516 -0
  120. package/scripts/ledger-grammar.mjs +85 -0
  121. package/scripts/ledger-grammar.test.mjs +142 -0
  122. package/scripts/ledger-read-require-file.test.mjs +197 -0
  123. package/scripts/ledger.mjs +1753 -0
  124. package/scripts/ledger.test.mjs +3554 -0
  125. package/scripts/line-distance-prose.test.mjs +245 -0
  126. package/scripts/liveness-rationale-prose.test.mjs +83 -0
  127. package/scripts/locale-pin-prose.test.mjs +189 -0
  128. package/scripts/member-outcome-prose.test.mjs +167 -0
  129. package/scripts/member-outcomes-header.test.mjs +148 -0
  130. package/scripts/member-outcomes-prose.test.mjs +63 -0
  131. package/scripts/member-outcomes.mjs +231 -0
  132. package/scripts/member-outcomes.test.mjs +507 -0
  133. package/scripts/member-prompt-prose.test.mjs +161 -0
  134. package/scripts/member-record.mjs +605 -0
  135. package/scripts/member-record.test.mjs +516 -0
  136. package/scripts/member-write-guard.mjs +279 -0
  137. package/scripts/member-write-guard.test.mjs +211 -0
  138. package/scripts/merge-commit-probe-prose.test.mjs +122 -0
  139. package/scripts/merge-gate.mjs +262 -0
  140. package/scripts/merge-gate.test.mjs +613 -0
  141. package/scripts/muted-git-guard-sweep.test.mjs +493 -0
  142. package/scripts/net-ssh-precedence-prose.test.mjs +91 -0
  143. package/scripts/net-watchdog-prose.test.mjs +79 -0
  144. package/scripts/net.sh +409 -0
  145. package/scripts/net.test.mjs +211 -0
  146. package/scripts/no-ci-gate-prose.test.mjs +108 -0
  147. package/scripts/no-undo-audit.sh +1134 -0
  148. package/scripts/no-undo-audit.test.mjs +3965 -0
  149. package/scripts/no-wave.test.mjs +138 -0
  150. package/scripts/node-floor-sweep.test.mjs +611 -0
  151. package/scripts/pointer-target-prose.test.mjs +186 -0
  152. package/scripts/pr-overlap.mjs +417 -0
  153. package/scripts/pr-overlap.test.mjs +695 -0
  154. package/scripts/printf-die-sweep.test.mjs +384 -0
  155. package/scripts/prompt-renderer.mjs +39 -0
  156. package/scripts/prompt-renderer.test.mjs +68 -0
  157. package/scripts/prose-pin.mjs +808 -0
  158. package/scripts/prose-pin.test.mjs +1034 -0
  159. package/scripts/prove-merge.sh +228 -0
  160. package/scripts/prove-merge.test.mjs +995 -0
  161. package/scripts/pull-table-relabel-prose.test.mjs +60 -0
  162. package/scripts/quiet-payload-prose.test.mjs +222 -0
  163. package/scripts/reap.sh +1768 -0
  164. package/scripts/reap.test.mjs +4395 -0
  165. package/scripts/reaping-prose.test.mjs +159 -0
  166. package/scripts/refuter-scratch-prose.test.mjs +135 -0
  167. package/scripts/release-label-required-prose.test.mjs +71 -0
  168. package/scripts/release-label-split-prose.test.mjs +169 -0
  169. package/scripts/release-ticket.sh +1716 -0
  170. package/scripts/release-ticket.test.mjs +5106 -0
  171. package/scripts/renovate-release-contract.test.mjs +379 -0
  172. package/scripts/repo-root.mjs +544 -0
  173. package/scripts/repo-root.test.mjs +873 -0
  174. package/scripts/reporter-output-rule-prose.test.mjs +208 -0
  175. package/scripts/review-agent-report-only.test.mjs +49 -0
  176. package/scripts/review-core-cwd-isolation.test.mjs +374 -0
  177. package/scripts/review-core-reads.test.mjs +478 -0
  178. package/scripts/review-core-refuter-scratch.test.mjs +148 -0
  179. package/scripts/review-core-snapshot-path.test.mjs +777 -0
  180. package/scripts/review-core-specialist-scratch.test.mjs +189 -0
  181. package/scripts/review-core-testcmd.test.mjs +288 -0
  182. package/scripts/review-core-unrun.test.mjs +530 -0
  183. package/scripts/review-core-unverified-discriminant.test.mjs +208 -0
  184. package/scripts/review-core.mjs +1028 -0
  185. package/scripts/review-eval-resolver-path.test.mjs +55 -0
  186. package/scripts/review-eval.mjs +197 -0
  187. package/scripts/review-host-fixture.mjs +73 -0
  188. package/scripts/review-in-run-retry.test.mjs +187 -0
  189. package/scripts/review-no-vendor-dispatch.test.mjs +45 -0
  190. package/scripts/review-path-default.test.mjs +796 -0
  191. package/scripts/review-runner-spawns.test.mjs +93 -0
  192. package/scripts/review-runner.test.mjs +155 -0
  193. package/scripts/review-tier-audit.test.mjs +140 -0
  194. package/scripts/run-artifact-pr-prose.test.mjs +341 -0
  195. package/scripts/run-merge-bot-prose.test.mjs +1391 -0
  196. package/scripts/scratch-partition-invariant-prose.test.mjs +74 -0
  197. package/scripts/scripts-path-citation-sweep.test.mjs +73 -0
  198. package/scripts/section-between-guard-prose.test.mjs +378 -0
  199. package/scripts/select-dimensions.test.mjs +674 -0
  200. package/scripts/shared-refusal.test.mjs +388 -0
  201. package/scripts/shell-traps-prose.test.mjs +507 -0
  202. package/scripts/shortlist.mjs +355 -0
  203. package/scripts/shortlist.test.mjs +366 -0
  204. package/scripts/slow-transport.mjs +72 -0
  205. package/scripts/snapshot-repo.test.mjs +772 -0
  206. package/scripts/snapshot-runner-audience-prose.test.mjs +129 -0
  207. package/scripts/spend-view.test.mjs +312 -0
  208. package/scripts/staleness-qualifier-prose.test.mjs +251 -0
  209. package/scripts/staleness-verdict-prose.test.mjs +142 -0
  210. package/scripts/staleness.mjs +414 -0
  211. package/scripts/staleness.test.mjs +893 -0
  212. package/scripts/stalled-member-liveness-prose.test.mjs +219 -0
  213. package/scripts/stash-prohibition-prose.test.mjs +313 -0
  214. package/scripts/strip-comments.mjs +44 -0
  215. package/scripts/tier-check.mjs +468 -0
  216. package/scripts/tier-check.test.mjs +726 -0
  217. package/scripts/tier-guard-gate-prose.test.mjs +216 -0
  218. package/scripts/tier-outcomes-header.test.mjs +586 -0
  219. package/scripts/tier-outcomes.mjs +441 -0
  220. package/scripts/tier-outcomes.test.mjs +342 -0
  221. package/scripts/tier-roles.mjs +250 -0
  222. package/scripts/tier-roles.test.mjs +316 -0
  223. package/scripts/tracker-block-copy-prose.test.mjs +288 -0
  224. package/scripts/triage-labels-gloss-prose.test.mjs +97 -0
  225. package/scripts/unattended-git-sweep.test.mjs +142 -0
  226. package/scripts/verify-sha-exit2-prose.test.mjs +269 -0
  227. package/scripts/verify-sha.sh +117 -0
  228. package/scripts/verify-sha.test.mjs +693 -0
  229. package/scripts/watcher-degraded-block.test.mjs +372 -0
  230. package/scripts/watcher-key-prose.test.mjs +106 -0
  231. package/scripts/within-run-pair-prose.test.mjs +208 -0
  232. package/scripts/worktree-audit.sh +482 -0
  233. package/scripts/worktree-audit.test.mjs +1407 -0
  234. package/scripts/worktree-head-prose.test.mjs +276 -0
  235. package/scripts/worktree-listing-sweep.test.mjs +217 -0
  236. package/scripts/worktree-model-prose.test.mjs +216 -0
  237. package/scripts/worktree.sh +470 -0
  238. package/skills/next-ticket/SKILL.md +138 -0
  239. package/skills/run-team/SKILL.md +3603 -0
  240. package/skills/run-team/references/ci-and-staleness.md +75 -0
  241. package/skills/run-team/references/correction-tickets.md +37 -0
  242. package/skills/run-team/references/isolation.md +23 -0
  243. package/skills/run-team/references/member-lifecycle.md +73 -0
  244. package/skills/run-team/references/reaping.md +73 -0
  245. package/skills/sizing-a-ticket/SKILL.md +39 -0
@@ -0,0 +1,530 @@
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, paragraph, phrase, stripSlashGutter } from "./prose-pin.mjs";
7
+ import { unrunReason, unrunEntries, unrunCrashed, FINDINGS_SCHEMA } from "./review-core.mjs";
8
+
9
+ // A dimension that crashed and a dimension that ran clean returned BYTE-
10
+ // IDENTICAL shapes: `findings: []` either way, with the key listed in
11
+ // `dimensionsRun` regardless (#137, #138). Nothing in this suite could see
12
+ // that mode — no test touched `FINDINGS_SCHEMA` or the verify stage's falsy-
13
+ // review branch at all — so a green run said nothing about it. This file is
14
+ // that missing eye.
15
+ //
16
+ // Pins read CODE, not SOURCE, wherever they read source text at all:
17
+ // `stripComments` exists because two pins in this directory were MEASURED
18
+ // vacuous against a field commented out with `/* */` (see strip-comments.mjs),
19
+ // and a schema pin written against raw source passes with the field dead under
20
+ // `additionalProperties: false`.
21
+ const REPO = join(import.meta.dirname, "..");
22
+ const SOURCE = readFileSync(join(REPO, "scripts", "review-core.mjs"), "utf8");
23
+ const CODE = stripComments(SOURCE);
24
+
25
+ // #138's case. The `review &&` guard the ticket cites proves the author already
26
+ // expects a falsy return here — spend limit, timeout, terminal error — and the
27
+ // `[]` it produced was indistinguishable from a clean pass.
28
+ test("a reviewer that returned nothing is unrun, and says why it might have", () => {
29
+ for (const dead of [null, undefined, false, 0, ""]) {
30
+ const reason = unrunReason(dead);
31
+ assert.equal(typeof reason, "string", `a falsy review (${JSON.stringify(dead)}) must yield a reason`);
32
+ assert.match(reason, /returned nothing/, "the reason no longer names a reviewer that returned nothing");
33
+ }
34
+ });
35
+
36
+ // #137's case: the `'tests 0'` reading rule the specialist prompt already
37
+ // states, given somewhere to land. The reason names the COMMAND, because
38
+ // "0 tests" without it sends a reader hunting for which command produced them.
39
+ test("a zero-test run is unrun, naming the command that produced no tests", () => {
40
+ const reason = unrunReason({
41
+ dimension: "tests",
42
+ scope_searched: "the whole snapshot",
43
+ findings: [],
44
+ test_run: { command: "npm test --", tests: 0, pass: 0, fail: 0 },
45
+ });
46
+ assert.equal(typeof reason, "string", "a zero-test run must yield a reason");
47
+ assert.match(reason, /npm test --/, "the reason no longer names the command that produced no tests");
48
+ });
49
+
50
+ // ABSENT or null is the same fact as `tests: 0` — nothing ran — and it is the
51
+ // whole reason the check is `!run.tests` rather than `run.tests === 0`. Measured
52
+ // unpinned: the narrower comparison passed all 737 tests in the repo.
53
+ test("a test_run that reported no count at all is unrun", () => {
54
+ for (const run of [{ command: "npm test --" }, { command: "npm test --", tests: null }]) {
55
+ const reason = unrunReason({ dimension: "tests", scope_searched: "x", findings: [], test_run: run });
56
+ assert.equal(typeof reason, "string", `a countless test_run (${JSON.stringify(run)}) must yield a reason`);
57
+ }
58
+ });
59
+
60
+ // A specialist that ignored the schema is the same fact from a different
61
+ // cause, and must not read as covered because the field it skipped is the one
62
+ // being tested.
63
+ test("a review reporting no test run at all is unrun", () => {
64
+ const reason = unrunReason({ dimension: "types", scope_searched: "src/", findings: [] });
65
+ assert.equal(typeof reason, "string", "a missing test_run must yield a reason");
66
+ assert.match(reason, /no test run/, "the reason no longer says the reviewer reported no test run");
67
+ });
68
+
69
+ // THE REFUSAL SURFACE, and the half a suite fed only broken input cannot pin.
70
+ // A new required field and a new unrun predicate are both refusal surfaces: a
71
+ // specialist that legitimately has nothing to report must still come back
72
+ // clean. Marking a genuinely clean dimension unrun re-runs work that was done
73
+ // and teaches a controller to ignore the field — the same end state as not
74
+ // having it.
75
+ test("a clean review with an empty findings list is NOT unrun", () => {
76
+ assert.equal(
77
+ unrunReason({
78
+ dimension: "silent-failure",
79
+ scope_searched: "grep -rn 'catch' over the diff's 4 files",
80
+ findings: [],
81
+ test_run: { command: "npm test --", tests: 12, pass: 12, fail: 0 },
82
+ }),
83
+ null,
84
+ "a dimension that ran the suite and found nothing is clean, not unrun",
85
+ );
86
+ });
87
+
88
+ // A suite with real failures RAN. Reading `fail > 0` as unrun would hide the
89
+ // one class of test result that most needs reporting.
90
+ test("a run with failing tests is NOT unrun", () => {
91
+ assert.equal(
92
+ unrunReason({
93
+ dimension: "tests",
94
+ scope_searched: "the snapshot's own suite",
95
+ findings: [{ severity: "critical", claim: "x", evidence: "y" }],
96
+ test_run: { command: "npm test --", tests: 14, pass: 11, fail: 3 },
97
+ }),
98
+ null,
99
+ "a suite that reported failures still ran",
100
+ );
101
+ });
102
+
103
+ // #143's all-skipped case, and the reason the clause reads `pass === 0 && !fail`
104
+ // rather than the bare "zero passes" #143's body proposes. `skipped` is NOT a
105
+ // declared field of `test_run` (see the schema pin below), and whether
106
+ // `additionalProperties: false` drops such a field or rejects the whole object
107
+ // is stated BOTH ways in this directory and is not settled here — either way it
108
+ // never reaches this classifier, so a run where every test skipped can only
109
+ // arrive as `pass: 0` with `fail` zero or absent. Nothing passed and nothing
110
+ // failed is no work done.
111
+ // BOTH arms of `findings`, because this clause is findings-INDEPENDENT by
112
+ // design and only a non-empty fixture says so. The sibling `fail > 0` clause
113
+ // below is the one that reads `findings`; ANDing `!review.findings?.length` in
114
+ // here too would let a specialist that reports 0 passes and 0 fails and attaches
115
+ // one filler finding read as clean — the loophole #143 exists to close. Every
116
+ // fixture here sent `[]`, so that mutation survived the whole suite.
117
+ test("a run where nothing passed and nothing failed is unrun — every test skipped", () => {
118
+ for (const findings of [[], [{ severity: "suggestion", claim: "x", evidence: "y" }]]) {
119
+ for (const run of [
120
+ { command: "node --test", tests: 2, pass: 0, fail: 0 },
121
+ { command: "node --test", tests: 2, pass: 0 },
122
+ ]) {
123
+ const reason = unrunReason({ dimension: "tests", scope_searched: "x", findings, test_run: run });
124
+ const where = `${JSON.stringify(run)} with ${findings.length} findings`;
125
+ assert.equal(typeof reason, "string", `an all-skipped run (${where}) must yield a reason`);
126
+ assert.match(reason, /node --test/, "the reason no longer names the command that did no work");
127
+ }
128
+ }
129
+ });
130
+
131
+ // #651: the clause above fired at EXACTLY zero, so one executed test bought a
132
+ // clean read — `tests 937 / pass 1 / fail 0` is a crash mid-suite, not a pass.
133
+ // The `pass` variants are the two shapes a no-failure run arrives in (`fail: 0`
134
+ // and `fail` absent, both falsy); the fixture with a finding attached is there
135
+ // for the same reason the all-skipped one is — this clause is findings-
136
+ // INDEPENDENT, and every fixture sending `[]` is how that mutation survives.
137
+ test("a run that executed a fraction of what it collected is unrun, not clean", () => {
138
+ for (const findings of [[], [{ severity: "suggestion", claim: "x", evidence: "y" }]]) {
139
+ for (const run of [
140
+ { command: "node --test", tests: 937, pass: 1, fail: 0 },
141
+ { command: "node --test", tests: 937, pass: 1 },
142
+ { command: "node --test", tests: 937, pass: 468, fail: 0 },
143
+ ]) {
144
+ const reason = unrunReason({ dimension: "tests", scope_searched: "x", findings, test_run: run });
145
+ const where = `${JSON.stringify(run)} with ${findings.length} findings`;
146
+ assert.equal(typeof reason, "string", `a mostly-unexecuted run (${where}) must yield a reason`);
147
+ assert.match(reason, /node --test/, "the reason no longer names the command that ran a fraction of its collection");
148
+ assert.match(reason, new RegExp(`${run.pass}\\b.*\\b${run.tests}\\b`), "the reason no longer reports both counts");
149
+ }
150
+ }
151
+ });
152
+
153
+ // THE ACCEPT SIDE of #651's ratio, and the half a refuse-only pin cannot hold. A
154
+ // small suite is not a partial one: 3 of 3 is every test the tree has. The `todo`
155
+ // fixture is the MEASURED hazard the issue names — `node --test` counts a todo
156
+ // outside `pass` (tests 2 / pass 1 / fail 0 / todo 1), so a strict
157
+ // `pass + fail === tests` rule would refuse any host repo carrying one, and a
158
+ // floor at exactly half is what keeps it clean. `pass: null` is the optional
159
+ // field arriving explicitly empty: `null * 2 < tests` is 0 < tests, so only the
160
+ // `typeof` guard stops that from reading as no work.
161
+ test("a small-but-complete run, a half-todo run, and one that omitted pass are NOT unrun", () => {
162
+ for (const run of [
163
+ { command: "node --test", tests: 3, pass: 3, fail: 0 },
164
+ { command: "node --test", tests: 937, pass: 937, fail: 0 },
165
+ { command: "node --test", tests: 2, pass: 1, fail: 0 },
166
+ { command: "node --test", tests: 937, pass: null },
167
+ ]) {
168
+ assert.equal(
169
+ unrunReason({ dimension: "tests", scope_searched: "the snapshot's own suite", findings: [], test_run: run }),
170
+ null,
171
+ `a run that did its work (${JSON.stringify(run)}) must stay clean`,
172
+ );
173
+ }
174
+ });
175
+
176
+ // The ratio must not swallow a failing suite that actually EXECUTED its whole
177
+ // collection: pass+fail equals tests here, so every test collected ran, and
178
+ // refusing it would be the over-refusal #137 removed — reached only because
179
+ // this fixture files findings, which is what keeps the sibling clause below
180
+ // off it.
181
+ test("a fully-executed failing run is NOT unrun by the ratio — a suite that failed ran", () => {
182
+ assert.equal(
183
+ unrunReason({
184
+ dimension: "tests",
185
+ scope_searched: "the snapshot's own suite",
186
+ findings: [{ severity: "critical", claim: "x", evidence: "y" }],
187
+ test_run: { command: "node --test", tests: 10, pass: 4, fail: 6 },
188
+ }),
189
+ null,
190
+ "a suite that reported failures still ran, having executed everything it collected",
191
+ );
192
+ });
193
+
194
+ // #651 CONTINUED: the ratio clause above was gated on `!run.fail`, so a crash
195
+ // that left even ONE failing test alongside its one pass skipped it entirely
196
+ // and fell to the CONJUNCTION clause below, which one filed finding defeats —
197
+ // `{tests:937, pass:1, fail:1}` plus a finding read clean, 935 of 937 never
198
+ // run. The ratio now sums pass AND fail against the same half floor, findings-
199
+ // INDEPENDENT for the same reason the fail-free ratio test above is.
200
+ test("a run that executed a fraction of what it collected through a MIX of pass and fail is unrun", () => {
201
+ for (const findings of [[], [{ severity: "suggestion", claim: "x", evidence: "y" }]]) {
202
+ for (const run of [
203
+ { command: "node --test", tests: 937, pass: 1, fail: 1 },
204
+ { command: "node --test", tests: 937, pass: 200, fail: 200 },
205
+ ]) {
206
+ const reason = unrunReason({ dimension: "tests", scope_searched: "x", findings, test_run: run });
207
+ const where = `${JSON.stringify(run)} with ${findings.length} findings`;
208
+ assert.equal(typeof reason, "string", `a mostly-unexecuted mixed run (${where}) must yield a reason`);
209
+ assert.match(reason, /node --test/, "the reason no longer names the command that ran a fraction of its collection");
210
+ }
211
+ }
212
+ });
213
+
214
+ // THE ACCEPT SIDE of the mixed-ratio test above: pass+fail reaching past half
215
+ // of tests is work done, whatever the split between the two. A finding is
216
+ // attached so the sibling CONJUNCTION clause (`fail > 0 && no findings`)
217
+ // cannot be the thing keeping this clean — only the ratio is under test here.
218
+ test("a mixed pass/fail run that executed past half its collection is NOT unrun", () => {
219
+ assert.equal(
220
+ unrunReason({
221
+ dimension: "tests",
222
+ scope_searched: "the snapshot's own suite",
223
+ findings: [{ severity: "critical", claim: "x", evidence: "y" }],
224
+ test_run: { command: "node --test", tests: 937, pass: 300, fail: 300 },
225
+ }),
226
+ null,
227
+ "a mixed run past the half floor did its work",
228
+ );
229
+ });
230
+
231
+ // THE ACCEPT SIDE of the clause above, and the case a bare `pass 0` rule gets
232
+ // wrong: a suite where every test failed also reports zero passes, and it is the
233
+ // run that most needs reporting — refusing it is the over-refusal #137 removed.
234
+ // The `fail > 0` pin above cannot stand in for this one. Its fixture passes 11
235
+ // tests, so it stays clean whether the clause reads `pass === 0` or
236
+ // `pass === 0 && !fail`; only a fixture with BOTH zero passes and failures can
237
+ // tell those two apart.
238
+ test("a run where every test failed is NOT unrun, even though nothing passed", () => {
239
+ assert.equal(
240
+ unrunReason({
241
+ dimension: "tests",
242
+ scope_searched: "the snapshot's own suite",
243
+ findings: [{ severity: "critical", claim: "x", evidence: "y" }],
244
+ test_run: { command: "npm test --", tests: 3, pass: 0, fail: 3 },
245
+ }),
246
+ null,
247
+ "a suite that reported only failures still ran",
248
+ );
249
+ });
250
+
251
+ // #143's third case, deferred there from the #526 review. `fail > 0` on its own
252
+ // is a suite that ran, pinned clean above and deliberately so; the contradiction
253
+ // is the CONJUNCTION with an empty findings list — the suite ran, it reported
254
+ // failures, and the reviewer filed nothing about them. `findings` is required by
255
+ // the schema, so the undefined arm covers a specialist that ignored it rather
256
+ // than a shape the schema permits.
257
+ test("a run with failing tests and no findings at all is unrun", () => {
258
+ for (const findings of [[], undefined]) {
259
+ const reason = unrunReason({
260
+ dimension: "tests",
261
+ scope_searched: "the snapshot's own suite",
262
+ findings,
263
+ test_run: { command: "node --test", tests: 744, pass: 738, fail: 6 },
264
+ });
265
+ assert.equal(typeof reason, "string", `fail>0 with findings ${JSON.stringify(findings)} must yield a reason`);
266
+ assert.match(reason, /6 failing tests/, "the reason no longer says how many tests failed unreported");
267
+ }
268
+ });
269
+
270
+ // `pass`/`fail` are optional (see the schema pin below), so a run that reported
271
+ // only a count must still come back clean rather than tripping the predicate on
272
+ // a field it was never required to send.
273
+ test("a run that reported tests but not pass/fail is NOT unrun", () => {
274
+ assert.equal(
275
+ unrunReason({
276
+ dimension: "comments",
277
+ scope_searched: "every added comment in the diff",
278
+ findings: [],
279
+ test_run: { command: "node --test", tests: 7 },
280
+ }),
281
+ null,
282
+ "an optional field's absence must not mark a real run unrun",
283
+ );
284
+ });
285
+
286
+ // #139: the description at `:37` called `scope_searched` **Required** while the
287
+ // `required` array omitted it, so a specialist that skipped it validated clean —
288
+ // reproducing the exact failure the description exists to prevent. Both halves
289
+ // pinned, because either one alone re-opens the ticket.
290
+ test("scope_searched is in the required array, not only in its own description", () => {
291
+ const { required } = FINDINGS_SCHEMA;
292
+ assert.ok(Array.isArray(required), "FINDINGS_SCHEMA no longer has a top-level required array — update this test");
293
+ assert.ok(required.includes("scope_searched"), "scope_searched is documented Required and is not in the required array (#139)");
294
+ assert.ok(required.includes("test_run"), "test_run is not required, so an unrun dimension can still return a clean-looking object (#137)");
295
+ });
296
+
297
+ // `additionalProperties: false` REJECTS an undeclared field, so a `required`
298
+ // entry whose property is not declared is worse than neither: the specialist is
299
+ // forced to send a field the schema then drops. Both halves, one pin.
300
+ test("test_run is declared, carries the command and count, and does not force pass/fail", () => {
301
+ const testRun = FINDINGS_SCHEMA.properties.test_run;
302
+ assert.ok(testRun, "test_run is not declared in FINDINGS_SCHEMA's properties — additionalProperties:false drops it");
303
+ for (const field of ["command", "tests", "pass", "fail"]) {
304
+ assert.ok(testRun.properties[field], `test_run no longer declares ${field}`);
305
+ }
306
+ assert.ok(Array.isArray(testRun.required), "test_run no longer names which of its fields are required — update this test");
307
+ assert.ok(testRun.required.includes("command"), "test_run.command must be required — a count with no command bounds nothing");
308
+ assert.ok(testRun.required.includes("tests"), "test_run.tests must be required — it is the field the unrun rule reads");
309
+ // A runner whose output does not split pass from fail must not be forced to
310
+ // invent numbers: an unanswerable required field is answered with a guess,
311
+ // and a guessed count is worse than an absent one.
312
+ for (const optional of ["pass", "fail"]) {
313
+ assert.ok(!testRun.required.includes(optional), `${optional} must stay optional — see the comment above this assertion`);
314
+ }
315
+ });
316
+
317
+ // Wiring, not classification. `unrunReason` can be correct and reach nobody:
318
+ // the review object it reads is in scope for exactly one closure — the verify
319
+ // stage's `(review, d)` — and `reviewed` below is findings, flattened, with the
320
+ // per-dimension envelope already gone. If the recording is not in that closure
321
+ // it cannot be anywhere.
322
+ function verifyStage() {
323
+ return between(CODE, "(review, d) =>", "const n = verifiersFor", "the verify stage");
324
+ }
325
+
326
+ // The entry, not the call site. `unrunEntries` returns zero or one, so both
327
+ // writers `push(...)` it with no guard of their own — and a guard is exactly what
328
+ // the predecessor of this test could not see: it compared the source positions of
329
+ // two substrings, so wrapping the recording in `if (review && why)` left both in
330
+ // place, kept the suite green, and silently dropped every crashed dimension.
331
+ test("an unrun classification becomes an entry with no guard for a caller to get wrong", () => {
332
+ const entries = unrunEntries(null, "tests");
333
+ assert.equal(entries.length, 1, "a falsy review must yield exactly one entry — nothing else records #138's cause");
334
+ assert.equal(entries[0].dimension, "tests", "the entry no longer names the dimension it was asked about");
335
+ assert.match(entries[0].reason, /returned nothing/, "the entry no longer carries the classifier's reason");
336
+ assert.deepEqual(
337
+ unrunEntries(
338
+ { dimension: "tests", scope_searched: "x", findings: [], test_run: { command: "npm test --", tests: 9 } },
339
+ "tests",
340
+ ),
341
+ [],
342
+ "a covered dimension must yield NO entry — an empty push is what lets both call sites stay unguarded",
343
+ );
344
+ });
345
+
346
+ // #138's ACTUAL case, and the one its first attempt could not reach. `pipeline()`
347
+ // short-circuits between stages — the harness runs `if (result === null) break`
348
+ // before the next stage — so a reviewer that returned null never enters the verify
349
+ // closure, and a recording living there sees every dimension except the dead one.
350
+ // The pipeline's RESULT still shows it: one slot per dimension, in order, null
351
+ // where the chain died. This runs that derivation rather than reading it.
352
+ test("a dimension whose chain died is recorded unrun, by index, from the pipeline result", () => {
353
+ const dimensions = [{ key: "correctness" }, { key: "tests" }, { key: "types" }];
354
+ const unrun = unrunCrashed([[], null, []], dimensions);
355
+ assert.deepEqual(
356
+ unrun.map((u) => u.dimension),
357
+ ["tests"],
358
+ "a null pipeline slot must record ITS dimension unrun, and only it (#138)",
359
+ );
360
+ assert.match(unrun[0].reason, /returned nothing/, "the crashed dimension's reason no longer names a reviewer that returned nothing");
361
+ assert.deepEqual(
362
+ unrunCrashed([[], [], []], dimensions),
363
+ [],
364
+ "a dimension that reached the verify stage is not crashed — this must not re-refuse a clean run",
365
+ );
366
+ // An empty findings array is the SHAPE a clean dimension returns, and it is
367
+ // falsy nowhere; reading emptiness as death is the over-refusal #137 removed.
368
+ assert.deepEqual(unrunCrashed([[]], [{ key: "types" }]), [], "an empty findings list from a live dimension is not a crash");
369
+ });
370
+
371
+ // The adjacent case, which is about this derivation rather than about a reviewer:
372
+ // it runs after every specialist and refuter has finished, so a throw here costs
373
+ // the entire run's findings. A slot it cannot name must still come back named.
374
+ test("a null slot the dimension list cannot explain is still reported, never thrown on", () => {
375
+ const unrun = unrunCrashed([null], []);
376
+ assert.equal(unrun.length, 1, "a slot with no matching dimension must still be recorded unrun");
377
+ assert.match(unrun[0].dimension, /slot 0/, "an unnameable slot must say which slot it was");
378
+ });
379
+
380
+ // Wiring, not classification — and textual, because it has to be. Both writers
381
+ // are executable above; whether the SCRIPT calls them is not, since the file is a
382
+ // workflow body the harness executes and nothing here can run it. Stated ceiling:
383
+ // this sees a call deleted or moved, and does not see one wrapped in a guard of
384
+ // its own. That is why the classification moved behind two lifted functions —
385
+ // the pin it replaced had source positions as its only evidence.
386
+ test("both halves are wired in: the verify stage, and the pipeline result the stage cannot see", () => {
387
+ const stage = verifyStage();
388
+ const asked = stage.indexOf("dimensionsUnrun.push(...unrunEntries(review, d.key))");
389
+ assert.notEqual(asked, -1, "the verify stage no longer records #137's half — a reviewer that ran no suite reads clean");
390
+ const deref = stage.indexOf("review && review.findings");
391
+ assert.notEqual(deref, -1, "the findings guard moved — update this test");
392
+ assert.ok(asked < deref, "the recording sits behind the falsy-review guard, which already reads a dead reviewer as clean (#138)");
393
+ // AFTER the pipeline returns, never inside a stage: a stage cannot observe its
394
+ // own absence, which is the entire reason #138 shipped as dead code once.
395
+ const call = CODE.indexOf("const reviewed = await pipeline(");
396
+ assert.notEqual(call, -1, "the pipeline call moved — update this test");
397
+ const derived = CODE.indexOf("dimensionsUnrun.push(...unrunCrashed(reviewed, dimensions))");
398
+ assert.notEqual(derived, -1, "nothing derives the crashed dimensions from the pipeline result — #138 is unreachable again");
399
+ assert.ok(call < derived, "the derivation runs before the pipeline returns, where its result does not exist yet");
400
+ });
401
+
402
+ test("the returned object carries dimensionsUnrun alongside dimensionsRun", () => {
403
+ assert.match(CODE, /const dimensionsUnrun = \[\]/, "dimensionsUnrun is never declared — the return would throw");
404
+ const at = CODE.lastIndexOf("return {");
405
+ assert.notEqual(at, -1, "review-core.mjs no longer ends in a return literal — update this test");
406
+ const tail = CODE.slice(at);
407
+ // BOTH, adjacent. `dimensionsRun` keeps its meaning and its value — the
408
+ // dispatched set after the size trim — because a consumer diffing it against
409
+ // DEFAULT_DIMENSIONS to spot a trim would otherwise read a crashed dimension
410
+ // as a trimmed one: the same conflation this ticket set closes, one field over.
411
+ // The new list is what subtracts from it, which only works if it ships too.
412
+ assert.match(tail, /dimensionsRun: dimensions\.map\(\(d\) => d\.key\)/, "dimensionsRun no longer reports the dispatched set");
413
+ assert.match(tail, /dimensionsUnrun/, "the return never surfaces dimensionsUnrun — the classification dies in the script (#137, #138)");
414
+ });
415
+
416
+ // The schema field is inert unless the prompt points at it — the specialists
417
+ // are what fill it in, and a field nothing asks for comes back absent from
418
+ // every one of them.
419
+ //
420
+ // #143 records the gap this pin closes: `review-pr-testcmd.test.mjs` pins the
421
+ // RULING (`'tests 0' is a FAILED run`) and nothing pins the FOLLOW-THROUGH, so
422
+ // the sentence saying what to DO about a zero-test run could be deleted with
423
+ // the suite green. This edit rewrites that sentence; pin it where it now lands.
424
+ test("the specialist prompt names test_run as where a zero-test run gets reported", () => {
425
+ const prompt = between(CODE, "READ ONLY FROM THE SNAPSHOT", "Scratch files go in", "the specialist prompt");
426
+ assert.match(prompt, /test_run/, "the prompt never names test_run, so nothing fills the field the schema requires");
427
+ // The instruction that matters is reporting the run that produced NOTHING. A
428
+ // specialist that reports only successful runs leaves `test_run` absent in
429
+ // exactly the case the field exists for.
430
+ assert.match(
431
+ prompt,
432
+ /even when it (failed|produced)|produced nothing/,
433
+ "the prompt no longer tells specialists to report a run that failed or produced nothing",
434
+ );
435
+ });
436
+
437
+ // The workflow's return shape is documented in one place a controller actually
438
+ // reads, and this repo's recurring defect is a second copy disconnecting in one
439
+ // token. A `dimensionsUnrun` nobody is told to read is a field nobody reads.
440
+ test("run-team's Reviewers section documents dimensionsUnrun, not only dimensionsRun", () => {
441
+ const doc = readFileSync(join(REPO, "skills", "run-team", "SKILL.md"), "utf8");
442
+ assert.match(doc, /dimensionsUnrun/, "run-team/SKILL.md still documents a return shape without dimensionsUnrun");
443
+ // The superseded workaround must be GONE, not merely accompanied. It reads
444
+ // every zero-finding dimension as unrun — including one that ran clean — so
445
+ // leaving it in place next to the real field teaches the opposite rule.
446
+ assert.doesNotMatch(
447
+ doc,
448
+ /a dimension listed\s+in `dimensionsRun` with nothing in `survived`\/`refuted`\/`unverified` is \*\*unrun,\s+not clean\*\*/,
449
+ "run-team/SKILL.md still states the pre-#137 workaround, which marks a clean dimension unrun",
450
+ );
451
+ });
452
+
453
+ // What the absence of an unrun classification ESTABLISHES is that a suite ran —
454
+ // never that the dimension is covered. `unrunReason` above reads `test_run`'s
455
+ // counts and quotes `command` into its message; it never compares that command
456
+ // against the one the dispatch handed out, so a specialist that substituted a
457
+ // narrower runner reports a non-zero count, is not classified unrun, and reads
458
+ // as covered having validated a fraction of the suite. Comparing the two was
459
+ // refuted 2-0 and stays refuted (#535) — the doc claiming only what the
460
+ // classifier can see is the remedy, and nothing pinned the word it turns on.
461
+ //
462
+ // The positive pin carries the claim: sliced to the paragraph so a failure
463
+ // prints it rather than the whole 2000-line doc, matched through `phrase` so a
464
+ // reflow of the hard wrap cannot fire it, and run out to the sentence's `;` so
465
+ // the clause has to END there. That terminator is what catches the likelier
466
+ // regression — an editor softening rather than reverting, `ran a suite AND IS
467
+ // THEREFORE COVERED` — which a pin on the anchor alone reads as still present.
468
+ // The exclusion then has nothing left to guess at, so it stays whole-doc and
469
+ // case-insensitive: the retracted claim is caught wherever in the file it comes
470
+ // back, and in the lowercase paraphrase a `phrase` pin on `NOT` walks past.
471
+ // Measured both ways — each form reds, and a reflow, a `; every` → `; each`
472
+ // reword, and a correctly negated coverage sentence in the paragraph stay green.
473
+ test("run-team claims a suite RAN from a key's absence from dimensionsUnrun, never that it is covered", () => {
474
+ const doc = readFileSync(join(REPO, "skills", "run-team", "SKILL.md"), "utf8");
475
+ const para = between(doc, "**`dimensionsRun` is the dispatch", "The rule this replaces", "run-team/SKILL.md");
476
+ assert.match(
477
+ para,
478
+ phrase("and NOT in `dimensionsUnrun` ran a suite;"),
479
+ "run-team/SKILL.md no longer says a key absent from dimensionsUnrun ran a suite, full stop",
480
+ );
481
+ assert.doesNotMatch(
482
+ doc,
483
+ /in\s+`dimensionsUnrun`\s+is\s+covered/i,
484
+ "run-team/SKILL.md reads a key's absence from dimensionsUnrun as coverage — the classifier never checked the command that ran",
485
+ );
486
+ });
487
+
488
+ // The same claim on the OTHER surface, and the half nothing was watching. The
489
+ // pin above reads run-team/SKILL.md only, so when #535 corrected the doc, the
490
+ // classifier's own comment kept asserting the retracted equivalence — "a key in
491
+ // the first and not the second is the only thing that means covered" — and this
492
+ // suite stayed green on it (#1143). Source is where a reader arrives BEFORE the
493
+ // doc, so it is the copy that gets to mislead first.
494
+ //
495
+ // Reads SOURCE, not CODE — inverting this file's header rule, for that rule's
496
+ // own reason. `stripComments` exists so that no pin can be satisfied by
497
+ // commented-out text; here the comment IS the subject, and CODE has it stripped
498
+ // to nothing, which would make this pin unsatisfiable rather than vacuous.
499
+ //
500
+ // `stripSlashGutter` first, and it buys BOTH halves: the clause wraps
501
+ // mid-sentence at a `// ` that `phrase`'s `\s+` cannot span, and the block's
502
+ // bare `//` separator line becomes a real blank line — which is what lets the
503
+ // SHARED `paragraph` bound apply here instead of a local copy of
504
+ // quiet-payload-prose.test.mjs's comment-block-above slicer, `paragraph`'s own
505
+ // doc-comment being where this repo says a local copy is the defect, not a
506
+ // style choice. Slice and anchor are then the sibling pin's exactly:
507
+ // `anchorAt`'s exactly-once guarantee, and an end bound at the paragraph rather
508
+ // than one running past the block into the `return` below it.
509
+ //
510
+ // The positive pin runs out through `(#535).` for the SKILL.md pin's reason —
511
+ // the likelier regression is an editor softening rather than reverting, and a
512
+ // pin stopping at `ran a suite` reads `ran a suite and is therefore covered` as
513
+ // still present. The exclusion is whole-file and case-insensitive so the
514
+ // retracted wording is caught wherever it comes back, and it targets `only
515
+ // thing that means covered` rather than `covered` alone so the paragraph's own
516
+ // correct denials — which must keep saying the word — stay green.
517
+ test("review-core.mjs's own comment claims a suite RAN from a key's absence from dimensionsUnrun, never that it is covered", () => {
518
+ const prose = stripSlashGutter(SOURCE);
519
+ const para = paragraph(prose, "`dimensionsRun` names what was DISPATCHED", "review-core.mjs");
520
+ assert.match(
521
+ para,
522
+ phrase("A key in the first and NOT in the second ran a suite — not that it is covered (#535)."),
523
+ "review-core.mjs's dimensionsRun/dimensionsUnrun comment no longer says a key absent from dimensionsUnrun ran a suite, full stop",
524
+ );
525
+ assert.doesNotMatch(
526
+ prose,
527
+ /only\s+thing\s+that\s+means\s+covered/i,
528
+ "review-core.mjs is back to reading a key's absence from dimensionsUnrun as coverage — `unrunReason` never compares `run.command` against the command the dispatch handed out (#535)",
529
+ );
530
+ });