@feigi/fleet-ctl 0.0.0

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 (245) hide show
  1. package/.claude-plugin/plugin.json +9 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +18 -0
  4. package/agents/fleet-finisher.agent.md +7 -0
  5. package/agents/fleet-implementer-alt.agent.md +210 -0
  6. package/agents/fleet-implementer.agent.md +210 -0
  7. package/agents/fleet-merge-bot.agent.md +7 -0
  8. package/agents/fleet-review-comments.agent.md +40 -0
  9. package/agents/fleet-review-correctness.agent.md +43 -0
  10. package/agents/fleet-review-runner.agent.md +73 -0
  11. package/agents/fleet-review-silent-failure.agent.md +49 -0
  12. package/agents/fleet-review-simplify.agent.md +46 -0
  13. package/agents/fleet-review-snapshot.agent.md +24 -0
  14. package/agents/fleet-review-tests.agent.md +46 -0
  15. package/agents/fleet-review-types.agent.md +41 -0
  16. package/agents/fleet-review-verifier.agent.md +29 -0
  17. package/commands/review-and-fix.md +98 -0
  18. package/commands/run-merge-bot.md +357 -0
  19. package/commands/run-team-help.md +17 -0
  20. package/package.json +23 -0
  21. package/scripts/agent-test-dir-prose.test.mjs +59 -0
  22. package/scripts/agent-test.test.mjs +1636 -0
  23. package/scripts/ambient-git-vars-mjs-prose.test.mjs +354 -0
  24. package/scripts/ambient-git-vars-prose.test.mjs +192 -0
  25. package/scripts/ancestry-check-position-prose.test.mjs +175 -0
  26. package/scripts/apply-ruleset.test.mjs +420 -0
  27. package/scripts/arg-header-probes-prose.test.mjs +393 -0
  28. package/scripts/arg.mjs +600 -0
  29. package/scripts/arg.test.mjs +1354 -0
  30. package/scripts/board-cli.test.mjs +694 -0
  31. package/scripts/board-identity.test.mjs +429 -0
  32. package/scripts/board-liveness-banner.test.mjs +119 -0
  33. package/scripts/board-prev-shape.test.mjs +229 -0
  34. package/scripts/board-tryparse-null.test.mjs +119 -0
  35. package/scripts/board.html +471 -0
  36. package/scripts/board.mjs +2037 -0
  37. package/scripts/board.test.mjs +3086 -0
  38. package/scripts/brief-after-cut-prose.test.mjs +53 -0
  39. package/scripts/candidates-exit3-prose.test.mjs +302 -0
  40. package/scripts/candidates.mjs +674 -0
  41. package/scripts/candidates.test.mjs +2101 -0
  42. package/scripts/caveat-unification-prose.test.mjs +98 -0
  43. package/scripts/ci-comment-rot-prose.test.mjs +2025 -0
  44. package/scripts/ci-completes-premise-prose.test.mjs +257 -0
  45. package/scripts/ci-state-prose.test.mjs +113 -0
  46. package/scripts/ci-state.mjs +761 -0
  47. package/scripts/ci-state.test.mjs +1640 -0
  48. package/scripts/ci-vacuous-green.test.mjs +368 -0
  49. package/scripts/citation-sweep-prose.test.mjs +1572 -0
  50. package/scripts/claim-lifecycle.test.mjs +185 -0
  51. package/scripts/claim-ticket.sh +417 -0
  52. package/scripts/claim-ticket.test.mjs +1121 -0
  53. package/scripts/closing-keyword-prose.test.mjs +193 -0
  54. package/scripts/cockpit-launch-idempotent-prose.test.mjs +165 -0
  55. package/scripts/cockpit-tick-nonblocking.test.mjs +210 -0
  56. package/scripts/compute-board.mjs +579 -0
  57. package/scripts/compute-board.test.mjs +1060 -0
  58. package/scripts/compute-spend.mjs +329 -0
  59. package/scripts/compute-spend.test.mjs +451 -0
  60. package/scripts/cross-repo-citation-prose.test.mjs +156 -0
  61. package/scripts/cwd-isolation-pins.mjs +83 -0
  62. package/scripts/dedupe-guard-prose.test.mjs +243 -0
  63. package/scripts/derive-testcmd.sh +239 -0
  64. package/scripts/derive-testcmd.test.mjs +380 -0
  65. package/scripts/diff-stats.mjs +231 -0
  66. package/scripts/diff-stats.test.mjs +408 -0
  67. package/scripts/dispatch-block-golden-prose.test.mjs +1024 -0
  68. package/scripts/dispatch-block-pins-prose.test.mjs +615 -0
  69. package/scripts/drop-merged-label.sh +173 -0
  70. package/scripts/drop-merged-label.test.mjs +480 -0
  71. package/scripts/expected-jobs-prose.test.mjs +80 -0
  72. package/scripts/filing-bar-seat-prose.test.mjs +242 -0
  73. package/scripts/filing-claim-bar-prose.test.mjs +166 -0
  74. package/scripts/finisher-dispatch-premise-prose.test.mjs +312 -0
  75. package/scripts/finisher-halt-prose.test.mjs +106 -0
  76. package/scripts/finisher-name-prose.test.mjs +134 -0
  77. package/scripts/finisher-own-tree-prose.test.mjs +285 -0
  78. package/scripts/finisher-pin-race-prose.test.mjs +339 -0
  79. package/scripts/fix-applier-correction-rules-prose.test.mjs +201 -0
  80. package/scripts/fix-applier-result-file-prose.test.mjs +100 -0
  81. package/scripts/fleet-bootstrap +155 -0
  82. package/scripts/fleet-heartbeat.mjs +272 -0
  83. package/scripts/fleet-heartbeat.test.mjs +450 -0
  84. package/scripts/fleet-provenance +207 -0
  85. package/scripts/fleet-provenance.test.mjs +64 -0
  86. package/scripts/fleet-run +148 -0
  87. package/scripts/fleet-run.test.mjs +90 -0
  88. package/scripts/fleet-state.mjs +400 -0
  89. package/scripts/fleet-state.test.mjs +373 -0
  90. package/scripts/fleet-tick-prose.test.mjs +299 -0
  91. package/scripts/fleet-tick.mjs +832 -0
  92. package/scripts/fleet-tick.test.mjs +1332 -0
  93. package/scripts/force-with-lease-reason-prose.test.mjs +184 -0
  94. package/scripts/frontmatter-allowlist.json +64 -0
  95. package/scripts/frontmatter-check.mjs +256 -0
  96. package/scripts/frontmatter-check.test.mjs +436 -0
  97. package/scripts/git-env.mjs +124 -0
  98. package/scripts/git-env.test.mjs +149 -0
  99. package/scripts/git-status-untracked-mode-sweep.test.mjs +216 -0
  100. package/scripts/gone-walk.test.mjs +213 -0
  101. package/scripts/gp-sep-invariant-prose.test.mjs +188 -0
  102. package/scripts/head-moved-after-label-prose.test.mjs +233 -0
  103. package/scripts/immutable-body-claim-prose.test.mjs +413 -0
  104. package/scripts/implementer-model-tier.test.mjs +643 -0
  105. package/scripts/inflight-citation-prose.test.mjs +144 -0
  106. package/scripts/inflight-exit2-prose.test.mjs +81 -0
  107. package/scripts/inflight-probe-guard-prose.test.mjs +109 -0
  108. package/scripts/inflight-scan-scope-prose.test.mjs +57 -0
  109. package/scripts/inflight.sh +1106 -0
  110. package/scripts/inflight.test.mjs +2984 -0
  111. package/scripts/injection-control-prose.test.mjs +404 -0
  112. package/scripts/install-root-audit.test.mjs +464 -0
  113. package/scripts/instrument-check-prose.test.mjs +235 -0
  114. package/scripts/instruments.sh +394 -0
  115. package/scripts/instruments.test.mjs +787 -0
  116. package/scripts/issue-tracker-prose.test.mjs +71 -0
  117. package/scripts/json.sh +248 -0
  118. package/scripts/json.test.mjs +364 -0
  119. package/scripts/ledger-dispatch.test.mjs +516 -0
  120. package/scripts/ledger-grammar.mjs +85 -0
  121. package/scripts/ledger-grammar.test.mjs +142 -0
  122. package/scripts/ledger-read-require-file.test.mjs +197 -0
  123. package/scripts/ledger.mjs +1753 -0
  124. package/scripts/ledger.test.mjs +3554 -0
  125. package/scripts/line-distance-prose.test.mjs +245 -0
  126. package/scripts/liveness-rationale-prose.test.mjs +83 -0
  127. package/scripts/locale-pin-prose.test.mjs +189 -0
  128. package/scripts/member-outcome-prose.test.mjs +167 -0
  129. package/scripts/member-outcomes-header.test.mjs +148 -0
  130. package/scripts/member-outcomes-prose.test.mjs +63 -0
  131. package/scripts/member-outcomes.mjs +231 -0
  132. package/scripts/member-outcomes.test.mjs +507 -0
  133. package/scripts/member-prompt-prose.test.mjs +161 -0
  134. package/scripts/member-record.mjs +605 -0
  135. package/scripts/member-record.test.mjs +516 -0
  136. package/scripts/member-write-guard.mjs +279 -0
  137. package/scripts/member-write-guard.test.mjs +211 -0
  138. package/scripts/merge-commit-probe-prose.test.mjs +122 -0
  139. package/scripts/merge-gate.mjs +262 -0
  140. package/scripts/merge-gate.test.mjs +613 -0
  141. package/scripts/muted-git-guard-sweep.test.mjs +493 -0
  142. package/scripts/net-ssh-precedence-prose.test.mjs +91 -0
  143. package/scripts/net-watchdog-prose.test.mjs +79 -0
  144. package/scripts/net.sh +409 -0
  145. package/scripts/net.test.mjs +211 -0
  146. package/scripts/no-ci-gate-prose.test.mjs +108 -0
  147. package/scripts/no-undo-audit.sh +1134 -0
  148. package/scripts/no-undo-audit.test.mjs +3965 -0
  149. package/scripts/no-wave.test.mjs +138 -0
  150. package/scripts/node-floor-sweep.test.mjs +611 -0
  151. package/scripts/pointer-target-prose.test.mjs +186 -0
  152. package/scripts/pr-overlap.mjs +417 -0
  153. package/scripts/pr-overlap.test.mjs +695 -0
  154. package/scripts/printf-die-sweep.test.mjs +384 -0
  155. package/scripts/prompt-renderer.mjs +39 -0
  156. package/scripts/prompt-renderer.test.mjs +68 -0
  157. package/scripts/prose-pin.mjs +808 -0
  158. package/scripts/prose-pin.test.mjs +1034 -0
  159. package/scripts/prove-merge.sh +228 -0
  160. package/scripts/prove-merge.test.mjs +995 -0
  161. package/scripts/pull-table-relabel-prose.test.mjs +60 -0
  162. package/scripts/quiet-payload-prose.test.mjs +222 -0
  163. package/scripts/reap.sh +1768 -0
  164. package/scripts/reap.test.mjs +4395 -0
  165. package/scripts/reaping-prose.test.mjs +159 -0
  166. package/scripts/refuter-scratch-prose.test.mjs +135 -0
  167. package/scripts/release-label-required-prose.test.mjs +71 -0
  168. package/scripts/release-label-split-prose.test.mjs +169 -0
  169. package/scripts/release-ticket.sh +1716 -0
  170. package/scripts/release-ticket.test.mjs +5106 -0
  171. package/scripts/renovate-release-contract.test.mjs +379 -0
  172. package/scripts/repo-root.mjs +544 -0
  173. package/scripts/repo-root.test.mjs +873 -0
  174. package/scripts/reporter-output-rule-prose.test.mjs +208 -0
  175. package/scripts/review-agent-report-only.test.mjs +49 -0
  176. package/scripts/review-core-cwd-isolation.test.mjs +374 -0
  177. package/scripts/review-core-reads.test.mjs +478 -0
  178. package/scripts/review-core-refuter-scratch.test.mjs +148 -0
  179. package/scripts/review-core-snapshot-path.test.mjs +777 -0
  180. package/scripts/review-core-specialist-scratch.test.mjs +189 -0
  181. package/scripts/review-core-testcmd.test.mjs +288 -0
  182. package/scripts/review-core-unrun.test.mjs +530 -0
  183. package/scripts/review-core-unverified-discriminant.test.mjs +208 -0
  184. package/scripts/review-core.mjs +1028 -0
  185. package/scripts/review-eval-resolver-path.test.mjs +55 -0
  186. package/scripts/review-eval.mjs +197 -0
  187. package/scripts/review-host-fixture.mjs +73 -0
  188. package/scripts/review-in-run-retry.test.mjs +187 -0
  189. package/scripts/review-no-vendor-dispatch.test.mjs +45 -0
  190. package/scripts/review-path-default.test.mjs +796 -0
  191. package/scripts/review-runner-spawns.test.mjs +93 -0
  192. package/scripts/review-runner.test.mjs +155 -0
  193. package/scripts/review-tier-audit.test.mjs +140 -0
  194. package/scripts/run-artifact-pr-prose.test.mjs +341 -0
  195. package/scripts/run-merge-bot-prose.test.mjs +1391 -0
  196. package/scripts/scratch-partition-invariant-prose.test.mjs +74 -0
  197. package/scripts/scripts-path-citation-sweep.test.mjs +73 -0
  198. package/scripts/section-between-guard-prose.test.mjs +378 -0
  199. package/scripts/select-dimensions.test.mjs +674 -0
  200. package/scripts/shared-refusal.test.mjs +388 -0
  201. package/scripts/shell-traps-prose.test.mjs +507 -0
  202. package/scripts/shortlist.mjs +355 -0
  203. package/scripts/shortlist.test.mjs +366 -0
  204. package/scripts/slow-transport.mjs +72 -0
  205. package/scripts/snapshot-repo.test.mjs +772 -0
  206. package/scripts/snapshot-runner-audience-prose.test.mjs +129 -0
  207. package/scripts/spend-view.test.mjs +312 -0
  208. package/scripts/staleness-qualifier-prose.test.mjs +251 -0
  209. package/scripts/staleness-verdict-prose.test.mjs +142 -0
  210. package/scripts/staleness.mjs +414 -0
  211. package/scripts/staleness.test.mjs +893 -0
  212. package/scripts/stalled-member-liveness-prose.test.mjs +219 -0
  213. package/scripts/stash-prohibition-prose.test.mjs +313 -0
  214. package/scripts/strip-comments.mjs +44 -0
  215. package/scripts/tier-check.mjs +468 -0
  216. package/scripts/tier-check.test.mjs +726 -0
  217. package/scripts/tier-guard-gate-prose.test.mjs +216 -0
  218. package/scripts/tier-outcomes-header.test.mjs +586 -0
  219. package/scripts/tier-outcomes.mjs +441 -0
  220. package/scripts/tier-outcomes.test.mjs +342 -0
  221. package/scripts/tier-roles.mjs +250 -0
  222. package/scripts/tier-roles.test.mjs +316 -0
  223. package/scripts/tracker-block-copy-prose.test.mjs +288 -0
  224. package/scripts/triage-labels-gloss-prose.test.mjs +97 -0
  225. package/scripts/unattended-git-sweep.test.mjs +142 -0
  226. package/scripts/verify-sha-exit2-prose.test.mjs +269 -0
  227. package/scripts/verify-sha.sh +117 -0
  228. package/scripts/verify-sha.test.mjs +693 -0
  229. package/scripts/watcher-degraded-block.test.mjs +372 -0
  230. package/scripts/watcher-key-prose.test.mjs +106 -0
  231. package/scripts/within-run-pair-prose.test.mjs +208 -0
  232. package/scripts/worktree-audit.sh +482 -0
  233. package/scripts/worktree-audit.test.mjs +1407 -0
  234. package/scripts/worktree-head-prose.test.mjs +276 -0
  235. package/scripts/worktree-listing-sweep.test.mjs +217 -0
  236. package/scripts/worktree-model-prose.test.mjs +216 -0
  237. package/scripts/worktree.sh +470 -0
  238. package/skills/next-ticket/SKILL.md +138 -0
  239. package/skills/run-team/SKILL.md +3603 -0
  240. package/skills/run-team/references/ci-and-staleness.md +75 -0
  241. package/skills/run-team/references/correction-tickets.md +37 -0
  242. package/skills/run-team/references/isolation.md +23 -0
  243. package/skills/run-team/references/member-lifecycle.md +73 -0
  244. package/skills/run-team/references/reaping.md +73 -0
  245. package/skills/sizing-a-ticket/SKILL.md +39 -0
