@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
|
@@ -1,1668 +0,0 @@
|
|
|
1
|
-
import { A as Actor, n as GraphReFlyConfig, V as VersioningLevel, N as Node, M as Messages, K as NodeSink } from './node-ClS5yC-B.cjs';
|
|
2
|
-
import { D as DescribeNodeOutput, a as DescribeDetail, b as DescribeField } from './meta-vE8bxW1E.cjs';
|
|
3
|
-
import { StorageHandle } from './extra/storage-core.cjs';
|
|
4
|
-
import { SnapshotStorageTier } from './extra/storage-tiers.cjs';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Pure structural diff over `GraphDescribeOutput` snapshots.
|
|
8
|
-
*
|
|
9
|
-
* Produces a {@link DescribeChangeset} of {@link DescribeEvent}s describing the
|
|
10
|
-
* topology delta from `prev` → `next`. Used by `Graph.describe({ reactive:
|
|
11
|
-
* "diff" })` internally and re-exported here for static-snapshot diffing
|
|
12
|
-
* (e.g. computing the topology delta between two persisted snapshots without
|
|
13
|
-
* spinning up a live graph).
|
|
14
|
-
*
|
|
15
|
-
* Topology-only — no value/state events. The data layer lives in
|
|
16
|
-
* `Graph.observe`. Per Tier 1.5.1 (locked Session A.1), `DescribeEvent` and
|
|
17
|
-
* {@link ObserveEvent} have disjoint type sets so a consumer can route both
|
|
18
|
-
* streams without ambiguity.
|
|
19
|
-
*
|
|
20
|
-
* `flushedAt_ns` is taken from `core/clock.ts`'s `monotonicNs()` so callers can
|
|
21
|
-
* order changesets across the same process without wall-clock skew.
|
|
22
|
-
*
|
|
23
|
-
* @module
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Meta dictionary attached to a node, as surfaced by
|
|
28
|
-
* {@link DescribeNodeOutput.meta}. Aliased here so {@link DescribeEvent}'s
|
|
29
|
-
* `node-meta-changed` variant has a stable, narrow type.
|
|
30
|
-
*/
|
|
31
|
-
type Meta = Record<string, unknown>;
|
|
32
|
-
/**
|
|
33
|
-
* One topology delta between two `describe()` snapshots. Disjoint from
|
|
34
|
-
* `ObserveEvent` (the data-layer envelope).
|
|
35
|
-
*/
|
|
36
|
-
type DescribeEvent = {
|
|
37
|
-
type: "node-added";
|
|
38
|
-
path: string;
|
|
39
|
-
node: DescribeNodeOutput;
|
|
40
|
-
} | {
|
|
41
|
-
type: "node-removed";
|
|
42
|
-
path: string;
|
|
43
|
-
} | {
|
|
44
|
-
type: "node-meta-changed";
|
|
45
|
-
path: string;
|
|
46
|
-
prevMeta: Meta;
|
|
47
|
-
nextMeta: Meta;
|
|
48
|
-
} | {
|
|
49
|
-
type: "edge-added";
|
|
50
|
-
from: string;
|
|
51
|
-
to: string;
|
|
52
|
-
} | {
|
|
53
|
-
type: "edge-removed";
|
|
54
|
-
from: string;
|
|
55
|
-
to: string;
|
|
56
|
-
} | {
|
|
57
|
-
type: "subgraph-mounted";
|
|
58
|
-
path: string;
|
|
59
|
-
} | {
|
|
60
|
-
type: "subgraph-unmounted";
|
|
61
|
-
path: string;
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Coalesced batch of {@link DescribeEvent}s emitted as a single DATA wave by
|
|
65
|
-
* `Graph.describe({ reactive: "diff" })` per outermost batch flush.
|
|
66
|
-
*
|
|
67
|
-
* `flushedAt_ns` is monotonic (from `core/clock.ts`); compare against another
|
|
68
|
-
* changeset's `flushedAt_ns` to order them. `events` is empty only when
|
|
69
|
-
* `topologyDiff` is called with two structurally identical snapshots; reactive
|
|
70
|
-
* variants suppress empty changesets so consumers don't see no-op DATA waves.
|
|
71
|
-
*/
|
|
72
|
-
type DescribeChangeset = {
|
|
73
|
-
events: ReadonlyArray<DescribeEvent>;
|
|
74
|
-
flushedAt_ns: number;
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Pure topology delta from `prev` → `next`. No I/O, no node references — purely
|
|
78
|
-
* over the JSON shape `Graph.describe()` returns.
|
|
79
|
-
*
|
|
80
|
-
* Event ordering within a changeset:
|
|
81
|
-
* 1. `subgraph-mounted` (added subgraphs first — their nodes follow)
|
|
82
|
-
* 2. `node-added`
|
|
83
|
-
* 3. `node-meta-changed`
|
|
84
|
-
* 4. `edge-added`
|
|
85
|
-
* 5. `edge-removed`
|
|
86
|
-
* 6. `node-removed`
|
|
87
|
-
* 7. `subgraph-unmounted` (last — node removals already reported)
|
|
88
|
-
*
|
|
89
|
-
* Each group is emitted in code-point sort order on the path / `${from}->${to}`
|
|
90
|
-
* key so the changeset is deterministic across runs (useful for snapshot
|
|
91
|
-
* tests and golden-output assertions).
|
|
92
|
-
*/
|
|
93
|
-
declare function topologyDiff(prev: GraphDescribeOutput, next: GraphDescribeOutput): DescribeChangeset;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Causal walkback over a {@link Graph.describe} snapshot (roadmap §9.2).
|
|
97
|
-
*
|
|
98
|
-
* `explainPath` finds the shortest dep-chain from `from` to `to` and returns a
|
|
99
|
-
* step-by-step {@link CausalChain} enriched with each node's current value,
|
|
100
|
-
* status, last-mutation actor, and any `graph.trace()` reasoning annotation.
|
|
101
|
-
*
|
|
102
|
-
* Pure function over the snapshot — peer to {@link reachable}. The
|
|
103
|
-
* {@link Graph.explain} instance method auto-passes `describe({detail:"standard"})`
|
|
104
|
-
* plus runtime annotations and `lastMutation` so callers get rich output by
|
|
105
|
-
* default.
|
|
106
|
-
*
|
|
107
|
-
* @module
|
|
108
|
-
*/
|
|
109
|
-
|
|
110
|
-
/** One node along the causal chain returned by {@link explainPath}. */
|
|
111
|
-
interface CausalStep {
|
|
112
|
-
/** Qualified node path. */
|
|
113
|
-
path: string;
|
|
114
|
-
/** Node kind (`state` / `derived` / `producer` / etc.). */
|
|
115
|
-
type: DescribeNodeOutput["type"];
|
|
116
|
-
/** Status as of the source snapshot. */
|
|
117
|
-
status?: DescribeNodeOutput["status"];
|
|
118
|
-
/** Cached value at snapshot time (omitted when describe didn't include it). */
|
|
119
|
-
value?: unknown;
|
|
120
|
-
/** Hop distance from `from` (0 = `from`, N = `to`). */
|
|
121
|
-
hop: number;
|
|
122
|
-
/** Annotation set via `graph.trace(path, annotation)` or `graph.add(node, { name: path, annotation })`, when present. */
|
|
123
|
-
annotation?: string;
|
|
124
|
-
/** Most recent guarded mutation, when known. */
|
|
125
|
-
lastMutation?: Readonly<{
|
|
126
|
-
actor: Actor;
|
|
127
|
-
timestamp_ns: number;
|
|
128
|
-
}>;
|
|
129
|
-
/** V0/V1 versioning info, when present. */
|
|
130
|
-
v?: DescribeNodeOutput["v"];
|
|
131
|
-
/** Index of this step in the next step's `deps` (i.e. which dep slot fed forward). */
|
|
132
|
-
dep_index?: number;
|
|
133
|
-
/**
|
|
134
|
-
* All dep slots when the same dep appears multiple times in the next
|
|
135
|
-
* step's `deps`. Present only for multi-edge connections; `dep_index`
|
|
136
|
-
* always equals `dep_indices[0]` when set.
|
|
137
|
-
*/
|
|
138
|
-
dep_indices?: number[];
|
|
139
|
-
}
|
|
140
|
-
/** Outcome of an {@link explainPath} call. */
|
|
141
|
-
interface CausalChain {
|
|
142
|
-
from: string;
|
|
143
|
-
to: string;
|
|
144
|
-
/** True when a path was found. */
|
|
145
|
-
found: boolean;
|
|
146
|
-
/** Why the chain may be empty/incomplete. `"ok"` when `found` is true.
|
|
147
|
-
* `"pending"` is the reactive-explain sentinel emitted while reactive args
|
|
148
|
-
* are waiting for their first DATA (qa D5). */
|
|
149
|
-
reason: "ok" | "no-such-from" | "no-such-to" | "no-path" | "max-depth-exceeded" | "pending";
|
|
150
|
-
/** Ordered steps — first element is `from`, last is `to`. Empty when `!found`. */
|
|
151
|
-
steps: readonly CausalStep[];
|
|
152
|
-
/** Pretty multi-line rendering. Always present, even on failure (one-line message). */
|
|
153
|
-
text: string;
|
|
154
|
-
/** JSON-serializable form (drops `text` to keep payloads compact). */
|
|
155
|
-
toJSON(): {
|
|
156
|
-
from: string;
|
|
157
|
-
to: string;
|
|
158
|
-
found: boolean;
|
|
159
|
-
reason: CausalChain["reason"];
|
|
160
|
-
steps: readonly CausalStep[];
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
/** Options for {@link explainPath}. */
|
|
164
|
-
interface ExplainPathOptions {
|
|
165
|
-
/** Maximum hop distance to search. Omit for unbounded. */
|
|
166
|
-
maxDepth?: number;
|
|
167
|
-
/** Per-path reasoning annotations (typically `graph.trace()` output map). */
|
|
168
|
-
annotations?: ReadonlyMap<string, string>;
|
|
169
|
-
/** Per-path `lastMutation` map (overrides describe-derived values). */
|
|
170
|
-
lastMutations?: ReadonlyMap<string, Readonly<{
|
|
171
|
-
actor: Actor;
|
|
172
|
-
timestamp_ns: number;
|
|
173
|
-
}>>;
|
|
174
|
-
/**
|
|
175
|
-
* When `true` and `from === to`, search for a non-trivial cycle (path
|
|
176
|
-
* back to `from` through ≥1 other node) instead of returning the trivial
|
|
177
|
-
* single-step. Use when debugging feedback loops (COMPOSITION-GUIDE §7).
|
|
178
|
-
* If no real cycle exists, falls back to the trivial single-step. Default
|
|
179
|
-
* `false` — backward-compatible.
|
|
180
|
-
*/
|
|
181
|
-
findCycle?: boolean;
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Walks backward from `to` through `deps` to find the shortest path to `from`,
|
|
185
|
-
* then assembles an ordered, enriched {@link CausalChain}.
|
|
186
|
-
*
|
|
187
|
-
* @param described - `graph.describe()` output (any detail level; richer detail → richer steps).
|
|
188
|
-
* @param from - Path of the upstream node (the cause).
|
|
189
|
-
* @param to - Path of the downstream node (the effect).
|
|
190
|
-
* @param opts - Optional `maxDepth` and per-path annotation overlays.
|
|
191
|
-
* @returns A {@link CausalChain} — `found:false` with a `reason` when no path exists.
|
|
192
|
-
*
|
|
193
|
-
* @example
|
|
194
|
-
* ```ts
|
|
195
|
-
* import { explainPath } from "@graphrefly/graphrefly-ts";
|
|
196
|
-
* const chain = explainPath(graph.describe({ detail: "standard" }), "input", "result");
|
|
197
|
-
* console.log(chain.text);
|
|
198
|
-
* ```
|
|
199
|
-
*/
|
|
200
|
-
declare function explainPath(described: GraphDescribeOutput, from: string, to: string, opts?: ExplainPathOptions): CausalChain;
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Graph profiling and inspection utilities.
|
|
204
|
-
*
|
|
205
|
-
* Provides per-node memory estimation, connectivity stats, and hotspot
|
|
206
|
-
* detection. Non-invasive — reads from `describe()` and node internals
|
|
207
|
-
* without modifying state.
|
|
208
|
-
*
|
|
209
|
-
* @module
|
|
210
|
-
*/
|
|
211
|
-
|
|
212
|
-
/** Per-node profile entry. */
|
|
213
|
-
interface NodeProfile {
|
|
214
|
-
/** Qualified path within the graph. */
|
|
215
|
-
path: string;
|
|
216
|
-
/** Node type (state, derived, producer, effect). */
|
|
217
|
-
type: string;
|
|
218
|
-
/** Node status (disconnected, dirty, settled, errored, completed). */
|
|
219
|
-
status: string;
|
|
220
|
-
/** Approximate retained bytes for the node's cached value. */
|
|
221
|
-
valueSizeBytes: number;
|
|
222
|
-
/** Number of downstream subscribers (sinks). */
|
|
223
|
-
subscriberCount: number;
|
|
224
|
-
/** Number of upstream dependencies. */
|
|
225
|
-
depCount: number;
|
|
226
|
-
/**
|
|
227
|
-
* True if this is an effect node with no external subscribers — a classic
|
|
228
|
-
* leak pattern. See {@link GraphProfileResult.orphans} for the broader
|
|
229
|
-
* orphan-node detection across `derived` / `producer` / `effect`.
|
|
230
|
-
*/
|
|
231
|
-
isOrphanEffect: boolean;
|
|
232
|
-
/**
|
|
233
|
-
* Orphan category (batch 8 Unit 13 D). `null` when the node is healthy.
|
|
234
|
-
* - `"orphan-effect"` — effect with zero subscribers (pre-existing class).
|
|
235
|
-
* - `"idle-derived"` — derived with zero subscribers (wasted compute path
|
|
236
|
-
* if it ever activates; may indicate a factory forgot keepalive).
|
|
237
|
-
* - `"idle-producer"` — producer with zero subscribers (no external
|
|
238
|
-
* consumer; may be an over-eager factory or forgotten cleanup).
|
|
239
|
-
*/
|
|
240
|
-
orphanKind: "orphan-effect" | "idle-derived" | "idle-producer" | null;
|
|
241
|
-
}
|
|
242
|
-
/** Aggregate graph profile. */
|
|
243
|
-
interface GraphProfileResult {
|
|
244
|
-
/** Total node count. */
|
|
245
|
-
nodeCount: number;
|
|
246
|
-
/** Total edge count. */
|
|
247
|
-
edgeCount: number;
|
|
248
|
-
/** Subgraph count. */
|
|
249
|
-
subgraphCount: number;
|
|
250
|
-
/** All node profiles. */
|
|
251
|
-
nodes: NodeProfile[];
|
|
252
|
-
/** Total approximate value memory across all nodes. */
|
|
253
|
-
totalValueSizeBytes: number;
|
|
254
|
-
/**
|
|
255
|
-
* Top-N hotspots by dimension. Each list is sorted descending. See
|
|
256
|
-
* {@link GraphProfileOptions.topN} for the cap (default 10).
|
|
257
|
-
*/
|
|
258
|
-
hotspots: {
|
|
259
|
-
byValueSize: NodeProfile[];
|
|
260
|
-
bySubscriberCount: NodeProfile[];
|
|
261
|
-
byDepCount: NodeProfile[];
|
|
262
|
-
};
|
|
263
|
-
/**
|
|
264
|
-
* Every orphan across types — `effect`, `derived`, `producer` with zero
|
|
265
|
-
* subscribers. See {@link NodeProfile.orphanKind} for category.
|
|
266
|
-
*/
|
|
267
|
-
orphans: NodeProfile[];
|
|
268
|
-
/** Effect nodes with no external subscribers (legacy; subset of `orphans`). */
|
|
269
|
-
orphanEffects: NodeProfile[];
|
|
270
|
-
}
|
|
271
|
-
/** Options for {@link graphProfile}. */
|
|
272
|
-
interface GraphProfileOptions {
|
|
273
|
-
/** Limit hotspot list (default 10). */
|
|
274
|
-
topN?: number;
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Profile a graph's memory and connectivity characteristics.
|
|
278
|
-
*
|
|
279
|
-
* Uses `describe({ detail: "standard" })` for node metadata and direct
|
|
280
|
-
* `NodeImpl` access for subscriber counts and cached values.
|
|
281
|
-
*
|
|
282
|
-
* @param graph - The graph to profile.
|
|
283
|
-
* @param opts - Optional configuration.
|
|
284
|
-
* @returns Aggregate profile with per-node details, hotspots (multi-dim), and orphans.
|
|
285
|
-
*/
|
|
286
|
-
declare function graphProfile(graph: Graph, opts?: GraphProfileOptions): GraphProfileResult;
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Reserved segment for meta companion paths: `nodeName::__meta__::metaKey` (GRAPHREFLY-SPEC §3.6).
|
|
290
|
-
* Forbidden as a local node or mount name.
|
|
291
|
-
*/
|
|
292
|
-
declare const GRAPH_META_SEGMENT = "__meta__";
|
|
293
|
-
/**
|
|
294
|
-
* Options for {@link Graph}. Named fields documented below; the open index
|
|
295
|
-
* signature is preserved so callers can stash extension data on the graph
|
|
296
|
-
* without losing type discipline on the reserved names.
|
|
297
|
-
*
|
|
298
|
-
* - `config` — bind this graph to a specific {@link GraphReFlyConfig} for
|
|
299
|
-
* tier/metaPassthrough/inspector lookups. Defaults to the singleton
|
|
300
|
-
* `defaultConfig` exported from `core/node.ts`.
|
|
301
|
-
* - `versioning` — convenience for `graph.setVersioning(level)` at
|
|
302
|
-
* construction time. Monotonic bulk-apply; see {@link Graph.setVersioning}.
|
|
303
|
-
* - `factories` — reserved for future per-graph factory registration;
|
|
304
|
-
* currently factories flow through `Graph.fromSnapshot(data, {factories})`.
|
|
305
|
-
*/
|
|
306
|
-
interface GraphOptions {
|
|
307
|
-
config?: GraphReFlyConfig;
|
|
308
|
-
versioning?: VersioningLevel;
|
|
309
|
-
factories?: Record<string, GraphNodeFactory>;
|
|
310
|
-
/**
|
|
311
|
-
* Capacity of the reasoning-trace ring buffer. Default: `1000`. Set lower
|
|
312
|
-
* to reduce memory; higher for audit-heavy workloads. Set at construction
|
|
313
|
-
* time — not mutable afterward (ring buffers can't resize cleanly).
|
|
314
|
-
*/
|
|
315
|
-
traceCapacity?: number;
|
|
316
|
-
/**
|
|
317
|
-
* Tier 1.5.3 Phase 2.5 (Session A.1 lock + Phase 2.5 design DG1=B, 2026-04-27).
|
|
318
|
-
* Top-level factory identifier for Graph-returning factories (`agentMemory`,
|
|
319
|
-
* `harnessLoop`, `pipelineGraph`, etc.). When set, `describe()` surfaces
|
|
320
|
-
* `factory` + `factoryArgs` at the top of `GraphDescribeOutput` so consumers
|
|
321
|
-
* can identify provenance, and `compileSpec` can delegate reconstruction to
|
|
322
|
-
* `catalog.graphFactories[factory]` with `factoryArgs`. Prefer the
|
|
323
|
-
* post-construction `Graph.prototype.tagFactory(name, args?)` mutator inside
|
|
324
|
-
* the factory body over passing here directly.
|
|
325
|
-
*/
|
|
326
|
-
factory?: string;
|
|
327
|
-
/**
|
|
328
|
-
* JSON-serializable subset of the construction args. For non-JSON fields
|
|
329
|
-
* (LLMAdapter, callbacks, embedders), prefer the {@link placeholderArgs}
|
|
330
|
-
* helper which substitutes descriptive `"<Node>"` / `"<function>"` strings
|
|
331
|
-
* (DG2 = ii). Catalog `graphFactories` recipients receive this back during
|
|
332
|
-
* `compileSpec` to recreate the graph with the user-supplied runtime ctx.
|
|
333
|
-
*/
|
|
334
|
-
factoryArgs?: unknown;
|
|
335
|
-
[key: string]: unknown;
|
|
336
|
-
}
|
|
337
|
-
/** Filter for {@link Graph.describe} — object-style partial match or predicate. */
|
|
338
|
-
type DescribeFilter = Partial<Pick<DescribeNodeOutput, "type" | "status">> | {
|
|
339
|
-
type?: DescribeNodeOutput["type"];
|
|
340
|
-
status?: DescribeNodeOutput["status"];
|
|
341
|
-
/** Keep nodes whose `deps` includes this qualified path. */
|
|
342
|
-
depsIncludes?: string;
|
|
343
|
-
/** Snake-case alias for `depsIncludes` (Python parity). */
|
|
344
|
-
deps_includes?: string;
|
|
345
|
-
/** Keep nodes whose `meta` contains this key. */
|
|
346
|
-
metaHas?: string;
|
|
347
|
-
/** Snake-case alias for `metaHas` (Python parity). */
|
|
348
|
-
meta_has?: string;
|
|
349
|
-
} | ((node: DescribeNodeOutput) => boolean) | ((nodePath: string, node: DescribeNodeOutput) => boolean);
|
|
350
|
-
/** Options for {@link Graph.signal} and {@link Graph.set} (actor context, internal lifecycle). */
|
|
351
|
-
type GraphActorOptions = {
|
|
352
|
-
actor?: Actor;
|
|
353
|
-
/**
|
|
354
|
-
* When `true`, skips node guards (graph lifecycle TEARDOWN, unmount teardown, etc.).
|
|
355
|
-
*/
|
|
356
|
-
internal?: boolean;
|
|
357
|
-
};
|
|
358
|
-
/** Options for {@link Graph.describe} (Phase 3.3b progressive disclosure). */
|
|
359
|
-
type GraphDescribeOptions = {
|
|
360
|
-
/**
|
|
361
|
-
* Scope `describe()` to what `actor` is allowed to observe. Accepts a
|
|
362
|
-
* static {@link Actor} (resolved at call time) or a `Node<Actor>` — when a
|
|
363
|
-
* Node is passed and `reactive: true` is set, the reactive describe handle
|
|
364
|
-
* subscribes to the actor node and re-derives whenever the actor changes,
|
|
365
|
-
* so harnesses that bind a reactive actor (e.g. per-turn `currentActor`
|
|
366
|
-
* state) get a single live describe Node instead of re-calling
|
|
367
|
-
* `describe({ actor })` per turn.
|
|
368
|
-
*
|
|
369
|
-
* **Cache-undefined semantics:** when a `Node<Actor>` is supplied whose
|
|
370
|
-
* `cache` is `undefined` (e.g. a `producer` that has not yet emitted),
|
|
371
|
-
* describe is treated identically to `actor: undefined` — i.e. **no
|
|
372
|
-
* scoping** (full visibility). This matches every other Node-cache read in
|
|
373
|
-
* the codebase, but means a not-yet-active actor node degrades to "describe
|
|
374
|
-
* everything." Activate the actor node (subscribe + emit, or seed via
|
|
375
|
-
* `state(initial)`) before calling `describe` if you rely on guard
|
|
376
|
-
* scoping. In `reactive: true` mode the describe re-derives once the
|
|
377
|
-
* actor node populates.
|
|
378
|
-
*
|
|
379
|
-
* **Terminal-type handling:** if the supplied `Node<Actor>` emits
|
|
380
|
-
* `COMPLETE`, `ERROR`, or `TEARDOWN`, the reactive describe releases the
|
|
381
|
-
* actor subscription and re-derives one last time against the final
|
|
382
|
-
* `actor.cache` value. Subsequent describe outputs reflect that frozen
|
|
383
|
-
* cache until `handle.dispose()` runs.
|
|
384
|
-
*/
|
|
385
|
-
actor?: Actor | Node<Actor>;
|
|
386
|
-
/**
|
|
387
|
-
* Node filter. Filters operate on whatever fields the chosen `detail` level
|
|
388
|
-
* provides. For `metaHas` and `status` filters, use `detail: "standard"` or
|
|
389
|
-
* higher — at `"minimal"` those fields are absent and the filter silently
|
|
390
|
-
* excludes all nodes.
|
|
391
|
-
*/
|
|
392
|
-
filter?: DescribeFilter;
|
|
393
|
-
/**
|
|
394
|
-
* Detail level (Phase 3.3b). Default: `"minimal"`.
|
|
395
|
-
* - `"minimal"` — type + deps only
|
|
396
|
-
* - `"standard"` — type, status, value, deps, meta, versioning (`v`)
|
|
397
|
-
* - `"full"` — standard + guard, lastMutation
|
|
398
|
-
*/
|
|
399
|
-
detail?: DescribeDetail;
|
|
400
|
-
/**
|
|
401
|
-
* Explicit field selection (GraphQL-style). Overrides `detail` when provided.
|
|
402
|
-
* Dotted paths like `"meta.label"` select specific meta keys.
|
|
403
|
-
*/
|
|
404
|
-
fields?: DescribeField[];
|
|
405
|
-
/**
|
|
406
|
-
* Reactive describe (D2):
|
|
407
|
-
* - `true` — return `{ node, dispose }` where `node` emits a fresh
|
|
408
|
-
* `GraphDescribeOutput` every time the graph state settles. Same
|
|
409
|
-
* coalescing as {@link Graph.explain} with `{ reactive: true }`.
|
|
410
|
-
* - `"diff"` — return `{ node, dispose }` where `node` emits a
|
|
411
|
-
* {@link DescribeChangeset} per topology change. Empty changesets are
|
|
412
|
-
* suppressed; the initial cache is a synthetic full-add diff so a fresh
|
|
413
|
-
* subscriber sees the current topology as adds via push-on-subscribe.
|
|
414
|
-
* (Tier 1.5.1 — Session A.1 lock).
|
|
415
|
-
*/
|
|
416
|
-
reactive?: boolean | "diff";
|
|
417
|
-
/** Reactive-only: name for the backing derived node (default `"describe"`). */
|
|
418
|
-
reactiveName?: string;
|
|
419
|
-
};
|
|
420
|
-
/** Handle returned by {@link Graph.describe} with `{ reactive: true }`. */
|
|
421
|
-
interface ReactiveDescribeHandle<T> {
|
|
422
|
-
readonly node: Node<T>;
|
|
423
|
-
dispose(): void;
|
|
424
|
-
}
|
|
425
|
-
/** JSON snapshot from {@link Graph.describe} (GRAPHREFLY-SPEC §3.6, Appendix B). */
|
|
426
|
-
type GraphDescribeOutput = {
|
|
427
|
-
name: string;
|
|
428
|
-
nodes: Record<string, DescribeNodeOutput>;
|
|
429
|
-
edges: ReadonlyArray<{
|
|
430
|
-
from: string;
|
|
431
|
-
to: string;
|
|
432
|
-
}>;
|
|
433
|
-
subgraphs: string[];
|
|
434
|
-
/**
|
|
435
|
-
* Top-level factory identifier (Tier 1.5.3 Phase 2.5 — DG1=B). Present when
|
|
436
|
-
* the graph was constructed by a Graph-returning factory that called
|
|
437
|
-
* `Graph.prototype.tagFactory(name, args?)` (or set `GraphOptions.factory`).
|
|
438
|
-
* Used by `compileSpec` for catalog-based reconstruction via
|
|
439
|
-
* `catalog.graphFactories[factory]`.
|
|
440
|
-
*/
|
|
441
|
-
factory?: string;
|
|
442
|
-
/** JSON-serializable construction args paired with `factory`. */
|
|
443
|
-
factoryArgs?: unknown;
|
|
444
|
-
/**
|
|
445
|
-
* Re-read the live graph with higher detail (Phase 3.3b).
|
|
446
|
-
* Returns a new `GraphDescribeOutput`; the original remains a snapshot.
|
|
447
|
-
* Present on live describe results; absent on deserialized snapshots.
|
|
448
|
-
*/
|
|
449
|
-
expand?: (detailOrFields: DescribeDetail | DescribeField[]) => GraphDescribeOutput;
|
|
450
|
-
};
|
|
451
|
-
/**
|
|
452
|
-
* Persisted graph snapshot: {@link GraphDescribeOutput} plus optional format version
|
|
453
|
-
* ({@link Graph.snapshot}, {@link Graph.restore}, {@link Graph.fromSnapshot}, {@link Graph.toObject},
|
|
454
|
-
* {@link Graph.toJSONString} — §3.8).
|
|
455
|
-
*/
|
|
456
|
-
type GraphPersistSnapshot = GraphDescribeOutput & {
|
|
457
|
-
version?: number;
|
|
458
|
-
};
|
|
459
|
-
type GraphFactoryContext = {
|
|
460
|
-
path: string;
|
|
461
|
-
type: DescribeNodeOutput["type"];
|
|
462
|
-
value: unknown;
|
|
463
|
-
meta: Record<string, unknown>;
|
|
464
|
-
deps: readonly string[];
|
|
465
|
-
resolvedDeps: readonly Node[];
|
|
466
|
-
};
|
|
467
|
-
type GraphNodeFactory = (name: string, context: GraphFactoryContext) => Node;
|
|
468
|
-
/**
|
|
469
|
-
* Checkpoint record shape passed to `SnapshotStorageTier.save`. Written by
|
|
470
|
-
* {@link Graph.attachSnapshotStorage} per-tier according to each tier's
|
|
471
|
-
* `compactEvery` cadence.
|
|
472
|
-
*
|
|
473
|
-
* `mode: "full"` → full snapshot. Baseline anchor emitted on the first save
|
|
474
|
-
* and every `compactEvery`-th save thereafter. Sufficient to recover state
|
|
475
|
-
* on its own without WAL replay.
|
|
476
|
-
* `mode: "diff"` → delta payload only, relative to this tier's most recent
|
|
477
|
-
* `"full"` baseline. Between compacts. Wire-efficient; requires WAL replay
|
|
478
|
-
* over the preceding `"full"` record to reconstruct state.
|
|
479
|
-
*
|
|
480
|
-
* Every record includes `seq` (per-tier monotonic counter), `timestamp_ns`
|
|
481
|
-
* (wall-clock at flush time), and `format_version` (envelope version for
|
|
482
|
-
* cross-version WAL replay).
|
|
483
|
-
*/
|
|
484
|
-
type GraphCheckpointRecord = {
|
|
485
|
-
name: string;
|
|
486
|
-
seq: number;
|
|
487
|
-
timestamp_ns: number;
|
|
488
|
-
format_version: number;
|
|
489
|
-
} & ({
|
|
490
|
-
mode: "full";
|
|
491
|
-
snapshot: GraphPersistSnapshot;
|
|
492
|
-
} | {
|
|
493
|
-
mode: "diff";
|
|
494
|
-
diff: GraphWALDiff;
|
|
495
|
-
});
|
|
496
|
-
/** Options for {@link Graph.attachSnapshotStorage}. */
|
|
497
|
-
type GraphAttachStorageOptions = {
|
|
498
|
-
/**
|
|
499
|
-
* Before the first save, attempt to restore from the first tier whose
|
|
500
|
-
* `load(graph.name)` hits. Runs asynchronously in the background for
|
|
501
|
-
* async tiers; errors surface via `onError`. Default `false`.
|
|
502
|
-
*/
|
|
503
|
-
autoRestore?: boolean;
|
|
504
|
-
/**
|
|
505
|
-
* Limit the subscription surface (scoped observe). By default
|
|
506
|
-
* `attachSnapshotStorage` observes every node in the graph tree; on large graphs
|
|
507
|
-
* that's thousands of subscriptions just for tier-gating. Pass a path
|
|
508
|
-
* list (or a single glob) to observe only those nodes.
|
|
509
|
-
*/
|
|
510
|
-
paths?: readonly string[] | string;
|
|
511
|
-
/** Pre-save path-level filter — skip records triggered by paths that fail this predicate. */
|
|
512
|
-
filter?: (name: string, described: DescribeNodeOutput) => boolean;
|
|
513
|
-
/** Surfaced on tier save errors and autoRestore failures. */
|
|
514
|
-
onError?: (error: unknown, tier: SnapshotStorageTier<GraphCheckpointRecord>) => void;
|
|
515
|
-
};
|
|
516
|
-
/**
|
|
517
|
-
* Event emitted by {@link Graph.topology} on every structural change to the
|
|
518
|
-
* graph's own registry. Does NOT include value mutations (use `observe()` for
|
|
519
|
-
* those) or transitively nested subgraph events (subscribe to each mounted
|
|
520
|
-
* child's `topology` for that).
|
|
521
|
-
*
|
|
522
|
-
* - `"added"` — `name` is the local key registered via {@link Graph.add}
|
|
523
|
-
* (`nodeKind: "node"`) or {@link Graph.mount} (`nodeKind: "mount"`).
|
|
524
|
-
* - `"removed"` — emitted AFTER {@link Graph.remove} completes teardown.
|
|
525
|
-
* `audit` is the full {@link GraphRemoveAudit} returned to the caller.
|
|
526
|
-
*/
|
|
527
|
-
type TopologyEvent = {
|
|
528
|
-
kind: "added";
|
|
529
|
-
name: string;
|
|
530
|
-
nodeKind: "node" | "mount";
|
|
531
|
-
} | {
|
|
532
|
-
kind: "removed";
|
|
533
|
-
name: string;
|
|
534
|
-
nodeKind: "node" | "mount";
|
|
535
|
-
audit: GraphRemoveAudit;
|
|
536
|
-
};
|
|
537
|
-
/**
|
|
538
|
-
* Direction options for diagram exports. Mirrors `DiagramDirection` from
|
|
539
|
-
* `@graphrefly/graphrefly/extra/render` (the renderers consume their own
|
|
540
|
-
* structurally-identical type) — re-exported here so callers building
|
|
541
|
-
* options for `Graph` ergonomics don't need a separate import.
|
|
542
|
-
*/
|
|
543
|
-
type GraphDiagramDirection = "TD" | "LR" | "BT" | "RL";
|
|
544
|
-
/**
|
|
545
|
-
* Snapshot format version (§3.8). Exported so the surface layer's
|
|
546
|
-
* `saveSnapshot` writes the same `format_version` as
|
|
547
|
-
* `Graph.attachSnapshotStorage` — one source of truth prevents silent wire
|
|
548
|
-
* drift between auto-checkpoint and one-shot persistence paths.
|
|
549
|
-
*/
|
|
550
|
-
declare const SNAPSHOT_VERSION = 1;
|
|
551
|
-
/**
|
|
552
|
-
* Option shapes that trigger structured-mode dispatch in {@link Graph.observe}.
|
|
553
|
-
* Presence of any of these fields (truthy) → returns {@link ObserveResult};
|
|
554
|
-
* otherwise `observe()` returns the raw-stream variants.
|
|
555
|
-
*/
|
|
556
|
-
type StructuredTriggers = {
|
|
557
|
-
structured?: true;
|
|
558
|
-
timeline?: true;
|
|
559
|
-
causal?: true;
|
|
560
|
-
derived?: true;
|
|
561
|
-
format?: "pretty" | "json" | "stage-log";
|
|
562
|
-
detail?: "minimal" | "full";
|
|
563
|
-
};
|
|
564
|
-
/** {@link Graph.observe} on a single node or meta path — sink receives plain message batches. */
|
|
565
|
-
type GraphObserveOne = {
|
|
566
|
-
subscribe(sink: NodeSink): () => void;
|
|
567
|
-
/** Send messages upstream toward the observed node's sources (e.g. PAUSE/RESUME). */
|
|
568
|
-
up(messages: Messages): void;
|
|
569
|
-
};
|
|
570
|
-
/**
|
|
571
|
-
* {@link Graph.observe} on the whole graph — sink receives each batch with the qualified source path.
|
|
572
|
-
* Subscription order follows code-point sort on paths (mounts-first walk, then sorted locals/meta).
|
|
573
|
-
*/
|
|
574
|
-
type GraphObserveAll = {
|
|
575
|
-
subscribe(sink: (nodePath: string, messages: Messages) => void): () => void;
|
|
576
|
-
/** Send messages upstream toward a specific observed node's sources (e.g. PAUSE/RESUME). */
|
|
577
|
-
up(path: string, messages: Messages): void;
|
|
578
|
-
};
|
|
579
|
-
/**
|
|
580
|
-
* Detail level for `observe()` progressive disclosure (Phase 3.3b).
|
|
581
|
-
* - `"minimal"` — DATA events only, no timestamps, no causal info.
|
|
582
|
-
* - `"standard"` — all message types (DATA, DIRTY, RESOLVED, INVALIDATE,
|
|
583
|
-
* PAUSE, RESUME, COMPLETE, ERROR, TEARDOWN).
|
|
584
|
-
* - `"full"` — standard + timeline + causal + derived.
|
|
585
|
-
*/
|
|
586
|
-
type ObserveDetail = "minimal" | "standard" | "full";
|
|
587
|
-
/**
|
|
588
|
-
* Tier name for {@link ObserveEvent} filtering. Aligns with spec §1.2 message
|
|
589
|
-
* tier semantics — each `ObserveTier` corresponds to one or more protocol
|
|
590
|
-
* message types. Used by {@link ObserveOptions.tiers} to scope observation to
|
|
591
|
-
* a subset of event categories (e.g. `tiers: ["error", "complete", "teardown"]`
|
|
592
|
-
* for failure-only health monitoring).
|
|
593
|
-
*/
|
|
594
|
-
type ObserveTier = ObserveEvent["type"];
|
|
595
|
-
/**
|
|
596
|
-
* Coalesced batch of {@link ObserveEvent}s emitted as one DATA wave per
|
|
597
|
-
* outermost batch flush by `Graph.observe({ reactive: true })`.
|
|
598
|
-
*
|
|
599
|
-
* Disjoint from `DescribeChangeset` (the topology-layer envelope). Each event
|
|
600
|
-
* carries its own `path` so consumers route per-path without unwrapping the
|
|
601
|
-
* envelope first. `flushedAt_ns` is monotonic via `core/clock.ts`.
|
|
602
|
-
*/
|
|
603
|
-
type ObserveChangeset = {
|
|
604
|
-
events: ReadonlyArray<ObserveEvent>;
|
|
605
|
-
flushedAt_ns: number;
|
|
606
|
-
};
|
|
607
|
-
/** Options for structured observation modes on {@link Graph.observe}. */
|
|
608
|
-
type ObserveOptions = {
|
|
609
|
-
actor?: Actor;
|
|
610
|
-
/** Return an {@link ObserveResult} accumulator instead of a raw stream. */
|
|
611
|
-
structured?: boolean;
|
|
612
|
-
/** Include causal trace info (which dep triggered each recomputation). */
|
|
613
|
-
causal?: boolean;
|
|
614
|
-
/** Include timestamps and batch context on each event. */
|
|
615
|
-
timeline?: boolean;
|
|
616
|
-
/** Include per-evaluation dep snapshots for compute/derived nodes. */
|
|
617
|
-
derived?: boolean;
|
|
618
|
-
/**
|
|
619
|
-
* Detail level (Phase 3.3b). Individual flags (`causal`, `timeline`, `derived`)
|
|
620
|
-
* override. `"full"` implies all three plus structured.
|
|
621
|
-
* `"minimal"` filters to DATA-only events.
|
|
622
|
-
*/
|
|
623
|
-
detail?: ObserveDetail;
|
|
624
|
-
/**
|
|
625
|
-
* Filter observed events to these tiers only. When omitted, all event types
|
|
626
|
-
* are delivered. Applies to both the structured callback and the reactive
|
|
627
|
-
* variants (`observe({ reactive: true })`).
|
|
628
|
-
*
|
|
629
|
-
* Example: `tiers: ["error", "complete", "teardown"]` for failure-only
|
|
630
|
-
* health monitoring; `tiers: ["data"]` for value-flow tracking.
|
|
631
|
-
*/
|
|
632
|
-
tiers?: readonly ObserveTier[];
|
|
633
|
-
/**
|
|
634
|
-
* Return a `Node<ObserveChangeset>` that emits one DATA wave per outermost
|
|
635
|
-
* batch flush, with all observed events for that flush coalesced into a
|
|
636
|
-
* single changeset. Auto-enables structured mode (the reactive variant
|
|
637
|
-
* delivers {@link ObserveEvent}s, not raw messages).
|
|
638
|
-
*
|
|
639
|
-
* Coalescing matches `describe({ reactive: true })`'s `registerBatchFlushHook`
|
|
640
|
-
* mechanism — N events in one batch → one changeset DATA wave at flush.
|
|
641
|
-
*/
|
|
642
|
-
reactive?: boolean;
|
|
643
|
-
/** Optional name for the reactive changeset node when `reactive: true`. */
|
|
644
|
-
reactiveName?: string;
|
|
645
|
-
/**
|
|
646
|
-
* When set, auto-enables structured mode and attaches a logger.
|
|
647
|
-
* - `"pretty"` — colored one-line output per event.
|
|
648
|
-
* - `"json"` — one JSON object per event.
|
|
649
|
-
* - `"stage-log"` — pipeline-stage-labeled output for multi-node
|
|
650
|
-
* observers. Auto-enables `timeline: true` so each line carries an
|
|
651
|
-
* elapsed-seconds offset from the subscription. Provide a
|
|
652
|
-
* {@link stageLabels} map to label each observed path; paths without a
|
|
653
|
-
* mapping fall back to the path string.
|
|
654
|
-
*/
|
|
655
|
-
format?: "pretty" | "json" | "stage-log";
|
|
656
|
-
/** Sink for rendered lines (`console.log` by default). Only used when `format` is set. */
|
|
657
|
-
logger?: (line: string, event: ObserveEvent) => void;
|
|
658
|
-
/** Keep only these event types in formatted output. Only used when `format` is set. */
|
|
659
|
-
includeTypes?: ObserveEvent["type"][];
|
|
660
|
-
/** Exclude these event types from formatted output. Only used when `format` is set. */
|
|
661
|
-
excludeTypes?: ObserveEvent["type"][];
|
|
662
|
-
/** Built-in color preset (`ansi` default) or explicit color tokens. Only used when `format` is set. */
|
|
663
|
-
theme?: ObserveThemeName | ObserveTheme;
|
|
664
|
-
/**
|
|
665
|
-
* Stage labels for `format: "stage-log"`. Keys are observe paths; values
|
|
666
|
-
* are short stage names (e.g. `{ "intake::latest": "INTAKE" }`). Paths
|
|
667
|
-
* without a mapping render under the path string itself. Ignored for
|
|
668
|
-
* other formats.
|
|
669
|
-
*/
|
|
670
|
-
stageLabels?: Record<string, string>;
|
|
671
|
-
/**
|
|
672
|
-
* Cap the `events` buffer. When set, the result uses a {@link RingBuffer}
|
|
673
|
-
* under the hood: oldest events are dropped on overflow. Unbounded when
|
|
674
|
-
* omitted (default).
|
|
675
|
-
*/
|
|
676
|
-
maxEvents?: number;
|
|
677
|
-
};
|
|
678
|
-
/** Accumulated observation result (structured mode). */
|
|
679
|
-
type ObserveResult<T = unknown> = AsyncIterable<ObserveEvent> & {
|
|
680
|
-
/** Latest DATA value by observed path. */
|
|
681
|
-
readonly values: Record<string, T>;
|
|
682
|
-
/** Number of DIRTY messages received. */
|
|
683
|
-
readonly dirtyCount: number;
|
|
684
|
-
/** Number of RESOLVED messages received. */
|
|
685
|
-
readonly resolvedCount: number;
|
|
686
|
-
/** Number of INVALIDATE messages received (tier 1 cache-clear). */
|
|
687
|
-
readonly invalidateCount: number;
|
|
688
|
-
/** Number of PAUSE messages received (tier 2 backpressure). */
|
|
689
|
-
readonly pauseCount: number;
|
|
690
|
-
/** Number of RESUME messages received (tier 2 backpressure). */
|
|
691
|
-
readonly resumeCount: number;
|
|
692
|
-
/** Number of TEARDOWN messages received (tier 5 permanent cleanup). */
|
|
693
|
-
readonly teardownCount: number;
|
|
694
|
-
/**
|
|
695
|
-
* All events in order — ring-buffered when `options.maxEvents` is set,
|
|
696
|
-
* unbounded otherwise. Always materialized as an `ObserveEvent[]`
|
|
697
|
-
* snapshot on read.
|
|
698
|
-
*/
|
|
699
|
-
readonly events: ObserveEvent[];
|
|
700
|
-
/** True if any observed node sent COMPLETE without prior ERROR on that node. */
|
|
701
|
-
readonly anyCompletedCleanly: boolean;
|
|
702
|
-
/** True if any observed node sent ERROR. */
|
|
703
|
-
readonly anyErrored: boolean;
|
|
704
|
-
/** True if at least one COMPLETE received and no ERROR from any observed node. */
|
|
705
|
-
readonly completedWithoutErrors: boolean;
|
|
706
|
-
/**
|
|
707
|
-
* Attach a live listener that fires for each event as it arrives.
|
|
708
|
-
* Returns an unsubscribe fn. Independent of the `events` buffer.
|
|
709
|
-
*/
|
|
710
|
-
onEvent(listener: (event: ObserveEvent) => void): () => void;
|
|
711
|
-
/** Stop observing. */
|
|
712
|
-
dispose(): void;
|
|
713
|
-
/**
|
|
714
|
-
* Resubscribe with higher detail (Phase 3.3b).
|
|
715
|
-
* Disposes current observation, returns new `ObserveResult` with merged options.
|
|
716
|
-
*/
|
|
717
|
-
expand(extra: Partial<Pick<ObserveOptions, "causal" | "timeline" | "derived">> | ObserveDetail): ObserveResult<T>;
|
|
718
|
-
};
|
|
719
|
-
/** Fields common to every {@link ObserveEvent} variant. */
|
|
720
|
-
interface ObserveEventBase {
|
|
721
|
-
path?: string;
|
|
722
|
-
/** Optional `timeline` context — wall-clock when `options.timeline === true`. */
|
|
723
|
-
timestamp_ns?: number;
|
|
724
|
-
in_batch?: boolean;
|
|
725
|
-
/** Monotonically increasing counter per subscribe-callback invocation. All events in one delivery share the same id. */
|
|
726
|
-
batch_id?: number;
|
|
727
|
-
/**
|
|
728
|
-
* Attribution for `data`/`error` events (B9 — actor threading). When
|
|
729
|
-
* the originating `node.down(...)` call supplied an `actor` via
|
|
730
|
-
* `NodeTransportOptions`, it's forwarded here as read from
|
|
731
|
-
* `Node.lastMutation`. Internal / unattributed writes stamp the
|
|
732
|
-
* library's `DEFAULT_ACTOR` (`{type: "system", id: ""}`) rather than
|
|
733
|
-
* being silently dropped, so downstream policy/audit consumers can
|
|
734
|
-
* evaluate policies against a well-formed actor in every case.
|
|
735
|
-
*
|
|
736
|
-
* Not populated for tier-1/tier-2 protocol events (`dirty`, `resolved`,
|
|
737
|
-
* `pause`, `resume`, `invalidate`, `teardown`) — those don't carry
|
|
738
|
-
* caller attribution.
|
|
739
|
-
*/
|
|
740
|
-
actor?: Actor;
|
|
741
|
-
}
|
|
742
|
-
/** Optional `causal` context present on `data`/`resolved`/`derived` events. */
|
|
743
|
-
interface ObserveCausalContext {
|
|
744
|
-
trigger_dep_index?: number;
|
|
745
|
-
trigger_dep_name?: string;
|
|
746
|
-
/**
|
|
747
|
-
* V0 version of the triggering dep at observation time (§6.0b).
|
|
748
|
-
* This is the dep's post-emission version (after its own `advanceVersion`),
|
|
749
|
-
* not the pre-emission version that caused this node's recomputation.
|
|
750
|
-
*/
|
|
751
|
-
trigger_version?: {
|
|
752
|
-
id: string;
|
|
753
|
-
version: number;
|
|
754
|
-
};
|
|
755
|
-
/**
|
|
756
|
-
* One scalar per dep: the last value that arrived in the current wave,
|
|
757
|
-
* or the pre-wave cached value for deps that didn't fire. Convenient
|
|
758
|
-
* for single-value-wave tooling (the common case).
|
|
759
|
-
*/
|
|
760
|
-
dep_values?: unknown[];
|
|
761
|
-
/**
|
|
762
|
-
* Full per-dep batches for the wave that fired the fn — `dep_batches[i]`
|
|
763
|
-
* is the array of values dep `i` delivered this wave (`undefined` for
|
|
764
|
-
* deps that didn't fire). Use this to distinguish a single-value wave
|
|
765
|
-
* from a multi-value wave; `dep_values` compresses each batch to its
|
|
766
|
-
* last element and hides that difference.
|
|
767
|
-
*/
|
|
768
|
-
dep_batches?: ReadonlyArray<ReadonlyArray<unknown> | undefined>;
|
|
769
|
-
}
|
|
770
|
-
/** A single event in the structured observation log (discriminated on `type`). */
|
|
771
|
-
type ObserveEvent = (ObserveEventBase & ObserveCausalContext & {
|
|
772
|
-
type: "data";
|
|
773
|
-
data: unknown;
|
|
774
|
-
}) | (ObserveEventBase & {
|
|
775
|
-
type: "dirty";
|
|
776
|
-
}) | (ObserveEventBase & ObserveCausalContext & {
|
|
777
|
-
type: "resolved";
|
|
778
|
-
}) | (ObserveEventBase & {
|
|
779
|
-
type: "invalidate";
|
|
780
|
-
}) | (ObserveEventBase & {
|
|
781
|
-
type: "pause";
|
|
782
|
-
lockId: unknown;
|
|
783
|
-
}) | (ObserveEventBase & {
|
|
784
|
-
type: "resume";
|
|
785
|
-
lockId: unknown;
|
|
786
|
-
}) | (ObserveEventBase & {
|
|
787
|
-
type: "complete";
|
|
788
|
-
}) | (ObserveEventBase & {
|
|
789
|
-
type: "error";
|
|
790
|
-
data: unknown;
|
|
791
|
-
}) | (ObserveEventBase & {
|
|
792
|
-
type: "teardown";
|
|
793
|
-
}) | (ObserveEventBase & ObserveCausalContext & {
|
|
794
|
-
type: "derived";
|
|
795
|
-
dep_values: unknown[];
|
|
796
|
-
});
|
|
797
|
-
/** Built-in color preset names for observe `format` rendering. */
|
|
798
|
-
type ObserveThemeName = "none" | "ansi";
|
|
799
|
-
/** ANSI/style overrides for observe `format` event rendering. */
|
|
800
|
-
type ObserveTheme = Partial<Record<ObserveEvent["type"] | "path" | "reset", string>>;
|
|
801
|
-
/**
|
|
802
|
-
* Named container for nodes and explicit edges (GRAPHREFLY-SPEC §3.1–§3.7).
|
|
803
|
-
*
|
|
804
|
-
* Qualified paths use `::` as the segment separator (for example `parent::child::node`).
|
|
805
|
-
*
|
|
806
|
-
* Edges are pure wires: `connect` only validates wiring — the target must already list the source in
|
|
807
|
-
* its dependency array; no transforms run on the edge.
|
|
808
|
-
*
|
|
809
|
-
* @example
|
|
810
|
-
* ```ts
|
|
811
|
-
* import { Graph, state } from "@graphrefly/graphrefly-ts";
|
|
812
|
-
*
|
|
813
|
-
* const g = new Graph("app");
|
|
814
|
-
* g.add(state(0, { name: "counter" }));
|
|
815
|
-
* ```
|
|
816
|
-
*
|
|
817
|
-
* @category graph
|
|
818
|
-
*/
|
|
819
|
-
declare class Graph {
|
|
820
|
-
readonly name: string;
|
|
821
|
-
readonly opts: Readonly<GraphOptions>;
|
|
822
|
-
/** Protocol config bound to this graph (defaults to `defaultConfig`). */
|
|
823
|
-
readonly config: GraphReFlyConfig;
|
|
824
|
-
/** @internal — exposed for {@link teardownMountedGraph} and cross-graph helpers. */
|
|
825
|
-
readonly _nodes: Map<string, Node<unknown>>;
|
|
826
|
-
/**
|
|
827
|
-
* @internal Reverse lookup for duplicate-instance detection in
|
|
828
|
-
* {@link Graph.add} — O(1) replacement for an O(n) scan of `_nodes`.
|
|
829
|
-
* Weak so nodes can be GC'd after `remove()` even if a caller keeps the
|
|
830
|
-
* map alive via some unusual pattern.
|
|
831
|
-
*/
|
|
832
|
-
private readonly _nodeToName;
|
|
833
|
-
/** @internal — exposed for {@link teardownMountedGraph}. */
|
|
834
|
-
readonly _mounts: Map<string, Graph>;
|
|
835
|
-
/**
|
|
836
|
-
* @internal Parent graph if this instance is mounted. `undefined` when
|
|
837
|
-
* this is the root or when the graph has been unmounted. Used for
|
|
838
|
-
* reparenting rejection + O(depth) ancestor walks.
|
|
839
|
-
*/
|
|
840
|
-
_parent: Graph | undefined;
|
|
841
|
-
private readonly _storageDisposers;
|
|
842
|
-
private readonly _disposers;
|
|
843
|
-
/** @internal Set in {@link destroy} / `_destroyClearOnly`; surfaced via {@link destroyed}. */
|
|
844
|
-
private _destroyed;
|
|
845
|
-
/**
|
|
846
|
-
* @internal Lazy `TopologyEvent` producer. Created on first `.topology`
|
|
847
|
-
* access. Zero cost until something subscribes — producer fn only runs when
|
|
848
|
-
* the first sink attaches, registering one handler into
|
|
849
|
-
* {@link Graph._topologyEmitters}.
|
|
850
|
-
*/
|
|
851
|
-
private _topology;
|
|
852
|
-
/**
|
|
853
|
-
* @internal Active emit handlers for the topology producer. Each entry is
|
|
854
|
-
* the closure registered by the producer fn on activation; cleared on
|
|
855
|
-
* deactivation. `_emitTopology` broadcasts through every entry (there is at
|
|
856
|
-
* most one per activation cycle of the producer).
|
|
857
|
-
*/
|
|
858
|
-
private readonly _topologyEmitters;
|
|
859
|
-
/**
|
|
860
|
-
* @param name - Non-empty graph id (must not contain `::` and must not
|
|
861
|
-
* equal the reserved meta segment `__meta__`).
|
|
862
|
-
* @param opts - See {@link GraphOptions}. Stored frozen on the instance.
|
|
863
|
-
*/
|
|
864
|
-
/** Tier 1.5.3 Phase 2.5 — top-level factory tag for Graph-returning factories. */
|
|
865
|
-
private _factory?;
|
|
866
|
-
private _factoryArgs?;
|
|
867
|
-
constructor(name: string, opts?: GraphOptions);
|
|
868
|
-
/**
|
|
869
|
-
* Tag this graph with its constructing factory's identifier and args.
|
|
870
|
-
* Used by Graph-returning factories (`agentMemory`, `harnessLoop`,
|
|
871
|
-
* `pipelineGraph`, etc.) so `describe()` exposes provenance and
|
|
872
|
-
* `compileSpec` can delegate reconstruction to
|
|
873
|
-
* `catalog.graphFactories[factory]`. Tier 1.5.3 Phase 2.5 (DG1=B).
|
|
874
|
-
*
|
|
875
|
-
* `factoryArgs` should be JSON-serializable. For non-JSON fields
|
|
876
|
-
* (LLMAdapter, callbacks, etc.), use {@link placeholderArgs} to
|
|
877
|
-
* substitute descriptive strings (DG2=ii).
|
|
878
|
-
*
|
|
879
|
-
* Returns `this` for fluent chaining inside factory bodies.
|
|
880
|
-
*/
|
|
881
|
-
tagFactory(factory: string, factoryArgs?: unknown): this;
|
|
882
|
-
/**
|
|
883
|
-
* Walk ancestors up through `_parent`. Returns the chain starting at this
|
|
884
|
-
* instance, ending at the root (a graph with no parent). O(depth).
|
|
885
|
-
*
|
|
886
|
-
* @param includeSelf - Include `this` in the chain (default `true`).
|
|
887
|
-
*/
|
|
888
|
-
ancestors(includeSelf?: boolean): Graph[];
|
|
889
|
-
/**
|
|
890
|
-
* Reactive stream of structural changes to this graph's own registry
|
|
891
|
-
* (add / mount / remove). Value mutations live on `observe()`; this
|
|
892
|
-
* companion only fires when the topology shape changes.
|
|
893
|
-
*
|
|
894
|
-
* Lazy: the underlying node is created on first access and activates when
|
|
895
|
-
* something subscribes. No emission replay — late subscribers do not
|
|
896
|
-
* receive historical events and should snapshot via {@link Graph.describe}
|
|
897
|
-
* before listening for incremental changes. Events that fire while the
|
|
898
|
-
* producer has zero subscribers are dropped (no retention).
|
|
899
|
-
*
|
|
900
|
-
* Own-graph only: a parent's `topology` does NOT emit for structural
|
|
901
|
-
* changes inside a mounted child. Transitive consumers subscribe to each
|
|
902
|
-
* child's topology separately (recurse through `topology`'s own "added"
|
|
903
|
-
* events with `nodeKind: "mount"` to discover new children).
|
|
904
|
-
*
|
|
905
|
-
* See {@link TopologyEvent} for payload shape.
|
|
906
|
-
*
|
|
907
|
-
* @category observability
|
|
908
|
-
*/
|
|
909
|
-
get topology(): Node<TopologyEvent>;
|
|
910
|
-
/**
|
|
911
|
-
* @internal Fire a {@link TopologyEvent} to every active subscriber of
|
|
912
|
-
* `this.topology`. No-op when the topology node has never been accessed or
|
|
913
|
-
* currently has no sinks — zero cost for graphs nobody observes.
|
|
914
|
-
*/
|
|
915
|
-
private _emitTopology;
|
|
916
|
-
/**
|
|
917
|
-
* Registers a node under a local name. Fails if the name is already used,
|
|
918
|
-
* reserved by a mount, the same node instance is already registered, or
|
|
919
|
-
* the node is torn down.
|
|
920
|
-
*
|
|
921
|
-
* Returns the registered node so callers can chain:
|
|
922
|
-
* `const counter = g.add(state(0, { name: "counter" }))`.
|
|
923
|
-
*
|
|
924
|
-
* **Signature:** `add(node, { name?, annotation? })`. Name lives in opts;
|
|
925
|
-
* falls back to `node.name` from the node's own options. Throws if neither
|
|
926
|
-
* is a non-empty string.
|
|
927
|
-
*
|
|
928
|
-
* The optional `opts.annotation` installs an initial
|
|
929
|
-
* `graph.trace(name, annotation)` entry — same effect as calling
|
|
930
|
-
* `graph.trace` right after, but reads naturally next to the registration.
|
|
931
|
-
*
|
|
932
|
-
* @param node - Node instance to own.
|
|
933
|
-
* @param opts - `{ name?, annotation? }`.
|
|
934
|
-
*/
|
|
935
|
-
/**
|
|
936
|
-
* O(1) reverse lookup — returns the name the given Node was registered
|
|
937
|
-
* under via {@link Graph.add}, or `undefined` if it isn't registered here.
|
|
938
|
-
*
|
|
939
|
-
* Audit 2 (2026-04-24): replaces the orchestration's `findRegisteredNodePath`
|
|
940
|
-
* O(nodes²) describe-scan with direct `WeakMap<Node, string>` lookup.
|
|
941
|
-
*/
|
|
942
|
-
nameOf(node: Node): string | undefined;
|
|
943
|
-
add<T extends Node>(node: T, opts?: {
|
|
944
|
-
name?: string;
|
|
945
|
-
annotation?: string;
|
|
946
|
-
}): T;
|
|
947
|
-
/**
|
|
948
|
-
* Bulk-apply a minimum versioning level to every currently-registered node
|
|
949
|
-
* in this graph (roadmap §6.0). `_applyVersioning` is monotonic — nodes
|
|
950
|
-
* already at a higher level are untouched. The method refuses to run
|
|
951
|
-
* mid-wave; invoke at setup time before any external subscribers attach.
|
|
952
|
-
*
|
|
953
|
-
* **Not** a default-for-future-adds mechanism — that's what
|
|
954
|
-
* `config.defaultVersioning` is for. Nodes added after this call do NOT
|
|
955
|
-
* automatically inherit `level`; register new nodes with their own
|
|
956
|
-
* `opts.versioning` or set `config.defaultVersioning` before construction.
|
|
957
|
-
*
|
|
958
|
-
* **Scope:** local only. Does not propagate to mounted subgraphs.
|
|
959
|
-
*
|
|
960
|
-
* @param level - `0` for V0, `1` for V1, or `undefined` to no-op.
|
|
961
|
-
*/
|
|
962
|
-
setVersioning(level: VersioningLevel | undefined): void;
|
|
963
|
-
/**
|
|
964
|
-
* Unregisters a node or unmounts a subgraph and sends `[[TEARDOWN]]` to the
|
|
965
|
-
* removed node or recursively through the mounted subtree (§3.2).
|
|
966
|
-
*
|
|
967
|
-
* @param name - Local mount or node name.
|
|
968
|
-
* @returns Audit record of what was removed: `{kind, nodes, mounts}`.
|
|
969
|
-
* `kind: "node"` → `nodes: [name]`, `mounts: []`. `kind: "mount"` →
|
|
970
|
-
* `nodes` lists every primary node torn down across the subtree (sorted
|
|
971
|
-
* qualified paths relative to the unmounted subgraph) and `mounts` lists
|
|
972
|
-
* the mounted subgraphs in depth-first order including `name` itself.
|
|
973
|
-
*/
|
|
974
|
-
remove(name: string): GraphRemoveAudit;
|
|
975
|
-
/**
|
|
976
|
-
* Bulk remove — invokes {@link Graph.remove} for every local name matching
|
|
977
|
-
* `filter`. Audit records merge into a single result. Mounted subgraphs
|
|
978
|
-
* are included via `filter` receiving the mount name; internal subtree
|
|
979
|
-
* entries are not walked directly (use describe + scan for tree-level
|
|
980
|
-
* queries).
|
|
981
|
-
*
|
|
982
|
-
* @param filter - Predicate or glob. Glob strings support `*` within a
|
|
983
|
-
* segment and `**` across segments (same grammar as `restore({only})`).
|
|
984
|
-
* @returns Combined audit of all nodes + mounts removed.
|
|
985
|
-
*/
|
|
986
|
-
removeAll(filter: ((name: string) => boolean) | string): GraphRemoveAudit;
|
|
987
|
-
/**
|
|
988
|
-
* Iterable over locally-registered `[localName, Node]` pairs (sorted).
|
|
989
|
-
* Does not recurse into mounts.
|
|
990
|
-
*/
|
|
991
|
-
[Symbol.iterator](): IterableIterator<[string, Node]>;
|
|
992
|
-
/**
|
|
993
|
-
* Returns a node by local name or `::` qualified path.
|
|
994
|
-
* Local names are looked up directly; paths with `::` delegate to {@link resolve}.
|
|
995
|
-
*
|
|
996
|
-
* @param name - Local name or qualified path.
|
|
997
|
-
*/
|
|
998
|
-
node(name: string): Node;
|
|
999
|
-
/**
|
|
1000
|
-
* Reads `graph.node(name).get()` — accepts `::` qualified paths (§3.2).
|
|
1001
|
-
*
|
|
1002
|
-
* @param name - Local name or qualified path.
|
|
1003
|
-
* @returns Cached value or `undefined`.
|
|
1004
|
-
*/
|
|
1005
|
-
get(name: string): unknown;
|
|
1006
|
-
/**
|
|
1007
|
-
* Shorthand for `graph.node(name).down([[DATA, value]], { actor })` — accepts `::` qualified paths (§3.2).
|
|
1008
|
-
*
|
|
1009
|
-
* @param name - Local name or qualified path.
|
|
1010
|
-
* @param value - Next `DATA` payload.
|
|
1011
|
-
* @param options - Optional `actor` and `internal` guard bypass.
|
|
1012
|
-
*/
|
|
1013
|
-
set(name: string, value: unknown, options?: GraphActorOptions): void;
|
|
1014
|
-
/**
|
|
1015
|
-
* Atomic multi-node DATA write. Wraps every {@link Graph.set} call in a
|
|
1016
|
-
* single `batch(...)` so downstream dependents see one coalesced wave
|
|
1017
|
-
* instead of N cascading ones.
|
|
1018
|
-
*
|
|
1019
|
-
* @param entries - `{name → value}` map or `[name, value]` pairs.
|
|
1020
|
-
* @param options - Passed to each underlying `set` call (same `actor` + `internal` semantics).
|
|
1021
|
-
*/
|
|
1022
|
-
setAll(entries: Record<string, unknown> | Iterable<readonly [string, unknown]>, options?: GraphActorOptions): void;
|
|
1023
|
-
/**
|
|
1024
|
-
* Emit a single `[[INVALIDATE]]` (tier 1) on a node. Thin wrapper over
|
|
1025
|
-
* `node.down([[INVALIDATE]], …)` matching the {@link Graph.set} ergonomics.
|
|
1026
|
-
*/
|
|
1027
|
-
invalidate(name: string, options?: GraphActorOptions): void;
|
|
1028
|
-
/**
|
|
1029
|
-
* Emit a single `[[ERROR, err]]` (tier 4) on a node.
|
|
1030
|
-
*/
|
|
1031
|
-
error(name: string, err: unknown, options?: GraphActorOptions): void;
|
|
1032
|
-
/**
|
|
1033
|
-
* Emit a single `[[COMPLETE]]` (tier 4) on a node, declaring the stream
|
|
1034
|
-
* cleanly finished. Distinct from {@link Graph.remove} (which emits
|
|
1035
|
-
* TEARDOWN and unregisters the node).
|
|
1036
|
-
*/
|
|
1037
|
-
complete(name: string, options?: GraphActorOptions): void;
|
|
1038
|
-
/**
|
|
1039
|
-
* Returns the full edge list for this graph tree, derived on demand from
|
|
1040
|
-
* each registered node's `_deps` (no stored registry). Local-only
|
|
1041
|
-
* (non-recursive) by default to match the historical `edges()` surface;
|
|
1042
|
-
* pass `{recursive: true}` to include mounted subgraphs with qualified
|
|
1043
|
-
* paths relative to this graph.
|
|
1044
|
-
*
|
|
1045
|
-
* Use {@link Graph.describe} for full-tree snapshots with edges already
|
|
1046
|
-
* qualified and paired with node metadata.
|
|
1047
|
-
*/
|
|
1048
|
-
edges(opts?: {
|
|
1049
|
-
recursive?: boolean;
|
|
1050
|
-
}): ReadonlyArray<[string, string]>;
|
|
1051
|
-
/**
|
|
1052
|
-
* Embed a child graph at a local mount name (§3.4). Child nodes are reachable via
|
|
1053
|
-
* {@link Graph.resolve} using `::` delimited paths (§3.5). Lifecycle
|
|
1054
|
-
* {@link Graph.signal} visits mounted subgraphs recursively.
|
|
1055
|
-
*
|
|
1056
|
-
* Rejects: same name as existing node or mount, self-mount, mount cycles,
|
|
1057
|
-
* and the same child graph instance mounted twice on one parent.
|
|
1058
|
-
*
|
|
1059
|
-
* @param name - Local mount point.
|
|
1060
|
-
* @param child - Nested `Graph` instance.
|
|
1061
|
-
* @returns The mounted `child`, for chaining.
|
|
1062
|
-
*/
|
|
1063
|
-
mount<G extends Graph>(name: string, child: G): G;
|
|
1064
|
-
mount(name: string): Graph;
|
|
1065
|
-
mount(name: string, builder: (sub: Graph) => void): Graph;
|
|
1066
|
-
/**
|
|
1067
|
-
* Look up a node by qualified path (§3.5). Segments are separated by `::`.
|
|
1068
|
-
*
|
|
1069
|
-
* If the first segment equals this graph's {@link Graph.name}, it is stripped
|
|
1070
|
-
* (so `root.resolve("app::a")` works when `root.name === "app"`). The strip
|
|
1071
|
-
* is applied **recursively** when descending into mounted children, so
|
|
1072
|
-
* `child.resolve("child::x")` also works when `child.name === "child"`.
|
|
1073
|
-
*
|
|
1074
|
-
* @param path - Qualified `::` path or local name.
|
|
1075
|
-
* @returns The resolved `Node`.
|
|
1076
|
-
*/
|
|
1077
|
-
resolve(path: string): Node;
|
|
1078
|
-
/**
|
|
1079
|
-
* Non-throwing {@link Graph.resolve}. Returns `undefined` instead of
|
|
1080
|
-
* throwing when the path does not resolve to a node.
|
|
1081
|
-
*/
|
|
1082
|
-
tryResolve(path: string): Node | undefined;
|
|
1083
|
-
private _resolveFromSegments;
|
|
1084
|
-
/**
|
|
1085
|
-
* Resolve `::__meta__::key` segments from a registered primary node (possibly chained).
|
|
1086
|
-
*/
|
|
1087
|
-
private _resolveMetaChainFromNode;
|
|
1088
|
-
/**
|
|
1089
|
-
* Deliver a message batch to every registered node in this graph and, recursively,
|
|
1090
|
-
* in mounted child graphs (§3.7). Recurses into mounts first, then delivers to
|
|
1091
|
-
* local nodes (sorted by name). Each {@link Node} receives at most one delivery
|
|
1092
|
-
* per call (deduped by reference).
|
|
1093
|
-
*
|
|
1094
|
-
* **Primary-vs-meta filter asymmetry (intentional):** primary nodes receive the
|
|
1095
|
-
* unfiltered `messages` batch — that's the canonical data-plane flow. Companion
|
|
1096
|
-
* `meta` nodes receive a filtered subset keyed by the per-type `metaPassthrough`
|
|
1097
|
-
* flag on {@link GraphReFlyConfig}. Built-in defaults: PAUSE / RESUME / DATA /
|
|
1098
|
-
* RESOLVED pass through to meta; INVALIDATE / COMPLETE / ERROR / TEARDOWN do
|
|
1099
|
-
* not.
|
|
1100
|
-
*
|
|
1101
|
-
* **Where lifecycle terminals reach meta:**
|
|
1102
|
-
* - **TEARDOWN** — primary's `_emit` cascades to meta children directly (see
|
|
1103
|
-
* `core/node.ts` "Meta TEARDOWN fan-out" block) so meta is torn down with
|
|
1104
|
-
* its primary regardless of the signal-level filter.
|
|
1105
|
-
* - **COMPLETE / ERROR / INVALIDATE** — scoped to primaries on the broadcast
|
|
1106
|
-
* path. Meta companions are an attribution side-channel, not a lifecycle
|
|
1107
|
-
* participant; address meta directly via `meta.down(...)` if you need to
|
|
1108
|
-
* forward these. Audit confirmed 2026-04-17: no current meta consumer
|
|
1109
|
-
* relies on broadcast COMPLETE/ERROR/INVALIDATE delivery.
|
|
1110
|
-
*
|
|
1111
|
-
* @param messages - Batch to deliver to every registered node (and mounts, recursively).
|
|
1112
|
-
* @param options - Optional `actor` / `internal` for transport.
|
|
1113
|
-
*/
|
|
1114
|
-
signal(messages: Messages, options?: GraphActorOptions): void;
|
|
1115
|
-
private _signalDeliver;
|
|
1116
|
-
private _signalMetaSubtree;
|
|
1117
|
-
/**
|
|
1118
|
-
* Static structure snapshot: qualified node keys, edges, mount names (GRAPHREFLY-SPEC §3.6, Appendix B).
|
|
1119
|
-
*
|
|
1120
|
-
* Returns the {@link GraphDescribeOutput} object directly (or a
|
|
1121
|
-
* `ReactiveDescribeHandle` when `{ reactive: true | "diff" }` is set).
|
|
1122
|
-
*
|
|
1123
|
-
* For formatted output (Mermaid / D2 / ASCII / pretty / JSON text), pass
|
|
1124
|
-
* the snapshot to one of the pure renderers in
|
|
1125
|
-
* `@graphrefly/graphrefly/extra/render`:
|
|
1126
|
-
*
|
|
1127
|
-
* ```ts
|
|
1128
|
-
* import { toMermaid, toAscii } from "@graphrefly/graphrefly/extra/render";
|
|
1129
|
-
*
|
|
1130
|
-
* const mermaid = toMermaid(graph.describe());
|
|
1131
|
-
* const ascii = toAscii(graph.describe(), { direction: "TD" });
|
|
1132
|
-
* ```
|
|
1133
|
-
*
|
|
1134
|
-
* For live formatted output, compose with `derived`:
|
|
1135
|
-
*
|
|
1136
|
-
* ```ts
|
|
1137
|
-
* import { derived } from "@graphrefly/graphrefly";
|
|
1138
|
-
* import { toMermaid } from "@graphrefly/graphrefly/extra/render";
|
|
1139
|
-
*
|
|
1140
|
-
* const live = derived(
|
|
1141
|
-
* [graph.describe({ reactive: true }).node],
|
|
1142
|
-
* ([g]) => toMermaid(g),
|
|
1143
|
-
* );
|
|
1144
|
-
* ```
|
|
1145
|
-
*
|
|
1146
|
-
* For the spec projection (type + deps + meta, strip runtime status/value),
|
|
1147
|
-
* pass `detail: "spec"`.
|
|
1148
|
-
*
|
|
1149
|
-
* @param options - Optional `actor` for guard-scoped visibility, `filter`
|
|
1150
|
-
* for selective output, `detail` / `fields` for projection, `reactive`
|
|
1151
|
-
* for the live handle.
|
|
1152
|
-
*
|
|
1153
|
-
* @example
|
|
1154
|
-
* ```ts
|
|
1155
|
-
* graph.describe() // full snapshot object
|
|
1156
|
-
* graph.describe({ filter: { status: "errored" } }) // filtered object
|
|
1157
|
-
* graph.describe({ detail: "spec" }) // GraphSpec projection
|
|
1158
|
-
* graph.describe({ reactive: true }) // live snapshot Node
|
|
1159
|
-
* ```
|
|
1160
|
-
*/
|
|
1161
|
-
describe(options: GraphDescribeOptions & {
|
|
1162
|
-
reactive: "diff";
|
|
1163
|
-
}): ReactiveDescribeHandle<DescribeChangeset>;
|
|
1164
|
-
describe(options: GraphDescribeOptions & {
|
|
1165
|
-
reactive: true;
|
|
1166
|
-
}): ReactiveDescribeHandle<GraphDescribeOutput>;
|
|
1167
|
-
describe(options?: GraphDescribeOptions): GraphDescribeOutput;
|
|
1168
|
-
private _collectSubgraphs;
|
|
1169
|
-
/**
|
|
1170
|
-
* Snapshot-based resource profile: per-node stats, orphan effect detection,
|
|
1171
|
-
* memory hotspots. Zero runtime overhead — walks nodes on demand.
|
|
1172
|
-
*
|
|
1173
|
-
* @param opts - Optional `topN` for hotspot limit (default 10).
|
|
1174
|
-
* @returns Aggregate profile with per-node details, hotspots, and orphan effects.
|
|
1175
|
-
*/
|
|
1176
|
-
resourceProfile(opts?: GraphProfileOptions): GraphProfileResult;
|
|
1177
|
-
/**
|
|
1178
|
-
* Reachability query rooted at `from`. Instance convenience — wraps
|
|
1179
|
-
* `reachable(this.describe(), from, direction, opts)`. See
|
|
1180
|
-
* {@link reachable} for semantics.
|
|
1181
|
-
*/
|
|
1182
|
-
reachable(from: string, direction: ReachableDirection, opts: ReachableOptions & {
|
|
1183
|
-
withDetail: true;
|
|
1184
|
-
}): ReachableResult;
|
|
1185
|
-
reachable(from: string, direction: ReachableDirection, opts?: ReachableOptions): string[];
|
|
1186
|
-
/**
|
|
1187
|
-
* Causal walkback: shortest dep-chain from `from` to `to`, enriched with
|
|
1188
|
-
* each node's value, status, last-mutation actor, and reasoning annotation
|
|
1189
|
-
* from {@link Graph.trace}. Wraps {@link explainPath} (roadmap §9.2).
|
|
1190
|
-
*
|
|
1191
|
-
* Same question, two answers:
|
|
1192
|
-
* - **Static (default)** — `explain(from, to, opts?)` returns a single
|
|
1193
|
-
* {@link CausalChain} snapshot of the graph at call time. Reactive
|
|
1194
|
-
* args (any `Node<...>`) are resolved to their current cache once.
|
|
1195
|
-
* - **Reactive** — `explain(from, to, { reactive: true, ... })` returns
|
|
1196
|
-
* `{ node: Node<CausalChain>; dispose: () => void }`. The node
|
|
1197
|
-
* recomputes whenever a `data` / `error` / `complete` / `teardown`
|
|
1198
|
-
* event fires anywhere on the graph's structured observe stream OR
|
|
1199
|
-
* any reactive arg (`Node<string>` for `from`/`to`,
|
|
1200
|
-
* `Node<number>` for `maxDepth`, `Node<boolean>` for `findCycle`)
|
|
1201
|
-
* emits. Replaces the former `reactiveExplainPath`.
|
|
1202
|
-
*
|
|
1203
|
-
* Tier 3.5 reactive-opt carve-out (F.9): `from`, `to`, `maxDepth`, and
|
|
1204
|
-
* `findCycle` accept `Node<...>` in addition to their plain types. When
|
|
1205
|
-
* mixed (some reactive, some static), the reactive variant subscribes only
|
|
1206
|
-
* to the Node-typed args; static args pass through unchanged. The static
|
|
1207
|
-
* call snapshots all reactive args at call time — for live re-walking, use
|
|
1208
|
-
* `{ reactive: true }`.
|
|
1209
|
-
*
|
|
1210
|
-
* **File path-scoped observe is deferred** — the reactive variant
|
|
1211
|
-
* subscribes to whole-graph observe today (a perf gap, not a spec
|
|
1212
|
-
* violation). Tracked in `docs/optimizations.md` Tier 10.8 deferred
|
|
1213
|
-
* follow-up: "reactiveExplainPath file-path-scoped observe".
|
|
1214
|
-
*
|
|
1215
|
-
* @param from - Upstream node path (the cause). `string | Node<string>`.
|
|
1216
|
-
* @param to - Downstream node path (the effect). `string | Node<string>`.
|
|
1217
|
-
* @param opts - Optional `maxDepth` (`number | Node<number>`) and
|
|
1218
|
-
* `findCycle` (`boolean | Node<boolean>`). When `findCycle:true`
|
|
1219
|
-
* and `from === to`, returns the shortest cycle through other nodes
|
|
1220
|
-
* (useful for diagnosing feedback loops, COMPOSITION-GUIDE §7).
|
|
1221
|
-
* When `reactive: true`, also accepts `name?`.
|
|
1222
|
-
*/
|
|
1223
|
-
explain(from: string | Node<string>, to: string | Node<string>, opts?: {
|
|
1224
|
-
maxDepth?: number | Node<number>;
|
|
1225
|
-
findCycle?: boolean | Node<boolean>;
|
|
1226
|
-
}): CausalChain;
|
|
1227
|
-
explain(from: string | Node<string>, to: string | Node<string>, opts: {
|
|
1228
|
-
reactive: true;
|
|
1229
|
-
maxDepth?: number | Node<number>;
|
|
1230
|
-
findCycle?: boolean | Node<boolean>;
|
|
1231
|
-
name?: string;
|
|
1232
|
-
}): {
|
|
1233
|
-
node: Node<CausalChain>;
|
|
1234
|
-
dispose: () => void;
|
|
1235
|
-
};
|
|
1236
|
-
private _explainStatic;
|
|
1237
|
-
private _describeReactive;
|
|
1238
|
-
/**
|
|
1239
|
-
* Reactive topology-diff variant of `describe()`. Wraps `_describeReactive`'s
|
|
1240
|
-
* snapshot stream and emits a `DescribeChangeset` per change, suppressing
|
|
1241
|
-
* empty changesets. The initial cache is a synthetic full-add diff so a
|
|
1242
|
-
* fresh subscriber sees the current topology as a single `node-added` /
|
|
1243
|
-
* `edge-added` / `subgraph-mounted` payload via push-on-subscribe.
|
|
1244
|
-
*/
|
|
1245
|
-
private _describeReactiveDiff;
|
|
1246
|
-
private _explainReactive;
|
|
1247
|
-
/**
|
|
1248
|
-
* @internal Collect all qualified paths in this graph tree matching a
|
|
1249
|
-
* glob pattern. Used by scoped autoCheckpoint subscription.
|
|
1250
|
-
*/
|
|
1251
|
-
private _pathsMatching;
|
|
1252
|
-
private _collectObserveTargets;
|
|
1253
|
-
private _appendMetaObserveTargets;
|
|
1254
|
-
/**
|
|
1255
|
-
* Live message stream from one node (or meta path), or from the whole graph (§3.6).
|
|
1256
|
-
*
|
|
1257
|
-
* Two modes dispatched on first argument:
|
|
1258
|
-
* - `observe(path, options?)` — one node. Returns {@link GraphObserveOne}
|
|
1259
|
-
* (raw stream), or {@link ObserveResult} when `options` requests structured
|
|
1260
|
-
* accumulation (`structured`, `timeline`, `causal`, `derived`, `format`,
|
|
1261
|
-
* `detail: "minimal"|"full"`).
|
|
1262
|
-
* - `observe(options?)` — all nodes. Returns {@link GraphObserveAll} (raw),
|
|
1263
|
-
* or {@link ObserveResult} under the same structured trigger conditions.
|
|
1264
|
-
*
|
|
1265
|
-
* Structured mode subscribes in sorted path order (code-point). Inspector
|
|
1266
|
-
* extras (`causal`/`derived`) require `graph.config.inspectorEnabled`;
|
|
1267
|
-
* when disabled, those fields silently drop and the rest still works.
|
|
1268
|
-
*
|
|
1269
|
-
* `ObserveResult` is also an `AsyncIterable<ObserveEvent>` — use
|
|
1270
|
-
* `for await (const ev of result)` for pull-based consumption.
|
|
1271
|
-
*/
|
|
1272
|
-
observe(path: string, options: ObserveOptions & {
|
|
1273
|
-
reactive: true;
|
|
1274
|
-
}): Node<ObserveChangeset>;
|
|
1275
|
-
observe(options: ObserveOptions & {
|
|
1276
|
-
reactive: true;
|
|
1277
|
-
}): Node<ObserveChangeset>;
|
|
1278
|
-
observe(path: string, options?: ObserveOptions & StructuredTriggers): ObserveResult;
|
|
1279
|
-
observe(path: string, options?: ObserveOptions): GraphObserveOne;
|
|
1280
|
-
observe(options: ObserveOptions & StructuredTriggers): ObserveResult;
|
|
1281
|
-
observe(options?: ObserveOptions): GraphObserveAll;
|
|
1282
|
-
/**
|
|
1283
|
-
* Reactive observe variant — wraps the structured observer and emits one
|
|
1284
|
-
* `ObserveChangeset` DATA per outermost batch flush, with all observed
|
|
1285
|
-
* events for that flush coalesced into a single envelope. Tier filter
|
|
1286
|
-
* (`options.tiers`) drops out-of-scope events before accumulation.
|
|
1287
|
-
*
|
|
1288
|
-
* Cleanup is producer-bound: the structured observer is torn down when the
|
|
1289
|
-
* last consumer of the returned node unsubscribes.
|
|
1290
|
-
*/
|
|
1291
|
-
private _observeReactive;
|
|
1292
|
-
/** Dispatch helper — builds a unified observer + its expand closure. */
|
|
1293
|
-
private _buildStructuredObserver;
|
|
1294
|
-
/**
|
|
1295
|
-
* Unified observer builder — replaces the four ex-creators
|
|
1296
|
-
* (`_createObserveResult` / `...ForAll` / `_createFallback…`). Accepts a
|
|
1297
|
-
* list of `[path, node]` targets (single-element for one-node observe,
|
|
1298
|
-
* N-element for all-nodes). Inspector hooks attach per-target when
|
|
1299
|
-
* `causal`/`derived` requested AND `config.inspectorEnabled`; otherwise
|
|
1300
|
-
* those fields gracefully drop.
|
|
1301
|
-
*
|
|
1302
|
-
* Events flow through a `recordEvent()` helper so the format logger,
|
|
1303
|
-
* ring-buffer, and async-iterable hooks all share one push path.
|
|
1304
|
-
*/
|
|
1305
|
-
private _createObserveResult;
|
|
1306
|
-
/**
|
|
1307
|
-
* Attach format-rendering logger to an ObserveResult by subscribing to its
|
|
1308
|
-
* event stream (no monkey-patching). Renders each event per `format` and
|
|
1309
|
-
* `theme`, filtered by `includeTypes` / `excludeTypes`.
|
|
1310
|
-
*/
|
|
1311
|
-
private _attachFormatLogger;
|
|
1312
|
-
/**
|
|
1313
|
-
* Register a cleanup function to be called on {@link Graph.destroy}.
|
|
1314
|
-
*
|
|
1315
|
-
* Factories use this to attach teardown logic for internal nodes, keepalive
|
|
1316
|
-
* subscriptions, or other resources that are not registered on the graph and
|
|
1317
|
-
* would otherwise leak on repeated create/destroy cycles.
|
|
1318
|
-
*
|
|
1319
|
-
* Returns a removal function — call it to unregister the disposer early.
|
|
1320
|
-
*/
|
|
1321
|
-
addDisposer(fn: () => void): () => void;
|
|
1322
|
-
/**
|
|
1323
|
-
* Drains disposers (registered via {@link addDisposer}), then sends `[[TEARDOWN]]` to all
|
|
1324
|
-
* nodes and clears registries on this graph and every mounted subgraph (§3.7).
|
|
1325
|
-
* The instance is left empty and may be reused with {@link Graph.add}.
|
|
1326
|
-
*/
|
|
1327
|
-
destroy(): void;
|
|
1328
|
-
/**
|
|
1329
|
-
* `true` once {@link destroy} has run on this graph. Useful for reactive
|
|
1330
|
-
* consumers that hold a Graph reference and want to fail fast / skip
|
|
1331
|
-
* work if the graph went away mid-flight (e.g. a `switchMap` over a
|
|
1332
|
-
* destroyable graph reference). Set after the destroy cascade completes;
|
|
1333
|
-
* stays `true` even if the instance is later reused via {@link add}.
|
|
1334
|
-
*/
|
|
1335
|
-
get destroyed(): boolean;
|
|
1336
|
-
/** Clear structure after parent already signaled TEARDOWN through this subtree. */
|
|
1337
|
-
private _destroyClearOnly;
|
|
1338
|
-
/**
|
|
1339
|
-
* Serializes structure and current values to JSON-shaped data (§3.8). Same
|
|
1340
|
-
* information as {@link Graph.describe} plus a `version` field for format
|
|
1341
|
-
* evolution.
|
|
1342
|
-
*
|
|
1343
|
-
* The overload path supports three outputs:
|
|
1344
|
-
* - no arg → `GraphPersistSnapshot` (plain JS object).
|
|
1345
|
-
* - `{format: "json-string"}` → deterministic JSON `string`
|
|
1346
|
-
* (key-sorted; safe for hashing or file write).
|
|
1347
|
-
* - `{format: "bytes", codec: name}` → `Uint8Array` wrapped in the v1
|
|
1348
|
-
* envelope from {@link encodeEnvelope}. The codec must be registered
|
|
1349
|
-
* on this graph's {@link GraphReFlyConfig} via `config.registerCodec`.
|
|
1350
|
-
* Paired with {@link Graph.decode} for auto-dispatch on the read side.
|
|
1351
|
-
*/
|
|
1352
|
-
snapshot(): GraphPersistSnapshot;
|
|
1353
|
-
snapshot(opts: {
|
|
1354
|
-
format: "json-string";
|
|
1355
|
-
}): string;
|
|
1356
|
-
snapshot(opts: {
|
|
1357
|
-
format: "bytes";
|
|
1358
|
-
codec: string;
|
|
1359
|
-
}): Uint8Array;
|
|
1360
|
-
/**
|
|
1361
|
-
* Auto-dispatch a byte buffer produced by {@link Graph.snapshot} with
|
|
1362
|
-
* `{format: "bytes", codec: name}`. Reads the v1 envelope, resolves the
|
|
1363
|
-
* named codec on `config` (defaults to `defaultConfig`), and returns the
|
|
1364
|
-
* decoded snapshot. Combine with {@link Graph.fromSnapshot} to rehydrate
|
|
1365
|
-
* a full graph topology from bytes.
|
|
1366
|
-
*
|
|
1367
|
-
* @throws If the envelope is malformed or the named codec isn't
|
|
1368
|
-
* registered on the target config.
|
|
1369
|
-
*/
|
|
1370
|
-
static decode(bytes: Uint8Array, opts?: {
|
|
1371
|
-
config?: GraphReFlyConfig;
|
|
1372
|
-
}): GraphPersistSnapshot;
|
|
1373
|
-
/**
|
|
1374
|
-
* Apply persisted values onto an existing graph whose topology matches the snapshot
|
|
1375
|
-
* (§3.8). Only {@link DescribeNodeOutput.type} `state` entries with a `value` field
|
|
1376
|
-
* are written by default; `derived` / `operator` / `effect` are always skipped so
|
|
1377
|
-
* deps drive recomputation. `producer` entries are skipped unless `includeProducers`
|
|
1378
|
-
* is set (producers recompute on activation, so restoring is usually a no-op
|
|
1379
|
-
* overwritten on the next wave — opt in for audit / forensic round-trip use cases).
|
|
1380
|
-
* Unknown paths are ignored.
|
|
1381
|
-
*
|
|
1382
|
-
* @param data - Snapshot envelope with matching `name` and node slices.
|
|
1383
|
-
* @throws If `data.name` does not equal {@link Graph.name}.
|
|
1384
|
-
*/
|
|
1385
|
-
restore(data: GraphPersistSnapshot, options?: {
|
|
1386
|
-
only?: string | readonly string[];
|
|
1387
|
-
/**
|
|
1388
|
-
* Fires per failing write. Default behavior (omitted) is silent —
|
|
1389
|
-
* missing paths and guard denials are swallowed to match the
|
|
1390
|
-
* historical semantics. Provide a callback to surface failures
|
|
1391
|
-
* without aborting the remaining restores.
|
|
1392
|
-
*/
|
|
1393
|
-
onError?: (path: string, err: unknown) => void;
|
|
1394
|
-
/**
|
|
1395
|
-
* Restore `producer` node values alongside `state`. Default `false`:
|
|
1396
|
-
* producers are reactive sources whose value recomputes on
|
|
1397
|
-
* activation, so restoring from a snapshot is usually a no-op
|
|
1398
|
-
* overwritten on the next wave. Audit / forensic round-trip use
|
|
1399
|
-
* cases that need the stored value to survive restoration can
|
|
1400
|
-
* opt in. Does not change `derived` / `effect` handling — those
|
|
1401
|
-
* are always skipped.
|
|
1402
|
-
*/
|
|
1403
|
-
includeProducers?: boolean;
|
|
1404
|
-
}): void;
|
|
1405
|
-
/**
|
|
1406
|
-
* Creates a graph named from the snapshot, optionally runs `build` to register nodes
|
|
1407
|
-
* and mounts, then {@link Graph.restore} values (§3.8).
|
|
1408
|
-
*
|
|
1409
|
-
* @param data - Snapshot envelope (`version` checked).
|
|
1410
|
-
* @param opts - Either a legacy `build(g)` callback, or an options object:
|
|
1411
|
-
* - `build?` — topology constructor; skips auto-hydration when present.
|
|
1412
|
-
* - `factories?` — map from glob pattern to {@link GraphNodeFactory},
|
|
1413
|
-
* used by auto-hydration to reconstruct non-state nodes. Per-call (no
|
|
1414
|
-
* process-global registry). First matching pattern wins.
|
|
1415
|
-
* @returns Hydrated `Graph` instance.
|
|
1416
|
-
*/
|
|
1417
|
-
static fromSnapshot(data: GraphPersistSnapshot, opts?: ((g: Graph) => void) | {
|
|
1418
|
-
build?: (g: Graph) => void;
|
|
1419
|
-
factories?: Record<string, GraphNodeFactory>;
|
|
1420
|
-
}): Graph;
|
|
1421
|
-
/**
|
|
1422
|
-
* ECMAScript `JSON.stringify` hook — returns the same object as
|
|
1423
|
-
* {@link Graph.snapshot}. Makes `JSON.stringify(graph)` "just work"
|
|
1424
|
-
* without double-encoding.
|
|
1425
|
-
*/
|
|
1426
|
-
toJSON(): GraphPersistSnapshot;
|
|
1427
|
-
/**
|
|
1428
|
-
* Unified persistence surface (§3.8). Cascades snapshot records through
|
|
1429
|
-
* one or more {@link SnapshotStorageTier}s, each with its own `debounceMs` /
|
|
1430
|
-
* `compactEvery` cadence and independent diff baseline.
|
|
1431
|
-
*
|
|
1432
|
-
* Subscription gates on {@link messageTier} ≥ 3 (DATA/RESOLVED/terminal),
|
|
1433
|
-
* never on tier-0/1/2 control waves (START/DIRTY/INVALIDATE/PAUSE/RESUME)
|
|
1434
|
-
* or tier-5 TEARDOWN (graceful shutdown is the caller's responsibility).
|
|
1435
|
-
*
|
|
1436
|
-
* Per-tier cadence lets the hot tier stay sync while cold tiers absorb
|
|
1437
|
-
* async writes without blocking the hot path. Each tier holds its own
|
|
1438
|
-
* `{lastSnapshot, lastVersionFingerprint}` so cold-tier diff baselines
|
|
1439
|
-
* aren't polluted by hot-tier flushes. Tiers with `debounceMs === 0`
|
|
1440
|
-
* share a single snapshot computation per observe event; debounced tiers
|
|
1441
|
-
* compute their own snapshot when their timer fires.
|
|
1442
|
-
*/
|
|
1443
|
-
attachSnapshotStorage(tiers: readonly SnapshotStorageTier<GraphCheckpointRecord>[], options?: GraphAttachStorageOptions): StorageHandle;
|
|
1444
|
-
/**
|
|
1445
|
-
* Try tiers in order (hottest first); apply the first record that hits
|
|
1446
|
-
* via {@link Graph.restore}. Returns `true` if any tier produced a
|
|
1447
|
-
* restorable snapshot, `false` if all missed.
|
|
1448
|
-
*
|
|
1449
|
-
* Resilience: a tier that returns data which cannot be restored (load
|
|
1450
|
-
* throws, shape unrecognized, or `restore()` itself throws) does not abort
|
|
1451
|
-
* the cascade — the error is routed through `onError` (if supplied) and
|
|
1452
|
-
* the next colder tier is tried. This mirrors how a multi-tier cache
|
|
1453
|
-
* falls through on a corrupt hot entry.
|
|
1454
|
-
*
|
|
1455
|
-
* Note: `restore()` mutates state incrementally. If a restore throws
|
|
1456
|
-
* partway through, the graph may hold a mixed state (some slices from
|
|
1457
|
-
* the bad tier, some pre-existing). A subsequent successful tier's
|
|
1458
|
-
* `restore()` overwrites the overlapping slices.
|
|
1459
|
-
*
|
|
1460
|
-
* Internal helper shared by {@link Graph.attachSnapshotStorage}'s `autoRestore`
|
|
1461
|
-
* option and the static {@link Graph.fromStorage} factory.
|
|
1462
|
-
*/
|
|
1463
|
-
private _cascadeRestore;
|
|
1464
|
-
/**
|
|
1465
|
-
* Construct a fresh {@link Graph} pre-hydrated from the first tier that
|
|
1466
|
-
* hits. Delegates topology reconstruction to {@link Graph.fromSnapshot}
|
|
1467
|
-
* on `"full"` records and direct {@link Graph.restore} on bare snapshots.
|
|
1468
|
-
*
|
|
1469
|
-
* Always asynchronous — awaits `tier.load()` for async tier support even
|
|
1470
|
-
* when all tiers are sync. Callers that know they only pass sync tiers
|
|
1471
|
-
* can safely `await` immediately.
|
|
1472
|
-
*
|
|
1473
|
-
* @throws If no tier holds a restorable record matching `name` *and* no
|
|
1474
|
-
* `factories` override is provided for dynamic nodes.
|
|
1475
|
-
*/
|
|
1476
|
-
static fromStorage(name: string, tiers: readonly SnapshotStorageTier<GraphCheckpointRecord>[], opts?: GraphOptions & {
|
|
1477
|
-
factories?: Record<string, GraphNodeFactory>;
|
|
1478
|
-
/**
|
|
1479
|
-
* Called when a tier throws during `load()` or when
|
|
1480
|
-
* {@link Graph.fromSnapshot} rejects a tier's record. The cascade
|
|
1481
|
-
* falls through to the next colder tier regardless.
|
|
1482
|
-
*/
|
|
1483
|
-
onError?: (err: unknown, tier: SnapshotStorageTier<GraphCheckpointRecord>) => void;
|
|
1484
|
-
}): Promise<Graph>;
|
|
1485
|
-
private _annotations;
|
|
1486
|
-
private readonly _traceRing;
|
|
1487
|
-
/**
|
|
1488
|
-
* Unified reasoning trace: write annotations or read the ring buffer.
|
|
1489
|
-
*
|
|
1490
|
-
* - `graph.trace("path", "annotation")` — attaches a reasoning annotation
|
|
1491
|
-
* to a node, capturing *why* an AI agent set a value. Overwrites the
|
|
1492
|
-
* current annotation (if any) and appends to the chronological ring.
|
|
1493
|
-
* Unknown paths are silently dropped (matching `observe` resilience).
|
|
1494
|
-
* No-op when `config.inspectorEnabled` is `false`.
|
|
1495
|
-
* - `graph.trace("path")` — returns the current annotation for `path`,
|
|
1496
|
-
* or `undefined` if none. Precedence: most recent `trace(path, ...)`
|
|
1497
|
-
* wins; if no trace call, whatever `graph.add(node, { name: "path", annotation })`
|
|
1498
|
-
* installed; otherwise `undefined`.
|
|
1499
|
-
* - `graph.trace()` — returns a chronological log of all write entries.
|
|
1500
|
-
* Returns `[]` when `config.inspectorEnabled` is `false`.
|
|
1501
|
-
*/
|
|
1502
|
-
trace(path: string, annotation: string, opts?: {
|
|
1503
|
-
actor?: Actor;
|
|
1504
|
-
}): void;
|
|
1505
|
-
trace(path: string): string | undefined;
|
|
1506
|
-
trace(): readonly TraceEntry[];
|
|
1507
|
-
/**
|
|
1508
|
-
* Latest annotation attached to `path` — via {@link Graph.trace} or via
|
|
1509
|
-
* {@link Graph.add}'s `{annotation}` option. Returns `undefined` if none.
|
|
1510
|
-
* `describe()` surfaces this via the `annotation` field on each node entry
|
|
1511
|
-
* (when present). Equivalent to `graph.trace(path)`.
|
|
1512
|
-
*/
|
|
1513
|
-
annotation(path: string): string | undefined;
|
|
1514
|
-
/**
|
|
1515
|
-
* Clear all reasoning-trace state (both the per-path annotations map and
|
|
1516
|
-
* the ring buffer). Useful for long-running processes that want periodic
|
|
1517
|
-
* resets, or tests that need a clean slate.
|
|
1518
|
-
*/
|
|
1519
|
-
clearTrace(): void;
|
|
1520
|
-
/**
|
|
1521
|
-
* Remove trace entries matching `predicate`. Returns the number of
|
|
1522
|
-
* entries removed. Does not touch the per-path annotations map — call
|
|
1523
|
-
* {@link Graph.clearTrace} for a full reset.
|
|
1524
|
-
*/
|
|
1525
|
-
pruneTrace(predicate: (entry: TraceEntry) => boolean): number;
|
|
1526
|
-
/**
|
|
1527
|
-
* Computes structural + value diff between two {@link Graph.describe} snapshots.
|
|
1528
|
-
*
|
|
1529
|
-
* @param a - Earlier describe output.
|
|
1530
|
-
* @param b - Later describe output.
|
|
1531
|
-
* @returns Added/removed nodes, changed fields, and edge deltas.
|
|
1532
|
-
*/
|
|
1533
|
-
static diff(a: GraphDescribeOutput, b: GraphDescribeOutput): GraphDiffResult;
|
|
1534
|
-
}
|
|
1535
|
-
/** Entry in the reasoning trace ring buffer (roadmap 3.3). */
|
|
1536
|
-
type TraceEntry = {
|
|
1537
|
-
path: string;
|
|
1538
|
-
annotation: string;
|
|
1539
|
-
timestamp_ns: number;
|
|
1540
|
-
/**
|
|
1541
|
-
* Actor that produced the annotation (optional). Enables multi-agent
|
|
1542
|
-
* attribution: distinguish "LLM set this rootCause" from "human approved
|
|
1543
|
-
* this intervention" in the trace log.
|
|
1544
|
-
*/
|
|
1545
|
-
actor?: Actor;
|
|
1546
|
-
};
|
|
1547
|
-
/** Result of {@link Graph.diff}. */
|
|
1548
|
-
type GraphDiffResult = {
|
|
1549
|
-
nodesAdded: string[];
|
|
1550
|
-
nodesRemoved: string[];
|
|
1551
|
-
nodesChanged: GraphDiffChange[];
|
|
1552
|
-
/**
|
|
1553
|
-
* V0 version bumps (same `v.id`, different `v.version`). Surfaced even
|
|
1554
|
-
* when values are identical — the bump itself is audit-meaningful.
|
|
1555
|
-
*/
|
|
1556
|
-
versionChanges: GraphVersionChange[];
|
|
1557
|
-
edgesAdded: Array<{
|
|
1558
|
-
from: string;
|
|
1559
|
-
to: string;
|
|
1560
|
-
}>;
|
|
1561
|
-
edgesRemoved: Array<{
|
|
1562
|
-
from: string;
|
|
1563
|
-
to: string;
|
|
1564
|
-
}>;
|
|
1565
|
-
subgraphsAdded: string[];
|
|
1566
|
-
subgraphsRemoved: string[];
|
|
1567
|
-
};
|
|
1568
|
-
/**
|
|
1569
|
-
* WAL-oriented diff — extends {@link GraphDiffResult} with the full node
|
|
1570
|
-
* slice for each added path so {@link replayWAL} can reconstruct nodes added
|
|
1571
|
-
* between full anchors (topology mutations inside a `compactEvery` window).
|
|
1572
|
-
*
|
|
1573
|
-
* `Graph.diff()` returns the audit shape (no payload); `attachSnapshotStorage` writes
|
|
1574
|
-
* this WAL shape. The two shapes stay structurally compatible — `GraphWALDiff`
|
|
1575
|
-
* is a superset.
|
|
1576
|
-
*/
|
|
1577
|
-
type GraphWALDiff = GraphDiffResult & {
|
|
1578
|
-
/**
|
|
1579
|
-
* Full node slices for every path in `nodesAdded`, keyed by path. Applied
|
|
1580
|
-
* verbatim to `snapshot.nodes[path]` during replay.
|
|
1581
|
-
*/
|
|
1582
|
-
nodesAddedFull: Record<string, DescribeNodeOutput>;
|
|
1583
|
-
};
|
|
1584
|
-
/**
|
|
1585
|
-
* Build a WAL-ready diff between two snapshots: the structural diff from
|
|
1586
|
-
* {@link Graph.diff} plus the full node slice for each added path (pulled
|
|
1587
|
-
* from `b.nodes`). Callers that only need the audit shape should use
|
|
1588
|
-
* `Graph.diff` directly.
|
|
1589
|
-
*/
|
|
1590
|
-
declare function diffForWAL(a: GraphDescribeOutput, b: GraphDescribeOutput): GraphWALDiff;
|
|
1591
|
-
/** A single field change within a diff. */
|
|
1592
|
-
type GraphDiffChange = {
|
|
1593
|
-
path: string;
|
|
1594
|
-
field: string;
|
|
1595
|
-
from: unknown;
|
|
1596
|
-
to: unknown;
|
|
1597
|
-
};
|
|
1598
|
-
/** A single V0 version bump within a diff. */
|
|
1599
|
-
type GraphVersionChange = {
|
|
1600
|
-
path: string;
|
|
1601
|
-
id: string;
|
|
1602
|
-
from: number;
|
|
1603
|
-
to: number;
|
|
1604
|
-
};
|
|
1605
|
-
/** Audit record returned by {@link Graph.remove}. */
|
|
1606
|
-
type GraphRemoveAudit = {
|
|
1607
|
-
/** Whether the removed entry was a local node or a mount. */
|
|
1608
|
-
kind: "node" | "mount";
|
|
1609
|
-
/**
|
|
1610
|
-
* Primary nodes torn down by this `remove()`. For `kind: "node"` contains
|
|
1611
|
-
* just the removed name; for `kind: "mount"` lists every primary node in
|
|
1612
|
-
* the unmounted subtree (qualified paths relative to the mount point,
|
|
1613
|
-
* sorted).
|
|
1614
|
-
*/
|
|
1615
|
-
nodes: string[];
|
|
1616
|
-
/**
|
|
1617
|
-
* Mounted subgraphs that were unmounted. For `kind: "node"` this is empty;
|
|
1618
|
-
* for `kind: "mount"` starts with the top-level mount name and lists its
|
|
1619
|
-
* descendants in depth-first order.
|
|
1620
|
-
*/
|
|
1621
|
-
mounts: string[];
|
|
1622
|
-
};
|
|
1623
|
-
/** Direction for {@link reachable} graph traversal. */
|
|
1624
|
-
type ReachableDirection = "upstream" | "downstream";
|
|
1625
|
-
/** Options for {@link reachable}. */
|
|
1626
|
-
type ReachableOptions = {
|
|
1627
|
-
/** Maximum hop depth from `from` (0 returns `[]`). Omit for unbounded traversal. */
|
|
1628
|
-
maxDepth?: number;
|
|
1629
|
-
/**
|
|
1630
|
-
* Traverse both directions in one pass (union of upstream + downstream).
|
|
1631
|
-
* Ignores the `direction` arg when set.
|
|
1632
|
-
*/
|
|
1633
|
-
both?: boolean;
|
|
1634
|
-
/**
|
|
1635
|
-
* Return the richer {@link ReachableResult} shape (paths + per-path
|
|
1636
|
-
* hop depth + truncation flag) instead of the flat sorted string array.
|
|
1637
|
-
*/
|
|
1638
|
-
withDetail?: boolean;
|
|
1639
|
-
};
|
|
1640
|
-
/** Rich reachable result (opt-in via `{withDetail: true}`). */
|
|
1641
|
-
type ReachableResult = {
|
|
1642
|
-
/** Reachable paths, sorted lexicographically. */
|
|
1643
|
-
paths: string[];
|
|
1644
|
-
/** Hop depth from `from` to each reachable path. */
|
|
1645
|
-
depths: Map<string, number>;
|
|
1646
|
-
/** True when traversal hit `maxDepth` and some neighbors were not explored. */
|
|
1647
|
-
truncated: boolean;
|
|
1648
|
-
};
|
|
1649
|
-
/**
|
|
1650
|
-
* Reachability query over a {@link Graph.describe} snapshot.
|
|
1651
|
-
*
|
|
1652
|
-
* Traversal follows `deps` (upstream) and reverse-`deps` (downstream). Edges
|
|
1653
|
-
* are derived from deps post Unit 7, so `edges[]` in the snapshot is
|
|
1654
|
-
* redundant with deps — it's walked defensively in case a caller supplied a
|
|
1655
|
-
* pre-Unit-7 snapshot.
|
|
1656
|
-
*
|
|
1657
|
-
* @param described - `graph.describe()` output to traverse.
|
|
1658
|
-
* @param from - Start path (qualified node path).
|
|
1659
|
-
* @param direction - Traversal direction (ignored when `opts.both` is `true`).
|
|
1660
|
-
* @param options - Optional `maxDepth`, `both`, `withDetail`.
|
|
1661
|
-
* @returns Sorted paths (flat) — or {@link ReachableResult} when `withDetail: true`.
|
|
1662
|
-
*/
|
|
1663
|
-
declare function reachable(described: GraphDescribeOutput, from: string, direction: ReachableDirection, options?: ReachableOptions & {
|
|
1664
|
-
withDetail: true;
|
|
1665
|
-
}): ReachableResult;
|
|
1666
|
-
declare function reachable(described: GraphDescribeOutput, from: string, direction: ReachableDirection, options?: ReachableOptions): string[];
|
|
1667
|
-
|
|
1668
|
-
export { type ObserveTheme as A, type ObserveThemeName as B, type CausalChain as C, type DescribeChangeset as D, type ExplainPathOptions as E, type ObserveTier as F, Graph as G, type ReachableOptions as H, type TraceEntry as I, diffForWAL as J, explainPath as K, graphProfile as L, type Meta as M, type NodeProfile as N, type ObserveChangeset as O, reachable as P, topologyDiff as Q, type ReachableDirection as R, SNAPSHOT_VERSION as S, type TopologyEvent as T, type GraphOptions as a, type GraphDescribeOutput as b, type CausalStep as c, type DescribeEvent as d, type DescribeFilter as e, GRAPH_META_SEGMENT as f, type GraphActorOptions as g, type GraphAttachStorageOptions as h, type GraphCheckpointRecord as i, type GraphDescribeOptions as j, type GraphDiagramDirection as k, type GraphDiffChange as l, type GraphDiffResult as m, type GraphFactoryContext as n, type GraphNodeFactory as o, type GraphObserveAll as p, type GraphObserveOne as q, type GraphPersistSnapshot as r, type GraphProfileOptions as s, type GraphProfileResult as t, type GraphVersionChange as u, type GraphWALDiff as v, type ObserveDetail as w, type ObserveEvent as x, type ObserveOptions as y, type ObserveResult as z };
|