@feigi/fleet-ctl 3.23.36 → 3.23.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/package.json +1 -1
  2. package/scripts/main-checkout.mjs +1 -1
  3. package/scripts/member-write-guard.mjs +1 -1
  4. package/scripts/repo-root.mjs +1 -1
  5. package/skills/run-team/references/reaping.md +1 -1
  6. package/scripts/agent-test-dir-prose.test.mjs +0 -59
  7. package/scripts/agent-test.test.mjs +0 -1640
  8. package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
  9. package/scripts/ambient-git-vars-prose.test.mjs +0 -192
  10. package/scripts/ancestry-check-position-prose.test.mjs +0 -175
  11. package/scripts/apply-ruleset.test.mjs +0 -421
  12. package/scripts/arg-header-probes-prose.test.mjs +0 -394
  13. package/scripts/arg.test.mjs +0 -1354
  14. package/scripts/board-cli.test.mjs +0 -710
  15. package/scripts/board-identity.test.mjs +0 -429
  16. package/scripts/board-liveness-banner.test.mjs +0 -119
  17. package/scripts/board-prev-shape.test.mjs +0 -228
  18. package/scripts/board-tryparse-null.test.mjs +0 -119
  19. package/scripts/board.test.mjs +0 -3121
  20. package/scripts/brief-after-cut-prose.test.mjs +0 -53
  21. package/scripts/candidates-exit3-prose.test.mjs +0 -302
  22. package/scripts/candidates.test.mjs +0 -2312
  23. package/scripts/caveat-unification-prose.test.mjs +0 -98
  24. package/scripts/cell-readout.test.mjs +0 -615
  25. package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
  26. package/scripts/ci-completes-premise-prose.test.mjs +0 -257
  27. package/scripts/ci-state-prose.test.mjs +0 -113
  28. package/scripts/ci-state.test.mjs +0 -1933
  29. package/scripts/ci-vacuous-green.test.mjs +0 -368
  30. package/scripts/citation-sweep-prose.test.mjs +0 -1712
  31. package/scripts/claim-lifecycle.test.mjs +0 -187
  32. package/scripts/claim-ticket.test.mjs +0 -1122
  33. package/scripts/closing-keyword-prose.test.mjs +0 -193
  34. package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
  35. package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
  36. package/scripts/compute-board.test.mjs +0 -1214
  37. package/scripts/compute-spend.test.mjs +0 -517
  38. package/scripts/consumer-technology-prose.test.mjs +0 -126
  39. package/scripts/cross-repo-citation-prose.test.mjs +0 -155
  40. package/scripts/cwd-isolation-pins.mjs +0 -83
  41. package/scripts/dedupe-guard-prose.test.mjs +0 -243
  42. package/scripts/delete-merged-branch.test.mjs +0 -576
  43. package/scripts/derive-testcmd.test.mjs +0 -595
  44. package/scripts/diff-stats.test.mjs +0 -404
  45. package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
  46. package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
  47. package/scripts/dispositions-check.test.mjs +0 -936
  48. package/scripts/dispositions-gate-prose.test.mjs +0 -129
  49. package/scripts/drop-merged-label.test.mjs +0 -479
  50. package/scripts/exec-stub.mjs +0 -93
  51. package/scripts/exec-stub.test.mjs +0 -69
  52. package/scripts/expected-jobs-prose.test.mjs +0 -80
  53. package/scripts/fan-out-authorization-prose.test.mjs +0 -80
  54. package/scripts/filing-bar-seat-prose.test.mjs +0 -242
  55. package/scripts/filing-claim-bar-prose.test.mjs +0 -166
  56. package/scripts/finisher-died-prose.test.mjs +0 -31
  57. package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
  58. package/scripts/finisher-halt-prose.test.mjs +0 -106
  59. package/scripts/finisher-name-prose.test.mjs +0 -134
  60. package/scripts/finisher-own-tree-prose.test.mjs +0 -299
  61. package/scripts/finisher-pin-race-prose.test.mjs +0 -339
  62. package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
  63. package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
  64. package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
  65. package/scripts/fleet-bootstrap.test.mjs +0 -75
  66. package/scripts/fleet-heartbeat.test.mjs +0 -450
  67. package/scripts/fleet-provenance.test.mjs +0 -138
  68. package/scripts/fleet-run.test.mjs +0 -90
  69. package/scripts/fleet-state.test.mjs +0 -460
  70. package/scripts/fleet-tick-prose.test.mjs +0 -300
  71. package/scripts/fleet-tick.test.mjs +0 -2444
  72. package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
  73. package/scripts/frontmatter-check.test.mjs +0 -436
  74. package/scripts/git-env.test.mjs +0 -149
  75. package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
  76. package/scripts/gone-walk.test.mjs +0 -213
  77. package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
  78. package/scripts/head-moved-after-label-prose.test.mjs +0 -233
  79. package/scripts/immutable-body-claim-prose.test.mjs +0 -204
  80. package/scripts/implementer-model-tier.test.mjs +0 -235
  81. package/scripts/inflight-citation-prose.test.mjs +0 -144
  82. package/scripts/inflight-exit2-prose.test.mjs +0 -81
  83. package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
  84. package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
  85. package/scripts/inflight.test.mjs +0 -2882
  86. package/scripts/injection-control-prose.test.mjs +0 -404
  87. package/scripts/install-root-audit.test.mjs +0 -464
  88. package/scripts/instrument-check-prose.test.mjs +0 -235
  89. package/scripts/instruments.test.mjs +0 -787
  90. package/scripts/is-cli.test.mjs +0 -99
  91. package/scripts/issue-tracker-prose.test.mjs +0 -71
  92. package/scripts/json.test.mjs +0 -364
  93. package/scripts/ledger-dispatch.test.mjs +0 -927
  94. package/scripts/ledger-grammar.test.mjs +0 -227
  95. package/scripts/ledger-read-require-file.test.mjs +0 -197
  96. package/scripts/ledger-rotate.test.mjs +0 -142
  97. package/scripts/ledger.test.mjs +0 -3436
  98. package/scripts/line-distance-prose.test.mjs +0 -245
  99. package/scripts/liveness-rationale-prose.test.mjs +0 -83
  100. package/scripts/locale-pin-prose.test.mjs +0 -189
  101. package/scripts/main-checkout.test.mjs +0 -332
  102. package/scripts/member-outcome-prose.test.mjs +0 -167
  103. package/scripts/member-outcomes-header.test.mjs +0 -129
  104. package/scripts/member-outcomes-prose.test.mjs +0 -63
  105. package/scripts/member-outcomes.test.mjs +0 -638
  106. package/scripts/member-prompt-prose.test.mjs +0 -165
  107. package/scripts/member-record.test.mjs +0 -541
  108. package/scripts/member-write-guard.test.mjs +0 -214
  109. package/scripts/merge-commit-probe-prose.test.mjs +0 -122
  110. package/scripts/merge-gate.test.mjs +0 -613
  111. package/scripts/muted-git-guard-sweep.test.mjs +0 -493
  112. package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
  113. package/scripts/net-watchdog-prose.test.mjs +0 -79
  114. package/scripts/net.test.mjs +0 -211
  115. package/scripts/no-ci-gate-prose.test.mjs +0 -108
  116. package/scripts/no-undo-audit.test.mjs +0 -3961
  117. package/scripts/no-wave.test.mjs +0 -138
  118. package/scripts/node-floor-sweep.test.mjs +0 -611
  119. package/scripts/pointer-target-prose.test.mjs +0 -186
  120. package/scripts/pr-cost.test.mjs +0 -521
  121. package/scripts/pr-overlap.test.mjs +0 -692
  122. package/scripts/printf-die-sweep.test.mjs +0 -384
  123. package/scripts/prompt-renderer.mjs +0 -40
  124. package/scripts/prompt-renderer.test.mjs +0 -68
  125. package/scripts/prose-pin.mjs +0 -807
  126. package/scripts/prose-pin.test.mjs +0 -1034
  127. package/scripts/prove-merge.test.mjs +0 -995
  128. package/scripts/pull-table-relabel-prose.test.mjs +0 -60
  129. package/scripts/quiet-payload-prose.test.mjs +0 -222
  130. package/scripts/reap-cherry-check-prose.test.mjs +0 -80
  131. package/scripts/reap.test.mjs +0 -4432
  132. package/scripts/reaping-prose.test.mjs +0 -239
  133. package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
  134. package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
  135. package/scripts/recipe-derivation-prose.test.mjs +0 -112
  136. package/scripts/recipe-prove.test.mjs +0 -1042
  137. package/scripts/refuter-scratch-prose.test.mjs +0 -135
  138. package/scripts/release-label-required-prose.test.mjs +0 -71
  139. package/scripts/release-label-split-prose.test.mjs +0 -184
  140. package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
  141. package/scripts/release-ticket.test.mjs +0 -5099
  142. package/scripts/renovate-release-contract.test.mjs +0 -379
  143. package/scripts/repo-root.test.mjs +0 -873
  144. package/scripts/reporter-output-rule-prose.test.mjs +0 -208
  145. package/scripts/review-agent-report-only.test.mjs +0 -49
  146. package/scripts/review-core-booking.test.mjs +0 -35
  147. package/scripts/review-core-cwd-isolation.test.mjs +0 -374
  148. package/scripts/review-core-reads.test.mjs +0 -478
  149. package/scripts/review-core-refuter-scratch.test.mjs +0 -148
  150. package/scripts/review-core-scratch-refusal.test.mjs +0 -64
  151. package/scripts/review-core-shared-test-run.test.mjs +0 -275
  152. package/scripts/review-core-snapshot-path.test.mjs +0 -830
  153. package/scripts/review-core-specialist-scratch.test.mjs +0 -191
  154. package/scripts/review-core-testcmd.test.mjs +0 -335
  155. package/scripts/review-core-unrun.test.mjs +0 -566
  156. package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
  157. package/scripts/review-eval-resolver-path.test.mjs +0 -55
  158. package/scripts/review-host-fixture.mjs +0 -89
  159. package/scripts/review-in-run-retry.test.mjs +0 -211
  160. package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
  161. package/scripts/review-path-default.test.mjs +0 -796
  162. package/scripts/review-runner-spawns.test.mjs +0 -95
  163. package/scripts/review-runner.test.mjs +0 -166
  164. package/scripts/review-tier-audit.test.mjs +0 -140
  165. package/scripts/run-artifact-pr-prose.test.mjs +0 -341
  166. package/scripts/run-merge-bot-prose.test.mjs +0 -1413
  167. package/scripts/run-team-local-hook.test.mjs +0 -442
  168. package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
  169. package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
  170. package/scripts/section-between-guard-prose.test.mjs +0 -379
  171. package/scripts/select-dimensions.test.mjs +0 -674
  172. package/scripts/shared-refusal.test.mjs +0 -388
  173. package/scripts/shell-traps-prose.test.mjs +0 -504
  174. package/scripts/shortlist.test.mjs +0 -380
  175. package/scripts/slow-transport.mjs +0 -72
  176. package/scripts/snapshot-repo.test.mjs +0 -1006
  177. package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
  178. package/scripts/spend-view.test.mjs +0 -312
  179. package/scripts/staleness-qualifier-prose.test.mjs +0 -251
  180. package/scripts/staleness-verdict-prose.test.mjs +0 -142
  181. package/scripts/staleness.test.mjs +0 -893
  182. package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
  183. package/scripts/stash-prohibition-prose.test.mjs +0 -313
  184. package/scripts/strip-comments.mjs +0 -44
  185. package/scripts/temp-dir.mjs +0 -47
  186. package/scripts/ticket-router.test.mjs +0 -981
  187. package/scripts/tier-check.test.mjs +0 -828
  188. package/scripts/tier-outcomes-header.test.mjs +0 -518
  189. package/scripts/tier-outcomes.test.mjs +0 -572
  190. package/scripts/tier-roles.test.mjs +0 -535
  191. package/scripts/tracker-block-copy-prose.test.mjs +0 -288
  192. package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
  193. package/scripts/unattended-git-sweep.test.mjs +0 -142
  194. package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
  195. package/scripts/verify-sha.test.mjs +0 -692
  196. package/scripts/watcher-degraded-block.test.mjs +0 -369
  197. package/scripts/watcher-key-prose.test.mjs +0 -106
  198. package/scripts/within-run-pair-prose.test.mjs +0 -212
  199. package/scripts/worktree-audit.test.mjs +0 -1408
  200. package/scripts/worktree-head-prose.test.mjs +0 -276
  201. package/scripts/worktree-listing-sweep.test.mjs +0 -217
  202. package/scripts/worktree-model-prose.test.mjs +0 -216
  203. package/scripts/worktree-porcelain.mjs +0 -35
  204. package/scripts/worktree-porcelain.test.mjs +0 -102
