@feigi/fleet-ctl 3.143.4 → 3.144.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.
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  // The per-ticket router: which implementer cell a Pull dispatches. One script
3
- // for dispatch and for the offline fit, because the stratum rule is the one
4
- // function that must never read differently between the two.
3
+ // for dispatch and for the offline fit, because the walk from a ticket's inputs
4
+ // to its group is the one function that must never read differently between
5
+ // the two.
5
6
  //
6
7
  // route [--session <dir|id>] [--objective cost|speed] --ticket <N> --arm A|B
7
8
  // --impl-row <k> --issue <issue.json> --guard <cost-guard.json>
@@ -9,7 +10,7 @@
9
10
  // [--chain-head] [--pending <tsv>]
10
11
  // Prints one line, the Pull's Routing (ledger-grammar.mjs owns its
11
12
  // grammar): `POLICY=<cell> CELL=<cell> DRAW=<k/K|-> BY=<burn-in|every-5th|->
12
- // STRATUM=<light|heavy|unknown> BRIEF=<chars|-> CRITERIA=<n|-> PARENT=<N|->
13
+ // STRATUM=<rule path> BRIEF=<chars|-> CRITERIA=<n|-> PARENT=<N|->
13
14
  // SIZED=<light|heavy|-> OBJECTIVE=<cost|speed> TRIPPED=<cell,…|->
14
15
  // REASON=<reason>`,
15
16
  // routing by the objective's row set, and appends the Pull's
@@ -53,7 +54,7 @@ import { isDeepStrictEqual } from "node:util";
53
54
  import { isCLI } from "./is-cli.mjs";
54
55
  import { gitEnv } from "./git-env.mjs";
55
56
  import { makeDie, defineFlags } from "./arg.mjs";
56
- import { CELL, OBJECTIVES, POLICY_CELL, STRATA, drawCell, formatRouting, parseMember } from "./ledger-grammar.mjs";
57
+ import { CELL, OBJECTIVES, POLICY_CELL, drawCell, formatRouting, isRulePath, parseMember } from "./ledger-grammar.mjs";
57
58
  import { objectiveFromReceipt, sessionFromReceipt } from "./phase0-receipt.mjs";
58
59
  import { parseTsv as parseMemberTsv } from "./member-outcomes.mjs";
