@feigi/fleet-ctl 3.23.36 → 3.23.38

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 (205) hide show
  1. package/package.json +1 -1
  2. package/scripts/cell-readout.mjs +38 -11
  3. package/scripts/main-checkout.mjs +1 -1
  4. package/scripts/member-write-guard.mjs +1 -1
  5. package/scripts/repo-root.mjs +1 -1
  6. package/skills/run-team/references/reaping.md +1 -1
  7. package/scripts/agent-test-dir-prose.test.mjs +0 -59
  8. package/scripts/agent-test.test.mjs +0 -1640
  9. package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
  10. package/scripts/ambient-git-vars-prose.test.mjs +0 -192
  11. package/scripts/ancestry-check-position-prose.test.mjs +0 -175
  12. package/scripts/apply-ruleset.test.mjs +0 -421
  13. package/scripts/arg-header-probes-prose.test.mjs +0 -394
  14. package/scripts/arg.test.mjs +0 -1354
  15. package/scripts/board-cli.test.mjs +0 -710
  16. package/scripts/board-identity.test.mjs +0 -429
  17. package/scripts/board-liveness-banner.test.mjs +0 -119
  18. package/scripts/board-prev-shape.test.mjs +0 -228
  19. package/scripts/board-tryparse-null.test.mjs +0 -119
  20. package/scripts/board.test.mjs +0 -3121
  21. package/scripts/brief-after-cut-prose.test.mjs +0 -53
  22. package/scripts/candidates-exit3-prose.test.mjs +0 -302
  23. package/scripts/candidates.test.mjs +0 -2312
  24. package/scripts/caveat-unification-prose.test.mjs +0 -98
  25. package/scripts/cell-readout.test.mjs +0 -615
  26. package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
  27. package/scripts/ci-completes-premise-prose.test.mjs +0 -257
  28. package/scripts/ci-state-prose.test.mjs +0 -113
  29. package/scripts/ci-state.test.mjs +0 -1933
  30. package/scripts/ci-vacuous-green.test.mjs +0 -368
  31. package/scripts/citation-sweep-prose.test.mjs +0 -1712
  32. package/scripts/claim-lifecycle.test.mjs +0 -187
  33. package/scripts/claim-ticket.test.mjs +0 -1122
  34. package/scripts/closing-keyword-prose.test.mjs +0 -193
  35. package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
  36. package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
  37. package/scripts/compute-board.test.mjs +0 -1214
  38. package/scripts/compute-spend.test.mjs +0 -517
  39. package/scripts/consumer-technology-prose.test.mjs +0 -126
  40. package/scripts/cross-repo-citation-prose.test.mjs +0 -155
  41. package/scripts/cwd-isolation-pins.mjs +0 -83
  42. package/scripts/dedupe-guard-prose.test.mjs +0 -243
  43. package/scripts/delete-merged-branch.test.mjs +0 -576
  44. package/scripts/derive-testcmd.test.mjs +0 -595
  45. package/scripts/diff-stats.test.mjs +0 -404
  46. package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
  47. package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
  48. package/scripts/dispositions-check.test.mjs +0 -936
  49. package/scripts/dispositions-gate-prose.test.mjs +0 -129
  50. package/scripts/drop-merged-label.test.mjs +0 -479
  51. package/scripts/exec-stub.mjs +0 -93
  52. package/scripts/exec-stub.test.mjs +0 -69
  53. package/scripts/expected-jobs-prose.test.mjs +0 -80
  54. package/scripts/fan-out-authorization-prose.test.mjs +0 -80
  55. package/scripts/filing-bar-seat-prose.test.mjs +0 -242
  56. package/scripts/filing-claim-bar-prose.test.mjs +0 -166
  57. package/scripts/finisher-died-prose.test.mjs +0 -31
  58. package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
  59. package/scripts/finisher-halt-prose.test.mjs +0 -106
  60. package/scripts/finisher-name-prose.test.mjs +0 -134
  61. package/scripts/finisher-own-tree-prose.test.mjs +0 -299
  62. package/scripts/finisher-pin-race-prose.test.mjs +0 -339
  63. package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
  64. package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
  65. package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
  66. package/scripts/fleet-bootstrap.test.mjs +0 -75
  67. package/scripts/fleet-heartbeat.test.mjs +0 -450
  68. package/scripts/fleet-provenance.test.mjs +0 -138
  69. package/scripts/fleet-run.test.mjs +0 -90
  70. package/scripts/fleet-state.test.mjs +0 -460
  71. package/scripts/fleet-tick-prose.test.mjs +0 -300
  72. package/scripts/fleet-tick.test.mjs +0 -2444
  73. package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
  74. package/scripts/frontmatter-check.test.mjs +0 -436
  75. package/scripts/git-env.test.mjs +0 -149
  76. package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
  77. package/scripts/gone-walk.test.mjs +0 -213
  78. package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
  79. package/scripts/head-moved-after-label-prose.test.mjs +0 -233
  80. package/scripts/immutable-body-claim-prose.test.mjs +0 -204
  81. package/scripts/implementer-model-tier.test.mjs +0 -235
  82. package/scripts/inflight-citation-prose.test.mjs +0 -144
  83. package/scripts/inflight-exit2-prose.test.mjs +0 -81
  84. package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
  85. package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
  86. package/scripts/inflight.test.mjs +0 -2882
  87. package/scripts/injection-control-prose.test.mjs +0 -404
  88. package/scripts/install-root-audit.test.mjs +0 -464
  89. package/scripts/instrument-check-prose.test.mjs +0 -235
  90. package/scripts/instruments.test.mjs +0 -787
  91. package/scripts/is-cli.test.mjs +0 -99
  92. package/scripts/issue-tracker-prose.test.mjs +0 -71
  93. package/scripts/json.test.mjs +0 -364
  94. package/scripts/ledger-dispatch.test.mjs +0 -927
  95. package/scripts/ledger-grammar.test.mjs +0 -227
  96. package/scripts/ledger-read-require-file.test.mjs +0 -197
  97. package/scripts/ledger-rotate.test.mjs +0 -142
  98. package/scripts/ledger.test.mjs +0 -3436
  99. package/scripts/line-distance-prose.test.mjs +0 -245
  100. package/scripts/liveness-rationale-prose.test.mjs +0 -83
  101. package/scripts/locale-pin-prose.test.mjs +0 -189
  102. package/scripts/main-checkout.test.mjs +0 -332
  103. package/scripts/member-outcome-prose.test.mjs +0 -167
  104. package/scripts/member-outcomes-header.test.mjs +0 -129
  105. package/scripts/member-outcomes-prose.test.mjs +0 -63
  106. package/scripts/member-outcomes.test.mjs +0 -638
  107. package/scripts/member-prompt-prose.test.mjs +0 -165
  108. package/scripts/member-record.test.mjs +0 -541
  109. package/scripts/member-write-guard.test.mjs +0 -214
  110. package/scripts/merge-commit-probe-prose.test.mjs +0 -122
  111. package/scripts/merge-gate.test.mjs +0 -613
  112. package/scripts/muted-git-guard-sweep.test.mjs +0 -493
  113. package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
  114. package/scripts/net-watchdog-prose.test.mjs +0 -79
  115. package/scripts/net.test.mjs +0 -211
  116. package/scripts/no-ci-gate-prose.test.mjs +0 -108
  117. package/scripts/no-undo-audit.test.mjs +0 -3961
  118. package/scripts/no-wave.test.mjs +0 -138
  119. package/scripts/node-floor-sweep.test.mjs +0 -611
  120. package/scripts/pointer-target-prose.test.mjs +0 -186
  121. package/scripts/pr-cost.test.mjs +0 -521
  122. package/scripts/pr-overlap.test.mjs +0 -692
  123. package/scripts/printf-die-sweep.test.mjs +0 -384
  124. package/scripts/prompt-renderer.mjs +0 -40
  125. package/scripts/prompt-renderer.test.mjs +0 -68
  126. package/scripts/prose-pin.mjs +0 -807
  127. package/scripts/prose-pin.test.mjs +0 -1034
  128. package/scripts/prove-merge.test.mjs +0 -995
  129. package/scripts/pull-table-relabel-prose.test.mjs +0 -60
  130. package/scripts/quiet-payload-prose.test.mjs +0 -222
  131. package/scripts/reap-cherry-check-prose.test.mjs +0 -80
  132. package/scripts/reap.test.mjs +0 -4432
  133. package/scripts/reaping-prose.test.mjs +0 -239
  134. package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
  135. package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
  136. package/scripts/recipe-derivation-prose.test.mjs +0 -112
  137. package/scripts/recipe-prove.test.mjs +0 -1042
  138. package/scripts/refuter-scratch-prose.test.mjs +0 -135
  139. package/scripts/release-label-required-prose.test.mjs +0 -71
  140. package/scripts/release-label-split-prose.test.mjs +0 -184
  141. package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
  142. package/scripts/release-ticket.test.mjs +0 -5099
  143. package/scripts/renovate-release-contract.test.mjs +0 -379
  144. package/scripts/repo-root.test.mjs +0 -873
  145. package/scripts/reporter-output-rule-prose.test.mjs +0 -208
  146. package/scripts/review-agent-report-only.test.mjs +0 -49
  147. package/scripts/review-core-booking.test.mjs +0 -35
  148. package/scripts/review-core-cwd-isolation.test.mjs +0 -374
  149. package/scripts/review-core-reads.test.mjs +0 -478
  150. package/scripts/review-core-refuter-scratch.test.mjs +0 -148
  151. package/scripts/review-core-scratch-refusal.test.mjs +0 -64
  152. package/scripts/review-core-shared-test-run.test.mjs +0 -275
  153. package/scripts/review-core-snapshot-path.test.mjs +0 -830
  154. package/scripts/review-core-specialist-scratch.test.mjs +0 -191
  155. package/scripts/review-core-testcmd.test.mjs +0 -335
  156. package/scripts/review-core-unrun.test.mjs +0 -566
  157. package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
  158. package/scripts/review-eval-resolver-path.test.mjs +0 -55
  159. package/scripts/review-host-fixture.mjs +0 -89
  160. package/scripts/review-in-run-retry.test.mjs +0 -211
  161. package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
  162. package/scripts/review-path-default.test.mjs +0 -796
  163. package/scripts/review-runner-spawns.test.mjs +0 -95
  164. package/scripts/review-runner.test.mjs +0 -166
  165. package/scripts/review-tier-audit.test.mjs +0 -140
  166. package/scripts/run-artifact-pr-prose.test.mjs +0 -341
  167. package/scripts/run-merge-bot-prose.test.mjs +0 -1413
  168. package/scripts/run-team-local-hook.test.mjs +0 -442
  169. package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
  170. package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
  171. package/scripts/section-between-guard-prose.test.mjs +0 -379
  172. package/scripts/select-dimensions.test.mjs +0 -674
  173. package/scripts/shared-refusal.test.mjs +0 -388
  174. package/scripts/shell-traps-prose.test.mjs +0 -504
  175. package/scripts/shortlist.test.mjs +0 -380
  176. package/scripts/slow-transport.mjs +0 -72
  177. package/scripts/snapshot-repo.test.mjs +0 -1006
  178. package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
  179. package/scripts/spend-view.test.mjs +0 -312
  180. package/scripts/staleness-qualifier-prose.test.mjs +0 -251
  181. package/scripts/staleness-verdict-prose.test.mjs +0 -142
  182. package/scripts/staleness.test.mjs +0 -893
  183. package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
  184. package/scripts/stash-prohibition-prose.test.mjs +0 -313
  185. package/scripts/strip-comments.mjs +0 -44
  186. package/scripts/temp-dir.mjs +0 -47
  187. package/scripts/ticket-router.test.mjs +0 -981
  188. package/scripts/tier-check.test.mjs +0 -828
  189. package/scripts/tier-outcomes-header.test.mjs +0 -518
  190. package/scripts/tier-outcomes.test.mjs +0 -572
  191. package/scripts/tier-roles.test.mjs +0 -535
  192. package/scripts/tracker-block-copy-prose.test.mjs +0 -288
  193. package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
  194. package/scripts/unattended-git-sweep.test.mjs +0 -142
  195. package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
  196. package/scripts/verify-sha.test.mjs +0 -692
  197. package/scripts/watcher-degraded-block.test.mjs +0 -369
  198. package/scripts/watcher-key-prose.test.mjs +0 -106
  199. package/scripts/within-run-pair-prose.test.mjs +0 -212
  200. package/scripts/worktree-audit.test.mjs +0 -1408
  201. package/scripts/worktree-head-prose.test.mjs +0 -276
  202. package/scripts/worktree-listing-sweep.test.mjs +0 -217
  203. package/scripts/worktree-model-prose.test.mjs +0 -216
  204. package/scripts/worktree-porcelain.mjs +0 -35
  205. package/scripts/worktree-porcelain.test.mjs +0 -102
