@feigi/fleet-ctl 3.41.1 → 3.41.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.41.1",
3
+ "version": "3.41.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": {
@@ -1214,34 +1214,56 @@ function readShortlist(path) {
1214
1214
  return parseShortlist(text);
1215
1215
  }
1216
1216
 
1217
- // An Exclusion whose premise has lifted, for a ticket the current file does
1218
- // not already carry (if it does, the refresh that lifted it has run). A
1219
- // `behind-pr:#M` reads off the open list already in hand; a `behind-issue:#M`
1220
- // costs one `gh issue view`. A branch-named `behind-pr` is left to the
1221
- // refresh itself: before its PR exists, "no open PR" is not "merged". Any
1222
- // probe that cannot answer leaves the exclusion standing.
1217
+ // A gh state read of one Exclusion premise, scrubbed as shortlist.mjs's
1218
+ // probeState() is: gh's remote resolution follows GIT_DIR/GIT_WORK_TREE, and
1219
+ // GH_REPO outranks both. The state it printed, or null when it could not
1220
+ // answer — a nonzero exit, or exit 0 with a body carrying no state (an HTML
1221
+ // error page, JSON with no state). Either way the unanswered probe is
1222
+ // disclosed, not dropped: every other gh call in this file either dies or
1223
+ // logs its failure, so a bare empty catch here would be the one silent
1224
+ // exception in a file whose whole design goal is "no silent stall".
1225
+ function premiseState(noun, target, label) {
1226
+ const r = spawnSync("gh", [noun, "view", target, "--json", "state"], { encoding: "utf8", timeout: GH_TIMEOUT_MS, env: gitEnv({ GH_REPO: "" }) });
1227
+ if (r.error || r.status !== 0) {
1228
+ console.error(`${NAME}: ${failure(r, `gh ${noun} view ${target}`)} — ${label} premise unconfirmed, exclusion stands`);
1229
+ return null;
1230
+ }
1231
+ let st = null;
1232
+ try { st = JSON.parse(r.stdout).state; } catch { /* no state: disclosed below */ }
1233
+ if (typeof st !== "string") {
1234
+ console.error(`${NAME}: gh ${noun} view ${target} printed no state — ${label} premise unconfirmed, exclusion stands`);
1235
+ return null;
1236
+ }
1237
+ return st;
1238
+ }
1239
+
1240
+ // An Exclusion whose premise sends the tick to a refresh. Lifted, for a
1241
+ // ticket the current file does not already carry (if it does, the refresh
1242
+ // that lifted it has run): a `behind-pr:#M` reads off the open list already
1243
+ // in hand; a `behind-issue:#M` costs one `gh issue view`; a branch-named
1244
+ // `behind-pr` costs one `gh pr view`, whose MERGED or CLOSED lifts it —
1245
+ // before its PR exists, "no open PR" is not "merged". Standing, for a
1246
+ // branch-named `behind-pr` whose ticket the current file still carries: the
1247
+ // file may predate the exclusion, and only the refresh's own probe can drop
1248
+ // the ticket from it, so any answer short of MERGED or CLOSED, an
1249
+ // unanswered probe included, asks for that refresh. An unanswered probe
1250
+ // never lifts an exclusion.
1223
1251
  function liftedPremise(excluded, entries, prs) {
1224
1252
  const inFile = new Set(entries.map((e) => e.n));
1225
1253
  const open = new Set(prs.map((p) => p.number));
1226
1254
  for (const { n, premises } of excluded) {
1227
- if (inFile.has(n)) continue;
1228
1255
  for (const { kind, target } of premises) {
1229
- if (!isDigits(target)) continue;
1256
+ if (kind === "pr" && !isDigits(target)) {
1257
+ const st = premiseState("pr", target, `behind-pr:#${target}`);
1258
+ const lifted = st === "CLOSED" || st === "MERGED";
1259
+ if (lifted && !inFile.has(n)) return `behind-pr:#${target} ${st}`;
1260
+ if (!lifted && inFile.has(n)) return `behind-pr:#${target} not merged, #${n} still on the shortlist`;
1261
+ continue;
1262
+ }
1263
+ if (inFile.has(n) || !isDigits(target)) continue;
1230
1264
  if (kind === "pr" && !open.has(Number(target))) return `behind-pr:#${target} no longer open`;
1231
1265
  if (kind === "issue") {
1232
- // Scrubbed as shortlist.mjs's probeState() is: gh's remote resolution
1233
- // follows GIT_DIR/GIT_WORK_TREE, and GH_REPO outranks both.
1234
- const r = spawnSync("gh", ["issue", "view", target, "--json", "state"], { encoding: "utf8", timeout: GH_TIMEOUT_MS, env: gitEnv({ GH_REPO: "" }) });
1235
- if (r.error || r.status !== 0) {
1236
- // Disclosed, not dropped: every other gh call in this file either
1237
- // dies or logs its failure — a bare empty catch here would be the
1238
- // one silent exception in a file whose whole design goal is "no
1239
- // silent stall".
1240
- console.error(`${NAME}: ${failure(r, `gh issue view ${target}`)} — behind-issue:#${target} premise unconfirmed, exclusion stands`);
1241
- continue;
1242
- }
1243
- let st = null;
1244
- try { st = JSON.parse(r.stdout).state; } catch { /* unanswered: the exclusion stands */ }
1266
+ const st = premiseState("issue", target, `behind-issue:#${target}`);
1245
1267
  if (st === "CLOSED" || st === "MERGED") return `behind-issue:#${target} ${st}`;
1246
1268
  }
1247
1269
  }
@@ -1386,9 +1408,11 @@ function main() {
1386
1408
  throw e;
1387
1409
  }
1388
1410
 
1389
- // Pull from the current file first; refresh when it is short, absent, or an
1390
- // exclusion has lifted — and top the PULL up from what the refresh found,
1391
- // so a slot the current file could not fill does not wait a tick for it.
1411
+ // Pull from the current file first; refresh when it is short, absent, an
1412
+ // exclusion has lifted, or a branch-named one still names a ticket on it.
1413
+ // A refresh that succeeds replaces the heads outright: the PULL is read off
1414
+ // what shortlist.mjs just probed, never merged with the file's own heads,
1415
+ // or a ticket the refresh dropped would be pulled anyway.
1392
1416
  let heads = unclaimed(current.entries, run);
1393
1417
  let supply = current.scanned;
1394
1418
  let dropped = current.dropped;
@@ -1400,7 +1424,7 @@ function main() {
1400
1424
  const r = refresh();
1401
1425
  if (r.ok) {
1402
1426
  const excludedSet = new Set(run.excluded.map((x) => x.n));
1403
- heads = [...new Set([...heads, ...unclaimed(r.entries, run)])];
1427
+ heads = unclaimed(r.entries, run);
1404
1428
  supply = r.scanned;
1405
1429
  dropped = r.dropped;
1406
1430
  fresh = {
@@ -658,9 +658,11 @@ phase, or in any later one, asks the maintainer which tickets to take.
658
658
  drop, survivors and specs together, is named the same way.
659
659
  2. **Refresh is the tick's from here on.** `fleet-tick.mjs` runs
660
660
  `shortlist.mjs` itself when unclaimed entries fall below the implementer
661
- cap, when the file is missing or empty, and when an `excluded` premise has
662
- lifted, and prints `REFRESHED shortlist: <n> entries; <k> lifted`. Phase 0
663
- runs it by hand once because a dead run's shortlist is stale by definition.
661
+ cap, when the file is missing or empty, when an `excluded` premise has
662
+ lifted, and when a branch-named `behind-pr` exclusion whose PR is not yet
663
+ MERGED or CLOSED names a ticket the file still carries, and prints
664
+ `REFRESHED shortlist: <n> entries; <k> lifted`. Phase 0 runs it by hand
665
+ once because a dead run's shortlist is stale by definition.
664
666
 
665
667
  **No multi-select, no maintainer tick.** Selection and ordering are batched —
666
668
  one scan, oldest first; admission never is. The invariant this replaces — one