@feigi/fleet-ctl 3.23.35 → 3.23.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/package.json +1 -1
  2. package/scripts/main-checkout.mjs +1 -1
  3. package/scripts/member-write-guard.mjs +1 -1
  4. package/scripts/repo-root.mjs +1 -1
  5. package/skills/run-team/references/reaping.md +1 -1
  6. package/scripts/agent-test-dir-prose.test.mjs +0 -59
  7. package/scripts/agent-test.test.mjs +0 -1640
  8. package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
  9. package/scripts/ambient-git-vars-prose.test.mjs +0 -192
  10. package/scripts/ancestry-check-position-prose.test.mjs +0 -175
  11. package/scripts/apply-ruleset.test.mjs +0 -421
  12. package/scripts/arg-header-probes-prose.test.mjs +0 -394
  13. package/scripts/arg.test.mjs +0 -1354
  14. package/scripts/board-cli.test.mjs +0 -710
  15. package/scripts/board-identity.test.mjs +0 -429
  16. package/scripts/board-liveness-banner.test.mjs +0 -119
  17. package/scripts/board-prev-shape.test.mjs +0 -228
  18. package/scripts/board-tryparse-null.test.mjs +0 -119
  19. package/scripts/board.test.mjs +0 -3121
  20. package/scripts/brief-after-cut-prose.test.mjs +0 -53
  21. package/scripts/candidates-exit3-prose.test.mjs +0 -302
  22. package/scripts/candidates.test.mjs +0 -2312
  23. package/scripts/caveat-unification-prose.test.mjs +0 -98
  24. package/scripts/cell-readout.test.mjs +0 -615
  25. package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
  26. package/scripts/ci-completes-premise-prose.test.mjs +0 -257
  27. package/scripts/ci-state-prose.test.mjs +0 -113
  28. package/scripts/ci-state.test.mjs +0 -1933
  29. package/scripts/ci-vacuous-green.test.mjs +0 -368
  30. package/scripts/citation-sweep-prose.test.mjs +0 -1712
  31. package/scripts/claim-lifecycle.test.mjs +0 -187
  32. package/scripts/claim-ticket.test.mjs +0 -1122
  33. package/scripts/closing-keyword-prose.test.mjs +0 -193
  34. package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
  35. package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
  36. package/scripts/compute-board.test.mjs +0 -1214
  37. package/scripts/compute-spend.test.mjs +0 -517
  38. package/scripts/consumer-technology-prose.test.mjs +0 -126
  39. package/scripts/cross-repo-citation-prose.test.mjs +0 -155
  40. package/scripts/cwd-isolation-pins.mjs +0 -83
  41. package/scripts/dedupe-guard-prose.test.mjs +0 -243
  42. package/scripts/delete-merged-branch.test.mjs +0 -576
  43. package/scripts/derive-testcmd.test.mjs +0 -595
  44. package/scripts/diff-stats.test.mjs +0 -404
  45. package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
  46. package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
  47. package/scripts/dispositions-check.test.mjs +0 -936
  48. package/scripts/dispositions-gate-prose.test.mjs +0 -129
  49. package/scripts/drop-merged-label.test.mjs +0 -479
  50. package/scripts/exec-stub.mjs +0 -93
  51. package/scripts/exec-stub.test.mjs +0 -69
  52. package/scripts/expected-jobs-prose.test.mjs +0 -80
  53. package/scripts/fan-out-authorization-prose.test.mjs +0 -80
  54. package/scripts/filing-bar-seat-prose.test.mjs +0 -242
  55. package/scripts/filing-claim-bar-prose.test.mjs +0 -166
  56. package/scripts/finisher-died-prose.test.mjs +0 -31
  57. package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
  58. package/scripts/finisher-halt-prose.test.mjs +0 -106
  59. package/scripts/finisher-name-prose.test.mjs +0 -134
  60. package/scripts/finisher-own-tree-prose.test.mjs +0 -299
  61. package/scripts/finisher-pin-race-prose.test.mjs +0 -339
  62. package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
  63. package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
  64. package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
  65. package/scripts/fleet-bootstrap.test.mjs +0 -75
  66. package/scripts/fleet-heartbeat.test.mjs +0 -450
  67. package/scripts/fleet-provenance.test.mjs +0 -138
  68. package/scripts/fleet-run.test.mjs +0 -90
  69. package/scripts/fleet-state.test.mjs +0 -460
  70. package/scripts/fleet-tick-prose.test.mjs +0 -300
  71. package/scripts/fleet-tick.test.mjs +0 -2444
  72. package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
  73. package/scripts/frontmatter-check.test.mjs +0 -436
  74. package/scripts/git-env.test.mjs +0 -149
  75. package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
  76. package/scripts/gone-walk.test.mjs +0 -213
  77. package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
  78. package/scripts/head-moved-after-label-prose.test.mjs +0 -233
  79. package/scripts/immutable-body-claim-prose.test.mjs +0 -204
  80. package/scripts/implementer-model-tier.test.mjs +0 -235
  81. package/scripts/inflight-citation-prose.test.mjs +0 -144
  82. package/scripts/inflight-exit2-prose.test.mjs +0 -81
  83. package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
  84. package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
  85. package/scripts/inflight.test.mjs +0 -2882
  86. package/scripts/injection-control-prose.test.mjs +0 -404
  87. package/scripts/install-root-audit.test.mjs +0 -464
  88. package/scripts/instrument-check-prose.test.mjs +0 -235
  89. package/scripts/instruments.test.mjs +0 -787
  90. package/scripts/is-cli.test.mjs +0 -99
  91. package/scripts/issue-tracker-prose.test.mjs +0 -71
  92. package/scripts/json.test.mjs +0 -364
  93. package/scripts/ledger-dispatch.test.mjs +0 -927
  94. package/scripts/ledger-grammar.test.mjs +0 -227
  95. package/scripts/ledger-read-require-file.test.mjs +0 -197
  96. package/scripts/ledger-rotate.test.mjs +0 -142
  97. package/scripts/ledger.test.mjs +0 -3436
  98. package/scripts/line-distance-prose.test.mjs +0 -245
  99. package/scripts/liveness-rationale-prose.test.mjs +0 -83
  100. package/scripts/locale-pin-prose.test.mjs +0 -189
  101. package/scripts/main-checkout.test.mjs +0 -332
  102. package/scripts/member-outcome-prose.test.mjs +0 -167
  103. package/scripts/member-outcomes-header.test.mjs +0 -129
  104. package/scripts/member-outcomes-prose.test.mjs +0 -63
  105. package/scripts/member-outcomes.test.mjs +0 -638
  106. package/scripts/member-prompt-prose.test.mjs +0 -165
  107. package/scripts/member-record.test.mjs +0 -541
  108. package/scripts/member-write-guard.test.mjs +0 -214
  109. package/scripts/merge-commit-probe-prose.test.mjs +0 -122
  110. package/scripts/merge-gate.test.mjs +0 -613
  111. package/scripts/muted-git-guard-sweep.test.mjs +0 -493
  112. package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
  113. package/scripts/net-watchdog-prose.test.mjs +0 -79
  114. package/scripts/net.test.mjs +0 -211
  115. package/scripts/no-ci-gate-prose.test.mjs +0 -108
  116. package/scripts/no-undo-audit.test.mjs +0 -3961
  117. package/scripts/no-wave.test.mjs +0 -138
  118. package/scripts/node-floor-sweep.test.mjs +0 -611
  119. package/scripts/pointer-target-prose.test.mjs +0 -186
  120. package/scripts/pr-cost.test.mjs +0 -521
  121. package/scripts/pr-overlap.test.mjs +0 -692
  122. package/scripts/printf-die-sweep.test.mjs +0 -384
  123. package/scripts/prompt-renderer.mjs +0 -40
  124. package/scripts/prompt-renderer.test.mjs +0 -68
  125. package/scripts/prose-pin.mjs +0 -807
  126. package/scripts/prose-pin.test.mjs +0 -1034
  127. package/scripts/prove-merge.test.mjs +0 -995
  128. package/scripts/pull-table-relabel-prose.test.mjs +0 -60
  129. package/scripts/quiet-payload-prose.test.mjs +0 -222
  130. package/scripts/reap-cherry-check-prose.test.mjs +0 -80
  131. package/scripts/reap.test.mjs +0 -4432
  132. package/scripts/reaping-prose.test.mjs +0 -239
  133. package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
  134. package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
  135. package/scripts/recipe-derivation-prose.test.mjs +0 -112
  136. package/scripts/recipe-prove.test.mjs +0 -1042
  137. package/scripts/refuter-scratch-prose.test.mjs +0 -135
  138. package/scripts/release-label-required-prose.test.mjs +0 -71
  139. package/scripts/release-label-split-prose.test.mjs +0 -184
  140. package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
  141. package/scripts/release-ticket.test.mjs +0 -5099
  142. package/scripts/renovate-release-contract.test.mjs +0 -379
  143. package/scripts/repo-root.test.mjs +0 -873
  144. package/scripts/reporter-output-rule-prose.test.mjs +0 -208
  145. package/scripts/review-agent-report-only.test.mjs +0 -49
  146. package/scripts/review-core-booking.test.mjs +0 -35
  147. package/scripts/review-core-cwd-isolation.test.mjs +0 -374
  148. package/scripts/review-core-reads.test.mjs +0 -478
  149. package/scripts/review-core-refuter-scratch.test.mjs +0 -148
  150. package/scripts/review-core-scratch-refusal.test.mjs +0 -64
  151. package/scripts/review-core-shared-test-run.test.mjs +0 -275
  152. package/scripts/review-core-snapshot-path.test.mjs +0 -830
  153. package/scripts/review-core-specialist-scratch.test.mjs +0 -191
  154. package/scripts/review-core-testcmd.test.mjs +0 -335
  155. package/scripts/review-core-unrun.test.mjs +0 -566
  156. package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
  157. package/scripts/review-eval-resolver-path.test.mjs +0 -55
  158. package/scripts/review-host-fixture.mjs +0 -89
  159. package/scripts/review-in-run-retry.test.mjs +0 -211
  160. package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
  161. package/scripts/review-path-default.test.mjs +0 -796
  162. package/scripts/review-runner-spawns.test.mjs +0 -95
  163. package/scripts/review-runner.test.mjs +0 -166
  164. package/scripts/review-tier-audit.test.mjs +0 -140
  165. package/scripts/run-artifact-pr-prose.test.mjs +0 -341
  166. package/scripts/run-merge-bot-prose.test.mjs +0 -1413
  167. package/scripts/run-team-local-hook.test.mjs +0 -442
  168. package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
  169. package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
  170. package/scripts/section-between-guard-prose.test.mjs +0 -379
  171. package/scripts/select-dimensions.test.mjs +0 -674
  172. package/scripts/shared-refusal.test.mjs +0 -388
  173. package/scripts/shell-traps-prose.test.mjs +0 -504
  174. package/scripts/shortlist.test.mjs +0 -380
  175. package/scripts/slow-transport.mjs +0 -72
  176. package/scripts/snapshot-repo.test.mjs +0 -1006
  177. package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
  178. package/scripts/spend-view.test.mjs +0 -312
  179. package/scripts/staleness-qualifier-prose.test.mjs +0 -251
  180. package/scripts/staleness-verdict-prose.test.mjs +0 -142
  181. package/scripts/staleness.test.mjs +0 -893
  182. package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
  183. package/scripts/stash-prohibition-prose.test.mjs +0 -313
  184. package/scripts/strip-comments.mjs +0 -44
  185. package/scripts/temp-dir.mjs +0 -47
  186. package/scripts/ticket-router.test.mjs +0 -981
  187. package/scripts/tier-check.test.mjs +0 -828
  188. package/scripts/tier-outcomes-header.test.mjs +0 -518
  189. package/scripts/tier-outcomes.test.mjs +0 -572
  190. package/scripts/tier-roles.test.mjs +0 -535
  191. package/scripts/tracker-block-copy-prose.test.mjs +0 -288
  192. package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
  193. package/scripts/unattended-git-sweep.test.mjs +0 -142
  194. package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
  195. package/scripts/verify-sha.test.mjs +0 -692
  196. package/scripts/watcher-degraded-block.test.mjs +0 -369
  197. package/scripts/watcher-key-prose.test.mjs +0 -106
  198. package/scripts/within-run-pair-prose.test.mjs +0 -212
  199. package/scripts/worktree-audit.test.mjs +0 -1408
  200. package/scripts/worktree-head-prose.test.mjs +0 -276
  201. package/scripts/worktree-listing-sweep.test.mjs +0 -217
  202. package/scripts/worktree-model-prose.test.mjs +0 -216
  203. package/scripts/worktree-porcelain.mjs +0 -35
  204. package/scripts/worktree-porcelain.test.mjs +0 -102
