@feigi/fleet-ctl 3.65.0 → 3.66.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feigi/fleet-ctl",
3
- "version": "3.65.0",
3
+ "version": "3.66.0",
4
4
  "description": "Agent fleet: run-team controller, merge bot, PR reviewer, and the ticket pipeline they share",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -25,8 +25,15 @@
25
25
  // silently (`claude-haiku-4-5` has no `max`, so `@smol:max` would run
26
26
  // at something else), tier-check would then read a level the
27
27
  // definition never declared, and every row the definition ran would
28
- // be inadmissible. A target the catalog does
29
- // not list cannot be checked, so it fails too;
28
+ // be inadmissible. The one exception is an implementer definition
29
+ // whose cell the router never selects (not in the router table's
30
+ // `cells`, in none of its `rows` values, and not the policy cell): a
31
+ // cell can be defined before the router may pick it, so its mismatch
32
+ // is a notice. The router table is `router-table.json` beside this
33
+ // script, or the file `--table <path>` names; one that cannot be read,
34
+ // or that lacks a `cells` array or a `rows` object of cell names,
35
+ // refuses. A target the catalog does not list cannot be checked, so it
36
+ // fails too;
30
37
  // (e) `modelRoles.slow`/`modelRoles.task` resolving to the same model is
31
38
  // flagged as a notice — legal, but every `slow-*` cell then measures
32
39
  // the same model as its `task-*` twin;
@@ -48,6 +55,7 @@ import { join, dirname } from "node:path";
48
55
  import { fileURLToPath } from "node:url";
49
56
  import { isCLI } from "./is-cli.mjs";
50
57
  import { makeDie, defineFlags } from "./arg.mjs";
58
+ import { CELL_DEF, POLICY_CELL } from "./ledger-grammar.mjs";
51
59
 
52
60
  const NAME = "tier-roles";
53
61
  const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
@@ -122,6 +130,28 @@ export function expectedOmpModel(declaredModel, modelRoles) {
122
130
  return { role, level, model: role ? resolveRole(role, modelRoles) : null };
123
131
  }
124
132
 
133
+ // A definition file name -> the implementer cell it is (`task-max` for
134
+ // `fleet-implementer-task-max.agent.md`), `null` for any other definition,
135
+ // including one whose name is not a cell.
136
+ export function implementerCell(file) {
137
+ const name = file.replace(/\.agent\.md$/, "");
138
+ return CELL_DEF.test(name) ? name.slice("fleet-implementer-".length) : null;
139
+ }
140
+
141
+ // The cells the router can select from a parsed router table: the pool it
142
+ // explores (`cells`), the cell each stratum's row names (`rows` values) and the
143
+ // policy cell, which every Pull falls back to whatever the table says. An
144
+ // Error saying why when the table lacks a `cells` array of names or a `rows`
145
+ // object of names — a table that cannot be read must refuse, never quietly
146
+ // make every cell non-routable.
147
+ export function routableCells(table) {
148
+ const bad = (why) => new Error(`router table: ${why}`);
149
+ if (!isJsonObject(table)) return bad("not a JSON object");
150
+ if (!Array.isArray(table.cells) || !table.cells.every((c) => typeof c === "string")) return bad("`cells` is not an array of cell names");
151
+ if (!isJsonObject(table.rows) || !Object.values(table.rows).every((c) => typeof c === "string")) return bad("`rows` is not an object of cell names");
152
+ return new Set([POLICY_CELL, ...table.cells, ...Object.values(table.rows)]);
153
+ }
154
+
125
155
  // Tolerates a role value written without its provider prefix — omp's
126
156
  // `resolvedModelIdentity` is always provider-prefixed, a plain `modelRoles`
127
157
  // entry may not be.
