@feigi/fleet-ctl 3.64.5 → 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.64.5",
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": {
@@ -22,9 +22,9 @@
22
22
  //
23
23
  // `finish` steps, in order, because the order is the point:
24
24
  //
25
- // tick `fleet-tick.mjs`, with the caps `.fleet/phase0.json` records
26
- // when it names them. Failed unless its last line is
27
- // `ACTION: run over`.
25
+ // tick `fleet-tick.mjs`, with the In-flight bound the caps
26
+ // `.fleet/phase0.json` records add up to, when it names them.
27
+ // Failed unless its last line is `ACTION: run over`.
28
28
  // scrape `member-outcomes.mjs <dir>` for every session directory
29
29
  // omp keeps for this cwd, each scraper's own yield line as the
30
30
  // output. A scraper that exits non-zero fails the step: a
@@ -47,8 +47,8 @@ import { latestFinisherAttempts, foldLedger, pastPinDue } from "./fleet-tick.mjs
47
47
  // wherever it sits (laterAttempt below): live → IMPLEMENTING, `=PR#M`
48
48
  // → that PR decides, `=released`/`=bailed` → no card of
49
49
  // the row's own (the POOL loop shows the ticket if it is still
50
- // `ready-for-agent`), `=killed`/`=tier-mismatch` → IMPLEMENTING with that
51
- // outcome as a flag. There a `PR#` mention — the `→ PR#M` arrow or any
50
+ // `ready-for-agent`), `=killed`/`=tier-mismatch`/`=blocked` → IMPLEMENTING with
51
+ // that outcome as a flag. There a `PR#` mention — the `→ PR#M` arrow or any
52
52
  // other prose — is human-readable only; parseRow reads only the settled impl
53
53
  // token's outcome, as rowPr() does for every reader. rowPr() takes the row's
54
54
  // first settled `=PR#M` impl token, this card its latest attempt: the two
