@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,828 +0,0 @@
1
- import { test } from "node:test";
2
- import assert from "node:assert/strict";
3
- import { spawnSync, execFileSync } from "node:child_process";
4
- import { mkdirSync, writeFileSync, existsSync, readFileSync, chmodSync } from "node:fs";
5
- import { tempDir } from "./temp-dir.mjs";
6
- import { join } from "node:path";
7
- import { fileURLToPath } from "node:url";
8
-
9
- import {
10
- declaredPairFor,
11
- resolveActual, evaluateMember,
12
- formatMismatch, formatOmpExpectation, appendedLedgerText, withToken,
13
- } from "./tier-check.mjs";
14
- import { parseFrontmatter } from "./tier-roles.mjs";
15
- import { deriveRun } from "./fleet-tick.mjs";
16
-
17
- const SCRIPT = fileURLToPath(new URL("./tier-check.mjs", import.meta.url));
18
- const LEDGER_SCRIPT = fileURLToPath(new URL("./ledger.mjs", import.meta.url));
19
-
20
- // ---------------------------------------------------------------------------
21
- // fixtures — shaped like member-record.test.mjs's, one line per event.
22
- //
23
- // Model spellings below are the REAL measured ones, not the bare family
24
- // name: omp's own `resolvedModel`/`resolvedModelIdentity`/transcript
25
- // `model` are ALWAYS provider-prefixed (906/906 measured), sometimes with a
26
- // trailing `:level`. Using anything else here would let a `modelsEqual`
27
- // regression hide behind a fixture omp never actually writes.
28
- // ---------------------------------------------------------------------------
29
-
30
- function agentMd(model) {
31
- return [
32
- "---",
33
- "name: fixture-implementer",
34
- "description: fixture",
35
- `model: ${model}`,
36
- "---",
37
- "",
38
- "Follow the dispatch brief.",
39
- "",
40
- ].join("\n");
41
- }
42
-
43
- // `resolvedModelIdentity` on `session_init` — written at DISPATCH, before any
44
- // assistant turn — is what makes the fixtures below realistic: a member
45
- // still working carries it with no assistant line at all. `agent` is the
46
- // same line's record of the definition the dispatch named (a generic
47
- // dispatch writes `task`).
48
- function ompTranscript(resolvedModelIdentity, thinkingLevel, { withTurn = true, agent } = {}) {
49
- const lines = [
50
- { type: "session", version: 3, id: "s1", timestamp: "2026-09-09T15:11:49.444Z", cwd: "/tmp/x" },
51
- { type: "thinking_level_change", id: "t1", parentId: null, timestamp: "2026-09-09T15:11:49.494Z", thinkingLevel, configured: null },
52
- { type: "session_init", id: "i1", parentId: "t1", timestamp: "2026-09-09T15:11:49.495Z", task: "fixture", resolvedModelIdentity, ...(agent ? { agent } : {}) },
53
- ];
54
- if (withTurn) {
55
- lines.push({
56
- type: "message", id: "m1", parentId: "i1", timestamp: "2026-09-09T15:12:00.000Z",
57
- message: { role: "assistant", content: [{ type: "text", text: "ok" }], model: resolvedModelIdentity, usage: { input: 2, output: 201, cacheRead: 0, cacheWrite: 100, cost: { total: 0.01 } } },
58
- });
59
- }
60
- return lines.map((l) => JSON.stringify(l)).join("\n") + "\n";
61
- }
62
-
63
- function dir() {
64
- return tempDir("tier-check-");
65
- }
66
-
67
- // The measured real `modelRoles` shape (ADR 0011/0014) used by every fixture
68
- // below that needs a role to resolve through: `slow`, `task`, `smol`, each
69
- // carrying its own baked level suffix the way a real install does.
70
- const MODEL_ROLES = {
71
- default: "anthropic/claude-sonnet-5:high",
72
- slow: "anthropic/claude-opus-5:high",
73
- task: "anthropic/claude-sonnet-5:high",
74
- smol: "anthropic/claude-haiku-4-5:auto",
75
- };
76
-
77
- function modelRolesFile(d) {
78
- const p = join(d, "model-roles.json");
79
- writeFileSync(p, JSON.stringify(MODEL_ROLES));
80
- return p;
81
- }
82
-
83
- function runCli(argv, cwd, extra = []) {
84
- return spawnSync(process.execPath, [SCRIPT, ...argv, ...extra], { cwd, encoding: "utf8" });
85
- }
86
-
87
- // ---------------------------------------------------------------------------
88
- // pure core
89
- // ---------------------------------------------------------------------------
90
-
91
- test("parseFrontmatter reads model, role and level together", () => {
92
- const fm = parseFrontmatter(agentMd("@slow:xhigh"));
93
- assert.deepEqual(fm, { model: "@slow:xhigh", role: "slow", level: "xhigh" });
94
- });
95
-
96
- test("declaredPairFor is the frontmatter's own model/level, no harness branch", () => {
97
- const fm = { model: "@slow:xhigh", role: "slow", level: "xhigh" };
98
- assert.deepEqual(declaredPairFor(fm), { model: "@slow:xhigh", level: "xhigh" });
99
- });
100
-
101
- test("a declared model that is not a route never reads ok, even when the resolved model would otherwise match", () => {
102
- const r = evaluateMember({
103
- member: "impl-1",
104
- frontmatter: { model: "opus", role: null, level: "xhigh" },
105
- transcriptText: ompTranscript("opus", "xhigh"),
106
- modelRoles: MODEL_ROLES,
107
- });
108
- assert.equal(r.ok, false, "an unrouted declared model read as a match — null !== null slipped through");
109
- });
110
-
111
- test("appendedLedgerText appends to existing free text rather than replacing it", () => {
112
- assert.equal(appendedLedgerText("impl-42 · class=routine", "note"), "impl-42 · class=routine · note");
113
- assert.equal(appendedLedgerText("", "note"), "note");
114
- assert.equal(appendedLedgerText(null, "note"), "note");
115
- });
116
-
117
- // Review finding #5 (p2): the documented loop is check, fix, re-check — a
118
- // member that still mismatches for the SAME reason on a later run must not
119
- // grow the row a second time. A DIFFERENT note still appends.
120
- test("appendedLedgerText is idempotent on the identical note but still appends a genuinely different one", () => {
121
- assert.equal(appendedLedgerText("impl-42 · class=routine · note", "note"), "impl-42 · class=routine · note");
122
- assert.equal(appendedLedgerText("note", "note"), "note");
123
- assert.equal(appendedLedgerText("impl-42 · class=routine · note", "different note"), "impl-42 · class=routine · note · different note");
124
- });
125
-
126
- // The idempotency guard keys on the note being the row's TRAILING ` · `-joined
127
- // segment, not on the note appearing anywhere: an earlier segment carrying the
128
- // same text (a pair that was since fixed, then re-broken) or a longer segment
129
- // merely ending in it (a different member whose name ends in this one's) is
130
- // not this run's note, and the new one still appends.
131
- test("appendedLedgerText's idempotency is anchored to the trailing ` · ` segment, never a substring match", () => {
132
- assert.equal(
133
- appendedLedgerText("impl-42 · note · class=routine", "note"),
134
- "impl-42 · note · class=routine · note",
135
- );
136
- const note = "Impl-1: declared opus/xhigh resolved anthropic/claude-opus-5/high";
137
- assert.equal(
138
- appendedLedgerText(`impl-42 · Fix${note}`, note),
139
- `impl-42 · Fix${note} · ${note}`,
140
- );
141
- });
142
-
143
- // The idempotency guard is on the token's EXACT presence, not a substring: a
144
- // row already carrying a LONGER token that merely starts with a SHORTER one
145
- // (two definitions sharing a name prefix, `fleet-implementer` vs
146
- // `fleet-implementer-alt`) must still gain the shorter token — `.includes`
147
- // would treat it as already present and silently drop it.
148
- test("withToken's idempotency is exact-token, never a substring match on a token sharing a prefix", () => {
149
- const existing = "impl-7 · class=routine · tier-ok=impl-7:fleet-implementer-alt";
150
- assert.equal(
151
- withToken(existing, "tier-ok=impl-7:fleet-implementer"),
152
- "impl-7 · class=routine · tier-ok=impl-7:fleet-implementer-alt · tier-ok=impl-7:fleet-implementer",
153
- );
154
- });
155
-
156
- test("formatMismatch is the ticket's exact line shape", () => {
157
- const line = formatMismatch({
158
- member: "impl-9",
159
- declared: { model: "@slow:xhigh", level: "xhigh" },
160
- resolved: { model: "anthropic/claude-opus-5", level: "high" },
161
- });
162
- assert.equal(line, "impl-9: declared @slow:xhigh/xhigh resolved anthropic/claude-opus-5/high");
163
- });
164
-
165
- // ---------------------------------------------------------------------------
166
- // Review finding #2 (p1): the omp job-record short-circuit fires ONLY when
167
- // BOTH fields are given; a partial record falls back to the transcript for
168
- // the half it lacks, and never reports the missing half as `null`.
169
- // ---------------------------------------------------------------------------
170
-
171
- test("resolveActual: full job record (both fields) never reads transcriptText", () => {
172
- const r = resolveActual({ transcriptText: undefined, resolvedModel: "anthropic/claude-opus-5", resolvedThinkingLevel: "high" });
173
- assert.deepEqual(r, { model: "anthropic/claude-opus-5", level: "high", viaJobRecord: true });
174
- });
175
-
176
- test("resolveActual: resolvedModel alone falls back to the transcript for the thinking level, never `null`", () => {
177
- const r = resolveActual({
178
- resolvedModel: "anthropic/claude-opus-5", resolvedThinkingLevel: undefined,
179
- transcriptText: ompTranscript("anthropic/claude-opus-5", "xhigh"),
180
- });
181
- assert.deepEqual(r, { model: "anthropic/claude-opus-5", level: "xhigh", viaJobRecord: false });
182
- });
183
-
184
- test("resolveActual: resolvedThinkingLevel alone falls back to the transcript for the model, never `null`", () => {
185
- const r = resolveActual({
186
- resolvedModel: undefined, resolvedThinkingLevel: "xhigh",
187
- transcriptText: ompTranscript("anthropic/claude-sonnet-5", "high"),
188
- });
189
- assert.deepEqual(r, { model: "anthropic/claude-sonnet-5", level: "xhigh", viaJobRecord: false });
190
- });
191
-
192
- test("resolveActual: neither job-record field given reads both off the transcript, preferring resolvedModelIdentity over the per-turn model", () => {
193
- const r = resolveActual({ transcriptText: ompTranscript("anthropic/claude-opus-5", "xhigh") });
194
- assert.deepEqual(r, { model: "anthropic/claude-opus-5", level: "xhigh", viaJobRecord: false });
195
- });
196
-
197
- // Review finding #3 (p1): the identity exists BEFORE the first assistant
198
- // turn — a member still working must resolve from it rather than reading a
199
- // correctly-dispatched member as an unresolved mismatch.
200
- test("resolveActual: a member with no assistant turn yet still resolves via resolvedModelIdentity", () => {
201
- const r = resolveActual({ transcriptText: ompTranscript("anthropic/claude-opus-5", "xhigh", { withTurn: false }) });
202
- assert.deepEqual(r, { model: "anthropic/claude-opus-5", level: "xhigh", viaJobRecord: false });
203
- });
204
-
205
- test("evaluateMember: a still-running member (no assistant turn) at its declared tier reads ok, not a mismatch", () => {
206
- const r = evaluateMember({
207
- member: "StillRunning",
208
- frontmatter: parseFrontmatter(agentMd("@slow:xhigh")),
209
- transcriptText: ompTranscript("anthropic/claude-opus-5", "xhigh", { withTurn: false }),
210
- modelRoles: MODEL_ROLES,
211
- });
212
- assert.equal(r.ok, true, JSON.stringify(r));
213
- });
214
-
215
- // ---------------------------------------------------------------------------
216
- // AC 1 — every fleet agent, at the declared tier -> exit 0
217
- // ---------------------------------------------------------------------------
218
-
219
- test("AC1: fleet-implementer (@slow:xhigh) at declared tier -> ok", () => {
220
- const r = evaluateMember({
221
- member: "AgentWordPair",
222
- frontmatter: parseFrontmatter(agentMd("@slow:xhigh")),
223
- transcriptText: ompTranscript("anthropic/claude-opus-5", "xhigh"),
224
- modelRoles: MODEL_ROLES,
225
- });
226
- assert.equal(r.ok, true, JSON.stringify(r));
227
- });
228
-
229
- test("AC1: fleet-implementer-alt (@task:xhigh) at declared tier -> ok", () => {
230
- const r = evaluateMember({
231
- member: "AnotherWordPair",
232
- frontmatter: parseFrontmatter(agentMd("@task:xhigh")),
233
- transcriptText: ompTranscript("anthropic/claude-sonnet-5", "xhigh"),
234
- modelRoles: MODEL_ROLES,
235
- });
236
- assert.equal(r.ok, true, JSON.stringify(r));
237
- });
238
-
239
- test("AC1 end-to-end via the CLI: a batch of both agents, every one at its declared tier -> exit 0", () => {
240
- const d = dir();
241
- writeFileSync(join(d, "fleet-implementer.agent.md"), agentMd("@slow:xhigh"));
242
- writeFileSync(join(d, "fleet-implementer-alt.agent.md"), agentMd("@task:xhigh"));
243
- writeFileSync(join(d, "omp-impl.jsonl"), ompTranscript("anthropic/claude-opus-5", "xhigh"));
244
- writeFileSync(join(d, "omp-impl-alt.jsonl"), ompTranscript("anthropic/claude-sonnet-5", "xhigh"));
245
- const batch = [
246
- { member: "OmpWordPairOne", agentFile: "fleet-implementer.agent.md", transcript: "omp-impl.jsonl" },
247
- { member: "OmpWordPairTwo", agentFile: "fleet-implementer-alt.agent.md", transcript: "omp-impl-alt.jsonl" },
248
- ];
249
- writeFileSync(join(d, "batch.json"), JSON.stringify(batch));
250
- const r = runCli(["--batch", "batch.json", "--repo", d], d, ["--model-roles", modelRolesFile(d)]);
251
- assert.equal(r.status, 0, r.stdout + r.stderr);
252
- });
253
-
254
- // ---------------------------------------------------------------------------
255
- // AC 2 — the measured real case: resolved thinkingLevel `high` vs declared xhigh
256
- // ---------------------------------------------------------------------------
257
-
258
- test("AC2: resolved thinkingLevel `high` against declared `xhigh` -> mismatch naming both pairs", () => {
259
- const r = evaluateMember({
260
- member: "MeasuredRealCase",
261
- frontmatter: parseFrontmatter(agentMd("@slow:xhigh")),
262
- transcriptText: ompTranscript("anthropic/claude-opus-5", "high"),
263
- modelRoles: MODEL_ROLES,
264
- });
265
- assert.equal(r.ok, false);
266
- assert.deepEqual(r.declared, { model: "@slow:xhigh", level: "xhigh" });
267
- assert.deepEqual(r.resolved, { model: "anthropic/claude-opus-5", level: "high", viaJobRecord: false });
268
- assert.equal(formatMismatch(r), "MeasuredRealCase: declared @slow:xhigh/xhigh resolved anthropic/claude-opus-5/high");
269
- });
270
-
271
- test("AC2 end-to-end via the CLI: the same case exits 1 and prints the member and both pairs", () => {
272
- const d = dir();
273
- writeFileSync(join(d, "fleet-implementer.agent.md"), agentMd("@slow:xhigh"));
274
- writeFileSync(join(d, "omp-impl.jsonl"), ompTranscript("anthropic/claude-opus-5", "high"));
275
- const batch = [{ member: "MeasuredRealCase", agentFile: "fleet-implementer.agent.md", transcript: "omp-impl.jsonl" }];
276
- writeFileSync(join(d, "batch.json"), JSON.stringify(batch));
277
- const r = runCli(["--batch", "batch.json", "--repo", d], d, ["--model-roles", modelRolesFile(d)]);
278
- assert.equal(r.status, 1, r.stdout + r.stderr);
279
- assert.match(r.stderr, /MeasuredRealCase: declared @slow:xhigh\/xhigh resolved anthropic\/claude-opus-5\/high/);
280
- });
281
-
282
- // ---------------------------------------------------------------------------
283
- // AC 3 — role-target mismatch -> exit 1
284
- // ---------------------------------------------------------------------------
285
-
286
- test("AC3: role-target mismatch (declared @task, resolved smol's model) -> mismatch", () => {
287
- const r = evaluateMember({
288
- member: "RoleMismatch",
289
- frontmatter: parseFrontmatter(agentMd("@task:xhigh")),
290
- transcriptText: ompTranscript("anthropic/claude-haiku-4-5", "xhigh"),
291
- modelRoles: MODEL_ROLES,
292
- });
293
- assert.equal(r.ok, false);
294
- assert.equal(formatMismatch(r), "RoleMismatch: declared @task:xhigh/xhigh resolved anthropic/claude-haiku-4-5/xhigh");
295
- });
296
-
297
- test("AC3 end-to-end via the CLI: a role-target mismatch exits 1", () => {
298
- const d = dir();
299
- writeFileSync(join(d, "fleet-implementer.agent.md"), agentMd("@slow:xhigh"));
300
- writeFileSync(join(d, "omp-impl.jsonl"), ompTranscript("anthropic/claude-sonnet-5", "xhigh"));
301
- const batch = [{ member: "RoleMismatchCli", agentFile: "fleet-implementer.agent.md", transcript: "omp-impl.jsonl" }];
302
- writeFileSync(join(d, "batch.json"), JSON.stringify(batch));
303
- const r = runCli(["--batch", "batch.json", "--repo", d], d, ["--model-roles", modelRolesFile(d)]);
304
- assert.equal(r.status, 1, r.stdout + r.stderr);
305
- assert.match(r.stderr, /RoleMismatchCli: declared @slow:xhigh\/xhigh resolved anthropic\/claude-sonnet-5\/xhigh/);
306
- });
307
-
308
- // ---------------------------------------------------------------------------
309
- // AC 4 — job record present: never opens the child's session file; absent:
310
- // it opens the file.
311
- // ---------------------------------------------------------------------------
312
-
313
- test("AC4: resolvedModel/resolvedThinkingLevel given -> resolveActual never reads transcriptText", () => {
314
- const r = resolveActual({ transcriptText: undefined, resolvedModel: "anthropic/claude-opus-5", resolvedThinkingLevel: "high" });
315
- assert.deepEqual(r, { model: "anthropic/claude-opus-5", level: "high", viaJobRecord: true });
316
- });
317
-
318
- test("AC4: job record present in a batch entry -> the CLI never opens (or even names) a transcript file", () => {
319
- const d = dir();
320
- writeFileSync(join(d, "fleet-implementer.agent.md"), agentMd("@slow:xhigh"));
321
- const batch = [{
322
- member: "JobRecordShortcut", agentFile: "fleet-implementer.agent.md",
323
- // No `transcript`/`session` key at all — proves the CLI does not
324
- // require, let alone open, a session file when BOTH job-record fields
325
- // are given.
326
- resolvedModel: "anthropic/claude-opus-5", resolvedThinkingLevel: "xhigh",
327
- }];
328
- writeFileSync(join(d, "batch.json"), JSON.stringify(batch));
329
- const r = runCli(["--batch", "batch.json", "--repo", d], d, ["--model-roles", modelRolesFile(d)]);
330
- assert.equal(r.status, 0, r.stdout + r.stderr);
331
- });
332
-
333
- test("AC4: job record absent -> the CLI opens the transcript file (and a missing one refuses, proving it tried)", () => {
334
- const d = dir();
335
- writeFileSync(join(d, "fleet-implementer.agent.md"), agentMd("@slow:xhigh"));
336
- const batch = [{
337
- member: "NoJobRecord", agentFile: "fleet-implementer.agent.md",
338
- transcript: "does-not-exist.jsonl",
339
- }];
340
- writeFileSync(join(d, "batch.json"), JSON.stringify(batch));
341
- const r = runCli(["--batch", "batch.json", "--repo", d], d, ["--model-roles", modelRolesFile(d)]);
342
- assert.equal(r.status, 2, r.stdout + r.stderr);
343
- assert.match(r.stderr, /ENOENT|does-not-exist\.jsonl/);
344
- });
345
-
346
- test("AC4b: job record PARTIAL (resolvedModel only, no transcript/session given) -> refuses rather than defaulting the missing level to null", () => {
347
- const d = dir();
348
- writeFileSync(join(d, "fleet-implementer.agent.md"), agentMd("@slow:xhigh"));
349
- const batch = [{ member: "PartialNoFallback", agentFile: "fleet-implementer.agent.md", resolvedModel: "anthropic/claude-opus-5" }];
350
- writeFileSync(join(d, "batch.json"), JSON.stringify(batch));
351
- const r = runCli(["--batch", "batch.json", "--repo", d], d, ["--model-roles", modelRolesFile(d)]);
352
- assert.equal(r.status, 2, r.stdout + r.stderr);
353
- assert.match(r.stderr, /no --transcript or --session given/);
354
- });
355
-
356
- test("AC4c: job record PARTIAL (resolvedModel only) plus a transcript for the missing level -> resolves correctly, not a false mismatch", () => {
357
- const d = dir();
358
- writeFileSync(join(d, "fleet-implementer.agent.md"), agentMd("@slow:xhigh"));
359
- writeFileSync(join(d, "omp-impl.jsonl"), ompTranscript("anthropic/claude-opus-5", "xhigh"));
360
- const batch = [{
361
- member: "PartialWithFallback", agentFile: "fleet-implementer.agent.md",
362
- resolvedModel: "anthropic/claude-opus-5", transcript: "omp-impl.jsonl",
363
- }];
364
- writeFileSync(join(d, "batch.json"), JSON.stringify(batch));
365
- const r = runCli(["--batch", "batch.json", "--repo", d], d, ["--model-roles", modelRolesFile(d)]);
366
- assert.equal(r.status, 0, r.stdout + r.stderr);
367
- });
368
-
369
- // ---------------------------------------------------------------------------
370
- // ADR 0011/0014 — the declared alias routes through a role, and compare is
371
- // against THAT role's own `modelRoles.<role>` target, never against the
372
- // alias's own spelling.
373
- // ---------------------------------------------------------------------------
374
-
375
- test("an explicit override suffix reaching a `modelRoles.slow` target at the SAME generation reads ok", () => {
376
- const r = evaluateMember({
377
- member: "impl-1",
378
- frontmatter: parseFrontmatter(agentMd("@slow:xhigh")),
379
- resolvedModel: "anthropic/claude-opus-5-5:xhigh", resolvedThinkingLevel: "xhigh",
380
- modelRoles: { slow: "anthropic/claude-opus-5-5:high" },
381
- });
382
- assert.equal(r.ok, true, JSON.stringify(r));
383
- });
384
-
385
- test("the SAME declared/roles but resolved at an OLDER generation is NOT ok", () => {
386
- const r = evaluateMember({
387
- member: "impl-1",
388
- frontmatter: parseFrontmatter(agentMd("@slow:xhigh")),
389
- resolvedModel: "anthropic/claude-opus-5", resolvedThinkingLevel: "xhigh",
390
- modelRoles: { slow: "anthropic/claude-opus-5-5:high" },
391
- });
392
- assert.equal(r.ok, false, JSON.stringify(r));
393
- assert.equal(formatMismatch(r), "impl-1: declared @slow:xhigh/xhigh resolved anthropic/claude-opus-5/xhigh");
394
- assert.equal(formatOmpExpectation(r), " impl-1: omp routes @slow:xhigh through @slow = anthropic/claude-opus-5-5");
395
- });
396
-
397
- test("modelRoles.slow pointing at another role (`@plan`) resolves through the chain, even to a non-Anthropic model", () => {
398
- const r = evaluateMember({
399
- member: "impl-1",
400
- frontmatter: parseFrontmatter(agentMd("@slow:xhigh")),
401
- resolvedModel: "openai/gpt-5.4", resolvedThinkingLevel: "xhigh",
402
- modelRoles: { slow: "@plan", plan: "openai/gpt-5.4:high" },
403
- });
404
- assert.equal(r.ok, true, JSON.stringify(r));
405
- });
406
-
407
- test("an unset modelRoles.<role> reads not ok, and the expectation line names the unset role", () => {
408
- const r = evaluateMember({
409
- member: "impl-1",
410
- frontmatter: parseFrontmatter(agentMd("@slow:xhigh")),
411
- resolvedModel: "anthropic/claude-opus-5", resolvedThinkingLevel: "xhigh",
412
- modelRoles: {},
413
- });
414
- assert.equal(r.ok, false, JSON.stringify(r));
415
- assert.equal(formatOmpExpectation(r), " impl-1: omp routes @slow:xhigh through @slow = (modelRoles.slow unset)");
416
- });
417
-
418
- test("a non-route declared model reads not ok, and the expectation line names it as unrouted", () => {
419
- const r = evaluateMember({
420
- member: "impl-1",
421
- frontmatter: parseFrontmatter(agentMd("opus")),
422
- resolvedModel: "anthropic/claude-opus-5", resolvedThinkingLevel: "xhigh",
423
- modelRoles: MODEL_ROLES,
424
- });
425
- assert.equal(r.ok, false, JSON.stringify(r));
426
- assert.match(formatOmpExpectation(r), /no role — model: is not a route/);
427
- });
428
-
429
- test("CLI: no --model-roles and no `omp` on PATH refuses naming the config read", () => {
430
- const d = dir();
431
- writeFileSync(join(d, "fleet-implementer.agent.md"), agentMd("@slow:xhigh"));
432
- writeFileSync(join(d, "omp-impl.jsonl"), ompTranscript("anthropic/claude-opus-5", "xhigh"));
433
- const batch = [{ member: "NoPathOmp", agentFile: "fleet-implementer.agent.md", transcript: "omp-impl.jsonl" }];
434
- writeFileSync(join(d, "batch.json"), JSON.stringify(batch));
435
- const emptyPath = tempDir("tier-check-empty-path-");
436
- const r = spawnSync(process.execPath, [SCRIPT, "--batch", "batch.json", "--repo", d], {
437
- cwd: d, encoding: "utf8", env: { ...process.env, PATH: emptyPath },
438
- });
439
- assert.equal(r.status, 2, r.stdout + r.stderr);
440
- assert.match(r.stderr, /omp config get modelRoles --json failed/);
441
- });
442
-
443
- test("CLI: --model-roles pointing at a JSON array refuses", () => {
444
- const d = dir();
445
- writeFileSync(join(d, "fleet-implementer.agent.md"), agentMd("@slow:xhigh"));
446
- writeFileSync(join(d, "omp-impl.jsonl"), ompTranscript("anthropic/claude-opus-5", "xhigh"));
447
- const batch = [{ member: "ArrModelRoles", agentFile: "fleet-implementer.agent.md", transcript: "omp-impl.jsonl" }];
448
- writeFileSync(join(d, "batch.json"), JSON.stringify(batch));
449
- const arrPath = join(d, "model-roles.json");
450
- writeFileSync(arrPath, JSON.stringify(["not", "an", "object"]));
451
- const r = runCli(["--batch", "batch.json", "--repo", d], d, ["--model-roles", arrPath]);
452
- assert.equal(r.status, 2, r.stdout + r.stderr);
453
- });
454
-
455
- // ---------------------------------------------------------------------------
456
- // --session lookup (review finding #4): the controller supplies a session
457
- // root it already knows instead of an exact transcript file.
458
- // ---------------------------------------------------------------------------
459
-
460
- test("--session: resolves via the flat <session>/<member>.jsonl file, bypassing readOmpMember's null-model gate", () => {
461
- const sessionDir = dir();
462
- // No assistant turn at all — proves this path does NOT filter out a
463
- // still-running member the way readOmpMember's `if (!folded.model) return
464
- // null` would (the exact gate this bypass exists to avoid).
465
- writeFileSync(join(sessionDir, "OmpSessionMember.jsonl"), ompTranscript("anthropic/claude-opus-5", "xhigh", { withTurn: false }));
466
- const d = dir();
467
- writeFileSync(join(d, "fleet-implementer.agent.md"), agentMd("@slow:xhigh"));
468
- const batch = [{ member: "OmpSessionMember", agentFile: "fleet-implementer.agent.md", session: sessionDir }];
469
- writeFileSync(join(d, "batch.json"), JSON.stringify(batch));
470
- const r = runCli(["--batch", "batch.json", "--repo", d], d, ["--model-roles", modelRolesFile(d)]);
471
- assert.equal(r.status, 0, r.stdout + r.stderr);
472
- });
473
-
474
- test("--session: no <member>.jsonl under the session root refuses by name", () => {
475
- const sessionDir = dir();
476
- const d = dir();
477
- writeFileSync(join(d, "fleet-implementer.agent.md"), agentMd("@slow:xhigh"));
478
- const batch = [{ member: "NoSuchMember", agentFile: "fleet-implementer.agent.md", session: sessionDir }];
479
- writeFileSync(join(d, "batch.json"), JSON.stringify(batch));
480
- const r = runCli(["--batch", "batch.json", "--repo", d], d, ["--model-roles", modelRolesFile(d)]);
481
- assert.equal(r.status, 2, r.stdout + r.stderr);
482
- assert.match(r.stderr, /no NoSuchMember\.jsonl found under --session/);
483
- });
484
-
485
- // ---------------------------------------------------------------------------
486
- // #1398 — an implementer is judged on the ledger's terms: its definition
487
- // derived from the ticket row's `tier=`, its dispatched agent type read off
488
- // its own transcript, and the verdict written back to the row either way —
489
- // `tier-ok=impl-<N>:<definition>` on a pass, `settle impl-<N> tier-mismatch`
490
- // on a failure. fleet-tick.mjs's deriveRun is the reader of both.
491
- // ---------------------------------------------------------------------------
492
-
493
- const ledgerCli = (file, ...args) => execFileSync(process.execPath, [LEDGER_SCRIPT, "--file", file, ...args], { encoding: "utf8" });
494
-
495
- // One implementer's world: its definitions under <d>/agents/, its ticket row
496
- // on a --file ledger, its transcript at <d>/session/<member>.jsonl — the flat
497
- // `session` lookup phase 2 hands the check.
498
- function implWorld({
499
- ticket = 7, member = `impl-${ticket}`, row = `${member} · class=routine`,
500
- definitions = { "fleet-implementer-slow-high": "@slow:high" },
501
- agent = "fleet-implementer-slow-high", model = "anthropic/claude-opus-5", level = "high",
502
- } = {}) {
503
- const d = dir();
504
- mkdirSync(join(d, "agents"));
505
- for (const [name, route] of Object.entries(definitions)) writeFileSync(join(d, "agents", `${name}.agent.md`), agentMd(route));
506
- const ledger = join(d, "ledger.md");
507
- ledgerCli(ledger, "row", String(ticket), row);
508
- mkdirSync(join(d, "session"));
509
- writeFileSync(join(d, "session", `${member}.jsonl`), ompTranscript(model, level, { agent }));
510
- writeFileSync(join(d, "batch.json"), JSON.stringify([{ member, session: "session" }]));
511
- const read = () => JSON.parse(ledgerCli(ledger, "read"));
512
- return {
513
- ledger, read,
514
- check: () => runCli(["--batch", "batch.json", "--repo", d, "--ledger", ledger, "--model-roles", modelRolesFile(d)], d),
515
- row: () => read().rows.find((r) => r.split(/\s/)[0] === `#${ticket}`),
516
- tick: () => deriveRun({ ...read(), drain: null }, []),
517
- };
518
- }
519
-
520
- test("implementer pass: exit 0 writes tier-ok=impl-<N>:<definition> onto the row exactly once, however often the check re-runs", () => {
521
- const w = implWorld();
522
- const r = w.check();
523
- assert.equal(r.status, 0, r.stdout + r.stderr);
524
- assert.equal(w.row(), "#7 impl-7 · class=routine · tier-ok=impl-7:fleet-implementer-slow-high");
525
- assert.equal(w.check().status, 0);
526
- assert.equal(w.row(), "#7 impl-7 · class=routine · tier-ok=impl-7:fleet-implementer-slow-high", "a re-run grew the row");
527
- // The token is no longer the row's tail once the member settles and the
528
- // controller writes past it — a re-run still finds it.
529
- ledgerCli(w.ledger, "row", "7", "impl-7 · class=routine · tier-ok=impl-7:fleet-implementer-slow-high · → PR#9");
530
- assert.equal(w.check().status, 0);
531
- assert.equal(w.row().split("tier-ok=").length - 1, 1, w.row());
532
- });
533
-
534
- test("implementer mismatch: exit 1 settles the member tier-mismatch on the ledger and notes why, once", () => {
535
- const w = implWorld({ model: "anthropic/claude-sonnet-5" });
536
- const r = w.check();
537
- assert.equal(r.status, 1, r.stdout + r.stderr);
538
- assert.match(r.stderr, /impl-7: declared @slow:high\/high resolved anthropic\/claude-sonnet-5\/high/);
539
- const row = w.row();
540
- assert.equal(row, "#7 impl-7=tier-mismatch · class=routine · impl-7: declared @slow:high/high resolved anthropic/claude-sonnet-5/high");
541
- assert.deepEqual(w.tick().tierMismatch, ["impl-7"]);
542
- const again = w.check();
543
- assert.equal(again.status, 1, again.stdout + again.stderr);
544
- assert.equal(w.row(), row, "a re-run on an unchanged mismatch changed the row");
545
- });
546
-
547
- test("implementer: the expected definition follows the row's tier= — none is the policy cell, any other <cell> its own", () => {
548
- for (const [tier, definition] of [[null, "fleet-implementer-slow-high"], ["task-high", "fleet-implementer-task-high"], ["slow-medium", "fleet-implementer-slow-medium"]]) {
549
- const w = implWorld({
550
- row: `impl-7 · class=routine${tier ? ` · tier=${tier}` : ""}`,
551
- definitions: { "fleet-implementer-slow-high": "@slow:high", "fleet-implementer-task-high": "@slow:high", "fleet-implementer-slow-medium": "@slow:high" },
552
- agent: definition,
553
- });
554
- const r = w.check();
555
- assert.equal(r.status, 0, `${tier}: ${r.stdout}${r.stderr}`);
556
- assert.ok(w.row().endsWith(` · tier-ok=impl-7:${definition}`), `${tier}: ${w.row()}`);
557
- }
558
- // The row's tier, not the dispatch, names the definition: a task-high row
559
- // whose member ran the policy cell fails even though that definition's
560
- // tier resolved exactly.
561
- const w = implWorld({ row: "impl-7 · tier=task-high", definitions: { "fleet-implementer-slow-high": "@slow:high", "fleet-implementer-task-high": "@task:high" } });
562
- const r = w.check();
563
- assert.equal(r.status, 1, r.stdout + r.stderr);
564
- assert.match(r.stderr, /impl-7: dispatched fleet-implementer-slow-high, expected fleet-implementer-task-high/);
565
- });
566
-
567
- test("implementer: a cell with no definition file under agents/ fails as a mismatch rather than crashing the check", () => {
568
- const w = implWorld({ row: "impl-7 · tier=slow-medium", agent: "fleet-implementer-slow-medium" });
569
- const r = w.check();
570
- assert.equal(r.status, 1, r.stdout + r.stderr);
571
- assert.match(r.stderr, /impl-7: expected fleet-implementer-slow-medium has no agents\/fleet-implementer-slow-medium\.agent\.md/);
572
- assert.match(w.row(), /impl-7=tier-mismatch/);
573
- });
574
-
575
- test("implementer: a `task` dispatch fails even when the model and level it resolved match the definition's", () => {
576
- const w = implWorld({ agent: "task" });
577
- const r = w.check();
578
- assert.equal(r.status, 1, r.stdout + r.stderr);
579
- assert.match(r.stderr, /impl-7: dispatched task, expected fleet-implementer-slow-high/);
580
- assert.doesNotMatch(r.stderr, /declared @slow/, "the model half passed and must not be reported as a mismatch");
581
- assert.match(w.row(), /impl-7=tier-mismatch/);
582
- });
583
-
584
- test("implementer: a member already settled another way records tier-mismatch as a row token and holds the tick", () => {
585
- const w = implWorld({ row: "impl-7=bailed · class=routine", agent: "task" });
586
- assert.deepEqual(w.tick().tierUnchecked, ["impl-7"], "a settled member with no verdict must hold as unchecked");
587
- const r = w.check();
588
- assert.equal(r.status, 1, r.stdout + r.stderr);
589
- assert.equal(w.row(), "#7 impl-7=bailed · class=routine · tier-mismatch=impl-7:fleet-implementer-slow-high · impl-7: dispatched task, expected fleet-implementer-slow-high");
590
- assert.deepEqual([w.tick().tierMismatch, w.tick().tierUnchecked], [["impl-7"], []]);
591
- assert.equal(w.check().status, 1);
592
- assert.equal(w.row().split("tier-mismatch=").length - 1, 1, "a re-run wrote the token twice");
593
- });
594
-
595
- test("tick: a settled, unchecked implementer holds; a later tier-check writes tier-ok and the hold clears", () => {
596
- const w = implWorld({ row: "impl-7=released · class=routine" });
597
- assert.deepEqual(w.tick().tierUnchecked, ["impl-7"]);
598
- const r = w.check();
599
- assert.equal(r.status, 0, r.stdout + r.stderr);
600
- assert.deepEqual([w.tick().tierMismatch, w.tick().tierUnchecked], [[], []]);
601
- });
602
-
603
- // A dispatch whose `task` call failed before any transcript was written: the
604
- // member is on the ledger — `dispatch` runs before the call — and the session
605
- // directory exists, but `<session>/<member>.jsonl` does not.
606
- function noTranscriptWorld({ settle = "killed" } = {}) {
607
- const d = dir();
608
- mkdirSync(join(d, "agents"));
609
- writeFileSync(join(d, "agents", "fleet-implementer-slow-high.agent.md"), agentMd("@slow:high"));
610
- const ledger = join(d, "ledger.md");
611
- ledgerCli(ledger, "dispatch", "7", "impl-7");
612
- if (settle) ledgerCli(ledger, "settle", "impl-7", settle);
613
- mkdirSync(join(d, "session"));
614
- const read = () => JSON.parse(ledgerCli(ledger, "read"));
615
- return {
616
- d, ledger,
617
- bytes: () => readFileSync(ledger, "utf8"),
618
- check: (entries = [{ member: "impl-7", session: "session" }]) => {
619
- writeFileSync(join(d, "batch.json"), JSON.stringify(entries));
620
- return runCli(["--batch", "batch.json", "--repo", d, "--ledger", ledger, "--model-roles", modelRolesFile(d)], d);
621
- },
622
- row: () => read().rows.find((r) => r.split(/\s/)[0] === "#7"),
623
- tick: () => deriveRun({ ...read(), drain: null }, []),
624
- };
625
- }
626
-
627
- test("no transcript, member settled: tier-unverifiable is appended once, exit 3, and the tick's unchecked hold clears", () => {
628
- const w = noTranscriptWorld();
629
- assert.deepEqual(w.tick().tierUnchecked, ["impl-7"]);
630
- const r = w.check();
631
- assert.equal(r.status, 3, r.stdout + r.stderr);
632
- assert.equal(w.row(), "#7 impl-7=killed · tier-unverifiable=impl-7:no-transcript");
633
- assert.deepEqual([w.tick().tierUnchecked, w.tick().tierMismatch], [[], []]);
634
- const before = w.bytes();
635
- assert.equal(w.check().status, 3);
636
- assert.equal(w.bytes(), before, "a re-run grew the row");
637
- });
638
-
639
- test("no transcript, member live: still an error — exit 2, nothing written, still unchecked", () => {
640
- const w = noTranscriptWorld({ settle: null });
641
- const before = w.bytes();
642
- const r = w.check();
643
- assert.equal(r.status, 2, r.stdout + r.stderr);
644
- assert.match(r.stderr, /no impl-7\.jsonl found under --session/);
645
- assert.equal(w.bytes(), before);
646
- assert.deepEqual(w.tick().tierUnchecked, ["impl-7"]);
647
- });
648
-
649
- test("no transcript: a session omitted, empty, missing or not a directory is a usage error for live and settled members alike", () => {
650
- for (const settle of [null, "killed"]) {
651
- const w = noTranscriptWorld({ settle });
652
- const before = w.bytes();
653
- for (const session of [undefined, "", "no-such-dir", join("agents", "fleet-implementer.agent.md")]) {
654
- const r = w.check([{ member: "impl-7", ...(session === undefined ? {} : { session }) }]);
655
- assert.equal(r.status, 2, `${settle} ${JSON.stringify(session)}: ${r.stdout}${r.stderr}`);
656
- assert.equal(w.bytes(), before, `${settle} ${JSON.stringify(session)}: the ledger changed`);
657
- }
658
- }
659
- });
660
-
661
- test("no transcript beside a mismatch in one batch: the mismatch's exit 1 wins over exit 3", () => {
662
- const w = noTranscriptWorld();
663
- ledgerCli(w.ledger, "dispatch", "8", "impl-8");
664
- writeFileSync(join(w.d, "session", "impl-8.jsonl"), ompTranscript("anthropic/claude-sonnet-5", "high", { agent: "fleet-implementer" }));
665
- const r = w.check([{ member: "impl-7", session: "session" }, { member: "impl-8", session: "session" }]);
666
- assert.equal(r.status, 1, r.stdout + r.stderr);
667
- assert.match(w.row(), /tier-unverifiable=impl-7:no-transcript/);
668
- assert.deepEqual(w.tick().tierMismatch, ["impl-8"]);
669
- });
670
-
671
- test("no transcript: only `killed` and `released` are a failed dispatch — a member settled any way that proves it ran is a wrong session, exit 2", () => {
672
- for (const settle of ["killed", "released"]) {
673
- const w = noTranscriptWorld({ settle });
674
- const r = w.check();
675
- assert.equal(r.status, 3, `${settle}: ${r.stdout}${r.stderr}`);
676
- assert.equal(w.row(), `#7 impl-7=${settle} · tier-unverifiable=impl-7:no-transcript`);
677
- }
678
- // A PR, a bail report and a mismatch verdict each prove the member ran and
679
- // wrote a transcript, so an existing session directory without it is the
680
- // wrong directory — never a verdict that clears the hold unchecked.
681
- for (const settle of ["PR#20", "bailed", "tier-mismatch"]) {
682
- const w = noTranscriptWorld({ settle });
683
- const before = w.bytes();
684
- const r = w.check();
685
- assert.equal(r.status, 2, `${settle}: ${r.stdout}${r.stderr}`);
686
- assert.match(r.stderr, new RegExp(`impl-7: settled ${settle} with no impl-7\\.jsonl under --session session — .*name the session directory that dispatched it`));
687
- assert.equal(w.bytes(), before, `${settle}: the ledger changed`);
688
- }
689
- });
690
-
691
- test("no transcript: a session directory that cannot be searched is exit 2 naming EACCES, never a recorded tier-unverifiable", (t) => {
692
- if (process.getuid?.() === 0) return t.skip("root searches every directory");
693
- const w = noTranscriptWorld();
694
- // The transcript EXISTS — only the search bit is gone.
695
- writeFileSync(join(w.d, "session", "impl-7.jsonl"), ompTranscript("anthropic/claude-opus-5", "high", { agent: "fleet-implementer" }));
696
- const before = w.bytes();
697
- chmodSync(join(w.d, "session"), 0o000);
698
- let r;
699
- try {
700
- r = w.check();
701
- } finally {
702
- chmodSync(join(w.d, "session"), 0o755);
703
- }
704
- assert.equal(r.status, 2, r.stdout + r.stderr);
705
- assert.match(r.stderr, /impl-7: .*EACCES/);
706
- assert.equal(w.bytes(), before, "an unsearchable session was recorded as no transcript");
707
- assert.deepEqual(w.tick().tierUnchecked, ["impl-7"]);
708
- });
709
-
710
- test("ledger append: a mismatch on a member with no derivable ticket (an omp AgentId) still exits 1 but writes no ledger row", () => {
711
- const d = dir();
712
- execFileSync("git", ["init", "-q"], { cwd: d });
713
- const ledgerFile = join(d, ".fleet", "ledger.md");
714
- writeFileSync(join(d, "fleet-implementer.agent.md"), agentMd("@slow:xhigh"));
715
- writeFileSync(join(d, "omp-impl.jsonl"), ompTranscript("anthropic/claude-opus-5", "high"));
716
- const batch = [{ member: "SomeWordPair", agentFile: "fleet-implementer.agent.md", transcript: "omp-impl.jsonl" }];
717
- writeFileSync(join(d, "batch.json"), JSON.stringify(batch));
718
- const r = runCli(["--batch", "batch.json", "--repo", d, "--ledger", ledgerFile], d, ["--model-roles", modelRolesFile(d)]);
719
- assert.equal(r.status, 1, r.stdout + r.stderr);
720
- assert.equal(existsSync(ledgerFile), false, "a ledger file materialised for a member with no derivable ticket");
721
- });
722
-
723
- test("CLI: --batch given no value refuses by name", () => {
724
- const r = runCli(["--batch"], dir());
725
- assert.equal(r.status, 2);
726
- assert.match(r.stderr, /--batch needs a value/);
727
- });
728
-
729
- test("CLI: no --batch at all refuses with the usage line", () => {
730
- const r = runCli([], dir());
731
- assert.equal(r.status, 2);
732
- assert.match(r.stderr, /usage: tier-check\.mjs/);
733
- });
734
-
735
- test("CLI: a batch entry missing member/agentFile refuses by naming the entry, not a generic parse error", () => {
736
- const d = dir();
737
- writeFileSync(join(d, "batch.json"), JSON.stringify([{ member: "SomeWordPair" }]));
738
- const r = runCli(["--batch", "batch.json", "--repo", d], d, ["--model-roles", modelRolesFile(d)]);
739
- assert.equal(r.status, 2, r.stdout + r.stderr);
740
- assert.match(r.stderr, /missing member\/agentFile/);
741
- });
742
-
743
- test("CLI: an impl- entry carrying agentFile refuses — the definition is the ledger row's, never the caller's", () => {
744
- const d = dir();
745
- writeFileSync(join(d, "batch.json"), JSON.stringify([{ member: "impl-1", agentFile: "agents/fleet-implementer-alt.agent.md", session: "s" }]));
746
- const r = runCli(["--batch", "batch.json", "--repo", d, "--ledger", join(d, "ledger.md")], d, ["--model-roles", modelRolesFile(d)]);
747
- assert.equal(r.status, 2, r.stdout + r.stderr);
748
- assert.match(r.stderr, /impl-1: an impl- entry carries no agentFile/);
749
- });
750
-
751
- test("CLI: --repo defaults to the script's own plugin/ root, so the real agents/fleet-implementer-slow-high.agent.md is found without --repo", () => {
752
- const d = dir();
753
- const ledger = join(d, "ledger.md");
754
- ledgerCli(ledger, "row", "1", "impl-1");
755
- writeFileSync(join(d, "omp-impl.jsonl"), ompTranscript("anthropic/claude-opus-5", "high", { agent: "fleet-implementer-slow-high" }));
756
- const batch = [{ member: "impl-1", transcript: join(d, "omp-impl.jsonl") }];
757
- writeFileSync(join(d, "batch.json"), JSON.stringify(batch));
758
- const r = runCli(["--batch", join(d, "batch.json"), "--ledger", ledger], d, ["--model-roles", modelRolesFile(d)]);
759
- // A row with no `tier=` runs at the policy cell, and the real
760
- // fleet-implementer-slow-high declares @slow:high (implementer-model-tier
761
- // .test.mjs pins the name ⇒ route derivation) — this fixture's transcript
762
- // matches it, so a correctly resolved --repo default exits 0. A wrong
763
- // default (or none) finds no definition file and fails as a mismatch instead.
764
- assert.equal(r.status, 0, r.stdout + r.stderr);
765
- });
766
-
767
- // ---------------------------------------------------------------------------
768
- // #1669: tier-check bound only makeDie/makeArg, so a stray or misspelled flag
769
- // was silently ignored and the run computed a real verdict against the
770
- // DEFAULT ledger/repo instead of refusing. sweep() closes that gap.
771
- // ---------------------------------------------------------------------------
772
-
773
- // No agent/transcript/batch-content fixtures here: sweep() dies on the
774
- // stray flag immediately after the arg() reads, before main() ever opens
775
- // --batch's own file (verified by mutation — deleting this file's fixture
776
- // writes changes no assertion's outcome), so writing them would be dead
777
- // setup that never runs.
778
- test("CLI: an unknown flag outside the roster refuses by name, not a computed verdict", () => {
779
- const d = dir();
780
- const r = runCli(["--batch", "batch.json", "--repo", d, "--zz-no-such-flag"], d);
781
- assert.equal(r.status, 2);
782
- assert.match(r.stderr, /unknown flag --zz-no-such-flag/);
783
- });
784
-
785
- // The ticket's own repro: a misspelled --ledgerr used to fall through to
786
- // arg()'s `||`/`??` default and compute a real 0/1 verdict against the
787
- // DEFAULT ledger, never naming the typo.
788
- test("CLI: a misspelled --ledgerr refuses instead of computing a verdict against the default ledger", () => {
789
- const d = dir();
790
- const r = runCli(["--batch", "batch.json", "--repo", d, "--ledgerr", "/tmp/should-not-be-read.tsv"], d);
791
- assert.equal(r.status, 2, r.stdout + r.stderr);
792
- assert.match(r.stderr, /unknown flag --ledgerr/);
793
- });
794
-
795
- // The false-positive class the sweep addition risks: a roster flag present
796
- // but missing its value must still answer arg()'s own "needs a value"
797
- // message, never sweep()'s generic stray complaint — arg()'s per-flag
798
- // guards run (and can refuse) before sweep() is ever reached. The stray
799
- // riding after the valueless flag is what makes that ordering observable:
800
- // with no stray in argv, sweep() has nothing to complain about and the
801
- // "unknown flag" assertion holds under either ordering (#1711 — a stray-less
802
- // twin of this test stayed green with sweep() hoisted to main()'s first
803
- // statement, so it was deleted rather than kept as a second guard).
804
- test("CLI: a stray flag riding after a valueless roster flag never pre-empts that flag's own value-guard message", () => {
805
- const d = dir();
806
- writeFileSync(join(d, "batch.json"), JSON.stringify([{ member: "impl-1", agentFile: "x.md" }]));
807
- const r = runCli(["--batch", "batch.json", "--repo", "d.md", "--ledger", "--zz-no-such-flag"], d);
808
- assert.equal(r.status, 2, r.stdout + r.stderr);
809
- assert.ok(!r.stderr.includes("unknown flag"));
810
- assert.match(r.stderr, /--ledger needs a value/);
811
- });
812
-
813
- // Review finding #1 (survived, confirmed): sweep() alone only refuses
814
- // `--`-prefixed tokens, so the ticket's stated harm was only half closed —
815
- // a single-dash misspelling (`-ledger`) rode through in silence the same
816
- // way `--ledgerr` used to. Binding stray() alongside sweep(), the same
817
- // pairing every sibling CLI (ci-state, diff-stats, board, pr-overlap)
818
- // already uses, closes the other half.
819
- test("CLI: a single-dash misspelling (`-ledger`) refuses as a stray, not a computed verdict", () => {
820
- const d = dir();
821
- writeFileSync(join(d, "fleet-implementer.agent.md"), agentMd("@slow:xhigh"));
822
- writeFileSync(join(d, "omp-impl.jsonl"), ompTranscript("anthropic/claude-opus-5", "xhigh"));
823
- const batch = [{ member: "impl-1", agentFile: "fleet-implementer.agent.md", transcript: "omp-impl.jsonl" }];
824
- writeFileSync(join(d, "batch.json"), JSON.stringify(batch));
825
- const r = runCli(["--batch", "batch.json", "--repo", d, "-ledger", "/tmp/should-not-be-read.tsv"], d);
826
- assert.equal(r.status, 2, r.stdout + r.stderr);
827
- assert.match(r.stderr, /unexpected argument '-ledger'/);
828
- });