@oscaner-skills/cdd-engine 4.11.0 → 4.13.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.
@@ -36,7 +36,6 @@
36
36
  // bare functions (the plan's zero-bare-function discipline).
37
37
  import { readFileSync } from "node:fs";
38
38
  import path from "node:path";
39
- import { PlanDocType } from "../contract/doc.js";
40
39
  import { FrontMatterExtractor } from "../contract/frontmatter.js";
41
40
  import { DOC_KEYS } from "../contract/project.js";
42
41
  import { ConfigLoader } from "../infra/config.js";
@@ -44,8 +43,8 @@ import { RepoRoot } from "../infra/root.js";
44
43
  import { ENGINE_RUNTIME } from "../infra/runtime.js";
45
44
  import { SlugIndex } from "../infra/slug-index.js";
46
45
  import { Workspace, WorkspaceRoot } from "../infra/workspace.js";
47
- import { CarrierIntegrity } from "../session/carrier-integrity.js";
48
- import { TaskGraph } from "../session/graph.js";
46
+ import { ArtifactReads } from "../session/artifact-reads.js";
47
+ import { CarrierIntegrity, CarrierMismatchError } from "../session/carrier-integrity.js";
49
48
  import { Ledger, RoundRecords } from "../session/ledger.js";
50
49
  import { PipelineFrontier } from "../session/pipeline.js";
51
50
  import { PROGRESS_LEGEND, PROGRESS_MARKERS } from "./graph-view.js";
@@ -57,6 +56,11 @@ const VERB_ORDER = ["implement", "review", "branch-review", "fix"];
57
56
  /** The judgement glyphs of one aggregated token (spec §5.3 — the mark is MANDATORY:
58
57
  * `✓` a completed round, `✗` a round that failed its target action). */
59
58
  const JUDGEMENT_MARKERS = { passed: "✓", failed: "✗", recovered: "✗→✓" };
59
+ /** The closed projection — no matrix, default view. The value a caller that observes
60
+ * no artifacts passes (a `null` registry answers zero `art:` rows). */
61
+ export const NO_ARTIFACTS = { registry: null, showAll: false };
62
+ /** The empty slot — one shared value, never a freshly minted arm. */
63
+ const NO_DOC = { kind: "none" };
60
64
  /** The DocKey domain of the `doc-type:` declaration — the declared value must
61
65
  * be one of the four keys; anything else reads null (present facts, never a
62
66
  * fabricated type). Derived from the ONE DocKey declaration (contract/project.ts
@@ -75,6 +79,17 @@ const PHASE_TITLE_MAX = 60;
75
79
  /** The label column of the board's line rows — ` ` + the label padded to this
76
80
  * width (`overall` is the longest verb at 7), so every value starts in one column. */
77
81
  const LABEL_WIDTH = 9;
82
+ /** The `art:` fact block's continuation keys — the board's OWN spelling of the three
83
+ * facts a judgment carries (spec §2.6). Deliberately independent of
84
+ * `Words#artifactIdentity`: that row is the gate's §2.4 contract (`derived: `,
85
+ * a colon inside its own two-space column), while the board's rows are the §2.6
86
+ * contract (`derived`, no colon, the board's continuation column). One source per
87
+ * contract, and the board's half is pinned by its byte assertions. */
88
+ const ARTIFACT_FACT_LABELS = {
89
+ derived: "derived",
90
+ found: "found",
91
+ reason: "reason",
92
+ };
78
93
  /** One board line's carrier facts — the `+N` count's WHOLE read face (spec §2.7 ·
79
94
  * §2.10). The record's path comes from the ledger's ONE accessor, bound to this
80
95
  * line's type + key; ownership excludes a legacy record whose path a later round of
@@ -186,22 +201,70 @@ export class BoardView {
186
201
  * the program overall the identity's `program:` names. An entry that is itself
187
202
  * a plan contributes the plan and resolves its spec by the same slug. The
188
203
  * `programMissing` fact is the phase-spec hard gate: a `program:` that names no
189
- * on-disk overall (or no `program:` at all). Zero filename derivation. */
204
+ * on-disk overall (or no `program:` at all). Zero filename derivation and zero
205
+ * "first document": each slot is the index's SET answer (0 / 1 / n).
206
+ *
207
+ * Naming the entry document on argv (`cdd board --spec` / `--plan`) does NOT
208
+ * exempt its slot from the set: the entry's identity is still its slug, so a
209
+ * second same-class document makes that slot `many` and the row renders the
210
+ * marker plus every declared home. `own` survives only where the set cannot be
211
+ * asked — no legal slug, or an undeclared `doc-type:` that no class can hold. */
190
212
  static #nodeSources(index, entry) {
191
213
  const slug = BoardView.#validSlug(entry);
192
214
  const isPlan = entry.docType === "plan";
193
- const spec = slug === null ? (isPlan ? null : entry) : isPlan ? index.identityDoc(slug) : entry;
194
- const plan = isPlan ? entry : slug === null ? null : index.planOf(slug);
195
- const overall = spec?.docType === "phase-spec" && spec.program !== null
196
- ? index.overallOf(spec.program)
215
+ const own = { kind: "one", entry };
216
+ const spec = slug === null
217
+ ? isPlan
218
+ ? NO_DOC
219
+ : own
220
+ : entry.docType === null
221
+ ? own
222
+ : BoardView.#docSlotOf(index, slug, "identity");
223
+ const plan = slug === null ? (isPlan ? own : NO_DOC) : BoardView.#docSlotOf(index, slug, "plan");
224
+ const specEntry = BoardView.#slotEntry(spec);
225
+ const overall = specEntry?.docType === "phase-spec" && specEntry.program !== null
226
+ ? index.overallOf(specEntry.program)
197
227
  : null;
198
228
  return {
199
229
  spec,
200
230
  plan,
201
231
  overall,
202
- programMissing: spec !== null && BoardView.#programMissing(index, spec),
232
+ programMissing: specEntry !== null && BoardView.#programMissing(index, specEntry),
203
233
  };
204
234
  }
