@feigi/fleet-ctl 3.23.36 → 3.23.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/package.json +1 -1
  2. package/scripts/main-checkout.mjs +1 -1
  3. package/scripts/member-write-guard.mjs +1 -1
  4. package/scripts/repo-root.mjs +1 -1
  5. package/skills/run-team/references/reaping.md +1 -1
  6. package/scripts/agent-test-dir-prose.test.mjs +0 -59
  7. package/scripts/agent-test.test.mjs +0 -1640
  8. package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
  9. package/scripts/ambient-git-vars-prose.test.mjs +0 -192
  10. package/scripts/ancestry-check-position-prose.test.mjs +0 -175
  11. package/scripts/apply-ruleset.test.mjs +0 -421
  12. package/scripts/arg-header-probes-prose.test.mjs +0 -394
  13. package/scripts/arg.test.mjs +0 -1354
  14. package/scripts/board-cli.test.mjs +0 -710
  15. package/scripts/board-identity.test.mjs +0 -429
  16. package/scripts/board-liveness-banner.test.mjs +0 -119
  17. package/scripts/board-prev-shape.test.mjs +0 -228
  18. package/scripts/board-tryparse-null.test.mjs +0 -119
  19. package/scripts/board.test.mjs +0 -3121
  20. package/scripts/brief-after-cut-prose.test.mjs +0 -53
  21. package/scripts/candidates-exit3-prose.test.mjs +0 -302
  22. package/scripts/candidates.test.mjs +0 -2312
  23. package/scripts/caveat-unification-prose.test.mjs +0 -98
  24. package/scripts/cell-readout.test.mjs +0 -615
  25. package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
  26. package/scripts/ci-completes-premise-prose.test.mjs +0 -257
  27. package/scripts/ci-state-prose.test.mjs +0 -113
  28. package/scripts/ci-state.test.mjs +0 -1933
  29. package/scripts/ci-vacuous-green.test.mjs +0 -368
  30. package/scripts/citation-sweep-prose.test.mjs +0 -1712
  31. package/scripts/claim-lifecycle.test.mjs +0 -187
  32. package/scripts/claim-ticket.test.mjs +0 -1122
  33. package/scripts/closing-keyword-prose.test.mjs +0 -193
  34. package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
  35. package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
  36. package/scripts/compute-board.test.mjs +0 -1214
  37. package/scripts/compute-spend.test.mjs +0 -517
  38. package/scripts/consumer-technology-prose.test.mjs +0 -126
  39. package/scripts/cross-repo-citation-prose.test.mjs +0 -155
  40. package/scripts/cwd-isolation-pins.mjs +0 -83
  41. package/scripts/dedupe-guard-prose.test.mjs +0 -243
  42. package/scripts/delete-merged-branch.test.mjs +0 -576
  43. package/scripts/derive-testcmd.test.mjs +0 -595
  44. package/scripts/diff-stats.test.mjs +0 -404
  45. package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
  46. package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
  47. package/scripts/dispositions-check.test.mjs +0 -936
  48. package/scripts/dispositions-gate-prose.test.mjs +0 -129
  49. package/scripts/drop-merged-label.test.mjs +0 -479
  50. package/scripts/exec-stub.mjs +0 -93
  51. package/scripts/exec-stub.test.mjs +0 -69
  52. package/scripts/expected-jobs-prose.test.mjs +0 -80
  53. package/scripts/fan-out-authorization-prose.test.mjs +0 -80
  54. package/scripts/filing-bar-seat-prose.test.mjs +0 -242
  55. package/scripts/filing-claim-bar-prose.test.mjs +0 -166
  56. package/scripts/finisher-died-prose.test.mjs +0 -31
  57. package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
  58. package/scripts/finisher-halt-prose.test.mjs +0 -106
  59. package/scripts/finisher-name-prose.test.mjs +0 -134
  60. package/scripts/finisher-own-tree-prose.test.mjs +0 -299
  61. package/scripts/finisher-pin-race-prose.test.mjs +0 -339
  62. package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
  63. package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
  64. package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
  65. package/scripts/fleet-bootstrap.test.mjs +0 -75
  66. package/scripts/fleet-heartbeat.test.mjs +0 -450
  67. package/scripts/fleet-provenance.test.mjs +0 -138
  68. package/scripts/fleet-run.test.mjs +0 -90
  69. package/scripts/fleet-state.test.mjs +0 -460
  70. package/scripts/fleet-tick-prose.test.mjs +0 -300
  71. package/scripts/fleet-tick.test.mjs +0 -2444
  72. package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
  73. package/scripts/frontmatter-check.test.mjs +0 -436
  74. package/scripts/git-env.test.mjs +0 -149
  75. package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
  76. package/scripts/gone-walk.test.mjs +0 -213
  77. package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
  78. package/scripts/head-moved-after-label-prose.test.mjs +0 -233
  79. package/scripts/immutable-body-claim-prose.test.mjs +0 -204
  80. package/scripts/implementer-model-tier.test.mjs +0 -235
  81. package/scripts/inflight-citation-prose.test.mjs +0 -144
  82. package/scripts/inflight-exit2-prose.test.mjs +0 -81
  83. package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
  84. package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
  85. package/scripts/inflight.test.mjs +0 -2882
  86. package/scripts/injection-control-prose.test.mjs +0 -404
  87. package/scripts/install-root-audit.test.mjs +0 -464
  88. package/scripts/instrument-check-prose.test.mjs +0 -235
  89. package/scripts/instruments.test.mjs +0 -787
  90. package/scripts/is-cli.test.mjs +0 -99
  91. package/scripts/issue-tracker-prose.test.mjs +0 -71
  92. package/scripts/json.test.mjs +0 -364
  93. package/scripts/ledger-dispatch.test.mjs +0 -927
  94. package/scripts/ledger-grammar.test.mjs +0 -227
  95. package/scripts/ledger-read-require-file.test.mjs +0 -197
  96. package/scripts/ledger-rotate.test.mjs +0 -142
  97. package/scripts/ledger.test.mjs +0 -3436
  98. package/scripts/line-distance-prose.test.mjs +0 -245
  99. package/scripts/liveness-rationale-prose.test.mjs +0 -83
  100. package/scripts/locale-pin-prose.test.mjs +0 -189
  101. package/scripts/main-checkout.test.mjs +0 -332
  102. package/scripts/member-outcome-prose.test.mjs +0 -167
  103. package/scripts/member-outcomes-header.test.mjs +0 -129
  104. package/scripts/member-outcomes-prose.test.mjs +0 -63
  105. package/scripts/member-outcomes.test.mjs +0 -638
  106. package/scripts/member-prompt-prose.test.mjs +0 -165
  107. package/scripts/member-record.test.mjs +0 -541
  108. package/scripts/member-write-guard.test.mjs +0 -214
  109. package/scripts/merge-commit-probe-prose.test.mjs +0 -122
  110. package/scripts/merge-gate.test.mjs +0 -613
  111. package/scripts/muted-git-guard-sweep.test.mjs +0 -493
  112. package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
  113. package/scripts/net-watchdog-prose.test.mjs +0 -79
  114. package/scripts/net.test.mjs +0 -211
  115. package/scripts/no-ci-gate-prose.test.mjs +0 -108
  116. package/scripts/no-undo-audit.test.mjs +0 -3961
  117. package/scripts/no-wave.test.mjs +0 -138
  118. package/scripts/node-floor-sweep.test.mjs +0 -611
  119. package/scripts/pointer-target-prose.test.mjs +0 -186
  120. package/scripts/pr-cost.test.mjs +0 -521
  121. package/scripts/pr-overlap.test.mjs +0 -692
  122. package/scripts/printf-die-sweep.test.mjs +0 -384
  123. package/scripts/prompt-renderer.mjs +0 -40
  124. package/scripts/prompt-renderer.test.mjs +0 -68
  125. package/scripts/prose-pin.mjs +0 -807
  126. package/scripts/prose-pin.test.mjs +0 -1034
  127. package/scripts/prove-merge.test.mjs +0 -995
  128. package/scripts/pull-table-relabel-prose.test.mjs +0 -60
  129. package/scripts/quiet-payload-prose.test.mjs +0 -222
  130. package/scripts/reap-cherry-check-prose.test.mjs +0 -80
  131. package/scripts/reap.test.mjs +0 -4432
  132. package/scripts/reaping-prose.test.mjs +0 -239
  133. package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
  134. package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
  135. package/scripts/recipe-derivation-prose.test.mjs +0 -112
  136. package/scripts/recipe-prove.test.mjs +0 -1042
  137. package/scripts/refuter-scratch-prose.test.mjs +0 -135
  138. package/scripts/release-label-required-prose.test.mjs +0 -71
  139. package/scripts/release-label-split-prose.test.mjs +0 -184
  140. package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
  141. package/scripts/release-ticket.test.mjs +0 -5099
  142. package/scripts/renovate-release-contract.test.mjs +0 -379
  143. package/scripts/repo-root.test.mjs +0 -873
  144. package/scripts/reporter-output-rule-prose.test.mjs +0 -208
  145. package/scripts/review-agent-report-only.test.mjs +0 -49
  146. package/scripts/review-core-booking.test.mjs +0 -35
  147. package/scripts/review-core-cwd-isolation.test.mjs +0 -374
  148. package/scripts/review-core-reads.test.mjs +0 -478
  149. package/scripts/review-core-refuter-scratch.test.mjs +0 -148
  150. package/scripts/review-core-scratch-refusal.test.mjs +0 -64
  151. package/scripts/review-core-shared-test-run.test.mjs +0 -275
  152. package/scripts/review-core-snapshot-path.test.mjs +0 -830
  153. package/scripts/review-core-specialist-scratch.test.mjs +0 -191
  154. package/scripts/review-core-testcmd.test.mjs +0 -335
  155. package/scripts/review-core-unrun.test.mjs +0 -566
  156. package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
  157. package/scripts/review-eval-resolver-path.test.mjs +0 -55
  158. package/scripts/review-host-fixture.mjs +0 -89
  159. package/scripts/review-in-run-retry.test.mjs +0 -211
  160. package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
  161. package/scripts/review-path-default.test.mjs +0 -796
  162. package/scripts/review-runner-spawns.test.mjs +0 -95
  163. package/scripts/review-runner.test.mjs +0 -166
  164. package/scripts/review-tier-audit.test.mjs +0 -140
  165. package/scripts/run-artifact-pr-prose.test.mjs +0 -341
  166. package/scripts/run-merge-bot-prose.test.mjs +0 -1413
  167. package/scripts/run-team-local-hook.test.mjs +0 -442
  168. package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
  169. package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
  170. package/scripts/section-between-guard-prose.test.mjs +0 -379
  171. package/scripts/select-dimensions.test.mjs +0 -674
  172. package/scripts/shared-refusal.test.mjs +0 -388
  173. package/scripts/shell-traps-prose.test.mjs +0 -504
  174. package/scripts/shortlist.test.mjs +0 -380
  175. package/scripts/slow-transport.mjs +0 -72
  176. package/scripts/snapshot-repo.test.mjs +0 -1006
  177. package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
  178. package/scripts/spend-view.test.mjs +0 -312
  179. package/scripts/staleness-qualifier-prose.test.mjs +0 -251
  180. package/scripts/staleness-verdict-prose.test.mjs +0 -142
  181. package/scripts/staleness.test.mjs +0 -893
  182. package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
  183. package/scripts/stash-prohibition-prose.test.mjs +0 -313
  184. package/scripts/strip-comments.mjs +0 -44
  185. package/scripts/temp-dir.mjs +0 -47
  186. package/scripts/ticket-router.test.mjs +0 -981
  187. package/scripts/tier-check.test.mjs +0 -828
  188. package/scripts/tier-outcomes-header.test.mjs +0 -518
  189. package/scripts/tier-outcomes.test.mjs +0 -572
  190. package/scripts/tier-roles.test.mjs +0 -535
  191. package/scripts/tracker-block-copy-prose.test.mjs +0 -288
  192. package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
  193. package/scripts/unattended-git-sweep.test.mjs +0 -142
  194. package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
  195. package/scripts/verify-sha.test.mjs +0 -692
  196. package/scripts/watcher-degraded-block.test.mjs +0 -369
  197. package/scripts/watcher-key-prose.test.mjs +0 -106
  198. package/scripts/within-run-pair-prose.test.mjs +0 -212
  199. package/scripts/worktree-audit.test.mjs +0 -1408
  200. package/scripts/worktree-head-prose.test.mjs +0 -276
  201. package/scripts/worktree-listing-sweep.test.mjs +0 -217
  202. package/scripts/worktree-model-prose.test.mjs +0 -216
  203. package/scripts/worktree-porcelain.mjs +0 -35
  204. package/scripts/worktree-porcelain.test.mjs +0 -102