@@ -210,8 +240,11 @@ function kindOf(v) {
210
240
  // leftover `task.agentModelOverrides`) against what the fleet's own
211
241
  // definitions need. `violations` stop a run; `notices` never do —
212
242
  // they flag a hazard (two roles' cells measuring one model) that is legal
213
- // configuration, just probably not what the operator meant.
214
- export function checkRoutes({ agentsDir, agentsSource = `--agents ${agentsDir}`, modelRoles, overrides, catalog }) {
243
+ // configuration, just probably not what the operator meant. `routable` is
244
+ // the set `routableCells` returns: the router never selects an implementer
245
+ // definition outside it, so an unsupported level there is a notice; `null`
246
+ // is no table at all, and then every definition is held to the level check.
247
+ export function checkRoutes({ agentsDir, agentsSource = `--agents ${agentsDir}`, modelRoles, overrides, catalog, routable = null }) {
215
248
  const violations = [];
216
249
  const notices = [];
217
250
  const usedBy = {}; // role -> [{ file, level }, ...]
@@ -276,8 +309,13 @@ export function checkRoutes({ agentsDir, agentsSource = `--agents ${agentsDir}`,
276
309
  }
277
310
  const efforts = entry.thinking ?? [];
278
311
  for (const { file, level } of usedBy[role]) {
279
- if (!efforts.includes(level)) {
280
- violations.push(`${file}: level ${level} is not one modelRoles.${role}'s target ${model} runs at (thinking: ${efforts.join(", ") || "none"}) — omp would clamp it silently`);
312
+ if (efforts.includes(level)) continue;
313
+ const mismatch = `${file}: level ${level} is not one modelRoles.${role}'s target ${model} runs at (thinking: ${efforts.join(", ") || "none"})`;
314
+ const cell = implementerCell(file);
315
+ if (routable !== null && cell !== null && !routable.has(cell)) {
316
+ notices.push(`${mismatch} — cell ${cell} is not one the router selects; omp would clamp this level silently once it does`);
317
+ } else {
318
+ violations.push(`${mismatch} — omp would clamp it silently`);
281
319
  }
282
320
  }
283
321
  }
@@ -340,6 +378,7 @@ const { arg, numArg, has, sweep, stray } = defineFlags(die, {
340
378
  overrides: "value",
341
379
  "model-roles": "value",
342
380
  catalog: "value",
381
+ table: "value",
343
382
  "max-concurrency": "value",
344
383
  },
345
384
  });
@@ -377,7 +416,7 @@ function main() {
377
416
  stray();
378
417
 
379
418
  const check = has("check");
380
- if (!check) die("--check --in-flight <B> is required (usage: tier-roles.mjs --check --in-flight <B> [--agents <dir>] [--model-roles <path>] [--overrides <path>] [--catalog <path>] [--max-concurrency <path>])");
419
+ if (!check) die("--check --in-flight <B> is required (usage: tier-roles.mjs --check --in-flight <B> [--agents <dir>] [--model-roles <path>] [--overrides <path>] [--catalog <path>] [--table <path>] [--max-concurrency <path>])");
381
420
 
382
421
  // numArg() is the fleet's digits rule (arg.mjs): `0x5`, `1e1`, ` 5`, `5.0`
383
422
  // and `+5` are refused where `Number()` would have read a bound the caller
@@ -392,6 +431,15 @@ function main() {
392
431
  const overrides = loadJsonObject(arg("overrides"), ...config("task.agentModelOverrides"), "overrides");
393
432
  const modelRoles = loadJsonObject(arg("model-roles"), ...config("modelRoles"), "model-roles");
394
433
  const catalog = loadJsonObject(arg("catalog"), readOmpModelCatalog, "omp models --json", "catalog");
434
+ const tablePath = arg("table") ?? join(SCRIPT_DIR, "router-table.json");
435
+ let table;
436
+ try {
437
+ table = JSON.parse(readFileSync(tablePath, "utf8"));
438
+ } catch (e) {
439
+ die(`cannot read the router table ${tablePath}: ${e.message}`);
440
+ }
441
+ const routable = routableCells(table);
442
+ if (routable instanceof Error) die(`${tablePath}: ${routable.message}`);
395
443
 
396
444
  const { violations, notices } = checkRoutes({
397
445
  agentsDir,
@@ -399,8 +447,8 @@ function main() {
399
447
  modelRoles,
400
448
  overrides,
401
449
  catalog,
450
+ routable,
402
451
  });
403
-
404
452
  const notice = semaphoreNotice({ inFlight: inFlightBound, read: readMaxConcurrency(arg("max-concurrency")) });
405
453
  if (notice !== null) notices.push(notice);
406
454
 
@@ -1006,7 +1006,9 @@ Before the run's first dispatch run `~/.fleet/bin/fleet-run tier-roles.mjs
1006
1006
  --check`; exit 1 names every definition whose `model:` is not a route,
1007
1007
  every unset `modelRoles.<role>` a definition needs, every definition whose
1008
1008
  `:<level>` its role's target does not run at (omp's model catalog — omp
1009
- would clamp it silently), every
1009
+ would clamp it silently), except an implementer definition whose cell the
1010
+ router never selects (not in `router-table.json`'s `cells` or `rows` values,
1011
+ and not the policy cell), which is a notice and never stops the run; every
1010
1012
  `task.agentModelOverrides` entry that would shadow a fleet definition, and
1011
1013
  an `--agents` directory holding no `*.agent.md` definition,
1012
1014
  prints the exact remedy, and **stops the run** before any member is