235
+ /** One doc slot — the index's SET answer for a class, filtered and then counted,
236
+ * never searched with `.find`. Two documents of the class are `many`, and every
237
+ * caller renders the marker and the whole set instead of choosing one. */
238
+ static #docSlotOf(index, slug, role) {
239
+ const docs = index
240
+ .docsOf(slug)
241
+ .filter((doc) => role === "plan" ? doc.docType === "plan" : doc.docType !== null && doc.docType !== "plan");
242
+ if (docs.length === 0)
243
+ return NO_DOC;
244
+ if (docs.length === 1)
245
+ return { kind: "one", entry: docs[0] };
246
+ return { kind: "many", found: docs };
247
+ }
248
+ /** The single document a slot carries — `null` for both the empty and the
249
+ * ambiguous arm: neither has ONE document to speak about. */
250
+ static #slotEntry(slot) {
251
+ return slot.kind === "one" ? slot.entry : null;
252
+ }
253
+ /** One document slot's violation marker — the single arm asks `#entryMark` (the ONE
254
+ * duplicate / identity judgment the pre-flight gate shares), and an ambiguous set
255
+ * renders the same `duplicated` marker the doc domain's `read` refuses on. */
256
+ static #slotMark(index, slot, role) {
257
+ if (slot.kind === "one")
258
+ return BoardView.#entryMark(index, slot.entry, role);
259
+ return slot.kind === "many" ? MARK_SLUG_DUPLICATED : null;
260
+ }
261
+ /** The cell of a doc row whose slug names MORE than one document of its class: the
262
+ * existing duplicate marker plus every path of the set. No version, no status, no
263
+ * rounds — those are facts of ONE document, and this identity has none. */
264
+ static #duplicateDocLine(label, found) {
265
+ const paths = found.map((doc) => doc.rel).join(" · ");
266
+ return ` ${label.padEnd(LABEL_WIDTH)}${MARK_SLUG_DUPLICATED} ${paths}`;
267
+ }
205
268
  /** The entry's valid slug — the workspace key, or null when the declaration is
206
269
  * absent or illegal (an illegal value is a violation, never a directory name). */
207
270
  static #validSlug(entry) {
@@ -237,7 +300,7 @@ export class BoardView {
237
300
  * `overall` line). The ledger is the one that OWNS `progress` — a node board reads
238
301
  * the overall line from the program's workspace, never the node's. */
239
302
  static #lineOf(label, key, entry, progress, ledger) {
240
- const rounds = BoardView.#rowRounds(progress, key, entry?.docType ?? null);
303
+ const rounds = BoardView.#rowRounds(progress, key);
241
304
  return {
242
305
  label,
243
306
  version: entry?.version ?? null,
@@ -246,6 +309,8 @@ export class BoardView {
246
309
  rounds,
247
310
  carriers: LineCarriers.ofLedger(ledger, key, key, rounds),
248
311
  marker: null,
312
+ type: key,
313
+ key,
249
314
  };
250
315
  }
251
316
  /** summaryCell(records) — the line's aggregated rounds cell (P24 §12): the SUCCESS
@@ -433,20 +498,32 @@ export class BoardView {
433
498
  // -------------------------------------------------------------------------
434
499
  // the render face (spec §5.3) — the entry document → board layout + next render
435
500
  // -------------------------------------------------------------------------
436
- /** render(index, entry, repoRoot, words, host, channels, holding, next) — the
437
- * entry document's board (spec §3.1): the entry's declared `doc-type:` picks the
438
- * shape — `overall` → the program board, every other type → the node board. The
439
- * index supplies every related node (`program:` → overall; same slug → spec /
440
- * plan), so no filename grammar participates. `next` is the INJECTED `NextHop`
441
- * the node board's `next:` row renders (null = the board holds no derivable hop,
442
- * the `(none)` degradation). The argv channel is threaded into the shared
443
- * `RouteRenderer` (the SAME channel the capsule's route render reads, so the
501
+ /** render(readTable, plan, index, entry, repoRoot, words, host, channels, holding,
502
+ * next, projection) — the entry document's board (spec §3.1): the declared `doc-type:`
503
+ * picks the shape — `overall` → the program board, every other type → the node
504
+ * board. The index supplies every related node (`program:` → overall; same slug →
505
+ * spec / plan), so no filename grammar participates. `next` is the INJECTED
506
+ * `NextHop` the node board's `next:` row renders (null = the board holds no
507
+ * derivable hop, the `(none)` degradation). The argv channel is threaded into the
508
+ * shared `RouteRenderer` (the SAME channel the capsule's route render reads, so the
444
509
  * board's `next:` and the engine's `next:` literal compose their argv from ONE
445
510
  * flag-spelling source). A present doc line carrying a violation renders the
446
- * matching `(BLOCKED)` marker and the board exits 2 (spec §3.1 — the board's
447
- * reject face is exit 2, never the dispatch CDD_BLOCKED channel). Pure reads —
448
- * zero tree writes, zero ledger writes, zero child dispatch. */
449
- static render(index, entry, repoRoot, words, host, channels = {}, holding = { kind: "absent" }, next = null) {
511
+ * matching `(BLOCKED)` marker and the board exits 2 (spec §3.1 — the board's reject
512
+ * face is exit 2, never the dispatch CDD_BLOCKED channel). Pure reads — zero tree
513
+ * writes, zero ledger writes, zero child dispatch.
514
+ *
515
+ * `readTable` is the caller's ORDERED per-phase plan value table (spec §2.1 ·
516
+ * §2.4): `Cli#runBoard` builds it once, in `index.phaseSpecsOf` row order, so an
517
+ * overall board's every phase cell and every `CDD_WARN:` line reads the SAME value
518
+ * the wave segment reads. A single-document board is a table of length 1 — its one
519
+ * row is the argv face's read (solo `--plan`) or the derived face's (`--spec`).
520
+ * The board therefore holds no plan-reading seam of its own: the ONE read point is
521
+ * the injected `PlanSource`, and a value is never re-read here.
522
+ *
523
+ * `projection` is the artifact observation's ONE input (the matrix seam plus the
524
+ * `--artifacts` switch) — the two halves travel together so neither can arrive
525
+ * without the other. */
526
+ static render(readTable, plan, index, entry, repoRoot, words, host, channels = {}, holding = { kind: "absent" }, next = null, projection = NO_ARTIFACTS) {
450
527
  const lines = [`cdd board: ${entry.slug ?? "(none)"}`, ""];
451
528
  // The repo-basis value object — constructed ONCE at this boundary, the ONE
452
529
  // conversion exit the doc cells and the `next:` render normalize their embedded
@@ -455,8 +532,12 @@ export class BoardView {
455
532
  // one form).
456
533
  const root = new RepoRoot(repoRoot);
457
534
  const exitCode = entry.docType === "overall"
458
- ? BoardView.#programBoard(lines, index, entry, root)
459
- : BoardView.#nodeBoard(lines, index, entry, root, words, host, channels, holding, next);
535
+ ? BoardView.#programBoard(readTable, plan, lines, index, entry, root, words, projection)
536
+ : BoardView.#nodeBoard(
537
+ // A node board is ONE document: the caller's single row. An empty table
538
+ // means no document was read at all — the seam's own undeclared value is
539
+ // that read result (no file is opened, so this mints no second read).
540
+ readTable[0] ?? plan.readFor(null), plan, lines, index, entry, root, words, host, channels, holding, next, projection);
460
541
  lines.push("", PROGRESS_LEGEND.board);
461
542
  return { lines, exitCode };
462
543
  }
