@feigi/fleet-ctl 3.161.0 → 3.161.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.161.0",
3
+ "version": "3.161.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": {
@@ -1010,8 +1010,9 @@ const STARTING_ROLES = Object.freeze(["slow", "task", "smol"]);
1010
1010
 
1011
1011
  /**
1012
1012
  * The starting set of a Baseline Cell: its level on each of the three models,
1013
- * `slow` first. The Cells burn-in draws and counts, and the Cells the Fit judges.
1014
- * A Cell exploration adds is none of them, whatever its merged PRs. Exported so
1013
+ * `slow` first. The Cells burn-in draws and counts, and the Cells the Fit always judges. A Cell exploration adds
1014
+ * does not end burn-in or hold it open, whatever its merged PRs; the Fit judges it beside these once it holds counted
1015
+ * Pulls. Exported so
1015
1016
  * ticket-router.mjs's burn-in and pr-cost.mjs's retire condition read one rule,
1016
1017
  * though neither script imports the other.
1017
1018
  * @returns {string[]}
@@ -797,11 +797,19 @@ const round4 = (x) => Math.round(x * 1e4) / 1e4;
797
797
  * is cut by date, whatever the working tree's files hold. `order` ranks each cell's generations
798
798
  * over every Pull in the window, the restriction aside, so the fit names the
799
799
  * same newest generation the guard does. No unit is in a group yet: `book`
800
- * puts each where a tree walks its features row.
800
+ * puts each where a tree walks its features row. `cells` are the Cells the fit judges: the starting set of
801
+ * `baseline` in its own order, then each other Cell that holds counted Pulls among these units on its newest generation,
802
+ * by name. It is rebuilt from the records at every fit, so a Cell exploration has drawn is judged for as long as the
803
+ * records hold its Pulls. `tallies` is tally()'s of these units under `order`, which growTree searches.
801
804
  */
802
- function fitPulls({ features, members, verdicts, window }) {
805
+ function fitPulls({ features, members, verdicts, window, baseline }) {
803
806
  const all = attribute({ features, members, tiers: verdicts, windowStart: window || null });
804
- return { units: all.filter((u) => u.pull.exploration_draw !== "" || u.pull.sizing_src === "rule"), order: generations(all) };
807
+ const units = all.filter((u) => u.pull.exploration_draw !== "" || u.pull.sizing_src === "rule");
808
+ const order = generations(all);
809
+ const set = startingSetOf(baseline);
810
+ const tallies = tally(units, order);
811
+ const drawn = tallies.filter((t) => t.n > 0 && !set.includes(t.cell)).map((t) => t.cell);
812
+ return { units, order, tallies, cells: [...set, ...drawn] };
805
813
  }
806
814
 
807
815
  /** `units`, each booked to the group `table`'s tree walks its features row to (stratumOf). */
@@ -1014,7 +1022,8 @@ function judgeSpeedRow(pulls, cells, excluded, base, baseline) {
1014
1022
  * The re-fit table, over the tree `prior.splits` holds: this makes no split
1015
1023
  * and takes none away (fitTree grows the tree). `guard` is `{ tripped, n, shared, window_start }` (readGuard's
1016
1024
  * shape). `baseline` is the run's Baseline Cell, which the table records as `baseline_cell`: its `cells` are the
1017
- * Baseline Cell's starting set (startingSetOf), the Cells the fit judges, and the fit adds no Cell. `rows` and
1025
+ * Cells the fit judges (fitPulls'): the Baseline Cell's starting set (startingSetOf) and every other Cell that holds
1026
+ * counted Pulls among the fit's own, so a Cell exploration has drawn is judged and may hold a row. `rows` and
1018
1027
  * `reasons` hold one set per
1019
1028
  * objective, and each a row or record for every node. `reasons.cost` holds
1020
1029
  * `judgeRow()`'s record, judged with the Cells `cost` excludes, its `cell` the cell the node's `cost` row holds: a
@@ -1033,18 +1042,19 @@ function judgeSpeedRow(pulls, cells, excluded, base, baseline) {
1033
1042
  * the whole starting set when absent — and the table records them as `starting_cells`, so
1034
1043
  * the records, the guard, the prior and that set fit the same table again.
1035
1044
  * Throws on a `startingCells` that is empty, which would end burn-in on no
1036
- * count at all, or that names a Cell that is no starting Cell of `baseline`.
1045
+ * count at all, that names a Cell that is no starting Cell of `baseline`, or that names one twice, which
1046
+ * validateTable would refuse in `starting_cells`.
1037
1047
  */
1038
1048
  export function fitTable({ prior, features, members, verdicts, guard, baseline = DEFAULT_BASELINE_CELL, startingCells = startingSetOf(baseline) }) {
1039
1049
  const window = guard.window_start ?? prior.window_start ?? null;
1040
- return tableOver({ prior, ...fitPulls({ features, members, verdicts, window }), guard, window, baseline, startingCells });
1050
+ return tableOver({ prior, ...fitPulls({ features, members, verdicts, window, baseline }), guard, window, baseline, startingCells });
1041
1051
  }
1042
1052
 
1043
- // The table over the tree `prior.splits` holds, from the fit's Pulls (fitPulls') booked to its groups.
1044
- function tableOver({ prior, units: unbooked, order, guard, window, baseline, startingCells }) {
1053
+ // The table over the tree `prior.splits` holds, from the fit's Pulls (fitPulls') booked to its groups, judged over `cells`.
1054
+ function tableOver({ prior, units: unbooked, order, cells, guard, window, baseline, startingCells }) {
1045
1055
  const set = startingSetOf(baseline);
1046
- if (startingCells.length === 0 || !startingCells.every((c) => set.includes(c))) {
1047
- throw new Error(`startingCells is not a non-empty list of starting Cells: ${JSON.stringify(startingCells)}`);
1056
+ if (startingCells.length === 0 || !startingCells.every((c) => set.includes(c)) || new Set(startingCells).size !== startingCells.length) {
1057
+ throw new Error(`startingCells is not a non-empty list of starting Cells, each once: ${JSON.stringify(startingCells)}`);
1048
1058
  }
1049
1059
  const nodes = treeNodes(prior.splits);
1050
1060
  const units = book(unbooked, prior);
@@ -1056,12 +1066,12 @@ function tableOver({ prior, units: unbooked, order, guard, window, baseline, sta
1056
1066
  const reasons = { cost: {}, speed: {} };
1057
1067
  for (const s of nodes) {
1058
1068
  const up = parentOf(s);
1059
- const cost = judgeRow(pulls[s], set, out.cost, baseline);
1069
+ const cost = judgeRow(pulls[s], cells, out.cost, baseline);
1060
1070
  const own = cost.cell !== null || up === null;
1061
1071
  const costCell = cost.cell ?? (up === null ? baseline : rows.cost[up]);
1062
1072
  // `speed` starts from, and falls back to, the `cost` row's Cell as its own exclusions leave it.
1063
1073
  const speedBase = out.speed.has(costCell) ? baseline : costCell;
1064
- const speed = own ? judgeSpeedRow(pulls[s], set, out.speed, speedBase, baseline) : unjudged();
1074
+ const speed = own ? judgeSpeedRow(pulls[s], cells, out.speed, speedBase, baseline) : unjudged();
1065
1075
  const speedCell = speed.cell ?? (own ? speedBase : rows.speed[up]);
1066
1076
  rows.cost[s] = costCell;
1067
1077
  rows.speed[s] = speedCell;
@@ -1073,7 +1083,7 @@ function tableOver({ prior, units: unbooked, order, guard, window, baseline, sta
1073
1083
  window_start: window,
1074
1084
  n_rows: units.length,
1075
1085
  baseline_cell: baseline,
1076
- cells: [...set],
1086
+ cells,
1077
1087
  burn_in: anyStartingCellShort(guard, startingCells, baseline),
1078
1088
  starting_cells: [...startingCells],
1079
1089
  splits: prior.splits,
@@ -1135,8 +1145,9 @@ function treeOf(cuts) {
1135
1145
  }
1136
1146
 
1137
1147
  /**
1138
- * The tree the fit grows, and what the gate found. The group searched is every counted Pull of the run's starting set
1139
- * (`baseline`'s) that the guard has not tripped on a reason `cost` excludes (`excluded`: one tree serves both
1148
+ * The tree the fit grows, and what the gate found. The group searched is every counted Pull (`tallies`, fitPulls') of
1149
+ * the Cells the fit judges (`cells`, fitPulls': the run's starting set and every Cell exploration has drawn) that the guard has not
1150
+ * tripped on a reason `cost` excludes (`excluded`: one tree serves both
1140
1151
  * Objectives and is scored on $, so a Cell tripped on `minutes` alone stays in the search), that records the
1141
1152
  * probability its Cell was assigned with (the rest are `left_out`): the gate
1142
1153
  * weighs each Pull by it. `previous` is the `gate` record of the last Fit that computed, or null. The tree is the root
@@ -1146,11 +1157,11 @@ function treeOf(cuts) {
1146
1157
  * keeps that Fit's `passed` and `stands`, and a first pass cannot stand on the same records twice. `gate.passed`,
1147
1158
  * `gate.stands` and `gate.records` are what the next Fit reads.
1148
1159
  */
1149
- function growTree({ units, order, excluded, previous, baseline }) {
1150
- const cells = [baseline, ...startingSetOf(baseline).filter((c) => c !== baseline && !excluded.has(c))];
1160
+ function growTree({ tallies, cells: judged, excluded, previous, baseline }) {
1161
+ const cells = [baseline, ...judged.filter((c) => c !== baseline && !excluded.has(c))];
1151
1162
  const pulls = [];
1152
1163
  let leftOut = 0;
1153
- for (const { pulls: counted } of tally(units, order).filter((t) => cells.includes(t.cell))) {
1164
+ for (const { pulls: counted } of tallies.filter((t) => cells.includes(t.cell))) {
1154
1165
  for (const u of counted) {
1155
1166
  const prob = probabilityOf(u.pull);
1156
1167
  if (prob === null) {
@@ -1195,7 +1206,7 @@ function growTree({ units, order, excluded, previous, baseline }) {
1195
1206
  */
1196
1207
  export function fitTree({ prior, features, members, verdicts, guard, previous = null, baseline = DEFAULT_BASELINE_CELL, startingCells = startingSetOf(baseline) }) {
1197
1208
  const window = guard.window_start ?? prior.window_start ?? null;
1198
- const fitted = fitPulls({ features, members, verdicts, window });
1209
+ const fitted = fitPulls({ features, members, verdicts, window, baseline });
1199
1210
  const { gate, splits } = growTree({ ...fitted, excluded: new Set(excludedCells(guard.tripped, "cost")), previous, baseline });
1200
1211
  return { table: tableOver({ prior: { ...prior, splits }, ...fitted, guard, window, baseline, startingCells }), gate };
1201
1212
  }