@demlik/tea 0.13.0 → 0.14.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.
- package/README.md +11 -9
- package/dist/agent/index.d.ts +637 -45
- package/dist/agent/index.js +9 -19
- package/dist/{chunk-25LBDCBC.js → chunk-6IQPODUF.js} +2 -2
- package/dist/{chunk-25LBDCBC.js.map → chunk-6IQPODUF.js.map} +1 -1
- package/dist/chunk-AQ6ZIMEA.js +421 -0
- package/dist/chunk-AQ6ZIMEA.js.map +1 -0
- package/dist/{chunk-MUUROGIH.js → chunk-BLJ2JQSH.js} +62 -12
- package/dist/chunk-BLJ2JQSH.js.map +1 -0
- package/dist/{chunk-RH5EFRVJ.js → chunk-F2US5BW6.js} +25 -5
- package/dist/chunk-F2US5BW6.js.map +1 -0
- package/dist/{batch-window/index.js → chunk-F7FMAWLA.js} +4 -8
- package/dist/chunk-F7FMAWLA.js.map +1 -0
- package/dist/{chunk-O4MVQTEJ.js → chunk-HUKZQX6U.js} +20 -16
- package/dist/chunk-HUKZQX6U.js.map +1 -0
- package/dist/{chunk-EWJP3YYP.js → chunk-HWVW4AXC.js} +3 -3
- package/dist/chunk-HWVW4AXC.js.map +1 -0
- package/dist/{chunk-DMYGQB4O.js → chunk-HYDWG35Q.js} +23 -6
- package/dist/chunk-HYDWG35Q.js.map +1 -0
- package/dist/{chunk-YUXP55T2.js → chunk-I5MQMJDW.js} +57 -7
- package/dist/chunk-I5MQMJDW.js.map +1 -0
- package/dist/{chunk-J6527VRQ.js → chunk-LFZUK6J2.js} +3 -3
- package/dist/chunk-LFZUK6J2.js.map +1 -0
- package/dist/{chunk-ZVJZ72HY.js → chunk-LYLTKJWM.js} +25 -11
- package/dist/chunk-LYLTKJWM.js.map +1 -0
- package/dist/{chunk-D736QUGF.js → chunk-MYXFNWAJ.js} +4 -5
- package/dist/chunk-MYXFNWAJ.js.map +1 -0
- package/dist/{chunk-K575PT4S.js → chunk-PR6TB3BL.js} +15 -4
- package/dist/chunk-PR6TB3BL.js.map +1 -0
- package/dist/chunk-RQULHGYH.js +1804 -0
- package/dist/chunk-RQULHGYH.js.map +1 -0
- package/dist/{chunk-FV3Z5MBE.js → chunk-TXN2KFHF.js} +14 -4
- package/dist/chunk-TXN2KFHF.js.map +1 -0
- package/dist/{chunk-Q2UM7BXU.js → chunk-VBDU4JL6.js} +2 -2
- package/dist/chunk-VBDU4JL6.js.map +1 -0
- package/dist/chunk-Z2L3LSNV.js +1470 -0
- package/dist/chunk-Z2L3LSNV.js.map +1 -0
- package/dist/{core-Co0LWkIA.d.ts → core-CTzMJ82M.d.ts} +72 -23
- package/dist/devtools/index.d.ts +2 -2
- package/dist/devtools/index.js +207 -2
- package/dist/devtools/index.js.map +1 -1
- package/dist/do/index.d.ts +42 -29
- package/dist/do/index.js +36 -25
- package/dist/do/index.js.map +1 -1
- package/dist/{durable-effects-C6uwzjb5.d.ts → durable-effects-B0-qGQDy.d.ts} +2 -2
- package/dist/extension/index.d.ts +300 -3
- package/dist/extension/index.js +596 -5
- package/dist/extension/index.js.map +1 -1
- package/dist/flow/index.d.ts +1295 -0
- package/dist/flow/index.js +732 -0
- package/dist/flow/index.js.map +1 -0
- package/dist/idempotency/index.d.ts +90 -116
- package/dist/idempotency/index.js +4 -1
- package/dist/{batch-window/index.d.ts → index-4vZzljCD.d.ts} +7 -12
- package/dist/{fan-out/index.d.ts → index-6A7dB8f6.d.ts} +7 -9
- package/dist/index-B5BZ-_cT.d.ts +616 -0
- package/dist/index-Bc40JWVl.d.ts +131 -0
- package/dist/{debounce/index.d.ts → index-DHSUmQTR.d.ts} +7 -7
- package/dist/index-DJWIER_3.d.ts +69 -0
- package/dist/{snapshot/index.d.ts → index-DMCeMPMJ.d.ts} +15 -78
- package/dist/{monitored-run/index.d.ts → index-NjrT3fL2.d.ts} +37 -13
- package/dist/{recorder/index.d.ts → index-TvRb1KVf.d.ts} +4 -7
- package/dist/{deadline/index.d.ts → index-q0hXFeZ0.d.ts} +155 -9
- package/dist/index.d.ts +711 -6
- package/dist/index.js +1 -2
- package/dist/jev/index.d.ts +634 -0
- package/dist/jev/index.js +433 -0
- package/dist/jev/index.js.map +1 -0
- package/dist/machine-CdIcN2Xm.d.ts +1773 -0
- package/dist/machine-viz/index.d.ts +1 -1
- package/dist/machine-viz/index.js +12 -5
- package/dist/machine-viz/index.js.map +1 -1
- package/dist/mem/index.d.ts +18 -3
- package/dist/mem/index.js +22 -2
- package/dist/mem/index.js.map +1 -1
- package/dist/node/index.d.ts +104 -6
- package/dist/node/index.js +132 -9
- package/dist/node/index.js.map +1 -1
- package/dist/{paginator → paginate}/index.d.ts +151 -6
- package/dist/paginate/index.js +7 -0
- package/dist/parity/index.d.ts +4 -10
- package/dist/parity/index.js +4 -7
- package/dist/parity/index.js.map +1 -1
- package/dist/pbt/index.d.ts +247 -5
- package/dist/pbt/index.js +124 -5
- package/dist/pbt/index.js.map +1 -1
- package/dist/{trace-replay → persistence}/index.d.ts +7 -5
- package/dist/persistence/index.js +6 -0
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +1 -2
- package/dist/react/index.js.map +1 -1
- package/dist/resilience/index.d.ts +743 -0
- package/dist/resilience/index.js +657 -0
- package/dist/resilience/index.js.map +1 -0
- package/dist/retry-backoff/index.d.ts +3 -2
- package/dist/retry-backoff/index.js +1 -1
- package/dist/runtime-types-LWDoi943.d.ts +998 -0
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +1 -2
- package/dist/testing/index.js.map +1 -1
- package/dist/{throttled-input → timing}/index.d.ts +143 -12
- package/dist/{throttled-input → timing}/index.js +57 -12
- package/dist/timing/index.js.map +1 -0
- package/dist/{types-XS_miRnB.d.ts → types-DP3f5NIl.d.ts} +1 -1
- package/dist/work-queue/index.d.ts +130 -54
- package/dist/work-queue/index.js +3 -2
- package/dist/work-queue/index.js.map +1 -1
- package/package.json +45 -218
- package/dist/authed-call/index.d.ts +0 -120
- package/dist/authed-call/index.js +0 -134
- package/dist/authed-call/index.js.map +0 -1
- package/dist/await-terminal/index.d.ts +0 -101
- package/dist/await-terminal/index.js +0 -76
- package/dist/await-terminal/index.js.map +0 -1
- package/dist/batch-window/index.js.map +0 -1
- package/dist/cache/index.d.ts +0 -152
- package/dist/cache/index.js +0 -8
- package/dist/chart/index.d.ts +0 -218
- package/dist/chart/index.js +0 -16
- package/dist/chart/index.js.map +0 -1
- package/dist/chart/inspect/index.d.ts +0 -86
- package/dist/chart/inspect/index.js +0 -5
- package/dist/chart/inspect/react.d.ts +0 -113
- package/dist/chart/inspect/react.js +0 -11
- package/dist/chart/inspect/react.js.map +0 -1
- package/dist/chart/inspect/styles.css +0 -286
- package/dist/chart/lane/index.d.ts +0 -362
- package/dist/chart/lane/index.js +0 -9
- package/dist/chart/lane/index.js.map +0 -1
- package/dist/chart/lane/react.d.ts +0 -84
- package/dist/chart/lane/react.js +0 -559
- package/dist/chart/lane/react.js.map +0 -1
- package/dist/chart/lane/server.d.ts +0 -148
- package/dist/chart/lane/server.js +0 -209
- package/dist/chart/lane/server.js.map +0 -1
- package/dist/chart/lane/styles.css +0 -498
- package/dist/chart/lane/viewer/assets/abnfDiagram-N423BO3Z-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/architectureDiagram-T3A2C74G-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/blockDiagram-VBNYF7ZC-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/c4Diagram-5PPSVZJV-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/chunk-2GRJ4B5K-HdDf8SI3.js +0 -1
- package/dist/chart/lane/viewer/assets/chunk-5RXB4S5H-CcNtpUd7.js +0 -231
- package/dist/chart/lane/viewer/assets/chunk-5VM5RSS4-BP4fRS_5.js +0 -15
- package/dist/chart/lane/viewer/assets/chunk-KBJHAD2P-DZOw7xU6.js +0 -1
- package/dist/chart/lane/viewer/assets/chunk-NSK5VX7P-CBCyTZMs.js +0 -128
- package/dist/chart/lane/viewer/assets/classDiagram-JCYQIIEL-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/classDiagram-v2-OCEON4UE-D4uAiFr8.js +0 -206
- package/dist/chart/lane/viewer/assets/cose-bilkent-JH36ORCC-DOwCrGXH.js +0 -1
- package/dist/chart/lane/viewer/assets/cynefinDiagram-MW4NZA55-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/dagre-K_PewWfS.js +0 -1
- package/dist/chart/lane/viewer/assets/dagre-VZM6K2ZE-831qZcA8.js +0 -4
- package/dist/chart/lane/viewer/assets/diagram-7IWD3JNH-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/diagram-B4RE2ZJO-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/diagram-LBJQPF4R-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/diagram-Q27KOJAE-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/diagram-UB23O5K3-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/ebnfDiagram-BXEA7PRR-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/erDiagram-JOGREHBK-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/flowDiagram-UKHOOZJN-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/ganttDiagram-PKOTCBZU-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/gitGraphDiagram-DS77QQ5N-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/index-9SkH5NA3.css +0 -1
- package/dist/chart/lane/viewer/assets/index-Bgt4sXpW.js +0 -195
- package/dist/chart/lane/viewer/assets/infoDiagram-6WML65LV-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/ishikawaDiagram-WSZJBQD7-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/journeyDiagram-NVQOT4AX-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/kanban-definition-27J2QSJJ-G7PaPzy-.js +0 -89
- package/dist/chart/lane/viewer/assets/katex-DOwCrGXH.js +0 -1
- package/dist/chart/lane/viewer/assets/mindmap-definition-FAOFIHXS-CGj9nrVk.js +0 -96
- package/dist/chart/lane/viewer/assets/path-fybaL0A-.js +0 -1
- package/dist/chart/lane/viewer/assets/pegDiagram-VL7TDLO6-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/pieDiagram-7S7Q4E2Y-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/quadrantDiagram-CIZ2JOQS-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/railroadDiagram-AXF67PYL-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/requirementDiagram-LRYGKXZP-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/sankeyDiagram-W5VNT64P-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/sequenceDiagram-SI44F4Z6-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/stateDiagram-OKZ733FA-B_88AzBS.js +0 -1
- package/dist/chart/lane/viewer/assets/stateDiagram-v2-UEYNNEHI-CR5gcgq6.js +0 -1
- package/dist/chart/lane/viewer/assets/swimlanes-SLNWSIFB-B4xK-rwg.js +0 -1
- package/dist/chart/lane/viewer/assets/swimlanesDiagram-ULZ7WXOC-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/timeline-definition-Z64GVDOM-CCv52MfY.js +0 -120
- package/dist/chart/lane/viewer/assets/vennDiagram-T6HMQDX7-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/wardleyDiagram-T6FBY63Y-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/xychartDiagram-ELKLHX3M-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/index.html +0 -15
- package/dist/chart/report/index.d.ts +0 -117
- package/dist/chart/report/index.js +0 -32
- package/dist/chart/report/index.js.map +0 -1
- package/dist/chunk-2YFLOCWX.js +0 -15
- package/dist/chunk-2YFLOCWX.js.map +0 -1
- package/dist/chunk-3I52QZZ5.js +0 -519
- package/dist/chunk-3I52QZZ5.js.map +0 -1
- package/dist/chunk-3ZAFFRRB.js +0 -457
- package/dist/chunk-3ZAFFRRB.js.map +0 -1
- package/dist/chunk-4EQZ76JC.js +0 -33
- package/dist/chunk-4EQZ76JC.js.map +0 -1
- package/dist/chunk-4KLG43GY.js +0 -223
- package/dist/chunk-4KLG43GY.js.map +0 -1
- package/dist/chunk-7FRZ2CT2.js +0 -424
- package/dist/chunk-7FRZ2CT2.js.map +0 -1
- package/dist/chunk-AZZLE7XR.js +0 -62
- package/dist/chunk-AZZLE7XR.js.map +0 -1
- package/dist/chunk-BYQUGDD3.js +0 -16
- package/dist/chunk-BYQUGDD3.js.map +0 -1
- package/dist/chunk-CIQG5L42.js +0 -685
- package/dist/chunk-CIQG5L42.js.map +0 -1
- package/dist/chunk-CLM6ERNO.js +0 -61
- package/dist/chunk-CLM6ERNO.js.map +0 -1
- package/dist/chunk-COS5MSTO.js +0 -88
- package/dist/chunk-COS5MSTO.js.map +0 -1
- package/dist/chunk-CRPZJVD2.js +0 -71
- package/dist/chunk-CRPZJVD2.js.map +0 -1
- package/dist/chunk-D62FDQKE.js +0 -53
- package/dist/chunk-D62FDQKE.js.map +0 -1
- package/dist/chunk-D736QUGF.js.map +0 -1
- package/dist/chunk-DGE4PV4A.js +0 -26
- package/dist/chunk-DGE4PV4A.js.map +0 -1
- package/dist/chunk-DMYGQB4O.js.map +0 -1
- package/dist/chunk-EWJP3YYP.js.map +0 -1
- package/dist/chunk-FV3Z5MBE.js.map +0 -1
- package/dist/chunk-HCEVHFJ7.js +0 -54
- package/dist/chunk-HCEVHFJ7.js.map +0 -1
- package/dist/chunk-J6527VRQ.js.map +0 -1
- package/dist/chunk-JELSZN25.js +0 -47
- package/dist/chunk-JELSZN25.js.map +0 -1
- package/dist/chunk-K575PT4S.js.map +0 -1
- package/dist/chunk-L57ZOT5K.js +0 -184
- package/dist/chunk-L57ZOT5K.js.map +0 -1
- package/dist/chunk-MU6MCIAC.js +0 -15
- package/dist/chunk-MU6MCIAC.js.map +0 -1
- package/dist/chunk-MUUROGIH.js.map +0 -1
- package/dist/chunk-NR7BU22N.js +0 -758
- package/dist/chunk-NR7BU22N.js.map +0 -1
- package/dist/chunk-O4MVQTEJ.js.map +0 -1
- package/dist/chunk-OOYD44JI.js +0 -317
- package/dist/chunk-OOYD44JI.js.map +0 -1
- package/dist/chunk-Q2UM7BXU.js.map +0 -1
- package/dist/chunk-RH5EFRVJ.js.map +0 -1
- package/dist/chunk-S2EGRPCM.js +0 -47
- package/dist/chunk-S2EGRPCM.js.map +0 -1
- package/dist/chunk-SINXE47Y.js +0 -55
- package/dist/chunk-SINXE47Y.js.map +0 -1
- package/dist/chunk-UF4MZSLT.js +0 -53
- package/dist/chunk-UF4MZSLT.js.map +0 -1
- package/dist/chunk-UOC2PL46.js +0 -13
- package/dist/chunk-UOC2PL46.js.map +0 -1
- package/dist/chunk-VYFAZN3F.js +0 -372
- package/dist/chunk-VYFAZN3F.js.map +0 -1
- package/dist/chunk-WRAA7GVZ.js +0 -209
- package/dist/chunk-WRAA7GVZ.js.map +0 -1
- package/dist/chunk-XGELA764.js +0 -163
- package/dist/chunk-XGELA764.js.map +0 -1
- package/dist/chunk-YUXP55T2.js.map +0 -1
- package/dist/chunk-YWIKDKHY.js +0 -307
- package/dist/chunk-YWIKDKHY.js.map +0 -1
- package/dist/chunk-ZJ5AOYBH.js +0 -8
- package/dist/chunk-ZJ5AOYBH.js.map +0 -1
- package/dist/chunk-ZSUUOEPL.js +0 -731
- package/dist/chunk-ZSUUOEPL.js.map +0 -1
- package/dist/chunk-ZVJZ72HY.js.map +0 -1
- package/dist/circuit-breaker/index.d.ts +0 -197
- package/dist/circuit-breaker/index.js +0 -3
- package/dist/circuit-breaker/index.js.map +0 -1
- package/dist/deadline/index.js +0 -6
- package/dist/deadline/index.js.map +0 -1
- package/dist/debounce/index.js +0 -3
- package/dist/debounce/index.js.map +0 -1
- package/dist/extension/react.d.ts +0 -121
- package/dist/extension/react.js +0 -75
- package/dist/extension/react.js.map +0 -1
- package/dist/extension/subs/index.d.ts +0 -45
- package/dist/extension/subs/index.js +0 -80
- package/dist/extension/subs/index.js.map +0 -1
- package/dist/extension/test-utils.d.ts +0 -128
- package/dist/extension/test-utils.js +0 -277
- package/dist/extension/test-utils.js.map +0 -1
- package/dist/fan-out/index.js +0 -5
- package/dist/fan-out/index.js.map +0 -1
- package/dist/fold-BJPdjc9w.d.ts +0 -435
- package/dist/graph-B3L5e0N1.d.ts +0 -923
- package/dist/idempotency/adapter.d.ts +0 -62
- package/dist/idempotency/adapter.js +0 -4
- package/dist/idempotency/adapter.js.map +0 -1
- package/dist/idempotent-intake/index.d.ts +0 -188
- package/dist/idempotent-intake/index.js +0 -7
- package/dist/idempotent-intake/index.js.map +0 -1
- package/dist/journal/index.d.ts +0 -373
- package/dist/journal/index.js +0 -3
- package/dist/journal/index.js.map +0 -1
- package/dist/llm-call/index.d.ts +0 -311
- package/dist/llm-call/index.js +0 -16
- package/dist/llm-call/index.js.map +0 -1
- package/dist/machine-BtFWQmmq.d.ts +0 -804
- package/dist/monitored-run/index.js +0 -10
- package/dist/monitored-run/index.js.map +0 -1
- package/dist/paginated-walk/index.d.ts +0 -235
- package/dist/paginated-walk/index.js +0 -16
- package/dist/paginated-walk/index.js.map +0 -1
- package/dist/paginator/index.js +0 -3
- package/dist/paginator/index.js.map +0 -1
- package/dist/pbt/arbitraries/index.d.ts +0 -136
- package/dist/pbt/arbitraries/index.js +0 -3
- package/dist/pbt/arbitraries/index.js.map +0 -1
- package/dist/pbt/runners/index.d.ts +0 -118
- package/dist/pbt/runners/index.js +0 -5
- package/dist/pbt/runners/index.js.map +0 -1
- package/dist/poller/index.d.ts +0 -352
- package/dist/poller/index.js +0 -115
- package/dist/poller/index.js.map +0 -1
- package/dist/prediction/index.d.ts +0 -131
- package/dist/prediction/index.js +0 -4
- package/dist/prediction/index.js.map +0 -1
- package/dist/protocol-B5YmJr0d.d.ts +0 -45
- package/dist/pure/index.d.ts +0 -3
- package/dist/pure/index.js +0 -4
- package/dist/pure/index.js.map +0 -1
- package/dist/rate-limit/index.d.ts +0 -115
- package/dist/rate-limit/index.js +0 -3
- package/dist/rate-limit/index.js.map +0 -1
- package/dist/reconciler/index.d.ts +0 -193
- package/dist/reconciler/index.js +0 -164
- package/dist/reconciler/index.js.map +0 -1
- package/dist/recorder/index.js +0 -3
- package/dist/recorder/index.js.map +0 -1
- package/dist/reducer-4GNR6b8B.d.ts +0 -447
- package/dist/resilient-call/index.d.ts +0 -320
- package/dist/resilient-call/index.js +0 -14
- package/dist/resilient-call/index.js.map +0 -1
- package/dist/retry-to-success/index.d.ts +0 -109
- package/dist/retry-to-success/index.js +0 -37
- package/dist/retry-to-success/index.js.map +0 -1
- package/dist/run-pAcmBpah.d.ts +0 -713
- package/dist/runtime-types-CNLmhWif.d.ts +0 -517
- package/dist/saga/index.d.ts +0 -241
- package/dist/saga/index.js +0 -150
- package/dist/saga/index.js.map +0 -1
- package/dist/samples-B3My5oh2.d.ts +0 -59
- package/dist/snapshot/index.js +0 -5
- package/dist/snapshot/index.js.map +0 -1
- package/dist/subs/index.d.ts +0 -472
- package/dist/subs/index.js +0 -7
- package/dist/subs/index.js.map +0 -1
- package/dist/throttle/index.d.ts +0 -134
- package/dist/throttle/index.js +0 -3
- package/dist/throttle/index.js.map +0 -1
- package/dist/throttled-input/index.js.map +0 -1
- package/dist/token-refresh/index.d.ts +0 -216
- package/dist/token-refresh/index.js +0 -6
- package/dist/token-refresh/index.js.map +0 -1
- package/dist/trace-replay/index.js +0 -6
- package/dist/trace-replay/index.js.map +0 -1
- package/dist/with-deadline/index.d.ts +0 -197
- package/dist/with-deadline/index.js +0 -111
- package/dist/with-deadline/index.js.map +0 -1
- package/dist/with-resilience/index.d.ts +0 -225
- package/dist/with-resilience/index.js +0 -240
- package/dist/with-resilience/index.js.map +0 -1
- package/dist/with-telemetry/index.d.ts +0 -150
- package/dist/with-telemetry/index.js +0 -70
- package/dist/with-telemetry/index.js.map +0 -1
- package/dist/work-queue/adapter.d.ts +0 -84
- package/dist/work-queue/adapter.js +0 -4
- package/dist/work-queue/adapter.js.map +0 -1
- package/dist/work-queue/ops.d.ts +0 -71
- package/dist/work-queue/ops.js +0 -3
- package/dist/work-queue/ops.js.map +0 -1
- package/dist/workflow/index.d.ts +0 -485
- package/dist/workflow/index.js +0 -244
- package/dist/workflow/index.js.map +0 -1
- /package/dist/{cache → paginate}/index.js.map +0 -0
- /package/dist/{chart/inspect → persistence}/index.js.map +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/chart/lane/inspect.ts","../src/chart/lane/structure.ts","../src/chart/lane/run.ts","../src/chart/lane/view.ts"],"names":["bad"],"mappings":";;;;;AA2DA,IAAM,QAAA,GAAW,CAAC,KAAA,KAChB,aAAA,CAAc,KAAgC,CAAA;AAsHhD,SAAS,OAAA,CAAQ,OAAsB,KAAA,EAAsC;AAC3E,EAAA,MAAM,OAAO,QAAA,CAAS,KAAK,CAAA,CAAE,GAAA,CAAI,MAAM,IAAI,CAAA;AAC3C,EAAA,MAAM,QAAA,GAAW,cAAc,IAAI,CAAA;AACnC,EAAA,IAAI,QAAA,KAAa,SAAS,OAAO,EAAE,MAAM,SAAA,EAAW,KAAA,EAAO,MAAM,IAAA,EAAK;AACtE,EAAA,IAAI,QAAA,KAAa,MAAM,OAAO,IAAA;AAC9B,EAAA,MAAM,QAAQ,MAAA,CAAO,OAAA,CAAQ,IAAA,EAAM,EAAA,IAAM,EAAE,CAAA;AAC3C,EAAA,IAAI,KAAA,CAAM,WAAW,CAAA,EAAG,OAAO,EAAE,IAAA,EAAM,UAAA,EAAY,KAAA,EAAO,KAAA,CAAM,IAAA,EAAK;AACrE,EAAA,IAAI,KAAA,CAAM,OAAA,IAAW,KAAA,CAAM,UAAA,EAAY;AACrC,IAAA,KAAA,MAAW,CAAC,KAAA,EAAO,IAAI,CAAA,IAAK,KAAA,EAAO;AACjC,MAAA,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A,CAAE,KAAA,CAAM,MAAM,CAAA,EAAA,EAAK,EAAE,KAAA,CAAM,MAAA,KAAW,MAAA,GAAS,EAAA,GAAK,GAAG,CAAA,EAAG,CAAA,CAAE,KAAA,CAAM,KAAK,IAAI,IAAI,CAAA,CAAA;AAAA,EAC1F;AACA,EAAA,IAAI,CAAA,CAAE,aAAa,MAAA,EAAW,OAAO,UAAK,CAAA,CAAE,QAAQ,GAAG,IAAI,CAAA,CAAA;AAC3D,EAAA,OAAO,GAAG,CAAA,CAAE,OAAA,CAAQ,KAAK,KAAK,CAAC,GAAG,IAAI,CAAA,CAAA;AACxC","file":"chunk-CIQG5L42.js","sourcesContent":["// ═══════════════════════════════════════════════════════════════════════════\n// THE LANE, ASKED ABOUT ITSELF — the headless description a UI needs.\n//\n// `@demlik/tea/chart/inspect` already answers every question about ONE chart at\n// ONE state: which events are legal here, which are refused and why, what each\n// edge would do. A lane needs all of that, N times over, plus the four\n// questions that only exist because there is more than one machine:\n//\n// which phase is running, and what are the others doing\n// what state is each task in\n// what is each task waiting on\n// which tasks are stuck\n//\n// So this file composes rather than duplicates: `describeChart` and\n// `inspectState` are called per task, `waitingOn` is the report's OWN\n// derivation (one site, not two — and since that answer is itself derived from\n// the events' declared `from`, there is no vocabulary anywhere on this path to\n// keep in step), and `phaseStandings` is the same walk `deriveLaneStatus`\n// makes. The only thing invented here is `stuck`, and it is defined below\n// rather than felt.\n//\n// PURE, framework-free, and it never runs the lane. Fold in, description out.\n// ═══════════════════════════════════════════════════════════════════════════\n\nimport type { Chart } from \"../graph\";\nimport {\n type ChartDescription,\n type ChartRefusal,\n describeChart,\n type EventPreview,\n type InspectOptions,\n inspectState,\n} from \"../inspect\";\nimport {\n foldLane,\n type LogEntry,\n type PhaseStand,\n type PhaseStanding,\n phaseStandings,\n type TaskState,\n trippedTasks,\n} from \"../report/fold\";\nimport { waitingOn } from \"../report/report\";\nimport {\n endPolarityOf,\n type ImportedChart,\n type ImportedLane,\n initialOf,\n originOf,\n statesOf,\n} from \"../report/workflow\";\n\n/**\n * An `ImportedChart` IS the runtime shape `describeChart` walks — the same\n * `events`/`states` records, narrowed to the three edge forms a lane region can\n * produce. The cast is here rather than in `describeChart`, because widening\n * the inspector's parameter to accept a runtime-typed chart would cost every\n * OTHER caller the literal types that are the point of a chart.\n */\nconst describe = (chart: ImportedChart): ChartDescription =>\n describeChart(chart as unknown as Chart<never>);\n\n/** Why a task cannot move. `null` when it can. */\nexport type StuckReason =\n | {\n /** It reached an error final: as finished as a shipped task, and lost. */\n readonly kind: \"tripped\";\n readonly state: string;\n }\n | {\n /**\n * A non-final state that routes NOTHING. The chart's totality means this\n * cannot happen on a chart that compiled — it is reported rather than\n * swallowed because reaching it means a document declared a dead end, and\n * a lane parked there will sit forever with no one to say why.\n */\n readonly kind: \"dead-end\";\n readonly state: string;\n }\n | {\n /** The retry budget is spent: the next guarded event is a one-way door. */\n readonly kind: \"budget-spent\";\n readonly state: string;\n readonly event: string;\n readonly landsOn: string;\n }\n | {\n /**\n * Every event this state routes comes from the OUTSIDE WORLD — no `cmd`\n * result and no `sub` will ever arrive here, so the lane advances only\n * when a person acts.\n *\n * This is the fourth kind, and it was missing until a real epic was\n * rendered and looked at: a task parked at a human approval reported\n * \"nothing is stuck — every task can still move\", which is true of the\n * machine and false of the day. Nothing will happen until someone does\n * something, which is precisely what a stuck list is for.\n *\n * Derived from `from`, never from a state name: `roles` carries the\n * consumer's own words for who is owed, in declaration order.\n */\n readonly kind: \"awaiting-world\";\n readonly state: string;\n readonly roles: readonly string[];\n readonly events: readonly string[];\n };\n\n/** One task of a lane, inspected. */\nexport interface LaneTaskInspection {\n readonly task: string;\n readonly phase: string;\n /** The leaf it is in right now, out of the fold. */\n readonly state: string;\n /** `false` still running, `true` a success final, `\"error\"` tripped. */\n readonly endPolarity: false | true | \"error\";\n /** The state it will resume to, while it is parked. `undefined` otherwise. */\n readonly was?: string;\n readonly retries: number;\n readonly maxRetries: number;\n /**\n * The events this state routes, grouped by who sends them — {@link waitingOn},\n * read rather than recomputed. `null` at a final. On a lane imported without\n * a provenance map it degrades to the events alone, and says so.\n */\n readonly waitingOn: string | null;\n readonly stuck: StuckReason | null;\n /** Every event of this task's alphabet, legal or refused, with the reason. */\n readonly events: readonly EventPreview[];\n /** The refused half of {@link LaneTaskInspection.events}, pulled out. */\n readonly refusals: readonly ChartRefusal[];\n /** The legal half, as names — the button row. */\n readonly legal: readonly string[];\n}\n\n/** One phase of a lane, inspected. */\nexport interface LanePhaseInspection {\n readonly name: string;\n readonly index: number;\n readonly standing: PhaseStanding;\n /** The phase's tasks, each inspected — running concurrently, all of them. */\n readonly tasks: readonly LaneTaskInspection[];\n /** The tasks in this phase sitting on an error final. */\n readonly tripped: readonly string[];\n}\n\n/** A whole lane, as data a UI can build itself from. */\nexport interface LaneInspection {\n readonly id?: string;\n readonly status: \"active\" | \"done\";\n /** The terminal it landed on, or `null` while it is still running. */\n readonly terminal: string | null;\n /** The phase running right now, or `null` once the lane has ended. */\n readonly activePhase: string | null;\n readonly phases: readonly LanePhaseInspection[];\n /** Every task on an error final, lane-wide — fabrika's `context.errors`. */\n readonly tripped: readonly string[];\n /** Every task that cannot move, and why. The list a human is paged on. */\n readonly stuck: readonly {\n readonly task: string;\n readonly reason: StuckReason;\n }[];\n}\n\n/**\n * Why this task cannot move, or `null`.\n *\n * FOUR KINDS, and the last two are the ones worth having. \"Tripped\" and \"dead\n * end\" are stuck in the ordinary sense — nothing can happen next. The other two\n * are states a machine would call live and a person would call stopped: a task\n * with its retry budget spent CAN still move, but the next `FAIL` is no longer\n * a retry, it is the error final; and a task whose every routed event comes\n * from the outside world moves only when someone acts.\n *\n * That last one was missing until a real epic was rendered and looked at — a\n * lane with a child parked at a human approval reported \"nothing is stuck\", and\n * no test could see it, because every test asked the machine and the machine\n * was right.\n */\nfunction stuckAt(chart: ImportedChart, state: TaskState): StuckReason | null {\n const node = statesOf(chart).get(state.type);\n const polarity = endPolarityOf(node);\n if (polarity === \"error\") return { kind: \"tripped\", state: state.type };\n if (polarity === true) return null;\n const edges = Object.entries(node?.on ?? {});\n if (edges.length === 0) return { kind: \"dead-end\", state: state.type };\n if (state.retries >= state.maxRetries) {\n for (const [event, edge] of edges) {\n if (\"when\" in edge) {\n return {\n kind: \"budget-spent\",\n state: state.type,\n event,\n landsOn: edge.otherwise,\n };\n }\n }\n }\n // Waiting on a PERSON. Every routed event has a declared origin and every one\n // of them is a world role, so no cmd result and no sub can arrive — the lane\n // sits until someone acts. An event whose origin was never declared makes this\n // unknowable, and unknowable is not the same as false, so it is not reported.\n const origins = edges.map(([event]) => ({\n event,\n origin: originOf(chart, event),\n }));\n // NOT STARTED IS NOT STUCK. A task sitting at its entry state is waiting on a\n // person by construction — that is what an entry state IS — and reporting it\n // here buries the one task that actually stopped under seven that never\n // began. Rendering a real epic showed both halves of this: without the kind\n // at all, a child parked at a human approval read as fine; with it applied to\n // entry states, that same child was one line in eight identical ones. \"Not\n // started\" is a different fact and it already has its own line.\n const started = state.type !== initialOf(chart);\n if (\n started &&\n origins.length > 0 &&\n origins.every((o) => typeof o.origin === \"object\" && o.origin !== null)\n ) {\n const roles: string[] = [];\n for (const { origin } of origins) {\n const role = (origin as { readonly world: string }).world;\n if (!roles.includes(role)) roles.push(role);\n }\n return {\n kind: \"awaiting-world\",\n state: state.type,\n roles,\n events: origins.map((o) => o.event),\n };\n }\n return null;\n}\n\n/**\n * A whole lane, inspected at the state its log folds to.\n *\n * ```ts\n * const lane = chartFromWorkflow(JSON.parse(workflowJson));\n * const view = inspectLane(lane, parseEventsJsonl(eventsJsonl));\n * view.activePhase; // \"phase2\"\n * view.phases[1]?.tasks[0]; // state, waiting-on, legal events, refusals\n * view.stuck; // what a human has to go and do\n * ```\n *\n * Takes the LOG rather than a folded state, deliberately: the fold is pure over\n * a prefix, so `inspectLane(lane, entries.slice(0, k))` is the exact view at\n * step k and time travel costs a `slice`.\n */\nexport function inspectLane(\n lane: ImportedLane,\n entries: readonly LogEntry[],\n optsFor?: (taskId: string) => InspectOptions,\n): LaneInspection {\n return inspectLaneStates(lane, foldLane(lane, entries), optsFor);\n}\n\n/**\n * The same view, from the LEAVES rather than from a log.\n *\n * The two callers differ in exactly one thing and it is which of these doors\n * they come through. A reader holding `workflow.json` + `events.jsonl` has no\n * states, so it folds — {@link inspectLane}. A reader watching a lane RUN has\n * the states and no log worth folding: `runLane` boots each region where its\n * sub-issue actually is, so re-deriving the leaves from a log that starts at\n * every chart's `initial: true` would answer a different question than the one\n * on screen. It hands the leaves it has.\n *\n * @param optsFor per-task {@link InspectOptions} — the `parts` bag and the\n * sample payloads, which only the LIVE door has. Omit it and every preview\n * degrades honestly, exactly as `inspectState` does with no bag at all.\n */\nexport function inspectLaneStates(\n lane: ImportedLane,\n states: Readonly<Record<string, TaskState>>,\n optsFor?: (taskId: string) => InspectOptions,\n): LaneInspection {\n const stands = phaseStandings(lane, states);\n const active = stands.find((stand) => stand.standing === \"active\");\n const trippedPhase = stands.find((stand) => stand.standing === \"tripped\");\n const stuck: { task: string; reason: StuckReason }[] = [];\n\n const inspectTask = (\n stand: PhaseStand,\n taskId: string,\n ): LaneTaskInspection | null => {\n const chart = lane.charts[taskId];\n const state = states[taskId];\n if (chart === undefined || state === undefined) return null;\n const desc = describe(chart);\n // the WHOLE leaf, not `{ type, was }`. A guard is a predicate over the\n // region's ctx — fabrika's own is `(s) => s.retries < s.maxRetries` — so\n // handing it a state stripped of `retries`/`maxRetries` made it read\n // `undefined < undefined`, return false, and every guarded control on every\n // live lane showed its `otherwise` arm: a task with its whole budget unspent\n // told the reader that `FAIL` lands on the error final.\n const events = inspectState(desc, { ...state }, optsFor?.(taskId));\n const reason = stuckAt(chart, state);\n if (reason !== null) stuck.push({ task: taskId, reason });\n return {\n task: taskId,\n phase: stand.name,\n state: state.type,\n endPolarity: endPolarityOf(statesOf(chart).get(state.type)),\n ...(state.was === undefined ? {} : { was: state.was }),\n retries: state.retries,\n maxRetries: state.maxRetries,\n waitingOn: waitingOn(chart, state.type),\n stuck: reason,\n events,\n refusals: events.flatMap((preview) =>\n preview.status === \"refused\" && preview.reason !== undefined\n ? [{ from: state.type, event: preview.event, reason: preview.reason }]\n : [],\n ),\n legal: events\n .filter((preview) => preview.status === \"legal\")\n .map((preview) => preview.event),\n };\n };\n\n const phases = stands.map((stand) => ({\n name: stand.name,\n index: stand.index,\n standing: stand.standing,\n tripped: stand.tripped,\n tasks: stand.tasks.flatMap((taskId) => inspectTask(stand, taskId) ?? []),\n }));\n\n return {\n ...(lane.id === undefined ? {} : { id: lane.id }),\n status: active === undefined ? \"done\" : \"active\",\n terminal:\n active !== undefined\n ? null\n : trippedPhase !== undefined\n ? lane.terminals.tripped\n : lane.terminals.complete,\n activePhase: active?.name ?? null,\n phases,\n tripped: trippedTasks(lane, states),\n stuck,\n };\n}\n","// ═══════════════════════════════════════════════════════════════════════════\n// THE LANE, AS A STRUCTURE — N chart instances in parallel, grouped into\n// phases that sequence.\n//\n// A chart describes ONE machine. A lane is not one machine and pretending it\n// is costs you the two facts that matter most about it: WHICH tasks are running\n// beside each other right now, and WHAT has to finish before the next group\n// starts. So the lane is its own structure, and it is deliberately thin — two\n// halves, no third:\n//\n// `defineLane` — the AUTHORING door. Phases in order, each holding the tasks\n// that run concurrently in it, each task an instance of a chart. Everything\n// an author would otherwise repeat is DERIVED: the phase order is the\n// declaration order, a phase's task set is its keys, which of a task's finals\n// are success and which are error is read off the charts themselves, and —\n// where the charts are `defineChart` literals — so are the lane's own\n// alphabets, `LaneState` and `LaneMsg`.\n//\n// `laneShape` — the READING door, over ANY lane: one built here, or one\n// `chartFromWorkflow` imported from a `workflow.json` this repo has never\n// seen. Both hold the same `ImportedChart` values, so the fold, the report and\n// the inspector take either without knowing which.\n//\n// WHAT THIS IS NOT, and the boundary is worth stating because it is the whole\n// design: there is no lane RUNTIME here. No per-instance boot override, no\n// router turning `ISSUE_5729.DONE` into a message for region 5729, nothing that\n// makes a lane dispatchable as a `Machine`. fabrika folds its own log and this\n// module reads the result. A lane you can DRAW is a smaller thing than a lane\n// you can RUN, and it is the thing that was missing.\n// ═══════════════════════════════════════════════════════════════════════════\n\nimport type {\n CellEdgeKey,\n Chart,\n ErrorFinal,\n EventName,\n EventOrigin,\n InitialState,\n StateName,\n StateOf,\n Strict,\n SuccessFinal,\n Total,\n Ty,\n} from \"../graph\";\nimport type { PhaseStanding } from \"../report/fold\";\nimport {\n endPolarityOf,\n type ImportedChart,\n type ImportedEdge,\n type ImportedLane,\n type ImportedNode,\n RETRY_BUDGET,\n statesOf,\n} from \"../report/workflow\";\n\n// ── the two doors, and the ONE thing they have in common ───────────────────\n//\n// A lane's task runs a chart, and there are exactly two places a chart comes\n// from: `defineChart` (literal types, `ctx`, payloads, cmds, cells) and\n// `chartFromWorkflow` (an `ImportedChart` — `Chart<unknown>` by construction,\n// because the document it was read from is one this repo has never compiled).\n//\n// Neither is assignable to the other, and the older spelling picked one:\n// `phases` took `ImportedChart`, so a lane assembled from `defineChart`\n// literals erased every literal type the chart module exists to preserve. That\n// is the module's core guarantee dropped at its last seam.\n//\n// `LaneRegion` is the structural minimum BOTH satisfy — an event alphabet and\n// states grouped into phases — so the spec's type parameter can carry whichever\n// one the author actually wrote. What is stored is a third thing and always the\n// same third thing: {@link lowerRegion} lowers either door's chart to the ONE\n// `ImportedChart` representation the fold, the report and the inspector read.\n// Types from the spec, value from the lowering — no cast between them.\n\n/** The shape a lane task's chart has at EITHER door. */\nexport interface LaneRegion {\n readonly events: Readonly<Record<string, unknown>>;\n readonly states: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n}\n\n// ── the authored form ──────────────────────────────────────────────────────\n\n/**\n * A lane, as an author writes it.\n *\n * The nesting IS the structure: `phases` is an ordered record of phase name →\n * the tasks running concurrently in that phase → the chart each of those tasks\n * is an instance of. Nothing states the phase order (it is the key order),\n * nothing states a phase's task set (it is the keys), and nothing states which\n * finals are which (the charts say).\n */\nexport interface LaneSpec {\n /** The lane's own id — what a report titles itself with. */\n readonly id?: string;\n /** What fires this lane, when something does. */\n readonly trigger?: string;\n /** Phase name → task id → the chart that task runs. IN ORDER. */\n readonly phases: Readonly<\n Record<string, Readonly<Record<string, LaneRegion>>>\n >;\n /** The lane's two endings. `tripped` is where an error final lands it. */\n readonly terminals: {\n readonly complete: string;\n readonly tripped: string;\n };\n /**\n * The retry budget, per task, where it is not {@link RETRY_BUDGET}.\n *\n * SUPPLIED, not derived, and the one thing on this interface that is. The\n * guarded edge's predicate is `retries < maxRetries` and no chart declares\n * the right-hand side — it is a property of the RUN, which is why fabrika\n * keeps it in the document's `context` rather than in the machine.\n */\n readonly retries?: Readonly<Record<string, number>>;\n /** Anything else the lane carries per task, passed through untouched. */\n readonly extras?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n}\n\n// ── the authoring mistakes the types can see ───────────────────────────────\n//\n// Constraint checking is plain assignability and does not run excess-property\n// checks, so these map an offending SHAPE to a marker object naming the\n// offender — which the object-literal check then rejects, with the rule in the\n// diagnostic instead of a `never` the author has to reverse-engineer.\n\n// A NUMERIC KEY IS A KEY. fabrika's task ids are GitHub issue numbers, so\n// `{ 5729: coder }` is the obvious spelling of a phase and an author will\n// reach for it — but `keyof { 5729: … }` is the NUMBER `5729`, and the older\n// `Extract<keyof …, string>` annihilated it: every alphabet the lane derives\n// went `never`, no hand was demanded and the CORRECT hand was rejected. So a\n// key is normalised to the way every OTHER layer already spells it — the log's\n// `task` field, the `${task}.${event}` wire key, `Object.entries` — which is\n// as a string. `Keyed` re-keys the record itself so an indexed access lands,\n// and both leave a degenerate `Record<string, …>` exactly as degenerate as it\n// was, so {@link LaneLiteralAlphabets} below still fires.\n// Exported for `./run`, which asks the same question of the HANDS record — one\n// spelling of a key in the module, not two.\nexport type Key<K> = K extends string | number ? `${K}` : never;\nexport type Keyed<R> = { [K in keyof R as Key<K>]: R[K] };\n\ntype TaskIdsIn<P> = { [K in keyof P]: Key<keyof P[K]> }[keyof P];\n\n/**\n * Task ids declared under more than one phase.\n *\n * DEGENERACY-GUARDED, and not for tidiness: `Omit<P, K>` over a `P` with an\n * index signature is `P` again, so at a computed-key phase record this reads\n * every task as declared twice and accuses the author of a duplicate they did\n * not write. {@link LaneLiteralAlphabets} is what actually went wrong there,\n * and it is ordered ahead of this so it is what the author is told.\n */\ntype DuplicateTasks<P> = [IsDegenerate<TaskIdsIn<P>>] extends [true]\n ? never\n : {\n [K in keyof P]: Extract<Key<keyof P[K]>, TaskIdsIn<Omit<P, K>>>;\n }[keyof P];\n\n/** Phases whose task record is empty — a phase that completes on arrival. */\ntype EmptyPhases<P> = {\n [K in keyof P]: [keyof P[K]] extends [never] ? Key<K> : never;\n}[keyof P];\n\n// ── the lane's own literal-alphabet gate ───────────────────────────────────\n//\n// `graph.ts` has `__stateNamesMustBeLiteralsNotAComputedStringKey` for exactly\n// one failure mode: an alphabet that stopped being a union of literals is not a\n// weakened chart, it is a chart with the checking SWITCHED OFF, and nothing\n// says so. The lane had no equivalent, and it has the same failure mode one\n// level up — `{ [dyn]: coder }` or `Object.fromEntries(ids.map(…))` degrades\n// `LaneTaskId` to `string`, so no hand is required, an invented task id is\n// accepted and `__laneHandNamesAnUnknownTask` is dead code.\n//\n// The terminals are in here for the SAME reason and it is worth stating,\n// because the way an author reaches it is not exotic: hoisting the terminals to\n// a variable without `as const` widens them to `string`, which silently\n// disables `__terminalCollidesWithAPhase` and makes `LaneTerminal<L>` the bare\n// `string`. Told as \"this object lost its literal types\", it is one `as const`;\n// discovered later, it is a lane whose ending is unnamed.\n\n/** The three alphabets a lane derives, each refused where it degenerated. */\ntype LaneLiteralAlphabets<S> = ([IsDegenerate<Key<keyof PhasesOf<S>>>] extends [\n true,\n]\n ? { readonly __lanePhaseNamesMustBeLiteralsAddAsConst: true }\n : unknown) &\n ([IsDegenerate<TaskIdsIn<PhasesOf<S>>>] extends [true]\n ? { readonly __laneTaskIdsMustBeLiteralsAddAsConst: true }\n : unknown) &\n ([IsDegenerate<TerminalsOf<S>>] extends [true]\n ? { readonly __laneTerminalsMustBeLiteralsAddAsConst: true }\n : unknown);\n\n/**\n * Task ids, or event names, carrying a dot.\n *\n * `${task}.${event}` IS the lane's wire key — `runLane` compiles each region\n * under `ns = taskId` and `foldLane` splits an incoming name at the FIRST dot —\n * so a dot on either side re-partitions the key space. Task `a` + event `b.GO`\n * and task `a.b` + event `GO` both register `\"a.b.GO\"`: last writer wins, one\n * task's event is unreachable forever, and a message addressed to `a` moves\n * `a.b`. And task `epic.issue_1` emits a log line the splitter can never route\n * back. Banning the dot makes the collision unrepresentable for every pairing\n * at once, which is the same move `graph.ts` makes for a foreign event name and\n * for a state name.\n */\ntype DottedTaskIds<P> = Extract<TaskIdsIn<P>, `${string}.${string}`>;\n\ntype DottedEventTasks<P> = {\n [K in keyof P]: {\n [T in keyof P[K]]: [IsDegenerate<EventName<P[K][T]>>] extends [true]\n ? never\n : [Extract<EventName<P[K][T]>, `${string}.${string}`>] extends [never]\n ? never\n : Key<T>;\n }[keyof P[K]];\n}[keyof P];\n\n// ── and the three the TYPED door adds ──────────────────────────────────────\n//\n// These three are questions about a chart's INSIDES, and which door the chart\n// came through decides whether they can be asked at all. A `defineChart`\n// literal answers them in the type layer; an `ImportedChart` cannot be asked\n// (its states are `string` by construction), so each check reads the alphabet\n// for degeneracy first and stands down where the answer would be a guess. The\n// runtime checks in `defineLane` stay exactly where they are — they are what\n// the imported door still needs, and they are now the SECOND net under the\n// typed one rather than the only net under both.\n\n/**\n * Task ids whose chart hands a transition to a hand-written cell.\n *\n * Degeneracy-guarded like its two siblings below: `CellEdgeKey` over an\n * imported chart is `never` for the same reason it is `never` over a chart with\n * no cell edge, and reading the first as the second is how a check that cannot\n * be asked pretends to have been answered. It happens to be the SAFE direction\n * here — the answer is \"no cell\", which is what the imported door always\n * says — but a check that is right by luck is a check that stops being right.\n */\ntype CellDelegatingTasks<P> = {\n [K in keyof P]: {\n [T in keyof P[K]]: [IsDegenerate<StateName<P[K][T]>>] extends [true]\n ? never\n : [CellEdgeKey<P[K][T]>] extends [never]\n ? never\n : Key<T>;\n }[keyof P[K]];\n}[keyof P];\n\n/** Task ids whose chart marks no `initial: true` — the fold has no zero. */\ntype NoInitialTasks<P> = {\n [K in keyof P]: {\n [T in keyof P[K]]: [IsDegenerate<StateName<P[K][T]>>] extends [true]\n ? never\n : [InitialState<P[K][T]>] extends [never]\n ? Key<T>\n : never;\n }[keyof P[K]];\n}[keyof P];\n\n/**\n * Task ids whose chart marks MORE THAN ONE `initial: true`.\n *\n * Zero and two are both wrong and only zero was caught. Two is the worse of\n * the pair, because it does not fail — it splits: `laneShape` walked the states\n * and kept the LAST one it saw, `initialOf` (and therefore the fold, and\n * therefore every report) takes the FIRST, so the report printed a start state\n * the fold never booted into. `graph.ts` refuses the same thing on a single\n * chart with `__chartDeclaresManyInitialStates`; the lane door had dropped it,\n * because a lane region's entry is per-INSTANCE (`boot()`) and the check that\n * used to sit on the chart's own `InitialData` went with it.\n */\ntype ManyInitialTasks<P> = {\n [K in keyof P]: {\n [T in keyof P[K]]: [IsDegenerate<StateName<P[K][T]>>] extends [true]\n ? never\n : [IsUnion<InitialState<P[K][T]>>] extends [true]\n ? Key<T>\n : never;\n }[keyof P[K]];\n}[keyof P];\n\n/** Task ids whose chart declares no final — its phase could never complete. */\ntype NoFinalTasks<P> = {\n [K in keyof P]: {\n [T in keyof P[K]]: [IsDegenerate<StateName<P[K][T]>>] extends [true]\n ? never\n : [SuccessFinal<P[K][T]> | ErrorFinal<P[K][T]>] extends [never]\n ? Key<T>\n : never;\n }[keyof P[K]];\n}[keyof P];\n\n/** `graph.ts`'s own union test — a `T` that is not a single member. */\ntype IsUnion<T, U = T> = T extends unknown\n ? [U] extends [T]\n ? false\n : true\n : never;\n\n// ── the guarded edge, and the one predicate a lane can fold ────────────────\n//\n// THE FOLD OWNS THE GUARD. `report/fold.ts` walks a guarded edge with the one\n// inline predicate `retries < maxRetries`, because a `workflow.json` carries a\n// guard NAME and never a guard BODY — the array IS the retry guard, in fabrika\n// and here. That is exactly right for the imported door and it was applied,\n// unstated, to the typed one as well: `lowerRegion` kept the name and dropped\n// everything else, so a chart guarded on `amount < 100` and driven with\n// `amount: 5000` RAN to `declined` and FOLDED to `captured` — a tripped run\n// reported complete, with a `retries: 1/2` invented on a chart that has no\n// retry concept.\n//\n// Carrying the real predicate onto the lowered edge is the fix that would cost\n// the typed door nothing, and it is not available: a `defineChart` guard's BODY\n// lives in `Parts`, which is handed to `compile`/`runLane` and which\n// `defineLane` never sees. There is no seam at which the fold could be given\n// it, so a lane whose guard is not the retry guard is a lane this module cannot\n// fold — and the honest move is to refuse it at the door rather than to answer\n// it wrongly in a report.\n//\n// What IS checkable is the contract the fold's predicate is written against:\n// the region's `ctx` carries the two numbers it reads. That is necessary and\n// not sufficient (a guard body could still be about something else while the\n// budget rides along), so the marker names the contract rather than claiming to\n// have read the author's mind — but it catches the case the reviewer found,\n// where a lane region reaches for `when` meaning something the lane cannot see.\n\n/** A chart's `ctx`, as declared — the `Ty<…>` payload, unwrapped. */\ntype LaneCtxOf<C> = C extends { readonly ctx: Ty<infer T> } ? T : unknown;\n\n/** Does any of `C`'s edges carry a `when`? */\ntype HasGuardedEdge<C> = C extends { readonly states: infer G }\n ? {\n [P in keyof G]: {\n [S in keyof G[P]]: G[P][S] extends { readonly on: infer O }\n ? {\n [E in keyof O]: O[E] extends { readonly when: string }\n ? true\n : never;\n }[keyof O]\n : never;\n }[keyof G[P]];\n }[keyof G]\n : never;\n\n/** The budget the fold's guarded arm reads, and the only shape it can read. */\ntype RetryBudgetCtx = { readonly retries: number; readonly maxRetries: number };\n\n/** Task ids that guard an edge on something the fold cannot evaluate. */\ntype GuardsOffTheBudgetTasks<P> = {\n [K in keyof P]: {\n [T in keyof P[K]]: [IsDegenerate<StateName<P[K][T]>>] extends [true]\n ? never\n : [HasGuardedEdge<P[K][T]>] extends [never]\n ? never\n : LaneCtxOf<P[K][T]> extends RetryBudgetCtx\n ? never\n : Key<T>;\n }[keyof P[K]];\n}[keyof P];\n\n/**\n * Task ids whose region never went through `defineChart`.\n *\n * `LaneRegion` is the structural minimum BOTH doors satisfy, which is what lets\n * one type parameter carry either — and it is also a hole: a hand-written\n * object of that shape passes it, so `Strict` and `Total` never run, a typo'd\n * target is never checked, and the fold lands the task in a state that does not\n * exist and leaves it there forever with no diagnostic. A brand stamped by\n * `defineChart` would be the tighter fix; it is not available from here, since\n * that would change `defineChart`'s own return type. So the region is put\n * through the checking door FROM here instead: a chart that satisfies its own\n * F-bounded constraint plus `Strict` and `Total` is a chart `defineChart` would\n * have accepted, whatever produced it, and one that does not is refused by the\n * name of the door it skipped.\n *\n * Stands down at the imported door, where `Chart<C>` is not a question an\n * `ImportedChart` can be asked.\n */\ntype UncheckedRegionTasks<P> = {\n [K in keyof P]: {\n [T in keyof P[K]]: [IsDegenerate<StateName<P[K][T]>>] extends [true]\n ? never\n : [P[K][T]] extends [Chart<P[K][T]> & Strict<P[K][T]> & Total<P[K][T]>]\n ? never\n : Key<T>;\n }[keyof P[K]];\n}[keyof P];\n\ntype PhasesOf<S> = S extends { readonly phases: infer P } ? P : never;\ntype TerminalsOf<S> = S extends {\n readonly terminals: { readonly complete: infer C; readonly tripped: infer T };\n}\n ? C | T\n : never;\ntype RetryKeysOf<S> = S extends { readonly retries: infer R }\n ? Key<keyof R>\n : never;\n\n/**\n * The authoring mistakes assignability can catch — the lane's own shape, and\n * the charts it was handed.\n *\n * THE ORDER IS LOAD-BEARING. {@link LaneLiteralAlphabets} comes first because\n * every check under it is a question about a union of literals, and at a\n * degenerate alphabet those questions do not merely go unanswered — they answer\n * WRONGLY. With two phases and a computed task key the old order accused the\n * author of `__taskDeclaredInTwoPhases` for a task declared exactly once, which\n * is a diagnostic that sends them looking in the one place the mistake is not.\n * A check that cannot be asked stands down; a check that would lie is ordered\n * behind the one that names the real cause.\n *\n * The chart-shaped ones stand down at the imported door, where the answer would\n * be a guess rather than a fact, and {@link defineLane}'s runtime checks catch\n * what they can there instead. Where a guarantee cannot be had, it is thrown\n * for rather than pretended.\n */\nexport type LaneChecks<S> = LaneLiteralAlphabets<S> &\n ([DuplicateTasks<PhasesOf<S>>] extends [never]\n ? unknown\n : {\n readonly __taskDeclaredInTwoPhases: DuplicateTasks<PhasesOf<S>>;\n }) &\n ([EmptyPhases<PhasesOf<S>>] extends [never]\n ? unknown\n : { readonly __phaseDeclaresNoTasks: EmptyPhases<PhasesOf<S>> }) &\n ([Extract<TerminalsOf<S>, Key<keyof PhasesOf<S>>>] extends [never]\n ? unknown\n : {\n readonly __terminalCollidesWithAPhase: Extract<\n TerminalsOf<S>,\n Key<keyof PhasesOf<S>>\n >;\n }) &\n ([Exclude<RetryKeysOf<S>, TaskIdsIn<PhasesOf<S>>>] extends [never]\n ? unknown\n : {\n readonly __retryBudgetNamesAnUnknownTask: Exclude<\n RetryKeysOf<S>,\n TaskIdsIn<PhasesOf<S>>\n >;\n }) &\n ([DottedTaskIds<PhasesOf<S>>] extends [never]\n ? unknown\n : { readonly __laneTaskIdCannotContainADot: DottedTaskIds<PhasesOf<S>> }) &\n ([DottedEventTasks<PhasesOf<S>>] extends [never]\n ? unknown\n : {\n readonly __laneRegionEventNameCannotContainADot: DottedEventTasks<\n PhasesOf<S>\n >;\n }) &\n ([UncheckedRegionTasks<PhasesOf<S>>] extends [never]\n ? unknown\n : {\n readonly __laneRegionDidNotComeThroughDefineChart: UncheckedRegionTasks<\n PhasesOf<S>\n >;\n }) &\n ([CellDelegatingTasks<PhasesOf<S>>] extends [never]\n ? unknown\n : {\n readonly __laneTaskChartDelegatesToACell: CellDelegatingTasks<\n PhasesOf<S>\n >;\n }) &\n ([NoInitialTasks<PhasesOf<S>>] extends [never]\n ? unknown\n : {\n readonly __laneTaskChartMarksNoInitialState: NoInitialTasks<\n PhasesOf<S>\n >;\n }) &\n ([ManyInitialTasks<PhasesOf<S>>] extends [never]\n ? unknown\n : {\n readonly __laneTaskChartMarksManyInitialStates: ManyInitialTasks<\n PhasesOf<S>\n >;\n }) &\n ([GuardsOffTheBudgetTasks<PhasesOf<S>>] extends [never]\n ? unknown\n : {\n readonly __laneRegionGuardsOnSomethingOtherThanTheRetryBudget: GuardsOffTheBudgetTasks<\n PhasesOf<S>\n >;\n }) &\n ([NoFinalTasks<PhasesOf<S>>] extends [never]\n ? unknown\n : { readonly __laneTaskChartDeclaresNoFinal: NoFinalTasks<PhasesOf<S>> });\n\n/** The self-referential constraint `defineLane` binds its argument with. */\nexport type LaneOf<S> = LaneSpec & LaneChecks<S>;\n\n// ── one representation: lowering either door's chart to `ImportedChart` ────\n\nconst isRecord = (v: unknown): v is Readonly<Record<string, unknown>> =>\n typeof v === \"object\" && v !== null && !Array.isArray(v);\n\n/**\n * One authored edge → the one imported edge form, or `undefined` for the one\n * shape a lane cannot hold.\n *\n * A `defineChart` edge has five spellings and four of them lower exactly: the\n * bare target, the target with cmds, the guarded pair, and `resume`. The fifth\n * — `{ to, cell }` — does not: a cell picks its target in hand-written code at\n * runtime, and a lane region has no runtime to pick with. That is refused, here\n * and in the types.\n *\n * The cmds ride along. They were dropped once as \"the RUN's business, not the\n * topology's\", and the cost showed up on the page: every reader downstream\n * (`readEdgeCore`, `EventPreview`, `outcomeOf`) already renders them, so a lane\n * built from literals could say a click lands on `build` and never that it\n * fires `spawn_shell` — information the author wrote down and the lowering\n * threw away.\n */\nconst lowerEdge = (edge: unknown): ImportedEdge | undefined => {\n if (typeof edge === \"string\") return { target: edge };\n if (!isRecord(edge)) return undefined;\n if (isRecord(edge.resume) && typeof edge.resume.fallback === \"string\") {\n return { resume: { fallback: edge.resume.fallback } };\n }\n if (typeof edge.target !== \"string\") return undefined;\n const target = edge.target;\n const cmds = {\n ...(edge.cmd === undefined ? {} : { cmd: edge.cmd as string | string[] }),\n ...(edge.otherwiseCmd === undefined\n ? {}\n : { otherwiseCmd: edge.otherwiseCmd as string | string[] }),\n };\n return typeof edge.when === \"string\" && typeof edge.otherwise === \"string\"\n ? { target, when: edge.when, otherwise: edge.otherwise, ...cmds }\n : { target, ...cmds };\n};\n\n/**\n * A chart from EITHER door → the single `ImportedChart` representation.\n *\n * Idempotent on an imported chart (every edge is already in the lowered form\n * and every event is already `scope: \"edges\"`), which is what makes this a\n * lowering rather than a second code path: the imported door goes through it\n * and comes out the value it went in as.\n */\nconst isString = (v: unknown): v is string => typeof v === \"string\";\n\n/** `compile`'s own reading of `scope`: a word, or a list of them. */\nconst scopeList = (scope: unknown): readonly string[] =>\n typeof scope === \"string\"\n ? [scope]\n : Array.isArray(scope)\n ? scope.filter(isString)\n : [\"edges\"];\n\n/**\n * The events `state` ACCEPTS AND DROPS — the refusal set, read off the chart\n * once at lowering instead of asked at dispatch.\n *\n * THE DIVERGENCE THIS CLOSES. `compile.ts` self-loops a pair the state's\n * `ignore` names or the event's `scope` does not address, and throws only on a\n * live-but-undecided pair. The lowered chart could not say \"refused\", so\n * `stepTask` threw on a log `runLane` had accepted — a report calling a run\n * unreplayable when the run had replayed it. The fold cannot ask the chart at\n * dispatch time (its states are `string` by then), so the answer is computed\n * here and carried.\n *\n * WHAT IS AND IS NOT IN THE SET, because the boundary is the whole design. A\n * refusal the chart DECLARES is carried: an `ignore` entry, and an event whose\n * `scope` names phases that do not include this state's. An `\"edges\"` event\n * that this state simply does not route is NOT — `graph.ts` is explicit that\n * such a pair is \"not ignored, it is simply not addressed to that state\", and\n * making it a refusal here would change the IMPORTED door, where every event is\n * `scope: \"edges\"` by construction: a `workflow.json` log naming an unrouted\n * event would stop being refused, which is precisely the check fabrika's own\n * fold keeps and `fold.test.ts` pins. So the rule is exactly the one an\n * imported chart cannot trigger, and lowering an imported chart is still the\n * identity.\n */\nconst refusalsAt = (\n region: LaneRegion,\n group: string,\n node: Readonly<Record<string, unknown>>,\n routed: ReadonlySet<string>,\n): readonly string[] => {\n const ignored = new Set(\n Array.isArray(node.ignore) ? node.ignore.filter(isString) : [],\n );\n const isFinal = node.end !== undefined;\n const out: string[] = [];\n for (const [event, decl] of Object.entries(region.events)) {\n if (routed.has(event)) continue;\n const scope = scopeList(isRecord(decl) ? decl.scope : undefined);\n // \"edges\" is not a phase, so an \"edges\" event is addressed to no state by\n // broadcast — and that is the case left OUT. What is refused is an event\n // broadcast SOMEWHERE ELSE, an event broadcast HERE at a state that is\n // final (a final accepts nothing and owes nothing, which is why `Total`\n // exempts it from the pair and why `compile` self-loops it), or an event\n // this state's `ignore` names.\n const broadcast = scope.some((s) => s !== \"edges\");\n const live = scope.some((s) => s === \"all\" || s === group);\n if (ignored.has(event) || (broadcast && (!live || isFinal))) {\n out.push(event);\n }\n }\n return out;\n};\n\nconst lowerRegion = (\n taskId: string,\n region: LaneRegion,\n defects: string[],\n): ImportedChart => {\n const states: Record<string, Record<string, ImportedNode>> = {};\n const refusals: Record<string, readonly string[]> = {};\n for (const [group, nodes] of Object.entries(region.states)) {\n const lowered: Record<string, ImportedNode> = {};\n for (const [name, node] of Object.entries(nodes)) {\n if (!isRecord(node)) {\n defects.push(`task \"${taskId}\": state \"${name}\" is not an object`);\n continue;\n }\n const on: Record<string, ImportedEdge> = {};\n if (isRecord(node.on)) {\n for (const [event, edge] of Object.entries(node.on)) {\n const low = lowerEdge(edge);\n if (low === undefined) {\n defects.push(\n `task \"${taskId}\": \"${name}.${event}\" delegates its target to a cell — a lane region routes to targets it DECLARES, because nothing here runs a cell to pick one`,\n );\n continue;\n }\n on[event] = low;\n }\n }\n const refused = refusalsAt(region, group, node, new Set(Object.keys(on)));\n if (refused.length > 0) refusals[name] = refused;\n lowered[name] = {\n ...(node.initial === true ? { initial: true as const } : {}),\n ...(Object.keys(on).length > 0 ? { on } : {}),\n ...(node.end === true\n ? { end: true as const }\n : node.end === \"error\"\n ? { end: \"error\" as const }\n : {}),\n };\n }\n states[group] = lowered;\n }\n\n // `from` RIDES THROUGH. The lowering drops what a lane cannot use — payload\n // types, cmds, ctx, and the phase dimension a region does not have — but\n // provenance is not one of those: it is the whole basis of \"what is this\n // waiting on\" and of the `awaiting-world` stuck kind, and dropping it made\n // the TYPED door strictly worse than the imported one, which carries a\n // provenance map from its boundary. The imported door states it once at\n // import; the typed door states it once on the event. Same fact, one site\n // each, and neither is this function's to invent.\n const events: Record<\n string,\n { readonly scope: \"edges\"; readonly from?: EventOrigin }\n > = {};\n for (const [name, decl] of Object.entries(region.events)) {\n const from = isRecord(decl)\n ? (decl.from as EventOrigin | undefined)\n : undefined;\n events[name] = {\n scope: \"edges\",\n ...(from === undefined ? {} : { from }),\n };\n }\n\n return {\n events,\n states,\n ...(Object.keys(refusals).length > 0 ? { refusals } : {}),\n };\n};\n\n/** The lane does not hold together — with every defect named, never a half-lane. */\nexport class LaneShapeError extends Error {\n override readonly name = \"LaneShapeError\";\n readonly _tag = \"LaneShapeError\" as const;\n constructor(public readonly defects: readonly string[]) {\n super(\n `@demlik/tea: this lane does not hold together —\\n` +\n defects.map((d) => ` • ${d}`).join(\"\\n\"),\n );\n }\n}\n\n/**\n * An authored lane: the {@link ImportedLane} every reader takes, plus the spec\n * it was authored from.\n *\n * `spec` is the whole typed door. It is DATA, not a phantom — the lane keeps\n * the charts it was handed, so `LaneState<L>` and `LaneMsg<L>` read the literal\n * types straight off it and nothing has to be re-declared beside the lane. An\n * imported lane simply has no `spec`, which is exactly what makes it read back\n * as `Chart<unknown>` through the same derivations: one formula, two doors.\n */\nexport interface Lane<S> extends ImportedLane {\n /** The spec this lane was authored from — where the literal types live. */\n readonly spec: S;\n}\n\n/**\n * A lane, from phases of charts.\n *\n * The result is an {@link ImportedLane} and nothing more — the SAME value\n * `chartFromWorkflow` returns for a `workflow.json`, so `foldLane`,\n * `deriveLaneStatus`, `laneReport` and `inspectLane` all take it without a\n * second code path. There is exactly one lane representation in this module and\n * two ways to obtain it.\n *\n * ```ts\n * const lane = defineLane({\n * id: \"epic-5728\",\n * phases: {\n * phase1: { issue_5729: coderChart, issue_5730: coderChart },\n * phase2: { issue_5731: coderChart },\n * },\n * terminals: { complete: \"complete\", tripped: \"tripped\" },\n * });\n * ```\n *\n * @throws {LaneShapeError} for the defects the type layer cannot see — a chart\n * with no `initial: true`, a chart with no final at all (its phase could\n * never complete, so the lane could never advance), and two terminals spelled\n * the same way.\n */\nexport function defineLane<const S extends LaneOf<S>>(spec: S): Lane<S> {\n const defects: string[] = [];\n const phases: { name: string; tasks: string[] }[] = [];\n const charts: Record<string, ImportedChart> = {};\n const context: ImportedLane[\"context\"] = {};\n\n if (spec.terminals.complete === spec.terminals.tripped) {\n defects.push(\n `both terminals are \"${spec.terminals.complete}\" — a lane that ended cannot say which ending it reached`,\n );\n }\n\n for (const [phaseName, tasks] of Object.entries(spec.phases)) {\n const ids: string[] = [];\n for (const [taskId, region] of Object.entries(tasks)) {\n ids.push(taskId);\n const chart = lowerRegion(taskId, region, defects);\n charts[taskId] = chart;\n const nodes = [...statesOf(chart).values()];\n const initials = nodes.filter((node) => node.initial === true).length;\n if (initials === 0) {\n defects.push(\n `task \"${taskId}\": its chart marks no state \\`initial: true\\` — the fold has no zero to start from`,\n );\n }\n // TWO is as wrong as zero, and it is the worse of the pair because it\n // does not fail — it SPLITS. `laneShape` and `initialOf` walk the same\n // states and disagree about which one they mean, so the report prints a\n // start state the fold never booted into. Refused here as well as in the\n // types, because the imported door has no marker to stand behind.\n if (initials > 1) {\n defects.push(\n `task \"${taskId}\": its chart marks ${initials} states \\`initial: true\\` — a fold has one zero, and which one it picks would be an accident of key order`,\n );\n }\n if (!nodes.some((node) => node.end !== undefined)) {\n defects.push(\n `task \"${taskId}\": its chart declares no final — phase \"${phaseName}\" could never complete, so the lane could never advance`,\n );\n }\n (context as Record<string, unknown>)[taskId] = {\n maxRetries: spec.retries?.[taskId] ?? RETRY_BUDGET,\n extras: spec.extras?.[taskId] ?? {},\n };\n }\n phases.push({ name: phaseName, tasks: ids });\n }\n\n if (phases.length === 0) defects.push(\"the lane declares no phase\");\n if (defects.length > 0) throw new LaneShapeError(defects);\n\n return {\n ...(spec.id === undefined ? {} : { id: spec.id }),\n ...(spec.trigger === undefined ? {} : { trigger: spec.trigger }),\n phases,\n terminals: spec.terminals,\n charts,\n context,\n spec,\n };\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// THE ALPHABETS A LANE DERIVES — one formula, read at both doors.\n//\n// Every type below is written ONCE and instantiated twice: at a `defineLane`\n// lane it runs over the spec's literal charts and keeps every literal; at an\n// `ImportedLane` it runs over {@link ImportedSpec} — the same shape with the\n// bare `string` in every alphabet — and degenerates to exactly what the\n// imported door has always said. There is no `L extends TypedLane ? … : …`\n// anywhere in here, and that is the point: the imported door is not a special\n// case of the typed one, it is the SAME derivation at `Chart<unknown>`.\n// ═══════════════════════════════════════════════════════════════════════════\n\n/** What an `ImportedLane` reads back as: every alphabet the bare `string`. */\ninterface ImportedSpec {\n readonly phases: Readonly<\n Record<string, Readonly<Record<string, ImportedChart>>>\n >;\n readonly terminals: { readonly complete: string; readonly tripped: string };\n}\n\n/** The spec a lane was authored from — an imported lane carries none. */\ntype SpecOf<L> = L extends { readonly spec: infer S } ? S : ImportedSpec;\n\n/**\n * The lane's phases, keyed the way every other layer keys them: by strings.\n *\n * A phase or a task written as a number (`{ 5729: coder }` — and fabrika's task\n * ids ARE GitHub issue numbers) is a key like any other; it is only `keyof`\n * that hands it back as a number. Normalising here, ONCE, is what lets every\n * derivation below stay the plain formula it was.\n */\ntype Phases<L> = Keyed<PhasesOf<SpecOf<L>>>;\n\n/** The tasks of phase `P`, keyed by string for the same reason. */\ntype TasksOf<L, P extends LanePhaseName<L>> = Keyed<Phases<L>[P]>;\n\n/**\n * `[string] extends [N]` — the alphabet stopped being a union of literals.\n *\n * The same guard `graph.ts` uses to catch a computed string key, here for the\n * opposite reason: an imported chart is DELIBERATELY degenerate, and a subset\n * derived off it (`InitialState`, `SuccessFinal`, `CellEdgeKey`) collapses to\n * `never` rather than to `string`. `never` would be a lie — the imported door\n * knows nothing about those states, it does not know there are none — so every\n * derived subset below is read through {@link StateSubset}, which hands back\n * `string` where the chart cannot be asked.\n */\ntype IsDegenerate<N> = [string] extends [N] ? true : false;\n\n/** A derived subset of a chart's states — `string` where the chart is imported. */\ntype StateSubset<C, T> = [IsDegenerate<StateName<C>>] extends [true]\n ? string\n : T;\n\n/** Every phase name, as a union. The ORDER is the value's, not the type's. */\nexport type LanePhaseName<L> = Extract<keyof Phases<L>, string>;\n\n/** The task ids declared in phase `P`. */\nexport type LaneTasksIn<L, P extends LanePhaseName<L>> = Extract<\n keyof TasksOf<L, P>,\n string\n>;\n\n/** Every task id in the lane, whatever phase it runs in. */\nexport type LaneTaskId<L> = {\n [P in LanePhaseName<L>]: LaneTasksIn<L, P>;\n}[LanePhaseName<L>];\n\n/** The chart task `T` runs — ITS chart, not a union over the lane's charts. */\nexport type LaneTaskChart<L, T extends LaneTaskId<L>> = {\n [P in LanePhaseName<L>]: T extends keyof TasksOf<L, P>\n ? TasksOf<L, P>[T]\n : never;\n}[LanePhaseName<L>];\n\n/** The phase task `T` runs in. `defineLane` refuses a task with two. */\nexport type LanePhaseOf<L, T extends LaneTaskId<L>> = {\n [P in LanePhaseName<L>]: T extends keyof TasksOf<L, P> ? P : never;\n}[LanePhaseName<L>];\n\n/** The tasks running BESIDE `T` — its phase's set, minus itself. */\nexport type LaneSiblings<L, T extends LaneTaskId<L>> = Exclude<\n LaneTasksIn<L, LanePhaseOf<L, T> & LanePhaseName<L>>,\n T\n>;\n\n/** Where task `T`'s fold starts — `initial: true`, off its own chart. */\nexport type LaneInitial<L, T extends LaneTaskId<L>> = StateSubset<\n LaneTaskChart<L, T>,\n InitialState<LaneTaskChart<L, T>>\n>;\n\n/** `end: true` on task `T`'s chart — the endings that let its phase complete. */\nexport type LaneSuccessFinals<L, T extends LaneTaskId<L>> = StateSubset<\n LaneTaskChart<L, T>,\n SuccessFinal<LaneTaskChart<L, T>>\n>;\n\n/** `end: \"error\"` on task `T`'s chart — the endings that trip the lane. */\nexport type LaneErrorFinals<L, T extends LaneTaskId<L>> = StateSubset<\n LaneTaskChart<L, T>,\n ErrorFinal<LaneTaskChart<L, T>>\n>;\n\n/** The lane's two endings, as a union of the two literals. */\nexport type LaneTerminal<L> = TerminalsOf<SpecOf<L>>;\n\n/**\n * A phase that is not carrying task states.\n *\n * ONE TYPE, TWO NAMES, and it used to be two types with ONE name: this and\n * `report/fold.ts`'s {@link PhaseStanding} were both exported as\n * `PhaseStanding` from two entry points with different members, so which one a\n * reader got depended on which module they happened to import. It is a\n * SUBSET, so it is spelled as one — the phase standings minus the one reading\n * in which the phase IS its tasks' states, which is exactly why `LaneState`'s\n * phase leaf cannot hold `\"active\"`: while a phase is active there is a task\n * map there instead.\n */\nexport type PhaseAtRest = Exclude<PhaseStanding, \"active\">;\n\n/**\n * The compound state of a whole lane.\n *\n * A lane is not one machine and its state is not one state:\n *\n * ```ts\n * const s: LaneState<typeof lane> = {\n * phases: {\n * phase1: { issue_5729: { type: \"build\", retries: 0, maxRetries: 2 } },\n * phase2: \"waiting\",\n * },\n * lane: \"running\",\n * };\n * ```\n *\n * Every leaf is that task's OWN `StateOf<chart>`, narrowed — `issue_5729` may\n * only stand in a state its own chart declares, carrying its own `ctx`. At an\n * imported lane the same formula reads back with `string` throughout.\n */\nexport type LaneState<L> = {\n readonly phases: {\n readonly [P in LanePhaseName<L>]:\n | PhaseAtRest\n | {\n readonly [T in LaneTasksIn<L, P>]: StateOf<TasksOf<L, P>[T]>;\n };\n };\n /** `running`, or the terminal it ended on. */\n readonly lane: \"running\" | LaneTerminal<L>;\n};\n\n/**\n * One message, addressed to one task of the lane.\n *\n * The union is built PER TASK, not as one alphabet across the lane: the event\n * is narrowed to the events that task's own chart declares, so a message\n * carrying a real event to the wrong task is as much a compile error as one\n * carrying an event nothing declares. A lane of two different chart templates\n * is where that stops being a technicality.\n */\nexport type LaneMsg<L> = {\n [P in LanePhaseName<L>]: {\n [T in LaneTasksIn<L, P>]: {\n readonly task: T;\n readonly event: EventName<TasksOf<L, P>[T]>;\n };\n }[LaneTasksIn<L, P>];\n}[LanePhaseName<L>];\n\n// ── the reading form ───────────────────────────────────────────────────────\n\n/** One task of a lane, with everything about it that is derivable. */\nexport interface LaneTaskShape {\n readonly id: string;\n /** The phase it runs in. */\n readonly phase: string;\n /** That phase's position in the sequence. */\n readonly phaseIndex: number;\n /** Where its fold starts — `initial: true`, read off the chart. */\n readonly initial: string;\n /** The right-hand side of the guarded edge's `retries < maxRetries`. */\n readonly maxRetries: number;\n /** `end: true` — the endings that let the phase complete. */\n readonly successFinals: readonly string[];\n /** `end: \"error\"` — the endings that trip the lane. */\n readonly errorFinals: readonly string[];\n /** The tasks running BESIDE this one, in the same phase. */\n readonly siblings: readonly string[];\n}\n\n/** One phase, and the tasks that run concurrently inside it. */\nexport interface LanePhaseShape {\n readonly name: string;\n readonly index: number;\n readonly tasks: readonly string[];\n /** The phase this one's `onDone` advances to, or the lane's ending. */\n readonly next: string;\n}\n\n/**\n * A whole lane, read as data. Nothing here is supplied — every field is a\n * derivation over the phases and the charts they hold.\n */\nexport interface LaneShape {\n readonly id?: string;\n readonly trigger?: string;\n readonly phases: readonly LanePhaseShape[];\n /** Every task, in phase order then declaration order. */\n readonly tasks: readonly LaneTaskShape[];\n readonly terminals: { readonly complete: string; readonly tripped: string };\n /**\n * Tasks whose chart declares NO error final.\n *\n * Not a defect — a lane may legitimately hold a task that cannot fail. It is\n * reported because it is invisible otherwise and it changes what the lane can\n * do: no run of that task can ever reach the `tripped` terminal.\n */\n readonly cannotTrip: readonly string[];\n}\n\nconst finalsOf = (\n chart: ImportedChart,\n want: true | \"error\",\n): readonly string[] => {\n const out: string[] = [];\n for (const [name, node] of statesOf(chart)) {\n if (endPolarityOf(node as ImportedNode) === want) out.push(name);\n }\n return out;\n};\n\n/**\n * Read a lane — imported or authored — into its {@link LaneShape}.\n *\n * Pure and total. It executes nothing, it validates nothing, and it refuses\n * nothing: it is the reader half, and a lane that is odd (a task with no error\n * final, say) comes back described rather than rejected. {@link defineLane} is\n * where an authoring mistake is refused; this is where any lane is read.\n */\nexport function laneShape(lane: ImportedLane): LaneShape {\n const phases: LanePhaseShape[] = lane.phases.map((phase, index) => ({\n name: phase.name,\n index,\n tasks: phase.tasks,\n // The `onDone` chain, as a reader sees it: every phase but the last hands\n // off to the next one, and the last hands off to the lane's own ending.\n next: lane.phases[index + 1]?.name ?? lane.terminals.complete,\n }));\n\n const tasks: LaneTaskShape[] = [];\n const cannotTrip: string[] = [];\n for (const phase of phases) {\n for (const taskId of phase.tasks) {\n const chart = lane.charts[taskId];\n if (chart === undefined) continue;\n const errorFinals = finalsOf(chart, \"error\");\n if (errorFinals.length === 0) cannotTrip.push(taskId);\n // THE FIRST, not the last — `initialOf` (and therefore the fold, and\n // therefore every report built on it) takes the first, and a reader that\n // took the last printed a start state the fold never booted into.\n // `defineLane` refuses a chart with two, so on an authored lane the two\n // readings coincide; on an imported one this is the tie-break that keeps\n // the shape and the fold saying the same word.\n let initial = \"\";\n for (const [name, node] of statesOf(chart)) {\n if (node.initial === true && initial === \"\") initial = name;\n }\n tasks.push({\n id: taskId,\n phase: phase.name,\n phaseIndex: phase.index,\n initial,\n maxRetries: lane.context[taskId]?.maxRetries ?? RETRY_BUDGET,\n successFinals: finalsOf(chart, true),\n errorFinals,\n siblings: phase.tasks.filter((other) => other !== taskId),\n });\n }\n }\n\n return {\n ...(lane.id === undefined ? {} : { id: lane.id }),\n ...(lane.trigger === undefined ? {} : { trigger: lane.trigger }),\n phases,\n tasks,\n terminals: lane.terminals,\n cannotTrip,\n };\n}\n","// ═══════════════════════════════════════════════════════════════════════════\n// THE LANE, RUN — N compiled regions behind one dispatch surface.\n//\n// `structure.ts` describes a lane and `report/fold.ts` folds one. Neither RUNS\n// one, and running one is four separate questions:\n//\n// ROUTING `{ task, event }` must reach that task's region and no\n// other. There is already a namespacing scheme for exactly\n// this — `compile(chart, parts, ns)` keys the emitted table\n// `${ns}.${event}` so N instances of one chart share a\n// dispatch surface with disjoint literal unions. The lane's\n// `ns` IS the task id, so the wire form of `{ task, event }`\n// is `keyOf`'s `${task}.${event}` and this module invents\n// nothing.\n//\n// BOOT each instance boots where ITS sub-issue actually is —\n// `queued`, `landed`, `frozen` — so the entry state is a\n// per-instance decision, not the chart's one static\n// `initial: true`. `boot()` supplies it, typed to that\n// task's own chart.\n//\n// ADVANCEMENT a phase completes when every region in it reaches a final,\n// and the lane then advances or lands on a terminal. That\n// rule is NOT re-implemented here: `phaseStandings` +\n// `laneTerminalReached` are the fold's own functions, called\n// from this module's cells. The runtime and the fold are one\n// implementation because they are one call.\n//\n// CMDS a region's cmds leave the lane tagged with the task that\n// emitted them, under the same `${task}.${name}` namespace\n// the messages come back in — so an interpreter that\n// receives `issue_5729.spawn_shell` knows where to send the\n// reply without a side table. The tag is NESTED, under\n// `lane`, rather than spread over the payload: a work lane's\n// cmd may perfectly well declare a `task` of its own, and a\n// tag that overwrote it would take the author's value with\n// no type error to show for it.\n//\n// REHYDRATION `init(loaded)` is the branch a production restart walks,\n// every time. A persisted state is DATA that outlived the\n// code that wrote it — a task added since, a state renamed\n// since — so it is validated against the lane on the way in\n// rather than trusted and discovered mid-run, as a reducer\n// throw inside the host's dispatch loop.\n//\n// THE BUDGET `retries` on the lane is the retry budget, `lane.context\n// [task].maxRetries` is where `defineLane` puts it, and the\n// fold reads it from there. A `boot()` that names a\n// different number is refused rather than silently\n// preferred: two numbers for one fact is how a run and a\n// report of that run come to disagree about whether a task\n// ever retried.\n//\n// WHAT THE PHASES DO NOT DO. They do not gate dispatch. A message addressed to\n// a task in phase 2 moves that region while phase 1 is still active, and it is\n// meant to: `foldLane` folds the WHOLE log, so a run that refused what a fold\n// accepts would be the drift this module exists to rule out. Phases sequence\n// the lane's own STANDING (which phase is active, when the lane advances or\n// trips) — they are not admission control over the regions.\n//\n// WHAT IT IS NOT. This does not build a `Machine`; it builds a machine's `init`\n// and `update`. `interpret` is the host's — it is required exactly when a lane\n// emits cmds, and a lane knows nothing about the shells the cmds run in. The\n// author writes `defineMachine({ ...runLane(lane, hands), interpret })`, and\n// that call needs no cast: the two fields are already the types `defineMachine`\n// demands.\n// ═══════════════════════════════════════════════════════════════════════════\n\nimport type { Cmd, Reducer } from \"../../pure/core\";\nimport type { Parts } from \"../compile\";\nimport { type CompiledTable, compileTable } from \"../compile\";\nimport type {\n CmdOf,\n EventName,\n MsgIn,\n MsgOf,\n StateName,\n StateOf,\n} from \"../graph\";\nimport { laneTerminalReached, phaseStandings } from \"../report/fold\";\nimport { RETRY_BUDGET, statesOf } from \"../report/workflow\";\nimport {\n type Key,\n type Keyed,\n type Lane,\n type LaneRegion,\n LaneShapeError,\n type LaneTaskChart,\n type LaneTaskId,\n type LaneTerminal,\n} from \"./structure\";\n\n// ═══════════════════════════════════════════════════════════════════════════\n// THE ALPHABETS A RUNNING LANE ADDS — the same per-task derivation `LaneState`\n// and `LaneMsg` use, at the shapes a `Machine` actually consumes.\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Every region's leaf state, keyed by task.\n *\n * This is `LaneState`'s information with the phase dimension left out, and the\n * omission is the point: `LaneState` is the READING shape (what is running\n * beside what, which phases are waiting), and every one of those facts is\n * derived from the leaves plus the lane's phase order. A run that stored the\n * phase standing beside the leaves would be storing a derived fact, which is\n * exactly the mistake `laneShape` exists not to make. `deriveLaneStatus(lane,\n * state.regions)` produces the compound reading whenever it is wanted.\n */\nexport type LaneRegions<L> = {\n readonly [T in LaneTaskId<L>]: StateOf<LaneTaskChart<L, T>>;\n};\n\n/**\n * The state of a lane in flight: every region's leaf, plus which of the three\n * things the lane itself is doing.\n *\n * `lane` is DERIVED after every step — it is `laneTerminalReached` over the\n * leaves — and it is stored because it is what a host reads to know the run is\n * over. It can never disagree with the leaves: nothing else writes it.\n */\nexport type LaneRunState<L> = {\n readonly regions: LaneRegions<L>;\n readonly lane: \"running\" | LaneTerminal<L>;\n};\n\n/**\n * The message union a running lane consumes: `{ task, event }`, on the wire.\n *\n * `MsgIn<C, NS>` is the chart module's own answer to \"how does the compiled\n * table key event E under namespace NS\", so instantiating it per task at\n * `NS = T` gives `${task}.${event}` with the payload that event declares — the\n * addressing pair of `LaneMsg<L>` and the key `keyOf` builds from it, which are\n * the same fact spelled for a reader and for a dispatcher.\n */\nexport type LaneRunMsg<L> = {\n // The `& Cmd`-shaped `{ type: string }` is a WITNESS, not a widening: at a\n // concrete lane the member's `type` is already a literal and `\"x\" & string`\n // IS `\"x\"`. It is here because `Machine`/`Reducer` constrain\n // `M extends { type: string }`, and `MsgIn`'s key is a deferred conditional\n // tsc will not reduce while `L` is a parameter — so without it the constraint\n // cannot be discharged inside this module. It sits INSIDE the mapped type, so\n // the result is still a union and `Extract<M, { type: K }>` still distributes\n // over it; hoisted outside, every cell's msg would widen back to `{ type:\n // string }` and the per-task narrowing would be gone.\n [T in LaneTaskId<L>]: MsgIn<LaneTaskChart<L, T>, T> & {\n readonly type: string;\n };\n}[LaneTaskId<L>];\n\n/** One region cmd, wearing the task that emitted it. */\ntype Tagged<T extends string, K> = K extends {\n readonly type: infer N extends string;\n}\n ? // the same witness `LaneRunMsg` carries, for the same reason: `Cmd` is\n // `{ type: string }` and a template literal over two parameters is not\n // reduced to one while they are parameters.\n Omit<K, \"type\" | \"lane\"> & {\n readonly type: `${T}.${N}`;\n readonly lane: { readonly task: T };\n } & Cmd\n : never;\n\n/**\n * The cmd union a running lane emits — each region's own `CmdOf<chart>`, under\n * the SAME `${task}.${name}` namespace the messages arrive in.\n *\n * The task id is carried as well as spelled into the type, because the two\n * readers differ: an interpreter's handler map is keyed by `cmd.type` (so the\n * namespace has to be in the name), while the code that routes the reply back\n * wants the task id without parsing it out of a string.\n *\n * IT IS NESTED, and `lane` is the one key a region's cmd may not use — which\n * {@link LaneRunChecks} refuses at the typed door. The tag used to be a flat\n * `task`, spread OVER the payload, and `task` is an entirely ordinary field for\n * a cmd in a work lane to carry: the author's value was replaced by the lane's\n * task id, and `Tagged` narrowed the author's field to that literal, so there\n * was no type error either. One nested key is a smaller surface than every key\n * a chart might plausibly name.\n */\nexport type LaneCmd<L> = {\n [T in LaneTaskId<L>]: Tagged<T, CmdOf<LaneTaskChart<L, T>>>;\n}[LaneTaskId<L>];\n\n// ═══════════════════════════════════════════════════════════════════════════\n// THE HANDS — what a lane cannot derive: the code, and where each instance\n// starts.\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * One task's half of the run.\n *\n * Both halves are typed to THAT task's chart — `parts` against its edges, its\n * guards and its cmds; `boot` against its states. Neither is a union across the\n * lane's charts, which is what makes a lane of two different templates safe to\n * hand code to.\n */\nexport interface LaneHand<C> {\n /** The code the chart cannot hold — assigns, guards, cmd builders, cells. */\n readonly parts: Parts<C, StateOf<C>, MsgOf<C>>;\n /**\n * Where THIS instance starts. An emitted epic boots each child where its\n * sub-issue actually is, so two instances of one chart start in two different\n * states and the chart's `initial: true` is the default rather than the law.\n *\n * Typed to THAT task's own chart, both ways: the return type is what makes\n * `() => ({ type: \"queued\", … })` infer the literal instead of widening to\n * `string`, and {@link LaneRunChecks} asks the same question a second time so\n * the diagnostic names the task rather than pointing at a state union.\n */\n readonly boot: () => StateOf<C>;\n}\n\n/** Every task's hand — one per region, none missing, none invented. */\nexport type LaneHands<L> = {\n readonly [T in LaneTaskId<L>]: LaneHand<LaneTaskChart<L, T>>;\n};\n\n/** `[string] extends [N]` — an imported chart's alphabet, which cannot be asked. */\ntype IsDegenerate<N> = [string] extends [N] ? true : false;\n\n/** What `boot()` says it returns, for the task keyed `T` however it was spelled. */\ntype BootOf<H, T> = Keyed<H>[T & keyof Keyed<H>] extends {\n readonly boot: () => infer B;\n}\n ? B\n : never;\n\n/**\n * Tasks whose `boot()` returns a state whose `type` is no longer a LITERAL.\n *\n * Hoisting the hands to a variable is what every author does the moment a lane\n * is assembled by a helper, and without a `satisfies` it widens `boot()`'s\n * `type` from `\"queued\"` to `string`. The check below then cannot answer its\n * question, and used to answer a DIFFERENT one — it named a task whose boot\n * state was entirely correct and sent the author to look at the one thing that\n * was right.\n *\n * So this is asked FIRST and says what actually happened. It is the hands' half\n * of `__laneTerminalsMustBeLiteralsAddAsConst` on the spec side: the same\n * mistake, the same shape of answer.\n */\ntype BootLostItsLiterals<L, H> = {\n [T in LaneTaskId<L>]: [IsDegenerate<StateName<LaneTaskChart<L, T>>>] extends [\n true,\n ]\n ? never\n : [BootOf<H, T>] extends [never]\n ? never\n : [\n IsDegenerate<\n BootOf<H, T> extends { readonly type: infer S } ? S : never\n >,\n ] extends [true]\n ? T\n : never;\n}[LaneTaskId<L>];\n\n/** Tasks whose `boot()` returns something that is not a state of THEIR chart. */\ntype BootsOutsideItsChart<L, H> = {\n [T in LaneTaskId<L>]: [IsDegenerate<StateName<LaneTaskChart<L, T>>>] extends [\n true,\n ]\n ? never\n : [BootOf<H, T>] extends [never]\n ? never\n : // a widened boot is the finding above, not this one — one mistake, one\n // marker, and the author is not told two things about one typo.\n [\n IsDegenerate<\n BootOf<H, T> extends { readonly type: infer S } ? S : never\n >,\n ] extends [true]\n ? never\n : [BootOf<H, T>] extends [StateOf<LaneTaskChart<L, T>>]\n ? never\n : T;\n}[LaneTaskId<L>];\n\n/**\n * Tasks whose chart declares a FOREIGN event.\n *\n * `keyOf` leaves a foreign event's name bare under a namespace — on purpose:\n * `deadline_exceeded` is the same event for every instance of a chart, and the\n * name was never the author's to rename. A lane cannot hold that: a lane\n * message is addressed to ONE region, and a bare event names none of them.\n * Refused rather than broadcast, because \"this event went to every region at\n * once\" is a different machine than the one the phases describe.\n */\ntype DeclaresAForeignEvent<L> = {\n [T in LaneTaskId<L>]: [IsDegenerate<EventName<LaneTaskChart<L, T>>>] extends [\n true,\n ]\n ? never\n : [ForeignOf<LaneTaskChart<L, T>>] extends [never]\n ? never\n : T;\n}[LaneTaskId<L>];\n\ntype ForeignOf<C> = C extends { readonly events: infer E }\n ? {\n [K in keyof E]: E[K] extends { readonly foreign: true } ? K : never;\n }[keyof E]\n : never;\n\n/**\n * Tasks whose chart declares a cmd carrying `lane` — the one reserved key.\n *\n * {@link LaneCmd} nests the task id under `lane` and a nested tag can still be\n * shadowed by a payload that spells the same key. It is refused rather than\n * silently overwritten, because \"the field you declared is not the field your\n * interpreter receives\" is the exact defect nesting was introduced to end.\n */\ntype CmdCarriesTheLaneTag<L> = {\n [T in LaneTaskId<L>]: [\n Extract<CmdOf<LaneTaskChart<L, T>>, { readonly lane: unknown }>,\n ] extends [never]\n ? never\n : T;\n}[LaneTaskId<L>];\n\n/** The five authoring mistakes a RUN can make that a drawing cannot. */\nexport type LaneRunChecks<L, H> = ([\n Exclude<Key<keyof H>, LaneTaskId<L>>,\n] extends [never]\n ? unknown\n : {\n readonly __laneHandNamesAnUnknownTask: Exclude<\n Key<keyof H>,\n LaneTaskId<L>\n >;\n }) &\n ([BootLostItsLiterals<L, H>] extends [never]\n ? unknown\n : {\n readonly __laneHandsLostTheirLiteralTypesAddSatisfiesLaneHands: BootLostItsLiterals<\n L,\n H\n >;\n }) &\n ([BootsOutsideItsChart<L, H>] extends [never]\n ? unknown\n : {\n readonly __laneTaskBootsIntoAStateItsChartDoesNotDeclare: BootsOutsideItsChart<\n L,\n H\n >;\n }) &\n ([DeclaresAForeignEvent<L>] extends [never]\n ? unknown\n : {\n readonly __laneRegionChartDeclaresAForeignEvent: DeclaresAForeignEvent<L>;\n }) &\n ([CmdCarriesTheLaneTag<L>] extends [never]\n ? unknown\n : {\n readonly __laneRegionCmdDeclaresTheReservedLaneField: CmdCarriesTheLaneTag<L>;\n });\n\n/**\n * The self-referential constraint `runLane` binds its hands with.\n *\n * The CHECKS come first in the intersection, and the order is load-bearing for\n * the diagnostic rather than for the semantics: tsc reports the first\n * constituent that fails, so a hands object that boots a task into the wrong\n * state is told which RULE it broke and which TASK broke it, instead of being\n * handed that task's whole state union to compare by eye.\n */\nexport type LaneHandsOf<L, H> = LaneRunChecks<L, H> & LaneHands<L>;\n\n/**\n * A lane's `init` and `update` — the two halves of a `Machine` a lane can\n * derive, and exactly the two.\n */\nexport interface LaneRuntime<L> {\n readonly init: (\n loaded: LaneRunState<L> | null,\n ) => readonly [LaneRunState<L>, readonly LaneCmd<L>[]];\n readonly update: Reducer<LaneRunState<L>, LaneRunMsg<L>, LaneCmd<L>>;\n}\n\n// ── the erased shapes the dispatch actually walks ──────────────────────────\n\n/** A region leaf, as the router reads it: a name, and whatever else it carries. */\ntype RtLeaf = {\n readonly type: string;\n /** Present on a parked leaf: the state a `resume` will land back on. */\n readonly was?: string;\n /** Present where the chart's ctx carries a budget — the guard's right side. */\n readonly maxRetries?: number;\n};\ntype RtRunState = {\n readonly regions: Readonly<Record<string, RtLeaf>>;\n readonly lane: string;\n};\ntype RtMsg = { readonly type: string };\n/** The hand, after the type layer has done its work — cf. `rtParts`. */\ntype RtHand = {\n readonly parts: object;\n readonly boot: () => { readonly type: string };\n};\n\n/** What `runLane` reads off the spec: the charts, still carrying their types. */\ntype RunnableSpec = {\n readonly phases: Readonly<\n Record<string, Readonly<Record<string, LaneRegion>>>\n >;\n};\n\nconst isForeign = (event: unknown): boolean =>\n typeof event === \"object\" &&\n event !== null &&\n \"foreign\" in event &&\n event.foreign === true;\n\n/**\n * Why a dot is refused in a task id and in an event name.\n *\n * A dispatch key is `task` + `.` + `event`, and every reader splits it at the\n * FIRST dot — `bareEvent`, `liveFeed`'s `address`, the replayer over `events.jsonl`.\n * So task `a` with event `b.GO` and task `a.b` with event `GO` register the\n * same key `a.b.GO`, one of them wins the table and the other's event is\n * unreachable for the life of the process; and a task id with a dot in it\n * writes a log the replayer re-partitions into a task that does not exist.\n * `Total<C>` already bans the dot in a state name and in a foreign event name\n * for exactly this reason — this is that rule at the runtime door, where the\n * imported chart's alphabet is `string` and no type can carry it.\n */\nconst DOT =\n \"a dispatch key is the task id, a dot, then the event name — and every reader splits it at the FIRST dot, so a dot here makes two different messages one key\";\n\n/** The bare event a dispatch key carries — with the dot refused, split once. */\nconst bare = (taskId: string, key: string): string =>\n key.startsWith(`${taskId}.`) ? key.slice(taskId.length + 1) : key;\n\n/**\n * A leaf with the `was` it arrived with, and no `was` at all where there was\n * none — the fold's `{ ...state, type }`, which never adds the field.\n */\nconst carryWas = (leaf: RtLeaf, was: string | undefined): RtLeaf => {\n if (was !== undefined) return { ...leaf, was };\n const { was: _dropped, ...rest } = leaf;\n return rest;\n};\n\n/**\n * Run a lane: one compiled region per task, one dispatch surface, one derived\n * lane standing.\n *\n * ```ts\n * const epic = defineLane({\n * phases: { phase1: { issue_5729: coder, issue_5730: coder } },\n * terminals: { complete: \"complete\", tripped: \"tripped\" },\n * });\n *\n * const machine = defineMachine({\n * ...runLane(epic, {\n * issue_5729: { parts, boot: () => ({ type: \"queued\", retries: 0, maxRetries: 2 }) },\n * // this one is already merged on GitHub — it boots where it IS.\n * issue_5730: { parts, boot: () => ({ type: \"shipped\", retries: 0, maxRetries: 2 }) },\n * }),\n * interpret,\n * });\n * ```\n *\n * @throws {LaneShapeError} for the run-time half of what the markers say: a\n * task with no chart on the spec, a region declaring a foreign event, and a\n * `boot()` landing on a state its chart does not declare.\n */\nexport function runLane<\n L extends Lane<RunnableSpec>,\n const H extends LaneHandsOf<L, H>,\n>(lane: L, hands: H): LaneRuntime<L> {\n // A mapped type over the task ids IS a record keyed by them; widening to the\n // erased view is an assignment, not a cast, and it is what lets the walk\n // below index by a task id it read off the lane.\n const byTask: Readonly<Record<string, RtHand>> = hands;\n\n const defects: string[] = [];\n const tables = new Map<string, CompiledTable>();\n const boots = new Map<string, () => RtLeaf>();\n /** `${state}.${event}` per task, for the edges that RESUME — see `update`. */\n const resumes = new Map<string, ReadonlySet<string>>();\n\n for (const phase of lane.phases) {\n for (const taskId of phase.tasks) {\n const region = lane.spec.phases[phase.name]?.[taskId];\n const hand = byTask[taskId];\n // `lane.charts` is what every OTHER reader walks — the fold, the\n // inspector, the boot check below, the event list `update` is keyed from.\n // A task the phases declare and the charts do not is the one input where\n // this module's closing cast asserts something false, so it is a defect\n // here rather than a `continue` that quietly drops the region.\n const chart = lane.charts[taskId];\n if (region === undefined || hand === undefined || chart === undefined) {\n defects.push(\n `task \"${taskId}\": the lane declares it but ${\n region === undefined\n ? \"its spec holds no chart\"\n : chart === undefined\n ? \"the lane's `charts` hold none for it\"\n : \"no hand was given for it\"\n }`,\n );\n continue;\n }\n if (taskId.includes(\".\")) {\n defects.push(\n `task \"${taskId}\": a task id may not carry a dot — ${DOT}`,\n );\n }\n for (const [name, event] of Object.entries(region.events)) {\n if (isForeign(event)) {\n defects.push(\n `task \"${taskId}\": its chart declares \"${name}\" foreign — a foreign event keeps its BARE name under a namespace, so a lane message carrying it addresses no region in particular`,\n );\n }\n if (name.includes(\".\")) {\n defects.push(\n `task \"${taskId}\": its chart declares the event \"${name}\" — an event name may not carry a dot, ${DOT}`,\n );\n }\n }\n // ONE region → ONE compiled table, namespaced by the task id. This is\n // `compile(chart, parts, ns)` with `ns = taskId`, and the reason the\n // routing needed no second scheme.\n tables.set(taskId, compileTable(region, hand.parts, taskId));\n boots.set(taskId, hand.boot);\n const sites = new Set<string>();\n for (const [name, node] of statesOf(chart)) {\n for (const [event, edge] of Object.entries(node.on ?? {})) {\n if (\"resume\" in edge) sites.add(`${name}.${event}`);\n }\n }\n resumes.set(taskId, sites);\n }\n }\n if (defects.length > 0) throw new LaneShapeError(defects);\n\n /** The lane's own standing, after the leaves moved. The fold's two functions. */\n const standingOf = (regions: Readonly<Record<string, RtLeaf>>): string =>\n laneTerminalReached(phaseStandings(lane, regions), lane.terminals) ??\n \"running\";\n\n /** The budget the LANE declares for a task — `defineLane`'s `retries`. */\n const budgetOf = (taskId: string): number =>\n lane.context[taskId]?.maxRetries ?? RETRY_BUDGET;\n\n /**\n * Every region's leaf against the lane, with EVERY defect named.\n *\n * One site for both doors, because they are the same question asked of two\n * origins: `boot()` produces a leaf from code, a restart produces one from\n * storage, and neither is checked by any type at the imported door. What is\n * asked is what the rest of the module then assumes — the task set is\n * exactly the lane's, every `type` is a state of that task's chart, every\n * `was` is too (it is a TARGET: a resume walks to it, so a `was` the chart\n * does not declare is a region that lands nowhere), and the retry budget is\n * the lane's own.\n */\n const check = (\n regions: Readonly<Record<string, unknown>>,\n origin: string,\n ): readonly string[] => {\n const bad: string[] = [];\n for (const taskId of Object.keys(regions)) {\n if (!boots.has(taskId)) {\n bad.push(\n `${origin}: it names task \"${taskId}\", which this lane does not run — a state written by an older build of the lane is not a state this one can load`,\n );\n }\n }\n for (const taskId of boots.keys()) {\n const chart = lane.charts[taskId];\n if (chart === undefined) continue;\n const raw = regions[taskId];\n const leaf =\n typeof raw === \"object\" && raw !== null ? (raw as RtLeaf) : undefined;\n if (leaf === undefined || typeof leaf.type !== \"string\") {\n bad.push(\n `${origin}: it holds no leaf for task \"${taskId}\" — every region of the lane has to be standing somewhere`,\n );\n continue;\n }\n const states = statesOf(chart);\n // the runtime half of `__laneTaskBootsIntoAStateItsChartDoesNotDeclare`,\n // and the only net at the imported door, where the marker stands down.\n if (!states.has(leaf.type)) {\n bad.push(\n `${origin}: task \"${taskId}\" stands in \"${leaf.type}\", which its chart does not declare`,\n );\n }\n if (leaf.was !== undefined && !states.has(leaf.was)) {\n bad.push(\n `${origin}: task \"${taskId}\" carries \\`was: \"${leaf.was}\"\\`, which its chart does not declare — a resume would walk it to a state that does not exist`,\n );\n }\n const budget = budgetOf(taskId);\n if (typeof leaf.maxRetries === \"number\" && leaf.maxRetries !== budget) {\n bad.push(\n `task \"${taskId}\": its \\`maxRetries\\` is ${leaf.maxRetries} and the lane's budget for it is ${budget} — the lane's \\`retries\\` is the one source of that number (\\`lane.context\\`, which \\`foldLane\\` reads), so a run carrying a second one reports a different task than the one it ran`,\n );\n }\n }\n return bad;\n };\n\n const init = (loaded: RtRunState | null): readonly [RtRunState, never[]] => {\n // Invariant 2: a rehydrated lane keeps its leaves verbatim, and emits no\n // cmds. VERBATIM, not unread — this is the branch every production restart\n // walks, and what it is handed is data that outlived the code that wrote\n // it. The standing is the one field NOT taken back: it is derived from the\n // leaves by `standingOf` and nothing else may write it, so re-deriving it\n // costs one walk and makes a persisted standing that disagrees with its own\n // leaves impossible to load.\n if (loaded !== null) {\n const bad = check(\n loaded.regions ?? {},\n \"this lane cannot resume the state it was handed\",\n );\n if (bad.length > 0) throw new LaneShapeError(bad);\n return [\n { regions: loaded.regions, lane: standingOf(loaded.regions) },\n [],\n ];\n }\n const regions: Record<string, RtLeaf> = {};\n for (const [taskId, boot] of boots) regions[taskId] = boot();\n const bad = check(regions, \"this lane cannot boot\");\n if (bad.length > 0) throw new LaneShapeError(bad);\n // A lane can boot ALREADY finished — every child landed before the run\n // started — so the standing is derived at boot by the same rule that\n // derives it after every step, rather than assumed to be \"running\".\n return [{ regions, lane: standingOf(regions) }, []];\n };\n\n const update: Record<\n string,\n (s: RtRunState, m: RtMsg) => readonly [RtRunState, readonly Cmd[]]\n > = {};\n\n for (const [taskId, table] of tables) {\n // total by construction: a task with no chart was refused above, so the\n // key set this loop builds is exactly the tasks × their charts' events —\n // which is what the closing cast asserts.\n const chart = lane.charts[taskId];\n const resumeSites = resumes.get(taskId) ?? new Set<string>();\n if (chart === undefined) continue;\n for (const event of Object.keys(chart.events)) {\n // `keyOf(chart, event, taskId)` — with the foreign case refused above,\n // every key is the decorated one.\n update[`${taskId}.${event}`] = (state, msg) => {\n const leaf = state.regions[taskId];\n const cell =\n leaf === undefined ? undefined : table[leaf.type]?.[msg.type];\n if (leaf === undefined || cell === undefined) {\n throw new LaneShapeError([\n `task \"${taskId}\": no cell for \"${msg.type}\" in state \"${leaf?.type ?? \"<none>\"}\"`,\n ]);\n }\n const [moved, cmds] = cell(leaf, msg);\n // ── `was`, ON A RESUME ──────────────────────────────────────────────\n // The fold's rule, applied to the compiled cell's output: `stepTask`\n // returns `{ ...state, type: was ?? fallback }` on a resume and does\n // NOT rewrite `was` — you are LEAVING the park, not entering one —\n // while `buildCell` re-injects `was = st.type` for any landing in a\n // parking state, resume included.\n //\n // With ONE parking state the two never differ where it is read: a\n // resume out of it lands somewhere unparked, so the injection writes a\n // field nothing reads again. With TWO mutually reachable parking states\n // a resume lands ON a parking state, the injection overwrites the `was`\n // the fold kept, and the NEXT resume walks the run and the report to\n // two different STATES. That is not a `was` divergence any more.\n const next = resumeSites.has(`${leaf.type}.${bare(taskId, msg.type)}`)\n ? carryWas(moved, leaf.was)\n : moved;\n const regions = { ...state.regions, [taskId]: next };\n return [\n { regions, lane: standingOf(regions) },\n // the cmds leave wearing their task, under the namespace the replies\n // will come back in — BESIDE the payload, never over it.\n cmds.map((cmd) => ({\n ...cmd,\n lane: { task: taskId },\n type: `${taskId}.${cmd.type}`,\n })),\n ];\n };\n }\n }\n\n // ── THE ONE CAST ────────────────────────────────────────────────────────\n // `compile`'s cast, one layer up and for the same reason. `Reducer` is a\n // mapped type over `M[\"type\"]`; this walk builds exactly those keys from the\n // tasks × their charts' events, and tsc cannot see that a string-keyed record\n // built in a loop is total over the union. `LaneRunState`'s `regions` is the\n // same story one level in: a record built by iterating the lane's tasks IS\n // the mapped type over them.\n return { init, update } as unknown as LaneRuntime<L>;\n}\n","// ═══════════════════════════════════════════════════════════════════════════\n// THE LANE, AS ONE SCREEN'S WORTH OF DATA — two sources, one model.\n//\n// `inspectLane` already answers every question about a lane at ONE moment.\n// A screen needs two things on top of that, and neither is a new question about\n// the lane:\n//\n// WHICH MOMENT. Both sources can be asked for the state at step k, and both\n// answer it EXACTLY: a folded log is pure over a prefix\n// (`fold.ts`), and a recorded run re-folds a prefix through\n// `replay`. So \"the scrubber\" is one field — `leavesAt` — and\n// the two sources differ only in how they implement it.\n//\n// WHAT IS ON OFFER. A fabrika lane is already-run history: there are no code\n// bodies anywhere, so nothing can be dispatched, ever. A lane\n// under `runLane` has them, so its controls are live. That is\n// the ONLY behavioural difference between the two sources, and\n// it is carried as a value on every control rather than as a\n// branch in the view: a control that cannot be sent holds an\n// {@link Unanswerable} saying why, so the component renders the\n// reason instead of quietly rendering nothing.\n//\n// THE EDITORIAL RULES ARE `report.ts`'s, AND THEY ARE NOT RELEARNED HERE.\n// A real emitted phase holds eight tasks and six of them sit untouched at their\n// entry state; a wall of near-identical diagrams is exactly as useless in a\n// browser as in a PR comment. So this model marks each task `moved` and each\n// phase's `expanded` set, by the same rule the markdown applies — with the one\n// concession the medium earns: a screen can put the collapsed tasks' diagrams\n// behind a disclosure instead of dropping them, which a comment cannot.\n//\n// THE FIRST QUESTION ABOUT A STUCK EPIC IS *WHICH* OF TWELVE THINGS IS STUCK.\n// `stuck` is therefore the model's first field and the view's first panel, and\n// it is `inspectLane`'s own list — not a second definition of stuck.\n//\n// PURE AND FRAMEWORK-FREE, like every other headless half in this module. React\n// is in `./react`; a script or a TUI gets everything below with no DOM.\n// ═══════════════════════════════════════════════════════════════════════════\n\nimport type { EventPreview, InspectOptions, Unanswerable } from \"../inspect\";\nimport { drawTask, walkedEdges } from \"../report/draw\";\nimport {\n foldLane,\n type LogEntry,\n type PhaseStanding,\n type TaskState,\n timeline,\n walkedEdgeKey,\n} from \"../report/fold\";\nimport {\n bareEvent,\n type ImportedChart,\n type ImportedLane,\n initialOf,\n RETRY_BUDGET,\n statesOf,\n} from \"../report/workflow\";\nimport { inspectLaneStates, type StuckReason } from \"./inspect\";\n\n// ═══════════════════════════════════════════════════════════════════════════\n// THE DRAWING SEAM — one call, and it is deliberately the only one.\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * One task's region, drawn: the current node lit, the walked edges marked.\n *\n * THE WHOLE MODULE DRAWS THROUGH THIS ONE FUNCTION, and its body is one call.\n * `report/draw.ts`'s own banner says `drawTask` is itself a seam standing in for\n * `chartMermaid`'s option-taking form; when that fold lands, THIS body becomes\n * the new call and nothing else in the lane view changes — not the model, not\n * the component, not the stylesheet. That is the point of routing every drawing\n * through a single private function rather than calling the drawer from the\n * three places that want a picture.\n */\nconst draw = (\n chart: ImportedChart,\n current: string,\n walked: ReadonlyMap<string, number>,\n): string => drawTask(chart, { current, walked });\n\n/** Does this chart route `event` out of `from`, or is a step there a no-op? */\nfunction declaresEdge(\n chart: ImportedChart | undefined,\n from: string,\n event: string,\n): boolean {\n if (chart === undefined) return true;\n return statesOf(chart).get(from)?.on?.[bareEvent(event)] !== undefined;\n}\n\n/**\n * Is `state` a state you can RESUME out of — a parking state?\n *\n * `was` is written when a region enters a parking state and it is never\n * cleared, so a task that parked once and moved on still carries where it\n * parked FROM. Reading it unconditionally put \"· resumes to review\" beside a\n * task sitting on `frozen`: a dead task announcing a return it cannot make,\n * from a fact that stopped being true several steps earlier. The state's own\n * edges are what say whether it is still parked.\n */\nfunction parksHere(chart: ImportedChart | undefined, state: string): boolean {\n if (chart === undefined) return false;\n const on = statesOf(chart).get(state)?.on ?? {};\n return Object.values(on).some(\n (edge) => edge !== undefined && \"resume\" in edge,\n );\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// THE MODEL\n// ═══════════════════════════════════════════════════════════════════════════\n\n/** A task's retry bookkeeping, when the source carries it. */\nexport interface RetryBudget {\n readonly retries: number;\n readonly maxRetries: number;\n}\n\n/**\n * One event control, for one task.\n *\n * `send` is where the two sources part company, and it is a VALUE rather than a\n * flag: the answer to \"what would clicking this dispatch\" is the msg itself, so\n * a source that can answer it answers with the msg, and a source that cannot\n * holds the reason. There is no third state and no boolean to get backwards.\n */\nexport interface LaneControl {\n readonly task: string;\n readonly event: string;\n /** `\"legal\"`, or the refusal's kind — the CSS hook, as in `<ChartInspector>`. */\n readonly kind: string;\n readonly refused: boolean;\n /** The refusal's one-line explanation. Present iff refused. */\n readonly why?: string;\n /** Where this would land and what it would fire — the DECLARED answer. */\n readonly outcome: string;\n /** The msg a click dispatches, or why this source cannot offer one. */\n readonly send: { readonly type: string } | Unanswerable<\"dispatch\">;\n}\n\n/** One task of the lane, at the scrubbed moment. */\nexport interface LaneTaskView {\n readonly task: string;\n readonly phase: string;\n readonly state: string;\n readonly endPolarity: false | true | \"error\";\n /**\n * The state it resumes to — present ONLY while the task is actually parked.\n * A region keeps `was` after it leaves the park, and rendering that made a\n * finished task claim a return it cannot make.\n */\n readonly was?: string;\n /** Grouped by who sends them — `report.ts`'s own derivation. `null` at a final. */\n readonly waitingOn: string | null;\n readonly stuck: StuckReason | null;\n /**\n * `false` while the task still sits at its chart's entry state.\n *\n * The editorial rule's input: a task that has not moved has a story one line\n * long, and six of them side by side are six copies of one picture.\n */\n readonly moved: boolean;\n readonly budget: RetryBudget | Unanswerable<\"retries\">;\n readonly controls: readonly LaneControl[];\n /** This region, drawn at this moment. See {@link draw}. */\n readonly diagram: string;\n}\n\n/** One phase of the lane, at the scrubbed moment. */\nexport interface LanePhaseView {\n readonly name: string;\n readonly index: number;\n readonly standing: PhaseStanding;\n readonly tasks: readonly LaneTaskView[];\n /** The tasks in this phase sitting on an error final. */\n readonly tripped: readonly string[];\n /**\n * The tasks worth showing in full, by id — `report.ts`'s rule, applied.\n *\n * Only the ACTIVE phase expands anything: a finished phase's story is which\n * ending each of its tasks reached, and a phase that never started has no\n * story at all. Within the active phase, a task that has moved is expanded and\n * a task still at its entry state is not — unless NOTHING in the phase has\n * moved, in which case the first is the representative, because collapsing\n * every task would leave the reader with no picture at all.\n */\n readonly expanded: readonly string[];\n}\n\n/** One step of the run, as the timeline table draws it. */\nexport interface LaneStepView {\n readonly index: number;\n readonly task: string;\n /** The event VERBATIM — the source's own spelling. */\n readonly event: string;\n readonly from: string;\n readonly to: string;\n /** The edge that fired, keyed as the drawing keys it. */\n readonly edge: string;\n /**\n * The msg arrived and NOTHING happened — the chart routes no such edge here.\n *\n * A total chart answers every msg, so a refused one is still a line in the\n * log and still a step of the tape; it is just not a WALK. Left unmarked it\n * reads as a real transition that happened to land where it started\n * (`issue_1 DONE review → review`), which is the one row on the timeline a\n * reader would take at face value and be wrong about.\n */\n readonly refused: boolean;\n}\n\n/** A whole lane, at one moment, ready to render. */\nexport interface LaneViewModel {\n readonly source: \"replay\" | \"live\";\n readonly title: string;\n readonly status: \"active\" | \"done\";\n /** The terminal it landed on, or `null` while it is still running. */\n readonly terminal: string | null;\n readonly activePhase: string | null;\n /** Every task on an error final, lane-wide. */\n readonly tripped: readonly string[];\n /**\n * WHICH OF TWELVE THINGS IS STUCK — the reader's first question, answered\n * first. `inspectLane`'s own list, with the phase attached so the answer names\n * a place as well as a task.\n */\n readonly stuck: readonly {\n readonly task: string;\n readonly phase: string;\n readonly reason: StuckReason;\n }[];\n readonly phases: readonly LanePhaseView[];\n /** Every step up to the cursor. */\n readonly steps: readonly LaneStepView[];\n /**\n * When each step happened, indexed by step — or why this source cannot say.\n *\n * A fabrika log stamps every line. A recorded tape carries ORDER and nothing\n * else, so the live source answers this with the reason rather than with a\n * column of invented times.\n */\n readonly clock: readonly string[] | Unanswerable<\"clock\">;\n readonly cursor: number;\n readonly total: number;\n /** `true` while the cursor is behind the present. */\n readonly scrubbed: boolean;\n /**\n * Why THIS SOURCE can dispatch nothing at all — absent on a source that can.\n *\n * A fact about the source, so it is stated once by the source rather than\n * scraped back off whichever control still happens to carry it. Scraping is\n * what it used to be, and it went silent on exactly the lane that needed it\n * most: on a finished lane every control is refused BY THE CHART, so the one\n * sentence explaining why the whole page is dead had nowhere left to live.\n */\n readonly noDispatch?: Unanswerable<\"dispatch\">;\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// THE SOURCE SEAM — the four things a source decides, and nothing else.\n// ═══════════════════════════════════════════════════════════════════════════\n\n/** Every region's leaf, keyed by task. */\nexport type LaneLeaves = Readonly<Record<string, TaskState>>;\n\n/**\n * What a lane view is fed. Two implementations, {@link replayFeed} and\n * {@link liveFeed}, and the component branches on none of it.\n */\nexport interface LaneFeed {\n readonly kind: \"replay\" | \"live\";\n readonly lane: ImportedLane;\n /** How many steps have happened — the scrubber's extent. */\n readonly total: number;\n /** Every region's leaf after the first `n` steps. EXACT, on both sides. */\n readonly leavesAt: (n: number) => LaneLeaves;\n /** The steps, in order. */\n readonly steps: readonly LaneStepView[];\n /** {@link LaneViewModel.clock}. */\n readonly clock: readonly string[] | Unanswerable<\"clock\">;\n /** The retry budget, or why this source cannot state it. */\n readonly budget: (\n task: string,\n leaves: LaneLeaves,\n ) => RetryBudget | Unanswerable<\"retries\">;\n /** The `parts` bag and samples, per task. Absent where there are none. */\n readonly optsFor?: (task: string) => InspectOptions;\n /**\n * What a click dispatches — or why this source offers no click.\n *\n * The task is a parameter because a lane's dispatch surface is addressed:\n * `compile(chart, parts, taskId)` keys the table `${task}.${event}`, so the\n * msg a control sends is the region's event WEARING its task. The preview's\n * own `msg` is the bare one; namespacing it is the feed's job, once.\n */\n readonly send: (task: string, preview: EventPreview) => LaneControl[\"send\"];\n /** {@link LaneViewModel.noDispatch} — set it iff NO control of this source can be sent. */\n readonly noDispatch?: Unanswerable<\"dispatch\">;\n}\n\nconst NO_DISPATCH: Unanswerable<\"dispatch\"> = {\n answerable: false,\n question: \"dispatch\",\n why: \"this lane is a workflow document and its event log — the code bodies that would run an edge do not exist here, so no control can be sent. The log is the only thing that moves it.\",\n};\n\nconst NO_CLOCK: Unanswerable<\"clock\"> = {\n answerable: false,\n question: \"clock\",\n why: \"a recorded tape carries the ORDER of the msgs and no wall-clock — an events log stamps every line, a running machine does not\",\n};\n\nconst NO_RETRIES: Unanswerable<\"retries\"> = {\n answerable: false,\n question: \"retries\",\n why: \"this region's own state carries no `retries` — the retry budget is a fact of the state a chart chose to keep, and this one keeps none\",\n};\n\n/** No sample for this event's payload — the one honest \"cannot\" a LIVE lane has. */\nconst noSample = (event: string): Unanswerable<\"dispatch\"> => ({\n answerable: false,\n question: \"dispatch\",\n why: `no sample for \\`${event}\\`'s payload — \\`ty<T>()\\` is \\`{}\\` at runtime, so the shape cannot be derived and the msg cannot be built`,\n});\n\n// ── the replay feed ───────────────────────────────────────────────────────\n\n/**\n * THE FABRIKA CASE: a lane plus the log it actually produced.\n *\n * Every field is the report module's own function. The scrubber is\n * `foldLane(lane, entries.slice(0, n))`, which is not an approximation of the\n * state at step n — it is the definition of it.\n */\nexport function replayFeed(\n lane: ImportedLane,\n entries: readonly LogEntry[],\n): LaneFeed {\n const steps = timeline(lane, entries);\n return {\n kind: \"replay\",\n lane,\n total: entries.length,\n leavesAt: (n) => foldLane(lane, entries.slice(0, n)),\n // NEVER REFUSED, and that is a property of this source rather than of this\n // log: `foldLane` throws `UnreplayableLogError` on a line the chart routes\n // nowhere, so a log holding a refused msg does not produce a lane view at\n // all. A recorded TAPE is the opposite — a click that no-ops is a msg like\n // any other — which is where the mark earns its keep.\n steps: steps.map(({ at: _at, ...rest }) => ({ ...rest, refused: false })),\n clock: steps.map((s) => s.at),\n budget: (task, leaves) => {\n const leaf = leaves[task];\n return leaf === undefined\n ? NO_RETRIES\n : { retries: leaf.retries, maxRetries: leaf.maxRetries };\n },\n // No `optsFor`: a document carries no guard bodies and no payload samples,\n // and the previews degrade to exactly that.\n send: () => NO_DISPATCH,\n noDispatch: NO_DISPATCH,\n };\n}\n\n// ── the live feed ─────────────────────────────────────────────────────────\n\n/** A running region's leaf: a state name, plus whatever ctx that chart keeps. */\nexport type RunningLeaf = { readonly type: string } & Readonly<\n Record<string, unknown>\n>;\n\n/** What {@link liveFeed} needs from the runtime it is watching. */\nexport interface LiveFeedInput {\n /**\n * The regions after the first `n` recorded msgs, by PURE replay — `init` +\n * `update` only, exactly as `<ChartInspector>`'s scrubber does it.\n */\n readonly regionsAt: (n: number) => Readonly<Record<string, RunningLeaf>>;\n /** The recorded tape: `${task}.${event}` per step, in order. */\n readonly msgs: readonly { readonly type: string }[];\n /** The `parts` bag and samples, per task — the hands the run was given. */\n readonly optsFor?: (task: string) => InspectOptions;\n}\n\nconst numberAt = (leaf: RunningLeaf, key: string): number | undefined =>\n typeof leaf[key] === \"number\" ? (leaf[key] as number) : undefined;\n\n/**\n * THE RUNNING CASE: a lane under `runLane`, watched.\n *\n * The leaves come off the RUNTIME rather than off a fold, and that distinction\n * is load-bearing: `runLane` boots each region where its sub-issue actually is,\n * so a fold that started every task at its chart's `initial: true` would draw a\n * different lane than the one running.\n *\n * The steps are derived from the same replay: `from` is the leaf before the msg\n * and `to` is the leaf after, both exact, and the edge they walked is\n * {@link walkedEdgeKey} — the fold's own answer, so the live drawing thickens\n * the same edges the markdown would.\n */\nexport function liveFeed(lane: ImportedLane, input: LiveFeedInput): LaneFeed {\n // One replay per prefix, memoized: the steps below read every prefix, and\n // re-folding inside the loop would be quadratic for no reason.\n const prefixes: Readonly<Record<string, RunningLeaf>>[] = [];\n for (let n = 0; n <= input.msgs.length; n += 1) {\n prefixes.push(input.regionsAt(n));\n }\n\n const tasks = Object.keys(lane.charts);\n /** `${task}.${event}` → the pair, split at the task the LANE declares. */\n const address = (\n type: string,\n ): { readonly task: string; readonly event: string } | undefined => {\n for (const task of tasks) {\n if (type.startsWith(`${task}.`)) {\n return { task, event: type.slice(task.length + 1) };\n }\n }\n return undefined;\n };\n\n // Whether a region's state carries `retries` at all is a property of the\n // chart's ctx, not of where the run got to — so it is read ONCE, off the boot\n // leaves, rather than discovered as the scrubber wanders past a task.\n const carriesRetries = new Set<string>();\n for (const [task, leaf] of Object.entries(prefixes[0] ?? {})) {\n if (numberAt(leaf, \"retries\") !== undefined) carriesRetries.add(task);\n }\n\n const steps: LaneStepView[] = [];\n for (const [index, msg] of input.msgs.entries()) {\n const at = address(msg.type);\n const chart = at === undefined ? undefined : lane.charts[at.task];\n const before = at === undefined ? undefined : prefixes[index]?.[at.task];\n const after = at === undefined ? undefined : prefixes[index + 1]?.[at.task];\n if (at === undefined || chart === undefined) continue;\n if (before === undefined || after === undefined) continue;\n steps.push({\n index,\n task: at.task,\n event: at.event,\n from: before.type,\n to: after.type,\n edge: walkedEdgeKey(chart, before.type, at.event, after.type),\n refused: !declaresEdge(chart, before.type, at.event),\n });\n }\n\n const leavesAt = (n: number): LaneLeaves => {\n const regions =\n prefixes[Math.max(0, Math.min(n, prefixes.length - 1))] ?? {};\n const out: Record<string, TaskState> = {};\n for (const [task, leaf] of Object.entries(regions)) {\n out[task] = {\n // THE REGION'S OWN CTX, CARRIED. `TaskState` names the four fields the\n // FOLD needs, and a running region is a whole state: the guards a live\n // preview evaluates are `(state, msg) => …` over that state, so a leaf\n // narrowed to its four bookkeeping fields makes every guard read\n // `undefined` and answer with its `otherwise` arm. The extra keys are\n // invisible to a `TaskState` reader and exactly what a guard came for.\n ...leaf,\n type: leaf.type,\n retries: numberAt(leaf, \"retries\") ?? 0,\n maxRetries:\n numberAt(leaf, \"maxRetries\") ??\n lane.context[task]?.maxRetries ??\n RETRY_BUDGET,\n ...(typeof leaf.was === \"string\" ? { was: leaf.was } : {}),\n };\n }\n return out;\n };\n\n return {\n kind: \"live\",\n lane,\n total: input.msgs.length,\n leavesAt,\n steps,\n clock: NO_CLOCK,\n budget: (task, leaves) => {\n const leaf = leaves[task];\n if (leaf === undefined || !carriesRetries.has(task)) return NO_RETRIES;\n return { retries: leaf.retries, maxRetries: leaf.maxRetries };\n },\n ...(input.optsFor === undefined ? {} : { optsFor: input.optsFor }),\n // The code bodies exist, so the only thing that can stop a click is a\n // payload nobody could derive.\n send: (task, preview) =>\n preview.msg === undefined\n ? noSample(preview.event)\n : { ...preview.msg, type: `${task}.${preview.event}` },\n };\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// THE BUILD\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * The lane at step `cursor`, as one value a view renders straight.\n *\n * ```ts\n * const feed = replayFeed(chartFromWorkflow(document), parseEventsJsonl(log));\n * const view = laneView(feed, feed.total); // now\n * const then = laneView(feed, 3); // exactly after three events\n * ```\n */\nexport function laneView(\n feed: LaneFeed,\n cursor: number,\n title?: string,\n): LaneViewModel {\n const total = feed.total;\n const at = Math.max(0, Math.min(cursor, total));\n const leaves = feed.leavesAt(at);\n const seen = feed.steps.filter((s) => s.index < at);\n const inspection = inspectLaneStates(feed.lane, leaves, feed.optsFor);\n\n // THE PHASE THE READER CAME FOR, when there is no active one left. A lane\n // that ENDED has no active phase, and the rule below expands only the active\n // one — so a lane that finished successfully drew not one diagram, under a\n // paragraph promising that every task had one. `tripped` was special-cased\n // and `complete` was not, and complete is the common ending.\n //\n // The last phase that actually ran is the ending: it holds the tasks that\n // reached the terminal, and the earlier ones are history a reader can open.\n const lastRan = inspection.phases.reduce(\n (last, p, i) => (p.standing === \"waiting\" ? last : i),\n -1,\n );\n const endsAt = inspection.terminal === null ? -1 : lastRan;\n\n const phases = inspection.phases.map((phase, index): LanePhaseView => {\n const tasks = phase.tasks.map((task): LaneTaskView => {\n const chart = feed.lane.charts[task.task];\n const walked = walkedEdges(seen.filter((s) => s.task === task.task));\n return {\n task: task.task,\n phase: task.phase,\n state: task.state,\n endPolarity: task.endPolarity,\n ...(task.was === undefined || !parksHere(chart, task.state)\n ? {}\n : { was: task.was }),\n waitingOn: task.waitingOn,\n stuck: task.stuck,\n moved: chart === undefined ? true : task.state !== initialOf(chart),\n budget: feed.budget(task.task, leaves),\n controls: task.events.map((preview) =>\n control(feed, task.task, preview),\n ),\n diagram: chart === undefined ? \"\" : draw(chart, task.state, walked),\n };\n });\n return {\n name: phase.name,\n index: phase.index,\n standing: phase.standing,\n tripped: phase.tripped,\n tasks,\n expanded: expandedIn(phase.standing, tasks, index === endsAt),\n };\n });\n\n const phaseOf = (task: string): string =>\n phases.find((p) => p.tasks.some((t) => t.task === task))?.name ?? \"\";\n\n return {\n source: feed.kind,\n title: title ?? feed.lane.id ?? \"lane\",\n status: inspection.status,\n terminal: inspection.terminal,\n activePhase: inspection.activePhase,\n tripped: inspection.tripped,\n stuck: inspection.stuck.map((s) => ({\n task: s.task,\n phase: phaseOf(s.task),\n reason: s.reason,\n })),\n phases,\n steps: seen,\n clock: feed.clock,\n cursor: at,\n total,\n scrubbed: at < total,\n ...(feed.noDispatch === undefined ? {} : { noDispatch: feed.noDispatch }),\n };\n}\n\n/**\n * `report.ts`'s rule, as a set of task ids.\n *\n * The phase a reader is here for expands, and inside it only the tasks that\n * moved — with the one exception the markdown makes for the same reason: a\n * phase that just started has moved nothing, and collapsing all of it would\n * leave the reader with no picture at all, so its first task represents the\n * rest (they are all at the same entry state, so any of them is the same\n * picture).\n *\n * WHICH PHASE that is depends on whether the lane is still moving: the ACTIVE\n * one while it runs, and the one it ENDED IN once it has stopped.\n */\nfunction expandedIn(\n standing: PhaseStanding,\n tasks: readonly LaneTaskView[],\n ending: boolean,\n): readonly string[] {\n // A TRIPPED phase expands the tasks that tripped it. `report.ts` gives that\n // phase one line and that is right for a comment, where the reader is going\n // to click through to the lane anyway. On the screen they came for, the task\n // that ended the lane is the whole reason they are here.\n if (standing === \"tripped\") {\n return tasks.filter((t) => t.endPolarity === \"error\").map((t) => t.task);\n }\n if (standing !== \"active\" && !ending) return [];\n const moved = tasks.filter((t) => t.moved).map((t) => t.task);\n if (moved.length > 0) return moved;\n const first = tasks[0];\n return first === undefined ? [] : [first.task];\n}\n\n/** One `EventPreview` as a control, with this source's answer to \"can I send it\". */\nfunction control(\n feed: LaneFeed,\n task: string,\n preview: EventPreview,\n): LaneControl {\n const refused = preview.status === \"refused\";\n return {\n task,\n event: preview.event,\n kind: refused ? (preview.reason?.kind ?? \"undeclared\") : \"legal\",\n refused,\n ...(preview.why === undefined ? {} : { why: preview.why }),\n outcome: outcomeOf(preview),\n send: refused ? NO_DISPATCH_REFUSED : feed.send(task, preview),\n };\n}\n\n/**\n * A refused control cannot be sent for a reason that is not about the SOURCE —\n * the chart refused it — so it carries that answer rather than the source's.\n * The refusal itself is already on the control; this is what a caller reading\n * only `send` gets, and it must not say \"no code bodies\" about a lane that has\n * them.\n */\nconst NO_DISPATCH_REFUSED: Unanswerable<\"dispatch\"> = {\n answerable: false,\n question: \"dispatch\",\n why: \"this event is refused at this state — see the refusal for which mechanism refused it\",\n};\n\n/**\n * Why a guard could not be evaluated, as a sentence.\n *\n * The verdict's `why` is a tag — `no-guard-bag`, `no-sample` — which is the\n * right thing for a caller to branch on and the wrong thing to print. Reading\n * `retriesRemaining? (no-guard-bag)` on screen tells you the answer is missing\n * without telling you why, and the why is the useful half: on an imported lane\n * it is not a gap to fix, it is what an imported lane IS.\n */\nfunction guardUnknownLine(why: string): string {\n switch (why) {\n case \"no-guard-bag\":\n return \"cannot say which — this lane came from a workflow document, so the guard bodies that would decide do not exist here\";\n case \"no-implementation\":\n return \"cannot say which — no implementation was supplied for this guard\";\n case \"no-sample\":\n return \"cannot say which — the guard reads the message payload and no sample was given for this event\";\n default:\n return `cannot say which — evaluating the guard threw (${why})`;\n }\n}\n\n/** The one-line \"where would this go, and what would it DECLARE it fires\". */\nfunction outcomeOf(v: EventPreview): string {\n const cmds = v.cmds.length > 0 ? ` / ${v.cmds.join(\", \")}` : \"\";\n if (v.guard !== undefined) {\n return v.guard.branch === \"unknown\"\n ? `${v.targets.join(\" | \")} — ${guardUnknownLine(v.guard.why ?? \"\")}`\n : `→ ${v.guard.target} [${v.guard.branch === \"then\" ? \"\" : \"!\"}${v.guard.guard}]${cmds}`;\n }\n if (v.resolved !== undefined) return `→ ${v.resolved}${cmds}`;\n return `${v.targets.join(\" | \")}${cmds}`;\n}\n"]}
|
package/dist/chunk-CLM6ERNO.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { MsgType } from './chunk-JELSZN25.js';
|
|
2
|
-
import { tryInterpret } from './chunk-ZSUUOEPL.js';
|
|
3
|
-
|
|
4
|
-
// src/token-refresh/index.ts
|
|
5
|
-
function initTokenRefresh() {
|
|
6
|
-
return { token: null, stale: false };
|
|
7
|
-
}
|
|
8
|
-
function refreshTokenCmd() {
|
|
9
|
-
return { type: "refresh_token" };
|
|
10
|
-
}
|
|
11
|
-
function tokenRefreshedMsg(token) {
|
|
12
|
-
return { type: MsgType.TokenRefreshed, token };
|
|
13
|
-
}
|
|
14
|
-
function tokenRefreshFailedMsg(error) {
|
|
15
|
-
return { type: MsgType.TokenRefreshFailed, error };
|
|
16
|
-
}
|
|
17
|
-
function createTokenRefresh(config = {}) {
|
|
18
|
-
const skewMs = config.skewMs !== void 0 && config.skewMs > 0 ? config.skewMs : 0;
|
|
19
|
-
function needsRefresh(state, at) {
|
|
20
|
-
if (state.token === null) return true;
|
|
21
|
-
if (state.stale) return true;
|
|
22
|
-
if (!Number.isFinite(state.token.expiresAt)) return true;
|
|
23
|
-
return at >= state.token.expiresAt - skewMs;
|
|
24
|
-
}
|
|
25
|
-
function on401(state) {
|
|
26
|
-
if (state.stale) return state;
|
|
27
|
-
return { ...state, stale: true };
|
|
28
|
-
}
|
|
29
|
-
function refreshed(state, token) {
|
|
30
|
-
const normalized = Object.is(token.expiresAt, -0) ? { ...token, expiresAt: 0 } : token;
|
|
31
|
-
return { ...state, token: normalized, stale: false };
|
|
32
|
-
}
|
|
33
|
-
function ensureFresh(state, at) {
|
|
34
|
-
if (needsRefresh(state, at)) {
|
|
35
|
-
return [state, [refreshTokenCmd()]];
|
|
36
|
-
}
|
|
37
|
-
return [state, []];
|
|
38
|
-
}
|
|
39
|
-
function handlers(ports) {
|
|
40
|
-
return {
|
|
41
|
-
refresh_token: tryInterpret(
|
|
42
|
-
() => ports.refresh(),
|
|
43
|
-
(token) => tokenRefreshedMsg(token),
|
|
44
|
-
(error) => tokenRefreshFailedMsg(error)
|
|
45
|
-
)
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
return {
|
|
49
|
-
/** The slice initializer — spread into the consumer's `init`. */
|
|
50
|
-
init: initTokenRefresh,
|
|
51
|
-
needsRefresh,
|
|
52
|
-
on401,
|
|
53
|
-
refreshed,
|
|
54
|
-
ensureFresh,
|
|
55
|
-
handlers
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export { createTokenRefresh, initTokenRefresh, refreshTokenCmd, tokenRefreshFailedMsg, tokenRefreshedMsg };
|
|
60
|
-
//# sourceMappingURL=chunk-CLM6ERNO.js.map
|
|
61
|
-
//# sourceMappingURL=chunk-CLM6ERNO.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/token-refresh/index.ts"],"names":[],"mappings":";;;;AAkJO,SAAS,gBAAA,GAA+B;AAC7C,EAAA,OAAO,EAAE,KAAA,EAAO,IAAA,EAAM,KAAA,EAAO,KAAA,EAAM;AACrC;AAYO,SAAS,eAAA,GAAmC;AACjD,EAAA,OAAO,EAAE,MAAM,eAAA,EAAgB;AACjC;AAaO,SAAS,kBAAkB,KAAA,EAAiC;AACjE,EAAA,OAAO,EAAE,IAAA,EAA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,EAAO,EAAE,CAAA,EAAG;AAC3B,MAAA,OAAO,CAAC,KAAA,EAAO,CAAC,eAAA,EAAiB,CAAC,CAAA;AAAA,IACpC;AACA,IAAA,OAAO,CAAC,KAAA,EAAO,EAAE,CAAA;AAAA,EACnB;AAgBA,EAAA,SAAS,SACP,KAAA,EACsD;AACtD,IAAA,OAAO;AAAA,MACL,aAAA,EAAe,YAAA;AAAA,QAMb,MAAM,MAAM,OAAA,EAAQ;AAAA,QACpB,CAAC,KAAA,KAAU,iBAAA,CAAkB,KAAK,CAAA;AAAA,QAClC,CAAC,KAAA,KAAU,qBAAA,CAAsB,KAAK;AAAA;AACxC,KACF;AAAA,EACF;AAEA,EAAA,OAAO;AAAA;AAAA,IAEL,IAAA,EAAM,gBAAA;AAAA,IACN,YAAA;AAAA,IACA,KAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GACF;AACF","file":"chunk-CLM6ERNO.js","sourcesContent":["/**\n * @demlik/tea/token-refresh — a credential's lifecycle as pure state + verbs,\n * with the actual token fetch deferred to a single injected port.\n *\n * This is the L1 brick `authed-call` (#10 in the composition specs) stacks on:\n * a token slice `{ token, stale }` plus pure transitions that decide *when* a\n * credential must be re-minted, and one `handlers(ports)` splice that performs\n * the re-mint. It follows the uniform knob contract every composition wears —\n * `createTokenRefresh(config) → { init, <verbs>, handlers }` — so a consumer\n * spreads ~3 hooks into their machine instead of hand-wiring the refresh dance.\n *\n * It is a LEAF module in the same mold as `@demlik/tea/retry-backoff`: it\n * depends only on the core (`../index`), never on a sibling brick. The two\n * non-negotiables of every knob hold here by construction:\n *\n * - **Durable** — the token slice is plain JSON-serializable data, so it\n * survives a Durable Object eviction / page reload. A rehydrated machine\n * resumes knowing exactly which token it holds and whether it is stale.\n * - **Replayable** — every transition is a pure verb returning\n * `readonly [State, Cmd[]]`. No verb reads the wall clock or performs I/O,\n * so `replay` reconstructs the slice exactly. Time enters ONLY as an `at`\n * parameter the caller stamps; the network fetch enters ONLY at the\n * `handlers` boundary. This keeps the substrate's purity invariants intact\n * (invariant 2: pure transitions; invariant 4: I/O is an effect, not a\n * reducer body).\n *\n * ## The staleness model — two independent reasons to refresh\n *\n * A token becomes unusable for two unrelated reasons, and the slice tracks both\n * without conflating them:\n *\n * 1. **Expiry** — the token has a known `expiresAt` (epoch ms). It is \"near\n * expiry\" once `at >= expiresAt - skewMs`. The `skewMs` skew refreshes\n * *ahead* of the hard deadline so an in-flight call never races a token\n * that expires mid-request. This is the proactive, time-driven reason and\n * is computed purely from the injected `at` — no clock in the verb.\n *\n * 2. **Server rejection (401)** — the server rejected a request the client\n * believed was still valid (clock skew, a server-side revocation, an early\n * rotation). `on401` flips a `stale` flag regardless of `expiresAt`. This\n * is the reactive reason: the client's belief about validity was wrong, so\n * the next `needsRefresh` returns true even though the clock says the\n * token is fine.\n *\n * `needsRefresh` is the union of the two (plus \"no token at all\"). One source\n * of truth for \"should I fetch a fresh credential before the next call?\", read\n * by the consumer's reducer at the call boundary.\n *\n * Typical wiring (inside a consumer machine):\n *\n * const tr = createTokenRefresh({ skewMs: 30_000 });\n *\n * // in init:\n * init: (loaded) => [loaded ?? { auth: tr.init() }, Cmd.none],\n *\n * // in a reducer cell that is about to make an authed call:\n * before_call: (s, msg) => {\n * const [auth, cmds] = tr.ensureFresh(s.auth, msg.at);\n * return [{ ...s, auth }, cmds]; // emits a refresh Cmd iff a refresh is due\n * },\n *\n * // on a 401 from a guarded call:\n * got_401: (s) => [{ ...s, auth: tr.on401(s.auth) }, []],\n *\n * // when the refresh port resolves:\n * token_refreshed: (s, msg) => [{ ...s, auth: tr.refreshed(s.auth, msg.token) }, []],\n *\n * // splice the I/O:\n * interpret: { ...tr.handlers({ refresh: () => mySdk.mintToken() }) },\n *\n * NOT a substrate primitive: from `../index` it reuses only the `Cmd` /\n * `Interpret` types and the `tryInterpret` Railway helper (a runtime function,\n * not a type) that every effectful brick uses — and no sibling brick. It is a\n * leaf utility consumers reach via the `@demlik/tea/token-refresh` subpath.\n */\n\nimport { type Cmd, type Interpret, tryInterpret } from \"../index\";\nimport { MsgType } from \"../protocol\";\n\n/**\n * A minted credential: the opaque `value` to send on the wire, and the absolute\n * `expiresAt` (epoch milliseconds — the `Date.now()` scale) the issuer stamped\n * it with. Both fields are plain data so a `Token` is trivially serializable\n * into a consumer's `Store<S>`.\n *\n * `value` is `string` because that is the universal shape of a bearer token /\n * API key / session cookie on the wire. A consumer whose refresh port yields a\n * richer object can JSON-encode it into `value`, or keep this module's slice as\n * the \"is it fresh?\" gate and hold the richer object elsewhere in their Model.\n */\nexport interface Token {\n /** The opaque credential to present on each request (bearer token, API key). */\n readonly value: string;\n /** Absolute expiry instant, epoch milliseconds. The `Date.now()` scale. */\n readonly expiresAt: number;\n}\n\n/**\n * Pure configuration — the knob's only field. Carries no mutable state;\n * `TokenState` does. One config is shared across all the refreshes of one\n * logical credential (often a module-scope const).\n */\nexport interface TokenRefreshConfig {\n /**\n * Refresh-ahead skew, in milliseconds. A token is treated as needing a\n * refresh once `at >= expiresAt - skewMs`, i.e. `skewMs` BEFORE its hard\n * expiry. This buys headroom so a call that starts just under the wire never\n * races a token that lapses mid-flight, and absorbs small client/server clock\n * disagreement. `0` means \"refresh exactly at expiry\"; a negative value is\n * clamped to `0` (a skew that pushes the trigger past expiry is meaningless).\n *\n * @default 0\n */\n readonly skewMs?: number;\n}\n\n/**\n * The token slice this knob owns — the Model field a consumer spreads in via\n * `init()`. A two-field record rather than a phase union because the two\n * dimensions are orthogonal: a token can be present-and-fresh, present-but-stale\n * (a 401 came back), absent, or absent-and-stale (cleared after a failed\n * refresh). Every combination is meaningful, so neither field implies the\n * other's value and a discriminated union would only manufacture impossible\n * arms.\n *\n * - `token` — the currently held credential, or `null` when none has been\n * minted yet (fresh boot) or the last refresh failed.\n * - `stale` — set by `on401` when the server rejected a request the client\n * believed valid. Forces the next `needsRefresh` to true regardless of\n * `expiresAt`; cleared by `refreshed` once a new credential lands.\n *\n * Both fields `readonly` so the whole slice threads safely through a pure\n * reducer and serializes into a `Store<S>`.\n */\nexport interface TokenState {\n /** The held credential, or `null` if none is available (boot / failed refresh). */\n readonly token: Token | null;\n /** Whether a 401 has marked the held token unusable ahead of its `expiresAt`. */\n readonly stale: boolean;\n}\n\n/**\n * The starting slice: no token held, not stale. The first `needsRefresh` after\n * this returns `true` (no token), so a consumer's first guarded call mints a\n * credential before going out.\n */\nexport function initTokenRefresh(): TokenState {\n return { token: null, stale: false };\n}\n\n/**\n * The Cmd this knob emits to ask the runtime to mint a fresh token. Plain data\n * (no closure — invariant 1) carrying nothing: the refresh port takes no input,\n * and the slice the result installs is read off the follow-up Msg, not this\n * Cmd. The consumer unions this into their machine's Cmd type and lets\n * `handlers` interpret it.\n */\nexport interface RefreshTokenCmd extends Cmd<\"refresh_token\"> {}\n\n/** Construct a `refresh_token` Cmd. */\nexport function refreshTokenCmd(): RefreshTokenCmd {\n return { type: \"refresh_token\" };\n}\n\n/**\n * The Msg the refresh port dispatches on success — carries the freshly minted\n * `Token`. The consumer unions this into their Msg type and handles it by\n * folding `refreshed(state, msg.token)` into the slice.\n */\nexport interface TokenRefreshedMsg {\n readonly type: typeof MsgType.TokenRefreshed;\n readonly token: Token;\n}\n\n/** Construct a `token_refreshed` Msg carrying the new token. */\nexport function tokenRefreshedMsg(token: Token): TokenRefreshedMsg {\n return { type: MsgType.TokenRefreshed, token };\n}\n\n/**\n * The Msg the refresh port dispatches on failure — carries the rejection so the\n * consumer's reducer can decide whether to back off, surface an error, or give\n * up (errors are data: it is dispatched, never swallowed). The slice itself is\n * left untouched by a failed refresh — the held token (if any) stays held and\n * stale stays set, so the consumer can retry; clearing it is the consumer's\n * policy, expressed in their reducer.\n */\nexport interface TokenRefreshFailedMsg {\n readonly type: typeof MsgType.TokenRefreshFailed;\n readonly error: unknown;\n}\n\n/** Construct a `token_refresh_failed` Msg carrying the rejection. */\nexport function tokenRefreshFailedMsg(error: unknown): TokenRefreshFailedMsg {\n return { type: MsgType.TokenRefreshFailed, error };\n}\n\n/** The two Msgs the refresh port can produce. Union for a consumer's Msg type. */\nexport type TokenRefreshMsg = TokenRefreshedMsg | TokenRefreshFailedMsg;\n\n/** The ports this knob's `handlers` splice needs — the single refresh DI seam. */\nexport interface TokenRefreshPorts {\n /**\n * Mint a fresh credential. Called ONLY from the `refresh_token` interpret\n * handler — never from a verb — so the network I/O and any clock the issuer\n * reads stay at the effect boundary. May reject; the rejection is routed to\n * `token_refresh_failed` (errors are data), never thrown into the runtime.\n */\n readonly refresh: () => Promise<Token>;\n}\n\n/**\n * The knob: hand it a config, get back the slice initializer, the pure verbs,\n * and the `handlers` splice. Mirrors every L2 composition's uniform contract so\n * the call sites read identically across bricks.\n *\n * @example\n * const tr = createTokenRefresh({ skewMs: 30_000 });\n * const s0 = tr.init();\n * const [s1, cmds] = tr.ensureFresh(s0, Date.now()); // cmds = [refreshTokenCmd()]\n */\nexport function createTokenRefresh(config: TokenRefreshConfig = {}) {\n // Clamp once at construction: a negative skew would push the refresh trigger\n // PAST expiry, which inverts the knob's intent (\"refresh ahead\"). NaN (a\n // miswired config) collapses to 0 so `needsRefresh`'s comparison stays total.\n const skewMs =\n config.skewMs !== undefined && config.skewMs > 0 ? config.skewMs : 0;\n\n /**\n * Whether the held token must be refreshed before the next guarded call, at\n * the injected instant `at` (epoch ms). PURE — reads only, no clock, no\n * mutation. True iff ANY of:\n *\n * - no token is held (`token === null`) — nothing to present;\n * - the token was marked `stale` by a 401 — the server disagrees with the\n * client's belief that it is valid;\n * - the token's `expiresAt` is not a finite number (`NaN` / `±Infinity`) —\n * a miswired issuer or a corrupted slice; we cannot reason about when it\n * lapses, so we fail SAFE toward minting a fresh one rather than letting\n * `at >= NaN` (always `false`) or `at >= Infinity` (always `false`) mask\n * a broken expiry as \"fresh forever\";\n * - the token is at or past its skewed expiry (`at >= expiresAt - skewMs`)\n * — the proactive refresh-ahead window has opened.\n *\n * The expiry cutoff is half-open (`>=`), matching the window edges in\n * `rate-limit` / `cache` / `circuit-breaker`: a token minted to expire at `t`\n * with zero skew is considered due at exactly `t`.\n */\n function needsRefresh(state: TokenState, at: number): boolean {\n if (state.token === null) return true;\n if (state.stale) return true;\n // Non-finite expiry (NaN/±Infinity) can never be compared into a \"due\"\n // verdict — `at >= NaN` and `at >= Infinity` are both `false`, which would\n // pin a broken token as fresh forever. Fail safe: treat it as needing a\n // refresh so the next call mints a credential with a real deadline.\n if (!Number.isFinite(state.token.expiresAt)) return true;\n return at >= state.token.expiresAt - skewMs;\n }\n\n /**\n * Mark the held token unusable because a request the client believed valid\n * came back 401. PURE — returns a new slice; the input is never mutated.\n * Sets `stale` regardless of `expiresAt`, so the next `needsRefresh` returns\n * true even when the clock still says the token is fine. The token VALUE is\n * kept (not nulled) — it is the consumer's last-known credential until a\n * refresh replaces it, and keeping it lets observability show what was\n * rejected.\n *\n * Idempotent: a second 401 on an already-stale slice returns the same shape.\n * A 401 with no token held is a no-op (already needs a refresh).\n */\n function on401(state: TokenState): TokenState {\n if (state.stale) return state;\n return { ...state, stale: true };\n }\n\n /**\n * Install a freshly minted `token`, clearing `stale`. PURE — returns a new\n * slice; the input is never mutated. This is the fold for the\n * `token_refreshed` Msg: after it, `needsRefresh(state, at)` is false for any\n * `at` below the new skewed expiry, and the stale flag is gone (the new\n * credential supersedes whatever the 401 rejected).\n *\n * This is the slice's WRITE boundary for a credential, so it is where the\n * durability invariant is paid for: it normalizes a negative-zero `expiresAt`\n * to `+0` before the value enters the slice. `-0` is the one finite double\n * JSON cannot round-trip — `JSON.stringify(-0)` is `\"0\"`, which parses back as\n * `+0`, so a slice carrying `-0` would diverge from its persisted form across\n * a Durable Object eviction / page reload (invariant: the boundary parses, the\n * core trusts). `-0` and `+0` denote the same epoch-ms instant, so collapsing\n * them loses no information and makes the un-round-trippable state\n * unrepresentable in the slice by construction.\n */\n function refreshed(state: TokenState, token: Token): TokenState {\n const normalized: Token = Object.is(token.expiresAt, -0)\n ? { ...token, expiresAt: 0 }\n : token;\n return { ...state, token: normalized, stale: false };\n }\n\n /**\n * The verb a consumer calls at the call boundary: \"make sure I have a fresh\n * credential before the next request.\" PURE — returns `[next, cmds]`. When a\n * refresh is due (`needsRefresh(state, at)`), emits a single `refresh_token`\n * Cmd; otherwise emits none. The slice is returned UNCHANGED in both branches\n * — the refresh itself is async and lands later via `refreshed`, so there is\n * no in-flight phase to record here. (A consumer that wants single-flight —\n * \"don't fire a second refresh while one is pending\" — layers that in their\n * own reducer, e.g. by tracking a pending flag; this brick stays minimal and\n * lets the consumer own that policy.)\n *\n * The `at` is the caller's stamped clock reading (epoch ms), never read here —\n * keeping the verb pure and `replay`-able.\n */\n function ensureFresh(\n state: TokenState,\n at: number,\n ): readonly [TokenState, readonly Cmd[]] {\n if (needsRefresh(state, at)) {\n return [state, [refreshTokenCmd()]];\n }\n return [state, []];\n }\n\n /**\n * The interpret splice: wraps the injected `refresh` port and routes its\n * Ok/Err to `token_refreshed` / `token_refresh_failed` Msgs via the core's\n * `tryInterpret` Railway helper. Spread the result into a consumer's\n * `interpret` map:\n *\n * interpret: { ...other, ...tr.handlers({ refresh: () => sdk.mintToken() }) }\n *\n * The port is the ONLY place the network (and any clock the issuer reads) is\n * touched — every verb above stays pure. `tryInterpret` guarantees the\n * handler never rejects: a port rejection becomes a `token_refresh_failed`\n * Msg (errors are data), so the runtime's dispatch loop is never poisoned by\n * an unhandled rejection.\n */\n function handlers(\n ports: TokenRefreshPorts,\n ): Interpret<TokenRefreshMsg, RefreshTokenCmd, unknown> {\n return {\n refresh_token: tryInterpret<\n RefreshTokenCmd,\n Token,\n TokenRefreshMsg,\n unknown\n >(\n () => ports.refresh(),\n (token) => tokenRefreshedMsg(token),\n (error) => tokenRefreshFailedMsg(error),\n ),\n };\n }\n\n return {\n /** The slice initializer — spread into the consumer's `init`. */\n init: initTokenRefresh,\n needsRefresh,\n on401,\n refreshed,\n ensureFresh,\n handlers,\n };\n}\n\n/** The shape `createTokenRefresh` returns — useful for typing a held knob. */\nexport type TokenRefresh = ReturnType<typeof createTokenRefresh>;\n"]}
|
package/dist/chunk-COS5MSTO.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { createResilientCall, liftResilience } from './chunk-4KLG43GY.js';
|
|
2
|
-
import { MsgType } from './chunk-JELSZN25.js';
|
|
3
|
-
import { describeError } from './chunk-G5E74IJB.js';
|
|
4
|
-
|
|
5
|
-
// src/llm-call/index.ts
|
|
6
|
-
function createLlmCall(config, rng = Math.random) {
|
|
7
|
-
const resilientConfig = {
|
|
8
|
-
...config.retry === void 0 ? {} : { retry: config.retry }
|
|
9
|
-
};
|
|
10
|
-
const rc = createResilientCall(resilientConfig, rng);
|
|
11
|
-
function init() {
|
|
12
|
-
return rc.init();
|
|
13
|
-
}
|
|
14
|
-
function attempt(s, input, at, key = input.purpose) {
|
|
15
|
-
return rc.attempt(s, key, input, at);
|
|
16
|
-
}
|
|
17
|
-
function succeed(s, key, msg) {
|
|
18
|
-
return rc.succeed(s, key, msg);
|
|
19
|
-
}
|
|
20
|
-
function fail(s, key, msg) {
|
|
21
|
-
return rc.fail(s, key, msg);
|
|
22
|
-
}
|
|
23
|
-
function onTimer(s, msg) {
|
|
24
|
-
return rc.onTimer(s, msg);
|
|
25
|
-
}
|
|
26
|
-
function subs(s) {
|
|
27
|
-
return rc.subs(s);
|
|
28
|
-
}
|
|
29
|
-
async function invokeOne(input) {
|
|
30
|
-
const model = config.model(input.model);
|
|
31
|
-
const messages = config.loadMessages ? await config.loadMessages(input) : [];
|
|
32
|
-
const schema = config.schemas[input.purpose];
|
|
33
|
-
const structured = model.withStructuredOutput(schema);
|
|
34
|
-
const raw = await structured.invoke(messages);
|
|
35
|
-
const output = schema.parse(raw);
|
|
36
|
-
return { key: input.purpose, purpose: input.purpose, output };
|
|
37
|
-
}
|
|
38
|
-
const resilientRunHandler = rc.handlers({
|
|
39
|
-
run: (input) => invokeOne(input)
|
|
40
|
-
}).resilient_run;
|
|
41
|
-
async function settleOf(cmd) {
|
|
42
|
-
const settle = await resilientRunHandler(cmd, {});
|
|
43
|
-
if (settle.type === MsgType.ResilientOk) {
|
|
44
|
-
return { ...settle, result: { ...settle.result, key: cmd.key } };
|
|
45
|
-
}
|
|
46
|
-
const rawError = settle.error;
|
|
47
|
-
const err = {
|
|
48
|
-
key: cmd.key,
|
|
49
|
-
purpose: cmd.input.purpose,
|
|
50
|
-
reason: describeError(rawError),
|
|
51
|
-
error: rawError
|
|
52
|
-
};
|
|
53
|
-
return {
|
|
54
|
-
type: MsgType.ResilientErr,
|
|
55
|
-
key: settle.key,
|
|
56
|
-
error: err,
|
|
57
|
-
at: settle.at
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function handlers(ports) {
|
|
61
|
-
if (ports === void 0) {
|
|
62
|
-
return { resilient_run: (cmd) => settleOf(cmd) };
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
resilient_run: (cmd, ctx) => {
|
|
66
|
-
const fired = (async () => {
|
|
67
|
-
const settle = await settleOf(cmd);
|
|
68
|
-
if (settle.type === MsgType.ResilientOk) {
|
|
69
|
-
const msg2 = ports.onOk(settle.result);
|
|
70
|
-
if (msg2 !== void 0) await ctx.dispatch(msg2);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const msg = ports.onErr(settle.error);
|
|
74
|
-
if (msg !== void 0) await ctx.dispatch(msg);
|
|
75
|
-
})();
|
|
76
|
-
ctx.waitUntil(fired);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
return { init, attempt, succeed, fail, onTimer, subs, handlers, invokeOne };
|
|
81
|
-
}
|
|
82
|
-
function liftLlmCall(state, result) {
|
|
83
|
-
return liftResilience(state, result);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export { createLlmCall, liftLlmCall };
|
|
87
|
-
//# sourceMappingURL=chunk-COS5MSTO.js.map
|
|
88
|
-
//# sourceMappingURL=chunk-COS5MSTO.js.map
|