@@ -1,1413 +0,0 @@
1
- // Pins the #170 addition to run-merge-bot.md's step 4: dropping `in-progress`
2
- // from every issue a merged PR closes. Same discipline as
3
- // issue-tracker-prose.test.mjs — a positive match on a whole file is a
4
- // vacuous pin, so this slices to step 4 alone before asserting.
5
- //
6
- // THE CEILING: this proves the phrase is PRESENT in step 4. It cannot prove
7
- // the rule is not negated by a sentence added beside it, and it does not run
8
- // the step — drop-merged-label.test.mjs owns the script's own behavior.
9
- import { test } from "node:test";
10
- import assert from "node:assert/strict";
11
- import { execFileSync, spawnSync } from "node:child_process";
12
- import { mkdtempSync, readFileSync, writeFileSync } from "node:fs";
13
- import { tempDir } from "./temp-dir.mjs";
14
- import { join } from "node:path";
15
- import { between, paragraph, phrase } from "./prose-pin.mjs";
16
-
17
- const REPO = join(import.meta.dirname, "..");
18
- const DOC = readFileSync(join(REPO, "commands", "run-merge-bot.md"), "utf8");
19
-
20
- // Bounded to step 4 alone: unbounded to EOF the slice runs through staleness,
21
- // the no-undo audit and the watcher loop, and a mention of `in-progress`
22
- // anywhere in those would satisfy the assertions with step 4 itself untouched.
23
- function step4() {
24
- const start = "4. `gh pr merge <pr> --merge`";
25
- const at = DOC.indexOf(start);
26
- assert.notEqual(at, -1, `'${start}' moved — update this test`);
27
- const rest = DOC.slice(at + start.length);
28
- const end = rest.indexOf("**Staleness fires");
29
- assert.notEqual(end, -1, "step 4's end marker moved — update this test");
30
- return start + rest.slice(0, end);
31
- }
32
-
33
- test("step 4 drops in-progress from every issue the merged PR closes", () => {
34
- assert.match(step4(), /Drop `in-progress` from every issue this PR closes/);
35
- assert.match(step4(), /drop-merged-label\.sh <pr> --apply/);
36
- });
37
-
38
- test("step 4 says a failed removal must be reported, never swallowed", () => {
39
- assert.match(step4(), /a removal failed — report it as `label-drop-failed-#<issue>`, never swallow it/);
40
- });
41
-
42
- // #2196: the bot deletes the merged head branch itself rather than leaning on
43
- // the repo's auto-delete setting, and a branch left behind is a report, not a
44
- // silence — reap.sh only ever reaps a `[gone]` branch.
45
- test("step 4 deletes the head branch itself and reports a failed delete", () => {
46
- assert.match(step4(), /delete-merged-branch\.sh <pr>/);
47
- assert.match(step4(), /report it as `branch-delete-failed-#<pr>`, never swallow it/);
48
- assert.doesNotMatch(step4(), /GitHub removes the remote branch anyway/);
49
- });
50
-
51
- // #2295: exit 3 is a deliberate keep — another open PR uses the branch — and
52
- // step 4 must say so, or a bot reads it as one more failure to report or retry.
53
- test("step 4 treats a kept branch as a keep, never a failure or a retry", () => {
54
- assert.match(step4(), /\*\*Exit 3 the branch is kept on purpose — another open PR uses it as its head or its base\*\*/);
55
- assert.match(step4(), /one `branch-kept-#<pr>` line per such PR/);
56
- assert.match(step4(), /A deliberate keep, not a failure: never retry it, and never report it as `branch-delete-failed`/);
57
- });
58
-
59
- test("the drop runs only after the merge is confirmed, never before", () => {
60
- assert.match(step4(), /call this only after the merge is confirmed/);
61
- });
62
-
63
- // #303: on `unknown` the runbook used to send the operator to `git stash list`
64
- // alone, which is empty at rc 0 in two of the three states that produce
65
- // `unknown` (measured: `chmod 000` on `refs/stash`, and on `logs/refs/stash`).
66
- // Sliced to the audit section, same discipline as step4(): it pins the text to
67
- // the section that has to carry it, so a later paragraph naming `refs/stash`
68
- // somewhere else in the doc can never stand in for this one.
69
- function noUndoAudit() {
70
- const start = "## No-undo audit (before every rebase)";
71
- const at = DOC.indexOf(start);
72
- assert.notEqual(at, -1, `'${start}' moved — update this test`);
73
- const rest = DOC.slice(at + start.length);
74
- const end = rest.indexOf("**4. Take `main`'s side wholesale");
75
- assert.notEqual(end, -1, "the audit section's end marker moved — update this test");
76
- return rest.slice(0, end);
77
- }
78
-
79
- // THE CEILING: presence of the instruction, not its correctness. The paths are
80
- // pinned as written — `--git-common-dir`, not `.git/` — because a linked
81
- // worktree's `.git` is a file and `.git/refs/stash` reaches nothing there.
82
- test("the `unknown` path sends the operator to both stash files, via the common dir", () => {
83
- // The instruction is pinned by its rule, not by a tally of the causes: the
84
- // sentence used to count them, and #482 added one, which is how a count
85
- // written into prose goes stale.
86
- assert.match(noUndoAudit(), /On `unknown` do not stop at that list: the causes git stays silent about leave it empty at rc 0/);
87
- assert.match(noUndoAudit(), /c=\$\(git rev-parse --git-common-dir\)/);
88
- assert.match(noUndoAudit(), /ls -l "\$c"\/refs\/stash "\$c"\/logs\/refs\/stash`/);
89
- assert.match(noUndoAudit(), /cat "\$c"\/logs\/refs\/stash`/);
90
- });
91
-
92
- // #482: the cause whose whole shape is that the list did NOT come back empty —
93
- // `git stash list` printed entries, then exited nonzero, and the audit answers
94
- // `unknown` instead of the number it could have counted. The runbook has to
95
- // carry both halves: that the state exists at all, since an operator who reads
96
- // `unknown` as "the list was empty" goes looking for the wrong thing, and that
97
- // git's own words are already on the audit's line, since the earlier
98
- // instruction sends them to re-read a list whose stderr they have.
99
- test("the `unknown` path names the cause where the list printed entries and then failed", () => {
100
- assert.match(noUndoAudit(), /`git stash list` printed entries and then exited nonzero, so what it printed is short/);
101
- assert.match(noUndoAudit(), /a corrupt loose object behind an entry that is not the tip does this, and the audit reports `unknown` there/);
102
- assert.match(noUndoAudit(), /the audit's own line carries that text for you/);
103
- });
104
-
105
- // `----------` alone is under-inclusive: an unreadable logs/refs DIRECTORY
106
- // (`chmod 000 .git/logs/refs`) produces the same `unknown`, but `ls` fails
107
- // before it prints a mode column — `ls: .git/logs/refs/stash: Permission
108
- // denied`, with `refs/stash` beside it at a healthy `-rw-r--r--`. Both halves
109
- // of the tell are pinned, or the second silently rots back out.
110
- test("the fault tell covers a Permission denied from `ls`, not only a `----------` mode", () => {
111
- assert.match(noUndoAudit(), /a mode of `----------` on either, or a `Permission denied` from `ls` itself, is the fault,/);
112
- });
113
-
114
- test("the `unknown` path warns that a missing refs/stash file is not an empty stash", () => {
115
- assert.match(noUndoAudit(), /A missing `refs\/stash` file is not an empty stash: `git gc` packs it into `packed-refs`/);
116
- });
117
-
118
- // Whitespace-normalized so a same-words reflow of the audit paragraph cannot
119
- // false-red these two pins: they hold the two longest spans in this file, and
120
- // the paragraph is currently one unwrapped line, so a future hard-wrap landing
121
- // inside a span is the live hazard. Scoped to the #437 pins below on purpose —
122
- // converting the file's other pins is a separate change.
123
- const flat = (s) => s.replace(/\s+/g, " ");
124
-
125
- // #437 item 3: of the four `unknown` causes, the stash-object-missing one is
126
- // the one `git stash list` itself refuses to stay silent about. Measured, git
127
- // 2.50.1: `stash list` against a repo with `rm .git/objects/<stash-sha>`
128
- // prints nothing on stdout but exits 1 with stderr `fatal: bad object
129
- // refs/stash`, while the other three causes (unreadable ref file, unreadable
130
- // reflog, absent ref beside a live reflog) are each rc 0 with no stdout and no
131
- // stderr. The doc names the cause rather than counting to it: this paragraph
132
- // already spends "the fourth" on the absent-ref/live-reflog case, so an
133
- // ordinal here would bind the same word to two members of the same set.
134
- test("the `unknown` path says the missing-object cause names itself in git's own stderr", () => {
135
- assert.match(
136
- flat(noUndoAudit()),
137
- /The missing-object cause is the one git is not silent about: `git stash list`'s own stderr there already ends `fatal: bad object refs\/stash`/,
138
- );
139
- });
140
-
141
- // #437 item 1: `git show refs/stash` recovers the entry in the states where
142
- // `ls -l`/`cat` come back with nothing — measured, git 2.50.1, over the twelve
143
- // states {staged, unstaged} x {loose, packed} x {reflog unreadable, reflog
144
- // blank, reflog removed}: `git show refs/stash` printed the `WIP on <branch>`
145
- // label in all twelve, but printed NO diff in all six staged ones, because the
146
- // stash tree equals the index-commit parent and the default `--cc` combined
147
- // diff suppresses every hunk. `git stash show -p refs/stash` printed the hunk
148
- // in all twelve, so it is the command the doc names for the content.
149
- // Both fail only where the ref FILE is the broken one — chmod 000 (`git show`
150
- // rc 128 `ambiguous argument`, `git stash show -p` rc 1) or `printf
151
- // 'not-a-sha' > refs/stash` (both, after `ignoring broken ref`) — and measured
152
- // in both of those the reflog is untouched and still names the stash SHA as
153
- // its second field, where `git stash show -p <that sha>` printed the hunk
154
- // staged or not, while `git show <that sha>` again printed none when staged.
155
- // #1055 added the third member of that enumeration: measured, git 2.50.1, `rm
156
- // refs/stash` with no `packed-refs` fails both the same way (`ambiguous
157
- // argument` / `refs/stash is not a valid reference`) while the reflog still
158
- // names the SHA, and after `git pack-refs --all` both succeed at rc 0 — so the
159
- // clause enumerates the UNPACKED absence, not absence as such.
160
- test("the `unknown` path names git show refs/stash as the recovery when the file reads come back empty", () => {
161
- assert.match(
162
- flat(noUndoAudit()),
163
- /`git show refs\/stash` still resolves the ref whether loose or packed, printing the `WIP on <branch>` label/,
164
- );
165
- assert.match(
166
- flat(noUndoAudit()),
167
- /it prints no diff beside that label when the stashed change was staged before `git stash`, so read the content with `git stash show -p refs\/stash`, which prints the hunk either way/,
168
- );
169
- assert.match(
170
- flat(noUndoAudit()),
171
- /Both fail only where the ref FILE is itself the broken one — unreadable, holding text that is not a SHA, or gone with nothing in `packed-refs` — and there the SHA `cat` already printed, in the reflog's second field, is what `git stash show -p <that sha>` recovers instead/,
172
- );
173
- });
174
-
175
- // #1055: the fallback above IS a SHA `cat` printed, so it is unavailable in the
176
- // double fault — where the premise clause ("`cat` denied") fires and the ref is
177
- // also unresolvable — and the paragraph went on offering it there. Measured,
178
- // git 2.50.1, all three shapes (`chmod 000` on `refs/stash` AND
179
- // `logs/refs/stash`; `printf 'not-a-sha' > refs/stash` plus `chmod 000` on
180
- // `logs/refs/stash`; `rm refs/stash` with no `packed-refs` plus `chmod 000`
181
- // on `logs/refs`): `git stash list` empty at rc 0, `git show refs/stash`
182
- // `ambiguous argument`, `git stash show -p refs/stash` `refs/stash is not a
183
- // valid reference`, and `cat` rc 1 printing no SHA to fall back on.
184
- //
185
- // The recovery SPLITS by shape, measured, not inferred — an earlier draft
186
- // claimed one outcome for all three, which is the defect #1055 fixed here.
187
- // `chmod 644` on the two files (`chmod 755` on an unsearchable `logs/refs`)
188
- // puts the entry straight back in `git stash list` ONLY where the ref FILE's
189
- // own content survived — the both-unreadable shape. Where the ref file's
190
- // content is itself gone or garbage, restoring the reflog's mode only makes
191
- // `cat` print the SHA again; `git stash list` stays empty at rc 0 until the
192
- // ref is re-pointed by hand: `git update-ref refs/stash <sha>` succeeds
193
- // directly once the file is gone, but on garbage text it answers `fatal: …
194
- // reference broken` even with `-d` — measured — so the file has to be `rm`'d
195
- // first either way. Once re-pointed, both land the entry as a NEW
196
- // `stash@{0}` (empty subject, the update's own reflog line) with the
197
- // recovered one pushed down to `stash@{1}`, never restored to its original
198
- // slot — measured with `git stash list` before and after `git update-ref`.
199
- //
200
- // Failing all of that, `git fsck` prints `dangling commit <sha>` per stash
201
- // entry — 3 of 3 entries in a three-stash fixture, and still with every
202
- // object packed by `repack -ad` — at rc 10 in the unreadable-ref shape while
203
- // printing them, and still at rc 0 with both files simply deleted and
204
- // nothing in `packed-refs`. `git stash show -p <that sha>` printed the hunk
205
- // there, including for an entry staged before `git stash`, refusing a
206
- // non-stash dangling commit with `is not a stash-like commit`. Its measured
207
- // limits are why the doc calls it a lead: fsck hands back no `stash@{N}`,
208
- // and an entry dropped by `git stash drop` is dangling with the same `WIP on
209
- // <branch>:` subject and the same rc 0 from `git stash show -p` as a live
210
- // one.
211
- //
212
- // `git gc --prune=now` is deliberately NOT mentioned either way: measured, it
213
- // dies `fatal: bad object refs/stash` / `failed to run repack` at rc 128 in the
214
- // unreadable-ref shape, so the obvious "recover before something prunes it"
215
- // warning would be false for the shape it reads as being about.
216
- //
217
- // Six claims pinned separately, never one span: the STATE (now three
218
- // shapes), the permission fix's SCOPE (one shape names it back outright),
219
- // the re-point recovery the other two shapes need instead, the stash@{0}/
220
- // stash@{1} shape that re-point leaves behind, the fsck lead, and the lead's
221
- // unreliability — each rots independently. Dropping the state turns the
222
- // caveat into unscoped advice; dropping the last one promotes a lead to a
223
- // listing, which is the specific rewrite this paragraph's history predicts;
224
- // widening the permission fix back across all three shapes silently
225
- // reintroduces the exact false promise #1055 corrected, which is why its
226
- // scope is pinned as a short span rather than folded into the fix
227
- // instruction's own sentence.
228
- test("the double fault leaves no ref-based recovery, and names the mode fix, the re-point fallback and the fsck lead in their place", () => {
229
- assert.match(
230
- flat(noUndoAudit()),
231
- /That fallback is a SHA `cat` printed, so it is gone where the reflog is the denied read too — both files unreadable, `refs\/stash` holding text that is not a SHA while the reflog cannot be read, or `refs\/stash` gone with nothing in `packed-refs` while the reflog cannot be read — and nothing ref-based recovers there/,
232
- );
233
- assert.match(
234
- flat(noUndoAudit()),
235
- /Only the both-files-unreadable shape then has `git stash list` name the entry again on its own/,
236
- );
237
- assert.match(
238
- flat(noUndoAudit()),
239
- /so restoring the reflog's mode only unlocks the SHA `cat` now prints; `git stash list` stays empty at rc 0 until you clear the broken ref and re-point it yourself/,
240
- );
241
- assert.match(
242
- flat(noUndoAudit()),
243
- /`git update-ref refs\/stash <that sha>` works directly once `refs\/stash` is already gone; where it instead holds garbage text, `git update-ref` refuses that too \(`reference broken`, even with `-d`\) until you `rm` the file first/,
244
- );
245
- assert.match(
246
- flat(noUndoAudit()),
247
- /Either path is measured to list the entry again as a new `stash@\{0\}` \(an empty-subject entry the update itself adds\), pushing the recovered one down to `stash@\{1\}` rather than restoring it to its original slot/,
248
- );
249
- assert.match(
250
- flat(noUndoAudit()),
251
- /`git fsck` still prints a `dangling commit <sha>` line per stash entry, objects loose or packed/,
252
- );
253
- assert.match(
254
- flat(noUndoAudit()),
255
- /refusing anything that is not a stash \(`is not a stash-like commit`\)/,
256
- );
257
- assert.match(
258
- flat(noUndoAudit()),
259
- /Treat it as a lead, not a listing: no `stash@\{N\}` comes back with it, and an entry someone dropped on purpose is indistinguishable from a live one/,
260
- );
261
- assert.match(flat(noUndoAudit()), /Restore read permission where the mode is yours to fix/);
262
- });
263
-
264
- // #376 added a fourth cause whose `ls -l` signature is the OPPOSITE of the
265
- // three above — the ref file is gone rather than unreadable, so neither the
266
- // `----------` mode nor the `Permission denied` tell fires, and an operator
267
- // reading only those two concludes the audit was wrong and rebases. The
268
- // reflog beside it is what makes the entries recoverable, so the instruction
269
- // has to name both halves: the signature, and that the SHAs are the recovery.
270
- //
271
- // Two matches, not one on the whole sentence, and `\s+` between the words: a
272
- // single literal spanning the clause reds on a pure reflow or on bolding
273
- // `fourth cause` in place, neither of which changes what it guards. Measured —
274
- // the first draft of this pin did exactly that.
275
- test("the fourth cause — an absent refs/stash beside a live reflog — is named with its own ls signature", () => {
276
- assert.match(noUndoAudit(), /`No\s+such\s+file\s+or\s+directory`\s+for\s+`refs\/stash`\s+alone/);
277
- assert.match(noUndoAudit(), /recover\s+from\s+the\s+SHAs\s+`cat`\s+prints,\s+do\s+not\s+rebase\s+over\s+it/);
278
- });
279
-
280
- // #149: step 1 used to rebase locally and `git push --force-with-lease`,
281
- // denied unpredictably by the auto-mode classifier — 2 allowed / 2 denied on
282
- // byte-identical invocations in one session — sometimes stranding a rebased
283
- // head that never reached the remote, so `gh pr merge` landed the stale one.
284
- // settings.json has carried an `autoMode.allow` entry for that exact command
285
- // since 1dadc5d, so adding one is not the fix for a denial here; the classifier
286
- // judges per invocation. Step 1 now rebases server-side first: an API call, not
287
- // a push, so the classifier is never consulted for it.
288
- //
289
- // THE CEILING: same as step4() above — presence, not correctness, and not
290
- // that the fallback runs the way it's written.
291
- function step1() {
292
- const start = "1. If the PR is behind";
293
- const at = DOC.indexOf(start);
294
- assert.notEqual(at, -1, `'${start}' moved — update this test`);
295
- const rest = DOC.slice(at + start.length);
296
- const end = rest.indexOf("2. Watch checks settle");
297
- assert.notEqual(end, -1, "step 1's end marker moved — update this test");
298
- return start + rest.slice(0, end);
299
- }
300
-
301
- test("step 1 rebases server-side first, not with a local force-push", () => {
302
- assert.match(step1(), /`gh pr update-branch <pr> --rebase`/);
303
- assert.match(step1(), /no local git command runs/);
304
- });
305
-
306
- test("step 1 falls back to a local, unpushed rebase when the server-side path can't run", () => {
307
- assert.match(step1(), /a real conflict, or `allow_update_branch` off/);
308
- assert.match(step1(), /Rebase locally, for verification only — this rebase never needs to reach the remote/);
309
- assert.match(step1(), /Report this path as `rebase-fallback-#<pr>`/);
310
- });
311
-
312
- // #408: a controller once told its merge bot to prove a post-rebase stale
313
- // worktree safe with `git cherry origin/main HEAD` — trivially `+` for any
314
- // unmerged PR, since main never had the PR's commits merged rebase or not.
315
- // Measured directly (two local clones, one simulating the server-side rebase
316
- // the other never sees) before writing this: origin/<branch> reads `-`
317
- // (nothing unique), origin/main reads `+` on the identical stale HEAD.
318
- test("step 1 names the correct upstream for proving a post-rebase worktree stale but safe", () => {
319
- assert.match(step1(), /`git cherry origin\/<branch> HEAD`/);
320
- assert.match(step1(), /\*\*not\*\* `git cherry origin\/main HEAD`/);
321
- });
322
-
323
- // #447. The probe above told the bot to run `git cherry` and then stopped:
324
- // neither result had an instruction, on the path that is now the default. Two
325
- // separate rots follow from that, and each is pinned to its own contiguous
326
- // string rather than to a word appearing somewhere in step 1.
327
- //
328
- // (a) The ORDERING must ride in the same sentence as the command. Step 4
329
- // deletes the remote branch once the PR lands (#2196), so `origin/<branch>`
330
- // stops existing at the merge and a probe run afterwards dies on a missing ref —
331
- // which reads like the divergence it was meant to rule out. A constraint
332
- // parked in a later paragraph is one a reader can reach the command without
333
- // having read, so the assertion below spans command and constraint as one
334
- // literal run of text and reds if they are split apart.
335
- test("step 1's staleness probe carries its ordering constraint in the same sentence as the command", () => {
336
- assert.match(
337
- step1(),
338
- /run `git cherry origin\/<branch> HEAD` from the worktree \*\*before the merge, never after\*\*/,
339
- );
340
- // the reason, without which the constraint is an unexplained rule
341
- assert.match(step1(), /step 4 deletes the remote branch once the PR lands/);
342
- assert.match(step1(), /fails on a missing ref/);
343
- });
344
-
345
- // (b) The OUTCOME. `+` must be answered on the server-side path, and answered
346
- // with the structural reason — the path rebases through the API and pushes
347
- // nothing, and step 4 merges the remote head, so an unpushed local commit
348
- // cannot enter the merge. The reason is pinned with the verdict on purpose: a
349
- // bare "no STOP here" is exactly the sentence a later reader would delete for
350
- // looking unjustified.
351
- test("step 1 answers a `+` on the server-side path, with the structural reason", () => {
352
- assert.match(step1(), /Neither result halts this path/);
353
- assert.match(step1(), /this step rebases through the API and pushes nothing/);
354
- assert.match(step1(), /structurally unable to enter the merge/);
355
- });
356
-
357
- // (c) WHICH output is clean. An earlier draft of this paragraph called silence
358
- // the clean answer, which is false for the case the paragraph is about:
359
- // git-cherry emits a line per commit in `origin/<branch>..HEAD` and marks a
360
- // patch-equivalent one `-` rather than dropping it, so a worktree that has
361
- // fetched the rebase reads all-`-` and only an un-fetched one reads nothing
362
- // (measured 2026-08-29 against real git — scratch repo, branch rebased onto an
363
- // advanced main and force-pushed, clone left at the pre-rebase head; nothing
364
- // before that clone fetched, a `-` per rebased commit after, a `+` in both
365
- // once an unpushed commit was added). Pinned to the rule, not to the shape of
366
- // either listing: `+` is the signal, its absence is clean.
367
- test("step 1 defines the probe's clean answer by the absence of `+`, not by silence", () => {
368
- assert.match(step1(), /The clean answer is the absence of a `\+`, not the absence of output/);
369
- assert.match(step1(), /one that has fetched reads `-` for every rebased commit\. Both are clean/);
370
- });
371
-
372
- // The other half of (b), and the one that costs real work if it rots: the new
373
- // wording must NOT license skipping the STOP where the hazard is real. The
374
- // verdict and the identifier are pinned here, inside the block that carries
375
- // them; the RATIONALE gets its own tighter slice below, because the two rot
376
- // independently — #1038 corrected a false reason while the verdict stayed
377
- // right, and a pin holding both in one span cannot tell those apart.
378
- //
379
- // Sliced to the fallback, not to step 1: the server-side paragraph discusses
380
- // this same STOP, so a step1()-wide assertion stayed green with the bullet
381
- // gutted (measured by mutation, 2026-08-29).
382
- function fallbackBlock() {
383
- const start = "**Fallback (server-side rebase unavailable).**";
384
- const at = DOC.indexOf(start);
385
- assert.notEqual(at, -1, `'${start}' moved — update this test`);
386
- const rest = DOC.slice(at + start.length);
387
- const end = rest.indexOf("2. Watch checks settle");
388
- assert.notEqual(end, -1, "the fallback block's end marker moved — update this test");
389
- return start + rest.slice(0, end);
390
- }
391
-
392
- test("the fallback's diverged-worktree STOP survives the primary path's `+` answer", () => {
393
- assert.match(fallbackBlock(), /\*\*Worktree ahead\*\* → STOP, report `worktree-diverged-#<pr>`/);
394
- });
395
-
396
- // The same false mechanism stated a third time, in the sentence that sends the
397
- // bot to compare the two heads at all — "the rebase would carry an unreviewed
398
- // local commit into the merge". Pinned positively in its own paragraph.
399
- const headCheck = () =>
400
- paragraph(DOC, "**Confirm the worktree head", "run-merge-bot.md's fallback head check");
401
-
402
- test("the fallback's head check states the mismatch as a corrupted verification, not a push into the merge", () => {
403
- assert.match(
404
- headCheck(),
405
- phrase("the rebase would fold an unreviewed local commit into the tree you verify, while the merge takes the remote head without it"),
406
- );
407
- });
408
-
409
- // #1512. The fallback's head check read `gh pr view <pr> --json headRefOid` as
410
- // its SOLE comparison operand — the one field that lags the branch ref it is
411
- // meant to describe, which is why step 1's own poll was moved off it (#903)
412
- // and why the phase-1 dispatch site was moved off it (#1168). Both failure
413
- // directions are live at this site: a false `worktree-diverged` STOP on a
414
- // just-rebased worktree, and — the half that ships — a false EQUAL, because a
415
- // worktree unfetched since the rebase and a PR object lagging the rebase hold
416
- // the SAME pre-rebase sha, so the two stale values agree and the fallback
417
- // verifies a tree the remote no longer has.
418
- //
419
- // These pins hold WHICH SOURCE the check turns on, not that a comparison
420
- // exists. Measured: with the operand swapped, this file was 48/48 green on
421
- // both the pre-fix and post-fix doc — `rev-parse HEAD` survives the swap, the
422
- // `headRefOid` command survives in the block as the recorded diagnostic, and
423
- // every arm's wording is unchanged. That is the shape the pins above cannot
424
- // tell apart, and the reason these are mappings and bounded negatives rather
425
- // than presences.
426
- //
427
- // MUTATION RECORD — #1512, scratch-copy method (`cp -R plugin/` to a tmp dir,
428
- // mutate the copy, `node --test` the copy, read counts, discard; one mutant
429
- // per copy, so the real checkout is never the subject). 18 semantic mutants,
430
- // 9 controls, run against this file's 56 tests. 17 of 18 red, every red a
431
- // true positive naming the pin whose claim was actually lost:
432
- //
433
- // The `ls-remote` line deleted from the command block; the block's "NOT the
434
- // gate" comment reverted to the old one; the compare rule's re-admitting
435
- // clause in all three wordings (naming `headRefOid` with and without
436
- // "against", and naming "the PR object's head" with neither); the empty-read
437
- // clause rewritten to fall back to the PR object; the `Equal` arm rewritten
438
- // to accept either source; the one-re-read bound deleted; the refusal flipped
439
- // to "take the newer reading and proceed"; the `Equal`-is-unreachable clause
440
- // deleted; the fail-open clause deleted; the settle-window clause deleted;
441
- // the `rev-parse origin/<branch>` prohibition deleted; the arm-discriminator
442
- // paragraph deleted; the false-EQUAL clause deleted. Reverting the whole
443
- // block to its pre-#1512 form reds 7.
444
- //
445
- // THE SURVIVOR, recorded rather than patched — see the count guard's own
446
- // ceiling note: a re-admitting clause naming neither `headRefOid` nor
447
- // "against" ("the PR object's value is also fine to use here") passes both
448
- // counts, and is denied only by the block and the arms, which is where the
449
- // instruction is actually executed.
450
- //
451
- // Controls all stayed 56/56 green: the compare rule rewrapped at 80 columns,
452
- // the re-read paragraph at 70, the fail-open paragraph at 90 and the arm
453
- // discriminator at 75; the unpinned measurement sentence reworded with
454
- // different shas and a different git version; the unpinned "costing a pass"
455
- // tail and the unpinned re-read rationale reworded; the block's operand
456
- // comment reworded; and the out-of-scope `Worktree behind` arm's TRAILING
457
- // SENTENCE reworded, its bolded head left untouched — that is the mutant
458
- // that stayed green. Rewording the bolded head instead reds two tests this
459
- // record does not own: the `arms()` test above, which pins
460
- // "`**Worktree behind, or no worktree at all** → not a divergence`"
461
- // verbatim, and the pre-existing `stopArm()` slice below, whose end bound is
462
- // the literal string "- **Worktree behind". The pins refuse operand drift,
463
- // not layout, and a tail-only reword of that arm does not reach them —
464
- // its bolded head is owned by tests outside this record.
465
-
466
- // The runnable half. A revert deletes the `ls-remote` line from the block, and
467
- // the three-line block is the only place the operator is handed commands, so
468
- // this is the one pin a revert cannot route around by rewording prose. Bounded
469
- // to the block: `git ls-remote` recurs through step 1 above and `headRefOid`
470
- // recurs through the whole file.
471
- const headBlock = () =>
472
- between(
473
- DOC,
474
- "git -C <worktree> rev-parse HEAD",
475
- "**Compare the worktree head",
476
- "run-merge-bot.md's fallback head-check command block",
477
- );
478
-
479
- test("the fallback reads the branch ref, and marks the PR-object read as not the gate", () => {
480
- assert.match(headBlock(), phrase("git ls-remote origin refs/heads/<branch> | cut -f1"));
481
- // The demotion travels with the command, not only in prose three paragraphs
482
- // down: a reader who runs the block and stops reading must still not take
483
- // `headRefOid` for the verdict.
484
- assert.match(headBlock(), phrase("gh pr view <pr> --json headRefOid -q .headRefOid"));
485
- assert.match(headBlock(), phrase("NOT the gate"));
486
- });
487
-
488
- // The operand as a MAPPING — which source the worktree head is compared
489
- // AGAINST. The positive clause and the prohibition fail independently: a
490
- // mutant that names the ref while leaving `headRefOid` admissible reds on the
491
- // prohibition, one that drops the ref entirely reds on the mapping.
492
- //
493
- // `git rev-parse origin/<branch>` is the false fix waiting beside the real
494
- // one, and the reason it is pinned separately: a reader who learns only "not
495
- // the PR object" reaches for the local remote-tracking ref, which is the very
496
- // value a stale worktree was cut from — it agrees by construction and passes
497
- // every tree the check exists to catch. #1168 pinned the same prohibition at
498
- // the sibling site for the same reason.
499
- const compareRule = () =>
500
- paragraph(DOC, "**Compare the worktree head", "run-merge-bot.md's fallback compare rule");
501
-
502
- test("the fallback compares against the branch ref, and forbids both cheaper operands", () => {
503
- assert.match(compareRule(), phrase("Compare the worktree head against the branch REF"));
504
- assert.match(
505
- compareRule(),
506
- phrase("never against `gh pr view <pr> --json headRefOid -q .headRefOid`"),
507
- );
508
- assert.match(compareRule(), phrase("Never `git rev-parse origin/<branch>` either"));
509
- assert.match(compareRule(), phrase("agrees with it by construction"));
510
- assert.match(compareRule(), phrase("never the operand this check turns on"));
511
- });
512
-
513
- // COUNT guard, and the ceiling on the presences above. Every assertion in
514
- // that test is a presence, so a mutant that keeps all five verbatim and
515
- // appends one clause re-admitting the PR object satisfies every one of them:
516
- // measured, "…never the operand this check turns on — though where the ref
517
- // read is awkward, comparing against `headRefOid` is acceptable." left this
518
- // file 55/55 green. #1168 measured three mutants of exactly this class
519
- // escaping its own literal negative at the sibling site, and answered with a
520
- // count; this is that answer, over the two tokens such a clause has to use.
521
- //
522
- // Both counts are the paragraph AS WRITTEN. `headRefOid` is 3, not 2 — the
523
- // prohibition spells the whole command, so `--json headRefOid -q .headRefOid`
524
- // is two of them, and "The `headRefOid` read stays" is the third. `against`
525
- // is 2: the mapping and the prohibition. A re-admitting clause has to add one
526
- // or the other, whichever way it is worded.
527
- //
528
- // THE CEILING, measured rather than assumed: a clause that names neither
529
- // token — "the PR object's head is also acceptable here" — passes both counts.
530
- // What denies it is not this test but the block and the arms: the compare
531
- // rule is prose, while `headBlock()` pins the commands the operator actually
532
- // runs and `arms()` pins the place the verdict is actually taken, and neither
533
- // admits the field. A doc mutated that way contradicts itself in one
534
- // paragraph and still routes the reader to the ref.
535
- test("no second operand is admitted beside the branch ref", () => {
536
- assert.equal(
537
- (compareRule().match(/headRefOid/g) ?? []).length,
538
- 3,
539
- "the compare rule names headRefOid a fourth time — a re-admitting clause, under some wording the presences above all satisfy",
540
- );
541
- assert.equal(
542
- (compareRule().match(/\bagainst\b/g) ?? []).length,
543
- 2,
544
- "a third compared-against clause entered the compare rule — the operand is no longer the ref and nothing else",
545
- );
546
- });
547
-
548
- // MAPPING guard, ceiling on the pin above. The prohibition is a presence pin,
549
- // so a mutant that keeps it verbatim and re-admits the field through a second
550
- // clause satisfies it — #1168 measured three such mutants escaping its own
551
- // literal `doesNotMatch` at the sibling site. Two bounded negatives close the
552
- // two places such a clause can live and still be obeyed.
553
- //
554
- // The empty-read clause is the first: "if the ref reads empty, use
555
- // `headRefOid` instead" is the exception that reinstates the whole defect,
556
- // and is exactly the mutant that escaped at the sibling site. This slice is
557
- // that clause alone, where the PR object has no legitimate business at all.
558
- const emptyReadClause = () =>
559
- between(
560
- DOC,
561
- "**An empty ref read is neither equal nor a mismatch**",
562
- "**Why the ref and not",
563
- "run-merge-bot.md's fallback empty-ref-read clause",
564
- );
565
-
566
- test("an unreadable ref refuses, and never falls back to the PR object", () => {
567
- assert.match(emptyReadClause(), phrase("report the ref as unreadable and stop, `blocked`"));
568
- assert.doesNotMatch(
569
- emptyReadClause(),
570
- /headRefOid/,
571
- "the empty-ref-read clause hands the verdict to the PR object — the exception that reinstates the defect",
572
- );
573
- });
574
-
575
- // The arms are the second place. They are where the verdict is actually
576
- // taken, so a `headRefOid` named inside one ("**Equal** — against the ref or
577
- // the PR head — → proceed") is the operand back, under a wording no literal
578
- // negative above covers. The arms name no source today and need none: the
579
- // paragraphs above resolve the operand before the reader reaches them.
580
- const arms = () =>
581
- between(DOC, "- **Equal** → proceed.", "**Plain `git fetch origin` only", "run-merge-bot.md's fallback arms");
582
-
583
- test("no arm of the fallback names the PR object as a thing to compare against", () => {
584
- assert.doesNotMatch(
585
- arms(),
586
- /headRefOid/,
587
- "an arm names headRefOid — the verdict turns on the PR object again, whatever the paragraphs above say",
588
- );
589
- // Runs with the positives that make the negative mean something: a
590
- // `doesNotMatch` alone is satisfied by arms that were deleted.
591
- assert.match(arms(), phrase("**Equal** → proceed."));
592
- assert.match(arms(), phrase("**Worktree ahead** → STOP"));
593
- assert.match(arms(), phrase("**Worktree behind, or no worktree at all** → not a divergence"));
594
- });
595
-
596
- // The fail-open half, and the whole reason the OPERAND moved rather than the
597
- // verdict gaining a settle window. Without it a reader is left with the false
598
- // refusal alone — the cheap, visible half — and re-derives the settle-window
599
- // remedy #1168's own ticket proposed, which fires only where the two operands
600
- // disagree and so never reaches the pair that agrees. Pinned because that
601
- // re-derivation restores the hole while looking like a fix.
602
- //
603
- // THE CEILING: the measurement sentence beside these clauses is deliberately
604
- // unpinned — it is one run's reading at a sibling site, and re-measuring must
605
- // not turn a test red.
606
- const whyRef = () => paragraph(DOC, "**Why the ref and not", "run-merge-bot.md's fallback fail-open rationale");
607
-
608
- test("the fallback says the PR-object compare fails open too, and that a re-read cannot fix it", () => {
609
- assert.match(whyRef(), phrase("both operands go stale in the SAME direction"));
610
- assert.match(whyRef(), phrase("fails OPEN as readily as it fails closed"));
611
- assert.match(whyRef(), phrase("the check reads **Equal**"));
612
- assert.match(
613
- whyRef(),
614
- phrase("Re-reading `headRefOid` on a settle window does not reach that half at all"),
615
- );
616
- });
617
-
618
- // The remedy for a mismatch and its bound, in one paragraph but four clauses
619
- // that fail independently:
620
- //
621
- // - no re-read at all, and a ref that moved mid-verification is read once
622
- // and acted on as a divergence;
623
- // - no bound, and the same instruction reads as "fetch until it agrees" —
624
- // the unbounded loop step 1 already had to be written out of once, and
625
- // the shape this doc forbids by name elsewhere;
626
- // - no refusal, and a head that moved during verification proceeds on an
627
- // audit of a tree that is gone;
628
- // - no `Equal`-is-unreachable clause, and the surviving mismatch can still
629
- // be let through as equal, which is #1512's own defect restored one
630
- // paragraph later than where it was removed.
631
- const reRead = () => paragraph(DOC, "**Unequal → `git fetch origin`", "run-merge-bot.md's fallback bounded re-read");
632
-
633
- test("a mismatch is re-read exactly once, then refused rather than waited out", () => {
634
- assert.match(reRead(), phrase("`git fetch origin` and read the ref once more"));
635
- assert.match(reRead(), phrase("Bounded at one re-read, never a third"));
636
- assert.match(reRead(), phrase("refuse: report `head-moved-after-label-#<pr>` and stop"));
637
- assert.match(reRead(), phrase("Do not read a third time"));
638
- assert.match(
639
- reRead(),
640
- phrase("**`Equal` is not among the outcomes a surviving mismatch can reach**"),
641
- );
642
- });
643
-
644
- // The consequence of the operand swap that the swap alone does not settle.
645
- // Against `headRefOid` the stale-plus-lagging worktree read EQUAL and never
646
- // reached the arms; against the ref it reaches them, and the arms are labelled
647
- // ahead/behind — a linear vocabulary the case does not fit, because a rebase
648
- // orphans the pre-rebase head, so the ref does not carry the worktree's
649
- // commits BY SHA even though it carries every patch in them. Read literally,
650
- // "commits the ref lacks" sends a worktree holding no work of its own to the
651
- // STOP: the false refusal, re-entering through the arm labels after being
652
- // removed from the operand. The discriminator is `git cherry`, which this
653
- // step already established two paragraphs up, and pinning it is what keeps
654
- // the arms' unchanged behaviour actually reachable.
655
- const armRouting = () => paragraph(DOC, "**Ahead or behind is", "run-merge-bot.md's fallback arm discriminator");
656
-
657
- test("which arm a surviving mismatch takes is decided by patch equivalence, not by the sha compare", () => {
658
- assert.match(armRouting(), phrase("`git cherry origin/<branch> HEAD` from the worktree"));
659
- assert.match(armRouting(), phrase("not the sha compare"));
660
- assert.match(armRouting(), phrase("a `+` → ahead; no `+` → behind"));
661
- });
662
-
663
- // #1038's AC-4 is a property of the whole block, not of the two sentences that
664
- // carried the false claim: no sentence in the fallback may say a local commit
665
- // reaches the remote. The three positive pins cover the spans it was written
666
- // in; this sweeps the rest, which is what catches a restore that lands in a
667
- // paragraph nobody pinned. The negative runs with the property that MAKES it
668
- // true on the same slice — the rebase is verification-only — because a bare
669
- // `doesNotMatch` also passes on a slice that no longer says anything at all.
670
- test("no sentence in the fallback claims the local rebase can carry a commit into the merge", () => {
671
- assert.match(
672
- fallbackBlock(),
673
- phrase("Rebase locally, for verification only — this rebase never needs to reach the remote"),
674
- );
675
- assert.doesNotMatch(fallbackBlock(), /carry[\s\S]{0,60}into the merge/);
676
- });
677
-
678
- // #1038. The STOP's verdict was right and its stated REASON was false: it
679
- // justified halting because an unpushed commit is one "your rebase would
680
- // carry into the merge", and the fallback contains no `git push`, no
681
- // `--force` and no `--force-with-lease` at all. A refuter ran the documented
682
- // sequence in a fixture: the unpushed commit appeared in neither the merge
683
- // commit's ancestry nor its tree, while a control that pushed the rebased
684
- // head did land it. The real hazard is the silent one — the fallback verifies
685
- // the LOCAL rebased head, so a commit only the worktree holds moves the
686
- // verified tree off the reviewed head and every green is measured against a
687
- // tree no merge will take.
688
- //
689
- // Why the reason is load-bearing and not decoration: a bot that reasons from
690
- // the old sentence, then observes that the fallback never pushes, can
691
- // correctly conclude the stated hazard does not apply and proceed — the wrong
692
- // action, reached from the page's own text. So the premise, the polarity
693
- // clause and the wrong-tree clause are each pinned positively here, and the
694
- // old reason's SHAPE is swept for one test above, over the whole fallback:
695
- // a restore that replaces the corrected sentences reds these pins, while one
696
- // that leaves both wordings standing — the two-sites-disagreeing shape this
697
- // ticket exists to end — reds the sweep alone.
698
- //
699
- // Sliced to the arm itself, not to the whole fallback: `worktree-diverged`,
700
- // the remote head and what gets verified all recur through the block's later
701
- // paragraphs, and the sibling `Worktree behind` arm is the end bound, so a
702
- // rationale lifted out of the bullet into prose below it reds here.
703
- //
704
- // MUTATION RECORD — #1038, scratch-copy method (`cp -R plugin/` to a tmp dir,
705
- // mutate the copy, `node --test` the copy, read counts, discard; one mutant
706
- // per copy, so the real checkout is never the subject). 16 semantic mutants,
707
- // 8 controls, run against this file's 44 tests. Every mutant reds, and every
708
- // red is a true positive:
709
- //
710
- // Red exactly one pin, the right one — the STOP rationale deleted; its
711
- // polarity flipped to "can enter the merge"; the wrong-tree clause deleted;
712
- // the rationale lifted out of the bullet into a paragraph below the arms (the
713
- // slice bound); the fix-agent premise deleted; the verdict and identifier
714
- // dropped (reds the verdict test alone, not the rationale one); the head
715
- // check's verification clause softened to "the heads differ"; the old reason
716
- // re-added BESIDE the corrected one at either site (reds the sweep alone);
717
- // and each of the server-side paragraph's two corrected clauses deleted.
718
- // Restoring the old reason by REPLACEMENT at either site reds two — that
719
- // site's positive pin and the sweep — as does deleting the verification-only
720
- // property, which reds the sweep and step 1's own fallback test.
721
- //
722
- // Controls all stayed 44/44 green: the STOP arm rewrapped at 80 columns, the
723
- // premise at 60, the head check and the server-side paragraph at 70, the
724
- // three unpinned sentences reworded (the silent-failure tail, the `+`-report
725
- // tail, the head-check heading), and the sibling `Worktree behind` arm
726
- // reworded — the pins refuse drift, not layout, and they do not reach the
727
- // arm the ticket put out of scope.
728
- const stopArm = () =>
729
- between(DOC, "- **Worktree ahead**", "- **Worktree behind", "run-merge-bot.md's fallback arms");
730
-
731
- test("the STOP halts on verification against the wrong tree, not on a commit carried into the merge", () => {
732
- // the premise the old assertion carried on its true half: WHAT produces the
733
- // divergence. Retained here, or correcting the reason would quietly drop it.
734
- assert.match(stopArm(), phrase("leaves an unpushed, unreviewed commit that a clean-tree audit passes"));
735
- assert.match(
736
- stopArm(),
737
- phrase("Nothing on this path pushes, so that commit cannot enter the merge — what it corrupts is the verification"),
738
- );
739
- assert.match(
740
- stopArm(),
741
- phrase("both the `origin/main...HEAD` diff and the suite run against a tree that is not the reviewed head"),
742
- );
743
- });
744
-
745
- // The second site, and the reason a one-sentence fix would have been worse
746
- // than the defect: the server-side paragraph did not merely omit the
747
- // correction, it LAUNDERED the false reason — it told the reader that "your
748
- // rebase would carry into the merge" names a hazard belonging to the fallback
749
- // "where it still applies". Fix the STOP alone and that sentence stays on the
750
- // page insisting the wrong reason is right, one paragraph above the bullet
751
- // that now disagrees with it. Pinned inside the paragraph that carries the
752
- // cross-reference, so the two sites cannot drift apart again in silence.
753
- const plusOutcome = () =>
754
- paragraph(DOC, "**Neither result halts this path", "run-merge-bot.md's `+` outcome paragraph");
755
-
756
- test("the server-side paragraph routes no carry-into-the-merge rationale to the fallback", () => {
757
- assert.match(plusOutcome(), phrase("neither path can carry a local commit to the remote, because neither pushes"));
758
- assert.match(
759
- plusOutcome(),
760
- phrase("so a commit only the worktree holds makes the verified tree something other than the reviewed head"),
761
- );
762
- assert.doesNotMatch(plusOutcome(), /carry[\s\S]{0,60}into the merge/);
763
- });
764
-
765
- // #447 AC-3, and the reason this pin reaches across files: run-team's failure
766
- // table promised `worktree-diverged-#<pr>` for "the worktree ahead of the PR
767
- // head" with no path qualifier, while the halt itself lives only in the
768
- // fallback. Whichever file is edited alone, the other goes back to lying.
769
- const RUN_TEAM = readFileSync(join(REPO, "skills", "run-team", "SKILL.md"), "utf8");
770
-
771
- // Sliced to the failure table alone. Unbounded, `worktree` and `fallback` both
772
- // occur freely elsewhere in a file thousands of lines long.
773
- function failureTable() {
774
- const start = "## Failure handling";
775
- const at = RUN_TEAM.indexOf(start);
776
- assert.notEqual(at, -1, `'${start}' moved — update this test`);
777
- const rest = RUN_TEAM.slice(at + start.length);
778
- const end = rest.indexOf("A red PR never silently becomes");
779
- assert.notEqual(end, -1, "the failure table's end marker moved — update this test");
780
- return rest.slice(0, end);
781
- }
782
-
783
- test("run-team scopes the diverged-worktree row to the fallback, not to every merge path", () => {
784
- assert.match(
785
- failureTable(),
786
- /\| Merge bot finds the worktree ahead of the PR head \*\*on the local-rebase fallback\*\* \|/,
787
- );
788
- });
789
-
790
- // #903: the poll read `gh pr view <pr> --json headRefOid` — the one field that
791
- // desyncs from the branch it is meant to be watching. Measured on this repo:
792
- // `gh pr update-branch --rebase` landed and moved the ref to 221f4e9 while
793
- // headRefOid stayed on the pre-rebase 8bc2cc4 with no CI run on the new head,
794
- // so the poll read a landed rebase as un-landed for all 60 iterations and fell
795
- // through to the local-rebase fallback — which would have replayed commits the
796
- // remote already carried. Both halves pinned: the ref read must be PRESENT, and
797
- // the sentence naming which source is authoritative must survive with it. The
798
- // second assert is what stops a future edit reverting the mechanism while
799
- // leaving a now-lying rationale behind.
800
- test("step 1 polls the branch ref, not the PR object's head", () => {
801
- // anchored to the POLL assignment inside the loop, not to any ls-remote in
802
- // step 1 — the `pre=` line uses the same command, so a bare presence match
803
- // stays green when only the loop body is reverted. Measured: it did.
804
- assert.match(step1(), /\n\s+post=\$\(git ls-remote origin "\$ref" \| cut -f1\)/);
805
- assert.match(step1(), /\*\*Poll `git ls-remote`, not `gh pr view headRefOid`\*\*/);
806
- // The DETECTOR, not just the fix. Both prose rules above describe a `pr_head`
807
- // field the printf has to actually emit, so deleting it leaves the doc
808
- // describing a field it no longer prints. Measured: with only the two asserts
809
- // above, deleting the printf field left this file 15/15 and the suite
810
- // 1155/1155, byte-identical to baseline. Bare /pr_head/ and /headRefOid/
811
- // matches were measured green on that same mutant too — `headRefOid` survives
812
- // in the headline and in "Keep the `headRefOid` read", and `pr_head` in the
813
- // desync verdict and the `<pr_head>` ancestry command — so both are anchored
814
- // to their own line here. #1895 moved the rebase call's own output onto the
815
- // fire block's report, so this line ends at `pr_head`.
816
- assert.match(step1(), /\n\s+printf 'rc=%s branch=%s pre=%s post=%s pr_head=%s\\n'/);
817
- // #910: the field is the re-poll's result, never a read of its own. This
818
- // line used to carry an inline `"$(gh pr view <pr> --json headRefOid -q
819
- // .headRefOid)"`, a single read of the PR object taken in the instant the
820
- // ref poll broke, which is the lag window the settle paragraph measures.
821
- // Anchored to its own line like the format string above: `pr_head` recurs
822
- // through step 1, so a bare match survives the inline read being restored.
823
- assert.match(step1(), /\n\s+"\$pr_head"\n/);
824
- });
825
-
826
- // The settle-window paragraph is bracketed in the doc by two rules that ARE
827
- // pinned — the test above anchors the headline naming which source is
828
- // authoritative, the ancestry test further below the precondition — and
829
- // neither reaches the paragraphs between them. That gap is the shape #1147 was
830
- // scored for in this branch's own tier row: every explanatory sentence around a
831
- // mandate pinned, the mandate itself left bare, so inverting it to "either is
832
- // fine" costs nothing. Measured against the doc as it stood before this test
833
- // existed: inverting the imperative to "report the desync on the first
834
- // `headRefOid` read … without any re-poll or cap", deleting the whole
835
- // paragraph, and reverting the prose hunk outright each left the whole suite
836
- // green. So this anchors the two imperative clauses and nothing else. The other
837
- // two paragraphs in the narrower settle-window-to-ancestry stretch — the empty
838
- // `pr_head` and the surviving desync — are pinned by the tests that follow it
839
- // (#1948), so no paragraph from the settle window to the ancestry rule is bare
840
- // now. The wider #1147 gap this paragraph opens with (headline to ancestry)
841
- // still holds other unpinned paragraphs outside that stretch — #1948's own
842
- // scope stops at the settle window and the surviving desync, not the whole gap.
843
- //
844
- // The clauses are split because they fail independently: dropping "on the same
845
- // bounded cap" turns a bounded re-poll into an unbounded one while the "only if"
846
- // clause still reads correctly, and dropping "only if … runs out" restores the
847
- // single-read verdict while the re-poll instruction still stands.
848
- //
849
- // THE CEILING: the surrounding measurement sentence is deliberately unpinned —
850
- // it reports one run's observed attempt numbers and wall clocks, and re-measuring
851
- // must not turn a test red.
852
- test("step 1 re-polls before calling a desync, and that mandate is pinned", () => {
853
- assert.match(
854
- step1(),
855
- /re-poll `headRefOid` on the same bounded cap you already use for `ls-remote`/,
856
- );
857
- assert.match(
858
- step1(),
859
- /report the desync only if `pr_head` is still on `pre` when that cap runs out/,
860
- );
861
- });
862
-
863
- // #1946 added the third outcome of that re-poll: `pr_head` still EMPTY when
864
- // the cap runs out. It landed between the settle-window paragraph and the
865
- // desync verdict with no pin, and #1948 measured the whole file green with the
866
- // paragraph deleted and with its imperative inverted to fold the empty read
867
- // into the desync and feed it to the ancestry check. Three clauses, each
868
- // failing alone:
869
- //
870
- // - no "unreadable" report, and the empty read has no row of its own;
871
- // - the "rather than folding it into" negation split from the "either the
872
- // desync above or the landed row" list it governs, and the empty read
873
- // gets filed as one of the two outcomes it is neither of — measured: two
874
- // independent presence asserts here (one per side) both stayed green
875
- // when "rather than folding it into" was reworded to "then fold it
876
- // into", the exact inversion the test title forbids. Bound to one
877
- // contiguous span instead so the negation and its list cannot drift
878
- // apart;
879
- // - no ancestry refusal, and `git merge-base --is-ancestor` is run with an
880
- // empty operand, which has no head in it to place.
881
- //
882
- // Bounded by `paragraph()`, not `step1()`: step 1 runs ~60 lines through the
883
- // fallback, and a copy of any of these clauses there would hold a step-1 pin
884
- // green with this paragraph gone. Matched through `phrase()`, so a rewrap
885
- // stays green. THE CEILING: the paragraph's rationale — why an empty value only
886
- // proves the LAST read failed — is deliberately unpinned; it can be reworded
887
- // freely.
888
- const emptyPrHead = () =>
889
- paragraph(DOC, "**`pr_head` still empty once the re-poll cap runs out", "run-merge-bot.md step 1 empty pr_head");
890
-
891
- test("step 1 reports a pr_head still empty after the cap as unreadable, never as a desync or a landed rebase", () => {
892
- assert.match(emptyPrHead(), phrase("Report the PR-object read as unreadable"));
893
- assert.match(
894
- emptyPrHead(),
895
- phrase("unreadable rather than folding it into either the desync above or the landed row"),
896
- );
897
- });
898
-
899
- test("step 1 never feeds an empty pr_head into the close-and-reopen ancestry check", () => {
900
- assert.match(emptyPrHead(), phrase("do not feed an empty `pr_head` into the close-and-reopen check"));
901
- });
902
-
903
- // The verdict the settle window exists to delay, unpinned until #1948 though
904
- // it is the one outcome the bot must not act on. Four clauses, each failing
905
- // alone: the controller routing, the two forbidden repairs, and the stop. The
906
- // reason the local rebase is forbidden is pinned apart from the prohibition, so
907
- // "because" → "since" leaves both green while dropping either reds.
908
- const survivingDesync = () =>
909
- paragraph(DOC, "**A desync that DOES survive the cap", "run-merge-bot.md step 1 surviving desync");
910
-
911
- test("step 1 hands a desync that survives the cap to the controller and repairs nothing itself", () => {
912
- assert.match(survivingDesync(), phrase("is the one state that needs a controller"));
913
- assert.match(survivingDesync(), phrase("do not retry the rebase"));
914
- assert.match(survivingDesync(), phrase("do not rebase locally"));
915
- assert.match(survivingDesync(), phrase("the remote is already correct"));
916
- assert.match(survivingDesync(), phrase("Report it and stop"));
917
- });
918
-
919
- // #903's expensive half. Close-and-reopen is the usual remedy for a desynced PR
920
- // and is normally reversible — but a rebase orphans the recorded head by
921
- // construction, and that is the very event that produced the desync. Measured:
922
- // three reopen attempts on #903 each returned `Could not open the pull request`,
923
- // and the only recovery was a replacement PR (#908), losing the review thread
924
- // and every label on it. The precondition is the whole rule, so it is pinned
925
- // alongside the verdict it forces.
926
- test("step 1 requires an ancestry check before closing a desynced PR", () => {
927
- assert.match(step1(), /git merge-base --is-ancestor <pr_head> origin\/<branch>/);
928
- assert.match(step1(), /Non-ancestor → \*\*do not close\*\*/);
929
- });
930
-
931
- // --- #910: step 1's block, lifted from the fence and executed ---------------
932
- //
933
- // The settle paragraph says a desync is not a desync until it survives a
934
- // bounded re-poll, and the block used to read `headRefOid` once, inline in its
935
- // printf, so a bot that ran the block and stopped reading reported one for a
936
- // state that clears itself. The ruling on #910 put the re-poll in the block.
937
- // The behaviour it asks for cannot be seen by a string pin: a loop's bound, its
938
- // break condition, and which outcomes enter it. So these RUN the block, the way
939
- // shell-traps-prose.test.mjs runs this document's monitor. `git`, `gh` and
940
- // `sleep` are stubbed, each probe answers from a per-case sequence (its last
941
- // value repeating), and every call is logged, so a case asserts what the block
942
- // printed and how many times it asked.
943
- //
944
- // The stubs are shell functions defined ahead of the block, not executables on
945
- // PATH. A function shadows a command in all three shells, `$(…)` and pipelines
946
- // included, and a freshly written executable is scanned on its first exec under
947
- // macOS: measured here at ~5s per stub, 15s a run for three, where the
948
- // functions cost nothing.
949
- //
950
- // THE CEILING: nothing here contacts GitHub, and `sleep` is logged, not taken,
951
- // so this measures the block's control flow and not real lag or wall time.
952
- // `seq` and `cut` are the real ones. `<pr>` is filled in, because a bot fills
953
- // it in, and left literal the shell reads it as two redirections.
954
- //
955
- // #1895 split the block in two: a fire block that reads `pre` and calls
956
- // `gh pr update-branch`, and a poll block handed `rc`, `branch` and `pre` off
957
- // the fire block's report line. Both run here, in sequence, against one case
958
- // directory, and the poll's `<rc>`/`<branch>`/`<pre>` are filled from what the
959
- // fire block PRINTED — the hand-off a bot makes — so a fire-to-poll value the
960
- // report line drops
961
- // reds here instead of being carried in by the test.
962
- const BASH_BLOCKS = [...DOC.matchAll(/```bash\n([\s\S]*?)```/g)].map((m) => m[1]);
963
- const STEP1_FIRE = BASH_BLOCKS.filter((b) => b.includes("gh pr update-branch <pr> --rebase"));
964
- assert.equal(
965
- STEP1_FIRE.length,
966
- 1,
967
- `expected exactly one bash block running gh pr update-branch, found ${STEP1_FIRE.length}; update this test`,
968
- );
969
- const STEP1_POLL = BASH_BLOCKS.filter((b) => b.includes("<pre>") && b.includes("seq 1 60"));
970
- assert.equal(
971
- STEP1_POLL.length,
972
- 1,
973
- `expected exactly one bash block polling from a handed-over <pre>, found ${STEP1_POLL.length}; update this test`,
974
- );
975
-
976
- // `next`: one value per line in "$1", one consumed per call, the last one
977
- // repeating once the sequence runs out. Arithmetic, not a bare `[ -gt ]`, on
978
- // wc's count: BSD wc pads it with spaces. The counters are files because most
979
- // calls run in a `$(…)` subshell, where a variable would not survive. An empty
980
- // `ls` value is a failed read: no line at all, which `cut -f1` turns into an
981
- // empty `post`. `return`, never `exit`, with one exception: `sleep` runs in
982
- // the block's own shell, so its `exit` is the harness-deadline stand-in — with
983
- // `$CASE/kill` holding a count, the sleep that reaches it ends the whole block
984
- // mid-poll, no report line printed, and clears the file so a re-issue runs on.
985
- const STEP1_STUBS = `next() {
986
- stub_n=$(cat "$1.n" 2>/dev/null || echo 0); stub_n=$((stub_n+1)); echo "$stub_n" >"$1.n"
987
- stub_last=$(($(wc -l <"$1"))); [ "$stub_n" -gt "$stub_last" ] && stub_n=$stub_last
988
- sed -n "\${stub_n}p" "$1"
989
- }
990
- git() {
991
- [ "$1" = ls-remote ] || { echo "unexpected: git $*" >&2; return 97; }
992
- echo ls-remote >>"$CASE/log"
993
- stub_sha=$(next "$CASE/ls")
994
- [ -z "$stub_sha" ] || printf '%s\\t%s\\n' "$stub_sha" "$3"
995
- }
996
- gh() {
997
- case "$*" in
998
- "pr view 42 --json headRefName -q .headRefName") echo feat ;;
999
- "pr update-branch 42 --rebase")
1000
- echo update-branch >>"$CASE/log"
1001
- [ "$UPDATE_RC" -eq 0 ] || { echo "GraphQL: merge conflict" >&2; return "$UPDATE_RC"; }
1002
- echo "PR branch updated" ;;
1003
- "pr view 42 --json headRefOid -q .headRefOid")
1004
- echo headRefOid >>"$CASE/log"
1005
- next "$CASE/head" ;;
1006
- *) echo "unexpected: gh $*" >&2; return 97 ;;
1007
- esac
1008
- }
1009
- sleep() {
1010
- echo "sleep $*" >>"$CASE/log"
1011
- [ -f "$CASE/kill" ] && [ "$(grep -c '^sleep' "$CASE/log")" -ge "$(cat "$CASE/kill")" ] && { rm "$CASE/kill"; exit 137; }
1012
- return 0
1013
- }
1014
- `;
1015
- const STEP1_FIRE_SCRIPT = STEP1_STUBS + STEP1_FIRE[0].replaceAll("<pr>", "42");
1016
- const step1PollScript = ({ rc, branch, pre }) =>
1017
- STEP1_STUBS + STEP1_POLL[0].replaceAll("<pr>", "42").replaceAll("<rc>", rc).replaceAll("<branch>", branch).replaceAll("<pre>", pre);
1018
-
1019
- const STEP1_DIR = tempDir("merge-bot-step1-");
1020
-
1021
- const step1HasShell = (s) => {
1022
- try {
1023
- execFileSync(s, ["-c", "exit 0"], { stdio: "ignore" });
1024
- return true;
1025
- } catch {
1026
- return false;
1027
- }
1028
- };
1029
- // sh and bash exist on every runner; zsh, the shell this document says it runs
1030
- // under, is absent on ubuntu-latest and is skipped there rather than faked.
1031
- const STEP1_SHELLS = ["sh", "bash", "zsh"].filter(step1HasShell);
1032
-
1033
- const PRE = "a".repeat(40);
1034
- const POST = "b".repeat(40);
1035
- const THIRD = "c".repeat(40);
1036
-
1037
- // The timeout is the bound's own witness: a re-poll rewritten as an unbounded
1038
- // `until` spins on a PR object that never moves, and reds here instead of
1039
- // hanging the suite.
1040
- function step1Case({ ls, head, updateRc = 0 }) {
1041
- const dir = mkdtempSync(join(STEP1_DIR, "case-"));
1042
- const lines = (xs) => xs.map((x) => `${x}\n`).join("");
1043
- writeFileSync(join(dir, "ls"), lines(ls));
1044
- writeFileSync(join(dir, "head"), lines(head));
1045
- writeFileSync(join(dir, "log"), "");
1046
- return { dir, env: { ...process.env, CASE: dir, UPDATE_RC: String(updateRc) } };
1047
- }
1048
-
1049
- function step1Script(c, name, text) {
1050
- const script = join(c.dir, name);
1051
- writeFileSync(script, text);
1052
- return script;
1053
- }
1054
-
1055
- const step1Run = (shell, c, script) => execFileSync(shell, [script], { encoding: "utf8", timeout: 30_000, env: c.env });
1056
-
1057
- // The fire block's report line, parsed the way a bot reads it to fill the
1058
- // poll's `<rc>` and `<pre>`.
1059
- function fireStep1(shell, c) {
1060
- const stdout = step1Run(shell, c, step1Script(c, "fire.sh", STEP1_FIRE_SCRIPT));
1061
- const fired = /^rc=(\S*) branch=(\S*) pre=(\S*)$/m.exec(stdout);
1062
- assert.ok(fired, `${shell}: the fire block printed no rc/pre line:\n${stdout}`);
1063
- return { rc: fired[1], branch: fired[2], pre: fired[3] };
1064
- }
1065
-
1066
- function step1Report(shell, c, stdout) {
1067
- const report = /^rc=(\S*) branch=\S* pre=(\S*) post=(\S*) pr_head=(\S*)$/m.exec(stdout);
1068
- assert.ok(report, `${shell}: the poll block printed no report line:\n${stdout}`);
1069
- const log = readFileSync(join(c.dir, "log"), "utf8").split("\n").filter(Boolean);
1070
- const firstRead = log.indexOf("headRefOid");
1071
- return {
1072
- rc: report[1],
1073
- pre: report[2],
1074
- post: report[3],
1075
- prHead: report[4],
1076
- fires: log.filter((l) => l === "update-branch").length,
1077
- reads: log.filter((l) => l === "headRefOid").length,
1078
- sleeps: log.filter((l) => l.startsWith("sleep")),
1079
- // The re-poll's own sleeps: every one after the first PR-object read. The
1080
- // ref poll's sleeps all come before it.
1081
- repollSleeps: firstRead === -1 ? 0 : log.slice(firstRead).filter((l) => l.startsWith("sleep")).length,
1082
- };
1083
- }
1084
-
1085
- function runStep1(shell, fixture) {
1086
- const c = step1Case(fixture);
1087
- const poll = step1Script(c, "poll.sh", step1PollScript(fireStep1(shell, c)));
1088
- return step1Report(shell, c, step1Run(shell, c, poll));
1089
- }
1090
-
1091
- test("step 1 re-polls a lagging PR object and reports the head it caught up to", () => {
1092
- for (const shell of STEP1_SHELLS) {
1093
- // The measured shape: the ref moved on the first poll, and the PR object
1094
- // followed a few reads later. A single read reports `pre` here, and that is
1095
- // a desync verdict for a state that cleared itself.
1096
- const lag = runStep1(shell, { ls: [PRE, POST], head: [PRE, PRE, PRE, POST] });
1097
- assert.equal(
1098
- lag.prHead,
1099
- POST,
1100
- `${shell}: pr_head reported ${lag.prHead} after the PR object caught up on read 4; the block read it too early`,
1101
- );
1102
- assert.equal(lag.reads, 4, `${shell}: expected 4 PR-object reads (3 lagging, 1 caught up), got ${lag.reads}`);
1103
- assert.equal(lag.repollSleeps, 3, `${shell}: expected one sleep between each pair of reads, got ${lag.repollSleeps}`);
1104
- // An empty read is no answer, so it cannot end the wait either.
1105
- const blank = runStep1(shell, { ls: [PRE, POST], head: ["", POST] });
1106
- assert.equal(blank.prHead, POST, `${shell}: an empty PR-object read ended the re-poll`);
1107
- assert.equal(blank.reads, 2, `${shell}: expected the empty read to be re-polled once, got ${blank.reads} reads`);
1108
- }
1109
- });
1110
-
1111
- test("step 1 reports a desync only after the re-poll has run its 60 × 5s cap", () => {
1112
- for (const shell of STEP1_SHELLS) {
1113
- const stuck = runStep1(shell, { ls: [PRE, POST], head: [PRE] });
1114
- assert.equal(stuck.post, POST, `${shell}: fixture: the ref moved, so this is the desync signature`);
1115
- assert.equal(stuck.prHead, PRE, `${shell}: a PR object that never moved was reported as ${stuck.prHead}`);
1116
- assert.equal(
1117
- stuck.reads,
1118
- 61,
1119
- `${shell}: the desync was reported after ${stuck.reads} PR-object reads; the cap is one read plus 60 re-polls`,
1120
- );
1121
- assert.equal(stuck.repollSleeps, 60, `${shell}: expected 60 re-poll sleeps, got ${stuck.repollSleeps}`);
1122
- assert.deepEqual(
1123
- [...new Set(stuck.sleeps)],
1124
- ["sleep 5"],
1125
- `${shell}: every wait is the ref poll's own 5s, got ${[...new Set(stuck.sleeps)].join(", ")}`,
1126
- );
1127
- }
1128
- });
1129
-
1130
- // What the re-poll must NOT hold up. It is gated on the one outcome that can
1131
- // produce the desync signature: `rc=0`, `post` non-empty, `post != pre`. The
1132
- // other rows of the four-outcome list take the fallback, and a five-minute wait
1133
- // on the PR object in front of each one would be spent on a question nobody
1134
- // asked. A PR object already off `pre` has answered, even on a third sha: that
1135
- // is merge-gate.mjs's `head-moved-after-label`, not this loop's to wait out.
1136
- test("step 1 takes one plain PR-object read wherever the ref did not land, or the PR object already moved", () => {
1137
- const cases = [
1138
- ["a non-zero rc", { updateRc: 1, ls: [PRE], head: [PRE] }, { rc: "1", prHead: PRE }],
1139
- ["a ref that never moved", { ls: [PRE], head: [PRE] }, { post: PRE, prHead: PRE }],
1140
- ["an unreadable ref", { ls: [PRE, ""], head: [PRE] }, { post: "", prHead: PRE }],
1141
- ["a PR object already on post", { ls: [PRE, POST], head: [POST] }, { post: POST, prHead: POST }],
1142
- ["a PR object on a third sha", { ls: [PRE, POST], head: [THIRD] }, { post: POST, prHead: THIRD }],
1143
- ];
1144
- for (const shell of STEP1_SHELLS) {
1145
- for (const [what, fixture, want] of cases) {
1146
- const got = runStep1(shell, fixture);
1147
- for (const [k, v] of Object.entries(want)) {
1148
- assert.equal(got[k], v, `${shell}, ${what}: ${k} reported ${JSON.stringify(got[k])}`);
1149
- }
1150
- assert.equal(got.reads, 1, `${shell}, ${what}: expected one plain PR-object read, got ${got.reads}`);
1151
- assert.equal(got.repollSleeps, 0, `${shell}, ${what}: the block waited on the PR object ${got.repollSleeps} times`);
1152
- }
1153
- }
1154
- });
1155
-
1156
- // #1895. The poll outlives omp's bash-backgrounding deadline on its COMMON
1157
- // path: the PR object's measured 84s-2min lag alone runs past omp's ~60s
1158
- // backgrounding, and a deadline kills the poll with
1159
- // no report line. The recovery the doc names is re-issuing the poll with the
1160
- // fire block's `pre`, and what has to hold is that the recovery reports the
1161
- // rebase as LANDED. Before the split the block could only be re-run whole,
1162
- // which re-read `pre` off a ref the rebase had already moved, and
1163
- // `gh pr update-branch` then answered "no new commits": reproduced against the
1164
- // pre-split doc with these stubs, the re-run fired the rebase twice and printed
1165
- // `rc=1` with `pre` and `post` both the rebased head — the already-current row,
1166
- // for a rebase that landed and was never verified. A poll that re-derives `pre`
1167
- // itself reds here the same way, reporting `post` equal to `pre`.
1168
- test("step 1's poll, cut off mid-re-poll and re-issued with the fire block's pre, reports the landed rebase", () => {
1169
- for (const shell of STEP1_SHELLS) {
1170
- // The ref moves at once; the PR object lags 12 reads, and the deadline
1171
- // lands on the re-poll's 5th sleep, inside that lag.
1172
- const c = step1Case({ ls: [PRE, POST], head: [...Array(12).fill(PRE), POST] });
1173
- const poll = step1Script(c, "poll.sh", step1PollScript(fireStep1(shell, c)));
1174
- writeFileSync(join(c.dir, "kill"), "5");
1175
- const cut = spawnSync(shell, [poll], { encoding: "utf8", timeout: 30_000, env: c.env });
1176
- assert.equal(cut.status, 137, `${shell}: the deadline stand-in did not end the poll:\n${cut.stdout}${cut.stderr}`);
1177
- assert.doesNotMatch(cut.stdout, /^rc=/m, `${shell}: the cut-off poll printed a report line — the fixture no longer models a deadline`);
1178
- const reissued = step1Report(shell, c, step1Run(shell, c, poll));
1179
- assert.deepEqual(
1180
- { rc: reissued.rc, pre: reissued.pre, post: reissued.post, prHead: reissued.prHead },
1181
- { rc: "0", pre: PRE, post: POST, prHead: POST },
1182
- `${shell}: the re-issued poll did not report the rebase as landed`,
1183
- );
1184
- assert.equal(reissued.fires, 1, `${shell}: recovering the poll fired the rebase again`);
1185
- }
1186
- });
1187
-
1188
- // The deadline half of #1895, the way step 2's CI wait and the grace wait
1189
- // carry theirs.
1190
- test("step 1's poll runs in one eval cell, never bash plus wait", () => {
1191
- const pair = between(DOC, "The poll:", "**Poll `git ls-remote`, not", "run-merge-bot.md step 1 poll rule");
1192
- assert.match(pair, phrase("one Python `eval` cell"));
1193
- assert.match(pair, phrase("its cell `timeout` at 900s or more"));
1194
- assert.match(pair, phrase("never `bash` plus `wait`"), "the rule no longer forbids the bash+wait form that backgrounds past ~60s");
1195
- });
1196
-
1197
- // #908: a controller brief predicted the merge would be "a fast-forward". True
1198
- // of the CONTENT (merge tree == pin tree == 988f29d1, `git diff` empty) and false
1199
- // of the SHAPE — `gh pr merge --merge` wrote two parents. The distinction is not
1200
- // cosmetic: prove-merge.sh guards the SHAPE with `[ "$parents" -ge 2 ]`, dying
1201
- // at "has no second parent — not a merge commit", and die() exits 2 — so an
1202
- // actual fast-forward yields no proof and a halt. Anchored on those strings
1203
- // rather than a line number, which drifted repeatedly here (#1136). Pinned so
1204
- // a future member cannot read the doc as permitting one.
1205
- test("step 4 says why --merge is load-bearing, not merely which flag to type", () => {
1206
- assert.match(step4(), /\*\*`--merge` \(no-ff\) is load-bearing, not stylistic/);
1207
- assert.match(step4(), /has no second parent — not a merge commit/);
1208
- // pins the VALUE, not the markdown around it: a cosmetic reflow dropping the
1209
- // bold must not red a correct document. Still discriminating — measured,
1210
- // `exits **1**` reds this assert both with and without the bold.
1211
- assert.match(step4(), /exits\s+\**2\**/);
1212
- });
1213
-
1214
- // #18. Load-bearing like its sibling paragraphs in this section: without this
1215
- // pin, a future edit could soften "write it against `gates` instead" or drop
1216
- // it, and the doc would go on recommending a sanity check against a flat field
1217
- // that flips its own polarity per proof path.
1218
- test("step 4 says to read gates, not the flat fields", () => {
1219
- assert.match(step4(), /Read `gates`, not the flat fields/);
1220
- assert.match(step4(), /write it against `gates` instead/);
1221
- });
1222
-
1223
- test("step 4 expects the fallback path to disprove, not to silently count as proved", () => {
1224
- assert.match(step4(), /A `rebase-fallback-#<pr>` merge is expected to disprove here/);
1225
- assert.match(step4(), /never as `proved`/);
1226
- });
1227
-
1228
- // Bounded to the Report line itself. An unbounded whole-file match is the
1229
- // vacuous pin this file's header forbids: the token surviving anywhere else in
1230
- // the doc would mask its removal from the vocabulary list.
1231
- test("the report vocabulary includes rebase-fallback", () => {
1232
- assert.match(DOC, /^Report merged [^\n]*rebase-fallback-#X/m);
1233
- });
1234
-
1235
- // #2295: step 4 tells the bot to report each kept branch, so the token has to
1236
- // be in the vocabulary the bot reports from. Bounded to the Report line, as above.
1237
- test("the report vocabulary includes branch-kept", () => {
1238
- assert.match(DOC, /^Report merged [^\n]*branch-kept-#X/m);
1239
- });
1240
-
1241
- // #1806 (spec 2026-09-24 § 5, ADR 0012 Decision 3). Step 3 is ONE script run
1242
- // twice, and the merge rests on the second run: a conclusion can invert under
1243
- // a fixed run id and a CI wait sits between the two readings. Sliced to step 3
1244
- // alone — `merge-gate`, `exit 0` and `gh pr merge` all recur through step 4
1245
- // and the report line, so an unbounded match survives the rule's deletion.
1246
- // These replace the retired `gateProof()` block: that section's synthetic
1247
- // fixtures and plain-`mkdir` claim moved into `merge-gate.test.mjs` as cases.
1248
- const step3 = () =>
1249
- between(DOC, "3. **Gate the merge with `merge-gate.mjs`", "4. `gh pr merge <pr> --merge`", "run-merge-bot.md step 3");
1250
-
1251
- test("step 3 runs the merge gate twice and merges only on the second exit 0", () => {
1252
- const s = step3();
1253
- assert.match(s, /~\/\.fleet\/bin\/fleet-run merge-gate\.mjs --pr <pr> --pre <pre> --post <post>/);
1254
- assert.match(
1255
- s,
1256
- phrase("**Run it again immediately before `gh pr merge`, and merge only on that second exit 0.**"),
1257
- "step 3 no longer re-runs the gate at the merge instant — a conclusion that inverted under the same run id, or a label pulled during the CI wait, merges on the first reading",
1258
- );
1259
- });
1260
-
1261
- test("step 3 waits on an unfinished run instead of skipping the PR, and only then", () => {
1262
- // The one exit 1 that is not a skip. Collapsed into "any exit 1 → skip",
1263
- // every freshly rebased PR is skipped, because its run is always in flight
1264
- // on the first reading.
1265
- assert.match(
1266
- step3(),
1267
- phrase("Exit 1 with a `ci:…` `reason`, `ci.runId` set and `ci.status` not `completed` → the run has started but not finished: wait on `ci.runId` (step 2), then run it again."),
1268
- "step 3 no longer separates the not-yet-finished run from a real refusal",
1269
- );
1270
- });
1271
-
1272
- // #1817. Right after `gh pr update-branch --rebase`, GitHub has not yet
1273
- // registered a run for the rebased head: `ci.runId` and `ci.status` both read
1274
- // `null`, which the arm above's "`ci.status` not `completed`" condition also
1275
- // matches — collapsed together, a bot reading this prose is sent to wait on
1276
- // `ci.runId` (step 2) with a `null` id, i.e. `gh run view null`. This pins
1277
- // the no-run case as its own arm, never routed through step 2's blocking wait.
1278
- test("step 3 waits and re-gates on a null ci.runId instead of routing it into step 2's wait", () => {
1279
- const s = step3();
1280
- assert.match(
1281
- s,
1282
- phrase("Exit 1 with `ci.runId` **null** (`reason` starts `no CI run whose headSha equals`) → GitHub has not yet registered a run for this head at all"),
1283
- "step 3 no longer carves the no-run-yet case out of the unfinished-run wait",
1284
- );
1285
- assert.match(
1286
- s,
1287
- phrase("never route this into step 2's `gh run view <run-id>` poll with a null id"),
1288
- "step 3 no longer warns against waiting on step 2's blocking call with a null run id",
1289
- );
1290
- assert.match(
1291
- s,
1292
- phrase("Wait 15s and run the gate again instead, capped at 20 attempts (~5 minutes); no run within that cap → skip the PR and report `<reason>-#<pr>`"),
1293
- "step 3 no longer bounds the no-run-yet wait, or no longer reports when the cap is exhausted",
1294
- );
1295
- });
1296
-
1297
- test("step 3 still skips a real refusal that is neither the unfinished-run wait nor the no-run-yet wait", () => {
1298
- assert.match(
1299
- step3(),
1300
- phrase("the same as any other exit 1. Any other exit 1 → skip the PR"),
1301
- "step 3 no longer distinguishes the two waits above from every other exit 1",
1302
- );
1303
- });
1304
-
1305
- test("step 3 reads exit 2 as could-not-evaluate, never as a verdict about the PR", () => {
1306
- const s = step3();
1307
- assert.match(s, phrase("Exit 2 → stop on that PR and report `<reason>-#<pr>`: the gate could not evaluate"));
1308
- assert.match(
1309
- s,
1310
- phrase("Re-run once only for `rate-limited`"),
1311
- "step 3 no longer bounds the exit-2 retry to the one reason that clears by itself",
1312
- );
1313
- });
1314
-
1315
- test("step 3 keys the gate's reading on both the PR and the bot's own name", () => {
1316
- // `merge-bot-<n>` is 1 + the merge-bot entries in the ledger's
1317
- // `## Dispatched` list, so no two bots in one run share it; `pr<N>` binds
1318
- // the reading to the merge it licenses. Either key dropped puts two readings
1319
- // at one path.
1320
- assert.match(step3(), phrase("--out <scratch>/pr<N>/merge-bot-<n>/ci.json"));
1321
- });
1322
-
1323
- // #1806 (spec § 4 items 4, 6, 11). The dispatched bot's pass ends in a grace
1324
- // and ONE report; the top-level invocation keeps its Monitor. Sliced to the
1325
- // grace section, which ends where **Then stay armed** begins.
1326
- const grace = () => between(DOC, "## Grace, then one report", "## Then stay armed", "run-merge-bot.md grace section");
1327
-
1328
- test("a dispatched bot holds a 15-minute grace, polling every 60s, before its one report", () => {
1329
- const s = grace();
1330
- assert.match(s, phrase("**Only a bot a controller dispatched holds a grace**"));
1331
- assert.match(s, phrase("then waits **15 minutes** for late labels, then reports once"));
1332
- assert.match(s, phrase("Every 60s, poll `gh pr list --state open --label ready-to-merge --limit 200 --json number`"),
1333
- "the grace poll lost its --limit, so it reads gh's bare default of 30 as the whole labelled queue (#2108)");
1334
- assert.match(
1335
- s,
1336
- phrase("**re-run selection from the top**, hold rule included, drain what it makes actionable, and restart the grace after that drain"),
1337
- "a label arriving in grace no longer re-enters selection with the hold rule, or no longer restarts the grace",
1338
- );
1339
- assert.match(s, phrase("**One report, at exit, and none before it**"));
1340
- });
1341
-
1342
- test("the grace wait holds in one eval cell, never bash plus wait", () => {
1343
- const pair = between(DOC, "The wait:", "**One report, at exit", "run-merge-bot.md grace wait rule");
1344
- assert.match(pair, phrase("hold the whole grace in one Python `eval` cell"));
1345
- assert.match(pair, phrase("its cell `timeout` at 1000s or more"));
1346
- assert.match(pair, phrase("never `bash` plus `wait`"), "the rule no longer forbids the bash+wait form that backgrounds past ~60s");
1347
- });
1348
-
1349
- test("the top-level invocation still arms its Monitor, and a dispatched bot still skips it", () => {
1350
- assert.match(
1351
- DOC,
1352
- phrase("**Skip this whole section if a controller dispatched you** (`/skill:run-team`, or any caller that says it owns the watcher) — hold the grace above instead."),
1353
- );
1354
- });
1355
-
1356
- // #705. `pr-overlap.mjs` grew a fourth signal, and a signal the runbook does
1357
- // not name is a signal the bot never reads — which is the same silent failure
1358
- // the ticket is about, moved from the script into its caller. The count is
1359
- // pinned in both of the places this document states it, because they rot
1360
- // independently: the invocation paragraph tells the bot what "firing" means,
1361
- // and the verdict-strength line tells it how hard to hold. Sliced to the hold
1362
- // rule alone — unbounded, "four signals" anywhere later in a 300-line
1363
- // document would satisfy these with the rule itself reverted to three.
1364
- const holdRule = () => between(DOC, "Before touching labeled PR `N`", "## The labelled head", "the hold rule");
1365
-
1366
- test("the hold rule names all four signals, prose included", () => {
1367
- const s = holdRule();
1368
- assert.match(
1369
- s,
1370
- phrase("**Any** of its four signals (`files`, `modules`, `dirs`, `prose`) firing means related"),
1371
- "the hold rule no longer names four signals — pr-overlap.mjs computes `prose` and a bot reading three ignores it",
1372
- );
1373
- assert.match(
1374
- s,
1375
- phrase("Directory-only and prose-only hits prompt investigation"),
1376
- "the hold rule no longer rates a prose hit as weak evidence beside a directory one",
1377
- );
1378
- });
1379
-
1380
- // The half that is not the count: an empty `prose[]` is a clear only when the
1381
- // scan covered the diff, and the script reports that in its own field rather
1382
- // than on stderr alone. A runbook that names the signal and not its unrun
1383
- // field reintroduces #705's exact shape — the clearest-looking output being
1384
- // the one that missed something — one level in.
1385
- test("the hold rule says prose=0 clears only when proseUnrun is null", () => {
1386
- assert.match(
1387
- holdRule(),
1388
- phrase("**`prose=0` is a clear only when `proseUnrun` is `null`.**"),
1389
- "the hold rule no longer gates an empty prose result on the scan having run",
1390
- );
1391
- });
1392
-
1393
- // The soft-signal bullet this mechanises. It predates the signal and stayed
1394
- // pure judgement for years; what changed is that one third of it — a data
1395
- // file cited by name — now has a mechanism, and the bullet has to point at it
1396
- // or the bot re-derives by hand what the script already computed. The other
1397
- // two thirds deliberately stay human: the paragraph below the bullet is the
1398
- // measurement (two PRs sharing `reset_hint=`/`resetHint`/`terminalFailure`,
1399
- // provably unrelated) that says mechanising a bare symbol name would cost
1400
- // more than it buys.
1401
- test("the same-docs-section bullet points at signal 4 and keeps symbols human", () => {
1402
- const s = paragraph(DOC, "they change the same exported symbol", "the same-section bullet");
1403
- assert.match(
1404
- s,
1405
- phrase("signal 4 mechanises the half of this where the section is a **data file** cited by name"),
1406
- "the same-section bullet no longer names the signal that mechanises its data-file half",
1407
- );
1408
- assert.match(
1409
- s,
1410
- phrase("a bare symbol or key name is still yours to read"),
1411
- "the same-section bullet no longer keeps bare symbol and config-key matching a human read",
1412
- );
1413
- });