@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,201 @@
1
+ // #859. The fix-applier dispatch block (phase 3) is a `>` blockquote pasted
2
+ // VERBATIM into the fix-applier's prompt — the controller copies those lines
3
+ // as-is, it does not paraphrase them, and it does not chase a cross-reference
4
+ // out of the block. Before this ticket the block carried the mutation-testing
5
+ // rule and the re-derive-the-pin rule, but none of the three prose-discipline
6
+ // rules the implementer block carries, even though a fix-applier's whole job
7
+ // is writing prose after review — commit messages, deferral-issue rationale,
8
+ // its final report — on a snapshot nothing downstream re-reviews.
9
+ //
10
+ // Measured against `origin/main` before this file existed: an
11
+ // implementer-only search of the fix-applier's prompt slice —
12
+ // `awk 'NR==1483,NR==1631' skills/run-team/SKILL.md | grep -iE
13
+ // "settling command|positional|COUNT|tally"` — hit nothing but unrelated CI
14
+ // behind-count prose. No test in this suite pinned any of the three rules
15
+ // inside the fix-applier's own prompt slice either; the two files that pin
16
+ // this text (`immutable-body-claim-prose.test.mjs`,
17
+ // `cross-repo-citation-prose.test.mjs`) both scope to the IMPLEMENTER'S copy,
18
+ // which lives in `plugin/agents/fleet-implementer.agent.md`, not in this
19
+ // section of SKILL.md. `grep -n '### Reviewers\|You are ALREADY in
20
+ // worktree\|Put the standing CI facts\|Two of the rules above are what
21
+ // caught both\|Fallback: hand-dispatched' skills/run-team/SKILL.md` against
22
+ // this tree finds `You are ALREADY in worktree` exactly ONCE, opening the
23
+ // fix-applier's own prompt this file pins below — it does not recur
24
+ // anywhere else in SKILL.md.
25
+ //
26
+ // SHAPE, matching the convention every file beside this one uses. Each rule
27
+ // gets its own ordered-span assertion, gaps sized to the punctuation that
28
+ // actually separates the anchors today (a handful of characters) so a
29
+ // deletion of the connecting clause reds without a loose `.{0,N}?` papering
30
+ // over it. A positive regex over the whole fix-applier prompt — 1200+ chars —
31
+ // would be satisfied by equivalent wording anywhere else in the Reviewers
32
+ // section it happened to also match; these slices are bounded to the fix-applier
33
+ // prompt specifically (`reviewersSection()` below, mirroring
34
+ // `review-path-default.test.mjs`'s `fixApplierPrompt()`, duplicated rather
35
+ // than imported for the reason `implementer-model-tier.test.mjs` gives for
36
+ // its own copy: two files, seven lines, nothing detects drift between them).
37
+ //
38
+ // THE CEILING these pins have: they prove a phrase is PRESENT and ADJACENT
39
+ // to its neighbor. A sentence appended after a pinned span that carves out
40
+ // an exception touches no pinned fragment and stays green, and so does a
41
+ // clause inserted inside one of the gaps above while it has headroom.
42
+ //
43
+ // #1002 closed that half for this prompt, with a mechanism that is not a
44
+ // regex: `dispatch-block-golden-prose.test.mjs` holds a whole-block golden
45
+ // fixture for the fix-applier prompt — its nested refuter prompt included —
46
+ // and any insertion reds there, because the prompt no longer equals its
47
+ // known-good copy. An LLM judge and a schema'd rule format were the two
48
+ // candidates considered there and both were rejected.
49
+ //
50
+ // These pins were kept, not replaced. A golden red says the prompt changed
51
+ // and hands the reader a diff; a red here names the correction rule that
52
+ // went missing. Editing this prompt now reds both, deliberately: the golden
53
+ // is re-blessed in the same change, which is the review point these pins do
54
+ // not have.
55
+ //
56
+ // #859's own third acceptance criterion — the candidates.test.mjs live-count
57
+ // clause restated as a property — is NOT covered by this file. Verified
58
+ // against this tree: neither "62 tests" nor "61 unrelated tests" appears
59
+ // anywhere in `plugin/scripts/candidates.test.mjs` today. Commit `7eed0a8`
60
+ // ("docs(candidates.test): drop three claims the tree contradicts from the
61
+ // pin's comments") already replaced both clauses with measured, count-free
62
+ // prose before this branch started, so there is nothing left there for this
63
+ // ticket to fix or to pin.
64
+ import { test } from "node:test";
65
+ import assert from "node:assert/strict";
66
+ import { readFileSync } from "node:fs";
67
+ import { join } from "node:path";
68
+ import { between, phrase } from "./prose-pin.mjs";
69
+
70
+ const REPO = join(import.meta.dirname, "..");
71
+ const RUN_TEAM = readFileSync(join(REPO, "skills", "run-team", "SKILL.md"), "utf8");
72
+
73
+ // Scoped to the Reviewers section first, so an `indexOf`-based anchor search
74
+ // starts inside the fix-applier's own prompt rather than risking a match
75
+ // against equivalent wording elsewhere in the file, present or future.
76
+ const reviewersSection = () =>
77
+ between(RUN_TEAM, "### Reviewers", "#### Fallback: hand-dispatched reviewer", "run-team Reviewers section");
78
+
79
+ const PROMPT_ANCHOR = "> You are ALREADY in worktree";
80
+ const PROMPT_END = "\n**Put the standing CI facts";
81
+ const fixApplierPrompt = () =>
82
+ between(reviewersSection(), PROMPT_ANCHOR, PROMPT_END, "run-team fix-applier prompt");
83
+
84
+ // The implementer's own copy of the count rule, the OTHER seat #859 requires
85
+ // the qualification to reach. Bounded to the two-line span that opens on
86
+ // "give them to every implementer regardless of class" and closes on the
87
+ // immutable-body rule that follows it, so a rewording anywhere else in the
88
+ // correction-ticket block cannot satisfy this slice by accident.
89
+ const implementerCountRule = () =>
90
+ between(
91
+ RUN_TEAM,
92
+ "Two of the rules above are what caught both",
93
+ "The immutable-body rule earns the same",
94
+ "run-team implementer count-rule paragraph",
95
+ );
96
+
97
+ // `**` emphasis and the `>` blockquote gutter are stripped and whitespace
98
+ // collapsed before matching, so a pin survives a bold move or a rewrap.
99
+ // Single `*`/backtick are left alone — this slice's only single-`*` and
100
+ // backtick usage is code-quoted (`` `the closing/second/last X` ``,
101
+ // `` `every other test in the file` ``), never italics, so nothing here
102
+ // depends on preserving it.
103
+ const flatten = (s) =>
104
+ s
105
+ .split("\n")
106
+ .map((l) => l.replace(/^\s*>?\s?/, ""))
107
+ .join(" ")
108
+ .replace(/\*\*/g, "")
109
+ .split(/\s+/)
110
+ .join(" ")
111
+ .trim();
112
+
113
+ test("the fix-applier prompt carries the settling-command rule, tied to its citation caveat", () => {
114
+ const prompt = flatten(fixApplierPrompt());
115
+ assert.match(
116
+ prompt,
117
+ /Every factual claim your diff restates needs a settling command run against the tree first.{0,15}?the issue body is a lead, never a citation/,
118
+ "the fix-applier prompt no longer requires a settling command for every restated claim, or drops the caveat that the issue body is a lead and not a citation",
119
+ );
120
+ });
121
+
122
+ test("the fix-applier prompt carries the no-positional-references rule with its own example", () => {
123
+ const prompt = flatten(fixApplierPrompt());
124
+ assert.match(
125
+ prompt,
126
+ /No positional references.{0,15}?the closing\/second\/last X.{0,15}?name the thing semantically/,
127
+ "the fix-applier prompt no longer forbids a positional reference, or dropped the example/remedy pair that makes the rule actionable",
128
+ );
129
+ });
130
+
131
+ test("the fix-applier prompt's count rule is qualified — a live property is restated, a past-tense measurement is not", () => {
132
+ const prompt = flatten(fixApplierPrompt());
133
+ // One ordered span, not four presence checks. The failure this guards is
134
+ // not deletion of the rule — it is deleting only the qualification and
135
+ // leaving the bare "never write a COUNT" behind, which is exactly the
136
+ // unsafe, unqualified rule #859 measured minting a false claim once
137
+ // already (rewriting a correct past-tense record as a property).
138
+ assert.match(
139
+ prompt,
140
+ /Never write a COUNT or a tally into prose; state the property instead.{0,15}?unless it is a past-tense record of a measurement you performed, which stays as written.{0,10}?a present-tense claim about a live property must be restated as a property.{0,60}?true at any count/,
141
+ "the fix-applier prompt's count rule lost its past-tense/live-property qualification, its ordering, or one of its two halves",
142
+ );
143
+ });
144
+
145
+ test("the fix-applier prompt's settling grep takes -F over literal text and trusts a zero only after a known match", () => {
146
+ // #1087. One span, both halves: `-F` alone still lets a command that can
147
+ // never return non-zero write "absent" under `Verified:`, and the positive
148
+ // control alone leaves the pattern-reading of literal prose as the default.
149
+ assert.match(
150
+ flatten(fixApplierPrompt()),
151
+ phrase("A settling grep over literal text takes `grep -F`, and its zero counts only after the same command finds a line known to match"),
152
+ "the fix-applier prompt no longer tells a settling grep over literal text to take -F, or dropped the positive control that has to pass before its zero is trusted",
153
+ );
154
+ });
155
+
156
+ test("the implementer's own count rule carries the identical past-tense/live-property qualification", () => {
157
+ // #859's ruling is explicit that BOTH seats need this, not only the new
158
+ // copy — this is the pre-existing rule, being re-derived rather than left
159
+ // as the unsafe unqualified form the fix-applier copy above no longer has.
160
+ const rule = flatten(implementerCountRule());
161
+ assert.match(
162
+ rule,
163
+ /never write a COUNT or a tally into prose; state the property instead.{0,15}?unless it is a past-tense record of a measurement you performed, which stays as written.{0,10}?a present-tense claim about a live property must be restated as a property.{0,60}?true at any count/,
164
+ "the implementer's own count rule lost its past-tense/live-property qualification — #859 requires both seats to carry it, not only the fix-applier's new copy",
165
+ );
166
+ });
167
+
168
+ test("a rewrapped fix-applier prompt still matches every pinned rule — these pins refuse drift, not reflow", () => {
169
+ // ACCEPT side. The fixture is DERIVED from the live text, never a quoted
170
+ // line, so a meaning-preserving reword of the surrounding prompt is not
171
+ // what this test measures — only that re-wrapping the pinned paragraph at
172
+ // a column width nothing here assumes leaves every ordered span intact.
173
+ const raw = between(
174
+ fixApplierPrompt(),
175
+ "Every factual claim your diff restates",
176
+ "\n>\n> **Apply",
177
+ "the fix-applier's new prose-discipline paragraph",
178
+ );
179
+ const body = flatten(raw);
180
+ const words = body.split(/\s+/).filter(Boolean);
181
+ const lines = words.reduce((acc, w) => {
182
+ const last = acc[acc.length - 1];
183
+ if (last && `${last} ${w}`.length <= 40) acc[acc.length - 1] = `${last} ${w}`;
184
+ else acc.push(w);
185
+ return acc;
186
+ }, []);
187
+ const narrow = lines.map((l) => `> ${l}`).join("\n");
188
+ assert.notEqual(narrow, raw, "the rewrap fixture no longer changes the paragraph's wrapping — update it");
189
+ const rewrappedFile = RUN_TEAM.replace(raw, () => narrow);
190
+ const rewrappedReviewers = between(
191
+ rewrappedFile,
192
+ "### Reviewers",
193
+ "#### Fallback: hand-dispatched reviewer",
194
+ "rewrapped run-team Reviewers section",
195
+ );
196
+ const prompt = flatten(between(rewrappedReviewers, PROMPT_ANCHOR, PROMPT_END, "rewrapped fix-applier prompt"));
197
+ assert.match(prompt, phrase("Every factual claim your diff restates needs a settling command run against the tree first"));
198
+ assert.match(prompt, phrase("No positional references"));
199
+ assert.match(prompt, phrase("unless it is a past-tense record of a measurement you performed"));
200
+ assert.match(prompt, phrase("its zero counts only after the same command finds a line known to match"));
201
+ });
@@ -0,0 +1,100 @@
1
+ // #1802 (spec docs/specs/2026-09-24-slot-based-fleet-loop-design.md § 3 §4,
2
+ // §8). The fix-applier now reads the review off `<scratch>/review-<pr>.json`
3
+ // and owns every per-PR ruling the controller used to make before dispatch —
4
+ // both mutual-exclusion scans, the suggested-fix re-derivation, `refuted=false`
5
+ // ≠ apply, per-site measurement for a sibling-site extension, and reading
6
+ // `testEnvironment`/`cwdAudit` before acting on a `test_run`. Their new home is
7
+ // review-and-fix.md's `## The review result file`, which is the copy the
8
+ // fix-applier reads. The controller-side copies in run-team/SKILL.md are due to
9
+ // be retired once the controller stops making these rulings (§ 8), and a
10
+ // retirement that loses the destination copy too would leave the rulings made
11
+ // by nobody, with every pin that read SKILL.md simply deleted alongside it.
12
+ //
13
+ // Two halves. The recipes half is not prose: a `jq` path naming a field the
14
+ // result does not carry prints `null` at exit 0, which reads exactly like an
15
+ // empty bucket — so every top-level field the recipes read is checked against
16
+ // the keys the review really returns (DIGEST_KEYS + the bulk arrays, the order
17
+ // review-in-run-retry.test.mjs holds both review bodies to by running them).
18
+ import { test } from "node:test";
19
+ import assert from "node:assert/strict";
20
+ import { readFileSync } from "node:fs";
21
+ import { join } from "node:path";
22
+ import { between, phrase } from "./prose-pin.mjs";
23
+ import { DIGEST_KEYS } from "./review-core.mjs";
24
+
25
+ const REPO = join(import.meta.dirname, "..");
26
+ const DOC = readFileSync(join(REPO, "commands", "review-and-fix.md"), "utf8");
27
+ const RESULT_KEYS = new Set([...DIGEST_KEYS, "snapshot", "survived", "refuted", "unverified"]);
28
+
29
+ const section = () => between(DOC, "\n## The review result file\n", "\n## Specialists\n", "review-and-fix.md's result-file section");
30
+ const ruling = (lead) => {
31
+ // One paragraph per ruling: the document writes one line per paragraph, so
32
+ // the paragraph is the line the bold lead-in opens.
33
+ const line = section().split("\n").find((l) => l.startsWith(lead));
34
+ assert.ok(line, `review-and-fix.md's result-file section no longer opens a paragraph with ${JSON.stringify(lead)}`);
35
+ return line;
36
+ };
37
+
38
+ test("the fix-applier reads the review off the result file, at the path the runner and the controller write", () => {
39
+ assert.match(section(), phrase("`<scratch>/review-<pr>.json`"));
40
+ // Step 1's fix-applier branch is what sends a fix-applier here at all.
41
+ const step1 = between(DOC, "1. Run the review yourself.", "\n2. Plan the actions.", "review-and-fix.md step 1");
42
+ assert.match(step1, phrase("see **The review result file**"), "step 1 no longer points a fix-applier at the result file");
43
+ });
44
+
45
+ test("every top-level field the jq recipes read is a field the review returns", () => {
46
+ const recipes = section().match(/^jq .*$/gm) ?? [];
47
+ assert.ok(recipes.length >= 5, `found ${recipes.length} jq recipes — the section lost its reading recipes`);
48
+ const read = new Set();
49
+ for (const line of recipes) {
50
+ const program = line.match(/'([^']*)'/)?.[1];
51
+ assert.ok(program, `a jq recipe has no single-quoted program: ${line}`);
52
+ // A projection `{a, b}` reads each name; otherwise the program's first
53
+ // path segment is the field it reads (`.survived`, `[.unverified[] | ...`).
54
+ const projection = program.match(/^\{([^}]*)\}$/);
55
+ if (projection) for (const k of projection[1].split(",")) read.add(k.trim());
56
+ else read.add(program.match(/\.(\w+)/)[1]);
57
+ }
58
+ for (const field of read) {
59
+ assert.ok(RESULT_KEYS.has(field), `a jq recipe reads .${field}, which the review result does not carry — it would print null at exit 0`);
60
+ }
61
+ // Both inputs every other ruling depends on must actually be read.
62
+ for (const field of ["survived", "unverified", "refuted", "counts", "testEnvironment", "cwdAudit", "dimensionsUnrun", "resume"]) {
63
+ assert.ok(read.has(field), `no jq recipe reads .${field}`);
64
+ }
65
+ });
66
+
67
+ test("the crash populations are told apart off refutersDispatched in the recipes, never off severity", () => {
68
+ const recipes = (section().match(/^jq .*$/gm) ?? []).join("\n");
69
+ assert.match(recipes, /select\(\.refutersDispatched > 0\)/);
70
+ assert.match(recipes, /select\(\.refutersDispatched == 0\)/);
71
+ });
72
+
73
+ test("the fix-applier owns the mutual-exclusion scan, run twice, with a single refuter for a conflicting pair", () => {
74
+ const p = ruling("**Scan the findings against each other for MUTUAL EXCLUSION");
75
+ assert.match(p, phrase("run it twice"));
76
+ assert.match(p, phrase("**Before you apply anything**"));
77
+ assert.match(p, phrase("**Then as each refuter you dispatch reports**"));
78
+ assert.match(p, phrase("**A conflicting pair goes to a SINGLE refuter, briefed with both claims**"));
79
+ });
80
+
81
+ test("the fix-applier owns the suggested-fix re-derivation, ordered so the tree to derive from exists", () => {
82
+ const p = ruling("**A finding whose suggested fix quotes text another applied finding deletes");
83
+ assert.match(p, phrase("**Re-derive, never copy:**"));
84
+ assert.match(p, phrase("apply the finding that changes the text first"));
85
+ });
86
+
87
+ test("the fix-applier owns refuted=false ≠ apply, and per-site measurement for a sibling-site extension", () => {
88
+ assert.match(ruling("**A `refuted=false` verdict is not an instruction to apply.**"), phrase("is a defer"));
89
+ assert.match(
90
+ ruling("**Extending a finding to sibling sites is a new claim at every added site"),
91
+ phrase("never on a copied one"),
92
+ );
93
+ });
94
+
95
+ test("the fix-applier reads testEnvironment and cwdAudit before acting on any test_run, and re-runs nothing", () => {
96
+ const p = ruling("**Read `testEnvironment` and `cwdAudit` before you act on any `test_run`.**");
97
+ assert.match(p, phrase("status --porcelain -uall"), "the cwdAudit check lost its explicit untracked mode");
98
+ assert.match(p, phrase("never revert content you did not write"));
99
+ assert.match(p, phrase("re-run nothing"), "a dimensionsUnrun entry now reads as an instruction to re-run the review");
100
+ });
@@ -0,0 +1,155 @@
1
+ #!/usr/bin/env node
2
+ // The Resolver's one-time bootstrap (#1335, ADR 0003 point 4). Places a copy
3
+ // of `fleet-run` at `~/.fleet/bin/fleet-run` — the one artefact this repo
4
+ // owns OUTSIDE the plugin, because the Resolver cannot resolve itself and no
5
+ // per-session mechanism can carry it (nothing survives between harness
6
+ // Bash-tool calls). Idempotent: re-running reports "unchanged" once the
7
+ // placed copy already matches.
8
+ //
9
+ // SOURCE, and the one licensed exception. Every other script's rule is
10
+ // "only installed scripts run" (ADR 0003 point 3) — never a source checkout.
11
+ // This script's source is always ITS OWN sibling `fleet-run`, i.e. whatever
12
+ // directory this file itself is running from. Two shapes exist for that:
13
+ // - run as an INSTALLED script (this file's own directory IS a registry
14
+ // installPath's scripts/ — the steady state, e.g. invoked as
15
+ // `fleet-run fleet-bootstrap` once a Resolver already exists), or
16
+ // - run DIRECTLY FROM A CHECKOUT (this file's own directory is not any
17
+ // registered installPath) — the state the world is actually in the
18
+ // first time this ever runs, since no install anywhere yet carries
19
+ // `scripts/fleet-run`. ADR 0003 licenses exactly this once, loudly.
20
+ // This file cannot tell those apart by calling git (that would be exactly
21
+ // the self-location-derives-a-repo pattern #1335's audit test forbids); it
22
+ // tells them apart by comparing its own directory's PARENT against the
23
+ // registries' recorded installPath strings — a plain string compare, no git
24
+ // involved, so it never anchors a git root to its own location.
25
+ "use strict";
26
+
27
+ const fs = require("node:fs");
28
+ const path = require("node:path");
29
+ const os = require("node:os");
30
+ const crypto = require("node:crypto");
31
+
32
+ const NAME = "fleet-bootstrap";
33
+
34
+ function die(message) {
35
+ process.stderr.write(`${NAME}: ${message}\n`);
36
+ process.exit(2);
37
+ }
38
+
39
+ // The Install root, same resolution point as scripts/fleet-run (ADR 0021):
40
+ // the realpath of `~/.omp/plugins/node_modules/@feigi/fleet-ctl`. Absent or
41
+ // dangling answers null, which the caller reports as "omp: not installed".
42
+ function readInstallPath(packagePath) {
43
+ try {
44
+ return fs.realpathSync(packagePath);
45
+ } catch {
46
+ return null;
47
+ }
48
+ }
49
+
50
+ function sha256(buf) {
51
+ return crypto.createHash("sha256").update(buf).digest("hex");
52
+ }
53
+
54
+ // Both sides of the checkout-vs-install comparison, normalized the same
55
+ // way: `ownDir`'s parent may have been reached through a symlinked path
56
+ // (macOS resolves `/tmp` through `/private/tmp`, measured), and nothing
57
+ // forbids a resolved install root from carrying a trailing separator.
58
+ // `fs.realpathSync` where the path exists; a plain
59
+ // `path.normalize` with the trailing separator stripped otherwise (an
60
+ // absent/`null` install path, or one this process cannot stat) — either way
61
+ // the two sides are compared in the same shape rather than raw strings from
62
+ // two different sources.
63
+ function canonical(p) {
64
+ if (typeof p !== "string" || p === "") return p;
65
+ try {
66
+ return fs.realpathSync(p);
67
+ } catch {
68
+ return path.normalize(p).replace(/[\\/]+$/, "");
69
+ }
70
+ }
71
+
72
+ function main() {
73
+ const argv = process.argv.slice(2);
74
+ const fromCheckoutFlag = argv.includes("--from-checkout");
75
+
76
+ const ownDir = __dirname;
77
+ const source = path.join(ownDir, "fleet-run");
78
+
79
+ let sourceBuf;
80
+ try {
81
+ sourceBuf = fs.readFileSync(source);
82
+ } catch (e) {
83
+ die(`cannot read ${source} — bootstrap copies fleet-run from its OWN directory and found nothing there (${e.code || e.message})`);
84
+ }
85
+
86
+ const home = os.homedir();
87
+ const PLUGIN_KEY = "@feigi/fleet-ctl"; // ADR 0006 name; ADR 0021 — the node_modules package dir.
88
+ const ompInstall = readInstallPath(path.join(home, ".omp", "plugins", "node_modules", PLUGIN_KEY));
89
+ const parent = canonical(path.dirname(ownDir));
90
+ const runningFromInstall = parent === canonical(ompInstall);
91
+
92
+ const target = path.join(home, ".fleet", "bin", "fleet-run");
93
+
94
+ // The exception is opt-in, not merely announced: a stray checkout run
95
+ // (a wrong branch, a stale worktree) must not silently overwrite the one
96
+ // artefact outside the plugin. Every steady-state invocation — through
97
+ // the Resolver, once it exists — runs from an install and never needs
98
+ // this flag at all.
99
+ if (!runningFromInstall && !fromCheckoutFlag) {
100
+ die(
101
+ `refusing to place ${target} from ${ownDir}, which is not omp's resolved install root (looked at `
102
+ + `${ompInstall ? `omp: ${ompInstall}` : "omp: not installed"}) — re-run with --from-checkout to take `
103
+ + "ADR 0003's one-time bootstrap exception explicitly",
104
+ );
105
+ }
106
+
107
+ if (!runningFromInstall) {
108
+ process.stderr.write(
109
+ `${NAME}: BOOTSTRAP EXCEPTION — running from a source checkout (${ownDir}), not omp's resolved `
110
+ + "install root (looked at "
111
+ + `${ompInstall ? `omp: ${ompInstall}` : "omp: not installed"}). `
112
+ + "ADR 0003 licenses this ONCE, as the Resolver's own bootstrap, because no install anywhere yet carries "
113
+ + "scripts/fleet-run for an install-root-driven copy to come from. Every other fleet script must run through "
114
+ + "the Resolver once it exists.\n",
115
+ );
116
+ }
117
+
118
+ fs.mkdirSync(path.dirname(target), { recursive: true });
119
+
120
+ let existingBuf = null;
121
+ try {
122
+ existingBuf = fs.readFileSync(target);
123
+ } catch {
124
+ existingBuf = null;
125
+ }
126
+
127
+ const changed = existingBuf === null || !existingBuf.equals(sourceBuf);
128
+ if (changed) {
129
+ fs.writeFileSync(target, sourceBuf);
130
+ }
131
+ fs.chmodSync(target, 0o755);
132
+
133
+ const sourceHash = sha256(sourceBuf);
134
+ if (existingBuf === null) {
135
+ process.stdout.write(`${NAME}: wrote ${target} (new, sha256 ${sourceHash})\n`);
136
+ } else if (changed) {
137
+ process.stdout.write(`${NAME}: wrote ${target} (changed: sha256 ${sha256(existingBuf)} -> ${sourceHash})\n`);
138
+ } else {
139
+ process.stdout.write(`${NAME}: unchanged — ${target} already matches ${source} (sha256 ${sourceHash})\n`);
140
+ }
141
+ process.stdout.write(`${NAME}: source ${source}\n`);
142
+
143
+ const pathDirs = (process.env.PATH || "").split(path.delimiter);
144
+ const binDir = path.dirname(target);
145
+ if (pathDirs.includes(binDir)) {
146
+ process.stdout.write(`${NAME}: PATH already includes ${binDir}\n`);
147
+ } else {
148
+ process.stdout.write(
149
+ `${NAME}: PATH does not include ${binDir} — add it yourself if you want to run "fleet-run" bare `
150
+ + `(e.g. add \`export PATH="${binDir}:$PATH"\` to your shell rc); this script edits no rc file\n`,
151
+ );
152
+ }
153
+ }
154
+
155
+ main();