@@ -1,1214 +0,0 @@
1
- // Regression gate for the pure board core. Zero deps:
2
- // node --test plugin/scripts/compute-board.test.mjs
3
- // Locks stage-derivation and the red-vs-stale distinction — the only tricky
4
- // logic — against a "simplification" silently breaking it.
5
- import { test } from "node:test";
6
- import assert from "node:assert/strict";
7
- import { parseRow, deriveColumn, deriveFlags, STALE_MS } from "./compute-board.mjs";
8
-
9
- test("parseRow: a merged row", () => {
10
- const r = parseRow("#332 impl-332=PR#344 → PR#344 → MERGED 73b356de");
11
- assert.equal(r.issue, 332);
12
- assert.equal(r.impl, "impl-332");
13
- assert.equal(r.pr, 344);
14
- assert.equal(r.merged, true);
15
- assert.equal(r.sha, "73b356de");
16
- assert.equal(r.agent, null, "impl-332 settled at PR#344 — nobody is live on this row");
17
- assert.equal(r.heldBehind, null);
18
- });
19
-
20
- test("parseRow: an in-review row with a live review runner, ruling and held-behind", () => {
21
- const r = parseRow("#324 impl-324=PR#346 → PR#346 · review=member:review-pr-346-b · ports=16324 · ruled:6-applies · held-behind:#313");
22
- assert.equal(r.issue, 324);
23
- assert.equal(r.impl, "impl-324");
24
- assert.equal(r.agent, "review-pr-346-b");
25
- assert.equal(r.pr, 346);
26
- assert.equal(r.merged, false);
27
- assert.equal(r.heldBehind, 313);
28
- });
29
-
30
- test("parseRow: implementing row, no PR yet", () => {
31
- const r = parseRow("#340 impl-340");
32
- assert.equal(r.pr, null);
33
- assert.equal(r.merged, false);
34
- assert.deepEqual(r.causes, []);
35
- });
36
-
37
- test("parseRow: enrichment cause tokens are lowercased", () => {
38
- const r = parseRow("#319 impl-319 KILLED");
39
- assert.deepEqual(r.causes, ["killed"]);
40
- });
41
-
42
- test("parseRow: a non-ticket line returns null", () => {
43
- assert.equal(parseRow("## Rows"), null);
44
- });
45
-
46
- test("deriveColumn: MERGED wins from the ledger alone", () => {
47
- const p = parseRow("#332 impl-332=PR#344 → PR#344 → MERGED 73b356de");
48
- assert.equal(deriveColumn(p, { open: false, labels: [] }), "MERGED");
49
- });
50
-
51
- test("deriveColumn: READY when the PR carries ready-to-merge", () => {
52
- const p = parseRow("#324 impl-324=PR#346 → PR#346 · review=member:review-pr-346");
53
- assert.equal(deriveColumn(p, { open: true, labels: ["ready-to-merge"] }), "READY");
54
- });
55
-
56
- test("deriveColumn: REVIEW when a PR exists without the label", () => {
57
- const p = parseRow("#324 impl-324=PR#346 → PR#346 · review=member:review-pr-346");
58
- assert.equal(deriveColumn(p, { open: true, labels: [] }), "REVIEW");
59
- });
60
-
61
- test("deriveColumn: IMPLEMENTING when there is no PR yet", () => {
62
- const p = parseRow("#340 impl-340");
63
- assert.equal(deriveColumn(p, null), "IMPLEMENTING");
64
- });
65
-
66
- const MIN = 60 * 1000;
67
-
68
- test("deriveFlags: red CI flags red-ci", () => {
69
- const p = parseRow("#324 impl-324=PR#346 → PR#346");
70
- const f = deriveFlags(p, { ci: "red", column: "REVIEW", sinceEnteredStage: null, now: 0 });
71
- assert.ok(f.includes("red-ci"));
72
- });
73
-
74
- test("deriveFlags: unknown CI never flags red", () => {
75
- const p = parseRow("#324 impl-324=PR#346 → PR#346");
76
- const f = deriveFlags(p, { ci: "unknown", column: "REVIEW", sinceEnteredStage: null, now: 0 });
77
- assert.ok(!f.includes("red-ci"));
78
- });
79
-
80
- test("deriveFlags: held-behind carries the blocker number", () => {
81
- const p = parseRow("#324 impl-324=PR#346 → PR#346 · held-behind:#313");
82
- const f = deriveFlags(p, { ci: "green", column: "REVIEW", sinceEnteredStage: null, now: 0 });
83
- assert.ok(f.includes("held-behind:#313"));
84
- });
85
-
86
- test("deriveFlags: stale when dwell exceeds the column threshold", () => {
87
- const p = parseRow("#340 impl-340");
88
- const now = 100 * MIN;
89
- const f = deriveFlags(p, { ci: null, column: "IMPLEMENTING", sinceEnteredStage: now - (STALE_MS.IMPLEMENTING + MIN), now });
90
- assert.ok(f.includes("stale"));
91
- });
92
-
93
- test("deriveFlags: fresh dwell is not stale", () => {
94
- const p = parseRow("#340 impl-340");
95
- const now = 100 * MIN;
96
- const f = deriveFlags(p, { ci: null, column: "IMPLEMENTING", sinceEnteredStage: now - MIN, now });
97
- assert.ok(!f.includes("stale"));
98
- });
99
-
100
- test("deriveFlags: cause tokens surface as flags", () => {
101
- const p = parseRow("#319 impl-319 KILLED");
102
- const f = deriveFlags(p, { ci: null, column: "IMPLEMENTING", sinceEnteredStage: 0, now: 0 });
103
- assert.ok(f.includes("killed"));
104
- });
105
-
106
- import { computeBoard, mergedReadPrs } from "./compute-board.mjs";
107
- import { deriveRun } from "./fleet-tick.mjs";
108
-
109
- const baseInputs = () => ({
110
- ledger: {
111
- rows: [
112
- "#332 impl-332=PR#344 → PR#344 → MERGED 73b356de",
113
- "#324 impl-324=PR#346 → PR#346 · review=member:review-pr-346 · held-behind:#313",
114
- "#340 impl-340",
115
- ],
116
- filed: ["#351 flaky retry marker in ci logs"],
117
- ruled: ["#346 6-applies keep the fallback"],
118
- },
119
- issues: [{ number: 341, title: "add a --json flag", labels: ["ready-for-agent"] }],
120
- prs: [
121
- { number: 344, state: "MERGED", labels: [], title: "impl 332" },
122
- { number: 346, state: "OPEN", labels: [], title: "impl 324" },
123
- ],
124
- ci: { 344: "green", 346: "red" },
125
- prev: null,
126
- now: 1000,
127
- repo: "owner/repo",
128
- repoUrl: "https://example.test/owner/repo",
129
- workspace: "/w/one",
130
- port: 8337,
131
- });
132
-
133
- test("computeBoard: one ticket per column, POOL from an unrowed ready issue", () => {
134
- const b = computeBoard(baseInputs());
135
- const col = (n) => b.tickets.find((t) => t.issue === n).column;
136
- assert.equal(col(332), "MERGED");
137
- assert.equal(col(324), "REVIEW");
138
- assert.equal(col(340), "IMPLEMENTING");
139
- assert.equal(col(341), "POOL");
140
- });
141
-
142
- // #1331: candidates.mjs's EXCLUDE negates all five wayfinder:* labels so a
143
- // wayfinder ticket never enters the DISPATCH scan regardless of triage role,
144
- // but the POOL loop below used to show one anyway — a ready-for-agent
145
- // wayfinder ticket (#1293's shape) rendered as an undispatchable POOL card,
146
- // inflating the operator's read of available work. Filtered by label prefix
147
- // here, in the POOL loop itself, not by narrowing gather()'s gh query —
148
- // narrowing the query also strips the ticket from `issues`, which titleFor()
149
- // below reads for ledger rows that have nothing to do with POOL (see the next
150
- // test).
151
- test("computeBoard: an unrowed wayfinder:* issue never becomes a POOL card", () => {
152
- const b = computeBoard({
153
- ...baseInputs(),
154
- issues: [{ number: 341, title: "add a --json flag", labels: ["ready-for-agent", "wayfinder:task"] }],
155
- });
156
- assert.equal(b.tickets.find((t) => t.issue === 341), undefined);
157
- });
158
-
159
- // The fix for the regression above must not reach into gather()'s gh query:
160
- // doing so also drops the wayfinder-labelled issue from `issues`, which
161
- // titleFor() reads for every non-PR ledger row (e.g. #340, IMPLEMENTING, no
162
- // PR yet) whose issue happens to carry a wayfinder label for an unrelated
163
- // reason. Losing that lookup regresses #340's card to a bare `#340` even
164
- // though only the POOL column was ever supposed to change.
165
- test("computeBoard: a ledger-row ticket linked to a wayfinder-labelled issue keeps its real title", () => {
166
- const b = computeBoard({
167
- ...baseInputs(),
168
- issues: [
169
- { number: 341, title: "add a --json flag", labels: ["ready-for-agent"] },
170
- { number: 340, title: "real ledger-row title", labels: ["wayfinder:task"] },
171
- ],
172
- });
173
- assert.equal(b.tickets.find((t) => t.issue === 340).title, "real ledger-row title");
174
- });
175
-
176
- // #786 review: board.mjs used to default a PR row's missing `state` to
177
- // "UNKNOWN" before handing it here. That default was inert — `pr.state ===
178
- // "OPEN"` (below) is already false for `undefined`, same as for "UNKNOWN" —
179
- // so board.mjs now passes `state` through raw. Pin the OBSERVABLE effect
180
- // rather than the internal sentinel value: a PR row with no `state` at all
181
- // still lands in REVIEW like any other open-PR ticket, not crashed or
182
- // silently misplaced by the missing field.
183
- test("computeBoard: a PR row with no state still lands in REVIEW", () => {
184
- const b = computeBoard({
185
- ...baseInputs(),
186
- prs: [{ number: 344, labels: [], title: "impl 332" }],
187
- ledger: { rows: ["#332 impl-332=PR#344 → PR#344"], filed: [], ruled: [] },
188
- });
189
- assert.equal(b.tickets.find((t) => t.issue === 332).column, "REVIEW");
190
- });
191
-
192
- test("computeBoard: ruling attaches to the PR ticket", () => {
193
- const b = computeBoard(baseInputs());
194
- assert.equal(b.tickets.find((t) => t.issue === 324).ruling, "6-applies keep the fallback");
195
- });
196
-
197
- test("computeBoard: attention holds only flagged tickets, red-ci before held-behind", () => {
198
- const b = computeBoard(baseInputs());
199
- assert.deepEqual(b.attention.map((t) => t.issue), [324]); // red-ci + held-behind
200
- assert.ok(b.attention[0].flags.includes("red-ci"));
201
- });
202
-
203
- test("computeBoard: filed follow-ups are parsed to {issue,subject}", () => {
204
- const b = computeBoard(baseInputs());
205
- assert.deepEqual(b.filed, [{ issue: 351, subject: "flaky retry marker in ci logs" }]);
206
- });
207
-
208
- test("computeBoard: dwell carries forward while the column is unchanged", () => {
209
- const first = computeBoard({ ...baseInputs(), now: 1000 });
210
- const second = computeBoard({ ...baseInputs(), prev: first, now: 5000 });
211
- // #340 stayed IMPLEMENTING → keep the original entry time
212
- assert.equal(second.tickets.find((t) => t.issue === 340).sinceEnteredStage, 1000);
213
- });
214
-
215
- test("computeBoard: dwell resets when the column changes", () => {
216
- const first = computeBoard({ ...baseInputs(), now: 1000 });
217
- const moved = baseInputs();
218
- moved.ledger.rows[2] = "#340 impl-340=PR#360 → PR#360"; // now REVIEW
219
- moved.prs.push({ number: 360, state: "OPEN", labels: [], title: "impl 340" });
220
- const second = computeBoard({ ...moved, prev: first, now: 5000 });
221
- assert.equal(second.tickets.find((t) => t.issue === 340).sinceEnteredStage, 5000);
222
- });
223
-
224
- test("computeBoard: queue counts pool and review-backlog", () => {
225
- const b = computeBoard(baseInputs());
226
- assert.equal(b.queue.pool, 1);
227
- // #324 has a reviewer token, so it is NOT backlog
228
- assert.equal(b.queue.reviewBacklog, 0);
229
- });
230
-
231
- test("computeBoard: the instance identity — repo, repoUrl, workspace, port — is echoed, never derived", () => {
232
- const b = computeBoard(baseInputs());
233
- assert.equal(b.repo, "owner/repo");
234
- assert.equal(b.repoUrl, "https://example.test/owner/repo");
235
- // #1584: gather() joins these from resolveCockpitInstance(); this module
236
- // reads no cwd, no git and no socket, so an echo is the whole contract.
237
- assert.equal(b.workspace, "/w/one");
238
- assert.equal(b.port, 8337);
239
- });
240
-
241
- // A caller with no instance to name — every hand-built inputs object, and the
242
- // gather() drivers in board-prev-shape.test.mjs — must still produce a board
243
- // carrying both KEYS. `undefined` disappears from JSON.stringify, and the
244
- // launch handshake #1585 added reads `workspace` straight off the served
245
- // JSON: a board with the key missing is a board it can never match.
246
- test("computeBoard: absent workspace/port are null, not missing keys", () => {
247
- const inp = baseInputs();
248
- delete inp.workspace;
249
- delete inp.port;
250
- const b = computeBoard(inp);
251
- assert.equal(b.workspace, null);
252
- assert.equal(b.port, null);
253
- });
254
-
255
- test("computeBoard: a PR with no CI entry is unknown, not null (null means no PR)", () => {
256
- const inp = baseInputs();
257
- delete inp.ci[346]; // #324's PR exists but CI has not reported
258
- const t = computeBoard(inp).tickets.find((x) => x.issue === 324);
259
- assert.equal(t.ci, "unknown");
260
- // a genuinely PR-less ticket still reports null
261
- assert.equal(computeBoard(inp).tickets.find((x) => x.issue === 340).ci, null);
262
- });
263
-
264
- test("computeBoard: ledgerState reflects gather()'s read outcome", () => {
265
- for (const state of ["unread", "unparsed", "read"]) {
266
- const inp = baseInputs();
267
- inp.ledger = { ...inp.ledger, state };
268
- assert.equal(computeBoard(inp).ledgerState, state);
269
- }
270
- });
271
-
272
- test("computeBoard: ledgerState defaults to read when gather() reports none", () => {
273
- const inp = baseInputs(); // ledger has no `state` key
274
- assert.equal(computeBoard(inp).ledgerState, "read");
275
- });
276
-
277
- // --------------------------------------------------------------------------
278
- // The liveness surface — #1597. `beat` is telemetry beside `spend`, under the
279
- // same rule: it can only ever POPULATE or OMIT `liveness`, never move a
280
- // ticket. The cockpit is one renderer of the heartbeat's mark, never the
281
- // thing that holds it.
282
-
283
- // `now` in baseInputs is 1000ms past the epoch, which is a fine clock for
284
- // dwell but useless for an age in minutes — so the liveness cases move it
285
- // somewhere a 20-minute-old mark can exist behind it.
286
- const NOW = 2_000_000_000_000;
287
- const livenessInputs = (beat) => ({ ...baseInputs(), now: NOW, beat });
288
-
289
- test("computeBoard: a stalled beat populates `liveness` with what is stranded", () => {
290
- const b = computeBoard(livenessInputs({ at: NOW - 90 * 60_000, interval: 1200, stopped: "" }));
291
- assert.equal(b.liveness.kind, "stale");
292
- // Counted off THIS model rather than re-queried: a ticket past POOL and
293
- // short of MERGED is one the ledger placed and nothing landed — the same
294
- // population the claim label marks, reached from the ledger the cockpit
295
- // already read. #324 (REVIEW) and #340 (IMPLEMENTING); #332 merged, #341 is
296
- // still pool.
297
- assert.equal(b.liveness.claimed, 2);
298
- assert.equal(b.liveness.supply, b.queue.pool);
299
- // The rendered line rides the payload because board.html is served as one
300
- // self-contained file and cannot import the rule. A second wording on the
301
- // page is a second answer to "is this run dead".
302
- assert.match(b.liveness.text, /heartbeat STALLED/);
303
- assert.match(b.liveness.text, /2 ticket\(s\) claimed and in flight/);
304
- assert.match(b.liveness.text, /70m past the 20m interval it promised/);
305
- });
306
-
307
- test("computeBoard: a failed ledger or pool read reports `unknown`, never a false zero", () => {
308
- // #1597 follow-up. `claimed`/`supply` derive from `ledger.rows`/`issues`,
309
- // which both collapse to the SAME empty array on a genuinely-drained read
310
- // and on a failed one (gather()'s tryRun/tryParse fallback) — the exact
311
- // collapse `ledgerState` exists to undo elsewhere on this same board. A
312
- // stall banner that quietly prints "0 claimed, pool supply 0" off a read
313
- // that never happened is the one report an operator has no reason to
314
- // distrust, and it also outranks and hides the ledger-read-failed banner
315
- // that would have explained the zeros.
316
- const stale = { at: NOW - 90 * 60_000, interval: 1200, stopped: "" };
317
-
318
- // Ledger read failed — the ticket-derived half must go unknown, and the
319
- // pool half, which never depended on the ledger, must stay a real count.
320
- const noLedger = computeBoard({
321
- ...livenessInputs(stale), ledger: { rows: [], filed: [], ruled: [], state: "unread" },
322
- });
323
- assert.equal(noLedger.liveness.claimed, null);
324
- assert.equal(noLedger.liveness.supply, noLedger.queue.pool);
325
- assert.match(noLedger.liveness.text, /unknown ticket\(s\) claimed and in flight/);
326
-
327
- // Pool read failed — the reverse split.
328
- const noPool = computeBoard({ ...livenessInputs(stale), poolOk: false });
329
- assert.equal(noPool.liveness.claimed, 2);
330
- assert.equal(noPool.liveness.supply, null);
331
- assert.match(noPool.liveness.text, /pool supply unknown/);
332
-
333
- // Both failed at once.
334
- const both = computeBoard({
335
- ...livenessInputs(stale), ledger: { rows: [], filed: [], ruled: [], state: "unparsed" }, poolOk: false,
336
- });
337
- assert.equal(both.liveness.claimed, null);
338
- assert.equal(both.liveness.supply, null);
339
-
340
- // A read that genuinely succeeded and came back empty is still a real 0,
341
- // never smuggled into `unknown` by an over-broad guard.
342
- const emptyOk = computeBoard({
343
- ...livenessInputs(stale), ledger: { rows: [], filed: [], ruled: [], state: "read" },
344
- });
345
- assert.equal(emptyOk.liveness.claimed, 0);
346
- });
347
-
348
- test("#2108: a capped pool read reaches the stall line as a floor, the same value the footer shows", () => {
349
- // stall() is handed the model's pool, so the line cannot print a bare count
350
- // the footer beside it has already retracted with a `+`.
351
- const stale = { at: NOW - 90 * 60_000, interval: 1200, stopped: "" };
352
- const b = computeBoard({ ...livenessInputs(stale), poolCapped: true });
353
- assert.equal(b.queue.pool, "1+");
354
- assert.equal(b.liveness.supply, "1+");
355
- assert.match(b.liveness.text, /pool supply 1\+/);
356
- });
357
-
358
- test("computeBoard: a healthy or absent beat omits the surface rather than rendering an empty one", () => {
359
- // Null, not an `{ ok: true }`-shaped nothing: the page hides the banner on
360
- // null, and a banner that fires on every healthy tick is a banner the
361
- // operator learns to read past — which would cost exactly the one night it
362
- // was built for.
363
- assert.equal(computeBoard(livenessInputs({ at: NOW - 60_000, interval: 300, stopped: "" })).liveness, null);
364
- assert.equal(computeBoard(livenessInputs(null)).liveness, null);
365
- // And a caller that passes no `beat` at all — every hand-built test driver,
366
- // and any board.json written before this key existed — gets the same null
367
- // rather than a crash or an undefined key.
368
- const inp = baseInputs();
369
- delete inp.beat;
370
- assert.equal(computeBoard(inp).liveness, null);
371
- });
372
-
373
- test("computeBoard: a deliberate stop reaches the page with its reason", () => {
374
- const b = computeBoard(livenessInputs({ at: NOW - 60_000, interval: 300, stopped: "budget exhausted" }));
375
- assert.equal(b.liveness.kind, "stopped");
376
- assert.match(b.liveness.text, /recorded reason: budget exhausted/);
377
- });
378
-
379
- test("computeBoard: a liveness input can never change a ticket's stage", () => {
380
- // The constraint the ticket states in its own words, and the one a
381
- // populate/omit assertion alone would not catch: a stall must not flag,
382
- // re-column, re-dwell or promote anything. The dead controller is the
383
- // reason nobody is moving the tickets; it is not itself a ticket movement.
384
- const quiet = computeBoard(livenessInputs(null));
385
- for (const beat of [
386
- { at: NOW - 90 * 60_000, interval: 1200, stopped: "" },
387
- { at: NOW - 60_000, interval: 300, stopped: "budget exhausted" },
388
- { at: NOW - 60_000, interval: 300, stopped: "" },
389
- ]) {
390
- const b = computeBoard(livenessInputs(beat));
391
- assert.deepEqual(b.tickets, quiet.tickets, "a liveness input moved a ticket");
392
- assert.deepEqual(b.attention, quiet.attention, "a liveness input raised an attention row");
393
- assert.deepEqual(b.queue, quiet.queue, "a liveness input changed the queue counts");
394
- }
395
- });
396
-
397
- // --------------------------------------------------------------------------
398
- // #1820: the Pull-era ledger. The rows below are #1820's own reproduction
399
- // rows, verbatim, measured on main @ 9b147b2 as stale IMPLEMENTING/REVIEW
400
- // cards that all counted in the stall report's `claimed`. PRs 920, 931 and
401
- // 932 are open; 930 is not in the open list, and gh reports it merged.
402
- const REPRO_ROWS = [
403
- "#901 excluded · behind-pr:#880",
404
- "#902 excluded · behind-issue:#870",
405
- "#903 impl-903=bailed",
406
- "#904 impl-904=killed",
407
- "#905 impl-905=PR#920 · fix-pr-920=failed",
408
- "#906 impl-906",
409
- "#907 impl-907=PR#930",
410
- "#908 impl-908=PR#931 · review=wf:r123",
411
- "#909 impl-909=PR#932 · review=member:review-pr-932",
412
- ];
413
- const openPr = (number, labels = [], headRefOid = null) => ({ number, state: "OPEN", labels, title: `pr ${number}`, headRefOid });
414
- const HOUR = 60 * MIN;
415
- // A prior stage entry 1 h old for every row, in the column each row showed on
416
- // main — the measurement's setup, so every non-terminal card is past its
417
- // dwell threshold and any `stale` a card should not carry would show.
418
- const reproInputs = (over = {}) => {
419
- const now = 10 * HOUR;
420
- const rows = over.rows ?? REPRO_ROWS;
421
- const was = (n) => ([905, 907, 908, 909].includes(n) ? "REVIEW" : "IMPLEMENTING");
422
- return {
423
- ...baseInputs(),
424
- ledger: { rows, filed: [], ruled: [] },
425
- issues: [],
426
- prs: [openPr(920), openPr(931), openPr(932)],
427
- merged: [930],
428
- ci: {},
429
- prev: { tickets: rows.map((r) => Number(r.slice(1).split(" ")[0])).map((issue) => ({ issue, column: was(issue), sinceEnteredStage: now - HOUR })) },
430
- now,
431
- ...over,
432
- };
433
- };
434
- const card = (b, n) => b.tickets.find((t) => t.issue === n);
435
-
436
- test("#1820: an Exclusion is a POOL card with its premise as a badge — never stale, never in attention", () => {
437
- const b = computeBoard(reproInputs());
438
- for (const [n, badge] of [[901, "excluded:#880"], [902, "excluded:#870"]]) {
439
- assert.equal(card(b, n).column, "POOL");
440
- assert.deepEqual(card(b, n).flags, [badge]);
441
- assert.equal(card(b, n).agent, null);
442
- assert.ok(!b.attention.some((t) => t.issue === n), `#${n} is supply, not a stranded claim`);
443
- }
444
- assert.equal(b.queue.pool, 2, "both Exclusions count as pool supply");
445
- assert.equal(b.queue.supply, 2);
446
- });
447
-
448
- test("#1820: a branch-named behind-pr premise is its own badge, not a number", () => {
449
- // Live-ledger shape: the premise is the branch name recorded before its PR existed.
450
- const b = computeBoard(reproInputs({ rows: ["#1716 excluded · behind-pr:implementer/1715-impl-1715", "#1717 excluded · behind-pr:#implementer/1690-slug"] }));
451
- assert.deepEqual(card(b, 1716).flags, ["excluded:implementer/1715-impl-1715"]);
452
- assert.deepEqual(card(b, 1717).flags, ["excluded:implementer/1690-slug"]);
453
- assert.equal(card(b, 1716).column, "POOL");
454
- });
455
-
456
- test("#1820: `excluded` only as the row's first word makes an Exclusion", () => {
457
- const b = computeBoard(reproInputs({ rows: ["#1705 impl-1705 · previously excluded · behind-pr:#60"] }));
458
- assert.equal(card(b, 1705).column, "IMPLEMENTING");
459
- assert.equal(card(b, 1705).agent, "impl-1705");
460
- assert.ok(!card(b, 1705).flags.some((f) => f.startsWith("excluded")));
461
- });
462
-
463
- test("#1820: a released or bailed implementer is a POOL card while ready-for-agent, else no card", () => {
464
- const gone = computeBoard(reproInputs());
465
- assert.equal(card(gone, 903), undefined, "#903 bailed and left the ready-for-agent list — relabelled out by cause");
466
- const rows = ["#903 impl-903=bailed", "#910 impl-910=released"];
467
- const back = computeBoard(reproInputs({
468
- rows,
469
- issues: [{ number: 903, title: "t903", labels: ["ready-for-agent"] }, { number: 910, title: "t910", labels: ["ready-for-agent"] }],
470
- }));
471
- for (const n of [903, 910]) {
472
- assert.equal(card(back, n).column, "POOL");
473
- assert.deepEqual(card(back, n).flags, []);
474
- }
475
- assert.equal(back.tickets.length, 2, "one card per ticket, not a row card beside the pool card");
476
- });
477
-
478
- test("#1820: a killed or tier-mismatch implementer stays IMPLEMENTING, flagged in attention", () => {
479
- const b = computeBoard(reproInputs({ rows: ["#904 impl-904=killed", "#911 impl-911=tier-mismatch"] }));
480
- assert.equal(card(b, 904).column, "IMPLEMENTING");
481
- assert.ok(card(b, 904).flags.includes("killed"));
482
- assert.equal(card(b, 911).column, "IMPLEMENTING");
483
- assert.ok(card(b, 911).flags.includes("tier-mismatch"));
484
- assert.deepEqual(b.attention.map((t) => t.issue).sort(), [904, 911]);
485
- assert.equal(card(b, 904).agent, null, "a settled member is not live");
486
- });
487
-
488
- test("#1820: the uppercase enrichment causes keep working, and KILLED beside =killed flags once", () => {
489
- const b = computeBoard(reproInputs({ rows: ["#912 impl-912 BLOCKED", "#913 impl-913=PR#931 SHA-OFF-BRANCH", "#914 impl-914=killed KILLED"] }));
490
- assert.ok(card(b, 912).flags.includes("blocked"));
491
- assert.ok(card(b, 913).flags.includes("sha-off-branch"));
492
- assert.equal(card(b, 914).flags.filter((f) => f === "killed").length, 1);
493
- });
494
-
495
- test("#1820: the row's LAST impl token decides, retry suffix included", () => {
496
- const b = computeBoard(reproInputs({
497
- rows: ["#915 impl-915=killed · impl-915-b", "#916 impl-916=bailed · impl-916-b=PR#931", "#917 impl-917=PR#920 · impl-917-b"],
498
- }));
499
- assert.equal(card(b, 915).column, "IMPLEMENTING");
500
- assert.equal(card(b, 915).agent, "impl-915-b");
501
- assert.ok(!card(b, 915).flags.includes("killed"), "the killed attempt was replaced");
502
- assert.equal(card(b, 916).column, "REVIEW");
503
- assert.equal(card(b, 916).pr, 931);
504
- assert.equal(card(b, 917).column, "IMPLEMENTING", "a live retry after a settled PR is back at work");
505
- assert.equal(card(b, 917).pr, null);
506
- });
507
-
508
- // #1843: the deciding impl token is the one with the greatest retry suffix,
509
- // wherever it sits in the row. ledger.mjs appends in retry order, so only a
510
- // hand-written `row` rewrite reorders them — and every ordering of the same
511
- // tokens must render the same card. No `prev`, so no card is stale and
512
- // `attention` holds only what the tokens themselves earn.
513
- const permutations = (xs) => (xs.length <= 1 ? [xs]
514
- : xs.flatMap((x, i) => permutations([...xs.slice(0, i), ...xs.slice(i + 1)]).map((rest) => [x, ...rest])));
515
- const cardFor = (row, n) => {
516
- const b = computeBoard(reproInputs({ rows: [row], prev: { tickets: [] } }));
517
- return { card: card(b, n), attention: b.attention.map((t) => t.issue) };
518
- };
519
-
520
- test("#1843: a replacement written before its predecessor still decides the card", () => {
521
- for (const row of ["#5 impl-5-b · class=routine · impl-5=killed", "#5 impl-5=killed · class=routine · impl-5-b"]) {
522
- assert.equal(parseRow(row).impl, "impl-5-b", row);
523
- const { card: c, attention } = cardFor(row, 5);
524
- assert.equal(c.column, "IMPLEMENTING", row);
525
- assert.equal(c.agent, "impl-5-b", row);
526
- assert.deepEqual(c.flags, [], `${row}: the killed attempt was replaced`);
527
- assert.deepEqual(attention, [], row);
528
- }
529
- });
530
-
531
- test("#1843: the greatest retry suffix decides in every ordering of a row's impl tokens", () => {
532
- const rows = permutations(["impl-5=killed", "impl-5-b=PR#9", "impl-5-c"]).map((p) => `#5 ${p.join(" · ")}`);
533
- for (const row of rows) {
534
- assert.equal(parseRow(row).impl, "impl-5-c", row);
535
- assert.deepEqual(cardFor(row, 5), cardFor(rows[0], 5), row);
536
- }
537
- const { card: c } = cardFor(rows[0], 5);
538
- assert.equal(c.column, "IMPLEMENTING", "impl-5-c is live, back at work after PR#9");
539
- assert.equal(c.pr, null);
540
- assert.deepEqual(c.flags, []);
541
- });
542
-
543
- test("#1843: a malformed token never decides, however great its retry suffix", () => {
544
- for (const row of ["#5 impl-5=PR#931 · impl-5-b=PR#93l", "#5 impl-5-b=PR#93l · impl-5=PR#931"]) {
545
- assert.equal(parseRow(row).impl, "impl-5", row);
546
- const { card: c } = cardFor(row, 5);
547
- assert.equal(c.column, "REVIEW", row);
548
- assert.equal(c.pr, 931, row);
549
- assert.ok(c.flags.includes("ledger-error"), row);
550
- }
551
- });
552
-
553
- test("#1843: two distinct impl names at one retry suffix render one card in either order", () => {
554
- // Not a row anything writes; the pick between them is incidental, but it
555
- // must be a function of the tokens, never of which one was typed last.
556
- assert.deepEqual(cardFor("#5 impl-5=killed · impl-6", 5), cardFor("#5 impl-6 · impl-5=killed", 5));
557
- });
558
-
559
- // review-1912-b: laterAttempt's retry-vs-number precedence let a token from
560
- // a DIFFERENT ticket's impl-N lineage outrank this row's own impl token
561
- // whenever the foreign token carried a higher retry suffix, reintroducing
562
- // #1843's own bug class (a dead/unrelated token's outcome read instead of
563
- // this ticket's live one) by a different mechanism than row position. A
564
- // foreign impl number is not "a later attempt" of this ticket at all — retry
565
- // only orders attempts on ONE number — so it must never outrank this row's
566
- // own impl token, however great its retry suffix.
567
- test("review-1912-b: a foreign ticket's impl token never outranks this row's own impl token, however great its retry suffix", () => {
568
- for (const row of ["#5 impl-5 impl-3-z=killed", "#5 impl-3-z=killed impl-5"]) {
569
- assert.equal(parseRow(row).impl, "impl-5", row);
570
- assert.equal(parseRow(row).implOutcome, null, row);
571
- const { card: c } = cardFor(row, 5);
572
- assert.equal(c.column, "IMPLEMENTING", row);
573
- assert.deepEqual(c.flags, [], `${row}: ticket 5 is live, not killed — impl-3-z is ticket 3's token`);
574
- }
575
- });
576
-
577
- // #2083: a finisher halt is the finisher working correctly — it refused to
578
- // label — so the PR parks in REVIEW with no `ready-to-merge`. The cockpit's
579
- // severity-4 flag is what puts it in front of a human.
580
- const HALTED = "#941 impl-941=PR#931 · reviewed=abc1234:0/0/0 · finisher-pr-931=halted:unreadable";
581
-
582
- test("#2083: a PR whose latest finisher halted carries the cause as a flag, ranked exactly at severity 4", () => {
583
- // Two killed (severity 4) rows around the halted one: attention sorts by
584
- // severity and is otherwise stable, so the halted card stays between them
585
- // only at exactly 4 — at 5 it would lead, at 3 or below it would trail.
586
- const b = computeBoard(reproInputs({
587
- rows: ["#904 impl-904=killed", HALTED, "#942 impl-942=killed", "#943 impl-943=PR#932 · held-behind:#931"],
588
- prev: { tickets: [] },
589
- }));
590
- assert.equal(card(b, 941).column, "REVIEW");
591
- assert.deepEqual(card(b, 941).flags, ["halted:unreadable"]);
592
- assert.deepEqual(b.attention.map((t) => t.issue), [904, 941, 942, 943]);
593
- });
594
-
595
- test("#2083: a later finisher attempt decides — a live or labelled `-b` clears the halt, in any token order", () => {
596
- for (const [row, flags] of [
597
- ["#941 impl-941=PR#931 · finisher-pr-931=halted:past-pin · finisher-pr-931-b", []],
598
- ["#941 impl-941=PR#931 · finisher-pr-931-b · finisher-pr-931=halted:past-pin", []],
599
- // The halt clears; the `-b` labelled a PR that still has no label (#2331).
600
- ["#941 impl-941=PR#931 · finisher-pr-931=halted:live-editor · finisher-pr-931-b=labelled", ["unlabelled"]],
601
- ["#941 impl-941=PR#931 · finisher-pr-931=failed · finisher-pr-931-b=halted:rebase", ["halted:rebase"]],
602
- // A bare copy beside the settled token is what a whole-line rewrite
603
- // leaves; the member is still settled halted.
604
- ["#941 impl-941=PR#931 · finisher-pr-931 · finisher-pr-931=halted:other", ["halted:other"]],
605
- // Another PR's finisher is not this PR's latest attempt.
606
- ["#941 impl-941=PR#931 · finisher-pr-931=halted:missing · finisher-pr-950-b=labelled", ["halted:missing"]],
607
- ["#941 impl-941=PR#931 · finisher-pr-950=halted:missing", []],
608
- ]) {
609
- const { card: c } = cardFor(row, 941);
610
- assert.equal(c.column, "REVIEW", row);
611
- assert.deepEqual(c.flags, flags, row);
612
- }
613
- });
614
-
615
- test("#2083: a halt a human already resolved — PR labelled or merged — flags nothing", () => {
616
- const ready = computeBoard(reproInputs({ rows: [HALTED], prs: [openPr(931, ["ready-to-merge"])], prev: { tickets: [] } }));
617
- assert.equal(card(ready, 941).column, "READY");
618
- assert.deepEqual(card(ready, 941).flags, []);
619
- const merged = computeBoard(reproInputs({ rows: [HALTED], prs: [], merged: [931], prev: { tickets: [] } }));
620
- assert.equal(card(merged, 941).column, "MERGED");
621
- assert.deepEqual(card(merged, 941).flags, []);
622
- });
623
-
624
- // #2331: a finisher settled `labelled` on a PR the open list shows without
625
- // `ready-to-merge` — the tick's reading, flagged at severity 4 whether the tick
626
- // is repairing it or has escalated it.
627
- test("#2331: a labelled finisher on a PR without ready-to-merge flags unlabelled, ranked exactly at severity 4", () => {
628
- const b = computeBoard(reproInputs({
629
- rows: ["#904 impl-904=killed", "#941 impl-941=PR#931 · finisher-pr-931=labelled", "#942 impl-942=killed",
630
- "#943 impl-943=PR#932 · held-behind:#931"],
631
- prev: { tickets: [] },
632
- }));
633
- assert.equal(card(b, 941).column, "REVIEW");
634
- assert.deepEqual(card(b, 941).flags, ["unlabelled"]);
635
- assert.deepEqual(b.attention.map((t) => t.issue), [904, 941, 942, 943]);
636
- // Escalated (a second labelled attempt) flags the same.
637
- assert.deepEqual(cardFor("#941 impl-941=PR#931 · finisher-pr-931=labelled · finisher-pr-931-b=labelled", 941).card.flags, ["unlabelled"]);
638
- });
639
-
640
- test("#2331: the label present, a live repair, a label-off'd attempt, or a closed PR flags nothing", () => {
641
- const ready = computeBoard(reproInputs({ rows: ["#941 impl-941=PR#931 · finisher-pr-931=labelled"],
642
- prs: [openPr(931, ["ready-to-merge"])], prev: { tickets: [] } }));
643
- assert.equal(card(ready, 941).column, "READY");
644
- assert.deepEqual(card(ready, 941).flags, []);
645
- for (const row of [
646
- "#941 impl-941=PR#931 · finisher-pr-931=labelled · finisher-pr-931-b",
647
- "#941 impl-941=PR#931 · finisher-pr-931=labelled label-off=finisher-pr-931",
648
- "#941 impl-941=PR#931 · finisher-pr-931",
649
- ]) {
650
- assert.deepEqual(cardFor(row, 941).card.flags, [], row);
651
- }
652
- const merged = computeBoard(reproInputs({ rows: ["#941 impl-941=PR#931 · finisher-pr-931=labelled"], prs: [], merged: [931], prev: { tickets: [] } }));
653
- assert.deepEqual(card(merged, 941).flags, []);
654
- // gh still lists the PR but not as open — no open list to read a missing label off.
655
- for (const state of ["CLOSED", "MERGED"]) {
656
- const shut = computeBoard(reproInputs({ rows: ["#941 impl-941=PR#931 · finisher-pr-931=labelled"],
657
- prs: [{ ...openPr(931), state }], prev: { tickets: [] } }));
658
- assert.deepEqual(card(shut, 941).flags, [], state);
659
- }
660
- // REVIEW only: a card the row already carries past review flags nothing, even unlabelled.
661
- const past = cardFor("#941 impl-941=PR#931 → MERGED abc1234 · finisher-pr-931=labelled", 941).card;
662
- assert.equal(past.column, "MERGED");
663
- assert.deepEqual(past.flags, []);
664
- });
665
-
666
- // The tick reads `## Dispatched` as well as the rows, and a whole-line `row`
667
- // rewrite can drop a settled finisher token from the row while `## Dispatched`
668
- // keeps it. The cockpit reads the same two places, so the card the tick is
669
- // repairing or escalating is the card it flags — and a label-off on the row
670
- // clears both alike.
671
- test("#2331: the cockpit reads `## Dispatched` as the tick does — a settled finisher a row rewrite dropped still flags", () => {
672
- const dispatched = ["impl-941=PR#931", "finisher-pr-931=labelled"];
673
- const open = [{ number: 931, labels: [], closingIssuesReferences: [{ number: 941 }], headRefOid: "abc1234abc1234abc1234abc1234abc1234abcd" }];
674
- for (const [rows, flags] of [
675
- [["#941 impl-941=PR#931 → PR#931 · reviewed=abc1234:0/0/0"], ["unlabelled"]],
676
- [["#941 impl-941=PR#931 → PR#931 · reviewed=abc1234:0/0/0 label-off=finisher-pr-931"], []],
677
- ]) {
678
- const tick = deriveRun({ rows, dispatched, drain: null }, open).unlabelled;
679
- assert.deepEqual(tick.map((u) => u.pr), flags.length ? [931] : [], rows[0]);
680
- const b = computeBoard(reproInputs({ rows, ledger: { rows, dispatched, filed: [], ruled: [] }, prev: { tickets: [] } }));
681
- assert.equal(card(b, 941).column, "REVIEW", rows[0]);
682
- assert.deepEqual(card(b, 941).flags, flags, rows[0]);
683
- }
684
- });
685
-
686
- // A finisher that settled `failed` or `killed` leaves its PR unlabelled with
687
- // nothing dispatched for it, so the cockpit is what surfaces it — one token per
688
- // outcome, distinct from each other, from `unlabelled`, and from the
689
- // implementer's bare `killed`.
690
- test("a PR whose latest finisher settled failed or killed flags finisher:failed / finisher:killed, ranked exactly at severity 4", () => {
691
- for (const outcome of ["failed", "killed"]) {
692
- const b = computeBoard(reproInputs({
693
- rows: ["#904 impl-904=killed", `#941 impl-941=PR#931 · finisher-pr-931=${outcome}`, "#942 impl-942=killed",
694
- "#943 impl-943=PR#932 · held-behind:#931"],
695
- prev: { tickets: [] },
696
- }));
697
- assert.equal(card(b, 941).column, "REVIEW", outcome);
698
- assert.deepEqual(card(b, 941).flags, [`finisher:${outcome}`], outcome);
699
- assert.deepEqual(b.attention.map((t) => t.issue), [904, 941, 942, 943], outcome);
700
- }
701
- });
702
-
703
- test("the finisher's latest attempt decides failed / killed — by suffix order, never token position", () => {
704
- for (const [row, flags] of [
705
- ["#941 impl-941=PR#931 · finisher-pr-931=labelled · finisher-pr-931-b=failed", ["finisher:failed"]],
706
- ["#941 impl-941=PR#931 · finisher-pr-931-b=killed · finisher-pr-931=labelled", ["finisher:killed"]],
707
- ["#941 impl-941=PR#931 · finisher-pr-931=halted:rebase · finisher-pr-931-b=failed", ["finisher:failed"]],
708
- // A later attempt settles it: a labelled one on a PR still without the label is `unlabelled`'s,
709
- // a halt is its own flag, a live repair flags nothing.
710
- ["#941 impl-941=PR#931 · finisher-pr-931=failed · finisher-pr-931-b=labelled", ["unlabelled"]],
711
- ["#941 impl-941=PR#931 · finisher-pr-931-b=labelled · finisher-pr-931=killed", ["unlabelled"]],
712
- ["#941 impl-941=PR#931 · finisher-pr-931=killed · finisher-pr-931-b=halted:other", ["halted:other"]],
713
- ["#941 impl-941=PR#931 · finisher-pr-931=failed · finisher-pr-931-b", []],
714
- ["#941 impl-941=PR#931 · finisher-pr-931-b · finisher-pr-931=failed", []],
715
- // An unsettled bare copy beside the settled token is what a whole-line rewrite leaves.
716
- ["#941 impl-941=PR#931 · finisher-pr-931 · finisher-pr-931=failed", ["finisher:failed"]],
717
- ]) {
718
- const { card: c } = cardFor(row, 941);
719
- assert.equal(c.column, "REVIEW", row);
720
- assert.deepEqual(c.flags, flags, row);
721
- }
722
- });
723
-
724
- test("a failed or killed finisher flags nothing once the label is on, the PR is shut, or a label-off accounts for it", () => {
725
- for (const outcome of ["failed", "killed"]) {
726
- const row = `#941 impl-941=PR#931 · finisher-pr-931=${outcome}`;
727
- const ready = computeBoard(reproInputs({ rows: [row], prs: [openPr(931, ["ready-to-merge"])], prev: { tickets: [] } }));
728
- assert.equal(card(ready, 941).column, "READY");
729
- assert.deepEqual(card(ready, 941).flags, [], outcome);
730
- const merged = computeBoard(reproInputs({ rows: [row], prs: [], merged: [931], prev: { tickets: [] } }));
731
- assert.deepEqual(card(merged, 941).flags, [], outcome);
732
- for (const state of ["CLOSED", "MERGED"]) {
733
- const shut = computeBoard(reproInputs({ rows: [row], prs: [{ ...openPr(931), state }], prev: { tickets: [] } }));
734
- assert.deepEqual(card(shut, 941).flags, [], `${outcome} ${state}`);
735
- }
736
- // REVIEW only: a card the row already carries past review flags nothing.
737
- const past = cardFor(`#941 impl-941=PR#931 → MERGED abc1234 · finisher-pr-931=${outcome}`, 941).card;
738
- assert.equal(past.column, "MERGED");
739
- assert.deepEqual(past.flags, [], outcome);
740
- }
741
- // A label-off naming a later attempt than the failed one cancels it; a failed attempt after the latest label-off flags.
742
- for (const [row, flags] of [
743
- ["#941 impl-941=PR#931 · finisher-pr-931=failed label-off=finisher-pr-931", []],
744
- ["#941 impl-941=PR#931 · finisher-pr-931=failed · finisher-pr-931-b=failed label-off=finisher-pr-931-b", []],
745
- ["#941 impl-941=PR#931 · finisher-pr-931=labelled label-off=finisher-pr-931 · finisher-pr-931-b=failed", ["finisher:failed"]],
746
- ["#941 impl-941=PR#931 · finisher-pr-931=failed label-off=finisher-pr-931 · finisher-pr-931-b=killed", ["finisher:killed"]],
747
- ["#941 impl-941=PR#931 · finisher-pr-931-b=failed label-off=finisher-pr-931", ["finisher:failed"]],
748
- ]) {
749
- assert.deepEqual(cardFor(row, 941).card.flags, flags, row);
750
- }
751
- });
752
-
753
- test("a failed or killed finisher token on another PR's row is a stray; one settled only in `## Dispatched` still flags", () => {
754
- const stray = ["#941 impl-941=PR#931", "#942 impl-942=PR#932 · finisher-pr-931=failed"];
755
- const b = computeBoard(reproInputs({ rows: stray, prev: { tickets: [] } }));
756
- assert.deepEqual(card(b, 941).flags, []);
757
- const masked = ["#941 impl-941=PR#931 · finisher-pr-931=failed", "#942 impl-942=PR#932 · finisher-pr-931-b"];
758
- const m = computeBoard(reproInputs({ rows: masked, prev: { tickets: [] } }));
759
- assert.deepEqual(card(m, 941).flags, ["finisher:failed"]);
760
- const rows = ["#941 impl-941=PR#931 → PR#931 · reviewed=abc1234:0/0/0"];
761
- const d = computeBoard(reproInputs({ rows, ledger: { rows, dispatched: ["impl-941=PR#931", "finisher-pr-931=killed"], filed: [], ruled: [] }, prev: { tickets: [] } }));
762
- assert.deepEqual(card(d, 941).flags, ["finisher:killed"]);
763
- });
764
-
765
- test("the latest finisher attempt decides the halt flag too, whichever of the row and `## Dispatched` holds it", () => {
766
- const flagsFor = (rowToken, dispatchedToken) => {
767
- const rows = [`#941 impl-941=PR#931 → PR#931 · reviewed=abc1234:0/0/0 · ${rowToken}`];
768
- const b = computeBoard(reproInputs({ rows, ledger: { rows, dispatched: ["impl-941=PR#931", dispatchedToken], filed: [], ruled: [] }, prev: { tickets: [] } }));
769
- return card(b, 941).flags;
770
- };
771
- assert.deepEqual(flagsFor("finisher-pr-931=halted:rebase", "finisher-pr-931-b=failed"), ["finisher:failed"]);
772
- assert.deepEqual(flagsFor("finisher-pr-931=failed", "finisher-pr-931-b=halted:rebase"), ["halted:rebase"]);
773
- // ACCEPT side: the halt still flags when it is the latest attempt in the row alone.
774
- assert.deepEqual(flagsFor("finisher-pr-931=halted:rebase", "finisher-pr-931=halted:rebase"), ["halted:rebase"]);
775
- });
776
-
777
- test("#1820: a live implementer is IMPLEMENTING, and still earns stale", () => {
778
- const b = computeBoard(reproInputs());
779
- assert.equal(card(b, 906).column, "IMPLEMENTING");
780
- assert.equal(card(b, 906).agent, "impl-906");
781
- assert.ok(card(b, 906).flags.includes("stale"));
782
- });
783
-
784
- test("#1820: MERGED comes from gh for a row PR absent from the open list", () => {
785
- const b = computeBoard(reproInputs());
786
- assert.equal(card(b, 907).column, "MERGED");
787
- assert.deepEqual(card(b, 907).flags, [], "MERGED is terminal — never stale");
788
- });
789
-
790
- test("#1820: a closed-unmerged PR keeps today's REVIEW column", () => {
791
- const b = computeBoard(reproInputs({ merged: [] }));
792
- assert.equal(card(b, 907).column, "REVIEW");
793
- // `merged` absent entirely — a hand-built caller — means none known.
794
- const inp = reproInputs();
795
- delete inp.merged;
796
- assert.equal(card(computeBoard(inp), 907).column, "REVIEW");
797
- });
798
-
799
- test("#1820: an explicit MERGED token still wins, over the open list and gh alike", () => {
800
- const b = computeBoard(reproInputs({
801
- rows: ["#918 impl-918=PR#931 → PR#931 → MERGED 73b356de"],
802
- prs: [openPr(931, ["ready-to-merge"])],
803
- merged: [],
804
- }));
805
- assert.equal(card(b, 918).column, "MERGED");
806
- });
807
-
808
- test("#1820: the merged read is consulted only for PRs absent from the open list", () => {
809
- const b = computeBoard(reproInputs({ rows: ["#919 impl-919=PR#931"], merged: [931] }));
810
- assert.equal(card(b, 919).column, "REVIEW", "the open list is gh's fresher answer for an open PR");
811
- });
812
-
813
- // #1841: MERGED is terminal. A row PR absent from the open list stays MERGED
814
- // once the previous board already showed the SAME PR, on this ticket,
815
- // MERGED — whether today's merged-PR read failed outright (`[]`) or simply
816
- // succeeded without listing that PR (since #1840 gather() never asks about a
817
- // carried-forward PR, so a successful read never lists it). Keyed on the PR,
818
- // not just the ticket: a retry under a NEW PR after an earlier one merged
819
- // must not inherit that earlier verdict.
820
- test("#1841: a failed merged read carries forward the previous board's MERGED, preserving dwell and excluding it from claimed", () => {
821
- const b = computeBoard(reproInputs({
822
- rows: ["#907 impl-907=PR#930"],
823
- merged: [], // the merged-PR read failed and degraded to []
824
- prev: { tickets: [{ issue: 907, pr: 930, column: "MERGED", sinceEnteredStage: 3 * HOUR }] },
825
- beat: { at: 10 * HOUR - 90 * MIN, interval: 1200, stopped: "" },
826
- }));
827
- const t = card(b, 907);
828
- assert.equal(t.column, "MERGED");
829
- assert.equal(t.sinceEnteredStage, 3 * HOUR, "dwell carried forward from the previous board, not reset");
830
- assert.deepEqual(t.flags, [], "MERGED is terminal — never stale");
831
- assert.equal(b.liveness.claimed, 0, "a carried-forward MERGED ticket is not an outstanding claim");
832
- });
833
-
834
- test("#1841: a successful merged read that simply omits the PR still carries MERGED forward", () => {
835
- const b = computeBoard(reproInputs({
836
- rows: ["#907 impl-907=PR#930"],
837
- merged: [999], // read succeeded without this PR, which gather() no longer asks about (#1840)
838
- prev: { tickets: [{ issue: 907, pr: 930, column: "MERGED", sinceEnteredStage: 3 * HOUR }] },
839
- }));
840
- assert.equal(card(b, 907).column, "MERGED");
841
- });
842
-
843
- test("#1841: with no previous board, a failed merged read still leaves the row REVIEW, as today", () => {
844
- const b = computeBoard(reproInputs({
845
- rows: ["#907 impl-907=PR#930"],
846
- merged: [],
847
- prev: null,
848
- }));
849
- assert.equal(card(b, 907).column, "REVIEW");
850
- });
851
-
852
- test("#1841: an open PR is never forced to MERGED by carry-forward", () => {
853
- const b = computeBoard(reproInputs({
854
- rows: ["#908 impl-908=PR#931"],
855
- prs: [openPr(931)],
856
- prev: { tickets: [{ issue: 908, pr: 931, column: "MERGED", sinceEnteredStage: 3 * HOUR }] },
857
- }));
858
- assert.equal(card(b, 908).column, "REVIEW", "the open list is gh's fresher answer — a stale MERGED carry-forward must not override it");
859
- });
860
-
861
- test("#1841: a retry under a different PR does not inherit the previous board's MERGED for this ticket", () => {
862
- const b = computeBoard(reproInputs({
863
- rows: ["#907 impl-907=PR#930 impl-907-b=PR#940"],
864
- prs: [],
865
- merged: [], // PR#940 was never observed open or merged this run
866
- prev: { tickets: [{ issue: 907, pr: 930, column: "MERGED", sinceEnteredStage: 3 * HOUR }] },
867
- }));
868
- assert.equal(card(b, 907).column, "REVIEW", "the previous MERGED verdict was about PR#930, not today's PR#940 — carry-forward is keyed on the PR, not just the ticket");
869
- });
870
-
871
- test("#1841: a previous board entry for this ticket that was not MERGED never triggers carry-forward", () => {
872
- const b = computeBoard(reproInputs({
873
- rows: ["#907 impl-907=PR#930"],
874
- merged: [],
875
- prev: { tickets: [{ issue: 907, pr: 930, column: "REVIEW", sinceEnteredStage: 3 * HOUR }] },
876
- }));
877
- assert.equal(card(b, 907).column, "REVIEW");
878
- });
879
-
880
- test("#1841: another ticket's MERGED entry in the same previous board does not carry forward onto this row", () => {
881
- const b = computeBoard(reproInputs({
882
- rows: ["#907 impl-907=PR#930", "#908 impl-908=PR#940"],
883
- prs: [],
884
- merged: [],
885
- prev: { tickets: [
886
- { issue: 907, pr: 930, column: "MERGED", sinceEnteredStage: 3 * HOUR },
887
- { issue: 908, pr: 940, column: "REVIEW", sinceEnteredStage: 1 * HOUR },
888
- ] },
889
- }));
890
- assert.equal(card(b, 907).column, "MERGED", "#907's own previous MERGED still carries forward");
891
- assert.equal(card(b, 908).column, "REVIEW", "#908 must not inherit #907's MERGED from the same prev.tickets array");
892
- });
893
-
894
- test("#1841: a no-impl-token PR-bound row (amendment 2a) also carries MERGED forward", () => {
895
- const b = computeBoard(reproInputs({
896
- rows: ["#1237 -> PR#1237 · review=member:review-pr-1237"],
897
- prs: [],
898
- merged: [],
899
- prev: { tickets: [{ issue: 1237, pr: 1237, column: "MERGED", sinceEnteredStage: 3 * HOUR }] },
900
- }));
901
- assert.equal(card(b, 1237).column, "MERGED");
902
- });
903
-
904
- // #1840: gather() asks gh about mergedReadPrs()'s set and nothing else, so
905
- // that set has to be EXACTLY the row PRs whose card `merged` can change: one
906
- // it leaves out renders REVIEW however long ago it merged, and one it adds is
907
- // a wasted question. The invariant is read off computeBoard() itself — the
908
- // PRs whose column moves between "gh knows of no merge" and "gh calls every
909
- // PR merged" — so the two functions cannot drift apart unseen.
910
- test("#1840: mergedReadPrs is exactly the row PRs whose column the merged read can change", () => {
911
- const rows = [
912
- "#901 impl-901=PR#931", // open: the open list answers it
913
- "#902 impl-902=PR#932 → MERGED 73b356de", // token-MERGED
914
- "#903 impl-903=PR#933", // carried forward (#1841)
915
- "#904 impl-904=PR#930 impl-904-b=PR#940", // retried under a new PR: 940 is not carried
916
- "#905 impl-905=PR#950", // previous board had it, not as MERGED
917
- "#906 impl-906", // implementing, no PR
918
- "#907 impl-907=released", // released, no PR
919
- "#908 excluded · behind-pr:#931 impl-908=PR#960", // an Exclusion is POOL whatever it carries
920
- "#1237 -> PR#1237 · review=member:review-pr-1237", // amendment 2a: no impl token, PR-bound
921
- "#909 impl-909=PR#950", // a second row on 950: asked once
922
- ];
923
- const prev = { tickets: [
924
- { issue: 903, pr: 933, column: "MERGED", sinceEnteredStage: HOUR },
925
- { issue: 904, pr: 930, column: "MERGED", sinceEnteredStage: HOUR },
926
- { issue: 905, pr: 950, column: "REVIEW", sinceEnteredStage: HOUR },
927
- ] };
928
- const inp = { ledger: { rows, filed: [], ruled: [] }, prs: [openPr(931)], prev };
929
- const need = mergedReadPrs(inp);
930
- assert.deepEqual(need, [940, 950, 1237]);
931
- const col = (merged) => new Map(computeBoard(reproInputs({ ...inp, merged })).tickets.map((t) => [t.issue, t.column]));
932
- const none = col([]);
933
- const all = col([930, 931, 932, 933, 940, 950, 960, 1237]);
934
- const moved = new Set([...none].filter(([issue, c]) => all.get(issue) !== c).map(([issue]) => rows.map(parseRow).find((p) => p.issue === issue).pr));
935
- assert.deepEqual([...moved].sort((a, b) => a - b), need);
936
- });
937
-
938
- // #1840 review: a ledger row whose PR mention is 22+ digits parses (via
939
- // `Number()`) to a value outside Number.isSafeInteger, which readMerged()
940
- // would stringify in exponential form (`1e+21`) — not a valid gh api
941
- // graphql alias/argument, and one that fails the WHOLE batched query, not
942
- // just that row. mergedReadPrs excludes it before it ever reaches gh, the
943
- // same way a PR-less row is excluded, so every other row PR's lookup stays
944
- // intact.
945
- test("#1840: a PR number outside Number.isSafeInteger is excluded from mergedReadPrs, so it cannot poison the batch for other row PRs", () => {
946
- const need = mergedReadPrs({
947
- ledger: { rows: [
948
- "#907 impl-907=PR#930",
949
- "#908 impl-908=PR#1000000000000000000000", // 22 digits: Number() -> 1e+21
950
- ], filed: [], ruled: [] },
951
- prs: [], prev: null,
952
- });
953
- assert.deepEqual(need, [930], "the unsafe-integer PR is left out; 930 still gets asked about");
954
- });
955
-
956
- test("#1820: review=wf/member, or a live fix-pr/finisher-pr, is under review; agent is the latest live member", () => {
957
- const b = computeBoard(reproInputs());
958
- assert.equal(card(b, 908).column, "REVIEW");
959
- assert.equal(card(b, 908).agent, null, "a Workflow review names no member");
960
- assert.equal(card(b, 909).agent, "review-pr-932");
961
- assert.equal(card(b, 905).agent, null, "fix-pr-920 settled failed — nobody is live");
962
- assert.equal(b.queue.reviewBacklog, 1, "only #905 has neither review= nor reviewed=");
963
-
964
- const live = computeBoard(reproInputs({
965
- rows: [
966
- "#920 impl-920=PR#931 · fix-pr-931",
967
- "#921 impl-921=PR#932 · review=member:review-pr-932 reviewed=abc1234:1/0/0 · finisher-pr-932",
968
- "#922 impl-922=PR#920 · review=wf:r1=failed review=fallback:review-pr-920-b",
969
- "#923 impl-923=PR#931 · review=member:review-pr-931 reviewed=abc1234:0/0/0",
970
- ],
971
- }));
972
- assert.equal(card(live, 920).agent, "fix-pr-931");
973
- assert.equal(card(live, 921).agent, "finisher-pr-932");
974
- assert.equal(card(live, 922).agent, "review-pr-920-b");
975
- assert.equal(card(live, 923).agent, null, "reviewed= settles the runner that produced it");
976
- assert.equal(live.queue.reviewBacklog, 0);
977
- });
978
-
979
- test("#1820: live-ledger PR rows — settled finisher, fallback runner", () => {
980
- const b = computeBoard(reproInputs({
981
- rows: [
982
- "#1715 impl-1715=PR#1824 · class=correction · reviewed=41901d4c:0/1/0 · finisher-pr-1824=labelled",
983
- "#1721 impl-1721=PR#1825 · class=correction · review=fallback:review-pr-1825-b",
984
- "#1755 impl-1755=PR#1830 · class=routine",
985
- ],
986
- prs: [openPr(1824, ["ready-to-merge"]), openPr(1825), openPr(1830)],
987
- }));
988
- assert.equal(card(b, 1715).column, "READY");
989
- assert.equal(card(b, 1715).agent, null);
990
- assert.equal(card(b, 1721).agent, "review-pr-1825-b");
991
- assert.equal(b.queue.reviewBacklog, 1, "only #1755 is waiting on a reviewer");
992
- });
993
-
994
- test("#1820: the reproduction's stall report counts only the real claims", () => {
995
- const b = computeBoard({ ...reproInputs(), beat: { at: 10 * HOUR - 90 * MIN, interval: 1200, stopped: "" } });
996
- // #904 killed, #905/#908/#909 in review, #906 live — Exclusions, the bailed
997
- // #903 and the merged #907 are nobody's outstanding claim.
998
- assert.equal(b.liveness.claimed, 5);
999
- assert.deepEqual(b.attention.map((t) => t.issue).sort(), [904, 905, 906, 908, 909]);
1000
- });
1001
-
1002
- test("#1820: `## Dispatched` is not read — row tokens alone decide", () => {
1003
- const b = computeBoard(reproInputs({
1004
- rows: ["#906 impl-906"],
1005
- ledger: { rows: ["#906 impl-906"], dispatched: ["impl-906=bailed", "impl-950"], filed: [], ruled: [] },
1006
- }));
1007
- assert.equal(card(b, 906).column, "IMPLEMENTING");
1008
- assert.equal(card(b, 906).agent, "impl-906");
1009
- assert.equal(card(b, 950), undefined);
1010
- });
1011
-
1012
- test("#1820: a malformed member outcome is never fatal and never counted live, and earns a `ledger-error` flag instead of rendering as a quiet, healthy row", () => {
1013
- const b = computeBoard(reproInputs({ rows: ["#924 impl-924=PR#931 · fix-pr-931=exploded"] }));
1014
- assert.equal(card(b, 924).column, "REVIEW");
1015
- assert.equal(card(b, 924).agent, null);
1016
- assert.ok(card(b, 924).flags.includes("ledger-error"), "a malformed outcome must be visible, not indistinguishable from a healthy row");
1017
- });
1018
-
1019
- test("#1820: a bare `review-pr-<n>` token (no `review=` prefix) names nobody — only ledger-grammar.mjs member families and `review=` tokens are read", () => {
1020
- const b = computeBoard(reproInputs({ rows: ["#960 impl-960=PR#931 review-pr-960"] }));
1021
- assert.equal(card(b, 960).agent, null, "review-pr-960 is neither a ledger-grammar.mjs member family nor a review= token");
1022
- assert.equal(card(b, 960).column, "REVIEW");
1023
- assert.equal(b.queue.reviewBacklog, 1, "no review=, no reviewed=, no live fix-pr/finisher-pr — the bare token does not exempt it");
1024
- });
1025
-
1026
- // --------------------------------------------------------------------------
1027
- // #1820 amendment 5a (#1842): a `review=` token puts a PR under review only
1028
- // while it is live. A settled `review=…=failed` is a dead review — the PR is
1029
- // owed one again, as run-team SKILL.md defines review-due and as
1030
- // fleet-tick.mjs's `reviewedAny` reads the token.
1031
-
1032
- // fleet-tick.mjs's review-due for the same rows, observed through deriveRun
1033
- // rather than restated: every PR open, unlabelled and closing an issue.
1034
- // `headRefOid` defaults to a fixed placeholder, never absent — (#2083) a
1035
- // genuinely missing head reads as "moved past reviewed=" in deriveRun, so
1036
- // an omitted-by-accident fixture would silently exercise past-pin's
1037
- // redispatch path instead of refusing the way production's openPrs() does.
1038
- const tickReviewDue = (rows, prs, headRefOid = "abc1234abc1234abc1234abc1234abc1234abcd") => deriveRun({ rows, dispatched: [], drain: null },
1039
- prs.map((number) => ({ number, labels: [], closingIssuesReferences: [{ number }], headRefOid }))).reviewDue;
1040
-
1041
- test("#1820 amendment 5a: a settled `review=...=failed` with no redispatch is owed a review — reviewBacklog agrees with fleet-tick.mjs's reviewDue", () => {
1042
- const row = "#961 impl-961=PR#961 · review=member:review-pr-961=failed";
1043
- const b = computeBoard(reproInputs({ rows: [row], prs: [openPr(961)] }));
1044
- assert.equal(card(b, 961).column, "REVIEW");
1045
- assert.equal(card(b, 961).agent, null, "the reviewer settled failed; nobody is live");
1046
- assert.equal(b.queue.reviewBacklog, 1, "a dead review is no review");
1047
- assert.deepEqual(tickReviewDue([row], [961]), [961], "the tick lists the same PR as review-due");
1048
- });
1049
-
1050
- test("#1820 amendment 5a: `=failed` then a live redispatch is under review; any `reviewed=` stays out of the backlog whatever review= tokens it carries", () => {
1051
- for (const row of [
1052
- "#962 impl-962=PR#931 · review=wf:r1=failed review=fallback:review-pr-931-b",
1053
- "#962 impl-962=PR#931 · review=member:review-pr-931=failed review=wf:r2",
1054
- "#962 impl-962=PR#931 · review=member:review-pr-931=failed reviewed=abc1234:0/0/0",
1055
- "#962 impl-962=PR#931 · reviewed=abc1234:1/0/0 review=wf:r2=failed",
1056
- "#962 impl-962=PR#931 · review=wf:r1=failed review=fallback:review-pr-931-b=failed reviewed=abc1234:0/1/0",
1057
- // A live fix-applier or finisher is reviewing it too, as before (#1820).
1058
- "#962 impl-962=PR#931 · review=member:review-pr-931=failed · fix-pr-931",
1059
- "#962 impl-962=PR#931 · review=member:review-pr-931=failed · finisher-pr-931",
1060
- ]) {
1061
- const b = computeBoard(reproInputs({ rows: [row] }));
1062
- assert.equal(card(b, 962).column, "REVIEW", row);
1063
- assert.equal(b.queue.reviewBacklog, 0, row);
1064
- }
1065
- });
1066
-
1067
- test("#1820 amendment 5a: on the same ledger and PR list, the cockpit's backlog is fleet-tick.mjs's reviewDue, row by row and in total", () => {
1068
- // [row, its PR, owed a review]. Every PR is open, unlabelled and closes an
1069
- // issue, and no row carries a live fix-pr-/finisher-pr-, which the tick's
1070
- // review-due does not read.
1071
- const cases = [
1072
- ["#961 impl-961=PR#961 · review=member:review-pr-961=failed", 961, true],
1073
- ["#962 impl-962=PR#962 · review=fallback:review-pr-962-b=failed", 962, true],
1074
- ["#963 impl-963=PR#963 · review=wf:r1=failed", 963, true],
1075
- ["#964 impl-964=PR#964 · review=wf:r1=failed review=fallback:review-pr-964-b=failed", 964, true],
1076
- ["#965 impl-965=PR#965 · review=member:review-pr-965=failed · fix-pr-965=failed", 965, true],
1077
- ["#966 impl-966=PR#966", 966, true],
1078
- ["#967 impl-967=PR#967 · review=wf:r1=failed review=fallback:review-pr-967-b", 967, false],
1079
- ["#968 impl-968=PR#968 · review=wf:r3", 968, false],
1080
- ["#969 impl-969=PR#969 · review=member:review-pr-969=failed reviewed=abc1234:0/0/0", 969, false],
1081
- ["#970 impl-970=PR#970 · reviewed=abc1234:1/0/0 review=wf:r2=failed", 970, false],
1082
- // A live copy left beside its settled one by a whole-line rewrite: the
1083
- // tick's `reviewedAny` counts any live review= token on the row, so the
1084
- // row is not owed one — the ruling's "neither a live review= nor a
1085
- // reviewed=", not the last review= token's liveness.
1086
- ["#971 impl-971=PR#971 · review=member:review-pr-971 review=member:review-pr-971=failed", 971, false],
1087
- // Amendment 2a rows — no impl token, PR from the mention or the row key.
1088
- ["#1237 review=wf:r9=failed", 1237, true],
1089
- ["#1238 -> PR#1238 · review=member:review-pr-1238=failed review=fallback:review-pr-1238-b", 1238, false],
1090
- ];
1091
- for (const [row, pr, owed] of cases) {
1092
- const b = computeBoard(reproInputs({ rows: [row], prs: [openPr(pr)] }));
1093
- assert.equal(b.tickets[0].column, "REVIEW", row);
1094
- assert.equal(b.queue.reviewBacklog, owed ? 1 : 0, `${row}: cockpit`);
1095
- assert.deepEqual(tickReviewDue([row], [pr]), owed ? [pr] : [], `${row}: tick`);
1096
- }
1097
- const rows = cases.map(([row]) => row);
1098
- const prs = cases.map(([, pr]) => pr);
1099
- const b = computeBoard(reproInputs({ rows, prs: prs.map((n) => openPr(n)) }));
1100
- assert.equal(b.queue.reviewBacklog, tickReviewDue(rows, prs).length);
1101
- assert.equal(b.queue.reviewBacklog, cases.filter(([, , owed]) => owed).length);
1102
- });
1103
-
1104
- test("#2083: a returned review whose finisher halted past-pin against a head it never read is owed a review again — cockpit and tick agree", () => {
1105
- // reviewed= first, then a fresher finisher discovers the head moved past
1106
- // it and halts — the same chronology the fleet-tick.test.mjs fixture
1107
- // above uses, so the halt is the row's freshest event.
1108
- const row = "#972 impl-972=PR#972 · reviewed=abc1234:0/0/0 · finisher-pr-972=halted:past-pin";
1109
- const staleHead = "def5678def5678def5678def5678def5678def";
1110
- const b = computeBoard(reproInputs({ rows: [row], prs: [openPr(972, [], staleHead)] }));
1111
- assert.equal(card(b, 972).column, "REVIEW");
1112
- assert.equal(b.queue.reviewBacklog, 1, "the halt's automatic re-review has not happened at this head yet");
1113
- assert.deepEqual(tickReviewDue([row], [972], staleHead), [972], "the tick agrees");
1114
- });
1115
-
1116
- test("#2083: once the head matches the reviewed= that answered a past-pin halt, neither counts it owed", () => {
1117
- const row = "#973 impl-973=PR#973 · finisher-pr-973=halted:past-pin · reviewed=abc1234:0/0/0";
1118
- const b = computeBoard(reproInputs({ rows: [row], prs: [openPr(973, [], "ABC1234")] }));
1119
- assert.equal(b.queue.reviewBacklog, 0, "the automatic re-review already answered the halt");
1120
- assert.deepEqual(tickReviewDue([row], [973], "ABC1234"), [], "the tick agrees");
1121
- });
1122
-
1123
- // #1926: a `review=` token outside the wf/member/fallback grammar is still
1124
- // read as live (compute-board.mjs's note above REVIEW). fleet-tick.mjs
1125
- // refuses such a ledger outright; the cockpit renders it instead, and reads
1126
- // the review as in flight — `=failed` settles only an in-grammar token.
1127
- test("#1926: a `review=` token outside the grammar reads as a live review that names nobody", () => {
1128
- const base = "#972 impl-972=PR#972";
1129
- assert.equal(parseRow(base).underReview, false, "control: the row's other tokens put it under no review");
1130
- for (const tok of [
1131
- "review=bogus:x",
1132
- "review=member",
1133
- "review=member:",
1134
- "review=",
1135
- "review=WF:r1",
1136
- "review=member:a=b",
1137
- "review=bogus:x=failed",
1138
- ]) {
1139
- const r = parseRow(`${base} · ${tok}`);
1140
- assert.equal(r.underReview, true, tok);
1141
- assert.equal(r.agent, null, `${tok}: no kind to name a runner by`);
1142
- }
1143
- });
1144
-
1145
- // --------------------------------------------------------------------------
1146
- // #1820 amendment 2a (#1839): a PR-bound row with no `impl` token — the shape
1147
- // `ledger.mjs dispatch <pr> fix-pr-<pr>|finisher-pr-<pr>` appends for a PR
1148
- // this run's implementers did not open — takes its PR the way fleet-tick.mjs
1149
- // does, the first `PR#M` mention else the row key, and that PR decides the
1150
- // card exactly as an impl token's `=PR#M` outcome does. Measured before the
1151
- // fix: this row was `IMPLEMENTING pr=null`, merged or not.
1152
- const INHERITED = "#1237 -> PR#1237 · review=member:review-pr-1237";
1153
-
1154
- test("#1820 amendment 2a: a PR-bound row with no impl token is a REVIEW card for its open PR", () => {
1155
- const b = computeBoard(reproInputs({ rows: [INHERITED], prs: [openPr(1237)] }));
1156
- assert.equal(card(b, 1237).column, "REVIEW");
1157
- assert.equal(card(b, 1237).pr, 1237);
1158
- assert.equal(card(b, 1237).agent, "review-pr-1237");
1159
- assert.equal(b.queue.reviewBacklog, 0, "its live review= runner is reviewing it");
1160
- });
1161
-
1162
- test("#1820 amendment 2a: the same row is MERGED once gh reports its PR merged", () => {
1163
- const b = computeBoard(reproInputs({ rows: [INHERITED], prs: [], merged: [1237] }));
1164
- assert.equal(card(b, 1237).column, "MERGED");
1165
- assert.equal(card(b, 1237).pr, 1237);
1166
- assert.deepEqual(card(b, 1237).flags, [], "MERGED is terminal — never stale");
1167
- });
1168
-
1169
- test("#1820 amendment 2a: with no PR#M mention, a PR-bound member or review token keys the PR to the row key; a mention wins over the key", () => {
1170
- for (const row of ["#1237 fix-pr-1237", "#1237 finisher-pr-1237=labelled", "#1237 review=wf:r9", "#1237 reviewed=abc1234:0/0/0"]) {
1171
- assert.equal(parseRow(row).pr, 1237, row);
1172
- }
1173
- assert.equal(parseRow("#1300 PR#1301 · fix-pr-1301").pr, 1301);
1174
- assert.equal(parseRow("#1237: fix-pr-1237").pr, null, "colon-suffixed first word is not an exact `#N` key match");
1175
- });
1176
-
1177
- test("#1820 amendment 2a: an Exclusion, and a row with no impl token and no PR-bound signal, keep no PR", () => {
1178
- const b = computeBoard(reproInputs({
1179
- rows: ["#901 excluded · behind-pr:#880", "#1500 excluded · behind-pr:#1499 · PR#1499 still open", "#1501 class=routine"],
1180
- prs: [openPr(1499)],
1181
- }));
1182
- for (const [n, badge] of [[901, "excluded:#880"], [1500, "excluded:#1499"]]) {
1183
- assert.equal(card(b, n).column, "POOL");
1184
- assert.deepEqual(card(b, n).flags, [badge]);
1185
- assert.equal(card(b, n).pr, null, `#${n} is supply — a PR mention on it names no card of its own`);
1186
- }
1187
- assert.equal(card(b, 1501).column, "IMPLEMENTING");
1188
- assert.equal(card(b, 1501).pr, null);
1189
- });
1190
-
1191
- test("#1820 amendment 2a: a row carrying any impl token is untouched, a malformed one included — its key is a ticket, not a PR", () => {
1192
- const b = computeBoard(reproInputs({ rows: ["#925 impl-925=PR#93l · review=member:review-pr-925"], prs: [openPr(925)] }));
1193
- assert.equal(card(b, 925).column, "IMPLEMENTING");
1194
- assert.equal(card(b, 925).pr, null);
1195
- assert.ok(card(b, 925).flags.includes("ledger-error"));
1196
- });
1197
-
1198
- // fleet-tick.mjs's PR for a row, observed rather than restated: a merge hold on
1199
- // a queued PR counts only when the row carrying the hold is keyed to that PR.
1200
- const tickKeysTo = (row, n) => deriveRun({ rows: [`${row} held-behind:#1`], dispatched: [], drain: null }, [
1201
- { number: n, labels: [{ name: "ready-to-merge" }], closingIssuesReferences: [] },
1202
- { number: 1, labels: [], closingIssuesReferences: [] },
1203
- ]).mergeHeld === 1;
1204
-
1205
- test("#1820 amendment 2a: on the same PR-signaled row text, the cockpit's PR is fleet-tick.mjs's", () => {
1206
- const rows = [INHERITED, "#1237 fix-pr-1237", "#1237 finisher-pr-1237=labelled", "#1237 reviewed=abc1234:1/0/0", "#1300 PR#1301 · fix-pr-1301"];
1207
- for (const row of rows) {
1208
- const pr = parseRow(row).pr;
1209
- assert.ok(pr != null && tickKeysTo(row, pr), `${row}: cockpit ${pr}, tick disagrees`);
1210
- }
1211
- // Keyed only by an exact `#N` first word, as fleet-tick.mjs keys it.
1212
- assert.equal(parseRow("#1237: fix-pr-1237").pr, null);
1213
- assert.ok(!tickKeysTo("#1237: fix-pr-1237", 1237));
1214
- });