@graphrefly/graphrefly 0.43.0 → 0.45.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 +21 -17
- package/dist/compat/index.cjs +20 -10
- package/dist/compat/index.cjs.map +1 -0
- package/dist/compat/index.d.cts +1 -22
- package/dist/compat/index.d.ts +1 -22
- package/dist/compat/index.js +3 -1
- package/dist/compat/index.js.map +1 -0
- package/dist/compat/jotai/index.cjs +21 -1
- package/dist/compat/jotai/index.cjs.map +1 -0
- package/dist/compat/jotai/index.d.cts +1 -2
- package/dist/compat/jotai/index.d.ts +1 -2
- package/dist/compat/jotai/index.js +3 -1
- package/dist/compat/jotai/index.js.map +1 -0
- package/dist/compat/nanostores/index.cjs +21 -1
- package/dist/compat/nanostores/index.cjs.map +1 -0
- package/dist/compat/nanostores/index.d.cts +1 -2
- package/dist/compat/nanostores/index.d.ts +1 -2
- package/dist/compat/nanostores/index.js +3 -1
- package/dist/compat/nanostores/index.js.map +1 -0
- package/dist/compat/nestjs/index.cjs +20 -10
- package/dist/compat/nestjs/index.cjs.map +1 -0
- package/dist/compat/nestjs/index.d.cts +1 -13
- package/dist/compat/nestjs/index.d.ts +1 -13
- package/dist/compat/nestjs/index.js +3 -1
- package/dist/compat/nestjs/index.js.map +1 -0
- package/dist/compat/react/index.cjs +21 -1
- package/dist/compat/react/index.cjs.map +1 -0
- package/dist/compat/react/index.d.cts +1 -2
- package/dist/compat/react/index.d.ts +1 -2
- package/dist/compat/react/index.js +3 -1
- package/dist/compat/react/index.js.map +1 -0
- package/dist/compat/solid/index.cjs +21 -1
- package/dist/compat/solid/index.cjs.map +1 -0
- package/dist/compat/solid/index.d.cts +1 -2
- package/dist/compat/solid/index.d.ts +1 -2
- package/dist/compat/solid/index.js +3 -1
- package/dist/compat/solid/index.js.map +1 -0
- package/dist/compat/svelte/index.cjs +21 -1
- package/dist/compat/svelte/index.cjs.map +1 -0
- package/dist/compat/svelte/index.d.cts +1 -2
- package/dist/compat/svelte/index.d.ts +1 -2
- package/dist/compat/svelte/index.js +3 -1
- package/dist/compat/svelte/index.js.map +1 -0
- package/dist/compat/vue/index.cjs +21 -1
- package/dist/compat/vue/index.cjs.map +1 -0
- package/dist/compat/vue/index.d.cts +1 -3
- package/dist/compat/vue/index.d.ts +1 -3
- package/dist/compat/vue/index.js +3 -1
- package/dist/compat/vue/index.js.map +1 -0
- package/dist/compat/zustand/index.cjs +21 -3
- package/dist/compat/zustand/index.cjs.map +1 -0
- package/dist/compat/zustand/index.d.cts +1 -6
- package/dist/compat/zustand/index.d.ts +1 -6
- package/dist/compat/zustand/index.js +3 -1
- package/dist/compat/zustand/index.js.map +1 -0
- package/dist/core/index.cjs +21 -1
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +1 -4
- package/dist/core/index.d.ts +1 -4
- package/dist/core/index.js +3 -1
- package/dist/core/index.js.map +1 -0
- package/dist/extra/browser.cjs +21 -1
- package/dist/extra/browser.cjs.map +1 -0
- package/dist/extra/browser.d.cts +1 -4
- package/dist/extra/browser.d.ts +1 -4
- package/dist/extra/browser.js +3 -1
- package/dist/extra/browser.js.map +1 -0
- package/dist/extra/index.cjs +20 -19
- package/dist/extra/index.cjs.map +1 -0
- package/dist/extra/index.d.cts +1 -17
- package/dist/extra/index.d.ts +1 -17
- package/dist/extra/index.js +3 -1
- package/dist/extra/index.js.map +1 -0
- package/dist/extra/node.cjs +21 -2
- package/dist/extra/node.cjs.map +1 -0
- package/dist/extra/node.d.cts +1 -187
- package/dist/extra/node.d.ts +1 -187
- package/dist/extra/node.js +3 -2
- package/dist/extra/node.js.map +1 -0
- package/dist/extra/operators.cjs +21 -1
- package/dist/extra/operators.cjs.map +1 -0
- package/dist/extra/operators.d.cts +1 -950
- package/dist/extra/operators.d.ts +1 -950
- package/dist/extra/operators.js +3 -1
- package/dist/extra/operators.js.map +1 -0
- package/dist/extra/reactive.cjs +21 -1
- package/dist/extra/reactive.cjs.map +1 -0
- package/dist/extra/reactive.d.cts +1 -353
- package/dist/extra/reactive.d.ts +1 -353
- package/dist/extra/reactive.js +3 -1
- package/dist/extra/reactive.js.map +1 -0
- package/dist/extra/render/index.cjs +21 -5
- package/dist/extra/render/index.cjs.map +1 -0
- package/dist/extra/render/index.d.cts +1 -183
- package/dist/extra/render/index.d.ts +1 -183
- package/dist/extra/render/index.js +3 -1
- package/dist/extra/render/index.js.map +1 -0
- package/dist/extra/sources.cjs +21 -3
- package/dist/extra/sources.cjs.map +1 -0
- package/dist/extra/sources.d.cts +1 -584
- package/dist/extra/sources.d.ts +1 -584
- package/dist/extra/sources.js +3 -1
- package/dist/extra/sources.js.map +1 -0
- package/dist/extra/storage-browser.cjs +21 -1
- package/dist/extra/storage-browser.cjs.map +1 -0
- package/dist/extra/storage-browser.d.cts +1 -37
- package/dist/extra/storage-browser.d.ts +1 -37
- package/dist/extra/storage-browser.js +3 -1
- package/dist/extra/storage-browser.js.map +1 -0
- package/dist/extra/storage-core.cjs +21 -1
- package/dist/extra/storage-core.cjs.map +1 -0
- package/dist/extra/storage-core.d.cts +1 -28
- package/dist/extra/storage-core.d.ts +1 -28
- package/dist/extra/storage-core.js +3 -1
- package/dist/extra/storage-core.js.map +1 -0
- package/dist/extra/storage-node.cjs +20 -0
- package/dist/extra/storage-node.cjs.map +1 -0
- package/dist/extra/storage-node.d.cts +1 -2
- package/dist/extra/storage-node.d.ts +1 -2
- package/dist/extra/storage-node.js +3 -0
- package/dist/extra/storage-node.js.map +1 -0
- package/dist/extra/storage-tiers-browser.cjs +21 -1
- package/dist/extra/storage-tiers-browser.cjs.map +1 -0
- package/dist/extra/storage-tiers-browser.d.cts +1 -120
- package/dist/extra/storage-tiers-browser.d.ts +1 -120
- package/dist/extra/storage-tiers-browser.js +3 -1
- package/dist/extra/storage-tiers-browser.js.map +1 -0
- package/dist/extra/storage-tiers-node.cjs +21 -1
- package/dist/extra/storage-tiers-node.cjs.map +1 -0
- package/dist/extra/storage-tiers-node.d.cts +1 -210
- package/dist/extra/storage-tiers-node.d.ts +1 -210
- package/dist/extra/storage-tiers-node.js +3 -1
- package/dist/extra/storage-tiers-node.js.map +1 -0
- package/dist/extra/storage-tiers.cjs +21 -1
- package/dist/extra/storage-tiers.cjs.map +1 -0
- package/dist/extra/storage-tiers.d.cts +1 -412
- package/dist/extra/storage-tiers.d.ts +1 -412
- package/dist/extra/storage-tiers.js +3 -1
- package/dist/extra/storage-tiers.js.map +1 -0
- package/dist/extra/storage-wal.cjs +21 -0
- package/dist/extra/storage-wal.cjs.map +1 -0
- package/dist/extra/storage-wal.d.cts +1 -0
- package/dist/extra/storage-wal.d.ts +1 -0
- package/dist/extra/storage-wal.js +3 -0
- package/dist/extra/storage-wal.js.map +1 -0
- package/dist/graph/index.cjs +21 -7
- package/dist/graph/index.cjs.map +1 -0
- package/dist/graph/index.d.cts +1 -7
- package/dist/graph/index.d.ts +1 -7
- package/dist/graph/index.js +3 -1
- package/dist/graph/index.js.map +1 -0
- package/dist/index.cjs +20 -227
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +45 -96
- package/dist/index.d.ts +45 -96
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -0
- package/dist/patterns/ai/browser.cjs +20 -7
- package/dist/patterns/ai/browser.cjs.map +1 -0
- package/dist/patterns/ai/browser.d.cts +1 -127
- package/dist/patterns/ai/browser.d.ts +1 -127
- package/dist/patterns/ai/browser.js +3 -3
- package/dist/patterns/ai/browser.js.map +1 -0
- package/dist/patterns/ai/index.cjs +20 -73
- package/dist/patterns/ai/index.cjs.map +1 -0
- package/dist/patterns/ai/index.d.cts +1 -21
- package/dist/patterns/ai/index.d.ts +1 -21
- package/dist/patterns/ai/index.js +3 -1
- package/dist/patterns/ai/index.js.map +1 -0
- package/dist/patterns/ai/node.cjs +21 -1
- package/dist/patterns/ai/node.cjs.map +1 -0
- package/dist/patterns/ai/node.d.cts +1 -59
- package/dist/patterns/ai/node.d.ts +1 -59
- package/dist/patterns/ai/node.js +3 -1
- package/dist/patterns/ai/node.js.map +1 -0
- package/dist/patterns/cqrs/index.cjs +21 -3
- package/dist/patterns/cqrs/index.cjs.map +1 -0
- package/dist/patterns/cqrs/index.d.cts +1 -8
- package/dist/patterns/cqrs/index.d.ts +1 -8
- package/dist/patterns/cqrs/index.js +3 -1
- package/dist/patterns/cqrs/index.js.map +1 -0
- package/dist/patterns/demo-shell/index.cjs +21 -5
- package/dist/patterns/demo-shell/index.cjs.map +1 -0
- package/dist/patterns/demo-shell/index.d.cts +1 -7
- package/dist/patterns/demo-shell/index.d.ts +1 -7
- package/dist/patterns/demo-shell/index.js +3 -1
- package/dist/patterns/demo-shell/index.js.map +1 -0
- package/dist/patterns/domain-templates/index.cjs +21 -3
- package/dist/patterns/domain-templates/index.cjs.map +1 -0
- package/dist/patterns/domain-templates/index.d.cts +1 -6
- package/dist/patterns/domain-templates/index.d.ts +1 -6
- package/dist/patterns/domain-templates/index.js +3 -1
- package/dist/patterns/domain-templates/index.js.map +1 -0
- package/dist/patterns/graphspec/index.cjs +21 -86
- package/dist/patterns/graphspec/index.cjs.map +1 -0
- package/dist/patterns/graphspec/index.d.cts +1 -8
- package/dist/patterns/graphspec/index.d.ts +1 -8
- package/dist/patterns/graphspec/index.js +3 -1
- package/dist/patterns/graphspec/index.js.map +1 -0
- package/dist/patterns/harness/index.cjs +21 -48
- package/dist/patterns/harness/index.cjs.map +1 -0
- package/dist/patterns/harness/index.d.cts +1 -14
- package/dist/patterns/harness/index.d.ts +1 -14
- package/dist/patterns/harness/index.js +3 -1
- package/dist/patterns/harness/index.js.map +1 -0
- package/dist/patterns/inspect/index.cjs +21 -3
- package/dist/patterns/inspect/index.cjs.map +1 -0
- package/dist/patterns/inspect/index.d.cts +1 -9
- package/dist/patterns/inspect/index.d.ts +1 -9
- package/dist/patterns/inspect/index.js +3 -1
- package/dist/patterns/inspect/index.js.map +1 -0
- package/dist/patterns/job-queue/index.cjs +21 -3
- package/dist/patterns/job-queue/index.cjs.map +1 -0
- package/dist/patterns/job-queue/index.d.cts +1 -9
- package/dist/patterns/job-queue/index.d.ts +1 -9
- package/dist/patterns/job-queue/index.js +3 -1
- package/dist/patterns/job-queue/index.js.map +1 -0
- package/dist/patterns/memory/index.cjs +21 -3
- package/dist/patterns/memory/index.cjs.map +1 -0
- package/dist/patterns/memory/index.d.cts +1 -8
- package/dist/patterns/memory/index.d.ts +1 -8
- package/dist/patterns/memory/index.js +3 -1
- package/dist/patterns/memory/index.js.map +1 -0
- package/dist/patterns/messaging/index.cjs +21 -3
- package/dist/patterns/messaging/index.cjs.map +1 -0
- package/dist/patterns/messaging/index.d.cts +1 -7
- package/dist/patterns/messaging/index.d.ts +1 -7
- package/dist/patterns/messaging/index.js +3 -1
- package/dist/patterns/messaging/index.js.map +1 -0
- package/dist/patterns/orchestration/index.cjs +21 -3
- package/dist/patterns/orchestration/index.cjs.map +1 -0
- package/dist/patterns/orchestration/index.d.cts +1 -9
- package/dist/patterns/orchestration/index.d.ts +1 -9
- package/dist/patterns/orchestration/index.js +3 -1
- package/dist/patterns/orchestration/index.js.map +1 -0
- package/dist/patterns/process/index.cjs +21 -1
- package/dist/patterns/process/index.cjs.map +1 -0
- package/dist/patterns/process/index.d.cts +1 -10
- package/dist/patterns/process/index.d.ts +1 -10
- package/dist/patterns/process/index.js +3 -1
- package/dist/patterns/process/index.js.map +1 -0
- package/dist/patterns/reactive-layout/index.cjs +21 -4
- package/dist/patterns/reactive-layout/index.cjs.map +1 -0
- package/dist/patterns/reactive-layout/index.d.cts +1 -7
- package/dist/patterns/reactive-layout/index.d.ts +1 -7
- package/dist/patterns/reactive-layout/index.js +3 -1
- package/dist/patterns/reactive-layout/index.js.map +1 -0
- package/dist/patterns/reduction/index.cjs +21 -3
- package/dist/patterns/reduction/index.cjs.map +1 -0
- package/dist/patterns/reduction/index.d.cts +1 -6
- package/dist/patterns/reduction/index.d.ts +1 -6
- package/dist/patterns/reduction/index.js +3 -1
- package/dist/patterns/reduction/index.js.map +1 -0
- package/dist/patterns/surface/index.cjs +21 -13
- package/dist/patterns/surface/index.cjs.map +1 -0
- package/dist/patterns/surface/index.d.cts +1 -9
- package/dist/patterns/surface/index.d.ts +1 -9
- package/dist/patterns/surface/index.js +3 -1
- package/dist/patterns/surface/index.js.map +1 -0
- package/dist/patterns/topology-view/index.cjs +21 -0
- package/dist/patterns/topology-view/index.cjs.map +1 -0
- package/dist/patterns/topology-view/index.d.cts +1 -0
- package/dist/patterns/topology-view/index.d.ts +1 -0
- package/dist/patterns/topology-view/index.js +3 -0
- package/dist/patterns/topology-view/index.js.map +1 -0
- package/dist/testing/index.cjs +21 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +1 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.js +3 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +608 -584
- package/dist/backoff-HPZMEZNF.js +0 -1
- package/dist/cascading-CH-_VwG9.d.cts +0 -199
- package/dist/cascading-OgKQZjsa.d.ts +0 -199
- package/dist/chunk-35JTVPOX.js +0 -1
- package/dist/chunk-3G5U5QNE.js +0 -5
- package/dist/chunk-3XDYJRYU.js +0 -1
- package/dist/chunk-4I45FVQS.js +0 -1
- package/dist/chunk-4VVTGLXJ.js +0 -1
- package/dist/chunk-4YAN45KM.js +0 -1
- package/dist/chunk-5QDBSZBV.js +0 -1
- package/dist/chunk-626TESAC.js +0 -3
- package/dist/chunk-6HOSXQKF.js +0 -1
- package/dist/chunk-6QZNQS5B.js +0 -1
- package/dist/chunk-C72GO4IZ.js +0 -1
- package/dist/chunk-CE72X3WO.js +0 -1
- package/dist/chunk-CK2E7BTU.js +0 -1
- package/dist/chunk-CLD3F4R5.js +0 -1
- package/dist/chunk-CUNIRONA.js +0 -1
- package/dist/chunk-D27JNOLZ.js +0 -1
- package/dist/chunk-D5RFJOZ2.js +0 -1
- package/dist/chunk-EBW4V6JN.js +0 -1
- package/dist/chunk-ESMPEKEV.js +0 -1
- package/dist/chunk-F3IGTWCQ.js +0 -1
- package/dist/chunk-F672GV32.js +0 -1
- package/dist/chunk-FDQGFWLF.js +0 -1
- package/dist/chunk-FG4TKHMC.js +0 -1
- package/dist/chunk-GPW2V3RE.js +0 -1
- package/dist/chunk-I7IGYPSL.js +0 -1
- package/dist/chunk-INQD2KRQ.js +0 -1
- package/dist/chunk-JNWRYDJN.js +0 -1
- package/dist/chunk-JQFH2DV6.js +0 -1
- package/dist/chunk-K2Q24F5T.js +0 -1
- package/dist/chunk-KGKJCHEK.js +0 -1
- package/dist/chunk-KRH66M4O.js +0 -1
- package/dist/chunk-KVV66NN2.js +0 -1
- package/dist/chunk-L6NSJVJZ.js +0 -1
- package/dist/chunk-LYCLF26R.js +0 -1
- package/dist/chunk-NNKJUORL.js +0 -1
- package/dist/chunk-NON4NLIC.js +0 -45
- package/dist/chunk-O2BLLH7M.js +0 -18
- package/dist/chunk-OCKEEPRJ.js +0 -2
- package/dist/chunk-OFZG3TB3.js +0 -9
- package/dist/chunk-OYJKFY7V.js +0 -1
- package/dist/chunk-P6C4WHZO.js +0 -5
- package/dist/chunk-PT7W5FCD.js +0 -5
- package/dist/chunk-Q4U3A3L5.js +0 -1
- package/dist/chunk-QE4IGY7I.js +0 -61
- package/dist/chunk-QYADASLV.js +0 -1
- package/dist/chunk-QYVXF7GW.js +0 -1
- package/dist/chunk-S3EEIPO7.js +0 -1
- package/dist/chunk-SUWT3ZON.js +0 -1
- package/dist/chunk-TPKQW72B.js +0 -1
- package/dist/chunk-TSOYJ743.js +0 -1
- package/dist/chunk-TZQPPQEQ.js +0 -1
- package/dist/chunk-V5A7M7RJ.js +0 -1
- package/dist/chunk-VIMF6LGM.js +0 -1
- package/dist/chunk-VJLMUKOI.js +0 -1
- package/dist/chunk-VN6RDSK2.js +0 -1
- package/dist/chunk-VNC3TMVY.js +0 -1
- package/dist/chunk-VOPGGIL7.js +0 -1
- package/dist/chunk-VQ4A6T2A.js +0 -1
- package/dist/chunk-XG62INFA.js +0 -1
- package/dist/chunk-Y4NI3X7O.js +0 -84
- package/dist/content-addressed-storage-4-ST1tYk.d.cts +0 -124
- package/dist/content-addressed-storage-DuYMjV7o.d.ts +0 -124
- package/dist/decay-2ZukgQ4o.d.cts +0 -112
- package/dist/decay-CdEBmDIs.d.ts +0 -112
- package/dist/fallback-CqYVLL6X.d.ts +0 -250
- package/dist/fallback-Ctlj2tMY.d.cts +0 -250
- package/dist/graph-7VguS7a4.d.ts +0 -1668
- package/dist/graph-C4SHb3Ly.d.cts +0 -1668
- package/dist/index-0rKFCVFp.d.cts +0 -557
- package/dist/index-B-i4_g3k.d.ts +0 -651
- package/dist/index-B5iz82A3.d.cts +0 -2655
- package/dist/index-BAOD98JD.d.cts +0 -754
- package/dist/index-BG0BN3PB.d.ts +0 -44
- package/dist/index-BJX94aud.d.cts +0 -34
- package/dist/index-BP8a88zx.d.ts +0 -385
- package/dist/index-BTQtTb_H.d.cts +0 -301
- package/dist/index-BVpm6noz.d.cts +0 -36
- package/dist/index-Bc41FuHp.d.cts +0 -291
- package/dist/index-BdGtBX-X.d.cts +0 -515
- package/dist/index-Bf7eqeSF.d.ts +0 -113
- package/dist/index-BiX1Nkgx.d.cts +0 -1844
- package/dist/index-BoLv_OfD.d.cts +0 -651
- package/dist/index-BojK2fwH.d.cts +0 -299
- package/dist/index-BsT7F2et.d.ts +0 -291
- package/dist/index-BwLvVVsy.d.cts +0 -189
- package/dist/index-C59mYFKp.d.ts +0 -121
- package/dist/index-C7O6r5fV.d.ts +0 -37
- package/dist/index-C9kSENB4.d.cts +0 -127
- package/dist/index-C9pjcz3l.d.cts +0 -209
- package/dist/index-CAC_rNzm.d.ts +0 -189
- package/dist/index-CCq87F7t.d.ts +0 -127
- package/dist/index-CDXc9zKM.d.cts +0 -26
- package/dist/index-CJK1JkYy.d.ts +0 -36
- package/dist/index-CLon-IWF.d.cts +0 -374
- package/dist/index-COD1kVoS.d.cts +0 -468
- package/dist/index-CPT7C_f1.d.ts +0 -374
- package/dist/index-CQG3D1cp.d.ts +0 -468
- package/dist/index-CZQXo5tH.d.ts +0 -209
- package/dist/index-CZjOhcBy.d.cts +0 -113
- package/dist/index-ChOyVLKm.d.cts +0 -86
- package/dist/index-CvrqGfNS.d.ts +0 -34
- package/dist/index-D-AEQVLo.d.ts +0 -2655
- package/dist/index-D4Y1cMG0.d.ts +0 -26
- package/dist/index-DBHK8O6H.d.ts +0 -301
- package/dist/index-DBevwHj_.d.ts +0 -515
- package/dist/index-DIOoAZUX.d.ts +0 -45
- package/dist/index-DSZ3ZCHF.d.ts +0 -3402
- package/dist/index-Dgs8zcj7.d.ts +0 -102
- package/dist/index-Dh_HJ82K.d.ts +0 -299
- package/dist/index-Dhc7a7Xo.d.cts +0 -102
- package/dist/index-Dmqp7KjD.d.ts +0 -86
- package/dist/index-Dn-wI9g4.d.ts +0 -231
- package/dist/index-Du7u1lSf.d.cts +0 -385
- package/dist/index-DwigL4lY.d.ts +0 -1844
- package/dist/index-DyR7eU5S.d.cts +0 -779
- package/dist/index-JZUPJIJy.d.ts +0 -779
- package/dist/index-K0_0eR8g.d.ts +0 -557
- package/dist/index-O16yXPK4.d.cts +0 -3402
- package/dist/index-O7fucFrU.d.cts +0 -121
- package/dist/index-RV_yDjOX.d.cts +0 -198
- package/dist/index-cm1GNcWE.d.ts +0 -754
- package/dist/index-f5IivDUX.d.cts +0 -37
- package/dist/index-hHcaFlJX.d.cts +0 -45
- package/dist/index-tJoTcnHh.d.cts +0 -231
- package/dist/index-wAzD9yVj.d.ts +0 -198
- package/dist/index-z96luz5O.d.cts +0 -44
- package/dist/meta-BgVAsg9j.d.ts +0 -102
- package/dist/meta-vE8bxW1E.d.cts +0 -102
- package/dist/node-ClS5yC-B.d.cts +0 -1347
- package/dist/node-ClS5yC-B.d.ts +0 -1347
- package/dist/observable-BsBzUrcI.d.ts +0 -36
- package/dist/observable-DLGPPtb8.d.cts +0 -36
- package/dist/pipeline-graph-DPqKDk59.d.cts +0 -137
- package/dist/pipeline-graph-loP57TBA.d.ts +0 -137
- package/dist/reactive-layout-Dsvob4zD.d.cts +0 -183
- package/dist/reactive-layout-v7KPvxoc.d.ts +0 -183
- package/dist/reactive-log-B00laMSQ.d.cts +0 -223
- package/dist/reactive-log-BezYsbA_.d.ts +0 -223
- package/dist/reactive-map-48mnZ-nu.d.cts +0 -296
- package/dist/reactive-map-BVVPdvmi.d.ts +0 -296
- package/dist/resilience-YIWPK4YC.js +0 -1
- package/dist/sugar-DLwvMr3F.d.ts +0 -223
- package/dist/sugar-DyVGtczU.d.cts +0 -223
- package/dist/topology-tree-BNGvuG82.d.ts +0 -25
- package/dist/topology-tree-BSdfSwMi.d.cts +0 -25
- package/dist/types-B1jDWVsM.d.cts +0 -442
- package/dist/types-DkzUUs0H.d.ts +0 -442
package/dist/node-ClS5yC-B.d.ts
DELETED
|
@@ -1,1347 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Who is performing an operation (attribution + ABAC input).
|
|
3
|
-
*
|
|
4
|
-
* @see GRAPHREFLY-SPEC — roadmap Phase 1.5 (Actor & Guard).
|
|
5
|
-
*/
|
|
6
|
-
type Actor = {
|
|
7
|
-
type: "human" | "llm" | "wallet" | "system" | string;
|
|
8
|
-
id: string;
|
|
9
|
-
} & Record<string, unknown>;
|
|
10
|
-
/** Default actor when none is passed ({@link normalizeActor}). */
|
|
11
|
-
declare const DEFAULT_ACTOR: Actor;
|
|
12
|
-
/**
|
|
13
|
-
* Fills missing `type` / `id` on an actor and returns {@link DEFAULT_ACTOR} when input is undefined.
|
|
14
|
-
*
|
|
15
|
-
* @param actor - Optional partial actor from a transport hint.
|
|
16
|
-
* @returns A normalized `Actor` safe to pass to guards and graph APIs.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* import { normalizeActor } from "@graphrefly/graphrefly-ts";
|
|
21
|
-
*
|
|
22
|
-
* normalizeActor({ type: "human", id: "u1" });
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
declare function normalizeActor(actor?: Actor): Actor;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* GraphReFly message protocol — §1 `~/src/graphrefly/GRAPHREFLY-SPEC.md`.
|
|
29
|
-
* Emissions are always `[[Type, Data?], ...]` (no single-tuple shorthand).
|
|
30
|
-
*
|
|
31
|
-
* This file is protocol-pure:
|
|
32
|
-
* - Message type symbols (10 built-ins).
|
|
33
|
-
* - `Message` / `Messages` tuple types.
|
|
34
|
-
* - `MessageTypeRegistration` interface (shape of a registry entry).
|
|
35
|
-
*
|
|
36
|
-
* It does NOT own the registry, tier lookups, or any cross-cutting singleton
|
|
37
|
-
* state — that lives in `GraphReFlyConfig` (see `config.ts`) so custom
|
|
38
|
-
* protocols can build isolated instances. Import this module when you need
|
|
39
|
-
* the symbol constants or the tuple types; import `config.ts` when you need
|
|
40
|
-
* tier / wire-crossing / registry lookups.
|
|
41
|
-
*/
|
|
42
|
-
/** Subscribe-time handshake. Delivered to each new sink at the top of `subscribe()`. Tier 0. */
|
|
43
|
-
declare const START: unique symbol;
|
|
44
|
-
/** Value delivery (`DATA`, value). Tier 3 — deferred inside `batch()`. */
|
|
45
|
-
declare const DATA: unique symbol;
|
|
46
|
-
/** Phase 1: value about to change. Tier 1 — immediate. */
|
|
47
|
-
declare const DIRTY: unique symbol;
|
|
48
|
-
/** Phase 2: dirty pass completed, value unchanged. Tier 3 — deferred inside `batch()`. */
|
|
49
|
-
declare const RESOLVED: unique symbol;
|
|
50
|
-
/** Clear cached state; do not auto-emit. Tier 1 — immediate. */
|
|
51
|
-
declare const INVALIDATE: unique symbol;
|
|
52
|
-
/** Suspend activity. Tier 2 — immediate. */
|
|
53
|
-
declare const PAUSE: unique symbol;
|
|
54
|
-
/** Resume after pause. Tier 2 — immediate. */
|
|
55
|
-
declare const RESUME: unique symbol;
|
|
56
|
-
/** Permanent cleanup. Tier 5 — deferred to batch phase 4. */
|
|
57
|
-
declare const TEARDOWN: unique symbol;
|
|
58
|
-
/** Clean termination. Tier 4 — deferred to batch phase 3. */
|
|
59
|
-
declare const COMPLETE: unique symbol;
|
|
60
|
-
/** Error termination. Tier 4 — deferred to batch phase 3. */
|
|
61
|
-
declare const ERROR: unique symbol;
|
|
62
|
-
/** One protocol tuple: `[Type, optional payload]`. */
|
|
63
|
-
type Message = readonly [symbol, unknown?];
|
|
64
|
-
/** A batch of tuples — the wire shape for `node.down()` / `node.up()`. */
|
|
65
|
-
type Messages = readonly Message[];
|
|
66
|
-
/** Singleton `[DIRTY]` tuple — payload-free, interned. */
|
|
67
|
-
declare const DIRTY_MSG: Message;
|
|
68
|
-
/** Singleton `[RESOLVED]` tuple — payload-free, interned. */
|
|
69
|
-
declare const RESOLVED_MSG: Message;
|
|
70
|
-
/** Singleton `[INVALIDATE]` tuple — payload-free, interned. */
|
|
71
|
-
declare const INVALIDATE_MSG: Message;
|
|
72
|
-
/** Singleton `[START]` tuple — payload-free, interned. */
|
|
73
|
-
declare const START_MSG: Message;
|
|
74
|
-
/** Singleton `[COMPLETE]` tuple — payload-free, interned. */
|
|
75
|
-
declare const COMPLETE_MSG: Message;
|
|
76
|
-
/** Singleton `[TEARDOWN]` tuple — payload-free, interned. */
|
|
77
|
-
declare const TEARDOWN_MSG: Message;
|
|
78
|
-
/** Pre-wrapped `[[DIRTY]]` for `_emit([DIRTY_ONLY_BATCH])`-style callers. */
|
|
79
|
-
declare const DIRTY_ONLY_BATCH: Messages;
|
|
80
|
-
/** Pre-wrapped `[[RESOLVED]]`. */
|
|
81
|
-
declare const RESOLVED_ONLY_BATCH: Messages;
|
|
82
|
-
/** Pre-wrapped `[[INVALIDATE]]`. */
|
|
83
|
-
declare const INVALIDATE_ONLY_BATCH: Messages;
|
|
84
|
-
/** Pre-wrapped `[[COMPLETE]]`. */
|
|
85
|
-
declare const COMPLETE_ONLY_BATCH: Messages;
|
|
86
|
-
/** Pre-wrapped `[[TEARDOWN]]`. */
|
|
87
|
-
declare const TEARDOWN_ONLY_BATCH: Messages;
|
|
88
|
-
/**
|
|
89
|
-
* Per-type record stored in a {@link GraphReFlyConfig}'s registry.
|
|
90
|
-
*
|
|
91
|
-
* - `tier` — signal tier (0–5 built-in; custom tiers allowed but should fit
|
|
92
|
-
* the phase model used by `batch.ts`).
|
|
93
|
-
* - `wireCrossing` — when `true`, forwarded across SSE/WebSocket/worker
|
|
94
|
-
* adapters. Defaults to `tier >= 3` if omitted in registration input.
|
|
95
|
-
* - `metaPassthrough` — when `false`, this message type is filtered out of
|
|
96
|
-
* `Graph.signal` deliveries to meta companion nodes (spec §2.3). Meta
|
|
97
|
-
* companions still receive everything via their primary's own cascade.
|
|
98
|
-
* Defaults to `true` (meta receives the message).
|
|
99
|
-
*/
|
|
100
|
-
interface MessageTypeRegistration {
|
|
101
|
-
tier: number;
|
|
102
|
-
wireCrossing: boolean;
|
|
103
|
-
metaPassthrough: boolean;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Input accepted by {@link GraphReFlyConfig.registerMessageType}. Only `tier`
|
|
107
|
-
* is required; `wireCrossing` defaults to `tier >= 3`; `metaPassthrough`
|
|
108
|
-
* defaults to `true`.
|
|
109
|
-
*/
|
|
110
|
-
interface MessageTypeRegistrationInput {
|
|
111
|
-
tier: number;
|
|
112
|
-
wireCrossing?: boolean;
|
|
113
|
-
metaPassthrough?: boolean;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Node versioning — GRAPHREFLY-SPEC §7.
|
|
118
|
-
*
|
|
119
|
-
* Progressive, optional versioning for node identity and change tracking.
|
|
120
|
-
*
|
|
121
|
-
* - **V0**: `id` + `version` — identity & change detection (~16 bytes overhead)
|
|
122
|
-
* - **V1**: + `cid` + `prev` — content addressing & linked history (~60 bytes overhead)
|
|
123
|
-
*
|
|
124
|
-
* **Lifecycle notes:**
|
|
125
|
-
* - Version advances only on DATA (not RESOLVED, INVALIDATE, or TEARDOWN).
|
|
126
|
-
* - `resetOnTeardown` clears the cached value but does NOT reset versioning state.
|
|
127
|
-
* After teardown, `v.cid` still reflects the last DATA value, not the cleared cache.
|
|
128
|
-
* The invariant `hash(node.cache) === v.cid` only holds in `settled`/`resolved` status.
|
|
129
|
-
* - Resubscribable nodes preserve versioning across subscription lifetimes (monotonic counter).
|
|
130
|
-
*/
|
|
131
|
-
/** V0: identity + monotonic version counter. */
|
|
132
|
-
type V0 = {
|
|
133
|
-
readonly id: string;
|
|
134
|
-
version: number;
|
|
135
|
-
};
|
|
136
|
-
/** V1: V0 + content-addressed identifier + previous cid link. */
|
|
137
|
-
type V1 = V0 & {
|
|
138
|
-
cid: string;
|
|
139
|
-
prev: string | null;
|
|
140
|
-
};
|
|
141
|
-
/** Union of all versioning info shapes. */
|
|
142
|
-
type NodeVersionInfo = V0 | V1;
|
|
143
|
-
/** Supported versioning levels (extensible to 2, 3 later). */
|
|
144
|
-
type VersioningLevel = 0 | 1;
|
|
145
|
-
/** Function that hashes a value to a hex string (for V1 cid). */
|
|
146
|
-
type HashFn = (value: unknown) => string;
|
|
147
|
-
interface VersioningOptions {
|
|
148
|
-
/** Override auto-generated id. */
|
|
149
|
-
id?: string;
|
|
150
|
-
/** Custom hash function for V1 cid (default: SHA-256 truncated to 16 hex chars). */
|
|
151
|
-
hash?: HashFn;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Default content hash: SHA-256 of deterministic JSON, truncated to 16 hex
|
|
155
|
-
* chars (~64-bit). Uses {@link canonicalizeForHash} for cross-language parity
|
|
156
|
-
* with Python `default_hash`.
|
|
157
|
-
*/
|
|
158
|
-
declare function defaultHash(value: unknown): string;
|
|
159
|
-
/**
|
|
160
|
-
* Create initial versioning state for a node.
|
|
161
|
-
*
|
|
162
|
-
* @param level - 0 for V0, 1 for V1.
|
|
163
|
-
* @param initialValue - The node's initial cached value (used for V1 cid).
|
|
164
|
-
* @param opts - Optional overrides (id, hash).
|
|
165
|
-
*/
|
|
166
|
-
declare function createVersioning(level: VersioningLevel, initialValue: unknown, opts?: VersioningOptions): NodeVersionInfo;
|
|
167
|
-
/**
|
|
168
|
-
* Advance versioning state after a DATA emission (value changed).
|
|
169
|
-
*
|
|
170
|
-
* Mutates `info` in place for performance (called on every DATA).
|
|
171
|
-
* Only call when the cached value has actually changed (not on RESOLVED).
|
|
172
|
-
*
|
|
173
|
-
* @param info - The node's current versioning state.
|
|
174
|
-
* @param newValue - The new cached value.
|
|
175
|
-
* @param hashFn - Hash function (only used for V1).
|
|
176
|
-
*/
|
|
177
|
-
declare function advanceVersion(info: NodeVersionInfo, newValue: unknown, hashFn: HashFn): void;
|
|
178
|
-
/** Type guard: is this V1 versioning info? */
|
|
179
|
-
declare function isV1(info: NodeVersionInfo): info is V1;
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Singleton protocol config. Holds the message-type registry, the
|
|
183
|
-
* `onMessage` / `onSubscribe` hooks, versioning defaults, and the freeze flag.
|
|
184
|
-
*
|
|
185
|
-
* Layering: this file is protocol-pure. It imports only from `messages.ts`
|
|
186
|
-
* and declares opaque type shapes for handlers — the concrete default
|
|
187
|
-
* implementations and the `defaultConfig` instance live in `node.ts` so that
|
|
188
|
-
* handler bodies can touch `NodeImpl` internals without creating a cycle.
|
|
189
|
-
*
|
|
190
|
-
* Two access paths:
|
|
191
|
-
* 1. **Default instance** (`defaultConfig` in `node.ts`) — use
|
|
192
|
-
* `configure((cfg) => ...)` at app startup; every node implicitly binds to it.
|
|
193
|
-
* 2. **Isolated instance** (`new GraphReFlyConfig(...)`) — pass via
|
|
194
|
-
* `opts.config` for test isolation or custom protocol stacks.
|
|
195
|
-
*
|
|
196
|
-
* A config **freezes on first getter read** of any hook (`onMessage`,
|
|
197
|
-
* `onSubscribe`). `NodeImpl`'s constructor intentionally touches one of these
|
|
198
|
-
* on first use so configuration cannot drift once nodes exist.
|
|
199
|
-
*/
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Minimal node surface visible to default handlers. Concrete `NodeImpl`
|
|
203
|
-
* implements this plus a large set of package-private fields; handlers that
|
|
204
|
-
* need the richer surface cast to the concrete type in `node.ts`.
|
|
205
|
-
*/
|
|
206
|
-
interface NodeCtx {
|
|
207
|
-
readonly name?: string;
|
|
208
|
-
readonly status: string;
|
|
209
|
-
readonly cache: unknown;
|
|
210
|
-
}
|
|
211
|
-
/** Imperative actions available inside a node's compute function (§5). */
|
|
212
|
-
interface NodeActions {
|
|
213
|
-
/**
|
|
214
|
-
* Sugar for `down([[DATA, value]])`. One call = one wave with a
|
|
215
|
-
* single DATA payload. The emit pipeline auto-prefixes `[DIRTY]`,
|
|
216
|
-
* runs equals substitution against the live cache, and dispatches
|
|
217
|
-
* to sinks with phase deferral. Diamond-safe by construction.
|
|
218
|
-
*/
|
|
219
|
-
emit(value: unknown): void;
|
|
220
|
-
/**
|
|
221
|
-
* Send one or more messages downstream. Accepts either a single
|
|
222
|
-
* {@link Message} tuple or a {@link Messages} array of tuples. One
|
|
223
|
-
* call = one wave: the emit pipeline tier-sorts the input,
|
|
224
|
-
* auto-prefixes `[DIRTY]` when a tier-3 payload is present and the
|
|
225
|
-
* node isn't already dirty, runs equals substitution, then
|
|
226
|
-
* dispatches. Multiple calls produce multiple waves.
|
|
227
|
-
*/
|
|
228
|
-
down(messageOrMessages: Message | Messages): void;
|
|
229
|
-
/**
|
|
230
|
-
* Send one or more messages upstream. Accepts the same shapes as
|
|
231
|
-
* {@link down}. Tier 3 (DATA/RESOLVED) and tier 4 (COMPLETE/ERROR)
|
|
232
|
-
* are downstream-only and will throw — up is for DIRTY, INVALIDATE,
|
|
233
|
-
* PAUSE, RESUME, and TEARDOWN only. No cache advance, no equals,
|
|
234
|
-
* no framing — a plain forward to every dep.
|
|
235
|
-
*/
|
|
236
|
-
up(messageOrMessages: Message | Messages): void;
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Message-flow context passed to {@link OnMessageHandler}.
|
|
240
|
-
*
|
|
241
|
-
* - `"down-in"` — message arriving from a dep (identified by `depIndex`).
|
|
242
|
-
* - `"up-in"` — message arriving from a sink.
|
|
243
|
-
*/
|
|
244
|
-
type MessageContext = {
|
|
245
|
-
direction: "down-in";
|
|
246
|
-
depIndex: number;
|
|
247
|
-
} | {
|
|
248
|
-
direction: "up-in";
|
|
249
|
-
};
|
|
250
|
-
/**
|
|
251
|
-
* Per-sink context passed to {@link OnSubscribeHandler}.
|
|
252
|
-
*/
|
|
253
|
-
interface SubscribeContext {
|
|
254
|
-
/** Post-subscribe sink count. `1` means first subscriber after 0. */
|
|
255
|
-
sinkCount: number;
|
|
256
|
-
/** True when this subscribe cleared a resubscribable terminal state. */
|
|
257
|
-
afterTerminalReset: boolean;
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Singleton message interceptor. Called for every message in either direction
|
|
261
|
-
* before the default per-tier dispatch runs. Return `"consume"` to suppress
|
|
262
|
-
* default handling.
|
|
263
|
-
*/
|
|
264
|
-
type OnMessageHandler = (node: NodeCtx, msg: Message, ctx: MessageContext, actions: NodeActions) => "consume" | undefined;
|
|
265
|
-
/**
|
|
266
|
-
* Singleton subscribe ceremony. Fires for every sink subscribe on every node.
|
|
267
|
-
* Default implementation emits the START handshake (+ cached DATA when
|
|
268
|
-
* present) to the new sink. Return a cleanup function to run on unsubscribe.
|
|
269
|
-
*/
|
|
270
|
-
type OnSubscribeHandler = (node: NodeCtx, sink: (messages: Messages) => void, ctx: SubscribeContext, actions: NodeActions) => (() => void) | undefined;
|
|
271
|
-
/**
|
|
272
|
-
* Event payload for {@link GlobalInspectorHook}. One event fires per outgoing
|
|
273
|
-
* message batch from any node bound to the config.
|
|
274
|
-
*
|
|
275
|
-
* - `kind: "emit"` — fires after equals substitution (`finalMessages`) and
|
|
276
|
-
* before sink dispatch. `messages` is the exact batch sinks see.
|
|
277
|
-
*/
|
|
278
|
-
type GlobalInspectorEvent = {
|
|
279
|
-
kind: "emit";
|
|
280
|
-
node: NodeCtx;
|
|
281
|
-
messages: Messages;
|
|
282
|
-
};
|
|
283
|
-
/**
|
|
284
|
-
* Process-global observability hook for full-graph tracing
|
|
285
|
-
* (Redux-DevTools-style action history). Fires from every node's `_emit`
|
|
286
|
-
* waist whenever {@link GraphReFlyConfig.inspectorEnabled} is `true`.
|
|
287
|
-
*
|
|
288
|
-
* Distinct from per-node `_setInspectorHook` (which is the dep-message /
|
|
289
|
-
* fn-run causal trace used by `Graph.observe(path, { causal, derived })`).
|
|
290
|
-
* Use the global hook to record every emission across every node — useful for
|
|
291
|
-
* time-travel debuggers, tracers, and replay tooling. Use the per-node hook
|
|
292
|
-
* to attribute a single subscribed path's wave to its driving deps.
|
|
293
|
-
*
|
|
294
|
-
* Errors thrown from the hook are swallowed — instrumentation must not break
|
|
295
|
-
* the data plane.
|
|
296
|
-
*/
|
|
297
|
-
type GlobalInspectorHook = (event: GlobalInspectorEvent) => void;
|
|
298
|
-
/**
|
|
299
|
-
* Ghost-state recorder used by the fast-check protocol invariant suite to
|
|
300
|
-
* mirror TLC invariants that reference TLA+ ghost variables (`cleanupWitness`,
|
|
301
|
-
* `terminatedBy`, `nonVacuousInvalidateCount`) with no first-class runtime
|
|
302
|
-
* representation. Attached to a `GraphReFlyConfig` via
|
|
303
|
-
* {@link GraphReFlyConfig.rigorRecorder}; zero production cost when unset
|
|
304
|
-
* (call sites in `NodeImpl` are guarded by a single `!= null` check).
|
|
305
|
-
*
|
|
306
|
-
* See `src/__tests__/properties/_invariants.ts` for the consumer side.
|
|
307
|
-
*
|
|
308
|
-
* Errors thrown from recorder methods are swallowed by `NodeImpl` — like
|
|
309
|
-
* {@link GlobalInspectorHook}, instrumentation must not break the data plane.
|
|
310
|
-
*/
|
|
311
|
-
interface RigorRecorder {
|
|
312
|
-
/**
|
|
313
|
-
* Fired at the non-vacuous branch of a node's INVALIDATE handler — the
|
|
314
|
-
* `this._cached !== undefined` path where the cleanup hook runs and the
|
|
315
|
-
* cache is reset. `prevValue` is the pre-reset `_cached` value. The
|
|
316
|
-
* vacuous branch (diamond fan-in second arrival or never-populated
|
|
317
|
-
* mid-chain derived) does NOT fire this hook, mirroring the TLA+
|
|
318
|
-
* `cleanupWitness` append guard.
|
|
319
|
-
*/
|
|
320
|
-
onNonVacuousInvalidate(node: NodeCtx, prevValue: unknown): void;
|
|
321
|
-
/**
|
|
322
|
-
* Fired when a node's status transitions to a terminal kind ("completed"
|
|
323
|
-
* or "errored"). `autoComplete` / `autoError` are the node's configured
|
|
324
|
-
* auto-terminal gates; `hasDeps` is `deps.length > 0`. Mirrors the TLA+
|
|
325
|
-
* `terminatedBy` classification ghost — dep-cascade transitions can be
|
|
326
|
-
* inferred by `hasDeps === true && autoX === true`.
|
|
327
|
-
*/
|
|
328
|
-
onTerminalTransition(node: NodeCtx, kind: "completed" | "errored", autoComplete: boolean, autoError: boolean, hasDeps: boolean): void;
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Singleton protocol config.
|
|
332
|
-
*
|
|
333
|
-
* A config freezes on first getter read of any hook. After freeze, any
|
|
334
|
-
* attempt to mutate (register a message type, set a hook) throws.
|
|
335
|
-
*/
|
|
336
|
-
declare class GraphReFlyConfig {
|
|
337
|
-
private _messageTypes;
|
|
338
|
-
private _codecs;
|
|
339
|
-
private _onMessage;
|
|
340
|
-
private _onSubscribe;
|
|
341
|
-
private _defaultVersioning;
|
|
342
|
-
private _defaultHashFn;
|
|
343
|
-
private _inspectorEnabled;
|
|
344
|
-
private _globalInspector?;
|
|
345
|
-
private _rigorRecorder?;
|
|
346
|
-
private _frozen;
|
|
347
|
-
/**
|
|
348
|
-
* Pre-bound tier lookup — shared by every node bound to this config. Since
|
|
349
|
-
* the registry is frozen on first hook access, this closure can be built
|
|
350
|
-
* once in the constructor and handed directly to `downWithBatch` /
|
|
351
|
-
* `_frameBatch` paths without per-node or per-emission `.bind(config)`
|
|
352
|
-
* allocation.
|
|
353
|
-
*/
|
|
354
|
-
readonly tierOf: (t: symbol) => number;
|
|
355
|
-
constructor(init: {
|
|
356
|
-
onMessage: OnMessageHandler;
|
|
357
|
-
onSubscribe: OnSubscribeHandler;
|
|
358
|
-
defaultVersioning?: VersioningLevel;
|
|
359
|
-
defaultHashFn?: HashFn;
|
|
360
|
-
});
|
|
361
|
-
get onMessage(): OnMessageHandler;
|
|
362
|
-
get onSubscribe(): OnSubscribeHandler;
|
|
363
|
-
set onMessage(v: OnMessageHandler);
|
|
364
|
-
set onSubscribe(v: OnSubscribeHandler);
|
|
365
|
-
/**
|
|
366
|
-
* Default versioning level applied to every node bound to this config,
|
|
367
|
-
* unless the node's own `opts.versioning` provides an explicit override.
|
|
368
|
-
* Setting this is only allowed before the config freezes (i.e., before
|
|
369
|
-
* the first node is created) so every node in the graph sees a
|
|
370
|
-
* consistent starting level. Individual nodes can still opt into a
|
|
371
|
-
* higher level via `opts.versioning`, or post-hoc via
|
|
372
|
-
* `NodeImpl._applyVersioning(level)` when the node is quiescent.
|
|
373
|
-
*
|
|
374
|
-
* v0 is the minimum opt-in — unversioned nodes (`undefined`) skip
|
|
375
|
-
* the version counter entirely. v1 adds content-addressed cid.
|
|
376
|
-
* Future levels (v2, v3) are reserved for linked-history and
|
|
377
|
-
* cryptographic attestation extensions.
|
|
378
|
-
*/
|
|
379
|
-
get defaultVersioning(): VersioningLevel | undefined;
|
|
380
|
-
set defaultVersioning(v: VersioningLevel | undefined);
|
|
381
|
-
/**
|
|
382
|
-
* Default content-hash function applied to every versioned node bound
|
|
383
|
-
* to this config, unless the node's own `opts.versioningHash` provides
|
|
384
|
-
* an explicit override. Use this when a graph needs a non-default hash
|
|
385
|
-
* — e.g., swap the vendored sync SHA-256 for a faster non-crypto hash
|
|
386
|
-
* (xxHash, FNV-1a) in hot-path workloads, or a stronger hash when
|
|
387
|
-
* versioning v1 cids are used as audit anchors.
|
|
388
|
-
*
|
|
389
|
-
* Only settable before the config freezes. Individual nodes can still
|
|
390
|
-
* override via `opts.versioningHash`.
|
|
391
|
-
*/
|
|
392
|
-
get defaultHashFn(): HashFn | undefined;
|
|
393
|
-
set defaultHashFn(v: HashFn | undefined);
|
|
394
|
-
/**
|
|
395
|
-
* When `false`, structured observation options (`causal`, `timeline`)
|
|
396
|
-
* and `Graph.trace()` writes are no-ops. Raw `Graph.observe()` always
|
|
397
|
-
* works. Default: `true` outside production (`NODE_ENV !== "production"`).
|
|
398
|
-
*
|
|
399
|
-
* Settable at any time — inspector gating is an operational concern, not
|
|
400
|
-
* a protocol invariant, so it does NOT require freeze before node creation.
|
|
401
|
-
*/
|
|
402
|
-
get inspectorEnabled(): boolean;
|
|
403
|
-
set inspectorEnabled(v: boolean);
|
|
404
|
-
/**
|
|
405
|
-
* Process-global observability hook (Redux-DevTools-style full-graph
|
|
406
|
-
* tracer). Fires once per outgoing batch from every node bound to this
|
|
407
|
-
* config, gated by {@link inspectorEnabled}. See {@link GlobalInspectorHook}.
|
|
408
|
-
*
|
|
409
|
-
* Settable at any time — like {@link inspectorEnabled} this is operational,
|
|
410
|
-
* not protocol-shaping, so it does NOT trigger config freeze.
|
|
411
|
-
*/
|
|
412
|
-
get globalInspector(): GlobalInspectorHook | undefined;
|
|
413
|
-
set globalInspector(v: GlobalInspectorHook | undefined);
|
|
414
|
-
/**
|
|
415
|
-
* Ghost-state recorder for the fast-check protocol invariant suite. Attach
|
|
416
|
-
* a {@link RigorRecorder} to capture TLA+-ghost events (cleanup witnesses,
|
|
417
|
-
* terminal classification, batch-idle checks) that have no first-class
|
|
418
|
-
* runtime surface; detach (`undefined`) for production, which is the
|
|
419
|
-
* default. Settable at any time — like {@link globalInspector} this is
|
|
420
|
-
* operational, not protocol-shaping, so it does NOT trigger config freeze.
|
|
421
|
-
*
|
|
422
|
-
* See `src/__tests__/properties/_invariants.ts` rigor mirror invariants
|
|
423
|
-
* (#54–#58) for the consumer side. Call sites in `NodeImpl` fire at:
|
|
424
|
-
* - the non-vacuous branch of `_onDepMessage`'s INVALIDATE handler
|
|
425
|
-
* - every status transition to `"completed"` / `"errored"`.
|
|
426
|
-
*/
|
|
427
|
-
get rigorRecorder(): RigorRecorder | undefined;
|
|
428
|
-
set rigorRecorder(v: RigorRecorder | undefined);
|
|
429
|
-
/**
|
|
430
|
-
* Register a custom message type. Must be called before any node that
|
|
431
|
-
* uses this config has been created — otherwise throws. Default
|
|
432
|
-
* `wireCrossing` is `tier >= 3`.
|
|
433
|
-
*/
|
|
434
|
-
registerMessageType(t: symbol, input: MessageTypeRegistrationInput): this;
|
|
435
|
-
/** Tier for `t`. Unknown types default to tier 1 (immediate, after START). */
|
|
436
|
-
messageTier(t: symbol): number;
|
|
437
|
-
/**
|
|
438
|
-
* Whether `t` is registered as wire-crossing. Unknown types default to
|
|
439
|
-
* `true` (spec §1.3.6 forward-compat — unknowns cross the wire).
|
|
440
|
-
*/
|
|
441
|
-
isWireCrossing(t: symbol): boolean;
|
|
442
|
-
/** Convenience inverse of {@link isWireCrossing}. */
|
|
443
|
-
isLocalOnly(t: symbol): boolean;
|
|
444
|
-
/**
|
|
445
|
-
* Whether `t` is forwarded to meta companions by `Graph.signal`. Defaults
|
|
446
|
-
* to `true` for unknowns (forward-compat — new types pass through meta by
|
|
447
|
-
* default; opt-in filter via `registerMessageType({metaPassthrough: false})`).
|
|
448
|
-
*/
|
|
449
|
-
isMetaPassthrough(t: symbol): boolean;
|
|
450
|
-
/** Whether `t` is a registered (built-in or custom) type. */
|
|
451
|
-
isKnownMessageType(t: symbol): boolean;
|
|
452
|
-
/**
|
|
453
|
-
* Register a graph codec by `codec.name`. Used by the envelope-based
|
|
454
|
-
* `graph.snapshot({format: "bytes", codec: name})` path and
|
|
455
|
-
* `Graph.decode(bytes)` auto-dispatch. Must be called before any node
|
|
456
|
-
* bound to this config is created — otherwise throws.
|
|
457
|
-
*
|
|
458
|
-
* Re-registering the same name overwrites, so user codecs can shadow
|
|
459
|
-
* built-in ones before freeze (e.g., to swap a zstd-wrapped dag-cbor in
|
|
460
|
-
* for `"dag-cbor"`).
|
|
461
|
-
*/
|
|
462
|
-
registerCodec<T extends {
|
|
463
|
-
readonly name: string;
|
|
464
|
-
readonly version: number;
|
|
465
|
-
}>(codec: T): this;
|
|
466
|
-
/**
|
|
467
|
-
* Resolve a registered codec by name. Returns `undefined` for unknown
|
|
468
|
-
* names. Typed callers cast to their concrete codec interface (e.g.,
|
|
469
|
-
* `config.lookupCodec<GraphCodec>("json")`) — this method stays
|
|
470
|
-
* layer-pure (no import of graph-layer types into `core/`).
|
|
471
|
-
*/
|
|
472
|
-
lookupCodec<T = {
|
|
473
|
-
readonly name: string;
|
|
474
|
-
readonly version: number;
|
|
475
|
-
}>(name: string): T | undefined;
|
|
476
|
-
/** @internal Used by tests and dev tooling — check freeze state without triggering it. */
|
|
477
|
-
_isFrozen(): boolean;
|
|
478
|
-
private _assertUnfrozen;
|
|
479
|
-
}
|
|
480
|
-
/**
|
|
481
|
-
* Register the 10 built-in message types on a fresh config. Called by
|
|
482
|
-
* `node.ts` when it constructs `defaultConfig` and by test code / advanced
|
|
483
|
-
* users after `new GraphReFlyConfig(...)`.
|
|
484
|
-
*/
|
|
485
|
-
declare function registerBuiltins(cfg: GraphReFlyConfig): void;
|
|
486
|
-
|
|
487
|
-
/**
|
|
488
|
-
* Actions checked by {@link NodeGuard}. `write` covers both {@link Node.down} and
|
|
489
|
-
* {@link Node.up} today; finer-grained strings may be added later (e.g. `"write.data"`).
|
|
490
|
-
*/
|
|
491
|
-
type GuardAction = "write" | "signal" | "observe" | (string & {});
|
|
492
|
-
type NodeGuard = (actor: Actor, action: GuardAction) => boolean;
|
|
493
|
-
type GuardDeniedDetails = {
|
|
494
|
-
actor: Actor;
|
|
495
|
-
action: GuardAction;
|
|
496
|
-
/** Registry or options name when known */
|
|
497
|
-
nodeName?: string;
|
|
498
|
-
};
|
|
499
|
-
/**
|
|
500
|
-
* Thrown when a {@link NodeGuard} denies an action for a given actor.
|
|
501
|
-
*
|
|
502
|
-
* Carries the rejected `actor`, `action`, and optional `nodeName` for diagnostic
|
|
503
|
-
* messages and middleware error handling.
|
|
504
|
-
*
|
|
505
|
-
* @example
|
|
506
|
-
* ```ts
|
|
507
|
-
* import { GuardDenied, policy } from "@graphrefly/graphrefly-ts";
|
|
508
|
-
*
|
|
509
|
-
* const guard = policy((allow) => { allow("observe"); });
|
|
510
|
-
* try {
|
|
511
|
-
* if (!guard({ type: "llm", id: "agent-1" }, "write")) {
|
|
512
|
-
* throw new GuardDenied(
|
|
513
|
-
* { actor: { type: "llm", id: "agent-1" }, action: "write", nodeName: "userInput" },
|
|
514
|
-
* );
|
|
515
|
-
* }
|
|
516
|
-
* } catch (e) {
|
|
517
|
-
* if (e instanceof GuardDenied) console.error(e.action, e.actor.type); // "write" "llm"
|
|
518
|
-
* }
|
|
519
|
-
* ```
|
|
520
|
-
*/
|
|
521
|
-
declare class GuardDenied extends Error {
|
|
522
|
-
readonly actor: Actor;
|
|
523
|
-
readonly action: GuardAction;
|
|
524
|
-
readonly nodeName?: string;
|
|
525
|
-
/**
|
|
526
|
-
* @param details - Actor, action, and optional node name for the denial.
|
|
527
|
-
* @param message - Optional override for the default error message.
|
|
528
|
-
*/
|
|
529
|
-
constructor(details: GuardDeniedDetails, message?: string);
|
|
530
|
-
/** Qualified registry path when known (roadmap diagnostics: same as {@link nodeName}). */
|
|
531
|
-
get node(): string | undefined;
|
|
532
|
-
}
|
|
533
|
-
type Where = (actor: Actor) => boolean;
|
|
534
|
-
type PolicyAllow = (action: GuardAction | readonly GuardAction[], opts?: {
|
|
535
|
-
where?: Where;
|
|
536
|
-
}) => void;
|
|
537
|
-
type PolicyDeny = (action: GuardAction | readonly GuardAction[], opts?: {
|
|
538
|
-
where?: Where;
|
|
539
|
-
}) => void;
|
|
540
|
-
type PolicyRuleData = {
|
|
541
|
-
effect: "allow" | "deny";
|
|
542
|
-
action: GuardAction | readonly GuardAction[];
|
|
543
|
-
actorType?: string | readonly string[];
|
|
544
|
-
actorId?: string | readonly string[];
|
|
545
|
-
claims?: Record<string, unknown>;
|
|
546
|
-
};
|
|
547
|
-
/**
|
|
548
|
-
* Declarative guard builder. Precedence: any matching **deny** blocks even if an allow also matches.
|
|
549
|
-
* If no rule matches, the guard returns `false` (deny-by-default). Aligned with graphrefly-py `policy()`.
|
|
550
|
-
*
|
|
551
|
-
* @param build - Callback that registers `allow(...)` / `deny(...)` rules in order.
|
|
552
|
-
* @returns A `NodeGuard` for use as `node({ guard })`.
|
|
553
|
-
*
|
|
554
|
-
* @example
|
|
555
|
-
* ```ts
|
|
556
|
-
* const guard = policy((allow, deny) => {
|
|
557
|
-
* allow("observe");
|
|
558
|
-
* deny("write", { where: (a) => a.type === "llm" });
|
|
559
|
-
* });
|
|
560
|
-
* ```
|
|
561
|
-
*/
|
|
562
|
-
declare function policy(build: (allow: PolicyAllow, deny: PolicyDeny) => void): NodeGuard;
|
|
563
|
-
/**
|
|
564
|
-
* Rebuild a declarative guard from persisted policy data (snapshot-safe).
|
|
565
|
-
*
|
|
566
|
-
* Rules are deny-overrides, same semantics as {@link policy}.
|
|
567
|
-
*/
|
|
568
|
-
declare function policyFromRules(rules: readonly PolicyRuleData[]): NodeGuard;
|
|
569
|
-
/**
|
|
570
|
-
* Derives a best-effort `meta.access` hint string by probing `guard` with the
|
|
571
|
-
* standard actor types `human`, `llm`, `wallet`, `system` for the `"write"` action
|
|
572
|
-
* (roadmap 1.5). Aligned with graphrefly-py `access_hint_for_guard`.
|
|
573
|
-
*
|
|
574
|
-
* @param guard - Guard function to probe (typically from {@link policy}).
|
|
575
|
-
* @returns `"restricted"` when no standard type is allowed; `"both"` when both
|
|
576
|
-
* `human` and `llm` are allowed (plus optionally `system`); the single allowed
|
|
577
|
-
* type name when only one passes; or a `"+"` joined list otherwise.
|
|
578
|
-
*
|
|
579
|
-
* @example
|
|
580
|
-
* ```ts
|
|
581
|
-
* import { policy, accessHintForGuard } from "@graphrefly/graphrefly-ts";
|
|
582
|
-
*
|
|
583
|
-
* const guardBoth = policy((allow) => { allow("write"); });
|
|
584
|
-
* accessHintForGuard(guardBoth); // "both"
|
|
585
|
-
*
|
|
586
|
-
* const guardHuman = policy((allow) => {
|
|
587
|
-
* allow("write", { where: (a) => a.type === "human" });
|
|
588
|
-
* });
|
|
589
|
-
* accessHintForGuard(guardHuman); // "human"
|
|
590
|
-
* ```
|
|
591
|
-
*/
|
|
592
|
-
declare function accessHintForGuard(guard: NodeGuard): string;
|
|
593
|
-
|
|
594
|
-
/**
|
|
595
|
-
* `NodeImpl` — the single GraphReFly node primitive.
|
|
596
|
-
*
|
|
597
|
-
* Per-dep state lives in a `DepRecord[]` — one entry per declared dep —
|
|
598
|
-
* consolidating subscription cleanup, latest-data tracking, dirty/settled
|
|
599
|
-
* flags, and terminal state into a single structure per dep.
|
|
600
|
-
*
|
|
601
|
-
* This file also owns the default singleton handlers (`defaultOnMessage`,
|
|
602
|
-
* `defaultOnSubscribe`), the `defaultConfig` instance, and the public
|
|
603
|
-
* `configure(...)` entry point. They live here because their bodies touch
|
|
604
|
-
* `NodeImpl` internals; `config.ts` stays NodeImpl-agnostic.
|
|
605
|
-
*
|
|
606
|
-
* See GRAPHREFLY-SPEC §2 and COMPOSITION-GUIDE §1/§9 for the behavior
|
|
607
|
-
* contract. See SESSION-foundation-redesign.md §§1–10 for design history.
|
|
608
|
-
*/
|
|
609
|
-
|
|
610
|
-
/**
|
|
611
|
-
* Lifecycle status of a node.
|
|
612
|
-
*
|
|
613
|
-
* @see GRAPHREFLY-SPEC.md §2.2
|
|
614
|
-
*/
|
|
615
|
-
type NodeStatus = "sentinel" | "pending" | "dirty" | "settled" | "resolved" | "completed" | "errored";
|
|
616
|
-
/** Callback that receives downstream message batches. */
|
|
617
|
-
type NodeSink = (messages: Messages) => void;
|
|
618
|
-
/**
|
|
619
|
-
* Observability hook events fired by a per-node inspector. Used by
|
|
620
|
-
* `Graph.observe(path, { causal, derived })` to build causal traces.
|
|
621
|
-
*
|
|
622
|
-
* - `"dep_message"` — fires in `_onDepMessage` before default dispatch,
|
|
623
|
-
* one event per message received from a dep. Includes `depIndex` and
|
|
624
|
-
* the raw `Message` tuple.
|
|
625
|
-
* - `"run"` — fires in `_execFn` just before the user fn runs. Includes
|
|
626
|
-
* the per-dep `prevData` snapshot that will be passed to fn.
|
|
627
|
-
*/
|
|
628
|
-
type NodeInspectorHookEvent = {
|
|
629
|
-
kind: "dep_message";
|
|
630
|
-
depIndex: number;
|
|
631
|
-
message: Message;
|
|
632
|
-
} | {
|
|
633
|
-
kind: "run";
|
|
634
|
-
batchData: readonly (readonly unknown[] | undefined)[];
|
|
635
|
-
prevData: readonly unknown[];
|
|
636
|
-
};
|
|
637
|
-
/** Callback attached to a node for per-message/per-run inspection. */
|
|
638
|
-
type NodeInspectorHook = (event: NodeInspectorHookEvent) => void;
|
|
639
|
-
/** Describe `type` for `Graph.describe` (GRAPHREFLY-SPEC Appendix B). */
|
|
640
|
-
type NodeDescribeKind = "state" | "derived" | "producer" | "effect";
|
|
641
|
-
/** Actor/delivery context for {@link Node.down} and {@link Node.up}. */
|
|
642
|
-
type NodeTransportOptions = {
|
|
643
|
-
actor?: Actor;
|
|
644
|
-
/** When `true`, skips guard checks. */
|
|
645
|
-
internal?: boolean;
|
|
646
|
-
/** `signal` for `Graph.signal` deliveries; default `write`. */
|
|
647
|
-
delivery?: "write" | "signal";
|
|
648
|
-
};
|
|
649
|
-
/**
|
|
650
|
-
* Cleanup return shape from a node {@link NodeFn}.
|
|
651
|
-
*
|
|
652
|
-
* Two forms, discriminated on return type:
|
|
653
|
-
*
|
|
654
|
-
* - `() => void` — fires before the next fn run AND on deactivation AND on
|
|
655
|
-
* INVALIDATE. The simplest form: one cleanup function for every transition
|
|
656
|
-
* away from the current run. Use when the same teardown logic applies to
|
|
657
|
-
* all three.
|
|
658
|
-
*
|
|
659
|
-
* - `{ beforeRun?, deactivate?, invalidate? }` — granular hooks. Each hook
|
|
660
|
-
* fires exactly once on its named transition; missing hooks are no-ops.
|
|
661
|
-
* Use when only some transitions should flush resources (e.g. a measurement
|
|
662
|
-
* cache that should survive re-runs but reset on deactivation).
|
|
663
|
-
*
|
|
664
|
-
* - `beforeRun` fires before the next fn invocation (same point as the
|
|
665
|
-
* function-form cleanup's pre-run hook).
|
|
666
|
-
* - `deactivate` fires on deactivation (last-sink unsubscribe or TEARDOWN).
|
|
667
|
-
* - `invalidate` fires on INVALIDATE (spec v0.4 graph-wide flush signal).
|
|
668
|
-
*
|
|
669
|
-
* Closure access: both forms are declared inside `NodeFn`, so hooks see the
|
|
670
|
-
* same closure as the fn body (per-run locals, `ctx.store`, dep refs).
|
|
671
|
-
*/
|
|
672
|
-
type NodeFnCleanup = (() => void) | {
|
|
673
|
-
beforeRun?: () => void;
|
|
674
|
-
deactivate?: () => void;
|
|
675
|
-
invalidate?: () => void;
|
|
676
|
-
};
|
|
677
|
-
/**
|
|
678
|
-
* Fn-time context exposing per-wave metadata and a per-node persistent
|
|
679
|
-
* scratch pad.
|
|
680
|
-
*
|
|
681
|
-
* - `prevData[i]` — last DATA value from dep `i` as of the END of the
|
|
682
|
-
* previous wave (i.e. the value that was stable before this wave started).
|
|
683
|
-
* Use as the fallback when `data[i]` is `undefined` (not involved) or
|
|
684
|
-
* `[]` (RESOLVED, no new values this wave).
|
|
685
|
-
* `undefined` means dep `i` has never produced DATA (sentinel state).
|
|
686
|
-
* `null` is a valid DATA value. `undefined` is not a valid DATA value —
|
|
687
|
-
* the protocol reserves it as the "never sent" sentinel.
|
|
688
|
-
* - `ctx.prevData[i] === undefined` → dep has never produced DATA
|
|
689
|
-
* - `ctx.prevData[i] !== undefined` → last DATA value (may be `null`)
|
|
690
|
-
* - `terminalDeps[i]` — runtime shape:
|
|
691
|
-
* - `undefined` → dep `i` is still live.
|
|
692
|
-
* - `true` → dep `i` sent COMPLETE.
|
|
693
|
-
* - anything else → dep `i` sent ERROR, value is the error payload.
|
|
694
|
-
* Type is `readonly unknown[]` because `true | unknown` collapses to
|
|
695
|
-
* `unknown` anyway; the three states are documented contract, not type.
|
|
696
|
-
* - `store` — mutable bag that persists across fn runs within one activation
|
|
697
|
-
* cycle. Wiped on deactivation and on resubscribable terminal reset.
|
|
698
|
-
*/
|
|
699
|
-
interface FnCtx {
|
|
700
|
-
readonly prevData: readonly unknown[];
|
|
701
|
-
readonly terminalDeps: readonly unknown[];
|
|
702
|
-
readonly store: Record<string, unknown>;
|
|
703
|
-
}
|
|
704
|
-
/**
|
|
705
|
-
* Compute function passed to `node(deps, fn, opts?)`.
|
|
706
|
-
*
|
|
707
|
-
* `data[i]` holds the batch of DATA values received from dep `i` during the
|
|
708
|
-
* current wave. Shape contract:
|
|
709
|
-
* - `undefined` — dep `i` was not involved in this wave (no DIRTY received).
|
|
710
|
-
* - `[]` — dep `i` was involved (dirtied), but settled as RESOLVED (value
|
|
711
|
-
* unchanged). Use `ctx.prevData[i]` to read its last known value from the
|
|
712
|
-
* previous wave.
|
|
713
|
-
* - `[v1, v2, ...]` — dep `i` sent one or more DATA values. `at(-1)` gives
|
|
714
|
-
* the latest; iterate for multi-emission processing.
|
|
715
|
-
*
|
|
716
|
-
* Emission is explicit via `actions.emit(v)` (sugar: equals + framing) or
|
|
717
|
-
* `actions.down(msgs)` (raw). Return a cleanup shape to register teardown:
|
|
718
|
-
* `() => void` (fires on every transition) or
|
|
719
|
-
* `{ beforeRun?, deactivate?, invalidate? }` (each hook fires on its named
|
|
720
|
-
* transition only). See {@link NodeFnCleanup}. Any non-cleanup return value
|
|
721
|
-
* is ignored. The `| void` leg lets arrow-block bodies satisfy `NodeFn`
|
|
722
|
-
* without an explicit `return undefined`.
|
|
723
|
-
*
|
|
724
|
-
* Sugar constructors (`derived`, `effect`, `dynamicNode`) unwrap `data[i]`
|
|
725
|
-
* to a single scalar (`at(-1)` with `ctx.prevData[i]` fallback) so their
|
|
726
|
-
* user-facing fn signatures stay unchanged. Use raw `node()` when you need
|
|
727
|
-
* the full batch array.
|
|
728
|
-
*/
|
|
729
|
-
type NodeFn = (data: readonly (readonly unknown[] | undefined)[], actions: NodeActions, ctx: FnCtx) => NodeFnCleanup | void;
|
|
730
|
-
/** Options accepted by every node constructor. */
|
|
731
|
-
interface NodeOptions<T = unknown> {
|
|
732
|
-
name?: string;
|
|
733
|
-
describeKind?: NodeDescribeKind;
|
|
734
|
-
equals?: (a: T, b: T) => boolean;
|
|
735
|
-
/**
|
|
736
|
-
* Pre-populate the cache at construction. `null` is a valid initial value.
|
|
737
|
-
* `undefined` is treated as absent (not a valid DATA payload).
|
|
738
|
-
*/
|
|
739
|
-
initial?: T | null;
|
|
740
|
-
meta?: Record<string, unknown>;
|
|
741
|
-
resubscribable?: boolean;
|
|
742
|
-
resetOnTeardown?: boolean;
|
|
743
|
-
/** Auto-emit `[[COMPLETE]]` when all deps complete. Default `true`. */
|
|
744
|
-
completeWhenDepsComplete?: boolean;
|
|
745
|
-
/**
|
|
746
|
-
* Auto-propagate `[[ERROR]]` when any dep errors. Default `true`.
|
|
747
|
-
* Set `false` only for rescue/catchError operators that handle errors
|
|
748
|
-
* explicitly via `ctx.terminalDeps`.
|
|
749
|
-
*/
|
|
750
|
-
errorWhenDepsError?: boolean;
|
|
751
|
-
/**
|
|
752
|
-
* First-run gate (§2.7). When `false` (default — matches the universal
|
|
753
|
-
* contract "fn does not fire until every declared dep has delivered"), fn
|
|
754
|
-
* is held until every declared dep has delivered at least one DATA or
|
|
755
|
-
* terminal. Sugar constructors (`derived`, `effect`) inherit the default
|
|
756
|
-
* so multi-parent activation produces one combined initial wave
|
|
757
|
-
* `[[START], [DIRTY], [DATA, fn(init...)]]` instead of the sequential
|
|
758
|
-
* `[[START], [DIRTY], [RESOLVED], [DIRTY], [DATA]]` shape produced by
|
|
759
|
-
* per-dep push-on-subscribe firings.
|
|
760
|
-
*
|
|
761
|
-
* When `true`, fn fires as soon as `_dirtyDepCount === 0` regardless of
|
|
762
|
-
* whether any dep is still sentinel. Operators like `withLatestFrom`,
|
|
763
|
-
* `valve`, and worker-bridge aggregators that deliberately fire on
|
|
764
|
-
* partial deps pass `partial: true` explicitly. Zero-dep producer-pattern
|
|
765
|
-
* factories (`stratify`, `budgetGate`, etc.) are unaffected either way —
|
|
766
|
-
* an empty `_deps` array has nothing for the gate to hold on.
|
|
767
|
-
*
|
|
768
|
-
* Gate scope: applies only until fn has fired once (`_hasCalledFnOnce`).
|
|
769
|
-
* Subsequent waves, INVALIDATE, and `_addDep` do not re-gate. Terminal
|
|
770
|
-
* reset (resubscribable node reconnect) resets `_hasCalledFnOnce` and
|
|
771
|
-
* re-arms the gate.
|
|
772
|
-
*/
|
|
773
|
-
partial?: boolean;
|
|
774
|
-
/**
|
|
775
|
-
* Tier-2 PAUSE/RESUME handling.
|
|
776
|
-
* - `true` (default): wave completion suppressed while paused; fn fires
|
|
777
|
-
* once on RESUME if gate is satisfied.
|
|
778
|
-
* - `false`: node ignores PAUSE (sources like timers that must keep running).
|
|
779
|
-
* - `"resumeAll"`: on RESUME, replay every buffered DATA (future).
|
|
780
|
-
*/
|
|
781
|
-
pausable?: boolean | "resumeAll";
|
|
782
|
-
guard?: NodeGuard;
|
|
783
|
-
versioning?: VersioningLevel;
|
|
784
|
-
versioningId?: string;
|
|
785
|
-
versioningHash?: HashFn;
|
|
786
|
-
/**
|
|
787
|
-
* Override the config instance this node binds to. Defaults to
|
|
788
|
-
* {@link defaultConfig}. Useful for test isolation and custom protocol
|
|
789
|
-
* stacks. The first node that reads any hook on the config freezes it.
|
|
790
|
-
*/
|
|
791
|
-
config?: GraphReFlyConfig;
|
|
792
|
-
}
|
|
793
|
-
/** A reactive node in the GraphReFly protocol. */
|
|
794
|
-
interface Node<T = unknown> {
|
|
795
|
-
readonly name?: string;
|
|
796
|
-
readonly status: NodeStatus;
|
|
797
|
-
/**
|
|
798
|
-
* Current cached value. Returns `undefined` when the node is in
|
|
799
|
-
* `"sentinel"` state (no DATA ever emitted). v5 reserves `undefined`
|
|
800
|
-
* globally as the sentinel value — the valid DATA type is `T | null`.
|
|
801
|
-
* Therefore `node.cache === undefined` is a valid "never emitted" guard.
|
|
802
|
-
* `node.status` distinguishes the richer states (`"sentinel"`,
|
|
803
|
-
* `"settled"`, `"errored"`, etc.) when you need more than has-value.
|
|
804
|
-
*/
|
|
805
|
-
readonly cache: T | null | undefined;
|
|
806
|
-
readonly meta: Record<string, Node>;
|
|
807
|
-
readonly lastMutation: Readonly<{
|
|
808
|
-
actor: Actor;
|
|
809
|
-
timestamp_ns: number;
|
|
810
|
-
}> | undefined;
|
|
811
|
-
readonly v: Readonly<NodeVersionInfo> | undefined;
|
|
812
|
-
/**
|
|
813
|
-
* Send one or more messages downstream. Accepts either a single
|
|
814
|
-
* {@link Message} tuple (e.g. `node.down([DATA, 42])`) or a
|
|
815
|
-
* {@link Messages} array of tuples (e.g.
|
|
816
|
-
* `node.down([[DIRTY], [DATA, 42]])`). One call = one wave: the
|
|
817
|
-
* emit pipeline tier-sorts the input, auto-prefixes `[DIRTY]` when
|
|
818
|
-
* any tier-3 payload is present and the node is not already dirty,
|
|
819
|
-
* runs equals substitution against the live cache (§3.5.1), then
|
|
820
|
-
* dispatches to sinks with phase deferral.
|
|
821
|
-
*/
|
|
822
|
-
down(messageOrMessages: Message | Messages, options?: NodeTransportOptions): void;
|
|
823
|
-
/**
|
|
824
|
-
* Sugar for `down([[DATA, value]])`. One wave with a single DATA
|
|
825
|
-
* payload — the pipeline adds the synthetic DIRTY prefix and runs
|
|
826
|
-
* equals substitution against the live cache.
|
|
827
|
-
*/
|
|
828
|
-
emit(value: T | undefined | null, options?: NodeTransportOptions): void;
|
|
829
|
-
/**
|
|
830
|
-
* Send one or more messages upstream. Accepts the same shapes as
|
|
831
|
-
* {@link down}. Upstream messages are tier <3 + tier 5 only
|
|
832
|
-
* (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN); tier-3/4 payloads
|
|
833
|
-
* throw — DATA/RESOLVED/COMPLETE/ERROR are downstream-only in this
|
|
834
|
-
* protocol. No equals substitution, no cache advance, no DIRTY
|
|
835
|
-
* auto-prefix — the up direction just forwards to every dep.
|
|
836
|
-
*/
|
|
837
|
-
up?(messageOrMessages: Message | Messages, options?: NodeTransportOptions): void;
|
|
838
|
-
subscribe(sink: NodeSink, actor?: Actor): () => void;
|
|
839
|
-
allowsObserve(actor: Actor): boolean;
|
|
840
|
-
hasGuard(): boolean;
|
|
841
|
-
}
|
|
842
|
-
/**
|
|
843
|
-
* Per-dep runtime state. One entry per upstream node.
|
|
844
|
-
*
|
|
845
|
-
* `terminal` is the single terminal-state slot, shaped to match
|
|
846
|
-
* {@link FnCtx.terminalDeps}:
|
|
847
|
-
* - `undefined` — dep is still live.
|
|
848
|
-
* - `true` — dep sent COMPLETE.
|
|
849
|
-
* - anything else — dep sent ERROR with that payload.
|
|
850
|
-
*
|
|
851
|
-
* `[ERROR, undefined]` is rejected at the dispatch boundary (`_emit`) per
|
|
852
|
-
* spec §1.2 — `undefined` would collide with the "live" encoding here.
|
|
853
|
-
* Always pass meaningful error values (Error objects, domain tags).
|
|
854
|
-
*/
|
|
855
|
-
interface DepRecord {
|
|
856
|
-
readonly node: Node;
|
|
857
|
-
unsub: (() => void) | null;
|
|
858
|
-
/**
|
|
859
|
-
* Last DATA value from this dep as of the end of the previous completed
|
|
860
|
-
* wave. `undefined` until dep has produced at least one DATA (sentinel).
|
|
861
|
-
* Committed by `_execFn` after snapshotting `ctx.prevData` and before
|
|
862
|
-
* `_clearWaveFlags`. `undefined` is reserved as the "never sent" sentinel —
|
|
863
|
-
* `undefined` is not a valid DATA payload.
|
|
864
|
-
*/
|
|
865
|
-
prevData: unknown;
|
|
866
|
-
/** True while awaiting DATA/RESOLVED for the current wave. */
|
|
867
|
-
dirty: boolean;
|
|
868
|
-
/**
|
|
869
|
-
* True if this dep was dirtied in the current wave (set in `_depDirtied`,
|
|
870
|
-
* cleared in `_clearWaveFlags`). Distinguishes "RESOLVED" (`involvedThisWave
|
|
871
|
-
* && dataBatch.length === 0`) from "not involved" (`!involvedThisWave`) in
|
|
872
|
-
* the `data[i]` batch snapshot passed to fn.
|
|
873
|
-
*/
|
|
874
|
-
involvedThisWave: boolean;
|
|
875
|
-
/**
|
|
876
|
-
* DATA values accumulated from this dep during the current wave.
|
|
877
|
-
* Populated by `_depSettledAsData`, cleared by `_clearWaveFlags`.
|
|
878
|
-
* Snapshotted (copied) by `_execFn` before `_clearWaveFlags` runs so
|
|
879
|
-
* that fn always sees the full wave batch.
|
|
880
|
-
*/
|
|
881
|
-
dataBatch: unknown[];
|
|
882
|
-
/** Terminal-state slot — see JSDoc on {@link DepRecord}. */
|
|
883
|
-
terminal: unknown;
|
|
884
|
-
}
|
|
885
|
-
/**
|
|
886
|
-
* Default {@link GraphReFlyConfig} instance. Every `NodeImpl` constructed
|
|
887
|
-
* without an explicit `opts.config` binds to this instance and freezes it
|
|
888
|
-
* on first hook access.
|
|
889
|
-
*/
|
|
890
|
-
declare const defaultConfig: GraphReFlyConfig;
|
|
891
|
-
/**
|
|
892
|
-
* Apply configuration to {@link defaultConfig}. Must be called before the
|
|
893
|
-
* first node is created — otherwise throws. Custom message types, hook
|
|
894
|
-
* overrides, etc. go through here at app startup.
|
|
895
|
-
*
|
|
896
|
-
* ```ts
|
|
897
|
-
* configure((cfg) => {
|
|
898
|
-
* cfg.registerMessageType(MY_TYPE, { tier: 3 });
|
|
899
|
-
* cfg.onMessage = (node, msg, ctx, actions) => { ... };
|
|
900
|
-
* });
|
|
901
|
-
* ```
|
|
902
|
-
*/
|
|
903
|
-
declare function configure(fn: (cfg: GraphReFlyConfig) => void): void;
|
|
904
|
-
|
|
905
|
-
/**
|
|
906
|
-
* Single-class node implementation. Covers state, producer, derived, effect,
|
|
907
|
-
* and passthrough shapes. See `sugar.ts` for ergonomic factories and
|
|
908
|
-
* `dynamicNode()` (sugar-level wrapper around plain `NodeImpl`).
|
|
909
|
-
*/
|
|
910
|
-
declare class NodeImpl<T = unknown> implements Node<T> {
|
|
911
|
-
readonly _optsName: string | undefined;
|
|
912
|
-
readonly _describeKind: NodeDescribeKind | undefined;
|
|
913
|
-
readonly meta: Record<string, Node>;
|
|
914
|
-
/**
|
|
915
|
-
* Cached `Object.keys(meta).length > 0` check. `meta` is frozen at
|
|
916
|
-
* construction so this boolean never flips. Used by `_emit` to skip
|
|
917
|
-
* the meta TEARDOWN fan-out block allocation on the common "no meta"
|
|
918
|
-
* hot path.
|
|
919
|
-
*/
|
|
920
|
-
readonly _hasMeta: boolean;
|
|
921
|
-
readonly _config: GraphReFlyConfig;
|
|
922
|
-
/** Mutable for autoTrackNode / Graph.connect() post-construction dep addition. */
|
|
923
|
-
_deps: DepRecord[];
|
|
924
|
-
_sinks: NodeSink | Set<NodeSink> | null;
|
|
925
|
-
_sinkCount: number;
|
|
926
|
-
_cached: T | undefined;
|
|
927
|
-
_status: NodeStatus;
|
|
928
|
-
_cleanup: NodeFnCleanup | undefined;
|
|
929
|
-
_store: Record<string, unknown>;
|
|
930
|
-
_waveHasNewData: boolean;
|
|
931
|
-
_hasNewTerminal: boolean;
|
|
932
|
-
_hasCalledFnOnce: boolean;
|
|
933
|
-
_paused: boolean;
|
|
934
|
-
_pendingWave: boolean;
|
|
935
|
-
_isExecutingFn: boolean;
|
|
936
|
-
_pendingRerun: boolean;
|
|
937
|
-
_rerunDepth: number;
|
|
938
|
-
/**
|
|
939
|
-
* Count of deps currently in `dirty === true`. `_maybeRunFnOnSettlement`
|
|
940
|
-
* treats `0` as "wave settled" — O(1) check for full dep settlement.
|
|
941
|
-
*/
|
|
942
|
-
_dirtyDepCount: number;
|
|
943
|
-
/**
|
|
944
|
-
* Inside an explicit `batch(() => ...)` scope, every `_emit` accumulates
|
|
945
|
-
* its already-framed messages here instead of dispatching synchronously.
|
|
946
|
-
* At batch end, `_flushBatchPending` runs (registered via
|
|
947
|
-
* `registerBatchFlushHook`) and delivers the whole accumulated batch as
|
|
948
|
-
* one `downWithBatch` call — collapsing what would otherwise be K
|
|
949
|
-
* separate sink invocations into one. This is the fix for the diamond
|
|
950
|
-
* fan-in K+1 over-fire.
|
|
951
|
-
*
|
|
952
|
-
* `null` outside batch (or after flush). Only ever appended to within
|
|
953
|
-
* a single explicit batch lifetime; reset to `null` on flush. State
|
|
954
|
-
* updates (cache, version, status) still happen per-emit via
|
|
955
|
-
* `_updateState` — only the downstream delivery is coalesced.
|
|
956
|
-
*/
|
|
957
|
-
_batchPendingMessages: Message[] | null;
|
|
958
|
-
/**
|
|
959
|
-
* Set of active pause locks held against this node. Every `[PAUSE, lockId]`
|
|
960
|
-
* adds its `lockId` to the set; every `[RESUME, lockId]` removes it.
|
|
961
|
-
* `_paused` is a derived quantity: `_pauseLocks.size > 0`. Multi-pauser
|
|
962
|
-
* correctness — one controller releasing its lock does NOT resume the
|
|
963
|
-
* node while another controller still holds its lock.
|
|
964
|
-
*/
|
|
965
|
-
_pauseLocks: Set<unknown> | null;
|
|
966
|
-
/**
|
|
967
|
-
* Buffered DATA messages held while paused. Only populated when
|
|
968
|
-
* `_pausable === "resumeAll"` (bufferAll mode). On final lock release
|
|
969
|
-
* the buffer is replayed through the node's outgoing pipeline in the
|
|
970
|
-
* order received. Non-bufferAll pause mode drops DATA on the floor
|
|
971
|
-
* (upstream is expected to honor PAUSE by suppressing production).
|
|
972
|
-
*/
|
|
973
|
-
_pauseBuffer: Message[] | null;
|
|
974
|
-
readonly _fn: NodeFn | undefined;
|
|
975
|
-
readonly _equals: (a: T, b: T) => boolean;
|
|
976
|
-
readonly _resubscribable: boolean;
|
|
977
|
-
readonly _resetOnTeardown: boolean;
|
|
978
|
-
readonly _autoComplete: boolean;
|
|
979
|
-
readonly _autoError: boolean;
|
|
980
|
-
readonly _pausable: boolean | "resumeAll";
|
|
981
|
-
/**
|
|
982
|
-
* @internal First-run-gate override. `false` (default) holds fn until every
|
|
983
|
-
* dep has delivered DATA or a terminal — spec §2.7 first-run gate. `true`
|
|
984
|
-
* disables the gate; fn fires as soon as `_dirtyDepCount === 0`, regardless
|
|
985
|
-
* of dep sentinel state. Operators that need partial firing
|
|
986
|
-
* (`withLatestFrom`, `valve`, worker-bridge aggregators) pass
|
|
987
|
-
* `partial: true` explicitly at construction.
|
|
988
|
-
*/
|
|
989
|
-
readonly _partial: boolean;
|
|
990
|
-
readonly _guard: NodeGuard | undefined;
|
|
991
|
-
/**
|
|
992
|
-
* @internal Additional guards stacked at runtime via {@link NodeImpl._pushGuard}
|
|
993
|
-
* (e.g. by `policyGate({ mode: "enforce" })`, roadmap §9.2). Effective
|
|
994
|
-
* write/signal/observe checks AND the original `_guard` with every entry here.
|
|
995
|
-
*/
|
|
996
|
-
_extraGuards: Set<NodeGuard> | undefined;
|
|
997
|
-
_hashFn: HashFn;
|
|
998
|
-
_versioning: NodeVersionInfo | undefined;
|
|
999
|
-
/**
|
|
1000
|
-
* Explicit versioning level, tracked separately from `_versioning` so
|
|
1001
|
-
* monotonicity checks and future v2/v3 extensions don't rely on the
|
|
1002
|
-
* fragile `"cid" in _versioning` shape discriminator. `undefined` means
|
|
1003
|
-
* the node has no versioning attached; `0` / `1` / future levels name
|
|
1004
|
-
* the tier. Mutated in lockstep with `_versioning` by the constructor
|
|
1005
|
-
* and by `_applyVersioning`.
|
|
1006
|
-
*/
|
|
1007
|
-
_versioningLevel: VersioningLevel | undefined;
|
|
1008
|
-
_lastMutation: {
|
|
1009
|
-
actor: Actor;
|
|
1010
|
-
timestamp_ns: number;
|
|
1011
|
-
} | undefined;
|
|
1012
|
-
/**
|
|
1013
|
-
* @internal Per-node inspector hooks for `Graph.observe(path,
|
|
1014
|
-
* { causal, derived })`. Fires in `_onDepMessage` and `_execFn`.
|
|
1015
|
-
* Attached via `_setInspectorHook` (returns a disposer). Multiple
|
|
1016
|
-
* observers can attach simultaneously — all registered hooks fire for
|
|
1017
|
-
* every event.
|
|
1018
|
-
*/
|
|
1019
|
-
_inspectorHooks: Set<NodeInspectorHook> | undefined;
|
|
1020
|
-
readonly _actions: NodeActions;
|
|
1021
|
-
constructor(deps: readonly Node[], fn: NodeFn | undefined, opts: NodeOptions<T>);
|
|
1022
|
-
private get _isTerminal();
|
|
1023
|
-
get name(): string | undefined;
|
|
1024
|
-
get status(): NodeStatus;
|
|
1025
|
-
get cache(): T | undefined | null;
|
|
1026
|
-
get lastMutation(): Readonly<{
|
|
1027
|
-
actor: Actor;
|
|
1028
|
-
timestamp_ns: number;
|
|
1029
|
-
}> | undefined;
|
|
1030
|
-
get v(): Readonly<NodeVersionInfo> | undefined;
|
|
1031
|
-
hasGuard(): boolean;
|
|
1032
|
-
/**
|
|
1033
|
-
* @internal Retroactively attach (or upgrade) versioning state on this
|
|
1034
|
-
* node. Intended for `Graph.setVersioning(level)` bulk application and
|
|
1035
|
-
* for rare cases where a specific node needs to be bumped to a higher
|
|
1036
|
-
* level (e.g., `v0 → v1`) after construction.
|
|
1037
|
-
*
|
|
1038
|
-
* **Safety:** the mutation is rejected mid-wave. Specifically,
|
|
1039
|
-
* throws if the node is currently executing its fn (`_isExecutingFn`).
|
|
1040
|
-
* Callers at quiescent points — before the first sink subscribes, or
|
|
1041
|
-
* after all sinks unsubscribe, or between external `down()` / `emit()`
|
|
1042
|
-
* invocations — are safe. The re-entrance window that motivated §10.6.4
|
|
1043
|
-
* removal was the "transition `_versioning` from `undefined` to a fresh
|
|
1044
|
-
* object mid-`_updateState`" case; that path is now guarded.
|
|
1045
|
-
*
|
|
1046
|
-
* **Monotonicity:** levels can only go up. Downgrade (e.g., `v1 → v0`)
|
|
1047
|
-
* is a no-op — once a node carries higher-level metadata, dropping it
|
|
1048
|
-
* mid-graph would tear the linked-history invariant for v1 and above.
|
|
1049
|
-
*
|
|
1050
|
-
* **Linked-history boundary (D1, 2026-04-13):** upgrading v0 → v1
|
|
1051
|
-
* produces a **fresh history root**. The new v1 state has `cid =
|
|
1052
|
-
* hash(currentCachedValue)` and `prev = null`, not a synthetic `prev`
|
|
1053
|
-
* anchored to any previous v0 value. The v0 monotonic `version` counter
|
|
1054
|
-
* is preserved across the upgrade, but the linked-cid chain (spec §7)
|
|
1055
|
-
* starts fresh at the upgrade point. Downstream audit tools that walk
|
|
1056
|
-
* `v.cid.prev` backwards through time will see a `null` boundary at
|
|
1057
|
-
* the upgrade — **this is intentional**: v0 had no cid to link to, and
|
|
1058
|
-
* fabricating one would lie about the hash. Callers that require an
|
|
1059
|
-
* unbroken cid chain from birth must attach versioning at construction
|
|
1060
|
-
* via `opts.versioning` or `config.defaultVersioning`, not retroactively.
|
|
1061
|
-
*
|
|
1062
|
-
* @param level - New minimum versioning level.
|
|
1063
|
-
* @param opts - Optional id / hash overrides; applied only if the
|
|
1064
|
-
* node currently has no versioning state.
|
|
1065
|
-
*/
|
|
1066
|
-
_applyVersioning(level: VersioningLevel, opts?: {
|
|
1067
|
-
id?: string;
|
|
1068
|
-
hash?: HashFn;
|
|
1069
|
-
}): void;
|
|
1070
|
-
/**
|
|
1071
|
-
* @internal Attach an inspector hook. Returns a disposer that removes
|
|
1072
|
-
* the hook. Used by `Graph.observe(path, { causal, derived })` to build
|
|
1073
|
-
* causal traces. Multiple hooks may be attached concurrently — all fire
|
|
1074
|
-
* for every event in registration order. Passing `undefined` is a no-op
|
|
1075
|
-
* and returns a no-op disposer.
|
|
1076
|
-
*/
|
|
1077
|
-
_setInspectorHook(hook?: NodeInspectorHook): () => void;
|
|
1078
|
-
/**
|
|
1079
|
-
* @internal Push an additional guard onto this node. Effective enforcement
|
|
1080
|
-
* is the AND of `_guard` and every guard pushed via this hook — any one
|
|
1081
|
-
* rejecting throws {@link GuardDenied}. Returns a disposer that removes
|
|
1082
|
-
* the pushed guard. Multiple guards may be stacked simultaneously.
|
|
1083
|
-
*
|
|
1084
|
-
* Used by `policyGate({ mode: "enforce" })` (roadmap §9.2) to overlay
|
|
1085
|
-
* runtime constraint enforcement onto an existing graph without rebuilding
|
|
1086
|
-
* its nodes. Pre-1.0 internal API; not part of the public surface.
|
|
1087
|
-
*
|
|
1088
|
-
* **Identity semantics:** guards are tracked in a `Set`, so pushing the
|
|
1089
|
-
* same `NodeGuard` reference twice is a single registration. Wrap each
|
|
1090
|
-
* push in a unique closure if independent stacking is needed.
|
|
1091
|
-
*
|
|
1092
|
-
* **Iteration order:** insertion-ordered (`Set` semantics). Determinism
|
|
1093
|
-
* follows from single-threaded JS execution; nested re-entry from inside
|
|
1094
|
-
* a guard body (push/pop while iterating) is undefined-but-survivable.
|
|
1095
|
-
*/
|
|
1096
|
-
_pushGuard(guard: NodeGuard): () => void;
|
|
1097
|
-
allowsObserve(actor: Actor): boolean;
|
|
1098
|
-
private _checkGuard;
|
|
1099
|
-
down(messageOrMessages: Message | Messages, options?: NodeTransportOptions): void;
|
|
1100
|
-
emit(value: T | undefined | null, options?: NodeTransportOptions): void;
|
|
1101
|
-
/**
|
|
1102
|
-
* Upstream forward (spec §1.4). Carries tier-1/2/5 control-plane only:
|
|
1103
|
-
* DIRTY (tier 1), PAUSE/RESUME (tier 2), INVALIDATE/TEARDOWN (tier 5).
|
|
1104
|
-
* Tier-3/4 (DATA/RESOLVED/COMPLETE/ERROR) are rejected by
|
|
1105
|
-
* `_validateUpTiers` — downstream-only by protocol.
|
|
1106
|
-
*
|
|
1107
|
-
* **Upstream-origin PAUSE applies at the PARENT's lockset via the parent's
|
|
1108
|
-
* own `up()`, not at this source's `_pauseLocks` when `_deps.length === 0`.**
|
|
1109
|
-
* At a leaf source, `up()` is a no-op: a subscription that calls
|
|
1110
|
-
* `sink.up([[PAUSE, lockId]])` expecting the source itself to pause is
|
|
1111
|
-
* NOT honored today. TLA+ `DeliverUp` encodes the target contract (source
|
|
1112
|
-
* applies its own lock); the runtime falls short. No in-tree caller relies
|
|
1113
|
-
* on upstream-origin PAUSE at a leaf, so this is documented as intentional
|
|
1114
|
-
* for now (option (c) in docs/optimizations.md "Up-direction PAUSE
|
|
1115
|
-
* semantics"). A future option (a) would tighten the runtime here; any
|
|
1116
|
-
* new consumer needing leaf-source upstream PAUSE is the trigger.
|
|
1117
|
-
*
|
|
1118
|
-
* **LockId uniqueness is the caller's responsibility.** Locks are stored
|
|
1119
|
-
* in a `Set<unknown>`; `Pause(n, 10)` and an upstream `UpPause(child, 10)`
|
|
1120
|
-
* that reaches `n` insert the SAME element — one `Resume(n, 10)` clears
|
|
1121
|
-
* both origins. Distinct pauser identities must use distinct lockIds.
|
|
1122
|
-
* Surfaced by the rigor-infra TLC audit (docs/optimizations.md "LockId
|
|
1123
|
-
* collision across up() and down() origin").
|
|
1124
|
-
*/
|
|
1125
|
-
up(messageOrMessages: Message | Messages, options?: NodeTransportOptions): void;
|
|
1126
|
-
/**
|
|
1127
|
-
* @internal Internal up-path used by `actions.up(...)` from inside fn.
|
|
1128
|
-
* Same tier validation as public `up`, but bypasses the guard check
|
|
1129
|
-
* since the fn context is already inside an authorized operation.
|
|
1130
|
-
*/
|
|
1131
|
-
private _emitUp;
|
|
1132
|
-
/**
|
|
1133
|
-
* @internal Enforce spec §1.2 — up-direction messages are restricted to
|
|
1134
|
-
* tier 0–2 and tier 5 (START, DIRTY, INVALIDATE, PAUSE, RESUME,
|
|
1135
|
-
* TEARDOWN). Tier 3 (DATA/RESOLVED) and tier 4 (COMPLETE/ERROR) are
|
|
1136
|
-
* downstream-only. Emitting tier-3/4 via `up` would bypass equals
|
|
1137
|
-
* substitution and cache advance entirely and is a protocol bug.
|
|
1138
|
-
*/
|
|
1139
|
-
private _validateUpTiers;
|
|
1140
|
-
subscribe(sink: NodeSink, actor?: Actor): () => void;
|
|
1141
|
-
private _removeSink;
|
|
1142
|
-
/**
|
|
1143
|
-
* @internal First-sink activation. For a producer (no deps + fn),
|
|
1144
|
-
* invokes fn once. For a compute node (has deps), subscribes to every
|
|
1145
|
-
* dep with the pre-set-dirty trick so the first-run gate waits for
|
|
1146
|
-
* every dep to settle at least once.
|
|
1147
|
-
*/
|
|
1148
|
-
_activate(): void;
|
|
1149
|
-
/**
|
|
1150
|
-
* @internal Append a dep post-construction. Used by `autoTrackNode`
|
|
1151
|
-
* (runtime dep discovery) and `Graph.connect()` (post-construction
|
|
1152
|
-
* wiring). Subscribes immediately — if DATA arrives synchronously
|
|
1153
|
-
* during subscribe and fn is currently executing, the re-run is
|
|
1154
|
-
* deferred via `_pendingRerun` flag (see `_execFn` guard).
|
|
1155
|
-
*
|
|
1156
|
-
* **Dedup:** idempotent on duplicate `depNode` — if `depNode` is
|
|
1157
|
-
* already in `_deps`, returns the existing index without mutating
|
|
1158
|
-
* state. Callers can safely invoke `_addDep` without their own
|
|
1159
|
-
* "already added" check. `autoTrackNode` still keeps a `depIndexMap`
|
|
1160
|
-
* as a fast-path lookup for known deps (returning cached `data[idx]`
|
|
1161
|
-
* without calling `_addDep` at all); this internal dedup is the
|
|
1162
|
-
* backstop for any caller that doesn't track its own dep set.
|
|
1163
|
-
*
|
|
1164
|
-
* @returns The index of the new dep in `_deps`, or the existing index
|
|
1165
|
-
* if the dep was already present.
|
|
1166
|
-
*/
|
|
1167
|
-
_addDep(depNode: Node): number;
|
|
1168
|
-
/**
|
|
1169
|
-
* @internal Unsubscribes from deps, fires fn cleanup (both shapes),
|
|
1170
|
-
* clears wave/store state, and (for compute nodes) drops `_cached` per
|
|
1171
|
-
* the ROM/RAM rule. Idempotent: second call is a no-op.
|
|
1172
|
-
*
|
|
1173
|
-
* @param skipStatusUpdate — When `true`, the caller takes responsibility
|
|
1174
|
-
* for setting `_status` after deactivation (e.g. TEARDOWN always sets
|
|
1175
|
-
* `"sentinel"` unconditionally). When `false` (default), deactivation
|
|
1176
|
-
* applies the ROM rule: compute nodes → `"sentinel"`, state nodes
|
|
1177
|
-
* preserve their current status.
|
|
1178
|
-
*/
|
|
1179
|
-
_deactivate(skipStatusUpdate?: boolean): void;
|
|
1180
|
-
/**
|
|
1181
|
-
* @internal Default per-tier dispatch for incoming dep messages. Called
|
|
1182
|
-
* by `defaultOnMessage`. Updates the DepRecord, triggers wave
|
|
1183
|
-
* completion, and forwards passthrough traffic.
|
|
1184
|
-
*/
|
|
1185
|
-
_onDepMessage(depIndex: number, msg: Message): void;
|
|
1186
|
-
/**
|
|
1187
|
-
* Called when a dep transitions `dirty: false → true` (either from an
|
|
1188
|
-
* incoming DIRTY, or pre-set during `_activate` / `_addDep` /
|
|
1189
|
-
* `_depInvalidated`). No-op if the dep is already dirty. Fires the
|
|
1190
|
-
* downstream DIRTY emit if we're the first to dirty this wave.
|
|
1191
|
-
*/
|
|
1192
|
-
private _depDirtied;
|
|
1193
|
-
/**
|
|
1194
|
-
* Called when a dep delivers new DATA: clears dirty, stores the payload,
|
|
1195
|
-
* marks wave-has-data, and — if this is the dep's first DATA — clears
|
|
1196
|
-
* its sentinel slot so the first-run gate can open.
|
|
1197
|
-
*/
|
|
1198
|
-
private _depSettledAsData;
|
|
1199
|
-
/**
|
|
1200
|
-
* Called when a dep emits RESOLVED (wave settled, value unchanged).
|
|
1201
|
-
* Clears dirty; does NOT touch `prevData` / `terminal` / sentinel
|
|
1202
|
-
* count — sentinel only exits on first DATA or terminal, not RESOLVED.
|
|
1203
|
-
*/
|
|
1204
|
-
private _depSettledAsResolved;
|
|
1205
|
-
/**
|
|
1206
|
-
* Called when a dep delivers COMPLETE (`terminal = true`) or ERROR
|
|
1207
|
-
* (`terminal = errorPayload`). Clears dirty, stores the terminal, and
|
|
1208
|
-
* — if the dep had never contributed a DATA yet — leaves sentinel
|
|
1209
|
-
* since the gate treats "terminated without data" as gate-open too.
|
|
1210
|
-
*/
|
|
1211
|
-
private _depSettledAsTerminal;
|
|
1212
|
-
/**
|
|
1213
|
-
* Called when a dep emits INVALIDATE: clears prevData, terminal, and
|
|
1214
|
-
* dataBatch. The dep is now back in the "never delivered a real value"
|
|
1215
|
-
* state — `prevData === undefined` so the sentinel check in fn will fire.
|
|
1216
|
-
*/
|
|
1217
|
-
private _depInvalidated;
|
|
1218
|
-
private _maybeRunFnOnSettlement;
|
|
1219
|
-
private _maybeAutoTerminalAfterWave;
|
|
1220
|
-
/**
|
|
1221
|
-
* @internal Runs the node fn once.
|
|
1222
|
-
*
|
|
1223
|
-
* Cleanup firing:
|
|
1224
|
-
* - Function-form cleanup — fires here (pre-run) AND on deactivation AND
|
|
1225
|
-
* on INVALIDATE. Cleared before the new fn runs.
|
|
1226
|
-
* - Object-form cleanup — only `beforeRun` fires here; `deactivate` and
|
|
1227
|
-
* `invalidate` hooks survive across re-runs. The cleanup reference
|
|
1228
|
-
* itself is preserved so `deactivate`/`invalidate` still fire later.
|
|
1229
|
-
*/
|
|
1230
|
-
private _execFn;
|
|
1231
|
-
private _clearWaveFlags;
|
|
1232
|
-
private _wrapFnError;
|
|
1233
|
-
/**
|
|
1234
|
-
* @internal Stable tier sort + synthetic DIRTY prefix for an outgoing
|
|
1235
|
-
* batch. Fast path: already-monotone single-tier batches (the common
|
|
1236
|
-
* case from interned singletons like `DIRTY_ONLY_BATCH`) return the
|
|
1237
|
-
* input unchanged. General path: decorate-sort-undecorate into a new
|
|
1238
|
-
* array, then prepend `[DIRTY]` after any tier-0 START entries when
|
|
1239
|
-
* a tier-3 payload is present and the node isn't already dirty.
|
|
1240
|
-
*
|
|
1241
|
-
* Single source of truth for the spec §1.3.1 framing invariant. Every
|
|
1242
|
-
* outgoing path hits `_frameBatch` exactly once via `_emit`.
|
|
1243
|
-
*/
|
|
1244
|
-
private _frameBatch;
|
|
1245
|
-
/**
|
|
1246
|
-
* @internal The unified dispatch waist — one call = one wave.
|
|
1247
|
-
* See `GRAPHREFLY-SPEC.md` §1.3.1 for protocol context — the stages
|
|
1248
|
-
* below are the implementation order.
|
|
1249
|
-
*
|
|
1250
|
-
* Pipeline stages, in order:
|
|
1251
|
-
*
|
|
1252
|
-
* 1. Terminal filter — post-COMPLETE/ERROR only TEARDOWN/INVALIDATE
|
|
1253
|
-
* still propagate so graph teardown and cache-clear still work.
|
|
1254
|
-
* 2. Tier sort (stable) — the batch can be in any order when it
|
|
1255
|
-
* arrives; the walker downstream (`downWithBatch`) assumes
|
|
1256
|
-
* ascending tier monotone, and so does `_updateState`'s tier-3
|
|
1257
|
-
* slice walk. This is the single source of truth for ordering.
|
|
1258
|
-
* 3. Synthetic DIRTY prefix — if a tier-3 payload is present, no
|
|
1259
|
-
* DIRTY is already in the batch, and the node isn't already in
|
|
1260
|
-
* `"dirty"` status, prepend `[DIRTY]` after any tier-0 START
|
|
1261
|
-
* entries. Guarantees spec §1.3.1 (DIRTY precedes DATA within
|
|
1262
|
-
* the same batch) uniformly across every entry point.
|
|
1263
|
-
* 4. PAUSE/RESUME lock bookkeeping (C0) — update `_pauseLocks`,
|
|
1264
|
-
* derive `_paused`, filter unknown-lockId RESUME, replay
|
|
1265
|
-
* bufferAll buffer on final lock release.
|
|
1266
|
-
* 5. Meta TEARDOWN fan-out — notify meta children before
|
|
1267
|
-
* `_updateState`'s TEARDOWN branch calls `_deactivate`. Hoisted
|
|
1268
|
-
* out of the walk to keep `_updateState` re-entrance-free.
|
|
1269
|
-
* 6. `_updateState` — walk the batch in tier order, advancing
|
|
1270
|
-
* `_cached` / `_status` / `_versioning` and running equals
|
|
1271
|
-
* substitution on tier-3 DATA (§3.5.1). Returns
|
|
1272
|
-
* `{finalMessages, equalsError?}`.
|
|
1273
|
-
* 7. `downWithBatch` dispatch (or bufferAll capture if paused with
|
|
1274
|
-
* `pausable: "resumeAll"`).
|
|
1275
|
-
* 8. Recursive ERROR emission if equals threw mid-walk.
|
|
1276
|
-
*/
|
|
1277
|
-
_emit(messages: Messages): void;
|
|
1278
|
-
/**
|
|
1279
|
-
* @internal Walk an outgoing (already-framed) batch, updating own
|
|
1280
|
-
* cache / status / versioning and running equals substitution on
|
|
1281
|
-
* every tier-3 DATA (§3.5.1). Framing — tier sort and synthetic
|
|
1282
|
-
* DIRTY prefix — has already happened upstream in `_frameBatch`.
|
|
1283
|
-
* This walk trusts the input is in monotone tier order and that the
|
|
1284
|
-
* spec §1.3.1 DIRTY/RESOLVED precedence invariant is already
|
|
1285
|
-
* satisfied by the frame.
|
|
1286
|
-
*
|
|
1287
|
-
* Equals substitution: every DATA payload is compared against the
|
|
1288
|
-
* live `_cached`; when equal, the tuple is rewritten to `[RESOLVED]`
|
|
1289
|
-
* in a per-call copy and cache is not re-advanced. `.cache` remains
|
|
1290
|
-
* coherent with "the last DATA payload this node actually sent
|
|
1291
|
-
* downstream".
|
|
1292
|
-
*
|
|
1293
|
-
* Returns `{ finalMessages, equalsError? }`:
|
|
1294
|
-
* - `finalMessages` — the array to deliver to sinks (may be
|
|
1295
|
-
* `messages` unchanged, a rewritten copy with DATA→RESOLVED
|
|
1296
|
-
* substitutions, or a truncated prefix when equals throws mid-walk).
|
|
1297
|
-
* - `equalsError` — present only when the configured `equals` function
|
|
1298
|
-
* threw on some DATA message. `_emit` delivers the prefix first,
|
|
1299
|
-
* then emits a fresh ERROR batch via a recursive `_emit` call so
|
|
1300
|
-
* subscribers observe `[...walked_prefix, ERROR]` in order.
|
|
1301
|
-
*/
|
|
1302
|
-
private _updateState;
|
|
1303
|
-
private _deliverToSinks;
|
|
1304
|
-
/**
|
|
1305
|
-
* @internal Dispatch entry point that respects the per-batch emit
|
|
1306
|
-
* accumulator (Bug 2). Inside an explicit `batch()` scope, append to
|
|
1307
|
-
* `_batchPendingMessages` and register a flush hook on first append.
|
|
1308
|
-
* Outside batch — or during a drain (where `flushInProgress` is true
|
|
1309
|
-
* but `batchDepth` is 0) — dispatch synchronously through `downWithBatch`.
|
|
1310
|
-
*
|
|
1311
|
-
* Per-emit state updates (`_frameBatch`, `_updateState`) have already
|
|
1312
|
-
* happened by the time we reach here; only the **downstream delivery**
|
|
1313
|
-
* is coalesced. Cache, version, and status are visible mid-batch on
|
|
1314
|
-
* the emitting node itself.
|
|
1315
|
-
*/
|
|
1316
|
-
private _dispatchOrAccumulate;
|
|
1317
|
-
/**
|
|
1318
|
-
* @internal Flushes the accumulated batch through `downWithBatch` and
|
|
1319
|
-
* clears the pending state. Idempotent — safe to call when pending is
|
|
1320
|
-
* already null or empty (e.g. on a `batch()` throw, where the hook
|
|
1321
|
-
* fires for cleanup but the drainPhase queues are wiped after).
|
|
1322
|
-
*
|
|
1323
|
-
* Critical: the accumulated batch is interleaved per-emit framings like
|
|
1324
|
-
* `[DIRTY, DATA(1), DIRTY, DATA(2)]` — non-monotone tier order. We must
|
|
1325
|
-
* re-frame to sort by tier before handing to `downWithBatch`, which
|
|
1326
|
-
* assumes pre-sorted input. `_frameBatch` also handles the synthetic
|
|
1327
|
-
* DIRTY prepend rule (no-op here — `hasDirty` is true since each
|
|
1328
|
-
* accumulated emit already carries its own DIRTY prefix).
|
|
1329
|
-
*/
|
|
1330
|
-
private _flushBatchPending;
|
|
1331
|
-
}
|
|
1332
|
-
/**
|
|
1333
|
-
* Creates a reactive {@link Node} — the single GraphReFly primitive (§2).
|
|
1334
|
-
*
|
|
1335
|
-
* Typical shapes:
|
|
1336
|
-
* - `node([])` / `node({ initial: v })` — a manual source (state node).
|
|
1337
|
-
* - `node(producerFn, opts)` — a producer that runs on first-subscribe.
|
|
1338
|
-
* - `node(deps, computeFn, opts)` — a derived / effect node.
|
|
1339
|
-
*
|
|
1340
|
-
* For value-returning computations, prefer the sugar factories in `sugar.ts`
|
|
1341
|
-
* (`state`, `derived`, `effect`, `producer`, `dynamicNode`), which wrap user
|
|
1342
|
-
* fns with `actions.emit(userFn(data))`. Calling `node()` directly gives you
|
|
1343
|
-
* the raw `NodeFn` contract: explicit emission via `actions`, cleanup return.
|
|
1344
|
-
*/
|
|
1345
|
-
declare function node<T = unknown>(depsOrFn?: readonly Node[] | NodeFn | NodeOptions<T>, fnOrOpts?: NodeFn | NodeOptions<T>, optsArg?: NodeOptions<T>): Node<T>;
|
|
1346
|
-
|
|
1347
|
-
export { type RigorRecorder as $, type Actor as A, type NodeInspectorHook as B, COMPLETE as C, DATA as D, ERROR as E, type FnCtx as F, type GlobalInspectorEvent as G, type HashFn as H, INVALIDATE as I, type NodeInspectorHookEvent as J, type NodeSink as K, type NodeStatus as L, type Messages as M, type Node as N, type NodeTransportOptions as O, type NodeVersionInfo as P, type OnMessageHandler as Q, type OnSubscribeHandler as R, PAUSE as S, type PolicyAllow as T, type PolicyDeny as U, type VersioningLevel as V, type PolicyRuleData as W, RESOLVED as X, RESOLVED_MSG as Y, RESOLVED_ONLY_BATCH as Z, RESUME as _, type NodeOptions as a, START as a0, START_MSG as a1, type SubscribeContext as a2, TEARDOWN as a3, TEARDOWN_MSG as a4, TEARDOWN_ONLY_BATCH as a5, type V0 as a6, type V1 as a7, type VersioningOptions as a8, accessHintForGuard as a9, advanceVersion as aa, configure as ab, createVersioning as ac, defaultConfig as ad, defaultHash as ae, isV1 as af, node as ag, normalizeActor as ah, policy as ai, policyFromRules as aj, registerBuiltins as ak, type NodeGuard as b, type NodeActions as c, type NodeFnCleanup as d, type NodeDescribeKind as e, COMPLETE_MSG as f, COMPLETE_ONLY_BATCH as g, DEFAULT_ACTOR as h, DIRTY as i, DIRTY_MSG as j, DIRTY_ONLY_BATCH as k, type DepRecord as l, type GlobalInspectorHook as m, GraphReFlyConfig as n, type GuardAction as o, GuardDenied as p, type GuardDeniedDetails as q, INVALIDATE_MSG as r, INVALIDATE_ONLY_BATCH as s, type Message as t, type MessageContext as u, type MessageTypeRegistration as v, type MessageTypeRegistrationInput as w, type NodeCtx as x, type NodeFn as y, NodeImpl as z };
|