@graphrefly/graphrefly 0.25.0 → 0.27.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.
Files changed (231) hide show
  1. package/README.md +8 -0
  2. package/dist/ai-CaR_912Q.d.cts +1033 -0
  3. package/dist/ai-WlRltJV7.d.ts +1033 -0
  4. package/dist/audit-ClmqGOCx.d.cts +245 -0
  5. package/dist/audit-DRlSzBu9.d.ts +245 -0
  6. package/dist/{chunk-QOWVNWOC.js → chunk-3ZWCKRHX.js} +27 -25
  7. package/dist/{chunk-QOWVNWOC.js.map → chunk-3ZWCKRHX.js.map} +1 -1
  8. package/dist/chunk-APFNLIRG.js +62 -0
  9. package/dist/chunk-APFNLIRG.js.map +1 -0
  10. package/dist/chunk-AT5LKYNL.js +395 -0
  11. package/dist/chunk-AT5LKYNL.js.map +1 -0
  12. package/dist/{chunk-IAHGTNOZ.js → chunk-BQ6RQQFF.js} +351 -2095
  13. package/dist/chunk-BQ6RQQFF.js.map +1 -0
  14. package/dist/{chunk-L2GLW2U7.js → chunk-BVZYTZ5H.js} +9 -103
  15. package/dist/chunk-BVZYTZ5H.js.map +1 -0
  16. package/dist/{chunk-EVR6UFUV.js → chunk-DST5DKZS.js} +19 -15
  17. package/dist/{chunk-EVR6UFUV.js.map → chunk-DST5DKZS.js.map} +1 -1
  18. package/dist/{chunk-TKE3JGOH.js → chunk-GTE6PWRZ.js} +5 -692
  19. package/dist/chunk-GTE6PWRZ.js.map +1 -0
  20. package/dist/chunk-HXZEYDUR.js +94 -0
  21. package/dist/chunk-HXZEYDUR.js.map +1 -0
  22. package/dist/chunk-J22W6HV3.js +107 -0
  23. package/dist/chunk-J22W6HV3.js.map +1 -0
  24. package/dist/{chunk-PY4XCDLR.js → chunk-J2VBW3DZ.js} +6 -95
  25. package/dist/chunk-J2VBW3DZ.js.map +1 -0
  26. package/dist/{chunk-HWPIFSW2.js → chunk-JSCT3CR4.js} +6 -4
  27. package/dist/{chunk-HWPIFSW2.js.map → chunk-JSCT3CR4.js.map} +1 -1
  28. package/dist/chunk-JWBCY4NC.js +330 -0
  29. package/dist/chunk-JWBCY4NC.js.map +1 -0
  30. package/dist/chunk-K2AUJHVP.js +2251 -0
  31. package/dist/chunk-K2AUJHVP.js.map +1 -0
  32. package/dist/chunk-MJ2NKQQL.js +119 -0
  33. package/dist/chunk-MJ2NKQQL.js.map +1 -0
  34. package/dist/chunk-N6UR7YVY.js +198 -0
  35. package/dist/chunk-N6UR7YVY.js.map +1 -0
  36. package/dist/chunk-NC6S43JJ.js +456 -0
  37. package/dist/chunk-NC6S43JJ.js.map +1 -0
  38. package/dist/chunk-OFVJBJXR.js +98 -0
  39. package/dist/chunk-OFVJBJXR.js.map +1 -0
  40. package/dist/chunk-OHISZPOJ.js +97 -0
  41. package/dist/chunk-OHISZPOJ.js.map +1 -0
  42. package/dist/chunk-OU5CQKNW.js +102 -0
  43. package/dist/chunk-OU5CQKNW.js.map +1 -0
  44. package/dist/{chunk-XOFWRC73.js → chunk-PF7GRZMW.js} +316 -21
  45. package/dist/chunk-PF7GRZMW.js.map +1 -0
  46. package/dist/{chunk-5DJTTKX3.js → chunk-PHOUUNK7.js} +74 -111
  47. package/dist/chunk-PHOUUNK7.js.map +1 -0
  48. package/dist/chunk-RNHBMHKA.js +1665 -0
  49. package/dist/chunk-RNHBMHKA.js.map +1 -0
  50. package/dist/chunk-SX52TAR4.js +110 -0
  51. package/dist/chunk-SX52TAR4.js.map +1 -0
  52. package/dist/{chunk-H4RVA4VE.js → chunk-VYPWMZ6H.js} +2 -2
  53. package/dist/chunk-WBZOVTYK.js +171 -0
  54. package/dist/chunk-WBZOVTYK.js.map +1 -0
  55. package/dist/chunk-WKNUIZOY.js +354 -0
  56. package/dist/chunk-WKNUIZOY.js.map +1 -0
  57. package/dist/chunk-X3VMZYBT.js +713 -0
  58. package/dist/chunk-X3VMZYBT.js.map +1 -0
  59. package/dist/chunk-X5R3GL6H.js +525 -0
  60. package/dist/chunk-X5R3GL6H.js.map +1 -0
  61. package/dist/chunk-XGPU467M.js +136 -0
  62. package/dist/chunk-XGPU467M.js.map +1 -0
  63. package/dist/compat/index.cjs +7656 -0
  64. package/dist/compat/index.cjs.map +1 -0
  65. package/dist/compat/index.d.cts +18 -0
  66. package/dist/compat/index.d.ts +18 -0
  67. package/dist/compat/index.js +50 -0
  68. package/dist/compat/index.js.map +1 -0
  69. package/dist/compat/jotai/index.cjs +2048 -0
  70. package/dist/compat/jotai/index.cjs.map +1 -0
  71. package/dist/compat/jotai/index.d.cts +2 -0
  72. package/dist/compat/jotai/index.d.ts +2 -0
  73. package/dist/compat/jotai/index.js +9 -0
  74. package/dist/compat/jotai/index.js.map +1 -0
  75. package/dist/compat/nanostores/index.cjs +2175 -0
  76. package/dist/compat/nanostores/index.cjs.map +1 -0
  77. package/dist/compat/nanostores/index.d.cts +2 -0
  78. package/dist/compat/nanostores/index.d.ts +2 -0
  79. package/dist/compat/nanostores/index.js +23 -0
  80. package/dist/compat/nanostores/index.js.map +1 -0
  81. package/dist/compat/nestjs/index.cjs +350 -16
  82. package/dist/compat/nestjs/index.cjs.map +1 -1
  83. package/dist/compat/nestjs/index.d.cts +6 -6
  84. package/dist/compat/nestjs/index.d.ts +6 -6
  85. package/dist/compat/nestjs/index.js +11 -9
  86. package/dist/compat/react/index.cjs +141 -0
  87. package/dist/compat/react/index.cjs.map +1 -0
  88. package/dist/compat/react/index.d.cts +2 -0
  89. package/dist/compat/react/index.d.ts +2 -0
  90. package/dist/compat/react/index.js +12 -0
  91. package/dist/compat/react/index.js.map +1 -0
  92. package/dist/compat/solid/index.cjs +128 -0
  93. package/dist/compat/solid/index.cjs.map +1 -0
  94. package/dist/compat/solid/index.d.cts +2 -0
  95. package/dist/compat/solid/index.d.ts +2 -0
  96. package/dist/compat/solid/index.js +12 -0
  97. package/dist/compat/solid/index.js.map +1 -0
  98. package/dist/compat/svelte/index.cjs +131 -0
  99. package/dist/compat/svelte/index.cjs.map +1 -0
  100. package/dist/compat/svelte/index.d.cts +2 -0
  101. package/dist/compat/svelte/index.d.ts +2 -0
  102. package/dist/compat/svelte/index.js +12 -0
  103. package/dist/compat/svelte/index.js.map +1 -0
  104. package/dist/compat/vue/index.cjs +146 -0
  105. package/dist/compat/vue/index.cjs.map +1 -0
  106. package/dist/compat/vue/index.d.cts +3 -0
  107. package/dist/compat/vue/index.d.ts +3 -0
  108. package/dist/compat/vue/index.js +12 -0
  109. package/dist/compat/vue/index.js.map +1 -0
  110. package/dist/compat/zustand/index.cjs +4931 -0
  111. package/dist/compat/zustand/index.cjs.map +1 -0
  112. package/dist/compat/zustand/index.d.cts +5 -0
  113. package/dist/compat/zustand/index.d.ts +5 -0
  114. package/dist/compat/zustand/index.js +12 -0
  115. package/dist/compat/zustand/index.js.map +1 -0
  116. package/dist/composite-C7PcQvcs.d.cts +303 -0
  117. package/dist/composite-aUCvjZVR.d.ts +303 -0
  118. package/dist/core/index.cjs +53 -4
  119. package/dist/core/index.cjs.map +1 -1
  120. package/dist/core/index.d.cts +4 -3
  121. package/dist/core/index.d.ts +4 -3
  122. package/dist/core/index.js +26 -24
  123. package/dist/demo-shell-BDkOptd6.d.ts +102 -0
  124. package/dist/demo-shell-Crid1WdR.d.cts +102 -0
  125. package/dist/extra/index.cjs +222 -110
  126. package/dist/extra/index.cjs.map +1 -1
  127. package/dist/extra/index.d.cts +6 -4
  128. package/dist/extra/index.d.ts +6 -4
  129. package/dist/extra/index.js +72 -65
  130. package/dist/extra/sources.cjs +2486 -0
  131. package/dist/extra/sources.cjs.map +1 -0
  132. package/dist/extra/sources.d.cts +465 -0
  133. package/dist/extra/sources.d.ts +465 -0
  134. package/dist/extra/sources.js +57 -0
  135. package/dist/extra/sources.js.map +1 -0
  136. package/dist/graph/index.cjs +408 -14
  137. package/dist/graph/index.cjs.map +1 -1
  138. package/dist/graph/index.d.cts +5 -5
  139. package/dist/graph/index.d.ts +5 -5
  140. package/dist/graph/index.js +13 -5
  141. package/dist/{graph-D-3JIQme.d.cts → graph-CCwGKLCm.d.ts} +195 -4
  142. package/dist/{graph-B6NFqv3z.d.ts → graph-DNCrvZSn.d.cts} +195 -4
  143. package/dist/index-3lsddbbS.d.ts +86 -0
  144. package/dist/index-B1tloyhO.d.cts +34 -0
  145. package/dist/{index-CYkjxu3s.d.ts → index-B6D3QNSA.d.ts} +33 -4
  146. package/dist/index-B6EhDnjH.d.cts +37 -0
  147. package/dist/index-B9B7_HEY.d.ts +37 -0
  148. package/dist/{index-Ds23Wvou.d.ts → index-BHlKbUwO.d.cts} +131 -883
  149. package/dist/{index-DiobMNwE.d.ts → index-BPVt8kqc.d.ts} +3 -3
  150. package/dist/index-BaSM3aYt.d.ts +195 -0
  151. package/dist/index-BuEoe-Qu.d.ts +121 -0
  152. package/dist/{index-Ch0IpIO0.d.cts → index-BwfLUNw4.d.ts} +131 -883
  153. package/dist/index-ByQxazQJ.d.cts +86 -0
  154. package/dist/index-C0svESO4.d.ts +127 -0
  155. package/dist/{index-OXImXMq6.d.ts → index-C8oil6M6.d.ts} +18 -196
  156. package/dist/{index-DKE1EATr.d.cts → index-CI3DprxP.d.cts} +18 -196
  157. package/dist/{index-AMWewNDe.d.cts → index-CO8uBlUh.d.cts} +33 -4
  158. package/dist/index-CxFrXH4m.d.ts +45 -0
  159. package/dist/index-D8wS_PeY.d.cts +121 -0
  160. package/dist/index-DO_6JN9Z.d.cts +127 -0
  161. package/dist/index-DVGiGFGT.d.cts +195 -0
  162. package/dist/index-DYme44FM.d.cts +44 -0
  163. package/dist/{index-J7Kc0oIQ.d.cts → index-DlLp-2Xn.d.cts} +3 -3
  164. package/dist/index-Dzk2hrlR.d.ts +44 -0
  165. package/dist/index-VHqptjhu.d.cts +45 -0
  166. package/dist/index-VdHQMPy1.d.ts +36 -0
  167. package/dist/index-Xi3u0HCQ.d.cts +36 -0
  168. package/dist/index-wEn0eFe8.d.ts +34 -0
  169. package/dist/index.cjs +1780 -176
  170. package/dist/index.cjs.map +1 -1
  171. package/dist/index.d.cts +784 -2082
  172. package/dist/index.d.ts +784 -2082
  173. package/dist/index.js +955 -4349
  174. package/dist/index.js.map +1 -1
  175. package/dist/memory-C6Z2tGpC.d.cts +139 -0
  176. package/dist/memory-li6FL5RM.d.ts +139 -0
  177. package/dist/messaging-Gt4LPbyA.d.cts +269 -0
  178. package/dist/messaging-XDoYablx.d.ts +269 -0
  179. package/dist/{meta-DWbkoq1s.d.cts → meta-BxCA7rcr.d.cts} +1 -1
  180. package/dist/{meta-CnkLA_43.d.ts → meta-CbznRPYJ.d.ts} +1 -1
  181. package/dist/{node-B-f-Lu-k.d.cts → node-BmerH3kS.d.cts} +26 -1
  182. package/dist/{node-B-f-Lu-k.d.ts → node-BmerH3kS.d.ts} +26 -1
  183. package/dist/{observable-uP-wy_uK.d.ts → observable-BgGUwcqp.d.ts} +1 -1
  184. package/dist/{observable-DBnrwcar.d.cts → observable-DJt_AxzQ.d.cts} +1 -1
  185. package/dist/patterns/ai.cjs +7930 -0
  186. package/dist/patterns/ai.cjs.map +1 -0
  187. package/dist/patterns/ai.d.cts +10 -0
  188. package/dist/patterns/ai.d.ts +10 -0
  189. package/dist/patterns/ai.js +71 -0
  190. package/dist/patterns/ai.js.map +1 -0
  191. package/dist/patterns/audit.cjs +5805 -0
  192. package/dist/patterns/audit.cjs.map +1 -0
  193. package/dist/patterns/audit.d.cts +6 -0
  194. package/dist/patterns/audit.d.ts +6 -0
  195. package/dist/patterns/audit.js +29 -0
  196. package/dist/patterns/audit.js.map +1 -0
  197. package/dist/patterns/demo-shell.cjs +5604 -0
  198. package/dist/patterns/demo-shell.cjs.map +1 -0
  199. package/dist/patterns/demo-shell.d.cts +6 -0
  200. package/dist/patterns/demo-shell.d.ts +6 -0
  201. package/dist/patterns/demo-shell.js +15 -0
  202. package/dist/patterns/demo-shell.js.map +1 -0
  203. package/dist/patterns/memory.cjs +5283 -0
  204. package/dist/patterns/memory.cjs.map +1 -0
  205. package/dist/patterns/memory.d.cts +5 -0
  206. package/dist/patterns/memory.d.ts +5 -0
  207. package/dist/patterns/memory.js +20 -0
  208. package/dist/patterns/memory.js.map +1 -0
  209. package/dist/patterns/reactive-layout/index.cjs +355 -13
  210. package/dist/patterns/reactive-layout/index.cjs.map +1 -1
  211. package/dist/patterns/reactive-layout/index.d.cts +6 -5
  212. package/dist/patterns/reactive-layout/index.d.ts +6 -5
  213. package/dist/patterns/reactive-layout/index.js +15 -12
  214. package/dist/reactive-layout-MQP--J3F.d.cts +183 -0
  215. package/dist/reactive-layout-u5Ulnqag.d.ts +183 -0
  216. package/dist/{storage-BuTdpCI1.d.cts → storage-CMjUUuxn.d.ts} +10 -2
  217. package/dist/{storage-F2X1U1x0.d.ts → storage-DdWlZo6U.d.cts} +10 -2
  218. package/dist/sugar-CCOxXK1e.d.ts +201 -0
  219. package/dist/sugar-D02n5JjF.d.cts +201 -0
  220. package/package.json +63 -3
  221. package/dist/chunk-5DJTTKX3.js.map +0 -1
  222. package/dist/chunk-IAHGTNOZ.js.map +0 -1
  223. package/dist/chunk-L2GLW2U7.js.map +0 -1
  224. package/dist/chunk-MW4VAKAO.js +0 -47
  225. package/dist/chunk-MW4VAKAO.js.map +0 -1
  226. package/dist/chunk-PY4XCDLR.js.map +0 -1
  227. package/dist/chunk-TKE3JGOH.js.map +0 -1
  228. package/dist/chunk-XOFWRC73.js.map +0 -1
  229. package/dist/index-BJB7t9gg.d.cts +0 -392
  230. package/dist/index-C-TXEa7C.d.ts +0 -392
  231. /package/dist/{chunk-H4RVA4VE.js.map → chunk-VYPWMZ6H.js.map} +0 -0