@@ -465,15 +546,22 @@ export class BoardView {
465
546
  * (`program:` → overall; same slug → spec / plan); a missing link renders
466
547
  * `(none)` and stays exit 0, while a violated line renders its marker and exits
467
548
  * 2. The repo-basis `root` is threaded alone (F2) — its `absolute` feeds the
468
- * fs-facing helpers, its value object the path renders. */
469
- static #nodeBoard(lines, index, entry, root, words, host, channels, holding, next) {
549
+ * fs-facing helpers, its value object the path renders. `read` is the caller's
550
+ * ONE plan value (spec §2.1): the plan row, the wave row and the `! no-spec`
551
+ * spec row all take their facts from it, so the document the board names and
552
+ * the document it read are one fact. */
553
+ static #nodeBoard(read, plan, lines, index, entry, root, words, host, channels, holding, next, projection) {
470
554
  const repoRoot = root.absolute;
471
555
  const sources = BoardView.#nodeSources(index, entry);
472
556
  const nodeSlug = BoardView.#validSlug(entry);
473
- const ledger = nodeSlug === null ? null : BoardView.#ledgerOf(nodeSlug, repoRoot);
557
+ const nodeSeat = nodeSlug === null ? null : BoardView.#ledgerOf(plan, nodeSlug, repoRoot, projection.registry);
558
+ const ledger = nodeSeat?.ledger ?? null;
474
559
  const progress = ledger?.readProgress() ?? null;
475
560
  const overallSlug = BoardView.#validSlug(sources.overall);
476
- const overallLedger = overallSlug === null ? null : BoardView.#ledgerOf(overallSlug, repoRoot);
561
+ const overallSeat = overallSlug === null
562
+ ? null
563
+ : BoardView.#ledgerOf(plan, overallSlug, repoRoot, projection.registry);
564
+ const overallLedger = overallSeat?.ledger ?? null;
477
565
  const overallProgress = overallLedger?.readProgress() ?? null;
478
566
  // The tree's dispatch fact + the node workspace's orphan drafts + the node's
479
567
  // crashed rounds render before the line rows (a reader answers "is anyone working
@@ -487,59 +575,101 @@ export class BoardView {
487
575
  lines.push(row);
488
576
  if (holding.kind !== "absent" || orphans.length > 0 || crashes.length > 0)
489
577
  lines.push("");
578
+ // The two identity marks the read-value ladder consults (spec §2.7's first two
579
+ // layers): a non-empty mark keeps the EXISTING `#docCell` accounting and exit 2 —
580
+ // identity breakage outranks the read value, so neither the plan row nor the spec
581
+ // row asks a `PlanRead` accessor, and no `! no-spec` literal (the orphan fold or
582
+ // the degraded wave row) can appear beside a broken identity.
583
+ const specMark = BoardView.#slotMark(index, sources.spec, "identity") ??
584
+ (sources.programMissing ? MARK_PROGRAM_MISSING : null);
585
+ const planMark = BoardView.#slotMark(index, sources.plan, "plan");
586
+ const specEntry = BoardView.#slotEntry(sources.spec);
587
+ const planEntry = BoardView.#slotEntry(sources.plan);
588
+ const planIdentityClean = planMark === null;
589
+ const identityClean = planIdentityClean && specMark === null;
490
590
  const docRows = [
491
591
  {
492
592
  label: "overall",
493
- entry: sources.overall,
593
+ slot: sources.overall === null ? NO_DOC : { kind: "one", entry: sources.overall },
494
594
  line: BoardView.#lineOf("overall", "overall", sources.overall, overallProgress, overallLedger),
495
595
  mark: BoardView.#entryMark(index, sources.overall, "identity"),
596
+ override: null,
496
597
  },
497
598
  {
498
599
  label: "spec",
499
- entry: sources.spec,
500
- line: BoardView.#lineOf("spec", BoardView.#lineWordOf(sources.spec), sources.spec, progress, ledger),
501
- mark: BoardView.#entryMark(index, sources.spec, "identity") ??
502
- (sources.programMissing ? MARK_PROGRAM_MISSING : null),
600
+ slot: sources.spec,
601
+ line: BoardView.#lineOf("spec", BoardView.#lineWordOf(specEntry), specEntry, progress, ledger),
602
+ mark: specMark,
603
+ // The reverse-lookup orphan's spec row (spec §2.7 ①): the identity-clean
604
+ // row bypasses `#entryMark` / `#docCell` accounting — landing in the mark
605
+ // channel would make it `blocked: true` and flip the orphan board to exit 2.
606
+ override: identityClean ? read.specLine(words) : null,
503
607
  },
504
608
  {
505
609
  label: "plan",
506
- entry: sources.plan,
507
- line: BoardView.#lineOf("plan", "plan", sources.plan, progress, ledger),
508
- mark: BoardView.#entryMark(index, sources.plan, "plan"),
610
+ slot: sources.plan,
611
+ line: BoardView.#lineOf("plan", "plan", planEntry, progress, ledger),
612
+ mark: planMark,
613
+ override: BoardView.#planCellOf(read, planEntry, planMark, words),
509
614
  },
510
615
  ];
511
616
  // The doc-name column is fixed-width: every name is padded to the widest one, so
512
617
  // the version column aligns down the block (spec §5.3).
513
- const nameWidth = Math.max(0, ...docRows
514
- .filter((row) => row.entry !== null)
515
- .map((row) => path.basename(row.entry.path).length));
618
+ const nameWidth = Math.max(0, ...docRows.flatMap((row) => row.slot.kind === "one" ? [path.basename(row.slot.entry.path).length] : []));
516
619
  let blocked = false;
517
620
  for (const row of docRows) {
518
- const cell = BoardView.#docCell(row.entry, row.line, nameWidth, row.mark);
621
+ // An ambiguous set is its own row: the marker plus every path, never one
622
+ // document's header facts (spec §2.3 — the read face answers a set with a set).
623
+ if (row.slot.kind === "many") {
624
+ lines.push(BoardView.#duplicateDocLine(row.label, row.slot.found));
625
+ blocked = true;
626
+ continue;
627
+ }
628
+ if (row.override !== null) {
629
+ lines.push(` ${row.label.padEnd(LABEL_WIDTH)}${row.override}`.trimEnd());
630
+ continue;
631
+ }
632
+ const cell = BoardView.#docCell(BoardView.#slotEntry(row.slot), row.line, nameWidth, row.mark);
519
633
  lines.push(` ${row.label.padEnd(LABEL_WIDTH)}${cell.text}`.trimEnd());
520
634
  blocked ||= cell.blocked;
521
635
  }
522
- const waves = BoardView.#waveLines(sources.plan?.path ?? null, progress, ledger);
523
- if (waves.length === 0) {
524
- lines.push(` ${"wave".padEnd(LABEL_WIDTH)}(none)`);
636
+ // The doc face asks the READ first and the assembler second (spec §2.4): a
637
+ // degradation literal is the value's, the healthy row stays byte-identical to
638
+ // today's (`waves()` + `graph.report(ledger.closedWaves())` + `#rowRounds` +
639
+ // `LineCarriers`). `waves()` being empty is never the `(none)` signal. The ONE
640
+ // literal an identity break bans is `! no-spec` (`spec-absent` beside a rendered
641
+ // `(BLOCKED)` marker); `! unparseable` / `! unreadable` / `(empty plan)` still
642
+ // render, so a reader can tell a missing plan from a plan that does not read.
643
+ const specAbsent = read.orphan()?.cause === "spec-absent";
644
+ const degraded = specAbsent && !planIdentityClean ? null : read.degradedWaveRow(words);
645
+ // The wave segment is derived ONCE — the rendered rows and the `art:` projection's
646
+ // record set read the same lines (never a second derivation over the same read).
647
+ const waves = degraded === null ? BoardView.#waveLines(read, progress, ledger) : [];
648
+ if (degraded !== null) {
649
+ lines.push(` ${"wave".padEnd(LABEL_WIDTH)}${degraded}`);
525
650
  }
526
651
  else {
527
- // The marker column is fixed-width: every wave label is padded to the widest
528
- // label so the ✔/▶/○ markers align into one column (spec §5.3 · D40).
529
- const labelWidth = Math.max(...waves.map((wave) => wave.label.length));
530
- waves.forEach((wave, index) => {
531
- const prefix = index === 0 ? ` ${"wave".padEnd(LABEL_WIDTH)}` : " ".repeat(2 + LABEL_WIDTH);
532
- const cell = BoardView.summaryCell(wave.rounds, wave.carriers);
533
- const label = wave.label.padEnd(labelWidth);
534
- lines.push(`${prefix}${label} ${wave.marker ?? ""}${cell === "" ? "" : ` ${cell}`}`.trimEnd());
535
- });
652
+ if (waves.length === 0) {
653
+ lines.push(` ${"wave".padEnd(LABEL_WIDTH)}(none)`);
654
+ }
655
+ else {
656
+ // The marker column is fixed-width: every wave label is padded to the widest
657
+ // label so the ✔/▶/○ markers align into one column (spec §5.3 · D40).
658
+ const labelWidth = Math.max(...waves.map((wave) => wave.label.length));
659
+ waves.forEach((wave, index) => {
660
+ const prefix = index === 0 ? ` ${"wave".padEnd(LABEL_WIDTH)}` : " ".repeat(2 + LABEL_WIDTH);
661
+ const cell = BoardView.summaryCell(wave.rounds, wave.carriers);
662
+ const label = wave.label.padEnd(labelWidth);
663
+ lines.push(`${prefix}${label} ${wave.marker ?? ""}${cell === "" ? "" : ` ${cell}`}`.trimEnd());
664
+ });
665
+ }
536
666
  }
537
667
  const branchLine = BoardView.#roundsLine("branch", "branch", progress, ledger);
538
668
  // The branch line's mark is the SAME drift-aware judgment its pipeline facts read
539
669
  // (`Ledger#lineStateAt`, identity document = the plan): a drifted plan reopens the
540
670
  // branch face, so the mark can never print `✔ closed` while `next:` names the
541
671
  // review the gate accepts — the reopened line renders as the CURRENT face (`▶`).
542
- const branchState = ledger?.lineStateAt("branch", "branch", sources.plan?.path ?? null) ?? "open";
672
+ const branchState = ledger?.lineStateAt("branch", "branch", planEntry?.path ?? null) ?? "open";
543
673
  const branchMark = branchState === "closed"
544
674
  ? `${PROGRESS_MARKERS.done} closed`
545
675
  : branchState === "reopened"
@@ -547,6 +677,23 @@ export class BoardView {
547
677
  : `${PROGRESS_MARKERS.pending} open`;
548
678
  const branchRounds = BoardView.summaryCell(branchLine.rounds, branchLine.carriers);
549
679
  lines.push(` ${"branch".padEnd(LABEL_WIDTH)}${branchMark}${branchRounds === "" ? "" : ` ${branchRounds}`}`.trimEnd());
680
+ // The `art:` fact block — the artifact inventory this node's rounds resolve to,
681
+ // rendered AFTER the line rows and BEFORE `next:` / `reason:` (the two last rows
682
+ // stay last, spec §2.6). A healthy tree adds zero bytes: only a `misplaced` /
683
+ // `invalid` judgment prints, and `--artifacts` alone opens the full inventory. The
684
+ // block never joins the tail counts — the findings axis and the artifact axis are
685
+ // two axes.
686
+ const artifactRows = BoardView.#artifactRows(BoardView.#artifactScopes({
687
+ docLines: docRows.map((row) => row.line),
688
+ waves,
689
+ branchLine,
690
+ nodeSeat,
691
+ overallSeat,
692
+ }), projection);
693
+ if (artifactRows.length > 0) {
694
+ lines.push("");
695
+ lines.push(...artifactRows);
696
+ }
550
697
  lines.push("");
551
698
  if (next === null) {
552
699
  lines.push(" next: (none)");
@@ -563,39 +710,67 @@ export class BoardView {
563
710
  * never participates in next, spec §6.5). The phase set derives from the ONE
564
711
  * index (`program:` grouping — no overall child-list array). A phase row's primary
565
712
  * key is its `slug:`, annotated with the truncated `title:`; any overall/phase
566
- * violation renders its marker and exits 2 (spec §3.1 — zero silent fallback). */
567
- static #programBoard(lines, index, entry, root) {
713
+ * violation renders its marker and exits 2 (spec §3.1 — zero silent fallback).
714
+ *
715
+ * The `art:` projection is the SAME one the node board renders (spec §2.4 · §2.6):
716
+ * the overall line is dispatched from the program workspace, so its own review
717
+ * rounds are the rounds a docs-fix gate judges, and the board must show that
718
+ * judgment before the dispatch. The scope binds the overall line to the program
719
+ * seat — the seat this render already holds — and `--artifacts` therefore opens the
720
+ * same inventory view here as on a node board (never a silent no-op). */
721
+ static #programBoard(readTable, plan, lines, index, entry, root, words, projection) {
568
722
  const repoRoot = root.absolute;
569
723
  const overallSlug = BoardView.#validSlug(entry);
570
- const ledger = overallSlug === null ? null : BoardView.#ledgerOf(overallSlug, repoRoot);
724
+ const seat = overallSlug === null
725
+ ? null
726
+ : BoardView.#ledgerOf(plan, overallSlug, repoRoot, projection.registry);
727
+ const ledger = seat?.ledger ?? null;
571
728
  const overallLine = BoardView.#lineOf("overall", "overall", entry, ledger?.readProgress() ?? null, ledger);
572
729
  const overallDoc = BoardView.#docCell(entry, overallLine, path.basename(entry.path).length, BoardView.#entryMark(index, entry, "identity"));
573
730
  lines.push(` ${"overall".padEnd(LABEL_WIDTH)}${overallDoc.text}`);
574
731
  lines.push("");
575
732
  let blocked = overallDoc.blocked;
576
733
  const phases = overallSlug === null ? [] : index.phaseSpecsOf(overallSlug);
577
- for (const phase of phases) {
734
+ for (const [pos, phase] of phases.entries()) {
735
+ // The phase's ONE plan value: `Cli#runBoard` builds the table in THIS row order
736
+ // (spec §2.1), so the cell and the `CDD_WARN:` line can never describe two
737
+ // different documents. A short table is a BROKEN caller contract — the board
738
+ // never mints a second read to cover it (`PlanRead#document()` sets the same
739
+ // posture), so the invariant answers by throwing.
740
+ if (pos >= readTable.length)
741
+ throw new Error("cdd: the board's per-phase plan table is shorter than its phase list");
742
+ const read = readTable[pos];
578
743
  const phaseSlug = BoardView.#validSlug(phase);
579
- const phaseLedger = phaseSlug === null ? null : BoardView.#ledgerOf(phaseSlug, repoRoot);
744
+ const phaseLedger = phaseSlug === null
745
+ ? null
746
+ : BoardView.#ledgerOf(plan, phaseSlug, repoRoot, projection.registry).ledger;
580
747
  const phaseProgress = phaseLedger?.readProgress() ?? null;
581
748
  const specLine = BoardView.#lineOf("spec", "phase-spec", phase, phaseProgress, phaseLedger);
582
- const planEntry = phaseSlug === null ? null : index.planOf(phaseSlug);
749
+ const planSlot = phaseSlug === null ? NO_DOC : BoardView.#docSlotOf(index, phaseSlug, "plan");
750
+ const planEntry = BoardView.#slotEntry(planSlot);
583
751
  const planLine = BoardView.#lineOf("plan", "plan", planEntry, phaseProgress, phaseLedger);
584
752
  const branchLine = BoardView.#roundsLine("branch", "branch", phaseProgress, phaseLedger);
585
753
  const mark = BoardView.#entryMark(index, phase, "identity") ??
586
754
  (BoardView.#programMissing(index, phase) ? MARK_PROGRAM_MISSING : null);
587
- const planMark = BoardView.#entryMark(index, planEntry, "plan");
755
+ const planMark = BoardView.#slotMark(index, planSlot, "plan");
588
756
  blocked ||= mark !== null || planMark !== null;
589
757
  const status = mark ?? phase.status ?? "Pending";
590
758
  // The phase's wave summary token (spec §5.3): the wave segment's first wave
591
759
  // number + an ellipsis (`wave W1…`) — the phase's wave progress at a glance,
592
760
  // derived from the SAME wave segment the phase board renders (no second read).
593
- const waves = BoardView.#waveLines(planEntry?.path ?? null, phaseProgress, phaseLedger);
594
- const waveCell = waves.length === 0 ? "" : `${waves[0].label.split(" ")[0]}…`;
761
+ // The READ owns the degradation literal (spec §2.4): `cell(words)` answers
762
+ // `""` only for a true undeclared phase, and null hands the healthy cell back
763
+ // to today's derivation.
764
+ const waveCell = read.cell(words) ?? BoardView.#waveCellOf(read, phaseProgress, phaseLedger);
765
+ // The plan cell of a phase whose slug names TWO plans: the marker plus both
766
+ // paths, never the first plan's summary (spec §2.3 — a set is answered by a set).
767
+ const planCell = planSlot.kind === "many"
768
+ ? [MARK_SLUG_DUPLICATED, planSlot.found.map((doc) => doc.rel).join(" · ")].join(" ")
769
+ : BoardView.summaryCell(planLine.rounds, planLine.carriers);
595
770
  const parts = [];
596
771
  const cells = [
597
772
  ["spec", BoardView.summaryCell(specLine.rounds, specLine.carriers)],
598
- ["plan", BoardView.summaryCell(planLine.rounds, planLine.carriers)],
773
+ ["plan", planCell],
599
774
  ["wave", waveCell],
600
775
  ["branch", BoardView.summaryCell(branchLine.rounds, branchLine.carriers)],
601
776
  ];
@@ -606,10 +781,57 @@ export class BoardView {
606
781
  const note = BoardView.#titleNote(phase.title);
607
782
  lines.push(` phase ${phase.slug ?? "(none)"} ${status}${tail === "" ? "" : ` ${tail}`}${note === "" ? "" : ` title: ${note}`}`);
608
783
  }
784
+ // The `art:` fact block, after the phase rows and before the rows that stay last
785
+ // (spec §2.6). One scope: the overall line, bound to the program seat — a phase's
786
+ // rounds belong to the phase's own board, exactly as a node board reads the
787
+ // program line through the program seat alone.
788
+ const artifactRows = BoardView.#artifactRows(seat === null ? [] : [{ lines: [overallLine], seat }], projection);
789
+ if (artifactRows.length > 0) {
790
+ lines.push("");
791
+ lines.push(...artifactRows);
792
+ }
609
793
  lines.push("");
610
794
  lines.push(" next: done");
611
795
  return blocked ? 2 : 0;
612
796
  }
797
+ /** The plan row's cell content when the READ owns the row — the STATUS-FIRST
798
+ * ladder of spec §2.1 · §2.7 (identity → read value → index):
799
+ *
800
+ * ① `mark !== null` (`slug: invalid` / `duplicated` / `missing`) → null: the
801
+ * row goes back to `#docCell`, which renders the marker and keeps exit 2.
802
+ * Identity breakage outranks the read value, so no accessor is asked.
803
+ * ② a non-ready read, or the `spec-absent` orphan → `planLine(words)` — the repo
804
+ * relative path plus the mark, never `#docCell`. Reason: a plan whose BODY
805
+ * breaks the grammar is still an indexed document (the index reads front
806
+ * matter only), so an index-first ladder would render `name version · status`
807
+ * and drop the `! unparseable` mark this phase's AC pins. The `slug-absent`
808
+ * read lands here too and its accessor answers null — the row then falls back
809
+ * to `#docCell`'s `MARK_SLUG_MISSING`, exit 2 untouched.
810
+ * ③ a healthy `ready` whose path IS this node's indexed plan entry → null: the
811
+ * row is today's `#docCell` bytes. A healthy `ready` the index does not name
812
+ * as this node's plan renders the bare path instead of `(none)` or another
813
+ * document's header — the registered `slug`-is-identity consequence.
814
+ *
815
+ * Null therefore means "`#docCell` owns this row", never "nothing to show". */
816
+ static #planCellOf(read, planEntry, mark, words) {
817
+ if (mark !== null)
818
+ return null;
819
+ const unread = read.kind !== "ready" || read.orphan()?.cause === "spec-absent";
820
+ if (unread)
821
+ return read.planLine(words);
822
+ const docPath = read.path();
823
+ // `DocEntry.path` is the absolute syscall form and the read's path is repo
824
+ // relative — `rel` is the ONE comparable identity (`entryAt`'s own key).
825
+ const indexed = planEntry !== null && planEntry.rel === docPath;
826
+ return indexed ? null : read.planLine(words);
827
+ }
828
+ /** The healthy program-face wave cell — the wave segment's first wave number plus
829
+ * an ellipsis (`W1…`, spec §5.3), derived from the SAME wave segment the phase
830
+ * board renders. Only a `cell(words) === null` (healthy) value reaches here. */
831
+ static #waveCellOf(read, progress, ledger) {
832
+ const first = BoardView.#waveLines(read, progress, ledger)[0];
833
+ return first === undefined ? "" : `${first.label.split(" ")[0]}…`;
834
+ }
613
835
  /** The phase-spec's `program:` gate (spec §2.2): a phase-spec naming no overall
614
836
  * (or carrying no `program:` at all) is a hard cancellation of the node. */
615
837
  static #programMissing(index, entry) {
@@ -653,49 +875,175 @@ export class BoardView {
653
875
  cells.push(rounds);
654
876
  return { text: cells.join(" "), blocked: false };
655
877
  }
878
+ // -------------------------------------------------------------------------
879
+ // the artifact projection (spec §2.6) — the matrix's judgment as an `art:` fact row
880
+ // -------------------------------------------------------------------------
881
+ /** The `art:` projection's scopes — the node's own lines bound to the node seat and
882
+ * the program's overall line bound to the program seat. The board OBSERVES names;
883
+ * it never mints one: every observed round's carrier path comes from the ledger's
884
+ * ONE accessor and every judgment from `ArtifactReads`. One record in, one scope set
885
+ * out (the two seats are told apart by name, never by argument position). */
886
+ static #artifactScopes(input) {
887
+ const scopes = [];
888
+ const overall = input.docLines[0];
889
+ if (input.overallSeat !== null && overall !== undefined) {
890
+ scopes.push({ lines: [overall], seat: input.overallSeat });
891
+ }
892
+ if (input.nodeSeat !== null) {
893
+ scopes.push({
894
+ lines: [...input.docLines.slice(1), ...input.waves, input.branchLine],
895
+ seat: input.nodeSeat,
896
+ });
897
+ }
898
+ return scopes;
899
+ }
900
+ /** The `art:` fact rows — one observed REVIEW round per record of each scope's lines,
901
+ * in `(cycle, attempt)` order. The observed set is the record sequence, never the
902
+ * workspace's name list: a `*.rulings.json` no record claims stays an `orphan:`
903
+ * observation and never enters this block (one name, one face). The judgment is the
904
+ * dispatch gate's own kind — `rulings` — read through the frame-free seam, so the
905
+ * board composes nothing a gate would compose differently.
906
+ *
907
+ * Default (no `--artifacts`): only the anomalous rounds render, so a healthy tree
908
+ * adds zero bytes. `--artifacts` opens the whole inventory: one row per observed
909
+ * round, one column per kind. */
910
+ static #artifactRows(scopes, projection) {
911
+ const artifacts = projection.registry;
912
+ if (artifacts === null)
913
+ return [];
914
+ const reads = (seat) => new ArtifactReads(artifacts, seat.workspace);
915
+ const observed = scopes.flatMap((scope) => BoardView.#observedOf(scope, artifacts, reads(scope.seat)));
916
+ observed.sort((left, right) => left.cycle - right.cycle || left.attempt - right.attempt);
917
+ return observed.flatMap((entry) => BoardView.#artifactBlockOf(entry, projection.showAll));
918
+ }
919
+ /** One scope's observed review rounds — the round records carrying a resolvable
920
+ * carrier, each read through the seam. A tampered carrier (a digest mismatch) is the
921
+ * `invalid` arm carrying the integrity message, never a thrown board. */
922
+ static #observedOf(scope, artifacts, reads) {
923
+ const basis = scope.seat.workspace.root.basis;
924
+ const observed = [];
925
+ for (const line of scope.lines) {
926
+ for (const record of line.rounds) {
927
+ if (record.op !== "review")
928
+ continue;
929
+ const carrier = scope.seat.ledger.carrierPathOf(line.type, line.key, record);
930
+ if (carrier === "")
931
+ continue;
932
+ observed.push({
933
+ line: BoardView.#artifactLineOf(artifacts, carrier, line.type),
934
+ kind: "rulings",
935
+ cycle: record.cycle,
936
+ attempt: record.attempt,
937
+ read: BoardView.#artifactReadOf(reads, carrier, record.carrierDigest ?? null),
938
+ relName: (name) => basis.relativize(scope.seat.workspace.resolve(name)),
939
+ relPath: (value) => basis.relativize(value),
940
+ });
941
+ }
942
+ }
943
+ return observed;
944
+ }
945
+ /** The observed round's line word — the carrier's OWN attributed identity (the
946
+ * reviewed round), falling back to the rendering line's word for a name the matrix
947
+ * cannot place. */
948
+ static #artifactLineOf(artifacts, carrier, fallback) {
949
+ const attributed = artifacts.attribute(path.basename(carrier));
950
+ return attributed !== null && attributed.identity.domain === "round"
951
+ ? attributed.identity.line
952
+ : fallback;
953
+ }
954
+ /** One composed read, with the integrity refusal folded into the `invalid` arm: a
955
+ * tampered carrier is a fact the board reports, never a crash of the read face. */
956
+ static #artifactReadOf(reads, carrier, digest) {
957
+ try {
958
+ return reads.read("rulings", carrier, digest);
959
+ }
960
+ catch (raw) {
961
+ if (!(raw instanceof CarrierMismatchError))
962
+ throw raw;
963
+ return { read: { kind: "invalid", path: "", reason: raw.message }, rulings: [] };
964
+ }
965
+ }
966
+ /** One observed round's `art:` block — the fact row plus its continuation lines. The
967
+ * default face prints anomalies alone; `--artifacts` prints every observed round and
968
+ * names its coordinate, so a troubleshooting view is one row per round while the
969
+ * daily view keeps its bytes. */
970
+ static #artifactBlockOf(entry, showAll) {
971
+ const read = entry.read.read;
972
+ const anomalous = read.kind === "misplaced" || read.kind === "invalid";
973
+ if (!showAll && !anomalous)
974
+ return [];
975
+ const coordinate = showAll ? ` · c${entry.cycle}·a${entry.attempt}` : "";
976
+ const arm = anomalous ? `! ${read.kind}` : read.kind;
977
+ const header = ` ${"art:".padEnd(LABEL_WIDTH)}${entry.line} · ${entry.kind}${coordinate} ${arm}`;
978
+ return [header, ...BoardView.#artifactFactsOf(entry, read)];
979
+ }
980
+ /** One `art:` block's continuation lines — the same facts the dispatch gate's
981
+ * `derived:` / `found:` report prints, on the board's own 9-column continuation
982
+ * shape. A healthy round carries none.
983
+ *
984
+ * The labels come from `ARTIFACT_FACT_LABELS`, NOT from `Words#artifactIdentity`:
985
+ * the two faces are two pinned contracts with different bytes — §2.4 fixes the
986
+ * gate's rows as ` derived: <value>` (colon, two-space column) while §2.6 fixes
987
+ * the board's as ` derived <value>` (no colon, the board's own
988
+ * continuation column). Sharing a label source would force one contract's bytes
989
+ * into the other; the words are therefore deliberately re-declared here once and
990
+ * pinned by the board's byte assertions. */
991
+ static #artifactFactsOf(entry, read) {
992
+ const labels = ARTIFACT_FACT_LABELS;
993
+ const value = (key, fact) => ` ${key.padEnd(LABEL_WIDTH)}${fact}`;
994
+ if (read.kind === "misplaced") {
995
+ const found = read.found.map((name) => entry.relName(name)).join(" · ");
996
+ return [value(labels.derived, entry.relName(read.derived)), value(labels.found, found)];
997
+ }
998
+ if (read.kind === "invalid") {
999
+ const derived = read.path === "" ? [] : [value(labels.derived, entry.relPath(read.path))];
1000
+ return [...derived, value(labels.reason, read.reason)];
1001
+ }
1002
+ return [];
1003
+ }
656
1004
  /** The node's ledger — the progress.json read face the render's closure/next
657
- * derivation consumes (each node reads its OWN workspace). */
658
- static #ledgerOf(nodeSlug, repoRoot) {
1005
+ * derivation consumes (each node reads its OWN workspace). The plan read seam is
1006
+ * the caller's per-command instance, threaded down unchanged: the board never
1007
+ * mints a second `PlanSource`. */
1008
+ static #ledgerOf(plan, nodeSlug, repoRoot, artifacts = null) {
659
1009
  const root = new WorkspaceRoot(repoRoot, ENGINE_RUNTIME.handoffNamespace.workspaceRoot);
