@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,535 +0,0 @@
1
- import { test } from "node:test";
2
- import assert from "node:assert/strict";
3
- import { spawnSync } from "node:child_process";
4
- import { chmodSync, copyFileSync, mkdirSync, readdirSync, writeFileSync } from "node:fs";
5
- import { tempDir } from "./temp-dir.mjs";
6
- import { delimiter, join } from "node:path";
7
- import { fileURLToPath } from "node:url";
8
-
9
- import {
10
- parseModelRoute, parseFrontmatter, stripLevel, resolveRole, expectedOmpModel,
11
- modelsEqual, checkRoutes, catalogEntry,
12
- } from "./tier-roles.mjs";
13
-
14
- const SCRIPT = fileURLToPath(new URL("./tier-roles.mjs", import.meta.url));
15
- const SCRIPTS_DIR = fileURLToPath(new URL(".", import.meta.url));
16
- const REPO_AGENTS = fileURLToPath(new URL("../agents", import.meta.url));
17
-
18
- function dir() {
19
- return tempDir("tier-roles-");
20
- }
21
-
22
- function agentsDir(files) {
23
- const d = dir();
24
- const agents = join(d, "agents");
25
- mkdirSync(agents, { recursive: true });
26
- for (const [name, model] of Object.entries(files)) {
27
- writeFileSync(
28
- join(agents, `${name}.agent.md`),
29
- `---\nname: ${name}\ndescription: fixture\nmodel: ${model}\n---\n\nFollow the dispatch brief.\n`,
30
- );
31
- }
32
- return agents;
33
- }
34
-
35
- function jsonFile(d, name, value) {
36
- const p = join(d, name);
37
- writeFileSync(p, JSON.stringify(value));
38
- return p;
39
- }
40
-
41
- function runCli(argv, cwd, env) {
42
- return spawnSync(process.execPath, [SCRIPT, ...argv], { cwd, encoding: "utf8", env });
43
- }
44
-
45
- // ---------------------------------------------------------------------------
46
- // parseModelRoute / parseFrontmatter
47
- // ---------------------------------------------------------------------------
48
-
49
- test("parseModelRoute: a well-formed route, unquoted", () => {
50
- assert.deepEqual(parseModelRoute("@slow:xhigh"), { role: "slow", level: "xhigh" });
51
- });
52
-
53
- test("parseModelRoute: a well-formed route, double-quoted", () => {
54
- assert.deepEqual(parseModelRoute('"@slow:xhigh"'), { role: "slow", level: "xhigh" });
55
- });
56
-
57
- test("parseModelRoute: a well-formed route, single-quoted", () => {
58
- assert.deepEqual(parseModelRoute("'@task:low'"), { role: "task", level: "low" });
59
- });
60
-
61
- test("parseModelRoute: every role/level combination is accepted", () => {
62
- for (const role of ["slow", "task", "smol"]) {
63
- for (const level of ["minimal", "low", "medium", "high", "xhigh", "max"]) {
64
- assert.deepEqual(parseModelRoute(`@${role}:${level}`), { role, level });
65
- }
66
- }
67
- });
68
-
69
- test("parseModelRoute: a bare vendor alias is not a route", () => {
70
- assert.deepEqual(parseModelRoute("opus"), { role: null, level: null });
71
- });
72
-
73
- test("parseModelRoute: an unrecognised role is not a route", () => {
74
- assert.deepEqual(parseModelRoute("@fast:high"), { role: null, level: null });
75
- });
76
-
77
- test("parseModelRoute: an unrecognised level is not a route", () => {
78
- assert.deepEqual(parseModelRoute("@slow:extreme"), { role: null, level: null });
79
- });
80
-
81
- test("parseModelRoute: missing the :<level> suffix is not a route", () => {
82
- assert.deepEqual(parseModelRoute("@slow"), { role: null, level: null });
83
- });
84
-
85
- test("parseFrontmatter: a quoted route parses model/role/level together", () => {
86
- const text = '---\nname: fleet-x\ndescription: d\nmodel: "@slow:xhigh"\n---\nbody\n';
87
- assert.deepEqual(parseFrontmatter(text), { model: '"@slow:xhigh"', role: "slow", level: "xhigh" });
88
- });
89
-
90
- test("parseFrontmatter: an unquoted route parses the same role/level", () => {
91
- const text = "---\nname: fleet-x\ndescription: d\nmodel: @slow:xhigh\n---\nbody\n";
92
- assert.deepEqual(parseFrontmatter(text), { model: "@slow:xhigh", role: "slow", level: "xhigh" });
93
- });
94
-
95
- test("parseFrontmatter: no model: field at all is null/null/null", () => {
96
- const text = "---\nname: fleet-x\ndescription: d\n---\nbody\n";
97
- assert.deepEqual(parseFrontmatter(text), { model: null, role: null, level: null });
98
- });
99
-
100
- test("parseFrontmatter: a non-route model: value carries the raw model but null role/level", () => {
101
- const text = "---\nname: fleet-x\ndescription: d\nmodel: opus\n---\nbody\n";
102
- assert.deepEqual(parseFrontmatter(text), { model: "opus", role: null, level: null });
103
- });
104
-
105
- // ---------------------------------------------------------------------------
106
- // stripLevel / resolveRole
107
- // ---------------------------------------------------------------------------
108
-
109
- test("stripLevel: removes a trailing :level, never touches the provider /", () => {
110
- assert.equal(stripLevel("anthropic/claude-opus-5:high"), "anthropic/claude-opus-5");
111
- assert.equal(stripLevel("anthropic/claude-opus-5"), "anthropic/claude-opus-5");
112
- assert.equal(stripLevel(null), "");
113
- });
114
-
115
- test("resolveRole: a direct role resolves to its stripped model", () => {
116
- assert.equal(resolveRole("slow", { slow: "anthropic/claude-opus-5:high" }), "anthropic/claude-opus-5");
117
- });
118
-
119
- test("resolveRole: an @-prefixed role value follows the chain to a bare model", () => {
120
- assert.equal(resolveRole("slow", { slow: "@plan", plan: "openai/gpt-5.4:high" }), "openai/gpt-5.4");
121
- });
122
-
123
- test("resolveRole: a cycle returns null rather than recursing forever", () => {
124
- assert.equal(resolveRole("a", { a: "@b", b: "@a" }), null);
125
- });
126
-
127
- test("resolveRole: unset/empty/non-string all return null", () => {
128
- assert.equal(resolveRole("slow", {}), null);
129
- assert.equal(resolveRole("slow", { slow: "" }), null);
130
- assert.equal(resolveRole("slow", { slow: 42 }), null);
131
- });
132
-
133
- // ---------------------------------------------------------------------------
134
- // expectedOmpModel
135
- // ---------------------------------------------------------------------------
136
-
137
- test("expectedOmpModel: a route resolves through the named role", () => {
138
- assert.deepEqual(
139
- expectedOmpModel("@slow:xhigh", { slow: "anthropic/claude-opus-5:auto" }),
140
- { role: "slow", level: "xhigh", model: "anthropic/claude-opus-5" },
141
- );
142
- });
143
-
144
- test("expectedOmpModel: an unset role resolves to a null model, role/level still reported", () => {
145
- assert.deepEqual(expectedOmpModel("@task:low", {}), { role: "task", level: "low", model: null });
146
- });
147
-
148
- test("expectedOmpModel: a non-route value has null role/level/model", () => {
149
- assert.deepEqual(expectedOmpModel("opus", {}), { role: null, level: null, model: null });
150
- });
151
-
152
- // ---------------------------------------------------------------------------
153
- // modelsEqual
154
- // ---------------------------------------------------------------------------
155
-
156
- test("modelsEqual: tolerates a role value written without its provider prefix", () => {
157
- assert.equal(modelsEqual("anthropic/claude-opus-5", "claude-opus-5"), true);
158
- assert.equal(modelsEqual("claude-opus-5", "anthropic/claude-opus-5"), true);
159
- assert.equal(modelsEqual("anthropic/claude-opus-5:high", "anthropic/claude-opus-5"), true);
160
- assert.equal(modelsEqual("anthropic/claude-opus-5", "anthropic/claude-haiku-4-5"), false);
161
- });
162
-
163
- test("modelsEqual: a bare suffix match without the '/' boundary is NOT equal", () => {
164
- // The prefix-tolerance above requires a `/` immediately before the shorter
165
- // spelling — this pins that boundary against a regression to a bare
166
- // `endsWith` (no `/`), which would wrongly equate two DIFFERENT models
167
- // that merely happen to share a trailing token.
168
- assert.equal(modelsEqual("claude-opus-5", "not-claude-opus-5"), false);
169
- assert.equal(modelsEqual("not-claude-opus-5", "claude-opus-5"), false);
170
- assert.equal(modelsEqual("x-claude-opus-5", "claude-opus-5"), false);
171
- });
172
-
173
- // ---------------------------------------------------------------------------
174
- // checkRoutes
175
- // ---------------------------------------------------------------------------
176
-
177
- const MODEL_ROLES = { slow: "anthropic/claude-opus-5:auto", task: "anthropic/claude-sonnet-5:auto", smol: "anthropic/claude-haiku-4-5:auto" };
178
-
179
- // The shape of `omp models --json`, trimmed to the three targets above. The
180
- // efforts are the ones measured on omp's own catalog (spec 2026-09-28 § 2):
181
- // the adaptive pair runs low…max, haiku's budget mode minimal…xhigh — no max.
182
- const ADAPTIVE = ["low", "medium", "high", "xhigh", "max"];
183
- const CATALOG = {
184
- models: [
185
- { provider: "amazon-bedrock", id: "anthropic.claude-haiku-4-5", selector: "amazon-bedrock/anthropic.claude-haiku-4-5", thinking: null },
186
- { provider: "anthropic", id: "claude-opus-5", selector: "anthropic/claude-opus-5", thinking: ADAPTIVE },
187
- { provider: "anthropic", id: "claude-sonnet-5", selector: "anthropic/claude-sonnet-5", thinking: ADAPTIVE },
188
- { provider: "anthropic", id: "claude-haiku-4-5", selector: "anthropic/claude-haiku-4-5", thinking: ["minimal", "low", "medium", "high", "xhigh"] },
189
- ],
190
- };
191
-
192
- const routes = (files, modelRoles = MODEL_ROLES, overrides = {}) =>
193
- checkRoutes({ agentsDir: agentsDir(files), modelRoles, overrides, catalog: CATALOG });
194
-
195
- test("checkRoutes: every definition routed and every role resolvable -> no violations or notices", () => {
196
- assert.deepEqual(routes({ "fleet-a": "@slow:xhigh", "fleet-b": "@smol:low" }), { violations: [], notices: [] });
197
- });
198
-
199
- test("checkRoutes: an agents directory holding no *.agent.md definition is a violation naming the directory, never a vacuous pass", () => {
200
- const empty = agentsDir({});
201
- const { violations } = checkRoutes({ agentsDir: empty, modelRoles: MODEL_ROLES, overrides: {}, catalog: CATALOG });
202
- assert.deepEqual(violations, [`no *.agent.md definition found in ${empty}`]);
203
-
204
- // A directory that holds only files the check does not read is the same case.
205
- writeFileSync(join(empty, "README.md"), "not a definition\n");
206
- assert.deepEqual(checkRoutes({ agentsDir: empty, modelRoles: MODEL_ROLES, overrides: {}, catalog: CATALOG }).violations, [`no *.agent.md definition found in ${empty}`]);
207
- });
208
-
209
- test("checkRoutes: an empty agents directory still reports the other violations alongside", () => {
210
- const { violations } = checkRoutes({ agentsDir: agentsDir({}), modelRoles: MODEL_ROLES, overrides: { "fleet-a": "@slow:xhigh" }, catalog: CATALOG });
211
- assert.equal(violations.length, 2);
212
- assert.match(violations.join("\n"), /task\.agentModelOverrides\.fleet-a shadows/);
213
- });
214
-
215
- test("checkRoutes: an --agents path that is missing, or a regular file, is a violation naming the flag and path, not a crash", () => {
216
- const d = dir();
217
- const missing = join(d, "nope");
218
- const file = join(d, "plain.txt");
219
- writeFileSync(file, "x\n");
220
- for (const [path, code] of [[missing, "ENOENT"], [file, "ENOTDIR"]]) {
221
- const { violations } = checkRoutes({ agentsDir: path, modelRoles: MODEL_ROLES, overrides: {}, catalog: CATALOG });
222
- assert.deepEqual(violations, [`--agents ${path}: cannot read the agents directory (${code})`]);
223
- }
224
- });
225
-
226
- test("checkRoutes: a directory named *.agent.md is a violation naming the entry, and the readable definitions after it are still checked", () => {
227
- const agents = agentsDir({ "fleet-a": "@slow:xhigh", "fleet-b": "@smol:max" });
228
- mkdirSync(join(agents, "a.agent.md"));
229
- const { violations } = checkRoutes({ agentsDir: agents, modelRoles: MODEL_ROLES, overrides: {}, catalog: CATALOG });
230
- assert.equal(violations.length, 2);
231
- assert.equal(violations[0], `--agents ${agents}: cannot read a.agent.md (EISDIR)`);
232
- assert.match(violations[1], /^fleet-b\.agent\.md: level max is not one modelRoles\.smol's target/);
233
- });
234
-
235
- test("checkRoutes: an unreadable agents directory names the source the caller gives, not --agents", () => {
236
- const missing = join(dir(), "nope");
237
- const { violations } = checkRoutes({ agentsDir: missing, agentsSource: "the default agents directory X", modelRoles: MODEL_ROLES, overrides: {}, catalog: CATALOG });
238
- assert.deepEqual(violations, ["the default agents directory X: cannot read the agents directory (ENOENT)"]);
239
- });
240
-
241
- test("checkRoutes (a): a definition whose model: is not a route is a violation naming the file", () => {
242
- const { violations } = routes({ "fleet-a": "opus" });
243
- assert.equal(violations.length, 1);
244
- assert.match(violations[0], /^fleet-a\.agent\.md: model "opus" is not @<role>:<level>$/);
245
- });
246
-
247
- test("checkRoutes (b): a used role with no modelRoles entry is a violation naming the role and the definition", () => {
248
- const { violations } = routes({ "fleet-a": "@slow:xhigh" }, {});
249
- assert.equal(violations.length, 1);
250
- assert.match(violations[0], /modelRoles\.slow is unset/);
251
- assert.match(violations[0], /fleet-a\.agent\.md/);
252
- });
253
-
254
- test("checkRoutes (b): an unset role no definition uses is not a violation", () => {
255
- assert.deepEqual(routes({ "fleet-a": "@slow:xhigh" }, { slow: MODEL_ROLES.slow }).violations, []);
256
- });
257
-
258
- test("checkRoutes (c): a fleet- key in task.agentModelOverrides shadows the definition and violates, remedy resets when nothing else remains", () => {
259
- const { violations } = routes({ "fleet-a": "@slow:xhigh" }, MODEL_ROLES, { "fleet-a": "@slow:xhigh" });
260
- assert.equal(violations.length, 1);
261
- assert.match(violations[0], /task\.agentModelOverrides\.fleet-a shadows the definition's own model \(precedence #1\) — remove it/);
262
- assert.match(violations[0], /omp config reset task\.agentModelOverrides/);
263
- });
264
-
265
- test("checkRoutes (c): the remedy keeps the operator's own non-fleet- entries when one exists", () => {
266
- const { violations } = routes({ "fleet-a": "@slow:xhigh" }, MODEL_ROLES, { "fleet-a": "@slow:xhigh", "my-other-agent": "opus" });
267
- assert.equal(violations.length, 1);
268
- assert.match(violations[0], /omp config set task\.agentModelOverrides/);
269
- assert.match(violations[0], /my-other-agent/);
270
- assert.doesNotMatch(violations[0], /"fleet-a"/);
271
- });
272
-
273
- test("checkRoutes (c): a non-fleet- override key is the operator's own and never violates", () => {
274
- assert.deepEqual(routes({ "fleet-a": "@slow:xhigh" }, MODEL_ROLES, { "my-other-agent": "opus" }).violations, []);
275
- });
276
-
277
- test("checkRoutes (d): a level the role's target does not run at is a violation naming the file and the efforts", () => {
278
- // The one the spec names: haiku has no `max`, so `smol-max` would clamp.
279
- const { violations } = routes({ "fleet-implementer-smol-max": "@smol:max", "fleet-implementer-smol-high": "@smol:high" });
280
- assert.equal(violations.length, 1);
281
- assert.match(violations[0], /^fleet-implementer-smol-max\.agent\.md: level max is not one modelRoles\.smol's target anthropic\/claude-haiku-4-5 runs at \(thinking: minimal, low, medium, high, xhigh\)/);
282
- // And the other edge of the adaptive range: no `minimal` on opus.
283
- assert.match(routes({ "fleet-a": "@slow:minimal" }).violations[0] ?? "", /fleet-a\.agent\.md: level minimal/);
284
- });
285
-
286
- test("checkRoutes (d): every level a target lists is accepted, through a role value written without its provider", () => {
287
- // The must-ACCEPT half: `task-max` is a real wire effort on the adaptive
288
- // models, and `smol-minimal` one on haiku's budget mode.
289
- assert.deepEqual(routes({ "fleet-a": "@task:max", "fleet-b": "@smol:minimal", "fleet-c": "@slow:low" }).violations, []);
290
- assert.deepEqual(routes({ "fleet-a": "@task:max" }, { task: "claude-sonnet-5:high" }).violations, []);
291
- });
292
-
293
- test("checkRoutes (d): a target the catalog does not list, or lists with no thinking at all, cannot pass", () => {
294
- const unlisted = routes({ "fleet-a": "@slow:high" }, { slow: "acme/unknown-1" }).violations;
295
- assert.equal(unlisted.length, 1);
296
- assert.match(unlisted[0], /modelRoles\.slow resolves to acme\/unknown-1, which omp's model catalog does not list — cannot check the level of fleet-a\.agent\.md/);
297
- const thinkless = routes({ "fleet-a": "@smol:low" }, { smol: "amazon-bedrock/anthropic.claude-haiku-4-5" }).violations;
298
- assert.equal(thinkless.length, 1);
299
- assert.match(thinkless[0], /level low is not one .*\(thinking: none\)/);
300
- });
301
-
302
- test("checkRoutes (d): a catalog omp did not print is named as a shape error, never blamed on the operator's roles", () => {
303
- const withCatalog = (catalog, modelRoles = MODEL_ROLES) =>
304
- checkRoutes({ agentsDir: agentsDir({ "fleet-a": "@slow:high" }), modelRoles, overrides: {}, catalog }).violations;
305
- for (const [catalog, kind] of [[{}, "absent"], [{ models: "nope" }, "string"], [{ models: null }, "null"]]) {
306
- const v = withCatalog(catalog);
307
- assert.equal(v.length, 1, JSON.stringify(v));
308
- assert.equal(v[0], `omp's model catalog has no models list (models: ${kind}) — cannot check the level of any definition`);
309
- }
310
- // An unset role is still its own violation beside a malformed catalog.
311
- assert.deepEqual(withCatalog({}, {}).map((v) => v.split(" ")[0]), ["omp's", "modelRoles.slow"]);
312
- const opus = (thinking) => ({ models: [{ selector: "anthropic/claude-opus-5", thinking }] });
313
- for (const [thinking, kind] of [["low,medium,high,max", "string"], [undefined, "absent"], [{ high: true }, "object"]]) {
314
- const v = withCatalog(opus(thinking));
315
- assert.equal(v.length, 1, JSON.stringify(v));
316
- assert.equal(v[0], `omp's model catalog lists anthropic/claude-opus-5 with thinking that is neither a list nor null (${kind}) — cannot check the level of fleet-a.agent.md`);
317
- }
318
- // The must-ACCEPT half: `thinking: null` is a real catalog value (a model
319
- // with no efforts), so it stays the level violation, and an empty list is a list.
320
- assert.match(withCatalog(opus(null))[0], /^fleet-a\.agent\.md: level high is not one .*\(thinking: none\)/);
321
- assert.match(withCatalog(opus([]))[0], /^fleet-a\.agent\.md: level high is not one .*\(thinking: none\)/);
322
- assert.deepEqual(withCatalog(opus(["high"])), []);
323
- });
324
-
325
- test("catalogEntry: an exact selector wins over a provider-less match", () => {
326
- assert.equal(catalogEntry("anthropic/claude-haiku-4-5", CATALOG).provider, "anthropic");
327
- assert.equal(catalogEntry("claude-opus-5", CATALOG).selector, "anthropic/claude-opus-5");
328
- assert.equal(catalogEntry("claude-opus", CATALOG), null);
329
- assert.equal(catalogEntry("anthropic/claude-opus-5", {}), null);
330
- });
331
-
332
- test("checkRoutes (e): slow and task resolving to the same model is a notice, not a violation", () => {
333
- const { violations, notices } = routes(
334
- { "fleet-a": "@slow:xhigh" },
335
- { slow: "anthropic/claude-opus-5:auto", task: "anthropic/claude-opus-5:auto", smol: MODEL_ROLES.smol },
336
- );
337
- assert.deepEqual(violations, []);
338
- assert.equal(notices.length, 1);
339
- assert.match(notices[0], /modelRoles\.slow and modelRoles\.task both resolve to/);
340
- });
341
-
342
- test("checkRoutes (e): slow and task resolving to different models is not a notice", () => {
343
- assert.deepEqual(routes({ "fleet-a": "@slow:xhigh" }).notices, []);
344
- });
345
-
346
- // The five-cell grid at ratification (spec 2026-09-28 § 2), and every real
347
- // definition clean against targets that run each one's level.
348
- test("checkRoutes: every real plugin/agents definition routes cleanly, and the implementer definitions are exactly the five cells", () => {
349
- const cells = readdirSync(REPO_AGENTS)
350
- .map((f) => /^fleet-implementer(?:-(.+))?\.agent\.md$/.exec(f))
351
- .filter(Boolean)
352
- .map((m) => m[1]);
353
- assert.deepEqual(cells.sort(), ["slow-high", "slow-medium", "smol-high", "task-high", "task-max"]);
354
- const { violations } = checkRoutes({ agentsDir: REPO_AGENTS, modelRoles: MODEL_ROLES, overrides: {}, catalog: CATALOG });
355
- assert.deepEqual(violations, []);
356
- });
357
-
358
- // ---------------------------------------------------------------------------
359
- // CLI
360
- // ---------------------------------------------------------------------------
361
-
362
- // Every flag the check reads the live install through, pointed at a fixture:
363
- // a test that left one off would shell out to the box's own `omp`.
364
- function installFlags(d, { overrides = {}, modelRoles = MODEL_ROLES, catalog = CATALOG } = {}) {
365
- return [
366
- "--overrides", jsonFile(d, "overrides.json", overrides),
367
- "--model-roles", jsonFile(d, "model-roles.json", modelRoles),
368
- "--catalog", jsonFile(d, "catalog.json", catalog),
369
- ];
370
- }
371
-
372
- test("CLI: --check with a clean install exits 0", () => {
373
- const d = dir();
374
- const agents = agentsDir({ "fleet-a": "@slow:xhigh" });
375
- const r = runCli(["--check", "--agents", agents, ...installFlags(d)], d);
376
- assert.equal(r.status, 0, r.stderr);
377
- });
378
-
379
- test("CLI: --check on an agents directory with no definitions exits 1 naming the directory", () => {
380
- const d = dir();
381
- const agents = agentsDir({});
382
- const r = runCli(["--check", "--agents", agents, ...installFlags(d)], d);
383
- assert.equal(r.status, 1);
384
- assert.match(r.stderr, /no \*\.agent\.md definition found in /);
385
- assert.doesNotMatch(r.stdout, /every definition routes/);
386
- });
387
-
388
- test("CLI: --check on an --agents path that is missing, a regular file, or holds a directory named *.agent.md exits 1 with a refusal naming the cause, no stack trace", () => {
389
- const d = dir();
390
- const file = join(d, "plain.txt");
391
- writeFileSync(file, "x\n");
392
- const trap = agentsDir({ "fleet-a": "@slow:xhigh" });
393
- mkdirSync(join(trap, "x.agent.md"));
394
- for (const [path, code] of [[join(d, "nope"), "ENOENT"], [file, "ENOTDIR"], [trap, "EISDIR"]]) {
395
- const r = runCli(["--check", "--agents", path, ...installFlags(d)], d);
396
- assert.equal(r.status, 1, path);
397
- assert.match(r.stderr, new RegExp(`^tier-roles: --agents ${path.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}: cannot read .*\\(${code}\\)`), path);
398
- assert.doesNotMatch(r.stderr, /\n\s+at /, path);
399
- assert.doesNotMatch(r.stdout, /every definition routes/);
400
- }
401
- });
402
-
403
- test("CLI: --check with no --agents and an unreadable built-in agents directory refuses without naming a flag it was not given", () => {
404
- const d = dir();
405
- const scripts = join(d, "scripts");
406
- mkdirSync(scripts);
407
- for (const f of ["tier-roles.mjs", "arg.mjs", "is-cli.mjs"]) copyFileSync(join(SCRIPTS_DIR, f), join(scripts, f));
408
- const r = spawnSync(process.execPath, [join(scripts, "tier-roles.mjs"), "--check", ...installFlags(d)], { cwd: d, encoding: "utf8" });
409
- assert.equal(r.status, 1, r.stderr);
410
- assert.match(r.stderr, /^tier-roles: the default agents directory .*agents: cannot read the agents directory \(ENOENT\)/);
411
- assert.doesNotMatch(r.stderr, /--agents/);
412
- assert.doesNotMatch(r.stderr, /\n\s+at /);
413
- });
414
-
415
- test("CLI: --check with a non-route model: exits 1 naming the file", () => {
416
- const d = dir();
417
- const agents = agentsDir({ "fleet-a": "opus" });
418
- const r = runCli(["--check", "--agents", agents, ...installFlags(d)], d);
419
- assert.equal(r.status, 1);
420
- assert.match(r.stderr, /fleet-a\.agent\.md: model "opus" is not @<role>:<level>/);
421
- });
422
-
423
- test("CLI: --check with a shadowing fleet- override exits 1 naming the remedy", () => {
424
- const d = dir();
425
- const agents = agentsDir({ "fleet-a": "@slow:xhigh" });
426
- const r = runCli(["--check", "--agents", agents, ...installFlags(d, { overrides: { "fleet-a": "@slow:xhigh" } })], d);
427
- assert.equal(r.status, 1);
428
- assert.match(r.stderr, /omp config reset task\.agentModelOverrides/);
429
- });
430
-
431
- test("CLI: --check with a smol-max cell exits 1 — haiku has no max, and the check refuses rather than clamps", () => {
432
- const d = dir();
433
- const agents = agentsDir({ "fleet-implementer-smol-high": "\"@smol:high\"", "fleet-implementer-smol-max": "\"@smol:max\"" });
434
- const r = runCli(["--check", "--agents", agents, ...installFlags(d)], d);
435
- assert.equal(r.status, 1);
436
- assert.match(r.stderr, /fleet-implementer-smol-max\.agent\.md: level max is not one modelRoles\.smol's target/);
437
- assert.doesNotMatch(r.stderr, /smol-high/);
438
- });
439
-
440
- test("CLI: a --catalog that is not a JSON object refuses by flag", () => {
441
- const d = dir();
442
- const agents = agentsDir({ "fleet-a": "@slow:xhigh" });
443
- const r = runCli(["--check", "--agents", agents, ...installFlags(d, { catalog: [] })], d);
444
- assert.equal(r.status, 2);
445
- assert.match(r.stderr, /--catalog .*catalog\.json must be a JSON object, got an array/);
446
- });
447
-
448
- test("CLI: a --catalog file holding null refuses as null, not as object", () => {
449
- const d = dir();
450
- const agents = agentsDir({ "fleet-a": "@slow:xhigh" });
451
- const r = runCli(["--check", "--agents", agents, ...installFlags(d, { catalog: null })], d);
452
- assert.equal(r.status, 2);
453
- assert.match(r.stderr, /--catalog .*catalog\.json must be a JSON object, got null$/m);
454
- });
455
-
456
- test("CLI: --check without --check flag is required", () => {
457
- const d = dir();
458
- const r = runCli([], d);
459
- assert.equal(r.status, 2);
460
- assert.match(r.stderr, /--check is required/);
461
- });
462
-
463
- test("CLI: an unknown flag refuses by name", () => {
464
- const d = dir();
465
- const r = runCli(["--check", "--bogus", "x"], d);
466
- assert.equal(r.status, 2);
467
- assert.match(r.stderr, /unknown flag --bogus/);
468
- });
469
-
470
- test("CLI: --agents defaults to the plugin's own agents directory", () => {
471
- const d = dir();
472
- const r = runCli(["--check", ...installFlags(d)], d);
473
- assert.equal(r.status, 0, r.stderr);
474
- });
475
-
476
- // A fake `omp` first on PATH whose every invocation prints `stdout` — the live
477
- // reads (`omp config get … --json`, `omp models --json`) have no flag-free
478
- // fixture path, so the binary itself is the fixture.
479
- function runCliWithFakeOmp(stdout, argv, cwd) {
480
- const bin = dir();
481
- const fake = join(bin, "omp");
482
- writeFileSync(fake, `#!/bin/sh\ncat <<'FAKE_OMP_EOF'\n${stdout}\nFAKE_OMP_EOF\n`);
483
- chmodSync(fake, 0o755);
484
- return runCli(argv, cwd, { ...process.env, PATH: `${bin}${delimiter}${process.env.PATH}` });
485
- }
486
-
487
- // What an `omp` read may print that is JSON yet not an object, with the shape
488
- // the refusal names.
489
- const NON_OBJECTS = [["null", "null"], ["an array", "[]"], ["a string", "\"x\""], ["a number", "42"], ["a boolean", "true"]];
490
-
491
- for (const [shape, printed] of NON_OBJECTS) {
492
- test(`CLI: live \`omp config get\` printing ${shape} refuses naming the command`, () => {
493
- const d = dir();
494
- const agents = agentsDir({ "fleet-a": "@slow:xhigh" });
495
- const r = runCliWithFakeOmp(printed, ["--check", "--agents", agents, "--model-roles", jsonFile(d, "mr.json", MODEL_ROLES), "--catalog", jsonFile(d, "c.json", CATALOG)], d);
496
- assert.equal(r.status, 2, r.stderr);
497
- assert.match(r.stderr, new RegExp(`omp config get task\\.agentModelOverrides --json exited 0 but printed ${shape}, not a JSON object`));
498
- });
499
- }
500
-
501
- for (const [shape, printed] of NON_OBJECTS) {
502
- test(`CLI: live \`omp models\` printing ${shape} refuses naming the command`, () => {
503
- const d = dir();
504
- const agents = agentsDir({ "fleet-a": "@slow:xhigh" });
505
- const r = runCliWithFakeOmp(printed, ["--check", "--agents", agents, "--overrides", jsonFile(d, "o.json", {}), "--model-roles", jsonFile(d, "mr.json", MODEL_ROLES)], d);
506
- assert.equal(r.status, 2, r.stderr);
507
- assert.match(r.stderr, new RegExp(`omp models --json exited 0 but printed ${shape}, not a JSON object`));
508
- });
509
- }
510
-
511
- test("CLI: live `omp config get` envelope holding a null value refuses as null, not as object", () => {
512
- const d = dir();
513
- const agents = agentsDir({ "fleet-a": "@slow:xhigh" });
514
- const r = runCliWithFakeOmp("{\"value\":null}", ["--check", "--agents", agents, "--model-roles", jsonFile(d, "mr.json", MODEL_ROLES), "--catalog", jsonFile(d, "c.json", CATALOG)], d);
515
- assert.equal(r.status, 2, r.stderr);
516
- assert.match(r.stderr, /omp config get task\.agentModelOverrides --json must be a JSON object, got null$/m);
517
- });
518
-
519
- test("CLI: live `omp` reads printing well-formed objects are accepted", () => {
520
- const d = dir();
521
- const agents = agentsDir({ "fleet-a": "@slow:xhigh" });
522
- // One fake serves all three reads: `{ value, models }` satisfies the config
523
- // envelope and the catalog at once; each config read then takes `value` as its record.
524
- const printed = JSON.stringify({ value: {}, models: CATALOG.models });
525
- const r = runCliWithFakeOmp(printed, ["--check", "--agents", agents], d);
526
- assert.notEqual(r.status, 2, r.stderr);
527
- assert.doesNotMatch(r.stderr, /not a JSON object/);
528
- });
529
-
530
- test("CLI: live `omp` reads printing an empty object are not refused by the readOmpJson guard", () => {
531
- const d = dir();
532
- const agents = agentsDir({ "fleet-a": "@slow:xhigh" });
533
- const r = runCliWithFakeOmp("{}", ["--check", "--agents", agents], d);
534
- assert.doesNotMatch(r.stderr, /exited 0 but printed/);
535
- });