@graphrefly/graphrefly 0.27.0 → 0.29.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/dist/backoff-HPZMEZNF.js +1 -0
- package/dist/cascading-Bp99ckMJ.d.ts +180 -0
- package/dist/cascading-CcAgRacD.d.cts +180 -0
- package/dist/chunk-22F4K3G7.js +1 -0
- package/dist/chunk-22SVXUPB.js +64 -0
- package/dist/chunk-2GQREQ6C.js +1 -0
- package/dist/chunk-3JXNEPCD.js +2 -0
- package/dist/chunk-4JJCCD5S.js +2 -0
- package/dist/chunk-4OFIQ66T.js +1 -0
- package/dist/chunk-4V4C7K56.js +1 -0
- package/dist/chunk-4VVTGLXJ.js +1 -0
- package/dist/chunk-567NWZ3T.js +1 -0
- package/dist/chunk-5JDE5JHE.js +1 -0
- package/dist/chunk-5QDBSZBV.js +1 -0
- package/dist/chunk-5Z4HDCO6.js +1 -0
- package/dist/chunk-63FFOHLA.js +1 -0
- package/dist/chunk-6QZNQS5B.js +1 -0
- package/dist/chunk-7JDLFI6N.js +1 -0
- package/dist/chunk-7TDOES3L.js +1 -0
- package/dist/chunk-A7IAQQ63.js +1 -0
- package/dist/chunk-AMG5VBHW.js +1 -0
- package/dist/chunk-AUY2YKCO.js +1 -0
- package/dist/chunk-AV3PIDFQ.js +1 -0
- package/dist/chunk-BA5URFYW.js +1 -0
- package/dist/chunk-BKPLTBL5.js +1 -0
- package/dist/chunk-BZP5T4X6.js +1 -0
- package/dist/chunk-CK2E7BTU.js +1 -0
- package/dist/chunk-CSJE2EKV.js +1 -0
- package/dist/chunk-E3AXATVZ.js +9 -0
- package/dist/chunk-ESMPEKEV.js +1 -0
- package/dist/chunk-GJR3P6JG.js +1 -0
- package/dist/chunk-GNCBXARM.js +1 -0
- package/dist/chunk-GPW2V3RE.js +1 -0
- package/dist/chunk-HSIEYSDY.js +1 -0
- package/dist/chunk-I6VIH3VA.js +1 -0
- package/dist/chunk-ISCENNXS.js +1 -0
- package/dist/chunk-JYOUF6UQ.js +1 -0
- package/dist/chunk-KASHOCF5.js +1 -0
- package/dist/chunk-LGSNR4LU.js +5 -0
- package/dist/chunk-LVGBLZM2.js +1 -0
- package/dist/chunk-MGKAO4EK.js +7 -0
- package/dist/chunk-NSG4C6BF.js +23 -0
- package/dist/chunk-OL33ZI6R.js +1 -0
- package/dist/chunk-PCZ35NXD.js +78 -0
- package/dist/chunk-PGMUCUHG.js +43 -0
- package/dist/chunk-QYADASLV.js +1 -0
- package/dist/chunk-RD52SNH2.js +1 -0
- package/dist/chunk-SLMYTGTU.js +1 -0
- package/dist/chunk-TWMEGG45.js +1 -0
- package/dist/chunk-UVJQ35G2.js +1 -0
- package/dist/chunk-VGTCGNRX.js +18 -0
- package/dist/chunk-VIMF6LGM.js +1 -0
- package/dist/chunk-VJLMUKOI.js +1 -0
- package/dist/chunk-VWPRPPKR.js +1 -0
- package/dist/chunk-W4TSQ6RJ.js +1 -0
- package/dist/chunk-WM7H7WTY.js +3 -0
- package/dist/chunk-Y32RJO24.js +1 -0
- package/dist/chunk-Y53B6NS4.js +1 -0
- package/dist/compat/index.cjs +15 -7656
- package/dist/compat/index.d.cts +15 -14
- package/dist/compat/index.d.ts +15 -14
- package/dist/compat/index.js +1 -50
- package/dist/compat/jotai/index.cjs +1 -2048
- package/dist/compat/jotai/index.d.cts +2 -2
- package/dist/compat/jotai/index.d.ts +2 -2
- package/dist/compat/jotai/index.js +1 -9
- package/dist/compat/nanostores/index.cjs +1 -2175
- package/dist/compat/nanostores/index.d.cts +2 -2
- package/dist/compat/nanostores/index.d.ts +2 -2
- package/dist/compat/nanostores/index.js +1 -23
- package/dist/compat/nestjs/index.cjs +15 -6782
- package/dist/compat/nestjs/index.d.cts +7 -6
- package/dist/compat/nestjs/index.d.ts +7 -6
- package/dist/compat/nestjs/index.js +1 -83
- package/dist/compat/react/index.cjs +1 -141
- package/dist/compat/react/index.d.cts +2 -2
- package/dist/compat/react/index.d.ts +2 -2
- package/dist/compat/react/index.js +1 -12
- package/dist/compat/solid/index.cjs +1 -128
- package/dist/compat/solid/index.d.cts +2 -2
- package/dist/compat/solid/index.d.ts +2 -2
- package/dist/compat/solid/index.js +1 -12
- package/dist/compat/svelte/index.cjs +1 -131
- package/dist/compat/svelte/index.d.cts +2 -2
- package/dist/compat/svelte/index.d.ts +2 -2
- package/dist/compat/svelte/index.js +1 -12
- package/dist/compat/vue/index.cjs +1 -146
- package/dist/compat/vue/index.d.cts +2 -2
- package/dist/compat/vue/index.d.ts +2 -2
- package/dist/compat/vue/index.js +1 -12
- package/dist/compat/zustand/index.cjs +7 -4931
- package/dist/compat/zustand/index.d.cts +5 -5
- package/dist/compat/zustand/index.d.ts +5 -5
- package/dist/compat/zustand/index.js +1 -12
- package/dist/composite-BL-llbnE.d.ts +69 -0
- package/dist/composite-Dze--DaA.d.cts +69 -0
- package/dist/core/index.cjs +1 -2271
- package/dist/core/index.d.cts +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +1 -110
- package/dist/extra/browser.cjs +1 -0
- package/dist/extra/browser.d.cts +3 -0
- package/dist/extra/browser.d.ts +3 -0
- package/dist/extra/browser.js +1 -0
- package/dist/extra/index.cjs +24 -9971
- package/dist/extra/index.d.cts +13 -6
- package/dist/extra/index.d.ts +13 -6
- package/dist/extra/index.js +1 -381
- package/dist/extra/node.cjs +3 -0
- package/dist/extra/node.d.cts +81 -0
- package/dist/extra/node.d.ts +81 -0
- package/dist/extra/node.js +2 -0
- package/dist/extra/operators.cjs +1 -0
- package/dist/extra/operators.d.cts +910 -0
- package/dist/extra/operators.d.ts +910 -0
- package/dist/extra/operators.js +1 -0
- package/dist/extra/reactive.cjs +1 -0
- package/dist/extra/reactive.d.cts +352 -0
- package/dist/extra/reactive.d.ts +352 -0
- package/dist/extra/reactive.js +1 -0
- package/dist/extra/sources.cjs +1 -2486
- package/dist/extra/sources.d.cts +6 -2
- package/dist/extra/sources.d.ts +6 -2
- package/dist/extra/sources.js +1 -57
- package/dist/extra/storage-browser.cjs +1 -0
- package/dist/extra/storage-browser.d.cts +71 -0
- package/dist/extra/storage-browser.d.ts +71 -0
- package/dist/extra/storage-browser.js +1 -0
- package/dist/extra/storage-core.cjs +1 -0
- package/dist/extra/storage-core.d.cts +98 -0
- package/dist/extra/storage-core.d.ts +98 -0
- package/dist/extra/storage-core.js +1 -0
- package/dist/extra/storage-node.cjs +2 -0
- package/dist/extra/storage-node.d.cts +60 -0
- package/dist/extra/storage-node.d.ts +60 -0
- package/dist/extra/storage-node.js +1 -0
- package/dist/fallback-BaTS7vVY.d.cts +258 -0
- package/dist/fallback-eOm3LNxP.d.ts +258 -0
- package/dist/graph/index.cjs +7 -5030
- package/dist/graph/index.d.cts +6 -5
- package/dist/graph/index.d.ts +6 -5
- package/dist/graph/index.js +1 -50
- package/dist/{graph-DNCrvZSn.d.cts → graph-DgohqXK-.d.cts} +151 -32
- package/dist/{graph-CCwGKLCm.d.ts → graph-Qjg9gWHI.d.ts} +151 -32
- package/dist/{index-BwfLUNw4.d.ts → index-2BVuRCI4.d.ts} +173 -2040
- package/dist/{index-BPVt8kqc.d.ts → index-2NvguqQA.d.ts} +10 -195
- package/dist/index-A65LZhoM.d.ts +186 -0
- package/dist/{index-DlLp-2Xn.d.cts → index-B-8FCEua.d.cts} +10 -195
- package/dist/index-B-gqvYel.d.ts +135 -0
- package/dist/index-B2PRuolf.d.cts +86 -0
- package/dist/index-BJqt9EwW.d.ts +231 -0
- package/dist/{index-BHlKbUwO.d.cts → index-BKjT5DiZ.d.cts} +173 -2040
- package/dist/{index-C0svESO4.d.ts → index-BM8BU4q6.d.ts} +1 -1
- package/dist/{index-VdHQMPy1.d.ts → index-BQaEnxBf.d.ts} +1 -1
- package/dist/index-BSfwiy5B.d.ts +192 -0
- package/dist/index-BTSkeCZs.d.cts +291 -0
- package/dist/index-BUVtw1Ay.d.cts +186 -0
- package/dist/index-BUi57v_p.d.ts +163 -0
- package/dist/{messaging-Gt4LPbyA.d.cts → index-BanNUILp.d.cts} +31 -93
- package/dist/{audit-DRlSzBu9.d.ts → index-BayHDRx6.d.cts} +27 -21
- package/dist/{index-B6D3QNSA.d.ts → index-BiyjsZ0m.d.ts} +148 -20
- package/dist/index-BqZ6vB2A.d.ts +2057 -0
- package/dist/{memory-li6FL5RM.d.ts → index-BuVidq3D.d.cts} +26 -26
- package/dist/index-Byh-xTyp.d.ts +105 -0
- package/dist/index-C08QPDcV.d.cts +321 -0
- package/dist/{demo-shell-BDkOptd6.d.ts → index-C66RJiX8.d.ts} +14 -14
- package/dist/index-C8RfjffH.d.ts +291 -0
- package/dist/index-CA1Cu7Ud.d.ts +873 -0
- package/dist/{index-ByQxazQJ.d.cts → index-CABbltIu.d.cts} +1 -1
- package/dist/{index-VHqptjhu.d.cts → index-CHEBsnYv.d.cts} +1 -1
- package/dist/{index-BuEoe-Qu.d.ts → index-CI0yDnLp.d.ts} +9 -9
- package/dist/{index-B9B7_HEY.d.ts → index-CJ45TW-h.d.ts} +1 -1
- package/dist/{index-CO8uBlUh.d.cts → index-CJZKZoo4.d.cts} +148 -20
- package/dist/{index-wEn0eFe8.d.ts → index-CX2tFJL1.d.ts} +1 -1
- package/dist/{index-BaSM3aYt.d.ts → index-CcWOJ6F0.d.ts} +3 -3
- package/dist/{audit-ClmqGOCx.d.cts → index-CiaVoZGo.d.ts} +27 -21
- package/dist/{index-Dzk2hrlR.d.ts → index-Ct5CWc4E.d.ts} +1 -1
- package/dist/index-D38duMCv.d.cts +357 -0
- package/dist/{index-C8oil6M6.d.ts → index-D5XJ2tSx.d.ts} +30 -6
- package/dist/{index-DO_6JN9Z.d.cts → index-D80do5jX.d.cts} +1 -1
- package/dist/index-D9HKAH_-.d.cts +231 -0
- package/dist/index-DBe_8XW5.d.cts +143 -0
- package/dist/{memory-C6Z2tGpC.d.cts → index-DCeTyFlB.d.ts} +26 -26
- package/dist/index-DDy8eeXS.d.ts +321 -0
- package/dist/index-DJ5oNBc8.d.ts +143 -0
- package/dist/{index-CI3DprxP.d.cts → index-DP0_O3ls.d.cts} +30 -6
- package/dist/{demo-shell-Crid1WdR.d.cts → index-DX8xS-yB.d.cts} +14 -14
- package/dist/index-DiZejfCI.d.cts +2057 -0
- package/dist/index-DknyJ2Fu.d.cts +163 -0
- package/dist/index-DoWMs-Kk.d.cts +135 -0
- package/dist/{messaging-XDoYablx.d.ts → index-DuB5aO4-.d.ts} +31 -93
- package/dist/index-DwjJGKxV.d.ts +357 -0
- package/dist/{index-B6EhDnjH.d.cts → index-H_oxVec5.d.cts} +1 -1
- package/dist/{index-3lsddbbS.d.ts → index-IMAHq-ia.d.ts} +1 -1
- package/dist/{index-B1tloyhO.d.cts → index-U1nir7MX.d.cts} +1 -1
- package/dist/index-Vg7tORgk.d.ts +86 -0
- package/dist/index-dig-r2tQ.d.cts +873 -0
- package/dist/{index-CxFrXH4m.d.ts → index-gsT79Xu9.d.ts} +1 -1
- package/dist/{index-D8wS_PeY.d.cts → index-i99Ka8s7.d.cts} +9 -9
- package/dist/index-iKkyJosF.d.cts +105 -0
- package/dist/{index-Xi3u0HCQ.d.cts → index-jleeotBT.d.cts} +1 -1
- package/dist/{index-DVGiGFGT.d.cts → index-kykKWwV-.d.cts} +3 -3
- package/dist/index-vgcLF5TH.d.cts +192 -0
- package/dist/{index-DYme44FM.d.cts → index-y1RllPn4.d.cts} +1 -1
- package/dist/index.cjs +151 -24142
- package/dist/index.d.cts +69 -2099
- package/dist/index.d.ts +69 -2099
- package/dist/index.js +1 -3868
- package/dist/{meta-CbznRPYJ.d.ts → meta-CX7YsOzp.d.cts} +5 -5
- package/dist/{meta-BxCA7rcr.d.cts → meta-CckhhFRd.d.ts} +5 -5
- package/dist/{node-BmerH3kS.d.cts → node-Dd6wHSib.d.cts} +71 -11
- package/dist/{node-BmerH3kS.d.ts → node-Dd6wHSib.d.ts} +71 -11
- package/dist/{observable-BgGUwcqp.d.ts → observable-BZJgo616.d.ts} +1 -1
- package/dist/{observable-DJt_AxzQ.d.cts → observable-kwzpLvbi.d.cts} +1 -1
- package/dist/patterns/ai/browser.cjs +25 -0
- package/dist/patterns/ai/browser.d.cts +127 -0
- package/dist/patterns/ai/browser.d.ts +127 -0
- package/dist/patterns/ai/browser.js +3 -0
- package/dist/patterns/ai/index.cjs +92 -0
- package/dist/patterns/ai/index.d.cts +17 -0
- package/dist/patterns/ai/index.d.ts +17 -0
- package/dist/patterns/ai/index.js +1 -0
- package/dist/patterns/ai/node.cjs +2 -0
- package/dist/patterns/ai/node.d.cts +58 -0
- package/dist/patterns/ai/node.d.ts +58 -0
- package/dist/patterns/ai/node.js +1 -0
- package/dist/patterns/audit/index.cjs +7 -0
- package/dist/patterns/audit/index.d.cts +6 -0
- package/dist/patterns/audit/index.d.ts +6 -0
- package/dist/patterns/audit/index.js +1 -0
- package/dist/patterns/cqrs/index.cjs +7 -0
- package/dist/patterns/cqrs/index.d.cts +5 -0
- package/dist/patterns/cqrs/index.d.ts +5 -0
- package/dist/patterns/cqrs/index.js +1 -0
- package/dist/patterns/demo-shell/index.cjs +8 -0
- package/dist/patterns/demo-shell/index.d.cts +6 -0
- package/dist/patterns/demo-shell/index.d.ts +6 -0
- package/dist/patterns/demo-shell/index.js +1 -0
- package/dist/patterns/domain-templates/index.cjs +7 -0
- package/dist/patterns/domain-templates/index.d.cts +5 -0
- package/dist/patterns/domain-templates/index.d.ts +5 -0
- package/dist/patterns/domain-templates/index.js +1 -0
- package/dist/patterns/graphspec/index.cjs +84 -0
- package/dist/patterns/graphspec/index.d.cts +7 -0
- package/dist/patterns/graphspec/index.d.ts +7 -0
- package/dist/patterns/graphspec/index.js +1 -0
- package/dist/patterns/guarded-execution/index.cjs +7 -0
- package/dist/patterns/guarded-execution/index.d.cts +7 -0
- package/dist/patterns/guarded-execution/index.d.ts +7 -0
- package/dist/patterns/guarded-execution/index.js +1 -0
- package/dist/patterns/harness/index.cjs +49 -0
- package/dist/patterns/harness/index.d.cts +11 -0
- package/dist/patterns/harness/index.d.ts +11 -0
- package/dist/patterns/harness/index.js +1 -0
- package/dist/patterns/job-queue/index.cjs +7 -0
- package/dist/patterns/job-queue/index.d.cts +5 -0
- package/dist/patterns/job-queue/index.d.ts +5 -0
- package/dist/patterns/job-queue/index.js +1 -0
- package/dist/patterns/lens/index.cjs +7 -0
- package/dist/patterns/lens/index.d.cts +7 -0
- package/dist/patterns/lens/index.d.ts +7 -0
- package/dist/patterns/lens/index.js +1 -0
- package/dist/patterns/memory/index.cjs +7 -0
- package/dist/patterns/memory/index.d.cts +5 -0
- package/dist/patterns/memory/index.d.ts +5 -0
- package/dist/patterns/memory/index.js +1 -0
- package/dist/patterns/messaging/index.cjs +7 -0
- package/dist/patterns/messaging/index.d.cts +5 -0
- package/dist/patterns/messaging/index.d.ts +5 -0
- package/dist/patterns/messaging/index.js +1 -0
- package/dist/patterns/orchestration/index.cjs +7 -0
- package/dist/patterns/orchestration/index.d.cts +6 -0
- package/dist/patterns/orchestration/index.d.ts +6 -0
- package/dist/patterns/orchestration/index.js +1 -0
- package/dist/patterns/reactive-layout/index.cjs +8 -6444
- package/dist/patterns/reactive-layout/index.d.cts +6 -6
- package/dist/patterns/reactive-layout/index.d.ts +6 -6
- package/dist/patterns/reactive-layout/index.js +1 -56
- package/dist/patterns/reduction/index.cjs +7 -0
- package/dist/patterns/reduction/index.d.cts +5 -0
- package/dist/patterns/reduction/index.d.ts +5 -0
- package/dist/patterns/reduction/index.js +1 -0
- package/dist/patterns/refine-loop/index.cjs +9 -0
- package/dist/patterns/refine-loop/index.d.cts +7 -0
- package/dist/patterns/refine-loop/index.d.ts +7 -0
- package/dist/patterns/refine-loop/index.js +1 -0
- package/dist/patterns/resilient-pipeline/index.cjs +1 -0
- package/dist/patterns/resilient-pipeline/index.d.cts +7 -0
- package/dist/patterns/resilient-pipeline/index.d.ts +7 -0
- package/dist/patterns/resilient-pipeline/index.js +1 -0
- package/dist/patterns/surface/index.cjs +15 -0
- package/dist/patterns/surface/index.d.cts +8 -0
- package/dist/patterns/surface/index.d.ts +8 -0
- package/dist/patterns/surface/index.js +1 -0
- package/dist/{reactive-layout-u5Ulnqag.d.ts → reactive-layout-BkBwVvwm.d.ts} +2 -2
- package/dist/{reactive-layout-MQP--J3F.d.cts → reactive-layout-PiFwVaWS.d.cts} +2 -2
- package/dist/reactive-log-1QTyx10a.d.ts +190 -0
- package/dist/reactive-log-BiVoSxke.d.cts +190 -0
- package/dist/{composite-aUCvjZVR.d.ts → reactive-map-CwO_COHy.d.cts} +2 -67
- package/dist/{composite-C7PcQvcs.d.cts → reactive-map-FeuTVAJb.d.ts} +2 -67
- package/dist/resilience-CBfYJW5C.d.ts +493 -0
- package/dist/resilience-XRUF267O.js +1 -0
- package/dist/resilience-uBz4yvYB.d.cts +493 -0
- package/dist/{sugar-CCOxXK1e.d.ts → sugar-CY-MCfZ9.d.ts} +17 -15
- package/dist/{sugar-D02n5JjF.d.cts → sugar-DHttV0LX.d.cts} +17 -15
- package/dist/topology-tree-CVjt2gp7.d.cts +25 -0
- package/dist/topology-tree-one6oSKY.d.ts +25 -0
- package/dist/types-O3GzJY2U.d.cts +401 -0
- package/dist/types-u64Ose53.d.ts +401 -0
- package/package.json +252 -22
- package/dist/ai-CaR_912Q.d.cts +0 -1033
- package/dist/ai-WlRltJV7.d.ts +0 -1033
- package/dist/chunk-3ZWCKRHX.js +0 -117
- package/dist/chunk-3ZWCKRHX.js.map +0 -1
- package/dist/chunk-7TAQJHQV.js +0 -103
- package/dist/chunk-7TAQJHQV.js.map +0 -1
- package/dist/chunk-APFNLIRG.js +0 -62
- package/dist/chunk-APFNLIRG.js.map +0 -1
- package/dist/chunk-AT5LKYNL.js +0 -395
- package/dist/chunk-AT5LKYNL.js.map +0 -1
- package/dist/chunk-BQ6RQQFF.js +0 -5087
- package/dist/chunk-BQ6RQQFF.js.map +0 -1
- package/dist/chunk-BVZYTZ5H.js +0 -599
- package/dist/chunk-BVZYTZ5H.js.map +0 -1
- package/dist/chunk-DST5DKZS.js +0 -1371
- package/dist/chunk-DST5DKZS.js.map +0 -1
- package/dist/chunk-GTE6PWRZ.js +0 -866
- package/dist/chunk-GTE6PWRZ.js.map +0 -1
- package/dist/chunk-HXZEYDUR.js +0 -94
- package/dist/chunk-HXZEYDUR.js.map +0 -1
- package/dist/chunk-J22W6HV3.js +0 -107
- package/dist/chunk-J22W6HV3.js.map +0 -1
- package/dist/chunk-J2VBW3DZ.js +0 -302
- package/dist/chunk-J2VBW3DZ.js.map +0 -1
- package/dist/chunk-JSCT3CR4.js +0 -38
- package/dist/chunk-JSCT3CR4.js.map +0 -1
- package/dist/chunk-JWBCY4NC.js +0 -330
- package/dist/chunk-JWBCY4NC.js.map +0 -1
- package/dist/chunk-K2AUJHVP.js +0 -2251
- package/dist/chunk-K2AUJHVP.js.map +0 -1
- package/dist/chunk-MJ2NKQQL.js +0 -119
- package/dist/chunk-MJ2NKQQL.js.map +0 -1
- package/dist/chunk-N6UR7YVY.js +0 -198
- package/dist/chunk-N6UR7YVY.js.map +0 -1
- package/dist/chunk-NC6S43JJ.js +0 -456
- package/dist/chunk-NC6S43JJ.js.map +0 -1
- package/dist/chunk-OFVJBJXR.js +0 -98
- package/dist/chunk-OFVJBJXR.js.map +0 -1
- package/dist/chunk-OHISZPOJ.js +0 -97
- package/dist/chunk-OHISZPOJ.js.map +0 -1
- package/dist/chunk-OU5CQKNW.js +0 -102
- package/dist/chunk-OU5CQKNW.js.map +0 -1
- package/dist/chunk-PF7GRZMW.js +0 -2712
- package/dist/chunk-PF7GRZMW.js.map +0 -1
- package/dist/chunk-PHOUUNK7.js +0 -2291
- package/dist/chunk-PHOUUNK7.js.map +0 -1
- package/dist/chunk-RNHBMHKA.js +0 -1665
- package/dist/chunk-RNHBMHKA.js.map +0 -1
- package/dist/chunk-SX52TAR4.js +0 -110
- package/dist/chunk-SX52TAR4.js.map +0 -1
- package/dist/chunk-VYPWMZ6H.js +0 -98
- package/dist/chunk-VYPWMZ6H.js.map +0 -1
- package/dist/chunk-WBZOVTYK.js +0 -171
- package/dist/chunk-WBZOVTYK.js.map +0 -1
- package/dist/chunk-WKNUIZOY.js +0 -354
- package/dist/chunk-WKNUIZOY.js.map +0 -1
- package/dist/chunk-X3VMZYBT.js +0 -713
- package/dist/chunk-X3VMZYBT.js.map +0 -1
- package/dist/chunk-X5R3GL6H.js +0 -525
- package/dist/chunk-X5R3GL6H.js.map +0 -1
- package/dist/chunk-XGPU467M.js +0 -136
- package/dist/chunk-XGPU467M.js.map +0 -1
- package/dist/compat/index.cjs.map +0 -1
- package/dist/compat/index.js.map +0 -1
- package/dist/compat/jotai/index.cjs.map +0 -1
- package/dist/compat/jotai/index.js.map +0 -1
- package/dist/compat/nanostores/index.cjs.map +0 -1
- package/dist/compat/nanostores/index.js.map +0 -1
- package/dist/compat/nestjs/index.cjs.map +0 -1
- package/dist/compat/nestjs/index.js.map +0 -1
- package/dist/compat/react/index.cjs.map +0 -1
- package/dist/compat/react/index.js.map +0 -1
- package/dist/compat/solid/index.cjs.map +0 -1
- package/dist/compat/solid/index.js.map +0 -1
- package/dist/compat/svelte/index.cjs.map +0 -1
- package/dist/compat/svelte/index.js.map +0 -1
- package/dist/compat/vue/index.cjs.map +0 -1
- package/dist/compat/vue/index.js.map +0 -1
- package/dist/compat/zustand/index.cjs.map +0 -1
- package/dist/compat/zustand/index.js.map +0 -1
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/extra/index.cjs.map +0 -1
- package/dist/extra/index.js.map +0 -1
- package/dist/extra/sources.cjs.map +0 -1
- package/dist/extra/sources.js.map +0 -1
- package/dist/graph/index.cjs.map +0 -1
- package/dist/graph/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/patterns/ai.cjs +0 -7930
- package/dist/patterns/ai.cjs.map +0 -1
- package/dist/patterns/ai.d.cts +0 -10
- package/dist/patterns/ai.d.ts +0 -10
- package/dist/patterns/ai.js +0 -71
- package/dist/patterns/ai.js.map +0 -1
- package/dist/patterns/audit.cjs +0 -5805
- package/dist/patterns/audit.cjs.map +0 -1
- package/dist/patterns/audit.d.cts +0 -6
- package/dist/patterns/audit.d.ts +0 -6
- package/dist/patterns/audit.js +0 -29
- package/dist/patterns/audit.js.map +0 -1
- package/dist/patterns/demo-shell.cjs +0 -5604
- package/dist/patterns/demo-shell.cjs.map +0 -1
- package/dist/patterns/demo-shell.d.cts +0 -6
- package/dist/patterns/demo-shell.d.ts +0 -6
- package/dist/patterns/demo-shell.js +0 -15
- package/dist/patterns/demo-shell.js.map +0 -1
- package/dist/patterns/memory.cjs +0 -5283
- package/dist/patterns/memory.cjs.map +0 -1
- package/dist/patterns/memory.d.cts +0 -5
- package/dist/patterns/memory.d.ts +0 -5
- package/dist/patterns/memory.js +0 -20
- package/dist/patterns/memory.js.map +0 -1
- package/dist/patterns/reactive-layout/index.cjs.map +0 -1
- package/dist/patterns/reactive-layout/index.js.map +0 -1
- package/dist/storage-CMjUUuxn.d.ts +0 -190
- package/dist/storage-DdWlZo6U.d.cts +0 -190
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/explain.ts","../src/extra/utils/sizeof.ts","../src/graph/profile.ts","../src/graph/graph.ts"],"sourcesContent":["/**\n * Causal walkback over a {@link Graph.describe} snapshot (roadmap §9.2).\n *\n * `explainPath` finds the shortest dep-chain from `from` to `to` and returns a\n * step-by-step {@link CausalChain} enriched with each node's current value,\n * status, last-mutation actor, and any `graph.trace()` reasoning annotation.\n *\n * Pure function over the snapshot — peer to {@link reachable}. The\n * {@link Graph.explain} instance method auto-passes `describe({detail:\"standard\"})`\n * plus runtime annotations and `lastMutation` so callers get rich output by\n * default.\n *\n * @module\n */\nimport type { Actor } from \"../core/actor.js\";\nimport type { DescribeNodeOutput } from \"../core/meta.js\";\nimport type { GraphDescribeOutput } from \"./graph.js\";\n\n/** One node along the causal chain returned by {@link explainPath}. */\nexport interface CausalStep {\n\t/** Qualified node path. */\n\tpath: string;\n\t/** Node kind (`state` / `derived` / `producer` / etc.). */\n\ttype: DescribeNodeOutput[\"type\"];\n\t/** Status as of the source snapshot. */\n\tstatus?: DescribeNodeOutput[\"status\"];\n\t/** Cached value at snapshot time (omitted when describe didn't include it). */\n\tvalue?: unknown;\n\t/** Hop distance from `from` (0 = `from`, N = `to`). */\n\thop: number;\n\t/** Reason annotation set via `graph.trace(path, reason)`, when present. */\n\treason?: string;\n\t/** Most recent guarded mutation, when known. */\n\tlastMutation?: Readonly<{ actor: Actor; timestamp_ns: number }>;\n\t/** V0/V1 versioning info, when present. */\n\tv?: DescribeNodeOutput[\"v\"];\n\t/** Index of this step in the next step's `deps` (i.e. which dep slot fed forward). */\n\tdep_index?: number;\n\t/**\n\t * All dep slots when the same dep appears multiple times in the next\n\t * step's `deps`. Present only for multi-edge connections; `dep_index`\n\t * always equals `dep_indices[0]` when set.\n\t */\n\tdep_indices?: number[];\n}\n\n/** Outcome of an {@link explainPath} call. */\nexport interface CausalChain {\n\tfrom: string;\n\tto: string;\n\t/** True when a path was found. */\n\tfound: boolean;\n\t/** Why the chain may be empty/incomplete. `\"ok\"` when `found` is true. */\n\treason: \"ok\" | \"no-such-from\" | \"no-such-to\" | \"no-path\" | \"max-depth-exceeded\";\n\t/** Ordered steps — first element is `from`, last is `to`. Empty when `!found`. */\n\tsteps: readonly CausalStep[];\n\t/** Pretty multi-line rendering. Always present, even on failure (one-line message). */\n\ttext: string;\n\t/** JSON-serializable form (drops `text` to keep payloads compact). */\n\ttoJSON(): {\n\t\tfrom: string;\n\t\tto: string;\n\t\tfound: boolean;\n\t\treason: CausalChain[\"reason\"];\n\t\tsteps: readonly CausalStep[];\n\t};\n}\n\n/** Options for {@link explainPath}. */\nexport interface ExplainPathOptions {\n\t/** Maximum hop distance to search. Omit for unbounded. */\n\tmaxDepth?: number;\n\t/** Per-path reasoning annotations (typically `graph.trace()` output map). */\n\tannotations?: ReadonlyMap<string, string>;\n\t/** Per-path `lastMutation` map (overrides describe-derived values). */\n\tlastMutations?: ReadonlyMap<string, Readonly<{ actor: Actor; timestamp_ns: number }>>;\n\t/**\n\t * When `true` and `from === to`, search for a non-trivial cycle (path\n\t * back to `from` through ≥1 other node) instead of returning the trivial\n\t * single-step. Use when debugging feedback loops (COMPOSITION-GUIDE §7).\n\t * If no real cycle exists, falls back to the trivial single-step. Default\n\t * `false` — backward-compatible.\n\t */\n\tfindCycle?: boolean;\n}\n\n/**\n * Walks backward from `to` through `deps` to find the shortest path to `from`,\n * then assembles an ordered, enriched {@link CausalChain}.\n *\n * @param described - `graph.describe()` output (any detail level; richer detail → richer steps).\n * @param from - Path of the upstream node (the cause).\n * @param to - Path of the downstream node (the effect).\n * @param opts - Optional `maxDepth` and per-path annotation overlays.\n * @returns A {@link CausalChain} — `found:false` with a `reason` when no path exists.\n *\n * @example\n * ```ts\n * import { explainPath } from \"@graphrefly/graphrefly-ts\";\n * const chain = explainPath(graph.describe({ detail: \"standard\" }), \"input\", \"result\");\n * console.log(chain.text);\n * ```\n */\nexport function explainPath(\n\tdescribed: GraphDescribeOutput,\n\tfrom: string,\n\tto: string,\n\topts: ExplainPathOptions = {},\n): CausalChain {\n\tconst fromExists = from in described.nodes;\n\tconst toExists = to in described.nodes;\n\tif (!fromExists) return makeFailure(from, to, \"no-such-from\");\n\tif (!toExists) return makeFailure(from, to, \"no-such-to\");\n\n\tconst maxDepth = opts.maxDepth;\n\tif (maxDepth != null && (!Number.isInteger(maxDepth) || maxDepth < 0)) {\n\t\tthrow new Error(`explainPath: maxDepth must be an integer >= 0`);\n\t}\n\n\tif (from === to) {\n\t\t// findCycle: search for shortest non-trivial cycle (a path of ≥2 hops\n\t\t// back to `from` through other nodes). Falls back to trivial single\n\t\t// step if no real cycle exists.\n\t\tif (opts.findCycle === true) {\n\t\t\tconst cycle = findShortestCycle(described, from, opts);\n\t\t\tif (cycle != null) return cycle;\n\t\t}\n\t\tconst step = buildStep(from, described.nodes[from]!, 0, opts);\n\t\treturn makeSuccess(from, to, [step]);\n\t}\n\n\tif (maxDepth === 0) return makeFailure(from, to, \"no-path\");\n\n\tconst result = bfsShortestPath(described, from, to, maxDepth);\n\tif (!result.found) {\n\t\treturn makeFailure(from, to, result.truncated ? \"max-depth-exceeded\" : \"no-path\");\n\t}\n\treturn makeSuccess(from, to, materializeSteps(described, result.pathOrder, opts));\n}\n\n// ── BFS helpers ──────────────────────────────────────────────────────────\n\ntype StepPlan = { path: string; depIndices?: number[] };\n\ninterface BfsResult {\n\tfound: boolean;\n\tpathOrder: StepPlan[];\n\ttruncated: boolean;\n}\n\n/**\n * Backward BFS from `to` to `from`. Returns the ordered chain `from → … → to`\n * with `depIndices` annotating each non-final step (which slot(s) in the next\n * step's `deps` list connect us — typically a single index, but multi-edges\n * preserve every matching slot).\n */\nfunction bfsShortestPath(\n\tdescribed: GraphDescribeOutput,\n\tfrom: string,\n\tto: string,\n\tmaxDepth: number | undefined,\n): BfsResult {\n\ttype Pred = { from: string; depIndices: number[] };\n\tconst pred = new Map<string, Pred>();\n\tconst queue: Array<{ path: string; depth: number }> = [{ path: to, depth: 0 }];\n\tconst visited = new Set<string>([to]);\n\tlet head = 0;\n\tlet truncated = false;\n\n\twhile (head < queue.length) {\n\t\tconst cur = queue[head++]!;\n\t\tif (cur.path === from) break;\n\t\tif (maxDepth != null && cur.depth >= maxDepth) {\n\t\t\tconst node = described.nodes[cur.path];\n\t\t\tif (node?.deps && node.deps.length > 0) truncated = true;\n\t\t\tcontinue;\n\t\t}\n\t\tconst node = described.nodes[cur.path];\n\t\tif (node == null) continue;\n\t\tconst deps = node.deps ?? [];\n\t\t// Aggregate all dep-slot indices for each unique dep — preserves\n\t\t// multi-edge information when the same dep appears twice.\n\t\tconst slots = new Map<string, number[]>();\n\t\tfor (let i = 0; i < deps.length; i++) {\n\t\t\tconst dep = deps[i]!;\n\t\t\tif (!dep) continue;\n\t\t\tlet arr = slots.get(dep);\n\t\t\tif (arr == null) {\n\t\t\t\tarr = [];\n\t\t\t\tslots.set(dep, arr);\n\t\t\t}\n\t\t\tarr.push(i);\n\t\t}\n\t\tfor (const [dep, indices] of slots) {\n\t\t\tif (visited.has(dep)) continue;\n\t\t\tvisited.add(dep);\n\t\t\tpred.set(dep, { from: cur.path, depIndices: indices });\n\t\t\tqueue.push({ path: dep, depth: cur.depth + 1 });\n\t\t}\n\t}\n\n\tif (!pred.has(from)) {\n\t\treturn { found: false, pathOrder: [], truncated };\n\t}\n\n\t// Reconstruct: walk pred from `from` forward to `to`.\n\tconst pathOrder: StepPlan[] = [{ path: from }];\n\tlet cursor = from;\n\twhile (cursor !== to) {\n\t\tconst p = pred.get(cursor);\n\t\tif (p == null) return { found: false, pathOrder: [], truncated: false };\n\t\t// Attach depIndices to the step we just came from (cursor) — dep_index\n\t\t// names \"which slot in the NEXT step's deps am I\".\n\t\tpathOrder[pathOrder.length - 1]!.depIndices = p.depIndices;\n\t\tpathOrder.push({ path: p.from });\n\t\tcursor = p.from;\n\t}\n\treturn { found: true, pathOrder, truncated: false };\n}\n\n/**\n * Find the shortest cycle starting and ending at `start`, excluding the\n * trivial 0-hop \"self-step\" case. Returns a {@link CausalChain} success when\n * a cycle of length ≥2 exists, otherwise `null`. Handles direct self-loops\n * (`start ∈ deps(start)`) and multi-hop cycles uniformly.\n */\nfunction findShortestCycle(\n\tdescribed: GraphDescribeOutput,\n\tstart: string,\n\topts: ExplainPathOptions,\n): CausalChain | null {\n\tconst startNode = described.nodes[start];\n\tif (startNode == null) return null;\n\tconst startDeps = startNode.deps ?? [];\n\n\t// Direct self-loop: start ∈ deps(start). Return [start, start] with\n\t// dep_index pointing at the matching slot(s).\n\tconst selfSlots: number[] = [];\n\tfor (let i = 0; i < startDeps.length; i++) if (startDeps[i] === start) selfSlots.push(i);\n\tif (selfSlots.length > 0) {\n\t\tconst step0 = buildStep(start, startNode, 0, opts);\n\t\tstep0.dep_index = selfSlots[0]!;\n\t\tconst step1 = buildStep(start, startNode, 1, opts);\n\t\treturn makeSuccess(start, start, [step0, step1]);\n\t}\n\n\t// Multi-hop cycle: BFS from each direct dep of start back to start.\n\tlet best: BfsResult | null = null;\n\tfor (let i = 0; i < startDeps.length; i++) {\n\t\tconst dep = startDeps[i]!;\n\t\tif (!dep || dep === start) continue;\n\t\tconst sub = bfsShortestPath(described, dep, start, opts.maxDepth);\n\t\tif (!sub.found) continue;\n\t\tif (best == null || sub.pathOrder.length < best.pathOrder.length) {\n\t\t\tbest = sub;\n\t\t\t// Prepend `start` so the cycle reads: start → dep → … → start.\n\t\t\t// The slot index from start to its first dep needs preserving.\n\t\t\tbest = {\n\t\t\t\tfound: true,\n\t\t\t\tpathOrder: [{ path: start, depIndices: [i] }, ...sub.pathOrder],\n\t\t\t\ttruncated: false,\n\t\t\t};\n\t\t}\n\t}\n\tif (best == null) return null;\n\treturn makeSuccess(start, start, materializeSteps(described, best.pathOrder, opts));\n}\n\nfunction materializeSteps(\n\tdescribed: GraphDescribeOutput,\n\tpathOrder: readonly StepPlan[],\n\topts: ExplainPathOptions,\n): CausalStep[] {\n\treturn pathOrder.map((entry, i) => {\n\t\tconst node = described.nodes[entry.path]!;\n\t\tconst step = buildStep(entry.path, node, i, opts);\n\t\tif (entry.depIndices != null && entry.depIndices.length > 0) {\n\t\t\tstep.dep_index = entry.depIndices[0]!;\n\t\t\tif (entry.depIndices.length > 1) step.dep_indices = [...entry.depIndices];\n\t\t}\n\t\treturn step;\n\t});\n}\n\nfunction buildStep(\n\tpath: string,\n\tnode: DescribeNodeOutput,\n\thop: number,\n\topts: ExplainPathOptions,\n): CausalStep {\n\tconst step: CausalStep = {\n\t\tpath,\n\t\ttype: node.type,\n\t\thop,\n\t};\n\tif (node.status !== undefined) step.status = node.status;\n\tif (\"value\" in node) step.value = node.value;\n\tif (node.v != null) step.v = node.v;\n\tconst annotation = opts.annotations?.get(path) ?? node.reason;\n\tif (annotation != null) step.reason = annotation;\n\tconst lastMutation = opts.lastMutations?.get(path) ?? node.lastMutation;\n\tif (lastMutation != null) step.lastMutation = lastMutation;\n\treturn step;\n}\n\nfunction makeSuccess(from: string, to: string, steps: readonly CausalStep[]): CausalChain {\n\treturn finalize(from, to, true, \"ok\", steps);\n}\n\nfunction makeFailure(from: string, to: string, reason: CausalChain[\"reason\"]): CausalChain {\n\treturn finalize(from, to, false, reason, []);\n}\n\nfunction finalize(\n\tfrom: string,\n\tto: string,\n\tfound: boolean,\n\treason: CausalChain[\"reason\"],\n\tsteps: readonly CausalStep[],\n): CausalChain {\n\tconst text = renderChain(from, to, found, reason, steps);\n\treturn {\n\t\tfrom,\n\t\tto,\n\t\tfound,\n\t\treason,\n\t\tsteps,\n\t\ttext,\n\t\ttoJSON() {\n\t\t\treturn { from, to, found, reason, steps };\n\t\t},\n\t};\n}\n\nfunction renderChain(\n\tfrom: string,\n\tto: string,\n\tfound: boolean,\n\treason: CausalChain[\"reason\"],\n\tsteps: readonly CausalStep[],\n): string {\n\tif (!found) {\n\t\tswitch (reason) {\n\t\t\tcase \"no-such-from\":\n\t\t\t\treturn `explainPath: no node named \"${from}\"`;\n\t\t\tcase \"no-such-to\":\n\t\t\t\treturn `explainPath: no node named \"${to}\"`;\n\t\t\tcase \"max-depth-exceeded\":\n\t\t\t\treturn `explainPath: no path from \"${from}\" to \"${to}\" within maxDepth`;\n\t\t\tdefault:\n\t\t\t\treturn `explainPath: no path from \"${from}\" to \"${to}\"`;\n\t\t}\n\t}\n\tconst lines: string[] = [`Causal path: ${from} → ${to} (${steps.length} step(s))`];\n\tfor (const step of steps) {\n\t\tconst arrow = step.hop === 0 ? \"·\" : \"↓\";\n\t\tconst head = ` ${arrow} ${step.path} (${step.type}${step.status ? `/${step.status}` : \"\"})`;\n\t\tlines.push(head);\n\t\tif (\"value\" in step) {\n\t\t\tlines.push(` value: ${formatValue(step.value)}`);\n\t\t}\n\t\tif (step.reason != null) {\n\t\t\tlines.push(` reason: ${step.reason}`);\n\t\t}\n\t\tif (step.lastMutation != null) {\n\t\t\tconst a = step.lastMutation.actor;\n\t\t\tlines.push(` actor: ${a.type}${a.id ? `:${a.id}` : \"\"}`);\n\t\t}\n\t}\n\treturn lines.join(\"\\n\");\n}\n\nfunction formatValue(v: unknown): string {\n\tif (v === undefined) return \"<sentinel>\";\n\tif (v === null) return \"null\";\n\tif (typeof v === \"string\") return JSON.stringify(v);\n\tif (typeof v === \"number\" || typeof v === \"boolean\" || typeof v === \"bigint\") return String(v);\n\ttry {\n\t\tconst s = JSON.stringify(v);\n\t\treturn s.length > 80 ? `${s.slice(0, 77)}...` : s;\n\t} catch {\n\t\treturn String(v);\n\t}\n}\n","/**\n * Approximate in-memory size estimation for arbitrary JS values.\n *\n * Iterative walk with cycle detection via `WeakSet`. V8-tuned overhead\n * heuristics. Not exact — approximate enough for profiling and hotspot\n * detection.\n *\n * Use cases: `graphProfile` (per-node value size), reactive data structure\n * memory audits, heuristic cache admission.\n *\n * @module\n */\n\n/** Approximate per-type overhead in bytes (V8 heuristics). */\nexport const OVERHEAD = {\n\tobject: 56,\n\tarray: 64,\n\tstring: 40, // header; content added separately\n\tnumber: 8,\n\tboolean: 4,\n\tnull: 0,\n\tundefined: 0,\n\tsymbol: 40,\n\tbigint: 16, // base; scales with digit count (see `_bigintSize`)\n\tfunction: 120,\n\tmap: 72,\n\tset: 72,\n\tmapEntry: 40,\n\tsetEntry: 24,\n\tdate: 24,\n\tregexp: 48,\n\terror: 64,\n\turl: 80,\n\tpromise: 48,\n\tweakmap: 40,\n\tweakset: 40,\n} as const;\n\n/**\n * Optional user hook. Declare a `sizeof` symbol key on any object to return\n * a precomputed size (in bytes); the walker will honor it and skip recursion.\n *\n * @example\n * ```ts\n * const SIZEOF = Symbol.for(\"sizeof\");\n * class MyCache { [SIZEOF]() { return this.bytes; } }\n * ```\n */\nexport const SIZEOF_SYMBOL = Symbol.for(\"sizeof\");\n\n/**\n * Estimate the approximate retained memory (in bytes) of a JS value.\n *\n * Handles primitives, plain objects, arrays, Maps, Sets, ArrayBuffers +\n * TypedArrays (shared-buffer dedup), Date, RegExp, Error, URL, Promise,\n * WeakMap, WeakSet, nested combinations. Cyclic refs are counted once.\n *\n * @param value - The value to measure.\n * @returns Approximate size in bytes.\n */\nexport function sizeof(value: unknown): number {\n\tconst seen = new WeakSet<object>();\n\tconst seenBuffers = new WeakSet<ArrayBufferLike>();\n\t// Iterative walk via explicit stack — avoids blowing the call stack on\n\t// deeply nested values (linked lists, AST nodes, deep JSON).\n\tconst stack: unknown[] = [value];\n\tlet total = 0;\n\twhile (stack.length > 0) {\n\t\tconst v = stack.pop();\n\t\ttotal += _shallowSize(v, seen, seenBuffers, stack);\n\t}\n\treturn total;\n}\n\n/** Shallow size of `v`; pushes children onto `stack` for iterative traversal. */\nfunction _shallowSize(\n\tvalue: unknown,\n\tseen: WeakSet<object>,\n\tseenBuffers: WeakSet<ArrayBufferLike>,\n\tstack: unknown[],\n): number {\n\tif (value === null || value === undefined) return 0;\n\n\tconst t = typeof value;\n\tswitch (t) {\n\t\tcase \"number\":\n\t\t\treturn OVERHEAD.number;\n\t\tcase \"boolean\":\n\t\t\treturn OVERHEAD.boolean;\n\t\tcase \"string\":\n\t\t\treturn OVERHEAD.string + (value as string).length * 2;\n\t\tcase \"bigint\":\n\t\t\treturn OVERHEAD.bigint + _bigintSize(value as bigint);\n\t\tcase \"symbol\":\n\t\t\treturn OVERHEAD.symbol;\n\t\tcase \"function\":\n\t\t\tif (seen.has(value as object)) return 0;\n\t\t\tseen.add(value as object);\n\t\t\treturn OVERHEAD.function;\n\t\tcase \"undefined\":\n\t\t\treturn 0;\n\t}\n\n\tconst obj = value as object;\n\tif (seen.has(obj)) return 0;\n\tseen.add(obj);\n\n\t// User-supplied size hook wins — `Symbol.for(\"sizeof\")` method on the\n\t// object returns an exact byte count and we skip recursion.\n\tconst hook = (obj as Record<symbol, unknown>)[SIZEOF_SYMBOL];\n\tif (typeof hook === \"function\") {\n\t\ttry {\n\t\t\tconst reported = (hook as () => unknown).call(obj);\n\t\t\tif (typeof reported === \"number\" && Number.isFinite(reported)) return reported;\n\t\t} catch {\n\t\t\t/* ignore — fall through to default estimator */\n\t\t}\n\t}\n\n\tif (obj instanceof Date) return OVERHEAD.date;\n\tif (obj instanceof RegExp) return OVERHEAD.regexp + obj.source.length * 2;\n\tif (obj instanceof Error) {\n\t\tconst m = obj.message ? obj.message.length * 2 : 0;\n\t\tconst s = obj.stack ? obj.stack.length * 2 : 0;\n\t\treturn OVERHEAD.error + m + s;\n\t}\n\tif (typeof URL !== \"undefined\" && obj instanceof URL) {\n\t\treturn OVERHEAD.url + obj.href.length * 2;\n\t}\n\tif (typeof Promise !== \"undefined\" && obj instanceof Promise) {\n\t\treturn OVERHEAD.promise;\n\t}\n\tif (obj instanceof WeakMap) return OVERHEAD.weakmap;\n\tif (obj instanceof WeakSet) return OVERHEAD.weakset;\n\n\tif (obj instanceof Map) {\n\t\tlet size = OVERHEAD.map;\n\t\tfor (const [k, v] of obj) {\n\t\t\tsize += OVERHEAD.mapEntry;\n\t\t\tstack.push(k);\n\t\t\tstack.push(v);\n\t\t}\n\t\treturn size;\n\t}\n\n\tif (obj instanceof Set) {\n\t\tlet size = OVERHEAD.set;\n\t\tfor (const v of obj) {\n\t\t\tsize += OVERHEAD.setEntry;\n\t\t\tstack.push(v);\n\t\t}\n\t\treturn size;\n\t}\n\n\tif (Array.isArray(obj)) {\n\t\tconst size = OVERHEAD.array + obj.length * 8;\n\t\tfor (const item of obj) stack.push(item);\n\t\treturn size;\n\t}\n\n\t// ArrayBuffer — count once per buffer (multi-view dedup via `seenBuffers`).\n\tif (obj instanceof ArrayBuffer) {\n\t\tif (seenBuffers.has(obj)) return 0;\n\t\tseenBuffers.add(obj);\n\t\treturn obj.byteLength;\n\t}\n\tif (ArrayBuffer.isView(obj)) {\n\t\tconst view = obj as { byteLength: number; buffer: ArrayBufferLike };\n\t\tif (seenBuffers.has(view.buffer)) return 48; // view header only\n\t\tseenBuffers.add(view.buffer);\n\t\t// Charge the full underlying buffer — a small view over a large\n\t\t// buffer still retains all of it. Add the view header on top.\n\t\treturn view.buffer.byteLength + 48;\n\t}\n\n\t// Plain object — sum key overhead + recurse into values.\n\tlet size = OVERHEAD.object;\n\tconst keys = Object.keys(obj);\n\tfor (const key of keys) {\n\t\tsize += OVERHEAD.string + key.length * 2;\n\t\ttry {\n\t\t\tstack.push((obj as Record<string, unknown>)[key]);\n\t\t} catch {\n\t\t\t/* getter throw — skip this key */\n\t\t}\n\t}\n\treturn size;\n}\n\n/** BigInt digit-count-based sizing: each ~32-bit limb ≈ 8 bytes. */\nfunction _bigintSize(n: bigint): number {\n\tconst abs = n < 0n ? -n : n;\n\tif (abs === 0n) return 0;\n\tconst bits = abs.toString(2).length;\n\treturn Math.ceil(bits / 32) * 8;\n}\n","/**\n * Graph profiling and inspection utilities.\n *\n * Provides per-node memory estimation, connectivity stats, and hotspot\n * detection. Non-invasive — reads from `describe()` and node internals\n * without modifying state.\n *\n * @module\n */\n\nimport { type Node, NodeImpl } from \"../core/node.js\";\nimport { sizeof } from \"../extra/utils/sizeof.js\";\nimport type { Graph, GraphDescribeOutput } from \"./graph.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Per-node profile entry. */\nexport interface NodeProfile {\n\t/** Qualified path within the graph. */\n\tpath: string;\n\t/** Node type (state, derived, producer, effect). */\n\ttype: string;\n\t/** Node status (disconnected, dirty, settled, errored, completed). */\n\tstatus: string;\n\t/** Approximate retained bytes for the node's cached value. */\n\tvalueSizeBytes: number;\n\t/** Number of downstream subscribers (sinks). */\n\tsubscriberCount: number;\n\t/** Number of upstream dependencies. */\n\tdepCount: number;\n\t/**\n\t * True if this is an effect node with no external subscribers — a classic\n\t * leak pattern. See {@link GraphProfileResult.orphans} for the broader\n\t * orphan-node detection across `derived` / `producer` / `effect`.\n\t */\n\tisOrphanEffect: boolean;\n\t/**\n\t * Orphan category (batch 8 Unit 13 D). `null` when the node is healthy.\n\t * - `\"orphan-effect\"` — effect with zero subscribers (pre-existing class).\n\t * - `\"idle-derived\"` — derived with zero subscribers (wasted compute path\n\t * if it ever activates; may indicate a factory forgot keepalive).\n\t * - `\"idle-producer\"` — producer with zero subscribers (no external\n\t * consumer; may be an over-eager factory or forgotten cleanup).\n\t */\n\torphanKind: \"orphan-effect\" | \"idle-derived\" | \"idle-producer\" | null;\n}\n\n/** Aggregate graph profile. */\nexport interface GraphProfileResult {\n\t/** Total node count. */\n\tnodeCount: number;\n\t/** Total edge count. */\n\tedgeCount: number;\n\t/** Subgraph count. */\n\tsubgraphCount: number;\n\t/** All node profiles. */\n\tnodes: NodeProfile[];\n\t/** Total approximate value memory across all nodes. */\n\ttotalValueSizeBytes: number;\n\t/**\n\t * Top-N hotspots by dimension. Each list is sorted descending. See\n\t * {@link GraphProfileOptions.topN} for the cap (default 10).\n\t */\n\thotspots: {\n\t\tbyValueSize: NodeProfile[];\n\t\tbySubscriberCount: NodeProfile[];\n\t\tbyDepCount: NodeProfile[];\n\t};\n\t/**\n\t * Every orphan across types — `effect`, `derived`, `producer` with zero\n\t * subscribers. See {@link NodeProfile.orphanKind} for category.\n\t */\n\torphans: NodeProfile[];\n\t/** Effect nodes with no external subscribers (legacy; subset of `orphans`). */\n\torphanEffects: NodeProfile[];\n}\n\n/** Options for {@link graphProfile}. */\nexport interface GraphProfileOptions {\n\t/** Limit hotspot list (default 10). */\n\ttopN?: number;\n}\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\n/**\n * Profile a graph's memory and connectivity characteristics.\n *\n * Uses `describe({ detail: \"standard\" })` for node metadata and direct\n * `NodeImpl` access for subscriber counts and cached values.\n *\n * @param graph - The graph to profile.\n * @param opts - Optional configuration.\n * @returns Aggregate profile with per-node details, hotspots (multi-dim), and orphans.\n */\nexport function graphProfile(graph: Graph, opts?: GraphProfileOptions): GraphProfileResult {\n\tconst topN = opts?.topN ?? 10;\n\n\tconst desc: GraphDescribeOutput = graph.describe({ detail: \"standard\" });\n\n\t// Build path→Node lookup via _collectObserveTargets (same as describe uses).\n\t// Runtime guard: if the internal method is missing (refactored), degrade\n\t// gracefully — profiles will show 0 for valueSizeBytes and subscriberCount.\n\tconst targets: [string, Node][] = [];\n\tconst collector = (\n\t\tgraph as unknown as { _collectObserveTargets?: (prefix: string, out: [string, Node][]) => void }\n\t)._collectObserveTargets;\n\tif (typeof collector === \"function\") {\n\t\tcollector.call(graph, \"\", targets);\n\t}\n\tconst pathToNode = new Map<string, Node>();\n\tfor (const [p, n] of targets) pathToNode.set(p, n);\n\n\tconst profiles: NodeProfile[] = [];\n\n\tfor (const [path, nodeDesc] of Object.entries(desc.nodes)) {\n\t\tconst nd = pathToNode.get(path);\n\t\tconst impl = nd instanceof NodeImpl ? nd : null;\n\n\t\tconst valueSizeBytes = impl ? sizeof(impl.cache) : 0;\n\t\tconst subscriberCount = impl ? impl._sinkCount : 0;\n\t\tconst depCount = nodeDesc.deps?.length ?? 0;\n\n\t\tconst isOrphanEffect = nodeDesc.type === \"effect\" && subscriberCount === 0;\n\t\tconst orphanKind: NodeProfile[\"orphanKind\"] =\n\t\t\tsubscriberCount === 0\n\t\t\t\t? nodeDesc.type === \"effect\"\n\t\t\t\t\t? \"orphan-effect\"\n\t\t\t\t\t: nodeDesc.type === \"derived\"\n\t\t\t\t\t\t? \"idle-derived\"\n\t\t\t\t\t\t: nodeDesc.type === \"producer\"\n\t\t\t\t\t\t\t? \"idle-producer\"\n\t\t\t\t\t\t\t: null\n\t\t\t\t: null;\n\n\t\tprofiles.push({\n\t\t\tpath,\n\t\t\ttype: nodeDesc.type,\n\t\t\tstatus: nodeDesc.status ?? \"unknown\",\n\t\t\tvalueSizeBytes,\n\t\t\tsubscriberCount,\n\t\t\tdepCount,\n\t\t\tisOrphanEffect,\n\t\t\torphanKind,\n\t\t});\n\t}\n\n\tconst totalValueSizeBytes = profiles.reduce((sum, p) => sum + p.valueSizeBytes, 0);\n\n\tconst topBy = <K extends keyof NodeProfile>(\n\t\tkey: K,\n\t\tcmp?: (a: NodeProfile, b: NodeProfile) => number,\n\t): NodeProfile[] =>\n\t\t[...profiles].sort(cmp ?? ((a, b) => (b[key] as number) - (a[key] as number))).slice(0, topN);\n\n\tconst orphans = profiles.filter((p) => p.orphanKind != null);\n\tconst orphanEffects = profiles.filter((p) => p.isOrphanEffect);\n\n\treturn {\n\t\tnodeCount: profiles.length,\n\t\tedgeCount: desc.edges.length,\n\t\tsubgraphCount: desc.subgraphs.length,\n\t\tnodes: profiles,\n\t\ttotalValueSizeBytes,\n\t\thotspots: {\n\t\t\tbyValueSize: topBy(\"valueSizeBytes\"),\n\t\t\tbySubscriberCount: topBy(\"subscriberCount\"),\n\t\t\tbyDepCount: topBy(\"depCount\"),\n\t\t},\n\t\torphans,\n\t\torphanEffects,\n\t};\n}\n","import type { Actor } from \"../core/actor.js\";\nimport { batch, isBatching } from \"../core/batch.js\";\nimport { monotonicNs, wallClockNs } from \"../core/clock.js\";\nimport type { GraphReFlyConfig } from \"../core/config.js\";\nimport { GuardDenied } from \"../core/guard.js\";\nimport {\n\tCOMPLETE,\n\tDATA,\n\tDIRTY,\n\tERROR,\n\tINVALIDATE,\n\ttype Messages,\n\tPAUSE,\n\tRESOLVED,\n\tRESUME,\n\tTEARDOWN,\n} from \"../core/messages.js\";\nimport {\n\ttype DescribeDetail,\n\ttype DescribeField,\n\ttype DescribeNodeOutput,\n\tdescribeNode,\n\tresolveDescribeFields,\n} from \"../core/meta.js\";\nimport {\n\tdefaultConfig,\n\ttype Node,\n\tNodeImpl,\n\ttype NodeSink,\n\ttype NodeTransportOptions,\n} from \"../core/node.js\";\nimport { producer, state as stateNode } from \"../core/sugar.js\";\nimport type { VersioningLevel } from \"../core/versioning.js\";\nimport type { StorageHandle, StorageTier } from \"../extra/storage.js\";\nimport { ResettableTimer } from \"../extra/timer.js\";\nimport { RingBuffer } from \"../extra/utils/ring-buffer.js\";\nimport { decodeEnvelope, encodeEnvelope, type GraphCodec } from \"./codec.js\";\nimport { type CausalChain, explainPath } from \"./explain.js\";\nimport { type GraphProfileOptions, type GraphProfileResult, graphProfile } from \"./profile.js\";\n\n/** The separator used for qualified paths in {@link Graph.resolve} et al. */\nconst PATH_SEP = \"::\";\n\n/**\n * Reserved segment for meta companion paths: `nodeName::__meta__::metaKey` (GRAPHREFLY-SPEC §3.6).\n * Forbidden as a local node or mount name.\n */\nexport const GRAPH_META_SEGMENT = \"__meta__\";\n\n/**\n * Options for {@link Graph}. Named fields documented below; the open index\n * signature is preserved so callers can stash extension data on the graph\n * without losing type discipline on the reserved names.\n *\n * - `config` — bind this graph to a specific {@link GraphReFlyConfig} for\n * tier/metaPassthrough/inspector lookups. Defaults to the singleton\n * `defaultConfig` exported from `core/node.ts`.\n * - `versioning` — convenience for `graph.setVersioning(level)` at\n * construction time. Monotonic bulk-apply; see {@link Graph.setVersioning}.\n * - `factories` — reserved for future per-graph factory registration;\n * currently factories flow through `Graph.fromSnapshot(data, {factories})`.\n */\nexport interface GraphOptions {\n\tconfig?: GraphReFlyConfig;\n\tversioning?: VersioningLevel;\n\tfactories?: Record<string, GraphNodeFactory>;\n\t/**\n\t * Capacity of the reasoning-trace ring buffer. Default: `1000`. Set lower\n\t * to reduce memory; higher for audit-heavy workloads. Set at construction\n\t * time — not mutable afterward (ring buffers can't resize cleanly).\n\t */\n\ttraceCapacity?: number;\n\t[key: string]: unknown;\n}\n\n/** Filter for {@link Graph.describe} — object-style partial match or predicate. */\nexport type DescribeFilter =\n\t| Partial<Pick<DescribeNodeOutput, \"type\" | \"status\">>\n\t| {\n\t\t\ttype?: DescribeNodeOutput[\"type\"];\n\t\t\tstatus?: DescribeNodeOutput[\"status\"];\n\t\t\t/** Keep nodes whose `deps` includes this qualified path. */\n\t\t\tdepsIncludes?: string;\n\t\t\t/** Snake-case alias for `depsIncludes` (Python parity). */\n\t\t\tdeps_includes?: string;\n\t\t\t/** Keep nodes whose `meta` contains this key. */\n\t\t\tmetaHas?: string;\n\t\t\t/** Snake-case alias for `metaHas` (Python parity). */\n\t\t\tmeta_has?: string;\n\t }\n\t| ((node: DescribeNodeOutput) => boolean)\n\t| ((nodePath: string, node: DescribeNodeOutput) => boolean);\n\n/** Options for {@link Graph.signal} and {@link Graph.set} (actor context, internal lifecycle). */\nexport type GraphActorOptions = {\n\tactor?: Actor;\n\t/**\n\t * When `true`, skips node guards (graph lifecycle TEARDOWN, unmount teardown, etc.).\n\t */\n\tinternal?: boolean;\n};\n\n/** Options for {@link Graph.describe} (Phase 3.3b progressive disclosure). */\nexport type GraphDescribeOptions = {\n\tactor?: Actor;\n\t/**\n\t * Node filter. Filters operate on whatever fields the chosen `detail` level\n\t * provides. For `metaHas` and `status` filters, use `detail: \"standard\"` or\n\t * higher — at `\"minimal\"` those fields are absent and the filter silently\n\t * excludes all nodes.\n\t */\n\tfilter?: DescribeFilter;\n\t/**\n\t * Detail level (Phase 3.3b). Default: `\"minimal\"`.\n\t * - `\"minimal\"` — type + deps only\n\t * - `\"standard\"` — type, status, value, deps, meta, versioning (`v`)\n\t * - `\"full\"` — standard + guard, lastMutation\n\t */\n\tdetail?: DescribeDetail;\n\t/**\n\t * Explicit field selection (GraphQL-style). Overrides `detail` when provided.\n\t * Dotted paths like `\"meta.label\"` select specific meta keys.\n\t */\n\tfields?: DescribeField[];\n\t/**\n\t * Output format.\n\t * - `undefined` / omitted — return the full {@link GraphDescribeOutput} object.\n\t * - `\"spec\"` — GraphSpec input format (object; no status/value, deps as edges).\n\t * - `\"json\"` — stable JSON **text** with sorted keys.\n\t * - `\"pretty\"` — human-readable plaintext (optionally colorized; see\n\t * `colorize` / `indent` / `logger` / `includeEdges` / `includeSubgraphs`).\n\t * - `\"mermaid\"` — Mermaid flowchart text.\n\t * - `\"d2\"` — D2 diagram text.\n\t */\n\tformat?: \"spec\" | \"json\" | \"pretty\" | \"mermaid\" | \"d2\";\n\t/** Pretty/diagram render: direction for diagram formats (default `LR`). */\n\tdirection?: GraphDiagramDirection;\n\t/** Pretty/JSON render: indent (default 2 for JSON, ignored for pretty). */\n\tindent?: number;\n\t/** Pretty render: optional logger hook; fires with the rendered text before return. */\n\tlogger?: (text: string) => void;\n\t/** Pretty render: include an Edges section (default `true`). */\n\tincludeEdges?: boolean;\n\t/** Pretty render: include a Subgraphs section (default `true`). */\n\tincludeSubgraphs?: boolean;\n};\n\n/** JSON snapshot from {@link Graph.describe} (GRAPHREFLY-SPEC §3.6, Appendix B). */\nexport type GraphDescribeOutput = {\n\tname: string;\n\tnodes: Record<string, DescribeNodeOutput>;\n\tedges: ReadonlyArray<{ from: string; to: string }>;\n\tsubgraphs: string[];\n\t/**\n\t * Re-read the live graph with higher detail (Phase 3.3b).\n\t * Returns a new `GraphDescribeOutput`; the original remains a snapshot.\n\t * Present on live describe results; absent on deserialized snapshots.\n\t */\n\texpand?: (detailOrFields: DescribeDetail | DescribeField[]) => GraphDescribeOutput;\n};\n\n/**\n * Persisted graph snapshot: {@link GraphDescribeOutput} plus optional format version\n * ({@link Graph.snapshot}, {@link Graph.restore}, {@link Graph.fromSnapshot}, {@link Graph.toObject},\n * {@link Graph.toJSONString} — §3.8).\n */\nexport type GraphPersistSnapshot = GraphDescribeOutput & {\n\tversion?: number;\n};\n\nexport type GraphFactoryContext = {\n\tpath: string;\n\ttype: DescribeNodeOutput[\"type\"];\n\tvalue: unknown;\n\tmeta: Record<string, unknown>;\n\tdeps: readonly string[];\n\tresolvedDeps: readonly Node[];\n};\n\nexport type GraphNodeFactory = (name: string, context: GraphFactoryContext) => Node;\n\n/**\n * Checkpoint record shape passed to `StorageTier.save`. Written by\n * {@link Graph.attachStorage} per-tier according to each tier's\n * `compactEvery` cadence.\n *\n * `mode: \"full\"` → full snapshot. Baseline anchor emitted on the first save\n * and every `compactEvery`-th save thereafter. Sufficient to recover state\n * on its own without WAL replay.\n * `mode: \"diff\"` → delta payload only, relative to this tier's most recent\n * `\"full\"` baseline. Between compacts. Wire-efficient; requires WAL replay\n * over the preceding `\"full\"` record to reconstruct state.\n *\n * Every record includes `seq` (per-tier monotonic counter), `timestamp_ns`\n * (wall-clock at flush time), and `format_version` (envelope version for\n * cross-version WAL replay).\n */\nexport type GraphCheckpointRecord = {\n\tseq: number;\n\ttimestamp_ns: number;\n\tformat_version: number;\n} & ({ mode: \"full\"; snapshot: GraphPersistSnapshot } | { mode: \"diff\"; diff: GraphWALDiff });\n\n/** Options for {@link Graph.attachStorage}. */\nexport type GraphAttachStorageOptions = {\n\t/**\n\t * Before the first save, attempt to restore from the first tier whose\n\t * `load(graph.name)` hits. Runs asynchronously in the background for\n\t * async tiers; errors surface via `onError`. Default `false`.\n\t */\n\tautoRestore?: boolean;\n\t/**\n\t * Limit the subscription surface (scoped observe). By default\n\t * `attachStorage` observes every node in the graph tree; on large graphs\n\t * that's thousands of subscriptions just for tier-gating. Pass a path\n\t * list (or a single glob) to observe only those nodes.\n\t */\n\tpaths?: readonly string[] | string;\n\t/** Pre-save path-level filter — skip records triggered by paths that fail this predicate. */\n\tfilter?: (name: string, described: DescribeNodeOutput) => boolean;\n\t/** Surfaced on tier save errors and autoRestore failures. */\n\tonError?: (error: unknown, tier: StorageTier) => void;\n};\n\n/**\n * Event emitted by {@link Graph.topology} on every structural change to the\n * graph's own registry. Does NOT include value mutations (use `observe()` for\n * those) or transitively nested subgraph events (subscribe to each mounted\n * child's `topology` for that).\n *\n * - `\"added\"` — `name` is the local key registered via {@link Graph.add}\n * (`nodeKind: \"node\"`) or {@link Graph.mount} (`nodeKind: \"mount\"`).\n * - `\"removed\"` — emitted AFTER {@link Graph.remove} completes teardown.\n * `audit` is the full {@link GraphRemoveAudit} returned to the caller.\n */\nexport type TopologyEvent =\n\t| { kind: \"added\"; name: string; nodeKind: \"node\" | \"mount\" }\n\t| {\n\t\t\tkind: \"removed\";\n\t\t\tname: string;\n\t\t\tnodeKind: \"node\" | \"mount\";\n\t\t\taudit: GraphRemoveAudit;\n\t };\n\n/** Direction options for diagram export helpers. */\nexport type GraphDiagramDirection = \"TD\" | \"LR\" | \"BT\" | \"RL\";\n\n/** Options for {@link Graph.toMermaid} / {@link Graph.toD2}. */\nexport type GraphDiagramOptions = {\n\t/**\n\t * Diagram flow direction.\n\t * - `TD`: top-down\n\t * - `LR`: left-right (default)\n\t * - `BT`: bottom-top\n\t * - `RL`: right-left\n\t */\n\tdirection?: GraphDiagramDirection;\n};\n\n/**\n * Snapshot format version (§3.8). Exported so the surface layer's\n * `saveSnapshot` writes the same `format_version` as\n * `Graph.attachStorage` — one source of truth prevents silent wire\n * drift between auto-checkpoint and one-shot persistence paths.\n */\nexport const SNAPSHOT_VERSION = 1;\n\n/**\n * Drain a disposer set iteratively — pop, remove, run. Disposers registered\n * mid-drain are picked up by the next iteration. Capped to guard against a\n * disposer that re-registers itself in an infinite loop. Exceptions are\n * surfaced via `console.error` rather than silently swallowed so leaks in\n * cleanup code remain visible.\n */\nfunction drainDisposers(set: Set<() => void>, graphName: string): void {\n\tconst cap = Math.max(16, set.size * 4);\n\tlet iterations = 0;\n\twhile (set.size > 0) {\n\t\tif (iterations++ >= cap) {\n\t\t\tconsole.error(\n\t\t\t\t`[Graph \"${graphName}\".destroy] disposer drain exceeded cap (${cap}); ${set.size} disposer(s) discarded`,\n\t\t\t);\n\t\t\tset.clear();\n\t\t\treturn;\n\t\t}\n\t\tconst it = set.values().next();\n\t\tif (it.done) return;\n\t\tconst dispose = it.value;\n\t\tset.delete(dispose);\n\t\ttry {\n\t\t\tdispose();\n\t\t} catch (err) {\n\t\t\tconsole.error(`[Graph \"${graphName}\".destroy] disposer threw:`, err);\n\t\t}\n\t}\n}\n\n/**\n * Cheap graph-level V0 version fingerprint: concatenate `v.id@v.version` for\n * every node that carries V0 info. Used by {@link Graph.attachStorage} to\n * short-circuit per-tier flushes when nothing versioned has changed since\n * the tier's last save. Non-versioned graphs produce an empty string so the\n * shortcut is a no-op for them (every scheduled flush writes).\n */\nfunction computeVersionFingerprint(nodes: Record<string, DescribeNodeOutput>): string {\n\tconst parts: string[] = [];\n\tfor (const path of Object.keys(nodes).sort()) {\n\t\tconst v = nodes[path]!.v;\n\t\tif (v != null) parts.push(`${path}\\t${v.id}\\t${v.version}`);\n\t}\n\treturn parts.join(\"\\n\");\n}\n\n/**\n * Validate the snapshot envelope: version, required keys, types. Aligned with\n * Python `_parse_snapshot_envelope`. Throws on invalid data.\n */\nfunction parseSnapshotEnvelope(data: GraphPersistSnapshot): void {\n\tif (data.version !== SNAPSHOT_VERSION) {\n\t\tthrow new Error(\n\t\t\t`unsupported snapshot version ${String(data.version)} (expected ${SNAPSHOT_VERSION})`,\n\t\t);\n\t}\n\tfor (const key of [\"name\", \"nodes\", \"edges\", \"subgraphs\"] as const) {\n\t\tif (!(key in data)) {\n\t\t\tthrow new Error(`snapshot missing required key \"${key}\"`);\n\t\t}\n\t}\n\tif (typeof data.name !== \"string\") {\n\t\tthrow new TypeError(`snapshot 'name' must be a string`);\n\t}\n\tif (typeof data.nodes !== \"object\" || data.nodes === null || Array.isArray(data.nodes)) {\n\t\tthrow new TypeError(`snapshot 'nodes' must be an object`);\n\t}\n\tif (!Array.isArray(data.edges)) {\n\t\tthrow new TypeError(`snapshot 'edges' must be an array`);\n\t}\n\tif (!Array.isArray(data.subgraphs)) {\n\t\tthrow new TypeError(`snapshot 'subgraphs' must be an array`);\n\t}\n}\n\n/**\n * Structural deep equality — handles cycles, BigInt, Map, Set, Date, RegExp,\n * TypedArray, and nested objects/arrays. Used by `Graph.diff` to compare\n * node values without the cycle/BigInt/Map/Set footguns of `JSON.stringify`.\n *\n * Semantics: `Object.is` on primitives (so `NaN === NaN`, `-0 !== 0`), same\n * constructor required for object types, key-order-insensitive for plain\n * objects, order-sensitive for arrays + TypedArrays, unordered for Set,\n * key-equality for Map.\n */\nfunction deepEqual(a: unknown, b: unknown): boolean {\n\tconst seen = new WeakMap<object, WeakSet<object>>();\n\tconst walk = (x: unknown, y: unknown): boolean => {\n\t\tif (Object.is(x, y)) return true;\n\t\tif (x == null || y == null || typeof x !== \"object\" || typeof y !== \"object\") return false;\n\t\t// Cycle handling: assume equal on re-encounter (cycles match iff they\n\t\t// correspond structurally — standard \"optimistic\" deep-equal rule).\n\t\tlet seenRhs = seen.get(x as object);\n\t\tif (seenRhs == null) {\n\t\t\tseenRhs = new WeakSet();\n\t\t\tseen.set(x as object, seenRhs);\n\t\t}\n\t\tif (seenRhs.has(y as object)) return true;\n\t\tseenRhs.add(y as object);\n\n\t\tconst ctorA = (x as object).constructor;\n\t\tconst ctorB = (y as object).constructor;\n\t\tif (ctorA !== ctorB) return false;\n\n\t\tif (x instanceof Date) return (x as Date).getTime() === (y as Date).getTime();\n\t\tif (x instanceof RegExp)\n\t\t\treturn (\n\t\t\t\t(x as RegExp).source === (y as RegExp).source && (x as RegExp).flags === (y as RegExp).flags\n\t\t\t);\n\t\tif (Array.isArray(x)) {\n\t\t\tconst arrB = y as unknown[];\n\t\t\tif ((x as unknown[]).length !== arrB.length) return false;\n\t\t\tfor (let i = 0; i < (x as unknown[]).length; i++) {\n\t\t\t\tif (!walk((x as unknown[])[i], arrB[i])) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\tif (x instanceof Map) {\n\t\t\tconst mB = y as Map<unknown, unknown>;\n\t\t\tif ((x as Map<unknown, unknown>).size !== mB.size) return false;\n\t\t\tfor (const [k, v] of x as Map<unknown, unknown>) {\n\t\t\t\tif (!mB.has(k) || !walk(v, mB.get(k))) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\tif (x instanceof Set) {\n\t\t\tconst sB = y as Set<unknown>;\n\t\t\tif ((x as Set<unknown>).size !== sB.size) return false;\n\t\t\t// O(n²) fallback — Sets have no ordering, and walking each pair\n\t\t\t// is the only way to support structural equality on non-primitive\n\t\t\t// members. Acceptable: diff scale is describe-output-sized.\n\t\t\tfor (const v of x as Set<unknown>) {\n\t\t\t\tlet found = false;\n\t\t\t\tfor (const w of sB) {\n\t\t\t\t\tif (walk(v, w)) {\n\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!found) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\tif (ArrayBuffer.isView(x)) {\n\t\t\tconst taA = x as unknown as { length: number; [i: number]: number };\n\t\t\tconst taB = y as unknown as { length: number; [i: number]: number };\n\t\t\tif (taA.length !== taB.length) return false;\n\t\t\tfor (let i = 0; i < taA.length; i++) if (taA[i] !== taB[i]) return false;\n\t\t\treturn true;\n\t\t}\n\t\t// Plain object: same key-set, same values (key order irrelevant).\n\t\tconst keysA = Object.keys(x as Record<string, unknown>);\n\t\tconst keysB = Object.keys(y as Record<string, unknown>);\n\t\tif (keysA.length !== keysB.length) return false;\n\t\tconst setB = new Set(keysB);\n\t\tfor (const k of keysA) {\n\t\t\tif (!setB.has(k)) return false;\n\t\t\tif (!walk((x as Record<string, unknown>)[k], (y as Record<string, unknown>)[k])) return false;\n\t\t}\n\t\treturn true;\n\t};\n\treturn walk(a, b);\n}\n\n/** Recursively sort object keys for deterministic JSON (git-diffable). */\nfunction sortJsonValue(value: unknown): unknown {\n\tif (value === null || typeof value !== \"object\") {\n\t\treturn value;\n\t}\n\tif (Array.isArray(value)) {\n\t\treturn value.map(sortJsonValue);\n\t}\n\tconst obj = value as Record<string, unknown>;\n\tconst keys = Object.keys(obj).sort();\n\tconst out: Record<string, unknown> = {};\n\tfor (const k of keys) {\n\t\tout[k] = sortJsonValue(obj[k]);\n\t}\n\treturn out;\n}\n\nfunction escapeMermaidLabel(value: string): string {\n\treturn value.replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll('\"', '\\\\\"');\n}\n\nfunction escapeD2Label(value: string): string {\n\treturn value.replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll('\"', '\\\\\"');\n}\n\nfunction d2DirectionFromGraphDirection(direction: GraphDiagramDirection): string {\n\tif (direction === \"TD\") return \"down\";\n\tif (direction === \"BT\") return \"up\";\n\tif (direction === \"RL\") return \"left\";\n\treturn \"right\";\n}\n\n/** Collect deduplicated (from, to) arrows from deps + edges. */\nfunction collectDiagramArrows(described: GraphDescribeOutput): [string, string][] {\n\tconst seen = new Set<string>();\n\tconst arrows: [string, string][] = [];\n\tfunction add(from: string, to: string): void {\n\t\tconst key = `${from}\\0${to}`;\n\t\tif (seen.has(key)) return;\n\t\tseen.add(key);\n\t\tarrows.push([from, to]);\n\t}\n\tfor (const [path, info] of Object.entries(described.nodes)) {\n\t\tconst deps: string[] | undefined = (info as Record<string, unknown>).deps as\n\t\t\t| string[]\n\t\t\t| undefined;\n\t\tif (deps) {\n\t\t\tfor (const dep of deps) add(dep, path);\n\t\t}\n\t}\n\tfor (const edge of described.edges) add(edge.from, edge.to);\n\treturn arrows;\n}\n\nfunction normalizeDiagramDirection(direction: unknown): GraphDiagramDirection {\n\tif (direction === undefined) return \"LR\";\n\tif (direction === \"TD\" || direction === \"LR\" || direction === \"BT\" || direction === \"RL\") {\n\t\treturn direction;\n\t}\n\tthrow new Error(\n\t\t`invalid diagram direction ${String(direction)}; expected one of: TD, LR, BT, RL`,\n\t);\n}\n\n// ---------------------------------------------------------------------------\n// describe({format}) renderers — consolidated from the ex-dumpGraph /\n// ex-toMermaid / ex-toD2 methods (Unit 12 + Unit 20).\n// ---------------------------------------------------------------------------\n\nfunction renderDescribeAsJson(d: GraphDescribeOutput, options: GraphDescribeOptions): string {\n\tconst includeEdges = options.includeEdges ?? true;\n\tconst includeSubgraphs = options.includeSubgraphs ?? true;\n\tconst { expand: _expand, ...rest } = d;\n\tconst payload: GraphDescribeOutput = {\n\t\t...rest,\n\t\tedges: includeEdges ? d.edges : [],\n\t\tsubgraphs: includeSubgraphs ? d.subgraphs : [],\n\t};\n\tconst text = JSON.stringify(sortJsonValue(payload), null, options.indent ?? 2);\n\toptions.logger?.(text);\n\treturn text;\n}\n\nfunction renderDescribeAsPretty(d: GraphDescribeOutput, options: GraphDescribeOptions): string {\n\tconst includeEdges = options.includeEdges ?? true;\n\tconst includeSubgraphs = options.includeSubgraphs ?? true;\n\tconst lines: string[] = [];\n\tlines.push(`Graph ${d.name}`);\n\tlines.push(\"Nodes:\");\n\tfor (const path of Object.keys(d.nodes).sort()) {\n\t\tconst n = d.nodes[path]!;\n\t\tlines.push(`- ${path} (${n.type}/${n.status}): ${describeData(n.value)}`);\n\t}\n\tif (includeEdges) {\n\t\tlines.push(\"Edges:\");\n\t\tfor (const edge of d.edges) {\n\t\t\tlines.push(`- ${edge.from} -> ${edge.to}`);\n\t\t}\n\t}\n\tif (includeSubgraphs) {\n\t\tlines.push(\"Subgraphs:\");\n\t\tfor (const sg of d.subgraphs) {\n\t\t\tlines.push(`- ${sg}`);\n\t\t}\n\t}\n\tconst text = lines.join(\"\\n\");\n\toptions.logger?.(text);\n\treturn text;\n}\n\nfunction renderDescribeAsMermaid(d: GraphDescribeOutput, options: GraphDescribeOptions): string {\n\tconst direction = normalizeDiagramDirection(options.direction);\n\tconst paths = Object.keys(d.nodes).sort();\n\tconst ids = new Map<string, string>();\n\tfor (let i = 0; i < paths.length; i += 1) ids.set(paths[i]!, `n${i}`);\n\tconst lines: string[] = [`flowchart ${direction}`];\n\tfor (const path of paths) {\n\t\tconst id = ids.get(path)!;\n\t\tlines.push(` ${id}[\"${escapeMermaidLabel(path)}\"]`);\n\t}\n\tfor (const [from, to] of collectDiagramArrows(d)) {\n\t\tconst fromId = ids.get(from);\n\t\tconst toId = ids.get(to);\n\t\tif (!fromId || !toId) continue;\n\t\tlines.push(` ${fromId} --> ${toId}`);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\nfunction renderDescribeAsD2(d: GraphDescribeOutput, options: GraphDescribeOptions): string {\n\tconst direction = normalizeDiagramDirection(options.direction);\n\tconst paths = Object.keys(d.nodes).sort();\n\tconst ids = new Map<string, string>();\n\tfor (let i = 0; i < paths.length; i += 1) ids.set(paths[i]!, `n${i}`);\n\tconst lines: string[] = [`direction: ${d2DirectionFromGraphDirection(direction)}`];\n\tfor (const path of paths) {\n\t\tconst id = ids.get(path)!;\n\t\tlines.push(`${id}: \"${escapeD2Label(path)}\"`);\n\t}\n\tfor (const [from, to] of collectDiagramArrows(d)) {\n\t\tconst fromId = ids.get(from);\n\t\tconst toId = ids.get(to);\n\t\tif (!fromId || !toId) continue;\n\t\tlines.push(`${fromId} -> ${toId}`);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\nfunction escapeRegexLiteral(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction globToRegex(pattern: string): RegExp {\n\tlet re = \"^\";\n\tfor (let i = 0; i < pattern.length; i += 1) {\n\t\tconst ch = pattern[i]!;\n\t\tif (ch === \"*\") {\n\t\t\tre += \".*\";\n\t\t\tcontinue;\n\t\t}\n\t\tif (ch === \"?\") {\n\t\t\tre += \".\";\n\t\t\tcontinue;\n\t\t}\n\t\tif (ch === \"[\") {\n\t\t\tconst end = pattern.indexOf(\"]\", i + 1);\n\t\t\tif (end <= i + 1) {\n\t\t\t\tre += \"\\\\[\";\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet cls = pattern.slice(i + 1, end);\n\t\t\tif (cls.startsWith(\"!\")) cls = `^${cls.slice(1)}`;\n\t\t\tcls = cls.replace(/\\\\/g, \"\\\\\\\\\");\n\t\t\tre += `[${cls}]`;\n\t\t\ti = end;\n\t\t\tcontinue;\n\t\t}\n\t\tre += escapeRegexLiteral(ch);\n\t}\n\tre += \"$\";\n\treturn new RegExp(re);\n}\n\nconst OBSERVE_ANSI_THEME: Required<ObserveTheme> = {\n\tdata: \"\\u001b[32m\",\n\tdirty: \"\\u001b[33m\",\n\tresolved: \"\\u001b[36m\",\n\tinvalidate: \"\\u001b[93m\",\n\tpause: \"\\u001b[90m\",\n\tresume: \"\\u001b[96m\",\n\tcomplete: \"\\u001b[34m\",\n\terror: \"\\u001b[31m\",\n\tteardown: \"\\u001b[91m\",\n\tderived: \"\\u001b[35m\",\n\tpath: \"\\u001b[90m\",\n\treset: \"\\u001b[0m\",\n};\n\nconst OBSERVE_NO_COLOR_THEME: Required<ObserveTheme> = {\n\tdata: \"\",\n\tdirty: \"\",\n\tresolved: \"\",\n\tinvalidate: \"\",\n\tpause: \"\",\n\tresume: \"\",\n\tcomplete: \"\",\n\terror: \"\",\n\tteardown: \"\",\n\tderived: \"\",\n\tpath: \"\",\n\treset: \"\",\n};\n\nfunction describeData(value: unknown): string {\n\tif (typeof value === \"string\") return JSON.stringify(value);\n\tif (typeof value === \"number\" || typeof value === \"boolean\" || value == null)\n\t\treturn String(value);\n\ttry {\n\t\treturn JSON.stringify(value);\n\t} catch {\n\t\treturn \"[unserializable]\";\n\t}\n}\n\nfunction resolveObserveTheme(theme: ObserveOptions[\"theme\"]): Required<ObserveTheme> {\n\tif (theme === \"none\") return OBSERVE_NO_COLOR_THEME;\n\tif (theme === \"ansi\" || theme == null) return OBSERVE_ANSI_THEME;\n\treturn {\n\t\tdata: theme.data ?? \"\",\n\t\tdirty: theme.dirty ?? \"\",\n\t\tresolved: theme.resolved ?? \"\",\n\t\tinvalidate: theme.invalidate ?? \"\",\n\t\tpause: theme.pause ?? \"\",\n\t\tresume: theme.resume ?? \"\",\n\t\tcomplete: theme.complete ?? \"\",\n\t\terror: theme.error ?? \"\",\n\t\tteardown: theme.teardown ?? \"\",\n\t\tderived: theme.derived ?? \"\",\n\t\tpath: theme.path ?? \"\",\n\t\treset: theme.reset ?? \"\",\n\t};\n}\n\n/** Resolve observe `detail` level into effective boolean flags. */\nfunction resolveObserveDetail(opts?: ObserveOptions): ObserveOptions {\n\tif (opts == null) return {};\n\tconst detail = opts.detail;\n\tif (detail === \"full\") {\n\t\treturn {\n\t\t\t...opts,\n\t\t\tstructured: opts.structured ?? true,\n\t\t\ttimeline: opts.timeline ?? true,\n\t\t\tcausal: opts.causal ?? true,\n\t\t\tderived: opts.derived ?? true,\n\t\t};\n\t}\n\tif (detail === \"minimal\") {\n\t\treturn { ...opts, structured: opts.structured ?? true };\n\t}\n\treturn opts;\n}\n\n/**\n * Option shapes that trigger structured-mode dispatch in {@link Graph.observe}.\n * Presence of any of these fields (truthy) → returns {@link ObserveResult};\n * otherwise `observe()` returns the raw-stream variants.\n */\nexport type StructuredTriggers = {\n\tstructured?: true;\n\ttimeline?: true;\n\tcausal?: true;\n\tderived?: true;\n\tformat?: \"pretty\" | \"json\";\n\tdetail?: \"minimal\" | \"full\";\n};\n\n/** {@link Graph.observe} on a single node or meta path — sink receives plain message batches. */\nexport type GraphObserveOne = {\n\tsubscribe(sink: NodeSink): () => void;\n\t/** Send messages upstream toward the observed node's sources (e.g. PAUSE/RESUME). */\n\tup(messages: Messages): void;\n};\n\n/**\n * {@link Graph.observe} on the whole graph — sink receives each batch with the qualified source path.\n * Subscription order follows code-point sort on paths (mounts-first walk, then sorted locals/meta).\n */\nexport type GraphObserveAll = {\n\tsubscribe(sink: (nodePath: string, messages: Messages) => void): () => void;\n\t/** Send messages upstream toward a specific observed node's sources (e.g. PAUSE/RESUME). */\n\tup(path: string, messages: Messages): void;\n};\n\n/**\n * Detail level for `observe()` progressive disclosure (Phase 3.3b).\n * - `\"minimal\"` — DATA events only, no timestamps, no causal info.\n * - `\"standard\"` — all message types (DATA, DIRTY, RESOLVED, INVALIDATE,\n * PAUSE, RESUME, COMPLETE, ERROR, TEARDOWN).\n * - `\"full\"` — standard + timeline + causal + derived.\n */\nexport type ObserveDetail = \"minimal\" | \"standard\" | \"full\";\n\n/** Options for structured observation modes on {@link Graph.observe}. */\nexport type ObserveOptions = {\n\tactor?: Actor;\n\t/** Return an {@link ObserveResult} accumulator instead of a raw stream. */\n\tstructured?: boolean;\n\t/** Include causal trace info (which dep triggered each recomputation). */\n\tcausal?: boolean;\n\t/** Include timestamps and batch context on each event. */\n\ttimeline?: boolean;\n\t/** Include per-evaluation dep snapshots for compute/derived nodes. */\n\tderived?: boolean;\n\t/**\n\t * Detail level (Phase 3.3b). Individual flags (`causal`, `timeline`, `derived`)\n\t * override. `\"full\"` implies all three plus structured.\n\t * `\"minimal\"` filters to DATA-only events.\n\t */\n\tdetail?: ObserveDetail;\n\n\t// ——— Format / logging (merged from spy) ———\n\n\t/**\n\t * When set, auto-enables structured mode and attaches a logger.\n\t * `\"pretty\"` renders colored one-line output; `\"json\"` emits one JSON object per event.\n\t */\n\tformat?: \"pretty\" | \"json\";\n\t/** Sink for rendered lines (`console.log` by default). Only used when `format` is set. */\n\tlogger?: (line: string, event: ObserveEvent) => void;\n\t/** Keep only these event types in formatted output. Only used when `format` is set. */\n\tincludeTypes?: ObserveEvent[\"type\"][];\n\t/** Exclude these event types from formatted output. Only used when `format` is set. */\n\texcludeTypes?: ObserveEvent[\"type\"][];\n\t/** Built-in color preset (`ansi` default) or explicit color tokens. Only used when `format` is set. */\n\ttheme?: ObserveThemeName | ObserveTheme;\n\t/**\n\t * Cap the `events` buffer. When set, the result uses a {@link RingBuffer}\n\t * under the hood: oldest events are dropped on overflow. Unbounded when\n\t * omitted (default).\n\t */\n\tmaxEvents?: number;\n};\n\n/** Accumulated observation result (structured mode). */\nexport type ObserveResult<T = unknown> = AsyncIterable<ObserveEvent> & {\n\t/** Latest DATA value by observed path. */\n\treadonly values: Record<string, T>;\n\t/** Number of DIRTY messages received. */\n\treadonly dirtyCount: number;\n\t/** Number of RESOLVED messages received. */\n\treadonly resolvedCount: number;\n\t/** Number of INVALIDATE messages received (tier 1 cache-clear). */\n\treadonly invalidateCount: number;\n\t/** Number of PAUSE messages received (tier 2 backpressure). */\n\treadonly pauseCount: number;\n\t/** Number of RESUME messages received (tier 2 backpressure). */\n\treadonly resumeCount: number;\n\t/** Number of TEARDOWN messages received (tier 5 permanent cleanup). */\n\treadonly teardownCount: number;\n\t/**\n\t * All events in order — ring-buffered when `options.maxEvents` is set,\n\t * unbounded otherwise. Always materialized as an `ObserveEvent[]`\n\t * snapshot on read.\n\t */\n\treadonly events: ObserveEvent[];\n\t/** True if any observed node sent COMPLETE without prior ERROR on that node. */\n\treadonly anyCompletedCleanly: boolean;\n\t/** True if any observed node sent ERROR. */\n\treadonly anyErrored: boolean;\n\t/** True if at least one COMPLETE received and no ERROR from any observed node. */\n\treadonly completedWithoutErrors: boolean;\n\t/**\n\t * Attach a live listener that fires for each event as it arrives.\n\t * Returns an unsubscribe fn. Independent of the `events` buffer.\n\t */\n\tonEvent(listener: (event: ObserveEvent) => void): () => void;\n\t/** Stop observing. */\n\tdispose(): void;\n\t/**\n\t * Resubscribe with higher detail (Phase 3.3b).\n\t * Disposes current observation, returns new `ObserveResult` with merged options.\n\t */\n\texpand(\n\t\textra: Partial<Pick<ObserveOptions, \"causal\" | \"timeline\" | \"derived\">> | ObserveDetail,\n\t): ObserveResult<T>;\n};\n\n/** Fields common to every {@link ObserveEvent} variant. */\nexport interface ObserveEventBase {\n\tpath?: string;\n\t/** Optional `timeline` context — wall-clock when `options.timeline === true`. */\n\ttimestamp_ns?: number;\n\tin_batch?: boolean;\n\t/** Monotonically increasing counter per subscribe-callback invocation. All events in one delivery share the same id. */\n\tbatch_id?: number;\n}\n\n/** Optional `causal` context present on `data`/`resolved`/`derived` events. */\nexport interface ObserveCausalContext {\n\ttrigger_dep_index?: number;\n\ttrigger_dep_name?: string;\n\t/**\n\t * V0 version of the triggering dep at observation time (§6.0b).\n\t * This is the dep's post-emission version (after its own `advanceVersion`),\n\t * not the pre-emission version that caused this node's recomputation.\n\t */\n\ttrigger_version?: { id: string; version: number };\n\t/**\n\t * One scalar per dep: the last value that arrived in the current wave,\n\t * or the pre-wave cached value for deps that didn't fire. Convenient\n\t * for single-value-wave tooling (the common case).\n\t */\n\tdep_values?: unknown[];\n\t/**\n\t * Full per-dep batches for the wave that fired the fn — `dep_batches[i]`\n\t * is the array of values dep `i` delivered this wave (`undefined` for\n\t * deps that didn't fire). Use this to distinguish a single-value wave\n\t * from a multi-value wave; `dep_values` compresses each batch to its\n\t * last element and hides that difference.\n\t */\n\tdep_batches?: ReadonlyArray<ReadonlyArray<unknown> | undefined>;\n}\n\n/** A single event in the structured observation log (discriminated on `type`). */\nexport type ObserveEvent =\n\t| (ObserveEventBase & ObserveCausalContext & { type: \"data\"; data: unknown })\n\t| (ObserveEventBase & { type: \"dirty\" })\n\t| (ObserveEventBase & ObserveCausalContext & { type: \"resolved\" })\n\t| (ObserveEventBase & { type: \"invalidate\" })\n\t| (ObserveEventBase & { type: \"pause\"; lockId: unknown })\n\t| (ObserveEventBase & { type: \"resume\"; lockId: unknown })\n\t| (ObserveEventBase & { type: \"complete\" })\n\t| (ObserveEventBase & { type: \"error\"; data: unknown })\n\t| (ObserveEventBase & { type: \"teardown\" })\n\t| (ObserveEventBase & ObserveCausalContext & { type: \"derived\"; dep_values: unknown[] });\n\n/** Built-in color preset names for observe `format` rendering. */\nexport type ObserveThemeName = \"none\" | \"ansi\";\n\n/** ANSI/style overrides for observe `format` event rendering. */\nexport type ObserveTheme = Partial<Record<ObserveEvent[\"type\"] | \"path\" | \"reset\", string>>;\n\n/**\n * Reject characters that would collide with internal serialization or path\n * grammar. Control chars (0x00–0x1F, 0x7F) break `describe()` key stability,\n * diagram rendering, and any tab-delimited log/trace format. Keep the test\n * tight so the error message points at the first offending code point.\n */\nfunction assertNoControlChars(name: string, graphName: string, label: string): void {\n\tfor (let i = 0; i < name.length; i++) {\n\t\tconst c = name.charCodeAt(i);\n\t\tif (c < 0x20 || c === 0x7f) {\n\t\t\tthrow new Error(\n\t\t\t\t`Graph \"${graphName}\": ${label} \"${name}\" must not contain control character (U+${c.toString(16).padStart(4, \"0\").toUpperCase()} at index ${i})`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * Validate a registerable local name (`add`, `mount`, `remove` inputs):\n * non-empty, no `::` separator, not the reserved `__meta__` segment, and no\n * control characters.\n */\nfunction assertRegisterableName(name: string, graphName: string, label: string): void {\n\tif (name === \"\") {\n\t\tthrow new Error(`Graph \"${graphName}\": ${label} name must be non-empty`);\n\t}\n\tif (name.includes(PATH_SEP)) {\n\t\tthrow new Error(\n\t\t\t`Graph \"${graphName}\": ${label} \"${name}\" must not contain '${PATH_SEP}' (path separator)`,\n\t\t);\n\t}\n\tif (name === GRAPH_META_SEGMENT) {\n\t\tthrow new Error(\n\t\t\t`Graph \"${graphName}\": ${label} name \"${GRAPH_META_SEGMENT}\" is reserved for meta companion paths`,\n\t\t);\n\t}\n\tassertNoControlChars(name, graphName, label);\n}\n\nfunction splitPath(path: string, graphName: string): string[] {\n\tif (path === \"\") {\n\t\tthrow new Error(`Graph \"${graphName}\": resolve path must be non-empty`);\n\t}\n\tconst segments = path.split(PATH_SEP);\n\tfor (const s of segments) {\n\t\tif (s === \"\") {\n\t\t\tthrow new Error(`Graph \"${graphName}\": resolve path has empty segment`);\n\t\t}\n\t}\n\treturn segments;\n}\n\n/**\n * Strip messages that are not marked `metaPassthrough` on the given config\n * (spec §2.3 Companion lifecycle). Built-ins: `INVALIDATE`, `COMPLETE`,\n * `ERROR`, `TEARDOWN` are registered `metaPassthrough: false` in\n * `registerBuiltins`. Custom types default to `true` (meta receives them).\n *\n * To target a meta node directly without the filter, call `meta.down(...)`.\n *\n * Returns empty array when nothing remains.\n */\nfunction filterMetaMessages(messages: Messages, config: GraphReFlyConfig): Messages {\n\t// Fast path: if every message is metaPassthrough, reuse the input array.\n\tlet anyFiltered = false;\n\tfor (const m of messages) {\n\t\tif (!config.isMetaPassthrough(m[0])) {\n\t\t\tanyFiltered = true;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (!anyFiltered) return messages;\n\tconst kept = messages.filter((m) => config.isMetaPassthrough(m[0]));\n\treturn kept as unknown as Messages;\n}\n\n/**\n * TEARDOWN every node in a mounted graph tree (depth-first into mounts).\n * Errors from individual node teardowns are swallowed — a single bad handler\n * must not abort cleanup of the rest of the subtree.\n */\nfunction teardownMountedGraph(root: Graph): void {\n\tfor (const child of root._mounts.values()) {\n\t\tteardownMountedGraph(child);\n\t}\n\tfor (const n of root._nodes.values()) {\n\t\ttry {\n\t\t\tn.down([[TEARDOWN]] satisfies Messages, { internal: true });\n\t\t} catch {\n\t\t\t/* resilience: keep tearing down siblings */\n\t\t}\n\t}\n}\n\n/**\n * Named container for nodes and explicit edges (GRAPHREFLY-SPEC §3.1–§3.7).\n *\n * Qualified paths use `::` as the segment separator (for example `parent::child::node`).\n *\n * Edges are pure wires: `connect` only validates wiring — the target must already list the source in\n * its dependency array; no transforms run on the edge.\n *\n * @example\n * ```ts\n * import { Graph, state } from \"@graphrefly/graphrefly-ts\";\n *\n * const g = new Graph(\"app\");\n * g.add(\"counter\", state(0));\n * ```\n *\n * @category graph\n */\nexport class Graph {\n\treadonly name: string;\n\treadonly opts: Readonly<GraphOptions>;\n\t/** Protocol config bound to this graph (defaults to `defaultConfig`). */\n\treadonly config: GraphReFlyConfig;\n\t/** @internal — exposed for {@link teardownMountedGraph} and cross-graph helpers. */\n\treadonly _nodes = new Map<string, Node>();\n\t/**\n\t * @internal Reverse lookup for duplicate-instance detection in\n\t * {@link Graph.add} — O(1) replacement for an O(n) scan of `_nodes`.\n\t * Weak so nodes can be GC'd after `remove()` even if a caller keeps the\n\t * map alive via some unusual pattern.\n\t */\n\tprivate readonly _nodeToName = new WeakMap<Node, string>();\n\t/** @internal — exposed for {@link teardownMountedGraph}. */\n\treadonly _mounts = new Map<string, Graph>();\n\t/**\n\t * @internal Parent graph if this instance is mounted. `undefined` when\n\t * this is the root or when the graph has been unmounted. Used for\n\t * reparenting rejection + O(depth) ancestor walks.\n\t */\n\t_parent: Graph | undefined = undefined;\n\tprivate readonly _storageDisposers = new Set<() => void>();\n\tprivate readonly _disposers = new Set<() => void>();\n\t/**\n\t * @internal Lazy `TopologyEvent` producer. Created on first `.topology`\n\t * access. Zero cost until something subscribes — producer fn only runs when\n\t * the first sink attaches, registering one handler into\n\t * {@link Graph._topologyEmitters}.\n\t */\n\tprivate _topology: Node<TopologyEvent> | undefined;\n\t/**\n\t * @internal Active emit handlers for the topology producer. Each entry is\n\t * the closure registered by the producer fn on activation; cleared on\n\t * deactivation. `_emitTopology` broadcasts through every entry (there is at\n\t * most one per activation cycle of the producer).\n\t */\n\tprivate readonly _topologyEmitters = new Set<(event: TopologyEvent) => void>();\n\n\t/**\n\t * @param name - Non-empty graph id (must not contain `::` and must not\n\t * equal the reserved meta segment `__meta__`).\n\t * @param opts - See {@link GraphOptions}. Stored frozen on the instance.\n\t */\n\tconstructor(name: string, opts?: GraphOptions) {\n\t\tif (name === \"\") {\n\t\t\tthrow new Error(\"Graph name must be non-empty\");\n\t\t}\n\t\tif (name.includes(PATH_SEP)) {\n\t\t\tthrow new Error(`Graph name must not contain '${PATH_SEP}' (got \"${name}\")`);\n\t\t}\n\t\tif (name === GRAPH_META_SEGMENT) {\n\t\t\tthrow new Error(`Graph name \"${GRAPH_META_SEGMENT}\" is reserved for meta companion paths`);\n\t\t}\n\t\tthis.name = name;\n\t\tthis.opts = Object.freeze({ ...(opts ?? {}) });\n\t\tthis.config = opts?.config ?? defaultConfig;\n\t\tthis._traceRing = new RingBuffer<TraceEntry>(opts?.traceCapacity ?? 1000);\n\t\tif (opts?.versioning != null) {\n\t\t\t// No nodes yet, but keep the API consistent — apply at construction\n\t\t\t// so opts.versioning is honored as a startup default via this helper.\n\t\t\tthis.setVersioning(opts.versioning);\n\t\t}\n\t}\n\n\t/**\n\t * Walk ancestors up through `_parent`. Returns the chain starting at this\n\t * instance, ending at the root (a graph with no parent). O(depth).\n\t *\n\t * @param includeSelf - Include `this` in the chain (default `true`).\n\t */\n\tancestors(includeSelf = true): Graph[] {\n\t\tconst out: Graph[] = [];\n\t\tlet p: Graph | undefined = includeSelf ? this : this._parent;\n\t\twhile (p != null) {\n\t\t\tout.push(p);\n\t\t\tp = p._parent;\n\t\t}\n\t\treturn out;\n\t}\n\n\t// ——————————————————————————————————————————————————————————————\n\t// Topology companion (structural-change event stream)\n\t// ——————————————————————————————————————————————————————————————\n\n\t/**\n\t * Reactive stream of structural changes to this graph's own registry\n\t * (add / mount / remove). Value mutations live on `observe()`; this\n\t * companion only fires when the topology shape changes.\n\t *\n\t * Lazy: the underlying node is created on first access and activates when\n\t * something subscribes. No emission replay — late subscribers do not\n\t * receive historical events and should snapshot via {@link Graph.describe}\n\t * before listening for incremental changes. Events that fire while the\n\t * producer has zero subscribers are dropped (no retention).\n\t *\n\t * Own-graph only: a parent's `topology` does NOT emit for structural\n\t * changes inside a mounted child. Transitive consumers subscribe to each\n\t * child's topology separately (recurse through `topology`'s own \"added\"\n\t * events with `nodeKind: \"mount\"` to discover new children).\n\t *\n\t * See {@link TopologyEvent} for payload shape.\n\t *\n\t * @category observability\n\t */\n\tget topology(): Node<TopologyEvent> {\n\t\tif (this._topology == null) {\n\t\t\tthis._topology = producer<TopologyEvent>(\n\t\t\t\t(actions) => {\n\t\t\t\t\tconst handler = (event: TopologyEvent): void => {\n\t\t\t\t\t\tactions.emit(event);\n\t\t\t\t\t};\n\t\t\t\t\tthis._topologyEmitters.add(handler);\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tthis._topologyEmitters.delete(handler);\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{ name: `${this.name}_topology` },\n\t\t\t);\n\t\t}\n\t\treturn this._topology;\n\t}\n\n\t/**\n\t * @internal Fire a {@link TopologyEvent} to every active subscriber of\n\t * `this.topology`. No-op when the topology node has never been accessed or\n\t * currently has no sinks — zero cost for graphs nobody observes.\n\t */\n\tprivate _emitTopology(event: TopologyEvent): void {\n\t\tif (this._topology == null || this._topologyEmitters.size === 0) return;\n\t\tfor (const h of this._topologyEmitters) h(event);\n\t}\n\n\t// ——————————————————————————————————————————————————————————————\n\t// Node registry\n\t// ——————————————————————————————————————————————————————————————\n\n\t/**\n\t * Registers a node under a local name. Fails if the name is already used,\n\t * reserved by a mount, the same node instance is already registered, or\n\t * the node is torn down.\n\t *\n\t * Returns the registered node so callers can chain:\n\t * `const counter = g.add(\"counter\", state(0))`.\n\t *\n\t * @param name - Local key (no `::`).\n\t * @param node - Node instance to own.\n\t */\n\tadd<T extends Node>(name: string, node: T): T {\n\t\tassertRegisterableName(name, this.name, \"add\");\n\t\tif (this._mounts.has(name)) {\n\t\t\tthrow new Error(`Graph \"${this.name}\": name \"${name}\" is already a mount point`);\n\t\t}\n\t\tif (this._nodes.has(name)) {\n\t\t\tthrow new Error(`Graph \"${this.name}\": node \"${name}\" already exists`);\n\t\t}\n\t\tconst existingName = this._nodeToName.get(node);\n\t\tif (existingName !== undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t`Graph \"${this.name}\": node instance already registered as \"${existingName}\"`,\n\t\t\t);\n\t\t}\n\t\tthis._nodes.set(name, node);\n\t\tthis._nodeToName.set(node, name);\n\t\t// Edges are derived on demand from node `_deps` (see `edges()`) — no\n\t\t// stored registry to keep in sync. See Unit 7 of the graph review.\n\t\tthis._emitTopology({ kind: \"added\", name, nodeKind: \"node\" });\n\t\treturn node;\n\t}\n\n\t/**\n\t * Bulk-apply a minimum versioning level to every currently-registered node\n\t * in this graph (roadmap §6.0). `_applyVersioning` is monotonic — nodes\n\t * already at a higher level are untouched. The method refuses to run\n\t * mid-wave; invoke at setup time before any external subscribers attach.\n\t *\n\t * **Not** a default-for-future-adds mechanism — that's what\n\t * `config.defaultVersioning` is for. Nodes added after this call do NOT\n\t * automatically inherit `level`; register new nodes with their own\n\t * `opts.versioning` or set `config.defaultVersioning` before construction.\n\t *\n\t * **Scope:** local only. Does not propagate to mounted subgraphs.\n\t *\n\t * @param level - `0` for V0, `1` for V1, or `undefined` to no-op.\n\t */\n\tsetVersioning(level: VersioningLevel | undefined): void {\n\t\tif (level == null) return;\n\t\tfor (const node of this._nodes.values()) {\n\t\t\tif (node instanceof NodeImpl) {\n\t\t\t\tnode._applyVersioning(level);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Unregisters a node or unmounts a subgraph and sends `[[TEARDOWN]]` to the\n\t * removed node or recursively through the mounted subtree (§3.2).\n\t *\n\t * @param name - Local mount or node name.\n\t * @returns Audit record of what was removed: `{kind, nodes, mounts}`.\n\t * `kind: \"node\"` → `nodes: [name]`, `mounts: []`. `kind: \"mount\"` →\n\t * `nodes` lists every primary node torn down across the subtree (sorted\n\t * qualified paths relative to the unmounted subgraph) and `mounts` lists\n\t * the mounted subgraphs in depth-first order including `name` itself.\n\t */\n\tremove(name: string): GraphRemoveAudit {\n\t\tassertRegisterableName(name, this.name, \"remove\");\n\n\t\t// Case 1: unmount a subgraph\n\t\tconst child = this._mounts.get(name);\n\t\tif (child) {\n\t\t\tconst audit: GraphRemoveAudit = { kind: \"mount\", nodes: [], mounts: [] };\n\t\t\tconst targets: [string, Node][] = [];\n\t\t\tchild._collectObserveTargets(\"\", targets);\n\t\t\tfor (const [p, n] of targets) {\n\t\t\t\t// Only primary nodes (not meta companions) — meta cascades via\n\t\t\t\t// the primary's TEARDOWN.\n\t\t\t\tif (!p.includes(`${PATH_SEP}${GRAPH_META_SEGMENT}${PATH_SEP}`)) {\n\t\t\t\t\taudit.nodes.push(p);\n\t\t\t\t}\n\t\t\t\tvoid n;\n\t\t\t}\n\t\t\taudit.nodes.sort();\n\t\t\taudit.mounts.push(name);\n\t\t\taudit.mounts.push(...child._collectSubgraphs(`${name}${PATH_SEP}`));\n\t\t\tthis._mounts.delete(name);\n\t\t\tchild._parent = undefined;\n\t\t\tteardownMountedGraph(child);\n\t\t\tthis._emitTopology({ kind: \"removed\", name, nodeKind: \"mount\", audit });\n\t\t\treturn audit;\n\t\t}\n\n\t\t// Case 2: remove a local node\n\t\tconst node = this._nodes.get(name);\n\t\tif (!node) {\n\t\t\tthrow new Error(`Graph \"${this.name}\": unknown node or mount \"${name}\"`);\n\t\t}\n\t\tthis._nodes.delete(name);\n\t\tthis._nodeToName.delete(node);\n\t\tnode.down([[TEARDOWN]] satisfies Messages, { internal: true });\n\t\tconst audit: GraphRemoveAudit = { kind: \"node\", nodes: [name], mounts: [] };\n\t\tthis._emitTopology({ kind: \"removed\", name, nodeKind: \"node\", audit });\n\t\treturn audit;\n\t}\n\n\t/**\n\t * Bulk remove — invokes {@link Graph.remove} for every local name matching\n\t * `filter`. Audit records merge into a single result. Mounted subgraphs\n\t * are included via `filter` receiving the mount name; internal subtree\n\t * entries are not walked directly (use describe + scan for tree-level\n\t * queries).\n\t *\n\t * @param filter - Predicate or glob. Glob strings support `*` within a\n\t * segment and `**` across segments (same grammar as `restore({only})`).\n\t * @returns Combined audit of all nodes + mounts removed.\n\t */\n\tremoveAll(filter: ((name: string) => boolean) | string): GraphRemoveAudit {\n\t\tconst match =\n\t\t\ttypeof filter === \"function\"\n\t\t\t\t? filter\n\t\t\t\t: (() => {\n\t\t\t\t\t\tconst re = globToRegex(filter);\n\t\t\t\t\t\treturn (n: string) => re.test(n);\n\t\t\t\t\t})();\n\t\tconst audit: GraphRemoveAudit = { kind: \"mount\", nodes: [], mounts: [] };\n\t\t// Snapshot names first — remove mutates the maps.\n\t\tconst localNames = [...this._nodes.keys(), ...this._mounts.keys()].filter((n) => match(n));\n\t\tfor (const name of localNames) {\n\t\t\tconst sub = this.remove(name);\n\t\t\taudit.nodes.push(...sub.nodes);\n\t\t\taudit.mounts.push(...sub.mounts);\n\t\t}\n\t\taudit.nodes.sort();\n\t\taudit.mounts.sort();\n\t\treturn audit;\n\t}\n\n\t/**\n\t * Iterable over locally-registered `[localName, Node]` pairs (sorted).\n\t * Does not recurse into mounts.\n\t */\n\t[Symbol.iterator](): IterableIterator<[string, Node]> {\n\t\tconst sorted = [...this._nodes.keys()].sort();\n\t\tconst nodes = this._nodes;\n\t\tlet i = 0;\n\t\treturn {\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t\tnext(): IteratorResult<[string, Node]> {\n\t\t\t\tif (i >= sorted.length) return { value: undefined, done: true };\n\t\t\t\tconst name = sorted[i++];\n\t\t\t\treturn { value: [name, nodes.get(name)!], done: false };\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Returns a node by local name or `::` qualified path.\n\t * Local names are looked up directly; paths with `::` delegate to {@link resolve}.\n\t *\n\t * @param name - Local name or qualified path.\n\t */\n\tnode(name: string): Node {\n\t\tif (name === \"\") {\n\t\t\tthrow new Error(`Graph \"${this.name}\": node name must be non-empty`);\n\t\t}\n\t\tif (name.includes(PATH_SEP)) {\n\t\t\treturn this.resolve(name);\n\t\t}\n\t\tconst n = this._nodes.get(name);\n\t\tif (!n) {\n\t\t\tthrow new Error(`Graph \"${this.name}\": unknown node \"${name}\"`);\n\t\t}\n\t\treturn n;\n\t}\n\n\t/**\n\t * Reads `graph.node(name).get()` — accepts `::` qualified paths (§3.2).\n\t *\n\t * @param name - Local name or qualified path.\n\t * @returns Cached value or `undefined`.\n\t */\n\tget(name: string): unknown {\n\t\treturn this.node(name).cache;\n\t}\n\n\t/**\n\t * Shorthand for `graph.node(name).down([[DATA, value]], { actor })` — accepts `::` qualified paths (§3.2).\n\t *\n\t * @param name - Local name or qualified path.\n\t * @param value - Next `DATA` payload.\n\t * @param options - Optional `actor` and `internal` guard bypass.\n\t */\n\tset(name: string, value: unknown, options?: GraphActorOptions): void {\n\t\tconst internal = options?.internal === true;\n\t\tthis.node(name).down([[DATA, value]] satisfies Messages, {\n\t\t\tactor: options?.actor,\n\t\t\tinternal,\n\t\t\tdelivery: \"write\",\n\t\t});\n\t}\n\n\t/**\n\t * Atomic multi-node DATA write. Wraps every {@link Graph.set} call in a\n\t * single `batch(...)` so downstream dependents see one coalesced wave\n\t * instead of N cascading ones.\n\t *\n\t * @param entries - `{name → value}` map or `[name, value]` pairs.\n\t * @param options - Passed to each underlying `set` call (same `actor` + `internal` semantics).\n\t */\n\tsetAll(\n\t\tentries: Record<string, unknown> | Iterable<readonly [string, unknown]>,\n\t\toptions?: GraphActorOptions,\n\t): void {\n\t\tconst iter: Iterable<readonly [string, unknown]> =\n\t\t\tSymbol.iterator in entries\n\t\t\t\t? (entries as Iterable<readonly [string, unknown]>)\n\t\t\t\t: Object.entries(entries as Record<string, unknown>);\n\t\tbatch(() => {\n\t\t\tfor (const [name, value] of iter) this.set(name, value, options);\n\t\t});\n\t}\n\n\t/**\n\t * Emit a single `[[INVALIDATE]]` (tier 1) on a node. Thin wrapper over\n\t * `node.down([[INVALIDATE]], …)` matching the {@link Graph.set} ergonomics.\n\t */\n\tinvalidate(name: string, options?: GraphActorOptions): void {\n\t\tconst internal = options?.internal === true;\n\t\tthis.node(name).down([[INVALIDATE]] satisfies Messages, {\n\t\t\tactor: options?.actor,\n\t\t\tinternal,\n\t\t\tdelivery: \"write\",\n\t\t});\n\t}\n\n\t/**\n\t * Emit a single `[[ERROR, err]]` (tier 4) on a node.\n\t */\n\terror(name: string, err: unknown, options?: GraphActorOptions): void {\n\t\tconst internal = options?.internal === true;\n\t\tthis.node(name).down([[ERROR, err]] satisfies Messages, {\n\t\t\tactor: options?.actor,\n\t\t\tinternal,\n\t\t\tdelivery: \"write\",\n\t\t});\n\t}\n\n\t/**\n\t * Emit a single `[[COMPLETE]]` (tier 4) on a node, declaring the stream\n\t * cleanly finished. Distinct from {@link Graph.remove} (which emits\n\t * TEARDOWN and unregisters the node).\n\t */\n\tcomplete(name: string, options?: GraphActorOptions): void {\n\t\tconst internal = options?.internal === true;\n\t\tthis.node(name).down([[COMPLETE]] satisfies Messages, {\n\t\t\tactor: options?.actor,\n\t\t\tinternal,\n\t\t\tdelivery: \"write\",\n\t\t});\n\t}\n\n\t// ——————————————————————————————————————————————————————————————\n\t// Edges (derived on-demand from node `_deps`)\n\t// ——————————————————————————————————————————————————————————————\n\n\t/**\n\t * Returns the full edge list for this graph tree, derived on demand from\n\t * each registered node's `_deps` (no stored registry). Local-only\n\t * (non-recursive) by default to match the historical `edges()` surface;\n\t * pass `{recursive: true}` to include mounted subgraphs with qualified\n\t * paths relative to this graph.\n\t *\n\t * Use {@link Graph.describe} for full-tree snapshots with edges already\n\t * qualified and paired with node metadata.\n\t */\n\tedges(opts?: { recursive?: boolean }): ReadonlyArray<[string, string]> {\n\t\tconst recursive = opts?.recursive === true;\n\t\tconst nodeToLocal = new Map<Node, string>();\n\t\tif (!recursive) {\n\t\t\tfor (const [localName, n] of this._nodes) nodeToLocal.set(n, localName);\n\t\t\tconst result: [string, string][] = [];\n\t\t\tfor (const [localName, n] of this._nodes) {\n\t\t\t\tif (!(n instanceof NodeImpl)) continue;\n\t\t\t\tfor (const dep of n._deps) {\n\t\t\t\t\tconst from = nodeToLocal.get(dep.node);\n\t\t\t\t\tif (from != null) result.push([from, localName]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tresult.sort((a, b) =>\n\t\t\t\ta[0] < b[0] ? -1 : a[0] > b[0] ? 1 : a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0,\n\t\t\t);\n\t\t\treturn result;\n\t\t}\n\t\tconst targets: [string, Node][] = [];\n\t\tthis._collectObserveTargets(\"\", targets);\n\t\tconst nodeToPath = new Map<Node, string>();\n\t\tfor (const [p, n] of targets) nodeToPath.set(n, p);\n\t\tconst result: [string, string][] = [];\n\t\tfor (const [path, n] of targets) {\n\t\t\tif (!(n instanceof NodeImpl)) continue;\n\t\t\tfor (const dep of n._deps) {\n\t\t\t\tconst from = nodeToPath.get(dep.node);\n\t\t\t\tif (from != null) result.push([from, path]);\n\t\t\t}\n\t\t}\n\t\tresult.sort((a, b) =>\n\t\t\ta[0] < b[0] ? -1 : a[0] > b[0] ? 1 : a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0,\n\t\t);\n\t\treturn result;\n\t}\n\n\t// ——————————————————————————————————————————————————————————————\n\t// Composition\n\t// ——————————————————————————————————————————————————————————————\n\n\t/**\n\t * Embed a child graph at a local mount name (§3.4). Child nodes are reachable via\n\t * {@link Graph.resolve} using `::` delimited paths (§3.5). Lifecycle\n\t * {@link Graph.signal} visits mounted subgraphs recursively.\n\t *\n\t * Rejects: same name as existing node or mount, self-mount, mount cycles,\n\t * and the same child graph instance mounted twice on one parent.\n\t *\n\t * @param name - Local mount point.\n\t * @param child - Nested `Graph` instance.\n\t * @returns The mounted `child`, for chaining.\n\t */\n\tmount<G extends Graph>(name: string, child: G): G {\n\t\tassertRegisterableName(name, this.name, \"mount\");\n\t\tif (this._nodes.has(name)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Graph \"${this.name}\": cannot mount at \"${name}\" — node with that name exists`,\n\t\t\t);\n\t\t}\n\t\tif (this._mounts.has(name)) {\n\t\t\tthrow new Error(`Graph \"${this.name}\": mount \"${name}\" already exists`);\n\t\t}\n\t\tif ((child as Graph) === this) {\n\t\t\tthrow new Error(`Graph \"${this.name}\": cannot mount a graph into itself`);\n\t\t}\n\t\t// Reject reparenting (Unit 6 B): same child instance may only be\n\t\t// mounted once across the entire tree. Cheap O(1) check via the\n\t\t// back-pointer (replaces both the \"mounted twice on this parent\"\n\t\t// loop AND the O(G) cycle DFS).\n\t\tif (child._parent != null) {\n\t\t\tthrow new Error(\n\t\t\t\t`Graph \"${this.name}\": this child graph is already mounted on \"${child._parent.name}\"`,\n\t\t\t);\n\t\t}\n\t\t// Cycle rejection — walk UP from `this` to detect if we are already in\n\t\t// `child`'s descendant tree. O(depth), independent of tree size.\n\t\tfor (let p: Graph | undefined = this; p != null; p = p._parent) {\n\t\t\tif (p === (child as Graph)) {\n\t\t\t\tthrow new Error(`Graph \"${this.name}\": mount(\"${name}\", …) would create a mount cycle`);\n\t\t\t}\n\t\t}\n\t\tthis._mounts.set(name, child);\n\t\tchild._parent = this;\n\t\tthis._emitTopology({ kind: \"added\", name, nodeKind: \"mount\" });\n\t\treturn child;\n\t}\n\n\t/**\n\t * Look up a node by qualified path (§3.5). Segments are separated by `::`.\n\t *\n\t * If the first segment equals this graph's {@link Graph.name}, it is stripped\n\t * (so `root.resolve(\"app::a\")` works when `root.name === \"app\"`). The strip\n\t * is applied **recursively** when descending into mounted children, so\n\t * `child.resolve(\"child::x\")` also works when `child.name === \"child\"`.\n\t *\n\t * @param path - Qualified `::` path or local name.\n\t * @returns The resolved `Node`.\n\t */\n\tresolve(path: string): Node {\n\t\tconst segments = splitPath(path, this.name);\n\t\treturn this._resolveFromSegments(segments);\n\t}\n\n\t/**\n\t * Non-throwing {@link Graph.resolve}. Returns `undefined` instead of\n\t * throwing when the path does not resolve to a node.\n\t */\n\ttryResolve(path: string): Node | undefined {\n\t\ttry {\n\t\t\treturn this.resolve(path);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate _resolveFromSegments(segments: readonly string[]): Node {\n\t\t// Recursive self-name strip: if the first segment equals this graph's\n\t\t// own name, peel it off. Applied at every recursion level so nested\n\t\t// resolution of `child::x` inside `child` works uniformly.\n\t\tlet seg = segments;\n\t\tif (seg[0] === this.name) {\n\t\t\tseg = seg.slice(1);\n\t\t\tif (seg.length === 0) {\n\t\t\t\tthrow new Error(`Graph \"${this.name}\": resolve path ends at graph name only`);\n\t\t\t}\n\t\t}\n\t\tconst head = seg[0] as string;\n\t\tconst rest = seg.slice(1);\n\n\t\tif (rest.length === 0) {\n\t\t\tconst n = this._nodes.get(head);\n\t\t\tif (n) return n;\n\t\t\tif (this._mounts.has(head)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Graph \"${this.name}\": path ends at subgraph \"${head}\" — not a node (GRAPHREFLY-SPEC §3.5)`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new Error(`Graph \"${this.name}\": unknown name \"${head}\"`);\n\t\t}\n\n\t\tconst localN = this._nodes.get(head);\n\t\tif (localN && rest.length > 0 && rest[0] === GRAPH_META_SEGMENT) {\n\t\t\treturn this._resolveMetaChainFromNode(localN, rest, seg.join(PATH_SEP));\n\t\t}\n\n\t\tconst child = this._mounts.get(head);\n\t\tif (!child) {\n\t\t\tif (this._nodes.has(head)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Graph \"${this.name}\": \"${head}\" is a node; trailing path \"${rest.join(PATH_SEP)}\" is invalid`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new Error(`Graph \"${this.name}\": unknown mount or node \"${head}\"`);\n\t\t}\n\n\t\treturn child.resolve(rest.join(PATH_SEP));\n\t}\n\n\t/**\n\t * Resolve `::__meta__::key` segments from a registered primary node (possibly chained).\n\t */\n\tprivate _resolveMetaChainFromNode(n: Node, parts: readonly string[], fullPath: string): Node {\n\t\tlet current = n;\n\t\tlet i = 0;\n\t\tconst p = [...parts];\n\t\twhile (i < p.length) {\n\t\t\tif (p[i] !== GRAPH_META_SEGMENT) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Graph \"${this.name}\": expected ${GRAPH_META_SEGMENT} segment in meta path \"${fullPath}\"`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (i + 1 >= p.length) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Graph \"${this.name}\": meta path requires a key after ${GRAPH_META_SEGMENT} in \"${fullPath}\"`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst key = p[i + 1] as string;\n\t\t\tconst next = current.meta[key];\n\t\t\tif (!next) {\n\t\t\t\tthrow new Error(`Graph \"${this.name}\": unknown meta \"${key}\" in path \"${fullPath}\"`);\n\t\t\t}\n\t\t\tcurrent = next;\n\t\t\ti += 2;\n\t\t}\n\t\treturn current;\n\t}\n\n\t/**\n\t * Deliver a message batch to every registered node in this graph and, recursively,\n\t * in mounted child graphs (§3.7). Recurses into mounts first, then delivers to\n\t * local nodes (sorted by name). Each {@link Node} receives at most one delivery\n\t * per call (deduped by reference).\n\t *\n\t * **Primary-vs-meta filter asymmetry (intentional):** primary nodes receive the\n\t * unfiltered `messages` batch — that's the canonical data-plane flow. Companion\n\t * `meta` nodes receive a filtered subset keyed by the per-type `metaPassthrough`\n\t * flag on {@link GraphReFlyConfig}. Built-in defaults: PAUSE / RESUME / DATA /\n\t * RESOLVED pass through to meta; INVALIDATE / COMPLETE / ERROR / TEARDOWN do\n\t * not.\n\t *\n\t * **Where lifecycle terminals reach meta:**\n\t * - **TEARDOWN** — primary's `_emit` cascades to meta children directly (see\n\t * `core/node.ts` \"Meta TEARDOWN fan-out\" block) so meta is torn down with\n\t * its primary regardless of the signal-level filter.\n\t * - **COMPLETE / ERROR / INVALIDATE** — scoped to primaries on the broadcast\n\t * path. Meta companions are an attribution side-channel, not a lifecycle\n\t * participant; address meta directly via `meta.down(...)` if you need to\n\t * forward these. Audit confirmed 2026-04-17: no current meta consumer\n\t * relies on broadcast COMPLETE/ERROR/INVALIDATE delivery.\n\t *\n\t * @param messages - Batch to deliver to every registered node (and mounts, recursively).\n\t * @param options - Optional `actor` / `internal` for transport.\n\t */\n\tsignal(messages: Messages, options?: GraphActorOptions): void {\n\t\t// Reject tier ≥ 3 (DATA / RESOLVED / COMPLETE / ERROR / TEARDOWN when\n\t\t// called externally — destroy() routes through signal with\n\t\t// `{internal: true}` which bypasses this check). Broadcasting per-flow\n\t\t// values to every node in the tree is almost always a mistake.\n\t\tif (options?.internal !== true) {\n\t\t\tfor (const m of messages) {\n\t\t\t\tconst tier = this.config.messageTier(m[0]);\n\t\t\t\t// Tier 3 (DATA / RESOLVED) is per-flow state — broadcasting it\n\t\t\t\t// to every node overwrites unrelated caches. Tier 4/5 stays\n\t\t\t\t// allowed: ERROR/COMPLETE/TEARDOWN have legitimate broadcast\n\t\t\t\t// use (graceful shutdown, error cascade).\n\t\t\t\tif (tier === 3) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Graph \"${this.name}\": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). ` +\n\t\t\t\t\t\t\t`Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). ` +\n\t\t\t\t\t\t\t`For per-node value writes, use Graph.set or graph.node(name).down(...).`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst errors: unknown[] = [];\n\t\tthis._signalDeliver(messages, options ?? {}, new Set(), errors);\n\t\t// Surface the first collected error so callers see failures without\n\t\t// aborting the rest of the broadcast. Guard denials are re-thrown\n\t\t// immediately in _signalDeliver (deliberate access-control rejections).\n\t\tif (errors.length > 0) throw errors[0];\n\t}\n\n\tprivate _signalDeliver(\n\t\tmessages: Messages,\n\t\topts: GraphActorOptions,\n\t\tvis: Set<Node>,\n\t\terrors: unknown[],\n\t): void {\n\t\tfor (const sub of this._mounts.values()) {\n\t\t\tsub._signalDeliver(messages, opts, vis, errors);\n\t\t}\n\t\tconst internal = opts.internal === true;\n\t\tconst downOpts: NodeTransportOptions = internal\n\t\t\t? { internal: true }\n\t\t\t: { actor: opts.actor, delivery: \"signal\" };\n\t\tconst metaMessages = filterMetaMessages(messages, this.config);\n\t\tfor (const localName of [...this._nodes.keys()].sort()) {\n\t\t\tconst n = this._nodes.get(localName)!;\n\t\t\tif (vis.has(n)) continue;\n\t\t\tvis.add(n);\n\t\t\ttry {\n\t\t\t\tn.down(messages, downOpts);\n\t\t\t} catch (err) {\n\t\t\t\t// Guard denials bubble — they're deliberate rejections, not\n\t\t\t\t// resilience failures. Other errors collect so one bad handler\n\t\t\t\t// doesn't abort the rest of the broadcast.\n\t\t\t\tif (err instanceof GuardDenied) throw err;\n\t\t\t\terrors.push(err);\n\t\t\t}\n\t\t\tif (metaMessages.length === 0) continue;\n\t\t\tthis._signalMetaSubtree(n, metaMessages, vis, downOpts, errors);\n\t\t}\n\t}\n\n\tprivate _signalMetaSubtree(\n\t\troot: Node,\n\t\tmessages: Messages,\n\t\tvis: Set<Node>,\n\t\tdownOpts: NodeTransportOptions,\n\t\terrors: unknown[],\n\t): void {\n\t\tfor (const mk of Object.keys(root.meta).sort()) {\n\t\t\tconst mnode = root.meta[mk];\n\t\t\tif (vis.has(mnode)) continue;\n\t\t\tvis.add(mnode);\n\t\t\ttry {\n\t\t\t\tmnode.down(messages, downOpts);\n\t\t\t} catch (err) {\n\t\t\t\tif (err instanceof GuardDenied) throw err;\n\t\t\t\terrors.push(err);\n\t\t\t}\n\t\t\tthis._signalMetaSubtree(mnode, messages, vis, downOpts, errors);\n\t\t}\n\t}\n\n\t/**\n\t * Static structure snapshot: qualified node keys, edges, mount names (GRAPHREFLY-SPEC §3.6, Appendix B).\n\t *\n\t * `format` controls the return type:\n\t * - omitted or `\"spec\"` → {@link GraphDescribeOutput} object.\n\t * - `\"json\"` / `\"pretty\"` / `\"mermaid\"` / `\"d2\"` → rendered string.\n\t *\n\t * @param options - Optional `actor` for guard-scoped visibility, `filter` for\n\t * selective output, or `format` to render.\n\t *\n\t * @example\n\t * ```ts\n\t * graph.describe() // full snapshot object\n\t * graph.describe({ filter: { status: \"errored\" } }) // filtered object\n\t * graph.describe({ format: \"pretty\" }) // human-readable text\n\t * graph.describe({ format: \"mermaid\" }) // Mermaid flowchart\n\t * graph.describe({ format: \"d2\", direction: \"TD\" }) // D2 top-down\n\t * ```\n\t */\n\tdescribe(\n\t\toptions: GraphDescribeOptions & { format: \"json\" | \"pretty\" | \"mermaid\" | \"d2\" },\n\t): string;\n\tdescribe(options?: GraphDescribeOptions): GraphDescribeOutput;\n\tdescribe(options?: GraphDescribeOptions): GraphDescribeOutput | string {\n\t\tconst actor = options?.actor;\n\t\tconst filter = options?.filter;\n\t\tconst includeFields = resolveDescribeFields(options?.detail, options?.fields);\n\t\tconst isSpec = options?.format === \"spec\";\n\t\t// For spec format, force minimal fields (type + deps only, no status/value)\n\t\tconst effectiveFields = isSpec ? resolveDescribeFields(\"minimal\") : includeFields;\n\n\t\tconst targets: [string, Node][] = [];\n\t\tthis._collectObserveTargets(\"\", targets);\n\t\tconst nodeToPath = new Map<Node, string>();\n\t\tfor (const [p, n] of targets) {\n\t\t\tnodeToPath.set(n, p);\n\t\t}\n\t\tconst nodes: Record<string, DescribeNodeOutput> = {};\n\t\tfor (const [p, n] of targets) {\n\t\t\tif (actor != null && !n.allowsObserve(actor)) continue;\n\t\t\tconst raw = describeNode(n, effectiveFields);\n\t\t\tconst deps =\n\t\t\t\tn instanceof NodeImpl\n\t\t\t\t\t? n._deps.map((d) => nodeToPath.get(d.node) ?? d.node.name ?? \"\")\n\t\t\t\t\t: [];\n\t\t\tconst { name: _name, ...rest } = raw;\n\t\t\tconst entry: DescribeNodeOutput = { ...rest, deps };\n\t\t\t// Unit 14 A: attach reason annotation from `trace(path, reason)`\n\t\t\t// when one exists. Skipped for the `\"spec\"` format (input-schema\n\t\t\t// use case — annotations don't round-trip through GraphSpec).\n\t\t\tif (!isSpec) {\n\t\t\t\tconst reason = this._annotations.get(p);\n\t\t\t\tif (reason != null) entry.reason = reason;\n\t\t\t}\n\t\t\tif (filter != null) {\n\t\t\t\tif (typeof filter === \"function\") {\n\t\t\t\t\tconst fn = filter as\n\t\t\t\t\t\t| ((nodePath: string, node: DescribeNodeOutput) => boolean)\n\t\t\t\t\t\t| ((node: DescribeNodeOutput) => boolean);\n\t\t\t\t\tconst pass =\n\t\t\t\t\t\tfn.length >= 2\n\t\t\t\t\t\t\t? (fn as (nodePath: string, node: DescribeNodeOutput) => boolean)(p, entry)\n\t\t\t\t\t\t\t: (fn as (node: DescribeNodeOutput) => boolean)(entry);\n\t\t\t\t\tif (!pass) continue;\n\t\t\t\t} else {\n\t\t\t\t\tlet match = true;\n\t\t\t\t\tfor (const [fk, fv] of Object.entries(filter)) {\n\t\t\t\t\t\tconst normalizedKey =\n\t\t\t\t\t\t\tfk === \"deps_includes\" ? \"depsIncludes\" : fk === \"meta_has\" ? \"metaHas\" : fk;\n\t\t\t\t\t\tif (normalizedKey === \"depsIncludes\") {\n\t\t\t\t\t\t\tif (!entry.deps.includes(String(fv))) {\n\t\t\t\t\t\t\t\tmatch = false;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (normalizedKey === \"metaHas\") {\n\t\t\t\t\t\t\tif (!Object.hasOwn(entry.meta ?? {}, String(fv))) {\n\t\t\t\t\t\t\t\tmatch = false;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ((entry as Record<string, unknown>)[normalizedKey] !== fv) {\n\t\t\t\t\t\t\tmatch = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!match) continue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tnodes[p] = entry;\n\t\t}\n\t\tconst nodeKeys = new Set(Object.keys(nodes));\n\t\t// Edges are derived from node `_deps` via `edges({recursive: true})`\n\t\t// (sorted, fully qualified relative to this graph).\n\t\tlet edges: { from: string; to: string }[] = this.edges({ recursive: true }).map(\n\t\t\t([from, to]) => ({ from, to }),\n\t\t);\n\t\tif (actor != null || filter != null) {\n\t\t\tedges = edges.filter((e) => nodeKeys.has(e.from) && nodeKeys.has(e.to));\n\t\t}\n\t\tconst allSubgraphs = this._collectSubgraphs(\"\");\n\t\tconst subgraphs =\n\t\t\tactor != null || filter != null\n\t\t\t\t? allSubgraphs.filter((sg) => {\n\t\t\t\t\t\tconst prefix = `${sg}${PATH_SEP}`;\n\t\t\t\t\t\treturn [...nodeKeys].some((k) => k === sg || k.startsWith(prefix));\n\t\t\t\t\t})\n\t\t\t\t: allSubgraphs;\n\n\t\t// Capture graph ref and base options for expand()\n\t\tconst graph = this;\n\t\tconst baseOpts = options;\n\n\t\tconst struct: GraphDescribeOutput = {\n\t\t\tname: this.name,\n\t\t\tnodes,\n\t\t\tedges,\n\t\t\tsubgraphs,\n\t\t\texpand(detailOrFields: DescribeDetail | DescribeField[]): GraphDescribeOutput {\n\t\t\t\tconst merged: GraphDescribeOptions = { ...baseOpts, format: undefined };\n\t\t\t\tif (Array.isArray(detailOrFields)) {\n\t\t\t\t\tmerged.fields = detailOrFields;\n\t\t\t\t\tmerged.detail = undefined;\n\t\t\t\t} else {\n\t\t\t\t\tmerged.detail = detailOrFields;\n\t\t\t\t\tmerged.fields = undefined;\n\t\t\t\t}\n\t\t\t\treturn graph.describe(merged);\n\t\t\t},\n\t\t};\n\n\t\t// Text-format dispatch. `\"spec\"` and undefined return the struct as-is.\n\t\tconst opts = options ?? {};\n\t\tconst fmt = opts.format;\n\t\tif (fmt === \"json\") return renderDescribeAsJson(struct, opts);\n\t\tif (fmt === \"pretty\") return renderDescribeAsPretty(struct, opts);\n\t\tif (fmt === \"mermaid\") return renderDescribeAsMermaid(struct, opts);\n\t\tif (fmt === \"d2\") return renderDescribeAsD2(struct, opts);\n\t\treturn struct;\n\t}\n\n\tprivate _collectSubgraphs(prefix: string): string[] {\n\t\tconst out: string[] = [];\n\t\tfor (const m of [...this._mounts.keys()].sort()) {\n\t\t\tconst q = prefix === \"\" ? m : `${prefix}${m}`;\n\t\t\tout.push(q);\n\t\t\tout.push(...this._mounts.get(m)!._collectSubgraphs(`${q}${PATH_SEP}`));\n\t\t}\n\t\treturn out;\n\t}\n\n\t/**\n\t * Snapshot-based resource profile: per-node stats, orphan effect detection,\n\t * memory hotspots. Zero runtime overhead — walks nodes on demand.\n\t *\n\t * @param opts - Optional `topN` for hotspot limit (default 10).\n\t * @returns Aggregate profile with per-node details, hotspots, and orphan effects.\n\t */\n\tresourceProfile(opts?: GraphProfileOptions): GraphProfileResult {\n\t\treturn graphProfile(this, opts);\n\t}\n\n\t/**\n\t * Reachability query rooted at `from`. Instance convenience — wraps\n\t * `reachable(this.describe(), from, direction, opts)`. See\n\t * {@link reachable} for semantics.\n\t */\n\treachable(\n\t\tfrom: string,\n\t\tdirection: ReachableDirection,\n\t\topts: ReachableOptions & { withDetail: true },\n\t): ReachableResult;\n\treachable(from: string, direction: ReachableDirection, opts?: ReachableOptions): string[];\n\treachable(\n\t\tfrom: string,\n\t\tdirection: ReachableDirection,\n\t\topts: ReachableOptions = {},\n\t): string[] | ReachableResult {\n\t\tif (opts.withDetail === true) {\n\t\t\treturn reachable(this.describe(), from, direction, {\n\t\t\t\t...opts,\n\t\t\t\twithDetail: true,\n\t\t\t});\n\t\t}\n\t\treturn reachable(this.describe(), from, direction, opts);\n\t}\n\n\t/**\n\t * Causal walkback: shortest dep-chain from `from` to `to`, enriched with\n\t * each node's value, status, last-mutation actor, and reasoning annotation\n\t * from {@link Graph.trace}. Wraps {@link explainPath} (roadmap §9.2).\n\t *\n\t * @param from - Upstream node (the cause).\n\t * @param to - Downstream node (the effect).\n\t * @param opts - Optional `maxDepth` and `findCycle`. When `findCycle:true`\n\t * and `from === to`, returns the shortest cycle through other nodes\n\t * (useful for diagnosing feedback loops, COMPOSITION-GUIDE §7).\n\t * Annotations and lastMutations are collected automatically from the\n\t * live graph.\n\t */\n\texplain(\n\t\tfrom: string,\n\t\tto: string,\n\t\topts?: { maxDepth?: number; findCycle?: boolean },\n\t): CausalChain {\n\t\t// `detail: \"full\"` includes `value`, `status`, `lastMutation`, `v`, etc.\n\t\t// — everything `explainPath` enriches each step with.\n\t\tconst described = this.describe({ detail: \"full\" });\n\t\tconst annotations = new Map<string, string>(this._annotations);\n\t\tconst lastMutations = new Map<string, Readonly<{ actor: Actor; timestamp_ns: number }>>();\n\t\tfor (const [path, n] of Object.entries(described.nodes)) {\n\t\t\tif (n.lastMutation != null) lastMutations.set(path, n.lastMutation);\n\t\t}\n\t\treturn explainPath(described, from, to, {\n\t\t\t...(opts?.maxDepth != null ? { maxDepth: opts.maxDepth } : {}),\n\t\t\t...(opts?.findCycle === true ? { findCycle: true as const } : {}),\n\t\t\tannotations,\n\t\t\tlastMutations,\n\t\t});\n\t}\n\n\t/**\n\t * @internal Collect all qualified paths in this graph tree matching a\n\t * glob pattern. Used by scoped autoCheckpoint subscription.\n\t */\n\tprivate _pathsMatching(glob: string): string[] {\n\t\tconst re = globToRegex(glob);\n\t\tconst targets: [string, Node][] = [];\n\t\tthis._collectObserveTargets(\"\", targets);\n\t\treturn targets.map(([p]) => p).filter((p) => re.test(p));\n\t}\n\n\tprivate _collectObserveTargets(prefix: string, out: [string, Node][]): void {\n\t\tfor (const m of [...this._mounts.keys()].sort()) {\n\t\t\tconst p2 = prefix === \"\" ? m : `${prefix}${PATH_SEP}${m}`;\n\t\t\tthis._mounts.get(m)!._collectObserveTargets(p2, out);\n\t\t}\n\t\tfor (const loc of [...this._nodes.keys()].sort()) {\n\t\t\tconst n = this._nodes.get(loc)!;\n\t\t\tconst p = prefix === \"\" ? loc : `${prefix}${PATH_SEP}${loc}`;\n\t\t\tout.push([p, n]);\n\t\t\tthis._appendMetaObserveTargets(p, n, out);\n\t\t}\n\t}\n\n\tprivate _appendMetaObserveTargets(basePath: string, n: Node, out: [string, Node][]): void {\n\t\tfor (const mk of Object.keys(n.meta).sort()) {\n\t\t\tconst m = n.meta[mk];\n\t\t\tconst mp = `${basePath}${PATH_SEP}${GRAPH_META_SEGMENT}${PATH_SEP}${mk}`;\n\t\t\tout.push([mp, m]);\n\t\t\tthis._appendMetaObserveTargets(mp, m, out);\n\t\t}\n\t}\n\n\t/**\n\t * Live message stream from one node (or meta path), or from the whole graph (§3.6).\n\t *\n\t * Two modes dispatched on first argument:\n\t * - `observe(path, options?)` — one node. Returns {@link GraphObserveOne}\n\t * (raw stream), or {@link ObserveResult} when `options` requests structured\n\t * accumulation (`structured`, `timeline`, `causal`, `derived`, `format`,\n\t * `detail: \"minimal\"|\"full\"`).\n\t * - `observe(options?)` — all nodes. Returns {@link GraphObserveAll} (raw),\n\t * or {@link ObserveResult} under the same structured trigger conditions.\n\t *\n\t * Structured mode subscribes in sorted path order (code-point). Inspector\n\t * extras (`causal`/`derived`) require `graph.config.inspectorEnabled`;\n\t * when disabled, those fields silently drop and the rest still works.\n\t *\n\t * `ObserveResult` is also an `AsyncIterable<ObserveEvent>` — use\n\t * `for await (const ev of result)` for pull-based consumption.\n\t */\n\tobserve(path: string, options?: ObserveOptions & StructuredTriggers): ObserveResult;\n\tobserve(path: string, options?: ObserveOptions): GraphObserveOne;\n\tobserve(options: ObserveOptions & StructuredTriggers): ObserveResult;\n\tobserve(options?: ObserveOptions): GraphObserveAll;\n\tobserve(\n\t\tpathOrOpts?: string | ObserveOptions,\n\t\toptions?: ObserveOptions,\n\t): GraphObserveOne | GraphObserveAll | ObserveResult {\n\t\tconst isPath = typeof pathOrOpts === \"string\";\n\t\tconst rawOpts = isPath ? options : (pathOrOpts as ObserveOptions | undefined);\n\t\tconst resolved = resolveObserveDetail(rawOpts);\n\t\tconst wantsStructured =\n\t\t\tresolved.structured === true ||\n\t\t\tresolved.timeline === true ||\n\t\t\tresolved.causal === true ||\n\t\t\tresolved.derived === true ||\n\t\t\tresolved.detail === \"minimal\" ||\n\t\t\tresolved.detail === \"full\" ||\n\t\t\tresolved.format != null;\n\t\tconst actor = resolved.actor;\n\n\t\tif (isPath) {\n\t\t\tconst path = pathOrOpts as string;\n\t\t\tconst target = this.resolve(path);\n\t\t\tif (actor != null && !target.allowsObserve(actor)) {\n\t\t\t\tthrow new GuardDenied({ actor, action: \"observe\", nodeName: path });\n\t\t\t}\n\t\t\tif (wantsStructured) return this._buildStructuredObserver([[path, target]], resolved, \"one\");\n\t\t\treturn {\n\t\t\t\tsubscribe(sink: NodeSink) {\n\t\t\t\t\treturn target.subscribe(sink);\n\t\t\t\t},\n\t\t\t\tup(messages: Messages) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\ttarget.up?.(messages);\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tif (err instanceof GuardDenied) return;\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tconst collected: [string, Node][] = [];\n\t\tthis._collectObserveTargets(\"\", collected);\n\t\tcollected.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0));\n\t\tconst picked =\n\t\t\tactor == null ? collected : collected.filter(([, nd]) => nd.allowsObserve(actor));\n\t\tif (wantsStructured) return this._buildStructuredObserver(picked, resolved, \"all\");\n\t\treturn {\n\t\t\tsubscribe: (sink: (nodePath: string, messages: Messages) => void) => {\n\t\t\t\tconst unsubs = picked.map(([p, nd]) =>\n\t\t\t\t\tnd.subscribe((msgs) => {\n\t\t\t\t\t\tsink(p, msgs);\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\treturn () => {\n\t\t\t\t\tfor (const u of unsubs) u();\n\t\t\t\t};\n\t\t\t},\n\t\t\tup: (upPath: string, messages: Messages) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst nd = this.resolve(upPath);\n\t\t\t\t\tnd.up?.(messages);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tif (err instanceof GuardDenied) return;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\n\t/** Dispatch helper — builds a unified observer + its expand closure. */\n\tprivate _buildStructuredObserver<T>(\n\t\ttargets: ReadonlyArray<[string, Node]>,\n\t\toptions: ObserveOptions,\n\t\tmode: \"one\" | \"all\",\n\t): ObserveResult<T> {\n\t\tconst firstPath = mode === \"one\" ? targets[0]?.[0] : undefined;\n\t\tconst expand = (merged: ObserveOptions): ObserveResult<T> => {\n\t\t\tif (mode === \"one\" && firstPath != null) {\n\t\t\t\tconst target = this.resolve(firstPath);\n\t\t\t\treturn this._buildStructuredObserver([[firstPath, target]], merged, \"one\");\n\t\t\t}\n\t\t\tconst collected: [string, Node][] = [];\n\t\t\tthis._collectObserveTargets(\"\", collected);\n\t\t\tcollected.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0));\n\t\t\tconst actor = merged.actor;\n\t\t\tconst picked =\n\t\t\t\tactor == null ? collected : collected.filter(([, nd]) => nd.allowsObserve(actor));\n\t\t\treturn this._buildStructuredObserver(picked, merged, \"all\");\n\t\t};\n\t\treturn this._createObserveResult<T>(targets, options, expand);\n\t}\n\n\t/**\n\t * Unified observer builder — replaces the four ex-creators\n\t * (`_createObserveResult` / `...ForAll` / `_createFallback…`). Accepts a\n\t * list of `[path, node]` targets (single-element for one-node observe,\n\t * N-element for all-nodes). Inspector hooks attach per-target when\n\t * `causal`/`derived` requested AND `config.inspectorEnabled`; otherwise\n\t * those fields gracefully drop.\n\t *\n\t * Events flow through a `recordEvent()` helper so the format logger,\n\t * ring-buffer, and async-iterable hooks all share one push path.\n\t */\n\tprivate _createObserveResult<T>(\n\t\ttargets: ReadonlyArray<[string, Node]>,\n\t\toptions: ObserveOptions,\n\t\texpand: (merged: ObserveOptions) => ObserveResult<T>,\n\t): ObserveResult<T> {\n\t\tconst timeline = options.timeline === true;\n\t\tconst causal = options.causal === true;\n\t\tconst derived = options.derived === true;\n\t\tconst minimal = options.detail === \"minimal\";\n\t\tconst inspectorOn = this.config.inspectorEnabled;\n\t\tconst wantInspector = (causal || derived) && inspectorOn;\n\n\t\t// Event buffer: unbounded array, or RingBuffer when maxEvents capped.\n\t\tconst maxEvents = options.maxEvents;\n\t\tconst ring =\n\t\t\tmaxEvents != null && maxEvents > 0 ? new RingBuffer<ObserveEvent>(maxEvents) : null;\n\t\tconst events: ObserveEvent[] = [];\n\n\t\t// Listener set — format logger, async iterable, and user `onEvent` hooks.\n\t\tconst listeners = new Set<(event: ObserveEvent) => void>();\n\n\t\tconst values: Record<string, T> = {};\n\t\tconst nodeErrored = new Set<string>();\n\t\tlet dirtyCount = 0;\n\t\tlet resolvedCount = 0;\n\t\tlet invalidateCount = 0;\n\t\tlet pauseCount = 0;\n\t\tlet resumeCount = 0;\n\t\tlet teardownCount = 0;\n\t\tlet anyCompletedCleanly = false;\n\t\tlet anyErrored = false;\n\t\tlet batchSeq = 0;\n\n\t\t// Per-target causal context (keyed by target index).\n\t\tconst lastTriggerDepIndex = new Map<Node, number>();\n\t\tconst lastRunDepValues = new Map<Node, readonly unknown[]>();\n\t\tconst lastRunDepBatches = new Map<Node, ReadonlyArray<ReadonlyArray<unknown> | undefined>>();\n\n\t\tconst recordEvent = (event: ObserveEvent): void => {\n\t\t\tif (ring) ring.push(event);\n\t\t\telse events.push(event);\n\t\t\tfor (const listener of listeners) listener(event);\n\t\t};\n\n\t\tconst baseMeta = (): Partial<ObserveEventBase> =>\n\t\t\ttimeline ? { timestamp_ns: monotonicNs(), in_batch: isBatching(), batch_id: batchSeq } : {};\n\n\t\tconst attachInspector = (target: Node, path: string): (() => void) | undefined => {\n\t\t\tif (!wantInspector || !(target instanceof NodeImpl)) return undefined;\n\t\t\treturn target._setInspectorHook((ev) => {\n\t\t\t\tif (ev.kind === \"dep_message\") {\n\t\t\t\t\tlastTriggerDepIndex.set(target, ev.depIndex);\n\t\t\t\t} else if (ev.kind === \"run\") {\n\t\t\t\t\tconst effective = ev.batchData.map((b, i) =>\n\t\t\t\t\t\tb != null && b.length > 0 ? b.at(-1) : ev.prevData[i],\n\t\t\t\t\t);\n\t\t\t\t\tlastRunDepValues.set(target, effective);\n\t\t\t\t\t// Snapshot the full per-dep batches so multi-value waves stay\n\t\t\t\t\t// visible to observers. `ev.batchData` references run-local\n\t\t\t\t\t// arrays, so clone the outer array (inner arrays are\n\t\t\t\t\t// effectively immutable from the observer's POV).\n\t\t\t\t\tconst batches: ReadonlyArray<ReadonlyArray<unknown> | undefined> = ev.batchData.map(\n\t\t\t\t\t\t(b) => (b != null ? [...b] : undefined),\n\t\t\t\t\t);\n\t\t\t\t\tlastRunDepBatches.set(target, batches);\n\t\t\t\t\tif (derived) {\n\t\t\t\t\t\trecordEvent({\n\t\t\t\t\t\t\ttype: \"derived\",\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tdep_values: effective,\n\t\t\t\t\t\t\tdep_batches: batches,\n\t\t\t\t\t\t\t...baseMeta(),\n\t\t\t\t\t\t} as ObserveEvent);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\n\t\tconst buildCausal = (target: Node): ObserveCausalContext => {\n\t\t\tconst idx = lastTriggerDepIndex.get(target);\n\t\t\tconst depValues = lastRunDepValues.get(target);\n\t\t\tif (!causal || depValues == null) return {};\n\t\t\tconst triggerDep =\n\t\t\t\tidx != null && idx >= 0 && target instanceof NodeImpl ? target._deps[idx] : undefined;\n\t\t\tconst triggerNode = triggerDep?.node;\n\t\t\tconst tv = triggerNode?.v;\n\t\t\tconst depBatches = lastRunDepBatches.get(target);\n\t\t\treturn {\n\t\t\t\ttrigger_dep_index: idx,\n\t\t\t\ttrigger_dep_name: triggerNode?.name,\n\t\t\t\t...(tv != null ? { trigger_version: { id: tv.id, version: tv.version } } : {}),\n\t\t\t\tdep_values: [...depValues],\n\t\t\t\t...(depBatches != null ? { dep_batches: depBatches } : {}),\n\t\t\t};\n\t\t};\n\n\t\tconst inspectorDetaches: Array<() => void> = [];\n\t\tconst unsubs: Array<() => void> = [];\n\t\tfor (const [path, target] of targets) {\n\t\t\tconst detach = attachInspector(target, path);\n\t\t\tif (detach) inspectorDetaches.push(detach);\n\t\t\tunsubs.push(\n\t\t\t\ttarget.subscribe((msgs) => {\n\t\t\t\t\tbatchSeq++;\n\t\t\t\t\tfor (const m of msgs) {\n\t\t\t\t\t\tconst t = m[0];\n\t\t\t\t\t\tconst base = baseMeta();\n\t\t\t\t\t\tif (t === DATA) {\n\t\t\t\t\t\t\tvalues[path] = m[1] as T;\n\t\t\t\t\t\t\trecordEvent({\n\t\t\t\t\t\t\t\ttype: \"data\",\n\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t\tdata: m[1],\n\t\t\t\t\t\t\t\t...base,\n\t\t\t\t\t\t\t\t...buildCausal(target),\n\t\t\t\t\t\t\t} as ObserveEvent);\n\t\t\t\t\t\t} else if (minimal) {\n\t\t\t\t\t\t\tif (t === DIRTY) dirtyCount++;\n\t\t\t\t\t\t\telse if (t === RESOLVED) resolvedCount++;\n\t\t\t\t\t\t\telse if (t === INVALIDATE) invalidateCount++;\n\t\t\t\t\t\t\telse if (t === PAUSE) pauseCount++;\n\t\t\t\t\t\t\telse if (t === RESUME) resumeCount++;\n\t\t\t\t\t\t\telse if (t === TEARDOWN) teardownCount++;\n\t\t\t\t\t\t\telse if (t === COMPLETE && !nodeErrored.has(path)) anyCompletedCleanly = true;\n\t\t\t\t\t\t\telse if (t === ERROR) {\n\t\t\t\t\t\t\t\tanyErrored = true;\n\t\t\t\t\t\t\t\tnodeErrored.add(path);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (t === DIRTY) {\n\t\t\t\t\t\t\tdirtyCount++;\n\t\t\t\t\t\t\trecordEvent({ type: \"dirty\", path, ...base } as ObserveEvent);\n\t\t\t\t\t\t} else if (t === RESOLVED) {\n\t\t\t\t\t\t\tresolvedCount++;\n\t\t\t\t\t\t\trecordEvent({\n\t\t\t\t\t\t\t\ttype: \"resolved\",\n\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t\t...base,\n\t\t\t\t\t\t\t\t...buildCausal(target),\n\t\t\t\t\t\t\t} as ObserveEvent);\n\t\t\t\t\t\t} else if (t === INVALIDATE) {\n\t\t\t\t\t\t\tinvalidateCount++;\n\t\t\t\t\t\t\trecordEvent({ type: \"invalidate\", path, ...base } as ObserveEvent);\n\t\t\t\t\t\t} else if (t === PAUSE) {\n\t\t\t\t\t\t\tpauseCount++;\n\t\t\t\t\t\t\trecordEvent({ type: \"pause\", path, lockId: m[1], ...base } as ObserveEvent);\n\t\t\t\t\t\t} else if (t === RESUME) {\n\t\t\t\t\t\t\tresumeCount++;\n\t\t\t\t\t\t\trecordEvent({ type: \"resume\", path, lockId: m[1], ...base } as ObserveEvent);\n\t\t\t\t\t\t} else if (t === COMPLETE) {\n\t\t\t\t\t\t\tif (!nodeErrored.has(path)) anyCompletedCleanly = true;\n\t\t\t\t\t\t\trecordEvent({ type: \"complete\", path, ...base } as ObserveEvent);\n\t\t\t\t\t\t} else if (t === ERROR) {\n\t\t\t\t\t\t\tanyErrored = true;\n\t\t\t\t\t\t\tnodeErrored.add(path);\n\t\t\t\t\t\t\trecordEvent({\n\t\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t\tdata: m[1],\n\t\t\t\t\t\t\t\t...base,\n\t\t\t\t\t\t\t} as ObserveEvent);\n\t\t\t\t\t\t} else if (t === TEARDOWN) {\n\t\t\t\t\t\t\tteardownCount++;\n\t\t\t\t\t\t\trecordEvent({ type: \"teardown\", path, ...base } as ObserveEvent);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tlet disposed = false;\n\t\tconst dispose = (): void => {\n\t\t\tif (disposed) return;\n\t\t\tdisposed = true;\n\t\t\tfor (const u of unsubs) u();\n\t\t\tfor (const d of inspectorDetaches) d();\n\t\t\tfor (const resolve of asyncResolvers) resolve({ value: undefined, done: true });\n\t\t\tasyncResolvers.length = 0;\n\t\t};\n\n\t\t// AsyncIterator plumbing: queue events until a pull arrives, or wake\n\t\t// a pending pull when a new event lands.\n\t\tconst asyncQueue: ObserveEvent[] = [];\n\t\tconst asyncResolvers: Array<(r: IteratorResult<ObserveEvent>) => void> = [];\n\t\tlisteners.add((ev) => {\n\t\t\tconst resolve = asyncResolvers.shift();\n\t\t\tif (resolve) resolve({ value: ev, done: false });\n\t\t\telse asyncQueue.push(ev);\n\t\t});\n\n\t\tconst result: ObserveResult<T> = {\n\t\t\tget values() {\n\t\t\t\treturn values;\n\t\t\t},\n\t\t\tget dirtyCount() {\n\t\t\t\treturn dirtyCount;\n\t\t\t},\n\t\t\tget resolvedCount() {\n\t\t\t\treturn resolvedCount;\n\t\t\t},\n\t\t\tget invalidateCount() {\n\t\t\t\treturn invalidateCount;\n\t\t\t},\n\t\t\tget pauseCount() {\n\t\t\t\treturn pauseCount;\n\t\t\t},\n\t\t\tget resumeCount() {\n\t\t\t\treturn resumeCount;\n\t\t\t},\n\t\t\tget teardownCount() {\n\t\t\t\treturn teardownCount;\n\t\t\t},\n\t\t\tget events() {\n\t\t\t\treturn ring ? ring.toArray() : [...events];\n\t\t\t},\n\t\t\tget anyCompletedCleanly() {\n\t\t\t\treturn anyCompletedCleanly;\n\t\t\t},\n\t\t\tget anyErrored() {\n\t\t\t\treturn anyErrored;\n\t\t\t},\n\t\t\tget completedWithoutErrors() {\n\t\t\t\treturn anyCompletedCleanly && !anyErrored;\n\t\t\t},\n\t\t\tonEvent(listener) {\n\t\t\t\tlisteners.add(listener);\n\t\t\t\treturn () => listeners.delete(listener);\n\t\t\t},\n\t\t\tdispose,\n\t\t\texpand(extra) {\n\t\t\t\tdispose();\n\t\t\t\tconst merged: ObserveOptions = { ...options };\n\t\t\t\tif (typeof extra === \"string\") {\n\t\t\t\t\tmerged.detail = extra;\n\t\t\t\t} else {\n\t\t\t\t\tObject.assign(merged, extra);\n\t\t\t\t}\n\t\t\t\treturn expand(resolveObserveDetail(merged));\n\t\t\t},\n\t\t\t[Symbol.asyncIterator](): AsyncIterator<ObserveEvent> {\n\t\t\t\treturn {\n\t\t\t\t\tnext(): Promise<IteratorResult<ObserveEvent>> {\n\t\t\t\t\t\tif (asyncQueue.length > 0) {\n\t\t\t\t\t\t\treturn Promise.resolve({ value: asyncQueue.shift()!, done: false });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (disposed) return Promise.resolve({ value: undefined, done: true });\n\t\t\t\t\t\treturn new Promise((resolve) => asyncResolvers.push(resolve));\n\t\t\t\t\t},\n\t\t\t\t\treturn(): Promise<IteratorResult<ObserveEvent>> {\n\t\t\t\t\t\tdispose();\n\t\t\t\t\t\treturn Promise.resolve({ value: undefined, done: true });\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\n\t\t// Format logger: subscribes to event stream, renders via theme/format.\n\t\tif (options.format != null) this._attachFormatLogger(result, options);\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Attach format-rendering logger to an ObserveResult by subscribing to its\n\t * event stream (no monkey-patching). Renders each event per `format` and\n\t * `theme`, filtered by `includeTypes` / `excludeTypes`.\n\t */\n\tprivate _attachFormatLogger(result: ObserveResult, options: ObserveOptions): void {\n\t\tconst format = options.format;\n\t\tif (format == null) return;\n\t\tconst logger = options.logger ?? ((line: string) => console.log(line));\n\t\t// Compile include/exclude predicates once.\n\t\tconst include = options.includeTypes ? new Set(options.includeTypes) : null;\n\t\tconst exclude = options.excludeTypes ? new Set(options.excludeTypes) : null;\n\t\tconst shouldLog =\n\t\t\tinclude == null && exclude == null\n\t\t\t\t? () => true\n\t\t\t\t: (type: ObserveEvent[\"type\"]): boolean =>\n\t\t\t\t\t\t(include == null || include.has(type)) && (exclude == null || !exclude.has(type));\n\t\tconst theme = resolveObserveTheme(options.theme);\n\n\t\tconst renderEvent = (event: ObserveEvent): string => {\n\t\t\tif (format === \"json\") {\n\t\t\t\ttry {\n\t\t\t\t\treturn JSON.stringify(event);\n\t\t\t\t} catch {\n\t\t\t\t\treturn JSON.stringify({\n\t\t\t\t\t\ttype: event.type,\n\t\t\t\t\t\tpath: event.path,\n\t\t\t\t\t\tdata: \"[unserializable]\",\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst color = theme[event.type] ?? \"\";\n\t\t\tconst pathPart = event.path ? `${theme.path}${event.path}${theme.reset} ` : \"\";\n\t\t\tconst isDataBearing = event.type === \"data\" || event.type === \"error\";\n\t\t\tconst isLockBearing = event.type === \"pause\" || event.type === \"resume\";\n\t\t\tconst dataPart = isDataBearing\n\t\t\t\t? ` ${describeData((event as { data: unknown }).data)}`\n\t\t\t\t: isLockBearing\n\t\t\t\t\t? ` ${describeData((event as { lockId: unknown }).lockId)}`\n\t\t\t\t\t: \"\";\n\t\t\tconst causal =\n\t\t\t\tevent.type === \"data\" || event.type === \"resolved\" || event.type === \"derived\"\n\t\t\t\t\t? (event as ObserveCausalContext)\n\t\t\t\t\t: undefined;\n\t\t\tconst triggerPart =\n\t\t\t\tcausal?.trigger_dep_name != null\n\t\t\t\t\t? ` <- ${causal.trigger_dep_name}`\n\t\t\t\t\t: causal?.trigger_dep_index != null\n\t\t\t\t\t\t? ` <- #${causal.trigger_dep_index}`\n\t\t\t\t\t\t: \"\";\n\t\t\tconst batchPart = event.in_batch ? \" [batch]\" : \"\";\n\t\t\treturn `${pathPart}${color}${event.type.toUpperCase()}${theme.reset}${dataPart}${triggerPart}${batchPart}`;\n\t\t};\n\n\t\tresult.onEvent((event) => {\n\t\t\tif (shouldLog(event.type)) logger(renderEvent(event), event);\n\t\t});\n\t}\n\n\t// `dumpGraph` is folded into `describe({format: \"pretty\" | \"json\"})` (Unit 12).\n\t// `toMermaid` / `toD2` are folded into `describe({format: \"mermaid\" | \"d2\"})` (Unit 20).\n\n\t// ——————————————————————————————————————————————————————————————\n\t// Lifecycle & persistence (§3.7–§3.8)\n\t// ——————————————————————————————————————————————————————————————\n\n\t/**\n\t * Register a cleanup function to be called on {@link Graph.destroy}.\n\t *\n\t * Factories use this to attach teardown logic for internal nodes, keepalive\n\t * subscriptions, or other resources that are not registered on the graph and\n\t * would otherwise leak on repeated create/destroy cycles.\n\t *\n\t * Returns a removal function — call it to unregister the disposer early.\n\t */\n\taddDisposer(fn: () => void): () => void {\n\t\tthis._disposers.add(fn);\n\t\treturn () => {\n\t\t\tthis._disposers.delete(fn);\n\t\t};\n\t}\n\n\t/**\n\t * Drains disposers (registered via {@link addDisposer}), then sends `[[TEARDOWN]]` to all\n\t * nodes and clears registries on this graph and every mounted subgraph (§3.7).\n\t * The instance is left empty and may be reused with {@link Graph.add}.\n\t */\n\tdestroy(): void {\n\t\t// Drain disposers (keepalive unsubs etc.) BEFORE TEARDOWN so that\n\t\t// internal effect nodes are disconnected before the cascade fires.\n\t\t// Drain iteratively so disposers registered mid-drain also run; cap\n\t\t// iterations to guard against a disposer that re-registers itself.\n\t\tdrainDisposers(this._disposers, this.name);\n\t\t// TEARDOWN is tier 5 — below `attachStorage`'s `tier < 5` gate, so no\n\t\t// final checkpoint fires; storage disposers unsubscribe after TEARDOWN\n\t\t// has propagated through the subscription pipeline.\n\t\tthis.signal([[TEARDOWN]] satisfies Messages, { internal: true });\n\t\tdrainDisposers(this._storageDisposers, this.name);\n\t\tfor (const child of [...this._mounts.values()]) {\n\t\t\tchild._parent = undefined;\n\t\t\tchild._destroyClearOnly();\n\t\t}\n\t\tthis._mounts.clear();\n\t\tthis._nodes.clear();\n\t\tthis._parent = undefined;\n\t}\n\n\t/** Clear structure after parent already signaled TEARDOWN through this subtree. */\n\tprivate _destroyClearOnly(): void {\n\t\tfor (const child of [...this._mounts.values()]) {\n\t\t\tchild._parent = undefined;\n\t\t\tchild._destroyClearOnly();\n\t\t}\n\t\tthis._mounts.clear();\n\t\tthis._nodes.clear();\n\t\tthis._parent = undefined;\n\t}\n\n\t/**\n\t * Serializes structure and current values to JSON-shaped data (§3.8). Same\n\t * information as {@link Graph.describe} plus a `version` field for format\n\t * evolution.\n\t *\n\t * The overload path supports three outputs:\n\t * - no arg → `GraphPersistSnapshot` (plain JS object).\n\t * - `{format: \"json-string\"}` → deterministic JSON `string`\n\t * (key-sorted; safe for hashing or file write).\n\t * - `{format: \"bytes\", codec: name}` → `Uint8Array` wrapped in the v1\n\t * envelope from {@link encodeEnvelope}. The codec must be registered\n\t * on this graph's {@link GraphReFlyConfig} via `config.registerCodec`.\n\t * Paired with {@link Graph.decode} for auto-dispatch on the read side.\n\t */\n\tsnapshot(): GraphPersistSnapshot;\n\tsnapshot(opts: { format: \"json-string\" }): string;\n\tsnapshot(opts: { format: \"bytes\"; codec: string }): Uint8Array;\n\tsnapshot(opts?: {\n\t\tformat?: \"json-string\" | \"bytes\";\n\t\tcodec?: string;\n\t}): GraphPersistSnapshot | string | Uint8Array {\n\t\tconst { expand: _, ...d } = this.describe({ detail: \"full\" });\n\t\t// Explicit key sorting for deterministic output — don't rely on\n\t\t// describe() iteration order (audit batch-3, §3.8).\n\t\t// Strip non-restorable fields (runtime attribution) so snapshot → restore → snapshot\n\t\t// is idempotent. Use describe({ detail: \"full\" }) for audit snapshots instead.\n\t\tconst sortedNodes: Record<string, DescribeNodeOutput> = {};\n\t\tfor (const key of Object.keys(d.nodes).sort()) {\n\t\t\tconst { lastMutation: _lm, guard: _g, ...node } = d.nodes[key]!;\n\t\t\tsortedNodes[key] = node;\n\t\t}\n\t\tconst sortedSubgraphs = [...d.subgraphs].sort();\n\t\tconst snap: GraphPersistSnapshot = {\n\t\t\t...d,\n\t\t\tversion: 1,\n\t\t\tnodes: sortedNodes,\n\t\t\tsubgraphs: sortedSubgraphs,\n\t\t};\n\t\tif (opts?.format == null) return snap;\n\t\tif (opts.format === \"json-string\") return JSON.stringify(snap);\n\t\tif (opts.format === \"bytes\") {\n\t\t\tif (opts.codec == null) {\n\t\t\t\tthrow new Error(\"snapshot({format: 'bytes'}) requires a `codec` name\");\n\t\t\t}\n\t\t\tconst codec = this.config.lookupCodec<GraphCodec>(opts.codec);\n\t\t\tif (codec == null) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`snapshot: codec \"${opts.codec}\" is not registered on this graph's config. ` +\n\t\t\t\t\t\t`Call config.registerCodec(...) before creating nodes.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn encodeEnvelope(codec, codec.encode(snap));\n\t\t}\n\t\tthrow new Error(`snapshot: unknown format \"${String(opts.format)}\"`);\n\t}\n\n\t/**\n\t * Auto-dispatch a byte buffer produced by {@link Graph.snapshot} with\n\t * `{format: \"bytes\", codec: name}`. Reads the v1 envelope, resolves the\n\t * named codec on `config` (defaults to `defaultConfig`), and returns the\n\t * decoded snapshot. Combine with {@link Graph.fromSnapshot} to rehydrate\n\t * a full graph topology from bytes.\n\t *\n\t * @throws If the envelope is malformed or the named codec isn't\n\t * registered on the target config.\n\t */\n\tstatic decode(bytes: Uint8Array, opts?: { config?: GraphReFlyConfig }): GraphPersistSnapshot {\n\t\tconst cfg = opts?.config ?? defaultConfig;\n\t\tconst { codec, codecVersion, payload } = decodeEnvelope(bytes, cfg);\n\t\treturn codec.decode(payload, codecVersion);\n\t}\n\n\t/**\n\t * Apply persisted values onto an existing graph whose topology matches the snapshot\n\t * (§3.8). Only {@link DescribeNodeOutput.type} `state` entries with a `value` field\n\t * are written by default; `derived` / `operator` / `effect` are always skipped so\n\t * deps drive recomputation. `producer` entries are skipped unless `includeProducers`\n\t * is set (producers recompute on activation, so restoring is usually a no-op\n\t * overwritten on the next wave — opt in for audit / forensic round-trip use cases).\n\t * Unknown paths are ignored.\n\t *\n\t * @param data - Snapshot envelope with matching `name` and node slices.\n\t * @throws If `data.name` does not equal {@link Graph.name}.\n\t */\n\trestore(\n\t\tdata: GraphPersistSnapshot,\n\t\toptions?: {\n\t\t\tonly?: string | readonly string[];\n\t\t\t/**\n\t\t\t * Fires per failing write. Default behavior (omitted) is silent —\n\t\t\t * missing paths and guard denials are swallowed to match the\n\t\t\t * historical semantics. Provide a callback to surface failures\n\t\t\t * without aborting the remaining restores.\n\t\t\t */\n\t\t\tonError?: (path: string, err: unknown) => void;\n\t\t\t/**\n\t\t\t * Restore `producer` node values alongside `state`. Default `false`:\n\t\t\t * producers are reactive sources whose value recomputes on\n\t\t\t * activation, so restoring from a snapshot is usually a no-op\n\t\t\t * overwritten on the next wave. Audit / forensic round-trip use\n\t\t\t * cases that need the stored value to survive restoration can\n\t\t\t * opt in. Does not change `derived` / `effect` handling — those\n\t\t\t * are always skipped.\n\t\t\t */\n\t\t\tincludeProducers?: boolean;\n\t\t},\n\t): void {\n\t\tparseSnapshotEnvelope(data);\n\t\tif (data.name !== this.name) {\n\t\t\tthrow new Error(\n\t\t\t\t`Graph \"${this.name}\": restore snapshot name \"${data.name}\" does not match this graph`,\n\t\t\t);\n\t\t}\n\t\tconst onlyPatterns =\n\t\t\toptions?.only == null\n\t\t\t\t? null\n\t\t\t\t: (Array.isArray(options.only) ? options.only : [options.only]).map((p) => globToRegex(p));\n\t\tconst includeProducers = options?.includeProducers === true;\n\t\tfor (const path of Object.keys(data.nodes).sort()) {\n\t\t\tif (onlyPatterns !== null && !onlyPatterns.some((re) => re.test(path))) continue;\n\t\t\tconst slice = data.nodes[path];\n\t\t\tif (slice === undefined) continue;\n\t\t\tif (!(\"value\" in slice) || slice.value === undefined) {\n\t\t\t\t// Value absent (valid slice with no snapshotted value) or\n\t\t\t\t// value === undefined (malformed — undefined is the global\n\t\t\t\t// SENTINEL per spec §2.5, not valid DATA). Surface the\n\t\t\t\t// malformed case so torn snapshots don't round-trip silently.\n\t\t\t\tif (\"value\" in slice && slice.value === undefined) {\n\t\t\t\t\toptions?.onError?.(\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t`restore: slice.value is undefined for \"${path}\" (undefined is the global SENTINEL; not valid DATA)`,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (slice.type === \"derived\" || slice.type === \"effect\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (slice.type === \"producer\" && !includeProducers) {\n\t\t\t\t// Reactive producers recompute on activation — restoring would\n\t\t\t\t// be overwritten on the first wave. Opt in via\n\t\t\t\t// `{includeProducers: true}` for audit use cases.\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// V0 shortcut: if the snapshot slice and the live node both carry\n\t\t\t// matching versioning info (`v.id` + `v.version`), skip the\n\t\t\t// `set()` — the state is already what the snapshot represents.\n\t\t\t// Avoids redundant DATA waves on idempotent restores.\n\t\t\tif (slice.v != null) {\n\t\t\t\tconst live = this.tryResolve(path);\n\t\t\t\tconst lv = live?.v;\n\t\t\t\tif (lv != null && lv.id === slice.v.id && lv.version === slice.v.version) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tthis.set(path, slice.value);\n\t\t\t} catch (err) {\n\t\t\t\toptions?.onError?.(path, err);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Creates a graph named from the snapshot, optionally runs `build` to register nodes\n\t * and mounts, then {@link Graph.restore} values (§3.8).\n\t *\n\t * @param data - Snapshot envelope (`version` checked).\n\t * @param opts - Either a legacy `build(g)` callback, or an options object:\n\t * - `build?` — topology constructor; skips auto-hydration when present.\n\t * - `factories?` — map from glob pattern to {@link GraphNodeFactory},\n\t * used by auto-hydration to reconstruct non-state nodes. Per-call (no\n\t * process-global registry). First matching pattern wins.\n\t * @returns Hydrated `Graph` instance.\n\t */\n\tstatic fromSnapshot(\n\t\tdata: GraphPersistSnapshot,\n\t\topts?:\n\t\t\t| ((g: Graph) => void)\n\t\t\t| { build?: (g: Graph) => void; factories?: Record<string, GraphNodeFactory> },\n\t): Graph {\n\t\tparseSnapshotEnvelope(data);\n\t\tconst build = typeof opts === \"function\" ? opts : opts?.build;\n\t\tconst factoryMap = typeof opts === \"function\" ? undefined : opts?.factories;\n\t\tconst g = new Graph(data.name);\n\t\tif (build) {\n\t\t\tbuild(g);\n\t\t\tg.restore(data);\n\t\t\treturn g;\n\t\t}\n\t\t// Auto-create mount hierarchy from subgraphs.\n\t\tfor (const mount of [...data.subgraphs].sort((a, b) => {\n\t\t\tconst da = a.split(PATH_SEP).length;\n\t\t\tconst db = b.split(PATH_SEP).length;\n\t\t\tif (da !== db) return da - db;\n\t\t\tif (a < b) return -1;\n\t\t\tif (a > b) return 1;\n\t\t\treturn 0;\n\t\t})) {\n\t\t\tconst parts = mount.split(PATH_SEP);\n\t\t\tlet target: Graph = g;\n\t\t\tfor (const seg of parts) {\n\t\t\t\tif (!target._mounts.has(seg)) {\n\t\t\t\t\ttarget.mount(seg, new Graph(seg));\n\t\t\t\t}\n\t\t\t\ttarget = target._mounts.get(seg)!;\n\t\t\t}\n\t\t}\n\n\t\t// Compile factory glob patterns once. First match in insertion order wins.\n\t\tconst factories = factoryMap\n\t\t\t? Object.entries(factoryMap).map(([pattern, factory]) => ({\n\t\t\t\t\tre: globToRegex(pattern),\n\t\t\t\t\tfactory,\n\t\t\t\t}))\n\t\t\t: [];\n\t\tconst factoryForPath = (path: string): GraphNodeFactory | undefined => {\n\t\t\tfor (const entry of factories) {\n\t\t\t\tif (entry.re.test(path)) return entry.factory;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t};\n\n\t\t// Resolve the owning graph + local name for a qualified snapshot path.\n\t\tconst ownerForPath = (path: string): [Graph, string] => {\n\t\t\tconst segments = path.split(PATH_SEP);\n\t\t\tconst local = segments.pop();\n\t\t\tif (local == null || local.length === 0) {\n\t\t\t\tthrow new Error(`invalid snapshot path \"${path}\"`);\n\t\t\t}\n\t\t\tlet owner: Graph = g;\n\t\t\tfor (const seg of segments) {\n\t\t\t\tconst next = owner._mounts.get(seg);\n\t\t\t\tif (!next) throw new Error(`unknown mount \"${seg}\" in path \"${path}\"`);\n\t\t\t\towner = next;\n\t\t\t}\n\t\t\treturn [owner, local];\n\t\t};\n\n\t\tconst primaryEntries = Object.entries(data.nodes)\n\t\t\t.filter(([path]) => !path.includes(`${PATH_SEP}${GRAPH_META_SEGMENT}${PATH_SEP}`))\n\t\t\t.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0));\n\t\tconst pending = new Map(primaryEntries);\n\t\tconst created = new Map<string, Node>();\n\n\t\tlet progressed = true;\n\t\twhile (pending.size > 0 && progressed) {\n\t\t\tprogressed = false;\n\t\t\tfor (const [path, slice] of [...pending.entries()]) {\n\t\t\t\tconst deps = slice?.deps ?? [];\n\t\t\t\tif (!deps.every((dep) => created.has(dep))) continue;\n\t\t\t\tconst [owner, localName] = ownerForPath(path);\n\t\t\t\tconst meta: Record<string, unknown> = { ...(slice?.meta ?? {}) };\n\t\t\t\tconst factory = factoryForPath(path);\n\t\t\t\tlet node: Node;\n\t\t\t\tif (slice?.type === \"state\") {\n\t\t\t\t\tnode = stateNode(slice.value, { meta });\n\t\t\t\t} else {\n\t\t\t\t\tif (factory == null) continue;\n\t\t\t\t\tnode = factory(localName, {\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\ttype: slice.type,\n\t\t\t\t\t\tvalue: slice.value,\n\t\t\t\t\t\tmeta,\n\t\t\t\t\t\tdeps,\n\t\t\t\t\t\tresolvedDeps: deps.map((dep) => created.get(dep)!),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\towner.add(localName, node);\n\t\t\t\tcreated.set(path, node);\n\t\t\t\tpending.delete(path);\n\t\t\t\tprogressed = true;\n\t\t\t}\n\t\t}\n\t\tif (pending.size > 0) {\n\t\t\tconst unresolved = [...pending.keys()].sort().join(\", \");\n\t\t\tthrow new Error(\n\t\t\t\t`Graph.fromSnapshot could not reconstruct nodes without build callback: ${unresolved}. ` +\n\t\t\t\t\t`Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`,\n\t\t\t);\n\t\t}\n\t\t// Edges are derived from node `_deps` reconstructed during node\n\t\t// creation above — no explicit edge replay needed (Unit 7).\n\t\tg.restore(data);\n\t\treturn g;\n\t}\n\n\t/**\n\t * ECMAScript `JSON.stringify` hook — returns the same object as\n\t * {@link Graph.snapshot}. Makes `JSON.stringify(graph)` \"just work\"\n\t * without double-encoding.\n\t */\n\ttoJSON(): GraphPersistSnapshot {\n\t\treturn this.snapshot();\n\t}\n\n\t/**\n\t * Unified persistence surface (§3.8). Cascades snapshot records through\n\t * one or more {@link StorageTier}s, each with its own `debounceMs` /\n\t * `compactEvery` cadence and independent diff baseline.\n\t *\n\t * Subscription gates on {@link messageTier} ≥ 3 (DATA/RESOLVED/terminal),\n\t * never on tier-0/1/2 control waves (START/DIRTY/INVALIDATE/PAUSE/RESUME)\n\t * or tier-5 TEARDOWN (graceful shutdown is the caller's responsibility).\n\t *\n\t * Per-tier cadence lets the hot tier stay sync while cold tiers absorb\n\t * async writes without blocking the hot path. Each tier holds its own\n\t * `{lastSnapshot, lastVersionFingerprint}` so cold-tier diff baselines\n\t * aren't polluted by hot-tier flushes. Tiers with `debounceMs === 0`\n\t * share a single snapshot computation per observe event; debounced tiers\n\t * compute their own snapshot when their timer fires.\n\t */\n\tattachStorage(\n\t\ttiers: readonly StorageTier[],\n\t\toptions: GraphAttachStorageOptions = {},\n\t): StorageHandle {\n\t\ttype TierState = {\n\t\t\ttier: StorageTier;\n\t\t\tdebounceMs: number;\n\t\t\tcompactEvery: number;\n\t\t\ttimer: ResettableTimer | undefined;\n\t\t\tseq: number;\n\t\t\tlastSnapshot: GraphPersistSnapshot | undefined;\n\t\t\tlastFingerprint: string;\n\t\t\tdisposed: boolean;\n\t\t\t// Chain of pending async saves for this tier. Each flush awaits the\n\t\t\t// previous one so baseline advances only after persistence confirms;\n\t\t\t// on rejection the chain resets (next flush starts from the last\n\t\t\t// successfully-persisted baseline). Sync tiers never populate this.\n\t\t\tsavePending: Promise<void> | undefined;\n\t\t};\n\t\tconst states: TierState[] = tiers.map((tier) => ({\n\t\t\ttier,\n\t\t\tdebounceMs: Math.max(0, tier.debounceMs ?? 0),\n\t\t\tcompactEvery: Math.max(1, tier.compactEvery ?? 10),\n\t\t\ttimer: undefined,\n\t\t\tseq: 0,\n\t\t\tlastSnapshot: undefined,\n\t\t\tlastFingerprint: \"\",\n\t\t\tdisposed: false,\n\t\t\tsavePending: undefined,\n\t\t}));\n\n\t\tif (options.autoRestore === true) {\n\t\t\t// Fire-and-forget cascade restore; errors surface via onError with\n\t\t\t// the specific tier that failed.\n\t\t\tvoid this._cascadeRestore(tiers, options.onError);\n\t\t}\n\n\t\tconst runFlush = (s: TierState, snapshot: GraphPersistSnapshot): void => {\n\t\t\tif (s.disposed) return;\n\t\t\tconst fingerprint = computeVersionFingerprint(snapshot.nodes);\n\t\t\tif (s.lastSnapshot != null && fingerprint !== \"\" && fingerprint === s.lastFingerprint) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst nextSeq = s.seq + 1;\n\t\t\t// Persisted records carry wall-clock attribution (CLAUDE.md time-util\n\t\t\t// rule). Internal event-order timestamps use monotonicNs — this is the\n\t\t\t// output-to-durable-store boundary, so wall clock is correct and\n\t\t\t// cross-source comparable with surface.saveSnapshot records.\n\t\t\tconst timestamp_ns = wallClockNs();\n\t\t\tconst isFirst = s.lastSnapshot == null;\n\t\t\tconst shouldCompact = isFirst || nextSeq % s.compactEvery === 0;\n\t\t\tconst record: GraphCheckpointRecord = shouldCompact\n\t\t\t\t? {\n\t\t\t\t\t\tmode: \"full\",\n\t\t\t\t\t\tsnapshot,\n\t\t\t\t\t\tseq: nextSeq,\n\t\t\t\t\t\ttimestamp_ns,\n\t\t\t\t\t\tformat_version: SNAPSHOT_VERSION,\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tmode: \"diff\",\n\t\t\t\t\t\tdiff: diffForWAL(s.lastSnapshot!, snapshot),\n\t\t\t\t\t\tseq: nextSeq,\n\t\t\t\t\t\ttimestamp_ns,\n\t\t\t\t\t\tformat_version: SNAPSHOT_VERSION,\n\t\t\t\t\t};\n\t\t\tif (s.tier.filter && !s.tier.filter(this.name, record)) {\n\t\t\t\t// Filter rejected — don't advance seq or baseline.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet result: void | Promise<void>;\n\t\t\ttry {\n\t\t\t\tresult = s.tier.save(this.name, record);\n\t\t\t} catch (error) {\n\t\t\t\t// Synchronous throw — baseline untouched; surface and bail.\n\t\t\t\toptions.onError?.(error, s.tier);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (result && typeof (result as Promise<void>).then === \"function\") {\n\t\t\t\t// Async tier: defer baseline + seq advance until the promise\n\t\t\t\t// settles. Chain saves per-tier so they land in order without\n\t\t\t\t// overlapping baselines. On rejection, baseline is left intact\n\t\t\t\t// so the next flush diffs against the last successfully\n\t\t\t\t// persisted snapshot.\n\t\t\t\tconst prev = s.savePending ?? Promise.resolve();\n\t\t\t\tconst chained = prev.then(\n\t\t\t\t\t() => result as Promise<void>,\n\t\t\t\t\t// Previous rejection already surfaced; don't block this save.\n\t\t\t\t\t() => result as Promise<void>,\n\t\t\t\t);\n\t\t\t\tconst final = chained.then(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tif (s.disposed) return;\n\t\t\t\t\t\ts.seq = nextSeq;\n\t\t\t\t\t\ts.lastSnapshot = snapshot;\n\t\t\t\t\t\ts.lastFingerprint = fingerprint;\n\t\t\t\t\t},\n\t\t\t\t\t(err) => {\n\t\t\t\t\t\toptions.onError?.(err, s.tier);\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\ts.savePending = final.finally(() => {\n\t\t\t\t\tif (s.savePending === final) s.savePending = undefined;\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\ts.seq = nextSeq;\n\t\t\t\ts.lastSnapshot = snapshot;\n\t\t\t\ts.lastFingerprint = fingerprint;\n\t\t\t}\n\t\t};\n\n\t\tconst flushTier = (s: TierState, snapshot: GraphPersistSnapshot): void => {\n\t\t\ttry {\n\t\t\t\trunFlush(s, snapshot);\n\t\t\t} catch (error) {\n\t\t\t\toptions.onError?.(error, s.tier);\n\t\t\t}\n\t\t};\n\n\t\tconst onEvent = (path: string, messages: Messages): void => {\n\t\t\tconst triggeredByTier = messages.some((m) => {\n\t\t\t\tconst tier = this.config.messageTier(m[0]);\n\t\t\t\treturn tier >= 3 && tier < 5;\n\t\t\t});\n\t\t\tif (!triggeredByTier) return;\n\t\t\tif (options.filter) {\n\t\t\t\tconst nd = this.tryResolve(path);\n\t\t\t\tif (nd == null) return;\n\t\t\t\tconst described = describeNode(nd, resolveDescribeFields(\"standard\"));\n\t\t\t\tif (!options.filter(path, described)) return;\n\t\t\t}\n\t\t\t// Shared snapshot for all sync (debounceMs=0) tiers firing on this event.\n\t\t\tlet sharedSnapshot: GraphPersistSnapshot | undefined;\n\t\t\tconst getSnapshot = (): GraphPersistSnapshot => {\n\t\t\t\tif (sharedSnapshot == null) sharedSnapshot = this.snapshot();\n\t\t\t\treturn sharedSnapshot;\n\t\t\t};\n\t\t\tfor (const s of states) {\n\t\t\t\tif (s.disposed) continue;\n\t\t\t\tif (s.debounceMs === 0) {\n\t\t\t\t\tflushTier(s, getSnapshot());\n\t\t\t\t} else {\n\t\t\t\t\tif (s.timer == null) s.timer = new ResettableTimer();\n\t\t\t\t\ts.timer.start(s.debounceMs, () => {\n\t\t\t\t\t\tif (s.disposed) return;\n\t\t\t\t\t\tflushTier(s, this.snapshot());\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tlet off: () => void;\n\t\tif (options.paths != null) {\n\t\t\tconst paths =\n\t\t\t\ttypeof options.paths === \"string\"\n\t\t\t\t\t? this._pathsMatching(options.paths)\n\t\t\t\t\t: (options.paths as readonly string[]);\n\t\t\tconst unsubs = paths.map((p) => {\n\t\t\t\tconst nd = this.tryResolve(p);\n\t\t\t\tif (nd == null) return () => {};\n\t\t\t\treturn nd.subscribe((msgs) => onEvent(p, msgs));\n\t\t\t});\n\t\t\toff = () => {\n\t\t\t\tfor (const u of unsubs) u();\n\t\t\t};\n\t\t} else {\n\t\t\toff = this.observe().subscribe((path, messages) => onEvent(path, messages));\n\t\t}\n\n\t\tconst dispose = () => {\n\t\t\toff();\n\t\t\tfor (const s of states) {\n\t\t\t\ts.disposed = true;\n\t\t\t\ts.timer?.cancel();\n\t\t\t}\n\t\t\tthis._storageDisposers.delete(dispose);\n\t\t};\n\t\tthis._storageDisposers.add(dispose);\n\t\treturn { dispose };\n\t}\n\n\t/**\n\t * Try tiers in order (hottest first); apply the first record that hits\n\t * via {@link Graph.restore}. Returns `true` if any tier produced a\n\t * restorable snapshot, `false` if all missed.\n\t *\n\t * Resilience: a tier that returns data which cannot be restored (load\n\t * throws, shape unrecognized, or `restore()` itself throws) does not abort\n\t * the cascade — the error is routed through `onError` (if supplied) and\n\t * the next colder tier is tried. This mirrors how a multi-tier cache\n\t * falls through on a corrupt hot entry.\n\t *\n\t * Note: `restore()` mutates state incrementally. If a restore throws\n\t * partway through, the graph may hold a mixed state (some slices from\n\t * the bad tier, some pre-existing). A subsequent successful tier's\n\t * `restore()` overwrites the overlapping slices.\n\t *\n\t * Internal helper shared by {@link Graph.attachStorage}'s `autoRestore`\n\t * option and the static {@link Graph.fromStorage} factory.\n\t */\n\tprivate async _cascadeRestore(\n\t\ttiers: readonly StorageTier[],\n\t\tonError?: (err: unknown, tier: StorageTier) => void,\n\t): Promise<boolean> {\n\t\tfor (const tier of tiers) {\n\t\t\tlet raw: unknown;\n\t\t\ttry {\n\t\t\t\traw = await tier.load(this.name);\n\t\t\t} catch (err) {\n\t\t\t\tonError?.(err, tier);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (raw == null) continue;\n\t\t\tif (typeof raw !== \"object\" || Array.isArray(raw)) continue;\n\t\t\tconst record = raw as Record<string, unknown>;\n\t\t\ttry {\n\t\t\t\t// Accept both a `GraphCheckpointRecord` envelope\n\t\t\t\t// (`mode === \"full\"`) and a bare `GraphPersistSnapshot` (the\n\t\t\t\t// shape written by `saveGraphCheckpoint`). Bare snapshots\n\t\t\t\t// carry `version: 1`.\n\t\t\t\tif (record.mode === \"full\" && record.snapshot != null) {\n\t\t\t\t\tthis.restore(record.snapshot as GraphPersistSnapshot);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (record.version === SNAPSHOT_VERSION && record.nodes != null) {\n\t\t\t\t\tthis.restore(record as GraphPersistSnapshot);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tonError?.(err, tier);\n\t\t\t\t// Fall through to the next tier.\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Construct a fresh {@link Graph} pre-hydrated from the first tier that\n\t * hits. Delegates topology reconstruction to {@link Graph.fromSnapshot}\n\t * on `\"full\"` records and direct {@link Graph.restore} on bare snapshots.\n\t *\n\t * Always asynchronous — awaits `tier.load()` for async tier support even\n\t * when all tiers are sync. Callers that know they only pass sync tiers\n\t * can safely `await` immediately.\n\t *\n\t * @throws If no tier holds a restorable record matching `name` *and* no\n\t * `factories` override is provided for dynamic nodes.\n\t */\n\tstatic async fromStorage(\n\t\tname: string,\n\t\ttiers: readonly StorageTier[],\n\t\topts?: GraphOptions & {\n\t\t\tfactories?: Record<string, GraphNodeFactory>;\n\t\t\t/**\n\t\t\t * Called when a tier throws during `load()` or when\n\t\t\t * {@link Graph.fromSnapshot} rejects a tier's record. The cascade\n\t\t\t * falls through to the next colder tier regardless.\n\t\t\t */\n\t\t\tonError?: (err: unknown, tier: StorageTier) => void;\n\t\t},\n\t): Promise<Graph> {\n\t\tfor (const tier of tiers) {\n\t\t\tlet raw: unknown;\n\t\t\ttry {\n\t\t\t\traw = await tier.load(name);\n\t\t\t} catch (err) {\n\t\t\t\topts?.onError?.(err, tier);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (raw == null) continue;\n\t\t\tif (typeof raw !== \"object\" || Array.isArray(raw)) continue;\n\t\t\tconst record = raw as Record<string, unknown>;\n\t\t\tconst snapshot: GraphPersistSnapshot | undefined =\n\t\t\t\trecord.mode === \"full\" && record.snapshot != null\n\t\t\t\t\t? (record.snapshot as GraphPersistSnapshot)\n\t\t\t\t\t: record.version === SNAPSHOT_VERSION && record.nodes != null\n\t\t\t\t\t\t? (record as GraphPersistSnapshot)\n\t\t\t\t\t\t: undefined;\n\t\t\tif (snapshot == null) continue;\n\t\t\ttry {\n\t\t\t\treturn Graph.fromSnapshot(snapshot, opts);\n\t\t\t} catch (err) {\n\t\t\t\topts?.onError?.(err, tier);\n\t\t\t\t// Fall through to colder tier.\n\t\t\t}\n\t\t}\n\t\tthrow new Error(\n\t\t\t`Graph.fromStorage: no tier held a restorable record for \"${name}\" across ${tiers.length} tier(s)`,\n\t\t);\n\t}\n\n\t// ——————————————————————————————————————————————————————————————\n\t// Inspector (roadmap 3.3) — reasoning trace, overhead gating\n\t// ——————————————————————————————————————————————————————————————\n\n\t// Inspector gating lives on `this.config.inspectorEnabled` (see\n\t// `core/config.ts`). Default: `true` outside `NODE_ENV === \"production\"`.\n\n\tprivate _annotations = new Map<string, string>();\n\tprivate readonly _traceRing: RingBuffer<TraceEntry>;\n\n\t/**\n\t * Unified reasoning trace: write annotations or read the ring buffer.\n\t *\n\t * Write: `graph.trace(\"path\", \"reason\")` — attaches a reasoning annotation\n\t * to a node, capturing *why* an AI agent set a value. Unknown paths are\n\t * silently dropped (matching `observe` resilience). No-op when\n\t * `config.inspectorEnabled` is `false`.\n\t *\n\t * Read: `graph.trace()` — returns a chronological log of all annotations.\n\t * Returns `[]` when `config.inspectorEnabled` is `false`.\n\t */\n\ttrace(path: string, reason: string, opts?: { actor?: Actor }): void;\n\ttrace(): readonly TraceEntry[];\n\ttrace(\n\t\tpath?: string,\n\t\treason?: string,\n\t\topts?: { actor?: Actor },\n\t): undefined | readonly TraceEntry[] {\n\t\tif (path != null && reason != null) {\n\t\t\tif (!this.config.inspectorEnabled) return;\n\t\t\t// Silent-drop unknown paths — matches `observe` resilience. Callers\n\t\t\t// with robust path-hygiene needs can pre-check via `tryResolve`.\n\t\t\tif (this.tryResolve(path) == null) return;\n\t\t\tthis._annotations.set(path, reason);\n\t\t\tconst entry: TraceEntry = {\n\t\t\t\tpath,\n\t\t\t\treason,\n\t\t\t\ttimestamp_ns: monotonicNs(),\n\t\t\t\t...(opts?.actor != null ? { actor: opts.actor } : {}),\n\t\t\t};\n\t\t\tthis._traceRing.push(entry);\n\t\t\treturn;\n\t\t}\n\t\tif (!this.config.inspectorEnabled) return [];\n\t\treturn this._traceRing.toArray();\n\t}\n\n\t/**\n\t * Latest reason annotation attached to `path` via {@link Graph.trace},\n\t * or `undefined` if none. `describe()` surfaces this via the `reason`\n\t * field on each node entry (when present).\n\t */\n\tannotation(path: string): string | undefined {\n\t\treturn this._annotations.get(path);\n\t}\n\n\t/**\n\t * Clear all reasoning-trace state (both the per-path annotations map and\n\t * the ring buffer). Useful for long-running processes that want periodic\n\t * resets, or tests that need a clean slate.\n\t */\n\tclearTrace(): void {\n\t\tthis._annotations.clear();\n\t\tthis._traceRing.clear();\n\t}\n\n\t/**\n\t * Remove trace entries matching `predicate`. Returns the number of\n\t * entries removed. Does not touch the per-path annotations map — call\n\t * {@link Graph.clearTrace} for a full reset.\n\t */\n\tpruneTrace(predicate: (entry: TraceEntry) => boolean): number {\n\t\tconst kept = this._traceRing.toArray().filter((e) => !predicate(e));\n\t\tconst removed = this._traceRing.size - kept.length;\n\t\tthis._traceRing.clear();\n\t\tfor (const e of kept) this._traceRing.push(e);\n\t\treturn removed;\n\t}\n\n\t/**\n\t * Computes structural + value diff between two {@link Graph.describe} snapshots.\n\t *\n\t * @param a - Earlier describe output.\n\t * @param b - Later describe output.\n\t * @returns Added/removed nodes, changed fields, and edge deltas.\n\t */\n\tstatic diff(a: GraphDescribeOutput, b: GraphDescribeOutput): GraphDiffResult {\n\t\tconst aKeys = new Set(Object.keys(a.nodes));\n\t\tconst bKeys = new Set(Object.keys(b.nodes));\n\n\t\tconst nodesAdded = [...bKeys].filter((k) => !aKeys.has(k)).sort();\n\t\tconst nodesRemoved = [...aKeys].filter((k) => !bKeys.has(k)).sort();\n\t\tconst nodesChanged: GraphDiffChange[] = [];\n\t\tconst versionChanges: GraphVersionChange[] = [];\n\n\t\tfor (const key of aKeys) {\n\t\t\tif (!bKeys.has(key)) continue;\n\t\t\tconst na = a.nodes[key];\n\t\t\tconst nb = b.nodes[key];\n\t\t\tconst av = na.v;\n\t\t\tconst bv = nb.v;\n\t\t\t// Surface version bumps (even if value is identical, the bump itself\n\t\t\t// is meaningful for audit / wire-efficient sync).\n\t\t\tif (av != null && bv != null && av.id === bv.id && av.version !== bv.version) {\n\t\t\t\tversionChanges.push({\n\t\t\t\t\tpath: key,\n\t\t\t\t\tid: av.id,\n\t\t\t\t\tfrom: av.version,\n\t\t\t\t\tto: bv.version,\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst versionMatches =\n\t\t\t\tav != null && bv != null && av.id === bv.id && av.version === bv.version;\n\t\t\t// V0 fast path: when versions match, skip value / meta compare —\n\t\t\t// upstream is guaranteed unchanged by protocol. Only type/status\n\t\t\t// (cheap string compare) + sentinel flip are possible.\n\t\t\tfor (const field of [\"type\", \"status\", \"sentinel\"] as const) {\n\t\t\t\tconst va = (na as Record<string, unknown>)[field];\n\t\t\t\tconst vb = (nb as Record<string, unknown>)[field];\n\t\t\t\tif (va !== vb) {\n\t\t\t\t\tnodesChanged.push({ path: key, field, from: va, to: vb });\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (versionMatches) continue;\n\t\t\t// Full slow-path: deep-equal on value + meta.\n\t\t\tfor (const field of [\"value\", \"meta\"] as const) {\n\t\t\t\tconst va = (na as Record<string, unknown>)[field];\n\t\t\t\tconst vb = (nb as Record<string, unknown>)[field];\n\t\t\t\tif (!deepEqual(va, vb)) {\n\t\t\t\t\tnodesChanged.push({ path: key, field, from: va, to: vb });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst edgeKey = (e: { from: string; to: string }) => `${e.from}\\t${e.to}`;\n\t\tconst aEdges = new Set(a.edges.map(edgeKey));\n\t\tconst bEdges = new Set(b.edges.map(edgeKey));\n\n\t\tconst edgesAdded = b.edges.filter((e) => !aEdges.has(edgeKey(e)));\n\t\tconst edgesRemoved = a.edges.filter((e) => !bEdges.has(edgeKey(e)));\n\t\tconst aSubgraphs = new Set(a.subgraphs);\n\t\tconst bSubgraphs = new Set(b.subgraphs);\n\t\tconst subgraphsAdded = [...bSubgraphs].filter((s) => !aSubgraphs.has(s)).sort();\n\t\tconst subgraphsRemoved = [...aSubgraphs].filter((s) => !bSubgraphs.has(s)).sort();\n\n\t\treturn {\n\t\t\tnodesAdded,\n\t\t\tnodesRemoved,\n\t\t\tnodesChanged,\n\t\t\tversionChanges,\n\t\t\tedgesAdded,\n\t\t\tedgesRemoved,\n\t\t\tsubgraphsAdded,\n\t\t\tsubgraphsRemoved,\n\t\t};\n\t}\n}\n\n/** Entry in the reasoning trace ring buffer (roadmap 3.3). */\nexport type TraceEntry = {\n\tpath: string;\n\treason: string;\n\ttimestamp_ns: number;\n\t/**\n\t * Actor that produced the annotation (optional). Enables multi-agent\n\t * attribution: distinguish \"LLM set this rootCause\" from \"human approved\n\t * this intervention\" in the trace log.\n\t */\n\tactor?: Actor;\n};\n\n/** Result of {@link Graph.diff}. */\nexport type GraphDiffResult = {\n\tnodesAdded: string[];\n\tnodesRemoved: string[];\n\tnodesChanged: GraphDiffChange[];\n\t/**\n\t * V0 version bumps (same `v.id`, different `v.version`). Surfaced even\n\t * when values are identical — the bump itself is audit-meaningful.\n\t */\n\tversionChanges: GraphVersionChange[];\n\tedgesAdded: Array<{ from: string; to: string }>;\n\tedgesRemoved: Array<{ from: string; to: string }>;\n\tsubgraphsAdded: string[];\n\tsubgraphsRemoved: string[];\n};\n\n/**\n * WAL-oriented diff — extends {@link GraphDiffResult} with the full node\n * slice for each added path so {@link replayWAL} can reconstruct nodes added\n * between full anchors (topology mutations inside a `compactEvery` window).\n *\n * `Graph.diff()` returns the audit shape (no payload); `attachStorage` writes\n * this WAL shape. The two shapes stay structurally compatible — `GraphWALDiff`\n * is a superset.\n */\nexport type GraphWALDiff = GraphDiffResult & {\n\t/**\n\t * Full node slices for every path in `nodesAdded`, keyed by path. Applied\n\t * verbatim to `snapshot.nodes[path]` during replay.\n\t */\n\tnodesAddedFull: Record<string, DescribeNodeOutput>;\n};\n\n/**\n * Build a WAL-ready diff between two snapshots: the structural diff from\n * {@link Graph.diff} plus the full node slice for each added path (pulled\n * from `b.nodes`). Callers that only need the audit shape should use\n * `Graph.diff` directly.\n */\nexport function diffForWAL(a: GraphDescribeOutput, b: GraphDescribeOutput): GraphWALDiff {\n\tconst base = Graph.diff(a, b);\n\tconst nodesAddedFull: Record<string, DescribeNodeOutput> = {};\n\tfor (const path of base.nodesAdded) {\n\t\tconst slice = b.nodes[path];\n\t\tif (slice != null) nodesAddedFull[path] = slice;\n\t}\n\treturn { ...base, nodesAddedFull };\n}\n\n/** A single field change within a diff. */\nexport type GraphDiffChange = {\n\tpath: string;\n\tfield: string;\n\tfrom: unknown;\n\tto: unknown;\n};\n\n/** A single V0 version bump within a diff. */\nexport type GraphVersionChange = {\n\tpath: string;\n\tid: string;\n\tfrom: number;\n\tto: number;\n};\n\n/** Audit record returned by {@link Graph.remove}. */\nexport type GraphRemoveAudit = {\n\t/** Whether the removed entry was a local node or a mount. */\n\tkind: \"node\" | \"mount\";\n\t/**\n\t * Primary nodes torn down by this `remove()`. For `kind: \"node\"` contains\n\t * just the removed name; for `kind: \"mount\"` lists every primary node in\n\t * the unmounted subtree (qualified paths relative to the mount point,\n\t * sorted).\n\t */\n\tnodes: string[];\n\t/**\n\t * Mounted subgraphs that were unmounted. For `kind: \"node\"` this is empty;\n\t * for `kind: \"mount\"` starts with the top-level mount name and lists its\n\t * descendants in depth-first order.\n\t */\n\tmounts: string[];\n};\n\n/** Direction for {@link reachable} graph traversal. */\nexport type ReachableDirection = \"upstream\" | \"downstream\";\n\n/** Options for {@link reachable}. */\nexport type ReachableOptions = {\n\t/** Maximum hop depth from `from` (0 returns `[]`). Omit for unbounded traversal. */\n\tmaxDepth?: number;\n\t/**\n\t * Traverse both directions in one pass (union of upstream + downstream).\n\t * Ignores the `direction` arg when set.\n\t */\n\tboth?: boolean;\n\t/**\n\t * Return the richer {@link ReachableResult} shape (paths + per-path\n\t * hop depth + truncation flag) instead of the flat sorted string array.\n\t */\n\twithDetail?: boolean;\n};\n\n/** Rich reachable result (opt-in via `{withDetail: true}`). */\nexport type ReachableResult = {\n\t/** Reachable paths, sorted lexicographically. */\n\tpaths: string[];\n\t/** Hop depth from `from` to each reachable path. */\n\tdepths: Map<string, number>;\n\t/** True when traversal hit `maxDepth` and some neighbors were not explored. */\n\ttruncated: boolean;\n};\n\n/**\n * Reachability query over a {@link Graph.describe} snapshot.\n *\n * Traversal follows `deps` (upstream) and reverse-`deps` (downstream). Edges\n * are derived from deps post Unit 7, so `edges[]` in the snapshot is\n * redundant with deps — it's walked defensively in case a caller supplied a\n * pre-Unit-7 snapshot.\n *\n * @param described - `graph.describe()` output to traverse.\n * @param from - Start path (qualified node path).\n * @param direction - Traversal direction (ignored when `opts.both` is `true`).\n * @param options - Optional `maxDepth`, `both`, `withDetail`.\n * @returns Sorted paths (flat) — or {@link ReachableResult} when `withDetail: true`.\n */\nexport function reachable(\n\tdescribed: GraphDescribeOutput,\n\tfrom: string,\n\tdirection: ReachableDirection,\n\toptions?: ReachableOptions & { withDetail: true },\n): ReachableResult;\nexport function reachable(\n\tdescribed: GraphDescribeOutput,\n\tfrom: string,\n\tdirection: ReachableDirection,\n\toptions?: ReachableOptions,\n): string[];\nexport function reachable(\n\tdescribed: GraphDescribeOutput,\n\tfrom: string,\n\tdirection: ReachableDirection,\n\toptions: ReachableOptions = {},\n): string[] | ReachableResult {\n\tconst empty: ReachableResult = { paths: [], depths: new Map(), truncated: false };\n\tif (!from) return options.withDetail ? empty : [];\n\tif (!options.both && direction !== \"upstream\" && direction !== \"downstream\") {\n\t\tthrow new Error(`reachable: direction must be \"upstream\" or \"downstream\"`);\n\t}\n\tconst maxDepth = options.maxDepth;\n\tif (maxDepth != null && (!Number.isInteger(maxDepth) || maxDepth < 0)) {\n\t\tthrow new Error(`reachable: maxDepth must be an integer >= 0`);\n\t}\n\tif (maxDepth === 0) return options.withDetail ? empty : [];\n\n\tconst depsByPath = new Map<string, readonly string[]>();\n\tconst reverseDeps = new Map<string, Set<string>>();\n\tconst incomingEdges = new Map<string, Set<string>>();\n\tconst outgoingEdges = new Map<string, Set<string>>();\n\tconst universe = new Set<string>();\n\n\tfor (const [path, node] of Object.entries(described.nodes)) {\n\t\tif (!path) continue;\n\t\tuniverse.add(path);\n\t\tconst deps = node.deps ?? [];\n\t\tdepsByPath.set(path, deps);\n\t\tfor (const dep of deps) {\n\t\t\tif (!dep) continue;\n\t\t\tuniverse.add(dep);\n\t\t\tif (!reverseDeps.has(dep)) reverseDeps.set(dep, new Set());\n\t\t\treverseDeps.get(dep)!.add(path);\n\t\t}\n\t}\n\t// Edges are normally derived from deps post Unit 7, but synthetic snapshots\n\t// (e.g. test fixtures) may declare edges independently — walk both for\n\t// compatibility. Minimal null/string checks for malformed JSON.\n\tfor (const edge of described.edges) {\n\t\tif (edge == null || typeof edge !== \"object\") continue;\n\t\tconst from = typeof edge.from === \"string\" ? edge.from : \"\";\n\t\tconst to = typeof edge.to === \"string\" ? edge.to : \"\";\n\t\tif (!from || !to) continue;\n\t\tuniverse.add(from);\n\t\tuniverse.add(to);\n\t\tif (!outgoingEdges.has(from)) outgoingEdges.set(from, new Set());\n\t\toutgoingEdges.get(from)!.add(to);\n\t\tif (!incomingEdges.has(to)) incomingEdges.set(to, new Set());\n\t\tincomingEdges.get(to)!.add(from);\n\t}\n\n\tif (!universe.has(from)) return options.withDetail ? empty : [];\n\n\tconst doBoth = options.both === true;\n\tconst visit = (path: string): readonly string[] => {\n\t\tif (doBoth) {\n\t\t\tconst up = depsByPath.get(path) ?? [];\n\t\t\tconst upEdges = incomingEdges.get(path);\n\t\t\tconst down = reverseDeps.get(path);\n\t\t\tconst downEdges = outgoingEdges.get(path);\n\t\t\tconst acc: string[] = [...up];\n\t\t\tif (upEdges) acc.push(...upEdges);\n\t\t\tif (down) acc.push(...down);\n\t\t\tif (downEdges) acc.push(...downEdges);\n\t\t\treturn acc;\n\t\t}\n\t\tif (direction === \"upstream\") {\n\t\t\tconst up = depsByPath.get(path) ?? [];\n\t\t\tconst upEdges = incomingEdges.get(path);\n\t\t\tif (!upEdges) return up;\n\t\t\treturn [...up, ...upEdges];\n\t\t}\n\t\tconst down = reverseDeps.get(path);\n\t\tconst downEdges = outgoingEdges.get(path);\n\t\tconst acc: string[] = down ? [...down] : [];\n\t\tif (downEdges) acc.push(...downEdges);\n\t\treturn acc;\n\t};\n\n\t// Head-index BFS — avoids O(n²) from `Array.prototype.shift`.\n\tconst visited = new Set<string>([from]);\n\tconst depths = new Map<string, number>();\n\tconst queue: Array<{ path: string; depth: number }> = [{ path: from, depth: 0 }];\n\tlet head = 0;\n\tlet truncated = false;\n\twhile (head < queue.length) {\n\t\tconst next = queue[head++]!;\n\t\tif (maxDepth != null && next.depth >= maxDepth) {\n\t\t\t// Flag truncation only if this node actually has unexplored neighbors.\n\t\t\tif (visit(next.path).length > 0) truncated = true;\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const nb of visit(next.path)) {\n\t\t\tif (!nb || visited.has(nb)) continue;\n\t\t\tvisited.add(nb);\n\t\t\tdepths.set(nb, next.depth + 1);\n\t\t\tqueue.push({ path: nb, depth: next.depth + 1 });\n\t\t}\n\t}\n\n\tconst paths = [...depths.keys()].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));\n\tif (options.withDetail) return { paths, depths, truncated };\n\treturn paths;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuG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