@feigi/fleet-ctl 3.71.10 → 3.71.12

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.71.10",
3
+ "version": "3.71.12",
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": {
@@ -990,7 +990,7 @@ export async function gather({ ledgerFile, prevFile, stateFile = null, scriptDir
990
990
  // here because it reads the process table, and only when the mark is
991
991
  // stalled, so a healthy board reads none. computeBoard() words it.
992
992
  const now = Date.now();
993
- const stallOwnerOf = isStalled(assessBeat({ beat, ticked, acted, controller, now })) ? stallOwner(priorState, NAME) : null;
993
+ const stallOwnerOf = isStalled(assessBeat({ beat, ticked, acted, controller, now })) ? stallOwner(controller, NAME) : null;
994
994
  return { ledger, issues, prs, merged, ci, prev, repo, repoUrl, workspace, port, spend, beat, ticked, acted, controller, stallOwner: stallOwnerOf, poolOk,
995
995
  poolCapped, prsCapped,
996
996
  now, interval };
@@ -537,35 +537,18 @@ function mins(ms) {
537
537
  }
538
538
 
539
539
  // Whose stall a reader sees, off the controller record — the mark says only
540
- // that the beat stopped, never whether the run did. No record: unknown, and
541
- // the report keeps the wording it had before there was one.
542
- //
543
- // A mark older than the record's `at` was left by the run BEFORE the one
544
- // that wrote the record: rotate replaced the record after that run's last
545
- // beat, tick and ledger write. When every mark is that old, the record names
546
- // a controller that has left no mark yet, so judging it would call every
547
- // previous run alive. That stall reads the verdict rotate reached on the
548
- // record it replaced, `prior`: dead is a controller gone whose claims this run
549
- // resumes, ancestor is this same session's earlier run and so alive, none is
550
- // unknown. A mark written since the record — any later beat, tick or ledger
551
- // write — is the recorded controller's own, so the record itself is judged,
552
- // through proc.mjs: dead or a reused pid is gone and the NEXT run resumes;
553
- // alive, or an ancestor of the reader, is alive. A record with no `at` cannot
554
- // place the mark and is judged too.
540
+ // that the beat stopped, never whether the run did. The record is judged
541
+ // through proc.mjs: dead or a reused pid is gone and the next run resumes;
542
+ // alive, or an ancestor of the reader, is alive and named by pid. No record:
543
+ // unknown, and the report keeps the wording it had before there was one.
555
544
  //
556
545
  // `judge` is replaceable for the same reason proc.mjs's process source is: a
557
546
  // reader under a live omp session would otherwise find that session. A
558
547
  // process table that cannot be read leaves the stall unattributed, said on
559
548
  // stderr, rather than calling a controller nobody could judge dead or alive.
560
549
  export const NO_OWNER = Object.freeze({ kind: "none" });
561
- export function stallOwner({ controller, beat = null, ticked = null, acted = null }, name, judge = judgeRecord) {
550
+ export function stallOwner(controller, name, judge = judgeRecord) {
562
551
  if (!controller) return NO_OWNER;
563
- const before = (mark) => thisRun(mark, controller) === null;
564
- if (controller.at !== null && before(beat) && before(ticked) && before(acted)) {
565
- if (controller.prior === "dead") return { kind: "gone", resumes: "this run" };
566
- if (controller.prior === "ancestor") return { kind: "alive", pid: null };
567
- return NO_OWNER;
568
- }
569
552
  let verdict;
570
553
  try {
571
554
  verdict = judge(controller);
@@ -574,7 +557,7 @@ export function stallOwner({ controller, beat = null, ticked = null, acted = nul
574
557
  console.error(`${name}: WARNING ${e.message} — the recorded controller pid ${controller.pid} cannot be judged, so the stall report names no controller`);
575
558
  return NO_OWNER;
576
559
  }
577
- if (verdict === "dead") return { kind: "gone", resumes: "the next run" };
560
+ if (verdict === "dead") return { kind: "gone" };
578
561
  if (verdict === "alive" || verdict === "ancestor") return { kind: "alive", pid: controller.pid };
579
562
  return NO_OWNER;
580
563
  }
@@ -619,10 +602,10 @@ export function stallReport(verdict, { claimed, supply, owner = NO_OWNER } = {})
619
602
  ? `stopped deliberately — recorded reason: ${verdict.reason}`
620
603
  : verdict.beatless ? "no beat, tick or ledger write since, and no recorded reason" : "the beat stopped without a recorded reason";
621
604
  const head = owner.kind === "alive"
622
- ? `heartbeat not beating, controller alive (${owner.pid === null ? "this session's earlier run" : `pid ${owner.pid}`})`
605
+ ? `heartbeat not beating, controller alive (pid ${owner.pid})`
623
606
  : owner.kind === "gone" ? "heartbeat STALLED, controller gone" : "heartbeat STALLED";
624
607
  const tail = owner.kind === "gone"
625
- ? `; ${owner.resumes} resumes its claims without a PR, and its open PRs return through the fold-in`
608
+ ? "; the next run resumes its claims without a PR, and its open PRs return through the fold-in"
626
609
  : "";
627
610
  const seen = verdict.beatless
628
611
  ? `no beat this run, last ${MARK_NAMES[verdict.mark]} ${when(verdict.at)}`
@@ -1987,7 +1987,7 @@ function main() {
1987
1987
  if (!priorState.degraded) writeState(path, NAME, priorState, { ticked: { at: tickedAt } });
1988
1988
  if (isReported(verdict)) {
1989
1989
  console.log(stallReport(verdict, isStalled(verdict)
1990
- ? { claimed: claimed(), supply: current.scanned, owner: stallOwner(priorState, NAME) }
1990
+ ? { claimed: claimed(), supply: current.scanned, owner: stallOwner(priorState.controller, NAME) }
1991
1991
  : {}));
1992
1992
  }
1993
1993
 
@@ -14,6 +14,8 @@
14
14
  // `docs/metrics/ticket-features.tsv`, deduped on `session` + `agent`, and
15
15
  // deletes the pending file. A crash between the write and the delete leaves
16
16
  // rows the next drain finds already there, so a second run changes nothing.
17
+ // A pending file that is empty, or blank lines only, is removed with its own
18
+ // line: an append created it and never wrote.
17
19
  //
18
20
  // COST GUARD. `pr-cost.mjs --guard` rewrites `.fleet/cost-guard.json`, which
19
21
  // the router reads and fails closed without. It needs all three metrics TSVs;
@@ -56,7 +58,16 @@ function drain(repo) {
56
58
  const pending = join(repo, PENDING);
57
59
  if (!existsSync(pending)) return say(`drain: nothing pending in ${PENDING}`);
58
60
  const pendingText = readFileSync(pending, "utf8");
59
- const incoming = parseFeatures(pendingText);
61
+ if (pendingText.trim() === "") {
62
+ unlinkSync(pending);
63
+ return say(`drain: ${PENDING} was empty — removed (an append created it and never wrote: crash or full disk)`);
64
+ }
65
+ let incoming;
66
+ try {
67
+ incoming = parseFeatures(pendingText);
68
+ } catch (e) {
69
+ throw new Error(`${PENDING}: ${e.message}`);
70
+ }
60
71
  const target = join(repo, FEATURES);
61
72
  let text = existsSync(target) ? readFileSync(target, "utf8") : `${FEATURE_COLUMNS.join("\t")}\n`;
62
73
  const seen = new Set(parseFeatures(text).map(pullKey));
@@ -36,7 +36,7 @@
36
36
  // the guard are files the caller wrote, and a fitted commit is fetched by the
37
37
  // caller.
38
38
 
39
- import { readFileSync, writeFileSync, renameSync, existsSync, appendFileSync, mkdirSync } from "node:fs";
39
+ import { readFileSync, writeFileSync, renameSync, appendFileSync, mkdirSync, statSync } from "node:fs";
40
40
  import { spawnSync } from "node:child_process";
41
41
  import { basename, dirname, join, resolve } from "node:path";
42
42
  import { fileURLToPath } from "node:url";
@@ -580,7 +580,7 @@ function main() {
580
580
  const pending = F.arg("pending") ?? join(dirname(guardPath), "ticket-features.pending.tsv");
581
581
  try {
582
582
  mkdirSync(dirname(pending), { recursive: true });
583
- const header = existsSync(pending) ? "" : `${COLUMNS.join("\t")}\n`;
583
+ const header = statSync(pending, { throwIfNoEntry: false })?.size > 0 ? "" : `${COLUMNS.join("\t")}\n`;
584
584
  appendFileSync(pending, `${header}${formatFeatureRow(row)}\n`);
585
585
  } catch (e) {
586
586
  process.stderr.write(`${NAME}: WARNING could not append to ${pending}: ${e.message} — this Pull's ticket-features row is not recorded\n`);
@@ -1438,10 +1438,10 @@ record:
1438
1438
  Its claims without a PR come back through the next run's phase 0
1439
1439
  stranded-claim step (references/phase-0.md, "Resume the claims a dead run
1440
1440
  left without a PR"), and its open PRs through the fold-in.
1441
- - `heartbeat not beating, controller alive (pid N)`, or `(this session's
1442
- earlier run)` — a controller that stopped beating and kept going. Nothing
1443
- died, so nothing is resumed; when that controller is you, the fix is to
1444
- tick on every wake and beat when there is nothing to do.
1441
+ - `heartbeat not beating, controller alive (pid N)` — a controller that
1442
+ stopped beating and kept going. Nothing died, so nothing is resumed; when
1443
+ that controller is you, the fix is to tick on every wake and beat when there
1444
+ is nothing to do.
1445
1445
  - `heartbeat STALLED` alone — no record says whether that controller lives.
1446
1446
  The line is detection only.
1447
1447