@feigi/fleet-ctl 3.115.0 → 3.116.1

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.115.0",
3
+ "version": "3.116.1",
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": {
@@ -34,11 +34,13 @@ import {
34
34
  isOmpSessionDirName, ompSessionTranscripts, foldOmpTranscript, ompMemberRecord,
35
35
  } from "./member-record.mjs";
36
36
  import { readReceipt } from "./phase0-receipt.mjs";
37
- import { RECEIPT, CLOSEOUT_RECEIPT } from "./ledger-grammar.mjs";
37
+ import { RECEIPT, RECEIPT_HELD, CLOSEOUT_RECEIPT } from "./ledger-grammar.mjs";
38
38
  import { NAME, warnOnce, execRead } from "./board-common.mjs";
39
39
  import { mergedReadPrs, issuesOfPrs } from "./compute-board.mjs";
40
40
  import { readCostGuard } from "./fleet-tick.mjs";
41
41
  import { parseFrontmatter } from "./tier-roles.mjs";
42
+ import { isImplementer } from "./member-outcomes.mjs";
43
+ import { validateTable } from "./ticket-router.mjs";
42
44
  // The heartbeat's liveness mark and the controller record beside it, read here
43
45
  // and never written: the heartbeat is the mark's only writer and
44
46
  // `ledger.mjs rotate` the record's. stallOwner() reads the process table to
