@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,379 +0,0 @@
1
- // #1752 (parent #1743). The Renovate bot and the two release workflows keep a
2
- // JOINT contract that none of the three files can state alone:
3
- //
4
- // renovate.json decides which labels a bot PR carries
5
- // and whether it automerges;
6
- // .github/workflows/release-label.yml counts release labels (exactly one is
7
- // required) and, on an UNLABELLED bot
8
- // PR, stamps a blind fallback label;
9
- // .github/workflows/release.yml turns the one release label into the
10
- // version segment it bumps.
11
- //
12
- // Before #1752 the bot config set no labels at all, so every bot PR reached the
13
- // fallback and was stamped `patch` whatever it carried, and every bot PR was
14
- // automerged — a Node major could ship with nobody watching AND announce
15
- // itself as a patch. Each file read fine on its own; the defect was the
16
- // disagreement between them. So this test reads all three as DATA and checks
17
- // the contract they must keep together:
18
- //
19
- // 1. every update type the bot can emit resolves, from the bot config
20
- // itself, to exactly one label the gate counts — the fallback reclaiming
21
- // the labelling job is the defect, not a simplification;
22
- // 2. that label is one the fallback's own guard recognises, so the
23
- // fallback stands down instead of adding a second release label;
24
- // 3. release.yml bumps the segment matching the update type's size;
25
- // 4. no update type is simultaneously major and automergeable.
26
- //
27
- // It pins the contract, not the wording: label NAMES are read out of the
28
- // workflows (rename them consistently in all three files and this stays
29
- // green), the schedule is never read, and the bot config may express its
30
- // rules through `labels`, `addLabels` or top-level update-type objects.
31
- //
32
- // WHICH UPDATE TYPES THE BOT CAN EMIT. Renovate's schema (44.115.6, fetched
33
- // 2026-09-25) names ten: major, minor, patch, pin, pinDigest, digest,
34
- // lockFileMaintenance, rollback, bump, replacement. With `enabledManagers:
35
- // ["nvm"]` over an exact `.nvmrc` (ADR 0010) the `node-version` datasource
36
- // yields only the semver three — no digests, no lock file, no range to pin or
37
- // bump — and `rollback` only once `rollbackPrs` (default false) is opted into.
38
- // That derivation holds only for the nvm manager, so a widened
39
- // `enabledManagers` reds here rather than silently checking too few types.
40
- //
41
- // HOW THE BOT CONFIG RESOLVES, per Renovate's own source and docs rather than
42
- // guessed: `labels` is non-mergeable (a later setting replaces it), `addLabels`
43
- // appends, and the PR carries both; `automerge` defaults to false.
44
- // `lib/workers/repository/updates/flatten.ts` applies packageRules, merges the
45
- // top-level update-type object (`"major": {…}`), then applies packageRules
46
- // AGAIN, so packageRules win over that object — modelled in that order below.
47
- // The presets `config:recommended` extends set neither labels nor automerge
48
- // (checked against renovate's `lib/config/presets/internal/*.preset.ts`), so the
49
- // repo file alone decides both.
50
- //
51
- // CEILINGS. The workflows are read with targeted patterns, not a YAML parser —
52
- // this repo has no package.json and no YAML dependency, the same trade
53
- // ci-state.mjs makes; whole-line `#` comments are blanked first so a comment
54
- // cannot satisfy a pattern. A packageRule is treated as applying to every
55
- // update type it names regardless of any other matcher on it. That is
56
- // one-sided, not simply conservative: an extra matcher on a rule that ADDS
57
- // `automerge:false`/labels can make Renovate apply the safety settings to
58
- // FEWER packages than this test assumes — narrow the major rule away from
59
- // the real dependency it must cover and nothing here reds, while real
60
- // Renovate falls through to the unattended top-level automerge for it; this
61
- // repo's actual major rule matches on update type alone, which is what
62
- // keeps that gap closed, not this test. An extra matcher on a rule that
63
- // only LOOSENS settings is the direction that stays merely stricter than
64
- // Renovate. And the ordering of Renovate's label write against the
65
- // fallback job on the `opened` event is runtime behaviour no file here
66
- // records.
67
- import { test } from "node:test";
68
- import assert from "node:assert/strict";
69
- import { readFileSync } from "node:fs";
70
- import { join } from "node:path";
71
-
72
- const ROOT = join(import.meta.dirname, "..", "..");
73
- const BOT = "renovate.json";
74
- const GATE = ".github/workflows/release-label.yml";
75
- const RELEASE = ".github/workflows/release.yml";
76
-
77
- // Renovate's vocabulary on one side, release.yml's segment variables on the
78
- // other: the size a semver update type must be announced as.
79
- const SEGMENT_OF = { major: "MAJOR", minor: "MINOR", patch: "PATCH" };
80
-
81
- const code = (text) =>
82
- text
83
- .split("\n")
84
- .map((line) => (/^\s*#/.test(line) ? "" : line))
85
- .join("\n");
86
-
87
- // The `select(. == "a" or . == "b")` jq filter both workflows use to decide
88
- // which labels are release labels.
89
- function releaseLabelFilter(src, file, problems) {
90
- const hits = [...src.matchAll(/select\(((?:\s*\.\s*==\s*"[^"]*"\s*(?:or)?)+)\s*\)/g)];
91
- if (hits.length !== 1) {
92
- problems.push(
93
- `${file}: expected exactly one \`select(. == "…" or …)\` release-label filter, found ${hits.length} — cannot tell which labels it treats as release labels`,
94
- );
95
- return null;
96
- }
97
- return new Set([...hits[0][1].matchAll(/"([^"]*)"/g)].map((m) => m[1]));
98
- }
99
-
100
- function readGate(text, problems) {
101
- const src = code(text);
102
- const counted = releaseLabelFilter(src, GATE, problems);
103
- const guard = src.match(/grep\s+-qE\s+'\^\(([^)]*)\)\$'/);
104
- if (!guard) {
105
- problems.push(
106
- `${GATE}: no \`grep -qE '^(…)$'\` guard found — cannot tell which labels make the bot fallback stand down`,
107
- );
108
- }
109
- const fallbacks = [...src.matchAll(/--add-label\s+["']?([^\s"']+)/g)].map((m) => m[1]);
110
- if (fallbacks.length !== 1) {
111
- problems.push(
112
- `${GATE}: expected exactly one \`--add-label\` bot fallback, found ${fallbacks.length}`,
113
- );
114
- }
115
- return {
116
- counted,
117
- guard: guard ? new Set(guard[1].split("|")) : null,
118
- fallback: fallbacks.length === 1 ? fallbacks[0] : null,
119
- };
120
- }
121
-
122
- function readRelease(text, problems) {
123
- const src = code(text);
124
- const labels = releaseLabelFilter(src, RELEASE, problems);
125
- const bumps = new Map();
126
- for (const m of src.matchAll(/([^\s()|;]+)\)\s*(MAJOR|MINOR|PATCH)=\$\(\(\s*\2\s*\+\s*1\s*\)\)/g)) {
127
- bumps.set(m[1], m[2]);
128
- }
129
- if (labels) {
130
- for (const label of labels) {
131
- if (!bumps.has(label)) {
132
- problems.push(`${RELEASE}: reads \`${label}\` as a release label but no case arm bumps a segment for it`);
133
- }
134
- }
135
- }
136
- for (const segment of Object.values(SEGMENT_OF)) {
137
- const by = [...bumps].filter(([, s]) => s === segment).map(([l]) => l);
138
- if (by.length !== 1) {
139
- problems.push(`${RELEASE}: expected exactly one label to bump ${segment}, found ${by.length} (${by.join(", ") || "none"})`);
140
- }
141
- }
142
- return { labels, bumps };
143
- }
144
-
145
- // What a bot PR of `type` ends up carrying, in Renovate's own merge order.
146
- function resolveBot(cfg, type) {
147
- let labels = cfg.labels ?? [];
148
- const added = [...(cfg.addLabels ?? [])];
149
- let automerge = cfg.automerge ?? false;
150
- const apply = (layer) => {
151
- if ("labels" in layer) labels = layer.labels;
152
- if (layer.addLabels) added.push(...layer.addLabels);
153
- if ("automerge" in layer) automerge = layer.automerge;
154
- };
155
- if (cfg[type]) apply(cfg[type]);
156
- for (const rule of cfg.packageRules ?? []) {
157
- if (rule.matchUpdateTypes === undefined || [].concat(rule.matchUpdateTypes).includes(type)) apply(rule);
158
- }
159
- return { labels: [...new Set([...labels, ...added])], automerge: automerge === true };
160
- }
161
-
162
- function emittableTypes(cfg) {
163
- const types = Object.keys(SEGMENT_OF);
164
- const rollback = cfg.rollbackPrs === true || (cfg.packageRules ?? []).some((r) => r.rollbackPrs === true);
165
- return rollback ? [...types, "rollback"] : types;
166
- }
167
-
168
- // A JSON-valid renovate.json can still have the wrong SHAPE at exactly the
169
- // spots resolveBot/emittableTypes read without a type check — an update-type
170
- // override or a packageRules entry that is not a plain object, or
171
- // packageRules itself not an array — and both throw a raw TypeError instead
172
- // of a problem naming which file disagreed, breaking this test's own
173
- // contract (the ticket's AC: "failure message names the file... and what the
174
- // disagreement was"). Checked once, up front, so every downstream read can
175
- // assume the shape it needs.
176
- function isPlainObject(v) {
177
- return v !== null && typeof v === "object" && !Array.isArray(v);
178
- }
179
- function botShapeProblem(cfg) {
180
- if (cfg.packageRules !== undefined && !Array.isArray(cfg.packageRules)) {
181
- return `${BOT}: \`packageRules\` must be an array, got ${typeof cfg.packageRules}`;
182
- }
183
- for (const rule of cfg.packageRules ?? []) {
184
- if (!isPlainObject(rule)) return `${BOT}: a \`packageRules\` entry must be an object, got ${JSON.stringify(rule)}`;
185
- }
186
- for (const type of [...Object.keys(SEGMENT_OF), "rollback"]) {
187
- if (cfg[type] !== undefined && !isPlainObject(cfg[type])) {
188
- return `${BOT}: top-level \`${type}\` override must be an object, got ${JSON.stringify(cfg[type])}`;
189
- }
190
- }
191
- return null;
192
- }
193
-
194
- function contractProblems({ bot, gate, release }) {
195
- const problems = [];
196
- let cfg;
197
- try {
198
- cfg = JSON.parse(bot);
199
- } catch (err) {
200
- return [`${BOT}: not valid JSON (${err.message})`];
201
- }
202
- const shapeProblem = botShapeProblem(cfg);
203
- if (shapeProblem) return [shapeProblem];
204
-
205
- // The one check #1752 exists to guarantee — a major update must never
206
- // automerge — needs only `cfg` and `resolveBot`, so it runs before, and
207
- // independently of, the gate/release parsing below: a cosmetic mismatch in
208
- // either workflow (e.g. a quoting style neither readGate nor readRelease
209
- // recognises) must not mask a live major-automerge regression behind an
210
- // unrelated "cannot tell which labels…" problem.
211
- if (resolveBot(cfg, "major").automerge) {
212
- problems.push(
213
- `${BOT}: \`major\` updates are automerged — a major must wait for a human, so the rule for \`major\` needs \`"automerge": false\``,
214
- );
215
- }
216
-
217
- const g = readGate(gate, problems);
218
- const r = readRelease(release, problems);
219
- if (!g.counted || !g.guard || !g.fallback || !r.labels) return problems;
220
-
221
- if (g.counted.size !== r.labels.size || [...g.counted].some((l) => !r.labels.has(l))) {
222
- problems.push(
223
- `${GATE} vs ${RELEASE}: the gate counts [${[...g.counted]}] as release labels but release.yml reads [${[...r.labels]}] — a label only one side knows either passes the gate and mints nothing, or mints from a PR the gate refused`,
224
- );
225
- }
226
-
227
- if (JSON.stringify(cfg.enabledManagers) !== JSON.stringify(["nvm"])) {
228
- problems.push(
229
- `${BOT}: enabledManagers is ${JSON.stringify(cfg.enabledManagers)}, not ["nvm"] — the update types this test checks were derived for the nvm manager alone, so a new manager's update types (digest, pin, …) would go unchecked; extend emittableTypes before widening it`,
230
- );
231
- }
232
-
233
- for (const type of emittableTypes(cfg)) {
234
- const { labels, automerge } = resolveBot(cfg, type);
235
- const releaseLabels = labels.filter((l) => g.counted.has(l));
236
- const segments = releaseLabels.map((l) => r.bumps.get(l));
237
- // `major` itself is covered unconditionally above, before g/r even
238
- // parse; here we only catch OTHER types whose resolved label maps to a
239
- // MAJOR segment (a minor/patch rule mislabelled onto `major`).
240
- if (automerge && type !== "major" && segments.includes("MAJOR")) {
241
- problems.push(
242
- `${BOT}: \`${type}\` updates are automerged while carrying a major change — a major must wait for a human, so the rule for \`${type}\` needs \`"automerge": false\``,
243
- );
244
- }
245
- if (releaseLabels.length === 0) {
246
- problems.push(
247
- `${BOT}: \`${type}\` updates get no release label from the bot config (resolved labels: [${labels}]) — ${GATE}'s bot fallback then stamps them \`${g.fallback}\` whatever their size`,
248
- );
249
- continue;
250
- }
251
- if (releaseLabels.length > 1) {
252
- problems.push(
253
- `${BOT}: \`${type}\` updates resolve to ${releaseLabels.length} release labels [${releaseLabels}] — ${GATE} refuses more than one, so the PR can never merge`,
254
- );
255
- continue;
256
- }
257
- const [label] = releaseLabels;
258
- if (!g.guard.has(label)) {
259
- problems.push(
260
- `${GATE} vs ${BOT}: the bot fallback's guard does not recognise \`${label}\`, which the bot sets on \`${type}\` updates — the fallback adds \`${g.fallback}\` on top and the PR carries two release labels`,
261
- );
262
- }
263
- const want = SEGMENT_OF[type];
264
- if (want && segments[0] !== want) {
265
- problems.push(
266
- `${BOT} vs ${RELEASE}: \`${type}\` updates are labelled \`${label}\`, which release.yml bumps as ${segments[0] ?? "nothing"} — a ${type} update must mint a ${want} release`,
267
- );
268
- }
269
- }
270
- return problems;
271
- }
272
-
273
- const REAL = {
274
- bot: readFileSync(join(ROOT, BOT), "utf8"),
275
- gate: readFileSync(join(ROOT, GATE), "utf8"),
276
- release: readFileSync(join(ROOT, RELEASE), "utf8"),
277
- };
278
-
279
- const withBot = (mutate) => {
280
- const cfg = JSON.parse(REAL.bot);
281
- mutate(cfg);
282
- return { ...REAL, bot: JSON.stringify(cfg) };
283
- };
284
- const ruleFor = (cfg, type) =>
285
- cfg.packageRules.find((r) => [].concat(r.matchUpdateTypes ?? []).includes(type));
286
-
287
- const report = (problems) => `\n ${problems.join("\n ")}`;
288
- const assertClean = (files) => {
289
- const problems = contractProblems(files);
290
- assert.deepEqual(problems, [], `the bot/release contract is broken:${report(problems)}`);
291
- };
292
- const assertBroken = (files, file, pattern) => {
293
- const problems = contractProblems(files);
294
- assert.ok(
295
- problems.some((p) => p.startsWith(file) && pattern.test(p)),
296
- `expected a problem naming ${file} matching ${pattern}, got:${report(problems)}`,
297
- );
298
- };
299
-
300
- test("the committed bot config and both release workflows keep the joint contract", () => {
301
- assertClean(REAL);
302
- });
303
-
304
- test("dropping the bot's label rules reds: the blind fallback would label every update", () => {
305
- const files = withBot((cfg) => {
306
- for (const rule of cfg.packageRules) delete rule.labels;
307
- });
308
- for (const type of ["major", "minor", "patch"]) {
309
- assertBroken(files, BOT, new RegExp(`\`${type}\` updates get no release label.*bot fallback`));
310
- }
311
- assertBroken(withBot((cfg) => delete cfg.packageRules), BOT, /`major` updates get no release label/);
312
- });
313
-
314
- test("re-enabling major automerge reds, whether set outright or inherited from the default", () => {
315
- assertBroken(withBot((cfg) => (ruleFor(cfg, "major").automerge = true)), BOT, /`major` updates are automerged/);
316
- assertBroken(withBot((cfg) => delete ruleFor(cfg, "major").automerge), BOT, /`major` updates are automerged/);
317
- assertBroken(withBot((cfg) => delete cfg.packageRules), BOT, /`major` updates are automerged/);
318
- });
319
-
320
- test("a mislabelled update type reds, naming the bot config and release.yml", () => {
321
- assertBroken(
322
- withBot((cfg) => (ruleFor(cfg, "major").labels = ["patch"])),
323
- `${BOT} vs ${RELEASE}`,
324
- /`major` updates are labelled `patch`, which release.yml bumps as PATCH/,
325
- );
326
- // Top-level `automerge: true` stays in force for minor; relabelling its
327
- // rule `major` makes it a major change by release.yml's reading.
328
- assertBroken(
329
- withBot((cfg) => (ruleFor(cfg, "minor").labels = ["major"])),
330
- BOT,
331
- /`minor` updates are automerged while carrying a major change/,
332
- );
333
- });
334
-
335
- // A literal, checked edit: a mutant whose target text has drifted away would
336
- // otherwise leave the file unchanged and assert against the real tree.
337
- const swap = (text, from, to) => {
338
- assert.ok(text.includes(from), `mutation target \`${from}\` not found — update this test's mutant`);
339
- return text.split(from).join(to);
340
- };
341
-
342
- test("a workflow that stops agreeing with the other two reds, naming that workflow", () => {
343
- assertBroken(
344
- { ...REAL, gate: swap(REAL.gate, "'^(patch|minor|major)$'", "'^(patch|minor)$'") },
345
- `${GATE} vs ${BOT}`,
346
- /guard does not recognise `major`/,
347
- );
348
- assertBroken(
349
- { ...REAL, release: swap(swap(REAL.release, '"major"', '"breaking"'), "major) MAJOR=", "breaking) MAJOR=") },
350
- `${GATE} vs ${RELEASE}`,
351
- /the gate counts .* but release.yml reads/,
352
- );
353
- });
354
-
355
- test("rewording the schedule or renaming the labels in all three files stays green", () => {
356
- assertClean(withBot((cfg) => (cfg.schedule = ["on the first day of the month"])));
357
-
358
- const rename = (text) => text.replace(/\b(patch|minor|major)\b/g, "semver:$1");
359
- assertClean({
360
- ...withBot((cfg) => {
361
- for (const r of cfg.packageRules) r.labels = r.labels.map((l) => `semver:${l}`);
362
- }),
363
- gate: rename(REAL.gate),
364
- release: rename(REAL.release),
365
- });
366
- });
367
-
368
- test("the same contract expressed through addLabels and update-type objects stays green", () => {
369
- assertClean(
370
- withBot((cfg) => {
371
- cfg.labels = ["dependencies"];
372
- cfg.major = { automerge: false, addLabels: ["major"] };
373
- cfg.packageRules = [
374
- { matchUpdateTypes: "minor", addLabels: ["minor"] },
375
- { matchUpdateTypes: ["patch"], addLabels: ["patch"] },
376
- ];
377
- }),
378
- );
379
- });