@feigi/fleet-ctl 3.23.36 → 3.23.38

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 (205) hide show
  1. package/package.json +1 -1
  2. package/scripts/cell-readout.mjs +38 -11
  3. package/scripts/main-checkout.mjs +1 -1
  4. package/scripts/member-write-guard.mjs +1 -1
  5. package/scripts/repo-root.mjs +1 -1
  6. package/skills/run-team/references/reaping.md +1 -1
  7. package/scripts/agent-test-dir-prose.test.mjs +0 -59
  8. package/scripts/agent-test.test.mjs +0 -1640
  9. package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
  10. package/scripts/ambient-git-vars-prose.test.mjs +0 -192
  11. package/scripts/ancestry-check-position-prose.test.mjs +0 -175
  12. package/scripts/apply-ruleset.test.mjs +0 -421
  13. package/scripts/arg-header-probes-prose.test.mjs +0 -394
  14. package/scripts/arg.test.mjs +0 -1354
  15. package/scripts/board-cli.test.mjs +0 -710
  16. package/scripts/board-identity.test.mjs +0 -429
  17. package/scripts/board-liveness-banner.test.mjs +0 -119
  18. package/scripts/board-prev-shape.test.mjs +0 -228
  19. package/scripts/board-tryparse-null.test.mjs +0 -119
  20. package/scripts/board.test.mjs +0 -3121
  21. package/scripts/brief-after-cut-prose.test.mjs +0 -53
  22. package/scripts/candidates-exit3-prose.test.mjs +0 -302
  23. package/scripts/candidates.test.mjs +0 -2312
  24. package/scripts/caveat-unification-prose.test.mjs +0 -98
  25. package/scripts/cell-readout.test.mjs +0 -615
  26. package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
  27. package/scripts/ci-completes-premise-prose.test.mjs +0 -257
  28. package/scripts/ci-state-prose.test.mjs +0 -113
  29. package/scripts/ci-state.test.mjs +0 -1933
  30. package/scripts/ci-vacuous-green.test.mjs +0 -368
  31. package/scripts/citation-sweep-prose.test.mjs +0 -1712
  32. package/scripts/claim-lifecycle.test.mjs +0 -187
  33. package/scripts/claim-ticket.test.mjs +0 -1122
  34. package/scripts/closing-keyword-prose.test.mjs +0 -193
  35. package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
  36. package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
  37. package/scripts/compute-board.test.mjs +0 -1214
  38. package/scripts/compute-spend.test.mjs +0 -517
  39. package/scripts/consumer-technology-prose.test.mjs +0 -126
  40. package/scripts/cross-repo-citation-prose.test.mjs +0 -155
  41. package/scripts/cwd-isolation-pins.mjs +0 -83
  42. package/scripts/dedupe-guard-prose.test.mjs +0 -243
  43. package/scripts/delete-merged-branch.test.mjs +0 -576
  44. package/scripts/derive-testcmd.test.mjs +0 -595
  45. package/scripts/diff-stats.test.mjs +0 -404
  46. package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
  47. package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
  48. package/scripts/dispositions-check.test.mjs +0 -936
  49. package/scripts/dispositions-gate-prose.test.mjs +0 -129
  50. package/scripts/drop-merged-label.test.mjs +0 -479
  51. package/scripts/exec-stub.mjs +0 -93
  52. package/scripts/exec-stub.test.mjs +0 -69
  53. package/scripts/expected-jobs-prose.test.mjs +0 -80
  54. package/scripts/fan-out-authorization-prose.test.mjs +0 -80
  55. package/scripts/filing-bar-seat-prose.test.mjs +0 -242
  56. package/scripts/filing-claim-bar-prose.test.mjs +0 -166
  57. package/scripts/finisher-died-prose.test.mjs +0 -31
  58. package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
  59. package/scripts/finisher-halt-prose.test.mjs +0 -106
  60. package/scripts/finisher-name-prose.test.mjs +0 -134
  61. package/scripts/finisher-own-tree-prose.test.mjs +0 -299
  62. package/scripts/finisher-pin-race-prose.test.mjs +0 -339
  63. package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
  64. package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
  65. package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
  66. package/scripts/fleet-bootstrap.test.mjs +0 -75
  67. package/scripts/fleet-heartbeat.test.mjs +0 -450
  68. package/scripts/fleet-provenance.test.mjs +0 -138
  69. package/scripts/fleet-run.test.mjs +0 -90
  70. package/scripts/fleet-state.test.mjs +0 -460
  71. package/scripts/fleet-tick-prose.test.mjs +0 -300
  72. package/scripts/fleet-tick.test.mjs +0 -2444
  73. package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
  74. package/scripts/frontmatter-check.test.mjs +0 -436
  75. package/scripts/git-env.test.mjs +0 -149
  76. package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
  77. package/scripts/gone-walk.test.mjs +0 -213
  78. package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
  79. package/scripts/head-moved-after-label-prose.test.mjs +0 -233
  80. package/scripts/immutable-body-claim-prose.test.mjs +0 -204
  81. package/scripts/implementer-model-tier.test.mjs +0 -235
  82. package/scripts/inflight-citation-prose.test.mjs +0 -144
  83. package/scripts/inflight-exit2-prose.test.mjs +0 -81
  84. package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
  85. package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
  86. package/scripts/inflight.test.mjs +0 -2882
  87. package/scripts/injection-control-prose.test.mjs +0 -404
  88. package/scripts/install-root-audit.test.mjs +0 -464
  89. package/scripts/instrument-check-prose.test.mjs +0 -235
  90. package/scripts/instruments.test.mjs +0 -787
  91. package/scripts/is-cli.test.mjs +0 -99
  92. package/scripts/issue-tracker-prose.test.mjs +0 -71
  93. package/scripts/json.test.mjs +0 -364
  94. package/scripts/ledger-dispatch.test.mjs +0 -927
  95. package/scripts/ledger-grammar.test.mjs +0 -227
  96. package/scripts/ledger-read-require-file.test.mjs +0 -197
  97. package/scripts/ledger-rotate.test.mjs +0 -142
  98. package/scripts/ledger.test.mjs +0 -3436
  99. package/scripts/line-distance-prose.test.mjs +0 -245
  100. package/scripts/liveness-rationale-prose.test.mjs +0 -83
  101. package/scripts/locale-pin-prose.test.mjs +0 -189
  102. package/scripts/main-checkout.test.mjs +0 -332
  103. package/scripts/member-outcome-prose.test.mjs +0 -167
  104. package/scripts/member-outcomes-header.test.mjs +0 -129
  105. package/scripts/member-outcomes-prose.test.mjs +0 -63
  106. package/scripts/member-outcomes.test.mjs +0 -638
  107. package/scripts/member-prompt-prose.test.mjs +0 -165
  108. package/scripts/member-record.test.mjs +0 -541
  109. package/scripts/member-write-guard.test.mjs +0 -214
  110. package/scripts/merge-commit-probe-prose.test.mjs +0 -122
  111. package/scripts/merge-gate.test.mjs +0 -613
  112. package/scripts/muted-git-guard-sweep.test.mjs +0 -493
  113. package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
  114. package/scripts/net-watchdog-prose.test.mjs +0 -79
  115. package/scripts/net.test.mjs +0 -211
  116. package/scripts/no-ci-gate-prose.test.mjs +0 -108
  117. package/scripts/no-undo-audit.test.mjs +0 -3961
  118. package/scripts/no-wave.test.mjs +0 -138
  119. package/scripts/node-floor-sweep.test.mjs +0 -611
  120. package/scripts/pointer-target-prose.test.mjs +0 -186
  121. package/scripts/pr-cost.test.mjs +0 -521
  122. package/scripts/pr-overlap.test.mjs +0 -692
  123. package/scripts/printf-die-sweep.test.mjs +0 -384
  124. package/scripts/prompt-renderer.mjs +0 -40
  125. package/scripts/prompt-renderer.test.mjs +0 -68
  126. package/scripts/prose-pin.mjs +0 -807
  127. package/scripts/prose-pin.test.mjs +0 -1034
  128. package/scripts/prove-merge.test.mjs +0 -995
  129. package/scripts/pull-table-relabel-prose.test.mjs +0 -60
  130. package/scripts/quiet-payload-prose.test.mjs +0 -222
  131. package/scripts/reap-cherry-check-prose.test.mjs +0 -80
  132. package/scripts/reap.test.mjs +0 -4432
  133. package/scripts/reaping-prose.test.mjs +0 -239
  134. package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
  135. package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
  136. package/scripts/recipe-derivation-prose.test.mjs +0 -112
  137. package/scripts/recipe-prove.test.mjs +0 -1042
  138. package/scripts/refuter-scratch-prose.test.mjs +0 -135
  139. package/scripts/release-label-required-prose.test.mjs +0 -71
  140. package/scripts/release-label-split-prose.test.mjs +0 -184
  141. package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
  142. package/scripts/release-ticket.test.mjs +0 -5099
  143. package/scripts/renovate-release-contract.test.mjs +0 -379
  144. package/scripts/repo-root.test.mjs +0 -873
  145. package/scripts/reporter-output-rule-prose.test.mjs +0 -208
  146. package/scripts/review-agent-report-only.test.mjs +0 -49
  147. package/scripts/review-core-booking.test.mjs +0 -35
  148. package/scripts/review-core-cwd-isolation.test.mjs +0 -374
  149. package/scripts/review-core-reads.test.mjs +0 -478
  150. package/scripts/review-core-refuter-scratch.test.mjs +0 -148
  151. package/scripts/review-core-scratch-refusal.test.mjs +0 -64
  152. package/scripts/review-core-shared-test-run.test.mjs +0 -275
  153. package/scripts/review-core-snapshot-path.test.mjs +0 -830
  154. package/scripts/review-core-specialist-scratch.test.mjs +0 -191
  155. package/scripts/review-core-testcmd.test.mjs +0 -335
  156. package/scripts/review-core-unrun.test.mjs +0 -566
  157. package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
  158. package/scripts/review-eval-resolver-path.test.mjs +0 -55
  159. package/scripts/review-host-fixture.mjs +0 -89
  160. package/scripts/review-in-run-retry.test.mjs +0 -211
  161. package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
  162. package/scripts/review-path-default.test.mjs +0 -796
  163. package/scripts/review-runner-spawns.test.mjs +0 -95
  164. package/scripts/review-runner.test.mjs +0 -166
  165. package/scripts/review-tier-audit.test.mjs +0 -140
  166. package/scripts/run-artifact-pr-prose.test.mjs +0 -341
  167. package/scripts/run-merge-bot-prose.test.mjs +0 -1413
  168. package/scripts/run-team-local-hook.test.mjs +0 -442
  169. package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
  170. package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
  171. package/scripts/section-between-guard-prose.test.mjs +0 -379
  172. package/scripts/select-dimensions.test.mjs +0 -674
  173. package/scripts/shared-refusal.test.mjs +0 -388
  174. package/scripts/shell-traps-prose.test.mjs +0 -504
  175. package/scripts/shortlist.test.mjs +0 -380
  176. package/scripts/slow-transport.mjs +0 -72
  177. package/scripts/snapshot-repo.test.mjs +0 -1006
  178. package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
  179. package/scripts/spend-view.test.mjs +0 -312
  180. package/scripts/staleness-qualifier-prose.test.mjs +0 -251
  181. package/scripts/staleness-verdict-prose.test.mjs +0 -142
  182. package/scripts/staleness.test.mjs +0 -893
  183. package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
  184. package/scripts/stash-prohibition-prose.test.mjs +0 -313
  185. package/scripts/strip-comments.mjs +0 -44
  186. package/scripts/temp-dir.mjs +0 -47
  187. package/scripts/ticket-router.test.mjs +0 -981
  188. package/scripts/tier-check.test.mjs +0 -828
  189. package/scripts/tier-outcomes-header.test.mjs +0 -518
  190. package/scripts/tier-outcomes.test.mjs +0 -572
  191. package/scripts/tier-roles.test.mjs +0 -535
  192. package/scripts/tracker-block-copy-prose.test.mjs +0 -288
  193. package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
  194. package/scripts/unattended-git-sweep.test.mjs +0 -142
  195. package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
  196. package/scripts/verify-sha.test.mjs +0 -692
  197. package/scripts/watcher-degraded-block.test.mjs +0 -369
  198. package/scripts/watcher-key-prose.test.mjs +0 -106
  199. package/scripts/within-run-pair-prose.test.mjs +0 -212
  200. package/scripts/worktree-audit.test.mjs +0 -1408
  201. package/scripts/worktree-head-prose.test.mjs +0 -276
  202. package/scripts/worktree-listing-sweep.test.mjs +0 -217
  203. package/scripts/worktree-model-prose.test.mjs +0 -216
  204. package/scripts/worktree-porcelain.mjs +0 -35
  205. package/scripts/worktree-porcelain.test.mjs +0 -102