660
- return new Ledger(new Workspace(root, nodeSlug), new ConfigLoader());
1010
+ // ONE workspace instance per node: the ledger resolves names inside it and the
1011
+ // `art:` projection's read seam takes the SAME instance (`ArtifactReads` binds its
1012
+ // base at construction), so a board never observes two spellings of one directory.
1013
+ const workspace = new Workspace(root, nodeSlug);
1014
+ return { ledger: new Ledger(workspace, new ConfigLoader(), plan, artifacts), workspace };
661
1015
  }
662
- /** pipelineFacts(index, entry, root) — the board's FACTS about the pipeline (spec
663
- * §5.2): the node's ledger and the pipeline frontier's declared input (the spec
664
- * word and path, the plan path, the guarded plan read). The board reports facts
665
- * only — the per-face observations and the four face-order rules live in the
1016
+ /** pipelineFacts(read, plan, index, entry, root, projection) — the board's FACTS
1017
+ * about the pipeline (spec §5.2): the node's ledger and the pipeline frontier's declared
1018
+ * input (the spec word and path, the plan path, the plan read). The board reports
1019
+ * facts only — the per-face observations and the four face-order rules live in the
666
1020
  * session plane's `PipelineFrontier`. Null when the node holds no legal slug (no
667
- * workspace to observe). */
668
- static pipelineFacts(index, entry, root) {
1021
+ * workspace to observe).
1022
+ *
1023
+ * `read` is the caller's ONE plan read (the same `PlanSource` instance): the
1024
+ * frontier's graph input is the value's own `graph()`, and the declared `planPath`
1025
+ * is that same value's `stationPath()` — the document the board read and the path
1026
+ * the frontier receives are ONE fact, with no fallback to a second plan lookup.
1027
+ * The wave segment reads the same value through `#waveLines`; the board has no
1028
+ * second plan read point. */
1029
+ static pipelineFacts(read, plan, index, entry, root, projection = NO_ARTIFACTS) {
669
1030
  const nodeSlug = BoardView.#validSlug(entry);
670
1031
  if (nodeSlug === null)
671
1032
  return null;
672
- const ledger = BoardView.#ledgerOf(nodeSlug, root.absolute);
1033
+ const ledger = BoardView.#ledgerOf(plan, nodeSlug, root.absolute, projection.registry).ledger;
673
1034
  const sources = BoardView.#nodeSources(index, entry);
674
- const specPath = sources.spec?.path ?? null;
675
- const planPath = sources.plan?.path ?? null;
1035
+ const specPath = BoardView.#slotEntry(sources.spec)?.path ?? null;
1036
+ // The path the frontier receives IS the path of the document this read opened —
1037
+ // never a second index-derived candidate that could name another file.
1038
+ const planPath = read.stationPath();
676
1039
  // The identity line's OWN word — the document's DECLARED `doc-type:` — keys the
677
1040
  // line and names the pipeline station (`single-spec` closes onto its `done` row).
678
- const specType = BoardView.#lineWordOf(sources.spec);
1041
+ const specType = BoardView.#lineWordOf(BoardView.#slotEntry(sources.spec));
679
1042
  return {
680
1043
  ledger,
681
- input: { specType, specPath, planPath, planGraph: BoardView.planGraph(planPath) },
1044
+ input: { specType, specPath, planPath, plan: read },
682
1045
  };
683
1046
  }
