@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,369 +0,0 @@
1
- // #784. The degraded-watcher snippet in `run-team/SKILL.md` is prescriptive
2
- // shell a controller copies verbatim, and it has now shipped a defect that its
3
- // OWN surrounding prose already ruled out — three times. So this pin RUNS the
4
- // block rather than matching strings in it: it lifts the fenced snippet out of
5
- // the document, stubs `gh`, `ci-state.mjs` and `sleep` on PATH, and drives it
6
- // through the states the prose promises: every probe latched at the level its
7
- // cause lives at, each latch one-shot in both directions, one sleep per tick
8
- // whatever went wrong, an ordinary not-green left alone, and the per-PR loop
9
- // splitting per PR under zsh as well as sh.
10
- //
11
- // THE CEILING: the stubs cover only the three probes the block makes, and
12
- // `sleep` is counted rather than taken, so this measures the block's control
13
- // flow and nothing about real GitHub, real timing, or the "your normal handling
14
- // of $st" line the block leaves as a placeholder. It also assumes the block
15
- // stays a `while :; do` tick loop — that string is how the harness caps the run,
16
- // and a rewrite to another loop form must update this test rather than the
17
- // document.
18
- import { test } from "node:test";
19
- import assert from "node:assert/strict";
20
- import { execFileSync } from "node:child_process";
21
- import { mkdirSync, writeFileSync, readFileSync } from "node:fs";
22
- import { tempDir } from "./temp-dir.mjs";
23
- import { join } from "node:path";
24
- import { writeExecStub } from "./exec-stub.mjs";
25
-
26
- // The stubs shell out to jq, and so does the block under test. Without it every
27
- // gate would fail identically and the suite would go green on a block that
28
- // never ran — the vacuous pass this file exists to prevent.
29
- try {
30
- execFileSync("jq", ["--version"], { stdio: "ignore" });
31
- } catch {
32
- throw new Error("jq is required to exercise the watcher block; install it before running this suite");
33
- }
34
-
35
- const SKILL = readFileSync(join(import.meta.dirname, "..", "skills", "run-team", "SKILL.md"), "utf8");
36
-
37
- // Anchored on what the block CONTAINS, never on its ordinal: a fence inserted
38
- // ahead of it would re-rot an index. Exactly one block may say WATCHER DEGRADED.
39
- const blocks = [...SKILL.matchAll(/```sh\n([\s\S]*?)```/g)]
40
- .map((m) => m[1])
41
- .filter((b) => b.includes("WATCHER DEGRADED"));
42
- assert.equal(blocks.length, 1, `expected exactly one sh block emitting WATCHER DEGRADED, found ${blocks.length} — update this test`);
43
- const BLOCK = blocks[0];
44
-
45
- const DIR = tempDir("watcher-block-");
46
- const BIN = join(DIR, "bin");
47
- mkdirSync(BIN);
48
-
49
- const stub = (name, body) => writeExecStub(join(BIN, name), body);
50
-
51
- // Every *SEQ variable names a file of one value per line, consumed one per
52
- // invocation, so a scenario can change what a probe returns between ticks. The
53
- // matching fixed variable is the alternative. `gh` needs this for RL too: a
54
- // latch is one-shot only if it stays quiet across a SUSTAINED outage and speaks
55
- // once on recovery, and neither is observable from a single static budget.
56
- // PRSSEQ is the same for the open-PR list, one space-separated list per line.
57
- //
58
- // `pr list` stops at `--limit` — 30 when the flag is absent — the way gh does
59
- // (#2108): exit 0, no warning, the rest simply not printed. A block that lost
60
- // its --limit is therefore cut at 30 here exactly as it would be on GitHub.
61
- stub("gh", `#!/bin/sh
62
- next() {
63
- if [ -n "$1" ]; then
64
- n=$(cat "$1.n" 2>/dev/null || echo 0); n=$((n+1)); echo "$n" > "$1.n"
65
- sed -n "\${n}p" "$1"
66
- else
67
- printf '%s\\n' "$2"
68
- fi
69
- }
70
- case "$2" in
71
- list)
72
- if [ "$(next "$LISTSEQ" "\${LISTMODE-ok}")" = err ]; then exit 1; fi
73
- limit=30
74
- while [ $# -gt 0 ]; do [ "$1" = --limit ] && limit=$2; shift; done
75
- i=0
76
- for p in $(next "$PRSSEQ" "$PRS"); do
77
- i=$((i+1)); [ "$i" -le "$limit" ] || break
78
- echo "$p"
79
- done ;;
80
- *) next "$RLSEQ" "\${RL-5000}" ;;
81
- esac
82
- `);
83
-
84
- // $SEQ names a global sequence file; $SEQ.<pr>, when it exists, overrides it for
85
- // that PR with its own file and its own counter. Without that per-PR override no
86
- // scenario can hold two PRs in DIFFERENT states across more than one tick, which
87
- // is the shape every multi-PR latch mutation lives in.
88
- stub("ci-state.mjs", `#!/bin/sh
89
- pr=$2
90
- seq=$SEQ
91
- [ -n "$seq" ] && [ -f "$seq.$pr" ] && seq="$seq.$pr"
92
- if [ -n "$seq" ]; then
93
- n=$(cat "$seq.n" 2>/dev/null || echo 0); n=$((n+1)); echo "$n" > "$seq.n"
94
- mode=$(sed -n "\${n}p" "$seq")
95
- else
96
- mode=$MODE
97
- fi
98
- case "$mode" in
99
- empty) exit 1 ;;
100
- garbage) echo '<html>429</html>'; exit 1 ;;
101
- ratelimited) printf '{"pr":%s,"verdict":"rate-limited","reasons":["refused"]}\\n' "$pr"; exit 1 ;;
102
- emptyobj) echo '{}'; exit 1 ;;
103
- nulldoc) echo 'null'; exit 1 ;;
104
- nullverdict) printf '{"pr":%s,"verdict":null}\\n' "$pr"; exit 1 ;;
105
- blind42) [ "$pr" = 42 ] && exit 1; printf '{"pr":%s,"verdict":"not-green"}\\n' "$pr"; exit 1 ;;
106
- *) printf '{"pr":%s,"verdict":"not-green"}\\n' "$pr"; exit 1 ;;
107
- esac
108
- `);
109
-
110
- // Counted, never taken — the block's pacing is the thing under test and a real
111
- // 120s sleep would make the suite unrunnable.
112
- stub("sleep", `#!/bin/sh
113
- echo "SLEEP $1"
114
- `);
115
-
116
- const TICK_LOOP = "while :; do";
117
- assert.ok(BLOCK.includes(TICK_LOOP), `the block no longer opens with '${TICK_LOOP}'; the harness caps the run on that line — update this test`);
118
-
119
- function run(env, ticks, shell = "sh", { strict = false } = {}) {
120
- const harness = BLOCK
121
- .replace("~/.fleet/bin/fleet-run ci-state.mjs", "ci-state.mjs")
122
- .replace(TICK_LOOP, `tick=0\nwhile tick=$((tick+1)); [ "$tick" -le ${ticks} ]; do`);
123
- const path = join(DIR, "harness.sh");
124
- // #1334: `strict` prefixes `set -eu` onto the harness so a regression to an
125
- // unseeded latch (unbound under -u) or an unguarded `st=$(...)` (killed
126
- // under -e by ci-state.mjs's ordinary non-zero not-green exit) fails LOUD
127
- // here instead of shipping silent again.
128
- writeFileSync(path, strict ? `set -eu\n${harness}` : harness);
129
- return execFileSync(shell, [path], {
130
- encoding: "utf8",
131
- env: { ...process.env, ...env, PATH: `${BIN}:${process.env.PATH}` },
132
- });
133
- }
134
-
135
- const hasShell = (s) => {
136
- try {
137
- execFileSync(s, ["-c", "exit 0"], { stdio: "ignore" });
138
- return true;
139
- } catch {
140
- return false;
141
- }
142
- };
143
-
144
- const count = (out, needle) => out.split("\n").filter((l) => l.includes(needle)).length;
145
-
146
- // The WATCHER lines in order, as "D42"/"R42" — for the multi-PR cases, where
147
- // which PR spoke and when both matter and a bare count hides a reordering.
148
- const events = (out) =>
149
- out
150
- .split("\n")
151
- .filter((l) => l.startsWith("WATCHER"))
152
- .map((l) => `${l.includes("DEGRADED") ? "D" : "R"}${l.match(/#(\d+)/)?.[1] ?? "*"}`);
153
-
154
- test("a self-named rate-limited payload is an outage, not a reading", () => {
155
- // ci-state emits {"verdict":"rate-limited"} on stdout and exits non-zero. It
156
- // is parseable JSON, so a gate testing parseability alone clears the latch,
157
- // prints RECOVERED, and hands the outage payload downstream as CI state.
158
- const seq = join(DIR, "seq-ratelimited");
159
- writeFileSync(seq, "empty\nratelimited\n");
160
- const out = run({ SEQ: seq, PRS: "7" }, 2);
161
- assert.equal(count(out, "WATCHER DEGRADED"), 1, `expected one DEGRADED line, got:\n${out}`);
162
- assert.equal(
163
- count(out, "WATCHER RECOVERED"),
164
- 0,
165
- `a rate-limited payload cleared the latch — the gate is testing parseability, not the verdict:\n${out}`,
166
- );
167
- });
168
-
169
- test("unparseable and empty payloads are outages too", () => {
170
- for (const MODE of ["empty", "garbage"]) {
171
- const out = run({ MODE, PRS: "7" }, 1);
172
- assert.equal(count(out, "WATCHER DEGRADED"), 1, `${MODE}: expected one DEGRADED line, got:\n${out}`);
173
- }
174
- });
175
-
176
- test("the payload latch is keyed by PR, not shared across them", () => {
177
- // One persistently blind PR beside one healthy PR. A shared scalar latch is
178
- // re-cleared by the healthy PR every tick, so the pair repeats forever — the
179
- // per-tick volume the latch exists to prevent, and every RECOVERED in it
180
- // falsely asserts the watch is alive for a PR that is still blind.
181
- const out = run({ MODE: "blind42", PRS: "42 43" }, 3);
182
- assert.equal(count(out, "WATCHER DEGRADED"), 1, `expected one DEGRADED across three ticks, got:\n${out}`);
183
- assert.equal(count(out, "WATCHER RECOVERED"), 0, `a healthy PR cleared another PR's latch:\n${out}`);
184
- });
185
-
186
- test("one PR recovers without disturbing a sibling that is still blind", () => {
187
- // Two PRs, four ticks, blind at different times — the only shape in which the
188
- // per-PR latch's bookkeeping is observable at all. #4 is healthy on tick 1 and
189
- // blind thereafter; #42 is blind from tick 1 and readable from tick 3. Each
190
- // must announce itself exactly once in each direction, and #4's numbering is
191
- // deliberately a prefix of #42's so the `case " $blind " in *" $pr "*` space
192
- // anchoring is under test too.
193
- //
194
- // Three latch mutations die here and survive every other case in this file:
195
- // wiping `blind` wholesale on any recovery (#4 re-fires on tick 4 -> 3
196
- // DEGRADED), overwriting `blind="$pr"` instead of appending (neither PR stays
197
- // latched -> 5 DEGRADED, 0 RECOVERED), and dropping the spaces from the latch
198
- // test (#4 matches inside "42" and its outage is swallowed -> 1 DEGRADED).
199
- const seq = join(DIR, "seq-siblings");
200
- writeFileSync(`${seq}.4`, "normal\nempty\nempty\nempty\n");
201
- writeFileSync(`${seq}.42`, "empty\nempty\nnormal\nnormal\n");
202
- const out = run({ SEQ: seq, PRS: "4 42" }, 4);
203
- // The ordered sequence, not four counts: the anchoring mutant only DELAYS #4's
204
- // line to the tick #42's latch clears, so it lands on the same two-DEGRADED,
205
- // one-RECOVERED totals the real block does and is invisible to counting.
206
- assert.deepEqual(events(out), ["D42", "D4", "R42"], `wrong events, or in the wrong order:\n${out}`);
207
- });
208
-
209
- test("pacing lives in one place — a budget outage does not multiply by open PRs", () => {
210
- // A sleep inside the per-PR pass turns 8 open PRs into 8 pauses per tick,
211
- // against this section's own measured 24s outage reset.
212
- const budget = run({ RL: "5", PRS: "1 2 3 4 5 6 7 8" }, 1);
213
- assert.equal(count(budget, "SLEEP"), 1, `budget outage: expected one sleep per tick regardless of PR count, got:\n${budget}`);
214
- assert.equal(count(budget, "WATCHER DEGRADED"), 1, budget);
215
- // Same property one level down: a sleep in the per-PR degraded branch
216
- // multiplies the same way, and the budget case above cannot see it because
217
- // the per-PR pass never runs under a budget outage.
218
- const payload = run({ MODE: "empty", PRS: "1 2 3 4 5 6 7 8" }, 1);
219
- assert.equal(count(payload, "SLEEP"), 1, `payload outage: expected one sleep per tick regardless of PR count, got:\n${payload}`);
220
- // And once more on the healthy path, which neither case above reaches: both
221
- // route around the block's normal-handling line — the budget outage never
222
- // enters the per-PR pass, the payload outage `continue`s before it. A sleep
223
- // planted on that line is invisible to every other test in this file.
224
- const healthy = run({ MODE: "normal", PRS: "1 2 3 4 5 6 7 8" }, 1);
225
- assert.equal(count(healthy, "SLEEP"), 1, `healthy path: expected one sleep per tick regardless of PR count, got:\n${healthy}`);
226
- });
227
-
228
- test("a degraded payload tick still reaches the loop's own pacing", () => {
229
- // A degraded branch that continues the OUTER loop skips the tail sleep and
230
- // busy-spins probe pairs during exactly the outage it is reporting.
231
- const out = run({ MODE: "empty", PRS: "7" }, 3);
232
- assert.equal(count(out, "SLEEP"), 3, `every tick must reach the tail sleep, got:\n${out}`);
233
- });
234
-
235
- test("a non-numeric budget read is an outage, not a budget", () => {
236
- // `.resources.core.remaining` missing from the response yields `null`, and
237
- // `[ null -lt 200 ]` errors — silently, under the block's own 2>/dev/null.
238
- for (const RL of ["null", ""]) {
239
- const out = run({ RL, PRS: "7" }, 1);
240
- assert.equal(count(out, "WATCHER DEGRADED"), 1, `RL=${RL || "(empty)"} fell through to polling with no degraded line:\n${out}`);
241
- }
242
- });
243
-
244
- test("an ordinary not-green PR never trips the outage path", () => {
245
- const out = run({ MODE: "normal", PRS: "7" }, 3);
246
- assert.equal(count(out, "WATCHER"), 0, `not-green is a frequent, ordinary state that exits non-zero:\n${out}`);
247
- });
248
-
249
- test("#1334: the block survives set -eu on tick 1, on every probe path", () => {
250
- // budget_out/list_out/blind were read before ever being assigned — unbound
251
- // under set -u — and `st=$(ci-state.mjs ...)` was an unguarded assignment
252
- // from a command that exits non-zero on the ordinary not-green state,
253
- // killing the shell under set -e before the block's own payload-gate logic
254
- // ever ran. Both reintroduced the exact silence #784 exists to remove, and
255
- // neither is visible to any test above since none of them run under -eu.
256
- const healthy = run({ MODE: "normal", PRS: "7" }, 2, "sh", { strict: true });
257
- assert.equal(count(healthy, "SLEEP"), 2, `set -eu: an ordinary not-green payload died before tick 2:\n${healthy}`);
258
- const budget = run({ RL: "5", PRS: "7" }, 2, "sh", { strict: true });
259
- assert.equal(count(budget, "SLEEP"), 2, `set -eu: a budget outage died before tick 2:\n${budget}`);
260
- const list = run({ LISTMODE: "err", PRS: "7" }, 2, "sh", { strict: true });
261
- assert.equal(count(list, "SLEEP"), 2, `set -eu: an open-PR list outage died before tick 2:\n${list}`);
262
- const payload = run({ MODE: "empty", PRS: "7" }, 2, "sh", { strict: true });
263
- assert.equal(count(payload, "SLEEP"), 2, `set -eu: an unparseable payload died before tick 2:\n${payload}`);
264
- });
265
-
266
- test("a payload with no verdict at all is an outage, not a reading", () => {
267
- // `.verdict != "rate-limited"` never tests that a verdict EXISTS: {}, null and
268
- // an explicit null field all evaluate `null != "rate-limited"` -> true and
269
- // clear the gate, handing an empty or error object downstream as CI state.
270
- for (const MODE of ["emptyobj", "nulldoc", "nullverdict"]) {
271
- const out = run({ MODE, PRS: "7" }, 1);
272
- assert.equal(count(out, "WATCHER DEGRADED"), 1, `${MODE} cleared the gate — it tests inequality, not presence:\n${out}`);
273
- }
274
- });
275
-
276
- test("a failing `gh pr list` is an outage, not zero open PRs", () => {
277
- // The third probe, with the budget healthy: a non-quota failure (secondary
278
- // limit, 5xx, token error) never lowers .resources.core.remaining, so the
279
- // budget gate clears and an unguarded `for pr in $(gh pr list …)` iterates
280
- // zero times over the empty substitution — no error, no latch, no line. Total
281
- // silence per tick, which is the exact state this section exists to remove.
282
- const out = run({ LISTMODE: "err", PRS: "7" }, 3);
283
- assert.equal(count(out, "WATCHER DEGRADED"), 1, `expected one DEGRADED across three ticks, got:\n${out}`);
284
- assert.equal(count(out, "SLEEP"), 3, `an unreadable PR list must still reach the tail sleep, got:\n${out}`);
285
- });
286
-
287
- test("the open-PR list latch clears once on recovery, not once per tick", () => {
288
- const seq = join(DIR, "seq-list");
289
- writeFileSync(seq, "err\nok\nok\n");
290
- const out = run({ LISTSEQ: seq, MODE: "normal", PRS: "7" }, 3);
291
- assert.equal(count(out, "WATCHER DEGRADED"), 1, out);
292
- assert.equal(count(out, "WATCHER RECOVERED"), 1, `expected exactly one RECOVERED, got:\n${out}`);
293
- });
294
-
295
- // #2108. `n` open PRs, numbered from 1, as the space-separated list $PRS takes.
296
- const openPrs = (n) => Array.from({ length: n }, (_, i) => i + 1).join(" ");
297
- const CAPPED = "hit its --limit";
298
-
299
- test("#2108: an open-PR list that fills its --limit is a degraded cause, and the PRs it did return are still polled", () => {
300
- // Every ci-state read is blind, so each PR the pass reached speaks once: the
301
- // count of those lines is the count of PRs the block polled. 200 of 250 is
302
- // the explicit limit at work; 30 would be gh's bare default.
303
- const out = run({ MODE: "empty", PRS: openPrs(250) }, 1);
304
- assert.equal(count(out, CAPPED), 1, `a full page of open PRs went unreported:\n${out}`);
305
- assert.equal(count(out, "no usable ci-state reading"), 200, "the block no longer polls the 200 PRs its capped read returned");
306
- assert.equal(count(out, "SLEEP"), 1);
307
- });
308
-
309
- test("#2108: the cap latch is one-shot across ticks, and clears once when the list comes back under it", () => {
310
- const seq = join(DIR, "seq-prs-cap");
311
- writeFileSync(seq, `${openPrs(250)}\n${openPrs(250)}\n7\n7\n`);
312
- const out = run({ PRSSEQ: seq, MODE: "normal" }, 4);
313
- assert.equal(count(out, CAPPED), 1, `expected one capped DEGRADED across two capped ticks, got:\n${out}`);
314
- assert.equal(count(out, "under its --limit"), 1, `expected exactly one RECOVERED for the cap, got:\n${out}`);
315
- });
316
-
317
- test("#2108: a list one short of the cap, and past gh's bare default of 30, is complete and says nothing", () => {
318
- // The input the guard must ACCEPT: 199 is a whole answer, not a capped one,
319
- // and every one of them is polled — not the 30 a missing --limit yields.
320
- const out = run({ MODE: "empty", PRS: openPrs(199) }, 1);
321
- assert.equal(count(out, CAPPED), 0, `a list under its limit was reported as capped:\n${out}`);
322
- assert.equal(count(out, "no usable ci-state reading"), 199, "the block polled fewer PRs than the list returned");
323
- });
324
-
325
- test("the budget latch is one-shot across a sustained outage", () => {
326
- // Its own semantics, not the payload latch's: a budget branch that lost its
327
- // `[ -z "$budget_out" ]` guard spams a DEGRADED every tick during exactly the
328
- // outage it is reporting, and no per-PR test can see it — the per-PR pass
329
- // never runs while the budget is out.
330
- const out = run({ RL: "5", PRS: "7" }, 3);
331
- assert.equal(count(out, "WATCHER DEGRADED"), 1, `expected one DEGRADED across three ticks, got:\n${out}`);
332
- });
333
-
334
- test("the budget latch clears once on recovery, not once per tick", () => {
335
- // The mirror mutation: a RECOVERED branch that never resets budget_out re-fires
336
- // on every later tick, so the recovery line stops meaning "the watch is alive
337
- // again" and becomes the per-tick volume the latch exists to prevent.
338
- const seq = join(DIR, "seq-rl");
339
- writeFileSync(seq, "5\n5000\n5000\n");
340
- const out = run({ RLSEQ: seq, MODE: "normal", PRS: "7" }, 3);
341
- assert.equal(count(out, "WATCHER DEGRADED"), 1, out);
342
- assert.equal(count(out, "WATCHER RECOVERED"), 1, `expected exactly one RECOVERED, got:\n${out}`);
343
- });
344
-
345
- test("the per-PR loop splits per PR under zsh too, not once over the whole blob", () => {
346
- // zsh word-splits a command substitution's RESULT but not a bare parameter
347
- // expansion, so `for pr in $prs` runs ONE iteration there with every number
348
- // glued into a single value (measured) while sh and bash split it correctly.
349
- // A regression to the bare form is therefore invisible to every sh-only case
350
- // above — and the same trap applies to the blind-latch removal loop, where it
351
- // leaves a recovered PR latched forever.
352
- for (const shell of ["sh", "bash", "zsh"]) {
353
- if (!hasShell(shell)) continue;
354
- const out = run({ MODE: "empty", PRS: "42 43" }, 1, shell);
355
- assert.equal(count(out, "WATCHER DEGRADED"), 2, `${shell}: expected one DEGRADED per PR, got:\n${out}`);
356
- assert.ok(out.includes("#42") && out.includes("#43"), `${shell}: PR numbers were not split individually:\n${out}`);
357
- }
358
- });
359
-
360
- test("a recovered PR leaves the blind latch under zsh too", () => {
361
- for (const shell of ["sh", "bash", "zsh"]) {
362
- if (!hasShell(shell)) continue;
363
- const seq = join(DIR, `seq-blind-${shell}`);
364
- // One PR, blind on tick 1, readable on ticks 2 and 3.
365
- writeFileSync(seq, "empty\nnormal\nnormal\n");
366
- const out = run({ SEQ: seq, PRS: "42" }, 3, shell);
367
- assert.equal(count(out, "WATCHER RECOVERED"), 1, `${shell}: the PR never left the blind list, so RECOVERED repeats:\n${out}`);
368
- }
369
- });
@@ -1,106 +0,0 @@
1
- // #183. The watcher key was stated in two documents and the copies disagreed.
2
- // `run-team/SKILL.md` keys on `<run-id>:<attempt>:<conclusion>` and names the
3
- // `attempt`-less form as the bug that looks like it works — a rerun landing on
4
- // the same conclusion regenerates an already-seen key and fires nothing, so the
5
- // second failure is silent and reads exactly like a run still in progress.
6
- // `references/ci-and-staleness.md` — the file SKILL.md sends a controller to for
7
- // the why, from its CI paragraphs — still carried the two-part form at both of
8
- // its own sites. A controller that follows the pointer reads the refuted form
9
- // last, and last read is what it arms the Monitor with.
10
- //
11
- // THE CEILING: the tree-wide pin is literal. It catches the two-part key written
12
- // as the token, not a paraphrase ("key on run id and conclusion") that means the
13
- // same thing, and it cannot tell a stale copy from a deliberate counter-example —
14
- // a document that wants to show the broken form has to update this test. Neither
15
- // pin runs anything: ci-state.test.mjs owns `ci-state.mjs`'s behavior, and the
16
- // Monitor is armed by a controller reading this prose, not by code under test.
17
- // Accepted alongside that: a line break placed INSIDE the key token reddens the
18
- // positive pin with no content change, because flat() rejoins the halves with a
19
- // space the token does not contain. Measured on ci-and-staleness.md — textwrap
20
- // at widths 30/40/52/55 with break_on_hyphens=True splits `<run-id>` and reddens
21
- // it, while the same widths with break_on_hyphens=False, which is how this repo
22
- // actually wraps, never split it and stayed green. Left undefended on purpose:
23
- // a hyphen-seam special case in flat() buys nothing a realistic edit can reach,
24
- // and the split renders as `<run- id>:...`, a broken code span this pin arguably
25
- // SHOULD redden on.
26
- import { test } from "node:test";
27
- import assert from "node:assert/strict";
28
- import { readFileSync, readdirSync } from "node:fs";
29
- import { join } from "node:path";
30
-
31
- const REPO = join(import.meta.dirname, "..");
32
- const FLEET = REPO;
33
- // The plugin root sits one level under the repo root since #1336's re-nest
34
- // under `plugin/`; FLEET above walks up from THIS file's own location
35
- // (`plugin/scripts/`), so it lands on the plugin root correctly regardless.
36
- // The WALK below is still not `readdirSync(REPO)`: it must stay the plugin's
37
- // own component dirs, because the scope note further down is a measured
38
- // claim about which paths this test does and does not police, and a bare
39
- // `readdirSync` would silently annex `docs/`, `.github/` and the rest of the
40
- // repo root as out of scope.
41
- const WALK = ["commands", "scripts", "skills", "agents"];
42
- const CI_AND_STALENESS = readFileSync(
43
- join(FLEET, "skills", "run-team", "references", "ci-and-staleness.md"),
44
- "utf8",
45
- );
46
-
47
- const THREE_PART = "`<run-id>:<attempt>:<conclusion>`";
48
- // Derived, never written out: spelling the broken key literally here would put
49
- // it back in the tree, and the sweep this ticket closes (`grep -rn 'run-id>:'
50
- // commands scripts skills`) is supposed to come back all-three-part. Deriving it also
51
- // means this file has nothing to exclude itself from the walk below for.
52
- const TWO_PART = THREE_PART.replace("<attempt>:", "");
53
-
54
- // Reflow-safety: markdown here hard-wraps at ~80 columns, so the multi-word
55
- // SITES anchors below can land across a line break, and a pin that only matches
56
- // the unwrapped form reddens on a rewrap that changed nothing. That is what
57
- // flat() buys. The key tokens hold no spaces, so no space-wrapping reflow can
58
- // split them and flattening is a no-op for those — see THE CEILING above for
59
- // the break that does split one. Paragraphs are split off FIRST — the bound
60
- // that keeps a positive pin from being satisfied by a neighbouring paragraph —
61
- // and only then is whitespace inside each one flattened.
62
- const flat = (s) => s.replace(/\s+/g, " ").trim();
63
- const paragraphs = (text) => text.split(/\n\s*\n/).map(flat);
64
-
65
- // Anchored on what the sentence SAYS, never on where it sits: an ordinal re-rots
66
- // the moment anyone inserts ahead of it.
67
- function paragraphSaying(text, anchor, label) {
68
- const hits = paragraphs(text).filter((p) => p.includes(anchor));
69
- assert.equal(hits.length, 1, `${label}: '${anchor}' matched ${hits.length} paragraphs, expected 1 — update this test`);
70
- return hits[0];
71
- }
72
-
73
- const SITES = [
74
- ["the Monitor the controller arms over open PRs' latest runs", "controller arms second persistent Monitor"],
75
- ["the never-cache-a-conclusion rule", "never cache conclusion"],
76
- ];
77
-
78
- test("ci-and-staleness.md keys watchers on the three-part form at both of its sites", () => {
79
- for (const [label, anchor] of SITES) {
80
- assert.match(
81
- paragraphSaying(CI_AND_STALENESS, anchor, label),
82
- new RegExp(THREE_PART.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")),
83
- `${label} no longer keys on ${THREE_PART}; without \`attempt\` a rerun onto the same conclusion fires nothing and a stalled PR is indistinguishable from a running one`,
84
- );
85
- }
86
- });
87
-
88
- // Tree-wide, because the defect was a copy drifting from its original — pinning
89
- // only the file this ticket corrected leaves the next copy free to be made wrong.
90
- // "Tree-wide" is WALK and nowhere else, deliberately: the same key restated at
91
- // the repo root or under docs/ goes unflagged (measured — a copy at each of
92
- // those two paths left this test green, while the identical string under the
93
- // plugin's own dirs reddened it). Every copy #183 found lives here; widening the
94
- // root is a different ticket.
95
- test("no document under the plugin's own dirs states the two-part watcher key", () => {
96
- const offenders = WALK.flatMap((d) =>
97
- readdirSync(join(FLEET, d), { recursive: true, withFileTypes: true })
98
- .filter((e) => e.isFile() && !e.parentPath.includes("node_modules"))
99
- .map((e) => join(e.parentPath, e.name)),
100
- ).filter((f) => flat(readFileSync(f, "utf8")).includes(TWO_PART));
101
- assert.deepEqual(
102
- offenders,
103
- [],
104
- `these state the refuted two-part watcher key ${TWO_PART}; it must be ${THREE_PART}. If one of them means to show the broken form deliberately, update this test rather than the document`,
105
- );
106
- });