@@ -0,0 +1,245 @@
1
+ import { A as Actor, N as Node, P as PolicyRuleData, k as GuardAction } from './node-BmerH3kS.cjs';
2
+ import { a as Graph, G as GraphOptions, s as GraphPersistSnapshot, C as CausalChain } from './graph-DNCrvZSn.cjs';
3
+ import { T as TopicGraph } from './messaging-Gt4LPbyA.cjs';
4
+
5
+ /**
6
+ * Audit, policy enforcement, and compliance export (roadmap §9.2).
7
+ *
8
+ * Three composed factories that wrap any {@link Graph} with the harness
9
+ * accountability layer:
10
+ *
11
+ * - {@link auditTrail} — reactive mutation log with by-node/by-actor/by-time
12
+ * queries.
13
+ * - {@link policyEnforcer} — reactive ABAC enforcement; in `"audit"` mode
14
+ * records would-be denials, in `"enforce"` mode pushes guards onto target
15
+ * nodes so subsequent writes throw {@link GuardDenied}.
16
+ * - {@link complianceSnapshot} — point-in-time export of graph state +
17
+ * audit trail + policies for regulatory archival.
18
+ *
19
+ * @module
20
+ */
21
+
22
+ /** A single recorded mutation/event in an {@link AuditTrailGraph}. */
23
+ interface AuditEntry {
24
+ seq: number;
25
+ timestamp_ns: number;
26
+ wall_clock_ns: number;
27
+ path: string;
28
+ type: "data" | "dirty" | "resolved" | "invalidate" | "pause" | "resume" | "complete" | "error" | "teardown";
29
+ actor?: Actor;
30
+ value?: unknown;
31
+ error?: unknown;
32
+ reason?: string;
33
+ }
34
+ /** Options for {@link auditTrail}. */
35
+ interface AuditTrailOptions {
36
+ name?: string;
37
+ graph?: GraphOptions;
38
+ /** Ring-buffer cap for the underlying `reactiveLog`. Default: unbounded. */
39
+ maxSize?: number;
40
+ /**
41
+ * Which event types to record. Default: `["data", "error", "complete",
42
+ * "teardown"]` — the user-meaningful set. Opt in to mid-wave protocol
43
+ * events (`"dirty"`, `"resolved"`, `"invalidate"`, `"pause"`, `"resume"`)
44
+ * by listing them explicitly. Note: those tier-1/tier-2 events do not
45
+ * carry an `actor` (no `lastMutation` populated) — record them only for
46
+ * protocol-level diagnostics.
47
+ */
48
+ includeTypes?: readonly AuditEntry["type"][];
49
+ /** Per-event filter; return false to skip. */
50
+ filter?: (entry: AuditEntry) => boolean;
51
+ }
52
+ /**
53
+ * Mounted audit log — `entries` exposes the reactive `AuditEntry[]`; query
54
+ * helpers are sync convenience wrappers over the cached snapshot.
55
+ */
56
+ declare class AuditTrailGraph extends Graph {
57
+ readonly entries: Node<readonly AuditEntry[]>;
58
+ readonly count: Node<number>;
59
+ private readonly _log;
60
+ private readonly _target;
61
+ constructor(target: Graph, opts: AuditTrailOptions);
62
+ /** All entries currently in the ring (snapshot). */
63
+ all(): readonly AuditEntry[];
64
+ /** Entries matching `path`. Order preserved. */
65
+ byNode(path: string): readonly AuditEntry[];
66
+ /** Entries whose `actor.id` matches. Use `byActorType` for type filtering. */
67
+ byActor(actorId: string): readonly AuditEntry[];
68
+ /** Entries whose `actor.type` matches (e.g. `"llm"`, `"human"`). */
69
+ byActorType(type: string): readonly AuditEntry[];
70
+ /**
71
+ * Entries with `timestamp_ns` in `[start_ns, end_ns)` (end exclusive).
72
+ * Omit `end_ns` to query open-ended.
73
+ */
74
+ byTimeRange(start_ns: number, end_ns?: number): readonly AuditEntry[];
75
+ /** Reference to the audited graph (escape hatch for tooling). */
76
+ get target(): Graph;
77
+ }
78
+ /**
79
+ * Wraps any {@link Graph} with a reactive audit trail recording every event
80
+ * matching `includeTypes` (default: data + error + complete + teardown).
81
+ *
82
+ * Each entry carries `seq`, `timestamp_ns` (monotonic), `wall_clock_ns`,
83
+ * `path`, `type`, and — when available — `actor`, `value`, `error`, and the
84
+ * `graph.trace()` reasoning annotation for the path.
85
+ *
86
+ * The returned graph mounts an `entries` node + `count` derived. Query
87
+ * helpers (`byNode`, `byActor`, `byTimeRange`) operate on the cached
88
+ * snapshot synchronously.
89
+ */
90
+ declare function auditTrail(target: Graph, opts?: AuditTrailOptions): AuditTrailGraph;
91
+ /** A single policy denial recorded by {@link PolicyEnforcerGraph}. */
92
+ interface PolicyViolation {
93
+ timestamp_ns: number;
94
+ wall_clock_ns: number;
95
+ path: string;
96
+ actor: Actor;
97
+ action: GuardAction;
98
+ mode: "audit" | "enforce";
99
+ /** `"observed"` (audit mode after-the-fact) or `"blocked"` (enforce mode pre-write). */
100
+ result: "observed" | "blocked";
101
+ }
102
+ /** Options for {@link policyEnforcer}. */
103
+ interface PolicyEnforcerOptions {
104
+ name?: string;
105
+ graph?: GraphOptions;
106
+ /**
107
+ * `"audit"` (default) — observe events and record would-be denials;
108
+ * does not block writes. Audit mode requires `lastMutation` attribution
109
+ * on the audited node — anonymous/internal writes (no `actor` passed,
110
+ * unguarded node) are skipped silently because the policy cannot be
111
+ * evaluated without an actor.
112
+ *
113
+ * `"enforce"` — push guards onto target nodes so disallowed writes
114
+ * throw {@link GuardDenied}. Reverted on dispose.
115
+ */
116
+ mode?: "audit" | "enforce";
117
+ /**
118
+ * Restrict enforcement to specific node paths (qualified). When omitted,
119
+ * applies to every node visible in `target.describe()` at construction
120
+ * time (subgraphs are walked transitively) AND subscribes to the full
121
+ * topology tree via {@link watchTopologyTree}, so nodes added to
122
+ * `target` OR any transitively-mounted subgraph after construction are
123
+ * guarded automatically (enforce mode only).
124
+ *
125
+ * **Cost:** unrestricted mode runs `describe({detail:"minimal"})` once
126
+ * at construction (O(N) over the graph tree) plus one topology
127
+ * subscription per graph instance in the mount tree. Restricted mode
128
+ * skips both and disables dynamic coverage — callers providing
129
+ * `paths` must re-create on subgraph changes.
130
+ */
131
+ paths?: readonly string[];
132
+ /** Ring-buffer cap for the violations topic. Default: 1000. */
133
+ violationsLimit?: number;
134
+ }
135
+ /**
136
+ * Reactive ABAC enforcement layer. Policies are reactive — pass a
137
+ * `Node<readonly PolicyRuleData[]>` to allow LLMs (or any reactive source)
138
+ * to update them at runtime; the enforcer rebinds its internal
139
+ * {@link NodeGuard} on every push.
140
+ */
141
+ declare class PolicyEnforcerGraph extends Graph {
142
+ readonly policies: Node<readonly PolicyRuleData[]>;
143
+ readonly violations: TopicGraph<PolicyViolation>;
144
+ readonly violationCount: Node<number>;
145
+ private readonly _target;
146
+ private readonly _mode;
147
+ private _currentGuard;
148
+ constructor(target: Graph, policies: readonly PolicyRuleData[] | Node<readonly PolicyRuleData[]>, opts: PolicyEnforcerOptions);
149
+ private _publishViolation;
150
+ /** Snapshot of recorded violations. */
151
+ all(): readonly PolicyViolation[];
152
+ get mode(): "audit" | "enforce";
153
+ get target(): Graph;
154
+ }
155
+ /**
156
+ * Wraps a {@link Graph} with reactive policy enforcement. Pass either a
157
+ * static rule list or a {@link Node} of rules (LLM-updatable). Records
158
+ * `PolicyViolation` entries to `violations` topic; in `"enforce"` mode also
159
+ * pushes guards onto target nodes so disallowed writes throw.
160
+ */
161
+ declare function policyEnforcer(target: Graph, policies: readonly PolicyRuleData[] | Node<readonly PolicyRuleData[]>, opts?: PolicyEnforcerOptions): PolicyEnforcerGraph;
162
+ /**
163
+ * Reactive {@link CausalChain} that recomputes whenever the audited graph
164
+ * changes. Returns a `Node<CausalChain>` suitable for subscription, mounting,
165
+ * or composition (e.g. inside `graphLens.why(node)`).
166
+ *
167
+ * **How it stays live:** an internal `version` state is bumped by an observer
168
+ * attached to `target.observe()`; the derived chain depends on `version`, so
169
+ * each mutation triggers a recompute. To avoid stalling on no-op events, only
170
+ * `data`, `error`, `complete`, and `teardown` bump the version (matching the
171
+ * audit defaults).
172
+ */
173
+ declare function reactiveExplainPath(target: Graph, from: string, to: string, opts?: {
174
+ maxDepth?: number;
175
+ name?: string;
176
+ findCycle?: boolean;
177
+ }): {
178
+ node: Node<CausalChain>;
179
+ dispose: () => void;
180
+ };
181
+ /** Options for {@link complianceSnapshot}. */
182
+ interface ComplianceSnapshotOptions {
183
+ audit?: AuditTrailGraph;
184
+ policies?: PolicyEnforcerGraph;
185
+ /** Actor recorded as the snapshot taker. */
186
+ actor?: Actor;
187
+ }
188
+ /** Output of {@link complianceSnapshot}. JSON-serializable. */
189
+ interface ComplianceSnapshotResult {
190
+ format_version: 1;
191
+ timestamp_ns: number;
192
+ wall_clock_ns: number;
193
+ actor?: Actor;
194
+ graph: GraphPersistSnapshot;
195
+ audit?: {
196
+ count: number;
197
+ entries: AuditEntry[];
198
+ };
199
+ policies?: {
200
+ mode: "audit" | "enforce";
201
+ rules: readonly PolicyRuleData[];
202
+ violations: readonly PolicyViolation[];
203
+ };
204
+ /**
205
+ * Truncated SHA-256 hex (16 chars / ~64 bits) over a canonical encoding
206
+ * of every field above (excluding `fingerprint` itself). Deterministic
207
+ * across runs given identical inputs. Suitable for casual tamper-evidence
208
+ * and content-addressed dedup; for full cryptographic strength, hash the
209
+ * canonical JSON externally with Web Crypto / Node `crypto`.
210
+ */
211
+ fingerprint: string;
212
+ }
213
+ /**
214
+ * One-shot point-in-time export of a {@link Graph}'s state plus optional
215
+ * audit + policy bundles. Returns a JSON-serializable object with a
216
+ * deterministic truncated-SHA-256 {@link ComplianceSnapshotResult.fingerprint}
217
+ * over the canonical payload for tamper-evidence in regulatory archival.
218
+ *
219
+ * **Cryptographic strength:** the fingerprint is truncated to 64 bits for
220
+ * compact archival. Collision-resistant for casual integrity checks but NOT
221
+ * sufficient for adversarial tamper-evidence — pair with a full SHA-256
222
+ * (or stronger) over the canonical JSON when regulatory requirements demand
223
+ * collision resistance.
224
+ */
225
+ declare function complianceSnapshot(target: Graph, opts?: ComplianceSnapshotOptions): ComplianceSnapshotResult;
226
+
227
+ type audit_AuditEntry = AuditEntry;
228
+ type audit_AuditTrailGraph = AuditTrailGraph;
229
+ declare const audit_AuditTrailGraph: typeof AuditTrailGraph;
230
+ type audit_AuditTrailOptions = AuditTrailOptions;
231
+ type audit_ComplianceSnapshotOptions = ComplianceSnapshotOptions;
232
+ type audit_ComplianceSnapshotResult = ComplianceSnapshotResult;
233
+ type audit_PolicyEnforcerGraph = PolicyEnforcerGraph;
234
+ declare const audit_PolicyEnforcerGraph: typeof PolicyEnforcerGraph;
235
+ type audit_PolicyEnforcerOptions = PolicyEnforcerOptions;
236
+ type audit_PolicyViolation = PolicyViolation;
237
+ declare const audit_auditTrail: typeof auditTrail;
238
+ declare const audit_complianceSnapshot: typeof complianceSnapshot;
239
+ declare const audit_policyEnforcer: typeof policyEnforcer;
240
+ declare const audit_reactiveExplainPath: typeof reactiveExplainPath;
241
+ declare namespace audit {
242
+ export { type audit_AuditEntry as AuditEntry, audit_AuditTrailGraph as AuditTrailGraph, type audit_AuditTrailOptions as AuditTrailOptions, type audit_ComplianceSnapshotOptions as ComplianceSnapshotOptions, type audit_ComplianceSnapshotResult as ComplianceSnapshotResult, audit_PolicyEnforcerGraph as PolicyEnforcerGraph, type audit_PolicyEnforcerOptions as PolicyEnforcerOptions, type audit_PolicyViolation as PolicyViolation, audit_auditTrail as auditTrail, audit_complianceSnapshot as complianceSnapshot, audit_policyEnforcer as policyEnforcer, audit_reactiveExplainPath as reactiveExplainPath };
243
+ }
244
+
245
+ export { type AuditEntry as A, type ComplianceSnapshotOptions as C, PolicyEnforcerGraph as P, type PolicyViolation as a, audit as b, AuditTrailGraph as c, type AuditTrailOptions as d, type ComplianceSnapshotResult as e, type PolicyEnforcerOptions as f, auditTrail as g, complianceSnapshot as h, policyEnforcer as p, reactiveExplainPath as r };
@@ -0,0 +1,245 @@
1
+ import { A as Actor, N as Node, P as PolicyRuleData, k as GuardAction } from './node-BmerH3kS.js';
2
+ import { a as Graph, G as GraphOptions, s as GraphPersistSnapshot, C as CausalChain } from './graph-CCwGKLCm.js';
3
+ import { T as TopicGraph } from './messaging-XDoYablx.js';
4
+
5
+ /**
6
+ * Audit, policy enforcement, and compliance export (roadmap §9.2).
7
+ *
8
+ * Three composed factories that wrap any {@link Graph} with the harness
9
+ * accountability layer:
10
+ *
11
+ * - {@link auditTrail} — reactive mutation log with by-node/by-actor/by-time
12
+ * queries.
13
+ * - {@link policyEnforcer} — reactive ABAC enforcement; in `"audit"` mode
14
+ * records would-be denials, in `"enforce"` mode pushes guards onto target
15
+ * nodes so subsequent writes throw {@link GuardDenied}.
16
+ * - {@link complianceSnapshot} — point-in-time export of graph state +
17
+ * audit trail + policies for regulatory archival.
18
+ *
19
+ * @module
20
+ */
21
+
22
+ /** A single recorded mutation/event in an {@link AuditTrailGraph}. */
23
+ interface AuditEntry {
24
+ seq: number;
25
+ timestamp_ns: number;
26
+ wall_clock_ns: number;
27
+ path: string;
28
+ type: "data" | "dirty" | "resolved" | "invalidate" | "pause" | "resume" | "complete" | "error" | "teardown";
29
+ actor?: Actor;
30
+ value?: unknown;
31
+ error?: unknown;
32
+ reason?: string;
33
+ }
34
+ /** Options for {@link auditTrail}. */
35
+ interface AuditTrailOptions {
36
+ name?: string;
37
+ graph?: GraphOptions;
38
+ /** Ring-buffer cap for the underlying `reactiveLog`. Default: unbounded. */
39
+ maxSize?: number;
40
+ /**
41
+ * Which event types to record. Default: `["data", "error", "complete",
42
+ * "teardown"]` — the user-meaningful set. Opt in to mid-wave protocol
43
+ * events (`"dirty"`, `"resolved"`, `"invalidate"`, `"pause"`, `"resume"`)
44
+ * by listing them explicitly. Note: those tier-1/tier-2 events do not
45
+ * carry an `actor` (no `lastMutation` populated) — record them only for
46
+ * protocol-level diagnostics.
47
+ */
48
+ includeTypes?: readonly AuditEntry["type"][];
49
+ /** Per-event filter; return false to skip. */
50
+ filter?: (entry: AuditEntry) => boolean;
51
+ }
52
+ /**
53
+ * Mounted audit log — `entries` exposes the reactive `AuditEntry[]`; query
54
+ * helpers are sync convenience wrappers over the cached snapshot.
55
+ */
56
+ declare class AuditTrailGraph extends Graph {
57
+ readonly entries: Node<readonly AuditEntry[]>;
58
+ readonly count: Node<number>;
59
+ private readonly _log;
60
+ private readonly _target;
61
+ constructor(target: Graph, opts: AuditTrailOptions);
62
+ /** All entries currently in the ring (snapshot). */
63
+ all(): readonly AuditEntry[];
64
+ /** Entries matching `path`. Order preserved. */
65
+ byNode(path: string): readonly AuditEntry[];
66
+ /** Entries whose `actor.id` matches. Use `byActorType` for type filtering. */
67
+ byActor(actorId: string): readonly AuditEntry[];
68
+ /** Entries whose `actor.type` matches (e.g. `"llm"`, `"human"`). */
69
+ byActorType(type: string): readonly AuditEntry[];
70
+ /**
71
+ * Entries with `timestamp_ns` in `[start_ns, end_ns)` (end exclusive).
72
+ * Omit `end_ns` to query open-ended.
73
+ */
74
+ byTimeRange(start_ns: number, end_ns?: number): readonly AuditEntry[];
75
+ /** Reference to the audited graph (escape hatch for tooling). */
76
+ get target(): Graph;
77
+ }
78
+ /**
79
+ * Wraps any {@link Graph} with a reactive audit trail recording every event
80
+ * matching `includeTypes` (default: data + error + complete + teardown).
81
+ *
82
+ * Each entry carries `seq`, `timestamp_ns` (monotonic), `wall_clock_ns`,
83
+ * `path`, `type`, and — when available — `actor`, `value`, `error`, and the
84
+ * `graph.trace()` reasoning annotation for the path.
85
+ *
86
+ * The returned graph mounts an `entries` node + `count` derived. Query
87
+ * helpers (`byNode`, `byActor`, `byTimeRange`) operate on the cached
88
+ * snapshot synchronously.
89
+ */
90
+ declare function auditTrail(target: Graph, opts?: AuditTrailOptions): AuditTrailGraph;
91
+ /** A single policy denial recorded by {@link PolicyEnforcerGraph}. */
92
+ interface PolicyViolation {
93
+ timestamp_ns: number;
94
+ wall_clock_ns: number;
95
+ path: string;
96
+ actor: Actor;
97
+ action: GuardAction;
98
+ mode: "audit" | "enforce";
99
+ /** `"observed"` (audit mode after-the-fact) or `"blocked"` (enforce mode pre-write). */
100
+ result: "observed" | "blocked";
101
+ }
102
+ /** Options for {@link policyEnforcer}. */
103
+ interface PolicyEnforcerOptions {
104
+ name?: string;
105
+ graph?: GraphOptions;
106
+ /**
107
+ * `"audit"` (default) — observe events and record would-be denials;
108
+ * does not block writes. Audit mode requires `lastMutation` attribution
109
+ * on the audited node — anonymous/internal writes (no `actor` passed,
110
+ * unguarded node) are skipped silently because the policy cannot be
111
+ * evaluated without an actor.
112
+ *
113
+ * `"enforce"` — push guards onto target nodes so disallowed writes
114
+ * throw {@link GuardDenied}. Reverted on dispose.
115
+ */
116
+ mode?: "audit" | "enforce";
117
+ /**
118
+ * Restrict enforcement to specific node paths (qualified). When omitted,
119
+ * applies to every node visible in `target.describe()` at construction
120
+ * time (subgraphs are walked transitively) AND subscribes to the full
121
+ * topology tree via {@link watchTopologyTree}, so nodes added to
122
+ * `target` OR any transitively-mounted subgraph after construction are
123
+ * guarded automatically (enforce mode only).
124
+ *
125
+ * **Cost:** unrestricted mode runs `describe({detail:"minimal"})` once
126
+ * at construction (O(N) over the graph tree) plus one topology
127
+ * subscription per graph instance in the mount tree. Restricted mode
128
+ * skips both and disables dynamic coverage — callers providing
129
+ * `paths` must re-create on subgraph changes.
130
+ */
131
+ paths?: readonly string[];
132
+ /** Ring-buffer cap for the violations topic. Default: 1000. */
133
+ violationsLimit?: number;
134
+ }
135
+ /**
136
+ * Reactive ABAC enforcement layer. Policies are reactive — pass a
137
+ * `Node<readonly PolicyRuleData[]>` to allow LLMs (or any reactive source)
138
+ * to update them at runtime; the enforcer rebinds its internal
139
+ * {@link NodeGuard} on every push.
140
+ */
141
+ declare class PolicyEnforcerGraph extends Graph {
142
+ readonly policies: Node<readonly PolicyRuleData[]>;
143
+ readonly violations: TopicGraph<PolicyViolation>;
144
+ readonly violationCount: Node<number>;
145
+ private readonly _target;
146
+ private readonly _mode;
147
+ private _currentGuard;
148
+ constructor(target: Graph, policies: readonly PolicyRuleData[] | Node<readonly PolicyRuleData[]>, opts: PolicyEnforcerOptions);
149
+ private _publishViolation;
150
+ /** Snapshot of recorded violations. */
151
+ all(): readonly PolicyViolation[];
152
+ get mode(): "audit" | "enforce";
153
+ get target(): Graph;
154
+ }
155
+ /**
156
+ * Wraps a {@link Graph} with reactive policy enforcement. Pass either a
157
+ * static rule list or a {@link Node} of rules (LLM-updatable). Records
158
+ * `PolicyViolation` entries to `violations` topic; in `"enforce"` mode also
159
+ * pushes guards onto target nodes so disallowed writes throw.
160
+ */
161
+ declare function policyEnforcer(target: Graph, policies: readonly PolicyRuleData[] | Node<readonly PolicyRuleData[]>, opts?: PolicyEnforcerOptions): PolicyEnforcerGraph;
162
+ /**
163
+ * Reactive {@link CausalChain} that recomputes whenever the audited graph
164
+ * changes. Returns a `Node<CausalChain>` suitable for subscription, mounting,
165
+ * or composition (e.g. inside `graphLens.why(node)`).
166
+ *
167
+ * **How it stays live:** an internal `version` state is bumped by an observer
168
+ * attached to `target.observe()`; the derived chain depends on `version`, so
169
+ * each mutation triggers a recompute. To avoid stalling on no-op events, only
170
+ * `data`, `error`, `complete`, and `teardown` bump the version (matching the
171
+ * audit defaults).
172
+ */
173
+ declare function reactiveExplainPath(target: Graph, from: string, to: string, opts?: {
174
+ maxDepth?: number;
175
+ name?: string;
176
+ findCycle?: boolean;
177
+ }): {
178
+ node: Node<CausalChain>;
179
+ dispose: () => void;
180
+ };
181
+ /** Options for {@link complianceSnapshot}. */
182
+ interface ComplianceSnapshotOptions {
183
+ audit?: AuditTrailGraph;
184
+ policies?: PolicyEnforcerGraph;
185
+ /** Actor recorded as the snapshot taker. */
186
+ actor?: Actor;
187
+ }
188
+ /** Output of {@link complianceSnapshot}. JSON-serializable. */
189
+ interface ComplianceSnapshotResult {
190
+ format_version: 1;
191
+ timestamp_ns: number;
192
+ wall_clock_ns: number;
193
+ actor?: Actor;
194
+ graph: GraphPersistSnapshot;
195
+ audit?: {
196
+ count: number;
197
+ entries: AuditEntry[];
198
+ };
199
+ policies?: {
200
+ mode: "audit" | "enforce";
201
+ rules: readonly PolicyRuleData[];
202
+ violations: readonly PolicyViolation[];
203
+ };
204
+ /**
205
+ * Truncated SHA-256 hex (16 chars / ~64 bits) over a canonical encoding
206
+ * of every field above (excluding `fingerprint` itself). Deterministic
207
+ * across runs given identical inputs. Suitable for casual tamper-evidence
208
+ * and content-addressed dedup; for full cryptographic strength, hash the
209
+ * canonical JSON externally with Web Crypto / Node `crypto`.
210
+ */
211
+ fingerprint: string;
212
+ }
213
+ /**
214
+ * One-shot point-in-time export of a {@link Graph}'s state plus optional
215
+ * audit + policy bundles. Returns a JSON-serializable object with a
216
+ * deterministic truncated-SHA-256 {@link ComplianceSnapshotResult.fingerprint}
217
+ * over the canonical payload for tamper-evidence in regulatory archival.
218
+ *
219
+ * **Cryptographic strength:** the fingerprint is truncated to 64 bits for
220
+ * compact archival. Collision-resistant for casual integrity checks but NOT
221
+ * sufficient for adversarial tamper-evidence — pair with a full SHA-256
222
+ * (or stronger) over the canonical JSON when regulatory requirements demand
223
+ * collision resistance.
224
+ */
225
+ declare function complianceSnapshot(target: Graph, opts?: ComplianceSnapshotOptions): ComplianceSnapshotResult;
226
+
227
+ type audit_AuditEntry = AuditEntry;
228
+ type audit_AuditTrailGraph = AuditTrailGraph;
229
+ declare const audit_AuditTrailGraph: typeof AuditTrailGraph;
230
+ type audit_AuditTrailOptions = AuditTrailOptions;
231
+ type audit_ComplianceSnapshotOptions = ComplianceSnapshotOptions;
232
+ type audit_ComplianceSnapshotResult = ComplianceSnapshotResult;
233
+ type audit_PolicyEnforcerGraph = PolicyEnforcerGraph;
234
+ declare const audit_PolicyEnforcerGraph: typeof PolicyEnforcerGraph;
235
+ type audit_PolicyEnforcerOptions = PolicyEnforcerOptions;
236
+ type audit_PolicyViolation = PolicyViolation;
237
+ declare const audit_auditTrail: typeof auditTrail;
238
+ declare const audit_complianceSnapshot: typeof complianceSnapshot;
239
+ declare const audit_policyEnforcer: typeof policyEnforcer;
240
+ declare const audit_reactiveExplainPath: typeof reactiveExplainPath;
241
+ declare namespace audit {
242
+ export { type audit_AuditEntry as AuditEntry, audit_AuditTrailGraph as AuditTrailGraph, type audit_AuditTrailOptions as AuditTrailOptions, type audit_ComplianceSnapshotOptions as ComplianceSnapshotOptions, type audit_ComplianceSnapshotResult as ComplianceSnapshotResult, audit_PolicyEnforcerGraph as PolicyEnforcerGraph, type audit_PolicyEnforcerOptions as PolicyEnforcerOptions, type audit_PolicyViolation as PolicyViolation, audit_auditTrail as auditTrail, audit_complianceSnapshot as complianceSnapshot, audit_policyEnforcer as policyEnforcer, audit_reactiveExplainPath as reactiveExplainPath };
243
+ }
244
+
245
+ export { type AuditEntry as A, type ComplianceSnapshotOptions as C, PolicyEnforcerGraph as P, type PolicyViolation as a, audit as b, AuditTrailGraph as c, type AuditTrailOptions as d, type ComplianceSnapshotResult as e, type PolicyEnforcerOptions as f, auditTrail as g, complianceSnapshot as h, policyEnforcer as p, reactiveExplainPath as r };
@@ -1,33 +1,11 @@
1
1
  import {
2
2
  resolveDescribeFields
3
- } from "./chunk-H4RVA4VE.js";
3
+ } from "./chunk-VYPWMZ6H.js";
4
4
  import {
5
- COMPLETE,
6
- COMPLETE_MSG,
7
- COMPLETE_ONLY_BATCH,
8
- DATA,
9
5
  DEFAULT_ACTOR,
10
- DIRTY,
11
- DIRTY_MSG,
12
- DIRTY_ONLY_BATCH,
13
- ERROR,
14
6
  GraphReFlyConfig,
15
7
  GuardDenied,
16
- INVALIDATE,
17
- INVALIDATE_MSG,
18
- INVALIDATE_ONLY_BATCH,
19
8
  NodeImpl,
20
- PAUSE,
21
- RESOLVED,
22
- RESOLVED_MSG,
23
- RESOLVED_ONLY_BATCH,
24
- RESUME,
25
- START,
26
- START_MSG,
27
- TEARDOWN,
28
- TEARDOWN_MSG,
29
- TEARDOWN_ONLY_BATCH,
30
- __export,
31
9
  accessHintForGuard,
32
10
  advanceVersion,
33
11
  autoTrackNode,
@@ -52,7 +30,31 @@ import {
52
30
  registerBuiltins,
53
31
  state,
54
32
  wallClockNs
55
- } from "./chunk-5DJTTKX3.js";
33
+ } from "./chunk-PHOUUNK7.js";
34
+ import {
35
+ COMPLETE,
36
+ COMPLETE_MSG,
37
+ COMPLETE_ONLY_BATCH,
38
+ DATA,
39
+ DIRTY,
40
+ DIRTY_MSG,
41
+ DIRTY_ONLY_BATCH,
42
+ ERROR,
43
+ INVALIDATE,
44
+ INVALIDATE_MSG,
45
+ INVALIDATE_ONLY_BATCH,
46
+ PAUSE,
47
+ RESOLVED,
48
+ RESOLVED_MSG,
49
+ RESOLVED_ONLY_BATCH,
50
+ RESUME,
51
+ START,
52
+ START_MSG,
53
+ TEARDOWN,
54
+ TEARDOWN_MSG,
55
+ TEARDOWN_ONLY_BATCH,
56
+ __export
57
+ } from "./chunk-SX52TAR4.js";
56
58
 