684
- /** The plan's task graph — the ONE guarded plan read behind the board's own wave
685
- * segment. `readFileSync` throwing on an unreadable plan is caught here: a null
686
- * plan path or an unreadable/absent file yields null, honoring the wave face's
687
- * "degradation, never a throw" contract. The pipeline frontier itself reads no
688
- * file — the composition root injects this read's result as its `planGraph` cell. */
689
- static planGraph(planPath) {
690
- if (planPath === null)
691
- return null;
692
- try {
693
- return new TaskGraph(new PlanDocType("plan").parse(readFileSync(planPath, "utf8").split("\n")));
694
- }
695
- catch {
696
- return null;
697
- }
698
- }
699
1047
  /** The branch line — a docless line whose rounds ride the `branch` row. */
700
1048
  static #roundsLine(label, key, progress, ledger) {
701
1049
  const rounds = BoardView.#rowRounds(progress, key);
@@ -707,30 +1055,36 @@ export class BoardView {
707
1055
  rounds,
708
1056
  carriers: LineCarriers.ofLedger(ledger, key, key, rounds),
709
1057
  marker: null,
1058
+ type: key,
1059
+ key,
710
1060
  };
711
1061
  }
712
1062
  /** The node's round RECORDS for one key — read through the ledger's ONE row lookup
713
- * (`Ledger.rowFor`: the retired `spec` row reads as the line its workspace DECLARES)
714
- * and the ONE record normalizer (`RoundRecords.of`, legacy forms folded); the
1063
+ * (`Ledger.rowFor`, literal: a retired `spec` row answers no document word) and the
1064
+ * ONE record normalizer (`RoundRecords.of`, legacy COUNT forms folded); the
715
1065
  * aggregation and the judgement glyphs read these records, never a pre-grouped cycle
716
1066
  * map. Failed rounds stay on the board (they consumed an identity slot); an absent row
717
1067
  * yields an empty list. */
