@feigi/fleet-ctl 3.127.5 → 3.127.6

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.127.5",
3
+ "version": "3.127.6",
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": {
@@ -65,7 +65,10 @@
65
65
  // Ruling's note is not one `tier-outcomes.mjs append` derives (`isDerivedNote`);
66
66
  // `no_ruling`, the Pulls whose PR merged on GitHub with no Ruling, which stay
67
67
  // not merged; and `pending`, the Pulls whose PR is still open or not in the
68
- // list. Beside `min_n` it records `trip_points`, the floor's margin, and
68
+ // list. `no_ruling_prs` and `pending_prs` name the PRs behind the last two,
69
+ // ascending, as the report's top-level `pending` list does: a `no_ruling`
70
+ // Pull contributes the implementer PRs that make it one. Beside `min_n` it
71
+ // records `trip_points`, the floor's margin, and
69
72
  // `tsv_blobs`: the git blob id of each TSV it read, by the path it read it at.
70
73
 
71
74
  import { createHash } from "node:crypto";
@@ -117,27 +120,43 @@ export function computeReport({ members, tiers, features, prs, routerTable = nul
117
120
  const bootUnits = (g) => g.pulls.map((u) => bootUnit(u));
118
121
  const meanUsd = (t) => (t.merged ? t.spend / t.merged : null);
119
122
  const base = tallies.get(BASELINE_CELL) ?? null;
123
+ // The PRs behind each generation's `no_ruling` and `pending` counts, as the
124
+ // top-level `pending` list prints them: ascending, each once.
125
+ const behind = new Map();
126
+ for (const u of units) {
127
+ if (u.status === "excluded") continue;
128
+ const k = `${u.cell}\0${u.generation}`;
129
+ const held = behind.get(k) ?? behind.set(k, { no_ruling_prs: new Set(), pending_prs: new Set() }).get(k);
130
+ for (const pr of u.noRulingPrs) held.no_ruling_prs.add(pr);
131
+ if (u.status === "pending") held.pending_prs.add(u.pendingPr);
132
+ }
133
+ const prList = (set = []) => [...set].sort((x, y) => Number(x) - Number(y));
120
134
  // One generation's figures. The interval is the newest generation's against
121
135
  // the baseline's newest; an older generation is printed, never compared.
122
- const figuresOf = (cell, g, newest) => ({
123
- cell,
124
- generation: g.generation,
125
- n_pulls: g.n,
126
- n_merged: g.merged,
127
- n_claims: g.claims,
128
- n_failed: g.failed,
129
- fail_rate: g.claims ? round(g.failed / g.claims) : null,
130
- mean_usd: round(meanUsd(g), 2),
131
- median_usd: round(median(g.pulls.filter((u) => u.merged).map((u) => u.spend)), 2),
132
- by_hand: g.by_hand,
133
- no_ruling: g.no_ruling,
134
- pending: g.pending,
135
- router_usd: round(g.pulls.reduce((s, u) => s + routerUsd(u.pull), 0), 4),
136
- usd_diff_ci95: !newest || cell === BASELINE_CELL || !base ? null : bootstrapDiffCI(bootUnits(g), bootUnits(base)),
137
- left_out: g.left_out,
138
- unpriced: g.unpriced,
139
- untimed: g.untimed,
140
- });
136
+ const figuresOf = (cell, g, newest) => {
137
+ const held = behind.get(`${cell}\0${g.generation}`);
138
+ return {
139
+ cell,
140
+ generation: g.generation,
141
+ n_pulls: g.n,
142
+ n_merged: g.merged,
143
+ n_claims: g.claims,
144
+ n_failed: g.failed,
145
+ fail_rate: g.claims ? round(g.failed / g.claims) : null,
146
+ mean_usd: round(meanUsd(g), 2),
147
+ median_usd: round(median(g.pulls.filter((u) => u.merged).map((u) => u.spend)), 2),
148
+ by_hand: g.by_hand,
149
+ no_ruling: g.no_ruling,
150
+ no_ruling_prs: prList(held?.no_ruling_prs),
151
+ pending: g.pending,
152
+ pending_prs: prList(held?.pending_prs),
153
+ router_usd: round(g.pulls.reduce((s, u) => s + routerUsd(u.pull), 0), 4),
154
+ usd_diff_ci95: !newest || cell === BASELINE_CELL || !base ? null : bootstrapDiffCI(bootUnits(g), bootUnits(base)),
155
+ left_out: g.left_out,
156
+ unpriced: g.unpriced,
157
+ untimed: g.untimed,
158
+ };
159
+ };
141
160
  const figures = [...tallies.values()].map((t) => ({
142
161
  ...figuresOf(t.cell, t, true),
143
162
  excluded: t.excluded,
@@ -283,8 +283,11 @@ function numberOf(row, field, column = field) {
283
283
  /**
284
284
  * One unit per ticket-features row dated on or after `windowStart` (every dated
285
285
  * row when null), in file order: `{ pull, cell, stratum, generation, status,
286
- * merged, pr, ruling, pendingPr, noRuling, claims, falseClaims, rows, spend, workS }`,
287
- * `generation` null exactly when the Pull is excluded. `spend` is null when a
286
+ * merged, pr, ruling, pendingPr, noRuling, noRulingPrs, claims, falseClaims, rows, spend, workS }`,
287
+ * `generation` null exactly when the Pull is excluded. `noRulingPrs` are the
288
+ * Pull's own implementer PRs that are merged and that no Pull holds a Ruling
289
+ * for, which is what makes the Pull `noRuling`; [] when the Pull itself has a
290
+ * Ruling, or when PR state is unknown. `spend` is null when a
288
291
  * booked `cost` is blank, and `workS`, its work time in seconds, when a booked
289
292
  * `work_s` of a row naming no parent is. `prs` is `gh pr list`'s
290
293
  * `{ number, state }` rows, or null when PR state is unknown (the fit). `stratum`
@@ -358,7 +361,7 @@ export function attribute({ features, members, tiers, prs = null, windowStart =
358
361
  const r = ruled.get(pull) ?? null;
359
362
  let merged = r !== null;
360
363
  let pendingPr = null;
361
- let noRuling = false;
364
+ let noRulingPrs = [];
362
365
  if (state) {
363
366
  if (r) {
364
367
  const s = state.get(r.pr);
@@ -366,7 +369,7 @@ export function attribute({ features, members, tiers, prs = null, windowStart =
366
369
  merged = s === "MERGED";
367
370
  } else {
368
371
  pendingPr = own.find((m) => m.pr && state.get(m.pr) === "OPEN")?.pr ?? null;
369
- noRuling = own.some((m) => m.pr && state.get(m.pr) === "MERGED" && !held.has(m.pr));
372
+ noRulingPrs = own.filter((m) => m.pr && state.get(m.pr) === "MERGED" && !held.has(m.pr)).map((m) => m.pr);
370
373
  }
371
374
  }
372
375
  let claims = 0, falseClaims = 0;
@@ -396,8 +399,8 @@ export function attribute({ features, members, tiers, prs = null, windowStart =
396
399
  else if (blank || (r && !r.carried)) status = "unpriced";
397
400
  else if (untimed) status = "untimed";
398
401
  return {
399
- pull, cell: pull.chosen_cell, stratum: stratum(pull), generation, status, merged, pr: r?.pr ?? null, ruling: r?.ruling ?? null, noRuling,
400
- pendingPr, claims, falseClaims, rows: booked, spend: blank ? null : spend, workS: untimed ? null : workS,
402
+ pull, cell: pull.chosen_cell, stratum: stratum(pull), generation, status, merged, pr: r?.pr ?? null, ruling: r?.ruling ?? null,
403
+ noRuling: noRulingPrs.length > 0, noRulingPrs, pendingPr, claims, falseClaims, rows: booked, spend: blank ? null : spend, workS: untimed ? null : workS,
401
404
  };
402
405
  });
403
406
  }
@@ -576,24 +576,29 @@ export function fitTable({ prior, features, members, verdicts, guard, commit = n
576
576
 
577
577
  let { stage, cells } = prior;
578
578
  cells = [...cells];
579
- const star = judgeRow(estimates["*"], pulls["*"], cells, tripped);
580
- const rows = { cost: { "*": star.cell ?? POLICY_CELL }, speed: {} };
581
- const reasons = { cost: { "*": { ...star, cell: rows.cost["*"] } }, speed: {} };
582
- for (const s of STRATA) {
583
- if (!estimates[s]) continue;
584
- reasons.cost[s] = judgeRow(estimates[s], pulls[s], cells, tripped);
585
- if (reasons.cost[s].cell !== null) rows.cost[s] = reasons.cost[s].cell;
586
- }
587
- for (const s of Object.keys(reasons.cost)) {
588
- const costCell = rows.cost[s];
589
- if (costCell === undefined) {
590
- reasons.speed[s] = unjudged();
591
- continue;
579
+ // The rows and their reasons over `cells`: a fitted table's `reasons` cover exactly its `cells`.
580
+ const judgeRows = () => {
581
+ const star = judgeRow(estimates["*"], pulls["*"], cells, tripped);
582
+ const rows = { cost: { "*": star.cell ?? POLICY_CELL }, speed: {} };
583
+ const reasons = { cost: { "*": { ...star, cell: rows.cost["*"] } }, speed: {} };
584
+ for (const s of STRATA) {
585
+ if (!estimates[s]) continue;
586
+ reasons.cost[s] = judgeRow(estimates[s], pulls[s], cells, tripped);
587
+ if (reasons.cost[s].cell !== null) rows.cost[s] = reasons.cost[s].cell;
592
588
  }
593
- const record = judgeSpeedRow(estimates[s], pulls[s], cells, tripped, costCell);
594
- rows.speed[s] = record.cell ?? costCell;
595
- reasons.speed[s] = { ...record, cell: rows.speed[s] };
596
- }
589
+ for (const s of Object.keys(reasons.cost)) {
590
+ const costCell = rows.cost[s];
591
+ if (costCell === undefined) {
592
+ reasons.speed[s] = unjudged();
593
+ continue;
594
+ }
595
+ const record = judgeSpeedRow(estimates[s], pulls[s], cells, tripped, costCell);
596
+ rows.speed[s] = record.cell ?? costCell;
597
+ reasons.speed[s] = { ...record, cell: rows.speed[s] };
598
+ }
599
+ return { rows, reasons };
600
+ };
601
+ let { rows, reasons } = judgeRows();
597
602
  const atN = (c) => (guard.n[c] ?? 0) >= MIN_N;
598
603
  const adopted = Object.values(rows).some((set) => set["*"] !== POLICY_CELL);
599
604
  if (stage === 1 && cells.every(atN) && (adopted || cells.some((c) => tripped.has(c)))) {
@@ -601,6 +606,8 @@ export function fitTable({ prior, features, members, verdicts, guard, commit = n
601
606
  for (const { cell, survives } of STAGE2) {
602
607
  if (!cells.includes(cell) && cells.includes(survives) && !tripped.has(survives)) cells.push(cell);
603
608
  }
609
+ // The stage-2 cells were added after the rows were judged: judge the rows again over the new `cells`.
610
+ ({ rows, reasons } = judgeRows());
604
611
  }
605
612
  return {
606
613
  window_start: window,