@feigi/fleet-ctl 3.50.0 → 3.50.2

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.50.0",
3
+ "version": "3.50.2",
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": {
@@ -34,7 +34,13 @@
34
34
  // with none, (a), (b) and (d) have nothing to check; an agents
35
35
  // directory that cannot be read (missing, not a directory) or a
36
36
  // definition that cannot be read (a directory named `*.agent.md`)
37
- // fails too.
37
+ // fails too;
38
+ // (g) `--in-flight <B>`, required under `--check`: omp's
39
+ // `task.maxConcurrency` below 2·B+2, or one that cannot be read, is a
40
+ // notice (`0` is unbounded and prints none). The value is read live
41
+ // with `omp config get`, or from the file `--max-concurrency <path>`
42
+ // names, which takes its place when given. A notice never changes the
43
+ // exit code.
38
44
 
39
45
  import { readFileSync, readdirSync } from "node:fs";
40
46
  import { execFileSync } from "node:child_process";
@@ -304,21 +310,53 @@ export function checkRoutes({ agentsDir, agentsSource = `--agents ${agentsDir}`,
304
310
  return { violations, notices };
305
311
  }
306
312
 
313
+ // The phase-0 semaphore notice: omp's `task.maxConcurrency` against the
314
+ // In-flight bound. `read` is `{ ok: true, value }` or `{ ok: false, why }`.
315
+ // Returns the notice line, or null for `0` (unbounded) and `>= 2·B+2`. A
316
+ // notice never changes the exit code, so a value that cannot be read is a
317
+ // line too, not a refusal.
318
+ export function semaphoreNotice({ inFlight, read }) {
319
+ const unreadable = (why) => `task.maxConcurrency unreadable — ${why}; In-flight bound ${inFlight} is unchecked against it`;
320
+ // `why` can be omp's raw stderr, which ends in a newline and may span
321
+ // lines; a notice is one line.
322
+ if (!read.ok) return unreadable(read.why.replace(/\s+/g, " ").trim());
323
+ const c = read.value;
324
+ if (!Number.isInteger(c) || c < 0) return unreadable(`not a non-negative integer (got ${c === undefined ? "no value" : JSON.stringify(c)})`);
325
+ const threshold = 2 * inFlight + 2;
326
+ if (c === 0 || c >= threshold) return null;
327
+ return `task.maxConcurrency is ${c}, below 2·${inFlight}+2 = ${threshold} for In-flight bound ${inFlight} — omp queues members past it, so a Pulled implementer may sit unstarted; raise it in omp config (the fleet never writes it)`;
328
+ }
329
+
307
330
  // ---------------------------------------------------------------------------
308
331
  // CLI
309
332
  // ---------------------------------------------------------------------------
310
333
 
311
334
  const die = makeDie(NAME);
312
- const { arg, has, sweep, stray } = defineFlags(die, {
335
+ const { arg, numArg, has, sweep, stray } = defineFlags(die, {
313
336
  flags: {
314
337
  check: "bool",
338
+ "in-flight": "value",
315
339
  agents: "value",
316
340
  overrides: "value",
317
341
  "model-roles": "value",
318
342
  catalog: "value",
343
+ "max-concurrency": "value",
319
344
  },
320
345
  });
321
346
 
347
+ // The `task.maxConcurrency` read `semaphoreNotice` formats: the
348
+ // `--max-concurrency <path>` fixture (a file holding the bare JSON value)
349
+ // when given, else the live `omp config get` read. A read that throws is a
350
+ // result, not a refusal — the notice says it was unreadable and the exit
351
+ // code is the role check's either way.
352
+ function readMaxConcurrency(path) {
353
+ try {
354
+ return { ok: true, value: path === null ? readOmpConfigValue("task.maxConcurrency") : JSON.parse(readFileSync(path, "utf8")) };
355
+ } catch (e) {
356
+ return { ok: false, why: e.message };
357
+ }
358
+ }
359
+
322
360
  // `--<flagName> <path>` when given, else the live install read `readLive()`
323
361
  // performs (`source` names it in a refusal).
324
362
  function loadJsonObject(path, readLive, source, flagName) {
@@ -339,7 +377,14 @@ function main() {
339
377
  stray();
340
378
 
341
379
  const check = has("check");
342
- if (!check) die("--check is required (usage: tier-roles.mjs --check [--agents <dir>] [--model-roles <path>] [--overrides <path>] [--catalog <path>])");
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>])");
381
+
382
+ // numArg() is the fleet's digits rule (arg.mjs): `0x5`, `1e1`, ` 5`, `5.0`
383
+ // and `+5` are refused where `Number()` would have read a bound the caller
384
+ // never wrote.
385
+ const inFlightBound = numArg("in-flight");
386
+ if (inFlightBound === null) die("--in-flight is required with --check");
387
+ if (inFlightBound < 1) die(`--in-flight must be at least 1, got ${inFlightBound}`);
343
388
 
344
389
  const agentsFlag = arg("agents");
345
390
  const agentsDir = agentsFlag ?? join(SCRIPT_DIR, "..", "agents");
@@ -356,6 +401,9 @@ function main() {
356
401
  catalog,
357
402
  });
358
403
 
404
+ const notice = semaphoreNotice({ inFlight: inFlightBound, read: readMaxConcurrency(arg("max-concurrency")) });
405
+ if (notice !== null) notices.push(notice);
406
+
359
407
  if (violations.length === 0) {
360
408
  console.log("tier-roles: every definition routes to a resolvable model at a level it runs, no shadowing override");
361
409
  for (const n of notices) console.log(`tier-roles: notice: ${n}`);
@@ -2183,27 +2183,18 @@ while :; do # one tick
2183
2183
  echo "WATCHER DEGRADED: core REST budget=$rl — CI polling paused, silence is NOT green"
2184
2184
  budget_out=1
2185
2185
  fi
2186
- else # budget RECOVERED waits for the per-pass gate below
2186
+ else # every RECOVERED waits for the pass gates below
2187
2187
  prs=$(gh pr list --state open --limit "$pr_cap" --json number --jq '.[].number' 2>/dev/null) || prs=ERR
2188
2188
  if [ "$prs" = ERR ]; then
2189
2189
  if [ -z "$list_out" ]; then # global latch: this cause is account-level too
2190
2190
  echo "WATCHER DEGRADED: cannot list open PRs — CI polling paused, silence is NOT green"
2191
2191
  list_out=1
2192
2192
  fi
2193
- else
2194
- if [ -n "$list_out" ]; then
2195
- echo "WATCHER RECOVERED: open-PR list readable again — CI polling resumed"
2196
- list_out=
2197
- fi
2193
+ else # a list or cap RECOVERED waits for the pass gates too
2198
2194
  count=$(printf '%s\n' "$prs" | grep -c .) || : # grep -c exits 1 on zero matches; set -e must not take it
2199
- if [ "$count" -ge "$pr_cap" ]; then
2200
- if [ -z "$cap_out" ]; then # global latch: a full page may have been cut there
2201
- echo "WATCHER DEGRADED: open-PR list hit its --limit $pr_cap — PRs past it are NOT watched, silence on them is NOT green"
2202
- cap_out=1
2203
- fi
2204
- elif [ -n "$cap_out" ]; then
2205
- echo "WATCHER RECOVERED: open-PR list under its --limit $pr_cap — every open PR watched again"
2206
- cap_out=
2195
+ if [ "$count" -ge "$pr_cap" ] && [ -z "$cap_out" ]; then # global latch: a full page may have been cut there
2196
+ echo "WATCHER DEGRADED: open-PR list hit its --limit $pr_cap — PRs past it are NOT watched, silence on them is NOT green"
2197
+ cap_out=1
2207
2198
  fi
2208
2199
  # gh pr list is GraphQL, so $rl still holds. The pass is budgeted at 4 core
2209
2200
  # REST units per listed PR on top of the 200 floor. The 4 is the measured
@@ -2220,9 +2211,9 @@ while :; do # one tick
2220
2211
  # The workflow and run lookups bill a second core bucket that
2221
2212
  # `rate_limit` does not report. Its count is only in the response
2222
2213
  # headers of a lookup that bills it: one 1-unit read per tick, 4 units
2223
- # per listed PR on the same 200 floor. Recovery for both buckets waits
2224
- # until this gate clears too, so no line says polling resumed while
2225
- # this one still pauses it.
2214
+ # per listed PR on the same 200 floor. Recovery for every global latch
2215
+ # waits until this gate clears too, so no line says polling resumed
2216
+ # while this one still pauses it.
2226
2217
  hrl=$(gh api -i 'repos/{owner}/{repo}/actions/workflows?per_page=1' 2>/dev/null | awk 'tolower($1)=="x-ratelimit-remaining:" {sub(/\r$/, "", $2); print $2; exit}')
2227
2218
  case "$hrl" in ''|*[!0-9]*) hrl=ERR;; esac # a missing header is an outage, not a budget
2228
2219
  if [ "$hrl" = ERR ] || [ "$hrl" -lt $((200 + 4 * count)) ]; then
@@ -2232,6 +2223,14 @@ while :; do # one tick
2232
2223
  hidden_out=1
2233
2224
  fi
2234
2225
  else
2226
+ if [ -n "$list_out" ]; then
2227
+ echo "WATCHER RECOVERED: open-PR list readable again — CI polling resumed"
2228
+ list_out=
2229
+ fi
2230
+ if [ -n "$cap_out" ] && [ "$count" -lt "$pr_cap" ]; then
2231
+ echo "WATCHER RECOVERED: open-PR list under its --limit $pr_cap — every open PR watched again"
2232
+ cap_out=
2233
+ fi
2235
2234
  if [ -n "$budget_out" ]; then
2236
2235
  echo "WATCHER RECOVERED: core budget=$rl — CI polling resumed"
2237
2236
  budget_out=
@@ -2361,10 +2360,14 @@ would run dry mid-pass and each emit a blind line. The DEGRADED line from each
2361
2360
  pass gate names the amount it needed and the count it needed it for — except an
2362
2361
  unreadable header, which has no amount to compare and prints `bucket=ERR` alone
2363
2362
  — so a healthy-looking `budget=999` is not read as an outage with no cause. Only the
2364
- pass gates emit RECOVERED lines, and both only once the pass will actually run:
2365
- announcing recovery at the floor, or for one bucket while the other still pauses
2366
- the pass, would report resumption on a tick whose other gate then pauses it
2367
- again — a DEGRADED/RECOVERED pair every tick.
2363
+ pass gates emit RECOVERED lines — the budget's and the unreported bucket's, and the
2364
+ open-PR list's and its cap's with them — and all of them only once the pass will
2365
+ actually run: announcing recovery at the floor, or for one bucket while the other
2366
+ still pauses the pass, would report resumption on a tick whose other gate then
2367
+ pauses it again — a DEGRADED/RECOVERED pair every tick — and announcing the list or
2368
+ its cap on the tick that reads it back would say polling resumed on a tick that
2369
+ polls nothing. A list or cap latch held across a paused tick stays latched and says
2370
+ nothing more.
2368
2371
 
2369
2372
  **Judge `ci-state` on its payload, never its exit code** — the same rule as
2370
2373
  `merge-gate.mjs` applies on the merge path, applied to the watcher. `not-green` is an