57
59
  // src/core/index.ts
58
60
  var core_exports = {};
@@ -112,4 +114,4 @@ __export(core_exports, {
112
114
  export {
113
115
  core_exports
114
116
  };
115
- //# sourceMappingURL=chunk-QOWVNWOC.js.map
117
+ //# sourceMappingURL=chunk-3ZWCKRHX.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/index.ts"],"sourcesContent":["/**\n * Core layer: message protocol, node primitive, lifecycle (Phase 0).\n */\nexport * from \"./actor.js\";\nexport { batch, downWithBatch, isBatching } from \"./batch.js\";\nexport { monotonicNs, wallClockNs } from \"./clock.js\";\nexport {\n\ttype GlobalInspectorEvent,\n\ttype GlobalInspectorHook,\n\tGraphReFlyConfig,\n\ttype MessageContext,\n\ttype NodeActions,\n\ttype NodeCtx,\n\ttype OnMessageHandler,\n\ttype OnSubscribeHandler,\n\tregisterBuiltins,\n\ttype SubscribeContext,\n} from \"./config.js\";\nexport * from \"./guard.js\";\nexport {\n\tCOMPLETE,\n\tCOMPLETE_MSG,\n\tCOMPLETE_ONLY_BATCH,\n\tDATA,\n\tDIRTY,\n\tDIRTY_MSG,\n\tDIRTY_ONLY_BATCH,\n\tERROR,\n\tINVALIDATE,\n\tINVALIDATE_MSG,\n\tINVALIDATE_ONLY_BATCH,\n\ttype Message,\n\ttype Messages,\n\ttype MessageTypeRegistration,\n\ttype MessageTypeRegistrationInput,\n\tPAUSE,\n\tRESOLVED,\n\tRESOLVED_MSG,\n\tRESOLVED_ONLY_BATCH,\n\tRESUME,\n\tSTART,\n\tSTART_MSG,\n\tTEARDOWN,\n\tTEARDOWN_MSG,\n\tTEARDOWN_ONLY_BATCH,\n} from \"./messages.js\";\nexport {\n\ttype DescribeDetail,\n\ttype DescribeField,\n\ttype DescribeNodeOutput,\n\tresolveDescribeFields,\n} from \"./meta.js\";\nexport {\n\tconfigure,\n\ttype DepRecord,\n\tdefaultConfig,\n\ttype FnCtx,\n\ttype Node,\n\ttype NodeDescribeKind,\n\ttype NodeFn,\n\ttype NodeFnCleanup,\n\tNodeImpl,\n\ttype NodeInspectorHook,\n\ttype NodeInspectorHookEvent,\n\ttype NodeOptions,\n\ttype NodeSink,\n\ttype NodeStatus,\n\ttype NodeTransportOptions,\n\tnode,\n} from \"./node.js\";\nexport {\n\ttype AutoTrackOptions,\n\tautoTrackNode,\n\ttype DerivedFn,\n\ttype DynamicFn,\n\tderived,\n\tdynamicNode,\n\ttype EffectFn,\n\teffect,\n\ttype PipeOperator,\n\ttype ProducerFn,\n\tpipe,\n\tproducer,\n\tstate,\n\ttype TrackFn,\n} from \"./sugar.js\";\nexport {\n\tadvanceVersion,\n\tcreateVersioning,\n\tdefaultHash,\n\ttype HashFn,\n\tisV1,\n\ttype NodeVersionInfo,\n\ttype V0,\n\ttype V1,\n\ttype VersioningLevel,\n\ttype VersioningOptions,\n} from \"./versioning.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../src/core/index.ts"],"sourcesContent":["/**\n * Core layer: message protocol, node primitive, lifecycle (Phase 0).\n */\nexport * from \"./actor.js\";\nexport { batch, downWithBatch, isBatching } from \"./batch.js\";\nexport { monotonicNs, wallClockNs } from \"./clock.js\";\nexport {\n\ttype GlobalInspectorEvent,\n\ttype GlobalInspectorHook,\n\tGraphReFlyConfig,\n\ttype MessageContext,\n\ttype NodeActions,\n\ttype NodeCtx,\n\ttype OnMessageHandler,\n\ttype OnSubscribeHandler,\n\tregisterBuiltins,\n\ttype SubscribeContext,\n} from \"./config.js\";\nexport * from \"./guard.js\";\nexport {\n\tCOMPLETE,\n\tCOMPLETE_MSG,\n\tCOMPLETE_ONLY_BATCH,\n\tDATA,\n\tDIRTY,\n\tDIRTY_MSG,\n\tDIRTY_ONLY_BATCH,\n\tERROR,\n\tINVALIDATE,\n\tINVALIDATE_MSG,\n\tINVALIDATE_ONLY_BATCH,\n\ttype Message,\n\ttype Messages,\n\ttype MessageTypeRegistration,\n\ttype MessageTypeRegistrationInput,\n\tPAUSE,\n\tRESOLVED,\n\tRESOLVED_MSG,\n\tRESOLVED_ONLY_BATCH,\n\tRESUME,\n\tSTART,\n\tSTART_MSG,\n\tTEARDOWN,\n\tTEARDOWN_MSG,\n\tTEARDOWN_ONLY_BATCH,\n} from \"./messages.js\";\nexport {\n\ttype DescribeDetail,\n\ttype DescribeField,\n\ttype DescribeNodeOutput,\n\tresolveDescribeFields,\n} from \"./meta.js\";\nexport {\n\tconfigure,\n\ttype DepRecord,\n\tdefaultConfig,\n\ttype FnCtx,\n\ttype Node,\n\ttype NodeDescribeKind,\n\ttype NodeFn,\n\ttype NodeFnCleanup,\n\tNodeImpl,\n\ttype NodeInspectorHook,\n\ttype NodeInspectorHookEvent,\n\ttype NodeOptions,\n\ttype NodeSink,\n\ttype NodeStatus,\n\ttype NodeTransportOptions,\n\tnode,\n} from \"./node.js\";\nexport {\n\ttype AutoTrackOptions,\n\tautoTrackNode,\n\ttype DerivedFn,\n\ttype DynamicFn,\n\tderived,\n\tdynamicNode,\n\ttype EffectFn,\n\teffect,\n\ttype PipeOperator,\n\ttype ProducerFn,\n\tpipe,\n\tproducer,\n\tstate,\n\ttype TrackFn,\n} from \"./sugar.js\";\nexport {\n\tadvanceVersion,\n\tcreateVersioning,\n\tdefaultHash,\n\ttype HashFn,\n\tisV1,\n\ttype NodeVersionInfo,\n\ttype V0,\n\ttype V1,\n\ttype VersioningLevel,\n\ttype VersioningOptions,\n} from \"./versioning.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
@@ -0,0 +1,62 @@
1
+ import {
2
+ Graph
3
+ } from "./chunk-PF7GRZMW.js";
4
+ import {
5
+ state
6
+ } from "./chunk-PHOUUNK7.js";
7
+ import {
8
+ DATA,
9
+ __export
10
+ } from "./chunk-SX52TAR4.js";
11
+
12
+ // src/compat/zustand/index.ts
13
+ var zustand_exports = {};
14
+ __export(zustand_exports, {
15
+ create: () => create
16
+ });
17
+ var alwaysDiffer = () => false;
18
+ function create(initializer) {
19
+ const g = new Graph("zustand");
20
+ const s = state(void 0, {
21
+ name: "state",
22
+ equals: alwaysDiffer
23
+ });
24
+ g.add("state", s);
25
+ const getState = () => s.cache;
26
+ const setState = (partial, replace) => {
27
+ const prev = s.cache;
28
+ const next = typeof partial === "function" ? partial(prev) : partial;
29
+ s.emit(replace ? next : { ...prev, ...next });
30
+ };
31
+ const api = {
32
+ getState,
33
+ setState,
34
+ getInitialState: () => initialValue,
35
+ subscribe: (listener) => {
36
+ let initial = true;
37
+ let prev = s.cache;
38
+ return s.subscribe((msgs) => {
39
+ for (const [t, v] of msgs) {
40
+ if (t === DATA) {
41
+ if (initial) {
42
+ initial = false;
43
+ continue;
44
+ }
45
+ listener(v, prev);
46
+ prev = v;
47
+ }
48
+ }
49
+ });
50
+ },
51
+ destroy: g.destroy.bind(g)
52
+ };
53
+ const initialValue = initializer(setState, getState, api);
54
+ s.emit(initialValue);
55
+ return Object.assign(g, api);
56
+ }
57
+
58
+ export {
59
+ create,
60
+ zustand_exports
61
+ };
62
+ //# sourceMappingURL=chunk-APFNLIRG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/compat/zustand/index.ts"],"sourcesContent":["import { DATA } from \"../../core/messages.js\";\nimport { state as stateNode } from \"../../core/sugar.js\";\nimport { Graph } from \"../../graph/graph.js\";\n\n// Zustand fires listeners on every setState, regardless of reference\n// equality. Configure the state node with a permissive equals so every\n// emit produces DATA (not RESOLVED). Diamond coordination still works\n// because `n.emit` routes through the framed pipeline which auto-\n// prefixes `[DIRTY]`.\nconst alwaysDiffer = () => false;\n\n/** Zustand-compatible Store API. */\nexport interface StoreApi<T> {\n\tgetState: () => T;\n\tsetState: (partial: T | Partial<T> | ((state: T) => T | Partial<T>), replace?: boolean) => void;\n\tgetInitialState: () => T;\n\tsubscribe: (listener: (state: T, prevState: T) => void) => () => void;\n\tdestroy: () => void;\n}\n\n/** Function type for initializing the store. */\nexport type StateCreator<T> = (\n\tset: StoreApi<T>[\"setState\"],\n\tget: StoreApi<T>[\"getState\"],\n\tapi: StoreApi<T>,\n) => T;\n\n/**\n * Creates a Zustand-compatible store backed by a GraphReFly state node.\n * returns an object that is both a Graph and a StoreApi.\n *\n * @example\n * ```ts\n * const store = create((set) => ({\n * count: 0,\n * inc: () => set((s) => ({ count: s.count + 1 }))\n * }));\n * store.getState().inc();\n * ```\n *\n * @category compat\n */\nexport function create<T extends object>(initializer: StateCreator<T>): Graph & StoreApi<T> {\n\tconst g = new Graph(\"zustand\");\n\tconst s = stateNode<T>(undefined as unknown as T, {\n\t\tname: \"state\",\n\t\tequals: alwaysDiffer,\n\t});\n\tg.add(\"state\", s);\n\n\t// `getState` and `setState` read/write through `s` directly — the single\n\t// source of truth. `s.cache` is `undefined` (SENTINEL) until `emit()` is\n\t// called, but action closures (e.g. `inc: () => set(...)`) are only ever\n\t// invoked after initialization, so `s.cache` is valid by that time.\n\tconst getState = () => s.cache as T;\n\tconst setState = (partial: any, replace?: boolean): void => {\n\t\tconst prev = s.cache as T;\n\t\tconst next = typeof partial === \"function\" ? partial(prev) : partial;\n\t\t// `n.emit` goes through `_actionEmit` → `bundle()`, which auto-\n\t\t// prefixes `[DIRTY]` so diamond legs coordinate under downstream\n\t\t// composition. The `alwaysDiffer` equals keeps zustand's \"fire\n\t\t// on every setState\" semantics.\n\t\ts.emit(replace ? next : { ...prev, ...next });\n\t};\n\n\tconst api: StoreApi<T> = {\n\t\tgetState,\n\t\tsetState,\n\t\tgetInitialState: () => initialValue,\n\t\tsubscribe: (listener) => {\n\t\t\t// Skip the initial push-on-subscribe DATA — zustand subscribe fires on changes only.\n\t\t\tlet initial = true;\n\t\t\tlet prev = s.cache as T;\n\t\t\treturn s.subscribe((msgs) => {\n\t\t\t\tfor (const [t, v] of msgs) {\n\t\t\t\t\tif (t === DATA) {\n\t\t\t\t\t\tif (initial) {\n\t\t\t\t\t\t\tinitial = false;\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlistener(v as T, prev);\n\t\t\t\t\t\tprev = v as T;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tdestroy: g.destroy.bind(g),\n\t};\n\n\tconst initialValue = initializer(setState, getState, api);\n\ts.emit(initialValue);\n\n\treturn Object.assign(g, api);\n}\n"],"mappings":";;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AASA,IAAM,eAAe,MAAM;AAiCpB,SAAS,OAAyB,aAAmD;AAC3F,QAAM,IAAI,IAAI,MAAM,SAAS;AAC7B,QAAM,IAAI,MAAa,QAA2B;AAAA,IACjD,MAAM;AAAA,IACN,QAAQ;AAAA,EACT,CAAC;AACD,IAAE,IAAI,SAAS,CAAC;AAMhB,QAAM,WAAW,MAAM,EAAE;AACzB,QAAM,WAAW,CAAC,SAAc,YAA4B;AAC3D,UAAM,OAAO,EAAE;AACf,UAAM,OAAO,OAAO,YAAY,aAAa,QAAQ,IAAI,IAAI;AAK7D,MAAE,KAAK,UAAU,OAAO,EAAE,GAAG,MAAM,GAAG,KAAK,CAAC;AAAA,EAC7C;AAEA,QAAM,MAAmB;AAAA,IACxB;AAAA,IACA;AAAA,IACA,iBAAiB,MAAM;AAAA,IACvB,WAAW,CAAC,aAAa;AAExB,UAAI,UAAU;AACd,UAAI,OAAO,EAAE;AACb,aAAO,EAAE,UAAU,CAAC,SAAS;AAC5B,mBAAW,CAAC,GAAG,CAAC,KAAK,MAAM;AAC1B,cAAI,MAAM,MAAM;AACf,gBAAI,SAAS;AACZ,wBAAU;AACV;AAAA,YACD;AACA,qBAAS,GAAQ,IAAI;AACrB,mBAAO;AAAA,UACR;AAAA,QACD;AAAA,MACD,CAAC;AAAA,IACF;AAAA,IACA,SAAS,EAAE,QAAQ,KAAK,CAAC;AAAA,EAC1B;AAEA,QAAM,eAAe,YAAY,UAAU,UAAU,GAAG;AACxD,IAAE,KAAK,YAAY;AAEnB,SAAO,OAAO,OAAO,GAAG,GAAG;AAC5B;","names":[]}