@feigi/fleet-ctl 3.133.4 → 3.134.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.133.4",
3
+ "version": "3.134.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": {
@@ -16,6 +16,9 @@
16
16
  // rowDispatch, the function `route` itself calls), and on the evidence-favours
17
17
  // side the same for the Preview fit's table (`.fleet/router-preview.json`, which
18
18
  // metrics-refresh.mjs writes beside the guard), marked where its Cell differs.
19
+ // The receipts' newest `metrics` step, which the guard section quotes when there
20
+ // is no guard, also feeds the evidence-favours side: a refit that step says
21
+ // failed, with no fit written after it, is said in that side's heading.
19
22
  // Figures show only from a guard `readCostGuard` (fleet-tick.mjs, the reader
20
23
  // the tick judges the file by) accepts; `guard` here is that reader's own
21
24
  // answer, `{ status: "ok", guard }` or
@@ -108,13 +111,22 @@ function tierRoute(role, level, generation, modelRoles) {
108
111
  }
109
112
 
110
113
  // ---------------------------------------------------------------------------
111
- // No guard: the newest `metrics` step of the phase 0 and close-out receipts.
114
+ // The newest `metrics` step of the phase 0 and close-out receipts: the guard
115
+ // section quotes it when there is no guard, and evidence favours reads a failed refit off it.
112
116
  // ---------------------------------------------------------------------------
113
117
 
114
118
  // `step` is `{ status, at, output }` or null. A step that has not run carries no
115
119
  // refresh to quote.
116
120
  const ran = (step) => step != null && step.status !== "pending" && Number.isFinite(Date.parse(step.at));
117
121
 
122
+ // The newest `metrics` step of the two receipts that has run, by `at`; on equal
123
+ // times, phase 0's. Null when neither receipt has run one.
124
+ function newestStep(receipts) {
125
+ const steps = [receipts?.phase0, receipts?.closeout].filter(ran);
126
+ if (steps.length === 0) return null;
127
+ return steps.reduce((a, b) => (Date.parse(b.at) > Date.parse(a.at) ? b : a));
128
+ }
129
+
118
130
  // metrics-refresh's own line from a step's output: the cost-guard duty's, else
119
131
  // the last of its lines, else the output's first line. Its own prefix, the
120
132
  // "skipped," and the note that the file was left as it was are dropped; the rest
@@ -128,17 +140,23 @@ function refreshLine(output) {
128
140
  return line.trim().replace(/; \S*cost-guard\.json left as it is$/, "");
129
141
  }
130
142
 
131
- // The newest `metrics` step of the two receipts, with the verb its status and
132
- // line give it: `{ verb, at, why }`, or null when neither receipt has run one.
133
- function newestRefresh(receipts) {
134
- const steps = [receipts?.phase0, receipts?.closeout].filter(ran);
135
- if (steps.length === 0) return null;
136
- const step = steps.reduce((a, b) => (Date.parse(b.at) > Date.parse(a.at) ? b : a));
143
+ // The newest `metrics` step, with the verb its status and line give it:
144
+ // `{ verb, at, why }`, or null when neither receipt has run one.
145
+ function newestRefresh(step) {
146
+ if (step === null) return null;
137
147
  const why = refreshLine(step.output);
138
148
  const verb = step.status === "failed" ? "failed" : /metrics-refresh: cost guard: skipped,/.test(step.output ?? "") ? "skipped" : "ran";
139
149
  return { verb, at: step.at, why };
140
150
  }
141
151
 
152
+ // Why the Preview fit's refit failed, off a `metrics` step's output: the rest of
153
+ // metrics-refresh's `preview: failed — ` line, trimmed, or null when the output
154
+ // has none. Found anywhere in a line, as refreshLine finds its own.
155
+ export function refitFailure(output) {
156
+ const m = /metrics-refresh: preview: failed — ([^\n]*)/.exec(String(output ?? ""));
157
+ return m === null ? null : m[1].trim();
158
+ }
159
+
142
160
  // ---------------------------------------------------------------------------
143
161
  // The guard section.
144
162
  // ---------------------------------------------------------------------------
@@ -352,9 +370,10 @@ function booked(entry, pulls) {
352
370
  // The Cells drawn: the five, then any the guard holds or a card names beyond them.
353
371
  const drawOrder = (held, pulls) => [...new Set([...CELLS, ...held, ...pulls.flatMap((p) => p.targets.map((t) => t.cell)).filter((c) => CELL.test(c))])];
354
372
 
355
- function guardSection(read, receipts, modelRoles, pulls, recordsNote = null) {
373
+ // `step` is the receipts' newest `metrics` step, newestStep's pick.
374
+ function guardSection(read, receipts, step, modelRoles, pulls, recordsNote = null) {
356
375
  const label = readLabel(modelRoles);
357
- const refresh = newestRefresh(receipts);
376
+ const refresh = newestRefresh(step);
358
377
  const notes = [];
359
378
  const footnotes = [];
360
379
 
@@ -601,10 +620,24 @@ const FAVOURS = "evidence favours";
601
620
 
602
621
  // The evidence-favours side with no Preview fit to lay out: its heading says
603
622
  // why, and its column is empty — nothing is unknown there, there is nothing to show.
604
- const noFit = (heading) => ({
605
- title: FAVOURS, source: { text: "Preview fit", check: null }, heading, labels: [], footnotes: [], rows: null, unread: null,
623
+ const noFit = (heading, labels = []) => ({
624
+ title: FAVOURS, source: { text: "Preview fit", check: null }, heading, labels, footnotes: [], rows: null, unread: null,
606
625
  });
607
626
 
627
+ // The newest refit failed: `step` is the receipts' newest `metrics` step, `p`
628
+ // the Preview fit read, null when none was. Said while that step's output holds
629
+ // the failed line and no fit was written after it — a `computed_at` before the
630
+ // step's `at`, or one that is no time. A later step, a fit written after this
631
+ // one, or the receipt no longer read clears it.
632
+ function refitLabel(step, p) {
633
+ if (step === null) return [];
634
+ const why = refitFailure(step.output);
635
+ if (why === null) return [];
636
+ const computed = p === null ? NaN : Date.parse(p.computed_at);
637
+ if (Number.isFinite(computed) && computed >= Date.parse(step.at)) return [];
638
+ return [`the newest refit failed at ${when(step.at)}: ${why}`];
639
+ }
640
+
608
641
  // The Preview fit's heading labels, against `raw`, the guard on disk, `routed`,
609
642
  // readGuard's answer for it, `table`, the installed one, and `records`, whether
610
643
  // the fit read the guard's files: fitted beside another guard, on other records,
@@ -650,12 +683,13 @@ function nDiffers(p, raw, records) {
650
683
  // Cell marked where it differs from the Cell routes now gives that row. `preview`
651
684
  // is gather's read, `{ status: "ok", preview } | { status: "missing" } | {
652
685
  // status: "unreadable", why }`; `guard` readCostGuard's answer and `routed`
653
- // readGuard's for the same file, null when the router reads none; `mark` the
654
- // footnote mark its n footnote takes.
655
- function evidenceFavours({ preview, guard, routed, table, modelRoles, mark }) {
686
+ // readGuard's for the same file, null when the router reads none; `step` the
687
+ // receipts' newest `metrics` step, newestStep's pick; `mark` the footnote mark
688
+ // its n footnote takes.
689
+ function evidenceFavours({ preview, guard, routed, table, modelRoles, step, mark }) {
656
690
  if (routed === null) return noFit("no Preview fit: it is written only beside a cost guard");
657
- if (preview?.status === "unreadable") return noFit(`no Preview fit read: ${preview.why}`);
658
- if (preview?.status !== "ok") return noFit("no Preview fit yet: the next phase 0 writes one");
691
+ if (preview?.status === "unreadable") return noFit(`no Preview fit read: ${preview.why}`, refitLabel(step, null));
692
+ if (preview?.status !== "ok") return noFit("no Preview fit yet: the next phase 0 writes one", refitLabel(step, null));
659
693
  const p = preview.preview;
660
694
  const fit = p.table;
661
695
  const raw = guard.guard;
@@ -676,7 +710,7 @@ function evidenceFavours({ preview, guard, routed, table, modelRoles, mark }) {
676
710
  title: FAVOURS,
677
711
  source: { text: ["Preview fit", "this repository's runs", `computed ${when(p.computed_at)}`, plural(fit.n_rows, "Pull")].join(" · "), check: null },
678
712
  heading: fit.burn_in ? `stage ${fit.stage}: ${shortWords(fit, "present") ?? "every Cell has its merged PRs"}` : null,
679
- labels: previewLabels(p, raw, routed, table, records),
713
+ labels: [...refitLabel(step, p), ...previewLabels(p, raw, routed, table, records)],
680
714
  footnotes: differ.length === 0 ? [] : [{ mark, text: `${list(differ)}: the guard counts merges by GitHub's state, the fit by Rulings, and the fit admits only drawn or rule-sized Pulls` }],
681
715
  rows: Object.fromEntries(OBJECTIVES.map((o) => [o,
682
716
  Object.fromEntries(["*", ...STRATA].filter((s) => Object.hasOwn(fit.rows[o], s)).map((s) => [s, entry(o, s)])),
@@ -904,12 +938,13 @@ export function computeCellEvidence({ guard, receipts, agents, modelRoles = null
904
938
  guardJson = null, mainMetrics = null, closeoutPr = null, openPrs = null, checkoutTable = null }) {
905
939
  const routed = guard?.status === "ok" ? readGuard(guard.guard) : null;
906
940
  const routes = routesNow({ table, guard: routed, modelRoles, install, repoUrl, checkout: checkoutTable });
907
- const favours = evidenceFavours({ preview, guard, routed, table, modelRoles, mark: superscript(routes.footnotes.length + 1) });
941
+ const step = newestStep(receipts);
942
+ const favours = evidenceFavours({ preview, guard, routed, table, modelRoles, step, mark: superscript(routes.footnotes.length + 1) });
908
943
  const records = recordsAgainstMain({ read: guard, preview, main: mainMetrics, closeoutPr, openPrs });
909
944
  return {
910
945
  alerts: [records.alert, noRulingAlert(guard), readersAlert(guardJson)].filter((a) => a !== null),
911
946
  policy: policyRowsView({ sides: [routes, favours], objective }),
912
- guard: guardSection(guard, receipts, modelRoles, pulls, records.note),
947
+ guard: guardSection(guard, receipts, step, modelRoles, pulls, records.note),
913
948
  declared: declaredSection(agents, modelRoles),
914
949
  };
915
950
  }
@@ -70,7 +70,9 @@
70
70
  // in-process because a fit has no verdict for an exit status to carry, and the
71
71
  // `fit` CLI reads the TSVs only as committed. It never fails the run: an error
72
72
  // prints `metrics-refresh: preview: failed — <why>`, leaves the old file in
73
- // place and leaves the exit status as the other duties set it.
73
+ // place and leaves the exit status as the other duties set it. That line stays
74
+ // on stdout: the cockpit reads it off the receipts' `metrics` step, and
75
+ // close-out's receipt keeps only stdout from a run that exits 0.
74
76
  //
75
77
  // One `metrics-refresh: <duty>: …` line per duty on stdout. Exit 0 when no
76
78
  // duty failed; 1 when one failed — named on stderr, and the duties after