718
- static #rowRounds(progress, key, identity = null) {
719
- const row = progress === null ? undefined : Ledger.rowFor(progress, key, identity);
1068
+ static #rowRounds(progress, key) {
1069
+ const row = progress === null ? undefined : Ledger.rowFor(progress, key);
720
1070
  return RoundRecords.of(row);
721
1071
  }
722
1072
  /** The node's wave segment — one line per derived wave (its ✔/▶/○ marker rides the
723
1073
  * SAME `TaskGraph.report(closedWaves())` read the board and the pre-flight gate
724
1074
  * share — the same source GraphView renders from), the wave's own `progress.json`
725
- * row spread alongside. No plan → empty segment (degradation, never a throw). */
726
- static #waveLines(planPath, progress, ledger) {
727
- const graph = BoardView.planGraph(planPath);
1075
+ * row spread alongside. The batch list is the READ's own `waves()` (spec §2.4) and
1076
+ * the graph is only the `report(...)` input; both are the read's eager derivation
1077
+ * (spec §2.1), never a second file read. A non-ready read has no graph and the
1078
+ * segment is empty. */
1079
+ static #waveLines(read, progress, ledger) {
1080
+ const graph = read.graph();
728
1081
  if (graph === null)
729
1082
  return [];
1083
+ const waves = read.waves();
730
1084
  const report = graph.report(ledger === null ? new Set() : ledger.closedWaves());