@@ -490,7 +492,12 @@ export function receiptSpendDir(stateDir) {
490
492
  // truthiness check returning, because nothing in the data says which field is
491
493
  // the tag. This follows `ledger.mjs`'s `tracker`: a boolean checked before any
492
494
  // success-only field is read.
493
- export function gatherSpend({ dir, sinceMs = null, topN = 8, explicit = false } = {}) {
495
+ //
496
+ // `implementers`, when the caller hands in a Map, receives each implementer
497
+ // transcript's dispatch record (implementerRecord below) by member name, from
498
+ // the same fold the spend is read off: the cards' Cell lines read it, and the
499
+ // return value stays the panel's alone.
500
+ export function gatherSpend({ dir, sinceMs = null, topN = 8, explicit = false, implementers = null } = {}) {
494
501
  try {
495
502
  // `dir` is the caller's resolution, never one made here: the operator's
496
503
  // --spend-dir, or the session the phase-0 receipt records
@@ -533,7 +540,7 @@ export function gatherSpend({ dir, sinceMs = null, topN = 8, explicit = false }
533
540
  return { ok: false, error };
534
541
  }
535
542
 
536
- const { agents, toolTables, skipped, damaged } = readOmpSpend(dir, sinceMs);
543
+ const { agents, toolTables, skipped, damaged } = readOmpSpend(dir, sinceMs, implementers);
537
544
  if (!agents.length) {
538
545
  // `damaged` belongs here beside `skipped`. An omp transcript with
539
546
  // no parseable assistant-with-usage line folds to no model, so
@@ -626,17 +633,29 @@ export function gatherSpend({ dir, sinceMs = null, topN = 8, explicit = false }
626
633
  // the transcript regardless of whether the file ends up booked as an agent,
627
634
  // so a transcript that is corrupt where its assistant-with-usage line should
628
635
  // be still surfaces here instead of falling through `if (!m) continue` unseen.
629
- function readOmpSpend(dir, sinceMs) {
636
+ //
637
+ // `sinceMs` is the Tokens window, and it bounds the spend alone: an
638
+ // implementer's transcript older than it is still read into `implementers`,
639
+ // since a card's Cell line is about the card's Pull, not about the window.
640
+ function readOmpSpend(dir, sinceMs, implementers = null) {
630
641
  const agents = [];
631
642
  const toolTables = [];
632
643
  let skipped = 0;
633
644
  let damaged = 0;
634
645
  for (const { file, agent, spawnDepth } of ompSessionTranscripts(dir)) {
646
+ let outside = false;
635
647
  try {
636
- if (sinceMs != null && statSync(file).mtimeMs < sinceMs) continue;
648
+ outside = sinceMs != null && statSync(file).mtimeMs < sinceMs;
649
+ const wanted = implementers !== null && isImplementer(agent);
650
+ if (outside && !wanted) continue;
637
651
  const folded = foldOmpTranscript(readFileSync(file, "utf8"), file);
638
- damaged += folded.malformedNonLastLines;
652
+ if (outside) damagedRecord(file, folded);
653
+ else damaged += folded.malformedNonLastLines;
639
654
  const m = ompMemberRecord(folded, agent, spawnDepth);
655
+ if (outside) {
656
+ if (m) implementers.set(m.member, implementerRecord(m));
657
+ continue;
658
+ }
640
659
  if (!m) continue;
641
660
  // Both halves before either is recorded, so `skipped++` below always
642
661
  // means "this transcript contributed nothing".
@@ -646,8 +665,11 @@ function readOmpSpend(dir, sinceMs) {
646
665
  cacheWrite: m.tokens_cache_create, output: m.tokens_out, cacheRead: m.tokens_cache_read,
647
666
  });
648
667
  toolTables.push(tools);
668
+ if (implementers !== null && isImplementer(m.member)) implementers.set(m.member, implementerRecord(m));
649
669
  } catch (e) {
650
- skipped++;
670
+ // A transcript outside the window was never the spend's, so its
671
+ // failure is warned but not counted.
672
+ if (!outside) skipped++;
651
673
  // The prefix already names `file`; Node's errno text (`..., open|stat
652
674
  // '<file>'`) and member-record's shape refusal (`...: <file>`) end in
653
675
  // it too, so that tail is dropped. Any other wording prints whole.
@@ -661,6 +683,73 @@ function readOmpSpend(dir, sinceMs) {
661
683
  return { agents, toolTables, skipped, damaged };
662
684
  }
663
685
 
686
+ // An implementer's dispatch record, off its member record: the last turn's
687
+ // `model` beside what was fixed at dispatch — `session_init`'s model identity,
688
+ // the harness-written thinking level and the definition it was dispatched as.
689
+ // compute-board.mjs's cellLine reads it the way the figures read an
690
+ // implementer row.
691
+ function implementerRecord(m) {
692
+ return { member: m.member, model: m.model, resolvedModelIdentity: m.resolvedModelIdentity, thinking: m.thinking, subagent_type: m.subagent_type };
693
+ }
694
+
695
+ // Between runs: close-out has moved `phase0.json` to `phase0.previous.json`
696
+ // while `ledger.md` still holds that run's rows, so the cards read the
697
+ // implementer transcripts of the session the held receipt names — the cards
698
+ // only: the spend panel keeps following `phase0.json` (receiptSpendDir). Into
699
+ // `implementers`, as readOmpSpend fills it; a held receipt that is absent,
700
+ // unreadable or names no omp session directory, and a directory not there,
701
+ // add nothing, and an unreadable one says why on stderr. A transcript that
702
+ // will not read is skipped under readOmpSpend's own once-per-file warning,
703
+ // and one with a malformed middle line is warned by damagedRecord.
704
+ export function readHeldImplementers(stateDir, implementers) {
705
+ const held = join(stateDir, RECEIPT_HELD);
706
+ const read = readReceipt(held);
707
+ if (read.state === "unreadable") warnOnce("held-receipt", `${held}\0${read.why}`, `no card reads ${held}: ${read.why}`);
708
+ if (read.state !== "ok" || !isOmpSessionDirName(basename(read.receipt.session))) return;
709
+ let transcripts;
710
+ try { transcripts = ompSessionTranscripts(read.receipt.session); } catch { return; }
711
+ for (const { file, agent, spawnDepth } of transcripts) {
712
+ if (!isImplementer(agent)) continue;
713
+ try {
714
+ const folded = foldOmpTranscript(readFileSync(file, "utf8"), file);
715
+ damagedRecord(file, folded);
716
+ const m = ompMemberRecord(folded, agent, spawnDepth);
717
+ if (m) implementers.set(m.member, implementerRecord(m));
718
+ } catch (e) {
719
+ warnOnce("skips", file, `skipping ${file}: ${e.message}`);
720
+ }
721
+ }
722
+ }
723
+
724
+ // An implementer transcript read for the cards alone, where no spend panel
725
+ // counts it `damaged`: a malformed middle line can drop the turn its model
726
+ // came from, so the card's record is said to be suspect, once per file.
727
+ function damagedRecord(file, folded) {
728
+ if (folded.malformedNonLastLines > 0) {
729
+ warnOnce("damaged-implementer", file, `${file}: ${folded.malformedNonLastLines} malformed line(s) before its last, so its card's model and level may be wrong`);
730
+ }
731
+ }
732
+
733
+ // The installed router table, `router-table.json` beside the scripts, when
734
+ // `validateTable` accepts it, else null: a card words a policy row that has no
735
+ // row for its Stratum ("follows *") only off a table it could read. The table
736
+ // ships beside the scripts, so one that is missing, will not parse or is
737
+ // refused is a broken install, said once on stderr per fault rather than
738
+ // passed off as "no table".
739
+ export function readRouterTable(scriptDir) {
740
+ const file = join(scriptDir, "router-table.json");
741
+ let why;
742
+ try {
743
+ const t = validateTable(JSON.parse(readFileSync(file, "utf8")));
744
+ if (!(t instanceof Error)) return t;
745
+ why = t.message;
746
+ } catch (e) {
747
+ why = String(e.message);
748
+ }
749
+ warnOnce("router-table", `${file}\0${why}`, `router table not read, so no card says "follows *": ${file}: ${why}`);
750
+ return null;
751
+ }
752
+
664
753
  // The Cell evidence tab's reads. Each is the whole of one input, kept apart from
665
754
  // gather() so a test drives it alone; none of them throws, and a failure is
666
755
  // reported in the value, which the tab words.
@@ -961,7 +1050,13 @@ export async function gather({ ledgerFile, prevFile, stateFile = null, stateDir
961
1050
  // The guard's own rationale (fail loud, gate on presence and on range,
962
1051
  // not just finiteness) lives at argSpendSince()'s definition in board.mjs,
963
1052
  // whose main() runs it and hands the answer in as `spendSince`.
964
- const spend = gatherSpend({ dir: spendDir, sinceMs: spendSince, explicit: spendDirExplicit });
1053
+ // Each implementer's dispatch record, for the cards' Cell lines: off the
1054
+ // same transcripts the spend is read from, or — with no `phase0.json`, the
1055
+ // state between runs — off the session `phase0.previous.json` names.
1056
+ const implementers = new Map();
1057
+ const spend = gatherSpend({ dir: spendDir, sinceMs: spendSince, explicit: spendDirExplicit, implementers });
1058
+ if (stateDir !== null && !spendDirExplicit && !existsSync(join(stateDir, RECEIPT))) readHeldImplementers(stateDir, implementers);
1059
+ const routerTable = readRouterTable(scriptDir);
965
1060
  // The heartbeat's mark, raw. readState() never throws — an absent
966
1061
  // file is the ordinary state of a run whose heartbeat has not beaten yet,
967
1062
  // and an unreadable or corrupt one announces itself on stderr and degrades
@@ -1002,6 +1097,6 @@ export async function gather({ ledgerFile, prevFile, stateFile = null, stateDir
1002
1097
  const agents = readAgents(scriptDir);
1003
1098
  const modelRoles = stateDir === null ? heldRead(prev?.modelRoles) : await carryModelRoles(prev?.modelRoles, now);
1004
1099
  return { ledger, issues, prs, merged, closed, closedIssues, ci, prev, repo, repoUrl, workspace, port, spend, beat, ticked, acted, controller, stallOwner: stallOwnerOf, poolOk,
1005
- poolCapped, prsCapped, guard, receipts, agents, modelRoles,
1100
+ poolCapped, prsCapped, guard, receipts, agents, modelRoles, implementers: [...implementers.values()], routerTable,
1006
1101
  now, interval };
1007
1102
  }
@@ -55,6 +55,15 @@
55
55
  .card .n { color:var(--blue); font-weight:600; }
56
56
  .card .title { color:var(--fg); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
57
57
  .card .meta { color:var(--dim); font-size:12px; margin-top:3px; display:flex; gap:8px; flex-wrap:wrap; }
58
+ /* The Cell line: two lines under the meta line, and a third for the mark.
59
+ "not on record" is a hole, drawn dim and italic in its place. */
60
+ .card .cl { color:var(--dim); font-size:12px; margin-top:2px; }
61
+ .card .cl .nr { font-style:italic; opacity:.65; }
62
+ .card .cl.mark.amber { color:var(--amber); }
63
+ .card .cl.mark.red { color:var(--red); }
64
+ .ce-pulls { display:flex; gap:8px; flex-wrap:wrap; font-size:12px; margin-top:4px; }
65
+ .ce-pulls a { color:var(--blue); text-decoration:none; }
66
+ .ce-pulls .red { color:var(--red); }
58
67
  .card a { color:var(--blue); text-decoration:none; }
59
68
  .dot { width:8px; height:8px; border-radius:50%; display:inline-block; vertical-align:middle; }
60
69
  .dot.green{background:var(--green)} .dot.red{background:var(--red)} .dot.unknown{background:var(--dim)}
@@ -391,7 +400,9 @@ function ceOlder(o) {
391
400
  return box;
392
401
  }
393
402
 
394
- // One Cell's entry: its header line, then its figures or "no figures yet".
403
+ // One Cell's entry: its header line, then its figures or "no figures yet", a
404
+ // "no figures yet" for each generation a card links to that has none, its older
405
+ // generations, and this run's Pulls booked to it, each linking to its card.
395
406
  function ceEntry(e) {
396
407
  const box = ceBox("div", "ce-entry", e.anchor);
397
408
  const hd = el("div", "ce-hd");
@@ -409,7 +420,23 @@ function ceEntry(e) {
409
420
  if (e.none.marks.length) none.append(el("span", "ce-beside", " " + e.none.marks.join(", ")));
410
421
  box.append(none);
411
422
  }
423
+ for (const u of e.unfigured || []) {
424
+ const none = ceBox("div", "ce-gen", u.anchor);
425
+ none.append(el("span", "ce-dim", u.text));
426
+ box.append(none);
427
+ }
412
428
  for (const o of e.older) box.append(ceOlder(o));
429
+ if ((e.pulls || []).length) {
430
+ const row = el("div", "ce-pulls");
431
+ row.append(el("span", "ce-lbl", "this run's Pulls"));
432
+ for (const p of e.pulls) {
433
+ const a = el("a", null, "#" + p.issue);
434
+ a.href = p.href;
435
+ row.append(a);
436
+ if (p.mark) row.append(el("span", p.mark.severity === "red" ? "red" : "ce-amber", p.mark.text));
437
+ }
438
+ box.append(row);
439
+ }
413
440
  return box;
414
441
  }
415
442
 
@@ -635,10 +662,29 @@ function card(t) {
635
662
  for (const f of t.flags || []) meta.append(el("span", "badge flag", f));
636
663
  if (t.ruling) meta.append(el("span", "badge", "ruled:" + t.ruling));
637
664
  c.append(meta);
665
+ if (t.cellLine) {
666
+ for (const line of t.cellLine.lines) c.append(cellLineRow(line));
667
+ if (t.cellLine.mark) c.append(el("div", "cl mark " + t.cellLine.mark.severity, t.cellLine.mark.text));
668
+ }
638
669
  resumeFlash(c);
639
670
  return c;
640
671
  }
641
672
 
673
+ // One line of a card's Cell line: its parts, each after its own separator. A
674
+ // part with an `href` is a hash link, a guard entry or a policy row on Cell
675
+ // evidence, and opens in this window; a hole ("not on record") is drawn dim and
676
+ // italic in its place. Every word is the model's (compute-board.mjs's cellLine).
677
+ function cellLineRow(parts) {
678
+ const row = el("div", "cl");
679
+ for (const p of parts) {
680
+ if (p.sep) row.append(document.createTextNode(p.sep));
681
+ const node = el(p.href ? "a" : "span", p.dim ? "nr" : null, p.text);
682
+ if (p.href) node.href = p.href;
683
+ row.append(node);
684
+ }
685
+ return row;
686
+ }
687
+
642
688
  // The one writer of a shown banner: display, class and text move together, so
643
689
  // no caller can show a message while a previous caller's class is still set.
644
690
  function showBanner(text, cls = "") {
@@ -33,9 +33,13 @@
33
33
  // fleet-tick.mjs's I/O and main() never run here, main() being guarded on
34
34
  // argv[1].
35
35
  import { assessBeat, isStalled, isReported, stallReport, NO_OWNER } from "./fleet-state.mjs";
36
- import { parseToken, rowPr, premisesOf, HALT_CAUSES, REVIEW } from "./ledger-grammar.mjs";
36
+ import { parseToken, rowPr, premisesOf, HALT_CAUSES, REVIEW, CELL, POLICY_CELL, parseRoutedEntry, tierValues, cellValues } from "./ledger-grammar.mjs";
37
37
  import { latestFinisherAttempts, foldLedger, pastPinDue } from "./fleet-tick.mjs";
38
38
  import { computeCellEvidence } from "./compute-cell-evidence.mjs";
39
+ import { admissibleRow, lastSegment } from "./pull-attribution.mjs";
40
+ import { dispatchModel } from "./member-outcomes.mjs";
41
+ import { HEAVY_BRIEF_CHARS, HEAVY_CRITERIA } from "./ticket-router.mjs";
42
+ import { implementerCell, modelsEqual } from "./tier-roles.mjs";
39
43
 
40
44
  // A ledger row is freeform, controller-authored text. Two example shapes:
41
45
  // #<n> impl-<n>=PR#<m> → PR#<m> → MERGED 73b356de
@@ -303,6 +307,186 @@ export function deriveFlags(parsed, ctx) {
303
307
 
304
308
  const isBadge = (flag) => flag === "excluded" || flag.startsWith("excluded:");
305
309
 
310
+ // ---------------------------------------------------------------------------
311
+ // The card's Cell line: which Cell the card's latest Pull ran on, and why.
312
+ // ---------------------------------------------------------------------------
313
+
314
+ // A part of a Cell line: its words, whether they are a hole drawn dim and
315
+ // italic ("not on record"), the hash it links to, and the separator the page
316
+ // puts before it (" · " unless said otherwise).
317
+ const NOT_ON_RECORD = "not on record";
318
+ const part = (text, o = {}) => ({ text, dim: false, href: null, sep: " · ", ...o });
319
+ const hole = (o = {}) => part(NOT_ON_RECORD, { dim: true, ...o });
320
+ const grouped = (n) => String(n).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
321
+
322
+ // A transcript's member record, as gather() keeps it, put the way the figures
323
+ // read an implementer row (member-outcomes.mjs): its definition, its level
324
+ // ("-" is no level), and its dispatch model keyed as the Cell generation is.
325
+ function dispatchRecord(m) {
326
+ return {
327
+ subagentType: typeof m.subagent_type === "string" ? m.subagent_type : "",
328
+ effort: typeof m.thinking === "string" && m.thinking !== "-" ? m.thinking : "",
329
+ dispatchModel: dispatchModel(m.resolvedModelIdentity),
330
+ resolved: m.resolvedModelIdentity ?? null,
331
+ model: m.model ?? null,
332
+ };
333
+ }
334
+
335
+ // The row's implementers, in attempt order: its own ticket's impl tokens, or
336
+ // every impl token when it names none of its own.
337
+ function implementersOf(row, issue) {
338
+ const all = row.split(/\s+/).map(parseToken).filter((t) => t && !t.error && t.family === "impl");
339
+ const own = all.filter((t) => t.number === issue);
340
+ const seen = new Set();
341
+ return (own.length ? own : all)
342
+ .filter((t) => !seen.has(t.name) && seen.add(t.name))
343
+ .sort((a, b) => a.number - b.number || (a.retry ?? "").localeCompare(b.retry ?? ""))
344
+ .map((t) => t.name);
345
+ }
346
+
347
+ // The words of a recorded reason, after the draw's, and whether they name the
348
+ // policy row. `REASON` keeps only the first thing that went wrong, and nothing
349
+ // here guesses the rest.
350
+ function reasonWords(r, table) {
351
+ const drawn = r.draw !== null;
352
+ const row = `${r.objective} row`;
353
+ switch (r.reason) {
354
+ case "ok": {
355
+ if (drawn) return [];
356
+ const follows = table !== null && !Object.hasOwn(table.rows[r.objective], r.stratum);
357
+ const href = `#cells/row/${r.objective}/${follows ? "*" : r.stratum}`;
358
+ return [part(`${row}, ${r.stratum}`, { href }), ...(follows ? [part("follows *")] : [])];
359
+ }
360
+ case "table-cell-tripped": {
361
+ const named = r.tripped.length === 1 ? `${row}'s ${r.tripped[0]}` : `${row}'s Cell (one of ${r.tripped.join(", ")})`;
362
+ return [part(`${named} tripped${drawn ? "" : ": default Cell"}`, { href: `#cells/row/${r.objective}/${r.stratum}` })];
363
+ }
364
+ case "guard-tripped":
365
+ return [part(drawn ? `left out as tripped: ${r.tripped.join(", ")}` : "every other Cell tripped: no draw")];
366
+ case "guard-missing": return [part("no cost guard yet: default Cell only")];
367
+ case "no-issue-json": return [part("issue unreadable when routed")];
368
+ case "no-sizing": return [part("no sizing")];
369
+ default: return [part(`recorded as ${r.reason}`)];
370
+ }
371
+ }
372
+
373
+ // The Stratum and the numbers that set it.
374
+ function stratumWords(r) {
375
+ if (r.sized !== null) return `${r.stratum}: sized ${r.sized}`;
376
+ if (r.brief === null) return `${r.stratum}: no brief read`;
377
+ if (r.reason === "no-sizing") return `${r.stratum}: no sizing`;
378
+ const past = (n, at) => `${n > at ? "past" : "not past"} ${grouped(at)}`;
379
+ return `${r.stratum}: ${grouped(r.brief)} chars (${past(r.brief, HEAVY_BRIEF_CHARS)}), ${r.criteria} criteria (${past(r.criteria, HEAVY_CRITERIA)})`;
380
+ }
381
+
382
+ // "<model> · <level>" off a dispatch record, holes where it carries none.
383
+ function modelParts(rec, sep) {
384
+ if (rec === null) return [hole({ sep })];
385
+ return [rec.dispatchModel ? part(rec.dispatchModel, { sep }) : hole({ sep }), rec.effort ? part(rec.effort) : hole()];
386
+ }
387
+
388
+ const cellHref = (cell, generation) => `#cells/${cell}${generation ? `@${generation}` : ""}`;
389
+
390
+ /**
391
+ * The Cell line of a card whose ledger row has an impl token, or
392
+ * null when it has none: `{ cell, generation, lines: [why, stratum], mark,
393
+ * targets }`. `generation` is the Pull's (its first Admissible implementer's
394
+ * dispatch model), null when none is on record; `targets` is every guard entry
395
+ * the line links to, `{ cell, generation }`, its Cell's and a rescue's.
396
+ * `lines` are lists of parts (`part` above); `mark` is null or `{ text,
397
+ * severity }`, severity `amber` or `red` (red: the Pull counts in no Cell's
398
+ * figures). `routed` is the ledger's `## Routed` entries, `agents` its
399
+ * `## Dispatched` member → `agent=` map, `members` each implementer's member
400
+ * record by name (`{ model, resolvedModelIdentity, thinking, subagent_type }`)
401
+ * and `table` the installed router table, or null. Pure: the Routing is shown
402
+ * as recorded and never re-checked against today's guard.
403
+ */
404
+ export function cellLine({ row, issue, routed = [], agents = {}, members = new Map(), table = null }) {
405
+ const names = implementersOf(row, issue);
406
+ if (names.length === 0) return null;
407
+
408
+ // The latest Pull: the last implementer with a `## Routed` entry, those after
409
+ // it rescues or retries under it. A row with no entry predates the Routing,
410
+ // and its latest Pull is its latest impl token, at the row's Cell: its
411
+ // `tier=` is rewritten to the Cell each later implementer runs at, so an
412
+ // earlier one cannot be told off a rescue.
413
+ const entries = new Map();
414
+ for (const e of routed) {
415
+ const sp = typeof e === "string" ? e.indexOf(" ") : -1;
416
+ if (sp === -1 || entries.has(e.slice(0, sp))) continue;
417
+ entries.set(e.slice(0, sp), { routing: parseRoutedEntry(e)?.routing ?? null, raw: e.slice(sp + 1) });
418
+ }
419
+ const start = names.findLastIndex((n) => entries.has(n));
420
+ const under = start === -1 ? names.slice(-1) : names.slice(start);
421
+ const recorded = start === -1 ? null : entries.get(names[start]);
422
+ const routing = recorded?.routing ?? null;
423
+ const cell = routing?.cell ?? tierValues(row)[0] ?? cellValues(row)[0] ?? POLICY_CELL;
424
+ const level = CELL.exec(cell)?.[2] ?? null;
425
+ const expected = `fleet-implementer-${cell}`;
426
+
427
+ const recs = under.map((n) => (members.has(n) ? dispatchRecord(members.get(n)) : null));
428
+ const tierOk = (n) => row.split(/\s+/).find((w) => w.startsWith(`tier-ok=${n}:`))?.slice(`tier-ok=${n}:`.length) || null;
429
+ const ranAs = (n, i) => (Object.hasOwn(agents, n) ? agents[n] : null) ?? tierOk(n) ?? (recs[i]?.subagentType || null);
430
+ const admissible = recs.map((rec) => (rec === null ? null : admissibleRow(rec, cell)));
431
+ const firstAdmissible = admissible.indexOf(true);
432
+ const generation = firstAdmissible === -1 ? null : recs[firstAdmissible].dispatchModel;
433
+
434
+ // Line 1: the Cell, then why. A `tier=` that names no Cell (a hand-edited
435
+ // row) has no guard entry to land on, so it links nowhere and books nothing.
436
+ const isCell = CELL.test(cell);
437
+ const why = [part(cell, { href: isCell ? cellHref(cell, generation) : null, sep: "" })];
438
+ const targets = isCell ? [{ cell, generation }] : [];
439
+ if (routing !== null) {
440
+ if (routing.draw !== null) why.push(part(`drawn ${routing.draw.k} of ${routing.draw.K}: ${routing.by === "burn-in" ? "burn-in" : "every 5th Pull"}`));
441
+ why.push(...reasonWords(routing, table));
442
+ } else if (recorded !== null) {
443
+ why.push(part(`recorded as ${recorded.raw}`));
444
+ } else {
445
+ const route = row.split(/\s+/).find((w) => w.startsWith("route="));
446
+ why.push(route ? part(`recorded as ${route.slice("route=".length)}`) : hole());
447
+ }
448
+ const rescue = under.map((n, i) => ({ i, at: i === 0 ? null : implementerCell(ranAs(n, i) ?? "") })).findLast((x) => x.at !== null && x.at !== cell);
449
+ if (rescue !== undefined) {
450
+ const rec = recs[rescue.i];
451
+ const gen = rec !== null && admissibleRow(rec, rescue.at) ? rec.dispatchModel : null;
452
+ why.push(part(`rescue at ${rescue.at}`, { href: cellHref(rescue.at, gen) }), ...modelParts(rec, " "));
453
+ targets.push({ cell: rescue.at, generation: gen });
454
+ }
455
+
456
+ // Line 2: the Stratum with its numbers, then the model and level of the
457
+ // Pull's first implementer at its Cell.
458
+ const shown = recs[firstAdmissible === -1 ? 0 : firstAdmissible];
459
+ const stratum = [routing !== null ? part(stratumWords(routing), { sep: "" }) : hole({ sep: "" }), ...modelParts(shown, " · ")];
460
+ if (shown !== null && shown.model !== null && shown.resolved !== null && !modelsEqual(shown.model, shown.resolved)) {
461
+ stratum.push(part(`fell back to ${shown.model}`));
462
+ }
463
+
464
+ // The mark: the first implementer, the one the Pull's Cell binds, ran off it.
465
+ let mark = null;
466
+ const first = recs[0];
467
+ const said = ranAs(under[0], 0);
468
+ let off = null;
469
+ if (admissible[0] !== true) {
470
+ const defOff = first !== null ? first.subagentType !== expected : said !== null && said !== expected;
471
+ if (defOff) {
472
+ const as = said !== null && said !== expected ? said : first?.subagentType || "no definition on record";
473
+ off = { first: `first ran as ${as}`, alone: `ran as ${as}` };
474
+ } else if (first !== null && !first.dispatchModel) {
475
+ off = { first: "first ran with no model on record", alone: "no model on record" };
476
+ } else if (first !== null && first.effort !== level) {
477
+ const at = first.effort ? `at ${first.effort}` : "with no thinking level on record";
478
+ off = { first: `first ran ${at}, not ${level}`, alone: `ran ${at}, not ${level}` };
479
+ }
480
+ }
481
+ if (off !== null) {
482
+ if (admissible.slice(1).includes(true)) mark = { text: `⚑ ${off.first}`, severity: "amber" };
483
+ else if (admissible.includes(null)) mark = { text: `⚑ ${off.alone}: not checked`, severity: "amber" };
484
+ else mark = { text: `⚑ ${off.alone}: no Admissible row, so it counts in no Cell's figures`, severity: "red" };
485
+ }
486
+
487
+ return { cell, generation, lines: [why, stratum], mark, targets };
488
+ }
489
+
306
490
  // Internal helpers — not exported; covered through computeBoard's tests.
307
491
 
308
492
  // Carry the stage-entry timestamp forward while the column is unchanged, else
@@ -484,8 +668,13 @@ export function computeBoard(inputs) {
484
668
  const parsed = [];
485
669
  for (const [i, row] of rows.entries()) {
486
670
  const p = parseRow(row);
487
- if (p) parsed.push({ ...p, malformed: p.malformed || fold.malformed.has(i) });
671
+ if (p) parsed.push({ ...p, row, malformed: p.malformed || fold.malformed.has(i) });
488
672
  }
673
+ // Each implementer's member record by its name, for the Cell lines: the
674
+ // transcripts gather() read, this run's session's or, between runs, the
675
+ // previous run's.
676
+ const members = new Map((inputs.implementers || []).map((m) => [lastSegment(m.member), m]));
677
+ const lineInputs = { routed: ledger.routed || [], agents: ledger.agents || {}, members, table: inputs.routerTable };
489
678
  // The ticket row each PR's latest attempt settled to, first row wins.
490
679
  const claimedBy = new Map();
491
680
  for (const p of parsed) if (p.impl !== null && p.pr != null && !claimedBy.has(p.pr)) claimedBy.set(p.pr, p);
@@ -540,6 +729,9 @@ export function computeBoard(inputs) {
540
729
  sinceEnteredStage,
541
730
  flags,
542
731
  ruling: p.pr != null ? (ruledByPr.get(p.pr) ?? null) : null,
732
+ // A POOL card (an Exclusion) carries none, and cellLine gives a PR-only
733
+ // row none, since it has no impl token.
734
+ cellLine: column === "POOL" ? null : cellLine({ row: p.row, issue: p.issue, ...lineInputs }),
543
735
  });
544
736
  }
545
737
 
@@ -558,7 +750,7 @@ export function computeBoard(inputs) {
558
750
  const sinceEnteredStage = stageEntry(prevByIssue.get(iss.number), "POOL", now);
559
751
  tickets.push({
560
752
  issue: iss.number, title: iss.title, column: "POOL", agent: null,
561
- pr: null, ci: null, sinceEnteredStage, flags: [], ruling: null,
753
+ pr: null, ci: null, sinceEnteredStage, flags: [], ruling: null, cellLine: null,
562
754
  });
563
755
  }
564
756
 
@@ -644,7 +836,8 @@ export function computeBoard(inputs) {
644
836
  attention,
645
837
  // The Cell evidence tab's model (compute-cell-evidence.mjs), built from the
646
838
  // guard, the receipts' metrics steps, the definitions and the carried
647
- // `modelRoles` read gather() answered. A caller that read none of them
839
+ // `modelRoles` read gather() answered, and this run's Pulls: each card's
840
+ // Cell line, booked As-routed to its Cell. A caller that read none of them
648
841
  // (every hand-built input in this suite) gets the tab's no-guard state:
649
842
  // computeCellEvidence reads an input left out as nothing read.
650
843
  cellEvidence: computeCellEvidence({
@@ -652,6 +845,7 @@ export function computeBoard(inputs) {
652
845
  receipts: inputs.receipts,
653
846
  agents: inputs.agents,
654
847
  modelRoles: inputs.modelRoles,
848
+ pulls: tickets.filter((t) => t.cellLine).map((t) => ({ issue: t.issue, cell: t.cellLine.cell, mark: t.cellLine.mark, targets: t.cellLine.targets })),
655
849
  }),
656
850
  // The `omp config get modelRoles` read, carried tick to tick the way `ci`
657
851
  // and `repo` are: `{ value, readAt, error }`, read at most once a minute.
@@ -7,7 +7,8 @@
7
7
  // places it.
8
8
  //
9
9
  // What this part holds is the guard section: what the cost guard holds each
10
- // implementer Cell to, from the guard file and nothing recomputed, and "Declared,
10
+ // implementer Cell to, from the guard file and nothing recomputed, with this
11
+ // run's Pulls booked to each Cell off the board's cards, and "Declared,
11
12
  // not measured". Figures show only from a guard `readCostGuard` (fleet-tick.mjs,
12
13
  // the reader the tick judges the file by) accepts; `guard` here is that reader's
13
14
  // own answer, `{ status: "ok", guard }` or `{ status: "missing" | "unreadable" }`.
@@ -316,7 +317,31 @@ function guardHeading(g) {
316
317
  return { state, heading, source };
317
318
  }
318
319
 
319
- function guardSection(read, receipts, modelRoles) {
320
+ // "this run's Pulls" on an entry, and a target for every generation a card
321
+ // links to on it. `pulls` is each card's `{ issue, cell, mark, targets }`, booked
322
+ // As-routed: listed under the Pull's Cell, mark and all, whether or not it has an
323
+ // Admissible row. A generation no figures, older row or "no figures yet" carries
324
+ // gets a "no figures yet for <model>" of its own (the card's model), so a card's
325
+ // link lands in every state: the entry's own "no figures yet" takes it when it
326
+ // names no model.
327
+ function booked(entry, pulls) {
328
+ const cell = entry.cell;
329
+ const out = { ...entry, pulls: pulls.filter((p) => p.cell === cell).map((p) => ({ issue: p.issue, href: `#board/${p.issue}`, mark: p.mark })), unfigured: [] };
330
+ const has = new Set([out.figures?.generation, ...out.older.map((o) => o.generation), out.none?.generation].filter(Boolean));
331
+ for (const t of pulls.flatMap((p) => p.targets)) {
332
+ if (t.cell !== cell || !t.generation || has.has(t.generation)) continue;
333
+ has.add(t.generation);
334
+ const none = { text: `no figures yet for ${t.generation}`, generation: t.generation, anchor: `cell-${cell}@${t.generation}` };
335
+ if (out.none !== null && out.none.anchor === null) out.none = { ...out.none, ...none };
336
+ else out.unfigured.push(none);
337
+ }
338
+ return out;
339
+ }
340
+
341
+ // The Cells drawn: the five, then any the guard holds or a card names beyond them.
342
+ const drawOrder = (held, pulls) => [...new Set([...CELLS, ...held, ...pulls.flatMap((p) => p.targets.map((t) => t.cell)).filter((c) => CELL.test(c))])];
343
+
344
+ function guardSection(read, receipts, modelRoles, pulls) {
320
345
  const label = readLabel(modelRoles);
321
346
  const refresh = newestRefresh(receipts);
322
347
  const notes = [];
@@ -339,7 +364,7 @@ function guardSection(read, receipts, modelRoles) {
339
364
  heading: "no cost guard",
340
365
  source: null,
341
366
  notes,
342
- cells: CELLS.map((cell) => guardEntry(cell, stub, byCell, modelRoles, footnotes)),
367
+ cells: drawOrder([], pulls).map((cell) => booked(guardEntry(cell, stub, byCell, modelRoles, footnotes), pulls)),
343
368
  footnotes,
344
369
  };
345
370
  }
@@ -347,8 +372,8 @@ function guardSection(read, receipts, modelRoles) {
347
372
  const g = read.guard;
348
373
  const { state, heading, source } = guardHeading(g);
349
374
  const byCell = new Map(g.cells.map((c) => [c.cell, c]));
350
- const order = [...CELLS, ...g.cells.map((c) => c.cell).filter((c) => !CELLS.includes(c))];
351
- const cells = order.map((cell) => guardEntry(cell, g, byCell, modelRoles, footnotes));
375
+ const order = drawOrder(g.cells.map((c) => c.cell), pulls);
376
+ const cells = order.map((cell) => booked(guardEntry(cell, g, byCell, modelRoles, footnotes), pulls));
352
377
 
353
378
  const missing = FIELD_WORDS.filter(([key]) => g.cells.some((c) => count(c[key]) === null)).map(([, words]) => words);
354
379
  if (missing.length > 0) notes.push(`not checked: this guard predates the ${missing.join(", ")}`);
@@ -396,12 +421,14 @@ function declaredSection(agents, modelRoles) {
396
421
  * is `{ phase0, closeout }`, each the receipt's `metrics` step `{ status, at,
397
422
  * output }` or null, `agents` is `{ list: [{ file, model }], error }`, and
398
423
  * `modelRoles` the carried `{ value, readAt, error }` or null — `error` being
399
- * `{ at, message }`. An input left out reads as nothing read: a missing guard,
400
- * no receipt, no definitions, no `modelRoles` read.
424
+ * `{ at, message }`, and `pulls` this run's Pulls, one per card with a Cell line:
425
+ * `{ issue, cell, mark, targets: [{ cell, generation }] }` (compute-board.mjs's
426
+ * cellLine). An input left out reads as nothing read: a missing guard, no
427
+ * receipt, no definitions, no `modelRoles` read, no Pull.
401
428
  */
402
- export function computeCellEvidence({ guard, receipts, agents, modelRoles = null }) {
429
+ export function computeCellEvidence({ guard, receipts, agents, modelRoles = null, pulls = [] }) {
403
430
  return {
404
- guard: guardSection(guard, receipts, modelRoles),
431
+ guard: guardSection(guard, receipts, modelRoles, pulls),
405
432
  declared: declaredSection(agents, modelRoles),
406
433
  };
407
434
  }
@@ -811,8 +811,8 @@ export function drawCell({ session, ticket, policyCell, cells }) {
811
811
  // after the Pull's first implementer's member token, and it never changes
812
812
  // after: the row's `tier=`/`cell=` stay the mutable "Cell the next
813
813
  // implementer runs at". One grammar for the line, here, read by `pull.mjs` off
814
- // the router's stdout and by `ledger.mjs` to refuse a malformed one; the
815
- // cockpit's board card is to read it too, and does not yet. Its words, in
814
+ // the router's stdout, by `ledger.mjs` to refuse a malformed one, and by the
815
+ // cockpit's board card (compute-board.mjs's cellLine). Its words, in
816
816
  // this order, `-` for none:
817
817
  // POLICY the policy row's Cell CELL the Pull's Cell
818
818
  // DRAW k/K of the draw BY burn-in | every-5th