@@ -1,53 +0,0 @@
1
- // #22. Step 2's cut to 3–5 survivors runs before step 3 ever fetches the
2
- // Agent Brief, so a candidate the Brief would have promoted into the
3
- // shortlist is dropped on step 1 data alone and never gets read. Widening
4
- // the fetch to every candidate was rejected (issue discussion): reading
5
- // comments for ~100 candidates instead of 3–5 is the cost blowup step 1
6
- // exists to avoid. This pins the documented-limitation half of the
7
- // acceptance criteria instead — the cut states, at the point it happens,
8
- // that it never sees the Brief.
9
- //
10
- // THE CEILING, same as candidates-exit3-prose.test.mjs: a PRESENCE pin over a
11
- // bounded slice. It proves the clause is there, not that nothing near it
12
- // contradicts it.
13
- import { test } from "node:test";
14
- import assert from "node:assert/strict";
15
- import { readFileSync } from "node:fs";
16
- import { join } from "node:path";
17
- import { between, phrase } from "./prose-pin.mjs";
18
-
19
- const REPO = join(import.meta.dirname, "..");
20
- const NEXT_TICKET = readFileSync(
21
- join(REPO, "skills", "next-ticket", "SKILL.md"),
22
- "utf8",
23
- );
24
-
25
- const dependenciesStep = () =>
26
- between(
27
- NEXT_TICKET,
28
- "## 2. Dependencies",
29
- "## 3. In-flight check",
30
- "next-ticket/SKILL.md",
31
- );
32
-
33
- test("the dependencies step says the cut runs on step 1 data alone, never the Agent Brief", () => {
34
- const s = dependenciesStep();
35
- assert.match(s, phrase("Cut runs on step 1 data alone"));
36
- assert.match(s, phrase("never the Agent Brief"));
37
- });
38
-
39
- test("the dependencies step still states the cut this limitation is about", () => {
40
- // The antecedent the line-41 clause depends on — without it, "never sees
41
- // the Agent Brief" is an orphaned note about a cut the doc no longer states.
42
- assert.match(dependenciesStep(), phrase("Cut to oldest 3–5 here"));
43
- });
44
-
45
- test("the dependencies step says a Brief-promoted candidate is dropped before the Brief is fetched", () => {
46
- // The consequence that makes the limitation concrete: without this an
47
- // agent reads "cut runs on step 1 data alone" as a description, not a
48
- // warning that a specific candidate can be lost to it.
49
- assert.match(
50
- dependenciesStep(),
51
- phrase("a candidate the Brief would have promoted into survivors is dropped here"),
52
- );
53
- });
@@ -1,302 +0,0 @@
1
- // #407. PR #404 gave `candidates.mjs` a third exit code and touched no document
2
- // outside the script. Every consumer-facing statement of the contract still
3
- // named two, so a model consumer meeting exit 3 had no rule for it and the
4
- // nearest rule it did have was "2 = the query broke" — the likeliest reading of
5
- // a successful all-specs query was a failed one.
6
- //
7
- // The condition these pins describe is derived from the script, not from the
8
- // ticket's paraphrase: `allFilteredOut = rawCount > 0 && rows.length === 0`
9
- // (candidates.mjs's `allFilteredOut`), reassigned WHOLESALE in the fallback
10
- // branch and never OR'd with pass 1's value, then `rows.length === 0 ?
11
- // (allFilteredOut ? 3 : 1) : 0` at that script's `process.exitCode`
12
- // assignment. So exit 3 is "the FINAL query attempt returned rows and
13
- // dropSpecs removed every one" — a labeled pass the filter emptied that falls
14
- // back to a genuinely empty unfiltered pass is exit 1, which candidates.test.mjs
15
- // pins from the other side.
16
- //
17
- // THE CEILING, same as inflight-exit2-prose.test.mjs: these are PRESENCE pins
18
- // over a bounded slice. Text spliced INSIDE a pinned phrase reddens them; a
19
- // whole new sentence appended after one, carving out an exception, does not.
20
- // A reflow (line wraps, `**bold**` moved) stays green by design. The
21
- // declared-code scan carries a second ceiling of its own, explained in the
22
- // comment above `scriptHeader` and implemented at `codesIn`.
23
- import { test } from "node:test";
24
- import assert from "node:assert/strict";
25
- import { readFileSync } from "node:fs";
26
- import { join } from "node:path";
27
- import { between, logicalLines, phrase, stripSlashGutter } from "./prose-pin.mjs";
28
-
29
- const REPO = join(import.meta.dirname, "..");
30
- const read = (...p) => readFileSync(join(REPO, ...p), "utf8");
31
- const NEXT_TICKET = read("skills", "next-ticket", "SKILL.md");
32
- const RUN_TEAM = read("skills", "run-team", "SKILL.md");
33
- const REPO_ROOT = join(import.meta.dirname, "..", "..");
34
- const SPEC = readFileSync(join(REPO_ROOT, "docs", "specs", "2026-07-23-fleet-plugin-design.md"), "utf8");
35
-
36
- const candidatesStep = () =>
37
- between(NEXT_TICKET, "## 1. Candidates", "## 2. Dependencies", "next-ticket/SKILL.md");
38
-
39
- test("next-ticket's exit-code line tells exit 3 from the empty queue and from the broken query", () => {
40
- const s = candidatesStep();
41
- assert.match(s, phrase("Exit 1 = query fine, queue empty"));
42
- assert.match(s, phrase("Exit 3 = query fine, rows came back and the to-spec filter took every one"));
43
- assert.match(s, phrase("Exit 2 = query broke"));
44
- });
45
-
46
- test("next-ticket sends exit 3 to to-tickets rather than reading it as no work", () => {
47
- // The distinction the code exists to make: this caller's own invocation
48
- // reaches exit 3, so "empty" here would send it to the wrong conclusion.
49
- assert.match(candidatesStep(), phrase("run to-tickets rather than reading it as no work"));
50
- });
51
-
52
- test("next-ticket scopes exit 3 to the final pass, so it agrees with the fallback trigger", () => {
53
- // `--allow-fallback` is this caller's prescribed invocation, so the
54
- // final-pass rule is not a footnote here — it decides whether exit 3 or
55
- // exit 1 comes back, and a reader who misses it connects exit 3 to the
56
- // "counts as empty" sentence above and concludes the two disagree.
57
- const s = candidatesStep();
58
- assert.match(s, phrase("Exit 3 judges the LAST pass alone"));
59
- assert.match(s, phrase("falls back to a genuinely empty one is exit 1"));
60
- });
61
-
62
- // The same slice candidates.test.mjs bounds for the `--require-label` rule —
63
- // `1. **Build the Shortlist**` to the step after it. A match anywhere in phase 0 is
64
- // vacuous: phase 0 discusses `inflight.sh`'s exit 2 at length a few steps down,
65
- // so a file-wide search for "exit" finds another script's contract and reports
66
- // this one as documented.
67
- const scanStep = () =>
68
- between(RUN_TEAM, "1. **Build the Shortlist**", "\n2. ", "run-team/SKILL.md");
69
-
70
- test("phase 0 denies that exit 3 is the empty queue", () => {
71
- const s = scanStep();
72
- assert.match(s, phrase("Exit 3 is not that empty queue"));
73
- assert.match(s, phrase("the to-spec filter took every one"));
74
- });
75
-
76
- test("phase 0 forbids answering exit 3 by widening the net", () => {
77
- // The hazard this rule exists to close, and the one a careless wording
78
- // opens: exit 3 proves there ARE labeled items, which reads as evidence the
79
- // filter is too tight. It is not — the items are specs, and the fallback
80
- // pass is unfiltered, so widening reaches `ready-for-human` and untriaged
81
- // work an unattended run still has no channel to a human for.
82
- const s = scanStep();
83
- assert.match(s, phrase("never a reason to widen the net"));
84
- assert.match(s, phrase("still do not pass `--allow-fallback`"));
85
- });
86
-
87
- test("phase 0 names what exit 3's queue actually holds, so the run reports it rather than claiming no work", () => {
88
- const s = scanStep();
89
- assert.match(s, phrase("to-tickets' input rather than claimable tickets"));
90
- assert.match(s, phrase("Log it as specs awaiting to-tickets"));
91
- });
92
-
93
- // --- The script-surface contract table, and the preamble that scopes it.
94
- const scriptSurface = () =>
95
- between(SPEC, "## Script surface", "| Script | In | Out |", "the fleet-plugin design spec");
96
-
97
- const candidatesRow = () => {
98
- const line = SPEC.split("\n").find((l) => l.startsWith("| `candidates.mjs` |"));
99
- assert.ok(line, "the design spec's script-surface table no longer has a `candidates.mjs` row — update this test");
100
- return line;
101
- };
102
-
103
- test("the spec's candidates row stops reading an all-specs queue as exit 1", () => {
104
- const row = candidatesRow();
105
- // The clause as it stood absorbed the exit-3 case: "no candidate survived"
106
- // is true of a queue the filter emptied, which is exit 3. Narrowing it is
107
- // the correction — appending exit 3 while leaving this would ship two
108
- // clauses in one cell that contradict each other.
109
- assert.doesNotMatch(row, phrase("no candidate survived"));
110
- assert.match(row, phrase("no row came back at all"));
111
- assert.match(row, phrase("the to-spec filter removed every one"));
112
- });
113
-
114
- test("the spec's preamble states the further-code property instead of naming one carrier", () => {
115
- // Naming `ledger.mjs check` as THE script with an extra code made the
116
- // preamble false by omission the moment a second script minted one. A
117
- // property carries no carrier list to go stale and no tally to rot.
118
- const s = scriptSurface();
119
- assert.doesNotMatch(s, phrase("`ledger.mjs check` mints one further code"));
120
- assert.match(s, phrase("Where a script needs a verdict those meanings cannot carry, it mints a further code and states it in its own row"));
121
- });
122
-
123
- // Derived from the script's own contract rather than restating it: this is the
124
- // check that would have caught #407 the day PR #404 landed. Add a code to the
125
- // header in the `N = ` form every code there uses today, and each carrier the
126
- // coverage test reads reddens until it names the code too.
127
- //
128
- // THE SCAN'S CEILING: `N = ` is the only spelling it reads. Declare a code in
129
- // the same contract block as `exit 4 — ...` and this scan does not see it, so
130
- // the coverage test stays green over a code no document names — measured, next
131
- // to a `4 = ` control that reddens. Widening the scan to any digit next to `=`
132
- // or an em-dash was measured too: it does catch that spelling, and it also
133
- // mints a code out of ordinary header prose, so a bare `(#7 — see there)`
134
- // reddens the coverage test over a code nobody declared. What holds this up
135
- // is the contract's own wording — declare a new code `N = `, or teach this
136
- // scan the spelling you chose.
137
- //
138
- // Guarded at each step and called from a test body, never run at module scope:
139
- // an unguarded index here fails at IMPORT, taking the unrelated tests in this
140
- // file down with it and naming nothing as the thing to look at.
141
- //
142
- // #1619: `codesIn` runs the header through `stripSlashGutter` then
143
- // `logicalLines` before this regex ever sees it — same fix shape as #1609's
144
- // `pointer-target-prose.test.mjs`. `\b(\d) = ` is a single inter-word space
145
- // on each side, and a raw physical-line scan turns that space into a
146
- // newline the instant a reflow wraps the header between the digit and `=`,
147
- // or between `=` and the word after it. Measured against the scan this
148
- // replaced, reflowing this exact header with not one word changed: at 27
149
- // columns both 1 and 3 drop from the derived list, at 33 columns 2 drops
150
- // alone, at 56 columns 3 drops alone — in every case with the coverage
151
- // assertion below still PASSING, because a code this scan never finds is a
152
- // code that loop never checks. Worse than #1609's own symptom: that one
153
- // reddened loudly; this one stays green over a real coverage gap.
154
- function scriptHeader() {
155
- const src = read("scripts", "candidates.mjs");
156
- return src.slice(0, src.indexOf("\nimport "));
157
- }
158
-
159
- // `codesIn` is a pure extractor: it runs on the real header (via
160
- // `declaredNonZeroCodes`, below) AND on synthetic reflow/fixture text the
161
- // tests below construct by hand. Its three "update this test" guards only
162
- // make sense against the FIRST source — fired against a fixture, they would
163
- // blame `candidates.mjs` for a break the fixture (or this file's own
164
- // transform pipeline) introduced. `scanCodes` does the shared computation;
165
- // only `declaredNonZeroCodes` — the one caller reading the real file — turns
166
- // a bad scan into an "update this test" guard.
167
- function scanCodes(headerText) {
168
- const prose = logicalLines(stripSlashGutter(headerText)).text;
169
- const at = prose.indexOf("Exit-code contract");
170
- const codes = at === -1 ? [] : [...prose.slice(at).matchAll(/\b(\d) = /g)].map((m) => m[1]);
171
- const nonZero = [...new Set(codes)].filter((c) => c !== "0");
172
- return { at, codes, nonZero };
173
- }
174
-
175
- function codesIn(headerText) {
176
- return scanCodes(headerText).nonZero;
177
- }
178
-
179
- function declaredNonZeroCodes() {
180
- const { at, codes, nonZero } = scanCodes(scriptHeader());
181
- assert.notEqual(at, -1, "candidates.mjs' header no longer states an `Exit-code contract` — update this test");
182
- assert.ok(codes.includes("0"), "candidates.mjs' exit-code contract no longer declares 0 — update this test");
183
- assert.ok(nonZero.length > 0, "candidates.mjs' exit-code contract declares no non-zero code — update this test");
184
- return nonZero;
185
- }
186
-
187
- test("every non-zero code the script declares is named by the documents a consumer reads", () => {
188
- // run-team/SKILL.md's candidate scan step is deliberately NOT a carrier here.
189
- // It carries a rule for exit 3 alone — the exit that sends an all-specs queue
190
- // to to-tickets — and names neither exit 1 nor exit 2, reading an empty queue
191
- // as no work in prose instead. This loop asserts every declared code is named
192
- // by every carrier it reads, so listing that step reddens on exit 1 (measured).
193
- // Leaving it out is a decision, not an oversight.
194
- for (const [what, text] of [
195
- ["next-ticket/SKILL.md's candidate step", candidatesStep()],
196
- ["the design spec's candidates row", candidatesRow()],
197
- ]) {
198
- for (const code of declaredNonZeroCodes()) {
199
- assert.match(
200
- text,
201
- new RegExp(`exit ${code}\\b`, "i"),
202
- `${what} does not name exit ${code}, which candidates.mjs' own exit-code contract declares`,
203
- );
204
- }
205
- }
206
- });
207
-
208
- // #1619, the pin the test above could not carry. It reads the header as
209
- // checked in — one physical line per sentence — so it never notices that
210
- // `codesIn`'s regex is `\n`-hostile by necessity. Same convention as
211
- // `pointer-target-prose.test.mjs`'s #1609 reflow pin: reflowed HERE, never
212
- // committed as a fixture, because a checked-in rewrapped copy rots away from
213
- // `candidates.mjs`'s real header the moment one changes and not the other.
214
- const reflow = (text, cols) => {
215
- const out = [];
216
- let fenced = false;
217
- for (const line of text.split("\n")) {
218
- if (/^ {0,3}(?:```|~~~)/.test(line)) fenced = !fenced;
219
- if (fenced || line.length <= cols || /(?:[ \t]{2}|\\)$/.test(line)) {
220
- out.push(line);
221
- continue;
222
- }
223
- const lead = line.match(/^[ \t]*/)[0];
224
- const indent = " ".repeat(line.match(/^(?:[ \t]*(?:[-*+]|\d+[.)])[ \t]+|[ \t]*)/)[0].length);
225
- const words = line.slice(lead.length).split(" ").filter(Boolean);
226
- let cur = lead + (words.shift() ?? "");
227
- for (const word of words) {
228
- if (`${cur} ${word}`.length > cols) {
229
- out.push(cur);
230
- cur = indent + word;
231
- } else cur = `${cur} ${word}`;
232
- }
233
- out.push(cur);
234
- }
235
- return out.join("\n");
236
- };
237
-
238
- // Three widths, each measured against `candidates.mjs`'s real header to lose
239
- // a DIFFERENT code under the physical-line scan this file replaced: 27 drops
240
- // both 1 and 3, 33 drops 2 alone, 56 drops 3 alone. One width alone measures
241
- // one accident of where the breaks landed.
242
- //
243
- // LIVENESS: `assert.deepEqual` below only proves `codesIn` survives the
244
- // rewrap — nothing here proves the rewrap still SPLITS a `N = ` pair. A
245
- // future reword of the header's exit-code sentence could stop wrapping
246
- // mid-pair at all three widths and every assertion below would still pass,
247
- // pinning nothing. `oldStyleCodesIn` is the physical-line-only scan this
248
- // file replaced (no gutter strip, no join); asserting its result is a
249
- // STRICT subset of the full declared set is the same measurement the
250
- // comment above states in prose, turned into a check that reddens the day
251
- // it stops holding.
252
- const oldStyleCodesIn = (headerText) => {
253
- const at = headerText.indexOf("Exit-code contract");
254
- const codes = at === -1 ? [] : [...headerText.slice(at).matchAll(/\b(\d) = /g)].map((m) => m[1]);
255
- return [...new Set(codes)].filter((c) => c !== "0");
256
- };
257
-
258
- for (const cols of [27, 33, 56]) {
259
- test(`a pure reflow of candidates.mjs' header at ${cols} columns changes no declared exit code`, () => {
260
- const before = scriptHeader();
261
- const rewrapped = reflow(before, cols);
262
- assert.notEqual(rewrapped, before, `reflow at ${cols} columns changed nothing — this pin is not exercising a rewrap`);
263
- assert.equal(
264
- rewrapped.replace(/\s+/g, " ").trim(),
265
- before.replace(/\s+/g, " ").trim(),
266
- "the reflow fixture changed the header's words, so the comparison below would prove nothing",
267
- );
268
- const declared = declaredNonZeroCodes();
269
- const stale = oldStyleCodesIn(rewrapped);
270
- assert.ok(
271
- stale.length < declared.length && stale.every((c) => declared.includes(c)),
272
- `reflowing at ${cols} columns no longer splits any \`N = \` pair onto two physical lines (the old scan still finds every code) — this pin is vacuous at this width and no longer exercises the hazard \`logicalLines\` exists to survive.`,
273
- );
274
- assert.deepEqual(
275
- codesIn(rewrapped),
276
- declared,
277
- `rewrapping candidates.mjs' header at ${cols} columns changes which non-zero exit codes this file finds — the scan is reading physical lines again, so an author who reflows the header silently drops coverage for whichever code the wrap split, with the guard above still passing.`,
278
- );
279
- });
280
- }
281
-
282
- // #1619's OTHER half. The fix is TWO steps — stripSlashGutter THEN
283
- // logicalLines — but the three pins above only ever exercise logicalLines:
284
- // this file's `reflow` helper never reprints a `// ` gutter on a line it
285
- // wraps, so at every width tested (27/33/56, and every width from 20 to 80,
286
- // measured) the header's own line breaks never land a continuation line's
287
- // leading `// ` between a digit and its `= `. Dropping stripSlashGutter
288
- // alone — `codesIn` calling `logicalLines(headerText).text` straight,
289
- // keeping logicalLines — passes every test above unchanged (measured: 12/12
290
- // green). A real rewrap of a `//` comment block DOES reprint the gutter on
291
- // each new line, and this fixture is built to land the break exactly where
292
- // that matters: the authored line ends on a bare `3`, and the next line
293
- // opens with `// = `, so a scan that joins lines without first stripping
294
- // that gutter inserts `// ` between the code and its `= `, right where
295
- // `codesIn`'s regex needs one plain space.
296
- test("codesIn still finds a code whose comment-line break falls right before its `= `", () => {
297
- const fixture = [
298
- "// Exit-code contract: 0 = ok, 1 = degraded, 2 = broken, 3",
299
- "// = every row removed by the filter.",
300
- ].join("\n");
301
- assert.deepEqual(codesIn(fixture), ["1", "2", "3"]);
302
- });