@demlik/tea 0.12.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 +638 -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-7SVIRMC6.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-7V4EVLZA.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-WLGO64WC.js → chunk-HYDWG35Q.js} +23 -6
- package/dist/chunk-HYDWG35Q.js.map +1 -0
- package/dist/{chunk-I5OV65MS.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-CTzMJ82M.d.ts +562 -0
- 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 +48 -31
- package/dist/do/index.js +36 -25
- package/dist/do/index.js.map +1 -1
- package/dist/{durable-effects-D8SqU_if.d.ts → durable-effects-B0-qGQDy.d.ts} +2 -2
- package/dist/extension/index.d.ts +301 -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 -11
- package/dist/{fan-out/index.d.ts → index-6A7dB8f6.d.ts} +7 -8
- 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 -77
- package/dist/{monitored-run/index.d.ts → index-NjrT3fL2.d.ts} +37 -12
- package/dist/{recorder/index.d.ts → index-TvRb1KVf.d.ts} +4 -6
- package/dist/{deadline/index.d.ts → index-q0hXFeZ0.d.ts} +155 -8
- package/dist/index.d.ts +719 -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 +2 -1
- package/dist/machine-viz/index.js +12 -5
- package/dist/machine-viz/index.js.map +1 -1
- package/dist/mem/index.d.ts +19 -3
- package/dist/mem/index.js +22 -2
- package/dist/mem/index.js.map +1 -1
- package/dist/node/index.d.ts +130 -4
- package/dist/node/index.js +222 -10
- 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 +5 -10
- package/dist/parity/index.js +4 -7
- package/dist/parity/index.js.map +1 -1
- package/dist/pbt/index.d.ts +248 -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 -4
- package/dist/persistence/index.js +6 -0
- package/dist/react/index.d.ts +4 -3
- 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 +3 -2
- package/dist/testing/index.js +1 -2
- package/dist/testing/index.js.map +1 -1
- package/dist/{throttled-input → timing}/index.d.ts +144 -12
- package/dist/{throttled-input → timing}/index.js +57 -12
- package/dist/timing/index.js.map +1 -0
- package/dist/{types-D7u9DkH7.d.ts → types-DP3f5NIl.d.ts} +1 -1
- package/dist/work-queue/index.d.ts +131 -54
- package/dist/work-queue/index.js +3 -2
- package/dist/work-queue/index.js.map +1 -1
- package/package.json +50 -216
- package/dist/authed-call/index.d.ts +0 -119
- 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 -100
- 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 -151
- package/dist/cache/index.js +0 -8
- package/dist/chart/index.d.ts +0 -217
- package/dist/chart/index.js +0 -16
- package/dist/chart/index.js.map +0 -1
- package/dist/chart/inspect/index.d.ts +0 -85
- package/dist/chart/inspect/index.js +0 -5
- package/dist/chart/inspect/react.d.ts +0 -112
- 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 -361
- 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 -83
- 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 -116
- 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-3JU6657S.js +0 -372
- package/dist/chunk-3JU6657S.js.map +0 -1
- package/dist/chunk-4KTWLPL5.js +0 -33
- package/dist/chunk-4KTWLPL5.js.map +0 -1
- package/dist/chunk-5EHLEUTL.js +0 -686
- package/dist/chunk-5EHLEUTL.js.map +0 -1
- package/dist/chunk-5KJKJOFC.js +0 -758
- package/dist/chunk-5KJKJOFC.js.map +0 -1
- package/dist/chunk-7SVIRMC6.js.map +0 -1
- package/dist/chunk-7V4EVLZA.js.map +0 -1
- package/dist/chunk-A56OR5RF.js +0 -184
- package/dist/chunk-A56OR5RF.js.map +0 -1
- package/dist/chunk-AZZLE7XR.js +0 -62
- package/dist/chunk-AZZLE7XR.js.map +0 -1
- package/dist/chunk-B5VXOFMZ.js +0 -266
- package/dist/chunk-B5VXOFMZ.js.map +0 -1
- package/dist/chunk-BYQUGDD3.js +0 -16
- package/dist/chunk-BYQUGDD3.js.map +0 -1
- package/dist/chunk-D736QUGF.js.map +0 -1
- package/dist/chunk-E6GEDSF4.js +0 -307
- package/dist/chunk-E6GEDSF4.js.map +0 -1
- package/dist/chunk-EUF7XOEE.js +0 -223
- package/dist/chunk-EUF7XOEE.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-I5OV65MS.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-JER5O7PQ.js +0 -416
- package/dist/chunk-JER5O7PQ.js.map +0 -1
- package/dist/chunk-JGVL3WPL.js +0 -26
- package/dist/chunk-JGVL3WPL.js.map +0 -1
- package/dist/chunk-JP5D6GSL.js +0 -71
- package/dist/chunk-JP5D6GSL.js.map +0 -1
- package/dist/chunk-K575PT4S.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-ND3DH6KM.js +0 -88
- package/dist/chunk-ND3DH6KM.js.map +0 -1
- package/dist/chunk-Q2UM7BXU.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-SUST46KO.js +0 -53
- package/dist/chunk-SUST46KO.js.map +0 -1
- package/dist/chunk-TP5UPGLY.js +0 -61
- package/dist/chunk-TP5UPGLY.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-WLGO64WC.js.map +0 -1
- package/dist/chunk-WRAA7GVZ.js +0 -209
- package/dist/chunk-WRAA7GVZ.js.map +0 -1
- package/dist/chunk-ZCL7SCBK.js +0 -685
- package/dist/chunk-ZCL7SCBK.js.map +0 -1
- package/dist/chunk-ZD6PNZBK.js +0 -457
- package/dist/chunk-ZD6PNZBK.js.map +0 -1
- package/dist/chunk-ZF6WDK2D.js +0 -519
- package/dist/chunk-ZF6WDK2D.js.map +0 -1
- package/dist/chunk-ZJ5AOYBH.js +0 -8
- package/dist/chunk-ZJ5AOYBH.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/core-Bjc0bS8j.d.ts +0 -326
- 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 -44
- 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-Blbhru48.d.ts +0 -435
- package/dist/graph-CcjWZVrd.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 -187
- package/dist/idempotent-intake/index.js +0 -7
- package/dist/idempotent-intake/index.js.map +0 -1
- package/dist/llm-call/index.d.ts +0 -310
- package/dist/llm-call/index.js +0 -16
- package/dist/llm-call/index.js.map +0 -1
- package/dist/machine-0OmPvsy_.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 -234
- 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 -135
- 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 -117
- package/dist/pbt/runners/index.js +0 -5
- package/dist/pbt/runners/index.js.map +0 -1
- package/dist/poller/index.d.ts +0 -351
- package/dist/poller/index.js +0 -115
- package/dist/poller/index.js.map +0 -1
- package/dist/prediction/index.d.ts +0 -130
- 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 -2
- 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 -192
- 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-BqyoVyBG.d.ts +0 -447
- package/dist/resilient-call/index.d.ts +0 -319
- 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-BVeqJDBF.d.ts +0 -713
- package/dist/runtime-types-Bxc637bp.d.ts +0 -502
- package/dist/saga/index.d.ts +0 -240
- package/dist/saga/index.js +0 -150
- package/dist/saga/index.js.map +0 -1
- package/dist/samples-DCt6nF8H.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 -471
- 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 -215
- 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 -196
- 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 -224
- 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 -149
- 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 -83
- 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 -70
- package/dist/work-queue/ops.js +0 -3
- package/dist/work-queue/ops.js.map +0 -1
- package/dist/workflow/index.d.ts +0 -484
- 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
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { C as Cmd, S as Sub, M as Machine } from '../core-
|
|
2
|
-
import { R as Runtime } from '../runtime-types-
|
|
1
|
+
import { C as Cmd, S as Sub, M as Machine } from '../core-CTzMJ82M.js';
|
|
2
|
+
import { R as Runtime } from '../runtime-types-LWDoi943.js';
|
|
3
|
+
import 'zod';
|
|
3
4
|
import 'better-result';
|
|
4
5
|
|
|
5
6
|
/**
|
package/dist/testing/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/testing/assert-wrapper-faithful.ts","../../src/testing/assertions.ts","../../src/testing/bind-machine.ts","../../src/testing/noop-runtime.ts","../../src/testing/state-factory.ts"],"names":["step","expect"],"mappings":";;;;AAiJO,SAAS,qBAAA,CAYd,IAAA,EACA,WAAA,EACA,IAAA,EACM;AACN,EAAA,MAAM,OAAA,GAAW,IAAA,CAAK,OAAA,IAAY,IAAA,CAAK,GAAA;AACvC,EAAA,MAAM,cAAc,IAAA,CAAK,IAAA;AACzB,EAAA,MAAM,UAAA,GACJ,KAAK,UAAA,KAAe,IAAA,CAAK,UAAU,IAAA,GAAQ,IAAA,CAAK,OAAO,IAAA,GAAa,IAAA,CAAA;AAStE,EAAA,MAAM,EAAA,GAAK,EAAE,GAAA,EAAK,GAAA,EAAW,KAAK,KAAA,EAAM;AACxC,EAAA,MAAM,EAAA,GAAK,EAAE,GAAA,EAAK,OAAA,EAAW,KAAK,KAAA,EAAM;AAIxC,EAAA,MAAM,IAAA,GAAO,YAAA;AAAA,IAAa,EAAA;AAAA,IAAI,MA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ACvB,MAAA,GAAA,CAAI,GAAG,CAAA,GAAI,KAAA;AAAA,IACb;AAAA,EACF;AACA,EAAA,OAAO,GAAA;AACT;AAeO,SAAS,aACd,QAAA,EACoB;AAIpB,EAAA,MAAM,MAAM,EAAC;AACb,EAAA,KAAA,MAAW,OAAO,MAAA,CAAO,IAAA;AAAA,IACvB;AAAA,GACF,EAAwC;AACtC,IAAA,MAAM,aAAA,GAAgB,SAAS,GAAG,CAAA;AAClC,IAAA,GAAA,CAAI,GAAa,CAAA,GAAI,CAAC,SAAA,KAAuB;AAG3C,MAAA,MAAM,gBAAA,GAAmB,SAAA,GAAY,cAAA,CAAe,SAAS,IAAI,EAAC;AAClE,MAAA,OAAO,EAAE,IAAA,EAAM,GAAA,EAAK,GAAG,aAAA,EAAe,GAAG,gBAAA,EAAiB;AAAA,IAC5D,CAAA;AAAA,EACF;AACA,EAAA,OAAO,GAAA;AACT","file":"index.js","sourcesContent":["// ---------------------------------------------------------------------------\n// `assertWrapperFaithful` — the shared conformance gate for the wrapper tier.\n//\n// A `withX` wrapper bolts a cross-cutting concern (telemetry, deadline,\n// resilience) onto a base machine as an AUTHORING property — the base's source\n// never hand-wires it. The DANGER is the runtime betrayal: hiding wrapper state\n// in a closure, or silently swallowing / retiming a base Cmd, so the wrapper's\n// behavior is invisible to the reducer + Msg log. This helper is the binary\n// betrayal-detector every wrapper inherits. Pass = TEA-faithful, ship it.\n// Fail = betrayal, does not merge.\n//\n// It asserts, by `replay` (which composes `init` + `update` only — the\n// conformance path):\n//\n// 1. **Base behavior byte-identical.** `replay(wrapped).state.base` deep-\n// equals `replay(base).state`. The wrapper never alters base behavior.\n// 2. **Slice AND wrapper Cmds reconstruct under any ambient clock/RNG.**\n// Replaying the SAME msgs under a DIFFERENT global wall-clock + RNG yields\n// a deep-equal wrapper slice AND a deep-equal `$x:*` wrapper-Cmd subset —\n// BOTH halves of the wrapper's output (state slice + emitted Cmds) are a\n// pure function of the Msg log, NOT of `Date.now()` / `Math.random()`.\n// (`update` cells never receive `ctx`, so an impure update read reaches for\n// the GLOBAL ambient; stubbing two distinct ambients and comparing catches\n// a folded wall-clock read that two back-to-back replays under one ambient\n// would hide.) The slice comparison alone has a blind spot: a clock/RNG\n// read folded into a wrapper Cmd PAYLOAD (not the slice) leaves the slice\n// identical, so we ALSO compare the `$x:*` Cmds across the two ambients.\n// Legit time enters only as Msg `at` payloads, identical across replays.\n// 3. **Every wrapper decision is in the log.** At least one wrapper-tagged\n// Cmd (`$x:*`) or Msg appears in the replayed Cmd stream whenever there is\n// a transition — the wrapper's decisions are visible, not off-ledger.\n// PLUS a PER-TRANSITION check: at each step the bare machine's step-i Cmds\n// are an ordered subsequence of the wrapped machine's step-i Cmds, so a\n// base Cmd deferred to a LATER transition (intra-window retiming a\n// flattened subsequence would miss) surfaces as a step-level failure.\n// 4. **Slice is JSON-round-trip equal.** `$x` survives\n// `JSON.parse(JSON.stringify(...))` — durable across DO eviction / reload,\n// never a closure.\n//\n// Strengthens invariant 9 (the testing surface is named and small) and is the\n// mechanical CI form of the wrapper-tier conformance gate.\n// ---------------------------------------------------------------------------\n\nimport { expect, vi } from \"vitest\";\nimport { type Cmd, type Machine, replay, type Sub } from \"../index\";\n\n/**\n * The composed Model shape every `withX` wrapper produces: the base machine's\n * state nested under `base`, and the wrapper's own NAMED, serializable slice\n * under a single `$`-prefixed key. This helper does not care WHICH `$`-key the\n * wrapper uses — it discovers it structurally (the one non-`base` field).\n */\nexport type WrapperModel<S> = {\n readonly base: S;\n} & { readonly [K: `$${string}`]: unknown };\n\n/** Options for the conformance replay. Mirrors `replay`'s second argument. */\nexport interface AssertWrapperFaithfulOpts<S, WM, BaseM, BaseCtx, WrapperCtx> {\n /** The Msg sequence to fold through BOTH machines. Use the base's Msgs. */\n readonly msgs: readonly BaseM[];\n /** Ctx for the WRAPPED machine (base ctx + wrapper ports). */\n readonly ctx: WrapperCtx;\n /** Ctx for the BARE base machine. Defaults to `ctx` when omitted. */\n readonly baseCtx?: BaseCtx;\n /** Optional pre-`init` snapshot of the COMPOSED Model (wrapped rehydrate). */\n readonly loaded?: WM | null;\n /**\n * Optional pre-`init` snapshot of the BARE base state. Supply when the\n * wrapped `loaded` is non-null so the base-equivalence check rehydrates the\n * base machine from the matching nested slice. Defaults to `loaded?.base`.\n */\n readonly baseLoaded?: S | null;\n /**\n * Opt-in relaxation for an INTERCEPTING wrapper (e.g. `withResilience`).\n *\n * DEFAULT (`undefined` / `false`) — the OBSERVE-ONLY contract that\n * `withTelemetry` and `withDeadline` satisfy: every bare base Cmd must appear\n * UNCHANGED, in order, as a subsequence of the wrapped Cmd stream (properties\n * 1 and 3b). The wrapper may APPEND its own Cmds but may NOT alter, drop, or\n * retime a base Cmd. This is the strict default and it is NOT weakened.\n *\n * WHEN SET — for a wrapper whose whole job is to INTERCEPT a chosen base Cmd\n * (retag it into a wrapper-owned carrier so the concern — cache / breaker /\n * rate-limit / retry — can gate it), a target base Cmd LEGITIMATELY does not\n * appear raw at the top level of the wrapped stream. The contract is still\n * **retag-and-re-emit, never swallow** (rule 2): the Cmd must be RECORDED, not\n * vanished. So when a bare base Cmd is ABSENT from the top-level wrapped\n * subsequence, this option accepts it IFF, in that SAME transition window, it\n * is recorded by the wrapper as one of:\n *\n * - the inner payload of a `$x:*` \"run\" carrier Cmd (`carrierCmdType` +\n * `innerField`) — the retag path; OR\n * - any other `$x:*` divergence Cmd whose `recordsField` deep-equals the\n * base Cmd — the gate/defer path (e.g. a \"fast-failed\" or \"deferred\"\n * record Cmd that carries the base Cmd it diverged on).\n *\n * A target base Cmd that is NEITHER present raw NOR recorded by any `$x:*`\n * Cmd in its window is a SWALLOW betrayal and still fails the gate.\n *\n * Provide the field names the carrier uses so the gate can unwrap it\n * structurally without hard-coding `withResilience`'s vocabulary.\n */\n readonly intercepting?: InterceptingOpt;\n}\n\n/**\n * Configures the intercepting relaxation (see\n * `AssertWrapperFaithfulOpts.intercepting`). All fields name the carrier /\n * divergence shape so the gate can structurally find a retagged base Cmd\n * inside a `$x:*` Cmd. The gate only EVER inspects `$x:*`-prefixed wrapped\n * Cmds for a recorded base Cmd — it never relaxes the check for a base Cmd\n * that appears under any non-wrapper Cmd type.\n */\nexport interface InterceptingOpt {\n /**\n * The `Cmd.type` of the wrapper's run-carrier (e.g. `\"$resilience:run\"`).\n * A bare base Cmd that is retagged appears as `carrier[innerField]`.\n */\n readonly carrierCmdType: string;\n /** The field on the carrier Cmd that holds the original base Cmd. */\n readonly innerField: string;\n /**\n * OPTIONAL field on ANY OTHER `$x:*` Cmd that records a base Cmd the wrapper\n * gated/deferred without running it (e.g. a fast-fail record). When present\n * on a `$x:*` Cmd and deep-equal to the missing base Cmd, it counts as a\n * recorded divergence. Omit when the wrapper only ever retags via the\n * carrier.\n */\n readonly recordsField?: string;\n}\n\n/**\n * Assert a `withX` wrapper is TEA-faithful. Replays the wrapped machine and the\n * bare base machine over the same Msgs and checks the four conformance\n * properties (see file header).\n *\n * @param base the bare base `Machine`.\n * @param makeWrapped a thunk that wraps `base` and returns the composed machine\n * (e.g. `() => withTelemetry(base, cfg)`). A thunk — not the wrapped value —\n * so a wrapper that registers process-scoped ports (`definePort`) is\n * constructed inside the assertion's control, and so the same betrayal-\n * detector reads as `assertWrapperFaithful(base, () => withX(base, cfg), ...)`\n * at every wrapper's test site.\n * @param opts the conformance replay options.\n */\nexport function assertWrapperFaithful<\n S,\n BaseM extends { type: string },\n BaseC extends Cmd,\n BaseU extends Sub,\n BaseCtx,\n WM extends WrapperModel<S>,\n WrapperM extends { type: string },\n WrapperC extends Cmd,\n WrapperU extends Sub,\n WrapperCtx,\n>(\n base: Machine<S, BaseM, BaseC, BaseU, BaseCtx>,\n makeWrapped: () => Machine<WM, WrapperM, WrapperC, WrapperU, WrapperCtx>,\n opts: AssertWrapperFaithfulOpts<S, WM, BaseM, BaseCtx, WrapperCtx>,\n): void {\n const baseCtx = (opts.baseCtx ?? (opts.ctx as unknown as BaseCtx)) as BaseCtx;\n const wrappedMsgs = opts.msgs as unknown as readonly WrapperM[];\n const baseLoaded =\n opts.baseLoaded ?? (opts.loaded != null ? (opts.loaded.base as S) : null);\n\n // Two DISTINCT global ambients (wall-clock + RNG). `replay` composes only\n // `init` + `update`, and `update` cells are `(state, msg)` — they never\n // receive `ctx`. So an impure update read reaches for the GLOBAL `Date.now()`\n // / `Math.random()`, not an injected clock. Running the two determinism\n // replays under DIFFERENT ambients turns a folded wall-clock read into an\n // OBSERVABLE slice divergence (property 2) — a single fixed ambient (two\n // back-to-back replays) would return the same ms both times and hide it.\n const A0 = { now: 1_000_000, rng: 0.123 };\n const A1 = { now: 9_876_543, rng: 0.987 };\n\n // The bare baseline, `wrappedA`, and every per-transition baseline (props 3/4)\n // run under the SAME fixed ambient A0 so their cmds/state are deterministic.\n const bare = underAmbient(A0, () =>\n replay(base, { msgs: opts.msgs, ctx: baseCtx, loaded: baseLoaded }),\n );\n const wrapped = underAmbient(A0, () => makeWrapped());\n const wrappedA = underAmbient(A0, () =>\n replay(wrapped, {\n msgs: wrappedMsgs,\n ctx: opts.ctx,\n loaded: opts.loaded ?? null,\n }),\n );\n // The second determinism replay runs under a DISTINCT ambient A1. A faithful\n // wrapper's slice (a pure function of the Msg log) is identical under A0 and\n // A1; an impure update that folds `Date.now()` / `Math.random()` diverges.\n const wrappedB = underAmbient(A1, () =>\n replay(makeWrapped(), {\n msgs: wrappedMsgs,\n ctx: opts.ctx,\n loaded: opts.loaded ?? null,\n }),\n );\n\n // --- Property 1: base behavior byte-identical -----------------------------\n // `state.base` after wrapping === state after running the base alone. The\n // wrapper observes; it does not alter base behavior.\n expect(wrappedA.state.base).toEqual(bare.state);\n // The base's OWN Cmds appear in the wrapped Cmd stream unchanged: every bare\n // Cmd is present, in order, among the wrapped Cmds (with wrapper Cmds\n // interleaved). We assert the bare Cmds are a subsequence of the wrapped ones.\n // For an INTERCEPTING wrapper (`opts.intercepting` set) a target base Cmd is\n // accepted when it appears RETAGGED inside a `$x:*` carrier / recorded by a\n // `$x:*` divergence Cmd instead of raw — retag, not swallow.\n expectCmdSubsequence(bare.cmds, wrappedA.cmds, undefined, opts.intercepting);\n\n // --- Property 2: slice reconstructs under any ambient clock/RNG -----------\n // Replaying the same Msgs under a DIFFERENT global ambient yields a deep-equal\n // wrapper SLICE — the slice is a pure function of the Msg log, never of\n // `Date.now()` / `Math.random()`. We compare the single `$`-slice (not the\n // whole composed state) because comparing whole state would FALSE-POSITIVE\n // when the BASE machine reads the clock — that is the base's behavior, not the\n // wrapper's fault, and the wrapper's faithfulness is precisely what its own\n // slice records.\n const sliceKey = wrapperSliceKey(wrappedA.state);\n expect(\n sliceOf(wrappedB.state, sliceKey),\n `wrapper slice changed under a different ambient clock/RNG → update is ` +\n `reading Date.now()/Math.random(); time must enter only as Msg \\`at\\` data`,\n ).toEqual(sliceOf(wrappedA.state, sliceKey));\n\n // ...AND the wrapper-tagged Cmds reconstruct under any ambient too. The slice\n // is only HALF the wrapper's output — the other half is its emitted Cmds. A\n // wall-clock / RNG read folded into a wrapper Cmd PAYLOAD (not the state\n // slice) escapes the slice comparison above: the slice stays identical while\n // the Cmd carries a leaked `Date.now()` / `Math.random()`. So mirror the\n // slice check on the `$x:*` subset of the replayed Cmd stream — a faithful\n // wrapper emits Cmds that are a pure function of the Msg log, identical under\n // A0 and A1. Only Msg `at` payloads (identical across both replays) may carry\n // time; if a wrapper Cmd diverges between ambients, the wrapper read the\n // ambient clock/RNG into a Cmd. (Base Cmds are EXCLUDED — a base machine that\n // reads the clock is the base's behavior, not the wrapper's, exactly as the\n // slice comparison excludes whole-state.)\n const wrapperFamily = `${sliceKey}:`;\n const wrapperCmdsA = wrappedA.cmds.filter((c) =>\n c.type.startsWith(wrapperFamily),\n );\n const wrapperCmdsB = wrappedB.cmds.filter((c) =>\n c.type.startsWith(wrapperFamily),\n );\n expect(\n wrapperCmdsB,\n `wrapper Cmds (\"${wrapperFamily}*\") changed under a different ambient ` +\n `clock/RNG → a wrapper Cmd PAYLOAD is reading Date.now()/Math.random(); ` +\n `wrapper Cmds must be a pure function of the Msg log, time entering only ` +\n `as Msg \\`at\\` data`,\n ).toEqual(wrapperCmdsA);\n\n // --- Property 3: every wrapper decision appears as an XMsg/XCmd in the log -\n // The composed Model's wrapper slice is the single non-`base` `$`-key. We\n // discover its key family (`$telemetry` → `$telemetry:*`) and require that,\n // whenever there is at least one transition, the replayed Cmd stream carries\n // at least one wrapper-tagged Cmd. (Wrappers whose decisions are Msgs route\n // them through the SAME log; for a Cmd-emitting wrapper like withTelemetry the\n // decision is the `$x:emit` Cmd.) A wrapper that performed its work off-ledger\n // would have an EMPTY wrapper-Cmd set here despite real transitions — the\n // exact betrayal this gate exists to catch.\n if (opts.msgs.length > 0) {\n expect(\n wrapperCmdsA.length,\n `expected at least one \"${wrapperFamily}*\" wrapper-decision Cmd in the replay log ` +\n `(found none across ${opts.msgs.length} transition(s)) — a wrapper whose ` +\n `decisions are invisible to the Msg/Cmd log has betrayed total visibility`,\n ).toBeGreaterThan(0);\n }\n\n // --- Property 3b: per-transition Cmd subsequence --------------------------\n // The flattened subsequence (property 1) misses INTRA-WINDOW retiming — a\n // base Cmd that a saga-style wrapper DEFERS to a later transition still drains\n // within the replay, so the flattened bare-Cmd set stays an ordered\n // subsequence and slips through. Pin it per step: for each transition i, the\n // bare machine's step-i Cmds must be an ordered subsequence of the wrapped\n // machine's step-i Cmds. A deferred base Cmd is then visible as a step-i\n // subsequence failure (it shows up at i+1 in the wrapped run but at i in the\n // bare run). Prefix replays run under the fixed ambient A0 for determinism.\n for (let i = 0; i < opts.msgs.length; i++) {\n const bareStep = stepCmds(\n () =>\n underAmbient(A0, () =>\n replay(base, {\n msgs: opts.msgs.slice(0, i),\n ctx: baseCtx,\n loaded: baseLoaded,\n }),\n ).cmds,\n () =>\n underAmbient(A0, () =>\n replay(base, {\n msgs: opts.msgs.slice(0, i + 1),\n ctx: baseCtx,\n loaded: baseLoaded,\n }),\n ).cmds,\n );\n const wrappedStep = stepCmds(\n () =>\n underAmbient(A0, () =>\n replay(wrapped, {\n msgs: wrappedMsgs.slice(0, i),\n ctx: opts.ctx,\n loaded: opts.loaded ?? null,\n }),\n ).cmds,\n () =>\n underAmbient(A0, () =>\n replay(wrapped, {\n msgs: wrappedMsgs.slice(0, i + 1),\n ctx: opts.ctx,\n loaded: opts.loaded ?? null,\n }),\n ).cmds,\n );\n expectCmdSubsequence(bareStep, wrappedStep, i, opts.intercepting);\n }\n\n // --- Property 4: slice is JSON-round-trip equal ---------------------------\n // The wrapper slice survives JSON.parse(JSON.stringify(...)) — durable across\n // DO eviction / reload, never a closure.\n const slice = sliceOf(wrappedA.state, sliceKey);\n expect(JSON.parse(JSON.stringify(slice))).toEqual(slice);\n}\n\n/**\n * Run `fn` with the GLOBAL `Date.now` and `Math.random` stubbed to fixed\n * values, restoring them in a `finally` so the stub never leaks across\n * assertions or tests. `update` cells receive no `ctx`, so an impure read\n * inside one resolves to these globals — the lever this gate pulls to make a\n * folded wall-clock / RNG read observable in the wrapper slice.\n */\nfunction underAmbient<T>(\n ambient: { readonly now: number; readonly rng: number },\n fn: () => T,\n): T {\n const nowSpy = vi.spyOn(Date, \"now\").mockReturnValue(ambient.now);\n const rngSpy = vi.spyOn(Math, \"random\").mockReturnValue(ambient.rng);\n try {\n return fn();\n } finally {\n nowSpy.mockRestore();\n rngSpy.mockRestore();\n }\n}\n\n/** The wrapper slice value (the single `$`-key) on a composed Model. */\nfunction sliceOf(model: object, sliceKey: string): unknown {\n return (model as Record<string, unknown>)[sliceKey];\n}\n\n/**\n * The Cmds a single transition `i` emitted: the suffix of the cmds after\n * `msgs.slice(0, i+1)` past the cmds after `msgs.slice(0, i)`. Cmds accumulate\n * in order across `replay`, so the longer run is a prefix-extension of the\n * shorter one and the suffix is exactly step `i`'s contribution.\n */\nfunction stepCmds(\n prefixCmds: () => readonly Cmd[],\n throughCmds: () => readonly Cmd[],\n): readonly Cmd[] {\n const before = prefixCmds();\n const after = throughCmds();\n return after.slice(before.length);\n}\n\n/**\n * The wrapper slice key on a composed Model — the single own enumerable field\n * whose name starts with `$`. Throws if zero or more than one is found, because\n * the wrapper-tier contract is exactly one named `$`-slice per wrapper.\n */\nfunction wrapperSliceKey(model: object): string {\n const dollarKeys = Object.keys(model).filter((k) => k.startsWith(\"$\"));\n if (dollarKeys.length !== 1) {\n throw new Error(\n `assertWrapperFaithful: expected exactly one \"$\"-prefixed wrapper slice ` +\n `on the composed Model, found ${dollarKeys.length} (${dollarKeys.join(\", \") || \"none\"}). ` +\n `Every withX wrapper owns exactly one named slice (e.g. \"$telemetry\").`,\n );\n }\n // biome-ignore lint/style/noNonNullAssertion: length checked to be exactly 1 above\n return dollarKeys[0]!;\n}\n\n/**\n * Assert `needle` is an (order-preserving) subsequence of `haystack` by deep\n * equality — every base Cmd appears, in order, somewhere in the wrapped Cmd\n * stream (wrapper Cmds may be interleaved). This is the \"base Cmds pass through\n * UNCHANGED\" check that tolerates the wrapper's own appended Cmds without\n * requiring an exact-equal stream. When `step` is supplied the message names\n * the transition index, so a per-transition retiming failure points at the\n * exact step a base Cmd was deferred away from.\n *\n * `intercepting` (default `undefined` → the strict OBSERVE-ONLY check above)\n * relaxes the match for a base Cmd that an INTERCEPTING wrapper retags: when a\n * needle Cmd is NOT found raw in `haystack`, it is accepted IFF some `$x:*`\n * wrapper Cmd in `haystack` RECORDS it — as the carrier's `innerField` payload\n * (retag) or another `$x:*` Cmd's `recordsField` (recorded gate/defer). The\n * relaxation ONLY ever looks inside `$x:*` Cmds, so a base Cmd that vanished\n * with no `$x:*` record still fails. The order check is preserved: the carrier\n * / divergence Cmd must come at or after the cursor, exactly like a raw match.\n */\nfunction expectCmdSubsequence(\n needle: readonly Cmd[],\n haystack: readonly Cmd[],\n step?: number,\n intercepting?: InterceptingOpt,\n): void {\n let i = 0;\n for (const cmd of haystack) {\n if (i >= needle.length) break;\n if (__deepEqual(needle[i], cmd)) {\n i++;\n continue;\n }\n // Intercepting relaxation: the base Cmd at the cursor may legitimately be\n // absent raw because the wrapper RETAGGED it. Accept this haystack Cmd as\n // the matching slot IFF it is a `$x:*` wrapper Cmd that records `needle[i]`.\n if (\n intercepting !== undefined &&\n recordsBaseCmd(cmd, needle[i] as Cmd, intercepting)\n ) {\n i++;\n }\n }\n const where =\n step === undefined\n ? \"the wrapped Cmd stream\"\n : `the wrapped Cmd stream AT TRANSITION ${step} (a base Cmd deferred to a ` +\n `later transition is an intra-window retiming betrayal)`;\n const swallowHint =\n intercepting === undefined\n ? \"a missing/rewritten/retimed base Cmd is a swallow betrayal\"\n : `an intercepting wrapper must RETAG each target base Cmd into a ` +\n `\"${intercepting.carrierCmdType}\" carrier (inner field ` +\n `\"${intercepting.innerField}\") or record it on a \"$*:\" divergence Cmd ` +\n `— a base Cmd neither present raw NOR recorded by any \"$*:\" Cmd is a ` +\n `swallow betrayal`;\n expect(\n i,\n `expected every base Cmd to pass through unchanged (matched ${i} of ` +\n `${needle.length} base Cmds as an ordered subsequence of ${where}) — ` +\n `${swallowHint}`,\n ).toBe(needle.length);\n}\n\n/**\n * Does the wrapped Cmd `cmd` RECORD the base Cmd `baseCmd` under the\n * intercepting contract? True iff `cmd` is a `$`-prefixed wrapper Cmd AND\n * either:\n * - `cmd.type === carrierCmdType` and `cmd[innerField]` deep-equals\n * `baseCmd` (the retag carrier), OR\n * - `recordsField` is configured and `cmd[recordsField]` deep-equals\n * `baseCmd` (a recorded gate/defer divergence on any `$x:*` Cmd).\n *\n * The `$`-prefix guard is load-bearing: the relaxation must NEVER accept a base\n * Cmd hidden inside a NON-wrapper Cmd — that would let a wrapper launder a\n * swallowed base Cmd through an arbitrary re-emit. Only the wrapper's own\n * `$x:*` family may carry a retagged base Cmd.\n */\nfunction recordsBaseCmd(cmd: Cmd, baseCmd: Cmd, opt: InterceptingOpt): boolean {\n if (!cmd.type.startsWith(\"$\")) return false;\n const rec = cmd as unknown as Record<string, unknown>;\n if (\n cmd.type === opt.carrierCmdType &&\n __deepEqual(rec[opt.innerField], baseCmd)\n )\n return true;\n if (\n opt.recordsField !== undefined &&\n __deepEqual(rec[opt.recordsField], baseCmd)\n )\n return true;\n return false;\n}\n\n/**\n * Structural deep equality for plain Cmd data.\n *\n * NOT `JSON.stringify` equality: `JSON.stringify` DROPS undefined-valued fields,\n * so `{ type: \"x\" }` would falsely equal `{ type: \"x\", foo: undefined }` and the\n * gate could accept a wrapper that smuggles an extra (undefined) field into a\n * \"byte-identical\" base Cmd or a retag carrier. This walk distinguishes an\n * ABSENT key from an `undefined`-VALUED key by comparing the full own-enumerable\n * key SET (not just the defined values) in both directions, then recursing.\n *\n * Cmds are plain data — primitives, `null`, arrays, and plain objects — so this\n * intentionally does not model `Date`, `Map`, `Set`, cycles, or class instances.\n *\n * Exported under the `__` test-only convention so the conformance suite can\n * pin the absent-vs-undefined distinction directly. Not part of the public API.\n *\n * @internal test-only\n */\nexport function __deepEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n\n // Past the identity check, equality requires same kind on both sides. Anything\n // non-object (primitive, function, symbol) that wasn't `Object.is`-equal above\n // is unequal. `null` is `typeof \"object\"` but only equals `null` (caught by\n // `Object.is`), so screen it out explicitly.\n if (\n typeof a !== \"object\" ||\n typeof b !== \"object\" ||\n a === null ||\n b === null\n ) {\n return false;\n }\n\n const aIsArray = Array.isArray(a);\n if (aIsArray !== Array.isArray(b)) return false;\n\n if (aIsArray) {\n const bArr = b as unknown[];\n if (a.length !== bArr.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (!__deepEqual(a[i], bArr[i])) return false;\n }\n return true;\n }\n\n // Plain objects: compare the own-enumerable key SET first so a key present on\n // one side with an `undefined` value (and absent on the other) is caught —\n // the betrayal `JSON.stringify` hid. Then recurse on every value.\n const aRec = a as Record<string, unknown>;\n const bRec = b as Record<string, unknown>;\n const aKeys = Object.keys(aRec);\n const bKeys = Object.keys(bRec);\n if (aKeys.length !== bKeys.length) return false;\n for (const key of aKeys) {\n if (!Object.hasOwn(bRec, key)) return false;\n if (!__deepEqual(aRec[key], bRec[key])) return false;\n }\n return true;\n}\n","// ---------------------------------------------------------------------------\n// Test-side assertions over `replay`. Each helper composes the replay call\n// with a single `expect(...)` so consumers stop hand-rolling the 5-line\n// \"destructure { state, cmds } → expect.toBe / toEqual / toContainEqual\"\n// boilerplate at every test site.\n//\n// Each helper is a thin wrapper that:\n// 1. Calls `replay(machine, opts)` once.\n// 2. Pipes the result into a single vitest `expect(...)` matcher.\n//\n// All helpers return `void` — assertions throw on failure (vitest contract).\n// No mutation of the machine or opts. Pure test ergonomics.\n//\n// Type-inference note: each helper anchors its generic parameters to the\n// `machine` argument. The `expected` (and `opts.msgs`) arguments are wrapped\n// in `NoInfer<...>` so they do NOT participate in inference — otherwise a\n// `[]`-shaped `expected` would force `C = never` and reject a machine whose\n// real Cmd union is non-empty. Anchoring inference to the machine is the\n// same discipline `replay` uses (it has nothing but the machine and opts).\n//\n// Strengthens invariant 9 (the testing surface is named, small, and forks\n// nothing of the substrate's purity guarantees).\n// ---------------------------------------------------------------------------\n\nimport { expect } from \"vitest\";\nimport { type Cmd, type Machine, replay, type Sub } from \"../index\";\n\n// `NoInfer<T>` is the built-in TypeScript 5.4+ intrinsic that blocks\n// inference from a generic parameter at a position. We use it on `expected`\n// and `opts` so inference flows purely FROM the machine — `[]`-shaped\n// `expected` no longer drags `C` down to `never` and rejects the machine.\n\n/**\n * Shared options shape for every test assertion below. Mirrors the\n * second argument of `replay(machine, opts)` — `msgs` is the sequence to\n * fold over (may be empty for init-only assertions), `ctx` is the\n * substrate-required ctx value, `loaded` is the optional pre-`init`\n * snapshot (omit / pass `null` for fresh boot).\n */\nexport interface ReplayOpts<S, M, Ctx> {\n readonly msgs: readonly M[];\n readonly ctx: Ctx;\n readonly loaded?: S | null;\n}\n\n/**\n * Assert the final state after replaying `opts.msgs` equals `expected`.\n * Replaces the boilerplate:\n *\n * const { state } = replay(machine, opts);\n * expect(state).toEqual(expected);\n *\n * Uses `toEqual` (deep structural). For type-narrowing assertions that\n * branch on `state.type` afterwards, fall back to plain `replay` —\n * `expectFinalState` is the \"exact match\" tool.\n */\nexport function expectFinalState<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n>(\n machine: Machine<S, M, C, U, Ctx>,\n opts: NoInfer<ReplayOpts<S, M, Ctx>>,\n expected: NoInfer<S>,\n): void {\n const { state } = replay(machine, opts);\n expect(state).toEqual(expected);\n}\n\n/**\n * Assert that `cmd` appears at least once in the cmds array produced by\n * replaying `opts.msgs`. Uses `toContainEqual` (deep structural). Order\n * and surrounding cmds are not asserted — use `expectCmdSequence` for\n * exact ordered match.\n *\n * Replaces:\n *\n * const { cmds } = replay(machine, opts);\n * expect(cmds).toContainEqual(cmd);\n */\nexport function expectCmdEmitted<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n>(\n machine: Machine<S, M, C, U, Ctx>,\n opts: NoInfer<ReplayOpts<S, M, Ctx>>,\n cmd: NoInfer<C>,\n): void {\n const { cmds } = replay(machine, opts);\n expect(cmds).toContainEqual(cmd);\n}\n\n/**\n * Assert the exact ordered sequence of cmds emitted by replaying\n * `opts.msgs`. Uses `toEqual` against the full cmds array — extra cmds\n * fail the assertion, missing cmds fail the assertion, wrong order\n * fails the assertion.\n *\n * Replaces:\n *\n * const { cmds } = replay(machine, opts);\n * expect(cmds).toEqual(expected);\n */\nexport function expectCmdSequence<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n>(\n machine: Machine<S, M, C, U, Ctx>,\n opts: NoInfer<ReplayOpts<S, M, Ctx>>,\n expected: NoInfer<readonly C[]>,\n): void {\n const { cmds } = replay(machine, opts);\n expect(cmds).toEqual(expected);\n}\n\n/**\n * Assert the exact set of subs desired at the final state after\n * replaying `opts.msgs`. Uses `toEqual` against the full subs array.\n *\n * Replaces:\n *\n * const { subs } = replay(machine, opts);\n * expect(subs).toEqual(expected);\n */\nexport function expectActiveSubs<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n>(\n machine: Machine<S, M, C, U, Ctx>,\n opts: NoInfer<ReplayOpts<S, M, Ctx>>,\n expected: NoInfer<readonly U[]>,\n): void {\n const { subs } = replay(machine, opts);\n expect(subs).toEqual(expected);\n}\n\n/**\n * Single-msg step helper — feeds `loaded → msg → next state + cmds emitted by\n * that msg`. Returns a readonly tuple in the shape consumers used before the\n * substrate (`[state, cmds]`), so existing tests that destructure with\n * `[next, cmds]` can swap `reduce(state, msg)` for `step(machine, state, msg,\n * ctx)` without changing the assertion code.\n *\n * Internally a `replay` call with `loaded: prevState` and a single-element\n * `msgs` array. The cmds returned are exactly the cmds emitted by THIS msg\n * (init emits no cmds when `loaded` is provided, so the slice is the entire\n * array).\n *\n * Use when consumers want to walk a machine one msg at a time and assert per\n * step. For one-shot \"final state after N msgs\" assertions, prefer\n * `expectFinalState`.\n */\nexport function step<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n>(\n machine: Machine<S, M, C, U, Ctx>,\n loaded: NoInfer<S>,\n msg: NoInfer<M>,\n ctx: NoInfer<Ctx>,\n): readonly [S, readonly C[]] {\n const { state, cmds } = replay(machine, { msgs: [msg], ctx, loaded });\n return [state, cmds] as const;\n}\n","// ---------------------------------------------------------------------------\n// `bindMachine(machine, ctx)` — bound test harness over the free-function\n// assertions in `./assertions.ts`. Closes over the `machine` and `ctx` once\n// so per-test callsites stop repeating both at every invocation.\n//\n// Why this exists: every consumer test file ends up hand-rolling a local\n// two-arg `step(state, msg)` wrapper around `step(machine, state, msg, ctx)`,\n// and the four `expect*` assertions repeat `machine` + `ctx` at every\n// callsite. The bound form pulls both into one place and gives every\n// per-test call its tightest possible shape (2-arg max).\n//\n// `bindMachine` is built ON TOP of the free helpers — it does not replace\n// them. Both forms coexist; pick the one that fits the call site:\n//\n// - Free form → one-off call inside a helper that isn't bound to one\n// machine (e.g. cross-machine integration test).\n// - Bound form → a `describe` block runs many assertions against one\n// machine + ctx. The bound form is the common case.\n//\n// Strengthens invariant 9 (the testing surface is named, small, and forks\n// nothing of the substrate's purity guarantees).\n// ---------------------------------------------------------------------------\n\nimport { expect } from \"vitest\";\nimport { type Cmd, type Machine, replay, type Sub } from \"../index\";\n\n/**\n * Replay options shape used by every bound method. `ctx` is captured by\n * `bindMachine`; the per-call opts only need `msgs` and an optional\n * `loaded` snapshot. (Compare `ReplayOpts` in `./assertions.ts`, which\n * still takes `ctx` because the free helpers cannot capture it.)\n */\ninterface BoundOpts<S, M> {\n readonly msgs: readonly M[];\n readonly loaded?: S | null;\n}\n\n/**\n * The bound testing surface. Every method is 2-arg max — `ctx` and\n * `machine` are captured by `bindMachine`.\n *\n * `NoInfer<...>` on `expected` / `cmd` arguments mirrors the discipline\n * the free helpers use (see `./assertions.ts`): inference flows purely\n * FROM the machine, so a `[]`-shaped expected does not drag `C` down to\n * `never` and reject the machine.\n */\nexport interface BoundMachine<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n // `Ctx` is a phantom-style parameter — present for consumers that want to\n // spell `BoundMachine<S, M, C, U, Ctx>` explicitly, mirroring `Machine`.\n // biome-ignore lint/correctness/noUnusedVariables: phantom type param (see above)\n Ctx,\n> {\n /**\n * Single-msg step — feeds `loaded → msg → [next state, cmds emitted by\n * that msg]`. Mirrors the free `step(machine, loaded, msg, ctx)`.\n */\n step(loaded: S, msg: M): readonly [S, readonly C[]];\n /**\n * Assert the final state after replaying `opts.msgs` deep-equals\n * `expected`. Mirrors the free `expectFinalState(machine, opts, expected)`.\n */\n expectFinalState(opts: BoundOpts<S, M>, expected: NoInfer<S>): void;\n /**\n * Assert `cmd` appears at least once in the emitted cmd list. Order is\n * not asserted. Mirrors the free `expectCmdEmitted(machine, opts, cmd)`.\n */\n expectCmdEmitted(opts: BoundOpts<S, M>, cmd: NoInfer<C>): void;\n /**\n * Assert the exact ordered sequence of cmds emitted by replaying\n * `opts.msgs`. Mirrors the free `expectCmdSequence(machine, opts, expected)`.\n */\n expectCmdSequence(\n opts: BoundOpts<S, M>,\n expected: readonly NoInfer<C>[],\n ): void;\n /**\n * Assert the exact set of subs desired at the final state. Mirrors the\n * free `expectActiveSubs(machine, opts, expected)`.\n */\n expectActiveSubs(\n opts: BoundOpts<S, M>,\n expected: readonly NoInfer<U>[],\n ): void;\n /**\n * Bound `replay` — returns `{ state, cmds, subs }` for the given opts.\n * Use for the \"narrow-then-assert\" pattern where the test inspects a\n * specific field after `state.type === \"...\"` discrimination.\n */\n replay(opts: BoundOpts<S, M>): {\n state: S;\n cmds: readonly C[];\n subs: readonly U[];\n };\n}\n\n/**\n * Bind a machine + ctx into a small bag of 2-arg helpers. Each method\n * delegates to `replay(machine, { ...opts, ctx })` and pipes the result\n * through a single `expect(...)` matcher (or returns the raw tuple, for\n * `step` and `replay`).\n *\n * Use one bind per `describe` block (or per file) when many assertions\n * share the same machine + ctx. For one-off cross-machine calls, stick\n * with the free helpers from `./assertions.ts`.\n */\nexport function bindMachine<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n>(machine: Machine<S, M, C, U, Ctx>, ctx: Ctx): BoundMachine<S, M, C, U, Ctx> {\n return {\n step(loaded, msg) {\n const { state, cmds } = replay(machine, { msgs: [msg], ctx, loaded });\n return [state, cmds] as const;\n },\n expectFinalState(opts, expected) {\n const { state } = replay(machine, { ...opts, ctx });\n expect(state).toEqual(expected);\n },\n expectCmdEmitted(opts, cmd) {\n const { cmds } = replay(machine, { ...opts, ctx });\n expect(cmds).toContainEqual(cmd);\n },\n expectCmdSequence(opts, expected) {\n const { cmds } = replay(machine, { ...opts, ctx });\n expect(cmds).toEqual(expected);\n },\n expectActiveSubs(opts, expected) {\n const { subs } = replay(machine, { ...opts, ctx });\n expect(subs).toEqual(expected);\n },\n replay(opts) {\n return replay(machine, { ...opts, ctx });\n },\n };\n}\n","// ---------------------------------------------------------------------------\n// noopRuntime — a Runtime<S, M>-shaped value whose every method is inert.\n//\n// The motivating callsite: a machine's `ctx` requires a sibling Runtime<S,\n// M> reference (e.g. the queue runtime in extension/lib/queue-machine\n// reaches into an `auditRuntime: Runtime<...>` slot on its ctx so its\n// interpret handlers can dispatch into the audit machine). When the test\n// replays such a machine, `replay` never actually invokes `interpret`, so\n// the runtime reference is never dereferenced — but the type system\n// still requires a value of `Runtime<S, M>` shape at the ctx slot. Tests\n// today work around this with a hand-rolled 12-line NOOP_AUDIT_RUNTIME\n// const cast through `as unknown as Runtime<...>`.\n//\n// `noopRuntime<S, M>()` is that hand-roll, named once. It returns a real\n// Runtime<S, M> value whose every method is a structurally-correct no-op:\n//\n// - `dispatch`: resolves immediately, never advances state.\n// - `getState`: returns the optional `initialState` argument (or a\n// deliberate `undefined` cast as S — the function lies about its\n// return type when no initial state is provided; this is the trade-off\n// we accept for an ergonomic test substrate).\n// - `subscribe` / `observe` / `subscribePort`: register the listener,\n// return a no-op unsubscribe. The listener is never fired because the\n// state never changes.\n// - `emitPort`: no-op.\n// - `ready`: a Promise that resolves to the no-op runtime itself (the #45\n// `ready: Promise<Runtime<S, M>>` shape — already booted, nothing to wait\n// for).\n// - `stop`: resolved Promise<void>.\n//\n// Strengthens invariant 9 (the testing surface is named and small).\n// ---------------------------------------------------------------------------\n\nimport type { Port, Runtime } from \"../index\";\n\n/**\n * Construct an inert `Runtime<S, M>` value. Use at ctx sites that require\n * a Runtime reference but where the test never invokes `interpret` (so\n * the runtime is never dereferenced in practice).\n *\n * @param opts.initialState Optional value returned by `getState()`. Omit\n * when the test never calls `getState()` on the no-op runtime — most\n * tests only need the type-level slot filled.\n */\nexport function noopRuntime<S, M extends { type: string }>(opts?: {\n initialState?: S;\n}): Runtime<S, M> {\n const initialState = opts?.initialState;\n // Single source of truth for the \"do-nothing\" unsubscribe so multiple\n // subscribe call sites share the same function instance — purely cosmetic\n // (the function would be a no-op either way).\n const noopUnsubscribe = (): void => {};\n const runtime: Runtime<S, M> = {\n async dispatch(_msg: M): Promise<void> {\n // Resolves immediately. State never advances; listeners never fire.\n // Quiescent by default (#50), but the no-op has no follow-up chain to\n // drain, so single-step and run-to-quiescence collapse to the same no-op.\n },\n async dispatchOnce(_msg: M): Promise<void> {\n // Single-step sibling of `dispatch` (#50). Same no-op for the no-op\n // runtime — there is no tail to leave in flight.\n },\n async idle(): Promise<void> {\n // No tail to drain — the no-op runtime never enqueues a follow-up.\n },\n result(): S | undefined {\n // The no-op runtime never advances, so it is never terminal (#46).\n return undefined;\n },\n done(): Promise<S> {\n // Never terminal → the awaitable never settles, matching `run()` with no\n // `terminal` predicate. Returned as a never-resolving promise.\n return new Promise<S>(() => {});\n },\n getState(): S {\n // Lie if no initial state was provided. The caller's contract is\n // \"you accept the lie because you know replay never invokes\n // interpret and therefore never reads this.\" When the caller DOES\n // pass an initialState the lie collapses to truth.\n return initialState as S;\n },\n subscribe(_listener: () => void): () => void {\n return noopUnsubscribe;\n },\n observe(_observer: (msg: M, state: S) => void): () => void {\n return noopUnsubscribe;\n },\n onBoot(_handler: (state: S) => void): () => void {\n // Boot never fires on the inert runtime — it is \"already booted\" with no\n // initial fanout, so the handler is registered and never called (#47).\n return noopUnsubscribe;\n },\n on<K extends never>(\n _type: K,\n _handler: (event: never) => void,\n ): () => void {\n // The no-op runtime's event surface is `never` (no `events` projector),\n // so `on` is structurally present but uncallable — there is no `K` to\n // pass. The body is unreachable; it returns the shared no-op unsubscribe.\n return noopUnsubscribe;\n },\n subscribePort<T>(\n _port: Port<T>,\n _listener: (value: T) => void,\n ): () => void {\n return noopUnsubscribe;\n },\n emitPort<T>(_port: Port<T>, _value: T): void {\n // No-op. No subscribers to fan out to; nothing to do.\n },\n // Assigned just below — `ready` must resolve to `runtime` itself, which\n // can't be referenced inside its own object literal.\n ready: undefined as unknown as Promise<Runtime<S, M>>,\n async stop(): Promise<void> {\n // Resolves immediately. No in-flight tail to drain, no subs to clean.\n },\n };\n // Already \"booted\" — `ready` hands back the same runtime synchronously.\n runtime.ready = Promise.resolve(runtime);\n return runtime;\n}\n","// ---------------------------------------------------------------------------\n// stateFactory — typed phase-constructor API for a discriminated-union State.\n//\n// The motivating callsite: every reducer test today opens with ~60–80 lines\n// of hand-rolled factory functions, one per phase, each one's defaults\n// duplicated across files:\n//\n// function idleState() { return { type: \"idle\" }; }\n// function creatingWindowState(overrides?: Partial<...>) {\n// return { type: \"creating_window\", auditId: ..., wsUrl: ..., ...overrides };\n// }\n// ...\n//\n// `stateFactory<BackgroundState>({...})` collapses the whole block to one\n// declaration: pass each phase's REQUIRED defaults once (the type system\n// enforces every phase has an entry), and the helper builds an API of\n// `factory.idle()`, `factory.creating_window({...})`, etc.\n//\n// Two type-level guarantees:\n//\n// 1. Every phase has a defaults entry — `StateFactoryDefaults<S>` is a\n// mapped type keyed by every `S[\"type\"]`. Missing an entry is a\n// compile error (the @ts-expect-error in testing.spec.ts pins this).\n//\n// 2. Each phase's defaults match that phase's required shape minus the\n// `type` discriminator. Passing wrong fields fails to compile.\n//\n// The runtime is pure data:\n//\n// api[k] = (overrides) => ({\n// type: k,\n// ...defaults[k],\n// ...stripUndefined(overrides ?? {}),\n// })\n//\n// The `stripUndefined` pass is what preserves `exactOptionalPropertyTypes`\n// assignability — without it, calling `factory.creating_window({\n// queueItemId: undefined })` would land an explicit `queueItemId: undefined`\n// on the object, which is NOT assignable to `queueItemId?: string` under\n// `exactOptionalPropertyTypes`. Stripping undefineds before spread keeps\n// the boundary clean.\n//\n// `stripUndefined` is inlined (not imported from a shared stdlib) so this\n// package can stay dep-free of stdlib.\n// ---------------------------------------------------------------------------\n\n/** A factory-constructed phase: `S` narrowed to the arm whose discriminator equals `K`. */\ntype StateOf<S, K> = Extract<S, { type: K }>;\n\n/** A factory-constructed phase with the `type` discriminator removed — the \"fields the caller cares about\" half. */\ntype RequiredFields<T> = Omit<T, \"type\">;\n\n/**\n * Defaults shape passed to `stateFactory`. Mapped type over the discriminant\n * set: every phase MUST have an entry, and that entry MUST match the phase's\n * required fields minus the `type` discriminator.\n */\nexport type StateFactoryDefaults<S extends { type: string }> = {\n readonly [K in S[\"type\"]]: RequiredFields<StateOf<S, K>>;\n};\n\n/**\n * The API returned by `stateFactory`. One method per phase; calling it with\n * no args returns the default snapshot, calling it with a partial overrides\n * object merges those overrides in (with undefineds stripped — see\n * stripUndefined below).\n */\nexport type StateFactoryAPI<S extends { type: string }> = {\n readonly [K in S[\"type\"]]: (\n overrides?: Partial<RequiredFields<StateOf<S, K>>>,\n ) => StateOf<S, K>;\n};\n\n/**\n * Strip own-enumerable properties whose value is `undefined`. Used inside\n * the factory's spread chain so callers can pass `{ queueItemId: undefined }`\n * without the explicit-undefined landing on the result object (which would\n * fail to assign to a `queueItemId?: string` field under\n * `exactOptionalPropertyTypes`).\n *\n * Inlined (not imported from `a shared stdlib`) so `@demlik/tea/testing` can stay\n * dependency-free of stdlib. The 8-line cost of duplication is cheaper than\n * a package-graph edge.\n */\nfunction stripUndefined<T extends object>(obj: T): Partial<T> {\n const out: Partial<T> = {};\n for (const key of Object.keys(obj) as (keyof T)[]) {\n const value = obj[key];\n if (value !== undefined) {\n out[key] = value;\n }\n }\n return out;\n}\n\n/**\n * Build a typed phase-constructor API from per-phase defaults. The defaults\n * object MUST have one entry per `S[\"type\"]` discriminant; the returned API\n * has one method per phase. Each method merges the defaults with optional\n * overrides (undefineds stripped), then stamps the `type` discriminator.\n *\n * @example\n * type S = { type: \"a\"; n: number } | { type: \"b\"; s: string };\n * const f = stateFactory<S>({ a: { n: 0 }, b: { s: \"\" } });\n * f.a(); // { type: \"a\", n: 0 }\n * f.a({ n: 42 }); // { type: \"a\", n: 42 }\n * f.b({ s: \"hi\" }); // { type: \"b\", s: \"hi\" }\n */\nexport function stateFactory<S extends { type: string }>(\n defaults: StateFactoryDefaults<S>,\n): StateFactoryAPI<S> {\n // Build the API by walking the defaults' own keys. Each key corresponds\n // to one phase discriminator; the constructor closes over both the key\n // (for the `type` stamp) and that phase's defaults snapshot.\n const api = {} as { [k: string]: (overrides?: object) => unknown };\n for (const key of Object.keys(\n defaults,\n ) as (keyof StateFactoryDefaults<S>)[]) {\n const phaseDefaults = defaults[key];\n api[key as string] = (overrides?: object) => {\n // The strip-undefined pass lives here, not at the caller. See the\n // module header for the `exactOptionalPropertyTypes` rationale.\n const cleanedOverrides = overrides ? stripUndefined(overrides) : {};\n return { type: key, ...phaseDefaults, ...cleanedOverrides };\n };\n }\n return api as StateFactoryAPI<S>;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/testing/assert-wrapper-faithful.ts","../../src/testing/assertions.ts","../../src/testing/bind-machine.ts","../../src/testing/noop-runtime.ts","../../src/testing/state-factory.ts"],"names":["step","expect"],"mappings":";;;AAiJO,SAAS,qBAAA,CAYd,IAAA,EACA,WAAA,EACA,IAAA,EACM;AACN,EAAA,MAAM,OAAA,GAAW,IAAA,CAAK,OAAA,IAAY,IAAA,CAAK,GAAA;AACvC,EAAA,MAAM,cAAc,IAAA,CAAK,IAAA;AACzB,EAAA,MAAM,UAAA,GACJ,KAAK,UAAA,KAAe,IAAA,CAAK,UAAU,IAAA,GAAQ,IAAA,CAAK,OAAO,IAAA,GAAa,IAAA,CAAA;AAStE,EAAA,MAAM,EAAA,GAAK,EAAE,GAAA,EAAK,GAAA,EAAW,KAAK,KAAA,EAAM;AACxC,EAAA,MAAM,EAAA,GAAK,EAAE,GAAA,EAAK,OAAA,EAAW,KAAK,KAAA,EAAM;AAIxC,EAAA,MAAM,IAAA,GAAO,YAAA;AAAA,IAAa,EAAA;AAAA,IAAI,MAC5B,MAAA,CAAO,IAAA,EAAM,EAAE,IAAA,EAAM,IAAA,CAAK,IAAA,EAAM,GAAA,EAAK,OAAA,EAAS,MAAA,EAAQ,UAAA,EAAY;AAAA,GACpE;AACA,EAAA,MAAM,OAAA,GAAU,YAAA,CAAa,EAAA,EAAI,MAAM,aAAa,CAAA;AACpD,EAAA,MAAM,QAAA,GAAW,YAAA;AAAA,IAAa,EAAA;AAAA,IAAI,MAChC,OAAO,OAAA,EAAS;AAAA,MACd,IAAA,EAAM,WAAA;AAAA,MACN,KAAK,IAAA,CAAK,GAAA;A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AAM,gBAAA,GAAmB,SAAA,GAAY,cAAA,CAAe,SAAS,IAAI,EAAC;AAClE,MAAA,OAAO,EAAE,IAAA,EAAM,GAAA,EAAK,GAAG,aAAA,EAAe,GAAG,gBAAA,EAAiB;AAAA,IAC5D,CAAA;AAAA,EACF;AACA,EAAA,OAAO,GAAA;AACT","file":"index.js","sourcesContent":["// ---------------------------------------------------------------------------\n// `assertWrapperFaithful` — the shared conformance gate for the wrapper tier.\n//\n// A `withX` wrapper bolts a cross-cutting concern (telemetry, deadline,\n// resilience) onto a base machine as an AUTHORING property — the base's source\n// never hand-wires it. The DANGER is the runtime betrayal: hiding wrapper state\n// in a closure, or silently swallowing / retiming a base Cmd, so the wrapper's\n// behavior is invisible to the reducer + Msg log. This helper is the binary\n// betrayal-detector every wrapper inherits. Pass = TEA-faithful, ship it.\n// Fail = betrayal, does not merge.\n//\n// It asserts, by `replay` (which composes `init` + `update` only — the\n// conformance path):\n//\n// 1. **Base behavior byte-identical.** `replay(wrapped).state.base` deep-\n// equals `replay(base).state`. The wrapper never alters base behavior.\n// 2. **Slice AND wrapper Cmds reconstruct under any ambient clock/RNG.**\n// Replaying the SAME msgs under a DIFFERENT global wall-clock + RNG yields\n// a deep-equal wrapper slice AND a deep-equal `$x:*` wrapper-Cmd subset —\n// BOTH halves of the wrapper's output (state slice + emitted Cmds) are a\n// pure function of the Msg log, NOT of `Date.now()` / `Math.random()`.\n// (`update` cells never receive `ctx`, so an impure update read reaches for\n// the GLOBAL ambient; stubbing two distinct ambients and comparing catches\n// a folded wall-clock read that two back-to-back replays under one ambient\n// would hide.) The slice comparison alone has a blind spot: a clock/RNG\n// read folded into a wrapper Cmd PAYLOAD (not the slice) leaves the slice\n// identical, so we ALSO compare the `$x:*` Cmds across the two ambients.\n// Legit time enters only as Msg `at` payloads, identical across replays.\n// 3. **Every wrapper decision is in the log.** At least one wrapper-tagged\n// Cmd (`$x:*`) or Msg appears in the replayed Cmd stream whenever there is\n// a transition — the wrapper's decisions are visible, not off-ledger.\n// PLUS a PER-TRANSITION check: at each step the bare machine's step-i Cmds\n// are an ordered subsequence of the wrapped machine's step-i Cmds, so a\n// base Cmd deferred to a LATER transition (intra-window retiming a\n// flattened subsequence would miss) surfaces as a step-level failure.\n// 4. **Slice is JSON-round-trip equal.** `$x` survives\n// `JSON.parse(JSON.stringify(...))` — durable across DO eviction / reload,\n// never a closure.\n//\n// Strengthens invariant 9 (the testing surface is named and small) and is the\n// mechanical CI form of the wrapper-tier conformance gate.\n// ---------------------------------------------------------------------------\n\nimport { expect, vi } from \"vitest\";\nimport { type Cmd, type Machine, replay, type Sub } from \"../index\";\n\n/**\n * The composed Model shape every `withX` wrapper produces: the base machine's\n * state nested under `base`, and the wrapper's own NAMED, serializable slice\n * under a single `$`-prefixed key. This helper does not care WHICH `$`-key the\n * wrapper uses — it discovers it structurally (the one non-`base` field).\n */\nexport type WrapperModel<S> = {\n readonly base: S;\n} & { readonly [K: `$${string}`]: unknown };\n\n/** Options for the conformance replay. Mirrors `replay`'s second argument. */\nexport interface AssertWrapperFaithfulOpts<S, WM, BaseM, BaseCtx, WrapperCtx> {\n /** The Msg sequence to fold through BOTH machines. Use the base's Msgs. */\n readonly msgs: readonly BaseM[];\n /** Ctx for the WRAPPED machine (base ctx + wrapper ports). */\n readonly ctx: WrapperCtx;\n /** Ctx for the BARE base machine. Defaults to `ctx` when omitted. */\n readonly baseCtx?: BaseCtx;\n /** Optional pre-`init` snapshot of the COMPOSED Model (wrapped rehydrate). */\n readonly loaded?: WM | null;\n /**\n * Optional pre-`init` snapshot of the BARE base state. Supply when the\n * wrapped `loaded` is non-null so the base-equivalence check rehydrates the\n * base machine from the matching nested slice. Defaults to `loaded?.base`.\n */\n readonly baseLoaded?: S | null;\n /**\n * Opt-in relaxation for an INTERCEPTING wrapper (e.g. `withResilience`).\n *\n * DEFAULT (`undefined` / `false`) — the OBSERVE-ONLY contract that\n * `withTelemetry` and `withDeadline` satisfy: every bare base Cmd must appear\n * UNCHANGED, in order, as a subsequence of the wrapped Cmd stream (properties\n * 1 and 3b). The wrapper may APPEND its own Cmds but may NOT alter, drop, or\n * retime a base Cmd. This is the strict default and it is NOT weakened.\n *\n * WHEN SET — for a wrapper whose whole job is to INTERCEPT a chosen base Cmd\n * (retag it into a wrapper-owned carrier so the concern — cache / breaker /\n * rate-limit / retry — can gate it), a target base Cmd LEGITIMATELY does not\n * appear raw at the top level of the wrapped stream. The contract is still\n * **retag-and-re-emit, never swallow** (rule 2): the Cmd must be RECORDED, not\n * vanished. So when a bare base Cmd is ABSENT from the top-level wrapped\n * subsequence, this option accepts it IFF, in that SAME transition window, it\n * is recorded by the wrapper as one of:\n *\n * - the inner payload of a `$x:*` \"run\" carrier Cmd (`carrierCmdType` +\n * `innerField`) — the retag path; OR\n * - any other `$x:*` divergence Cmd whose `recordsField` deep-equals the\n * base Cmd — the gate/defer path (e.g. a \"fast-failed\" or \"deferred\"\n * record Cmd that carries the base Cmd it diverged on).\n *\n * A target base Cmd that is NEITHER present raw NOR recorded by any `$x:*`\n * Cmd in its window is a SWALLOW betrayal and still fails the gate.\n *\n * Provide the field names the carrier uses so the gate can unwrap it\n * structurally without hard-coding `withResilience`'s vocabulary.\n */\n readonly intercepting?: InterceptingOpt;\n}\n\n/**\n * Configures the intercepting relaxation (see\n * `AssertWrapperFaithfulOpts.intercepting`). All fields name the carrier /\n * divergence shape so the gate can structurally find a retagged base Cmd\n * inside a `$x:*` Cmd. The gate only EVER inspects `$x:*`-prefixed wrapped\n * Cmds for a recorded base Cmd — it never relaxes the check for a base Cmd\n * that appears under any non-wrapper Cmd type.\n */\nexport interface InterceptingOpt {\n /**\n * The `Cmd.type` of the wrapper's run-carrier (e.g. `\"$resilience:run\"`).\n * A bare base Cmd that is retagged appears as `carrier[innerField]`.\n */\n readonly carrierCmdType: string;\n /** The field on the carrier Cmd that holds the original base Cmd. */\n readonly innerField: string;\n /**\n * OPTIONAL field on ANY OTHER `$x:*` Cmd that records a base Cmd the wrapper\n * gated/deferred without running it (e.g. a fast-fail record). When present\n * on a `$x:*` Cmd and deep-equal to the missing base Cmd, it counts as a\n * recorded divergence. Omit when the wrapper only ever retags via the\n * carrier.\n */\n readonly recordsField?: string;\n}\n\n/**\n * Assert a `withX` wrapper is TEA-faithful. Replays the wrapped machine and the\n * bare base machine over the same Msgs and checks the four conformance\n * properties (see file header).\n *\n * @param base the bare base `Machine`.\n * @param makeWrapped a thunk that wraps `base` and returns the composed machine\n * (e.g. `() => withTelemetry(base, cfg)`). A thunk — not the wrapped value —\n * so a wrapper that registers process-scoped ports (`definePort`) is\n * constructed inside the assertion's control, and so the same betrayal-\n * detector reads as `assertWrapperFaithful(base, () => withX(base, cfg), ...)`\n * at every wrapper's test site.\n * @param opts the conformance replay options.\n */\nexport function assertWrapperFaithful<\n S,\n BaseM extends { type: string },\n BaseC extends Cmd,\n BaseU extends Sub,\n BaseCtx,\n WM extends WrapperModel<S>,\n WrapperM extends { type: string },\n WrapperC extends Cmd,\n WrapperU extends Sub,\n WrapperCtx,\n>(\n base: Machine<S, BaseM, BaseC, BaseU, BaseCtx>,\n makeWrapped: () => Machine<WM, WrapperM, WrapperC, WrapperU, WrapperCtx>,\n opts: AssertWrapperFaithfulOpts<S, WM, BaseM, BaseCtx, WrapperCtx>,\n): void {\n const baseCtx = (opts.baseCtx ?? (opts.ctx as unknown as BaseCtx)) as BaseCtx;\n const wrappedMsgs = opts.msgs as unknown as readonly WrapperM[];\n const baseLoaded =\n opts.baseLoaded ?? (opts.loaded != null ? (opts.loaded.base as S) : null);\n\n // Two DISTINCT global ambients (wall-clock + RNG). `replay` composes only\n // `init` + `update`, and `update` cells are `(state, msg)` — they never\n // receive `ctx`. So an impure update read reaches for the GLOBAL `Date.now()`\n // / `Math.random()`, not an injected clock. Running the two determinism\n // replays under DIFFERENT ambients turns a folded wall-clock read into an\n // OBSERVABLE slice divergence (property 2) — a single fixed ambient (two\n // back-to-back replays) would return the same ms both times and hide it.\n const A0 = { now: 1_000_000, rng: 0.123 };\n const A1 = { now: 9_876_543, rng: 0.987 };\n\n // The bare baseline, `wrappedA`, and every per-transition baseline (props 3/4)\n // run under the SAME fixed ambient A0 so their cmds/state are deterministic.\n const bare = underAmbient(A0, () =>\n replay(base, { msgs: opts.msgs, ctx: baseCtx, loaded: baseLoaded }),\n );\n const wrapped = underAmbient(A0, () => makeWrapped());\n const wrappedA = underAmbient(A0, () =>\n replay(wrapped, {\n msgs: wrappedMsgs,\n ctx: opts.ctx,\n loaded: opts.loaded ?? null,\n }),\n );\n // The second determinism replay runs under a DISTINCT ambient A1. A faithful\n // wrapper's slice (a pure function of the Msg log) is identical under A0 and\n // A1; an impure update that folds `Date.now()` / `Math.random()` diverges.\n const wrappedB = underAmbient(A1, () =>\n replay(makeWrapped(), {\n msgs: wrappedMsgs,\n ctx: opts.ctx,\n loaded: opts.loaded ?? null,\n }),\n );\n\n // --- Property 1: base behavior byte-identical -----------------------------\n // `state.base` after wrapping === state after running the base alone. The\n // wrapper observes; it does not alter base behavior.\n expect(wrappedA.state.base).toEqual(bare.state);\n // The base's OWN Cmds appear in the wrapped Cmd stream unchanged: every bare\n // Cmd is present, in order, among the wrapped Cmds (with wrapper Cmds\n // interleaved). We assert the bare Cmds are a subsequence of the wrapped ones.\n // For an INTERCEPTING wrapper (`opts.intercepting` set) a target base Cmd is\n // accepted when it appears RETAGGED inside a `$x:*` carrier / recorded by a\n // `$x:*` divergence Cmd instead of raw — retag, not swallow.\n expectCmdSubsequence(bare.cmds, wrappedA.cmds, undefined, opts.intercepting);\n\n // --- Property 2: slice reconstructs under any ambient clock/RNG -----------\n // Replaying the same Msgs under a DIFFERENT global ambient yields a deep-equal\n // wrapper SLICE — the slice is a pure function of the Msg log, never of\n // `Date.now()` / `Math.random()`. We compare the single `$`-slice (not the\n // whole composed state) because comparing whole state would FALSE-POSITIVE\n // when the BASE machine reads the clock — that is the base's behavior, not the\n // wrapper's fault, and the wrapper's faithfulness is precisely what its own\n // slice records.\n const sliceKey = wrapperSliceKey(wrappedA.state);\n expect(\n sliceOf(wrappedB.state, sliceKey),\n `wrapper slice changed under a different ambient clock/RNG → update is ` +\n `reading Date.now()/Math.random(); time must enter only as Msg \\`at\\` data`,\n ).toEqual(sliceOf(wrappedA.state, sliceKey));\n\n // ...AND the wrapper-tagged Cmds reconstruct under any ambient too. The slice\n // is only HALF the wrapper's output — the other half is its emitted Cmds. A\n // wall-clock / RNG read folded into a wrapper Cmd PAYLOAD (not the state\n // slice) escapes the slice comparison above: the slice stays identical while\n // the Cmd carries a leaked `Date.now()` / `Math.random()`. So mirror the\n // slice check on the `$x:*` subset of the replayed Cmd stream — a faithful\n // wrapper emits Cmds that are a pure function of the Msg log, identical under\n // A0 and A1. Only Msg `at` payloads (identical across both replays) may carry\n // time; if a wrapper Cmd diverges between ambients, the wrapper read the\n // ambient clock/RNG into a Cmd. (Base Cmds are EXCLUDED — a base machine that\n // reads the clock is the base's behavior, not the wrapper's, exactly as the\n // slice comparison excludes whole-state.)\n const wrapperFamily = `${sliceKey}:`;\n const wrapperCmdsA = wrappedA.cmds.filter((c) =>\n c.type.startsWith(wrapperFamily),\n );\n const wrapperCmdsB = wrappedB.cmds.filter((c) =>\n c.type.startsWith(wrapperFamily),\n );\n expect(\n wrapperCmdsB,\n `wrapper Cmds (\"${wrapperFamily}*\") changed under a different ambient ` +\n `clock/RNG → a wrapper Cmd PAYLOAD is reading Date.now()/Math.random(); ` +\n `wrapper Cmds must be a pure function of the Msg log, time entering only ` +\n `as Msg \\`at\\` data`,\n ).toEqual(wrapperCmdsA);\n\n // --- Property 3: every wrapper decision appears as an XMsg/XCmd in the log -\n // The composed Model's wrapper slice is the single non-`base` `$`-key. We\n // discover its key family (`$telemetry` → `$telemetry:*`) and require that,\n // whenever there is at least one transition, the replayed Cmd stream carries\n // at least one wrapper-tagged Cmd. (Wrappers whose decisions are Msgs route\n // them through the SAME log; for a Cmd-emitting wrapper like withTelemetry the\n // decision is the `$x:emit` Cmd.) A wrapper that performed its work off-ledger\n // would have an EMPTY wrapper-Cmd set here despite real transitions — the\n // exact betrayal this gate exists to catch.\n if (opts.msgs.length > 0) {\n expect(\n wrapperCmdsA.length,\n `expected at least one \"${wrapperFamily}*\" wrapper-decision Cmd in the replay log ` +\n `(found none across ${opts.msgs.length} transition(s)) — a wrapper whose ` +\n `decisions are invisible to the Msg/Cmd log has betrayed total visibility`,\n ).toBeGreaterThan(0);\n }\n\n // --- Property 3b: per-transition Cmd subsequence --------------------------\n // The flattened subsequence (property 1) misses INTRA-WINDOW retiming — a\n // base Cmd that a saga-style wrapper DEFERS to a later transition still drains\n // within the replay, so the flattened bare-Cmd set stays an ordered\n // subsequence and slips through. Pin it per step: for each transition i, the\n // bare machine's step-i Cmds must be an ordered subsequence of the wrapped\n // machine's step-i Cmds. A deferred base Cmd is then visible as a step-i\n // subsequence failure (it shows up at i+1 in the wrapped run but at i in the\n // bare run). Prefix replays run under the fixed ambient A0 for determinism.\n for (let i = 0; i < opts.msgs.length; i++) {\n const bareStep = stepCmds(\n () =>\n underAmbient(A0, () =>\n replay(base, {\n msgs: opts.msgs.slice(0, i),\n ctx: baseCtx,\n loaded: baseLoaded,\n }),\n ).cmds,\n () =>\n underAmbient(A0, () =>\n replay(base, {\n msgs: opts.msgs.slice(0, i + 1),\n ctx: baseCtx,\n loaded: baseLoaded,\n }),\n ).cmds,\n );\n const wrappedStep = stepCmds(\n () =>\n underAmbient(A0, () =>\n replay(wrapped, {\n msgs: wrappedMsgs.slice(0, i),\n ctx: opts.ctx,\n loaded: opts.loaded ?? null,\n }),\n ).cmds,\n () =>\n underAmbient(A0, () =>\n replay(wrapped, {\n msgs: wrappedMsgs.slice(0, i + 1),\n ctx: opts.ctx,\n loaded: opts.loaded ?? null,\n }),\n ).cmds,\n );\n expectCmdSubsequence(bareStep, wrappedStep, i, opts.intercepting);\n }\n\n // --- Property 4: slice is JSON-round-trip equal ---------------------------\n // The wrapper slice survives JSON.parse(JSON.stringify(...)) — durable across\n // DO eviction / reload, never a closure.\n const slice = sliceOf(wrappedA.state, sliceKey);\n expect(JSON.parse(JSON.stringify(slice))).toEqual(slice);\n}\n\n/**\n * Run `fn` with the GLOBAL `Date.now` and `Math.random` stubbed to fixed\n * values, restoring them in a `finally` so the stub never leaks across\n * assertions or tests. `update` cells receive no `ctx`, so an impure read\n * inside one resolves to these globals — the lever this gate pulls to make a\n * folded wall-clock / RNG read observable in the wrapper slice.\n */\nfunction underAmbient<T>(\n ambient: { readonly now: number; readonly rng: number },\n fn: () => T,\n): T {\n const nowSpy = vi.spyOn(Date, \"now\").mockReturnValue(ambient.now);\n const rngSpy = vi.spyOn(Math, \"random\").mockReturnValue(ambient.rng);\n try {\n return fn();\n } finally {\n nowSpy.mockRestore();\n rngSpy.mockRestore();\n }\n}\n\n/** The wrapper slice value (the single `$`-key) on a composed Model. */\nfunction sliceOf(model: object, sliceKey: string): unknown {\n return (model as Record<string, unknown>)[sliceKey];\n}\n\n/**\n * The Cmds a single transition `i` emitted: the suffix of the cmds after\n * `msgs.slice(0, i+1)` past the cmds after `msgs.slice(0, i)`. Cmds accumulate\n * in order across `replay`, so the longer run is a prefix-extension of the\n * shorter one and the suffix is exactly step `i`'s contribution.\n */\nfunction stepCmds(\n prefixCmds: () => readonly Cmd[],\n throughCmds: () => readonly Cmd[],\n): readonly Cmd[] {\n const before = prefixCmds();\n const after = throughCmds();\n return after.slice(before.length);\n}\n\n/**\n * The wrapper slice key on a composed Model — the single own enumerable field\n * whose name starts with `$`. Throws if zero or more than one is found, because\n * the wrapper-tier contract is exactly one named `$`-slice per wrapper.\n */\nfunction wrapperSliceKey(model: object): string {\n const dollarKeys = Object.keys(model).filter((k) => k.startsWith(\"$\"));\n if (dollarKeys.length !== 1) {\n throw new Error(\n `assertWrapperFaithful: expected exactly one \"$\"-prefixed wrapper slice ` +\n `on the composed Model, found ${dollarKeys.length} (${dollarKeys.join(\", \") || \"none\"}). ` +\n `Every withX wrapper owns exactly one named slice (e.g. \"$telemetry\").`,\n );\n }\n // biome-ignore lint/style/noNonNullAssertion: length checked to be exactly 1 above\n return dollarKeys[0]!;\n}\n\n/**\n * Assert `needle` is an (order-preserving) subsequence of `haystack` by deep\n * equality — every base Cmd appears, in order, somewhere in the wrapped Cmd\n * stream (wrapper Cmds may be interleaved). This is the \"base Cmds pass through\n * UNCHANGED\" check that tolerates the wrapper's own appended Cmds without\n * requiring an exact-equal stream. When `step` is supplied the message names\n * the transition index, so a per-transition retiming failure points at the\n * exact step a base Cmd was deferred away from.\n *\n * `intercepting` (default `undefined` → the strict OBSERVE-ONLY check above)\n * relaxes the match for a base Cmd that an INTERCEPTING wrapper retags: when a\n * needle Cmd is NOT found raw in `haystack`, it is accepted IFF some `$x:*`\n * wrapper Cmd in `haystack` RECORDS it — as the carrier's `innerField` payload\n * (retag) or another `$x:*` Cmd's `recordsField` (recorded gate/defer). The\n * relaxation ONLY ever looks inside `$x:*` Cmds, so a base Cmd that vanished\n * with no `$x:*` record still fails. The order check is preserved: the carrier\n * / divergence Cmd must come at or after the cursor, exactly like a raw match.\n */\nfunction expectCmdSubsequence(\n needle: readonly Cmd[],\n haystack: readonly Cmd[],\n step?: number,\n intercepting?: InterceptingOpt,\n): void {\n let i = 0;\n for (const cmd of haystack) {\n if (i >= needle.length) break;\n if (__deepEqual(needle[i], cmd)) {\n i++;\n continue;\n }\n // Intercepting relaxation: the base Cmd at the cursor may legitimately be\n // absent raw because the wrapper RETAGGED it. Accept this haystack Cmd as\n // the matching slot IFF it is a `$x:*` wrapper Cmd that records `needle[i]`.\n if (\n intercepting !== undefined &&\n recordsBaseCmd(cmd, needle[i] as Cmd, intercepting)\n ) {\n i++;\n }\n }\n const where =\n step === undefined\n ? \"the wrapped Cmd stream\"\n : `the wrapped Cmd stream AT TRANSITION ${step} (a base Cmd deferred to a ` +\n `later transition is an intra-window retiming betrayal)`;\n const swallowHint =\n intercepting === undefined\n ? \"a missing/rewritten/retimed base Cmd is a swallow betrayal\"\n : `an intercepting wrapper must RETAG each target base Cmd into a ` +\n `\"${intercepting.carrierCmdType}\" carrier (inner field ` +\n `\"${intercepting.innerField}\") or record it on a \"$*:\" divergence Cmd ` +\n `— a base Cmd neither present raw NOR recorded by any \"$*:\" Cmd is a ` +\n `swallow betrayal`;\n expect(\n i,\n `expected every base Cmd to pass through unchanged (matched ${i} of ` +\n `${needle.length} base Cmds as an ordered subsequence of ${where}) — ` +\n `${swallowHint}`,\n ).toBe(needle.length);\n}\n\n/**\n * Does the wrapped Cmd `cmd` RECORD the base Cmd `baseCmd` under the\n * intercepting contract? True iff `cmd` is a `$`-prefixed wrapper Cmd AND\n * either:\n * - `cmd.type === carrierCmdType` and `cmd[innerField]` deep-equals\n * `baseCmd` (the retag carrier), OR\n * - `recordsField` is configured and `cmd[recordsField]` deep-equals\n * `baseCmd` (a recorded gate/defer divergence on any `$x:*` Cmd).\n *\n * The `$`-prefix guard is load-bearing: the relaxation must NEVER accept a base\n * Cmd hidden inside a NON-wrapper Cmd — that would let a wrapper launder a\n * swallowed base Cmd through an arbitrary re-emit. Only the wrapper's own\n * `$x:*` family may carry a retagged base Cmd.\n */\nfunction recordsBaseCmd(cmd: Cmd, baseCmd: Cmd, opt: InterceptingOpt): boolean {\n if (!cmd.type.startsWith(\"$\")) return false;\n const rec = cmd as unknown as Record<string, unknown>;\n if (\n cmd.type === opt.carrierCmdType &&\n __deepEqual(rec[opt.innerField], baseCmd)\n )\n return true;\n if (\n opt.recordsField !== undefined &&\n __deepEqual(rec[opt.recordsField], baseCmd)\n )\n return true;\n return false;\n}\n\n/**\n * Structural deep equality for plain Cmd data.\n *\n * NOT `JSON.stringify` equality: `JSON.stringify` DROPS undefined-valued fields,\n * so `{ type: \"x\" }` would falsely equal `{ type: \"x\", foo: undefined }` and the\n * gate could accept a wrapper that smuggles an extra (undefined) field into a\n * \"byte-identical\" base Cmd or a retag carrier. This walk distinguishes an\n * ABSENT key from an `undefined`-VALUED key by comparing the full own-enumerable\n * key SET (not just the defined values) in both directions, then recursing.\n *\n * Cmds are plain data — primitives, `null`, arrays, and plain objects — so this\n * intentionally does not model `Date`, `Map`, `Set`, cycles, or class instances.\n *\n * Exported under the `__` test-only convention so the conformance suite can\n * pin the absent-vs-undefined distinction directly. Not part of the public API.\n *\n * @internal test-only\n */\nexport function __deepEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n\n // Past the identity check, equality requires same kind on both sides. Anything\n // non-object (primitive, function, symbol) that wasn't `Object.is`-equal above\n // is unequal. `null` is `typeof \"object\"` but only equals `null` (caught by\n // `Object.is`), so screen it out explicitly.\n if (\n typeof a !== \"object\" ||\n typeof b !== \"object\" ||\n a === null ||\n b === null\n ) {\n return false;\n }\n\n const aIsArray = Array.isArray(a);\n if (aIsArray !== Array.isArray(b)) return false;\n\n if (aIsArray) {\n const bArr = b as unknown[];\n if (a.length !== bArr.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (!__deepEqual(a[i], bArr[i])) return false;\n }\n return true;\n }\n\n // Plain objects: compare the own-enumerable key SET first so a key present on\n // one side with an `undefined` value (and absent on the other) is caught —\n // the betrayal `JSON.stringify` hid. Then recurse on every value.\n const aRec = a as Record<string, unknown>;\n const bRec = b as Record<string, unknown>;\n const aKeys = Object.keys(aRec);\n const bKeys = Object.keys(bRec);\n if (aKeys.length !== bKeys.length) return false;\n for (const key of aKeys) {\n if (!Object.hasOwn(bRec, key)) return false;\n if (!__deepEqual(aRec[key], bRec[key])) return false;\n }\n return true;\n}\n","// ---------------------------------------------------------------------------\n// Test-side assertions over `replay`. Each helper composes the replay call\n// with a single `expect(...)` so consumers stop hand-rolling the 5-line\n// \"destructure { state, cmds } → expect.toBe / toEqual / toContainEqual\"\n// boilerplate at every test site.\n//\n// Each helper is a thin wrapper that:\n// 1. Calls `replay(machine, opts)` once.\n// 2. Pipes the result into a single vitest `expect(...)` matcher.\n//\n// All helpers return `void` — assertions throw on failure (vitest contract).\n// No mutation of the machine or opts. Pure test ergonomics.\n//\n// Type-inference note: each helper anchors its generic parameters to the\n// `machine` argument. The `expected` (and `opts.msgs`) arguments are wrapped\n// in `NoInfer<...>` so they do NOT participate in inference — otherwise a\n// `[]`-shaped `expected` would force `C = never` and reject a machine whose\n// real Cmd union is non-empty. Anchoring inference to the machine is the\n// same discipline `replay` uses (it has nothing but the machine and opts).\n//\n// Strengthens invariant 9 (the testing surface is named, small, and forks\n// nothing of the substrate's purity guarantees).\n// ---------------------------------------------------------------------------\n\nimport { expect } from \"vitest\";\nimport { type Cmd, type Machine, replay, type Sub } from \"../index\";\n\n// `NoInfer<T>` is the built-in TypeScript 5.4+ intrinsic that blocks\n// inference from a generic parameter at a position. We use it on `expected`\n// and `opts` so inference flows purely FROM the machine — `[]`-shaped\n// `expected` no longer drags `C` down to `never` and rejects the machine.\n\n/**\n * Shared options shape for every test assertion below. Mirrors the\n * second argument of `replay(machine, opts)` — `msgs` is the sequence to\n * fold over (may be empty for init-only assertions), `ctx` is the\n * substrate-required ctx value, `loaded` is the optional pre-`init`\n * snapshot (omit / pass `null` for fresh boot).\n */\nexport interface ReplayOpts<S, M, Ctx> {\n readonly msgs: readonly M[];\n readonly ctx: Ctx;\n readonly loaded?: S | null;\n}\n\n/**\n * Assert the final state after replaying `opts.msgs` equals `expected`.\n * Replaces the boilerplate:\n *\n * const { state } = replay(machine, opts);\n * expect(state).toEqual(expected);\n *\n * Uses `toEqual` (deep structural). For type-narrowing assertions that\n * branch on `state.type` afterwards, fall back to plain `replay` —\n * `expectFinalState` is the \"exact match\" tool.\n */\nexport function expectFinalState<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n>(\n machine: Machine<S, M, C, U, Ctx>,\n opts: NoInfer<ReplayOpts<S, M, Ctx>>,\n expected: NoInfer<S>,\n): void {\n const { state } = replay(machine, opts);\n expect(state).toEqual(expected);\n}\n\n/**\n * Assert that `cmd` appears at least once in the cmds array produced by\n * replaying `opts.msgs`. Uses `toContainEqual` (deep structural). Order\n * and surrounding cmds are not asserted — use `expectCmdSequence` for\n * exact ordered match.\n *\n * Replaces:\n *\n * const { cmds } = replay(machine, opts);\n * expect(cmds).toContainEqual(cmd);\n */\nexport function expectCmdEmitted<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n>(\n machine: Machine<S, M, C, U, Ctx>,\n opts: NoInfer<ReplayOpts<S, M, Ctx>>,\n cmd: NoInfer<C>,\n): void {\n const { cmds } = replay(machine, opts);\n expect(cmds).toContainEqual(cmd);\n}\n\n/**\n * Assert the exact ordered sequence of cmds emitted by replaying\n * `opts.msgs`. Uses `toEqual` against the full cmds array — extra cmds\n * fail the assertion, missing cmds fail the assertion, wrong order\n * fails the assertion.\n *\n * Replaces:\n *\n * const { cmds } = replay(machine, opts);\n * expect(cmds).toEqual(expected);\n */\nexport function expectCmdSequence<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n>(\n machine: Machine<S, M, C, U, Ctx>,\n opts: NoInfer<ReplayOpts<S, M, Ctx>>,\n expected: NoInfer<readonly C[]>,\n): void {\n const { cmds } = replay(machine, opts);\n expect(cmds).toEqual(expected);\n}\n\n/**\n * Assert the exact set of subs desired at the final state after\n * replaying `opts.msgs`. Uses `toEqual` against the full subs array.\n *\n * Replaces:\n *\n * const { subs } = replay(machine, opts);\n * expect(subs).toEqual(expected);\n */\nexport function expectActiveSubs<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n>(\n machine: Machine<S, M, C, U, Ctx>,\n opts: NoInfer<ReplayOpts<S, M, Ctx>>,\n expected: NoInfer<readonly U[]>,\n): void {\n const { subs } = replay(machine, opts);\n expect(subs).toEqual(expected);\n}\n\n/**\n * Single-msg step helper — feeds `loaded → msg → next state + cmds emitted by\n * that msg`. Returns a readonly tuple in the shape consumers used before the\n * substrate (`[state, cmds]`), so existing tests that destructure with\n * `[next, cmds]` can swap `reduce(state, msg)` for `step(machine, state, msg,\n * ctx)` without changing the assertion code.\n *\n * Internally a `replay` call with `loaded: prevState` and a single-element\n * `msgs` array. The cmds returned are exactly the cmds emitted by THIS msg\n * (init emits no cmds when `loaded` is provided, so the slice is the entire\n * array).\n *\n * Use when consumers want to walk a machine one msg at a time and assert per\n * step. For one-shot \"final state after N msgs\" assertions, prefer\n * `expectFinalState`.\n */\nexport function step<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n>(\n machine: Machine<S, M, C, U, Ctx>,\n loaded: NoInfer<S>,\n msg: NoInfer<M>,\n ctx: NoInfer<Ctx>,\n): readonly [S, readonly C[]] {\n const { state, cmds } = replay(machine, { msgs: [msg], ctx, loaded });\n return [state, cmds] as const;\n}\n","// ---------------------------------------------------------------------------\n// `bindMachine(machine, ctx)` — bound test harness over the free-function\n// assertions in `./assertions.ts`. Closes over the `machine` and `ctx` once\n// so per-test callsites stop repeating both at every invocation.\n//\n// Why this exists: every consumer test file ends up hand-rolling a local\n// two-arg `step(state, msg)` wrapper around `step(machine, state, msg, ctx)`,\n// and the four `expect*` assertions repeat `machine` + `ctx` at every\n// callsite. The bound form pulls both into one place and gives every\n// per-test call its tightest possible shape (2-arg max).\n//\n// `bindMachine` is built ON TOP of the free helpers — it does not replace\n// them. Both forms coexist; pick the one that fits the call site:\n//\n// - Free form → one-off call inside a helper that isn't bound to one\n// machine (e.g. cross-machine integration test).\n// - Bound form → a `describe` block runs many assertions against one\n// machine + ctx. The bound form is the common case.\n//\n// Strengthens invariant 9 (the testing surface is named, small, and forks\n// nothing of the substrate's purity guarantees).\n// ---------------------------------------------------------------------------\n\nimport { expect } from \"vitest\";\nimport { type Cmd, type Machine, replay, type Sub } from \"../index\";\n\n/**\n * Replay options shape used by every bound method. `ctx` is captured by\n * `bindMachine`; the per-call opts only need `msgs` and an optional\n * `loaded` snapshot. (Compare `ReplayOpts` in `./assertions.ts`, which\n * still takes `ctx` because the free helpers cannot capture it.)\n */\ninterface BoundOpts<S, M> {\n readonly msgs: readonly M[];\n readonly loaded?: S | null;\n}\n\n/**\n * The bound testing surface. Every method is 2-arg max — `ctx` and\n * `machine` are captured by `bindMachine`.\n *\n * `NoInfer<...>` on `expected` / `cmd` arguments mirrors the discipline\n * the free helpers use (see `./assertions.ts`): inference flows purely\n * FROM the machine, so a `[]`-shaped expected does not drag `C` down to\n * `never` and reject the machine.\n */\nexport interface BoundMachine<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n // `Ctx` is a phantom-style parameter — present for consumers that want to\n // spell `BoundMachine<S, M, C, U, Ctx>` explicitly, mirroring `Machine`.\n // biome-ignore lint/correctness/noUnusedVariables: phantom type param (see above)\n Ctx,\n> {\n /**\n * Single-msg step — feeds `loaded → msg → [next state, cmds emitted by\n * that msg]`. Mirrors the free `step(machine, loaded, msg, ctx)`.\n */\n step(loaded: S, msg: M): readonly [S, readonly C[]];\n /**\n * Assert the final state after replaying `opts.msgs` deep-equals\n * `expected`. Mirrors the free `expectFinalState(machine, opts, expected)`.\n */\n expectFinalState(opts: BoundOpts<S, M>, expected: NoInfer<S>): void;\n /**\n * Assert `cmd` appears at least once in the emitted cmd list. Order is\n * not asserted. Mirrors the free `expectCmdEmitted(machine, opts, cmd)`.\n */\n expectCmdEmitted(opts: BoundOpts<S, M>, cmd: NoInfer<C>): void;\n /**\n * Assert the exact ordered sequence of cmds emitted by replaying\n * `opts.msgs`. Mirrors the free `expectCmdSequence(machine, opts, expected)`.\n */\n expectCmdSequence(\n opts: BoundOpts<S, M>,\n expected: readonly NoInfer<C>[],\n ): void;\n /**\n * Assert the exact set of subs desired at the final state. Mirrors the\n * free `expectActiveSubs(machine, opts, expected)`.\n */\n expectActiveSubs(\n opts: BoundOpts<S, M>,\n expected: readonly NoInfer<U>[],\n ): void;\n /**\n * Bound `replay` — returns `{ state, cmds, subs }` for the given opts.\n * Use for the \"narrow-then-assert\" pattern where the test inspects a\n * specific field after `state.type === \"...\"` discrimination.\n */\n replay(opts: BoundOpts<S, M>): {\n state: S;\n cmds: readonly C[];\n subs: readonly U[];\n };\n}\n\n/**\n * Bind a machine + ctx into a small bag of 2-arg helpers. Each method\n * delegates to `replay(machine, { ...opts, ctx })` and pipes the result\n * through a single `expect(...)` matcher (or returns the raw tuple, for\n * `step` and `replay`).\n *\n * Use one bind per `describe` block (or per file) when many assertions\n * share the same machine + ctx. For one-off cross-machine calls, stick\n * with the free helpers from `./assertions.ts`.\n */\nexport function bindMachine<\n S,\n M extends { type: string },\n C extends Cmd,\n U extends Sub,\n Ctx,\n>(machine: Machine<S, M, C, U, Ctx>, ctx: Ctx): BoundMachine<S, M, C, U, Ctx> {\n return {\n step(loaded, msg) {\n const { state, cmds } = replay(machine, { msgs: [msg], ctx, loaded });\n return [state, cmds] as const;\n },\n expectFinalState(opts, expected) {\n const { state } = replay(machine, { ...opts, ctx });\n expect(state).toEqual(expected);\n },\n expectCmdEmitted(opts, cmd) {\n const { cmds } = replay(machine, { ...opts, ctx });\n expect(cmds).toContainEqual(cmd);\n },\n expectCmdSequence(opts, expected) {\n const { cmds } = replay(machine, { ...opts, ctx });\n expect(cmds).toEqual(expected);\n },\n expectActiveSubs(opts, expected) {\n const { subs } = replay(machine, { ...opts, ctx });\n expect(subs).toEqual(expected);\n },\n replay(opts) {\n return replay(machine, { ...opts, ctx });\n },\n };\n}\n","// ---------------------------------------------------------------------------\n// noopRuntime — a Runtime<S, M>-shaped value whose every method is inert.\n//\n// The motivating callsite: a machine's `ctx` requires a sibling Runtime<S,\n// M> reference (e.g. the queue runtime in extension/lib/queue-machine\n// reaches into an `auditRuntime: Runtime<...>` slot on its ctx so its\n// interpret handlers can dispatch into the audit machine). When the test\n// replays such a machine, `replay` never actually invokes `interpret`, so\n// the runtime reference is never dereferenced — but the type system\n// still requires a value of `Runtime<S, M>` shape at the ctx slot. Tests\n// today work around this with a hand-rolled 12-line NOOP_AUDIT_RUNTIME\n// const cast through `as unknown as Runtime<...>`.\n//\n// `noopRuntime<S, M>()` is that hand-roll, named once. It returns a real\n// Runtime<S, M> value whose every method is a structurally-correct no-op:\n//\n// - `dispatch`: resolves immediately, never advances state.\n// - `getState`: returns the optional `initialState` argument (or a\n// deliberate `undefined` cast as S — the function lies about its\n// return type when no initial state is provided; this is the trade-off\n// we accept for an ergonomic test substrate).\n// - `subscribe` / `observe` / `subscribePort`: register the listener,\n// return a no-op unsubscribe. The listener is never fired because the\n// state never changes.\n// - `emitPort`: no-op.\n// - `ready`: a Promise that resolves to the no-op runtime itself (the #45\n// `ready: Promise<Runtime<S, M>>` shape — already booted, nothing to wait\n// for).\n// - `stop`: resolved Promise<void>.\n//\n// Strengthens invariant 9 (the testing surface is named and small).\n// ---------------------------------------------------------------------------\n\nimport type { Port, Runtime } from \"../index\";\n\n/**\n * Construct an inert `Runtime<S, M>` value. Use at ctx sites that require\n * a Runtime reference but where the test never invokes `interpret` (so\n * the runtime is never dereferenced in practice).\n *\n * @param opts.initialState Optional value returned by `getState()`. Omit\n * when the test never calls `getState()` on the no-op runtime — most\n * tests only need the type-level slot filled.\n */\nexport function noopRuntime<S, M extends { type: string }>(opts?: {\n initialState?: S;\n}): Runtime<S, M> {\n const initialState = opts?.initialState;\n // Single source of truth for the \"do-nothing\" unsubscribe so multiple\n // subscribe call sites share the same function instance — purely cosmetic\n // (the function would be a no-op either way).\n const noopUnsubscribe = (): void => {};\n const runtime: Runtime<S, M> = {\n async dispatch(_msg: M): Promise<void> {\n // Resolves immediately. State never advances; listeners never fire.\n // Quiescent by default (#50), but the no-op has no follow-up chain to\n // drain, so single-step and run-to-quiescence collapse to the same no-op.\n },\n async dispatchOnce(_msg: M): Promise<void> {\n // Single-step sibling of `dispatch` (#50). Same no-op for the no-op\n // runtime — there is no tail to leave in flight.\n },\n async idle(): Promise<void> {\n // No tail to drain — the no-op runtime never enqueues a follow-up.\n },\n result(): S | undefined {\n // The no-op runtime never advances, so it is never terminal (#46).\n return undefined;\n },\n done(): Promise<S> {\n // Never terminal → the awaitable never settles, matching `run()` with no\n // `terminal` predicate. Returned as a never-resolving promise.\n return new Promise<S>(() => {});\n },\n getState(): S {\n // Lie if no initial state was provided. The caller's contract is\n // \"you accept the lie because you know replay never invokes\n // interpret and therefore never reads this.\" When the caller DOES\n // pass an initialState the lie collapses to truth.\n return initialState as S;\n },\n subscribe(_listener: () => void): () => void {\n return noopUnsubscribe;\n },\n observe(_observer: (msg: M, state: S) => void): () => void {\n return noopUnsubscribe;\n },\n onBoot(_handler: (state: S) => void): () => void {\n // Boot never fires on the inert runtime — it is \"already booted\" with no\n // initial fanout, so the handler is registered and never called (#47).\n return noopUnsubscribe;\n },\n on<K extends never>(\n _type: K,\n _handler: (event: never) => void,\n ): () => void {\n // The no-op runtime's event surface is `never` (no `events` projector),\n // so `on` is structurally present but uncallable — there is no `K` to\n // pass. The body is unreachable; it returns the shared no-op unsubscribe.\n return noopUnsubscribe;\n },\n subscribePort<T>(\n _port: Port<T>,\n _listener: (value: T) => void,\n ): () => void {\n return noopUnsubscribe;\n },\n emitPort<T>(_port: Port<T>, _value: T): void {\n // No-op. No subscribers to fan out to; nothing to do.\n },\n // Assigned just below — `ready` must resolve to `runtime` itself, which\n // can't be referenced inside its own object literal.\n ready: undefined as unknown as Promise<Runtime<S, M>>,\n async stop(): Promise<void> {\n // Resolves immediately. No in-flight tail to drain, no subs to clean.\n },\n };\n // Already \"booted\" — `ready` hands back the same runtime synchronously.\n runtime.ready = Promise.resolve(runtime);\n return runtime;\n}\n","// ---------------------------------------------------------------------------\n// stateFactory — typed phase-constructor API for a discriminated-union State.\n//\n// The motivating callsite: every reducer test today opens with ~60–80 lines\n// of hand-rolled factory functions, one per phase, each one's defaults\n// duplicated across files:\n//\n// function idleState() { return { type: \"idle\" }; }\n// function creatingWindowState(overrides?: Partial<...>) {\n// return { type: \"creating_window\", auditId: ..., wsUrl: ..., ...overrides };\n// }\n// ...\n//\n// `stateFactory<BackgroundState>({...})` collapses the whole block to one\n// declaration: pass each phase's REQUIRED defaults once (the type system\n// enforces every phase has an entry), and the helper builds an API of\n// `factory.idle()`, `factory.creating_window({...})`, etc.\n//\n// Two type-level guarantees:\n//\n// 1. Every phase has a defaults entry — `StateFactoryDefaults<S>` is a\n// mapped type keyed by every `S[\"type\"]`. Missing an entry is a\n// compile error (the @ts-expect-error in testing.spec.ts pins this).\n//\n// 2. Each phase's defaults match that phase's required shape minus the\n// `type` discriminator. Passing wrong fields fails to compile.\n//\n// The runtime is pure data:\n//\n// api[k] = (overrides) => ({\n// type: k,\n// ...defaults[k],\n// ...stripUndefined(overrides ?? {}),\n// })\n//\n// The `stripUndefined` pass is what preserves `exactOptionalPropertyTypes`\n// assignability — without it, calling `factory.creating_window({\n// queueItemId: undefined })` would land an explicit `queueItemId: undefined`\n// on the object, which is NOT assignable to `queueItemId?: string` under\n// `exactOptionalPropertyTypes`. Stripping undefineds before spread keeps\n// the boundary clean.\n//\n// `stripUndefined` is inlined (not imported from a shared stdlib) so this\n// package can stay dep-free of stdlib.\n// ---------------------------------------------------------------------------\n\n/** A factory-constructed phase: `S` narrowed to the arm whose discriminator equals `K`. */\ntype StateOf<S, K> = Extract<S, { type: K }>;\n\n/** A factory-constructed phase with the `type` discriminator removed — the \"fields the caller cares about\" half. */\ntype RequiredFields<T> = Omit<T, \"type\">;\n\n/**\n * Defaults shape passed to `stateFactory`. Mapped type over the discriminant\n * set: every phase MUST have an entry, and that entry MUST match the phase's\n * required fields minus the `type` discriminator.\n */\nexport type StateFactoryDefaults<S extends { type: string }> = {\n readonly [K in S[\"type\"]]: RequiredFields<StateOf<S, K>>;\n};\n\n/**\n * The API returned by `stateFactory`. One method per phase; calling it with\n * no args returns the default snapshot, calling it with a partial overrides\n * object merges those overrides in (with undefineds stripped — see\n * stripUndefined below).\n */\nexport type StateFactoryAPI<S extends { type: string }> = {\n readonly [K in S[\"type\"]]: (\n overrides?: Partial<RequiredFields<StateOf<S, K>>>,\n ) => StateOf<S, K>;\n};\n\n/**\n * Strip own-enumerable properties whose value is `undefined`. Used inside\n * the factory's spread chain so callers can pass `{ queueItemId: undefined }`\n * without the explicit-undefined landing on the result object (which would\n * fail to assign to a `queueItemId?: string` field under\n * `exactOptionalPropertyTypes`).\n *\n * Inlined (not imported from `a shared stdlib`) so `@demlik/tea/testing` can stay\n * dependency-free of stdlib. The 8-line cost of duplication is cheaper than\n * a package-graph edge.\n */\nfunction stripUndefined<T extends object>(obj: T): Partial<T> {\n const out: Partial<T> = {};\n for (const key of Object.keys(obj) as (keyof T)[]) {\n const value = obj[key];\n if (value !== undefined) {\n out[key] = value;\n }\n }\n return out;\n}\n\n/**\n * Build a typed phase-constructor API from per-phase defaults. The defaults\n * object MUST have one entry per `S[\"type\"]` discriminant; the returned API\n * has one method per phase. Each method merges the defaults with optional\n * overrides (undefineds stripped), then stamps the `type` discriminator.\n *\n * @example\n * type S = { type: \"a\"; n: number } | { type: \"b\"; s: string };\n * const f = stateFactory<S>({ a: { n: 0 }, b: { s: \"\" } });\n * f.a(); // { type: \"a\", n: 0 }\n * f.a({ n: 42 }); // { type: \"a\", n: 42 }\n * f.b({ s: \"hi\" }); // { type: \"b\", s: \"hi\" }\n */\nexport function stateFactory<S extends { type: string }>(\n defaults: StateFactoryDefaults<S>,\n): StateFactoryAPI<S> {\n // Build the API by walking the defaults' own keys. Each key corresponds\n // to one phase discriminator; the constructor closes over both the key\n // (for the `type` stamp) and that phase's defaults snapshot.\n const api = {} as { [k: string]: (overrides?: object) => unknown };\n for (const key of Object.keys(\n defaults,\n ) as (keyof StateFactoryDefaults<S>)[]) {\n const phaseDefaults = defaults[key];\n api[key as string] = (overrides?: object) => {\n // The strip-undefined pass lives here, not at the caller. See the\n // module header for the `exactOptionalPropertyTypes` rationale.\n const cleanedOverrides = overrides ? stripUndefined(overrides) : {};\n return { type: key, ...phaseDefaults, ...cleanedOverrides };\n };\n }\n return api as StateFactoryAPI<S>;\n}\n"]}
|
|
@@ -1,13 +1,145 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import '../types-D7u9DkH7.js';
|
|
1
|
+
export { D as Debounced, d as debounce } from '../index-DHSUmQTR.js';
|
|
2
|
+
import { C as Cmd, S as Sub } from '../core-CTzMJ82M.js';
|
|
3
|
+
import { T as TtlCache, a as DeadlineSub } from '../index-q0hXFeZ0.js';
|
|
4
|
+
export { D as ThrottledInputSettled, s as subscribeThrottledInput, d as throttledInputSettled } from '../index-q0hXFeZ0.js';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '../types-DP3f5NIl.js';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
9
|
+
* internal/timing/throttle — a timer-based call transformer that caps invocation
|
|
10
|
+
* to at most once per `ms` window.
|
|
11
|
+
*
|
|
12
|
+
* Sibling of `../debounce` — the two share a SYMMETRIC surface
|
|
13
|
+
* (`Throttled<A>` / `Debounced<A>`, both callable + `.cancel()` + `.flush()`,
|
|
14
|
+
* both `{ leading?, trailing? }`) so they read as a pair. They are kept in
|
|
15
|
+
* separate files with NO cross-import: each is a self-contained timer, and the
|
|
16
|
+
* coalesce-vs-drop policies differ enough that sharing code would hide the
|
|
17
|
+
* distinction. The contrast IS the lesson:
|
|
18
|
+
*
|
|
19
|
+
* - **debounce** waits for quiet — fires once AFTER a burst settles.
|
|
20
|
+
* - **throttle** enforces a rate — fires AT MOST once per `ms` while the
|
|
21
|
+
* burst is ongoing, dropping the calls in between.
|
|
22
|
+
*
|
|
23
|
+
* Layering with `../throttled-input`: `throttle` and `debounce` are
|
|
24
|
+
* the two host-boundary PRIMITIVES — two distinct algorithms
|
|
25
|
+
* (at-most-once-per-window vs collapse-a-burst) behind one signature shape.
|
|
26
|
+
* `throttled-input` is NOT a third primitive: it is a TEA machine composed
|
|
27
|
+
* OVER them (the same semantics, reimplemented as pure, durable Model state)
|
|
28
|
+
* that re-exports both. Wrapping a raw host event → these primitives; durable, replayable
|
|
29
|
+
* gating inside a machine → `throttled-input` (see its module doc for the full
|
|
30
|
+
* layering map).
|
|
31
|
+
*
|
|
32
|
+
* WHAT THIS IS NOT — and why it lives outside `update`:
|
|
33
|
+
*
|
|
34
|
+
* - NOT a reducer / Transitions cell. Reducers are PURE (invariant 2 — same
|
|
35
|
+
* inputs → same outputs, no `Date.now`, no timers). A throttle holds a live
|
|
36
|
+
* `setTimeout` handle and a window cursor; folding it into `update` would
|
|
37
|
+
* smuggle a timer into the pure core.
|
|
38
|
+
* - NOT a Sub. A Sub is a continuous SOURCE of Msgs the substrate reconciles
|
|
39
|
+
* by id every transition (invariant 4). A throttle is a SINK transformer:
|
|
40
|
+
* it wraps a `void`-returning handler (the canonical one is
|
|
41
|
+
* `Runtime.dispatch`) so a high-frequency HOST event is rate-limited BEFORE
|
|
42
|
+
* it ever becomes a Msg.
|
|
43
|
+
*
|
|
44
|
+
* It is a higher-order function at the host boundary (pattern 14 — TEA owns
|
|
45
|
+
* state, JS owns timing). The host attaches the wrapped function to a
|
|
46
|
+
* high-frequency event source (`mousemove`, `scroll`, `pointermove`, a game
|
|
47
|
+
* loop) and the substrate downstream only ever sees the rate-limited Msg:
|
|
48
|
+
*
|
|
49
|
+
* const onMoved = throttle(
|
|
50
|
+
* (e: PointerEvent) =>
|
|
51
|
+
* runtime.dispatch({ type: "UserMovedCursor", x: e.clientX, y: e.clientY }),
|
|
52
|
+
* 16, // ~60fps cap
|
|
53
|
+
* );
|
|
54
|
+
* window.addEventListener("pointermove", onMoved);
|
|
55
|
+
* // cleanup: onMoved.cancel(); window.removeEventListener("pointermove", onMoved);
|
|
56
|
+
*
|
|
57
|
+
* Internal since #47 — not published on any subpath; reached from inside the
|
|
58
|
+
* package as `internal/timing/throttle`. Same one-shape-per-package rule as
|
|
59
|
+
* `rate-limit`, `deadline`, and `work-queue`.
|
|
60
|
+
*
|
|
61
|
+
* Uses the universal `setTimeout` / `clearTimeout` timer idiom (same discipline
|
|
62
|
+
* as `subs/from-timeout.ts`): exactly one live handle at a time, the window
|
|
63
|
+
* timer clears itself on expiry, `cancel` / `flush` clear and null it so a
|
|
64
|
+
* stale callback can never run.
|
|
65
|
+
*/
|
|
66
|
+
/**
|
|
67
|
+
* A throttled wrapper around `fn`. Callable with the SAME argument tuple as
|
|
68
|
+
* `fn` — `(...args: A) => void` — plus two control methods that share names and
|
|
69
|
+
* shapes with `Debounced<A>` so the two modules read as a symmetric pair.
|
|
70
|
+
*/
|
|
71
|
+
interface Throttled<A extends readonly unknown[]> {
|
|
72
|
+
/** Invoke `fn` if the window is open, else record args for the trailing fire. */
|
|
73
|
+
(...args: A): void;
|
|
74
|
+
/**
|
|
75
|
+
* Drop any pending trailing fire WITHOUT invoking `fn`, and close the active
|
|
76
|
+
* window. Clears the timer, forgets the captured trailing args, and resets
|
|
77
|
+
* the cursor so the next call fires immediately on the leading edge (if
|
|
78
|
+
* `leading` is enabled). Idempotent.
|
|
79
|
+
*
|
|
80
|
+
* The host-cleanup partner of `removeEventListener`: cancel the pending fire
|
|
81
|
+
* when the component unmounts / the listener detaches, so a queued
|
|
82
|
+
* `dispatch` can't land after teardown.
|
|
83
|
+
*/
|
|
84
|
+
cancel(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Fire any pending trailing call IMMEDIATELY with its latest captured args,
|
|
87
|
+
* then close the window. No-op when nothing is pending. Use to force the last
|
|
88
|
+
* dropped call out early — e.g. flush the final cursor position when a drag
|
|
89
|
+
* ends, so the rest state isn't a stale mid-drag sample.
|
|
90
|
+
*/
|
|
91
|
+
flush(): void;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Wrap `fn` so it runs AT MOST once per `ms` window, no matter how often it is
|
|
95
|
+
* called.
|
|
96
|
+
*
|
|
97
|
+
* Leading + trailing (the default): the first call fires `fn` IMMEDIATELY (the
|
|
98
|
+
* leading edge) and opens a `ms` window. Calls during the window are dropped
|
|
99
|
+
* from immediate firing but their args are remembered; when the window closes,
|
|
100
|
+
* `fn` fires ONCE more with the LATEST dropped args (the trailing edge) and a
|
|
101
|
+
* new window opens. A call after the window has already closed leads a fresh
|
|
102
|
+
* window immediately. Spacing every call at least `ms` apart therefore fires
|
|
103
|
+
* each one on its own leading edge.
|
|
104
|
+
*
|
|
105
|
+
* @param fn The handler to rate-limit. Typically `(...) => runtime.dispatch(...)`,
|
|
106
|
+
* but any `(...args: A) => void` works. The return value is
|
|
107
|
+
* ignored — throttle is a fire transformer, not a value pipe.
|
|
108
|
+
* @param ms Window length in milliseconds. `fn` fires at most once per `ms`.
|
|
109
|
+
* @param opts.leading Fire on the FIRST call of a window (the leading edge),
|
|
110
|
+
* immediately. Default `true`.
|
|
111
|
+
* @param opts.trailing Fire once at window END with the latest args dropped
|
|
112
|
+
* during the window. Default `true`.
|
|
113
|
+
*
|
|
114
|
+
* Edge combinations (matching lodash's settled semantics, the de-facto
|
|
115
|
+
* standard the ecosystem rediscovered):
|
|
116
|
+
*
|
|
117
|
+
* - `{ leading: true, trailing: true }` (default): immediate fire + a
|
|
118
|
+
* trailing fire per window while calls keep arriving. The trailing fire is
|
|
119
|
+
* SUPPRESSED when no extra call arrived during the window (a lone call
|
|
120
|
+
* already fired on the leading edge — no stale trailing double-fire).
|
|
121
|
+
* - `{ leading: true, trailing: false }`: only the immediate fire; everything
|
|
122
|
+
* in the window is dropped with no catch-up at the end.
|
|
123
|
+
* - `{ leading: false, trailing: true }`: no immediate fire; the FIRST call
|
|
124
|
+
* opens a window and `fn` fires at the window's end with the latest args.
|
|
125
|
+
* Steady "sample every `ms`" behavior with no instant response.
|
|
126
|
+
* - `{ leading: false, trailing: false }`: never fires. Degenerate but legal;
|
|
127
|
+
* we don't throw — the caller asked for a no-op transformer.
|
|
128
|
+
*
|
|
129
|
+
* WHY a default of leading + trailing both `true`: a throttle's job is "respond
|
|
130
|
+
* now, then keep responding at a steady rate." Leading gives the instant
|
|
131
|
+
* response (the first `mousemove` updates immediately); trailing guarantees the
|
|
132
|
+
* FINAL sample of a window isn't lost (the cursor ends where the user actually
|
|
133
|
+
* left it, not one window-width behind). Dropping either loses one of those two
|
|
134
|
+
* guarantees, so both default on.
|
|
135
|
+
*/
|
|
136
|
+
declare function throttle<A extends readonly unknown[]>(fn: (...args: A) => void, ms: number, opts?: {
|
|
137
|
+
leading?: boolean;
|
|
138
|
+
trailing?: boolean;
|
|
139
|
+
}): Throttled<A>;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* internal/timing/throttled-input — gate a high-frequency input stream into a
|
|
11
143
|
* SETTLED, RATE-CAPPED, optionally DEDUPED sequence of emits, as a TEA knob: one
|
|
12
144
|
* config object + a few pre-wired hooks you spread into your machine.
|
|
13
145
|
*
|
|
@@ -89,9 +221,9 @@ import '../types-D7u9DkH7.js';
|
|
|
89
221
|
*
|
|
90
222
|
* NOT a substrate primitive: it depends only on sibling subpaths (`../throttle`,
|
|
91
223
|
* `../debounce`, `../cache`, `../deadline`) and the core `Cmd` / `Sub` types.
|
|
92
|
-
*
|
|
93
|
-
* escape hatch is those
|
|
94
|
-
*
|
|
224
|
+
* Internal since #47 — reached from inside the package as
|
|
225
|
+
* `internal/timing/throttled-input`; the L1 escape hatch is those siblings
|
|
226
|
+
* threaded by hand. Same one-shape-per-package rule as `batch-window` and `poller`.
|
|
95
227
|
*/
|
|
96
228
|
|
|
97
229
|
/**
|
|
@@ -377,4 +509,4 @@ interface ThrottledInputKnob<V, C extends Cmd> {
|
|
|
377
509
|
*/
|
|
378
510
|
declare function createThrottledInput<V, C extends Cmd>(config: ThrottledInputConfig<V, C>): ThrottledInputKnob<V, C>;
|
|
379
511
|
|
|
380
|
-
export { type PendingInput, type ThrottledInput, type ThrottledInputConfig, type ThrottledInputKnob, type ThrottledInputNoCache, type ThrottledInputSub, type ThrottledInputWithCache, createThrottledInput, initThrottledInput, input, onFlush, subsFor };
|
|
512
|
+
export { type PendingInput, type Throttled, type ThrottledInput, type ThrottledInputConfig, type ThrottledInputKnob, type ThrottledInputNoCache, type ThrottledInputSub, type ThrottledInputWithCache, createThrottledInput, initThrottledInput, input, onFlush, subsFor, throttle };
|
|
@@ -1,15 +1,60 @@
|
|
|
1
|
-
export { debounce } from '../chunk-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { initCache, get, set } from '../chunk-7SVIRMC6.js';
|
|
6
|
-
import '../chunk-3JU6657S.js';
|
|
7
|
-
import '../chunk-2YFLOCWX.js';
|
|
8
|
-
import '../chunk-ZJ5AOYBH.js';
|
|
9
|
-
import '../chunk-5EHLEUTL.js';
|
|
10
|
-
import '../chunk-B5VXOFMZ.js';
|
|
1
|
+
export { debounce } from '../chunk-LFZUK6J2.js';
|
|
2
|
+
import { deadlineSub, initCache, get, set } from '../chunk-F2US5BW6.js';
|
|
3
|
+
export { subscribeDeadline as subscribeThrottledInput, deadlineExceeded as throttledInputSettled } from '../chunk-F2US5BW6.js';
|
|
4
|
+
import '../chunk-RQULHGYH.js';
|
|
11
5
|
|
|
12
|
-
// src/
|
|
6
|
+
// src/internal/timing/throttle/index.ts
|
|
7
|
+
function throttle(fn, ms, opts) {
|
|
8
|
+
const leading = opts?.leading ?? true;
|
|
9
|
+
const trailing = opts?.trailing ?? true;
|
|
10
|
+
let handle = null;
|
|
11
|
+
let pendingArgs = null;
|
|
12
|
+
function clearHandle() {
|
|
13
|
+
if (handle !== null) {
|
|
14
|
+
clearTimeout(handle);
|
|
15
|
+
handle = null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function onWindowExpired() {
|
|
19
|
+
if (trailing && pendingArgs !== null) {
|
|
20
|
+
const args = pendingArgs;
|
|
21
|
+
pendingArgs = null;
|
|
22
|
+
handle = setTimeout(onWindowExpired, ms);
|
|
23
|
+
fn(...args);
|
|
24
|
+
} else {
|
|
25
|
+
handle = null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const throttled = (...args) => {
|
|
29
|
+
if (handle === null) {
|
|
30
|
+
if (leading) {
|
|
31
|
+
fn(...args);
|
|
32
|
+
} else if (trailing) {
|
|
33
|
+
pendingArgs = args;
|
|
34
|
+
}
|
|
35
|
+
handle = setTimeout(onWindowExpired, ms);
|
|
36
|
+
} else if (trailing) {
|
|
37
|
+
pendingArgs = args;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
throttled.cancel = () => {
|
|
41
|
+
clearHandle();
|
|
42
|
+
pendingArgs = null;
|
|
43
|
+
};
|
|
44
|
+
throttled.flush = () => {
|
|
45
|
+
if (pendingArgs !== null) {
|
|
46
|
+
const args = pendingArgs;
|
|
47
|
+
pendingArgs = null;
|
|
48
|
+
clearHandle();
|
|
49
|
+
fn(...args);
|
|
50
|
+
} else {
|
|
51
|
+
clearHandle();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return throttled;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/internal/timing/throttled-input/index.ts
|
|
13
58
|
var DEFAULT_SUB_ID = "throttled-input:settle";
|
|
14
59
|
function initThrottledInput() {
|
|
15
60
|
return { lastAt: null, pending: null };
|
|
@@ -84,6 +129,6 @@ function createThrottledInput(config) {
|
|
|
84
129
|
};
|
|
85
130
|
}
|
|
86
131
|
|
|
87
|
-
export { createThrottledInput, initThrottledInput, input, onFlush, subsFor };
|
|
132
|
+
export { createThrottledInput, initThrottledInput, input, onFlush, subsFor, throttle };
|
|
88
133
|
//# sourceMappingURL=index.js.map
|
|
89
134
|
//# sourceMappingURL=index.js.map
|