@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,936 +0,0 @@
1
- // dispositions-check.mjs: a review fix-applier's disposition record judged
2
- // against the review file and the PR's diff, its verdict written onto the
3
- // ledger, and `ledger.mjs dispatch` then gating the finisher on it.
4
- //
5
- // Every CLI case runs against a real git repository built in a temp dir —
6
- // `origin/main` a ref, the PR head one commit past it — so the touched lines
7
- // are git's own answer, not a fixture's restatement of one.
8
-
9
- import { test } from "node:test";
10
- import assert from "node:assert/strict";
11
- import { spawnSync, execFileSync } from "node:child_process";
12
- import { mkdtempSync, rmSync, writeFileSync, readFileSync, mkdirSync, symlinkSync, existsSync } from "node:fs";
13
- import { tmpdir } from "node:os";
14
- import { join } from "node:path";
15
- import { fileURLToPath } from "node:url";
16
- import { deriveRun } from "./fleet-tick.mjs";
17
- import { touchedLines, checkDispositions, withVerdict, repoPath, formatViolation, failedBefore } from "./dispositions-check.mjs";
18
-
19
- const SCRIPT = fileURLToPath(new URL("./dispositions-check.mjs", import.meta.url));
20
- const LEDGER = fileURLToPath(new URL("./ledger.mjs", import.meta.url));
21
-
22
- const cleanEnv = (extra = {}) => {
23
- const env = { ...process.env, ...extra };
24
- delete env.GIT_DIR;
25
- delete env.GIT_WORK_TREE;
26
- return env;
27
- };
28
-
29
- function git(dir, ...args) {
30
- return execFileSync("git", ["-C", dir, ...args], {
31
- encoding: "utf8",
32
- env: cleanEnv({ GIT_AUTHOR_NAME: "t", GIT_AUTHOR_EMAIL: "t@t", GIT_COMMITTER_NAME: "t", GIT_COMMITTER_EMAIL: "t@t" }),
33
- }).trim();
34
- }
35
-
36
- const lines = (n, tag) => Array.from({ length: n }, (_, i) => `${tag} ${i + 1}`).join("\n") + "\n";
37
-
38
- // A repository whose `origin/main` holds src/a.js (20 lines) and src/b.js,
39
- // and whose PR head rewrites src/a.js lines 5-6 and appends line 21. Lines
40
- // 1-4 and 7-20 are untouched; src/b.js is not in the diff at all.
41
- function fixture(t) {
42
- const dir = mkdtempSync(join(tmpdir(), "dispositions-check-"));
43
- t.after(() => rmSync(dir, { recursive: true, force: true }));
44
- const repo = join(dir, "repo");
45
- mkdirSync(join(repo, "src"), { recursive: true });
46
- git(repo, "init", "-q", "-b", "main");
47
- writeFileSync(join(repo, "src", "a.js"), lines(20, "a"));
48
- writeFileSync(join(repo, "src", "b.js"), lines(10, "b"));
49
- git(repo, "add", "-A");
50
- git(repo, "commit", "-qm", "base");
51
- git(repo, "update-ref", "refs/remotes/origin/main", "HEAD");
52
- const a = lines(20, "a").split("\n");
53
- a[4] = "a 5 changed";
54
- a[5] = "a 6 changed";
55
- a.splice(20, 0, "a 21 added");
56
- writeFileSync(join(repo, "src", "a.js"), a.join("\n"));
57
- git(repo, "commit", "-qam", "pr");
58
- const head = git(repo, "rev-parse", "HEAD");
59
-
60
- const scratch = join(dir, "scratch");
61
- mkdirSync(scratch);
62
- const ledger = join(dir, "ledger.md");
63
- const ledgerCli = (...args) => spawnSync(process.execPath, [LEDGER, "--file", ledger, ...args], { encoding: "utf8", env: cleanEnv() });
64
- const okLedger = (...args) => {
65
- const r = ledgerCli(...args);
66
- assert.equal(r.status, 0, `ledger ${args.join(" ")}: exit ${r.status}\n${r.stderr}`);
67
- return JSON.parse(r.stdout);
68
- };
69
- okLedger("row", "10", `impl-10=PR#40 → PR#40 · reviewed=${head}:2/1/1`);
70
- okLedger("dispatch", "40", "fix-pr-40");
71
- okLedger("settle", "fix-pr-40", `applied:${head.slice(0, 7)}`);
72
-
73
- const finding = (file, line, severity = "important") => ({ severity, file, line, claim: "c", evidence: "e" });
74
- const review = {
75
- pr: 40, head, snapshot: join(dir, "snap"),
76
- counts: { survived: 2, refuted: 1, unverified: 1, crashed: 0 },
77
- // survived[0] on a touched line; survived[1] on an untouched one.
78
- survived: [finding("src/a.js", 5), finding("src/a.js", 12)],
79
- refuted: [finding("src/b.js", 3)],
80
- unverified: [finding("src/a.js", 15, "suggestion")],
81
- };
82
- const writeReview = (r = review) => writeFileSync(join(scratch, "review-40.json"), JSON.stringify(r));
83
- writeReview();
84
- const entry = (bucket, index, more = {}) => ({ bucket, index, scope: "in", claimKind: "behavior", disposition: "apply", ...more });
85
- // Every finding answered, every in-scope survivor applied: an ok record.
86
- const baseEntries = () => [entry("survived", 0), entry("survived", 1), entry("unverified", 0, { disposition: "defer", issue: 77 })];
87
- const writeRecord = (entries, recHead = head) =>
88
- writeFileSync(join(scratch, "dispositions-40.json"), JSON.stringify({ head: recHead, entries }));
89
-
90
- const check = (member = "fix-pr-40", env = cleanEnv(), script = SCRIPT, extra = []) => {
91
- const r = spawnSync(process.execPath, [script, "--member", member, "--scratch", scratch, "--repo", repo, "--ledger", ledger, ...extra],
92
- { encoding: "utf8", env, cwd: dir });
93
- return { ...r, json: r.status === 0 || r.status === 1 ? JSON.parse(r.stdout) : null };
94
- };
95
- const row = () => okLedger("read").rows.find((r) => r.startsWith("#10 "));
96
- return { dir, repo, head, scratch, review, writeReview, entry, baseEntries, writeRecord, check, row, ledgerCli, okLedger };
97
- }
98
-
99
- const mismatch = (r, re) => {
100
- assert.equal(r.status, 1, `expected a mismatch, got exit ${r.status}\n${r.stderr}`);
101
- assert.equal(r.json.verdict, "mismatch");
102
- if (re) assert.match(r.stderr, re);
103
- };
104
- const okVerdict = (r) => {
105
- assert.equal(r.status, 0, `expected ok, got exit ${r.status}\n${r.stderr}`);
106
- assert.equal(r.json.verdict, "ok");
107
- };
108
-
109
- test("an in-scope survivor deferred with no reason is a mismatch, and the finisher is refused with nothing written", (t) => {
110
- const f = fixture(t);
111
- const entries = f.baseEntries();
112
- entries[0] = f.entry("survived", 0, { disposition: "defer" });
113
- f.writeRecord(entries);
114
- const r = f.check();
115
- mismatch(r, /fix-pr-40: survived\[0\]: an in-scope survived finding deferred with no reason — src\/a\.js:5 is a line the PR's diff touched/);
116
- assert.deepEqual(r.json.violations.map((v) => [v.bucket, v.index]), [["survived", 0]]);
117
- assert.ok(f.row().includes(`dispositions-mismatch=fix-pr-40:${f.head}`), f.row());
118
-
119
- const before = readFileSync(join(f.dir, "ledger.md"), "utf8");
120
- const d = f.ledgerCli("dispatch", "40", "finisher-pr-40");
121
- assert.equal(d.status, 2);
122
- assert.match(d.stderr, /finisher-pr-40: dispositions mismatch — fix-pr-40's disposition record/);
123
- assert.equal(readFileSync(join(f.dir, "ledger.md"), "utf8"), before, "a refused dispatch writes nothing");
124
- });
125
-
126
- test("a survived finding left off the record is a mismatch naming its bucket and index, and so is an unverified one", (t) => {
127
- const f = fixture(t);
128
- f.writeRecord(f.baseEntries().filter((e) => !(e.bucket === "survived" && e.index === 1)));
129
- mismatch(f.check(), /^fix-pr-40: survived\[1\]: no entry — a finding with no entry is a dropped finding$/m);
130
-
131
- f.writeRecord(f.baseEntries().filter((e) => e.bucket !== "unverified"));
132
- const r = f.check();
133
- mismatch(r, /^fix-pr-40: unverified\[0\]: no entry/m);
134
- assert.deepEqual(r.json.violations, [{ bucket: "unverified", index: 0, rule: "no entry — a finding with no entry is a dropped finding" }]);
135
- });
136
-
137
- test("each allowed reason passes an in-scope survivor's deferral, writes dispositions-ok and lets the finisher dispatch", (t) => {
138
- for (const reason of ["false-rationale", "mutual-exclusion", "remedy-worse"]) {
139
- const f = fixture(t);
140
- const entries = f.baseEntries();
141
- entries[0] = f.entry("survived", 0, { disposition: "defer", reason, issue: 81 });
142
- f.writeRecord(entries);
143
- okVerdict(f.check());
144
- assert.ok(f.row().includes(`dispositions-ok=fix-pr-40:${f.head}`), `${reason}: ${f.row()}`);
145
- assert.equal(f.okLedger("dispatch", "40", "finisher-pr-40").agent, "fleet-finisher", reason);
146
- }
147
- });
148
-
149
- test("any other reason is a mismatch", (t) => {
150
- const f = fixture(t);
151
- for (const reason of ["outside-ticket-files", ""]) {
152
- const entries = f.baseEntries();
153
- entries[0] = f.entry("survived", 0, { disposition: "defer", reason });
154
- f.writeRecord(entries);
155
- mismatch(f.check(), /survived\[0\]: an in-scope survived finding deferred with/);
156
- }
157
- });
158
-
159
- test("a touched line is in scope whatever the record declares; an untouched one keeps its declared scope", (t) => {
160
- const f = fixture(t);
161
- // survived[0] sits on touched line 5: declaring it out changes nothing.
162
- const entries = f.baseEntries();
163
- entries[0] = f.entry("survived", 0, { scope: "out", disposition: "defer" });
164
- f.writeRecord(entries);
165
- mismatch(f.check(), /survived\[0\]: .* src\/a\.js:5 is a line the PR's diff touched, so it is in scope whatever its entry declares/);
166
-
167
- // survived[1] sits on untouched line 12: declared out, it defers with no reason.
168
- const out = f.baseEntries();
169
- out[1] = f.entry("survived", 1, { scope: "out", disposition: "defer", issue: 90 });
170
- f.writeRecord(out);
171
- okVerdict(f.check());
172
- // Declared in, the same deferral is a mismatch.
173
- out[1] = f.entry("survived", 1, { scope: "in", disposition: "defer" });
174
- f.writeRecord(out);
175
- mismatch(f.check(), /survived\[1\]: .* its entry declares scope in/);
176
- });
177
-
178
- test("a finding with no line is in scope, so its deferral needs an allowed reason", (t) => {
179
- const f = fixture(t);
180
- f.writeReview({ ...f.review, survived: [f.review.survived[0], { severity: "important", file: "src/a.js", claim: "c", evidence: "e" }] });
181
- const entries = f.baseEntries();
182
- entries[1] = f.entry("survived", 1, { scope: "out", disposition: "defer" });
183
- f.writeRecord(entries);
184
- mismatch(f.check(), /survived\[1\]: .* it has no line, so it is in scope/);
185
- });
186
-
187
- test("a fix-applier commit that shifts line numbers after the review head does not change the verdict", (t) => {
188
- const f = fixture(t);
189
- // survived[1], line 12, is untouched at the review head: declared out, deferred.
190
- const entries = f.baseEntries();
191
- entries[1] = f.entry("survived", 1, { scope: "out", disposition: "defer" });
192
- f.writeRecord(entries);
193
- okVerdict(f.check());
194
- // The fix-applier's commit rewrites line 12 and inserts lines above it: at
195
- // the worktree's HEAD line 12 is touched, at the review head it is not.
196
- const a = readFileSync(join(f.repo, "src", "a.js"), "utf8").split("\n");
197
- a[11] = "a 12 rewritten";
198
- a.splice(0, 0, "inserted 1", "inserted 2", "inserted 3");
199
- writeFileSync(join(f.repo, "src", "a.js"), a.join("\n"));
200
- git(f.repo, "commit", "-qam", "fix-applier");
201
- okVerdict(f.check());
202
- // And the reverse: survived[0] on touched line 5 stays a mismatch however
203
- // far the later commit pushed it.
204
- entries[0] = f.entry("survived", 0, { scope: "out", disposition: "defer" });
205
- f.writeRecord(entries);
206
- mismatch(f.check(), /survived\[0\]: .* src\/a\.js:5 is a line the PR's diff touched/);
207
- });
208
-
209
- test("what the check accepts: applied survivors, out-of-scope deferrals, unverified deferrals, reversed refutations with evidence", (t) => {
210
- const f = fixture(t);
211
- f.writeRecord([
212
- f.entry("survived", 0),
213
- f.entry("survived", 1, { scope: "out", claimKind: "shape", disposition: "defer", issue: 12 }),
214
- f.entry("unverified", 0, { disposition: "defer", reason: "anything", issue: 13, verdictPath: "/tmp/v.json" }),
215
- f.entry("refuted", 0, { reason: "re-ran the refuter's probe at the head and the defect reproduces", remedyFiles: ["src/b.js"] }),
216
- ]);
217
- const r = f.check();
218
- okVerdict(r);
219
- assert.deepEqual(r.json.violations, []);
220
- });
221
-
222
- test("a malformed, duplicate, out-of-range, stale or missing record is a mismatch", (t) => {
223
- const f = fixture(t);
224
- const cases = [
225
- [[...f.baseEntries(), f.entry("survived", 0)], /survived\[0\]: a second entry \(entries\[3\]\)/],
226
- [[...f.baseEntries(), f.entry("survived", 2)], /survived\[2\]: entries\[3\] names no finding — survived holds 2/],
227
- [[...f.baseEntries(), f.entry("bogus", 0)], /record: entries\[3\] names bucket "bogus"/],
228
- [[f.entry("survived", 0, { scope: "maybe" }), ...f.baseEntries().slice(1)], /survived\[0\]: malformed entry — scope "maybe" is not one of in\|out/],
229
- [[...f.baseEntries(), f.entry("refuted", 0)], /refuted\[0\]: a reversed refutation names its evidence in reason/],
230
- ];
231
- for (const [entries, re] of cases) {
232
- f.writeRecord(entries);
233
- mismatch(f.check(), re);
234
- }
235
- f.writeRecord(f.baseEntries(), "deadbeef");
236
- mismatch(f.check(), /record: the record answers head "deadbeef", not the review's/);
237
- rmSync(join(f.scratch, "dispositions-40.json"));
238
- mismatch(f.check(), /record: no disposition record at .*dispositions-40\.json/);
239
- });
240
-
241
- test("a re-check replaces the member's own verdict for the same head and never duplicates it", (t) => {
242
- const f = fixture(t);
243
- const bad = f.baseEntries();
244
- bad[0] = f.entry("survived", 0, { disposition: "defer" });
245
- f.writeRecord(bad);
246
- mismatch(f.check());
247
- f.writeRecord(f.baseEntries());
248
- okVerdict(f.check());
249
- const again = f.check();
250
- okVerdict(again);
251
- assert.match(again.stderr, /row #10 already carries dispositions-ok=fix-pr-40:[0-9a-f]+ — not written again/);
252
- const row = f.row();
253
- assert.equal(row.match(/dispositions-/g).length, 1, row);
254
- assert.ok(row.endsWith(` · dispositions-ok=fix-pr-40:${f.head}`), row);
255
- assert.equal(f.okLedger("dispatch", "40", "finisher-pr-40").agent, "fleet-finisher");
256
- });
257
-
258
- // A first mismatch is retried by `fix-pr-<M>-b`; a second on the same review
259
- // is written as an escalate, which keeps the finisher refused and is the end
260
- // of the automatic path.
261
- const badRecord = (f) => {
262
- const entries = f.baseEntries();
263
- entries[0] = f.entry("survived", 0, { disposition: "defer" });
264
- return entries;
265
- };
266
- const retry = (f, name = "fix-pr-40-b") => {
267
- f.okLedger("dispatch", "40", name);
268
- f.okLedger("settle", name, `applied:${f.head.slice(0, 7)}`);
269
- };
270
-
271
- test("a second mismatch on the same review writes dispositions-escalate, and the finisher stays refused", (t) => {
272
- const f = fixture(t);
273
- f.writeRecord(badRecord(f));
274
- mismatch(f.check());
275
- retry(f);
276
- const r = f.check("fix-pr-40-b");
277
- assert.equal(r.status, 1, r.stderr);
278
- assert.equal(r.json.verdict, "escalate");
279
- assert.equal(r.json.token, `dispositions-escalate=fix-pr-40-b:${f.head}`);
280
- assert.match(r.stderr, /^fix-pr-40-b: survived\[0\]: an in-scope survived finding deferred with no reason/m, "the violations are still printed");
281
- const row = f.row();
282
- assert.ok(row.includes(`dispositions-mismatch=fix-pr-40:${f.head}`) && row.includes(`dispositions-escalate=fix-pr-40-b:${f.head}`), row);
283
- const d = f.ledgerCli("dispatch", "40", "finisher-pr-40");
284
- assert.equal(d.status, 2);
285
- assert.match(d.stderr, /finisher-pr-40: dispositions escalate — fix-pr-40-b deferred .*second mismatch/);
286
- // Re-running the escalated member's check is idempotent.
287
- const again = f.check("fix-pr-40-b");
288
- assert.equal(again.json.verdict, "escalate");
289
- assert.equal(f.row().match(/dispositions-escalate=/g).length, 1, f.row());
290
- });
291
-
292
- test("the retry that passes the check ends the refusal, and the first mismatch stays on the row unread", (t) => {
293
- const f = fixture(t);
294
- f.writeRecord(badRecord(f));
295
- mismatch(f.check());
296
- retry(f);
297
- f.writeRecord(f.baseEntries());
298
- okVerdict(f.check("fix-pr-40-b"));
299
- assert.ok(f.row().includes(`dispositions-mismatch=fix-pr-40:${f.head}`), "the first fix-applier's verdict is kept");
300
- assert.equal(f.okLedger("dispatch", "40", "finisher-pr-40").agent, "fleet-finisher");
301
- });
302
-
303
- test("the first mismatch is a plain mismatch, and a mismatch on an earlier review does not count toward a later one", (t) => {
304
- const f = fixture(t);
305
- f.writeRecord(badRecord(f));
306
- const first = f.check();
307
- assert.equal(first.json.verdict, "mismatch");
308
- assert.equal(first.json.token, `dispositions-mismatch=fix-pr-40:${f.head}`);
309
- // The earlier fix-applier's mismatch answered another review's head.
310
- retry(f);
311
- f.okLedger("row", "10", f.row().slice(4).replace(`dispositions-mismatch=fix-pr-40:${f.head}`, "dispositions-mismatch=fix-pr-40:deadbee1"));
312
- const second = f.check("fix-pr-40-b");
313
- assert.equal(second.json.verdict, "mismatch", second.stderr);
314
- });
315
-
316
- test("a mismatch from a later suffix, an ok, or another PR's fix-applier is not an earlier failure", () => {
317
- const H = "abc1234";
318
- const row = (...tokens) => `#10 impl-10=PR#40 → PR#40 · reviewed=${H}:1/0/0 · ${tokens.join(" · ")}`;
319
- const b = { retry: "b" };
320
- assert.equal(failedBefore([row(`dispositions-mismatch=fix-pr-40:${H}`)], 40, b, H), true);
321
- assert.equal(failedBefore([row(`dispositions-escalate=fix-pr-40:${H}`)], 40, b, H), true);
322
- assert.equal(failedBefore([row(`dispositions-ok=fix-pr-40:${H}`)], 40, b, H), false, "an ok is no failure");
323
- assert.equal(failedBefore([row(`dispositions-mismatch=fix-pr-40-c:${H}`)], 40, b, H), false, "a later suffix is not earlier");
324
- assert.equal(failedBefore([row(`dispositions-mismatch=fix-pr-40-b:${H}`)], 40, b, H), false, "the member itself is not earlier");
325
- assert.equal(failedBefore([row(`dispositions-mismatch=fix-pr-40:${H}`)], 40, { retry: null }, H), false, "nor is the first fix-applier's own re-run");
326
- assert.equal(failedBefore([row(`dispositions-mismatch=fix-pr-40:fedcba9`)], 40, b, H), false, "another review's head");
327
- assert.equal(failedBefore([row(`dispositions-mismatch=fix-pr-41:${H}`)], 40, b, H), false, "another PR's fix-applier");
328
- // A split row: the earlier verdict sits on another row that resolves to PR 40.
329
- assert.equal(failedBefore(["#11 impl-11=PR#40 → PR#40 · dispositions-mismatch=fix-pr-40:abc1234", "#12 impl-12=PR#41 → PR#41"], 40, b, H), true);
330
- // A copy of PR 40's verdict on PR 41's row is a stray: that row does not resolve to PR 40.
331
- assert.equal(failedBefore(["#12 impl-12=PR#41 → PR#41 · dispositions-mismatch=fix-pr-40:abc1234"], 40, b, H), false);
332
- // The same review named by a short head on one side and a full SHA on the other.
333
- const full = `${H}${"0".repeat(33)}`;
334
- assert.equal(failedBefore([row(`dispositions-mismatch=fix-pr-40:${H}`)], 40, b, full), true, "an earlier token's short head matches a full check head");
335
- assert.equal(failedBefore([row(`dispositions-mismatch=fix-pr-40:${full}`)], 40, b, H), true, "an earlier token's full head matches a short check head");
336
- });
337
-
338
- test("nothing is judged or written when the review file or the git history cannot be read", (t) => {
339
- const f = fixture(t);
340
- f.writeRecord(f.baseEntries());
341
- const before = f.row();
342
- rmSync(join(f.scratch, "review-40.json"));
343
- let r = f.check();
344
- assert.equal(r.status, 2);
345
- assert.match(r.stderr, /could not read the review file/);
346
- f.writeReview({ ...f.review, counts: { ...f.review.counts, survived: 3 } });
347
- r = f.check();
348
- assert.equal(r.status, 2);
349
- assert.match(r.stderr, /counts\.survived is 3, but survived holds 2/);
350
- f.writeReview();
351
- git(f.repo, "update-ref", "-d", "refs/remotes/origin/main");
352
- r = f.check();
353
- assert.equal(r.status, 2);
354
- assert.match(r.stderr, /could not find the merge-base of origin\/main/);
355
- assert.equal(f.row(), before);
356
- r = f.check("finisher-pr-40");
357
- assert.equal(r.status, 2);
358
- assert.match(r.stderr, /'finisher-pr-40' is not a fix-applier/);
359
- });
360
-
361
- // A standalone `/review-and-fix` has no controller and so no ledger: the run
362
- // is from the worktree, `--ledger` is not given, and `.fleet/ledger.md` does
363
- // not exist under its git common dir.
364
- function standalone(f, ...extra) {
365
- const r = spawnSync(process.execPath, [SCRIPT, "--member", "fix-pr-40", "--scratch", f.scratch, ...extra],
366
- { encoding: "utf8", env: cleanEnv(), cwd: f.repo });
367
- return { ...r, json: r.status === 0 || r.status === 1 ? JSON.parse(r.stdout) : null };
368
- }
369
-
370
- test("with no ledger the exit status is the verdict, and nothing is written to any ledger", (t) => {
371
- const f = fixture(t);
372
- const ledgerBefore = readFileSync(join(f.dir, "ledger.md"), "utf8");
373
-
374
- f.writeRecord(f.baseEntries());
375
- let r = standalone(f);
376
- okVerdict(r);
377
- assert.equal(r.json.token, null);
378
- assert.deepEqual(r.json.violations, []);
379
- assert.equal(r.stderr, "", "no --ledger and no default ledger is a standalone run that prints nothing");
380
-
381
- const bad = f.baseEntries();
382
- bad[0] = f.entry("survived", 0, { disposition: "defer" });
383
- f.writeRecord(bad);
384
- r = standalone(f);
385
- mismatch(r, /^fix-pr-40: survived\[0\]: an in-scope survived finding deferred with no reason/m);
386
- assert.equal(r.json.token, null);
387
- assert.deepEqual(r.json.violations.map((v) => [v.bucket, v.index]), [["survived", 0]]);
388
-
389
- rmSync(join(f.scratch, "dispositions-40.json"));
390
- mismatch(standalone(f), /record: no disposition record at .*dispositions-40\.json/);
391
-
392
- assert.equal(existsSync(join(f.repo, ".fleet")), false, "no .fleet/ was created");
393
- assert.equal(readFileSync(join(f.dir, "ledger.md"), "utf8"), ledgerBefore, "a ledger elsewhere is not this run's and is not touched");
394
- });
395
-
396
- test("an explicit --ledger naming no file is no ledger either: the default ledger is not borrowed, nothing is created, and stderr says so", (t) => {
397
- const f = fixture(t);
398
- const own = seedOwnLedger(f);
399
- const ownBefore = readFileSync(own, "utf8");
400
- const absent = join(f.dir, "absent", "ledger.md");
401
- f.writeRecord(f.baseEntries());
402
- const r = standalone(f, "--repo", f.repo, "--ledger", absent);
403
- okVerdict(r);
404
- assert.equal(r.json.token, null);
405
- assert.equal(readFileSync(own, "utf8"), ownBefore);
406
- assert.equal(existsSync(join(f.dir, "absent")), false);
407
- const lines = r.stderr.split("\n").filter(Boolean);
408
- assert.equal(lines.length, 1, r.stderr);
409
- assert.ok(lines[0].startsWith(`dispositions-check: no ledger at ${absent} `), lines[0]);
410
- assert.match(lines[0], /no token was written.*--no-ledger/);
411
-
412
- // A --ledger that exists is used, and draws no such note.
413
- const present = standalone(f, "--repo", f.repo, "--ledger", own);
414
- okVerdict(present);
415
- assert.equal(present.json.token, `dispositions-ok=fix-pr-40:${f.head}`);
416
- assert.doesNotMatch(present.stderr, /no ledger at/);
417
- });
418
-
419
- // Writes `f.repo`'s own `.fleet/ledger.md` with the member's row, as a fleet
420
- // run's `ledger.mjs dispatch` leaves it, and returns its path.
421
- function seedOwnLedger(f) {
422
- const ledger = join(f.repo, ".fleet", "ledger.md");
423
- const run = (...args) => {
424
- const r = spawnSync(process.execPath, [LEDGER, "--file", ledger, ...args], { encoding: "utf8", env: cleanEnv() });
425
- assert.equal(r.status, 0, r.stderr);
426
- };
427
- run("row", "10", `impl-10=PR#40 → PR#40 · reviewed=${f.head}:2/1/1`);
428
- run("dispatch", "40", "fix-pr-40");
429
- run("settle", "fix-pr-40", `applied:${f.head.slice(0, 7)}`);
430
- return ledger;
431
- }
432
-
433
- test("the run's own .fleet/ledger.md is found without --ledger, and the verdict is written to it", (t) => {
434
- const f = fixture(t);
435
- const ledger = seedOwnLedger(f);
436
- f.writeRecord(f.baseEntries());
437
- const r = standalone(f);
438
- okVerdict(r);
439
- assert.equal(r.json.token, `dispositions-ok=fix-pr-40:${f.head}`);
440
- assert.match(readFileSync(ledger, "utf8"), new RegExp(`dispositions-ok=fix-pr-40:${f.head}`));
441
- });
442
-
443
- test("a ledger that exists is never skipped: one with no row for the member is a fault, not a standalone run", (t) => {
444
- const f = fixture(t);
445
- const other = join(f.dir, "other-ledger.md");
446
- const made = spawnSync(process.execPath, [LEDGER, "--file", other, "row", "11", "impl-11=PR#41 → PR#41"], { encoding: "utf8", env: cleanEnv() });
447
- assert.equal(made.status, 0, made.stderr);
448
- const before = readFileSync(other, "utf8");
449
- f.writeRecord(f.baseEntries());
450
- const r = standalone(f, "--ledger", other);
451
- assert.equal(r.status, 2, r.stderr);
452
- assert.match(r.stderr, /fix-pr-40 is on no row of PR #40/);
453
- assert.equal(readFileSync(other, "utf8"), before);
454
- });
455
-
456
- // A repository's `.fleet/ledger.md` outlives the fleet run that wrote it, and
457
- // every worktree of the repository finds it through the git common dir.
458
- function linkedWorktree(f) {
459
- const wt = join(f.dir, "wt");
460
- git(f.repo, "worktree", "add", "-q", "--detach", wt, f.head);
461
- return wt;
462
- }
463
-
464
- test("from a linked worktree the default ledger is the main checkout's, found through the git common dir", (t) => {
465
- const f = fixture(t);
466
- const wt = linkedWorktree(f);
467
- const ledger = seedOwnLedger(f);
468
- f.writeRecord(f.baseEntries());
469
- const r = standalone(f, "--repo", wt);
470
- okVerdict(r);
471
- assert.equal(r.json.token, `dispositions-ok=fix-pr-40:${f.head}`);
472
- assert.match(readFileSync(ledger, "utf8"), new RegExp(`dispositions-ok=fix-pr-40:${f.head}`));
473
- assert.equal(existsSync(join(wt, ".fleet")), false, "the worktree holds no ledger of its own");
474
- });
475
-
476
- test("--no-ledger is a standalone run whatever ledger the repository holds: a stale one is not a fault, and none is written", (t) => {
477
- const f = fixture(t);
478
- const wt = linkedWorktree(f);
479
- const stale = join(f.repo, ".fleet", "ledger.md");
480
- mkdirSync(join(f.repo, ".fleet"));
481
- const made = spawnSync(process.execPath, [LEDGER, "--file", stale, "row", "11", "impl-11=PR#41 → PR#41"], { encoding: "utf8", env: cleanEnv() });
482
- assert.equal(made.status, 0, made.stderr);
483
- const before = readFileSync(stale, "utf8");
484
- f.writeRecord(f.baseEntries());
485
-
486
- const fault = standalone(f, "--repo", wt);
487
- assert.equal(fault.status, 2, fault.stderr);
488
- assert.match(fault.stderr, /fix-pr-40 is on no row of PR #40.*--no-ledger/);
489
-
490
- const r = standalone(f, "--repo", wt, "--no-ledger");
491
- okVerdict(r);
492
- assert.equal(r.json.token, null);
493
- assert.equal(r.stderr, "", "--no-ledger is a chosen standalone run and prints nothing");
494
- assert.equal(readFileSync(stale, "utf8"), before);
495
-
496
- const bad = f.baseEntries();
497
- bad[0] = f.entry("survived", 0, { disposition: "defer" });
498
- f.writeRecord(bad);
499
- mismatch(standalone(f, "--repo", wt, "--no-ledger"), /^fix-pr-40: survived\[0\]/m);
500
- });
501
-
502
- test("--no-ledger leaves a ledger that holds the member's row unwritten, and contradicts --ledger", (t) => {
503
- const f = fixture(t);
504
- const ledger = seedOwnLedger(f);
505
- const before = readFileSync(ledger, "utf8");
506
- f.writeRecord(f.baseEntries());
507
- const r = standalone(f, "--no-ledger");
508
- okVerdict(r);
509
- assert.equal(r.json.token, null);
510
- assert.equal(r.stderr, "");
511
- assert.equal(readFileSync(ledger, "utf8"), before);
512
-
513
- const both = standalone(f, "--no-ledger", "--ledger", ledger);
514
- assert.equal(both.status, 2, both.stderr);
515
- assert.match(both.stderr, /--no-ledger and --ledger contradict/);
516
- });
517
-
518
- test("a ledger path that cannot be looked up is a fault, never a standalone run", (t) => {
519
- const f = fixture(t);
520
- f.writeRecord(f.baseEntries());
521
-
522
- // `.fleet` is a regular file, so `.fleet/ledger.md` fails ENOTDIR, not ENOENT.
523
- writeFileSync(join(f.repo, ".fleet"), "");
524
- let r = standalone(f);
525
- assert.equal(r.status, 2, r.stderr);
526
- assert.match(r.stderr, /could not look for the ledger .*ledger\.md/);
527
- rmSync(join(f.repo, ".fleet"));
528
-
529
- // A dangling symlink is a ledger that cannot be read, not an absent one.
530
- mkdirSync(join(f.repo, ".fleet"));
531
- symlinkSync(join(f.dir, "nowhere.md"), join(f.repo, ".fleet", "ledger.md"));
532
- r = standalone(f);
533
- assert.equal(r.status, 2, r.stderr);
534
- assert.equal(existsSync(join(f.dir, "nowhere.md")), false, "nothing was created through the link");
535
- });
536
-
537
- test("an ambient GIT_DIR naming another repository does not change the answer", (t) => {
538
- const f = fixture(t);
539
- const other = join(f.dir, "other");
540
- mkdirSync(other);
541
- git(other, "init", "-q", "-b", "main");
542
- const entries = f.baseEntries();
543
- entries[0] = f.entry("survived", 0, { scope: "out", disposition: "defer" });
544
- f.writeRecord(entries);
545
- const r = f.check("fix-pr-40", { ...cleanEnv(), GIT_DIR: join(other, ".git"), GIT_WORK_TREE: other });
546
- mismatch(r, /src\/a\.js:5 is a line the PR's diff touched/);
547
- });
548
-
549
- test("an ambient GIT_DIR naming another repository does not change which ledger is found", (t) => {
550
- const f = fixture(t);
551
- const ledger = seedOwnLedger(f);
552
- const other = join(f.dir, "other");
553
- mkdirSync(other);
554
- git(other, "init", "-q", "-b", "main");
555
- f.writeRecord(f.baseEntries());
556
- const r = spawnSync(process.execPath, [SCRIPT, "--member", "fix-pr-40", "--scratch", f.scratch, "--repo", f.repo],
557
- { encoding: "utf8", env: { ...cleanEnv(), GIT_DIR: join(other, ".git"), GIT_WORK_TREE: other }, cwd: f.dir });
558
- assert.equal(r.status, 0, r.stderr);
559
- assert.equal(JSON.parse(r.stdout).token, `dispositions-ok=fix-pr-40:${f.head}`);
560
- assert.match(readFileSync(ledger, "utf8"), new RegExp(`dispositions-ok=fix-pr-40:${f.head}`));
561
- });
562
-
563
- test("touchedLines reads new-side lines; pure deletions and deleted files touch none", () => {
564
- const diff = [
565
- "diff --git a/x b/x", "--- a/x", "+++ b/x",
566
- "@@ -3 +3 @@", "-o", "+n",
567
- "@@ -10,0 +11,2 @@", "+p", "+q",
568
- "@@ -20,2 +21,0 @@", "-r", "-s",
569
- "diff --git a/gone b/gone", "--- a/gone", "+++ /dev/null", "@@ -1,2 +0,0 @@", "-t", "-u",
570
- ].join("\n");
571
- const t = touchedLines(diff);
572
- assert.deepEqual([...t.get("x")], [3, 11, 12]);
573
- assert.equal(t.has("gone"), false);
574
- });
575
-
576
- test("repoPath reads an absolute finding path relative to the snapshot or the repository", () => {
577
- assert.equal(repoPath("/snap/src/a.js", ["/snap", "/repo"]), "src/a.js");
578
- assert.equal(repoPath("/repo/src/a.js", ["/snap", "/repo"]), "src/a.js");
579
- assert.equal(repoPath("./src/a.js"), "src/a.js");
580
- assert.equal(repoPath("/elsewhere/a.js", ["/snap"]), "/elsewhere/a.js");
581
- });
582
-
583
- test("checkDispositions reads an absolute snapshot path onto the diff's touched lines", () => {
584
- const review = { head: "abc1234", survived: [{ file: "/snap/src/a.js", line: 5 }], unverified: [], refuted: [] };
585
- const record = { head: "abc1234", entries: [{ bucket: "survived", index: 0, scope: "out", claimKind: "behavior", disposition: "defer" }] };
586
- const touched = new Map([["src/a.js", new Set([5])]]);
587
- assert.equal(checkDispositions({ review, record, touched, roots: ["/snap"] }).violations.length, 1);
588
- assert.equal(checkDispositions({ review, record, touched: new Map(), roots: ["/snap"] }).violations.length, 0);
589
- });
590
-
591
- test("withVerdict replaces only the same member's verdict for the same head", () => {
592
- const H = "abc1234abc1234abc1234abc1234abc1234abcde";
593
- const ok = `dispositions-ok=fix-pr-40:${H}`;
594
- const bad = `dispositions-mismatch=fix-pr-40:${H}`;
595
- const other = `dispositions-ok=fix-pr-40-b:${H}`;
596
- const older = "dispositions-mismatch=fix-pr-40:def5678";
597
- assert.equal(withVerdict(`impl-10=PR#40 · ${bad}`, ok), `impl-10=PR#40 · ${ok}`);
598
- assert.equal(withVerdict(`impl-10=PR#40 · ${ok}`, ok), `impl-10=PR#40 · ${ok}`);
599
- assert.equal(withVerdict(`${bad} · impl-10=PR#40`, ok), `impl-10=PR#40 · ${ok}`);
600
- assert.equal(withVerdict(`impl-10=PR#40 · ${other} · ${older}`, ok), `impl-10=PR#40 · ${other} · ${older} · ${ok}`);
601
- });
602
-
603
- // A second PR commit on the fixture's repository: `files` written (paths
604
- // relative to the repository), everything committed, and the review rewritten
605
- // to answer the new head with `survived` as its only covered findings.
606
- function advance(f, files, survived) {
607
- for (const [p, text] of Object.entries(files)) writeFileSync(join(f.repo, p), text);
608
- git(f.repo, "add", "-A");
609
- git(f.repo, "commit", "-qm", "pr 2");
610
- const head = git(f.repo, "rev-parse", "HEAD");
611
- f.writeReview({ ...f.review, head, counts: { ...f.review.counts, survived: survived.length, unverified: 0 }, survived, unverified: [] });
612
- return head;
613
- }
614
- const declaredOut = (f, n) => Array.from({ length: n }, (_, i) => f.entry("survived", i, { scope: "out", disposition: "defer" }));
615
- const flagged = (r) => r.json.violations.map((v) => v.index);
616
- const finding = (file, line) => ({ severity: "important", file, line, claim: "c", evidence: "e" });
617
-
618
- test("a touched line is found whatever git prints around it: an added `++ ` line, a name with a space, a quoted name", (t) => {
619
- const f = fixture(t);
620
- const a = readFileSync(join(f.repo, "src", "a.js"), "utf8").split("\n");
621
- a[1] = "++ b/elsewhere"; // git prints this added line as `+++ b/elsewhere`
622
- a[17] = "a 18 changed";
623
- const head = advance(f, {
624
- "src/a.js": a.join("\n"),
625
- "src/my file.js": lines(5, "m"),
626
- 'src/q"x.js': lines(3, "q"),
627
- "src/back\\slash.js": lines(2, "s"),
628
- }, [
629
- finding("src/a.js", 18), finding("src/my file.js", 3), finding('src/q"x.js', 2), finding("src/back\\slash.js", 1),
630
- finding("src/a.js", 10), // untouched: its declared scope stands
631
- ]);
632
- f.writeRecord(declaredOut(f, 5), head);
633
- const r = f.check();
634
- mismatch(r, /survived\[0\]: .*src\/a\.js:18 is a line the PR's diff touched/);
635
- assert.match(r.stderr, /survived\[1\]: .*src\/my file\.js:3 is a line the PR's diff touched/);
636
- assert.match(r.stderr, /survived\[2\]: .*src\/q"x\.js:2 is a line the PR's diff touched/);
637
- assert.match(r.stderr, /survived\[3\]: .*src\/back\\slash\.js:1 is a line the PR's diff touched/);
638
- assert.deepEqual(flagged(r), [0, 1, 2, 3]);
639
- });
640
-
641
- test("only the lines the diff changed are touched — no context lines, and a renamed file's unchanged lines are not", (t) => {
642
- const f = fixture(t);
643
- // Rename detection held by the check itself, not by a config default.
644
- git(f.repo, "config", "diff.renames", "false");
645
- const b = lines(10, "b").split("\n");
646
- b[2] = "b 3 changed";
647
- rmSync(join(f.repo, "src", "b.js"));
648
- const head = advance(f, { "src/c.js": b.join("\n") }, [
649
- finding("src/a.js", 8), // two lines past the fixture's change at 5-6: context under --unified=3
650
- finding("src/c.js", 7), // unchanged by the rename
651
- finding("src/c.js", 3), // changed: in scope
652
- ]);
653
- f.writeRecord(declaredOut(f, 3), head);
654
- const r = f.check();
655
- mismatch(r, /survived\[2\]: .*src\/c\.js:3 is a line the PR's diff touched/);
656
- assert.deepEqual(flagged(r), [2]);
657
- });
658
-
659
- test("run through a symlinked path, the check still judges and writes its verdict", (t) => {
660
- const f = fixture(t);
661
- const link = join(f.dir, "dispositions-check-link.mjs");
662
- symlinkSync(SCRIPT, link);
663
- f.writeRecord(f.baseEntries());
664
- okVerdict(f.check("fix-pr-40", cleanEnv(), link));
665
- assert.ok(f.row().includes(`dispositions-ok=fix-pr-40:${f.head}`), f.row());
666
- const bare = spawnSync(process.execPath, [link], { encoding: "utf8", env: cleanEnv() });
667
- assert.equal(bare.status, 2);
668
- assert.match(bare.stderr, /usage: dispositions-check\.mjs/);
669
- });
670
-
671
- test("nothing is judged or written for a review finding that is no object, an unreadable record file or a stray argument", (t) => {
672
- const f = fixture(t);
673
- f.writeRecord(f.baseEntries());
674
- const before = f.row();
675
- f.writeReview({ ...f.review, survived: [f.review.survived[0], null] });
676
- let r = f.check();
677
- assert.equal(r.status, 2, r.stderr);
678
- assert.match(r.stderr, /review-40\.json has a survived\[1\] that is not a finding object/);
679
- f.writeReview();
680
- // A record path that exists and cannot be read is the environment's fault,
681
- // not a ruling the fix-applier wrote: no mismatch is blamed on it.
682
- rmSync(join(f.scratch, "dispositions-40.json"));
683
- mkdirSync(join(f.scratch, "dispositions-40.json"));
684
- r = f.check();
685
- assert.equal(r.status, 2, r.stderr);
686
- assert.match(r.stderr, /could not read the disposition record .*dispositions-40\.json: EISDIR/);
687
- rmSync(join(f.scratch, "dispositions-40.json"), { recursive: true });
688
- f.writeRecord(f.baseEntries());
689
- r = f.check("fix-pr-40", cleanEnv(), SCRIPT, ["stray"]);
690
- assert.equal(r.status, 2, r.stderr);
691
- assert.equal(f.row(), before);
692
- // The control: the same files and flags, nothing stray, are judged and written.
693
- okVerdict(f.check());
694
- assert.notEqual(f.row(), before);
695
- });
696
-
697
- // The pure core, on one review: survived[0] on touched src/a.js:5, one refuted finding.
698
- const H40 = "abc1234abc1234abc1234abc1234abc1234abcde";
699
- const coreRun = (entries, { head = H40, reviewHead = H40, survived = [{ file: "src/a.js", line: 5 }], record, diffFiles = ["src/a.js"] } = {}) => checkDispositions({
700
- review: { head: reviewHead, survived, unverified: [], refuted: [{ file: "src/b.js", line: 1 }] },
701
- record: record === undefined ? { head, entries } : record,
702
- touched: new Map([["src/a.js", new Set([5])]]),
703
- diffFiles,
704
- roots: ["/snap"],
705
- });
706
- const core = (entries, opts) => coreRun(entries, opts).violations.map(formatViolation);
707
- const applied = { bucket: "survived", index: 0, scope: "in", claimKind: "behavior", disposition: "apply" };
708
-
709
- test("a record entry that is no object, names no position, or a record with no entries is a mismatch, never a crash", () => {
710
- assert.deepEqual(core([applied, { ...applied, index: -1 }]), ["survived[-1]: entries[1] names no finding — survived holds 1"]);
711
- assert.deepEqual(core([applied, null]), ["record: entries[1] is not an object"]);
712
- assert.deepEqual(core([applied, ["survived", 0]]), ["record: entries[1] is not an object"]);
713
- assert.deepEqual(core(null, { record: { head: H40 } }), [
714
- "record: the record is not {head, entries: [...]}", "survived[0]: no entry — a finding with no entry is a dropped finding",
715
- ]);
716
- });
717
-
718
- test("every optional field is held to its type, and a well-typed one passes", () => {
719
- const malformed = (more, msg) => assert.deepEqual(core([{ ...applied, ...more }]), [`survived[0]: malformed entry — ${msg}`]);
720
- malformed({ issue: 0 }, "issue is not an issue number");
721
- malformed({ issue: "7" }, "issue is not an issue number");
722
- malformed({ issue: 1.5 }, "issue is not an issue number");
723
- malformed({ reason: 5 }, "reason is not a string");
724
- malformed({ verdictPath: 1 }, "verdictPath is not a string");
725
- malformed({ remedyFiles: [1] }, "remedyFiles is not an array of paths");
726
- malformed({ remedyFiles: "src/a.js" }, "remedyFiles is not an array of paths");
727
- malformed({ claimKind: "both" }, 'claimKind "both" is not one of behavior|shape');
728
- malformed({ disposition: undefined }, "disposition null is not one of apply|defer");
729
- assert.deepEqual(core([{ ...applied, issue: 1, reason: "", verdictPath: "", remedyFiles: [] }]), []);
730
- });
731
-
732
- test("the record's head answers the review's as a prefix in either direction, never below seven hex", () => {
733
- assert.deepEqual(core([applied], { head: H40.slice(0, 7) }), []);
734
- assert.deepEqual(core([applied], { head: H40.toUpperCase() }), []);
735
- assert.deepEqual(core([applied], { reviewHead: H40.slice(0, 10) }), []);
736
- const stale = (head) => [`record: the record answers head ${JSON.stringify(head)}, not the review's ${H40}`];
737
- assert.deepEqual(core([applied], { head: "abc" }), stale("abc"));
738
- assert.deepEqual(core([applied], { head: "abc1235" }), stale("abc1235"));
739
- });
740
-
741
- test("a finding with a line and no file is in scope; a reversed refutation's whitespace reason names no evidence", () => {
742
- const out = { ...applied, scope: "out", disposition: "defer" };
743
- assert.match(core([out], { survived: [{ line: 5 }] })[0], /^survived\[0\]: .* it has no file, so it is in scope/);
744
- assert.deepEqual(core([applied, { ...applied, bucket: "refuted", reason: " \t" }]),
745
- ["refuted[0]: a reversed refutation names its evidence in reason, and this one names none"]);
746
- });
747
-
748
- test("an absolute path into a copy of the tree no root names is read by the touched file it ends in", () => {
749
- const out = { ...applied, scope: "out", disposition: "defer" };
750
- // A specialist's own copy of the snapshot, and a /tmp alias of a root.
751
- for (const file of ["/tmp/specialist-copy/src/a.js", "/private/snap/src/a.js"]) {
752
- assert.match(core([out], { survived: [{ file, line: 5 }] })[0] ?? "", /^survived\[0\]: .*src\/a\.js:5 is a line the PR's diff touched/, file);
753
- }
754
- // What it must accept: an untouched line, an untouched file, and a name
755
- // that only ends in a touched one mid-component.
756
- for (const [file, line] of [["/tmp/specialist-copy/src/a.js", 6], ["/tmp/specialist-copy/src/b.js", 5], ["/tmp/copy/notsrc/a.js", 5]]) {
757
- assert.deepEqual(core([out], { survived: [{ file, line }] }), [], file);
758
- }
759
- assert.equal(repoPath("/x/src/a.js", ["/snap"], ["a.js", "src/a.js"]), "src/a.js");
760
- assert.equal(repoPath("/x/notsrc/a.js", ["/snap"], ["src/a.js"]), "/x/notsrc/a.js");
761
- assert.equal(repoPath("./././src/a.js"), "src/a.js");
762
- });
763
-
764
- test("touchedLines reads an added `++ ` line as content and unquotes git's header names", () => {
765
- const diff = [
766
- "diff --git a/x b/x", "--- a/x", "+++ b/x",
767
- "@@ -2 +2 @@", "-l2", "+++ b/elsewhere",
768
- "@@ -25 +25 @@", "-l25", "+l25 changed",
769
- "diff --git a/my file b/my file", "--- a/my file\t", "+++ b/my file\t", "@@ -1 +1 @@", "-o", "+n",
770
- 'diff --git "a/q\\"x" "b/q\\"x"', '--- "a/q\\"x"', '+++ "b/q\\"x"', "@@ -0,0 +1 @@", "+n",
771
- 'diff --git "a/\\303\\251\\tt" "b/\\303\\251\\tt"', "--- /dev/null", '+++ "b/\\303\\251\\tt"', "@@ -0,0 +1 @@", "+n",
772
- ].join("\n");
773
- const t = touchedLines(diff);
774
- assert.deepEqual([...t.keys()], ["x", "my file", 'q"x', "é\tt"]);
775
- assert.deepEqual([...t.get("x")], [2, 25]);
776
- });
777
-
778
- test("withVerdict leaves a row already carrying only the token unchanged, folds an emptied row, and refuses a non-verdict token", () => {
779
- const ok = `dispositions-ok=fix-pr-40:${H40}`;
780
- assert.equal(withVerdict(ok, ok), ok);
781
- // Already the row's only verdict for that member and head: left where it sits.
782
- assert.equal(withVerdict(`${ok} · impl-10=PR#40`, ok), `${ok} · impl-10=PR#40`);
783
- assert.equal(withVerdict(`dispositions-mismatch=fix-pr-40:${H40}`, ok), ok);
784
- assert.equal(withVerdict(`· dispositions-mismatch=fix-pr-40:${H40} ·`, ok), ok);
785
- assert.throws(() => withVerdict(`impl-10=PR#40 · ${ok}`, "garbage"), /'garbage' is not a dispositions-ok=\/dispositions-mismatch=\/dispositions-escalate= token/);
786
- });
787
-
788
- // ---------------------------------------------------------------------------
789
- // remedy-outside-diff: a deferral whose remedy lies in a file the PR's diff
790
- // does not name. In the fixture src/a.js is in the PR's diff and src/b.js is
791
- // not.
792
- // ---------------------------------------------------------------------------
793
-
794
- const escalated = (r) => {
795
- assert.equal(r.status, 1, `expected an escalation, got exit ${r.status}\n${r.stderr}`);
796
- assert.equal(r.json.verdict, "escalate");
797
- };
798
- // survived[0], on touched line 5, deferred remedy-outside-diff.
799
- const deferOutside = (f, remedyFiles, recHead) => {
800
- const entries = f.baseEntries();
801
- entries[0] = f.entry("survived", 0, { disposition: "defer", reason: "remedy-outside-diff", issue: 81, remedyFiles });
802
- f.writeRecord(entries, recHead);
803
- };
804
- const withSeverity = (f, severity) => f.writeReview({ ...f.review, survived: [{ ...f.review.survived[0], severity }, f.review.survived[1]] });
805
- // The same review row with no fix-applier landed on it is fix-due: the control
806
- // that shows fixDueFor can see a PR become fix-due at all.
807
- const dueUntilFixed = (f) => deriveRun({ rows: [`#10 impl-10=PR#40 → PR#40 · reviewed=${f.head}:2/1/1`], dispatched: [], drain: null },
808
- [{ number: 40, labels: [], closingIssuesReferences: [{ number: 10 }] }]).fixDue;
809
- const fixDueFor = (f) => {
810
- const l = f.okLedger("read");
811
- return deriveRun({ rows: l.rows, dispatched: l.dispatched, drain: null }, [{ number: 40, labels: [], closingIssuesReferences: [{ number: 10 }] }]).fixDue;
812
- };
813
-
814
- test("a suggestion deferred remedy-outside-diff, its remedy in a file the diff lacks, passes as ok and lets the finisher dispatch", (t) => {
815
- const f = fixture(t);
816
- withSeverity(f, "suggestion");
817
- deferOutside(f, ["src/b.js"]);
818
- const r = f.check();
819
- okVerdict(r);
820
- assert.deepEqual(r.json.escalations, []);
821
- assert.ok(f.row().includes(`dispositions-ok=fix-pr-40:${f.head}`), f.row());
822
- assert.equal(f.okLedger("dispatch", "40", "finisher-pr-40").agent, "fleet-finisher");
823
- });
824
-
825
- test("a critical or important finding deferred remedy-outside-diff writes dispositions-escalate, refuses the finisher by name and never makes the PR fix-due", (t) => {
826
- for (const severity of ["important", "critical"]) {
827
- const f = fixture(t);
828
- withSeverity(f, severity);
829
- deferOutside(f, ["src/a.js", "src/b.js"]);
830
- const r = f.check();
831
- escalated(r);
832
- assert.deepEqual(r.json.violations, []);
833
- assert.deepEqual(r.json.escalations, [{ bucket: "survived", index: 0, severity, files: ["src/b.js"] }]);
834
- assert.equal(r.json.token, `dispositions-escalate=fix-pr-40:${f.head}`);
835
- assert.match(r.stderr, new RegExp(`^fix-pr-40: survived\\[0\\]: a ${severity} finding deferred remedy-outside-diff, its remedy in src/b\\.js — a human rules$`, "m"));
836
- assert.ok(f.row().includes(`dispositions-escalate=fix-pr-40:${f.head}`), f.row());
837
-
838
- const before = readFileSync(join(f.dir, "ledger.md"), "utf8");
839
- const d = f.ledgerCli("dispatch", "40", "finisher-pr-40");
840
- assert.equal(d.status, 2, severity);
841
- assert.match(d.stderr, /finisher-pr-40: dispositions escalate — fix-pr-40 deferred/);
842
- assert.equal(readFileSync(join(f.dir, "ledger.md"), "utf8"), before, "a refused dispatch writes nothing");
843
- assert.deepEqual(dueUntilFixed(f), [40], "control");
844
- assert.deepEqual(fixDueFor(f), [], `${severity}: an escalation is a human's, never a fix-pr dispatch`);
845
- }
846
- });
847
-
848
- test("remedy-outside-diff whose remedy files are all in the PR's diff, or none, is a mismatch — a suggestion's included", (t) => {
849
- const f = fixture(t);
850
- for (const severity of ["important", "suggestion"]) {
851
- withSeverity(f, severity);
852
- for (const remedyFiles of [["src/a.js"], ["./src/a.js"], [join(f.repo, "src/a.js")], [" src/a.js "], ["src//a.js"], ["src/../src/a.js"], ["./src/../src/a.js", " "], [], [""], undefined]) {
853
- deferOutside(f, remedyFiles);
854
- const r = f.check();
855
- mismatch(r, /^fix-pr-40: survived\[0\]: reason remedy-outside-diff needs a remedy file absent from the PR's diff — /m);
856
- assert.deepEqual(r.json.escalations, [], `${severity} ${JSON.stringify(remedyFiles)}`);
857
- assert.ok(f.row().includes(`dispositions-mismatch=fix-pr-40:${f.head}`), f.row());
858
- }
859
- }
860
- deferOutside(f, ["src/a.js"]);
861
- assert.match(f.check().stderr, /every file remedyFiles names is in the PR's diff/);
862
- deferOutside(f, []);
863
- assert.match(f.check().stderr, /remedyFiles names no file/);
864
- });
865
-
866
- test("a file the PR deleted or moved away is in the PR's diff, so a remedy naming only it is a mismatch", (t) => {
867
- const f = fixture(t);
868
- git(f.repo, "rm", "-q", "src/b.js");
869
- git(f.repo, "mv", "src/a.js", "src/c.js");
870
- git(f.repo, "commit", "-qm", "pr 2: delete b, move a");
871
- const head = git(f.repo, "rev-parse", "HEAD");
872
- f.writeReview({ ...f.review, head, survived: [{ severity: "suggestion", claim: "c", evidence: "e" }, f.review.survived[1]] });
873
- for (const remedyFiles of [["src/b.js"], ["src/a.js"], ["src/c.js"]]) {
874
- deferOutside(f, remedyFiles, head);
875
- mismatch(f.check(), /reason remedy-outside-diff needs a remedy file absent from the PR's diff/);
876
- }
877
- // The control: a file the PR never touched is outside it.
878
- git(f.repo, "update-ref", "refs/remotes/origin/main", "HEAD~1");
879
- deferOutside(f, ["src/never.js"], head);
880
- okVerdict(f.check());
881
- });
882
-
883
- test("a record that breaks a rule is a mismatch even when it also escalates, and prints both", (t) => {
884
- const f = fixture(t);
885
- withSeverity(f, "critical");
886
- deferOutside(f, ["src/b.js"]);
887
- const rec = JSON.parse(readFileSync(join(f.scratch, "dispositions-40.json"), "utf8"));
888
- f.writeRecord(rec.entries.filter((e) => !(e.bucket === "survived" && e.index === 1)));
889
- const r = f.check();
890
- mismatch(r, /^fix-pr-40: survived\[1\]: no entry/m);
891
- assert.match(r.stderr, /^fix-pr-40: survived\[0\]: a critical finding deferred remedy-outside-diff/m);
892
- assert.equal(r.json.token, `dispositions-mismatch=fix-pr-40:${f.head}`);
893
- });
894
-
895
- test("a re-check after an escalation replaces it with the member's new verdict, and the finisher then dispatches", (t) => {
896
- const f = fixture(t);
897
- deferOutside(f, ["src/b.js"]);
898
- escalated(f.check());
899
- f.writeRecord(f.baseEntries());
900
- okVerdict(f.check());
901
- const row = f.row();
902
- assert.equal(row.match(/dispositions-/g).length, 1, row);
903
- assert.equal(f.okLedger("dispatch", "40", "finisher-pr-40").agent, "fleet-finisher");
904
- });
905
-
906
- test("an out-of-scope deferral, an unverified one and an applied remedy need no remedy file and escalate nothing", (t) => {
907
- const f = fixture(t);
908
- const entries = f.baseEntries();
909
- entries[1] = f.entry("survived", 1, { scope: "out", disposition: "defer", reason: "remedy-outside-diff", issue: 12 });
910
- entries[2] = f.entry("unverified", 0, { disposition: "defer", reason: "remedy-outside-diff", issue: 13 });
911
- f.writeRecord(entries);
912
- const r = f.check();
913
- okVerdict(r);
914
- assert.deepEqual(r.json.escalations, []);
915
- });
916
-
917
- test("checkDispositions: escalation is every severity but suggestion, a missing severity included; diffFiles is required when a deferral needs it", () => {
918
- const entry = { bucket: "survived", index: 0, scope: "in", claimKind: "behavior", disposition: "defer", reason: "remedy-outside-diff", remedyFiles: ["src/b.js"] };
919
- for (const [severity, expected] of [["critical", 1], ["important", 1], [undefined, 1], ["suggestion", 0]]) {
920
- const r = coreRun([entry], { survived: [{ file: "src/a.js", line: 5, severity }] });
921
- assert.deepEqual(r.violations, [], String(severity));
922
- assert.equal(r.escalations.length, expected, String(severity));
923
- }
924
- assert.deepEqual(coreRun([entry], { survived: [{ file: "src/a.js", line: 5, severity: "important" }] }).escalations,
925
- [{ bucket: "survived", index: 0, severity: "important", files: ["src/b.js"] }]);
926
- assert.throws(() => coreRun([entry], { diffFiles: null }), /no diffFiles was given/);
927
- // A remedy the other reasons never read: no diffFiles needed.
928
- assert.deepEqual(coreRun([{ ...entry, reason: "remedy-worse" }], { diffFiles: null }).violations, []);
929
- });
930
-
931
- test("withVerdict replaces an escalation with the same member's later verdict for the head, and an escalation for an ok", () => {
932
- const esc = `dispositions-escalate=fix-pr-40:${H40}`;
933
- const ok = `dispositions-ok=fix-pr-40:${H40}`;
934
- assert.equal(withVerdict(`impl-10=PR#40 · ${esc}`, ok), `impl-10=PR#40 · ${ok}`);
935
- assert.equal(withVerdict(`impl-10=PR#40 · ${ok}`, esc), `impl-10=PR#40 · ${esc}`);
936
- });