@demlik/tea 0.11.0 → 0.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.
Files changed (163) hide show
  1. package/dist/agent/index.d.ts +6 -5
  2. package/dist/agent/index.js +11 -11
  3. package/dist/authed-call/index.d.ts +3 -2
  4. package/dist/authed-call/index.js +7 -7
  5. package/dist/await-terminal/index.d.ts +3 -2
  6. package/dist/await-terminal/index.js +2 -2
  7. package/dist/batch-window/index.d.ts +4 -3
  8. package/dist/batch-window/index.js +3 -3
  9. package/dist/cache/index.d.ts +3 -2
  10. package/dist/cache/index.js +4 -4
  11. package/dist/chart/index.d.ts +4 -3
  12. package/dist/chart/index.js +2 -2
  13. package/dist/chart/inspect/index.d.ts +5 -4
  14. package/dist/chart/inspect/index.js +3 -3
  15. package/dist/chart/inspect/react.d.ts +6 -5
  16. package/dist/chart/inspect/react.js +5 -5
  17. package/dist/chart/lane/index.d.ts +7 -6
  18. package/dist/chart/lane/index.js +6 -6
  19. package/dist/chart/lane/react.d.ts +6 -5
  20. package/dist/chart/lane/react.js +7 -7
  21. package/dist/chart/lane/viewer/assets/{chunk-5RXB4S5H-IPzIfiJ6.js → chunk-5RXB4S5H-CcNtpUd7.js} +1 -1
  22. package/dist/chart/lane/viewer/assets/{classDiagram-v2-OCEON4UE-DnUXz1Pv.js → classDiagram-v2-OCEON4UE-D4uAiFr8.js} +1 -1
  23. package/dist/chart/lane/viewer/assets/{dagre-VZM6K2ZE-Og2UIoWg.js → dagre-VZM6K2ZE-831qZcA8.js} +1 -1
  24. package/dist/chart/lane/viewer/assets/{index-sP-6AD57.css → index-9SkH5NA3.css} +1 -1
  25. package/dist/chart/lane/viewer/assets/{index-Obj05Jex.js → index-Bgt4sXpW.js} +4 -4
  26. package/dist/chart/lane/viewer/assets/{kanban-definition-27J2QSJJ-CxkCxJUN.js → kanban-definition-27J2QSJJ-G7PaPzy-.js} +1 -1
  27. package/dist/chart/lane/viewer/assets/{mindmap-definition-FAOFIHXS-DvgvXZhp.js → mindmap-definition-FAOFIHXS-CGj9nrVk.js} +1 -1
  28. package/dist/chart/lane/viewer/assets/{stateDiagram-OKZ733FA-CIZQWK5X.js → stateDiagram-OKZ733FA-B_88AzBS.js} +1 -1
  29. package/dist/chart/lane/viewer/assets/{stateDiagram-v2-UEYNNEHI-Sm6p0NoR.js → stateDiagram-v2-UEYNNEHI-CR5gcgq6.js} +1 -1
  30. package/dist/chart/lane/viewer/assets/{timeline-definition-Z64GVDOM-CV3KwSb-.js → timeline-definition-Z64GVDOM-CCv52MfY.js} +1 -1
  31. package/dist/chart/lane/viewer/index.html +2 -2
  32. package/dist/chart/report/index.d.ts +5 -4
  33. package/dist/chart/report/index.js +4 -4
  34. package/dist/{chunk-ZF6WDK2D.js → chunk-3I52QZZ5.js} +7 -7
  35. package/dist/{chunk-ZF6WDK2D.js.map → chunk-3I52QZZ5.js.map} +1 -1
  36. package/dist/{chunk-ZD6PNZBK.js → chunk-3ZAFFRRB.js} +3 -3
  37. package/dist/{chunk-ZD6PNZBK.js.map → chunk-3ZAFFRRB.js.map} +1 -1
  38. package/dist/{chunk-4KTWLPL5.js → chunk-4EQZ76JC.js} +3 -3
  39. package/dist/{chunk-4KTWLPL5.js.map → chunk-4EQZ76JC.js.map} +1 -1
  40. package/dist/{chunk-EUF7XOEE.js → chunk-4KLG43GY.js} +6 -6
  41. package/dist/{chunk-EUF7XOEE.js.map → chunk-4KLG43GY.js.map} +1 -1
  42. package/dist/{chunk-JER5O7PQ.js → chunk-7FRZ2CT2.js} +15 -7
  43. package/dist/chunk-7FRZ2CT2.js.map +1 -0
  44. package/dist/{chunk-ZCL7SCBK.js → chunk-CIQG5L42.js} +5 -5
  45. package/dist/{chunk-ZCL7SCBK.js.map → chunk-CIQG5L42.js.map} +1 -1
  46. package/dist/{chunk-TP5UPGLY.js → chunk-CLM6ERNO.js} +3 -3
  47. package/dist/{chunk-TP5UPGLY.js.map → chunk-CLM6ERNO.js.map} +1 -1
  48. package/dist/{chunk-ND3DH6KM.js → chunk-COS5MSTO.js} +3 -3
  49. package/dist/{chunk-ND3DH6KM.js.map → chunk-COS5MSTO.js.map} +1 -1
  50. package/dist/{chunk-JP5D6GSL.js → chunk-CRPZJVD2.js} +4 -4
  51. package/dist/{chunk-JP5D6GSL.js.map → chunk-CRPZJVD2.js.map} +1 -1
  52. package/dist/{chunk-SUST46KO.js → chunk-D62FDQKE.js} +3 -3
  53. package/dist/{chunk-SUST46KO.js.map → chunk-D62FDQKE.js.map} +1 -1
  54. package/dist/{chunk-JGVL3WPL.js → chunk-DGE4PV4A.js} +3 -3
  55. package/dist/{chunk-JGVL3WPL.js.map → chunk-DGE4PV4A.js.map} +1 -1
  56. package/dist/{chunk-WLGO64WC.js → chunk-DMYGQB4O.js} +4 -4
  57. package/dist/{chunk-WLGO64WC.js.map → chunk-DMYGQB4O.js.map} +1 -1
  58. package/dist/{chunk-A56OR5RF.js → chunk-L57ZOT5K.js} +3 -3
  59. package/dist/{chunk-A56OR5RF.js.map → chunk-L57ZOT5K.js.map} +1 -1
  60. package/dist/{chunk-5KJKJOFC.js → chunk-NR7BU22N.js} +3 -3
  61. package/dist/{chunk-5KJKJOFC.js.map → chunk-NR7BU22N.js.map} +1 -1
  62. package/dist/{chunk-7V4EVLZA.js → chunk-O4MVQTEJ.js} +4 -4
  63. package/dist/{chunk-7V4EVLZA.js.map → chunk-O4MVQTEJ.js.map} +1 -1
  64. package/dist/{chunk-B5VXOFMZ.js → chunk-OOYD44JI.js} +54 -3
  65. package/dist/chunk-OOYD44JI.js.map +1 -0
  66. package/dist/{chunk-7SVIRMC6.js → chunk-RH5EFRVJ.js} +3 -3
  67. package/dist/{chunk-7SVIRMC6.js.map → chunk-RH5EFRVJ.js.map} +1 -1
  68. package/dist/{chunk-3JU6657S.js → chunk-VYFAZN3F.js} +3 -3
  69. package/dist/{chunk-3JU6657S.js.map → chunk-VYFAZN3F.js.map} +1 -1
  70. package/dist/chunk-XGELA764.js +163 -0
  71. package/dist/chunk-XGELA764.js.map +1 -0
  72. package/dist/{chunk-I5OV65MS.js → chunk-YUXP55T2.js} +3 -3
  73. package/dist/{chunk-I5OV65MS.js.map → chunk-YUXP55T2.js.map} +1 -1
  74. package/dist/{chunk-E6GEDSF4.js → chunk-YWIKDKHY.js} +3 -3
  75. package/dist/{chunk-E6GEDSF4.js.map → chunk-YWIKDKHY.js.map} +1 -1
  76. package/dist/{chunk-5EHLEUTL.js → chunk-ZSUUOEPL.js} +51 -6
  77. package/dist/chunk-ZSUUOEPL.js.map +1 -0
  78. package/dist/{core-Bjc0bS8j.d.ts → core-Co0LWkIA.d.ts} +190 -3
  79. package/dist/deadline/index.d.ts +3 -2
  80. package/dist/deadline/index.js +3 -3
  81. package/dist/do/index.d.ts +12 -8
  82. package/dist/do/index.js +11 -11
  83. package/dist/do/index.js.map +1 -1
  84. package/dist/{durable-effects-D8SqU_if.d.ts → durable-effects-C6uwzjb5.d.ts} +1 -1
  85. package/dist/extension/index.d.ts +3 -2
  86. package/dist/extension/index.js +3 -3
  87. package/dist/extension/react.js +3 -3
  88. package/dist/extension/subs/index.d.ts +3 -2
  89. package/dist/fan-out/index.d.ts +3 -2
  90. package/dist/{fold-Blbhru48.d.ts → fold-BJPdjc9w.d.ts} +1 -1
  91. package/dist/{graph-CcjWZVrd.d.ts → graph-B3L5e0N1.d.ts} +1 -1
  92. package/dist/idempotent-intake/index.d.ts +3 -2
  93. package/dist/index.d.ts +14 -6
  94. package/dist/index.js +2 -2
  95. package/dist/journal/index.d.ts +373 -0
  96. package/dist/journal/index.js +3 -0
  97. package/dist/journal/index.js.map +1 -0
  98. package/dist/llm-call/index.d.ts +3 -2
  99. package/dist/llm-call/index.js +8 -8
  100. package/dist/{machine-0OmPvsy_.d.ts → machine-BtFWQmmq.d.ts} +1 -1
  101. package/dist/machine-viz/index.d.ts +2 -1
  102. package/dist/machine-viz/index.js +2 -2
  103. package/dist/mem/index.d.ts +3 -2
  104. package/dist/monitored-run/index.d.ts +4 -3
  105. package/dist/monitored-run/index.js +5 -5
  106. package/dist/node/index.d.ts +31 -3
  107. package/dist/node/index.js +92 -3
  108. package/dist/node/index.js.map +1 -1
  109. package/dist/paginated-walk/index.d.ts +3 -2
  110. package/dist/paginated-walk/index.js +7 -7
  111. package/dist/parity/index.d.ts +3 -2
  112. package/dist/parity/index.js +3 -3
  113. package/dist/pbt/arbitraries/index.d.ts +2 -1
  114. package/dist/pbt/index.d.ts +2 -1
  115. package/dist/pbt/index.js +3 -3
  116. package/dist/pbt/runners/index.d.ts +2 -1
  117. package/dist/pbt/runners/index.js +3 -3
  118. package/dist/poller/index.d.ts +3 -2
  119. package/dist/poller/index.js +3 -3
  120. package/dist/prediction/index.d.ts +2 -1
  121. package/dist/prediction/index.js +2 -2
  122. package/dist/pure/index.d.ts +2 -1
  123. package/dist/pure/index.js +2 -2
  124. package/dist/react/index.d.ts +4 -3
  125. package/dist/react/index.js +2 -2
  126. package/dist/react/index.js.map +1 -1
  127. package/dist/reconciler/index.d.ts +3 -2
  128. package/dist/reconciler/index.js +7 -7
  129. package/dist/recorder/index.d.ts +3 -2
  130. package/dist/{reducer-BqyoVyBG.d.ts → reducer-4GNR6b8B.d.ts} +2 -2
  131. package/dist/resilient-call/index.d.ts +3 -2
  132. package/dist/resilient-call/index.js +6 -6
  133. package/dist/{run-BVeqJDBF.d.ts → run-pAcmBpah.d.ts} +3 -3
  134. package/dist/{runtime-types-Bxc637bp.d.ts → runtime-types-CNLmhWif.d.ts} +17 -2
  135. package/dist/saga/index.d.ts +3 -2
  136. package/dist/{samples-DCt6nF8H.d.ts → samples-B3My5oh2.d.ts} +1 -1
  137. package/dist/snapshot/index.d.ts +2 -1
  138. package/dist/snapshot/index.js +3 -3
  139. package/dist/subs/index.d.ts +4 -3
  140. package/dist/subs/index.js +3 -3
  141. package/dist/testing/index.d.ts +3 -2
  142. package/dist/testing/index.js +2 -2
  143. package/dist/throttled-input/index.d.ts +3 -2
  144. package/dist/throttled-input/index.js +6 -6
  145. package/dist/token-refresh/index.d.ts +2 -1
  146. package/dist/token-refresh/index.js +3 -3
  147. package/dist/trace-replay/index.d.ts +3 -2
  148. package/dist/trace-replay/index.js +3 -3
  149. package/dist/{types-D7u9DkH7.d.ts → types-XS_miRnB.d.ts} +1 -1
  150. package/dist/with-deadline/index.d.ts +2 -1
  151. package/dist/with-deadline/index.js +2 -2
  152. package/dist/with-resilience/index.d.ts +3 -2
  153. package/dist/with-resilience/index.js +6 -6
  154. package/dist/with-telemetry/index.d.ts +2 -1
  155. package/dist/with-telemetry/index.js +2 -2
  156. package/dist/work-queue/adapter.d.ts +3 -2
  157. package/dist/work-queue/index.d.ts +3 -2
  158. package/dist/work-queue/ops.d.ts +3 -2
  159. package/dist/workflow/index.d.ts +4 -3
  160. package/package.json +11 -4
  161. package/dist/chunk-5EHLEUTL.js.map +0 -1
  162. package/dist/chunk-B5VXOFMZ.js.map +0 -1
  163. package/dist/chunk-JER5O7PQ.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/chart/report/draw.ts","../src/chart/report/workflow.ts","../src/chart/report/fold.ts","../src/chart/report/report.ts"],"names":[],"mappings":";;;AA4CO,SAAS,QAAA,CAAS,KAAA,EAAsB,IAAA,GAAoB,EAAC,EAAW;AAC7E,EAAA,OAAO,aAAa,KAAA,EAAgB;AAAA,IAClC,QAAA,EAAU,IAAA;AAAA,IACV,GAAI,KAAK,OAAA,KAAY,MAAA,GAAY,EAAC,GAAI,EAAE,SAAA,EAAW,IAAA,CAAK,OAAA,EAAQ;AAAA,IAChE,GAAI,KAAK,MAAA,KAAW,MAAA,GAAY,EAAC,GAAI,EAAE,MAAA,EAAQ,IAAA,CAAK,MAAA;AAAO,GAC5D,CAAA;AACH;AAUO,SAAS,YACd,KAAA,EACY;AACZ,EAAA,MAAM,MAAA,uBAAa,GAAA,EAAoB;AACvC,EAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,IAAA,MAAA,CAAO,GAAA,C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,KAAA,EAAyC;AACnE,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,KAAK,KAAK,CAAA,+BAAA,CAAA;AAChD,EAAA,MAAM,QAAkB,EAAC;AACzB,EAAA,KAAA,MAAW,CAAC,KAAA,EAAO,IAAI,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AACjD,IAAA,IAAI,OAAO,SAAS,QAAA,EAAU;AAC5B,MAAA,KAAA,CAAM,IAAA,CAAK,CAAA,EAAA,EAAK,KAAK,CAAA,IAAA,EAAO,IAAI,CAAA,CAAE,CAAA;AAClC,MAAA;AAAA,IACF;AACA,IAAA,MAAM,QAAQ,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,CAC9B,GAAA,CAAI,CAAC,CAAC,IAAA,EAAM,KAAK,CAAA,KAAM,KAAK,IAAI,CAAA,OAAA,EAAU,KAAK,CAAA,EAAA,CAAI,CAAA,CACnD,KAAK,IAAI,CAAA;AACZ,IAAA,KAAA,CAAM,IAAA,CAAK,CAAA,EAAA,EAAK,KAAK,CAAA,UAAA,EAAQ,KAAK,CAAA,CAAE,CAAA;AAAA,EACtC;AACA,EAAA,OAAO,KAAA,CAAM,KAAK,QAAK,CAAA;AACzB","file":"chunk-5KJKJOFC.js","sourcesContent":["// ═══════════════════════════════════════════════════════════════════════════\n// THE DIAGRAM SEAM — now a translation, not a drawing.\n//\n// This file used to hold a SECOND mermaid renderer, standing in until\n// `chartMermaid` grew an options bag. It grew one, so the swap this banner\n// promised has happened: `drawTask` is the report's door onto the one renderer\n// in `../compile`, and the two facts a report needs on top of the chart —\n// WHERE THE TASK IS NOW and WHICH EDGES IT WALKED — are options on that\n// drawing rather than a drawing of their own.\n//\n// The seam itself is unchanged and is why the swap was one function wide: the\n// report's markdown layout, its vocabulary and its timeline do not know how a\n// diagram is made.\n//\n// WHY THIS FILE STILL EXISTS rather than the report calling `chartMermaid`\n// directly. `chartMermaid` is typed `<const C extends Chart<C>>` — the\n// F-bounded literal chart, whose state and event names are literal types the\n// compiler recovered from a source literal. A report draws an `ImportedChart`,\n// whose every name is a runtime `string` read out of somebody's\n// `workflow.json`. That widening is real and it is not the report's to make at\n// eight call sites: it is made here, once, with the reason written next to it.\n// ═══════════════════════════════════════════════════════════════════════════\nimport { chartMermaid, type WalkCounts } from \"../compile\";\nimport type { ImportedChart } from \"./workflow\";\n\nexport { edgeKey, type WalkCounts } from \"../compile\";\n\nexport interface DrawOptions {\n /** The state the task is in right now — lit. */\n readonly current?: string;\n /** Edges the log actually walked, keyed `${from}|${event}|${to}`. */\n readonly walked?: WalkCounts;\n}\n\n/**\n * One task's region as a mermaid `stateDiagram-v2` block, with the current node\n * lit, the walked edges marked and the two endings drawn apart.\n *\n * `polarity` is always on: a lane's whole point is that `shipped` and `frozen`\n * are not the same ending, and a report that painted them alike would be lying\n * in the place a reader looks first. It is an OPTION on the renderer rather\n * than a default because a chart drawing is something a reviewer approves —\n * see `ChartMermaidOptions.polarity`.\n */\nexport function drawTask(chart: ImportedChart, opts: DrawOptions = {}): string {\n return chartMermaid(chart as never, {\n polarity: true,\n ...(opts.current === undefined ? {} : { highlight: opts.current }),\n ...(opts.walked === undefined ? {} : { walked: opts.walked }),\n });\n}\n\n/**\n * The edges a log walked, counted — the input `drawTask` marks from.\n *\n * Reads each step's DECLARED `edge` rather than recomputing one from\n * `from`/`event`/`to`: a resume edge is drawn to its fallback and walked to\n * wherever `was` pointed, so the observed target names an edge the drawing does\n * not have. `TimelineStep.edge` is the edge that actually fired.\n */\nexport function walkedEdges(\n steps: readonly { readonly edge: string }[],\n): WalkCounts {\n const counts = new Map<string, number>();\n for (const step of steps) {\n counts.set(step.edge, (counts.get(step.edge) ?? 0) + 1);\n }\n return counts;\n}\n","// ═══════════════════════════════════════════════════════════════════════════\n// THE IMPORTER — one `workflow.json` in, one chart per task out.\n//\n// This is the mirror of `kamp-us/phoenix` `packages/fabrika-cli/src/lane/\n// machine.ts`, and it is deliberately STRUCTURAL in exactly the same three\n// places, because that is what makes the two agree:\n//\n// an `on` string → `{ target }`\n// an `on` two-arm array → `{ target, when, otherwise }` (guarded)\n// a target of `type: \"history\"` → `{ resume: { fallback: <region initial> } }`\n// `type: \"final\"` → `end: true`\n// …reached as an array's fallthrough → `end: \"error\"`\n// machine-level `type: \"parallel\"` → a phase; its `onDone` pair → the terminals\n//\n// GRAMMAR, NEVER VOCABULARY. Every rule above is about what makes a document\n// WELL-FORMED — a state routes events to targets, a guarded edge is a two-arm\n// array, a `history` target means resume, a `final` is terminal. None of them\n// is about WHICH NAMES a consumer chose. So the event alphabet is read OFF the\n// document: a name a state declares is, by definition, an event of that\n// document, and there is no list here for it to be absent from.\n//\n// That is not a relaxation for its own sake. This file used to carry a consumer's\n// six event names as a closed set, which meant one upstream commit adding a\n// seventh took the importer offline for every document, not just the new one —\n// the same failure mode the report had when it matched STATE names, and the same\n// fix: enforce the shape, read the names.\n//\n// No guard name and no action name is ever dereferenced here, for the same\n// reason fabrika does not dereference them: the ARRAY is the guard. The name\n// travels into the chart's `when` because the chart draws it, and the fold\n// applies the one inline predicate (`retries < maxRetries`) the compiler\n// applies, whatever the name says. An event name is the same kind of thing.\n// ═══════════════════════════════════════════════════════════════════════════\n\nimport type { EventOrigin } from \"../graph\";\n\n/** `TASK_1.DONE` and `DONE` are the same event; the namespace is presentation. */\nexport const bareEvent = (event: string): string => {\n const dot = event.indexOf(\".\");\n return dot === -1 ? event : event.slice(dot + 1);\n};\n\n// ── the imported chart's shape ─────────────────────────────────────────────\n//\n// RUNTIME-TYPED, and the doc comment on `chartFromWorkflow` says why. These\n// interfaces are the chart's VALUE shape narrowed to the three edge forms a\n// fabrika region can produce — not `Chart<C>`, whose whole content is literal\n// types recovered from a literal the compiler can see.\n\n/** A declarative edge, in the only three forms a lane region can produce. */\n/**\n * `cmd` / `otherwiseCmd` are carried but never AUTHORED here: a `workflow.json`\n * declares no effects, so an imported edge simply has neither. They exist\n * because the TYPED door has them and lowering used to drop them, which left a\n * lane page able to say where a click LANDS and never what it FIRES — a fact\n * the author wrote down, lost in translation.\n */\ntype ImportedCmds = {\n readonly cmd?: string | readonly string[];\n readonly otherwiseCmd?: string | readonly string[];\n};\n\nexport type ImportedEdge =\n | ({ readonly target: string } & ImportedCmds)\n | ({\n readonly target: string;\n readonly when: string;\n readonly otherwise: string;\n } & ImportedCmds)\n | ({ readonly resume: { readonly fallback: string } } & ImportedCmds);\n\nexport interface ImportedNode {\n readonly initial?: true;\n readonly on?: Readonly<Record<string, ImportedEdge>>;\n /** `true` success final, `\"error\"` the fallthrough final that trips the lane. */\n readonly end?: true | \"error\";\n}\n\n/** One task's region, as a chart value. One phase group, named by the phase. */\nexport interface ImportedChart {\n readonly events: Readonly<\n Record<\n string,\n {\n readonly scope: \"edges\";\n /**\n * Where this event comes from — the chart's `from`, at runtime.\n *\n * OPTIONAL, and its absence is the document's honest answer:\n * `workflow.json` records the topology and nothing about who sends\n * what, so this is present exactly when the caller supplied it at\n * {@link chartFromWorkflow}.\n */\n readonly from?: EventOrigin;\n }\n >\n >;\n readonly states: Readonly<\n Record<string, Readonly<Record<string, ImportedNode>>>\n >;\n /**\n * State name → the events that state ACCEPTS AND DROPS, leaving itself alone.\n *\n * THE THIRD ANSWER. A lane state either routes an event, or refuses it, or\n * cannot replay it — tea's runtime has always had all three (`compile`'s\n * `refused` self-loops a pair the state's `ignore` names or the event's\n * `scope` does not address, and only a LIVE-but-undecided pair throws), and\n * the lowered chart could carry only two. So `stepTask` threw\n * `UnreplayableLogError` on a log `runLane` had accepted without blinking: a\n * run and a report of that run disagreeing, which is the one thing this\n * module promises they cannot do.\n *\n * IT IS ON THE CHART, NOT ON THE NODE, and that is deliberate.\n * {@link ImportedNode} is a MIRROR of the node fabrika's own compiler emits —\n * `golden.test.ts` compares the two — so a field fabrika never produces does\n * not belong inside it. This is our layer's annotation about someone else's\n * shape, and it sits one level out where it reads as one.\n *\n * ABSENT AT THE IMPORTED DOOR, always. A refusal is a fact about a state's\n * `ignore` and an event's `scope`, and `workflow.json` records neither — so\n * `chartFromWorkflow` writes none, an imported chart is the same value it\n * always was, and an imported log naming an unrouted event is still refused\n * loudly. Only `defineLane`'s lowering, which can SEE the two, fills it in.\n */\n readonly refusals?: Readonly<Record<string, readonly string[]>>;\n}\n\nexport interface ImportedPhase {\n readonly name: string;\n readonly tasks: readonly string[];\n}\n\nexport interface ImportedLane {\n /** The document's own `id`, when it carries one. */\n readonly id?: string;\n /** What fires this lane — a chore workflow's own field, carried not invented. */\n readonly trigger?: string;\n readonly phases: readonly ImportedPhase[];\n /** The workflow's two terminals, read off the last phase's `onDone` pair. */\n readonly terminals: { readonly complete: string; readonly tripped: string };\n /** One chart per task id — the ask's `charts`. */\n readonly charts: Readonly<Record<string, ImportedChart>>;\n /**\n * The document's `context` per task, minus the retry bookkeeping the fold\n * owns. `maxRetries` is split out because it is a transition input, not a\n * passenger — the guarded arm reads it.\n */\n readonly context: Readonly<\n Record<\n string,\n {\n readonly maxRetries: number;\n readonly extras: Readonly<Record<string, unknown>>;\n }\n >\n >;\n}\n\n/**\n * THE ONE PLACE PROVENANCE ENTERS.\n *\n * `workflow.json` carries topology and nothing else: it says `queued --WIP-->\n * build` and it does not say, and has never said, who sends a `WIP`. That fact\n * lives in fabrika's CODE, not in fabrika's document — so it cannot be read\n * here and it must not be guessed here.\n *\n * So the caller states it, ONCE, at the seam where their world meets ours, and\n * everything downstream derives from that: the charts carry it, the report\n * groups by it, the inspector reports it. One map, at the boundary the\n * information actually crosses — not a default sprinkled through the readers,\n * and not a table of fabrika's own event names baked in as a fallback, which\n * would put us right back to owning a copy of someone else's vocabulary.\n *\n * ```ts\n * chartFromWorkflow(document, {\n * from: {\n * WIP: { world: \"the operator\" },\n * BLOCKED: { world: \"the operator\" },\n * UNBLOCKED: { world: \"a human\" },\n * DONE: \"cmd\",\n * PASS: \"cmd\",\n * FAIL: \"cmd\",\n * },\n * });\n * ```\n *\n * Omit it and every reader degrades honestly — it says which events a state\n * accepts and refuses to say who they come from.\n */\nexport interface WorkflowImportOptions {\n /**\n * Event name → where its Msg comes from. Keyed by the BARE name, so one\n * entry covers every task's namespaced spelling of it (`ISSUE.WIP`,\n * `PARK_SWEEP.WIP`) — the namespace is presentation, the event is the event.\n *\n * A name with no entry is left undeclared rather than defaulted. \"I do not\n * know\" and \"the outside world\" are different answers and only one of them\n * is safe to invent.\n */\n readonly from?: Readonly<Record<string, EventOrigin>>;\n /**\n * Refuse a `from` key that names no event THIS document routes.\n *\n * The silent drop it closes is real: `UNBLOKED: { world: \"a human\" }` imports\n * clean, and every reader downstream then answers \"the chart does not say\"\n * for the one event the caller had just taken the trouble to declare. The\n * cross-check needs no list of ours — {@link eventAlphabet} derives the\n * document's own alphabet, which is precisely what that function exists for\n * and what nothing was calling.\n *\n * OPT-IN, because the map is legitimately WIDER than one document. A\n * consumer's cast is a property of their world, not of one template, so one\n * `from` covers every workflow they run — `src/chart/report/__fixtures__/\n * origins.ts` states fabrika's six once and imports two templates with it,\n * and the chore template routes neither `PASS` nor `FAIL`. Defaulting to\n * strict would make sharing a cast an error, which is the wrong half of the\n * trade. So the caller says which of the two they meant: pass this when the\n * map was written FOR this document, and a typo in it stops compiling.\n */\n readonly strictFrom?: true;\n}\n\n/**\n * The document does not fit — with EVERY defect named, never a half-import.\n *\n * Same contract as fabrika's `Malformed`: a `workflow.json` that cannot be\n * compiled comes back as a list of reasons rather than as a machine that works\n * for some states. Thrown rather than returned because the chart module's other\n * doors throw too (`initialStateOf`, `CellTargetError`) and an importer that\n * returned a union would be the only one a caller could forget to check.\n */\nexport class WorkflowImportError extends Error {\n override readonly name = \"WorkflowImportError\";\n readonly _tag = \"WorkflowImportError\" as const;\n constructor(public readonly defects: readonly string[]) {\n super(\n `@demlik/tea: this workflow.json does not compile to charts —\\n` +\n defects.map((d) => ` • ${d}`).join(\"\\n\"),\n );\n }\n}\n\nconst isRecord = (v: unknown): v is Record<string, unknown> =>\n typeof v === \"object\" && v !== null && !Array.isArray(v);\n\nconst nodeType = (node: unknown): string | undefined =>\n isRecord(node) && typeof node.type === \"string\" ? node.type : undefined;\n\n/**\n * The retry budget a document inherits when its `context` names none.\n *\n * Exported because the fold needs the same number when it boots a task the\n * document's `context` never mentioned, and a default spelled in two files is\n * a default that drifts in one of them.\n */\nexport const RETRY_BUDGET = 2;\n\n/**\n * The `when` a guarded arm carries when the document names no guard.\n *\n * A DESCRIPTION OF THE GRAMMAR, not a borrowed name. A two-arm array means\n * \"retry while the budget holds, else fall through\" in every document, because\n * that is what the array IS — so when the author wrote no label, the label says\n * the thing the array already said. Defaulting to some consumer's guard name\n * (`retriesRemaining`) would print their word over another consumer's document.\n */\nconst DEFAULT_GUARD = \"retries remain\";\n\ninterface RegionImport {\n readonly node?: Readonly<Record<string, ImportedNode>>;\n readonly defects: readonly string[];\n}\n\n/** One task region → the phase group's state bag. `hist` is DROPPED, not kept. */\nfunction importRegion(taskId: string, region: unknown): RegionImport {\n const defects: string[] = [];\n if (\n !isRecord(region) ||\n !isRecord(region.states) ||\n typeof region.initial !== \"string\"\n ) {\n return {\n defects: [\n `task \"${taskId}\": region must carry string \\`initial\\` and \\`states\\``,\n ],\n };\n }\n const states = region.states;\n const initialState = region.initial;\n if (states[initialState] === undefined) {\n defects.push(\n `task \"${taskId}\": initial state \"${initialState}\" is not in \\`states\\``,\n );\n }\n\n // Pass 1: which names are finals at all. The polarity needs the whole set\n // before any edge is read, because an error final is recognised by the edge\n // that REACHES it and the edge may be declared before the state.\n const finals = new Set<string>();\n for (const [name, node] of Object.entries(states)) {\n if (nodeType(node) === \"final\") finals.add(name);\n }\n const errorFinals = new Set<string>();\n\n // Pass 2: the edges.\n const on: Record<string, Record<string, ImportedEdge>> = {};\n for (const [stateName, node] of Object.entries(states)) {\n // `hist` IS a state node in the document and is NOT a chart state: the\n // chart carries history as a property of the EDGE (`resume`), which is why\n // it needs no pseudo-state to point at. Dropping it here is the same drop\n // fabrika's compiler makes, one line above its own table build.\n if (nodeType(node) === \"history\") continue;\n const edges: Record<string, ImportedEdge> = {};\n on[stateName] = edges;\n if (!isRecord(node)) {\n defects.push(`task \"${taskId}\": state \"${stateName}\" is not an object`);\n continue;\n }\n const raw = node.on ?? {};\n if (!isRecord(raw)) {\n defects.push(\n `task \"${taskId}\": state \"${stateName}\" carries a non-object \\`on\\``,\n );\n continue;\n }\n // Which bare name each spelling in THIS state collapsed to, so the one\n // event-name rule that IS grammatical can be checked: a state holds one\n // cell per event, so two spellings of one event in one state is a document\n // that means two things by the same edge. Nothing here cares WHICH names.\n const spelledAs = new Map<string, string>();\n for (const [eventName, transition] of Object.entries(raw)) {\n const event = bareEvent(eventName);\n if (event === \"\") {\n defects.push(\n `task \"${taskId}\": state \"${stateName}\" listens for \"${eventName}\", which names no event once its namespace is stripped`,\n );\n continue;\n }\n const already = spelledAs.get(event);\n if (already !== undefined) {\n defects.push(\n `task \"${taskId}\": state \"${stateName}\" spells the same event twice — \"${already}\" and \"${eventName}\" are both \\`${event}\\`, and a state routes each event once`,\n );\n continue;\n }\n spelledAs.set(event, eventName);\n\n // ── the guarded array ────────────────────────────────────────────────\n if (Array.isArray(transition)) {\n const arms = transition.map((arm) =>\n isRecord(arm) && typeof arm.target === \"string\"\n ? arm.target\n : undefined,\n );\n const [retry, fallthrough] = arms;\n if (\n transition.length !== 2 ||\n retry === undefined ||\n fallthrough === undefined\n ) {\n defects.push(\n `task \"${taskId}\": guarded \"${eventName}\" must be a two-arm array of \\`{target}\\` — [retry-while-retries-remain, else-fallthrough]`,\n );\n continue;\n }\n for (const target of [retry, fallthrough]) {\n if (states[target] === undefined) {\n defects.push(\n `task \"${taskId}\": \"${eventName}\" targets unknown state \"${target}\"`,\n );\n }\n }\n // THE POLARITY, recognised exactly where fabrika recognises it: a final\n // reached as the fallthrough is the task's error terminal.\n if (finals.has(fallthrough)) errorFinals.add(fallthrough);\n const head = transition[0];\n const when =\n isRecord(head) && typeof head.guard === \"string\"\n ? head.guard\n : DEFAULT_GUARD;\n edges[event] = { target: retry, when, otherwise: fallthrough };\n continue;\n }\n\n if (typeof transition !== \"string\") {\n defects.push(\n `task \"${taskId}\": \"${eventName}\" is neither a target nor a guarded array`,\n );\n continue;\n }\n if (states[transition] === undefined) {\n defects.push(\n `task \"${taskId}\": \"${eventName}\" targets unknown state \"${transition}\"`,\n );\n continue;\n }\n // ── the history target ───────────────────────────────────────────────\n edges[event] =\n nodeType(states[transition]) === \"history\"\n ? { resume: { fallback: initialState } }\n : { target: transition };\n }\n }\n\n if (defects.length > 0) return { defects };\n\n const out: Record<string, ImportedNode> = {};\n for (const [name, node] of Object.entries(states)) {\n if (nodeType(node) === \"history\") continue;\n const edges = on[name] ?? {};\n const isFinal = finals.has(name);\n out[name] = {\n ...(name === initialState ? { initial: true as const } : {}),\n ...(Object.keys(edges).length > 0 ? { on: edges } : {}),\n ...(isFinal\n ? { end: errorFinals.has(name) ? (\"error\" as const) : (true as const) }\n : {}),\n };\n }\n return { node: out, defects: [] };\n}\n\n/** The two targets of a phase's `onDone` pair: `[guarded success, fallthrough]`. */\nfunction onDoneTargets(\n phaseName: string,\n onDone: unknown,\n): { targets?: readonly [string, string]; defect?: string } {\n const defect = `phase \"${phaseName}\": \\`onDone\\` must be a two-arm array of \\`{target}\\` — [{target, guard}, {target}]`;\n if (!Array.isArray(onDone) || onDone.length !== 2) return { defect };\n const [success, trip] = onDone.map((arm) =>\n isRecord(arm) && typeof arm.target === \"string\" ? arm.target : undefined,\n );\n return success === undefined || trip === undefined\n ? { defect }\n : { targets: [success, trip] as const };\n}\n\n/**\n * `workflow.json` → one chart per task, plus the phase topology around them.\n *\n * WHICH HALF GUARANTEES WHAT — this matters, and it is the whole reason the\n * authored fixture (`src/chart/__fixtures__/lane.ts`) still exists beside this\n * function rather than being deleted in its favour:\n *\n * THIS FUNCTION gives you FIDELITY. It reads bytes that only exist at\n * runtime, so its result is `ImportedChart` — states, events and targets are\n * `string`, and nothing about them is checked before the process starts. What\n * it buys is that the drawing is of THE document the driver is actually\n * folding, including a `workflow.json` this repo has never seen.\n *\n * THE AUTHORED FIXTURE gives you TYPES. `lane.ts` is the same machine written\n * as a literal, so `StateName`, `ResumeTargets`, `Assigns` and the totality\n * obligation are all real there, and `assert.test-d.ts` pins them. What it\n * cannot do is follow a document it was not written against.\n *\n * Neither replaces the other. The golden test is the seam: it asserts this\n * importer's edge set against what fabrika's own compiler produces for the same\n * file, so the runtime-typed half stays honest about the literal-typed one.\n *\n * @param document the PARSED `workflow.json` — `JSON.parse`'s output, not text.\n * @param options {@link WorkflowImportOptions} — the facts the document does\n * not carry, stated once at the boundary they enter through.\n * @throws {WorkflowImportError} with every defect named, never a half-import.\n */\nexport function chartFromWorkflow(\n document: unknown,\n options: WorkflowImportOptions = {},\n): ImportedLane {\n const defects: string[] = [];\n const machineDef = isRecord(document) ? document.machine : undefined;\n if (!isRecord(machineDef) || !isRecord(machineDef.states)) {\n throw new WorkflowImportError([\n \"document must carry a `machine.states` object\",\n ]);\n }\n const documentContext = isRecord(machineDef.context)\n ? machineDef.context\n : {};\n const declaredTrigger = isRecord(document) ? document.trigger : undefined;\n if (declaredTrigger !== undefined && typeof declaredTrigger !== \"string\") {\n defects.push(\n \"document `trigger` must be a string naming what fires this lane\",\n );\n }\n\n const machineStates = machineDef.states;\n const charts: Record<string, ImportedChart> = {};\n const context: Record<\n string,\n {\n readonly maxRetries: number;\n readonly extras: Readonly<Record<string, unknown>>;\n }\n > = {};\n const phases: ImportedPhase[] = [];\n const gateTargets = new Set<string>();\n let terminals: { complete: string; tripped: string } | undefined;\n\n for (const [phaseName, node] of Object.entries(machineStates)) {\n if (nodeType(node) !== \"parallel\" || !isRecord(node)) continue;\n const regions = node.states;\n if (!isRecord(regions) || Object.keys(regions).length === 0) {\n defects.push(\n `phase \"${phaseName}\": a parallel phase must carry task regions in \\`states\\``,\n );\n continue;\n }\n const phaseTasks: string[] = [];\n for (const [taskId, region] of Object.entries(regions)) {\n const imported = importRegion(taskId, region);\n defects.push(...imported.defects);\n if (imported.node !== undefined) {\n const events: Record<\n string,\n { readonly scope: \"edges\"; readonly from?: EventOrigin }\n > = {};\n for (const edges of Object.values(imported.node)) {\n for (const event of Object.keys(edges.on ?? {})) {\n // The caller's map is the ONLY source of `from` — read once, here,\n // and written onto the event. Absent stays absent.\n const origin = options.from?.[event];\n events[event] =\n origin === undefined\n ? { scope: \"edges\" }\n : { scope: \"edges\", from: origin };\n }\n }\n // ONE group, named by the phase. The authored twin splits the same\n // states into working/parked/done, and that split is an AUTHORING\n // choice the document does not record — inventing it here would be\n // manufacturing knowledge the source does not have. It costs nothing:\n // every event is `scope: \"edges\"` (a lane state either routes an event\n // or refuses it), and with no broadcast scope the grouping carries no\n // obligation to carry.\n charts[taskId] = { events, states: { [phaseName]: imported.node } };\n }\n const ctx = documentContext[taskId];\n const bag = isRecord(ctx) ? ctx : {};\n const { maxRetries: rawMax, retries: _retries, ...extras } = bag;\n context[taskId] = {\n maxRetries: typeof rawMax === \"number\" ? rawMax : RETRY_BUDGET,\n extras,\n };\n phaseTasks.push(taskId);\n }\n phases.push({ name: phaseName, tasks: phaseTasks });\n\n const gate = onDoneTargets(phaseName, node.onDone);\n if (gate.defect !== undefined) defects.push(gate.defect);\n if (gate.targets !== undefined) {\n for (const target of gate.targets) {\n gateTargets.add(target);\n if (machineStates[target] === undefined) {\n defects.push(\n `phase \"${phaseName}\": \\`onDone\\` targets unknown machine-level state \"${target}\"`,\n );\n }\n }\n // Every phase names the same trip terminal; the LAST phase's success\n // target is the workflow's complete terminal, because earlier ones target\n // the next phase.\n terminals = { complete: gate.targets[0], tripped: gate.targets[1] };\n }\n }\n\n // A machine-level state the loop above did not import is a terminal or a\n // defect — never dropped silently.\n for (const [name, node] of Object.entries(machineStates)) {\n if (nodeType(node) === \"parallel\" && isRecord(node)) continue;\n if (nodeType(node) !== \"final\") {\n defects.push(\n `machine-level state \"${name}\" is neither a \\`parallel\\` phase nor a \\`final\\` terminal`,\n );\n } else if (!gateTargets.has(name)) {\n defects.push(\n `machine-level final \"${name}\" is targeted by no phase's \\`onDone\\` pair`,\n );\n }\n }\n if (phases.length === 0)\n defects.push(\"machine holds no `parallel` phase state\");\n if (defects.length > 0) throw new WorkflowImportError(defects);\n if (terminals === undefined) {\n throw new WorkflowImportError([\n \"no phase carried a readable `onDone` pair\",\n ]);\n }\n\n const id =\n isRecord(document) && typeof document.id === \"string\"\n ? document.id\n : undefined;\n const lane: ImportedLane = {\n ...(id === undefined ? {} : { id }),\n ...(typeof declaredTrigger === \"string\"\n ? { trigger: declaredTrigger }\n : {}),\n phases,\n terminals,\n charts,\n context,\n };\n\n // THE `from` MAP, CROSS-CHECKED — `eventAlphabet` exists for exactly this\n // and nothing was calling it. The alphabet is DERIVED from the document, so\n // this compares the caller's claim against the document itself rather than\n // against a list of ours. See `strictFrom` for why it is the caller's call.\n if (options.strictFrom === true) {\n const declared = new Set(eventAlphabet(lane));\n const strays = Object.keys(options.from ?? {}).filter(\n (event) => !declared.has(event),\n );\n if (strays.length > 0) {\n throw new WorkflowImportError(\n strays.map(\n (event) =>\n `\\`from\\` names \"${event}\", which no state in this document routes — the map is keyed by the BARE event name`,\n ),\n );\n }\n }\n return lane;\n}\n\n/** Parse and import in one step — for a caller holding the document's bytes. */\nexport function chartFromWorkflowText(\n text: string,\n options: WorkflowImportOptions = {},\n): ImportedLane {\n let parsed: unknown;\n try {\n parsed = JSON.parse(text);\n } catch {\n throw new WorkflowImportError([\"the document is not JSON\"]);\n }\n return chartFromWorkflow(parsed, options);\n}\n\n// ── reading a chart back ───────────────────────────────────────────────────\n\n/** Every state in an imported chart, flattened out of its one phase group. */\nexport function statesOf(\n chart: ImportedChart,\n): ReadonlyMap<string, ImportedNode> {\n const out = new Map<string, ImportedNode>();\n for (const group of Object.values(chart.states)) {\n for (const [name, node] of Object.entries(group)) out.set(name, node);\n }\n return out;\n}\n\n/** The state marked `initial: true`. */\nexport function initialOf(chart: ImportedChart): string {\n for (const [name, node] of statesOf(chart)) {\n if (node.initial === true) return name;\n }\n throw new Error(\"@demlik/tea: imported chart marks no initial state\");\n}\n\n/**\n * Every event name this lane declares, in first-declaration order.\n *\n * THE ALPHABET, DERIVED — the answer a caller used to get from a constant in\n * this file listing one consumer's six. It is a fact about the document, so it\n * is read from the document: the bare names its states route, deduplicated\n * across tasks and phases. A consumer that adds an event gets it here the\n * commit it lands, without a release of ours.\n *\n * Use it to build the `from` map at the import boundary and know you covered\n * every name, or to diff two revisions of a workflow for a vocabulary change.\n */\nexport function eventAlphabet(lane: ImportedLane): readonly string[] {\n const out = new Set<string>();\n for (const chart of Object.values(lane.charts)) {\n for (const event of Object.keys(chart.events)) out.add(event);\n }\n return [...out];\n}\n\n/**\n * Where `event` comes from, or `undefined` when the chart does not say.\n *\n * The ONE read of provenance, so a reader that wants to group by origin and a\n * reader that wants to label one event cannot disagree about what \"undeclared\"\n * looks like.\n */\nexport function originOf(\n chart: ImportedChart,\n event: string,\n): EventOrigin | undefined {\n return chart.events[event]?.from;\n}\n\n/** `true` success, `\"error\"` tripped, `false` not a final — the ONE polarity read. */\nexport function endPolarityOf(\n node: ImportedNode | undefined,\n): true | \"error\" | false {\n if (node?.end === undefined) return false;\n return node.end;\n}\n","// ═══════════════════════════════════════════════════════════════════════════\n// THE FOLD — `events.jsonl` in, per-task leaf states out, from scratch.\n//\n// The mirror of `packages/fabrika-cli/src/lane/fold.ts`. It is here for two\n// reasons and neither is \"because we might as well\":\n//\n// 1. THE TIMELINE. `lane history` returns the log verbatim and deliberately\n// does NOT store `from → to` — those are reconstructible by folding, so\n// storing them would be a second copy of a derived fact. Reconstructing\n// them is therefore the reader's job, and the reader needs a fold to do\n// it. Because the fold is a LEFT fold that is pure over a prefix, the\n// state before step k is exactly `foldLog(entries.slice(0, k))` — time\n// travel that is exact rather than approximated.\n//\n// 2. THE FILE PATH. A caller holding only `workflow.json` + `events.jsonl`\n// has no `lane status` output to be handed. It derives one.\n//\n// The transition semantics below are fabrika's, verbatim in behaviour: the\n// guard is the one inline `retries < maxRetries` (the guard NAME in the\n// document is inert data, never dereferenced), a resume lands on `was ?? the\n// region's initial` and does NOT rewrite `was`, and every other edge records\n// `was = the state you left`.\n// ═══════════════════════════════════════════════════════════════════════════\nimport { edgeKey } from \"./draw\";\nimport {\n bareEvent,\n endPolarityOf,\n type ImportedChart,\n type ImportedLane,\n initialOf,\n RETRY_BUDGET,\n statesOf,\n} from \"./workflow\";\n\n/**\n * The edge a step DREW, keyed as {@link edgeKey} spells it.\n *\n * ONE DECLARATION SITE for the resume rule, and that is the whole reason it is\n * a function rather than four lines inside {@link timeline}. A resume edge is\n * DRAWN once, to its fallback, and WALKED to wherever `was` pointed — so\n * recovering \"which edge lit up\" from the observed target lands on an edge the\n * drawing does not have. Any reader that knows `from`/`event`/`to` and wants\n * the drawn edge (a folded log's timeline; a live lane's recorded tape) asks\n * here, so the two cannot disagree about which edge to thicken.\n */\nexport function walkedEdgeKey(\n chart: ImportedChart,\n from: string,\n event: string,\n to: string,\n): string {\n const declared = statesOf(chart).get(from)?.on?.[event];\n const drawn =\n declared !== undefined && \"resume\" in declared\n ? declared.resume.fallback\n : to;\n return edgeKey(from, event, drawn);\n}\n\n/** One appended line of `events.jsonl`: which task, which event, when. */\nexport interface LogEntry {\n readonly task: string;\n readonly event: string;\n readonly at: string;\n}\n\n/** One task's folded state: the leaf, the retry budget, and the state it left. */\nexport interface TaskState {\n readonly type: string;\n readonly retries: number;\n readonly maxRetries: number;\n readonly was?: string;\n}\n\n/**\n * The derived answer `lane status` prints — reproduced here field for field,\n * because a report that computed its own vocabulary would contradict the driver\n * the moment the two disagreed.\n */\nexport interface LaneStatus {\n readonly stateValue:\n | string\n | Readonly<Record<string, Readonly<Record<string, string>> | string>>;\n readonly status: \"active\" | \"done\";\n readonly context: Readonly<Record<string, unknown>>;\n}\n\n/** The log does not replay against this workflow — with the reason named. */\nexport class UnreplayableLogError extends Error {\n override readonly name = \"UnreplayableLogError\";\n readonly _tag = \"UnreplayableLogError\" as const;\n constructor(public readonly defects: readonly string[]) {\n super(\n `@demlik/tea: this events log does not replay against this workflow —\\n` +\n defects.map((d) => ` • ${d}`).join(\"\\n\"),\n );\n }\n}\n\n/**\n * Parse `events.jsonl`. A line that does not parse is a DEFECT, never a\n * silently skipped event — a report built on a log it half-read is worse than\n * no report.\n */\nexport function parseEventsJsonl(text: string): readonly LogEntry[] {\n const defects: string[] = [];\n const entries: LogEntry[] = [];\n for (const [index, line] of text.split(\"\\n\").entries()) {\n if (line.trim() === \"\") continue;\n let parsed: unknown;\n try {\n parsed = JSON.parse(line);\n } catch {\n defects.push(`line ${index + 1} is not JSON`);\n continue;\n }\n const entry = asLogEntry(parsed);\n if (entry === undefined) {\n defects.push(\n `line ${index + 1} does not carry string \\`task\\`/\\`event\\`/\\`at\\``,\n );\n continue;\n }\n entries.push(entry);\n }\n if (defects.length > 0) throw new UnreplayableLogError(defects);\n return entries;\n}\n\nfunction asLogEntry(value: unknown): LogEntry | undefined {\n if (typeof value !== \"object\" || value === null) return undefined;\n const record = value as { task?: unknown; event?: unknown; at?: unknown };\n if (\n typeof record.task !== \"string\" ||\n typeof record.event !== \"string\" ||\n typeof record.at !== \"string\"\n ) {\n return undefined;\n }\n return { task: record.task, event: record.event, at: record.at };\n}\n\n/** `lane history`'s stdout — a JSON array of the same entries, verbatim. */\nexport function parseHistoryJson(text: string): readonly LogEntry[] {\n let parsed: unknown;\n try {\n parsed = JSON.parse(text);\n } catch {\n throw new UnreplayableLogError([\"`lane history` output is not JSON\"]);\n }\n if (!Array.isArray(parsed)) {\n throw new UnreplayableLogError([\n \"`lane history` output is not a JSON array of entries\",\n ]);\n }\n const entries: LogEntry[] = [];\n for (const [index, raw] of parsed.entries()) {\n const entry = asLogEntry(raw);\n if (entry === undefined) {\n throw new UnreplayableLogError([\n `history entry ${index} does not carry string \\`task\\`/\\`event\\`/\\`at\\``,\n ]);\n }\n entries.push(entry);\n }\n return entries;\n}\n\n/**\n * EVERY task the log names that this lane does not have, never just the first.\n *\n * The same contract {@link parseEventsJsonl} keeps one function up, and the\n * same one fabrika keeps: a log that names four tasks from a workflow the\n * caller swapped underneath it is four facts, and reporting one of them per\n * run turns one fix into four rounds of paste-the-error-back. Deduplicated by\n * name, in first-mention order — a thousand-line log naming one stale task is\n * one defect, not a thousand.\n */\nconst unknownTaskDefects = (\n lane: ImportedLane,\n entries: readonly LogEntry[],\n): readonly string[] => {\n const seen = new Set<string>();\n const defects: string[] = [];\n for (const entry of entries) {\n if (lane.charts[entry.task] !== undefined || seen.has(entry.task)) continue;\n seen.add(entry.task);\n defects.push(\n `log names task \"${entry.task}\", which is not in this lane's machine`,\n );\n }\n return defects;\n};\n\nconst chartOf = (lane: ImportedLane, taskId: string): ImportedChart => {\n const chart = lane.charts[taskId];\n if (chart === undefined) {\n throw new UnreplayableLogError([\n `log names task \"${taskId}\", which is not in this lane's machine`,\n ]);\n }\n return chart;\n};\n\n/** The initial state of every task — the fold's zero. */\nexport function initialStates(\n lane: ImportedLane,\n): Readonly<Record<string, TaskState>> {\n const out: Record<string, TaskState> = {};\n for (const [taskId, chart] of Object.entries(lane.charts)) {\n out[taskId] = {\n type: initialOf(chart),\n retries: 0,\n maxRetries: lane.context[taskId]?.maxRetries ?? RETRY_BUDGET,\n };\n }\n return out;\n}\n\n/**\n * ONE event applied to ONE task. The three edge forms, and the two ways there\n * can be no edge.\n *\n * THERE ARE THREE ANSWERS, NOT TWO, and this used to give two. tea's runtime\n * has always distinguished a REFUSAL — an event the state accepts and drops,\n * because its `ignore` names the event or the event is broadcast to some other\n * phase — from a pair it cannot replay, which is the only one that throws. The\n * lowered chart could not carry the first, so a log the runtime had happily\n * accepted came back `UnreplayableLogError` here: a run and a report of that\n * run disagreeing about what the machine did. The refusal set now rides on the\n * chart (`ImportedChart.refusals`, written by `lowerRegion` and by nothing\n * else), so both sides refuse the same pairs by construction.\n *\n * `taskId` is for the DIAGNOSTIC only. `stepTask` folds one region and has\n * never needed to know which; a reader staring at `state \"queued\" holds no cell\n * for \"DONE\"` on a twelve-task lane needs to know very much, and the callers\n * have it.\n */\nexport function stepTask(\n chart: ImportedChart,\n state: TaskState,\n event: string,\n taskId?: string,\n): TaskState {\n const node = statesOf(chart).get(state.type);\n const edge = node?.on?.[event];\n if (edge === undefined) {\n if (chart.refusals?.[state.type]?.includes(event) === true) return state;\n throw new UnreplayableLogError([\n `${taskId === undefined ? \"\" : `task \"${taskId}\": `}state \"${state.type}\" holds no cell for \"${event}\"`,\n ]);\n }\n if (\"resume\" in edge) {\n // `was` is NOT rewritten: you are LEAVING the park, not entering one.\n return { ...state, type: state.was ?? edge.resume.fallback };\n }\n if (\"when\" in edge) {\n // The guard NAME is inert. This one predicate is the guard, in fabrika and\n // here — which is exactly why the two cannot drift apart on a rename.\n return state.retries < state.maxRetries\n ? {\n ...state,\n type: edge.target,\n retries: state.retries + 1,\n was: state.type,\n }\n : { ...state, type: edge.otherwise, was: state.type };\n }\n return { ...state, type: edge.target, was: state.type };\n}\n\n/**\n * Fold the whole log into per-task leaf states.\n *\n * PURE OVER A PREFIX: tasks are independent regions, so the global log\n * partitions cleanly and each task folds through its own chart. `foldLane(lane,\n * entries.slice(0, k))` is therefore the exact state after k events, for every\n * k — which is what {@link timeline} spends.\n */\nexport function foldLane(\n lane: ImportedLane,\n entries: readonly LogEntry[],\n): Readonly<Record<string, TaskState>> {\n const unknown = unknownTaskDefects(lane, entries);\n if (unknown.length > 0) throw new UnreplayableLogError(unknown);\n const states: Record<string, TaskState> = { ...initialStates(lane) };\n for (const entry of entries) {\n const chart = chartOf(lane, entry.task);\n const current = states[entry.task];\n if (current === undefined) {\n throw new UnreplayableLogError([\n `log names task \"${entry.task}\", which is not in this lane's machine`,\n ]);\n }\n states[entry.task] = stepTask(\n chart,\n current,\n bareEvent(entry.event),\n entry.task,\n );\n }\n return states;\n}\n\n/** One row of the timeline: the entry, plus the `from → to` nobody stored. */\nexport interface TimelineStep {\n readonly index: number;\n readonly at: string;\n readonly task: string;\n /** The event VERBATIM, namespace and all — the log's own spelling. */\n readonly event: string;\n readonly from: string;\n readonly to: string;\n /**\n * The DECLARED edge this step fired, as {@link edgeKey} spells it.\n *\n * Not derivable from `from`/`event`/`to`, and that is the whole reason it is\n * carried: a resume edge is DRAWN once, to its fallback, and WALKED to\n * wherever `was` pointed. Recovering \"which edge lit up\" from the observed\n * target would land on an edge the drawing does not have — so the step\n * records the edge it took while it still knows.\n */\n readonly edge: string;\n}\n\n/**\n * The log with `from → to` recomputed per step.\n *\n * A single left-to-right pass, which is EXACTLY the prefix fold and not an\n * approximation of it: `foldLane` is a left fold over the same entries in the\n * same order, so the state carried into step k here is the state\n * `foldLane(lane, entries.slice(0, k))` returns. `fold.test.ts` asserts that\n * equality rather than asking you to take it on trust — the cheap form and the\n * definitional form, pinned to each other.\n */\nexport function timeline(\n lane: ImportedLane,\n entries: readonly LogEntry[],\n): readonly TimelineStep[] {\n const unknown = unknownTaskDefects(lane, entries);\n if (unknown.length > 0) throw new UnreplayableLogError(unknown);\n const states: Record<string, TaskState> = { ...initialStates(lane) };\n const steps: TimelineStep[] = [];\n for (const [index, entry] of entries.entries()) {\n const chart = chartOf(lane, entry.task);\n const before = states[entry.task];\n if (before === undefined) {\n throw new UnreplayableLogError([\n `log names task \"${entry.task}\", which is not in this lane's machine`,\n ]);\n }\n const event = bareEvent(entry.event);\n const after = stepTask(chart, before, event, entry.task);\n states[entry.task] = after;\n steps.push({\n index,\n at: entry.at,\n task: entry.task,\n event: entry.event,\n from: before.type,\n to: after.type,\n edge: walkedEdgeKey(chart, before.type, event, after.type),\n });\n }\n return steps;\n}\n\n/**\n * Where one phase stands. The four are exhaustive over a phase in a lane whose\n * log has been folded, and they are POSITIONAL rather than local: a phase whose\n * tasks all happen to be final is `\"waiting\"` if an earlier phase stopped the\n * lane before it could have run.\n */\nexport type PhaseStanding = \"complete\" | \"tripped\" | \"active\" | \"waiting\";\n\n/** One phase, and where it stands after the fold. */\nexport interface PhaseStand {\n readonly name: string;\n /** Its position in the sequence — the phase order, as a number. */\n readonly index: number;\n readonly tasks: readonly string[];\n readonly standing: PhaseStanding;\n /** The tasks in this phase that landed on an ERROR final. */\n readonly tripped: readonly string[];\n}\n\n/**\n * The ONE thing the phase walk reads off a task: which state it is standing in.\n *\n * {@link TaskState} satisfies it, and so does a RUNNING region's own\n * `StateOf<chart>` — which is the whole reason the parameter is spelled this\n * loosely. The fold and the runtime carry different per-task values (the fold's\n * carries `retries`, a region's carries its `ctx`), and the advancement rule\n * reads neither: it reads `type`, looks the node up in the chart, and asks its\n * `end` polarity. Widening the parameter to what the rule ACTUALLY reads is what\n * lets {@link phaseStandings} be called by both without a second copy of it.\n */\nexport type LeafStates = Readonly<Record<string, { readonly type: string }>>;\n\n/** Every task at an error final — the `errors` list, one declaration site. */\nexport function trippedTasks(\n lane: ImportedLane,\n states: LeafStates,\n): readonly string[] {\n return Object.keys(states).filter(\n (taskId) => endPolarityOf(nodeOf(lane, taskId, states)) === \"error\",\n );\n}\n\n/**\n * THE PHASE WALK — the one loop that decides which phase is running, which are\n * behind it, and which never got to start.\n *\n * It is fabrika's `deriveStatus` loop, factored out rather than copied: walk\n * phases in order, the first whose tasks are not ALL final is the active one\n * and the walk stops; a phase that IS all final but holds an error final trips\n * the lane and the walk stops there instead; everything after a stop is\n * `\"waiting\"`, whatever its tasks happen to read.\n *\n * That last clause is the whole reason this is positional. `foldLane` boots\n * every task of every phase, so a later phase's region can sit in a final\n * before its phase ever ran — a child the board abandoned boots straight into\n * an error final, which is exactly the case fabrika's emitter produces. Read\n * locally, that phase looks \"tripped\". Read in sequence, it is a phase that\n * never started, and the lane tripped somewhere else.\n *\n * {@link deriveLaneStatus} and the report both read this, so the compound state\n * value and the phase headings cannot disagree about what is running.\n */\nexport function phaseStandings(\n lane: ImportedLane,\n states: LeafStates,\n): readonly PhaseStand[] {\n const isFinal = (taskId: string): boolean =>\n endPolarityOf(nodeOf(lane, taskId, states)) !== false;\n const errors = trippedTasks(lane, states);\n let stopped = false;\n return lane.phases.map((phase, index) => {\n const tripped = phase.tasks.filter((taskId) => errors.includes(taskId));\n const base = { name: phase.name, index, tasks: phase.tasks, tripped };\n if (stopped) return { ...base, standing: \"waiting\" as const };\n if (!phase.tasks.every(isFinal)) {\n stopped = true;\n return { ...base, standing: \"active\" as const };\n }\n if (tripped.length > 0) {\n stopped = true;\n return { ...base, standing: \"tripped\" as const };\n }\n return { ...base, standing: \"complete\" as const };\n });\n}\n\n/**\n * THE ADVANCEMENT RULE — has the lane left the phases, and by which door?\n *\n * `undefined` means \"still running\": some phase is active, so the lane is\n * sitting in it. A terminal name means the walk ran out of phases — every phase\n * completed (`onDone` chained all the way past the last one, which is what the\n * `complete` terminal IS), or one of them completed holding a region at an\n * `end: \"error\"` final, which trips the lane wherever it had got to.\n *\n * Three lines, and they are pulled out here rather than inlined below because\n * this is the rule the RUNTIME advances by (`runLane`, in `../lane/run`). The\n * runtime does not re-derive it and does not agree with it by inspection: it\n * calls {@link phaseStandings} over its own region states and then this, so\n * \"the machine advanced\" and \"the fold says it advanced\" are the same sentence\n * evaluated twice, not two sentences kept in sync.\n */\nexport function laneTerminalReached(\n stands: readonly PhaseStand[],\n terminals: ImportedLane[\"terminals\"],\n): string | undefined {\n if (stands.some((stand) => stand.standing === \"tripped\"))\n return terminals.tripped;\n if (stands.some((stand) => stand.standing === \"active\")) return undefined;\n return terminals.complete;\n}\n\n/**\n * The whole \"compound machine\", as a pure derivation.\n *\n * The active phase is the first whose tasks are not all final; a COMPLETED\n * phase holding a task in an error final trips the workflow. That is fabrika's\n * `noErrors` gate — never a machine event, and here it reads the chart's\n * `end: \"error\"` polarity, which is the same fact the document's guarded\n * fallthrough declared. The walk itself is {@link phaseStandings}, so the\n * status and the drawing are one derivation seen twice.\n */\nexport function deriveLaneStatus(\n lane: ImportedLane,\n states: Readonly<Record<string, TaskState>>,\n): LaneStatus {\n const errors = trippedTasks(lane, states);\n\n const context: Record<string, unknown> = {};\n for (const [taskId, state] of Object.entries(states)) {\n context[taskId] = {\n retries: state.retries,\n maxRetries: state.maxRetries,\n ...(lane.context[taskId]?.extras ?? {}),\n };\n }\n context.errors = errors;\n\n const stands = phaseStandings(lane, states);\n const terminal = laneTerminalReached(stands, lane.terminals);\n if (terminal !== undefined) {\n return { stateValue: terminal, status: \"done\", context };\n }\n // `laneTerminalReached` returned `undefined`, which is precisely \"some phase\n // is active\" — so this find cannot miss.\n const active = stands.find((stand) => stand.standing === \"active\");\n if (active === undefined) {\n return { stateValue: lane.terminals.complete, status: \"done\", context };\n }\n\n const stateValue: Record<string, Record<string, string> | string> = {\n [active.name]: Object.fromEntries(\n active.tasks.map((taskId) => [taskId, states[taskId]?.type ?? \"?\"]),\n ),\n };\n for (const stand of stands.slice(active.index + 1)) {\n stateValue[stand.name] = \"waiting\";\n }\n return { stateValue, status: \"active\", context };\n}\n\nfunction nodeOf(lane: ImportedLane, taskId: string, states: LeafStates) {\n const chart = lane.charts[taskId];\n const state = states[taskId];\n if (chart === undefined || state === undefined) return undefined;\n return statesOf(chart).get(state.type);\n}\n\n/** `lane status`'s stdout, parsed back into the shape it was printed from. */\nexport function parseStatusJson(text: string): LaneStatus {\n let parsed: unknown;\n try {\n parsed = JSON.parse(text);\n } catch {\n throw new UnreplayableLogError([\"`lane status` output is not JSON\"]);\n }\n if (typeof parsed !== \"object\" || parsed === null) {\n throw new UnreplayableLogError([\"`lane status` output is not an object\"]);\n }\n const record = parsed as {\n stateValue?: unknown;\n status?: unknown;\n context?: unknown;\n };\n if (record.status !== \"active\" && record.status !== \"done\") {\n throw new UnreplayableLogError([\n '`lane status` output carries no `status` of \"active\" | \"done\"',\n ]);\n }\n if (record.stateValue === undefined) {\n throw new UnreplayableLogError([\n \"`lane status` output carries no `stateValue`\",\n ]);\n }\n return {\n stateValue: record.stateValue as LaneStatus[\"stateValue\"],\n status: record.status,\n context:\n typeof record.context === \"object\" && record.context !== null\n ? (record.context as Record<string, unknown>)\n : {},\n };\n}\n","// ═══════════════════════════════════════════════════════════════════════════\n// THE REPORT — one markdown string that reads the same in three places.\n//\n// A terminal, a PR comment and an issue comment are the three surfaces a lane's\n// state is actually looked at on, and they share exactly one format. So the\n// output is markdown with a mermaid fence: GitHub renders the fence, a terminal\n// shows it as the text it is, and neither needs a flag.\n//\n// THE EDITORIAL RULES, which are most of what this file is:\n//\n// ONE DIAGRAM PER TASK THAT MOVED, ACTIVE PHASE ONLY. A comment with eight\n// diagrams is a comment nobody reads. Future phases get one line each, and so\n// do the tasks still sitting at their entry state — a real emitted epic put\n// eight tasks in one phase, six of them untouched, and the rule as originally\n// written (per TASK, not per MOVED task) produced exactly the wall of\n// near-identical pictures it exists to prevent.\n//\n// \"WAITING ON\" IS DERIVED, AND NAMES NOTHING. This file used to answer it by\n// matching STATE NAMES — `queued`, `build`, `review`, `ship`, `blocked`,\n// `human:*` — against a list copied out of fabrika's `wire/lane-brief.ts`.\n// Those names are fabrika's, so a rename upstream turned this report into a\n// confident liar with nothing failing anywhere. The fact it was really after\n// is not \"which state is this\" but \"who has to act next\", which is a property\n// of the EVENT: a Msg comes from a Cmd's result, a Sub firing, or the outside\n// world, and the chart now says which (`graph.ts` §3a, `from`). So the answer\n// is the events legal HERE, grouped by THEIR origin — no state name, no event\n// name, no job title in this file.\n//\n// AND IT STILL REFUSES TO GUESS. A chart that declares no provenance gets no\n// invented one: the line says which events the state accepts and stops, which\n// is what the machine does say — the same refusal `shellState()` makes by\n// answering null rather than inventing a shell.\n//\n// THE RETRY LINE, WHEN AND ONLY WHEN IT MATTERS. `2/2` is the difference\n// between \"in review\" and \"one FAIL from frozen\", and `0/2` is noise.\n// ═══════════════════════════════════════════════════════════════════════════\nimport type { EventOrigin } from \"../graph\";\nimport { drawTask, walkedEdges } from \"./draw\";\nimport {\n deriveLaneStatus,\n foldLane,\n type LaneStatus,\n type LogEntry,\n type PhaseStand,\n phaseStandings,\n type TaskState,\n type TimelineStep,\n timeline,\n} from \"./fold\";\nimport {\n chartFromWorkflow,\n endPolarityOf,\n type ImportedChart,\n type ImportedLane,\n initialOf,\n originOf,\n statesOf,\n} from \"./workflow\";\n\n/** The lane the report is about. `workflow` is the PARSED document, or an import. */\nexport interface LaneReportInput {\n /** `workflow.json`, parsed — or an already-imported lane, reused as is. */\n readonly workflow: unknown;\n readonly entries: readonly LogEntry[];\n /**\n * `lane status`'s answer.\n *\n * OPTIONAL, and that is the whole shape of the two input paths: a caller\n * shelling out to `fabrika` hands over the CLI's own derivation and the\n * report never second-guesses it; a caller holding only the two files omits\n * it and the same derivation runs here.\n */\n readonly status?: LaneStatus;\n /** Heading for the block. Defaults to the document's `id`. */\n readonly title?: string;\n}\n\nexport interface LaneReport {\n readonly markdown: string;\n}\n\nconst isImportedLane = (v: unknown): v is ImportedLane =>\n typeof v === \"object\" &&\n v !== null &&\n Array.isArray((v as ImportedLane).phases) &&\n typeof (v as ImportedLane).charts === \"object\";\n\n/** `{ pipeline: { issue: \"review\" } }` → the phase that is actually running. */\nfunction activePhaseName(status: LaneStatus): string | undefined {\n if (typeof status.stateValue === \"string\") return undefined;\n for (const [name, value] of Object.entries(status.stateValue)) {\n if (typeof value === \"object\") return name;\n }\n return undefined;\n}\n\n/** Event names, as the report writes a list of them. */\nconst listed = (events: readonly string[]): string =>\n events.map((e) => `\\`${e}\\``).join(\", \");\n\n/**\n * One origin's worth of the answer, said the way that origin is said.\n *\n * The three phrasings are the three origins, and each says the thing that\n * origin makes true. A world role is a WHO, so the events are what that who\n * owes; a cmd is work already in flight, so the sentence is about the work and\n * the events are how it comes back; a sub is a source, so the sentence is about\n * the source. The role text (`the operator`, `a human`) is the consumer's own,\n * carried from the chart verbatim — including its article, because only the\n * consumer knows whether there is one of them or any of them.\n */\nfunction phrase(\n origin: EventOrigin,\n state: string,\n events: readonly string[],\n): string {\n if (origin === \"cmd\") {\n return `the work \\`${state}\\` dispatched — ${listed(events)}`;\n }\n if (origin === \"sub\") {\n return `the source \\`${state}\\` is subscribed to — ${listed(events)}`;\n }\n return `${origin.world}'s ${listed(events)}`;\n}\n\n/** The grouping key for an origin — the two words, or the role, distinctly. */\nconst originKey = (origin: EventOrigin): string =>\n typeof origin === \"string\" ? origin : `world:${origin.world}`;\n\n/**\n * What this task is waiting on — or `null` at a final.\n *\n * DERIVED, entirely: the events this state routes, grouped by the origin each\n * one DECLARES, in declaration order. Nothing here knows a state name, an event\n * name or a job title, so a consumer that renames half its states changes this\n * output correctly and a consumer with a completely different cast is served by\n * the same function.\n *\n * The degradation is the point of the second half. Provenance is not in\n * `workflow.json` — it is stated at the import boundary or not at all — so a\n * chart imported without it must say what it actually knows, which is WHICH\n * EVENTS the state accepts. It never says who sends them.\n */\nexport function waitingOn(chart: ImportedChart, state: string): string | null {\n const node = statesOf(chart).get(state);\n if (node?.end !== undefined) return null;\n const events = Object.keys(node?.on ?? {});\n if (events.length === 0) {\n // A live state that routes nothing. `inspectLane` calls this a dead end;\n // there is no one to wait for and saying so is the whole answer.\n return `\\`${state}\\` accepts no events, and it is not a final`;\n }\n\n // Group by origin, keeping the events in the order the chart declares them.\n const groups = new Map<string, { origin: EventOrigin; events: string[] }>();\n const undeclared: string[] = [];\n for (const event of events) {\n const origin = originOf(chart, event);\n if (origin === undefined) {\n undeclared.push(event);\n continue;\n }\n const key = originKey(origin);\n const group = groups.get(key);\n if (group === undefined) groups.set(key, { origin, events: [event] });\n else group.events.push(event);\n }\n\n // NO PROVENANCE AT ALL — the honest floor. Same voice as the refusal this\n // replaces: name what the machine says, and stop.\n if (groups.size === 0) return `\\`${state}\\` accepts ${listed(events)}`;\n\n const parts = [...groups.values()].map((g) =>\n phrase(g.origin, state, g.events),\n );\n // A PARTIAL map is not rounded up to a whole one. The events whose origin was\n // never stated are listed as exactly that, beside the ones that were.\n if (undeclared.length > 0) {\n parts.push(`${listed(undeclared)}, from somewhere the chart does not say`);\n }\n return parts.join(\" · \");\n}\n\n/** `2/2 — one \\`FAIL\\` from \\`frozen\\``, or `null` when no retry has been spent. */\nfunction retryLine(chart: ImportedChart, state: TaskState): string | null {\n if (state.retries <= 0) return null;\n const budget = `${state.retries}/${state.maxRetries}`;\n if (state.retries < state.maxRetries) return `**retries:** ${budget}`;\n // Spent. Name the edge that is now a one-way door, off the chart rather than\n // off a constant — a document whose fallthrough is `tripped` says `tripped`.\n const node = statesOf(chart).get(state.type);\n for (const [event, edge] of Object.entries(node?.on ?? {})) {\n if (\"when\" in edge) {\n return `**retries:** ${budget} — spent; one \\`${event}\\` from \\`${edge.otherwise}\\``;\n }\n }\n return `**retries:** ${budget} — spent`;\n}\n\n/**\n * One phase that is NOT the active one, in one line.\n *\n * The editorial rule the module opened with, applied to the phase dimension: a\n * comment with eight diagrams is a comment nobody reads, so a phase already\n * finished and a phase not yet started each get a line. A finished phase still\n * gets its leaves, because \"complete\" alone does not say WHICH ending each of\n * its tasks reached — and a phase that never started has no leaves worth\n * printing, because every one of them would be an initial state nothing walked.\n */\nfunction phaseLine(\n stand: PhaseStand,\n states: Readonly<Record<string, TaskState>>,\n): string {\n const count = `${stand.tasks.length} task${stand.tasks.length === 1 ? \"\" : \"s\"}`;\n if (stand.standing === \"waiting\") {\n return `**${stand.name}:** waiting — ${count}, not started.`;\n }\n const leaves = stand.tasks\n .map(\n (taskId) =>\n `\\`${taskId}\\` = \\`${states[taskId]?.type ?? \"?\"}\\`${\n stand.tripped.includes(taskId) ? \" **(tripped)**\" : \"\"\n }`,\n )\n .join(\", \");\n return `**${stand.name}:** ${stand.standing} — ${count}: ${leaves}`;\n}\n\nfunction timelineTable(steps: readonly TimelineStep[]): string {\n if (steps.length === 0)\n return \"_no events yet — the lane is at its initial state._\";\n const rows = steps.map(\n (s) =>\n `| ${s.index + 1} | ${s.at} | \\`${s.task}\\` | \\`${s.event}\\` | \\`${s.from}\\` → \\`${s.to}\\` |`,\n );\n return [\n \"| # | at | task | event | from → to |\",\n \"|---|---|---|---|---|\",\n ...rows,\n ].join(\"\\n\");\n}\n\n/**\n * A lane, as one markdown block.\n *\n * The diagram half is behind {@link drawTask}, which is a translation onto\n * `chartMermaid` — the package's one chart renderer.\n */\nexport function laneReport(input: LaneReportInput): LaneReport {\n const lane = isImportedLane(input.workflow)\n ? input.workflow\n : chartFromWorkflow(input.workflow);\n const entries = input.entries;\n const states = foldLane(lane, entries);\n const status = input.status ?? deriveLaneStatus(lane, states);\n const steps = timeline(lane, entries);\n\n const title = input.title ?? lane.id ?? \"lane\";\n const out: string[] = [`## ${title} — ${status.status}`, \"\"];\n\n // ── where it is ─────────────────────────────────────────────────────────\n out.push(`**where it is:** ${describeStateValue(status.stateValue)}`);\n if (lane.trigger !== undefined) out.push(`**fired by:** \\`${lane.trigger}\\``);\n const errors = status.context.errors;\n if (Array.isArray(errors) && errors.length > 0) {\n out.push(\n `**tripped:** ${errors.map((t) => `\\`${String(t)}\\``).join(\", \")} — the lane lands on \\`${lane.terminals.tripped}\\``,\n );\n }\n out.push(\"\");\n\n // ── the phases, in order: one in full, the rest in one line each ────────\n //\n // The standings are DERIVED from the fold — the same walk `deriveLaneStatus`\n // makes — rather than read off `stateValue`, because `stateValue` is silent\n // about a lane that already stopped: it collapses to the terminal's NAME, and\n // a reader of a tripped epic then cannot tell which phase tripped it, or\n // which phases below never got to start. The one thing still taken from\n // `status` is WHICH phase is active, so a report handed the CLI's own answer\n // shows the CLI's answer. (`fold.test.ts` asserts the two agree at every\n // prefix of every run, so this is a precedence rule, not a disagreement.)\n const stands = phaseStandings(lane, states);\n const named = activePhaseName(status);\n const active =\n stands.find((s) => s.name === named) ??\n stands.find((s) => s.standing === \"active\");\n\n for (const stand of stands) {\n if (stand === active) {\n // ONE DIAGRAM PER TASK THAT HAS MOVED — not per task.\n //\n // The rule at the top of this file says a comment with eight diagrams is\n // a comment nobody reads, and until this was run against a real emitted\n // epic the rule was only enforced on the phase dimension. A real phase\n // holds eight tasks; six of them sat untouched at `queued`, and the\n // report spent ~200 of its ~265 lines drawing the same picture six times\n // with a different node lit. A task still at its entry state has a story\n // one line long, so it gets one line.\n const untouched: string[] = [];\n for (const taskId of stand.tasks) {\n const chart = lane.charts[taskId];\n const state = states[taskId];\n if (chart === undefined || state === undefined) continue;\n if (state.type === initialOf(chart)) untouched.push(taskId);\n }\n // If NOTHING in the phase has moved, the phase just started — and\n // collapsing every task would leave the reader with no picture at all.\n // Draw the first as the representative (they are all at the same entry\n // state, so any of them is the same picture) and list the rest.\n if (untouched.length === stand.tasks.length) untouched.shift();\n for (const taskId of stand.tasks) {\n const chart = lane.charts[taskId];\n const state = states[taskId];\n if (chart === undefined || state === undefined) continue;\n if (untouched.includes(taskId)) continue;\n const polarity = endPolarityOf(statesOf(chart).get(state.type));\n out.push(\n `### ${taskId} — \\`${state.type}\\`${polarity === \"error\" ? \" — TRIPPED\" : \"\"}`,\n );\n const waiting = waitingOn(chart, state.type);\n out.push(\n waiting !== null\n ? `**waiting on:** ${waiting}`\n : polarity === \"error\"\n ? // The distinction `end: \"error\"` bought, spent where it is worth\n // something: this task is as finished as a shipped one, and the\n // phase it is in is going to trip the lane when its siblings\n // finish. A report that said \"final\" for both would bury that.\n `**waiting on:** nothing — this task landed on the error final \\`${state.type}\\`, and \\`${stand.name}\\` will trip the lane when its siblings finish.`\n : \"**waiting on:** nothing — this task is final.\",\n );\n const retries = retryLine(chart, state);\n if (retries !== null) out.push(retries);\n out.push(\"\");\n out.push(\"```mermaid\");\n out.push(\n drawTask(chart, {\n current: state.type,\n walked: walkedEdges(steps.filter((s) => s.task === taskId)),\n }),\n );\n out.push(\"```\");\n out.push(\"\");\n }\n if (untouched.length > 0) {\n // Named, not counted: \"6 tasks not started\" tells a reader nothing they\n // can act on, and the names are what they came for.\n const chart = lane.charts[untouched[0] as string];\n const at =\n chart === undefined ? \"their entry state\" : `\\`${initialOf(chart)}\\``;\n out.push(\n `**not started yet:** ${untouched.map((t) => `\\`${t}\\``).join(\", \")} — still at ${at}.`,\n );\n out.push(\"\");\n }\n continue;\n }\n out.push(phaseLine(stand, states));\n out.push(\"\");\n }\n\n // ── the timeline ────────────────────────────────────────────────────────\n out.push(\"### timeline\");\n out.push(\"\");\n out.push(timelineTable(steps));\n out.push(\"\");\n return {\n markdown: `${out\n .join(\"\\n\")\n .replace(/\\n{3,}/g, \"\\n\\n\")\n .trimEnd()}\\n`,\n };\n}\n\nfunction describeStateValue(value: LaneStatus[\"stateValue\"]): string {\n if (typeof value === \"string\") return `\\`${value}\\` — the workflow is done.`;\n const parts: string[] = [];\n for (const [phase, leaf] of Object.entries(value)) {\n if (typeof leaf === \"string\") {\n parts.push(`\\`${phase}\\`: ${leaf}`);\n continue;\n }\n const inner = Object.entries(leaf)\n .map(([task, state]) => `\\`${task}\\` = \\`${state}\\``)\n .join(\", \");\n parts.push(`\\`${phase}\\` → ${inner}`);\n }\n return parts.join(\" · \");\n}\n"]}