@@ -0,0 +1,316 @@
1
+ import { test } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { spawnSync } from "node:child_process";
4
+ import { mkdtempSync, mkdirSync, writeFileSync } from "node:fs";
5
+ import { tmpdir } from "node:os";
6
+ import { join } from "node:path";
7
+ import { fileURLToPath } from "node:url";
8
+
9
+ import {
10
+ parseModelRoute, parseFrontmatter, stripLevel, resolveRole, expectedOmpModel,
11
+ modelsEqual, checkRoutes,
12
+ } from "./tier-roles.mjs";
13
+
14
+ const SCRIPT = fileURLToPath(new URL("./tier-roles.mjs", import.meta.url));
15
+ const REPO_AGENTS = fileURLToPath(new URL("../agents", import.meta.url));
16
+
17
+ function dir() {
18
+ return mkdtempSync(join(tmpdir(), "tier-roles-"));
19
+ }
20
+
21
+ function agentsDir(files) {
22
+ const d = dir();
23
+ const agents = join(d, "agents");
24
+ mkdirSync(agents, { recursive: true });
25
+ for (const [name, model] of Object.entries(files)) {
26
+ writeFileSync(
27
+ join(agents, `${name}.agent.md`),
28
+ `---\nname: ${name}\ndescription: fixture\nmodel: ${model}\n---\n\nFollow the dispatch brief.\n`,
29
+ );
30
+ }
31
+ return agents;
32
+ }
33
+
34
+ function jsonFile(d, name, value) {
35
+ const p = join(d, name);
36
+ writeFileSync(p, JSON.stringify(value));
37
+ return p;
38
+ }
39
+
40
+ function runCli(argv, cwd) {
41
+ return spawnSync(process.execPath, [SCRIPT, ...argv], { cwd, encoding: "utf8" });
42
+ }
43
+
44
+ // ---------------------------------------------------------------------------
45
+ // parseModelRoute / parseFrontmatter
46
+ // ---------------------------------------------------------------------------
47
+
48
+ test("parseModelRoute: a well-formed route, unquoted", () => {
49
+ assert.deepEqual(parseModelRoute("@slow:xhigh"), { role: "slow", level: "xhigh" });
50
+ });
51
+
52
+ test("parseModelRoute: a well-formed route, double-quoted", () => {
53
+ assert.deepEqual(parseModelRoute('"@slow:xhigh"'), { role: "slow", level: "xhigh" });
54
+ });
55
+
56
+ test("parseModelRoute: a well-formed route, single-quoted", () => {
57
+ assert.deepEqual(parseModelRoute("'@task:low'"), { role: "task", level: "low" });
58
+ });
59
+
60
+ test("parseModelRoute: every role/level combination is accepted", () => {
61
+ for (const role of ["slow", "task", "smol"]) {
62
+ for (const level of ["minimal", "low", "medium", "high", "xhigh", "max"]) {
63
+ assert.deepEqual(parseModelRoute(`@${role}:${level}`), { role, level });
64
+ }
65
+ }
66
+ });
67
+
68
+ test("parseModelRoute: a bare vendor alias is not a route", () => {
69
+ assert.deepEqual(parseModelRoute("opus"), { role: null, level: null });
70
+ });
71
+
72
+ test("parseModelRoute: an unrecognised role is not a route", () => {
73
+ assert.deepEqual(parseModelRoute("@fast:high"), { role: null, level: null });
74
+ });
75
+
76
+ test("parseModelRoute: an unrecognised level is not a route", () => {
77
+ assert.deepEqual(parseModelRoute("@slow:extreme"), { role: null, level: null });
78
+ });
79
+
80
+ test("parseModelRoute: missing the :<level> suffix is not a route", () => {
81
+ assert.deepEqual(parseModelRoute("@slow"), { role: null, level: null });
82
+ });
83
+
84
+ test("parseFrontmatter: a quoted route parses model/role/level together", () => {
85
+ const text = '---\nname: fleet-x\ndescription: d\nmodel: "@slow:xhigh"\n---\nbody\n';
86
+ assert.deepEqual(parseFrontmatter(text), { model: '"@slow:xhigh"', role: "slow", level: "xhigh" });
87
+ });
88
+
89
+ test("parseFrontmatter: an unquoted route parses the same role/level", () => {
90
+ const text = "---\nname: fleet-x\ndescription: d\nmodel: @slow:xhigh\n---\nbody\n";
91
+ assert.deepEqual(parseFrontmatter(text), { model: "@slow:xhigh", role: "slow", level: "xhigh" });
92
+ });
93
+
94
+ test("parseFrontmatter: no model: field at all is null/null/null", () => {
95
+ const text = "---\nname: fleet-x\ndescription: d\n---\nbody\n";
96
+ assert.deepEqual(parseFrontmatter(text), { model: null, role: null, level: null });
97
+ });
98
+
99
+ test("parseFrontmatter: a non-route model: value carries the raw model but null role/level", () => {
100
+ const text = "---\nname: fleet-x\ndescription: d\nmodel: opus\n---\nbody\n";
101
+ assert.deepEqual(parseFrontmatter(text), { model: "opus", role: null, level: null });
102
+ });
103
+
104
+ // ---------------------------------------------------------------------------
105
+ // stripLevel / resolveRole
106
+ // ---------------------------------------------------------------------------
107
+
108
+ test("stripLevel: removes a trailing :level, never touches the provider /", () => {
109
+ assert.equal(stripLevel("anthropic/claude-opus-5:high"), "anthropic/claude-opus-5");
110
+ assert.equal(stripLevel("anthropic/claude-opus-5"), "anthropic/claude-opus-5");
111
+ assert.equal(stripLevel(null), "");
112
+ });
113
+
114
+ test("resolveRole: a direct role resolves to its stripped model", () => {
115
+ assert.equal(resolveRole("slow", { slow: "anthropic/claude-opus-5:high" }), "anthropic/claude-opus-5");
116
+ });
117
+
118
+ test("resolveRole: an @-prefixed role value follows the chain to a bare model", () => {
119
+ assert.equal(resolveRole("slow", { slow: "@plan", plan: "openai/gpt-5.4:high" }), "openai/gpt-5.4");
120
+ });
121
+
122
+ test("resolveRole: a cycle returns null rather than recursing forever", () => {
123
+ assert.equal(resolveRole("a", { a: "@b", b: "@a" }), null);
124
+ });
125
+
126
+ test("resolveRole: unset/empty/non-string all return null", () => {
127
+ assert.equal(resolveRole("slow", {}), null);
128
+ assert.equal(resolveRole("slow", { slow: "" }), null);
129
+ assert.equal(resolveRole("slow", { slow: 42 }), null);
130
+ });
131
+
132
+ // ---------------------------------------------------------------------------
133
+ // expectedOmpModel
134
+ // ---------------------------------------------------------------------------
135
+
136
+ test("expectedOmpModel: a route resolves through the named role", () => {
137
+ assert.deepEqual(
138
+ expectedOmpModel("@slow:xhigh", { slow: "anthropic/claude-opus-5:auto" }),
139
+ { role: "slow", level: "xhigh", model: "anthropic/claude-opus-5" },
140
+ );
141
+ });
142
+
143
+ test("expectedOmpModel: an unset role resolves to a null model, role/level still reported", () => {
144
+ assert.deepEqual(expectedOmpModel("@task:low", {}), { role: "task", level: "low", model: null });
145
+ });
146
+
147
+ test("expectedOmpModel: a non-route value has null role/level/model", () => {
148
+ assert.deepEqual(expectedOmpModel("opus", {}), { role: null, level: null, model: null });
149
+ });
150
+
151
+ // ---------------------------------------------------------------------------
152
+ // modelsEqual
153
+ // ---------------------------------------------------------------------------
154
+
155
+ test("modelsEqual: tolerates a role value written without its provider prefix", () => {
156
+ assert.equal(modelsEqual("anthropic/claude-opus-5", "claude-opus-5"), true);
157
+ assert.equal(modelsEqual("claude-opus-5", "anthropic/claude-opus-5"), true);
158
+ assert.equal(modelsEqual("anthropic/claude-opus-5:high", "anthropic/claude-opus-5"), true);
159
+ assert.equal(modelsEqual("anthropic/claude-opus-5", "anthropic/claude-haiku-4-5"), false);
160
+ });
161
+
162
+ test("modelsEqual: a bare suffix match without the '/' boundary is NOT equal", () => {
163
+ // The prefix-tolerance above requires a `/` immediately before the shorter
164
+ // spelling — this pins that boundary against a regression to a bare
165
+ // `endsWith` (no `/`), which would wrongly equate two DIFFERENT models
166
+ // that merely happen to share a trailing token.
167
+ assert.equal(modelsEqual("claude-opus-5", "not-claude-opus-5"), false);
168
+ assert.equal(modelsEqual("not-claude-opus-5", "claude-opus-5"), false);
169
+ assert.equal(modelsEqual("x-claude-opus-5", "claude-opus-5"), false);
170
+ });
171
+
172
+ // ---------------------------------------------------------------------------
173
+ // checkRoutes
174
+ // ---------------------------------------------------------------------------
175
+
176
+ const MODEL_ROLES = { slow: "anthropic/claude-opus-5:auto", task: "anthropic/claude-sonnet-5:auto", smol: "anthropic/claude-haiku-4-5:auto" };
177
+
178
+ test("checkRoutes: every definition routed and every role resolvable -> no violations or notices", () => {
179
+ const agents = agentsDir({ "fleet-a": "@slow:xhigh", "fleet-b": "@smol:low" });
180
+ const result = checkRoutes({ agentsDir: agents, modelRoles: MODEL_ROLES, overrides: {} });
181
+ assert.deepEqual(result, { violations: [], notices: [] });
182
+ });
183
+
184
+ test("checkRoutes (a): a definition whose model: is not a route is a violation naming the file", () => {
185
+ const agents = agentsDir({ "fleet-a": "opus" });
186
+ const { violations } = checkRoutes({ agentsDir: agents, modelRoles: MODEL_ROLES, overrides: {} });
187
+ assert.equal(violations.length, 1);
188
+ assert.match(violations[0], /^fleet-a\.agent\.md: model "opus" is not @<role>:<level>$/);
189
+ });
190
+
191
+ test("checkRoutes (b): a used role with no modelRoles entry is a violation naming the role and the definition", () => {
192
+ const agents = agentsDir({ "fleet-a": "@slow:xhigh" });
193
+ const { violations } = checkRoutes({ agentsDir: agents, modelRoles: {}, overrides: {} });
194
+ assert.equal(violations.length, 1);
195
+ assert.match(violations[0], /modelRoles\.slow is unset/);
196
+ assert.match(violations[0], /fleet-a\.agent\.md/);
197
+ });
198
+
199
+ test("checkRoutes (b): an unset role no definition uses is not a violation", () => {
200
+ const agents = agentsDir({ "fleet-a": "@slow:xhigh" });
201
+ const { violations } = checkRoutes({ agentsDir: agents, modelRoles: { slow: MODEL_ROLES.slow }, overrides: {} });
202
+ assert.deepEqual(violations, []);
203
+ });
204
+
205
+ test("checkRoutes (c): a fleet- key in task.agentModelOverrides shadows the definition and violates, remedy resets when nothing else remains", () => {
206
+ const agents = agentsDir({ "fleet-a": "@slow:xhigh" });
207
+ const { violations } = checkRoutes({
208
+ agentsDir: agents,
209
+ modelRoles: MODEL_ROLES,
210
+ overrides: { "fleet-a": "@slow:xhigh" },
211
+ });
212
+ assert.equal(violations.length, 1);
213
+ assert.match(violations[0], /task\.agentModelOverrides\.fleet-a shadows the definition's own model \(precedence #1\) — remove it/);
214
+ assert.match(violations[0], /omp config reset task\.agentModelOverrides/);
215
+ });
216
+
217
+ test("checkRoutes (c): the remedy keeps the operator's own non-fleet- entries when one exists", () => {
218
+ const agents = agentsDir({ "fleet-a": "@slow:xhigh" });
219
+ const { violations } = checkRoutes({
220
+ agentsDir: agents,
221
+ modelRoles: MODEL_ROLES,
222
+ overrides: { "fleet-a": "@slow:xhigh", "my-other-agent": "opus" },
223
+ });
224
+ assert.equal(violations.length, 1);
225
+ assert.match(violations[0], /omp config set task\.agentModelOverrides/);
226
+ assert.match(violations[0], /my-other-agent/);
227
+ assert.doesNotMatch(violations[0], /"fleet-a"/);
228
+ });
229
+
230
+ test("checkRoutes (c): a non-fleet- override key is the operator's own and never violates", () => {
231
+ const agents = agentsDir({ "fleet-a": "@slow:xhigh" });
232
+ const { violations } = checkRoutes({
233
+ agentsDir: agents,
234
+ modelRoles: MODEL_ROLES,
235
+ overrides: { "my-other-agent": "opus" },
236
+ });
237
+ assert.deepEqual(violations, []);
238
+ });
239
+
240
+ test("checkRoutes (d): slow and task resolving to the same model is a notice, not a violation", () => {
241
+ const agents = agentsDir({ "fleet-a": "@slow:xhigh" });
242
+ const { violations, notices } = checkRoutes({
243
+ agentsDir: agents,
244
+ modelRoles: { slow: "anthropic/claude-opus-5:auto", task: "anthropic/claude-opus-5:auto", smol: MODEL_ROLES.smol },
245
+ overrides: {},
246
+ });
247
+ assert.deepEqual(violations, []);
248
+ assert.equal(notices.length, 1);
249
+ assert.match(notices[0], /modelRoles\.slow and modelRoles\.task both resolve to/);
250
+ });
251
+
252
+ test("checkRoutes (d): slow and task resolving to different models is not a notice", () => {
253
+ const agents = agentsDir({ "fleet-a": "@slow:xhigh" });
254
+ const { notices } = checkRoutes({ agentsDir: agents, modelRoles: MODEL_ROLES, overrides: {} });
255
+ assert.deepEqual(notices, []);
256
+ });
257
+
258
+ test("checkRoutes: every real plugin/agents definition routes cleanly against a model-roles fixture that covers all three roles", () => {
259
+ const { violations } = checkRoutes({ agentsDir: REPO_AGENTS, modelRoles: MODEL_ROLES, overrides: {} });
260
+ assert.deepEqual(violations, []);
261
+ });
262
+
263
+ // ---------------------------------------------------------------------------
264
+ // CLI
265
+ // ---------------------------------------------------------------------------
266
+
267
+ test("CLI: --check with a clean install exits 0", () => {
268
+ const d = dir();
269
+ const agents = agentsDir({ "fleet-a": "@slow:xhigh" });
270
+ const overridesPath = jsonFile(d, "overrides.json", {});
271
+ const modelRolesPath = jsonFile(d, "model-roles.json", MODEL_ROLES);
272
+ const r = runCli(["--check", "--agents", agents, "--overrides", overridesPath, "--model-roles", modelRolesPath], d);
273
+ assert.equal(r.status, 0, r.stderr);
274
+ });
275
+
276
+ test("CLI: --check with a non-route model: exits 1 naming the file", () => {
277
+ const d = dir();
278
+ const agents = agentsDir({ "fleet-a": "opus" });
279
+ const overridesPath = jsonFile(d, "overrides.json", {});
280
+ const modelRolesPath = jsonFile(d, "model-roles.json", MODEL_ROLES);
281
+ const r = runCli(["--check", "--agents", agents, "--overrides", overridesPath, "--model-roles", modelRolesPath], d);
282
+ assert.equal(r.status, 1);
283
+ assert.match(r.stderr, /fleet-a\.agent\.md: model "opus" is not @<role>:<level>/);
284
+ });
285
+
286
+ test("CLI: --check with a shadowing fleet- override exits 1 naming the remedy", () => {
287
+ const d = dir();
288
+ const agents = agentsDir({ "fleet-a": "@slow:xhigh" });
289
+ const overridesPath = jsonFile(d, "overrides.json", { "fleet-a": "@slow:xhigh" });
290
+ const modelRolesPath = jsonFile(d, "model-roles.json", MODEL_ROLES);
291
+ const r = runCli(["--check", "--agents", agents, "--overrides", overridesPath, "--model-roles", modelRolesPath], d);
292
+ assert.equal(r.status, 1);
293
+ assert.match(r.stderr, /omp config reset task\.agentModelOverrides/);
294
+ });
295
+
296
+ test("CLI: --check without --check flag is required", () => {
297
+ const d = dir();
298
+ const r = runCli([], d);
299
+ assert.equal(r.status, 2);
300
+ assert.match(r.stderr, /--check is required/);
301
+ });
302
+
303
+ test("CLI: an unknown flag refuses by name", () => {
304
+ const d = dir();
305
+ const r = runCli(["--check", "--bogus", "x"], d);
306
+ assert.equal(r.status, 2);
307
+ assert.match(r.stderr, /unknown flag --bogus/);
308
+ });
309
+
310
+ test("CLI: --agents defaults to the plugin's own agents directory", () => {
311
+ const d = dir();
312
+ const overridesPath = jsonFile(d, "overrides.json", {});
313
+ const modelRolesPath = jsonFile(d, "model-roles.json", MODEL_ROLES);
314
+ const r = runCli(["--check", "--overrides", overridesPath, "--model-roles", modelRolesPath], d);
315
+ assert.equal(r.status, 0, r.stderr);
316
+ });
@@ -0,0 +1,288 @@
1
+ // #374. `docs/agents/issue-tracker.md` reproduces the implementer issue-read
2
+ // block — since #1804 carried by the body of `agents/fleet-implementer.agent.md`
3
+ // (spec 2026-09-24 § 2 Decision 2), which each harness injects as the member's
4
+ // system prompt; before that, by a `>` quote block in `run-team/SKILL.md`'s
5
+ // phase 2 — and the copy has fallen behind that block
6
+ // twice: #79 found it carrying the command and its caveat but neither rule
7
+ // saying which text wins, and #373 restored those two without the judgement
8
+ // rule that had arrived beside them upstream in the meantime.
9
+ //
10
+ // So this pins the copy COMPLETE against the source, rather than pinning any
11
+ // sentence present in it. A presence pin on the sentence #374 restores leaves
12
+ // the next sentence added upstream to drift exactly as that one did — the
13
+ // failure mode is the block GROWING, and only an end-to-end comparison sees
14
+ // growth.
15
+ //
16
+ // DESIGN, and the thing to read before deleting this test when it reddens: it
17
+ // compares the two paragraphs whole, so an edit to one side alone IS a failure,
18
+ // by construction. That is not a false positive — one wording, two files, and
19
+ // the file you did not edit is the copy that just went stale. The fix when it
20
+ // reddens is to apply the same edit to the other side, never to loosen the
21
+ // comparison. That remedy is now MEASURED green: #1004 found that rewording the
22
+ // block's last sentence in both files still reddened the growth assertion,
23
+ // because the reword invalidated a hard-coded copy of that sentence kept here
24
+ // as a fixture — a red that named growth for an edit that was not growth. Every
25
+ // fixture below is now derived from the live block instead, so the prescribed
26
+ // remedy reddens nothing.
27
+ //
28
+ // A rewrap is not an edit either: both slices are whitespace-normalized, and
29
+ // "a rewrapped copy still matches" below is what holds that open.
30
+ //
31
+ // NOR IS AN EMPHASIS MOVE, on the anchors. Narrowing a `**` span within the
32
+ // sentence this file anchors the far end of its slice on — `**Re-derive the
33
+ // ticket's claims** against ...`, same words, same order, same meaning —
34
+ // reddened all FOUR tests here, with a message about a stale end anchor
35
+ // (#1004, measured at two refs). Anchors are therefore matched against a view
36
+ // with `**` removed. The COMPARED SLICES keep every byte: this file compares
37
+ // one file's block against another file's copy of it, so emphasis appearing on
38
+ // one side only is real drift and still reddens. That is the one place this
39
+ // file deliberately diverges from `dispatch-block-pins-prose.test.mjs`, which
40
+ // strips `**` outright — it pins content against a single file, so it has no
41
+ // second side to disagree with and nothing to lose by stripping.
42
+ //
43
+ // #23's `caveat-unification-prose.test.mjs` deliberately left this pair out,
44
+ // on the ground that `run-team`'s copy sits inside a verbatim subagent prompt
45
+ // written for a different audience. That holds for the SKILL files it does
46
+ // compare, which paraphrase; it does not hold here, because the tracker
47
+ // section is not a paraphrase of the block but a reproduction of it, differing
48
+ // today only in wrap width and the prompt's quote markers. Comparing whole is
49
+ // available precisely because the copy is verbatim.
50
+ //
51
+ // THE CEILING: this proves the copy AGREES with the source. It cannot prove
52
+ // either is correct — a wrong sentence written into both agrees with itself
53
+ // and passes here, however the fixtures are obtained. No fixture change reaches
54
+ // that, and deriving them did not: the content pins in
55
+ // `dispatch-block-pins-prose.test.mjs` are what catch an identical gutting of
56
+ // both files.
57
+ import { test } from "node:test";
58
+ import assert from "node:assert/strict";
59
+ import { readFileSync } from "node:fs";
60
+ import { join } from "node:path";
61
+ import { paragraph, unemphasized } from "./prose-pin.mjs";
62
+
63
+ const REPO = join(import.meta.dirname, "..");
64
+ const read = (...p) => readFileSync(join(REPO, ...p), "utf8");
65
+ // The body alone — everything after the frontmatter's closing `---`. Named
66
+ // SKILL for the history above: this was run-team/SKILL.md's phase 2 until #1804.
67
+ const SKILL = read("agents", "fleet-implementer.agent.md").split("---").slice(2).join("---");
68
+ const REPO_ROOT = join(import.meta.dirname, "..", "..");
69
+ const TRACKER = readFileSync(join(REPO_ROOT, "docs", "agents", "issue-tracker.md"), "utf8");
70
+
71
+ // Names the block by its opening clause. Semantic, and the one clause both
72
+ // files must share for either to be the block at all.
73
+ const OPENER = "Read the issue with `gh issue view <N>";
74
+ const SKILL_END = /^Re-derive the ticket's claims against/;
75
+ const TRACKER_END = /^#/;
76
+
77
+ // Imported from `prose-pin.mjs` — anchor matching only, never the compared
78
+ // text. See the header for why the two differ. Written without `**` on both
79
+ // sides of the test so an anchor that someone later types WITH the markers
80
+ // still matches, and so the anchors above read as the sentences they name
81
+ // rather than as markup. `skillBlock`/`trackerBlock` below opt the same
82
+ // helper into `quoteBlock`/`paragraph`'s own anchor matching, so an opener
83
+ // move like this one does not stop at those two fixtures while `block`
84
+ // itself stays green (#1004, measured — see the comment above them).
85
+
86
+ // The far end of the slice is anchored on the first thing that is NOT this
87
+ // rule, and never on the block's own last sentence. A closing-phrase anchor
88
+ // stops the slice at today's last sentence, so a sentence appended after it
89
+ // falls outside BOTH slices and the pin passes with the copy already behind.
90
+ // The paragraph break is that same mistake one level up, and it shipped: #374's
91
+ // review appended a whole new `>` paragraph beside the block in run-team only
92
+ // and every test here stayed green while the tracker was genuinely behind.
93
+ // Anchoring past the rule instead puts growth of any size — sentence or
94
+ // paragraph — INSIDE the slice, where the equality pin sees it.
95
+ //
96
+ // WHY THIS IS NOT `quoteBlock`, which #1002 added for exactly this shape of
97
+ // job. `quoteBlock` bounds a block at its own maximal run of `>` lines, and
98
+ // growth arriving as a blank-line-separated `>` paragraph beside the block is a
99
+ // SEPARATE run. Measured on this file's own fixtures: a `>`-joined growth
100
+ // paragraph lands inside `quoteBlock`'s return, a blank-line-separated one does
101
+ // not — and the blank-line shape is the one #374's review actually shipped, and
102
+ // the one the anchor above catches. So a one-block bound (`quoteBlock` until
103
+ // #1804, `paragraph` since the block became plain prose in the agent body) is
104
+ // used below for the FIXTURES, where a bound that is exactly one block is what
105
+ // is wanted, and the slice keeps this broader bound, which is strictly wider.
106
+ //
107
+ // The two anchors differ because the two files hold the block differently: in
108
+ // the tracker it owns a `##` section, so the next heading ends it; in the
109
+ // agent body (run-team until #1804) it is one blockquote rule among siblings, so the rule that follows it does.
110
+ // Both are SEMANTIC, like the opener, and both are guarded below — an anchor
111
+ // that goes stale reddens loudly rather than silently widening the slice.
112
+ //
113
+ // Paragraphs are split, unquoted and whitespace-normalized BEFORE the opener is
114
+ // looked for, so neither end of the slice depends on where a line happens to
115
+ // break. Matching the opener against a raw line instead costs the accept case
116
+ // its point: a reflow landing inside the opener reddens on the anchor itself,
117
+ // where no amount of normalizing the slice afterwards can help. (Measured — the
118
+ // first draft of this test did exactly that.)
119
+ //
120
+ // Quote markers are stripped: they are markdown holding the block inside
121
+ // run-team's verbatim prompt, not part of the text being copied. Stripped
122
+ // before the paragraph split too, so a `>`-only separator line still closes the
123
+ // paragraph rather than joining two.
124
+ function block(text, what, end) {
125
+ const paragraphs = text
126
+ .split("\n")
127
+ .map((l) => l.replace(/^>\s?/, ""))
128
+ .join("\n")
129
+ .split(/\n\s*\n/)
130
+ // Whitespace-normalized for the reason `prose-pin.mjs`'s `phrase()` is:
131
+ // these two files hard-wrap the same prose at different widths TODAY, so
132
+ // without this the pin refuses the copy it is supposed to accept.
133
+ .map((p) => p.split(/\s+/).join(" ").trim())
134
+ .filter((p) => p);
135
+ // Exactly one, not the first: a second paragraph opening the same way is a
136
+ // second copy, and `find` would compare one of them and leave the other free
137
+ // to say anything.
138
+ const hits = paragraphs.filter((p) => unemphasized(p).startsWith(unemphasized(OPENER)));
139
+ assert.equal(hits.length, 1, `${what}: expected exactly one paragraph opening "${OPENER}", found ${hits.length} — update this test`);
140
+ const rest = paragraphs.slice(paragraphs.indexOf(hits[0]) + 1);
141
+ // Guarded, or a stale end anchor runs the slice to EOF and swallows the whole
142
+ // rest of the file: still red, but red about the wrong thing.
143
+ const stop = rest.findIndex((p) => end.test(unemphasized(p)));
144
+ assert.notEqual(stop, -1, `${what}: nothing after the block matches ${end} — the end anchor is stale, update this test`);
145
+ const slice = [hits[0], ...rest.slice(0, stop)];
146
+ // Positive control. Both slices coming back empty is how an equality pin
147
+ // passes while asserting nothing, and a stale anchor is how they would get
148
+ // there; the check above only proves the paragraph STARTS somewhere.
149
+ assert.ok(hits[0].length > OPENER.length, `${what}: the block slice is no longer than its opener — the extractor is broken, not the docs`);
150
+ return slice.join("\n");
151
+ }
152
+
153
+ const source = (text = SKILL) => block(text, "agents/fleet-implementer.agent.md", SKILL_END);
154
+ const copy = (text = TRACKER) => block(text, "docs/agents/issue-tracker.md", TRACKER_END);
155
+
156
+ // Each side's own raw bytes, for the fixtures below to mutate. Both throw,
157
+ // naming the block, if it is gone, doubled or re-anchored — which is the
158
+ // staleness guard a hard-coded copy of the prose needed and could not have,
159
+ // and unlike that copy, this one names the actual cause.
160
+ //
161
+ // `paragraph` bounds the agent body's side at the block's own blank line, so a
162
+ // fixture built from it cannot run past the block's end onto the next block.
163
+ // That is not hypothetical tidiness: a sibling rewrap fixture in
164
+ // `dispatch-block-pins-prose.test.mjs` ran one line past its block, spliced two
165
+ // blocks onto one line, and left its own staleness guard vacuous (#1003).
166
+ //
167
+ // `emphasisTolerant: true` on both: OPENER carries no `**`, and `block` above
168
+ // already tolerates a `**` landing on its words via `unemphasized`. Without
169
+ // this, the same emphasis move throws HERE instead — `quoteBlock`/`anchorAt`
170
+ // matched the raw byte here, not the unemphasized view, so a fixture-locating
171
+ // anchor this file never meant to be emphasis-sensitive went stale on an edit
172
+ // `block` itself shrugs off (#1004, measured: `**Read the issue**` reddened
173
+ // both fixture-based tests below, not just this one, with a stale-anchor
174
+ // message rather than the growth or reflow they are meant to catch).
175
+ // The agent body carries the block as plain prose, like the tracker, so its
176
+ // bound is the paragraph too — no `>` run to bound it since #1804.
177
+ const skillBlock = () => paragraph(SKILL, OPENER, "the implementer body's issue-read block", { emphasisTolerant: true });
178
+ // The tracker's copy is plain prose in a `##` section, not a quote run, so its
179
+ // bound is the paragraph — `prose-pin.mjs`'s single definition of that bound,
180
+ // blank-line-terminated and anchored exactly once.
181
+ const trackerBlock = () => paragraph(TRACKER, OPENER, "the tracker's copy of the issue-read block", { emphasisTolerant: true });
182
+
183
+ // Gutter off, whitespace collapsed — the shape wrap width cannot change, used
184
+ // below to prove a rewrap moved the breaks and nothing else.
185
+ const flat = (s) =>
186
+ s
187
+ .split("\n")
188
+ .map((l) => l.replace(/^>\s?/, ""))
189
+ .join(" ")
190
+ .split(/\s+/)
191
+ .join(" ")
192
+ .trim();
193
+
194
+ // Re-wraps at word boundaries and nowhere else, at a width the file does not
195
+ // use, so the accept case is exercised at wrap points the tree does not
196
+ // currently contain. Never splits a word, so the words and their order are
197
+ // invariant — which is what makes the equality check on `flat` below a real
198
+ // guard against a corrupt fixture rather than a restatement of the wrap.
199
+ const rewrapOne = (text, width, gutter) => {
200
+ const lines = [[]];
201
+ let len = 0;
202
+ for (const word of flat(text).split(" ")) {
203
+ if (len && len + 1 + word.length > width) {
204
+ lines.push([]);
205
+ len = 0;
206
+ }
207
+ len += (len ? 1 : 0) + word.length;
208
+ lines.at(-1).push(word);
209
+ }
210
+ return lines.map((l) => `${gutter}${l.join(" ")}`).join("\n");
211
+ };
212
+
213
+ // Per quote-paragraph, not over the whole flattened run: once the block has
214
+ // grown a blank-gutter-line paragraph beside it (the growth test below),
215
+ // `skillBlock()` returns TWO `>` paragraphs, and flattening both into one run
216
+ // before wrapping — the previous shape of this function — deletes the
217
+ // internal separator between them. The rewrapped text comes back as a single
218
+ // paragraph, `block()` re-splits the untouched copy on the blank line it
219
+ // still has, and the equality check compares a 2-paragraph copy against a
220
+ // 1-paragraph rewrap with no cause named (#1004, measured: the only red was a
221
+ // bare equality diff on "a rewrapped copy still matches"). Splitting on the
222
+ // separator line first — gutter-only, so it matches whether the gutter is
223
+ // `> ` or absent — and rejoining with that same line after wrapping each
224
+ // piece keeps every paragraph's wrap independent and the separator intact
225
+ // either way.
226
+ const rewrap = (text, width, gutter) =>
227
+ text
228
+ .split(/\n[ \t]*(?:>[ \t]*)?\n/)
229
+ .map((part) => rewrapOne(part, width, gutter))
230
+ .join(`\n${gutter.trimEnd()}\n`);
231
+
232
+ test("the tracker's copy of the issue-read block carries the block whole", () => {
233
+ // Equality, not containment: every stale copy this section has produced has
234
+ // been a strict PREFIX of the block, and `includes()` accepts a prefix.
235
+ assert.equal(copy(), source());
236
+ });
237
+
238
+ test("a copy that stops short of the block's end reddens", () => {
239
+ // The refuse direction, built as a prefix because that is the shape the drift
240
+ // has actually taken twice. Derived from the live copy rather than quoting a
241
+ // sentence, so it still shortens a block that has grown since.
242
+ const short = copy().slice(0, copy().lastIndexOf(". ") + 1);
243
+ assert.notEqual(short, copy(), "the truncation fixture no longer shortens the copy — update it");
244
+ assert.notEqual(short, source());
245
+ });
246
+
247
+ test("a rewrapped copy still matches", () => {
248
+ // The accept direction. Feeding the comparison prose it MUST accept is the
249
+ // only thing pinning reflow-safety; a suite of already-matching inputs passes
250
+ // with the normalization deleted. Re-wrapping a doc is not drift, and a pin
251
+ // that reddened on it would be deleted by the next person who reflowed a
252
+ // paragraph.
253
+ //
254
+ // Both sides, because either file can be reflowed independently and the
255
+ // normalization that accepts one is not the one that accepts the other: the
256
+ // source side's breaks carry a `>` gutter and the copy side's do not.
257
+ //
258
+ // Replacer functions, not replacement strings: `$&`, `$'` and `` $` `` are
259
+ // interpreted in the latter, and these fixtures are whole blocks of prose
260
+ // nobody is auditing for `$`.
261
+ const skill = skillBlock();
262
+ const narrowSkill = rewrap(skill, 46, "");
263
+ assert.equal(flat(narrowSkill), flat(skill), "the source rewrap changed the block's words, not just its breaks — the fixture is corrupt, not the docs");
264
+ assert.notEqual(narrowSkill, skill, "the source rewrap no longer changes run-team's wrapping — pick a width the file does not already use");
265
+ assert.equal(copy(), source(SKILL.replace(skill, () => narrowSkill)));
266
+
267
+ const tracker = trackerBlock();
268
+ const narrowTracker = rewrap(tracker, 52, "");
269
+ assert.equal(flat(narrowTracker), flat(tracker), "the copy rewrap changed the block's words, not just its breaks — the fixture is corrupt, not the docs");
270
+ assert.notEqual(narrowTracker, tracker, "the copy rewrap no longer changes the tracker's wrapping — pick a width the file does not already use");
271
+ assert.equal(copy(TRACKER.replace(tracker, () => narrowTracker)), source());
272
+ });
273
+
274
+ test("upstream growth arriving as a new paragraph beside the block reddens", () => {
275
+ // The hole the paragraph break left, and the reason the end anchor moved past
276
+ // the rule: growth does not have to land inside the block's last paragraph.
277
+ // Test 1 covers the sentence-sized case; this is the same drift one size up,
278
+ // and under the paragraph-break slice it passed.
279
+ const skill = skillBlock();
280
+ const grown = SKILL.replace(skill, () => `${skill}\n\nIf the ticket names a linked PR, read that PR's diff too.`);
281
+ // Non-vacuity, and the assertion the hard-coded fixture used to stand in for:
282
+ // the appended paragraph has to land INSIDE the source slice, or the
283
+ // comparison below never sees the growth it is named for. Checked on the
284
+ // slice rather than on the file, because landing in the file is what
285
+ // `String.replace` guarantees and landing in the slice is what matters.
286
+ assert.match(source(grown), /linked PR/, "the growth fixture landed outside the slice — the end anchor stops short of the block, update this test");
287
+ assert.notEqual(source(grown), copy());
288
+ });