@@ -273,7 +273,7 @@ export function deriveFlags(parsed, ctx) {
273
273
  if (parsed.heldBehind != null) flags.push(`held-behind:#${parsed.heldBehind}`);
274
274
  for (const c of parsed.causes) flags.push(c); // killed | blocked | sha-off-branch
275
275
  const o = parsed.implOutcome;
276
- if ((o === "killed" || o === "tier-mismatch") && !flags.includes(o)) flags.push(o);
276
+ if ((o === "killed" || o === "tier-mismatch" || o === "blocked") && !flags.includes(o)) flags.push(o);
277
277
  // Only while the halt still parks the PR: once a human resolves an
278
278
  // escalated halt by labelling or merging it, the flag has nothing to ask.
279
279
  // `past-pin`'s own automatic resolution (SKILL.md "Resolving a finisher
@@ -2,14 +2,15 @@
2
2
  // A member's report, recorded as one command: the writes its wake owes, then
3
3
  // the tick.
4
4
  //
5
- // fleet-event.mjs <kind> <args> [--implementer-cap <n>] [--reviewer-cap <n>]
5
+ // fleet-event.mjs <kind> <args> [--in-flight <n>]
6
6
  //
7
7
  // Reached through the Resolver and run from the main checkout. Every kind
8
- // performs its writes, then runs `fleet-tick.mjs --apply` with the caps —
9
- // each flag as given, else the one `.fleet/phase0.json` records, else the
10
- // tick's own default — and prints one `event: <kind>: <summary>` line with
11
- // the tick's output verbatim after it. Every kind is idempotent: a second run
12
- // finds its writes made and only ticks again.
8
+ // performs its writes, then runs `fleet-tick.mjs --apply` with the In-flight
9
+ // bound — `--in-flight` as given, else the one `.fleet/phase0.json`'s caps
10
+ // add up to, else the tick's own default — and prints one
11
+ // `event: <kind>: <summary>` line with the tick's output verbatim after it.
12
+ // Every kind is idempotent: a second run finds its writes made and only ticks
13
+ // again.
13
14
  //
14
15
  // `<scratch>` below is the phase-0 receipt's `scratch`, else the root
15
16
  // scratch-root.mjs prints; every settle reads its report under
@@ -115,8 +116,8 @@ const KINDS = {
115
116
  "review-result": { args: ["<pr>", "<path>"] },
116
117
  "review-failed": { args: ["<pr>", "<launch>"] },
117
118
  };
118
- const FLAGS = { "implementer-cap": "value", "reviewer-cap": "value" };
119
- const USAGE = `usage: ${NAME}.mjs <kind> <args> [--implementer-cap <n>] [--reviewer-cap <n>] — kinds: `
119
+ const FLAGS = { "in-flight": "value" };
120
+ const USAGE = `usage: ${NAME}.mjs <kind> <args> [--in-flight <n>] — kinds: `
120
121
  + Object.entries(KINDS).map(([k, { args }]) => `${k} ${args.join(" ")}`).join(", ");
121
122
 
122
123
  // The label each `bailCause` demotes to, and the relabel template's kind.
@@ -502,7 +503,7 @@ function reviewFailed(ev, pr, launch) {
502
503
 
503
504
  // ── main ────────────────────────────────────────────────────────────────────
504
505
 
505
- function capArg(F, name) {
506
+ function boundArg(F, name) {
506
507
  const v = F.arg(name);
507
508
  if (v === null) return null;
508
509
  if (!isDigits(v) || Number(v) < 1) die(`--${name} must be a whole number of at least 1, got '${v}'`);
@@ -530,8 +531,7 @@ function main() {
530
531
  if (!Object.hasOwn(KINDS, kind ?? "")) die(kind === undefined ? USAGE : `unknown kind '${kind}' — ${USAGE}`);
531
532
  const spec = KINDS[kind];
532
533
  if (args.length !== spec.args.length) die(`${kind} takes ${spec.args.join(" ")} — ${USAGE}`);
533
- const implCap = capArg(F, "implementer-cap");
534
- const reviewCap = capArg(F, "reviewer-cap");
534
+ const inFlight = boundArg(F, "in-flight");
535
535
  let pr = null;
536
536
  if (spec.family !== undefined) {
537
537
  const m = parseMember(args[0]);
@@ -555,15 +555,7 @@ function main() {
555
555
  }
556
556
  const caps = tickCaps(fleetDir);
557
557
  if (caps.error) die(`${caps.error} — nothing written`);
558
- const recorded = (flag) => {
559
- const i = caps.args.indexOf(flag);
560
- return i === -1 ? null : caps.args[i + 1];
561
- };
562
- const tickArgs = ["--apply"];
563
- for (const [flag, given] of [["--implementer-cap", implCap], ["--reviewer-cap", reviewCap]]) {
564
- const value = given ?? recorded(flag);
565
- if (value !== null) tickArgs.push(flag, value);
566
- }
558
+ const tickArgs = ["--apply", ...(inFlight === null ? caps.args : ["--in-flight", inFlight])];
567
559
 
568
560
  const ev = new Event({ fleetDir, scratch, ledger: readLedger() });
569
561
  if (kind === "impl-report") implReport(ev, args[0]);
@@ -30,7 +30,12 @@
30
30
  // holds (`held-behind:#M`, and `conflict-hold:#<pr>`, written by
31
31
  // the merge bot or by the controller off a `CONFLICT` line),
32
32
  // tier mismatches and the drain marker
33
- // all come off it. A missing ledger is a fresh run: zero rows.
33
+ // all come off it, and so does the ledger half of the In-flight
34
+ // count: every claimed ticket whose newest `impl-` member is live,
35
+ // or settled `killed`/`tier-mismatch` and so owed a replacement,
36
+ // with no open issue-closing PR yet. A newest member settled
37
+ // `blocked` counts nothing. A missing ledger is a fresh run: zero
38
+ // rows.
34
39
  // shortlist `.fleet/shortlist.json`, shortlist.mjs's output, resolved against
35
40
  // the git common dir as ledger.mjs resolves the ledger. Its
36
41
  // entries minus every ticket with an `impl-` row, or an `excluded`
@@ -43,13 +48,16 @@
43
48
  // downward. A file with no `dropped` names no drops.
44
49
  // gh The open PRs, by label, by whether they close an issue and by
45
50
  // GitHub's `mergeable` — the merge queue, which PRs are owed a
46
- // review, and which conflict. Also, for each ticket
47
- // holding the implementer row on a tier mismatch, whether its issue
48
- // is CLOSED (`gh issue view`): a closed ticket's mismatch
49
- // holds nothing. And, for each in-flight `review=` token whose PR
51
+ // review, which conflict, and the PR half of the In-flight count:
52
+ // every open PR that closes an issue, whoever opened it and
53
+ // whatever its state. Also, for each ticket holding the
54
+ // implementer row on a tier mismatch or owed a replacement,
55
+ // whether its issue is CLOSED (`gh issue view`): a closed
56
+ // ticket's mismatch holds nothing and its owed replacement is not
57
+ // in flight. And, for each in-flight `review=` token whose PR
50
58
  // the open list does not carry, whether that PR is MERGED or
51
59
  // CLOSED (`gh pr view`): a review cannot be running against a
52
- // finished PR, so its dangling token holds no reviewer slot.
60
+ // finished PR, so its dangling token is not a review unit.
53
61
  // main The main checkout against the run-start baseline
54
62
  // `.fleet/main-checkout.sha`, through main-checkout.mjs.
55
63
  // Anything but `clean` — dirty, unknown, no baseline — prints one
@@ -109,20 +117,17 @@
109
117
 
110
118
  import { parseMember, parseToken, premisesOf, rowNums, nextRetry, REVIEW, REVIEWED } from "./ledger-grammar.mjs";
111
119
 
112
- // Every role's TARGET is its configured cap. Availability of work belongs in
113
- // the ACTION, not the target: a reviewer target that shrank to the backlog
114
- // would print `0/0 → idle` and read as "correctly sized" for the exact drained
115
- // state that is the defect.
116
- //
117
- // The reviewer rows are computed first because the implementer row's gate
118
- // reads what they leave: the slots this tick's own dispatches fill.
120
+ // The implementer and reviewer rows' TARGET is the In-flight bound; the merge
121
+ // bot's is 1. Availability of work belongs in the ACTION, not the target: a
122
+ // reviewer target that shrank to the backlog would print `0/0 → idle` and read
123
+ // as "correctly sized" for the exact drained state that is the defect.
119
124
  export function reconcile(s) {
120
125
  const rev = reviewers(s);
121
126
  // The conflict rows only ask the controller to write a record — never to
122
127
  // dispatch — so they stand outside the dispatch hold: the fix-applier a
123
128
  // conflict hold leads to obeys the hold through its own role's row.
124
129
  return [
125
- ...dispatchHold(s, [implementers(s, rev.left), ...rev.rows]),
130
+ ...dispatchHold(s, [implementers(s), ...rev.rows]),
126
131
  ...rev.conflictRows,
127
132
  ...dispatchHold(s, [mergeBot(s)]),
128
133
  ...shortlistRows(s),
@@ -212,10 +217,10 @@ function specsDropped(dropped) {
212
217
  return `specs-dropped=${[...by].map(([reason, ns]) => `${ns.join(" ")} (${reason})`).join(", ")}`;
213
218
  }
214
219
 
215
- function implementers(s, left) {
220
+ function implementers(s) {
216
221
  const dropped = specsDropped(s.dropped);
217
- const row = mkRow("implementers", s.implLive, s.implCap,
218
- `unclaimed=${s.heads.length} supply=${s.supply ?? "?"} unreviewed=${left.unreviewed}`
222
+ const row = mkRow("implementers", s.inFlight, s.bound,
223
+ `implementers=${s.inFlightImpl} prs=${s.inFlightPrs} unclaimed=${s.heads.length} supply=${s.supply ?? "?"}`
219
224
  + (s.shortlistStatus === "ok" ? "" : ` shortlist=${s.shortlistStatus}`)
220
225
  + (dropped ? ` ${dropped}` : ""));
221
226
 
@@ -239,20 +244,22 @@ function implementers(s, left) {
239
244
  return row(`HOLD (tier unchecked ${s.tierUnchecked.join(" ")})`, { acts: true, extra: tierCheckStep(s.tierUnchecked, s.phase0?.session) });
240
245
  }
241
246
 
242
- const deficit = s.implCap - s.implLive;
243
- if (deficit <= 0) return row("AT CAP");
244
-
245
- // The review-backlog gate, NARROWED: more PRs into a review-bound
246
- // pipeline buy nothing — but the pipeline is review-bound only when a PR is
247
- // still owed its review after this tick's dispatches AND no reviewer slot is
248
- // left for it. A deep backlog with free slots is a reviewer-row DISPATCH on
249
- // this same tick, not a reason to idle an implementer; the old
250
- // `backlog >= 2` gate held there and starved implementers.
251
- // The merge queue never gates this row: a deep ready-to-merge queue adds no
252
- // rebases per PR.
253
- if (left.unreviewed >= 1 && left.free <= 0) return row("HOLD (review side saturated)");
247
+ // The In-flight bound: n tickets between their Claim and their PR's merge,
248
+ // at or over B, hold every Pull until a merge brings n below B. Quiet — a
249
+ // merge is what clears it, and the controller has nothing to do meanwhile —
250
+ // except for a ticket whose implementer was killed: it counts with no PR
251
+ // that could merge, so the dispatch of its replacement is what clears it,
252
+ // and the row asks the controller for it.
253
+ // A replacement implementer is never a Pull, so no branch here reads it.
254
+ // The merge queue and the review backlog never gate this row: a deep
255
+ // ready-to-merge queue adds no rebases per PR, and a review owed is the
256
+ // reviewer row's DISPATCH on this same tick.
257
+ if (s.inFlight >= s.bound) {
258
+ const hold = `HOLD (in-flight ${s.inFlight}/${s.bound})`;
259
+ return s.owedCounted.length ? row(hold, { acts: true, extra: replaceStep(s.owedCounted, s.implNames) }) : row(hold);
260
+ }
254
261
 
255
- if (s.heads.length) return row(`PULL ${s.heads.slice(0, deficit).map((n) => `#${n}`).join(" ")}`, { acts: true });
262
+ if (s.heads.length) return row(`PULL ${s.heads.slice(0, s.bound - s.inFlight).map((n) => `#${n}`).join(" ")}`, { acts: true });
256
263
 
257
264
  // Nothing unclaimed even after a refresh. `SUGGEST /triage` asks a
258
265
  // MAINTAINER to tick tickets, and on the unattended night the heartbeat
@@ -261,21 +268,18 @@ function implementers(s, left) {
261
268
  return row("SUGGEST /triage, hold idle");
262
269
  }
263
270
 
264
- // Reviewer units: an in-flight review = 1, each fix-applier = 1.
271
+ // Reviewer units: an in-flight review = 1, each fix-applier = 1. Every due
272
+ // unit is dispatched, no cap: a PR holds at most one live review unit, so
273
+ // units stay within the open PRs. The In-flight bound gates Pulls, not these,
274
+ // so a run that inherited more than B PRs dispatches a unit for each.
265
275
  // Named in priority order — fix-appliers first, then reviews, oldest first —
266
- // because finishing what is started beats starting more. Reviews are also
267
- // bounded by `--max-reviews`, left at its default (the reviewer cap) since
268
- // every review unit already counts against the session's own concurrency
269
- // semaphore; the other slots still serve fix-appliers.
276
+ // because finishing what is started beats starting more.
270
277
  function reviewers(s) {
271
278
  const detail = `reviews=${s.reviewsLive} fix-pr=${s.fixLive} fix-due=${s.fixDue.length}`
272
- + ` review-due=${s.reviewDue.length} max-reviews=${s.maxReviews}`;
273
- const row = mkRow("reviewers", s.reviewsLive + s.fixLive, s.reviewerCap, detail);
274
- let free = Math.max(0, s.reviewerCap - s.reviewsLive - s.fixLive);
275
- const fixes = s.fixDue.slice(0, free);
276
- free -= fixes.length;
277
- const reviews = s.reviewDue.slice(0, Math.min(free, Math.max(0, s.maxReviews - s.reviewsLive)));
278
- free -= reviews.length;
279
+ + ` review-due=${s.reviewDue.length}`;
280
+ const row = mkRow("reviewers", s.reviewsLive + s.fixLive, s.bound, detail);
281
+ const fixes = s.fixDue;
282
+ const reviews = s.reviewDue;
279
283
  const prs = (ns) => ns.map((n) => `PR#${n}`).join(" ");
280
284
 
281
285
  const rows = [];
@@ -284,7 +288,7 @@ function reviewers(s) {
284
288
  // A finisher settled `labelled` on a PR the open list shows without
285
289
  // `ready-to-merge`. One such attempt since the controller's last deliberate
286
290
  // removal gets one fresh finisher; a second one escalates, never a third
287
- // dispatch. Finishers take no reviewer slot, so neither waits on the cap.
291
+ // dispatch. Finishers are not review units, so neither waits on one.
288
292
  const names = (us) => us.flatMap((u) => u.labelled).join(", ");
289
293
  const repair = s.unlabelled.filter((u) => u.labelled.length === 1);
290
294
  const stuck = s.unlabelled.filter((u) => u.labelled.length > 1);
@@ -301,7 +305,7 @@ function reviewers(s) {
301
305
  // record and nobody working it: the controller writes the hold the merge
302
306
  // bot would, and the tick turns it into `DISPATCH fix-pr` from then on.
303
307
  // Past two landed conflict fix-appliers it is a treadmill, handed to a human
304
- // instead — no hold, no fix-applier. Neither row takes a reviewer slot, and
308
+ // instead — no hold, no fix-applier. Neither row is a review unit, and
305
309
  // neither stands aside for IDLE OK: that row is the one a hold replaces. They
306
310
  // are returned beside `rows`, not among them, so a main-checkout hold never
307
311
  // turns a record-only line into a HOLD.
@@ -315,14 +319,9 @@ function reviewers(s) {
315
319
  conflictRows.push(row(`ESCALATE conflict ${prs(s.conflictEscalate)}`,
316
320
  { extra: "GitHub reads CONFLICTING again after two conflict fix-appliers landed; comment on the PR and flag it for a human — no hold, no fix-applier" }));
317
321
  }
318
- if (!rows.length) {
319
- const owed = s.fixDue.length + s.reviewDue.length;
320
- if (owed && free <= 0) rows.push(row("AT CAP"));
321
- else if (s.reviewDue.length) rows.push(row(`HOLD (max-reviews ${s.maxReviews} in flight)`));
322
- else if (!unlabelledRows.length) rows.push(row("IDLE OK"));
323
- }
322
+ if (!rows.length && !unlabelledRows.length) rows.push(row("IDLE OK"));
324
323
  rows.push(...unlabelledRows);
325
- return { rows, conflictRows, left: { unreviewed: s.reviewDue.length - reviews.length, free } };
324
+ return { rows, conflictRows };
326
325
  }
327
326
 
328
327
  function mergeBot(s) {
@@ -343,7 +342,8 @@ function mergeBot(s) {
343
342
 
344
343
  // The refresh this tick ran, if it ran one. A REFRESHED that changed the list
345
344
  // is actionable — supply arrived. One that changed nothing is not: every idle
346
- // heartbeat tick refreshes while the shortlist is short of the cap, and an
345
+ // heartbeat tick refreshes while the shortlist is short of the In-flight
346
+ // bound and nothing holds the row, and an
347
347
  // unconditionally actionable REFRESHED would pin the beat at its base interval
348
348
  // on exactly the quiet night the heartbeat backs off on. A failed refresh IS
349
349
  // actionable: a blind implementer row backing off tick after identical tick is
@@ -865,6 +865,22 @@ export function deriveRun({ rows, dispatched, drain, retired = [] }, prs, closed
865
865
  const tierMismatch = newest.filter((m) => mismatched(m) && !closed.has(m.number)).map((m) => m.name);
866
866
  const cleared = (m) => verdicts.ok.has(m.name) || verdicts.unverifiable.has(m.name);
867
867
  const tierUnchecked = newest.filter((m) => !mismatched(m) && !cleared(m)).map((m) => m.name);
868
+ // The In-flight count: tickets between a Claim and their PR's merge. Read off
869
+ // the ledger and `prs` on every tick, never the Phase-0 fold. One term per
870
+ // open PR that closes an issue (GitHub's linked set; a PR closing nothing is
871
+ // never in flight, however it was made), plus one per claimed ticket whose
872
+ // newest impl member is live, or owes a replacement — settled `killed` or
873
+ // `tier-mismatch` on an issue not probed CLOSED — and that no open PR closes
874
+ // yet. A PR absorbs its ticket, so the hand-off from implementer to PR counts
875
+ // once; a ticket counts once however many members it has had. A member
876
+ // settled `blocked`, `bailed`, `released` or `PR#M` counts nothing on its
877
+ // own account, and neither does an Exclusion row, which is no member.
878
+ const prsIn = prs.filter((p) => p.closingIssuesReferences.length > 0);
879
+ const closing = new Set(prsIn.flatMap((p) => p.closingIssuesReferences.map((r) => r.number)));
880
+ const owesReplacement = (m) => (m.outcome === "killed" || m.outcome === "tier-mismatch") && !closing.has(m.number);
881
+ const owedReplacement = newest.filter(owesReplacement).map((m) => m.name);
882
+ const owedCounted = newest.filter((m) => owesReplacement(m) && !closed.has(m.number)).map((m) => m.name);
883
+ const inFlightImpl = newest.filter((m) => m.outcome === null && !closing.has(m.number)).length + owedCounted.length;
868
884
  const isQueued = (p) => p.labels.some((l) => l && l.name === "ready-to-merge");
869
885
  const queued = prs.filter(isQueued);
870
886
  const asc = (a, b) => a - b;
@@ -900,7 +916,7 @@ export function deriveRun({ rows, dispatched, drain, retired = [] }, prs, closed
900
916
  };
901
917
  // A `review=` token with no `reviewed=` after it reads as in flight, and the
902
918
  // ledger alone never says otherwise: a review whose own `reviewed=` write
903
- // never landed stays in flight after its PR merges, holding a reviewer slot
919
+ // never landed stays in flight after its PR merges, counting as a review unit
904
920
  // for good. `finished` is the PR numbers the caller has found MERGED or
905
921
  // CLOSED, and a finished PR has no review running against it. A PR on the
906
922
  // open list is open whatever `finished` says, and none is the default, so a
@@ -910,6 +926,11 @@ export function deriveRun({ rows, dispatched, drain, retired = [] }, prs, closed
910
926
  const unsettled = all.filter((m) => m.outcome === null).map((m) => m.name);
911
927
  return {
912
928
  implLive: live("impl"),
929
+ inFlight: inFlightImpl + prsIn.length,
930
+ inFlightImpl,
931
+ inFlightPrs: prsIn.length,
932
+ owedReplacement,
933
+ owedCounted,
913
934
  fixLive: live("fix-pr"),
914
935
  mergeBotLive,
915
936
  // The number of every merge bot settled `done`: each is a merge pass
@@ -1044,11 +1065,14 @@ export function parseShortlist(text) {
1044
1065
 
1045
1066
  // Why this tick refreshes the shortlist, or null. The premise-lifted
1046
1067
  // trigger costs gh calls, so main() asks it only when these answer null.
1047
- export function refreshWhy({ draining, status, entries, unclaimed: k, implCap }) {
1048
- if (draining !== null) return null;
1068
+ // Nothing refreshes while the bound holds (`held`, n ≥ B, whichever HOLD row
1069
+ // prints): a refresh then cannot feed a Pull, and the first tick back under
1070
+ // the bound refreshes and Pulls in the same tick, so nothing is lost.
1071
+ export function refreshWhy({ draining, held, status, entries, unclaimed: k, bound }) {
1072
+ if (draining !== null || held) return null;
1049
1073
  if (status !== "ok") return `shortlist ${status}`;
1050
1074
  if (entries === 0) return "shortlist empty";
1051
- if (k < implCap) return `unclaimed ${k} < cap ${implCap}`;
1075
+ if (k < bound) return `unclaimed ${k} < in-flight bound ${bound}`;
1052
1076
  return null;
1053
1077
  }
1054
1078
 
@@ -1309,14 +1333,10 @@ const die = makeDie(NAME);
1309
1333
  // Every input the controller used to state is read off the run now, so what
1310
1334
  // is left is configuration, and all of it defaults.
1311
1335
  const OPTIONS = {
1312
- // Defaults here, not threaded through int(): declared this way they still
1313
- // go through the guard below, where a hand-passed default went round it.
1314
- // No hard cap on either role, defaults only.
1315
- "implementer-cap": { type: "string", default: "2" },
1316
- "reviewer-cap": { type: "string", default: "6" },
1317
- // Reviews in flight at once. Default = the reviewer cap; run-team's own
1318
- // guidance is to leave it there rather than pass a tighter bound.
1319
- "max-reviews": { type: "string" },
1336
+ // The In-flight bound: the most tickets between Claim and merge at once. The
1337
+ // default lives here and nowhere else in code, declared this way so it still
1338
+ // goes through the guard below, where a hand-passed default went round it.
1339
+ "in-flight": { type: "string", default: "5" },
1320
1340
  // `--fold-unchanged` prints ONE line instead of the rows when this tick asks
1321
1341
  // for nothing and says exactly what the last one said — what makes an
1322
1342
  // unattended night affordable. Opt-in because folding is wrong on an edge:
@@ -1361,7 +1381,7 @@ function options() {
1361
1381
  const int = (name) => {
1362
1382
  const raw = values[name];
1363
1383
  // The digits rule, called rather than restated. Digits, not
1364
- // Number(): `Number("")` is 0, so `--max-reviews ""` — the shape an unset
1384
+ // Number(): `Number("")` is 0, so `--in-flight ""` — the shape an unset
1365
1385
  // shell variable produces — would otherwise read as a real number.
1366
1386
  if (!isDigits(String(raw).trim())) die(`--${name} must be a non-negative integer, got '${raw}'`);
1367
1387
  return Number(raw);
@@ -1371,10 +1391,8 @@ function options() {
1371
1391
  if (n < 1) die(`--${name} must be at least 1, got ${n}`);
1372
1392
  return n;
1373
1393
  };
1374
- const reviewerCap = positive("reviewer-cap");
1375
1394
  return {
1376
- implCap: positive("implementer-cap"), reviewerCap,
1377
- maxReviews: values["max-reviews"] === undefined ? reviewerCap : positive("max-reviews"),
1395
+ bound: positive("in-flight"),
1378
1396
  fold: values["fold-unchanged"], apply: values.apply, state: values.state || statePath(NAME), scratch: values.scratch,
1379
1397
  session: values.session || null, noTranscriptAfter: positive("no-transcript-after"),
1380
1398
  liveness: Object.fromEntries(Object.entries(LIVENESS_FLAGS).map(([family, flag]) => [family, positive(flag)])),
@@ -1402,14 +1420,18 @@ function openPrs() {
1402
1420
  die(`could not parse gh pr list output as JSON: ${e.message}`);
1403
1421
  }
1404
1422
  // closingIssuesReferences is checked, not defaulted: absent, it would read as
1405
- // an empty list and drop every open PR from review work. headRefOid likewise
1423
+ // an empty list and drop every open PR from review work — and from the
1424
+ // In-flight count. Each reference must carry an integer `number`: the count
1425
+ // matches a PR to the ticket it closes by it, and a reference without one
1426
+ // would leave that ticket's implementer counted twice. headRefOid likewise
1406
1427
  // — absent, a `halted:past-pin` PR would read as moved forever — and
1407
1428
  // mergeable: absent or outside GitHub's MergeableState enum, no PR would ever
1408
1429
  // read CONFLICTING.
1409
1430
  if (!Array.isArray(prs) || prs.some((p) => !p || typeof p.number !== "number"
1410
1431
  || !Array.isArray(p.labels) || !Array.isArray(p.closingIssuesReferences)
1432
+ || !p.closingIssuesReferences.every((r) => r && Number.isInteger(r.number))
1411
1433
  || typeof p.headRefOid !== "string" || !MERGEABLE_STATES.includes(p.mergeable))) {
1412
- die("gh pr list did not return {number,labels,closingIssuesReferences,headRefOid,mergeable} rows, mergeable one of MERGEABLE, CONFLICTING, UNKNOWN");
1434
+ die("gh pr list did not return {number,labels,closingIssuesReferences[{number}],headRefOid,mergeable} rows, mergeable one of MERGEABLE, CONFLICTING, UNKNOWN");
1413
1435
  }
1414
1436
  if (prs.length === PR_LIMIT) {
1415
1437
  die(`exactly ${PR_LIMIT} open PRs — the list is capped and may be truncated. Raise PR_LIMIT; a backlog that silently drops PRs is not a reconcile.`);
@@ -1539,18 +1561,25 @@ function liftedPremise(excluded, entries, prs) {
1539
1561
  return null;
1540
1562
  }
1541
1563
 
1542
- // The tickets, of those holding the implementer row on a tier mismatch, whose
1543
- // issue is CLOSED: the one live read deriveRun needs to lift a hold
1544
- // whose replacement has nothing left to replace. One `gh issue view` per
1545
- // mismatched ticket, and none when nothing is mismatched. A probe that cannot
1546
- // answer — a nonzero exit, or a reply carrying no issue state — is disclosed
1547
- // and the hold stands.
1548
- function closedTickets(mismatched) {
1564
+ // The tickets whose issue is CLOSED, of those the tick would otherwise keep
1565
+ // counting or holding on: every ticket holding the implementer row on a tier
1566
+ // mismatch, and every ticket owed a replacement. One live read deriveRun needs
1567
+ // to lift a hold, and uncount a ticket, whose replacement has nothing left to
1568
+ // replace. One `gh issue view` per ticket, deduped (a tier-mismatch outcome is
1569
+ // both), and none when nothing is owed. A probe that cannot answer — a nonzero
1570
+ // exit, or a reply carrying no issue state — is disclosed, and the ticket
1571
+ // stays counted and its hold stands: an unreadable state never uncounts.
1572
+ function closedTickets(mismatched, owed) {
1549
1573
  const closed = new Set();
1550
- for (const { number } of mismatched.map(parseMember)) {
1574
+ const mismatchedNumbers = new Set(mismatched.map((name) => parseMember(name).number));
1575
+ const numbers = new Set([...mismatchedNumbers, ...owed.map((name) => parseMember(name).number)]);
1576
+ for (const number of numbers) {
1577
+ const unconfirmed = mismatchedNumbers.has(number)
1578
+ ? `tier mismatch on #${number} unconfirmed closed, hold stands`
1579
+ : `replacement owed on #${number} unconfirmed closed, ticket stays counted`;
1551
1580
  const r = spawnSync("gh", ["issue", "view", String(number), "--json", "state"], { encoding: "utf8", timeout: GH_TIMEOUT_MS, env: gitEnv({ GH_REPO: "" }) });
1552
1581
  if (r.error || r.status !== 0) {
1553
- console.error(`${NAME}: ${failure(r, `gh issue view ${number}`)} — tier mismatch on #${number} unconfirmed closed, hold stands`);
1582
+ console.error(`${NAME}: ${failure(r, `gh issue view ${number}`)} — ${unconfirmed}`);
1554
1583
  continue;
1555
1584
  }
1556
1585
  let st = null;
@@ -1559,7 +1588,7 @@ function closedTickets(mismatched) {
1559
1588
  else if (typeof st !== "string") {
1560
1589
  // Exit 0 with a body that is not an issue (an HTML error page, a proxy's
1561
1590
  // text, JSON with no state) is as unanswered as a nonzero exit.
1562
- console.error(`${NAME}: gh issue view ${number} printed no state — tier mismatch on #${number} unconfirmed closed, hold stands`);
1591
+ console.error(`${NAME}: gh issue view ${number} printed no state — ${unconfirmed}`);
1563
1592
  }
1564
1593
  }
1565
1594
  return closed;
@@ -1568,23 +1597,23 @@ function closedTickets(mismatched) {
1568
1597
  // The PRs, of those whose review the ledger reads as in flight yet the open
1569
1598
  // list does not carry, that gh says are MERGED or CLOSED. A review cannot be
1570
1599
  // running against a finished PR, so the ledger's dangling `review=` token must
1571
- // not hold a reviewer slot for good. A probe that cannot answer — a nonzero
1600
+ // not count as a review unit for good. A probe that cannot answer — a nonzero
1572
1601
  // exit, a reply carrying no state, a state that is none of the three — is
1573
- // disclosed and the review keeps its slot: an unreadable state is never read
1602
+ // disclosed and the review keeps its unit: an unreadable state is never read
1574
1603
  // as finished. A PR gh calls OPEN keeps it quietly.
1575
1604
  function finishedReviewPrs(offList) {
1576
1605
  const finished = new Set();
1577
1606
  for (const number of offList) {
1578
1607
  const r = spawnSync("gh", ["pr", "view", String(number), "--json", "state"], { encoding: "utf8", timeout: GH_TIMEOUT_MS, env: gitEnv({ GH_REPO: "" }) });
1579
1608
  if (r.error || r.status !== 0) {
1580
- console.error(`${NAME}: ${failure(r, `gh pr view ${number}`)} — review on PR#${number} unconfirmed finished, its slot stands`);
1609
+ console.error(`${NAME}: ${failure(r, `gh pr view ${number}`)} — review on PR#${number} unconfirmed finished, its unit stands`);
1581
1610
  continue;
1582
1611
  }
1583
1612
  let st = null;
1584
1613
  try { st = JSON.parse(r.stdout).state; } catch { /* no state: disclosed below */ }
1585
1614
  if (st === "MERGED" || st === "CLOSED") finished.add(number);
1586
1615
  else if (st !== "OPEN") {
1587
- console.error(`${NAME}: gh pr view ${number} printed no PR state — review on PR#${number} unconfirmed finished, its slot stands`);
1616
+ console.error(`${NAME}: gh pr view ${number} printed no PR state — review on PR#${number} unconfirmed finished, its unit stands`);
1588
1617
  }
1589
1618
  }
1590
1619
  return finished;
@@ -1736,7 +1765,7 @@ function readRun(prs) {
1736
1765
  try {
1737
1766
  const ledger = readLedger();
1738
1767
  const run = deriveRun(ledger, prs);
1739
- const closed = closedTickets(run.tierMismatch);
1768
+ const closed = closedTickets(run.tierMismatch, run.owedReplacement);
1740
1769
  const finished = finishedReviewPrs(run.reviewsOffList);
1741
1770
  return closed.size || finished.size ? deriveRun(ledger, prs, closed, finished) : run;
1742
1771
  } catch (e) {
@@ -1898,9 +1927,13 @@ function main() {
1898
1927
  let supply = current.scanned;
1899
1928
  let dropped = current.dropped;
1900
1929
  let fresh = null;
1901
- const trigger = refreshWhy({ draining: run.draining, status: current.status, entries: current.entries.length,
1902
- unclaimed: heads.length, implCap: caps.implCap })
1903
- ?? (run.draining === null ? liftedPremise(run.excluded, current.entries, prs) : null);
1930
+ // While the bound holds a refresh cannot feed a Pull, so none of its
1931
+ // triggers runs: the first tick back under the bound refreshes and Pulls in
1932
+ // the same tick.
1933
+ const held = run.inFlight >= caps.bound;
1934
+ const trigger = refreshWhy({ draining: run.draining, held, status: current.status, entries: current.entries.length,
1935
+ unclaimed: heads.length, bound: caps.bound })
1936
+ ?? (run.draining === null && !held ? liftedPremise(run.excluded, current.entries, prs) : null);
1904
1937
  if (trigger) {
1905
1938
  const r = refresh();
1906
1939
  if (r.ok) {
@@ -49,7 +49,7 @@ export const briefsArchiveName = (stamp) => `${BRIEFS}.${stamp}`;
49
49
  // `role` is the dispatch-prompt.mjs template a member of the family is
50
50
  // rendered from, the one its brief's sidecar must name.
51
51
  const FAMILIES = {
52
- impl: { label: "impl-N", bound: "ticket", role: "implementer", outcomes: ["PR#M", "bailed", "released", "killed", "tier-mismatch"] },
52
+ impl: { label: "impl-N", bound: "ticket", role: "implementer", outcomes: ["PR#M", "bailed", "released", "killed", "tier-mismatch", "blocked"] },
53
53
  "fix-pr": { label: "fix-pr-M", bound: "pr", role: "fix-applier", outcomes: ["applied:<head>", "no-op", "failed", "killed"] },
54
54
  "finisher-pr": { label: "finisher-pr-M", bound: "pr", role: "finisher", outcomes: ["labelled", "failed", "killed", "halted:<cause>"] },
55
55
  "merge-bot": { label: "merge-bot-n", bound: null, role: "merge-bot", outcomes: ["done", "killed"] },
@@ -1,9 +1,9 @@
1
1
  // The phase-0 receipt, read. `.fleet/phase0.json` is written by phase0.mjs
2
2
  // after every step (its header gives the shape); this module is its readers'
3
3
  // half: the tick's dispatch gate, the session directory tier-check.mjs
4
- // and ticket-router.mjs take when their own flag is omitted, and the caps the
5
- // drivers hand the tick. One reading of the file, so the gate and the session
6
- // readers cannot disagree about what a receipt is.
4
+ // and ticket-router.mjs take when their own flag is omitted, and the In-flight
5
+ // bound the drivers hand the tick. One reading of the file, so the gate and
6
+ // the session readers cannot disagree about what a receipt is.
7
7
  //
8
8
  // Zero deps: node builtins and sibling modules only.
9
9
 
@@ -145,10 +145,18 @@ export function sessionFromReceipt(opts) {
145
145
  throw new Error(`no session given and none in the phase-0 receipt ${path} (${why}) — give one, or run ${phase0Command(null)} first`);
146
146
  }
147
147
 
148
+ // What the tick's two retired cap flags defaulted to, which is what a cap the
149
+ // receipt leaves unset counts as in the bound its caps add up to.
150
+ const RETIRED_IMPL_CAP = 2;
151
+ const RETIRED_REVIEW_CAP = 6;
152
+
148
153
  /**
149
- * The caps the receipt in `fleetDir` records, as the tick's own flags:
150
- * `{ args }`, none when there is no receipt or it names none, or `{ error }`
151
- * for a receipt that is there and cannot be read.
154
+ * The bound the receipt in `fleetDir` records, as the tick's own flag:
155
+ * `{ args }`, none when there is no receipt or it names no cap, or `{ error }`
156
+ * for a receipt that is there and cannot be read. The tick takes one
157
+ * In-flight bound, `--in-flight <B>`; a receipt that recorded the two caps
158
+ * phase 0 was given maps to their sum, an unset one at what its flag
159
+ * defaulted to.
152
160
  */
153
161
  export function tickCaps(fleetDir) {
154
162
  let phase0;
@@ -158,8 +166,7 @@ export function tickCaps(fleetDir) {
158
166
  if (e.code === "ENOENT") return { args: [] };
159
167
  return { error: `cannot read ${join(fleetDir, RECEIPT)}: ${e.message}` };
160
168
  }
161
- const args = [];
162
- if (phase0?.caps?.impl != null) args.push("--implementer-cap", String(phase0.caps.impl));
163
- if (phase0?.caps?.review != null) args.push("--reviewer-cap", String(phase0.caps.review));
164
- return { args };
169
+ const { impl, review } = phase0?.caps ?? {};
170
+ if (impl == null && review == null) return { args: [] };
171
+ return { args: ["--in-flight", String((impl ?? RETIRED_IMPL_CAP) + (review ?? RETIRED_REVIEW_CAP))] };
165
172
  }
@@ -74,8 +74,8 @@
74
74
  // `<member>.jsonl`, the trace of a dispatch that failed before a transcript
75
75
  // was written. That token clears the tick's unchecked hold without claiming
76
76
  // the tier was right. Every other case with no transcript is still exit 2: a
77
- // LIVE member may yet write one; a member settled `PR#M`, `bailed` or
78
- // `tier-mismatch` ran, so its transcript exists and the `session` is the
77
+ // LIVE member may yet write one; a member settled `PR#M`, `bailed`, `blocked`
78
+ // or `tier-mismatch` ran, so its transcript exists and the `session` is the
79
79
  // wrong directory; a `session` that is empty, missing or not a directory,
80
80
  // or omitted with none in the phase-0 receipt, is exit 2 whether the member
81
81
  // is live or settled; and a session
@@ -320,9 +320,10 @@ function sessionLacksTranscript(repoRoot, sessionPath, member) {
320
320
  // The settle outcomes a dispatch that failed before writing a transcript can
321
321
  // carry: `killed` (the Member-killed row — spend limit, API error, crash) and
322
322
  // `released` (a drain releases every claim that never became a PR). `PR#M`,
323
- // `bailed` and `tier-mismatch` each prove the member ran — it opened a PR,
324
- // reported its own bail, or had its transcript read by this check — so for
325
- // them a missing `<member>.jsonl` means the `session` is the wrong directory,
323
+ // `bailed`, `blocked` and `tier-mismatch` each prove the member ran — it
324
+ // opened a PR, reported its own bail or block, or had its transcript read by
325
+ // this check — so for them a missing `<member>.jsonl` means the `session` is
326
+ // the wrong directory,
326
327
  // and recording `tier-unverifiable` would clear the hold on a member whose
327
328
  // tier can still be judged.
328
329
  const NO_TRANSCRIPT_OUTCOMES = new Set(["killed", "released"]);
@@ -372,7 +373,7 @@ function recordImplementer(ledgerFile, r) {
372
373
  if (outcome === undefined) {
373
374
  die(`${r.member}: not on the ledger — \`ledger.mjs dispatch\` records a member before its tier can be settled`);
374
375
  }
375
- // A member already settled some other way (`bailed`, `killed`,
376
+ // A member already settled some other way (`bailed`, `blocked`, `killed`,
376
377
  // `released`, `PR#M`) cannot be re-settled — `settle` refuses — so the
377
378
  // mismatch rides as a row token instead, ahead of the note so the note
378
379
  // stays the row's trailing segment.
@@ -243,7 +243,7 @@ export function tierFromLedger(ledger, ticket, pr) {
243
243
  if (verdicts.length === 0) return null;
244
244
 
245
245
  const owners = new Set(tokens.filter((t) => t.outcome === `PR#${pr}`).map((t) => t.name));
246
- // A member settled to anything else terminal (released, bailed, killed) is
246
+ // A member settled to anything else terminal (released, bailed, blocked, killed) is
247
247
  // positive evidence it did NOT open this PR, so its stale tier-ok verdict
248
248
  // never wins the no-owner fallback below — but `tier-mismatch` itself is
249
249
  // exempt: that outcome IS the mismatch verdict this function reports, not
@@ -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