@graphrefly/graphrefly 0.26.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 (150) hide show
  1. package/dist/ai-CaR_912Q.d.cts +1033 -0
  2. package/dist/ai-WlRltJV7.d.ts +1033 -0
  3. package/dist/audit-ClmqGOCx.d.cts +245 -0
  4. package/dist/audit-DRlSzBu9.d.ts +245 -0
  5. package/dist/{chunk-JYXEWPH4.js → chunk-APFNLIRG.js} +2 -2
  6. package/dist/chunk-AT5LKYNL.js +395 -0
  7. package/dist/chunk-AT5LKYNL.js.map +1 -0
  8. package/dist/{chunk-AMCG74RZ.js → chunk-BQ6RQQFF.js} +215 -2128
  9. package/dist/chunk-BQ6RQQFF.js.map +1 -0
  10. package/dist/{chunk-IZYUSJC7.js → chunk-DST5DKZS.js} +6 -4
  11. package/dist/{chunk-IZYUSJC7.js.map → chunk-DST5DKZS.js.map} +1 -1
  12. package/dist/{chunk-LCE3GF5P.js → chunk-GTE6PWRZ.js} +2 -2
  13. package/dist/{chunk-RB6QPHJ7.js → chunk-J2VBW3DZ.js} +2 -93
  14. package/dist/chunk-J2VBW3DZ.js.map +1 -0
  15. package/dist/{chunk-FQMKGR6L.js → chunk-JWBCY4NC.js} +3 -3
  16. package/dist/chunk-K2AUJHVP.js +2251 -0
  17. package/dist/chunk-K2AUJHVP.js.map +1 -0
  18. package/dist/chunk-NC6S43JJ.js +456 -0
  19. package/dist/chunk-NC6S43JJ.js.map +1 -0
  20. package/dist/chunk-OFVJBJXR.js +98 -0
  21. package/dist/chunk-OFVJBJXR.js.map +1 -0
  22. package/dist/{chunk-6LDQFTYS.js → chunk-OU5CQKNW.js} +2 -2
  23. package/dist/{chunk-THTWHNU4.js → chunk-PF7GRZMW.js} +5 -5
  24. package/dist/chunk-RNHBMHKA.js +1665 -0
  25. package/dist/chunk-RNHBMHKA.js.map +1 -0
  26. package/dist/{chunk-SN4YWWYO.js → chunk-WBZOVTYK.js} +11 -11
  27. package/dist/chunk-WKNUIZOY.js +354 -0
  28. package/dist/chunk-WKNUIZOY.js.map +1 -0
  29. package/dist/{chunk-ZQMEI34O.js → chunk-X3VMZYBT.js} +3 -3
  30. package/dist/chunk-X5R3GL6H.js +525 -0
  31. package/dist/chunk-X5R3GL6H.js.map +1 -0
  32. package/dist/compat/index.d.cts +14 -14
  33. package/dist/compat/index.d.ts +14 -14
  34. package/dist/compat/index.js +17 -16
  35. package/dist/compat/jotai/index.d.cts +2 -2
  36. package/dist/compat/jotai/index.d.ts +2 -2
  37. package/dist/compat/nanostores/index.d.cts +2 -2
  38. package/dist/compat/nanostores/index.d.ts +2 -2
  39. package/dist/compat/nestjs/index.d.cts +6 -6
  40. package/dist/compat/nestjs/index.d.ts +6 -6
  41. package/dist/compat/nestjs/index.js +7 -6
  42. package/dist/compat/react/index.d.cts +2 -2
  43. package/dist/compat/react/index.d.ts +2 -2
  44. package/dist/compat/solid/index.d.cts +2 -2
  45. package/dist/compat/solid/index.d.ts +2 -2
  46. package/dist/compat/svelte/index.d.cts +2 -2
  47. package/dist/compat/svelte/index.d.ts +2 -2
  48. package/dist/compat/vue/index.d.cts +2 -2
  49. package/dist/compat/vue/index.d.ts +2 -2
  50. package/dist/compat/zustand/index.d.cts +5 -5
  51. package/dist/compat/zustand/index.d.ts +5 -5
  52. package/dist/compat/zustand/index.js +3 -3
  53. package/dist/composite-C7PcQvcs.d.cts +303 -0
  54. package/dist/composite-aUCvjZVR.d.ts +303 -0
  55. package/dist/core/index.d.cts +4 -3
  56. package/dist/core/index.d.ts +4 -3
  57. package/dist/{demo-shell-DEp-nMTl.d.ts → demo-shell-BDkOptd6.d.ts} +2 -2
  58. package/dist/{demo-shell-26p5fVxn.d.cts → demo-shell-Crid1WdR.d.cts} +2 -2
  59. package/dist/extra/index.d.cts +5 -4
  60. package/dist/extra/index.d.ts +5 -4
  61. package/dist/extra/index.js +68 -62
  62. package/dist/extra/sources.d.cts +1 -1
  63. package/dist/extra/sources.d.ts +1 -1
  64. package/dist/graph/index.d.cts +5 -5
  65. package/dist/graph/index.d.ts +5 -5
  66. package/dist/graph/index.js +3 -3
  67. package/dist/{graph-DQ69XU0g.d.ts → graph-CCwGKLCm.d.ts} +4 -4
  68. package/dist/{graph-6tZ5jEzr.d.cts → graph-DNCrvZSn.d.cts} +4 -4
  69. package/dist/{index-qldRdbQw.d.ts → index-3lsddbbS.d.ts} +1 -1
  70. package/dist/{index-Bxb5ZYc9.d.cts → index-B1tloyhO.d.cts} +1 -1
  71. package/dist/{index-eJ6T_qGM.d.ts → index-B6D3QNSA.d.ts} +2 -2
  72. package/dist/{index-B4MP_8V_.d.cts → index-B6EhDnjH.d.cts} +1 -1
  73. package/dist/{index-CmnuOibw.d.ts → index-B9B7_HEY.d.ts} +1 -1
  74. package/dist/{index-BeIdBfcb.d.cts → index-BHlKbUwO.d.cts} +16 -315
  75. package/dist/{index-CuYwdKO-.d.ts → index-BPVt8kqc.d.ts} +3 -3
  76. package/dist/index-BaSM3aYt.d.ts +195 -0
  77. package/dist/{index-BjI6ty9z.d.ts → index-BuEoe-Qu.d.ts} +9 -9
  78. package/dist/{index-DdD5MVDL.d.ts → index-BwfLUNw4.d.ts} +16 -315
  79. package/dist/{index-QBpffFW-.d.cts → index-ByQxazQJ.d.cts} +1 -1
  80. package/dist/{index-xdGjv0nO.d.ts → index-C0svESO4.d.ts} +1 -1
  81. package/dist/{index-BW1z3BN9.d.ts → index-C8oil6M6.d.ts} +3 -3
  82. package/dist/{index-C8mdwMXc.d.cts → index-CI3DprxP.d.cts} +3 -3
  83. package/dist/{index-CUwyr1Kk.d.cts → index-CO8uBlUh.d.cts} +2 -2
  84. package/dist/{index-DrISNAOm.d.ts → index-CxFrXH4m.d.ts} +1 -1
  85. package/dist/{index-BEfE8H_G.d.cts → index-D8wS_PeY.d.cts} +9 -9
  86. package/dist/{index-CUyrtuOf.d.cts → index-DO_6JN9Z.d.cts} +1 -1
  87. package/dist/index-DVGiGFGT.d.cts +195 -0
  88. package/dist/{index-DFhjO4Gg.d.cts → index-DYme44FM.d.cts} +1 -1
  89. package/dist/{index-_oMEWlDq.d.cts → index-DlLp-2Xn.d.cts} +3 -3
  90. package/dist/{index-CPgZ5wRl.d.ts → index-Dzk2hrlR.d.ts} +1 -1
  91. package/dist/{index-Bd_fwmLf.d.cts → index-VHqptjhu.d.cts} +1 -1
  92. package/dist/{index-CDAjUFIv.d.ts → index-VdHQMPy1.d.ts} +1 -1
  93. package/dist/{index-B_IP40nB.d.cts → index-Xi3u0HCQ.d.cts} +1 -1
  94. package/dist/{index-BYOHF0zP.d.ts → index-wEn0eFe8.d.ts} +1 -1
  95. package/dist/index.d.cts +35 -1692
  96. package/dist/index.d.ts +35 -1692
  97. package/dist/index.js +307 -3731
  98. package/dist/index.js.map +1 -1
  99. package/dist/memory-C6Z2tGpC.d.cts +139 -0
  100. package/dist/memory-li6FL5RM.d.ts +139 -0
  101. package/dist/messaging-Gt4LPbyA.d.cts +269 -0
  102. package/dist/messaging-XDoYablx.d.ts +269 -0
  103. package/dist/{meta-C0-8XW6Q.d.cts → meta-BxCA7rcr.d.cts} +1 -1
  104. package/dist/{meta-BGqSZ7mt.d.ts → meta-CbznRPYJ.d.ts} +1 -1
  105. package/dist/{node-C_IBuvX2.d.cts → node-BmerH3kS.d.cts} +1 -1
  106. package/dist/{node-C_IBuvX2.d.ts → node-BmerH3kS.d.ts} +1 -1
  107. package/dist/{observable-DCk45RH5.d.ts → observable-BgGUwcqp.d.ts} +1 -1
  108. package/dist/{observable-Crr1jgzx.d.cts → observable-DJt_AxzQ.d.cts} +1 -1
  109. package/dist/patterns/ai.cjs +7930 -0
  110. package/dist/patterns/ai.cjs.map +1 -0
  111. package/dist/patterns/ai.d.cts +10 -0
  112. package/dist/patterns/ai.d.ts +10 -0
  113. package/dist/patterns/ai.js +71 -0
  114. package/dist/patterns/ai.js.map +1 -0
  115. package/dist/patterns/audit.cjs +5805 -0
  116. package/dist/patterns/audit.cjs.map +1 -0
  117. package/dist/patterns/audit.d.cts +6 -0
  118. package/dist/patterns/audit.d.ts +6 -0
  119. package/dist/patterns/audit.js +29 -0
  120. package/dist/patterns/audit.js.map +1 -0
  121. package/dist/patterns/demo-shell.d.cts +6 -6
  122. package/dist/patterns/demo-shell.d.ts +6 -6
  123. package/dist/patterns/demo-shell.js +4 -4
  124. package/dist/patterns/memory.cjs +5283 -0
  125. package/dist/patterns/memory.cjs.map +1 -0
  126. package/dist/patterns/memory.d.cts +5 -0
  127. package/dist/patterns/memory.d.ts +5 -0
  128. package/dist/patterns/memory.js +20 -0
  129. package/dist/patterns/memory.js.map +1 -0
  130. package/dist/patterns/reactive-layout/index.d.cts +6 -6
  131. package/dist/patterns/reactive-layout/index.d.ts +6 -6
  132. package/dist/patterns/reactive-layout/index.js +4 -4
  133. package/dist/{reactive-layout-BaOQefHu.d.cts → reactive-layout-MQP--J3F.d.cts} +2 -2
  134. package/dist/{reactive-layout-D9gejYXE.d.ts → reactive-layout-u5Ulnqag.d.ts} +2 -2
  135. package/dist/{storage-BMycWEh2.d.ts → storage-CMjUUuxn.d.ts} +2 -2
  136. package/dist/{storage-DiqWHzVI.d.cts → storage-DdWlZo6U.d.cts} +2 -2
  137. package/dist/sugar-CCOxXK1e.d.ts +201 -0
  138. package/dist/sugar-D02n5JjF.d.cts +201 -0
  139. package/package.json +32 -2
  140. package/dist/chunk-AMCG74RZ.js.map +0 -1
  141. package/dist/chunk-RB6QPHJ7.js.map +0 -1
  142. package/dist/index-C0ZXMaXO.d.cts +0 -392
  143. package/dist/index-CY2TljO4.d.ts +0 -392
  144. /package/dist/{chunk-JYXEWPH4.js.map → chunk-APFNLIRG.js.map} +0 -0
  145. /package/dist/{chunk-LCE3GF5P.js.map → chunk-GTE6PWRZ.js.map} +0 -0
  146. /package/dist/{chunk-FQMKGR6L.js.map → chunk-JWBCY4NC.js.map} +0 -0
  147. /package/dist/{chunk-6LDQFTYS.js.map → chunk-OU5CQKNW.js.map} +0 -0
  148. /package/dist/{chunk-THTWHNU4.js.map → chunk-PF7GRZMW.js.map} +0 -0
  149. /package/dist/{chunk-SN4YWWYO.js.map → chunk-WBZOVTYK.js.map} +0 -0
  150. /package/dist/{chunk-ZQMEI34O.js.map → chunk-X3VMZYBT.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,6 +1,6 @@
1
1
  import {
2
2
  Graph
3
- } from "./chunk-THTWHNU4.js";
3
+ } from "./chunk-PF7GRZMW.js";
4
4
  import {
5
5
  state
6
6
  } from "./chunk-PHOUUNK7.js";
@@ -59,4 +59,4 @@ export {
59
59
  create,
60
60
  zustand_exports
61
61
  };
62
- //# sourceMappingURL=chunk-JYXEWPH4.js.map
62
+ //# sourceMappingURL=chunk-APFNLIRG.js.map