@feigi/fleet-ctl 3.23.35 → 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,927 +0,0 @@
1
- // `ledger.mjs dispatch | settle | drain` and the `## Dispatched` list (#1799;
2
- // spec 2026-09-24 § 6 §2 and § 4 item 2). The token grammar these write is
3
- // ledger-grammar.test.mjs's subject; this file is about what lands in the
4
- // file, and what the three subcommands refuse to write.
5
- //
6
- // Every call is its own process against one ledger file, with nothing carried
7
- // between calls but that file — the position a replacement controller is in
8
- // after a context loss, which is who these records exist for.
9
-
10
- import { test } from "node:test";
11
- import assert from "node:assert/strict";
12
- import { spawnSync } from "node:child_process";
13
- import { mkdtempSync, mkdirSync, rmSync, writeFileSync, readFileSync, existsSync } from "node:fs";
14
- import { tmpdir } from "node:os";
15
- import { join } from "node:path";
16
- import { fileURLToPath } from "node:url";
17
- import { computeBoard } from "./compute-board.mjs";
18
- import { deriveRun } from "./fleet-tick.mjs";
19
-
20
- const SCRIPT = fileURLToPath(new URL("./ledger.mjs", import.meta.url));
21
-
22
- function fixture(t, body = null) {
23
- const dir = mkdtempSync(join(tmpdir(), "ledger-dispatch-"));
24
- t.after(() => rmSync(dir, { recursive: true, force: true }));
25
- const file = join(dir, "ledger.md");
26
- if (body !== null) writeFileSync(file, body);
27
- // PATH is an empty directory: none of these subcommands may reach gh or
28
- // git, and with `--file` given nothing else in ledger.mjs does either.
29
- const bin = join(dir, "bin");
30
- mkdirSync(bin);
31
- const env = { ...process.env, PATH: bin };
32
- delete env.GIT_DIR;
33
- delete env.GIT_WORK_TREE;
34
- const cli = (...args) => {
35
- const r = spawnSync(process.execPath, [SCRIPT, "--file", file, ...args], { encoding: "utf8", env, cwd: dir });
36
- return { ...r, json: r.status === 0 ? JSON.parse(r.stdout) : null };
37
- };
38
- const ok = (...args) => {
39
- const r = cli(...args);
40
- assert.equal(r.status, 0, `${args.join(" ")}: got exit ${r.status}\n${r.stderr}`);
41
- return r.json;
42
- };
43
- const read = () => ok("read");
44
- const bytes = () => (existsSync(file) ? readFileSync(file, "utf8") : null);
45
- // A refusal is exit 2, a reason on stderr, no payload — and no write.
46
- const refused = (args, why) => {
47
- const before = bytes();
48
- const r = cli(...args);
49
- assert.equal(r.status, 2, `${args.join(" ")}: got exit ${r.status}\n${r.stderr}`);
50
- assert.match(r.stderr, why, `${args.join(" ")}: stderr was ${r.stderr}`);
51
- assert.equal(r.stdout, "", `${args.join(" ")}: a refusal must not also emit a payload`);
52
- assert.equal(bytes(), before, `${args.join(" ")}: a refusal must not touch the ledger`);
53
- };
54
- return { file, cli, ok, read, bytes, refused };
55
- }
56
-
57
- test("dispatch appends a live member row and records the dispatch in ## Dispatched", (t) => {
58
- const { ok, read, bytes } = fixture(t);
59
- assert.deepEqual(ok("dispatch", "412", "impl-412"), {
60
- member: "impl-412", agent: "fleet-implementer-slow-high", ticket: "#412", line: "#412 impl-412", created: true, total: 1,
61
- });
62
- const l = read();
63
- assert.deepEqual(l.rows, ["#412 impl-412"]);
64
- assert.deepEqual(l.dispatched, ["impl-412"]);
65
- assert.match(bytes(), /^## Dispatched\n\n- impl-412$/m);
66
- });
67
-
68
- // SKILL.md's phase 2 writes `row <N> "impl-<N> · class=routine"` at dispatch
69
- // today, so a row that already carries the live token is the ordinary case
70
- // and must be accepted without a second copy of it.
71
- test("dispatch keeps an existing row's text, appending the token only where it is missing", (t) => {
72
- const { ok, read } = fixture(t);
73
- ok("row", "412", "impl-412 · class=routine");
74
- ok("row", "415", "claimed · class=correction");
75
- assert.deepEqual(ok("dispatch", "412", "impl-412"), {
76
- member: "impl-412", agent: "fleet-implementer-slow-high", ticket: "#412", line: "#412 impl-412 · class=routine", created: false, total: 1,
77
- });
78
- assert.equal(ok("dispatch", "#415", "impl-415").line, "#415 claimed · class=correction · impl-415");
79
- assert.deepEqual(read().dispatched, ["impl-412", "impl-415"]);
80
- });
81
-
82
- test("a PR-bound member lands on the row carrying its PR, named by PR or by ticket", (t) => {
83
- const { ok, read } = fixture(t);
84
- ok("dispatch", "324", "impl-324");
85
- ok("settle", "impl-324", "PR#346");
86
- // By the PR number: found through the implementer's own settled token.
87
- assert.deepEqual(ok("dispatch", "346", "fix-pr-346"), {
88
- member: "fix-pr-346", agent: null, ticket: "#324", line: "#324 impl-324=PR#346 · fix-pr-346", created: false, total: 2,
89
- });
90
- // By the ticket number whose row carries that PR.
91
- assert.equal(ok("dispatch", "324", "finisher-pr-346").line, "#324 impl-324=PR#346 · fix-pr-346 · finisher-pr-346");
92
- // The human-readable arrow a `row` call writes is found the same way.
93
- ok("row", "330", "impl-330 → PR#350");
94
- assert.equal(ok("dispatch", "350", "fix-pr-350").ticket, "#330");
95
- // A PR no row carries gets a row of its own.
96
- assert.deepEqual(ok("dispatch", "777", "fix-pr-777"), {
97
- member: "fix-pr-777", agent: null, ticket: "#777", line: "#777 fix-pr-777", created: true, total: 5,
98
- });
99
- assert.equal(read().rows.length, 3);
100
- });
101
-
102
- test("dispatch refuses a call that would record the wrong member, and writes nothing", (t) => {
103
- const { ok, refused } = fixture(t);
104
- ok("row", "324", "impl-324");
105
- for (const [args, why] of [
106
- [["dispatch", "415", "impl-412"], /impl-412 works ticket #412, not #415/],
107
- [["dispatch", "324", "fix-pr-346"], /fix-pr-346 works PR #346, and row #324 carries no PR#346/],
108
- [["dispatch", "412", "review-pr-412"], /unknown member 'review-pr-412'/],
109
- [["dispatch", "412", "impl-412x"], /unknown member 'impl-412x'/],
110
- [["dispatch", "5", "merge-bot"], /merge bots work no ticket or PR/],
111
- [["dispatch", "5", "merge-bot-1"], /merge bots work no ticket or PR/],
112
- [["dispatch", "--requre-file", "impl-412"], /unknown flag --requre-file — expected a ticket or PR number/],
113
- [["dispatch", "-require-file", "impl-412"], /unknown flag -require-file — expected a ticket or PR number/],
114
- [["dispatch", "abc", "impl-412"], /'abc' is not a ticket or PR number/],
115
- [["dispatch", "impl-412"], /impl-412 works a ticket or PR — usage: ledger\.mjs dispatch <ticket\|pr> <member>/],
116
- [["dispatch"], /usage: ledger\.mjs dispatch <ticket\|pr> <member>/],
117
- [["dispatch", "412", "impl-412", "extra"], /usage: ledger\.mjs dispatch <ticket\|pr> <member>/],
118
- ]) {
119
- refused(args, why);
120
- }
121
- });
122
-
123
- test("a member is dispatched once; its replacement takes a name of its own", (t) => {
124
- const { ok, read, refused } = fixture(t);
125
- ok("dispatch", "412", "impl-412");
126
- refused(["dispatch", "412", "impl-412"], /impl-412 was already dispatched this run/);
127
- ok("settle", "impl-412", "killed");
128
- refused(["dispatch", "412", "impl-412"], /impl-412 was already dispatched this run \(impl-412=killed\)/);
129
- assert.equal(ok("dispatch", "412", "impl-412-b").line, "#412 impl-412=killed · impl-412-b");
130
- assert.deepEqual(read().dispatched, ["impl-412=killed", "impl-412-b"]);
131
- });
132
-
133
- test("merge-bot-<n> counts the ## Dispatched merge-bot entries, and a new ledger starts again at 1", (t) => {
134
- const { ok, read, refused } = fixture(t);
135
- assert.deepEqual(ok("dispatch", "merge-bot"), { member: "merge-bot-1", agent: "fleet-merge-bot", ticket: null, line: null, created: false, total: 1 });
136
- ok("dispatch", "412", "impl-412");
137
- ok("settle", "merge-bot-1", "done");
138
- // A settled bot still counts: its replacement gets a new n.
139
- assert.equal(ok("dispatch", "merge-bot").member, "merge-bot-2");
140
- // The explicit name is accepted when it is the next one, and only then.
141
- assert.equal(ok("dispatch", "merge-bot-3").member, "merge-bot-3");
142
- refused(["dispatch", "merge-bot-5"], /the next merge bot this run is merge-bot-4/);
143
- refused(["dispatch", "merge-bot-2"], /the next merge bot this run is merge-bot-4/);
144
- const l = read();
145
- assert.deepEqual(l.dispatched, ["merge-bot-1=done", "impl-412", "merge-bot-2", "merge-bot-3"]);
146
- assert.deepEqual(l.rows, ["#412 impl-412"], "a merge bot works no ticket, so it writes no row");
147
-
148
- const fresh = fixture(t);
149
- assert.equal(fresh.ok("dispatch", "merge-bot").member, "merge-bot-1");
150
- });
151
-
152
- // #2208: the controller names the `task` call's `agent` off this output, not
153
- // off prose a compaction drops — so every family's definition is printed, and
154
- // an implementer's follows its row's `tier=` the way tier-check.mjs reads it:
155
- // none is the policy cell, `slow-high`.
156
- test("dispatch prints the agent definition the call names: the row's tier for an implementer, fixed for finisher and merge bot, null for a review fix-applier", (t) => {
157
- const { ok } = fixture(t);
158
- assert.equal(ok("dispatch", "7", "impl-7").agent, "fleet-implementer-slow-high");
159
- ok("row", "8", "impl-8 · class=routine · tier=task-high");
160
- assert.equal(ok("dispatch", "8", "impl-8").agent, "fleet-implementer-task-high");
161
- // A replacement inherits the row's tier, because it reads the same row.
162
- ok("settle", "impl-8", "killed");
163
- assert.equal(ok("dispatch", "8", "impl-8-b").agent, "fleet-implementer-task-high");
164
- // Neither verdict token is a `tier=` token.
165
- ok("row", "10", "impl-10 · tier-ok=impl-10:fleet-implementer-task-high · tier-mismatch=impl-10:fleet-implementer-task-high");
166
- assert.equal(ok("dispatch", "10", "impl-10").agent, "fleet-implementer-slow-high");
167
- ok("settle", "impl-7", "PR#70");
168
- assert.equal(ok("dispatch", "70", "finisher-pr-70").agent, "fleet-finisher");
169
- assert.equal(ok("dispatch", "70", "fix-pr-70").agent, null);
170
- assert.equal(ok("dispatch", "merge-bot").agent, "fleet-merge-bot");
171
- });
172
-
173
- // A `tier=` of the right shape whose definition has no file is refused the
174
- // same way: a `task` call naming it cannot resolve. Two of those: a cell
175
- // outside the shipped grid (`smol-max` — haiku has no `max`), and the
176
- // pre-cell `alt`, whose definition is deleted. `row` refuses a non-cell
177
- // `tier=` before it is written, so the rows `row` would refuse are written
178
- // as a ledger edited by hand — the case dispatch's own check still meets.
179
- test("dispatch refuses an implementer whose row names no single definition, or one with no file, before marking it live", (t) => {
180
- const rows = ["#7 class=routine · tier=alt · tier=slow-high", "#8 class=routine · tier=../../etc", "#9 class=routine · tier=", "#11 class=routine · tier=alt"];
181
- const { ok, read, refused } = fixture(t, `# Fleet run ledger\n\n## Rows\n\n${rows.map((r) => `- ${r}\n`).join("")}\n## Filed\n\n## Ruled\n\n`);
182
- refused(["dispatch", "7", "impl-7"], /impl-7: row carries conflicting tier= tokens \(tier=alt, tier=slow-high\) — fix the row with `ledger\.mjs row` — not dispatching impl-7/);
183
- refused(["dispatch", "8", "impl-8"], /impl-8: tier=\.\.\/\.\.\/etc is not a definition suffix — expected \[a-z0-9\] words joined by '-' — fix the row with `ledger\.mjs row` — not dispatching impl-8/);
184
- refused(["dispatch", "9", "impl-9"], /impl-9: tier= is not a definition suffix/);
185
- ok("row", "10", "class=routine · tier=smol-max");
186
- refused(["dispatch", "10", "impl-10"], /impl-10: row #10's tier= names fleet-implementer-smol-max, which has no agents\/fleet-implementer-smol-max\.agent\.md — fix the row with `ledger\.mjs row` — not dispatching impl-10/);
187
- refused(["dispatch", "11", "impl-11"], /impl-11: row #11's tier= names fleet-implementer-alt, which has no agents\/fleet-implementer-alt\.agent\.md/);
188
- ok("row", "12", "class=routine · tier=task-high · tier=slow-high");
189
- refused(["dispatch", "12", "impl-12"], /impl-12: row carries conflicting tier= tokens \(tier=task-high, tier=slow-high\)/);
190
- assert.deepEqual(read().dispatched, []);
191
- });
192
-
193
- // `row` holds `tier=` to the cell grammar, so a retired or misspelt tier is
194
- // refused at the Pull's own write, before the claim is dispatched on — and a
195
- // cell token is accepted whether or not its definition has shipped, which is
196
- // `dispatch`'s to check. The value is held to the whole grammar, not a prefix
197
- // of it: a real family with an unknown level, a cell with trailing text, or a
198
- // case-variant of a cell is refused. Only a token that STARTS with `tier=` is
199
- // a tier token, so one that merely contains it (`x-tier=alt`) is written as is.
200
- test("row refuses a tier= that is not a cell token, and accepts every cell token", (t) => {
201
- const { ok, read, refused } = fixture(t);
202
- const bads = [
203
- "tier=alt", "tier=", "tier=../../etc", "tier=Task-High", "tier=task-high · tier=alt", "tier=haiku-high",
204
- "tier=slow-ultra", "tier=task-", "tier=smol-", "tier=slow", "tier=task-high-x", "tier=task-high-", "tier=task-highx",
205
- "tier==task-high", "tier=task-high,", "tier=TASK-HIGH", "tier=Slow-High", "tier=slow-HIGH", "tier=xslow-high",
206
- ];
207
- for (const bad of bads) {
208
- refused(["row", "7", `impl-7 · ${bad}`], /row #7: 'tier=[^']*' is not tier=<cell>/);
209
- }
210
- assert.deepEqual(read().rows, []);
211
- const goods = ["tier=task-high", "tier=slow-high", "tier=smol-max", "tier-ok=impl-7:fleet-implementer-task-high", "x-tier=alt", "x-tier=Slow-ultra · tier=task-high"];
212
- for (const good of goods) {
213
- assert.equal(ok("row", "7", `impl-7 · ${good}`).line, `#7 impl-7 · ${good}`);
214
- }
215
- });
216
-
217
- // The refusal is about the implementer's own definition: a member whose
218
- // definition does not come off `tier=` must still be dispatchable on such a
219
- // row, or one bad token would strand the PR's finisher and fix-applier.
220
- test("a malformed tier= on a row does not refuse a member whose definition ignores it", (t) => {
221
- const { ok } = fixture(t);
222
- ok("row", "7", "impl-7=PR#70 · tier=task-high · tier=slow-high");
223
- assert.equal(ok("dispatch", "70", "fix-pr-70").agent, null);
224
- assert.equal(ok("dispatch", "7", "finisher-pr-70").agent, "fleet-finisher");
225
- });
226
-
227
- // #2299: a fix-applier dispatched on merge-bot's conflict hold is a
228
- // `fleet-implementer-slow-high` (the policy cell) whatever the row's tier,
229
- // named off `dispatch`'s output like every other member. A review
230
- // fix-applier stays a generic `task` — including on a row whose hold a
231
- // fix-applier has already cleared.
232
- test("dispatch names a fix-applier on an unresolved conflict hold of its own PR the policy cell's implementer, whatever the row's tier or the hold's spelling", (t) => {
233
- const { ok } = fixture(t);
234
- ok("row", "20", "impl-20=PR#21 · conflict-hold:#21");
235
- assert.equal(ok("dispatch", "21", "fix-pr-21").agent, "fleet-implementer-slow-high");
236
- // A failed one leaves the hold unresolved, so its replacement is one too.
237
- ok("settle", "fix-pr-21", "failed");
238
- assert.equal(ok("dispatch", "21", "fix-pr-21-b").agent, "fleet-implementer-slow-high");
239
-
240
- // `tier=` is not consulted — conflicting values neither change nor refuse it.
241
- ok("row", "50", "impl-50=PR#51 · tier=task-high · conflict-hold:#51");
242
- assert.equal(ok("dispatch", "51", "fix-pr-51").agent, "fleet-implementer-slow-high");
243
- ok("row", "60", "impl-60=PR#61 · tier=task-high · tier=slow-high · conflict-hold:#61");
244
- assert.equal(ok("dispatch", "61", "fix-pr-61").agent, "fleet-implementer-slow-high");
245
-
246
- // The hold's other spelling the tick reads (fleet-tick.mjs's CONFLICT_HOLD).
247
- ok("row", "70", "impl-70=PR#71 · conflict-hold-71");
248
- assert.equal(ok("dispatch", "71", "fix-pr-71").agent, "fleet-implementer-slow-high");
249
- });
250
-
251
- test("dispatch names a review fix-applier null, including after a hold a fix-applier settled, until a fresh hold", (t) => {
252
- const { ok } = fixture(t);
253
- ok("row", "30", "impl-30=PR#31");
254
- assert.equal(ok("dispatch", "31", "fix-pr-31").agent, null);
255
-
256
- // A hold a fix-applier settled `applied:`/`no-op` after is cleared: the
257
- // row's next fix-applier works a review's survivors.
258
- ok("row", "80", "impl-80=PR#81 · conflict-hold:#81 · fix-pr-81=applied:def5678 · reviewed=abc1234:1/0/0");
259
- assert.equal(ok("dispatch", "81", "fix-pr-81-b").agent, null);
260
- ok("row", "90", "impl-90=PR#91 · conflict-hold:#91 · fix-pr-91=no-op");
261
- assert.equal(ok("dispatch", "91", "fix-pr-91-b").agent, null);
262
- // ...until a fresh hold after that settle.
263
- ok("row", "100", "impl-100=PR#101 · fix-pr-101=applied:73b356de · conflict-hold:#101");
264
- assert.equal(ok("dispatch", "101", "fix-pr-101-b").agent, "fleet-implementer-slow-high");
265
- });
266
-
267
- // The hold is the tick's reading, so a ledger the tick refuses — here a hold
268
- // recorded on another PR's row — names no definition: dispatch refuses before
269
- // the member is live, rather than reading one row the tick would throw on.
270
- test("dispatch refuses a fix-applier on a ledger the tick refuses, before marking it live", (t) => {
271
- const { ok, read, refused } = fixture(t);
272
- ok("row", "40", "impl-40=PR#41 · conflict-hold:#42");
273
- refused(["dispatch", "41", "fix-pr-41"], /'conflict-hold:#42' names PR #42, but this row is PR #41's .* — fleet-tick\.mjs refuses this ledger, so fix-pr-41's definition cannot be read off it/);
274
- assert.deepEqual(read().dispatched, []);
275
- // A finisher's dispositions gate reads the same fold, so it is refused too,
276
- // naming the ledger as the cause rather than reading an unreadable verdict.
277
- refused(["dispatch", "41", "finisher-pr-41"], /— fleet-tick\.mjs refuses this ledger, so finisher-pr-41's dispositions verdict cannot be read off it/);
278
- assert.deepEqual(read().dispatched, []);
279
- });
280
-
281
- // A PR's tokens can sit on two rows — its ticket's, and a `#<pr>` row `row`
282
- // keyed by the PR's own number (#2283). The tick folds both into one state per
283
- // PR; dispatch must name the fix-applier off that same state, so the two
284
- // readers agree whichever row carries the hold or the settle that clears it.
285
- test("dispatch reads a fix-applier's conflict hold off the PR's merged state, agreeing with the tick", (t) => {
286
- const { ok, read } = fixture(t);
287
- const agrees = (key, member, expected) => {
288
- const l = read();
289
- const tickHeld = deriveRun({ rows: l.rows, dispatched: l.dispatched, drain: null }, []).conflictHeld.includes(Number(key));
290
- const { agent } = ok("dispatch", key, member);
291
- assert.equal(agent, expected, `${member} on ${JSON.stringify(l.rows)}`);
292
- assert.equal(agent, tickHeld ? "fleet-implementer-slow-high" : null, `${member}: dispatch and the tick disagree`);
293
- };
294
-
295
- // The hold on the PR's own row, the ticket row first and holding none.
296
- ok("row", "20", "impl-20=PR#21");
297
- ok("row", "21", "conflict-hold:#21");
298
- agrees("21", "fix-pr-21", "fleet-implementer-slow-high");
299
-
300
- // The hold on the ticket row, cleared by a settle on the PR's own row.
301
- ok("row", "30", "impl-30=PR#31 · conflict-hold:#31");
302
- ok("row", "31", "fix-pr-31=applied:abc1234 · reviewed=def5678:2/0/0");
303
- agrees("31", "fix-pr-31-b", null);
304
- });
305
-
306
- test("settle rewrites the member's token in its row and in ## Dispatched, and nothing else", (t) => {
307
- const { ok, read } = fixture(t);
308
- ok("row", "412", "impl-412 · class=routine · ports=16412");
309
- ok("dispatch", "412", "impl-412");
310
- assert.deepEqual(ok("settle", "impl-412", "PR#420"), {
311
- member: "impl-412", outcome: "PR#420", ticket: "#412", line: "#412 impl-412=PR#420 · class=routine · ports=16412", changed: true,
312
- });
313
- // The one-token spelling the spec's record-before-tick table uses.
314
- ok("dispatch", "415", "impl-415");
315
- assert.equal(ok("settle", "impl-415=tier-mismatch").line, "#415 impl-415=tier-mismatch");
316
- ok("dispatch", "420", "fix-pr-420");
317
- assert.equal(ok("settle", "fix-pr-420", "applied:73b356de").line, "#412 impl-412=PR#420 · class=routine · ports=16412 · fix-pr-420=applied:73b356de");
318
- ok("dispatch", "420", "finisher-pr-420");
319
- ok("settle", "finisher-pr-420", "labelled");
320
- ok("dispatch", "merge-bot");
321
- assert.deepEqual(ok("settle", "merge-bot-1", "done"), { member: "merge-bot-1", outcome: "done", ticket: null, line: null, changed: true });
322
- const l = read();
323
- assert.deepEqual(l.dispatched, [
324
- "impl-412=PR#420", "impl-415=tier-mismatch", "fix-pr-420=applied:73b356de", "finisher-pr-420=labelled", "merge-bot-1=done",
325
- ]);
326
- assert.deepEqual(l.rows, [
327
- "#412 impl-412=PR#420 · class=routine · ports=16412 · fix-pr-420=applied:73b356de · finisher-pr-420=labelled",
328
- "#415 impl-415=tier-mismatch",
329
- ]);
330
- });
331
-
332
- test("settle refuses an outcome outside the member's vocabulary, and a malformed call, writing nothing", (t) => {
333
- const { ok, refused } = fixture(t);
334
- ok("dispatch", "412", "impl-412");
335
- ok("dispatch", "merge-bot");
336
- for (const [args, why] of [
337
- [["settle", "impl-412", "done"], /'done' is not an outcome of impl-N — expected PR#M \| bailed \| released \| killed \| tier-mismatch/],
338
- [["settle", "impl-412=labelled"], /'labelled' is not an outcome of impl-N/],
339
- [["settle", "impl-412", "PR#420 extra"], /is not an outcome of impl-N/],
340
- [["settle", "merge-bot-1", "labelled"], /expected done \| killed/],
341
- [["settle", "review-pr-346", "failed"], /unknown member 'review-pr-346'/],
342
- [["settle", "--requre-file", "bailed"], /unknown flag --requre-file — expected a member name/],
343
- [["settle", "impl-412"], /usage: ledger\.mjs settle <member> <outcome>/],
344
- [["settle"], /usage: ledger\.mjs settle <member> <outcome>/],
345
- [["settle", "impl-412", "bailed", "extra"], /usage: ledger\.mjs settle <member> <outcome>/],
346
- ]) {
347
- refused(args, why);
348
- }
349
- });
350
-
351
- test("settle repeats harmlessly with the same outcome and refuses a different one", (t) => {
352
- const { ok, bytes, refused } = fixture(t);
353
- ok("dispatch", "412", "impl-412");
354
- ok("settle", "impl-412", "bailed");
355
- const before = bytes();
356
- assert.deepEqual(ok("settle", "impl-412", "bailed"), {
357
- member: "impl-412", outcome: "bailed", ticket: "#412", line: "#412 impl-412=bailed", changed: false,
358
- });
359
- assert.equal(bytes(), before, "a repeat settle writes nothing");
360
- refused(["settle", "impl-412", "PR#5"], /impl-412 is already settled as bailed/);
361
- refused(["settle", "impl-999", "bailed"], /no live impl-999 in the ledger/);
362
- });
363
-
364
- // The must-ACCEPT half of settle's lookup: a live token that `dispatch` never
365
- // wrote (SKILL.md's `row` writes one today), and a dispatched member whose
366
- // row a later whole-line `row` call rewrote without its token. Refusing either
367
- // leaves that member counted live for the rest of the run.
368
- test("settle accepts a live token `row` wrote, and restores a token a later `row` dropped", (t) => {
369
- const { ok, read } = fixture(t);
370
- ok("row", "412", "impl-412 · class=routine");
371
- assert.equal(ok("settle", "impl-412", "bailed").line, "#412 impl-412=bailed · class=routine");
372
- ok("dispatch", "415", "impl-415");
373
- ok("row", "415", "rewritten by hand");
374
- assert.equal(ok("settle", "impl-415", "PR#9").line, "#415 rewritten by hand · impl-415=PR#9");
375
- assert.deepEqual(read().dispatched, ["impl-415=PR#9"]);
376
- });
377
-
378
- // #2139: every reader parses member tokens anywhere in a row, so a malformed
379
- // one `row` wrote used to land as a permanent settle — `settle merge-bot-1
380
- // done` then refused as "already settled as dispatched". `row` refuses it
381
- // instead, new row or rewrite alike, surfacing the grammar's own error.
382
- test("row refuses a malformed member token anywhere in its text, writing nothing", (t) => {
383
- const { ok, read, refused } = fixture(t);
384
- ok("dispatch", "merge-bot");
385
- refused(
386
- ["row", "2136", "merge-bot-1=dispatched · ci=123:1:success"],
387
- /malformed member token 'merge-bot-1=dispatched' — 'dispatched' is not an outcome of merge-bot-n — expected done \| killed/,
388
- );
389
- assert.deepEqual(read().rows, []);
390
- // A rewrite of an existing row is refused the same way; the old line stays.
391
- ok("row", "412", "impl-412 · class=routine");
392
- for (const [text, why] of [
393
- ["impl-412=done · class=routine", /'impl-412=done' — 'done' is not an outcome of impl-N — expected PR#M \| bailed/],
394
- ["class=routine · impl-412-b=labelled", /'impl-412-b=labelled' — 'labelled' is not an outcome of impl-N/],
395
- ["impl-412 · fix-pr-9=applied:not-a-sha", /'fix-pr-9=applied:not-a-sha' — .* expected applied:<head> \| no-op/],
396
- ["impl-412=", /'impl-412=' — '' is not an outcome of impl-N/],
397
- ]) {
398
- refused(["row", "412", text], why);
399
- }
400
- assert.deepEqual(read().rows, ["#412 impl-412 · class=routine"]);
401
- assert.equal(ok("settle", "merge-bot-1", "done").outcome, "done");
402
- });
403
-
404
- // The must-ACCEPT half: every well-formed member token — live or settled —
405
- // and every non-member key `row` carries today still goes through, including
406
- // tier-check.mjs's `tier-ok=`/`tier-mismatch=` verdicts (#1398), which name
407
- // a member but are not member tokens themselves.
408
- test("row still writes well-formed member tokens and non-member keys", (t) => {
409
- const { ok, read } = fixture(t);
410
- ok("dispatch", "merge-bot");
411
- const rows = [
412
- ["7", "impl-7 · class=routine · ports=16007"],
413
- ["8", "impl-8=PR#9 · fix-pr-9=applied:73b356de · review=wf:r1=failed reviewed=abc1234:1/0/0 · ci=123:1:success"],
414
- ["10", "held-behind:#9 · merge-bot-1=done · review=member:review-pr-10"],
415
- ["11", "impl-11 · tier=task-high · tier-ok=impl-11:fleet-implementer-task-high"],
416
- ["12", "impl-12=bailed · tier-mismatch=impl-12:fleet-implementer · impl-12: dispatched task, expected fleet-implementer"],
417
- ];
418
- for (const [ticket, text] of rows) ok("row", ticket, text);
419
- assert.deepEqual(read().rows, rows.map(([n, text]) => `#${n} ${text}`));
420
- });
421
-
422
- // #2331: `label-off=<attempt>` marks the controller's own removal of
423
- // `ready-to-merge`, so the tick does not read it as a finisher's miss. One
424
- // naming no finisher this run ever had would hide a real miss behind a record
425
- // of nothing, so `row` refuses it — locally, off `## Dispatched` and the rows'
426
- // member tokens, the same two places dispatch's live-sibling check reads.
427
- test("row refuses a label-off naming no finisher this run has, writing nothing", (t) => {
428
- const { ok, read, refused } = fixture(t);
429
- ok("dispatch", "10", "impl-10");
430
- ok("settle", "impl-10", "PR#40");
431
- ok("dispatch", "40", "finisher-pr-40");
432
- const before = read().rows;
433
- for (const [tok, why] of [
434
- ["label-off=finisher-pr-40-b", /'label-off=finisher-pr-40-b' names no finisher-pr member/], // never dispatched
435
- ["label-off=finisher-pr-41", /'label-off=finisher-pr-41'/], // another PR's, never dispatched
436
- ["label-off=impl-10", /'label-off=impl-10' names no finisher-pr member/], // a member, not a finisher
437
- ["label-off=finisher-pr-40=labelled", /'label-off=finisher-pr-40=labelled'/], // a token, not a name
438
- ["label-off=", /'label-off='/],
439
- ]) {
440
- refused(["row", "10", `impl-10=PR#40 → PR#40 · finisher-pr-40 ${tok}`], why);
441
- }
442
- // The new line's own copy of a name does not vouch for it.
443
- refused(["row", "10", "impl-10=PR#40 → PR#40 · finisher-pr-40-c=labelled label-off=finisher-pr-40-c"], /'label-off=finisher-pr-40-c'/);
444
- assert.deepEqual(read().rows, before);
445
- });
446
-
447
- test("row accepts a label-off naming a finisher in ## Dispatched or on any row, settled or live", (t) => {
448
- const { ok, read } = fixture(t);
449
- ok("dispatch", "10", "impl-10");
450
- ok("settle", "impl-10", "PR#40");
451
- ok("dispatch", "40", "finisher-pr-40");
452
- ok("settle", "finisher-pr-40", "labelled");
453
- // Only in `## Dispatched`: a whole-line rewrite dropped the settled token
454
- // from the row first, so no row names the attempt any more.
455
- ok("row", "10", "impl-10=PR#40 → PR#40");
456
- ok("row", "10", "impl-10=PR#40 → PR#40 label-off=finisher-pr-40");
457
- // Only on a row — a token `row` wrote never enters `## Dispatched`.
458
- ok("row", "50", "finisher-pr-50");
459
- ok("row", "50", "finisher-pr-50 label-off=finisher-pr-50");
460
- assert.deepEqual(read().rows, [
461
- "#10 impl-10=PR#40 → PR#40 label-off=finisher-pr-40",
462
- "#50 finisher-pr-50 label-off=finisher-pr-50",
463
- ]);
464
- assert.deepEqual(read().dispatched, ["impl-10=PR#40", "finisher-pr-40=labelled"]);
465
- });
466
-
467
- // #1876: the tick owes an open PR a review while its implementer is still
468
- // live, so a PR-bound member can be dispatched before `settle impl-N=PR#M`
469
- // names the PR on the ticket row. dispatch's fallback then keys a row of its
470
- // own to the PR — truthful until the settle, when two rows would name one PR:
471
- // the cockpit drew two REVIEW cards and the tick's `byPr`, first-row-wins until
472
- // #2283, lost the live review. The settle folds the PR-keyed row into the ticket row.
473
- test("settle impl-N=PR#M folds the PR-keyed row a pre-settle dispatch created into the ticket row", (t) => {
474
- const { ok, read } = fixture(t);
475
- ok("dispatch", "1300", "impl-1300");
476
- assert.equal(ok("dispatch", "1301", "fix-pr-1301").line, "#1301 fix-pr-1301");
477
- ok("row", "1301", "fix-pr-1301 · review=member:review-pr-1301");
478
- assert.deepEqual(read().rows, ["#1300 impl-1300", "#1301 fix-pr-1301 · review=member:review-pr-1301"]);
479
-
480
- const folded = "#1300 impl-1300=PR#1301 · fix-pr-1301 · review=member:review-pr-1301";
481
- assert.deepEqual(ok("settle", "impl-1300=PR#1301"), {
482
- member: "impl-1300", outcome: "PR#1301", ticket: "#1300", line: folded, changed: true,
483
- });
484
- const l = read();
485
- assert.deepEqual(l.rows, [folded]);
486
- assert.deepEqual(l.dispatched, ["impl-1300=PR#1301", "fix-pr-1301"], "the fold moves row tokens only");
487
-
488
- // Both readers see one PR with one live review on it.
489
- const board = computeBoard({
490
- ledger: { rows: l.rows, filed: [], ruled: [] }, issues: [], merged: [], ci: {}, prev: { tickets: [] }, now: 0,
491
- prs: [{ number: 1301, state: "OPEN", labels: [], title: "pr 1301" }],
492
- });
493
- const cards = board.tickets.filter((c) => c.pr === 1301);
494
- assert.equal(cards.length, 1);
495
- assert.equal(cards[0].column, "REVIEW");
496
- assert.equal(cards[0].agent, "review-pr-1301");
497
- assert.equal(board.queue.reviewBacklog, 0, "the PR is under review, not owed one");
498
- const run = deriveRun({ rows: l.rows, dispatched: l.dispatched, drain: null },
499
- [{ number: 1301, labels: [], closingIssuesReferences: [{ number: 1300 }] }]);
500
- assert.equal(run.reviewsLive, 1);
501
- assert.deepEqual(run.reviewDue, []);
502
-
503
- // Every later PR-bound write finds the one row naming the PR.
504
- assert.equal(ok("settle", "fix-pr-1301", "no-op").ticket, "#1300");
505
- assert.equal(ok("dispatch", "1301", "finisher-pr-1301").ticket, "#1300");
506
- assert.equal(read().rows.length, 1);
507
- });
508
-
509
- // #2064: merge-bot records a conflict its local-rebase fallback would not
510
- // force with `row`, and the fix-applier is recorded with the ordinary
511
- // `dispatch`/`settle`. The tick clears the hold only on a settle positioned
512
- // AFTER the hold token, so the writers must put it there — including when
513
- // the PR's review-fix `fix-pr-<M>` already settled earlier on the same row.
514
- test("a conflict hold written by row is cleared by a later dispatch + settle, in the order the tick reads", (t) => {
515
- const { ok, read } = fixture(t);
516
- const before = "impl-10=PR#40 · reviewed=abc1234:1/0/0 · fix-pr-40=applied:73b356de";
517
- ok("row", "10", before);
518
- ok("row", "10", `${before} · conflict-hold:#40`);
519
- const tick = () => {
520
- const l = read();
521
- return deriveRun({ rows: l.rows, dispatched: l.dispatched, drain: null },
522
- [{ number: 40, labels: [{ name: "ready-to-merge" }], closingIssuesReferences: [{ number: 10 }] }]);
523
- };
524
- assert.deepEqual([tick().fixDue, tick().mergeHeld], [[40], 1], "the earlier settle cannot clear the newer hold");
525
-
526
- assert.equal(ok("dispatch", "40", "fix-pr-40-b").line, `#10 ${before} · conflict-hold:#40 · fix-pr-40-b`);
527
- assert.deepEqual([tick().fixDue, tick().mergeHeld], [[], 1], "dispatched is not settled");
528
-
529
- assert.equal(ok("settle", "fix-pr-40-b", "applied:def5678").line, `#10 ${before} · conflict-hold:#40 · fix-pr-40-b=applied:def5678`);
530
- assert.deepEqual([tick().fixDue, tick().mergeHeld], [[], 0]);
531
- });
532
-
533
- // #2328: the conflict fix-applier rebases without the review file, so once it
534
- // lands the PR's unanswered survivors come back due — and `dispatch` names
535
- // their fix-applier a review one, off the same tick state.
536
- test("a review's survivors outlive a conflict fix-applier's settle: the next fix-applier is a review one", (t) => {
537
- const { ok, read } = fixture(t);
538
- ok("row", "20", "impl-20=PR#21 · reviewed=abc1234:2/0/0 · conflict-hold:#21");
539
- const tick = () => {
540
- const l = read();
541
- return deriveRun({ rows: l.rows, dispatched: l.dispatched, drain: null },
542
- [{ number: 21, labels: [], closingIssuesReferences: [{ number: 20 }] }]);
543
- };
544
- assert.deepEqual([tick().fixDue, tick().conflictHeld], [[21], [21]]);
545
- assert.equal(ok("dispatch", "21", "fix-pr-21").agent, "fleet-implementer-slow-high");
546
- assert.deepEqual(tick().fixDue, [], "one fix-applier at a time");
547
- ok("settle", "fix-pr-21", "applied:def5678");
548
- assert.deepEqual([tick().fixDue, tick().conflictHeld], [[21], []], "the survivors it never read are due again");
549
- assert.equal(ok("dispatch", "21", "fix-pr-21-b").agent, null);
550
- ok("settle", "fix-pr-21-b", "applied:0123abc");
551
- assert.deepEqual(tick().fixDue, []);
552
- });
553
-
554
- test("the fold takes the PR row's settled tokens in order, under the two-argument spelling, wherever the PR row sits", (t) => {
555
- const { ok, read } = fixture(t);
556
- // The PR's row comes first here, and a third row follows the ticket's.
557
- ok("dispatch", "1311", "fix-pr-1311");
558
- ok("settle", "fix-pr-1311", "applied:73b356de");
559
- ok("row", "1311", "fix-pr-1311=applied:73b356de · review=wf:r1=failed reviewed=abc1234:1/0/0 · ci=9:1:success");
560
- ok("row", "1310", "impl-1310 · class=routine");
561
- ok("dispatch", "1320", "impl-1320");
562
- const folded = "#1310 impl-1310=PR#1311 · class=routine · fix-pr-1311=applied:73b356de · review=wf:r1=failed reviewed=abc1234:1/0/0 · ci=9:1:success";
563
- assert.deepEqual(ok("settle", "impl-1310", "PR#1311"), {
564
- member: "impl-1310", outcome: "PR#1311", ticket: "#1310", line: folded, changed: true,
565
- });
566
- assert.deepEqual(read().rows, [folded, "#1320 impl-1320"]);
567
- // A PR row holding nothing past its key leaves no stray separator behind.
568
- ok("row", "1321", " ");
569
- assert.equal(ok("settle", "impl-1320=PR#1321").line, "#1320 impl-1320=PR#1321");
570
- assert.deepEqual(read().rows, [folded, "#1320 impl-1320=PR#1321"]);
571
- });
572
-
573
- // The must-LEAVE half: only the row keyed to the settled PR, and only when it
574
- // carries no implementer, is folded. A settle to a PR with no row of its own
575
- // is today's token rewrite and nothing more.
576
- test("settle folds no row keyed to another PR, no row carrying an impl- token, and nothing when the PR has no row", (t) => {
577
- const { ok, read } = fixture(t);
578
- ok("dispatch", "412", "impl-412");
579
- ok("dispatch", "777", "fix-pr-777");
580
- ok("dispatch", "420", "impl-420");
581
- ok("row", "421", "impl-421=killed · review=wf:r2");
582
- ok("dispatch", "413", "impl-413");
583
- ok("dispatch", "414", "impl-414");
584
- const before = read().rows;
585
-
586
- // #420 is keyed to the PR but is an implementer's own row (live or settled).
587
- assert.equal(ok("settle", "impl-412", "PR#420").line, "#412 impl-412=PR#420");
588
- assert.equal(ok("settle", "impl-413=PR#421").line, "#413 impl-413=PR#421");
589
- // No row keyed #500 at all; #777 belongs to a PR nobody here settles to.
590
- assert.equal(ok("settle", "impl-414", "PR#500").line, "#414 impl-414=PR#500");
591
- assert.deepEqual(read().rows, before.map((r) => r
592
- .replace(/^#412 impl-412$/, "#412 impl-412=PR#420")
593
- .replace(/^#413 impl-413$/, "#413 impl-413=PR#421")
594
- .replace(/^#414 impl-414$/, "#414 impl-414=PR#500")));
595
- assert.ok(read().rows.includes("#777 fix-pr-777"));
596
- });
597
-
598
- // The fold's key match is exact, never a prefix: `#42` must not absorb an
599
- // unrelated row keyed `#420` just because one key is a prefix of the other.
600
- test("settle to PR#42 does not fold an unrelated row keyed #420", (t) => {
601
- const { ok, read } = fixture(t);
602
- ok("row", "420", "unrelated other content for #420");
603
- ok("dispatch", "100", "impl-100");
604
- assert.equal(ok("settle", "impl-100", "PR#42").line, "#100 impl-100=PR#42");
605
- assert.deepEqual(read().rows, ["#420 unrelated other content for #420", "#100 impl-100=PR#42"]);
606
- });
607
-
608
- // #1876 follow-up: a row that already names a PR before this settle writes
609
- // to it must never be folded from — `rowPr()` and the tick's `PR_MENTION`
610
- // read only the FIRST `PR#` mention on a row, so folding here would let a
611
- // second PR's content ride on the first PR's identity (a replacement
612
- // implementer opening a second, different PR for the same ticket), or bury
613
- // the row's own fresher `review=` state under an older one the tick reads
614
- // last. The pre-existing two-row shape is left as it was rather than risk
615
- // either.
616
- test("settle does not fold when its own row already names a PR", (t) => {
617
- const { ok, read } = fixture(t);
618
- ok("dispatch", "100", "impl-100");
619
- ok("settle", "impl-100", "PR#150");
620
- ok("dispatch", "100", "impl-100-b");
621
- ok("dispatch", "160", "fix-pr-160");
622
- ok("row", "160", "fix-pr-160 · review=member:review-pr-160");
623
- assert.equal(ok("settle", "impl-100-b", "PR#160").line, "#100 impl-100=PR#150 · impl-100-b=PR#160");
624
- assert.deepEqual(read().rows, [
625
- "#100 impl-100=PR#150 · impl-100-b=PR#160",
626
- "#160 fix-pr-160 · review=member:review-pr-160",
627
- ]);
628
- });
629
-
630
- // #1876 follow-up: a row keyed `#M` with no impl- token is not always
631
- // dispatch's PR-M fallback — a mistyped PR number can coincide with an
632
- // unrelated ticket row (an Exclusion, here) that carries no PR-bound member
633
- // token at all. The fold must tell the two apart positively, not merely by
634
- // the absence of an impl- token, or a typo silently deletes real state a
635
- // settled member can never restore.
636
- test("settle to a mistyped PR number does not fold an unrelated row with no PR-bound token", (t) => {
637
- const { ok, read } = fixture(t);
638
- ok("row", "358", "excluded · behind-pr:#346");
639
- ok("dispatch", "351", "impl-351");
640
- assert.equal(ok("settle", "impl-351", "PR#358").line, "#351 impl-351=PR#358");
641
- assert.deepEqual(read().rows, ["#358 excluded · behind-pr:#346", "#351 impl-351=PR#358"]);
642
- });
643
-
644
- // Two genuinely separate PR-bound dispatches (a fix-pr and, after its own
645
- // settle, a finisher-pr replacement) can land on the same fallback row via
646
- // runDispatch()'s rowKey fallback — not just one `row` call's worth of
647
- // text — and an unrelated row between the fallback and the ticket must not
648
- // disturb the splice/index-repair distance from either side.
649
- test("the fold carries both families' settled tokens from separate dispatches, across an intervening unrelated row", (t) => {
650
- const { ok, read } = fixture(t);
651
- ok("dispatch", "900", "fix-pr-900");
652
- ok("settle", "fix-pr-900", "failed");
653
- ok("dispatch", "800", "impl-800");
654
- ok("dispatch", "900", "finisher-pr-900-b");
655
- ok("settle", "finisher-pr-900-b", "labelled");
656
- ok("dispatch", "700", "impl-700");
657
- assert.deepEqual(read().rows, ["#900 fix-pr-900=failed · finisher-pr-900-b=labelled", "#800 impl-800", "#700 impl-700"]);
658
- assert.equal(ok("settle", "impl-700", "PR#900").line, "#700 impl-700=PR#900 · fix-pr-900=failed · finisher-pr-900-b=labelled");
659
- assert.deepEqual(read().rows, ["#800 impl-800", "#700 impl-700=PR#900 · fix-pr-900=failed · finisher-pr-900-b=labelled"]);
660
- });
661
-
662
- test("drain writes one marker a later reader recognises, and it holds supply alone", (t) => {
663
- const { ok, read, bytes, refused } = fixture(t);
664
- ok("dispatch", "410", "impl-410");
665
- const reason = "maintainer asked to stop\n## Rows\n- #1 phantom";
666
- assert.deepEqual(ok("drain", reason), { drain: reason, created: true });
667
- const l = read();
668
- assert.equal(l.drain, reason);
669
- assert.deepEqual(l.rows, ["#410 impl-410"], "the reason is one escaped entry, never a line the parser reads back");
670
- assert.match(bytes(), /^## Drain\n\n- maintainer asked to stop\\n## Rows\\n- #1 phantom$/m);
671
- // One marker: a second drain reports the standing one and writes nothing.
672
- const before = bytes();
673
- assert.deepEqual(ok("drain", "again"), { drain: reason, created: false });
674
- assert.equal(bytes(), before);
675
- // Supply stops — a fresh implementer or a replacement for a live one...
676
- refused(["dispatch", "412", "impl-412"], /the run is draining \(maintainer asked to stop\n## Rows\n- #1 phantom\) — no implementer dispatch/);
677
- refused(["dispatch", "410", "impl-410-b"], /the run is draining/);
678
- // ...and everything else keeps firing until the open PRs are merged.
679
- ok("settle", "impl-410", "released");
680
- ok("dispatch", "346", "fix-pr-346");
681
- ok("dispatch", "346", "finisher-pr-346");
682
- assert.equal(ok("dispatch", "merge-bot").member, "merge-bot-1");
683
- });
684
-
685
- test("drain needs a reason", (t) => {
686
- const { refused } = fixture(t);
687
- refused(["drain"], /usage: ledger\.mjs drain "<reason>"/);
688
- refused(["drain", " "], /usage: ledger\.mjs drain "<reason>"/);
689
- });
690
-
691
- test("a ledger written before ## Dispatched existed reads as none dispatched and not draining, and survives a dispatch", (t) => {
692
- const { ok, read } = fixture(t, "# Fleet run ledger\n\n## Rows\n\n- #7 impl-7 · class=routine\n\n## Filed\n\n- #8 a filed subject\n\n## Ruled\n\n- #9 MERGE · green\n");
693
- const legacy = { rows: ["#7 impl-7 · class=routine"], filed: ["#8 a filed subject"], ruled: ["#9 MERGE · green"] };
694
- assert.deepEqual(read(), { ...legacy, dispatched: [], drain: null });
695
- assert.equal(ok("dispatch", "merge-bot").member, "merge-bot-1");
696
- assert.deepEqual(read(), { ...legacy, dispatched: ["merge-bot-1"], drain: null });
697
- });
698
-
699
- // #1799 fix-applier follow-up: a `## Dispatched` entry this grammar cannot
700
- // parse used to read, via `parseToken(e)?.name`, as "not this member" —
701
- // silently treating a corrupted section as though the member it names were
702
- // free, in both dispatch's duplicate guard and settle's lookup.
703
- test("a `## Dispatched` entry this grammar cannot parse refuses dispatch and settle, naming it, rather than reading as absent", (t) => {
704
- const body = "# Fleet run ledger\n\n## Rows\n\n## Dispatched\n\n- impl-412x\n\n## Filed\n\n## Ruled\n";
705
- const { refused } = fixture(t, body);
706
- refused(["dispatch", "412", "impl-412"], /## Dispatched has an entry 'impl-412x' this grammar cannot parse/);
707
- refused(["settle", "impl-412", "PR#420"], /## Dispatched has an entry 'impl-412x' this grammar cannot parse/);
708
- });
709
-
710
- // A replacement's own name is never a duplicate of its predecessor's, so the
711
- // exact-name guard above lets it through — but the predecessor is still live,
712
- // and the spec counts liveness as "unsettled impl- tokens" per family+number,
713
- // not per exact name. Two live tokens for #412 would double-count it.
714
- test("dispatch refuses a replacement while its predecessor is still live, in ## Dispatched or on a row", (t) => {
715
- const { ok, refused, read } = fixture(t);
716
- ok("dispatch", "412", "impl-412");
717
- refused(["dispatch", "412", "impl-412-b"], /impl-412 is still live — `settle impl-412 killed`/);
718
- ok("settle", "impl-412", "killed");
719
- // The predecessor is settled now: the replacement is no longer refused.
720
- assert.equal(ok("dispatch", "412", "impl-412-b").line, "#412 impl-412=killed · impl-412-b");
721
- assert.deepEqual(read().dispatched, ["impl-412=killed", "impl-412-b"]);
722
-
723
- // The same refusal when the live token was `row`'s, never `dispatch`'s.
724
- ok("row", "415", "impl-415");
725
- refused(["dispatch", "415", "impl-415-b"], /impl-415 is still live — `settle impl-415 killed`/);
726
- });
727
-
728
- // `load()`'s one read path for every subcommand: the write side (`drain`'s
729
- // own `created` guard) already refuses a second marker, but a corrupted file
730
- // carrying two anyway used to have its second `## Drain` bullet silently
731
- // dropped by `section(DRAIN)[0] ?? null`, with no warning on either stream.
732
- test("a ledger carrying two `## Drain` entries refuses to load rather than silently keeping only the first", (t) => {
733
- const body = "# Fleet run ledger\n\n## Rows\n\n## Dispatched\n\n## Filed\n\n## Ruled\n\n## Drain\n\n- first reason\n- second reason\n";
734
- const { refused } = fixture(t, body);
735
- refused(["read"], /has 2 `## Drain` entries — one marker per run/);
736
- });
737
-
738
- // The dispositions gate. A finisher labels a PR `ready-to-merge`, so it is
739
- // recorded only once the PR's current dispositions verdict is ok: among the
740
- // `dispositions-*=fix-pr-<M>[-x]:<head>` tokens whose head prefix-matches the
741
- // latest `reviewed=<head>`, the one from the highest-suffixed fix-applier.
742
- // A refusal is exit 2 and writes nothing — the `refused` helper checks both.
743
- const GATE_HEAD = `${"abc1234".repeat(5)}abcde`;
744
- const OTHER_HEAD = `${"def5678".repeat(5)}defab`;
745
- const gateRow = (counts, ...tokens) =>
746
- ["impl-10=PR#40 → PR#40", `reviewed=${GATE_HEAD.slice(0, 7)}:${counts}`, "fix-pr-40=applied:def5678", ...tokens].join(" · ");
747
-
748
- test("a finisher is refused on a dispositions mismatch and recorded on a dispositions ok", (t) => {
749
- const { ok, read, refused } = fixture(t);
750
- ok("row", "10", gateRow("1/0/0", `dispositions-mismatch=fix-pr-40:${GATE_HEAD}`));
751
- refused(["dispatch", "40", "finisher-pr-40"],
752
- /finisher-pr-40: dispositions mismatch — fix-pr-40's disposition record .*dispositions-check\.mjs/);
753
- assert.deepEqual(read().dispatched, []);
754
-
755
- ok("row", "10", gateRow("1/0/0", `dispositions-ok=fix-pr-40:${GATE_HEAD}`));
756
- assert.equal(ok("dispatch", "40", "finisher-pr-40").agent, "fleet-finisher");
757
- assert.deepEqual(read().dispatched, ["finisher-pr-40"]);
758
- });
759
-
760
- test("a finisher is refused as unchecked while no verdict answers the latest review's head", (t) => {
761
- const { ok, refused } = fixture(t);
762
- const unchecked = /finisher-pr-40: dispositions unchecked — no dispositions-ok=\/dispositions-mismatch=\/dispositions-escalate= token .* run dispositions-check\.mjs --member fix-pr-40/;
763
- // No token at all.
764
- ok("row", "10", gateRow("1/0/0"));
765
- refused(["dispatch", "40", "finisher-pr-40"], unchecked);
766
- // An unverified finding alone puts the PR under the gate too.
767
- ok("row", "10", gateRow("0/2/1"));
768
- refused(["dispatch", "40", "finisher-pr-40"], unchecked);
769
- // An ok answering another head satisfies nothing, wherever it sits on the row.
770
- ok("row", "10", gateRow("1/0/0", `dispositions-ok=fix-pr-40:${OTHER_HEAD}`));
771
- refused(["dispatch", "40", "finisher-pr-40"], unchecked);
772
- ok("row", "10", `impl-10=PR#40 → PR#40 · dispositions-ok=fix-pr-40:${OTHER_HEAD} · reviewed=${GATE_HEAD}:1/0/0`);
773
- refused(["dispatch", "40", "finisher-pr-40"], unchecked);
774
- // An earlier review's ok, answered before a later review returned, does not
775
- // carry over to the later one.
776
- ok("row", "10", `impl-10=PR#40 → PR#40 · reviewed=${OTHER_HEAD}:1/0/0 · dispositions-ok=fix-pr-40:${OTHER_HEAD} · reviewed=${GATE_HEAD}:1/0/0`);
777
- refused(["dispatch", "40", "finisher-pr-40"], unchecked);
778
- // Another PR's fix-applier's verdict is no answer for this PR.
779
- ok("row", "10", gateRow("1/0/0", `dispositions-ok=fix-pr-41:${GATE_HEAD}`));
780
- refused(["dispatch", "40", "finisher-pr-40"], unchecked);
781
- });
782
-
783
- test("a PR whose latest review counts no survived and no unverified finding dispatches a finisher with no verdict", (t) => {
784
- const { ok, read } = fixture(t);
785
- ok("row", "10", `impl-10=PR#40 → PR#40 · reviewed=${GATE_HEAD}:0/3/0`);
786
- assert.equal(ok("dispatch", "40", "finisher-pr-40").agent, "fleet-finisher");
787
- // A PR never reviewed is outside the gate as well: no review file, no record.
788
- ok("row", "11", "impl-11=PR#41 → PR#41");
789
- assert.equal(ok("dispatch", "41", "finisher-pr-41").agent, "fleet-finisher");
790
- assert.deepEqual(read().dispatched, ["finisher-pr-40", "finisher-pr-41"]);
791
- });
792
-
793
- test("the current verdict is the highest-suffixed fix-applier's, in either text order", (t) => {
794
- const { ok, read, refused } = fixture(t);
795
- const a = `dispositions-mismatch=fix-pr-40:${GATE_HEAD}`;
796
- const b = `dispositions-ok=fix-pr-40-b:${GATE_HEAD}`;
797
- for (const [i, tokens] of [[a, b], [b, a]].entries()) {
798
- ok("row", "10", gateRow("1/0/0", ...tokens));
799
- assert.equal(ok("dispatch", "40", `finisher-pr-40${i === 0 ? "" : "-b"}`).agent, "fleet-finisher");
800
- ok("settle", `finisher-pr-40${i === 0 ? "" : "-b"}`, "failed");
801
- }
802
- // Swapped between the two members, the -b's mismatch is current.
803
- const swapped = [`dispositions-ok=fix-pr-40:${GATE_HEAD}`, `dispositions-mismatch=fix-pr-40-b:${GATE_HEAD}`];
804
- for (const tokens of [swapped, [...swapped].reverse()]) {
805
- ok("row", "10", gateRow("1/0/0", ...tokens));
806
- refused(["dispatch", "40", "finisher-pr-40-c"], /finisher-pr-40-c: dispositions mismatch — fix-pr-40-b's disposition record/);
807
- }
808
- assert.deepEqual(read().dispatched, ["finisher-pr-40=failed", "finisher-pr-40-b=failed"]);
809
- });
810
-
811
- test("a mismatch is retried by the next fix-applier suffix: ok from it ends the refusal, escalate from it never does", (t) => {
812
- const { ok, read, refused } = fixture(t);
813
- ok("row", "10", gateRow("1/0/0", `dispositions-mismatch=fix-pr-40:${GATE_HEAD}`));
814
- refused(["dispatch", "40", "finisher-pr-40"], /dispositions mismatch/);
815
- // The retry is dispatched under the next suffix; the first name is spent.
816
- refused(["dispatch", "40", "fix-pr-40"], /fix-pr-40/);
817
- ok("dispatch", "40", "fix-pr-40-b");
818
- ok("settle", "fix-pr-40-b", `applied:${GATE_HEAD.slice(0, 7)}`);
819
- // Settled with no verdict of its own: the earlier mismatch still stands.
820
- refused(["dispatch", "40", "finisher-pr-40"], /dispositions mismatch — fix-pr-40's/);
821
- ok("row", "10", gateRow("1/0/0", `dispositions-mismatch=fix-pr-40:${GATE_HEAD}`, `dispositions-ok=fix-pr-40-b:${GATE_HEAD}`, "fix-pr-40-b=applied:0123abc"));
822
- assert.equal(ok("dispatch", "40", "finisher-pr-40").agent, "fleet-finisher");
823
- assert.ok(read().dispatched.includes("finisher-pr-40"));
824
- // Escalated instead: a finisher is refused naming it, whichever way the tokens sit.
825
- ok("settle", "finisher-pr-40", "failed");
826
- const escalated = [`dispositions-mismatch=fix-pr-40:${GATE_HEAD}`, `dispositions-escalate=fix-pr-40-b:${GATE_HEAD}`];
827
- for (const tokens of [escalated, [...escalated].reverse()]) {
828
- ok("row", "10", gateRow("1/0/0", ...tokens, "fix-pr-40-b=applied:0123abc"));
829
- refused(["dispatch", "40", "finisher-pr-40-b"], /finisher-pr-40-b: dispositions escalate — fix-pr-40-b deferred/);
830
- }
831
- // A new review (a new head) starts the gate over: the old escalate answers nothing.
832
- ok("row", "10", `impl-10=PR#40 → PR#40 · reviewed=${GATE_HEAD}:1/0/0 · ${escalated[1]} · review=wf:x reviewed=${OTHER_HEAD}:1/0/0`);
833
- refused(["dispatch", "40", "finisher-pr-40-b"], /dispositions unchecked/);
834
- });
835
-
836
- test("a later fix-applier that writes no verdict neither satisfies nor resets the gate", (t) => {
837
- const { ok, refused } = fixture(t);
838
- // A conflict-hold fix-applier after the review one: no review file, no token.
839
- ok("row", "10", gateRow("1/0/0", `dispositions-ok=fix-pr-40:${GATE_HEAD}`, "conflict-hold:#40", "fix-pr-40-b=no-op"));
840
- assert.equal(ok("dispatch", "40", "finisher-pr-40").agent, "fleet-finisher");
841
- ok("row", "11", ["impl-11=PR#41 → PR#41", `reviewed=${GATE_HEAD}:1/0/0`, "fix-pr-41=applied:def5678",
842
- `dispositions-mismatch=fix-pr-41:${GATE_HEAD}`, "conflict-hold:#41", "fix-pr-41-b=no-op"].join(" · "));
843
- refused(["dispatch", "41", "finisher-pr-41"], /finisher-pr-41: dispositions mismatch — fix-pr-41's/);
844
- });
845
-
846
- test("a finisher is refused on a dispositions escalate, naming it, and nothing retries it", (t) => {
847
- const { ok, read, refused } = fixture(t);
848
- ok("row", "10", gateRow("1/0/0", `dispositions-escalate=fix-pr-40:${GATE_HEAD}`));
849
- refused(["dispatch", "40", "finisher-pr-40"],
850
- /finisher-pr-40: dispositions escalate — fix-pr-40 deferred .*dispositions-check\.mjs --member fix-pr-40/);
851
- assert.deepEqual(read().dispatched, []);
852
- const l = read();
853
- const run = deriveRun({ rows: l.rows, dispatched: l.dispatched, drain: null },
854
- [{ number: 40, labels: [], closingIssuesReferences: [{ number: 10 }] }]);
855
- assert.deepEqual(run.fixDue, [], "an escalation never returns the PR to fixDue");
856
- assert.deepEqual(run.reviewed.find((r) => r.pr === 40).dispositions, { verdict: "escalate", member: "fix-pr-40" });
857
- });
858
-
859
- test("an escalate is the current verdict only until a higher-suffixed fix-applier's own verdict answers the head, and outranks a mismatch of the same member", (t) => {
860
- const { ok, refused } = fixture(t);
861
- const esc = `dispositions-escalate=fix-pr-40:${GATE_HEAD}`;
862
- const okB = `dispositions-ok=fix-pr-40-b:${GATE_HEAD}`;
863
- for (const [i, tokens] of [[esc, okB], [okB, esc]].entries()) {
864
- ok("row", "10", gateRow("1/0/0", ...tokens));
865
- assert.equal(ok("dispatch", "40", `finisher-pr-40${i === 0 ? "" : "-b"}`).agent, "fleet-finisher");
866
- ok("settle", `finisher-pr-40${i === 0 ? "" : "-b"}`, "failed");
867
- }
868
- const swapped = [`dispositions-ok=fix-pr-40:${GATE_HEAD}`, `dispositions-escalate=fix-pr-40-b:${GATE_HEAD}`];
869
- for (const tokens of [swapped, [...swapped].reverse()]) {
870
- ok("row", "10", gateRow("1/0/0", ...tokens));
871
- refused(["dispatch", "40", "finisher-pr-40-c"], /finisher-pr-40-c: dispositions escalate — fix-pr-40-b deferred/);
872
- }
873
- ok("row", "10", gateRow("1/0/0", `dispositions-mismatch=fix-pr-40:${GATE_HEAD}`, esc));
874
- refused(["dispatch", "40", "finisher-pr-40-c"], /dispositions escalate/);
875
- });
876
-
877
- test("one fix-applier carrying both verdicts for the same head reads as a mismatch", (t) => {
878
- const { ok, refused } = fixture(t);
879
- ok("row", "10", gateRow("1/0/0", `dispositions-ok=fix-pr-40:${GATE_HEAD}`, `dispositions-mismatch=fix-pr-40:${GATE_HEAD}`));
880
- refused(["dispatch", "40", "finisher-pr-40"], /dispositions mismatch/);
881
- });
882
-
883
- test("only a fix-applier's well-formed verdict answers the gate: another family's, a short head's or a non-verdict's never does", (t) => {
884
- const { ok, read, refused } = fixture(t);
885
- const unchecked = /finisher-pr-40: dispositions unchecked/;
886
- for (const token of [
887
- `dispositions-ok=finisher-pr-40:${GATE_HEAD}`, // a finisher writes no disposition record
888
- `dispositions-ok=impl-10:${GATE_HEAD}`,
889
- "dispositions-ok=fix-pr-40:abc", // 3 hex: below the 7-hex floor, matches every head starting abc
890
- `dispositions-maybe=fix-pr-40:${GATE_HEAD}`,
891
- ]) {
892
- ok("row", "10", gateRow("1/0/0", token));
893
- refused(["dispatch", "40", "finisher-pr-40"], unchecked);
894
- }
895
- // Case is not a verdict's meaning: an upper-case head and verdict still answer.
896
- ok("row", "10", gateRow("1/0/0", `DISPOSITIONS-OK=fix-pr-40:${GATE_HEAD.toUpperCase()}`));
897
- assert.equal(ok("dispatch", "40", "finisher-pr-40").agent, "fleet-finisher");
898
- assert.deepEqual(read().dispatched, ["finisher-pr-40"]);
899
- });
900
-
901
- test("a verdict's head and the review's match as prefixes in either direction", (t) => {
902
- const { ok, refused } = fixture(t);
903
- // A 7-hex verdict head answers a 40-hex `reviewed=` head …
904
- ok("row", "10", ["impl-10=PR#40 → PR#40", `reviewed=${GATE_HEAD}:1/0/0`, "fix-pr-40=applied:def5678",
905
- `dispositions-ok=fix-pr-40:${GATE_HEAD.slice(0, 7)}`].join(" · "));
906
- assert.equal(ok("dispatch", "40", "finisher-pr-40").agent, "fleet-finisher");
907
- // … and a 7-hex one that is not its prefix does not.
908
- ok("row", "11", ["impl-11=PR#41 → PR#41", `reviewed=${GATE_HEAD}:1/0/0`, "fix-pr-41=applied:def5678",
909
- `dispositions-ok=fix-pr-41:${OTHER_HEAD.slice(0, 7)}`].join(" · "));
910
- refused(["dispatch", "41", "finisher-pr-41"], /finisher-pr-41: dispositions unchecked/);
911
- });
912
-
913
- test("a finisher is refused while a fix-applier on the PR is live, even with an earlier ok answering the same head", (t) => {
914
- const { ok, read, refused } = fixture(t);
915
- // A re-review at the same head: fix-pr-40 answered the first round, and
916
- // fix-pr-40-b, answering the second, is still working.
917
- ok("row", "10", gateRow("1/0/0", `dispositions-ok=fix-pr-40:${GATE_HEAD}`, `reviewed=${GATE_HEAD.slice(0, 7)}:3/0/2`, "fix-pr-40-b"));
918
- refused(["dispatch", "40", "finisher-pr-40"], /finisher-pr-40: fix-pr-40-b still live on PR #40 — .*settle it, run dispositions-check\.mjs for it/);
919
- // A PR outside the verdict gate is still held while its fix-applier works.
920
- ok("row", "11", `impl-11=PR#41 → PR#41 · reviewed=${GATE_HEAD}:0/1/0 · fix-pr-41`);
921
- refused(["dispatch", "41", "finisher-pr-41"], /finisher-pr-41: fix-pr-41 still live on PR #41/);
922
- // Settled with its own verdict written, the -b's answer is the current one.
923
- ok("row", "10", gateRow("1/0/0", `dispositions-ok=fix-pr-40:${GATE_HEAD}`, `reviewed=${GATE_HEAD.slice(0, 7)}:3/0/2`,
924
- "fix-pr-40-b=applied:fedcba9", `dispositions-ok=fix-pr-40-b:${GATE_HEAD}`));
925
- assert.equal(ok("dispatch", "40", "finisher-pr-40").agent, "fleet-finisher");
926
- assert.deepEqual(read().dispatched, ["finisher-pr-40"]);
927
- });