59
60
  import {
@@ -68,10 +69,6 @@ export const DEFAULT_TABLE = join(SCRIPT_DIR, "router-table.json");
68
69
  // The install's own package.json, whose `version` names the plugin a Pull was routed by.
69
70
  export const INSTALL_PACKAGE = join(SCRIPT_DIR, "..", "package.json");
70
71
 
71
- // The free classifier's thresholds: heavy past the median brief length of
72
- // the tickets whose sizing verdict is known, or past five criteria.
73
- export const HEAVY_BRIEF_CHARS = 3483;
74
- export const HEAVY_CRITERIA = 5;
75
72
  // Exploration cadence after burn-in: the Pull that creates `impl-` row 5k.
76
73
  const EXPLORE_EVERY = 5;
77
74
  // The fit's adoption floor (merged PRs per side), margin, and cadence.
@@ -208,22 +205,93 @@ export function namedLines(named, root) {
208
205
  return paths.map((p) => lineEntry(p, abs, realRoot)).join(" ");
209
206
  }
210
207
 
208
+ // ---------------------------------------------------------------------------
209
+ // the tree — which group a ticket falls in
210
+ // ---------------------------------------------------------------------------
211
+
212
+ // The table's groups are the nodes of a tree of splits on what is known of a
213
+ // ticket at dispatch. A group is named by its rule path (ledger-grammar.mjs
214
+ // says how a path reads): `*` is the root, the group of every ticket before any
215
+ // split, and a node's two children are named by the node's path and the test
216
+ // each takes, joined by `&`. `splits` holds the tree, keyed by the path of the
217
+ // node a split sits at:
218
+ //
219
+ // "splits": { "*": { "input": "brief_chars", "cut": 4047 } }
220
+ //
221
+ // A split reads one input, a ticket-features column, and sends a ticket to one
222
+ // of its two children. For an input that reads as a number, a ticket past the
223
+ // cut goes to `<input>><cut>` and any other to `<input><=<cut>`; for `kind`, a
224
+ // ticket of the cut's kind goes to `kind=<cut>` and any other to
225
+ // `kind!=<cut>`. A ticket that lacks the input a split reads — its issue was not
226
+ // read, or its column is blank — goes no further than that node, and the
227
+ // node's own row routes it. Every node, inner nodes and root included, holds a
228
+ // `cost` row and a `speed` row of its own, and its estimates and reasons. A
229
+ // table with no split is the one-node tree: `*` routes every ticket.
230
+
231
+ const SEP = "&";
232
+ // Each input a split may read, and what it reads as: the columns of a ticket-features row that are known at
233
+ // dispatch and are a count or a kind. `parent` reads as the Slice's parent number, and 0 for an issue read that
234
+ // names none, so a cut at 0 splits Slices from the rest. The brief's paths, its title and the install's version
235
+ // are no input: no cut of theirs is defined.
236
+ const INPUTS = Object.freeze({
237
+ brief_chars: "number", criteria: "number", comments: "number", age_days: "number", paths: "number", test_paths: "number", xrefs: "number", dirs: "number",
238
+ parent: "number", kind: "kind",
239
+ });
240
+
241
+ /** What a ticket holds for `input` — a number, or a kind — or null where it lacks it: its issue was not read, or its column is blank. */
242
+ function inputOf(input, m) {
243
+ // A row whose issue was not read has blank metrics, `brief_chars` among them: it holds none of the inputs.
244
+ if (m.brief_chars === undefined || m.brief_chars === "") return null;
245
+ const s = m[input] ?? "";
246
+ if (input === "kind") return s === "" ? null : s;
247
+ if (input === "parent" && s === "") return 0;
248
+ const n = s === "" ? NaN : Number(s);
249
+ return Number.isFinite(n) ? n : null;
250
+ }
251
+
252
+ const child = (node, test) => (node === "*" ? test : `${node}${SEP}${test}`);
253
+ /** The two children of the split at `node`, the group a test holds for first. */
254
+ function childrenOf(node, { input, cut }) {
255
+ return (INPUTS[input] === "kind" ? [`kind=${cut}`, `kind!=${cut}`] : [`${input}>${cut}`, `${input}<=${cut}`]).map((test) => child(node, test));
256
+ }
257
+ /** The path of `node`'s parent, null for the root. */
258
+ const parentOf = (node) => (node === "*" ? null : node.includes(SEP) ? node.slice(0, node.lastIndexOf(SEP)) : "*");
259
+
260
+ /** The nodes of the tree `splits` holds, root first, then each split's two children, depth first. */
261
+ function treeNodes(splits) {
262
+ const nodes = [];
263
+ const down = (node) => {
264
+ nodes.push(node);
265
+ if (Object.hasOwn(splits, node)) for (const c of childrenOf(node, splits[node])) down(c);
266
+ };
267
+ down("*");
268
+ return nodes;
269
+ }
270
+
211
271
  /**
212
- * The `rule` classifier, over a row's metric columns: blank metrics are
213
- * `unknown`, a Slice (a row with a `parent`) is `heavy`, and any other row is
214
- * `heavy` past the brief length or the criteria count. A Slice whose metrics
215
- * are blank stays `unknown`, as it was routed: its issue was not read then.
272
+ * The group a ticket falls in: from the root, each split sends it to the child
273
+ * its input says, until a node has no split or the ticket lacks the input the
274
+ * node's split reads. `m` is the ticket's metrics row, the columns `issueMetrics`
275
+ * makes or a ticket-features file holds, as strings.
216
276
  */
217
- export function ruleStratum({ brief_chars, criteria, parent }) {
218
- if (brief_chars === "" || brief_chars === undefined || criteria === "" || criteria === undefined) return "unknown";
219
- if (parent) return "heavy";
220
- return Number(brief_chars) > HEAVY_BRIEF_CHARS || Number(criteria) > HEAVY_CRITERIA ? "heavy" : "light";
277
+ export function stratumOf(table, m) {
278
+ let node = "*";
279
+ while (Object.hasOwn(table.splits, node)) {
280
+ const split = table.splits[node];
281
+ const v = inputOf(split.input, m);
282
+ if (v === null) break;
283
+ const [holds, other] = childrenOf(node, split);
284
+ node = (INPUTS[split.input] === "kind" ? v === split.cut : v > split.cut) ? holds : other;
285
+ }
286
+ return node;
221
287
  }
222
288
 
223
289
  // ---------------------------------------------------------------------------
224
290
  // the table
225
291
  // ---------------------------------------------------------------------------
226
292
 
293
+ const shown = (x) => (typeof x === "number" ? String(x) : JSON.stringify(x));
294
+
227
295
  /** A parsed table, or an Error saying why it is not one. */
228
296
  export function validateTable(t) {
229
297
  const bad = (why) => new Error(`router table: ${why}`);
@@ -232,7 +300,26 @@ export function validateTable(t) {
232
300
  if (!Array.isArray(t.cells) || t.cells.length === 0) return bad("`cells` is not a non-empty array");
233
301
  for (const c of t.cells) if (typeof c !== "string" || !CELL.test(c)) return bad(`\`cells\` holds ${JSON.stringify(c)}, not a cell token`);
234
302
  if (new Set(t.cells).size !== t.cells.length) return bad("`cells` repeats a cell");
235
- // `rows` and `reasons` are each keyed by objective, then by `*` or a stratum.
303
+ // The tree: each split reads an input a split may read, at a cut that input can take, and sits at a node of the
304
+ // tree the other splits make.
305
+ if (!isObject(t.splits)) return bad("`splits` is not an object");
306
+ for (const [path, s] of Object.entries(t.splits)) {
307
+ const at = `splits[${JSON.stringify(path)}]`;
308
+ if (!isObject(s)) return bad(`\`${at}\` is not \`{ input, cut }\``);
309
+ if (typeof s.input !== "string" || !Object.hasOwn(INPUTS, s.input)) return bad(`\`${at}\` reads ${shown(s.input)}, which no split can read`);
310
+ const number = INPUTS[s.input] === "number";
311
+ // A number is a cut when the rule path it makes is one the Routing line can carry: no NaN, sign or exponent.
312
+ if (number ? typeof s.cut !== "number" || !isRulePath(childrenOf("*", s)[0]) : !KINDS.has(s.cut)) {
313
+ return bad(`\`${at}\` cuts ${s.input} at ${shown(s.cut)}, which is not ${number ? "a non-negative number" : "a ticket kind"}`);
314
+ }
315
+ if (Object.keys(s).length !== 2) return bad(`\`${at}\` is not \`{ input, cut }\``);
316
+ }
317
+ const nodes = treeNodes(t.splits);
318
+ // The first key of `o` that names no node of the tree.
319
+ const offTree = (o) => Object.keys(o).find((key) => !nodes.includes(key));
320
+ const unreached = offTree(t.splits);
321
+ if (unreached !== undefined) return bad(`\`splits[${JSON.stringify(unreached)}]\` sits at no node of the tree`);
322
+ // `rows` and `reasons` are each keyed by objective, then by the nodes of the tree.
236
323
  for (const field of ["rows", "reasons"]) {
237
324
  if (!isObject(t[field])) return bad(`\`${field}\` is not an object`);
238
325
  const stray = Object.keys(t[field]).find((o) => !OBJECTIVES.includes(o));
@@ -240,13 +327,18 @@ export function validateTable(t) {
240
327
  for (const o of OBJECTIVES) {
241
328
  const set = t[field][o];
242
329
  if (!isObject(set)) return bad(`\`${field}.${o}\` is not an object`);
243
- for (const k of Object.keys(set)) {
244
- if (k !== "*" && !STRATA.includes(k)) return bad(`\`${field}.${o}\` key ${JSON.stringify(k)} is not \`*\` or a stratum`);
245
- }
330
+ const k = offTree(set);
331
+ if (k !== undefined) return bad(`\`${field}.${o}\` key ${JSON.stringify(k)} is not a node of the tree`);
246
332
  }
247
333
  }
334
+ if (isObject(t.estimates)) {
335
+ const k = offTree(t.estimates);
336
+ if (k !== undefined) return bad(`\`estimates\` key ${JSON.stringify(k)} is not a node of the tree`);
337
+ }
248
338
  for (const o of OBJECTIVES) {
249
- if (!Object.hasOwn(t.rows[o], "*")) return bad(`\`rows.${o}\` has no \`*\` row`);
339
+ for (const node of nodes) {
340
+ if (!Object.hasOwn(t.rows[o], node)) return bad(node === "*" ? `\`rows.${o}\` has no \`*\` row` : `\`rows.${o}\` has no row for ${JSON.stringify(node)}`);
341
+ }
250
342
  for (const [k, v] of Object.entries(t.rows[o])) {
251
343
  if (typeof v !== "string" || !CELL.test(v)) return bad(`\`rows.${o}.${k}\` is ${JSON.stringify(v)}, not a cell token`);
252
344
  }
@@ -273,7 +365,7 @@ export function bArmLive(table, objective) {
273
365
  return table.classifier.b !== null && Object.values(table.rows[objective]).some((c) => c !== POLICY_CELL);
274
366
  }
275
367
 
276
- /** The row a stratum routes by: its own, else the `*` row's. */
368
+ /** The row a group routes by: its own, else the `*` row's — as a name no node of the table holds does, such as a group a Routing filed under another table names. */
277
369
  export const rowFor = (rows, stratum) => rows[stratum] ?? rows["*"];
278
370
 
279
371
  /**
@@ -338,14 +430,12 @@ export function readGuard(raw) {
338
430
  return r.ok ? r.guard : null;
339
431
  }
340
432
 
341
- /** The sizing verdict on a live B Pull: `{ stratum, src, label, usd }`, or null when it is unusable. */
433
+ /** The sizing verdict on a live B Pull: `{ src, label, usd }`, or null when it is unusable. */
342
434
  function readSizing(raw, classifier) {
343
435
  if (raw === null || typeof raw !== "object" || raw.source !== classifier.b) return null;
344
436
  const label = raw.label === "light" || raw.label === "heavy" ? raw.label : null;
345
437
  if (label === null) return null;
346
- const abstains = raw.source === "jev" && classifier.tau !== null && !(Number(raw.confidence) >= classifier.tau);
347
438
  return {
348
- stratum: abstains ? "unknown" : label,
349
439
  src: raw.source === "jev" ? `jev:${raw.model ?? ""}` : "haiku",
350
440
  label,
351
441
  usd: Number.isFinite(raw.usd) ? String(raw.usd) : "",
@@ -361,10 +451,12 @@ export function sessionDate(session) {
361
451
  * One Pull's routing, by `objective`'s row set. Every input is already read
362
452
  * but the paths the brief names, which `named_lines` reads under `root`, the
363
453
  * checkout. `version` is the install's, `plugin_version` on the row. The
364
- * exploration draw ignores the objective: it leaves out the cell
365
- * the `cost` set routes the Pull to — by the sizing when arm B is live for
366
- * the `cost` set, whichever set routes the Pull — so a Pull draws the same
367
- * cell under both.
454
+ * ticket's group is the node the tree's walk ends at (stratumOf), and the row
455
+ * set's row for it routes the Pull. The exploration draw ignores the objective:
456
+ * it leaves out the cell the `cost` set routes the group to, whichever set
457
+ * routes the Pull, so a Pull draws the same cell under both. A live B Pull
458
+ * records its sizing verdict and routes as an A Pull does: a label names no
459
+ * group of the tree.
368
460
  * @returns {{ line: string, row: Record<string,string> }}
369
461
  */
370
462
  export function route({
@@ -380,35 +472,29 @@ export function route({
380
472
  .slice(FEATURE_COLUMNS.indexOf("brief_chars"), FEATURE_COLUMNS.indexOf("plugin_version"))
381
473
  .filter((c) => c !== "objective").map((c) => [c, ""]));
382
474
  const m = metrics === null ? blank : { ...metrics, named_lines: namedLines(metrics.named_paths, root) };
383
- const ruleS = ruleStratum(m);
475
+ const stratum = stratumOf(table, m);
384
476
 
385
- let stratum = ruleS;
386
477
  let sizingSrc = "rule";
387
478
  let sizingPre = "";
388
479
  let routerUsd = "";
389
- const sized = arm === "B" ? readSizing(sizing, table.classifier) : null;
390
- const b = arm === "B" && bArmLive(table, objective);
391
- if (b) {
392
- const s = sized;
393
- if (s === null) {
480
+ if (arm === "B" && bArmLive(table, objective)) {
481
+ const sized = readSizing(sizing, table.classifier);
482
+ if (sized === null) {
394
483
  degrade("no-sizing");
395
- stratum = "unknown";
396
484
  sizingSrc = "";
397
485
  } else {
398
- ({ stratum, src: sizingSrc, label: sizingPre, usd: routerUsd } = s);
486
+ ({ src: sizingSrc, label: sizingPre, usd: routerUsd } = sized);
399
487
  }
400
488
  }
401
489
 
402
- const dispatch = (o, s) => rowDispatch({ table, guard, objective: o, stratum: s });
403
- const policyRow = dispatch(objective, ruleS);
404
- const baseRow = b ? dispatch(objective, stratum) : policyRow;
405
- const costB = arm === "B" && bArmLive(table, "cost");
406
- const drawRow = dispatch("cost", costB ? sized?.stratum ?? "unknown" : ruleS);
407
- for (const r of [policyRow.reason, baseRow.reason]) if (r !== "ok") degrade(r);
490
+ const dispatch = (o) => rowDispatch({ table, guard, objective: o, stratum });
491
+ const policyRow = dispatch(objective);
492
+ const drawRow = dispatch("cost");
493
+ if (policyRow.reason !== "ok") degrade(policyRow.reason);
408
494
  // With no guard the default cell is the only one: the guard cannot be
409
495
  // evaded by deleting it.
410
496
  const policy = policyRow.policy;
411
- let cell = baseRow.policy;
497
+ let cell = policy;
412
498
  let draw = null;
413
499
  let by = null;
414
500
  if (guard !== null) {
@@ -455,35 +541,39 @@ const round4 = (x) => Math.round(x * 1e4) / 1e4;
455
541
 
456
542
  /**
457
543
  * The fit's Pulls: pull-attribution.mjs's units over the window — booked as
458
- * routed, each to its own row's cell and stratum — restricted to rows the free
459
- * classifier routed plus exploration rows: a row a live B classifier routed is
460
- * the A/B's test set, not the fit's. The fit sees no PR state, so a Pull with
544
+ * routed, each to its own row's cell and group, `stratum` the walk from a
545
+ * features row to its group — restricted to rows the free classifier routed
546
+ * plus exploration rows: a row a live B classifier routed is the A/B's test
547
+ * set, not the fit's. The fit sees no PR state, so a Pull with
461
548
  * a Ruling is merged. A fit reads everything in the commit it is given: no row
462
549
  * is cut by date, because `--check` re-reads that same commit rather than
463
550
  * re-cutting the working tree's files. `order` ranks each cell's generations
464
551
  * over every Pull in the window, the restriction aside, so the fit names the
465
552
  * same newest generation the guard does.
466
553
  */
467
- function fitPulls({ features, members, verdicts, window }) {
468
- const all = attribute({ features, members, tiers: verdicts, windowStart: window || null, stratum: ruleStratum });
554
+ function fitPulls({ features, members, verdicts, window, stratum }) {
555
+ const all = attribute({ features, members, tiers: verdicts, windowStart: window || null, stratum });
469
556
  return { units: all.filter((u) => u.pull.exploration_draw !== "" || u.pull.sizing_src === "rule"), order: generations(all) };
470
557
  }
471
558
 
472
- // Per stratum and `*`, per cell, its newest generation's figures: `n` counted
559
+ // Per node of the tree, per cell, its newest generation's figures: `n` counted
473
560
  // Pulls, `merged`, $ per merged PR, minutes of work time per merged PR, false
474
561
  // claims over claims, fix rounds per merged PR, `by_hand` (the counted merged Pulls whose
475
562
  // Ruling was given by hand), and its left-out, unpriced and
476
563
  // untimed Pull counts. Both per merged PR figures take every counted Pull,
477
564
  // merged or not, over the merged ones. Beside them the cell's
478
565
  // excluded Pull count, `generation` naming the newest generation's model, and
479
- // `older`, each older generation's model to its figures, newest first. Beside
480
- // `estimates`, `pulls`: per stratum and `*`, per cell, the newest generation's
481
- // counted Pulls those figures are over.
482
- function estimate(units, order) {
566
+ // `older`, each older generation's model to its figures, newest first. A node's
567
+ // Pulls are those that went through it: the Pulls of its own group and of each
568
+ // group below it, so the root's are every Pull's. A node no Pull went through
569
+ // has none. Beside `estimates`, `pulls`: per node, per cell, the newest
570
+ // generation's counted Pulls those figures are over.
571
+ function estimate(units, order, nodes) {
483
572
  const estimates = {};
484
573
  const pulls = {};
485
- for (const s of units.length ? [...new Set([...units.map((u) => u.stratum), "*"])].sort() : []) {
486
- const mine = s === "*" ? units : units.filter((u) => u.stratum === s);
574
+ for (const s of nodes) {
575
+ const mine = s === "*" ? units : units.filter((u) => u.stratum === s || u.stratum.startsWith(`${s}${SEP}`));
576
+ if (mine.length === 0) continue;
487
577
  estimates[s] = {};
488
578
  pulls[s] = {};
489
579
  for (const t of tally(mine, order)) {
@@ -539,7 +629,7 @@ const JUDGE = Object.freeze({
539
629
  const unjudged = () => ({ cell: null, reason: "unjudged", cells: {}, pairs: [] });
540
630
 
541
631
  /**
542
- * One row's cell under one objective — the `*` row's or a stratum's — and
632
+ * One row's cell under one objective — a node's of the tree — and
543
633
  * why. The quality floor is held twice: pooled by the guard, whose trip takes
544
634
  * a cell out of every row and out of the exploration draw, and per row by the
545
635
  * fit, which refuses a cell under the floor that row alone. The floor is
@@ -641,45 +731,43 @@ function judgeSpeedRow(est, pulls, cells, tripped, costCell) {
641
731
  }
642
732
 
643
733
  /**
644
- * The re-fit table. `guard` is `{ tripped, n, window_start }` (readGuard's
734
+ * The re-fit table, over the tree `prior.splits` holds: the fit makes no split
735
+ * and takes none away. `guard` is `{ tripped, n, window_start }` (readGuard's
645
736
  * shape); `commit` is the sha of the commit the inputs were read from, or null
646
737
  * for the empty corpus before any fit. `rows` and `reasons` hold one set per
647
- * objective. `reasons.cost` holds `judgeRow()`'s record for `*` and for each
648
- * stratum with Pulls; a stratum whose record has no cell gets no `cost` row
649
- * and follows `*`, and an unjudged `*` is the default cell. `reasons.speed`
650
- * holds `judgeSpeedRow()`'s record for each row with a `cost` row, from that
651
- * row's cell, and an `unjudged` record with no cell for each stratum with no
652
- * `cost` row: a row with a `cost` row holds a `speed` row, the base when the
653
- * record has no cell, and a stratum with no `cost` row has no `speed` row
654
- * and follows `*`.
738
+ * objective, and each a row or record for every node. `reasons.cost` holds
739
+ * `judgeRow()`'s record, its `cell` the cell the node's `cost` row holds: a
740
+ * node whose record has no cell holds its parent's `cost` row, as a ticket
741
+ * there follows the parent, and an unjudged root holds the default cell.
742
+ * `reasons.speed` holds `judgeSpeedRow()`'s record for each node with a `cost`
743
+ * row of its own (the root always has one), from that row's cell, the base when
744
+ * the record has no cell; a node with none holds its parent's `speed` row and
745
+ * an `unjudged` record.
655
746
  */
656
747
  export function fitTable({ prior, features, members, verdicts, guard, commit = null }) {
657
748
  const window = guard.window_start ?? prior.window_start ?? null;
658
- const { units, order } = fitPulls({ features, members, verdicts, window });
659
- const { estimates, pulls } = estimate(units, order);
749
+ const nodes = treeNodes(prior.splits);
750
+ const { units, order } = fitPulls({ features, members, verdicts, window, stratum: (row) => stratumOf(prior, row) });
751
+ const { estimates, pulls } = estimate(units, order, nodes);
660
752
  const tripped = new Set(guard.tripped);
661
753
 
662
754
  let { stage, cells } = prior;
663
755
  cells = [...cells];
664
756
  // The rows and their reasons over `cells`: a fitted table's `reasons` cover exactly its `cells`.
665
757
  const judgeRows = () => {
666
- const star = judgeRow(estimates["*"], pulls["*"], cells, tripped);
667
- const rows = { cost: { "*": star.cell ?? POLICY_CELL }, speed: {} };
668
- const reasons = { cost: { "*": { ...star, cell: rows.cost["*"] } }, speed: {} };
669
- for (const s of STRATA) {
670
- if (!estimates[s]) continue;
671
- reasons.cost[s] = judgeRow(estimates[s], pulls[s], cells, tripped);
672
- if (reasons.cost[s].cell !== null) rows.cost[s] = reasons.cost[s].cell;
673
- }
674
- for (const s of Object.keys(reasons.cost)) {
675
- const costCell = rows.cost[s];
676
- if (costCell === undefined) {
677
- reasons.speed[s] = unjudged();
678
- continue;
679
- }
680
- const record = judgeSpeedRow(estimates[s], pulls[s], cells, tripped, costCell);
681
- rows.speed[s] = record.cell ?? costCell;
682
- reasons.speed[s] = { ...record, cell: rows.speed[s] };
758
+ const rows = { cost: {}, speed: {} };
759
+ const reasons = { cost: {}, speed: {} };
760
+ for (const s of nodes) {
761
+ const up = parentOf(s);
762
+ const cost = judgeRow(estimates[s], pulls[s], cells, tripped);
763
+ const own = cost.cell !== null || up === null;
764
+ const costCell = cost.cell ?? (up === null ? POLICY_CELL : rows.cost[up]);
765
+ const speed = own ? judgeSpeedRow(estimates[s], pulls[s], cells, tripped, costCell) : unjudged();
766
+ const speedCell = speed.cell ?? (own ? costCell : rows.speed[up]);
767
+ rows.cost[s] = costCell;
768
+ rows.speed[s] = speedCell;
769
+ reasons.cost[s] = { ...cost, cell: costCell };
770
+ reasons.speed[s] = { ...speed, cell: speedCell };
683
771
  }
684
772
  return { rows, reasons };
685
773
  };
@@ -701,6 +789,7 @@ export function fitTable({ prior, features, members, verdicts, guard, commit = n
701
789
  stage,
702
790
  cells,
703
791
  burn_in: !cells.every(atN),
792
+ splits: prior.splits,
704
793
  rows,
705
794
  classifier: prior.classifier,
706
795
  estimates,
@@ -721,7 +810,7 @@ export function mergedSince({ table, features, members, verdicts, fitted }) {
721
810
  .filter((u) => u.status === "counted" && u.merged && !read.has(`${u.pull.session}\0${u.pull.agent}`)).length;
722
811
  }
723
812
 
724
- // Each cell's Pull counts over every stratum, as the fit prints them: its
813
+ // Each cell's Pull counts over every Pull, the root's, as the fit prints them: its
725
814
  // newest generation, then each older one.
726
815
  function cellCounts(estimates) {
727
816
  const two = (x) => (x === null ? "-" : x.toFixed(2));
@@ -734,14 +823,13 @@ function cellCounts(estimates) {
734
823
  .join(", ") || "none";
735
824
  }
736
825
 
737
- // One line per row the fit judged or skipped, per objective: its cell (`-`
738
- // for a stratum that follows `*`) and its reason, then each candidate's
739
- // verdict and range.
826
+ // One line per row the fit judged, per objective: its cell and its reason,
827
+ // then each candidate's verdict and range.
740
828
  function rowLines(reasons) {
741
829
  const range = (r) => (r === null ? "" : ` [${r.map((x) => x.toFixed(2)).join(", ")}]`);
742
830
  return Object.entries(reasons).flatMap(([o, set]) => Object.entries(set).map(([s, r]) => {
743
831
  const cells = Object.entries(r.cells).map(([c, x]) => `${c} ${x.verdict}${range(x.range)}`).join(", ");
744
- return `${NAME}: row ${o} ${s} ${r.cell ?? "-"} ${r.reason}${cells ? ` (${cells})` : ""}\n`;
832
+ return `${NAME}: row ${o} ${s} ${r.cell} ${r.reason}${cells ? ` (${cells})` : ""}\n`;
745
833
  })).join("");
746
834
  }
747
835
 
@@ -281,9 +281,9 @@ Any other exit is a halt at duty 2: cause `other`, the receipt as the
281
281
  evidence, no label, and you run none of the script's steps by hand to get past
282
282
  it. The codes are distinct: 1 no usable tree (an occupied path, a failed add,
283
283
  a head that is not your pin, a Recipe that could not be read, a tree dirty
284
- before the Install step), 3 the Install step did not run (exit 126 or 127, a
285
- broken Recipe), 4 the Install step failed, 5 the Install step changed the
286
- tree or left its state unreadable; exit 2 is a refusal with no receipt, a
284
+ before the Install step), 3 the Install step did not run (exit 126 or 127, the
285
+ cause not established), 4 the Install step failed, 5 the Install step changed
286
+ the tree or left its state unreadable; exit 2 is a refusal with no receipt, a
287
287
  refused invocation or a receipt the script could not write. The script
288
288
  removes nothing, so a tree it left behind is removed like any other below.
289
289
 
@@ -464,8 +464,9 @@ straight after its reclaim, and reports it on an `APPLIED evict:` or
464
464
  worktree evict.mjs marked, naming
465
465
  `~/.omp/plugins/node_modules/@feigi/fleet-ctl/scripts/fleet-run evict.mjs --restore <tree> --apply`: run it, then render
466
466
  again. It runs the Install step in the tree as a claim does and refuses as a
467
- claim does. A refused restore leaves the tree evicted: dispatch nothing into
468
- it, report the restore's message, and the row comes up again on the next wake.
467
+ claim does, except that an exit 126 or 127 names no cause. A refused restore
468
+ leaves the tree evicted: dispatch nothing into it, report the restore's
469
+ message, and the row comes up again on the next wake.
469
470
  `render review-runner` and `render finisher` do not refuse: neither member runs
470
471
  code in the claim tree.
471
472