@@ -1,638 +0,0 @@
1
- import { test } from "node:test";
2
- import assert from "node:assert/strict";
3
- import { mkdirSync, writeFileSync, readFileSync, utimesSync, existsSync } from "node:fs";
4
- import { tempDir } from "./temp-dir.mjs";
5
- import { join, dirname } from "node:path";
6
- import { spawnSync } from "node:child_process";
7
- import { normalizeModel, parseMemberName, rowsForSession, COLUMNS, mergeRows, formatTsv, parseTsv } from "./member-outcomes.mjs";
8
- import { COLUMNS as TIER_COLUMNS, TIER_SWITCH_DATE } from "./tier-outcomes.mjs";
9
-
10
- const TIER_CLI = new URL("./tier-outcomes.mjs", import.meta.url).pathname;
11
-
12
- test("a versioned model id is kept verbatim", () => {
13
- assert.equal(normalizeModel("claude-opus-5"), "claude-opus-5");
14
- assert.equal(normalizeModel("claude-haiku-4-5-20251001"), "claude-haiku-4-5-20251001");
15
- });
16
-
17
- test("the [1m] context variant is stripped — it is the same model", () => {
18
- // A member's `model` can read "claude-opus-5[1m]" on one turn while another
19
- // turn of the same member says "claude-opus-5". Two spellings of one model
20
- // would split every count.
21
- assert.equal(normalizeModel("claude-opus-5[1m]"), "claude-opus-5");
22
- });
23
-
24
- test("a bare alias stays bare — it cannot be resolved to a version", () => {
25
- // Guessing a version here would invent data. `opus` is honestly less precise
26
- // than `claude-opus-5`, and a read-out can group on the family prefix.
27
- assert.equal(normalizeModel("opus"), "opus");
28
- assert.equal(normalizeModel("sonnet"), "sonnet");
29
- });
30
-
31
- test("<synthetic> is dropped, not mapped — it is not a model", () => {
32
- assert.equal(normalizeModel("<synthetic>"), null);
33
- });
34
-
35
- test("empty and absent are dropped", () => {
36
- assert.equal(normalizeModel(""), null);
37
- assert.equal(normalizeModel(undefined), null);
38
- });
39
-
40
- test("impl-<n> names a TICKET, not a PR", () => {
41
- assert.deepEqual(parseMemberName("impl-580"), { ticket: "580", pr: "" });
42
- });
43
-
44
- test("every pr-shaped member name yields a PR and no ticket", () => {
45
- assert.deepEqual(parseMemberName("fix-pr-662"), { ticket: "", pr: "662" });
46
- assert.deepEqual(parseMemberName("review-pr-555"), { ticket: "", pr: "555" });
47
- assert.deepEqual(parseMemberName("finisher-pr-904"), { ticket: "", pr: "904" });
48
- assert.deepEqual(parseMemberName("finish-pr-601"), { ticket: "", pr: "601" });
49
- assert.deepEqual(parseMemberName("finisher-532"), { ticket: "", pr: "532" });
50
- assert.deepEqual(parseMemberName("finish-567"), { ticket: "", pr: "567" });
51
- });
52
-
53
- test("resolve-pr-<n> names a PR and no ticket (#1250)", () => {
54
- // `resolve-pr-<n>` is the controller's conflict/rebase-resolver dispatch
55
- // against an already-open PR, real recorded names, the unrecognised before
56
- // this fix: `resolve-pr-1232`. Unmatched, it fell through to `{ticket:"",
57
- // pr:""}`, losing the join key into tier-outcomes.tsv.
58
- assert.deepEqual(parseMemberName("resolve-pr-1232"), { ticket: "", pr: "1232" });
59
- // The re-dispatch suffixes (#1482) apply to this family too, every other
60
- // PR-shaped name, the same as `resolve-pr-1440-2`, { ticket: "", pr: "1440" }.
61
- assert.deepEqual(parseMemberName("resolve-pr-1440-2"), { ticket: "", pr: "1440" });
62
- });
63
-
64
- test("merge-bot's number is a per-run dispatch counter, never a PR, so it is neither ticket nor PR", () => {
65
- // merge-bot-12 is the twelfth merge bot this run dispatched, not PR 12.
66
- // Booking it as a pr would join this row to an unrelated PR's verdict row.
67
- assert.deepEqual(parseMemberName("merge-bot-12"), { ticket: "", pr: "" });
68
- });
69
-
70
- test("a retry suffix does not change what the name identifies", () => {
71
- // run-team spawns `impl-<N>-b` when a member is re-dispatched.
72
- assert.deepEqual(parseMemberName("impl-580-b"), { ticket: "580", pr: "" });
73
- assert.deepEqual(parseMemberName("finisher-903-c"), { ticket: "", pr: "903" });
74
- });
75
-
76
- test("a -v<n> re-dispatch suffix is stripped the same way as a retry letter", () => {
77
- // #1482: a controller re-dispatches a finisher/reviewer against a PR whose
78
- // head moved after label — `<name>-v2`, `<name>-v10`, etc. Left unstripped,
79
- // this fell through to a blank pr column, orphaning the token row from the
80
- // PR's outcome.
81
- assert.deepEqual(parseMemberName("finisher-pr-1475-v2"), { ticket: "", pr: "1475" });
82
- // Two-digit suffixes are the same spelling, not a special case: -v10 is the
83
- // tenth re-dispatch, not a different pattern than -v2.
84
- assert.deepEqual(parseMemberName("finisher-pr-1475-v10"), { ticket: "", pr: "1475" });
85
- // The existing single-letter retry suffix keeps working unchanged.
86
- assert.deepEqual(parseMemberName("finisher-pr-1475-b"), { ticket: "", pr: "1475" });
87
- });
88
-
89
- test("a bare numeric re-dispatch suffix is stripped for PR-shaped names only (#1482)", () => {
90
- // The numeric-only suffix (a genuine second-ticket batch, not a retry) is
91
- // still deliberately NOT stripped for a TICKET-shaped name.
92
- assert.deepEqual(parseMemberName("impl-137-2"), { ticket: "", pr: "" });
93
- // The commoner numeric re-dispatch spelling (no `-v`, no letter) also falls
94
- // through the old regex: `finisher-pr-1440-2`, `fix-pr-1281-2`. A trailing
95
- // `-\d+` cannot be a second ticket the way `impl-<ticket>-<n>`'s can —
96
- // measured across docs/metrics/member-outcomes.tsv: 476,202 cache-create
97
- // tokens across 7 real rows fell through to a blank pr column this way,
98
- // more than the 37,580 the -v<n> fix above addressed.
99
- assert.deepEqual(parseMemberName("finisher-pr-1440-2"), { ticket: "", pr: "1440" });
100
- assert.deepEqual(parseMemberName("fix-pr-1281-2"), { ticket: "", pr: "1281" });
101
- // The ticket-shaped impl-<ticket>-<n> family is untouched: its second-ticket
102
- // ambiguity is real, and a PR-shaped name's is not.
103
- assert.deepEqual(parseMemberName("impl-753-2"), { ticket: "", pr: "" });
104
- });
105
-
106
- test("an unrecognised name yields blanks, never a guess", () => {
107
- assert.deepEqual(parseMemberName("size candidate 7"), { ticket: "", pr: "" });
108
- assert.deepEqual(parseMemberName(""), { ticket: "", pr: "" });
109
- });
110
-
111
- test("a member family spelled PascalCase or without hyphens yields the same join key as its kebab form (#2396)", () => {
112
- // omp task names are free-form: this repo's own member-outcomes.tsv carries
113
- // `ReviewPR77`, `FinisherPr1567b` and `FixPr1568-2` beside `impl-580`. Each
114
- // returned blanks, losing the row's join key into tier-outcomes.tsv.
115
- assert.deepEqual(parseMemberName("Impl327"), { ticket: "327", pr: "" });
116
- assert.deepEqual(parseMemberName("Fix-pr-766"), { ticket: "", pr: "766" });
117
- assert.deepEqual(parseMemberName("FixPr774"), { ticket: "", pr: "774" });
118
- assert.deepEqual(parseMemberName("Review-pr-771"), { ticket: "", pr: "771" });
119
- assert.deepEqual(parseMemberName("ReviewPR77"), { ticket: "", pr: "77" });
120
- assert.deepEqual(parseMemberName("Finisher-pr-766"), { ticket: "", pr: "766" });
121
- assert.deepEqual(parseMemberName("ResolvePr1232"), { ticket: "", pr: "1232" });
122
- assert.deepEqual(parseMemberName("Finisher532"), { ticket: "", pr: "532" });
123
- // The retry suffixes keep their meaning when glued on without a hyphen.
124
- assert.deepEqual(parseMemberName("FinisherPr1567b"), { ticket: "", pr: "1567" });
125
- assert.deepEqual(parseMemberName("FixPr1568-2"), { ticket: "", pr: "1568" });
126
- assert.deepEqual(parseMemberName("Impl580b"), { ticket: "580", pr: "" });
127
- // ...and the deliberate blanks stay blank in either spelling.
128
- assert.deepEqual(parseMemberName("Impl137-2"), { ticket: "", pr: "" });
129
- assert.deepEqual(parseMemberName("MergeBot12"), { ticket: "", pr: "" });
130
- });
131
-
132
- test("a generated word pair that merely starts with a family word yields blanks (#2396)", () => {
133
- assert.deepEqual(parseMemberName("InstallVerifySearch"), { ticket: "", pr: "" });
134
- assert.deepEqual(parseMemberName("ReviewPrDispatch"), { ticket: "", pr: "" });
135
- assert.deepEqual(parseMemberName("Issue134Implement"), { ticket: "", pr: "" });
136
- assert.deepEqual(parseMemberName("Implementer5"), { ticket: "", pr: "" });
137
- assert.deepEqual(parseMemberName("Impl1341/Impl1341.CwdProbe"), { ticket: "", pr: "" });
138
- });
139
-
140
- test("a review fan-out label books its PR, in the label's own spelling and in the stem omp writes for it", () => {
141
- // omp names the member by deleting every character outside [A-Za-z0-9_-]
142
- // from the label and appending -<n> from a label's second dispatch on.
143
- for (const [label, stem] of [
144
- ["review:correctness:pr2132", "reviewcorrectnesspr2132"],
145
- ["review:silent-failure:pr2132", "reviewsilent-failurepr2132"],
146
- ["verify:comments:pr2132", "verifycommentspr2132"],
147
- ["snapshot:pr2132", "snapshotpr2132"],
148
- ["test-run:pr2132", "test-runpr2132"],
149
- ]) {
150
- assert.deepEqual(parseMemberName(label), { ticket: "", pr: "2132" }, label);
151
- assert.deepEqual(parseMemberName(stem), { ticket: "", pr: "2132" }, stem);
152
- assert.deepEqual(parseMemberName(`${stem}-7`), { ticket: "", pr: "2132" }, `${stem}-7`);
153
- // Nested under the reviewer that dispatched it: the last segment is the member.
154
- assert.deepEqual(parseMemberName(`review-pr-2132/${stem}`), { ticket: "", pr: "2132" }, `nested ${stem}`);
155
- }
156
- // A dimension key that itself spells `pr` still yields the trailing number.
157
- assert.deepEqual(parseMemberName("reviewprpr12"), { ticket: "", pr: "12" });
158
- });
159
-
160
- test("a fan-out stem that carries no PR, or a name that only resembles one, books nothing", () => {
161
- // Measured stems from before the label carried its PR.
162
- for (const name of ["verifycorrectness-26", "reviewtests", "snapshot-8", "snapshot", "test-run",
163
- // Generated or human names: PascalCase never matches, and a bare number is not `pr<n>`.
164
- "ReviewCorrectness", "VerifyAndRepair", "Verify685", "ReviewTestsPr12", "review:correctness", "verify::pr", "reviewpr",
165
- // Look-alikes of a fan-out stem: a prefix before the family word, a key-less `verify`, a hyphen before `pr`.
166
- "xreviewfoopr12", "xsnapshotpr12", "verifypr12", "snapshot-pr12", "test-run-pr12", "verify-pr12", "reviewers-sprint-pr3"]) {
167
- assert.deepEqual(parseMemberName(name), { ticket: "", pr: "" }, name);
168
- }
169
- });
170
-
171
- // ---------------------------------------------------------------------------
172
- // omp fixtures — shaped like real ~/.omp/agent/sessions/**/*.jsonl lines
173
- // ---------------------------------------------------------------------------
174
-
175
- const evt = (o) => JSON.stringify(o);
176
- const sessionEvt = (cwd) => evt({ type: "session", version: 3, id: "s1", timestamp: "2026-09-08T15:11:49.444Z", cwd });
177
- const thinkingEvt = (level) => evt({ type: "thinking_level_change", id: "t1", parentId: null, timestamp: "2026-09-08T15:11:49.494Z", thinkingLevel: level, configured: null });
178
- const sessionInitEvt = (task, agent) => evt({ type: "session_init", id: "i1", parentId: "t1", timestamp: "2026-09-08T15:11:49.495Z", task, agent });
179
- const assistantEvt = (model, usage = {}, ts = "2026-08-25T09:00:00.000Z") => evt({
180
- type: "message", id: "m1", parentId: "i1", timestamp: ts,
181
- message: { role: "assistant", content: [{ type: "text", text: "ok" }], model, usage: { input: 1, output: 1, cacheRead: 0, cacheWrite: 0, totalTokens: 2, cost: { total: 0.001 }, ...usage } },
182
- });
183
-
184
- // A real `<ISO>_<uuid>` name: most of this file's fixtures reach the CLI via
185
- // spawnSync, and the CLI now refuses (#1302-style) a directory whose own
186
- // name is not an omp session dir — see "a directory that is not an omp
187
- // session dir is a refusal" below. rowsForSession() itself still reads
188
- // whatever directory it is handed and applies no name gate of its own; only
189
- // the CLI (member-outcomes.mjs's main()) and readMembers()'s tree walk
190
- // (member-record.test.mjs) do.
191
- function fixture(members) {
192
- const root = tempDir("mo-");
193
- const sessionDir = join(root, "2026-08-25T09-00-00-000Z_abcdef12-3456-7890-abcd-ef1234567890");
194
- for (const [name, lines] of members) {
195
- const file = join(sessionDir, `${name}.jsonl`);
196
- mkdirSync(dirname(file), { recursive: true });
197
- writeFileSync(file, lines.join("\n") + "\n");
198
- utimesSync(file, new Date("2026-08-25T09:00:00Z"), new Date("2026-08-25T09:00:00Z"));
199
- }
200
- return sessionDir;
201
- }
202
-
203
- test("one row per member, stamped with the session and its run date", () => {
204
- const dir = fixture([
205
- ["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]],
206
- ["merge-bot-12", [sessionEvt("/x"), thinkingEvt("xhigh"), sessionInitEvt("merge bot pass 12", "fleet-merge-bot"), assistantEvt("claude-opus-5")]],
207
- ]);
208
- const rows = rowsForSession(dir);
209
- assert.equal(rows.length, 2);
210
- assert.equal(rows[0].session, "2026-08-25T09-00-00-000Z_abcdef12-3456-7890-abcd-ef1234567890");
211
- assert.equal(rows[0].run_date, "2026-08-25");
212
- });
213
-
214
- test("a member whose file readFileSync cannot read is skipped without losing its siblings", () => {
215
- // Not a permissions test (unreliable across CI users/root) — a directory
216
- // named `<x>.jsonl` matches the recursive `.jsonl` filter exactly the same
217
- // way a regular file does, and readFileSync on a directory throws EISDIR,
218
- // the same class of per-file fault the try/catch below exists to survive.
219
- const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]]]);
220
- mkdirSync(join(dir, "bad.jsonl"));
221
- assert.equal(rowsForSession(dir).length, 1);
222
- });
223
-
224
- test("a session directory that does not exist yields no rows and does not throw", () => {
225
- const root = tempDir("mo-");
226
- assert.deepEqual(rowsForSession(join(root, "never-created")), []);
227
- });
228
-
229
- test("a member that yields no row still dates the session, and its siblings survive", () => {
230
- // A member dispatched but not yet answered (session_init, no assistant turn
231
- // yet) is dropped, but it DID write a transcript: its mtime is part of when
232
- // this session ran. Sampling mtime only for surviving members would date
233
- // the session from the older sibling.
234
- const dir = fixture([
235
- ["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]],
236
- ["impl-581", [sessionEvt("/x"), thinkingEvt("xhigh"), sessionInitEvt("Implement ticket 581", "fleet-implementer")]],
237
- ]);
238
- const newer = join(dir, "impl-581.jsonl");
239
- utimesSync(newer, new Date("2026-08-26T09:00:00Z"), new Date("2026-08-26T09:00:00Z"));
240
-
241
- const rows = rowsForSession(dir);
242
- assert.equal(rows.length, 1);
243
- assert.equal(rows[0].member, "impl-580");
244
- assert.equal(rows[0].run_date, "2026-08-26");
245
- });
246
-
247
- test("a nested member's fan-out is scraped too, keyed on its path-relative stem", () => {
248
- // Transcripts live at TWO depths: the flat top-level ones a directly-
249
- // dispatched member writes, and one level deeper for the fan-out a member
250
- // itself dispatches (a nested reviewer, say). A one-level readdir would
251
- // miss the whole nested half.
252
- //
253
- // Mutation this must survive: dropping `{ recursive: true }`.
254
- const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]]]);
255
- mkdirSync(join(dir, "Nested"), { recursive: true });
256
- writeFileSync(join(dir, "Nested", "Reviewer.jsonl"), [
257
- sessionEvt("/x"), thinkingEvt("xhigh"), sessionInitEvt("Review PR 943"), assistantEvt("claude-sonnet-5"),
258
- ].join("\n") + "\n");
259
-
260
- const rows = rowsForSession(dir);
261
- assert.equal(rows.length, 2);
262
- const nested = rows.find((r) => r.model === "claude-sonnet-5");
263
- assert.ok(nested, "the nested transcript produced a row");
264
- // The stem carries the path, which is what keeps `agent` unique across the
265
- // two depths — and what lets this widening REPLACE existing rows rather
266
- // than duplicate them, since a flat stem is unchanged by recursing.
267
- assert.equal(nested.agent, "Nested/Reviewer");
268
- assert.equal(rows.find((r) => r.model === "claude-opus-5").agent, "impl-580");
269
- });
270
-
271
- test("role comes from classifyRole and is not invented here", () => {
272
- // `role` had no assertion anywhere while it was the GROUPING column of the
273
- // header's former pair query, so a classifyRole regression moved every
274
- // bucket in that read-out while the suite stayed green.
275
- const dir = fixture([
276
- ["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]],
277
- ["merge-bot-3", [sessionEvt("/x"), thinkingEvt("xhigh"), sessionInitEvt("merge pass 3", "fleet-merge-bot"), assistantEvt("claude-opus-5")]],
278
- ["general-purpose", [sessionEvt("/x"), sessionInitEvt("Review PR 943 correctness"), assistantEvt("claude-opus-5")]],
279
- ]);
280
- const byMember = Object.fromEntries(rowsForSession(dir).map((r) => [r.member, r.role]));
281
- assert.equal(byMember["impl-580"], "implementer");
282
- assert.equal(byMember["merge-bot-3"], "merge-bot");
283
- // A non-canonical AgentId with no spawnDepth and no `agent` field, only
284
- // task prose — classifies off the task text alone.
285
- assert.equal(byMember["general-purpose"], "reviewer");
286
- });
287
-
288
- test("`subagent_type` is what the DISPATCH named, and blank when it named nothing", () => {
289
- // The whole of #1066: a deliberate alternate-tier pair is identifiable only
290
- // from the dispatch record, and `session_init.agent` is written at dispatch
291
- // time — so the column is derived, survives a regeneration, and mislabels
292
- // no historical row.
293
- const dir = fixture([
294
- ["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), sessionInitEvt("Implement ticket 580", "fleet-implementer"), assistantEvt("claude-opus-5")]],
295
- ["impl-581", [sessionEvt("/x"), thinkingEvt("xhigh"), sessionInitEvt("Implement ticket 581", "fleet-implementer-alt"), assistantEvt("claude-sonnet-5")]],
296
- ["impl-582", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]],
297
- ]);
298
- assert.deepEqual(
299
- Object.fromEntries(rowsForSession(dir).map((r) => [r.member, r.subagentType])),
300
- { "impl-580": "fleet-implementer", "impl-581": "fleet-implementer-alt", "impl-582": "" },
301
- );
302
- });
303
-
304
- test("a row whose cell count is wrong is REFUSED, never padded", () => {
305
- // Padding put "" in the trailing columns — `agent` was the LAST one when
306
- // this was written, a key rowsForSession can never produce, so mergeRows
307
- // could never replace it. Three measured routes there, all exit 0: a torn
308
- // last line became a permanent phantom that re-scraping could not heal, git
309
- // conflict markers became three data rows, and adding one column ahead of
310
- // `agent` collapsed 2,702 rows to 156. The columns that trail `agent` now
311
- // are the priced ones, where a padded blank reads as "no figure recorded".
312
- //
313
- // The 15-field spelling is the PREVIOUS schema, from before the four priced
314
- // columns: it must be refused rather than padded with blank prices, which
315
- // would read as "no figure was recorded" for members whose transcript
316
- // carried one. Re-scraping is the migration. The 14-field one before it is
317
- // refused the same way.
318
- //
319
- // Mutation this must survive: restoring `cells[i] ?? ""`.
320
- const short = ["s1", "2026-08-25", "memory"].join("\t");
321
- assert.throws(() => parseTsv(short), /malformed row: 3 fields, expected 19/);
322
- assert.throws(() => parseTsv("<<<<<<< HEAD"), /malformed row/);
323
- const full = formatTsv([row()]).replace(/\n$/, "").split("\t");
324
- assert.equal(full.length, 19);
325
- assert.throws(() => parseTsv(full.slice(0, 15).join("\t")), /15 fields, expected 19/);
326
- assert.throws(() => parseTsv(full.slice(0, 14).join("\t")), /14 fields, expected 19/);
327
- // A long row is refused too — that is the schema-drift direction.
328
- assert.throws(() => parseTsv(full.join("\t") + "\textra"), /20 fields/);
329
- });
330
-
331
- test("the four priced columns follow subagent_type, and a scraped member fills them", () => {
332
- assert.deepEqual(COLUMNS.slice(COLUMNS.indexOf("subagent_type")),
333
- ["subagent_type", "tokens_in", "tokens_cache_read", "tokens_cache_write_1h", "cost"]);
334
- const [parsed] = parseTsv(formatTsv([row({ tokensIn: 12, tokensCacheRead: 3400, tokensCacheWrite1h: 900, cost: 0.123457 })]));
335
- assert.deepEqual([parsed.tokensIn, parsed.tokensCacheRead, parsed.tokensCacheWrite1h, parsed.cost], ["12", "3400", "900", "0.123457"]);
336
- });
337
-
338
- const row = (o = {}) => ({
339
- session: "s1", run_date: "2026-08-25", role: "implementer", member: "impl-580",
340
- model: "claude-opus-5", effort: "xhigh", ticket: "580", pr: "",
341
- tokensCacheCreate: 0, tokensOut: 0, wallS: 0, turns: 1,
342
- // Default agent tracks the default/overridden member, so fixtures that vary
343
- // only `member` still get distinct transcript ids, and fixtures that share
344
- // the default member (untouched) still key as the SAME agent.
345
- agent: o.member ?? "impl-580", harness: "omp",
346
- subagentType: "fleet-implementer",
347
- tokensIn: 0, tokensCacheRead: 0, tokensCacheWrite1h: 0, cost: 0.01, ...o,
348
- });
349
-
350
- test("re-scraping a session REPLACES its rows rather than appending duplicates", () => {
351
- const merged = mergeRows([row({ model: "opus" })], [row({ model: "claude-opus-5" })]);
352
- assert.equal(merged.length, 1);
353
- assert.equal(merged[0].model, "claude-opus-5");
354
- });
355
-
356
- test("re-scraping one session leaves every other session untouched", () => {
357
- // The failure this guards: a backfill loop that rewrites the file per session
358
- // and drops the previous session each time.
359
- const merged = mergeRows(
360
- [row({ session: "s0", member: "impl-1" }), row({ session: "s1", member: "impl-580" })],
361
- [row({ session: "s1", member: "impl-580", turns: 9 })],
362
- );
363
- assert.equal(merged.length, 2);
364
- assert.equal(merged.find((r) => r.session === "s0").member, "impl-1");
365
- assert.equal(merged.find((r) => r.session === "s1").turns, 9);
366
- });
367
-
368
- test("output order is stable, so a regeneration produces no spurious diff", () => {
369
- const a = formatTsv(mergeRows([], [row({ member: "impl-9" }), row({ member: "impl-1" })]));
370
- const b = formatTsv(mergeRows([], [row({ member: "impl-1" }), row({ member: "impl-9" })]));
371
- assert.equal(a, b);
372
- });
373
-
374
- test("a tsv round-trips", () => {
375
- // formatTsv does not sort (only mergeRows does), so the round-trip preserves
376
- // input order. Ordering itself is pinned by the "output order is stable" test.
377
- const rows = [row(), row({ session: "s2", member: "fix-pr-662", role: "reviewer", ticket: "", pr: "662" })];
378
- assert.deepEqual(parseTsv(formatTsv(rows)).map((r) => r.member), ["impl-580", "fix-pr-662"]);
379
- });
380
-
381
- test("a blank field round-trips as blank, never as zero", () => {
382
- // Blank means UNKNOWN. Reading it back as 0 would make an unmeasured member
383
- // look like a free one.
384
- const parsed = parseTsv(formatTsv([row({ effort: "" })]));
385
- assert.equal(parsed[0].effort, "");
386
- });
387
-
388
- test("two UNNAMED members of one session are two rows, not one", () => {
389
- // `member` falls back to the agent stem for an unnamed dispatch, and every
390
- // unnamed agent in a session shares the same fallback. Keying on the member
391
- // name collapsed 1,202 of 2,694 real members into their siblings.
392
- const a = row({ agent: "aaaa", member: "general-purpose" });
393
- const b = row({ agent: "bbbb", member: "general-purpose" });
394
- const merged = mergeRows([], [a, b]);
395
- assert.equal(merged.length, 2);
396
- });
397
-
398
- const CLI = new URL("./member-outcomes.mjs", import.meta.url).pathname;
399
-
400
- test("no session dir is a refusal, not a silent no-op", () => {
401
- const r = spawnSync(process.execPath, [CLI], { encoding: "utf8" });
402
- assert.equal(r.status, 2);
403
- assert.match(r.stderr, /member-outcomes/);
404
- assert.equal(r.stdout, "");
405
- });
406
-
407
- test("a nonexistent session directory is a refusal, not a silent no-op", () => {
408
- // A wrong guess used to exit 0 having written nothing, because
409
- // rowsForSession() catches the readdir failure and returns []. A dir that
410
- // EXISTS but holds no transcripts yet is a real, legitimate state (a
411
- // session between launch and its first member's spawn) and must not
412
- // refuse; only a path that genuinely does not resolve should.
413
- const missing = join(tempDir("mo-empty-"), "never-created");
414
- const out = join(tempDir("mo-out-"), "member-outcomes.tsv");
415
- const r = spawnSync(process.execPath, [CLI, missing, "--file", out], { encoding: "utf8" });
416
- assert.equal(r.status, 2);
417
- assert.match(r.stderr, /cannot read/);
418
- assert.equal(existsSync(out), false);
419
- });
420
-
421
- test("a session-dir argument that is actually a FILE is a refusal, not a silent no-op", () => {
422
- const root = tempDir("mo-notdir-");
423
- const notADir = join(root, "impl-580.jsonl");
424
- writeFileSync(notADir, "");
425
- const out = join(tempDir("mo-out-"), "member-outcomes.tsv");
426
- const r = spawnSync(process.execPath, [CLI, notADir, "--file", out], { encoding: "utf8" });
427
- assert.equal(r.status, 2);
428
- assert.match(r.stderr, /ENOTDIR/);
429
- assert.equal(existsSync(out), false);
430
- });
431
-
432
- test("a directory that is not an omp <ISO>_<uuid> session dir is a refusal, not silently scraped whole", () => {
433
- // #1302-shaped regression: this CLI hands rowsForSession one EXPLICIT
434
- // directory, which readdirSync's `{recursive:true}` then walks in full —
435
- // so an encoded-cwd PROJECT directory (holding a real nested session dir
436
- // plus a stray top-level main-session transcript, the real tree's own
437
- // shape) used to be silently accepted whole: every session under it
438
- // stamped with the project dir's own name, and the controller's own
439
- // main-session transcript booked as a member.
440
- const root = tempDir("mo-proj-");
441
- const projectDir = join(root, "-dev-fleet-plugin");
442
- const sessionName = "2026-09-08T14-14-34-049Z_01a0815e-e141-716c-b2d8-2adf310fbe55";
443
- mkdirSync(join(projectDir, sessionName), { recursive: true });
444
- writeFileSync(join(projectDir, sessionName, "impl-5.jsonl"),
445
- [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")].join("\n") + "\n");
446
- writeFileSync(join(projectDir, `${sessionName}.jsonl`),
447
- [sessionEvt("/x"), assistantEvt("claude-sonnet-5")].join("\n") + "\n");
448
- const out = join(tempDir("mo-out-"), "member-outcomes.tsv");
449
- const r = spawnSync(process.execPath, [CLI, projectDir, "--file", out], { encoding: "utf8" });
450
- assert.equal(r.status, 2);
451
- assert.match(r.stderr, /is not an omp .* session directory/);
452
- assert.equal(existsSync(out), false);
453
- });
454
-
455
- test("--file=<path> is refused, not silently ignored", () => {
456
- // --file wants a SPACE-separated value, not `=`. Without a check, this never
457
- // sets fileIdx, so it silently writes the PRODUCTION metrics file instead of
458
- // the path the operator asked for.
459
- const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]]]);
460
- const r = spawnSync(process.execPath, [CLI, dir, "--file=/tmp/x.tsv"], { encoding: "utf8" });
461
- assert.equal(r.status, 2);
462
- assert.match(r.stderr, /--file/);
463
- });
464
-
465
- test("an unrecognised flag is refused, not silently dropped", () => {
466
- const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]]]);
467
- const r = spawnSync(process.execPath, [CLI, dir, "--wat"], { encoding: "utf8" });
468
- assert.equal(r.status, 2);
469
- assert.match(r.stderr, /--wat/);
470
- });
471
-
472
- test("two separate sessions scraped in two runs merge into one TSV", () => {
473
- const dirA = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), sessionInitEvt("Implement ticket 580", "fleet-implementer"), assistantEvt("claude-opus-5")]]]);
474
- const dirB = fixture([["Solo", [sessionEvt("/x"), thinkingEvt("high"), sessionInitEvt("Implement ticket 581", "fleet-implementer-alt"), assistantEvt("claude-sonnet-5")]]]);
475
-
476
- const out = join(tempDir("mo-out-"), "member-outcomes.tsv");
477
- const runA = spawnSync(process.execPath, [CLI, dirA, "--file", out], { encoding: "utf8" });
478
- assert.equal(runA.status, 0, runA.stderr);
479
- const runB = spawnSync(process.execPath, [CLI, dirB, "--file", out], { encoding: "utf8" });
480
- assert.equal(runB.status, 0, runB.stderr);
481
-
482
- const rows = parseTsv(readFileSync(out, "utf8"));
483
- assert.equal(rows.length, 2);
484
- assert.deepEqual(new Set(rows.map((r) => r.member)), new Set(["impl-580", "Solo"]));
485
- // #1066: the deliberate-pair column reaches the FILE, not just the record.
486
- assert.equal(rows.find((r) => r.member === "Solo").subagentType, "fleet-implementer-alt");
487
- });
488
-
489
- test("a scrape writes the priced columns off the transcript's usage, the 1h share off its cttl", () => {
490
- const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("high"),
491
- assistantEvt("claude-opus-5", { input: 7, cacheRead: 500, cacheWrite: 300, cttl: { ephemeral1h: 300 }, cost: { total: 0.25 } }),
492
- assistantEvt("claude-opus-5", { input: 3, cacheRead: 800, cacheWrite: 40, cttl: { ephemeral5m: 40 }, cost: { total: 0.0500004 } }, "2026-08-25T10:05:00.000Z"),
493
- ]]]);
494
- const out = join(tempDir("mo-out-"), "member-outcomes.tsv");
495
- const r = spawnSync(process.execPath, [CLI, dir, "--file", out], { encoding: "utf8" });
496
- assert.equal(r.status, 0, r.stderr);
497
- const [row] = parseTsv(readFileSync(out, "utf8"));
498
- assert.deepEqual([row.tokensIn, row.tokensCacheRead, row.tokensCacheCreate, row.tokensCacheWrite1h, row.cost],
499
- ["10", "1300", "340", "300", "0.3"]);
500
- });
501
-
502
- test("a run writes rows, and a second run over the same session changes nothing", () => {
503
- const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]]]);
504
- const out = join(tempDir("mo-out-"), "member-outcomes.tsv");
505
- const run = () => spawnSync(process.execPath, [CLI, dir, "--file", out], { encoding: "utf8" });
506
- assert.equal(run().status, 0);
507
- const first = readFileSync(out, "utf8");
508
- assert.equal(run().status, 0);
509
- assert.equal(readFileSync(out, "utf8"), first);
510
- });
511
-
512
- test("the header survives a rewrite", () => {
513
- // The header carries the read-out commands and the blank-means-unknown rule.
514
- // A rewrite that drops it strands every reader.
515
- const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]]]);
516
- const out = join(tempDir("mo-out-"), "member-outcomes.tsv");
517
- writeFileSync(out, "# keep me\n");
518
- spawnSync(process.execPath, [CLI, dir, "--file", out], { encoding: "utf8" });
519
- assert.match(readFileSync(out, "utf8"), /^# keep me$/m);
520
- });
521
-
522
- test("importing the module never runs the CLI, even from a file whose name ends with its own", () => {
523
- // The guard used to be a suffix match, so a wrapper called
524
- // run-member-outcomes.mjs tripped the CLI block on import: it wrote a file
525
- // and exited 2 in a process that only wanted the helpers.
526
- const dir = tempDir("mo-wrap-");
527
- const wrapper = join(dir, "run-member-outcomes.mjs");
528
- writeFileSync(wrapper, `import { normalizeModel } from ${JSON.stringify(CLI)};\n`
529
- + `console.log(normalizeModel("claude-opus-5"));\n`);
530
- const r = spawnSync(process.execPath, [wrapper], { encoding: "utf8" });
531
- assert.equal(r.status, 0);
532
- assert.equal(r.stdout.trim(), "claude-opus-5");
533
- assert.equal(r.stderr, "");
534
- });
535
-
536
- test("the documented bare form works — no --file needed", () => {
537
- // `member-outcomes.mjs <session-dir>` is the form the spec, the backfill loop
538
- // and run-team's phase-3 instruction all use. It exited 2 for every input
539
- // until the filter stopped treating `fileIdx + 1` as a real index when
540
- // --file is absent.
541
- const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]]]);
542
- const cwd = tempDir("mo-cwd-");
543
- mkdirSync(join(cwd, "docs", "metrics"), { recursive: true });
544
- const r = spawnSync(process.execPath, [CLI, dir], { encoding: "utf8", cwd });
545
- assert.equal(r.status, 0);
546
- assert.match(r.stderr, /scraped 1 of 1 members \(0 dropped\)/);
547
- const written = readFileSync(join(cwd, "docs", "metrics", "member-outcomes.tsv"), "utf8");
548
- assert.match(written, /impl-580/);
549
- });
550
-
551
- test("the run reports its own YIELD, not just the file's size", () => {
552
- // `wrote N rows` printed merged.length — the whole corpus — so a session where
553
- // every member dropped printed the same reassuring line as a healthy one.
554
- //
555
- // Mutation this must survive: printing merged.length alone.
556
- const dir = fixture([
557
- ["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]],
558
- // A sibling dispatched but never answered — the real drop shape: a
559
- // transcript that exists, carries no assistant turn, and so yields no row.
560
- ["impl-581", [sessionEvt("/x"), thinkingEvt("xhigh"), sessionInitEvt("Implement ticket 581", "fleet-implementer")]],
561
- ]);
562
- const out = join(tempDir("mo-out-"), "member-outcomes.tsv");
563
- writeFileSync(out, formatTsv([row({ session: "other", member: "impl-1" })]));
564
-
565
- const r = spawnSync(process.execPath, [CLI, dir, "--file", out], { encoding: "utf8" });
566
- assert.equal(r.status, 0);
567
- assert.match(r.stderr, /scraped 1 of 2 members \(1 dropped\)/);
568
- // The file total is still reported, and is deliberately a DIFFERENT number
569
- // from the yield — that difference is the whole point.
570
- assert.match(r.stderr, /holds 2 rows/);
571
- });
572
-
573
- test("a corpus this schema cannot read is refused before anything is rewritten", () => {
574
- // Reading an out-of-schema file used to pad it and rewrite it, converting a
575
- // human's unresolved merge conflict into confident-looking data.
576
- const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]]]);
577
- const out = join(tempDir("mo-out-"), "member-outcomes.tsv");
578
- const conflicted = "# hdr\n<<<<<<< HEAD\n" + formatTsv([row()]) + "=======\n>>>>>>> theirs\n";
579
- writeFileSync(out, conflicted);
580
- const r = spawnSync(process.execPath, [CLI, dir, "--file", out], { encoding: "utf8" });
581
- assert.equal(r.status, 2);
582
- assert.match(r.stderr, /malformed row/);
583
- assert.equal(readFileSync(out, "utf8"), conflicted, "the file is left exactly as found");
584
- });
585
-
586
- test("the header's blank lines and paragraph order survive a rewrite", () => {
587
- // Collecting every `#` line from anywhere hoisted a below-data note to the
588
- // top and dropped the blank separators, silently, while the comment promised
589
- // "preserved verbatim".
590
- const dir = fixture([["impl-580", [sessionEvt("/x"), thinkingEvt("xhigh"), assistantEvt("claude-opus-5")]]]);
591
- const out = join(tempDir("mo-out-"), "member-outcomes.tsv");
592
- const header = "# first paragraph\n\n# second paragraph\n";
593
- writeFileSync(out, header);
594
- spawnSync(process.execPath, [CLI, dir, "--file", out], { encoding: "utf8" });
595
- assert.equal(readFileSync(out, "utf8").startsWith(header), true);
596
- });
597
-
598
- test("a run dispatched under PascalCase names scrapes into rows tier-outcomes check can join, and a wrong tier fails (#2396)", () => {
599
- // End to end, the two CLIs the ticket's measurement ran: scrape the session,
600
- // then check tier-outcomes.tsv against what was scraped. Before the fix the
601
- // scraped row's ticket was blank, so check reported 0 checked and exited 0
602
- // even with a deliberately wrong tier.
603
- const dir = fixture([
604
- ["Impl327", [sessionEvt("/x"), thinkingEvt("high"), sessionInitEvt("Ticket 327", "fleet-implementer-alt"), assistantEvt("claude-sonnet-5")]],
605
- // Dispatched under the generic `task` definition, so only the NAME can
606
- // book it implementer — implementerRows() filters on role as well as ticket.
607
- ["Impl333", [sessionEvt("/x"), thinkingEvt("high"), sessionInitEvt("Ticket 333"), assistantEvt("claude-opus-5")]],
608
- ["FixPr774", [sessionEvt("/x"), thinkingEvt("high"), sessionInitEvt("Apply the findings"), assistantEvt("claude-opus-5")]],
609
- // No `session_init` line at all, so neither `task` nor `agent` exists: only
610
- // the canonical-stem gate in ompMemberRecord lets the name classify it.
611
- ["Impl340", [sessionEvt("/x"), thinkingEvt("high"), assistantEvt("claude-opus-5")]],
612
- ]);
613
- const work = tempDir("mo-tier-");
614
- const members = join(work, "member-outcomes.tsv");
615
- const scrape = spawnSync(process.execPath, [CLI, dir, "--file", members], { encoding: "utf8" });
616
- assert.equal(scrape.status, 0, scrape.stderr);
617
- const byMember = Object.fromEntries(parseTsv(readFileSync(members, "utf8")).map((r) => [r.member, `${r.role} ticket=${r.ticket} pr=${r.pr}`]));
618
- assert.deepEqual(byMember, {
619
- Impl327: "implementer ticket=327 pr=",
620
- Impl333: "implementer ticket=333 pr=",
621
- FixPr774: "reviewer ticket= pr=774",
622
- Impl340: "implementer ticket=340 pr=",
623
- });
624
-
625
- const check = (tier) => {
626
- const tierFile = join(work, "tier-outcomes.tsv");
627
- const row = [TIER_SWITCH_DATE, "774", "327", "routine", tier, "yes", "no", "n", "light", "production", "40", "2"].join("\t");
628
- writeFileSync(tierFile, `# ${TIER_COLUMNS.join("\t")}\n${row}\n`);
629
- return spawnSync(process.execPath, [TIER_CLI, "check", "--file", tierFile, "--member-outcomes", members, "--ledger", join(work, "no-ledger.md")], { encoding: "utf8", cwd: work });
630
- };
631
- const ok = check("alt");
632
- assert.equal(ok.status, 0, ok.stderr);
633
- assert.match(ok.stdout, /1 rows; 1 checked, 0 failed/);
634
- const mutant = check("WRONGTIER");
635
- assert.equal(mutant.status, 1);
636
- assert.match(mutant.stdout, /1 rows; 1 checked, 1 failed/);
637
- assert.match(mutant.stderr, /PR #774 \(ticket #327\): tier=WRONGTIER/);
638
- });