@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,228 +0,0 @@
1
- // #1192: the `--prev` read guarded only the PARSE, so a previous board that
2
- // parsed as JSON but carried a wrong-typed `tickets` crashed the gather its own
3
- // comment promises it cannot ("a corrupt/partial board.json is ignored, not
4
- // fatal"). `{"tickets": 5}` reached the prevCi map's `.filter` and left gather()
5
- // as a TypeError through main()'s handler — the build refused, and the message
6
- // named an "intermediate value" rather than the file the operator passed, so
7
- // `--prev` was not implicated in the failure it caused.
8
- //
9
- // The guard rejects the SHAPE where the payload enters, next to the parse, and
10
- // both faults take the one existing ignore path. Not per-read defaults: the
11
- // prevCi expression's `|| []` is exactly the wrong seam and shows why — it
12
- // defends against an ABSENT `tickets` and not against a present one of the
13
- // wrong type, and it is one of three reads of this payload (`prev?.repo`,
14
- // `prev?.repoUrl`, and compute-board.mjs's dwell tracking, which consumes the
15
- // whole `prev` gather() returns).
16
- //
17
- // Driven through the exported `gather()` and through the real CLI: the value
18
- // half (carry-forward present or empty) is only observable at gather()'s
19
- // return, and the contract half (exit code unchanged, nothing on stdout) is
20
- // only observable at the process boundary. Out of process either way, for the
21
- // reason board.test.mjs's own gather drivers give — gather() reads process.argv
22
- // and would otherwise read the test runner's.
23
- //
24
- // A separate file rather than more of board.test.mjs, the same reason
25
- // board-tryparse-null.test.mjs gives: the fleet runs several implementers at
26
- // once and two PRs appending to one test file conflict, which costs the PR its
27
- // CI entirely.
28
-
29
- import { test } from "node:test";
30
- import assert from "node:assert/strict";
31
- import { spawnSync } from "node:child_process";
32
- import { writeFileSync } from "node:fs";
33
- import { tempDir } from "./temp-dir.mjs";
34
- import { join } from "node:path";
35
- import { fileURLToPath } from "node:url";
36
- import { writeExecStub } from "./exec-stub.mjs";
37
-
38
- const BOARD = fileURLToPath(new URL("./board.mjs", import.meta.url));
39
-
40
- // What ci-state.mjs emits on a quota refusal: a payload at exit 2, which
41
- // runCiState reads as "no answer" (board.test.mjs's RATE_LIMITED_EXIT_2 pins
42
- // that reading). Some route into the carry-forward arm is what these tests
43
- // need, not this one in particular — since #875 a salvaged payload that will
44
- // not parse reaches it too — and a payload at exit 2 is the route with the
45
- // least of its own machinery: one write and one exit code, no truncation to
46
- // stage. Without SOME such route every ci value comes from mapCi and the
47
- // previous board is never consulted, so an empty carry-forward would be
48
- // indistinguishable from a consulted one.
49
- const CI_READ_FAILS = `import { writeSync } from "node:fs";
50
- writeSync(1, JSON.stringify({ pr: 42, verdict: "rate-limited", reasons: ["quota"] }) + "\\n");
51
- process.exit(2);`;
52
-
53
- // `prevBody` is written RAW, not through JSON.stringify: half the cases below
54
- // are payloads JSON.stringify cannot produce (`not json`) or would launder.
55
- //
56
- // The gather has to COMPLETE, not merely not-throw: a driver that died on the
57
- // prevCi TypeError exits non-zero with no stdout, and every value assertion
58
- // below would read `undefined` from a parse of nothing. Asserting status here
59
- // keeps that failure legible at the one place it can happen.
60
- function gathered(prevBody) {
61
- const cwd = tempDir("board-prevshape-");
62
- const bin = tempDir("board-prevshape-bin-");
63
- const scriptDir = tempDir("board-prevshape-scripts-");
64
-
65
- writeFileSync(join(scriptDir, "ci-state.mjs"), CI_READ_FAILS);
66
- // A real ledger answer, so the only unusual read on this stderr is the one
67
- // under test — the assertions below count lines.
68
- writeFileSync(join(scriptDir, "ledger.mjs"),
69
- `console.log(JSON.stringify({ rows: [], filed: [], ruled: [] }));`);
70
- writeExecStub(join(bin, "gh"),
71
- '#!/bin/sh\ncase "$1 $2" in\n"pr list") echo \'[{"number":42,"state":"OPEN","labels":[],"title":"t"}]\' ;;\n*) exit 1 ;;\nesac\n');
72
-
73
- const prevFile = join(cwd, "prev.json");
74
- writeFileSync(prevFile, prevBody);
75
-
76
- const driver = `const { gather } = await import(${JSON.stringify(BOARD)});
77
- const r = await gather({ ledgerFile: ${JSON.stringify(join(cwd, "nope.md"))},
78
- prevFile: ${JSON.stringify(prevFile)},
79
- scriptDir: ${JSON.stringify(scriptDir)}, interval: 15 });
80
- console.log(JSON.stringify({ ci: r.ci, prev: r.prev }));`;
81
- const r = spawnSync(process.execPath, ["--input-type=module", "-e", driver], {
82
- cwd, encoding: "utf8", env: { ...process.env, PATH: `${bin}:${process.env.PATH}` },
83
- });
84
- assert.equal(r.status, 0,
85
- `the gather refused a previous board it promises to ignore\n${r.stderr}`);
86
- return { ...JSON.parse(r.stdout.trim().split("\n").pop()), stderr: r.stderr, prevFile };
87
- }
88
-
89
- const ignoreLines = (stderr) =>
90
- stderr.split("\n").filter((l) => l.includes("ignoring unreadable prev board"));
91
-
92
- // ── the invalid-shape class ──────────────────────────────────────────────────
93
- //
94
- // One row per DISTINCT route into the defect, not per value: a wrong-typed
95
- // container, a wrong-typed entry, and a wrong-typed payload are three
96
- // different reads, and the three kind words below are the three branches of
97
- // the guard's own naming expression — a `typeof`-only version reports both
98
- // `null` and `[]` as "object", which is the diagnostic the operator cannot act
99
- // on. Every row asserts the gather COMPLETED (inside `gathered`) with an empty
100
- // carry-forward and exactly one diagnostic naming the file.
101
- const REFUSED = [
102
- // `{"tickets": 5}` is the ticket's own reproduction (#1192): a wrong-typed
103
- // container reached the prevCi map's `.filter` and crashed gather() before
104
- // this guard existed.
105
- ['{"tickets": 5}', /expected tickets to be an array, got number/],
106
- // The case an `Array.isArray` check alone lets straight through: `[null]`
107
- // IS an array, so it clears the container check and throws on the per-entry
108
- // `t.pr` read inside the prevCi map instead. The whole payload is refused
109
- // rather than the bad entry filtered out — a board with one unreadable
110
- // ticket is not a board whose OTHER tickets can be trusted to carry CI
111
- // state forward.
112
- ['{"tickets": [null]}', /expected tickets\[0\] to be a JSON object, got null/],
113
- ['{"tickets": "5"}', /expected tickets to be an array, got string/],
114
- ['{"tickets": {"42": "red"}}', /expected tickets to be an array, got object/],
115
- ['{"tickets": [1]}', /expected tickets\[0\] to be a JSON object, got number/],
116
- ['{"tickets": [{"pr": 42, "ci": "red"}, "x"]}', /expected tickets\[1\] to be a JSON object, got string/],
117
- ['{"tickets": [[]]}', /expected tickets\[0\] to be a JSON object, got array/],
118
- // Top-level faults. These four did NOT crash before the guard — `prev?.x`
119
- // reads undefined off all of them — so the defect here is the silence: the
120
- // operator passed a file that is not a board and the run said nothing, then
121
- // carried nothing forward. Ignoring them is unchanged; SAYING so is new.
122
- ["null", /expected a JSON object, got null/],
123
- ["5", /expected a JSON object, got number/],
124
- ['"a board"', /expected a JSON object, got string/],
125
- ["[]", /expected a JSON object, got array/],
126
- ];
127
-
128
- for (const [body, reason] of REFUSED) {
129
- test(`gather: an unusable previous board ${body} is ignored with one named diagnostic (#1192)`, () => {
130
- const r = gathered(body);
131
- assert.equal(r.ci[42], "unknown", "an unusable previous board must carry nothing forward");
132
- // Nothing reaches the payload's other three readers either — `prev?.repo`,
133
- // `prev?.repoUrl` and compute-board.mjs's dwell tracking, which reads the
134
- // returned `prev` through the same `(prev?.tickets || []).map` shape.
135
- assert.equal(r.prev, null);
136
- const lines = ignoreLines(r.stderr);
137
- assert.equal(lines.length, 1, `expected exactly one diagnostic, got:\n${r.stderr}`);
138
- assert.ok(lines[0].includes(r.prevFile), `diagnostic must name the file: ${lines[0]}`);
139
- assert.match(lines[0], reason);
140
- });
141
- }
142
-
143
- // A parse fault is the path that already worked, and its wording is not the
144
- // shape fault's: re-using one message for both would put a reader who sees
145
- // "expected a JSON object" in front of a file that never parsed.
146
- test("gather: a previous board that is not JSON still takes the ignore path with its own message (#1192)", () => {
147
- const r = gathered("not json at all");
148
- assert.equal(r.ci[42], "unknown");
149
- const lines = ignoreLines(r.stderr);
150
- assert.equal(lines.length, 1, `expected exactly one diagnostic, got:\n${r.stderr}`);
151
- assert.match(lines[0], /is not valid JSON/);
152
- assert.doesNotMatch(lines[0], /expected a JSON object/,
153
- "a parse fault must not be reported as a shape fault");
154
- });
155
-
156
- // ── the accept side: what this guard must NOT refuse ─────────────────────────
157
-
158
- test("gather: a well-formed previous board still supplies the carry-forward (#1192)", () => {
159
- // The behaviour the guard exists to protect, not merely to leave alone: PR
160
- // 42's own CI read fails here, so "red" can only have come from this file.
161
- // A guard that refused the payload — or nulled `prev` on its way past —
162
- // would show up here as "unknown" and nowhere else.
163
- const r = gathered('{"tickets": [{"pr": 42, "ci": "red"}]}');
164
- assert.equal(r.ci[42], "red");
165
- assert.deepEqual(r.prev, { tickets: [{ pr: 42, ci: "red" }] },
166
- "an accepted payload must reach gather()'s callers whole — compute-board.mjs reads it for dwell");
167
- assert.deepEqual(ignoreLines(r.stderr), [], "a usable previous board must draw no diagnostic");
168
- });
169
-
170
- // The rows a stricter guard gets wrong. `prev?.tickets || []` reads all three
171
- // as the empty carry-forward today, so all three are USABLE payloads, and a
172
- // guard written as `!Array.isArray(p.tickets)` or `"tickets" in p` would
173
- // start refusing boards that work — printing a diagnostic about a file whose
174
- // only fault is having no tickets on it, and throwing away the `repo`/`repoUrl`
175
- // the same payload still carries.
176
- const ACCEPTED = ['{}', '{"tickets": null}', '{"tickets": []}', '{"repo": "o/r"}'];
177
-
178
- for (const body of ACCEPTED) {
179
- test(`gather: a previous board with no usable tickets, ${body}, is accepted in silence (#1192)`, () => {
180
- const r = gathered(body);
181
- assert.equal(r.ci[42], "unknown");
182
- assert.deepEqual(r.prev, JSON.parse(body), "a payload with nothing to carry is still a payload");
183
- assert.deepEqual(ignoreLines(r.stderr), [],
184
- "nullish/empty tickets is an empty carry-forward, not a fault");
185
- });
186
- }
187
-
188
- // ── the process contract: an ignored previous board is not an error ──────────
189
- //
190
- // Only observable out here: `gather()`'s return says nothing about the exit
191
- // code, and the diagnostic's CHANNEL is the thing a cockpit consuming
192
- // `board build` stdout depends on. The stub `gh` fails every call — each gh
193
- // read degrades through tryRun — so the board still builds with no network and
194
- // no read of this repo's live issue list.
195
- function runBuild(prevArgs) {
196
- const cwd = tempDir("board-prevshape-cli-");
197
- const home = tempDir("board-prevshape-home-");
198
- const bin = tempDir("board-prevshape-cli-bin-");
199
- writeExecStub(join(bin, "gh"), "#!/bin/sh\nexit 1\n");
200
- return spawnSync(process.execPath, [BOARD, "build", "--ledger", join(cwd, "nope.md"), ...prevArgs], {
201
- cwd, encoding: "utf8", maxBuffer: 64 * 1024 * 1024,
202
- env: { ...process.env, HOME: home, PATH: `${bin}:${process.env.PATH}` },
203
- });
204
- }
205
-
206
- test("build: an ignored previous board changes neither the exit code nor stdout (#1192)", () => {
207
- const prevFile = join(tempDir("board-prevshape-file-"), "prev.json");
208
- writeFileSync(prevFile, '{"tickets": 5}');
209
- const withPrev = runBuild(["--prev", prevFile]);
210
- // The baseline is measured in the same run rather than asserted as a
211
- // constant: "whatever it would have been with no --prev at all" is the
212
- // criterion, and a rig that started failing for its own reasons would
213
- // otherwise read as this fix regressing.
214
- const without = runBuild([]);
215
- assert.equal(withPrev.status, without.status,
216
- `--prev changed the exit code: ${withPrev.status} vs ${without.status}\n${withPrev.stderr.slice(-400)}`);
217
- // Pinned absolutely too, so a rig broken in both arms cannot pass by
218
- // agreeing with itself. 70 was the pre-fix answer — main()'s internal-fault
219
- // handler (#1093) — and 2 is a refusal.
220
- assert.equal(withPrev.status, 0, withPrev.stderr.slice(-400));
221
- // stderr carries it, and only once.
222
- assert.equal(ignoreLines(withPrev.stderr).length, 1, withPrev.stderr);
223
- // stdout stays the board and nothing else: the cockpit parses this whole.
224
- const board = JSON.parse(withPrev.stdout);
225
- assert.ok(Array.isArray(board.tickets), "stdout must still be a board model");
226
- assert.doesNotMatch(withPrev.stdout, /ignoring unreadable prev board/,
227
- "a diagnostic on stdout would break every consumer that parses it");
228
- });
@@ -1,119 +0,0 @@
1
- // #1181: board.mjs's `tryParse` guarded its INPUT string against nullish and
2
- // not its PARSED VALUE. `JSON.parse("null")` succeeded and yielded null, so a
3
- // bare `null` payload skipped the fallback and reached the caller as its
4
- // answer — the shape #1170 fixed one function over, in `mapCi`.
5
- //
6
- // That gap does not crash either of tryParse's two current callers today:
7
- // withNumber's own array guard already rejects a null `rows` at the open-PR read's
8
- // call site, and gather()'s ledger branch already treats a null parse as
9
- // falsy. This guard is defense in depth, not a crash fix — what it actually
10
- // changes is (a) one named "payload is JSON null" stderr line in place of a
11
- // caller's own, more generic shape complaint, and (b) real protection for a
12
- // future tryParse caller with no shape guard of its own downstream. The two
13
- // "refusal" tests below pin that stderr line; their value assertions were
14
- // already true before this guard existed, and stay here as regression
15
- // coverage for the caller-visible shape, not as proof of the fix.
16
- //
17
- // Driven through the exported `gather()` rather than against `tryParse`, which
18
- // is module-private: the guard is only observable where a caller consumes the
19
- // result, and that is the boundary a consumer actually sees. Out of process for
20
- // the reason board.test.mjs's own gather drivers are — gather() reads
21
- // process.argv and would otherwise read the test runner's.
22
- //
23
- // A separate file rather than more of board.test.mjs, the same reason
24
- // ledger-read-require-file.test.mjs gives: the fleet runs several implementers
25
- // at once and two PRs appending to one test file conflict, which costs the PR
26
- // its CI entirely.
27
- //
28
- // The accept side of a well-formed payload is board.test.mjs's "a well-formed
29
- // issue/PR row passes through unchanged", at this same seam; what is pinned
30
- // here is the accept side this guard could newly break — a parsed answer that
31
- // is FALSY but readable.
32
-
33
- import { test } from "node:test";
34
- import assert from "node:assert/strict";
35
- import { spawnSync } from "node:child_process";
36
- import { writeFileSync } from "node:fs";
37
- import { tempDir } from "./temp-dir.mjs";
38
- import { join } from "node:path";
39
- import { fileURLToPath } from "node:url";
40
- import { writeExecStub } from "./exec-stub.mjs";
41
-
42
- const BOARD = fileURLToPath(new URL("./board.mjs", import.meta.url));
43
-
44
- // `repo view` answers a real object so nothing but the read under test can put
45
- // the string "parse failed" on stderr; the assertions below are scoped to their
46
- // own read besides, so neither guard rests on the other.
47
- const REPO_JSON = '{"nameWithOwner":"o/r","url":"https://example.invalid/o/r"}';
48
-
49
- // `ledgerBody` is the body of a stub `ledger.mjs`. board.mjs spawns
50
- // `node <scriptDir>/ledger.mjs`, and only a stub can hand it stdout that
51
- // arrives at exit 0 and parses to something no real ledger.mjs emits.
52
- function gatherWith({ issuesJson = "[]", prsJson = "[]", ledgerBody = null } = {}) {
53
- const cwd = tempDir("board-tpnull-");
54
- const bin = tempDir("board-tpnull-bin-");
55
- const scriptDir = tempDir("board-tpnull-scripts-");
56
-
57
- writeFileSync(join(scriptDir, "ci-state.mjs"), "process.stdout.write('{}');\n");
58
- writeFileSync(join(scriptDir, "ledger.mjs"),
59
- ledgerBody ?? `console.log(JSON.stringify({ rows: [], filed: [], ruled: [] }));`);
60
- writeExecStub(join(bin, "gh"),
61
- `#!/bin/sh\ncase "$1 $2" in\n` +
62
- `"issue list") echo '${issuesJson}' ;;\n` +
63
- `"pr list") echo '${prsJson}' ;;\n` +
64
- `"repo view") echo '${REPO_JSON}' ;;\n` +
65
- `*) exit 1 ;;\nesac\n`);
66
-
67
- const driver = `const { gather } = await import(${JSON.stringify(BOARD)});
68
- const r = await gather({ ledgerFile: ${JSON.stringify(join(cwd, "ledger.md"))},
69
- prevFile: null, scriptDir: ${JSON.stringify(scriptDir)}, interval: 15 });
70
- console.log(JSON.stringify({ issues: r.issues, prs: r.prs, ledger: r.ledger }));`;
71
- const r = spawnSync(process.execPath, ["--input-type=module", "-e", driver], {
72
- cwd, encoding: "utf8", env: { ...process.env, PATH: `${bin}:${process.env.PATH}` },
73
- });
74
- assert.equal(r.status, 0, `the driver itself must not fail\n${r.stdout}${r.stderr}`);
75
- return { ...JSON.parse(r.stdout.trim().split("\n").pop()), stderr: r.stderr };
76
- }
77
-
78
- // ── the refusal ──────────────────────────────────────────────────────────────
79
-
80
- test("gather: a `gh` payload that parses to JSON null degrades to an empty list, not to null (#1181)", () => {
81
- const r = gatherWith({ issuesJson: "null" });
82
- assert.deepEqual(r.issues, []);
83
- // Even without this guard tryParse still returns null here, and
84
- // withNumber's own array check already rejects a null `rows` — this site
85
- // never actually crashed. What the guard changes is the wording: this
86
- // named line in place of withNumber's generic "expected an array of rows,
87
- // got null" shape complaint.
88
- assert.match(r.stderr, /gh issue list: payload is JSON null/);
89
- // And not worded as the catch branch's fault: the parse succeeded. Reusing
90
- // that message is the likeliest way to write this guard, and it puts the two
91
- // states the ledger read deliberately keeps apart (#816) back under one
92
- // wording, sending whoever reads it looking for malformed stdout that is not
93
- // there.
94
- assert.doesNotMatch(r.stderr, /gh issue list parse failed/);
95
- });
96
-
97
- test("gather: a ledger read that parses to JSON null is `unparsed`, and says which fault it was (#1181)", () => {
98
- const r = gatherWith({ ledgerBody: `console.log("null");` });
99
- assert.equal(r.ledger.state, "unparsed");
100
- assert.deepEqual({ rows: r.ledger.rows, filed: r.ledger.filed, ruled: r.ledger.ruled },
101
- { rows: [], filed: [], ruled: [] });
102
- assert.match(r.stderr, /ledger read: payload is JSON null/);
103
- });
104
-
105
- // ── the accept side: what this guard must NOT refuse ─────────────────────────
106
-
107
- test("gather: a falsy-but-readable parsed payload still reaches the caller (#1181)", () => {
108
- // `0` stands for the whole falsy-but-readable class — `false` and `""` reach
109
- // the identical comparison — and it is the value that discriminates the
110
- // guard actually written from the one a reader reaches for: `=== null`
111
- // forwards it, `!parsed` swallows it. The forwarding is observable because
112
- // withNumber is then the thing that refuses it, and it names what it saw.
113
- const r = gatherWith({ issuesJson: "0" });
114
- assert.deepEqual(r.issues, []);
115
- assert.match(r.stderr, /gh issue list: expected an array of rows, got 0/,
116
- "tryParse must forward a falsy answer to its caller's own shape guard, not intercept it");
117
- assert.doesNotMatch(r.stderr, /gh issue list: payload is JSON null/,
118
- "0 is not null — reporting it as such is the falsiness bug this pins");
119
- });