1
+ {"version":3,"sources":["../src/chart/report/draw.ts","../src/chart/report/workflow.ts","../src/chart/report/fold.ts","../src/chart/report/report.ts"],"names":[],"mappings":";;;AA4CO,SAAS,QAAA,CAAS,KAAA,EAAsB,IAAA,GAAoB,EAAC,EAAW;AAC7E,EAAA,OAAO,aAAa,KAAA,EAAgB;AAAA,IAClC,QAAA,EAAU,IAAA;AAAA,IACV,GAAI,KAAK,OAAA,KAAY,MAAA,GAAY,EAAC,GAAI,EAAE,SAAA,EAAW,IAAA,CAAK,OAAA,EAAQ;AAAA,IAChE,GAAI,KAAK,MAAA,KAAW,MAAA,GAAY,EAAC,GAAI,EAAE,MAAA,EAAQ,IAAA,CAAK,MAAA;AAAO,GAC5D,CAAA;AACH;AAUO,SAAS,YACd,KAAA,EACY;AACZ,EAAA,MAAM,MAAA,uBAAa,GAAA,EAAoB;AACvC,EAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,IAAA,MAAA,CAAO,GAAA,CAAI,KAAK,IAAA,EAAA,CAAO,MAAA,CAAO,IAAI,IAAA,CAAK,IAAI,CAAA,IAAK,CAAA,IAAK,CAAC,CAAA;AAAA,EACxD;AACA,EAAA,OAAO,MAAA;AACT;;;AC/BO,IAAM,SAAA,GAAY,CAAC,KAAA,KAA0B;AAClD,EAAA,MAAM,GAAA,GAAM,KAA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,EAAG;AACjD,IAAA,IAAI,OAAO,SAAS,QAAA,EAAU;AAC5B,MAAA,KAAA,CAAM,IAAA,CAAK,CAAA,EAAA,EAAK,KAAK,CAAA,IAAA,EAAO,IAAI,CAAA,CAAE,CAAA;AAClC,MAAA;AAAA,IACF;AACA,IAAA,MAAM,QAAQ,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,CAC9B,GAAA,CAAI,CAAC,CAAC,IAAA,EAAM,KAAK,CAAA,KAAM,KAAK,IAAI,CAAA,OAAA,EAAU,KAAK,CAAA,EAAA,CAAI,CAAA,CACnD,KAAK,IAAI,CAAA;AACZ,IAAA,KAAA,CAAM,IAAA,CAAK,CAAA,EAAA,EAAK,KAAK,CAAA,UAAA,EAAQ,KAAK,CAAA,CAAE,CAAA;AAAA,EACtC;AACA,EAAA,OAAO,KAAA,CAAM,KAAK,QAAK,CAAA;AACzB","file":"chunk-NR7BU22N.js","sourcesContent":["// ═══════════════════════════════════════════════════════════════════════════\n// THE DIAGRAM SEAM — now a translation, not a drawing.\n//\n// This file used to hold a SECOND mermaid renderer, standing in until\n// `chartMermaid` grew an options bag. It grew one, so the swap this banner\n// promised has happened: `drawTask` is the report's door onto the one renderer\n// in `../compile`, and the two facts a report needs on top of the chart —\n// WHERE THE TASK IS NOW and WHICH EDGES IT WALKED — are options on that\n// drawing rather than a drawing of their own.\n//\n// The seam itself is unchanged and is why the swap was one function wide: the\n// report's markdown layout, its vocabulary and its timeline do not know how a\n// diagram is made.\n//\n// WHY THIS FILE STILL EXISTS rather than the report calling `chartMermaid`\n// directly. `chartMermaid` is typed `<const C extends Chart<C>>` — the\n// F-bounded literal chart, whose state and event names are literal types the\n// compiler recovered from a source literal. A report draws an `ImportedChart`,\n// whose every name is a runtime `string` read out of somebody's\n// `workflow.json`. That widening is real and it is not the report's to make at\n// eight call sites: it is made here, once, with the reason written next to it.\n// ═══════════════════════════════════════════════════════════════════════════\nimport { chartMermaid, type WalkCounts } from \"../compile\";\nimport type { ImportedChart } from \"./workflow\";\n\nexport { edgeKey, type WalkCounts } from \"../compile\";\n\nexport interface DrawOptions {\n /** The state the task is in right now — lit. */\n readonly current?: string;\n /** Edges the log actually walked, keyed `${from}|${event}|${to}`. */\n readonly walked?: WalkCounts;\n}\n\n/**\n * One task's region as a mermaid `stateDiagram-v2` block, with the current node\n * lit, the walked edges marked and the two endings drawn apart.\n *\n * `polarity` is always on: a lane's whole point is that `shipped` and `frozen`\n * are not the same ending, and a report that painted them alike would be lying\n * in the place a reader looks first. It is an OPTION on the renderer rather\n * than a default because a chart drawing is something a reviewer approves —\n * see `ChartMermaidOptions.polarity`.\n */\nexport function drawTask(chart: ImportedChart, opts: DrawOptions = {}): string {\n return chartMermaid(chart as never, {\n polarity: true,\n ...(opts.current === undefined ? {} : { highlight: opts.current }),\n ...(opts.walked === undefined ? {} : { walked: opts.walked }),\n });\n}\n\n/**\n * The edges a log walked, counted — the input `drawTask` marks from.\n *\n * Reads each step's DECLARED `edge` rather than recomputing one from\n * `from`/`event`/`to`: a resume edge is drawn to its fallback and walked to\n * wherever `was` pointed, so the observed target names an edge the drawing does\n * not have. `TimelineStep.edge` is the edge that actually fired.\n */\nexport function walkedEdges(\n steps: readonly { readonly edge: string }[],\n): WalkCounts {\n const counts = new Map<string, number>();\n for (const step of steps) {\n counts.set(step.edge, (counts.get(step.edge) ?? 0) + 1);\n }\n return counts;\n}\n","// ═══════════════════════════════════════════════════════════════════════════\n// THE IMPORTER — one `workflow.json` in, one chart per task out.\n//\n// This is the mirror of `kamp-us/phoenix` `packages/fabrika-cli/src/lane/\n// machine.ts`, and it is deliberately STRUCTURAL in exactly the same three\n// places, because that is what makes the two agree:\n//\n// an `on` string → `{ target }`\n// an `on` two-arm array → `{ target, when, otherwise }` (guarded)\n// a target of `type: \"history\"` → `{ resume: { fallback: <region initial> } }`\n// `type: \"final\"` → `end: true`\n// …reached as an array's fallthrough → `end: \"error\"`\n// machine-level `type: \"parallel\"` → a phase; its `onDone` pair → the terminals\n//\n// GRAMMAR, NEVER VOCABULARY. Every rule above is about what makes a document\n// WELL-FORMED — a state routes events to targets, a guarded edge is a two-arm\n// array, a `history` target means resume, a `final` is terminal. None of them\n// is about WHICH NAMES a consumer chose. So the event alphabet is read OFF the\n// document: a name a state declares is, by definition, an event of that\n// document, and there is no list here for it to be absent from.\n//\n// That is not a relaxation for its own sake. This file used to carry a consumer's\n// six event names as a closed set, which meant one upstream commit adding a\n// seventh took the importer offline for every document, not just the new one —\n// the same failure mode the report had when it matched STATE names, and the same\n// fix: enforce the shape, read the names.\n//\n// No guard name and no action name is ever dereferenced here, for the same\n// reason fabrika does not dereference them: the ARRAY is the guard. The name\n// travels into the chart's `when` because the chart draws it, and the fold\n// applies the one inline predicate (`retries < maxRetries`) the compiler\n// applies, whatever the name says. An event name is the same kind of thing.\n// ═══════════════════════════════════════════════════════════════════════════\n\nimport type { EventOrigin } from \"../graph\";\n\n/** `TASK_1.DONE` and `DONE` are the same event; the namespace is presentation. */\nexport const bareEvent = (event: string): string => {\n const dot = event.indexOf(\".\");\n return dot === -1 ? event : event.slice(dot + 1);\n};\n\n// ── the imported chart's shape ─────────────────────────────────────────────\n//\n// RUNTIME-TYPED, and the doc comment on `chartFromWorkflow` says why. These\n// interfaces are the chart's VALUE shape narrowed to the three edge forms a\n// fabrika region can produce — not `Chart<C>`, whose whole content is literal\n// types recovered from a literal the compiler can see.\n\n/** A declarative edge, in the only three forms a lane region can produce. */\n/**\n * `cmd` / `otherwiseCmd` are carried but never AUTHORED here: a `workflow.json`\n * declares no effects, so an imported edge simply has neither. They exist\n * because the TYPED door has them and lowering used to drop them, which left a\n * lane page able to say where a click LANDS and never what it FIRES — a fact\n * the author wrote down, lost in translation.\n */\ntype ImportedCmds = {\n readonly cmd?: string | readonly string[];\n readonly otherwiseCmd?: string | readonly string[];\n};\n\nexport type ImportedEdge =\n | ({ readonly target: string } & ImportedCmds)\n | ({\n readonly target: string;\n readonly when: string;\n readonly otherwise: string;\n } & ImportedCmds)\n | ({ readonly resume: { readonly fallback: string } } & ImportedCmds);\n\nexport interface ImportedNode {\n readonly initial?: true;\n readonly on?: Readonly<Record<string, ImportedEdge>>;\n /** `true` success final, `\"error\"` the fallthrough final that trips the lane. */\n readonly end?: true | \"error\";\n}\n\n/** One task's region, as a chart value. One phase group, named by the phase. */\nexport interface ImportedChart {\n readonly events: Readonly<\n Record<\n string,\n {\n readonly scope: \"edges\";\n /**\n * Where this event comes from — the chart's `from`, at runtime.\n *\n * OPTIONAL, and its absence is the document's honest answer:\n * `workflow.json` records the topology and nothing about who sends\n * what, so this is present exactly when the caller supplied it at\n * {@link chartFromWorkflow}.\n */\n readonly from?: EventOrigin;\n }\n >\n >;\n readonly states: Readonly<\n Record<string, Readonly<Record<string, ImportedNode>>>\n >;\n /**\n * State name → the events that state ACCEPTS AND DROPS, leaving itself alone.\n *\n * THE THIRD ANSWER. A lane state either routes an event, or refuses it, or\n * cannot replay it — tea's runtime has always had all three (`compile`'s\n * `refused` self-loops a pair the state's `ignore` names or the event's\n * `scope` does not address, and only a LIVE-but-undecided pair throws), and\n * the lowered chart could carry only two. So `stepTask` threw\n * `UnreplayableLogError` on a log `runLane` had accepted without blinking: a\n * run and a report of that run disagreeing, which is the one thing this\n * module promises they cannot do.\n *\n * IT IS ON THE CHART, NOT ON THE NODE, and that is deliberate.\n * {@link ImportedNode} is a MIRROR of the node fabrika's own compiler emits —\n * `golden.test.ts` compares the two — so a field fabrika never produces does\n * not belong inside it. This is our layer's annotation about someone else's\n * shape, and it sits one level out where it reads as one.\n *\n * ABSENT AT THE IMPORTED DOOR, always. A refusal is a fact about a state's\n * `ignore` and an event's `scope`, and `workflow.json` records neither — so\n * `chartFromWorkflow` writes none, an imported chart is the same value it\n * always was, and an imported log naming an unrouted event is still refused\n * loudly. Only `defineLane`'s lowering, which can SEE the two, fills it in.\n */\n readonly refusals?: Readonly<Record<string, readonly string[]>>;\n}\n\nexport interface ImportedPhase {\n readonly name: string;\n readonly tasks: readonly string[];\n}\n\nexport interface ImportedLane {\n /** The document's own `id`, when it carries one. */\n readonly id?: string;\n /** What fires this lane — a chore workflow's own field, carried not invented. */\n readonly trigger?: string;\n readonly phases: readonly ImportedPhase[];\n /** The workflow's two terminals, read off the last phase's `onDone` pair. */\n readonly terminals: { readonly complete: string; readonly tripped: string };\n /** One chart per task id — the ask's `charts`. */\n readonly charts: Readonly<Record<string, ImportedChart>>;\n /**\n * The document's `context` per task, minus the retry bookkeeping the fold\n * owns. `maxRetries` is split out because it is a transition input, not a\n * passenger — the guarded arm reads it.\n */\n readonly context: Readonly<\n Record<\n string,\n {\n readonly maxRetries: number;\n readonly extras: Readonly<Record<string, unknown>>;\n }\n >\n >;\n}\n\n/**\n * THE ONE PLACE PROVENANCE ENTERS.\n *\n * `workflow.json` carries topology and nothing else: it says `queued --WIP-->\n * build` and it does not say, and has never said, who sends a `WIP`. That fact\n * lives in fabrika's CODE, not in fabrika's document — so it cannot be read\n * here and it must not be guessed here.\n *\n * So the caller states it, ONCE, at the seam where their world meets ours, and\n * everything downstream derives from that: the charts carry it, the report\n * groups by it, the inspector reports it. One map, at the boundary the\n * information actually crosses — not a default sprinkled through the readers,\n * and not a table of fabrika's own event names baked in as a fallback, which\n * would put us right back to owning a copy of someone else's vocabulary.\n *\n * ```ts\n * chartFromWorkflow(document, {\n * from: {\n * WIP: { world: \"the operator\" },\n * BLOCKED: { world: \"the operator\" },\n * UNBLOCKED: { world: \"a human\" },\n * DONE: \"cmd\",\n * PASS: \"cmd\",\n * FAIL: \"cmd\",\n * },\n * });\n * ```\n *\n * Omit it and every reader degrades honestly — it says which events a state\n * accepts and refuses to say who they come from.\n */\nexport interface WorkflowImportOptions {\n /**\n * Event name → where its Msg comes from. Keyed by the BARE name, so one\n * entry covers every task's namespaced spelling of it (`ISSUE.WIP`,\n * `PARK_SWEEP.WIP`) — the namespace is presentation, the event is the event.\n *\n * A name with no entry is left undeclared rather than defaulted. \"I do not\n * know\" and \"the outside world\" are different answers and only one of them\n * is safe to invent.\n */\n readonly from?: Readonly<Record<string, EventOrigin>>;\n /**\n * Refuse a `from` key that names no event THIS document routes.\n *\n * The silent drop it closes is real: `UNBLOKED: { world: \"a human\" }` imports\n * clean, and every reader downstream then answers \"the chart does not say\"\n * for the one event the caller had just taken the trouble to declare. The\n * cross-check needs no list of ours — {@link eventAlphabet} derives the\n * document's own alphabet, which is precisely what that function exists for\n * and what nothing was calling.\n *\n * OPT-IN, because the map is legitimately WIDER than one document. A\n * consumer's cast is a property of their world, not of one template, so one\n * `from` covers every workflow they run — `src/chart/report/__fixtures__/\n * origins.ts` states fabrika's six once and imports two templates with it,\n * and the chore template routes neither `PASS` nor `FAIL`. Defaulting to\n * strict would make sharing a cast an error, which is the wrong half of the\n * trade. So the caller says which of the two they meant: pass this when the\n * map was written FOR this document, and a typo in it stops compiling.\n */\n readonly strictFrom?: true;\n}\n\n/**\n * The document does not fit — with EVERY defect named, never a half-import.\n *\n * Same contract as fabrika's `Malformed`: a `workflow.json` that cannot be\n * compiled comes back as a list of reasons rather than as a machine that works\n * for some states. Thrown rather than returned because the chart module's other\n * doors throw too (`initialStateOf`, `CellTargetError`) and an importer that\n * returned a union would be the only one a caller could forget to check.\n */\nexport class WorkflowImportError extends Error {\n override readonly name = \"WorkflowImportError\";\n readonly _tag = \"WorkflowImportError\" as const;\n constructor(public readonly defects: readonly string[]) {\n super(\n `@demlik/tea: this workflow.json does not compile to charts —\\n` +\n defects.map((d) => ` • ${d}`).join(\"\\n\"),\n );\n }\n}\n\nconst isRecord = (v: unknown): v is Record<string, unknown> =>\n typeof v === \"object\" && v !== null && !Array.isArray(v);\n\nconst nodeType = (node: unknown): string | undefined =>\n isRecord(node) && typeof node.type === \"string\" ? node.type : undefined;\n\n/**\n * The retry budget a document inherits when its `context` names none.\n *\n * Exported because the fold needs the same number when it boots a task the\n * document's `context` never mentioned, and a default spelled in two files is\n * a default that drifts in one of them.\n */\nexport const RETRY_BUDGET = 2;\n\n/**\n * The `when` a guarded arm carries when the document names no guard.\n *\n * A DESCRIPTION OF THE GRAMMAR, not a borrowed name. A two-arm array means\n * \"retry while the budget holds, else fall through\" in every document, because\n * that is what the array IS — so when the author wrote no label, the label says\n * the thing the array already said. Defaulting to some consumer's guard name\n * (`retriesRemaining`) would print their word over another consumer's document.\n */\nconst DEFAULT_GUARD = \"retries remain\";\n\ninterface RegionImport {\n readonly node?: Readonly<Record<string, ImportedNode>>;\n readonly defects: readonly string[];\n}\n\n/** One task region → the phase group's state bag. `hist` is DROPPED, not kept. */\nfunction importRegion(taskId: string, region: unknown): RegionImport {\n const defects: string[] = [];\n if (\n !isRecord(region) ||\n !isRecord(region.states) ||\n typeof region.initial !== \"string\"\n ) {\n return {\n defects: [\n `task \"${taskId}\": region must carry string \\`initial\\` and \\`states\\``,\n ],\n };\n }\n const states = region.states;\n const initialState = region.initial;\n if (states[initialState] === undefined) {\n defects.push(\n `task \"${taskId}\": initial state \"${initialState}\" is not in \\`states\\``,\n );\n }\n\n // Pass 1: which names are finals at all. The polarity needs the whole set\n // before any edge is read, because an error final is recognised by the edge\n // that REACHES it and the edge may be declared before the state.\n const finals = new Set<string>();\n for (const [name, node] of Object.entries(states)) {\n if (nodeType(node) === \"final\") finals.add(name);\n }\n const errorFinals = new Set<string>();\n\n // Pass 2: the edges.\n const on: Record<string, Record<string, ImportedEdge>> = {};\n for (const [stateName, node] of Object.entries(states)) {\n // `hist` IS a state node in the document and is NOT a chart state: the\n // chart carries history as a property of the EDGE (`resume`), which is why\n // it needs no pseudo-state to point at. Dropping it here is the same drop\n // fabrika's compiler makes, one line above its own table build.\n if (nodeType(node) === \"history\") continue;\n const edges: Record<string, ImportedEdge> = {};\n on[stateName] = edges;\n if (!isRecord(node)) {\n defects.push(`task \"${taskId}\": state \"${stateName}\" is not an object`);\n continue;\n }\n const raw = node.on ?? {};\n if (!isRecord(raw)) {\n defects.push(\n `task \"${taskId}\": state \"${stateName}\" carries a non-object \\`on\\``,\n );\n continue;\n }\n // Which bare name each spelling in THIS state collapsed to, so the one\n // event-name rule that IS grammatical can be checked: a state holds one\n // cell per event, so two spellings of one event in one state is a document\n // that means two things by the same edge. Nothing here cares WHICH names.\n const spelledAs = new Map<string, string>();\n for (const [eventName, transition] of Object.entries(raw)) {\n const event = bareEvent(eventName);\n if (event === \"\") {\n defects.push(\n `task \"${taskId}\": state \"${stateName}\" listens for \"${eventName}\", which names no event once its namespace is stripped`,\n );\n continue;\n }\n const already = spelledAs.get(event);\n if (already !== undefined) {\n defects.push(\n `task \"${taskId}\": state \"${stateName}\" spells the same event twice — \"${already}\" and \"${eventName}\" are both \\`${event}\\`, and a state routes each event once`,\n );\n continue;\n }\n spelledAs.set(event, eventName);\n\n // ── the guarded array ────────────────────────────────────────────────\n if (Array.isArray(transition)) {\n const arms = transition.map((arm) =>\n isRecord(arm) && typeof arm.target === \"string\"\n ? arm.target\n : undefined,\n );\n const [retry, fallthrough] = arms;\n if (\n transition.length !== 2 ||\n retry === undefined ||\n fallthrough === undefined\n ) {\n defects.push(\n `task \"${taskId}\": guarded \"${eventName}\" must be a two-arm array of \\`{target}\\` — [retry-while-retries-remain, else-fallthrough]`,\n );\n continue;\n }\n for (const target of [retry, fallthrough]) {\n if (states[target] === undefined) {\n defects.push(\n `task \"${taskId}\": \"${eventName}\" targets unknown state \"${target}\"`,\n );\n }\n }\n // THE POLARITY, recognised exactly where fabrika recognises it: a final\n // reached as the fallthrough is the task's error terminal.\n if (finals.has(fallthrough)) errorFinals.add(fallthrough);\n const head = transition[0];\n const when =\n isRecord(head) && typeof head.guard === \"string\"\n ? head.guard\n : DEFAULT_GUARD;\n edges[event] = { target: retry, when, otherwise: fallthrough };\n continue;\n }\n\n if (typeof transition !== \"string\") {\n defects.push(\n `task \"${taskId}\": \"${eventName}\" is neither a target nor a guarded array`,\n );\n continue;\n }\n if (states[transition] === undefined) {\n defects.push(\n `task \"${taskId}\": \"${eventName}\" targets unknown state \"${transition}\"`,\n );\n continue;\n }\n // ── the history target ───────────────────────────────────────────────\n edges[event] =\n nodeType(states[transition]) === \"history\"\n ? { resume: { fallback: initialState } }\n : { target: transition };\n }\n }\n\n if (defects.length > 0) return { defects };\n\n const out: Record<string, ImportedNode> = {};\n for (const [name, node] of Object.entries(states)) {\n if (nodeType(node) === \"history\") continue;\n const edges = on[name] ?? {};\n const isFinal = finals.has(name);\n out[name] = {\n ...(name === initialState ? { initial: true as const } : {}),\n ...(Object.keys(edges).length > 0 ? { on: edges } : {}),\n ...(isFinal\n ? { end: errorFinals.has(name) ? (\"error\" as const) : (true as const) }\n : {}),\n };\n }\n return { node: out, defects: [] };\n}\n\n/** The two targets of a phase's `onDone` pair: `[guarded success, fallthrough]`. */\nfunction onDoneTargets(\n phaseName: string,\n onDone: unknown,\n): { targets?: readonly [string, string]; defect?: string } {\n const defect = `phase \"${phaseName}\": \\`onDone\\` must be a two-arm array of \\`{target}\\` — [{target, guard}, {target}]`;\n if (!Array.isArray(onDone) || onDone.length !== 2) return { defect };\n const [success, trip] = onDone.map((arm) =>\n isRecord(arm) && typeof arm.target === \"string\" ? arm.target : undefined,\n );\n return success === undefined || trip === undefined\n ? { defect }\n : { targets: [success, trip] as const };\n}\n\n/**\n * `workflow.json` → one chart per task, plus the phase topology around them.\n *\n * WHICH HALF GUARANTEES WHAT — this matters, and it is the whole reason the\n * authored fixture (`src/chart/__fixtures__/lane.ts`) still exists beside this\n * function rather than being deleted in its favour:\n *\n * THIS FUNCTION gives you FIDELITY. It reads bytes that only exist at\n * runtime, so its result is `ImportedChart` — states, events and targets are\n * `string`, and nothing about them is checked before the process starts. What\n * it buys is that the drawing is of THE document the driver is actually\n * folding, including a `workflow.json` this repo has never seen.\n *\n * THE AUTHORED FIXTURE gives you TYPES. `lane.ts` is the same machine written\n * as a literal, so `StateName`, `ResumeTargets`, `Assigns` and the totality\n * obligation are all real there, and `assert.test-d.ts` pins them. What it\n * cannot do is follow a document it was not written against.\n *\n * Neither replaces the other. The golden test is the seam: it asserts this\n * importer's edge set against what fabrika's own compiler produces for the same\n * file, so the runtime-typed half stays honest about the literal-typed one.\n *\n * @param document the PARSED `workflow.json` — `JSON.parse`'s output, not text.\n * @param options {@link WorkflowImportOptions} — the facts the document does\n * not carry, stated once at the boundary they enter through.\n * @throws {WorkflowImportError} with every defect named, never a half-import.\n */\nexport function chartFromWorkflow(\n document: unknown,\n options: WorkflowImportOptions = {},\n): ImportedLane {\n const defects: string[] = [];\n const machineDef = isRecord(document) ? document.machine : undefined;\n if (!isRecord(machineDef) || !isRecord(machineDef.states)) {\n throw new WorkflowImportError([\n \"document must carry a `machine.states` object\",\n ]);\n }\n const documentContext = isRecord(machineDef.context)\n ? machineDef.context\n : {};\n const declaredTrigger = isRecord(document) ? document.trigger : undefined;\n if (declaredTrigger !== undefined && typeof declaredTrigger !== \"string\") {\n defects.push(\n \"document `trigger` must be a string naming what fires this lane\",\n );\n }\n\n const machineStates = machineDef.states;\n const charts: Record<string, ImportedChart> = {};\n const context: Record<\n string,\n {\n readonly maxRetries: number;\n readonly extras: Readonly<Record<string, unknown>>;\n }\n > = {};\n const phases: ImportedPhase[] = [];\n const gateTargets = new Set<string>();\n let terminals: { complete: string; tripped: string } | undefined;\n\n for (const [phaseName, node] of Object.entries(machineStates)) {\n if (nodeType(node) !== \"parallel\" || !isRecord(node)) continue;\n const regions = node.states;\n if (!isRecord(regions) || Object.keys(regions).length === 0) {\n defects.push(\n `phase \"${phaseName}\": a parallel phase must carry task regions in \\`states\\``,\n );\n continue;\n }\n const phaseTasks: string[] = [];\n for (const [taskId, region] of Object.entries(regions)) {\n const imported = importRegion(taskId, region);\n defects.push(...imported.defects);\n if (imported.node !== undefined) {\n const events: Record<\n string,\n { readonly scope: \"edges\"; readonly from?: EventOrigin }\n > = {};\n for (const edges of Object.values(imported.node)) {\n for (const event of Object.keys(edges.on ?? {})) {\n // The caller's map is the ONLY source of `from` — read once, here,\n // and written onto the event. Absent stays absent.\n const origin = options.from?.[event];\n events[event] =\n origin === undefined\n ? { scope: \"edges\" }\n : { scope: \"edges\", from: origin };\n }\n }\n // ONE group, named by the phase. The authored twin splits the same\n // states into working/parked/done, and that split is an AUTHORING\n // choice the document does not record — inventing it here would be\n // manufacturing knowledge the source does not have. It costs nothing:\n // every event is `scope: \"edges\"` (a lane state either routes an event\n // or refuses it), and with no broadcast scope the grouping carries no\n // obligation to carry.\n charts[taskId] = { events, states: { [phaseName]: imported.node } };\n }\n const ctx = documentContext[taskId];\n const bag = isRecord(ctx) ? ctx : {};\n const { maxRetries: rawMax, retries: _retries, ...extras } = bag;\n context[taskId] = {\n maxRetries: typeof rawMax === \"number\" ? rawMax : RETRY_BUDGET,\n extras,\n };\n phaseTasks.push(taskId);\n }\n phases.push({ name: phaseName, tasks: phaseTasks });\n\n const gate = onDoneTargets(phaseName, node.onDone);\n if (gate.defect !== undefined) defects.push(gate.defect);\n if (gate.targets !== undefined) {\n for (const target of gate.targets) {\n gateTargets.add(target);\n if (machineStates[target] === undefined) {\n defects.push(\n `phase \"${phaseName}\": \\`onDone\\` targets unknown machine-level state \"${target}\"`,\n );\n }\n }\n // Every phase names the same trip terminal; the LAST phase's success\n // target is the workflow's complete terminal, because earlier ones target\n // the next phase.\n terminals = { complete: gate.targets[0], tripped: gate.targets[1] };\n }\n }\n\n // A machine-level state the loop above did not import is a terminal or a\n // defect — never dropped silently.\n for (const [name, node] of Object.entries(machineStates)) {\n if (nodeType(node) === \"parallel\" && isRecord(node)) continue;\n if (nodeType(node) !== \"final\") {\n defects.push(\n `machine-level state \"${name}\" is neither a \\`parallel\\` phase nor a \\`final\\` terminal`,\n );\n } else if (!gateTargets.has(name)) {\n defects.push(\n `machine-level final \"${name}\" is targeted by no phase's \\`onDone\\` pair`,\n );\n }\n }\n if (phases.length === 0)\n defects.push(\"machine holds no `parallel` phase state\");\n if (defects.length > 0) throw new WorkflowImportError(defects);\n if (terminals === undefined) {\n throw new WorkflowImportError([\n \"no phase carried a readable `onDone` pair\",\n ]);\n }\n\n const id =\n isRecord(document) && typeof document.id === \"string\"\n ? document.id\n : undefined;\n const lane: ImportedLane = {\n ...(id === undefined ? {} : { id }),\n ...(typeof declaredTrigger === \"string\"\n ? { trigger: declaredTrigger }\n : {}),\n phases,\n terminals,\n charts,\n context,\n };\n\n // THE `from` MAP, CROSS-CHECKED — `eventAlphabet` exists for exactly this\n // and nothing was calling it. The alphabet is DERIVED from the document, so\n // this compares the caller's claim against the document itself rather than\n // against a list of ours. See `strictFrom` for why it is the caller's call.\n if (options.strictFrom === true) {\n const declared = new Set(eventAlphabet(lane));\n const strays = Object.keys(options.from ?? {}).filter(\n (event) => !declared.has(event),\n );\n if (strays.length > 0) {\n throw new WorkflowImportError(\n strays.map(\n (event) =>\n `\\`from\\` names \"${event}\", which no state in this document routes — the map is keyed by the BARE event name`,\n ),\n );\n }\n }\n return lane;\n}\n\n/** Parse and import in one step — for a caller holding the document's bytes. */\nexport function chartFromWorkflowText(\n text: string,\n options: WorkflowImportOptions = {},\n): ImportedLane {\n let parsed: unknown;\n try {\n parsed = JSON.parse(text);\n } catch {\n throw new WorkflowImportError([\"the document is not JSON\"]);\n }\n return chartFromWorkflow(parsed, options);\n}\n\n// ── reading a chart back ───────────────────────────────────────────────────\n\n/** Every state in an imported chart, flattened out of its one phase group. */\nexport function statesOf(\n chart: ImportedChart,\n): ReadonlyMap<string, ImportedNode> {\n const out = new Map<string, ImportedNode>();\n for (const group of Object.values(chart.states)) {\n for (const [name, node] of Object.entries(group)) out.set(name, node);\n }\n return out;\n}\n\n/** The state marked `initial: true`. */\nexport function initialOf(chart: ImportedChart): string {\n for (const [name, node] of statesOf(chart)) {\n if (node.initial === true) return name;\n }\n throw new Error(\"@demlik/tea: imported chart marks no initial state\");\n}\n\n/**\n * Every event name this lane declares, in first-declaration order.\n *\n * THE ALPHABET, DERIVED — the answer a caller used to get from a constant in\n * this file listing one consumer's six. It is a fact about the document, so it\n * is read from the document: the bare names its states route, deduplicated\n * across tasks and phases. A consumer that adds an event gets it here the\n * commit it lands, without a release of ours.\n *\n * Use it to build the `from` map at the import boundary and know you covered\n * every name, or to diff two revisions of a workflow for a vocabulary change.\n */\nexport function eventAlphabet(lane: ImportedLane): readonly string[] {\n const out = new Set<string>();\n for (const chart of Object.values(lane.charts)) {\n for (const event of Object.keys(chart.events)) out.add(event);\n }\n return [...out];\n}\n\n/**\n * Where `event` comes from, or `undefined` when the chart does not say.\n *\n * The ONE read of provenance, so a reader that wants to group by origin and a\n * reader that wants to label one event cannot disagree about what \"undeclared\"\n * looks like.\n */\nexport function originOf(\n chart: ImportedChart,\n event: string,\n): EventOrigin | undefined {\n return chart.events[event]?.from;\n}\n\n/** `true` success, `\"error\"` tripped, `false` not a final — the ONE polarity read. */\nexport function endPolarityOf(\n node: ImportedNode | undefined,\n): true | \"error\" | false {\n if (node?.end === undefined) return false;\n return node.end;\n}\n","// ═══════════════════════════════════════════════════════════════════════════\n// THE FOLD — `events.jsonl` in, per-task leaf states out, from scratch.\n//\n// The mirror of `packages/fabrika-cli/src/lane/fold.ts`. It is here for two\n// reasons and neither is \"because we might as well\":\n//\n// 1. THE TIMELINE. `lane history` returns the log verbatim and deliberately\n// does NOT store `from → to` — those are reconstructible by folding, so\n// storing them would be a second copy of a derived fact. Reconstructing\n// them is therefore the reader's job, and the reader needs a fold to do\n// it. Because the fold is a LEFT fold that is pure over a prefix, the\n// state before step k is exactly `foldLog(entries.slice(0, k))` — time\n// travel that is exact rather than approximated.\n//\n// 2. THE FILE PATH. A caller holding only `workflow.json` + `events.jsonl`\n// has no `lane status` output to be handed. It derives one.\n//\n// The transition semantics below are fabrika's, verbatim in behaviour: the\n// guard is the one inline `retries < maxRetries` (the guard NAME in the\n// document is inert data, never dereferenced), a resume lands on `was ?? the\n// region's initial` and does NOT rewrite `was`, and every other edge records\n// `was = the state you left`.\n// ═══════════════════════════════════════════════════════════════════════════\nimport { edgeKey } from \"./draw\";\nimport {\n bareEvent,\n endPolarityOf,\n type ImportedChart,\n type ImportedLane,\n initialOf,\n RETRY_BUDGET,\n statesOf,\n} from \"./workflow\";\n\n/**\n * The edge a step DREW, keyed as {@link edgeKey} spells it.\n *\n * ONE DECLARATION SITE for the resume rule, and that is the whole reason it is\n * a function rather than four lines inside {@link timeline}. A resume edge is\n * DRAWN once, to its fallback, and WALKED to wherever `was` pointed — so\n * recovering \"which edge lit up\" from the observed target lands on an edge the\n * drawing does not have. Any reader that knows `from`/`event`/`to` and wants\n * the drawn edge (a folded log's timeline; a live lane's recorded tape) asks\n * here, so the two cannot disagree about which edge to thicken.\n */\nexport function walkedEdgeKey(\n chart: ImportedChart,\n from: string,\n event: string,\n to: string,\n): string {\n const declared = statesOf(chart).get(from)?.on?.[event];\n const drawn =\n declared !== undefined && \"resume\" in declared\n ? declared.resume.fallback\n : to;\n return edgeKey(from, event, drawn);\n}\n\n/** One appended line of `events.jsonl`: which task, which event, when. */\nexport interface LogEntry {\n readonly task: string;\n readonly event: string;\n readonly at: string;\n}\n\n/** One task's folded state: the leaf, the retry budget, and the state it left. */\nexport interface TaskState {\n readonly type: string;\n readonly retries: number;\n readonly maxRetries: number;\n readonly was?: string;\n}\n\n/**\n * The derived answer `lane status` prints — reproduced here field for field,\n * because a report that computed its own vocabulary would contradict the driver\n * the moment the two disagreed.\n */\nexport interface LaneStatus {\n readonly stateValue:\n | string\n | Readonly<Record<string, Readonly<Record<string, string>> | string>>;\n readonly status: \"active\" | \"done\";\n readonly context: Readonly<Record<string, unknown>>;\n}\n\n/** The log does not replay against this workflow — with the reason named. */\nexport class UnreplayableLogError extends Error {\n override readonly name = \"UnreplayableLogError\";\n readonly _tag = \"UnreplayableLogError\" as const;\n constructor(public readonly defects: readonly string[]) {\n super(\n `@demlik/tea: this events log does not replay against this workflow —\\n` +\n defects.map((d) => ` • ${d}`).join(\"\\n\"),\n );\n }\n}\n\n/**\n * Parse `events.jsonl`. A line that does not parse is a DEFECT, never a\n * silently skipped event — a report built on a log it half-read is worse than\n * no report.\n */\nexport function parseEventsJsonl(text: string): readonly LogEntry[] {\n const defects: string[] = [];\n const entries: LogEntry[] = [];\n for (const [index, line] of text.split(\"\\n\").entries()) {\n if (line.trim() === \"\") continue;\n let parsed: unknown;\n try {\n parsed = JSON.parse(line);\n } catch {\n defects.push(`line ${index + 1} is not JSON`);\n continue;\n }\n const entry = asLogEntry(parsed);\n if (entry === undefined) {\n defects.push(\n `line ${index + 1} does not carry string \\`task\\`/\\`event\\`/\\`at\\``,\n );\n continue;\n }\n entries.push(entry);\n }\n if (defects.length > 0) throw new UnreplayableLogError(defects);\n return entries;\n}\n\nfunction asLogEntry(value: unknown): LogEntry | undefined {\n if (typeof value !== \"object\" || value === null) return undefined;\n const record = value as { task?: unknown; event?: unknown; at?: unknown };\n if (\n typeof record.task !== \"string\" ||\n typeof record.event !== \"string\" ||\n typeof record.at !== \"string\"\n ) {\n return undefined;\n }\n return { task: record.task, event: record.event, at: record.at };\n}\n\n/** `lane history`'s stdout — a JSON array of the same entries, verbatim. */\nexport function parseHistoryJson(text: string): readonly LogEntry[] {\n let parsed: unknown;\n try {\n parsed = JSON.parse(text);\n } catch {\n throw new UnreplayableLogError([\"`lane history` output is not JSON\"]);\n }\n if (!Array.isArray(parsed)) {\n throw new UnreplayableLogError([\n \"`lane history` output is not a JSON array of entries\",\n ]);\n }\n const entries: LogEntry[] = [];\n for (const [index, raw] of parsed.entries()) {\n const entry = asLogEntry(raw);\n if (entry === undefined) {\n throw new UnreplayableLogError([\n `history entry ${index} does not carry string \\`task\\`/\\`event\\`/\\`at\\``,\n ]);\n }\n entries.push(entry);\n }\n return entries;\n}\n\n/**\n * EVERY task the log names that this lane does not have, never just the first.\n *\n * The same contract {@link parseEventsJsonl} keeps one function up, and the\n * same one fabrika keeps: a log that names four tasks from a workflow the\n * caller swapped underneath it is four facts, and reporting one of them per\n * run turns one fix into four rounds of paste-the-error-back. Deduplicated by\n * name, in first-mention order — a thousand-line log naming one stale task is\n * one defect, not a thousand.\n */\nconst unknownTaskDefects = (\n lane: ImportedLane,\n entries: readonly LogEntry[],\n): readonly string[] => {\n const seen = new Set<string>();\n const defects: string[] = [];\n for (const entry of entries) {\n if (lane.charts[entry.task] !== undefined || seen.has(entry.task)) continue;\n seen.add(entry.task);\n defects.push(\n `log names task \"${entry.task}\", which is not in this lane's machine`,\n );\n }\n return defects;\n};\n\nconst chartOf = (lane: ImportedLane, taskId: string): ImportedChart => {\n const chart = lane.charts[taskId];\n if (chart === undefined) {\n throw new UnreplayableLogError([\n `log names task \"${taskId}\", which is not in this lane's machine`,\n ]);\n }\n return chart;\n};\n\n/** The initial state of every task — the fold's zero. */\nexport function initialStates(\n lane: ImportedLane,\n): Readonly<Record<string, TaskState>> {\n const out: Record<string, TaskState> = {};\n for (const [taskId, chart] of Object.entries(lane.charts)) {\n out[taskId] = {\n type: initialOf(chart),\n retries: 0,\n maxRetries: lane.context[taskId]?.maxRetries ?? RETRY_BUDGET,\n };\n }\n return out;\n}\n\n/**\n * ONE event applied to ONE task. The three edge forms, and the two ways there\n * can be no edge.\n *\n * THERE ARE THREE ANSWERS, NOT TWO, and this used to give two. tea's runtime\n * has always distinguished a REFUSAL — an event the state accepts and drops,\n * because its `ignore` names the event or the event is broadcast to some other\n * phase — from a pair it cannot replay, which is the only one that throws. The\n * lowered chart could not carry the first, so a log the runtime had happily\n * accepted came back `UnreplayableLogError` here: a run and a report of that\n * run disagreeing about what the machine did. The refusal set now rides on the\n * chart (`ImportedChart.refusals`, written by `lowerRegion` and by nothing\n * else), so both sides refuse the same pairs by construction.\n *\n * `taskId` is for the DIAGNOSTIC only. `stepTask` folds one region and has\n * never needed to know which; a reader staring at `state \"queued\" holds no cell\n * for \"DONE\"` on a twelve-task lane needs to know very much, and the callers\n * have it.\n */\nexport function stepTask(\n chart: ImportedChart,\n state: TaskState,\n event: string,\n taskId?: string,\n): TaskState {\n const node = statesOf(chart).get(state.type);\n const edge = node?.on?.[event];\n if (edge === undefined) {\n if (chart.refusals?.[state.type]?.includes(event) === true) return state;\n throw new UnreplayableLogError([\n `${taskId === undefined ? \"\" : `task \"${taskId}\": `}state \"${state.type}\" holds no cell for \"${event}\"`,\n ]);\n }\n if (\"resume\" in edge) {\n // `was` is NOT rewritten: you are LEAVING the park, not entering one.\n return { ...state, type: state.was ?? edge.resume.fallback };\n }\n if (\"when\" in edge) {\n // The guard NAME is inert. This one predicate is the guard, in fabrika and\n // here — which is exactly why the two cannot drift apart on a rename.\n return state.retries < state.maxRetries\n ? {\n ...state,\n type: edge.target,\n retries: state.retries + 1,\n was: state.type,\n }\n : { ...state, type: edge.otherwise, was: state.type };\n }\n return { ...state, type: edge.target, was: state.type };\n}\n\n/**\n * Fold the whole log into per-task leaf states.\n *\n * PURE OVER A PREFIX: tasks are independent regions, so the global log\n * partitions cleanly and each task folds through its own chart. `foldLane(lane,\n * entries.slice(0, k))` is therefore the exact state after k events, for every\n * k — which is what {@link timeline} spends.\n */\nexport function foldLane(\n lane: ImportedLane,\n entries: readonly LogEntry[],\n): Readonly<Record<string, TaskState>> {\n const unknown = unknownTaskDefects(lane, entries);\n if (unknown.length > 0) throw new UnreplayableLogError(unknown);\n const states: Record<string, TaskState> = { ...initialStates(lane) };\n for (const entry of entries) {\n const chart = chartOf(lane, entry.task);\n const current = states[entry.task];\n if (current === undefined) {\n throw new UnreplayableLogError([\n `log names task \"${entry.task}\", which is not in this lane's machine`,\n ]);\n }\n states[entry.task] = stepTask(\n chart,\n current,\n bareEvent(entry.event),\n entry.task,\n );\n }\n return states;\n}\n\n/** One row of the timeline: the entry, plus the `from → to` nobody stored. */\nexport interface TimelineStep {\n readonly index: number;\n readonly at: string;\n readonly task: string;\n /** The event VERBATIM, namespace and all — the log's own spelling. */\n readonly event: string;\n readonly from: string;\n readonly to: string;\n /**\n * The DECLARED edge this step fired, as {@link edgeKey} spells it.\n *\n * Not derivable from `from`/`event`/`to`, and that is the whole reason it is\n * carried: a resume edge is DRAWN once, to its fallback, and WALKED to\n * wherever `was` pointed. Recovering \"which edge lit up\" from the observed\n * target would land on an edge the drawing does not have — so the step\n * records the edge it took while it still knows.\n */\n readonly edge: string;\n}\n\n/**\n * The log with `from → to` recomputed per step.\n *\n * A single left-to-right pass, which is EXACTLY the prefix fold and not an\n * approximation of it: `foldLane` is a left fold over the same entries in the\n * same order, so the state carried into step k here is the state\n * `foldLane(lane, entries.slice(0, k))` returns. `fold.test.ts` asserts that\n * equality rather than asking you to take it on trust — the cheap form and the\n * definitional form, pinned to each other.\n */\nexport function timeline(\n lane: ImportedLane,\n entries: readonly LogEntry[],\n): readonly TimelineStep[] {\n const unknown = unknownTaskDefects(lane, entries);\n if (unknown.length > 0) throw new UnreplayableLogError(unknown);\n const states: Record<string, TaskState> = { ...initialStates(lane) };\n const steps: TimelineStep[] = [];\n for (const [index, entry] of entries.entries()) {\n const chart = chartOf(lane, entry.task);\n const before = states[entry.task];\n if (before === undefined) {\n throw new UnreplayableLogError([\n `log names task \"${entry.task}\", which is not in this lane's machine`,\n ]);\n }\n const event = bareEvent(entry.event);\n const after = stepTask(chart, before, event, entry.task);\n states[entry.task] = after;\n steps.push({\n index,\n at: entry.at,\n task: entry.task,\n event: entry.event,\n from: before.type,\n to: after.type,\n edge: walkedEdgeKey(chart, before.type, event, after.type),\n });\n }\n return steps;\n}\n\n/**\n * Where one phase stands. The four are exhaustive over a phase in a lane whose\n * log has been folded, and they are POSITIONAL rather than local: a phase whose\n * tasks all happen to be final is `\"waiting\"` if an earlier phase stopped the\n * lane before it could have run.\n */\nexport type PhaseStanding = \"complete\" | \"tripped\" | \"active\" | \"waiting\";\n\n/** One phase, and where it stands after the fold. */\nexport interface PhaseStand {\n readonly name: string;\n /** Its position in the sequence — the phase order, as a number. */\n readonly index: number;\n readonly tasks: readonly string[];\n readonly standing: PhaseStanding;\n /** The tasks in this phase that landed on an ERROR final. */\n readonly tripped: readonly string[];\n}\n\n/**\n * The ONE thing the phase walk reads off a task: which state it is standing in.\n *\n * {@link TaskState} satisfies it, and so does a RUNNING region's own\n * `StateOf<chart>` — which is the whole reason the parameter is spelled this\n * loosely. The fold and the runtime carry different per-task values (the fold's\n * carries `retries`, a region's carries its `ctx`), and the advancement rule\n * reads neither: it reads `type`, looks the node up in the chart, and asks its\n * `end` polarity. Widening the parameter to what the rule ACTUALLY reads is what\n * lets {@link phaseStandings} be called by both without a second copy of it.\n */\nexport type LeafStates = Readonly<Record<string, { readonly type: string }>>;\n\n/** Every task at an error final — the `errors` list, one declaration site. */\nexport function trippedTasks(\n lane: ImportedLane,\n states: LeafStates,\n): readonly string[] {\n return Object.keys(states).filter(\n (taskId) => endPolarityOf(nodeOf(lane, taskId, states)) === \"error\",\n );\n}\n\n/**\n * THE PHASE WALK — the one loop that decides which phase is running, which are\n * behind it, and which never got to start.\n *\n * It is fabrika's `deriveStatus` loop, factored out rather than copied: walk\n * phases in order, the first whose tasks are not ALL final is the active one\n * and the walk stops; a phase that IS all final but holds an error final trips\n * the lane and the walk stops there instead; everything after a stop is\n * `\"waiting\"`, whatever its tasks happen to read.\n *\n * That last clause is the whole reason this is positional. `foldLane` boots\n * every task of every phase, so a later phase's region can sit in a final\n * before its phase ever ran — a child the board abandoned boots straight into\n * an error final, which is exactly the case fabrika's emitter produces. Read\n * locally, that phase looks \"tripped\". Read in sequence, it is a phase that\n * never started, and the lane tripped somewhere else.\n *\n * {@link deriveLaneStatus} and the report both read this, so the compound state\n * value and the phase headings cannot disagree about what is running.\n */\nexport function phaseStandings(\n lane: ImportedLane,\n states: LeafStates,\n): readonly PhaseStand[] {\n const isFinal = (taskId: string): boolean =>\n endPolarityOf(nodeOf(lane, taskId, states)) !== false;\n const errors = trippedTasks(lane, states);\n let stopped = false;\n return lane.phases.map((phase, index) => {\n const tripped = phase.tasks.filter((taskId) => errors.includes(taskId));\n const base = { name: phase.name, index, tasks: phase.tasks, tripped };\n if (stopped) return { ...base, standing: \"waiting\" as const };\n if (!phase.tasks.every(isFinal)) {\n stopped = true;\n return { ...base, standing: \"active\" as const };\n }\n if (tripped.length > 0) {\n stopped = true;\n return { ...base, standing: \"tripped\" as const };\n }\n return { ...base, standing: \"complete\" as const };\n });\n}\n\n/**\n * THE ADVANCEMENT RULE — has the lane left the phases, and by which door?\n *\n * `undefined` means \"still running\": some phase is active, so the lane is\n * sitting in it. A terminal name means the walk ran out of phases — every phase\n * completed (`onDone` chained all the way past the last one, which is what the\n * `complete` terminal IS), or one of them completed holding a region at an\n * `end: \"error\"` final, which trips the lane wherever it had got to.\n *\n * Three lines, and they are pulled out here rather than inlined below because\n * this is the rule the RUNTIME advances by (`runLane`, in `../lane/run`). The\n * runtime does not re-derive it and does not agree with it by inspection: it\n * calls {@link phaseStandings} over its own region states and then this, so\n * \"the machine advanced\" and \"the fold says it advanced\" are the same sentence\n * evaluated twice, not two sentences kept in sync.\n */\nexport function laneTerminalReached(\n stands: readonly PhaseStand[],\n terminals: ImportedLane[\"terminals\"],\n): string | undefined {\n if (stands.some((stand) => stand.standing === \"tripped\"))\n return terminals.tripped;\n if (stands.some((stand) => stand.standing === \"active\")) return undefined;\n return terminals.complete;\n}\n\n/**\n * The whole \"compound machine\", as a pure derivation.\n *\n * The active phase is the first whose tasks are not all final; a COMPLETED\n * phase holding a task in an error final trips the workflow. That is fabrika's\n * `noErrors` gate — never a machine event, and here it reads the chart's\n * `end: \"error\"` polarity, which is the same fact the document's guarded\n * fallthrough declared. The walk itself is {@link phaseStandings}, so the\n * status and the drawing are one derivation seen twice.\n */\nexport function deriveLaneStatus(\n lane: ImportedLane,\n states: Readonly<Record<string, TaskState>>,\n): LaneStatus {\n const errors = trippedTasks(lane, states);\n\n const context: Record<string, unknown> = {};\n for (const [taskId, state] of Object.entries(states)) {\n context[taskId] = {\n retries: state.retries,\n maxRetries: state.maxRetries,\n ...(lane.context[taskId]?.extras ?? {}),\n };\n }\n context.errors = errors;\n\n const stands = phaseStandings(lane, states);\n const terminal = laneTerminalReached(stands, lane.terminals);\n if (terminal !== undefined) {\n return { stateValue: terminal, status: \"done\", context };\n }\n // `laneTerminalReached` returned `undefined`, which is precisely \"some phase\n // is active\" — so this find cannot miss.\n const active = stands.find((stand) => stand.standing === \"active\");\n if (active === undefined) {\n return { stateValue: lane.terminals.complete, status: \"done\", context };\n }\n\n const stateValue: Record<string, Record<string, string> | string> = {\n [active.name]: Object.fromEntries(\n active.tasks.map((taskId) => [taskId, states[taskId]?.type ?? \"?\"]),\n ),\n };\n for (const stand of stands.slice(active.index + 1)) {\n stateValue[stand.name] = \"waiting\";\n }\n return { stateValue, status: \"active\", context };\n}\n\nfunction nodeOf(lane: ImportedLane, taskId: string, states: LeafStates) {\n const chart = lane.charts[taskId];\n const state = states[taskId];\n if (chart === undefined || state === undefined) return undefined;\n return statesOf(chart).get(state.type);\n}\n\n/** `lane status`'s stdout, parsed back into the shape it was printed from. */\nexport function parseStatusJson(text: string): LaneStatus {\n let parsed: unknown;\n try {\n parsed = JSON.parse(text);\n } catch {\n throw new UnreplayableLogError([\"`lane status` output is not JSON\"]);\n }\n if (typeof parsed !== \"object\" || parsed === null) {\n throw new UnreplayableLogError([\"`lane status` output is not an object\"]);\n }\n const record = parsed as {\n stateValue?: unknown;\n status?: unknown;\n context?: unknown;\n };\n if (record.status !== \"active\" && record.status !== \"done\") {\n throw new UnreplayableLogError([\n '`lane status` output carries no `status` of \"active\" | \"done\"',\n ]);\n }\n if (record.stateValue === undefined) {\n throw new UnreplayableLogError([\n \"`lane status` output carries no `stateValue`\",\n ]);\n }\n return {\n stateValue: record.stateValue as LaneStatus[\"stateValue\"],\n status: record.status,\n context:\n typeof record.context === \"object\" && record.context !== null\n ? (record.context as Record<string, unknown>)\n : {},\n };\n}\n","// ═══════════════════════════════════════════════════════════════════════════\n// THE REPORT — one markdown string that reads the same in three places.\n//\n// A terminal, a PR comment and an issue comment are the three surfaces a lane's\n// state is actually looked at on, and they share exactly one format. So the\n// output is markdown with a mermaid fence: GitHub renders the fence, a terminal\n// shows it as the text it is, and neither needs a flag.\n//\n// THE EDITORIAL RULES, which are most of what this file is:\n//\n// ONE DIAGRAM PER TASK THAT MOVED, ACTIVE PHASE ONLY. A comment with eight\n// diagrams is a comment nobody reads. Future phases get one line each, and so\n// do the tasks still sitting at their entry state — a real emitted epic put\n// eight tasks in one phase, six of them untouched, and the rule as originally\n// written (per TASK, not per MOVED task) produced exactly the wall of\n// near-identical pictures it exists to prevent.\n//\n// \"WAITING ON\" IS DERIVED, AND NAMES NOTHING. This file used to answer it by\n// matching STATE NAMES — `queued`, `build`, `review`, `ship`, `blocked`,\n// `human:*` — against a list copied out of fabrika's `wire/lane-brief.ts`.\n// Those names are fabrika's, so a rename upstream turned this report into a\n// confident liar with nothing failing anywhere. The fact it was really after\n// is not \"which state is this\" but \"who has to act next\", which is a property\n// of the EVENT: a Msg comes from a Cmd's result, a Sub firing, or the outside\n// world, and the chart now says which (`graph.ts` §3a, `from`). So the answer\n// is the events legal HERE, grouped by THEIR origin — no state name, no event\n// name, no job title in this file.\n//\n// AND IT STILL REFUSES TO GUESS. A chart that declares no provenance gets no\n// invented one: the line says which events the state accepts and stops, which\n// is what the machine does say — the same refusal `shellState()` makes by\n// answering null rather than inventing a shell.\n//\n// THE RETRY LINE, WHEN AND ONLY WHEN IT MATTERS. `2/2` is the difference\n// between \"in review\" and \"one FAIL from frozen\", and `0/2` is noise.\n// ═══════════════════════════════════════════════════════════════════════════\nimport type { EventOrigin } from \"../graph\";\nimport { drawTask, walkedEdges } from \"./draw\";\nimport {\n deriveLaneStatus,\n foldLane,\n type LaneStatus,\n type LogEntry,\n type PhaseStand,\n phaseStandings,\n type TaskState,\n type TimelineStep,\n timeline,\n} from \"./fold\";\nimport {\n chartFromWorkflow,\n endPolarityOf,\n type ImportedChart,\n type ImportedLane,\n initialOf,\n originOf,\n statesOf,\n} from \"./workflow\";\n\n/** The lane the report is about. `workflow` is the PARSED document, or an import. */\nexport interface LaneReportInput {\n /** `workflow.json`, parsed — or an already-imported lane, reused as is. */\n readonly workflow: unknown;\n readonly entries: readonly LogEntry[];\n /**\n * `lane status`'s answer.\n *\n * OPTIONAL, and that is the whole shape of the two input paths: a caller\n * shelling out to `fabrika` hands over the CLI's own derivation and the\n * report never second-guesses it; a caller holding only the two files omits\n * it and the same derivation runs here.\n */\n readonly status?: LaneStatus;\n /** Heading for the block. Defaults to the document's `id`. */\n readonly title?: string;\n}\n\nexport interface LaneReport {\n readonly markdown: string;\n}\n\nconst isImportedLane = (v: unknown): v is ImportedLane =>\n typeof v === \"object\" &&\n v !== null &&\n Array.isArray((v as ImportedLane).phases) &&\n typeof (v as ImportedLane).charts === \"object\";\n\n/** `{ pipeline: { issue: \"review\" } }` → the phase that is actually running. */\nfunction activePhaseName(status: LaneStatus): string | undefined {\n if (typeof status.stateValue === \"string\") return undefined;\n for (const [name, value] of Object.entries(status.stateValue)) {\n if (typeof value === \"object\") return name;\n }\n return undefined;\n}\n\n/** Event names, as the report writes a list of them. */\nconst listed = (events: readonly string[]): string =>\n events.map((e) => `\\`${e}\\``).join(\", \");\n\n/**\n * One origin's worth of the answer, said the way that origin is said.\n *\n * The three phrasings are the three origins, and each says the thing that\n * origin makes true. A world role is a WHO, so the events are what that who\n * owes; a cmd is work already in flight, so the sentence is about the work and\n * the events are how it comes back; a sub is a source, so the sentence is about\n * the source. The role text (`the operator`, `a human`) is the consumer's own,\n * carried from the chart verbatim — including its article, because only the\n * consumer knows whether there is one of them or any of them.\n */\nfunction phrase(\n origin: EventOrigin,\n state: string,\n events: readonly string[],\n): string {\n if (origin === \"cmd\") {\n return `the work \\`${state}\\` dispatched — ${listed(events)}`;\n }\n if (origin === \"sub\") {\n return `the source \\`${state}\\` is subscribed to — ${listed(events)}`;\n }\n return `${origin.world}'s ${listed(events)}`;\n}\n\n/** The grouping key for an origin — the two words, or the role, distinctly. */\nconst originKey = (origin: EventOrigin): string =>\n typeof origin === \"string\" ? origin : `world:${origin.world}`;\n\n/**\n * What this task is waiting on — or `null` at a final.\n *\n * DERIVED, entirely: the events this state routes, grouped by the origin each\n * one DECLARES, in declaration order. Nothing here knows a state name, an event\n * name or a job title, so a consumer that renames half its states changes this\n * output correctly and a consumer with a completely different cast is served by\n * the same function.\n *\n * The degradation is the point of the second half. Provenance is not in\n * `workflow.json` — it is stated at the import boundary or not at all — so a\n * chart imported without it must say what it actually knows, which is WHICH\n * EVENTS the state accepts. It never says who sends them.\n */\nexport function waitingOn(chart: ImportedChart, state: string): string | null {\n const node = statesOf(chart).get(state);\n if (node?.end !== undefined) return null;\n const events = Object.keys(node?.on ?? {});\n if (events.length === 0) {\n // A live state that routes nothing. `inspectLane` calls this a dead end;\n // there is no one to wait for and saying so is the whole answer.\n return `\\`${state}\\` accepts no events, and it is not a final`;\n }\n\n // Group by origin, keeping the events in the order the chart declares them.\n const groups = new Map<string, { origin: EventOrigin; events: string[] }>();\n const undeclared: string[] = [];\n for (const event of events) {\n const origin = originOf(chart, event);\n if (origin === undefined) {\n undeclared.push(event);\n continue;\n }\n const key = originKey(origin);\n const group = groups.get(key);\n if (group === undefined) groups.set(key, { origin, events: [event] });\n else group.events.push(event);\n }\n\n // NO PROVENANCE AT ALL — the honest floor. Same voice as the refusal this\n // replaces: name what the machine says, and stop.\n if (groups.size === 0) return `\\`${state}\\` accepts ${listed(events)}`;\n\n const parts = [...groups.values()].map((g) =>\n phrase(g.origin, state, g.events),\n );\n // A PARTIAL map is not rounded up to a whole one. The events whose origin was\n // never stated are listed as exactly that, beside the ones that were.\n if (undeclared.length > 0) {\n parts.push(`${listed(undeclared)}, from somewhere the chart does not say`);\n }\n return parts.join(\" · \");\n}\n\n/** `2/2 — one \\`FAIL\\` from \\`frozen\\``, or `null` when no retry has been spent. */\nfunction retryLine(chart: ImportedChart, state: TaskState): string | null {\n if (state.retries <= 0) return null;\n const budget = `${state.retries}/${state.maxRetries}`;\n if (state.retries < state.maxRetries) return `**retries:** ${budget}`;\n // Spent. Name the edge that is now a one-way door, off the chart rather than\n // off a constant — a document whose fallthrough is `tripped` says `tripped`.\n const node = statesOf(chart).get(state.type);\n for (const [event, edge] of Object.entries(node?.on ?? {})) {\n if (\"when\" in edge) {\n return `**retries:** ${budget} — spent; one \\`${event}\\` from \\`${edge.otherwise}\\``;\n }\n }\n return `**retries:** ${budget} — spent`;\n}\n\n/**\n * One phase that is NOT the active one, in one line.\n *\n * The editorial rule the module opened with, applied to the phase dimension: a\n * comment with eight diagrams is a comment nobody reads, so a phase already\n * finished and a phase not yet started each get a line. A finished phase still\n * gets its leaves, because \"complete\" alone does not say WHICH ending each of\n * its tasks reached — and a phase that never started has no leaves worth\n * printing, because every one of them would be an initial state nothing walked.\n */\nfunction phaseLine(\n stand: PhaseStand,\n states: Readonly<Record<string, TaskState>>,\n): string {\n const count = `${stand.tasks.length} task${stand.tasks.length === 1 ? \"\" : \"s\"}`;\n if (stand.standing === \"waiting\") {\n return `**${stand.name}:** waiting — ${count}, not started.`;\n }\n const leaves = stand.tasks\n .map(\n (taskId) =>\n `\\`${taskId}\\` = \\`${states[taskId]?.type ?? \"?\"}\\`${\n stand.tripped.includes(taskId) ? \" **(tripped)**\" : \"\"\n }`,\n )\n .join(\", \");\n return `**${stand.name}:** ${stand.standing} — ${count}: ${leaves}`;\n}\n\nfunction timelineTable(steps: readonly TimelineStep[]): string {\n if (steps.length === 0)\n return \"_no events yet — the lane is at its initial state._\";\n const rows = steps.map(\n (s) =>\n `| ${s.index + 1} | ${s.at} | \\`${s.task}\\` | \\`${s.event}\\` | \\`${s.from}\\` → \\`${s.to}\\` |`,\n );\n return [\n \"| # | at | task | event | from → to |\",\n \"|---|---|---|---|---|\",\n ...rows,\n ].join(\"\\n\");\n}\n\n/**\n * A lane, as one markdown block.\n *\n * The diagram half is behind {@link drawTask}, which is a translation onto\n * `chartMermaid` — the package's one chart renderer.\n */\nexport function laneReport(input: LaneReportInput): LaneReport {\n const lane = isImportedLane(input.workflow)\n ? input.workflow\n : chartFromWorkflow(input.workflow);\n const entries = input.entries;\n const states = foldLane(lane, entries);\n const status = input.status ?? deriveLaneStatus(lane, states);\n const steps = timeline(lane, entries);\n\n const title = input.title ?? lane.id ?? \"lane\";\n const out: string[] = [`## ${title} — ${status.status}`, \"\"];\n\n // ── where it is ─────────────────────────────────────────────────────────\n out.push(`**where it is:** ${describeStateValue(status.stateValue)}`);\n if (lane.trigger !== undefined) out.push(`**fired by:** \\`${lane.trigger}\\``);\n const errors = status.context.errors;\n if (Array.isArray(errors) && errors.length > 0) {\n out.push(\n `**tripped:** ${errors.map((t) => `\\`${String(t)}\\``).join(\", \")} — the lane lands on \\`${lane.terminals.tripped}\\``,\n );\n }\n out.push(\"\");\n\n // ── the phases, in order: one in full, the rest in one line each ────────\n //\n // The standings are DERIVED from the fold — the same walk `deriveLaneStatus`\n // makes — rather than read off `stateValue`, because `stateValue` is silent\n // about a lane that already stopped: it collapses to the terminal's NAME, and\n // a reader of a tripped epic then cannot tell which phase tripped it, or\n // which phases below never got to start. The one thing still taken from\n // `status` is WHICH phase is active, so a report handed the CLI's own answer\n // shows the CLI's answer. (`fold.test.ts` asserts the two agree at every\n // prefix of every run, so this is a precedence rule, not a disagreement.)\n const stands = phaseStandings(lane, states);\n const named = activePhaseName(status);\n const active =\n stands.find((s) => s.name === named) ??\n stands.find((s) => s.standing === \"active\");\n\n for (const stand of stands) {\n if (stand === active) {\n // ONE DIAGRAM PER TASK THAT HAS MOVED — not per task.\n //\n // The rule at the top of this file says a comment with eight diagrams is\n // a comment nobody reads, and until this was run against a real emitted\n // epic the rule was only enforced on the phase dimension. A real phase\n // holds eight tasks; six of them sat untouched at `queued`, and the\n // report spent ~200 of its ~265 lines drawing the same picture six times\n // with a different node lit. A task still at its entry state has a story\n // one line long, so it gets one line.\n const untouched: string[] = [];\n for (const taskId of stand.tasks) {\n const chart = lane.charts[taskId];\n const state = states[taskId];\n if (chart === undefined || state === undefined) continue;\n if (state.type === initialOf(chart)) untouched.push(taskId);\n }\n // If NOTHING in the phase has moved, the phase just started — and\n // collapsing every task would leave the reader with no picture at all.\n // Draw the first as the representative (they are all at the same entry\n // state, so any of them is the same picture) and list the rest.\n if (untouched.length === stand.tasks.length) untouched.shift();\n for (const taskId of stand.tasks) {\n const chart = lane.charts[taskId];\n const state = states[taskId];\n if (chart === undefined || state === undefined) continue;\n if (untouched.includes(taskId)) continue;\n const polarity = endPolarityOf(statesOf(chart).get(state.type));\n out.push(\n `### ${taskId} — \\`${state.type}\\`${polarity === \"error\" ? \" — TRIPPED\" : \"\"}`,\n );\n const waiting = waitingOn(chart, state.type);\n out.push(\n waiting !== null\n ? `**waiting on:** ${waiting}`\n : polarity === \"error\"\n ? // The distinction `end: \"error\"` bought, spent where it is worth\n // something: this task is as finished as a shipped one, and the\n // phase it is in is going to trip the lane when its siblings\n // finish. A report that said \"final\" for both would bury that.\n `**waiting on:** nothing — this task landed on the error final \\`${state.type}\\`, and \\`${stand.name}\\` will trip the lane when its siblings finish.`\n : \"**waiting on:** nothing — this task is final.\",\n );\n const retries = retryLine(chart, state);\n if (retries !== null) out.push(retries);\n out.push(\"\");\n out.push(\"```mermaid\");\n out.push(\n drawTask(chart, {\n current: state.type,\n walked: walkedEdges(steps.filter((s) => s.task === taskId)),\n }),\n );\n out.push(\"```\");\n out.push(\"\");\n }\n if (untouched.length > 0) {\n // Named, not counted: \"6 tasks not started\" tells a reader nothing they\n // can act on, and the names are what they came for.\n const chart = lane.charts[untouched[0] as string];\n const at =\n chart === undefined ? \"their entry state\" : `\\`${initialOf(chart)}\\``;\n out.push(\n `**not started yet:** ${untouched.map((t) => `\\`${t}\\``).join(\", \")} — still at ${at}.`,\n );\n out.push(\"\");\n }\n continue;\n }\n out.push(phaseLine(stand, states));\n out.push(\"\");\n }\n\n // ── the timeline ────────────────────────────────────────────────────────\n out.push(\"### timeline\");\n out.push(\"\");\n out.push(timelineTable(steps));\n out.push(\"\");\n return {\n markdown: `${out\n .join(\"\\n\")\n .replace(/\\n{3,}/g, \"\\n\\n\")\n .trimEnd()}\\n`,\n };\n}\n\nfunction describeStateValue(value: LaneStatus[\"stateValue\"]): string {\n if (typeof value === \"string\") return `\\`${value}\\` — the workflow is done.`;\n const parts: string[] = [];\n for (const [phase, leaf] of Object.entries(value)) {\n if (typeof leaf === \"string\") {\n parts.push(`\\`${phase}\\`: ${leaf}`);\n continue;\n }\n const inner = Object.entries(leaf)\n .map(([task, state]) => `\\`${task}\\` = \\`${state}\\``)\n .join(\", \");\n parts.push(`\\`${phase}\\` → ${inner}`);\n }\n return parts.join(\" · \");\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { tryInterpret } from './chunk-5EHLEUTL.js';
2
- import { Cmd } from './chunk-B5VXOFMZ.js';
1
+ import { tryInterpret } from './chunk-ZSUUOEPL.js';
2
+ import { Cmd } from './chunk-OOYD44JI.js';
3
3
 
4
4
  // src/snapshot/index.ts
5
5
  var DEFAULT_SNAPSHOT_KEY = "@@snapshot";
@@ -89,5 +89,5 @@ function createSnapshot(config) {
89
89
  }
90
90
 
91
91
  export { createSnapshot, snapshotFailed, snapshotLoadFailed, snapshotLoaded, snapshotSaved };
92
- //# sourceMappingURL=chunk-7V4EVLZA.js.map
93
- //# sourceMappingURL=chunk-7V4EVLZA.js.map
92
+ //# sourceMappingURL=chunk-O4MVQTEJ.js.map
93
+ //# sourceMappingURL=chunk-O4MVQTEJ.js.map