731
1085
  const done = new Set(report.done);
732
- const currentIndex = report.waves.findIndex((wave) => wave.some((id) => !done.has(id)));
733
- return report.waves.map((wave, index) => {
1086
+ const currentIndex = waves.findIndex((wave) => wave.some((id) => !done.has(id)));
1087
+ return waves.map((wave, index) => {
734
1088
  const closed = wave.every((id) => done.has(id));
735
1089
  const marker = closed
736
1090
  ? PROGRESS_MARKERS.done
@@ -747,6 +1101,8 @@ export class BoardView {
747
1101
  rounds,
748
1102
  carriers: LineCarriers.ofLedger(ledger, "wave", key, rounds),
749
1103
  marker,
1104
+ type: "wave",
1105
+ key,
750
1106
  };
751
1107
  });
752
1108
  }
@@ -763,10 +1119,24 @@ export class BoardView {
763
1119
  // biome-ignore lint/complexity/noStaticOnlyClass: the board's assembly fact surface — the zero-bare-function discipline admits no standalone functions here.
764
1120
  export class BoardNext {
765
1121
  /** The board's ONE `NextHop` — null when the entry holds no legal slug (no
766
- * workspace to observe) or the board is the program board (cross-phase never
767
- * participates in next, spec §6.5). */
768
- static of(index, entry, root) {
769
- const facts = entry.docType === "overall" ? null : BoardView.pipelineFacts(index, entry, root);
1122
+ * workspace to observe), when the board is the program board (cross-phase never
1123
+ * participates in next, spec §6.5), or when the plan read carries no evidence to
1124
+ * route on (spec §2.3): an `unreadable` plan, a `spec-absent` orphan and the
1125
+ * `duplicated` set short-circuit to the existing hop-less shape (` next:
1126
+ * (none)`, no `reason:` row). The predicate is the SAME pair §2.3 uses, never a
1127
+ * third condition; `undeclared` is NOT in it ("spec written, no plan yet" is the
1128
+ * standing `kairos:cdd-plan` route — and so is the undecided read, whose board
1129
+ * bytes are today's) and `slug-absent` is not either (the identity channel owns
1130
+ * its exit code). The duplicated set is not: two plans answer no single
1131
+ * document, so the plan route may not be printed (§2.7 (d)). */
1132
+ static of(read, plan, index, entry, root, projection = NO_ARTIFACTS) {
1133
+ if (read.kind === "duplicated")
1134
+ return null;
1135
+ if (read.kind === "unreadable" || read.orphan()?.cause === "spec-absent")
1136
+ return null;
1137
+ const facts = entry.docType === "overall"
1138
+ ? null
1139
+ : BoardView.pipelineFacts(read, plan, index, entry, root, projection);
770
1140
  return facts === null ? null : BoardNext.#hopOf(facts, root);
771
1141
  }
772
1142
  /** The session plane's ONE assembly, called with the board's facts and the face