@@ -1,517 +0,0 @@
1
- import { test } from "node:test";
2
- import assert from "node:assert/strict";
3
- import { classifyRole, computeSpend, attributeTools, mergeTools, canonicalMemberName, CANONICAL_MEMBER_NAME_PREFIXES } from "./compute-spend.mjs";
4
- import { foldOmpTranscript, parseMemberName } from "./member-record.mjs";
5
-
6
- const agent = (o) => ({ label: "x", role: "other", cacheWrite: 0, output: 0, cacheRead: 0, ...o });
7
-
8
- const call = (id, name, cacheWrite = 0) => ({ kind: "assistant", cacheWrite, tools: [{ id, name }] });
9
- const result = (...rs) => ({ kind: "result", results: rs.map(([id, chars]) => ({ id, chars })) });
10
-
11
- test("a tool result's cost is the NEXT assistant turn's cache write, not its own turn's", () => {
12
- // The turn that CALLS a tool has not seen the result yet, so charging it there
13
- // would credit the cost to whatever the agent happened to do beforehand.
14
- const tools = attributeTools([
15
- call("t1", "Bash", 100),
16
- result(["t1", 500]),
17
- { kind: "assistant", cacheWrite: 900, tools: [] },
18
- ]);
19
- assert.equal(tools.length, 1);
20
- assert.equal(tools[0].tool, "Bash");
21
- assert.equal(tools[0].cacheWrite, 900);
22
- assert.equal(tools[0].resultChars, 500);
23
- assert.equal(tools[0].calls, 1);
24
- });
25
-
26
- test("a multi-result turn splits proportionally by result size", () => {
27
- const tools = attributeTools([
28
- { kind: "assistant", cacheWrite: 0, tools: [{ id: "a", name: "Read" }, { id: "b", name: "Grep" }] },
29
- result(["a", 750], ["b", 250]),
30
- { kind: "assistant", cacheWrite: 1000, tools: [] },
31
- ]);
32
- const by = Object.fromEntries(tools.map((t) => [t.tool, t.cacheWrite]));
33
- assert.equal(by.Read, 750);
34
- assert.equal(by.Grep, 250);
35
- });
36
-
37
- // Shared with the omp tests below, which fold the same stream out of omp's
38
- // own line shape and must attribute it identically.
39
- const CONSECUTIVE = [
40
- { kind: "assistant", cacheWrite: 0, tools: [{ id: "a", name: "Read" }, { id: "b", name: "Grep" }] },
41
- result(["a", 750]),
42
- result(["b", 250]),
43
- { kind: "assistant", cacheWrite: 1000, tools: [] },
44
- ];
45
- const ORPHAN = [result(["orphan", 100]), { kind: "assistant", cacheWrite: 50, tools: [] }];
46
-
47
- test("CONSECUTIVE result entries accumulate — that, not one multi-result entry, is the real shape", () => {
48
- // Regression: parallel tool calls arrive as N single-result entries in a row,
49
- // not as one entry carrying several results (see the attributeTools comment).
50
- // Replacing `pending` per result entry dropped every batch but the last, and
51
- // made the proportional split unreachable.
52
- const tools = attributeTools(CONSECUTIVE);
53
- const by = Object.fromEntries(tools.map((t) => [t.tool, t.cacheWrite]));
54
- assert.equal(by.Read, 750);
55
- assert.equal(by.Grep, 250);
56
- });
57
-
58
- test("an all-empty result batch still splits evenly rather than vanishing", () => {
59
- // A tool that returns nothing still costs a turn to process; dropping it would
60
- // silently under-report the cheap-but-chatty tools.
61
- const tools = attributeTools([
62
- { kind: "assistant", cacheWrite: 0, tools: [{ id: "a", name: "Read" }, { id: "b", name: "Grep" }] },
63
- result(["a", 0], ["b", 0]),
64
- { kind: "assistant", cacheWrite: 400, tools: [] },
65
- ]);
66
- const by = Object.fromEntries(tools.map((t) => [t.tool, t.cacheWrite]));
67
- assert.equal(by.Read, 200);
68
- assert.equal(by.Grep, 200);
69
- });
70
-
71
- test("a result whose tool_use id was never seen is counted as unknown, not dropped", () => {
72
- const tools = attributeTools(ORPHAN);
73
- assert.equal(tools[0].tool, "unknown");
74
- assert.equal(tools[0].cacheWrite, 50);
75
- });
76
-
77
- test("a trailing result with no following assistant turn costs nothing but is still counted", () => {
78
- // Truncated transcripts are normal — an agent killed mid-turn. The call and the
79
- // bytes are real; the cache write never happened, so attributing one would invent spend.
80
- const tools = attributeTools([call("t1", "Bash", 0), result(["t1", 900])]);
81
- assert.equal(tools[0].calls, 1);
82
- assert.equal(tools[0].resultChars, 900);
83
- assert.equal(tools[0].cacheWrite, 0);
84
- });
85
-
86
- // #1717: omp's side of the two fixtures above, as lines in the shape measured
87
- // against real ~/.omp/agent/sessions/** (member-record.mjs's foldOmpTranscript
88
- // comment): the call is a `toolCall` block on the assistant message, and each
89
- // result is a `toolResult` message line of its own naming the call's id.
90
- const ompMsg = (message) =>
91
- JSON.stringify({ type: "message", id: "e1", parentId: null, timestamp: "2026-09-26T10:00:00.000Z", message });
92
- const ompTurn = (cacheWrite, ...calls) => ompMsg({
93
- role: "assistant", model: "claude-opus-5", stopReason: calls.length ? "toolUse" : "stop",
94
- content: calls.map(([id, name]) => ({ type: "toolCall", id, name, arguments: {}, intent: "x" })),
95
- usage: { input: 1, output: 1, cacheRead: 0, cacheWrite, totalTokens: 2 + cacheWrite, cost: { total: 0.01 } },
96
- });
97
- const ompResult = (id, toolName, chars) => ompMsg({
98
- role: "toolResult", toolCallId: id, toolName, isError: false, timestamp: 1790415990525, details: {},
99
- content: [{ type: "text", text: "x".repeat(chars) }],
100
- });
101
- const ompTools = (...lines) => attributeTools(foldOmpTranscript(lines.join("\n"), "/fake/omp.jsonl").entries);
102
-
103
- test("omp: parallel results split the next turn's cache write, same as the synthetic fixture above (#1717)", () => {
104
- // Parallel calls land on omp as consecutive toolResult lines too — measured,
105
- // the batch sizes match the calls-per-turn counts — so this is the real
106
- // shape of the proportional split.
107
- const tools = ompTools(ompTurn(0, ["a", "Read"], ["b", "Grep"]), ompResult("a", "Read", 750), ompResult("b", "Grep", 250), ompTurn(1000));
108
- assert.deepEqual(tools, attributeTools(CONSECUTIVE));
109
- const by = Object.fromEntries(tools.map((t) => [t.tool, [t.calls, t.resultChars, t.cacheWrite]]));
110
- assert.deepEqual(by, { Read: [1, 750, 750], Grep: [1, 250, 250] });
111
- });
112
-
113
- test("omp: a result whose call never landed in an assistant message is unknown (#1717)", () => {
114
- // The measured way this happens: a turn aborted mid-stream writes the tool's
115
- // synthetic "not executed" result, then persists the assistant message with
116
- // empty content, so no `toolCall` block ever carries the id. The result line
117
- // names the tool itself, but the stream is id-only.
118
- const tools = ompTools(ompResult("orphan", "bash", 100), ompTurn(50));
119
- assert.deepEqual(tools, attributeTools(ORPHAN));
120
- assert.deepEqual(tools.map((t) => [t.tool, t.calls, t.resultChars, t.cacheWrite]), [["unknown", 0, 100, 50]]);
121
- });
122
-
123
- test("mergeTools sums across agents and recomputes shares over the merged total", () => {
124
- const merged = mergeTools([
125
- [{ tool: "Bash", calls: 2, resultChars: 100, cacheWrite: 300, pct: 100 }],
126
- [{ tool: "Bash", calls: 1, resultChars: 50, cacheWrite: 100, pct: 50 },
127
- { tool: "Read", calls: 4, resultChars: 20, cacheWrite: 100, pct: 50 }],
128
- ]);
129
- const by = Object.fromEntries(merged.map((t) => [t.tool, t]));
130
- assert.equal(by.Bash.calls, 3);
131
- assert.equal(by.Bash.cacheWrite, 400);
132
- assert.equal(by.Bash.resultChars, 150);
133
- assert.equal(by.Read.pct, 20);
134
- assert.equal(merged[0].tool, "Bash"); // sorted by spend
135
- });
136
-
137
- test("depth beats description for review-shaped names — fan-out is not reviewer spend", () => {
138
- // The fan-out names grandchildren things like "Review PR 539 correctness".
139
- // Matching description first would book half the specialist spend as reviewer
140
- // spend and destroy the only number that matters.
141
- assert.equal(classifyRole({ spawnDepth: 1, description: "Review PR 539 correctness" }), "specialist");
142
- assert.equal(classifyRole({ spawnDepth: 2, description: "Implement ticket 540" }), "specialist");
143
- });
144
-
145
- test("the controller's own UNNAMED dispatches are depth 1 too — sizing is not fan-out", () => {
146
- // Regression: only NAMED members are depth 0. The phase-0 sizing agents are
147
- // dispatched straight from the controller but unnamed, so they arrive at
148
- // depth 1 looking exactly like a specialist. Classifying on depth alone put
149
- // all five in "specialist" and moved the review headline from 83% to 87%.
150
- assert.equal(classifyRole({ spawnDepth: 1, description: "Size candidate batch A" }), "sizing");
151
- assert.equal(classifyRole({ spawnDepth: 1, description: "Size ticket 531" }), "sizing");
152
- });
153
-
154
- test("the sizing pattern is anchored, so a specialist that mentions sizing stays a specialist", () => {
155
- assert.equal(classifyRole({ spawnDepth: 1, description: "Review PR 539 — check batch sizing logic" }), "specialist");
156
- });
157
-
158
- test("the memory exclusion reads the recorded DEFINITION, so any member name books memory", () => {
159
- // #1505. The exclusion used to test the one `agentType` parameter, which the
160
- // pre-cutover reader filled with the member's NAME — so the same dispatch
161
- // (`memory-housekeeper`) booked three different roles depending on what it
162
- // was called: `memory-housekeeper` memory, `housekeeper` other,
163
- // `brain-housekeeping` specialist. Measured on the corpus that last one alone
164
- // moved its session's review-spend headline 40.70% -> 62.37%.
165
- // "brain-housekeeping" is the historical incident (#1505) and the only name
166
- // of the four originally listed here that a mutation pass found load-bearing:
167
- // it is the one whose NAME does not itself contain "memory-housekeeper", so
168
- // it is the one that would slip to "specialist" if the exclusion ever read
169
- // the member's NAME instead of its recorded DEFINITION.
170
- assert.equal(
171
- classifyRole({ agentDefinition: "memory-housekeeper", memberName: "brain-housekeeping", spawnDepth: 1, description: "Housekeep the brain" }),
172
- "memory",
173
- );
174
- // Depth 1 above is the load-bearing half: the specialist rule is what caught
175
- // `brain-housekeeping`, so this stays red if the exclusion moves below it.
176
- assert.equal(classifyRole({ agentDefinition: "memory-proxy", memberName: "review-eval", spawnDepth: 2 }), "memory");
177
- });
178
-
179
- test("an untyped dispatch, recorded as the generic `task` or as no definition, still classifies by its NAME", () => {
180
- // #1505's other half. The default agent records the literal `task` in
181
- // `session_init`, and a transcript with no `session_init` line records no
182
- // definition at all; neither names a memory agent or any fleet definition, so
183
- // the name is the only memory signal those members have. Re-measured
184
- // 2026-10-04: over the Claude Code `meta.json` sidecars under
185
- // ~/.claude/projects (the reader #1505 fixed, since dropped from
186
- // member-record.mjs) three members booked memory on their name alone, each
187
- // with no definition recorded and none with `task`; over the omp members on
188
- // disk none did, under `task` or without a definition. Dropping the name
189
- // would put `memory-housekeeper` (named for its own definition, at depth 1)
190
- // in the SPECIALIST bucket, which is the very defect #1505 reports.
191
- assert.equal(foldOmpTranscript(JSON.stringify({ type: "session_init", agent: "task" }), "/fake/omp.jsonl").agent, "task");
192
- assert.equal(foldOmpTranscript(JSON.stringify({ type: "session" }), "/fake/omp.jsonl").agent, null);
193
- assert.equal(classifyRole({ agentDefinition: "task", memberName: "memory-proxy-session-review-2-3" }), "memory");
194
- assert.equal(classifyRole({ agentDefinition: "task", memberName: "memory-housekeeper", spawnDepth: 1 }), "memory");
195
- // `task` matches no definition branch, so with a name it is the name that
196
- // decides and without one nothing does.
197
- assert.equal(classifyRole({ agentDefinition: "task", memberName: "fix-pr-1380" }), "reviewer");
198
- assert.equal(classifyRole({ agentDefinition: "task" }), "other");
199
- assert.equal(classifyRole({ agentDefinition: "", memberName: "memory-proxy-session-review-2-3" }), "memory");
200
- assert.equal(classifyRole({ agentDefinition: "", memberName: "memory-housekeeper", spawnDepth: 1 }), "memory");
201
- // ...and it is still not a guess: a name carrying no memory agent falls
202
- // through to the ordinary signals rather than being read as memory-adjacent.
203
- assert.equal(classifyRole({ agentDefinition: "", memberName: "impl-1505", description: "Implement ticket 1505" }), "implementer");
204
- });
205
-
206
- test("a memory agent named only in the dispatch PROSE does not book memory", () => {
207
- // The false-positive half, and the reason `desc` is excluded from the
208
- // exclusion's input: every memory-adjacent fleet member's own prompt names
209
- // the memory agents, so blending prose would book the lot of them memory and
210
- // quietly drain the buckets anyone reads.
211
- assert.equal(classifyRole({ description: "Relay the finding to memory-proxy, then finish PR 563" }), "finisher");
212
- assert.equal(classifyRole({ memberName: "fix-pr-1505", description: "Fix PR 1505 — memory-housekeeper writes the wrong scope" }), "reviewer");
213
- assert.equal(classifyRole({ description: "Ask memory-housekeeper about it", spawnDepth: 1 }), "specialist");
214
- });
215
-
216
- test("depth-0 fleet roles come off the controller's naming convention", () => {
217
- assert.equal(classifyRole({ spawnDepth: 0, description: "Implement ticket 556" }), "implementer");
218
- assert.equal(classifyRole({ spawnDepth: 0, description: "Review PR 564" }), "reviewer");
219
- assert.equal(classifyRole({ spawnDepth: 0, description: "Finish PR 563" }), "finisher");
220
-
221
- assert.equal(classifyRole({ spawnDepth: 0, description: "something else entirely" }), "other");
222
- });
223
-
224
- test("the NAME wins over an earlier-checked prose keyword — the fixed branch order must not let description hijack a name-resolved role (#1506)", () => {
225
- // Blending `${memberName} ${description}` into one haystack before running
226
- // classifyRole's fixed-order branches (implementer -> reviewer -> finisher
227
- // -> merge-bot) let a member's own free-text description satisfy an
228
- // EARLIER branch than the one its canonical NAME would hit, hijacking the
229
- // classification. Measured live: `finisher-1380` described as "Fix PR 1380
230
- // review findings." matched the reviewer branch on "review" in the prose
231
- // before the finisher branch ever saw the name; `merge-bot-12` described
232
- // with "...review findings" misread the same way as finisher. The name
233
- // must be checked alone, ahead of the blend.
234
- assert.equal(
235
- classifyRole({ memberName: "finisher-1380", description: "Fix PR 1380 review findings." }),
236
- "finisher",
237
- );
238
- assert.equal(
239
- classifyRole({ memberName: "merge-bot-12", description: "Finish PR 1420, apply the review findings" }),
240
- "merge-bot",
241
- );
242
- // Control: a member with NO canonical name still falls through to the
243
- // prose blend exactly as before — this fix only reorders, it does not
244
- // remove the description-only fallback.
245
- assert.equal(classifyRole({ description: "Fix PR 1380 review findings." }), "reviewer");
246
- });
247
-
248
- test("resolve-pr-<n> books review spend, off the real dispatched name (#1250)", () => {
249
- // Real recorded rows, both previously "other" for want of a name match:
250
- // `resolve-pr-1232` ("Resolve conflict on PR 1232", session caf66206) and
251
- // `resolve-pr-1310` ("Rebase and resolve conflicts for PR #1310", session
252
- // 28488458). Descriptions deliberately carry no other review word, so the
253
- // NAME has to carry the match, the same discipline the finisher spellings
254
- // above are held to.
255
- assert.equal(classifyRole({ memberName: "resolve-pr-1232", description: "Resolve conflict on PR 1232" }), "reviewer");
256
- assert.equal(classifyRole({ memberName: "resolve-pr-1310", description: "Rebase and resolve conflicts for PR #1310" }), "reviewer");
257
- // The bare prose form ("resolve pr" with no name carrying the PR number)
258
- // is deliberately NOT matched: neither real cited description above
259
- // contains it adjacently ("resolve conflict on pr", "resolve conflicts
260
- // for pr" — never "resolve pr" together), so it would be untested reach.
261
- // Matching it ahead of the finisher check below would let an unrelated
262
- // finisher's description that happens to mention "resolve" near "pr"
263
- // hijack its classification away from its own name.
264
- assert.equal(classifyRole({ memberName: "finisher-pr-436", description: "Resolve PR conflicts left by review findings" }), "finisher");
265
- // It must not be swept into merge-bot: this member's number is a PR, never
266
- // a per-run dispatch counter, and merge-bot drains a pass's PRs rather than
267
- // resolving one.
268
- assert.equal(classifyRole({ memberName: "merge-bot-8", description: "Merge pass 8" }), "merge-bot");
269
- });
270
-
271
- test("finish-<n> member names classify as finisher — a historical spelling that must stay classifiable", () => {
272
- // `finisher-pr-<n>` is the canonical finisher name (#326); `finish-<n>` is a
273
- // spelling earlier runs actually dispatched and recorded runs still have to
274
- // classify. The match has to come off the member NAME, not the literal words
275
- // "finish pr" or "finisher": the description deliberately does NOT start with
276
- // `finish-`, so an implementation keying on `description` alone fails here.
277
- assert.equal(classifyRole({ memberName: "finish-436", description: "Apply reviewer findings for PR 436" }), "finisher");
278
- // ...and the `^` has to be a real anchor: `finish-` mid-string is not a
279
- // finisher. Without this, dropping the anchor leaves the case above green.
280
- assert.equal(classifyRole({ spawnDepth: 0, description: "Rework the finish-label docs" }), "other");
281
- // A two-ticket finisher was dispatched as `finish-<n>-<m>`, so the pattern has
282
- // to match on the prefix rather than on a `finish-<digits>` shape. Its
283
- // description carries no finisher word either, for the same reason as above.
284
- assert.equal(classifyRole({ spawnDepth: 0, memberName: "finish-424-425", description: "Apply reviewer findings for PR 424 and 425" }), "finisher");
285
- });
286
-
287
- test("missing meta never throws — a transcript with no sibling .meta.json still counts", () => {
288
- assert.equal(classifyRole(undefined), "other");
289
- assert.equal(classifyRole({}), "other");
290
- });
291
-
292
- test("implementers classify off the member NAME, which is where `impl-` actually appears", () => {
293
- // `^impl-` is anchored against `${memberName} ${description}`, so it only ever
294
- // fires via the name. Pin that coupling — the description alone never matches.
295
- // It is the NAME and not the definition on purpose: `impl-332` is what the
296
- // controller called the member, never an agent definition that exists (#1505).
297
- assert.equal(classifyRole({ spawnDepth: 0, memberName: "impl-332", description: "whatever" }), "implementer");
298
- assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "impl-332", description: "whatever" }), "other");
299
- });
300
-
301
- test("a member family spelled PascalCase or without hyphens classifies off the name like its kebab form (#2396)", () => {
302
- // omp task names are free-form, and controllers have dispatched the same
303
- // families as `Impl327`, `FixPr774`, `Fix-pr-766`, `ReviewPR77`. The
304
- // descriptions carry no role word, so only the name can carry the match.
305
- const role = (memberName) => classifyRole({ spawnDepth: 0, memberName, description: "whatever" });
306
- assert.equal(role("Impl327"), "implementer");
307
- assert.equal(role("FixPr774"), "reviewer");
308
- assert.equal(role("Fix-pr-766"), "reviewer");
309
- assert.equal(role("ReviewPR77"), "reviewer");
310
- assert.equal(role("ResolvePr1232"), "reviewer");
311
- assert.equal(role("FinisherPr1567b"), "finisher");
312
- assert.equal(role("Finish436"), "finisher");
313
- assert.equal(role("MergeBot12"), "merge-bot");
314
- // What it must still REFUSE: a generated word pair that merely starts with a
315
- // family word is not that family. Kebab-casing these wholesale would turn
316
- // `FinishSetupDocs` into `finish-setup-docs`, which `^finish-` books.
317
- assert.equal(role("FinishSetupDocs"), "other");
318
- assert.equal(role("Implementer5"), "other");
319
- assert.equal(role("ImplPlan"), "other");
320
- });
321
-
322
- test("canonicalMemberName rewrites only a whole family-number name (#2396)", () => {
323
- // The start anchor: a name that merely ENDS in a family spelling is not one.
324
- assert.equal(canonicalMemberName("Xfix-pr-5"), "Xfix-pr-5");
325
- assert.equal(canonicalMemberName("Setup-Impl3"), "Setup-Impl3");
326
- // The number is required: a bare family word has no ticket to name.
327
- for (const bare of ["Impl", "FixPr", "ReviewPr", "MergeBot"]) {
328
- assert.equal(canonicalMemberName(bare), bare);
329
- assert.equal(classifyRole({ spawnDepth: 0, memberName: bare, description: "whatever" }), "other");
330
- }
331
- // Surrounding whitespace is dropped before matching, for the join key and the role alike.
332
- assert.equal(canonicalMemberName(" Impl327 "), "impl-327");
333
- assert.equal(parseMemberName(" Impl327 ").ticket, "327");
334
- assert.equal(parseMemberName(" impl-327 ").ticket, "327");
335
- assert.equal(classifyRole({ spawnDepth: 0, memberName: " impl-327 ", description: "whatever" }), "implementer");
336
- });
337
-
338
- test("every canonical member-name prefix round-trips from its PascalCase and hyphenless spellings (#2396)", () => {
339
- // A family added to the prefix list that the spelling pattern does not cover
340
- // would be a stem member-record accepts but this rewrite leaves blank.
341
- const stems = CANONICAL_MEMBER_NAME_PREFIXES.replace("finish(?:er)?", "finish|finisher").split("|");
342
- assert.ok(stems.includes("fix-pr") && stems.includes("finisher"), "the expansion above must still yield the stems it is checked against");
343
- for (const stem of stems) {
344
- const pascal = stem.split("-").map((w) => w[0].toUpperCase() + w.slice(1)).join("");
345
- for (const spelling of [`${pascal}12`, `${stem.replaceAll("-", "")}12`, `${stem}-12`]) {
346
- assert.equal(canonicalMemberName(spelling), `${stem}-12`, spelling);
347
- }
348
- }
349
- });
350
-
351
- test("the omp review fan-out classifies off its agent DEFINITION — depth cannot reach it there", () => {
352
- // The depth check above books a nested fan-out whose specialists are the
353
- // reviewer's grandchildren under that shape. omp has no such nesting: its
354
- // `review-eval.mjs` inside the CONTROLLER's own session, so every fan-out
355
- // member arrives at depth 0 and falls through to the description patterns —
356
- // which is the exact "Review PR 539 correctness" misread the depth check
357
- // exists to prevent. Measured 2026-09-16 over the live corpus: 466 of 477
358
- // `fleet-review-*` rows sit at depth 0, and one definition
359
- // (`fleet-review-verifier`) split across four buckets — 211 other, 172
360
- // reviewer, 20 finisher, 2 merge-bot — on nothing but prompt wording.
361
- assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "fleet-review-verifier", description: "Refute finding unv1 on PR 1353" }), "specialist");
362
- assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "fleet-review-correctness", description: "Review PR 1353 correctness" }), "specialist");
363
- assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "fleet-review-snapshot", description: "Cut the snapshot for PR 1353" }), "specialist");
364
- // And the definition is the ONLY thing these two branches read: a member
365
- // merely NAMED after a review definition was not dispatched as one (#1505) —
366
- // `def` empty and `name` carrying the review-shaped string falls through to
367
- // the description-inclusive fallback below, which has no "fleet-review-"
368
- // pattern of its own (only `review pr`/`review-pr-`/etc.), so it resolves
369
- // "other" rather than "specialist".
370
- assert.equal(classifyRole({ spawnDepth: 0, memberName: "fleet-review-verifier", description: "whatever" }), "other");
371
- });
372
-
373
- test("the omp review RUNNER is the reviewer member, not a fan-out specialist, though its definition shares the prefix", () => {
374
- // #1802. `fleet-review-runner` is the definition the controller dispatches
375
- // as `review-pr-<n>` — the member that HOLDS a review, at depth 0, whose
376
- // own fan-out is the specialists. The `fleet-review-` prefix the branch
377
- // above books as "specialist" would swallow it on the definition alone,
378
- // before the `review-pr-` name ever got read.
379
- assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "fleet-review-runner", memberName: "review-pr-1353", description: "whatever" }), "reviewer");
380
- // Exact, not a second prefix: every dimension definition still books as the
381
- // fan-out it is, including one whose key merely starts with `runner`.
382
- assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "fleet-review-runner-probe", description: "whatever" }), "specialist");
383
- assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "fleet-review-correctness", memberName: "review-pr-1353", description: "whatever" }), "specialist");
384
- // Depth still wins: whatever runs UNDER a runner is its fan-out.
385
- assert.equal(classifyRole({ spawnDepth: 1, agentDefinition: "fleet-review-runner", description: "whatever" }), "specialist");
386
- });
387
-
388
- test("a definition name in the dispatch PROSE is not a dispatch — the fleet branches read `def` alone", () => {
389
- // The false-positive half. Every fleet member's own prompt says what it is, so
390
- // these names appear in description text constantly; matching the
391
- // `${memberName} ${description}` blend would book a finisher that merely
392
- // mentions the review fan-out as one of its specialists.
393
- assert.equal(classifyRole({ spawnDepth: 0, description: "Relay the report to fleet-review-verifier" }), "other");
394
- assert.equal(classifyRole({ spawnDepth: 0, description: "Dispatch every implementer as fleet-implementer" }), "other");
395
- // And the control that must stay GREEN: prose-only input still classifies by
396
- // its prose, so this narrowing did not cost the description patterns anything.
397
- assert.equal(classifyRole({ spawnDepth: 0, description: "Apply fleet-review-verifier findings, then finish PR 563" }), "finisher");
398
- });
399
-
400
- test("the fleet implementer definitions classify as implementer, independent of the `^impl-` name pattern", () => {
401
- // `agentDefinition`-based classification (`fleet-implementer-<cell>`) is
402
- // checked BEFORE the `^impl-` name/description pattern below it, so it must
403
- // not depend on a canonically-shaped member name to fire — this pin
404
- // exercises classifyRole directly, on `agentDefinition` alone, so it stays
405
- // green whatever the reader hands `memberName`.
406
- //
407
- // Historically this was the ONLY implementer signal an omp member had:
408
- // before #1486, `agentDefinition` did not reach classifyRole from omp at
409
- // all, and before #1506, `memberName` did not either — readOmpMember left
410
- // it unset on the theory that the AgentId is a generated CamelCase word
411
- // pair naming nothing. #1506 closed that: a canonically-named omp member
412
- // (`impl-<n>`) now reaches `^impl-` too, through `memberName`, exactly like
413
- // this branch already reaches it through `agentDefinition`. Measured
414
- // 2026-09-16 before #1486's branch: 90 omp fleet-implementer/-alt rows
415
- // split 73 other, 7 merge-bot, 5 finisher, 5 reviewer, none of them
416
- // implementer — the gap was in what omp handed classifyRole, not in the
417
- // classifier's own patterns.
418
- // Every cell, and the pre-cell pair #2129 retired: recorded history still
419
- // carries rows dispatched under those two, and books them by definition.
420
- for (const def of ["fleet-implementer-slow-high", "fleet-implementer-slow-medium", "fleet-implementer-task-high", "fleet-implementer-task-max", "fleet-implementer-smol-high", "fleet-implementer", "fleet-implementer-alt"]) {
421
- assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: def, description: "Ticket #1486. Worktree: .worktrees/1486-classify" }), "implementer", def);
422
- }
423
- // EXACT, unlike the review prefix above: a `fleet-implementer-`-prefixed
424
- // name outside the `CELL` grammar is not an implementer definition.
425
- for (const def of ["fleet-implementer-probe", "fleet-implementer-slow-ultra", "fleet-implementer-alt-2"]) {
426
- assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: def, description: "whatever" }), "other", def);
427
- }
428
- });
429
-
430
- test("depth still outranks the definition — a fleet member's own fan-out is not another implementer", () => {
431
- // Ordering pin. Both new branches sit BEHIND the depth check, so a child an
432
- // implementer dispatched is the specialist it structurally is rather than
433
- // inheriting its parent's definition. Move either branch above the depth
434
- // check and this goes red.
435
- assert.equal(classifyRole({ spawnDepth: 1, agentDefinition: "fleet-implementer-slow-high", description: "whatever" }), "specialist");
436
- // And memory still outranks both, which is the rule that keeps memory-system
437
- // work out of review spend.
438
- assert.equal(classifyRole({ spawnDepth: 0, agentDefinition: "memory-proxy", description: "Review PR 1353 correctness" }), "memory");
439
- });
440
-
441
- test("a role outside ROLE_ORDER is still reported, so percentages sum to 100", () => {
442
- // Regression: roles were built by mapping over ROLE_ORDER, so an unknown role
443
- // vanished from the table while its tokens stayed in totals — the column
444
- // silently stopped summing to 100 and the run read as cheaper than it was.
445
- const { roles, totals } = computeSpend({
446
- agents: [agent({ role: "weird", cacheWrite: 500 }), agent({ role: "reviewer", cacheWrite: 500 })],
447
- });
448
- assert.equal(totals.cacheWrite, 1000);
449
- assert.deepEqual(roles.map((r) => r.role).sort(), ["reviewer", "weird"]);
450
- assert.equal(roles.reduce((n, r) => n + r.pct, 0), 100);
451
- });
452
-
453
- test("percentages are of cache_creation, not of raw tokens", () => {
454
- // cacheRead is deliberately lopsided here: if it leaked into the ranking or
455
- // the percentage base, the implementer would outrank the reviewer.
456
- const { roles, totals } = computeSpend({
457
- agents: [
458
- agent({ role: "reviewer", cacheWrite: 300, cacheRead: 10 }),
459
- agent({ role: "implementer", cacheWrite: 100, cacheRead: 9_000_000 }),
460
- ],
461
- });
462
- assert.equal(roles[0].role, "reviewer");
463
- assert.equal(roles[0].pct, 75);
464
- assert.equal(roles[1].pct, 25);
465
- assert.equal(totals.cacheRead, 9_000_010);
466
- });
467
-
468
- test("reviewPct sums specialists and reviewers", () => {
469
- const { reviewPct } = computeSpend({
470
- agents: [
471
- agent({ role: "specialist", cacheWrite: 470 }),
472
- agent({ role: "reviewer", cacheWrite: 360 }),
473
- agent({ role: "implementer", cacheWrite: 170 }),
474
- ],
475
- });
476
- assert.equal(Math.round(reviewPct), 83);
477
- });
478
-
479
- test("an empty run produces zeroes, not NaN", () => {
480
- const s = computeSpend({ agents: [] });
481
- assert.equal(s.totals.cacheWrite, 0);
482
- assert.deepEqual(s.roles, []);
483
- assert.deepEqual(s.top, []);
484
- assert.equal(s.reviewPct, 0);
485
- });
486
-
487
- test("top is ranked by cache_creation and honours topN", () => {
488
- const { top } = computeSpend({
489
- agents: [
490
- agent({ label: "a", cacheWrite: 10 }),
491
- agent({ label: "b", cacheWrite: 30 }),
492
- agent({ label: "c", cacheWrite: 20 }),
493
- ],
494
- topN: 2,
495
- });
496
- assert.deepEqual(top.map((t) => t.label), ["b", "c"]);
497
- });
498
-
499
- // #1879: `model` rides along on a top row only where the caller's agent
500
- // object supplied one. An agent with no `model` key must not gain one on its
501
- // top row: neither `model: null`, a column the served payload would then
502
- // carry, nor `model: undefined`, which JSON drops but an own-key check on
503
- // the in-process object still sees.
504
- test("a top row carries `model` only when its agent supplied one (#1879)", () => {
505
- const { top } = computeSpend({
506
- agents: [
507
- agent({ label: "no-model", role: "implementer", cacheWrite: 30 }),
508
- agent({ label: "with-model", role: "implementer", model: "claude-opus-5", cacheWrite: 20 }),
509
- ],
510
- });
511
- const [noModel, withModel] = top;
512
- assert.equal(noModel.label, "no-model");
513
- assert.equal(Object.hasOwn(noModel, "model"), false,
514
- `a row with no supplied model must carry no \`model\` key at all, got ${JSON.stringify(Object.keys(noModel))}`);
515
- assert.equal(withModel.label, "with-model");
516
- assert.equal(withModel.model, "claude-opus-5");
517
- });
@@ -1,126 +0,0 @@
1
- import { test } from "node:test";
2
- import assert from "node:assert/strict";
3
- import { readFileSync, readdirSync } from "node:fs";
4
- import { join } from "node:path";
5
- import { between, bullet, paragraph, phrase } from "./prose-pin.mjs";
6
-
7
- // The prose that describes the consumer repo as "whatever the Recipe says"
8
- // rather than as a Node project: every shipped runbook and the requirement
9
- // docs name the Recipe's Install step and Test entrypoint, and none of them
10
- // names a Node package manager, a lockfile or a Node-only tool as the way a
11
- // consumer is installed or tested. Each pin below holds ONE contiguous clause
12
- // of that vocabulary inside the bounded slice that carries it.
13
- const PLUGIN = join(import.meta.dirname, "..");
14
- const ROOT = join(PLUGIN, "..");
15
- const readPlugin = (rel) => readFileSync(join(PLUGIN, rel), "utf8");
16
- const readRoot = (rel) => readFileSync(join(ROOT, rel), "utf8");
17
- const RUN_TEAM = readPlugin("skills/run-team/SKILL.md");
18
- const REAPING = readPlugin("skills/run-team/references/reaping.md");
19
- const ISOLATION = readPlugin("skills/run-team/references/isolation.md");
20
- const REVIEW_AND_FIX = readPlugin("commands/review-and-fix.md");
21
- const REQUIREMENTS = readRoot("docs/requirements.md");
22
- const PULL_AND_CLAIM = readRoot("docs/components/pull-and-claim.md");
23
- const EXTERNAL = readRoot("docs/research/external-assumptions.md");
24
-
25
- // A Node-consumer assumption: a lockfile or `node_modules` named as the
26
- // consumer's install state, or a Node package-manager / runner invocation
27
- // named as how a consumer is installed or checked.
28
- const NODE_CONSUMER = /npm ci|node_modules|package-lock|pnpm-lock|yarn\.lock|npm install|npx (?:vitest|tsc)/;
29
-
30
- const markdownUnder = (dir) =>
31
- readdirSync(join(PLUGIN, dir), { recursive: true })
32
- .filter((rel) => rel.endsWith(".md"))
33
- .map((rel) => join(PLUGIN, dir, rel));
34
-
35
- test("the sweep's own pattern matches each Node-consumer form it exists to catch", () => {
36
- for (const sample of ["npm ci", "its node_modules still on disk", "package-lock.json", "pnpm-lock.yaml", "yarn.lock", "run npm install", "npx tsc --noEmit", "npx vitest run"]) {
37
- assert.match(sample, NODE_CONSUMER, `the pattern no longer matches "${sample}"`);
38
- }
39
- });
40
-
41
- test("no runbook, command, agent definition or requirement doc names a Node-consumer install state or tool", () => {
42
- const files = [
43
- ...markdownUnder("skills"),
44
- ...markdownUnder("commands"),
45
- ...markdownUnder("agents"),
46
- join(ROOT, "docs", "requirements.md"),
47
- join(ROOT, "docs", "components", "pull-and-claim.md"),
48
- join(ROOT, "README.md"),
49
- ];
50
- assert.ok(files.includes(join(PLUGIN, "skills", "run-team", "SKILL.md")), "the sweep no longer reaches run-team/SKILL.md");
51
- const offenders = files.filter((f) => NODE_CONSUMER.test(readFileSync(f, "utf8")));
52
- assert.deepEqual(offenders, [], `Node-consumer wording is back in: ${offenders.join(", ")}`);
53
- });
54
-
55
- test("the claim step runs the Recipe's Install step in the worktree, read from the cache", () => {
56
- const step = bullet(PULL_AND_CLAIM, "4. **Claim.**", "5. **Dispatch**", "pull-and-claim.md step 4");
57
- assert.match(step, phrase("runs the [Recipe](recipe.md)'s Install step there — read from the Recipe cache, refusing if it changed the tree"));
58
- });
59
-
60
- test("requirements 2.3 describes the Recipe derivation: any technology, what it reads, what proves it, what it caches", () => {
61
- const section = between(REQUIREMENTS, "### 2.3 Installable and testable — HARD", "### 2.4", "requirements.md section 2.3");
62
- assert.match(section, phrase("Any technology. Fleet derives your repo's Recipe (Install step + Test entrypoint) by agent reasoning"));
63
- const reads = bullet(section, "- **What the derivation reads:**", "- **What the proof requires:**", "requirements.md 2.3 derivation bullet");
64
- assert.match(reads, phrase("nothing checks for a particular manifest or lockfile."));
65
- const proof = bullet(section, "- **What the proof requires:**", "- **The cache:**", "requirements.md 2.3 proof bullet");
66
- assert.match(proof, phrase("`RECIPE NOT PROVEN` writes no cache and halts the run."));
67
- const cache = bullet(section, "- **The cache:**", "Hard rules for any technology:", "requirements.md 2.3 cache bullet");
68
- assert.match(cache, phrase("Every claim reads both commands from it and every review its Test entrypoint; a missing or unproven cache is a refusal naming the derivation step, never a guess."));
69
- assert.match(section, phrase("~/.fleet/bin/fleet-run derive-testcmd.sh . install && ~/.fleet/bin/fleet-run derive-testcmd.sh . test"));
70
- });
71
-
72
- test("requirements 1.1 adds whatever the Recipe runs to the tool floor", () => {
73
- assert.match(
74
- between(REQUIREMENTS, "| `shasum` | any |", "### 1.2", "requirements.md section 1.1 table tail"),
75
- phrase("Plus whatever your Recipe runs (§2.3): `mvn`, `go`, `cargo`, …"),
76
- );
77
- });
78
-
79
- test("the research note marks the Node-only consumer rows superseded by the Recipe ruling", () => {
80
- const row = bullet(EXTERNAL, "- ~~Contains `package.json`", "\n- `node` on PATH", "external-assumptions.md consumer-repo row");
81
- assert.match(row, phrase("Superseded by ADR 0015: the claim reads the Install step and Test entrypoint from the Recipe cache, and nothing checks for a manifest, a test-file name or a lockfile."));
82
- const implied = bullet(EXTERNAL, "- Consumer must be a Node project", "\n- `python3` and `shasum` on PATH", "external-assumptions.md implied-only row");
83
- assert.match(implied, phrase("Ruled 2026-09-28: ADR 0015 — any technology, Recipe by agent reasoning"));
84
- });
85
-
86
- test("review-and-fix step 3 reads the standalone testCmd off the Recipe cache and derives when there is none", () => {
87
- const step = bullet(REVIEW_AND_FIX, "3. **Run `testCmd` before you commit**", "\n4. **", "review-and-fix.md step 3");
88
- assert.match(step, phrase("the Test entrypoint in the repo's Recipe cache (`derive-testcmd.sh <repo> test` prints it)"));
89
- assert.match(step, phrase("run the Recipe derivation step first"));
90
- assert.doesNotMatch(step, /node --test/, "step 3 names this repository's own test command again");
91
- });
92
-
93
- test("review-and-fix's git archive bullet runs the Install step in the copy, read from a tree that holds the cache", () => {
94
- const archive = bullet(REVIEW_AND_FIX, "- **`git archive` carries tracked files only.**", "\n- **Initialize the copy", "review-and-fix.md git archive bullet");
95
- assert.match(archive, phrase("run the Install step in the copy (read it off the worktree or main checkout, `derive-testcmd.sh <worktree or main checkout> install`; pointed at the copy it refuses, since a copy holds no Recipe cache)"));
96
- });
97
-
98
- test("run-team: a tree with no runner gets the Recipe's Test entrypoint only when it brings up no shared stack", () => {
99
- const p = paragraph(RUN_TEAM, "**A reused worktree may lack the runner** — no longer here", "run-team/SKILL.md reused-worktree runner paragraph");
100
- assert.match(p, phrase("the Recipe's Test entrypoint (`~/.fleet/bin/fleet-run derive-testcmd.sh <main checkout> test` prints it) only when it brings up no shared stack to collide on, else that repo's own stack-free command."));
101
- });
102
-
103
- test("run-team: testCmd comes from the Recipe cache and names no repository's own command", () => {
104
- const p = paragraph(RUN_TEAM, "**Where `testCmd` comes from:**", "run-team/SKILL.md testCmd source paragraph");
105
- assert.match(p, phrase("the repository's Test entrypoint, out of the Recipe cache phase 0's Recipe derivation step proved — `~/.fleet/bin/fleet-run derive-testcmd.sh . test` prints it — and the one you hand specialists"));
106
- assert.doesNotMatch(p, /node --test/, "the testCmd source paragraph names this repository's own test command again");
107
- });
108
-
109
- test("run-team: the quick-install red flag points at the Recipe's Install step, not at an install command", () => {
110
- const flag = bullet(RUN_TEAM, "- \"A quick install to set up the worktree\"", "- \"I'm on my own copy, so I'm isolated\"", "run-team/SKILL.md quick-install red flag");
111
- assert.match(flag, phrase("the claim already ran the Recipe's Install step; any other install can rewrite the lockfile for the whole repo."));
112
- });
113
-
114
- test("a merged branch's stale worktree is said to keep its installed dependencies, in SKILL.md and in reaping.md", () => {
115
- const skill = paragraph(RUN_TEAM, "The merge bot deletes the remote branch after each merge", "run-team/SKILL.md reap paragraph");
116
- assert.match(skill, phrase("with its worktree — and its installed dependencies — still on disk."));
117
- const evidence = paragraph(REAPING, "Merge deletes remote branch, leaves local branch", "reaping.md reap-after-each-merge paragraph");
118
- assert.match(evidence, phrase("with worktree — and its installed dependencies — still on disk."));
119
- });
120
-
121
- test("the isolation reference says symlinking installed dependencies in does not isolate the stack, and reproduces a diagnostic by re-running the check", () => {
122
- const stack = paragraph(ISOLATION, "Private copy and test command solve different problems", "isolation.md stack-isolation paragraph");
123
- assert.match(stack, phrase("Symlinking installed dependencies in does not help."));
124
- const diag = paragraph(ISOLATION, "Probe copies carry same filenames as real tree", "isolation.md diagnostics paragraph");
125
- assert.match(diag, phrase("(re-run the check that raised it — the typechecker, the linter — from there)"));
126
- });