@graphrefly/graphrefly 0.17.0 → 0.19.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 (77) hide show
  1. package/dist/{chunk-R6OHUUYB.js → chunk-AHRKWMNI.js} +7 -7
  2. package/dist/chunk-AHRKWMNI.js.map +1 -0
  3. package/dist/{chunk-2PORF4RP.js → chunk-BER7UYLM.js} +27 -32
  4. package/dist/chunk-BER7UYLM.js.map +1 -0
  5. package/dist/{chunk-646OG3PO.js → chunk-IRZAGZUB.js} +51 -52
  6. package/dist/chunk-IRZAGZUB.js.map +1 -0
  7. package/dist/{chunk-IHJHBADD.js → chunk-JC2SN46B.js} +385 -197
  8. package/dist/chunk-JC2SN46B.js.map +1 -0
  9. package/dist/{chunk-XJ6EMQ22.js → chunk-OO5QOAXI.js} +4 -10
  10. package/dist/chunk-OO5QOAXI.js.map +1 -0
  11. package/dist/{chunk-YXROQFXZ.js → chunk-UW77D7SP.js} +3 -3
  12. package/dist/{chunk-F2ULI3Q3.js → chunk-XUOY3YKN.js} +7 -3
  13. package/dist/chunk-XUOY3YKN.js.map +1 -0
  14. package/dist/chunk-YLR5JUJZ.js +111 -0
  15. package/dist/chunk-YLR5JUJZ.js.map +1 -0
  16. package/dist/{chunk-BV3TPSBK.js → chunk-YXR3WW3Q.js} +740 -755
  17. package/dist/chunk-YXR3WW3Q.js.map +1 -0
  18. package/dist/compat/nestjs/index.cjs +1127 -983
  19. package/dist/compat/nestjs/index.cjs.map +1 -1
  20. package/dist/compat/nestjs/index.d.cts +4 -4
  21. package/dist/compat/nestjs/index.d.ts +4 -4
  22. package/dist/compat/nestjs/index.js +7 -13
  23. package/dist/core/index.cjs +653 -749
  24. package/dist/core/index.cjs.map +1 -1
  25. package/dist/core/index.d.cts +2 -2
  26. package/dist/core/index.d.ts +2 -2
  27. package/dist/core/index.js +7 -7
  28. package/dist/extra/index.cjs +773 -795
  29. package/dist/extra/index.cjs.map +1 -1
  30. package/dist/extra/index.d.cts +4 -4
  31. package/dist/extra/index.d.ts +4 -4
  32. package/dist/extra/index.js +5 -11
  33. package/dist/graph/index.cjs +1036 -975
  34. package/dist/graph/index.cjs.map +1 -1
  35. package/dist/graph/index.d.cts +3 -3
  36. package/dist/graph/index.d.ts +3 -3
  37. package/dist/graph/index.js +8 -8
  38. package/dist/{graph-fCsaaVIa.d.cts → graph-KsTe57nI.d.cts} +127 -51
  39. package/dist/{graph-Dc-P9BVm.d.ts → graph-mILUUqW8.d.ts} +127 -51
  40. package/dist/{index-DhXznWyH.d.ts → index-8a605sg9.d.ts} +2 -2
  41. package/dist/{index-D7y9Q8W4.d.ts → index-B2SvPEbc.d.ts} +8 -69
  42. package/dist/{index-YlOH1Gw6.d.cts → index-BBUYZfJ1.d.cts} +122 -78
  43. package/dist/{index-ClaKZFPl.d.cts → index-Bjh5C1Tp.d.cts} +38 -35
  44. package/dist/{index-DWq0P9T6.d.ts → index-BjtlNirP.d.cts} +5 -7
  45. package/dist/{index-N704txAA.d.ts → index-BnkMgNNa.d.ts} +38 -35
  46. package/dist/{index-BBVBYPxr.d.cts → index-CgSiUouz.d.ts} +5 -7
  47. package/dist/{index-BmoUvOGN.d.ts → index-CvKzv0AW.d.ts} +122 -78
  48. package/dist/{index-4OIX-q0C.d.cts → index-UudxGnzc.d.cts} +8 -69
  49. package/dist/{index-DlGMf_Qe.d.cts → index-VHA43cGP.d.cts} +2 -2
  50. package/dist/index.cjs +6146 -5725
  51. package/dist/index.cjs.map +1 -1
  52. package/dist/index.d.cts +617 -383
  53. package/dist/index.d.ts +617 -383
  54. package/dist/index.js +4401 -4028
  55. package/dist/index.js.map +1 -1
  56. package/dist/{meta-BV4pj9ML.d.cts → meta-BnG7XAaE.d.cts} +395 -289
  57. package/dist/{meta-BV4pj9ML.d.ts → meta-BnG7XAaE.d.ts} +395 -289
  58. package/dist/observable-C8Kx_O6k.d.cts +36 -0
  59. package/dist/observable-DcBwQY7t.d.ts +36 -0
  60. package/dist/patterns/reactive-layout/index.cjs +1037 -857
  61. package/dist/patterns/reactive-layout/index.cjs.map +1 -1
  62. package/dist/patterns/reactive-layout/index.d.cts +3 -3
  63. package/dist/patterns/reactive-layout/index.d.ts +3 -3
  64. package/dist/patterns/reactive-layout/index.js +4 -4
  65. package/package.json +1 -1
  66. package/dist/chunk-2PORF4RP.js.map +0 -1
  67. package/dist/chunk-646OG3PO.js.map +0 -1
  68. package/dist/chunk-BV3TPSBK.js.map +0 -1
  69. package/dist/chunk-EBNKJULL.js +0 -231
  70. package/dist/chunk-EBNKJULL.js.map +0 -1
  71. package/dist/chunk-F2ULI3Q3.js.map +0 -1
  72. package/dist/chunk-IHJHBADD.js.map +0 -1
  73. package/dist/chunk-R6OHUUYB.js.map +0 -1
  74. package/dist/chunk-XJ6EMQ22.js.map +0 -1
  75. package/dist/observable-Cz-AWhwR.d.cts +0 -42
  76. package/dist/observable-DCqlwGyl.d.ts +0 -42
  77. /package/dist/{chunk-YXROQFXZ.js.map → chunk-UW77D7SP.js.map} +0 -0
@@ -1,3 +1,3 @@
1
- export { D as DeltaCheckpoint, E as EvictedSubgraphInfo, b as EvictionPolicy, c as GraphCodec, a as GraphProfileOptions, G as GraphProfileResult, J as JsonCodec, L as LazyGraphCodec, N as NodeProfile, W as WALEntry, d as createDagCborCodec, e as createDagCborZstdCodec, g as graphProfile, n as negotiateCodec, r as replayWAL, s as sizeof } from '../index-4OIX-q0C.cjs';
2
- export { A as AutoCheckpointAdapter, D as DescribeFilter, d as GRAPH_META_SEGMENT, G as Graph, e as GraphActorOptions, b as GraphAutoCheckpointHandle, c as GraphAutoCheckpointOptions, f as GraphCheckpointRecord, g as GraphDescribeOptions, h as GraphDescribeOutput, i as GraphDiagramDirection, j as GraphDiagramOptions, k as GraphDiffChange, l as GraphDiffResult, m as GraphDumpOptions, n as GraphFactoryContext, o as GraphNodeFactory, p as GraphObserveAll, q as GraphObserveOne, a as GraphOptions, r as GraphPersistSnapshot, s as GraphSpyHandle, t as GraphSpyOptions, u as GraphSpyTheme, v as GraphSpyThemeName, O as ObserveDetail, w as ObserveEvent, x as ObserveOptions, y as ObserveResult, R as ReachableDirection, z as ReachableOptions, T as TraceEntry, B as reachable } from '../graph-fCsaaVIa.cjs';
3
- import '../meta-BV4pj9ML.cjs';
1
+ export { D as DeltaCheckpoint, E as EvictedSubgraphInfo, a as EvictionPolicy, G as GraphCodec, J as JsonCodec, L as LazyGraphCodec, W as WALEntry, c as createDagCborCodec, b as createDagCborZstdCodec, n as negotiateCodec, r as replayWAL, s as sizeof } from '../index-UudxGnzc.cjs';
2
+ export { A as AutoCheckpointAdapter, D as DescribeFilter, f as GRAPH_META_SEGMENT, G as Graph, g as GraphActorOptions, b as GraphAutoCheckpointHandle, c as GraphAutoCheckpointOptions, h as GraphCheckpointRecord, i as GraphDescribeOptions, j as GraphDescribeOutput, k as GraphDiagramDirection, l as GraphDiagramOptions, m as GraphDiffChange, n as GraphDiffResult, o as GraphDumpOptions, p as GraphFactoryContext, q as GraphNodeFactory, r as GraphObserveAll, s as GraphObserveOne, a as GraphOptions, t as GraphPersistSnapshot, e as GraphProfileOptions, d as GraphProfileResult, N as NodeProfile, O as ObserveDetail, u as ObserveEvent, v as ObserveOptions, w as ObserveResult, x as ObserveTheme, y as ObserveThemeName, R as ReachableDirection, z as ReachableOptions, T as TraceEntry, B as graphProfile, C as reachable } from '../graph-KsTe57nI.cjs';
3
+ import '../meta-BnG7XAaE.cjs';
@@ -1,3 +1,3 @@
1
- export { D as DeltaCheckpoint, E as EvictedSubgraphInfo, b as EvictionPolicy, c as GraphCodec, a as GraphProfileOptions, G as GraphProfileResult, J as JsonCodec, L as LazyGraphCodec, N as NodeProfile, W as WALEntry, d as createDagCborCodec, e as createDagCborZstdCodec, g as graphProfile, n as negotiateCodec, r as replayWAL, s as sizeof } from '../index-D7y9Q8W4.js';
2
- export { A as AutoCheckpointAdapter, D as DescribeFilter, d as GRAPH_META_SEGMENT, G as Graph, e as GraphActorOptions, b as GraphAutoCheckpointHandle, c as GraphAutoCheckpointOptions, f as GraphCheckpointRecord, g as GraphDescribeOptions, h as GraphDescribeOutput, i as GraphDiagramDirection, j as GraphDiagramOptions, k as GraphDiffChange, l as GraphDiffResult, m as GraphDumpOptions, n as GraphFactoryContext, o as GraphNodeFactory, p as GraphObserveAll, q as GraphObserveOne, a as GraphOptions, r as GraphPersistSnapshot, s as GraphSpyHandle, t as GraphSpyOptions, u as GraphSpyTheme, v as GraphSpyThemeName, O as ObserveDetail, w as ObserveEvent, x as ObserveOptions, y as ObserveResult, R as ReachableDirection, z as ReachableOptions, T as TraceEntry, B as reachable } from '../graph-Dc-P9BVm.js';
3
- import '../meta-BV4pj9ML.js';
1
+ export { D as DeltaCheckpoint, E as EvictedSubgraphInfo, a as EvictionPolicy, G as GraphCodec, J as JsonCodec, L as LazyGraphCodec, W as WALEntry, c as createDagCborCodec, b as createDagCborZstdCodec, n as negotiateCodec, r as replayWAL, s as sizeof } from '../index-B2SvPEbc.js';
2
+ export { A as AutoCheckpointAdapter, D as DescribeFilter, f as GRAPH_META_SEGMENT, G as Graph, g as GraphActorOptions, b as GraphAutoCheckpointHandle, c as GraphAutoCheckpointOptions, h as GraphCheckpointRecord, i as GraphDescribeOptions, j as GraphDescribeOutput, k as GraphDiagramDirection, l as GraphDiagramOptions, m as GraphDiffChange, n as GraphDiffResult, o as GraphDumpOptions, p as GraphFactoryContext, q as GraphNodeFactory, r as GraphObserveAll, s as GraphObserveOne, a as GraphOptions, t as GraphPersistSnapshot, e as GraphProfileOptions, d as GraphProfileResult, N as NodeProfile, O as ObserveDetail, u as ObserveEvent, v as ObserveOptions, w as ObserveResult, x as ObserveTheme, y as ObserveThemeName, R as ReachableDirection, z as ReachableOptions, T as TraceEntry, B as graphProfile, C as reachable } from '../graph-mILUUqW8.js';
3
+ import '../meta-BnG7XAaE.js';
@@ -2,18 +2,18 @@ import {
2
2
  JsonCodec,
3
3
  createDagCborCodec,
4
4
  createDagCborZstdCodec,
5
- graphProfile,
6
5
  negotiateCodec,
7
- replayWAL,
8
- sizeof
9
- } from "../chunk-EBNKJULL.js";
6
+ replayWAL
7
+ } from "../chunk-YLR5JUJZ.js";
10
8
  import {
11
9
  GRAPH_META_SEGMENT,
12
10
  Graph,
13
- reachable
14
- } from "../chunk-IHJHBADD.js";
15
- import "../chunk-F2ULI3Q3.js";
16
- import "../chunk-BV3TPSBK.js";
11
+ graphProfile,
12
+ reachable,
13
+ sizeof
14
+ } from "../chunk-JC2SN46B.js";
15
+ import "../chunk-XUOY3YKN.js";
16
+ import "../chunk-YXR3WW3Q.js";
17
17
  export {
18
18
  GRAPH_META_SEGMENT,
19
19
  Graph,
@@ -1,4 +1,67 @@
1
- import { j as DescribeNodeOutput, h as DescribeDetail, i as DescribeField, N as Node, y as VersioningLevel, A as Actor, m as Messages, p as NodeSink } from './meta-BV4pj9ML.cjs';
1
+ import { i as DescribeNodeOutput, g as DescribeDetail, h as DescribeField, N as Node, y as VersioningLevel, A as Actor, l as Messages, o as NodeSink } from './meta-BnG7XAaE.cjs';
2
+
3
+ /**
4
+ * Graph profiling and inspection utilities.
5
+ *
6
+ * Provides per-node memory estimation, connectivity stats, and hotspot
7
+ * detection. Non-invasive — reads from `describe()` and node internals
8
+ * without modifying state.
9
+ *
10
+ * @module
11
+ */
12
+
13
+ /** Per-node profile entry. */
14
+ interface NodeProfile {
15
+ /** Qualified path within the graph. */
16
+ path: string;
17
+ /** Node type (state, derived, producer, effect). */
18
+ type: string;
19
+ /** Node status (disconnected, dirty, settled, errored, completed). */
20
+ status: string;
21
+ /** Approximate retained bytes for the node's cached value. */
22
+ valueSizeBytes: number;
23
+ /** Number of downstream subscribers (sinks). */
24
+ subscriberCount: number;
25
+ /** Number of upstream dependencies. */
26
+ depCount: number;
27
+ /** True if this is an effect node with no external subscribers (potential leak). */
28
+ isOrphanEffect: boolean;
29
+ }
30
+ /** Aggregate graph profile. */
31
+ interface GraphProfileResult {
32
+ /** Total node count. */
33
+ nodeCount: number;
34
+ /** Total edge count. */
35
+ edgeCount: number;
36
+ /** Subgraph count. */
37
+ subgraphCount: number;
38
+ /** All node profiles. */
39
+ nodes: NodeProfile[];
40
+ /** Total approximate value memory across all nodes. */
41
+ totalValueSizeBytes: number;
42
+ /** Nodes sorted by valueSizeBytes descending (top N). */
43
+ hotspots: NodeProfile[];
44
+ /** Effect nodes with no external subscribers (potential leaks). */
45
+ orphanEffects: NodeProfile[];
46
+ }
47
+ /** Options for {@link graphProfile}. */
48
+ interface GraphProfileOptions {
49
+ /** Limit hotspot list (default 10). */
50
+ topN?: number;
51
+ /** Include subgraph nodes recursively (default true). */
52
+ recursive?: boolean;
53
+ }
54
+ /**
55
+ * Profile a graph's memory and connectivity characteristics.
56
+ *
57
+ * Uses `describe({ detail: "standard" })` for node metadata and direct
58
+ * `NodeImpl` access for subscriber counts and cached values.
59
+ *
60
+ * @param graph - The graph to profile.
61
+ * @param opts - Optional configuration.
62
+ * @returns Aggregate profile with per-node details and hotspots.
63
+ */
64
+ declare function graphProfile(graph: Graph, opts?: GraphProfileOptions): GraphProfileResult;
2
65
 
3
66
  /**
4
67
  * Reserved segment for meta companion paths: `nodeName::__meta__::metaKey` (GRAPHREFLY-SPEC §3.6).
@@ -165,6 +228,19 @@ type ObserveOptions = {
165
228
  * `"minimal"` filters to DATA-only events.
166
229
  */
167
230
  detail?: ObserveDetail;
231
+ /**
232
+ * When set, auto-enables structured mode and attaches a logger.
233
+ * `"pretty"` renders colored one-line output; `"json"` emits one JSON object per event.
234
+ */
235
+ format?: "pretty" | "json";
236
+ /** Sink for rendered lines (`console.log` by default). Only used when `format` is set. */
237
+ logger?: (line: string, event: ObserveEvent) => void;
238
+ /** Keep only these event types in formatted output. Only used when `format` is set. */
239
+ includeTypes?: ObserveEvent["type"][];
240
+ /** Exclude these event types from formatted output. Only used when `format` is set. */
241
+ excludeTypes?: ObserveEvent["type"][];
242
+ /** Built-in color preset (`ansi` default) or explicit color tokens. Only used when `format` is set. */
243
+ theme?: ObserveThemeName | ObserveTheme;
168
244
  };
169
245
  /** Accumulated observation result (structured mode). */
170
246
  type ObserveResult<T = unknown> = {
@@ -176,10 +252,12 @@ type ObserveResult<T = unknown> = {
176
252
  readonly resolvedCount: number;
177
253
  /** All events in order. */
178
254
  readonly events: ObserveEvent[];
179
- /** True if COMPLETE received without prior ERROR. */
180
- readonly completedCleanly: boolean;
181
- /** True if ERROR received. */
182
- readonly errored: boolean;
255
+ /** True if any observed node sent COMPLETE without prior ERROR on that node. */
256
+ readonly anyCompletedCleanly: boolean;
257
+ /** True if any observed node sent ERROR. */
258
+ readonly anyErrored: boolean;
259
+ /** True if at least one COMPLETE received and no ERROR from any observed node. */
260
+ readonly completedWithoutErrors: boolean;
183
261
  /** Stop observing. */
184
262
  dispose(): void;
185
263
  /**
@@ -195,6 +273,8 @@ type ObserveEvent = {
195
273
  data?: unknown;
196
274
  timestamp_ns?: number;
197
275
  in_batch?: boolean;
276
+ /** Monotonically increasing counter per subscribe-callback invocation. All events in one delivery share the same id. */
277
+ batch_id?: number;
198
278
  trigger_dep_index?: number;
199
279
  trigger_dep_name?: string;
200
280
  /**
@@ -208,30 +288,10 @@ type ObserveEvent = {
208
288
  };
209
289
  dep_values?: unknown[];
210
290
  };
211
- /** Built-in color presets for {@link Graph.spy}. */
212
- type GraphSpyThemeName = "none" | "ansi";
213
- /** ANSI/style overrides for {@link Graph.spy} event rendering. */
214
- type GraphSpyTheme = Partial<Record<ObserveEvent["type"] | "path" | "reset", string>>;
215
- /** Options for {@link Graph.spy}. */
216
- type GraphSpyOptions = ObserveOptions & {
217
- /** Observe one path; omit for graph-wide mode. */
218
- path?: string;
219
- /** Keep only these event types in spy output. */
220
- includeTypes?: ObserveEvent["type"][];
221
- /** Exclude these event types from spy output. */
222
- excludeTypes?: ObserveEvent["type"][];
223
- /** Built-in color preset (`ansi` default) or explicit color tokens. */
224
- theme?: GraphSpyThemeName | GraphSpyTheme;
225
- /** One-line `pretty` output (default) or JSON-per-event. */
226
- format?: "pretty" | "json";
227
- /** Optional sink for rendered lines (`console.log` by default). */
228
- logger?: (line: string, event: ObserveEvent) => void;
229
- };
230
- /** Handle returned by {@link Graph.spy}. */
231
- type GraphSpyHandle = {
232
- readonly result: ObserveResult;
233
- dispose(): void;
234
- };
291
+ /** Built-in color preset names for observe `format` rendering. */
292
+ type ObserveThemeName = "none" | "ansi";
293
+ /** ANSI/style overrides for observe `format` event rendering. */
294
+ type ObserveTheme = Partial<Record<ObserveEvent["type"] | "path" | "reset", string>>;
235
295
  /** Options for {@link Graph.dumpGraph}. */
236
296
  type GraphDumpOptions = {
237
297
  actor?: Actor;
@@ -432,6 +492,14 @@ declare class Graph {
432
492
  describe(options?: GraphDescribeOptions): GraphDescribeOutput;
433
493
  private _collectSubgraphs;
434
494
  private _collectAllEdges;
495
+ /**
496
+ * Snapshot-based resource profile: per-node stats, orphan effect detection,
497
+ * memory hotspots. Zero runtime overhead — walks nodes on demand.
498
+ *
499
+ * @param opts - Optional `topN` for hotspot limit (default 10).
500
+ * @returns Aggregate profile with per-node details, hotspots, and orphan effects.
501
+ */
502
+ resourceProfile(opts?: GraphProfileOptions): GraphProfileResult;
435
503
  private _qualifyEdgeEndpoint;
436
504
  private _collectObserveTargets;
437
505
  private _appendMetaObserveTargets;
@@ -453,6 +521,9 @@ declare class Graph {
453
521
  causal?: true;
454
522
  derived?: true;
455
523
  }): ObserveResult;
524
+ observe(path: string, options: ObserveOptions & {
525
+ format: "pretty" | "json";
526
+ }): ObserveResult;
456
527
  observe(path: string, options?: ObserveOptions): GraphObserveOne;
457
528
  observe(options: ObserveOptions & {
458
529
  structured?: true;
@@ -460,19 +531,26 @@ declare class Graph {
460
531
  causal?: true;
461
532
  derived?: true;
462
533
  }): ObserveResult;
534
+ observe(options: ObserveOptions & {
535
+ format: "pretty" | "json";
536
+ }): ObserveResult;
463
537
  observe(options?: ObserveOptions): GraphObserveAll;
464
538
  private _createObserveResult;
465
539
  private _createObserveResultForAll;
466
540
  /**
467
- * Convenience live debugger over {@link Graph.observe}. Logs protocol events as they flow.
468
- *
469
- * Supports one-node (`path`) and graph-wide modes, event filtering, and JSON/pretty rendering.
470
- * Color themes are built in (`ansi` / `none`) to avoid external dependencies.
471
- *
472
- * @param options - Spy configuration.
473
- * @returns Disposable handle plus a structured observation accumulator.
541
+ * Fallback ObserveResult for single-node when inspector is disabled but `format` is requested.
542
+ * Subscribes to raw messages and accumulates events with timeline info.
543
+ */
544
+ private _createFallbackObserveResult;
545
+ /**
546
+ * Fallback ObserveResult for graph-wide when inspector is disabled but `format` is requested.
474
547
  */
475
- spy(options?: GraphSpyOptions): GraphSpyHandle;
548
+ private _createFallbackObserveResultForAll;
549
+ /**
550
+ * Attaches a format logger to an ObserveResult, rendering events as they arrive.
551
+ * Wraps the result's dispose to flush pending events.
552
+ */
553
+ private _attachFormatLogger;
476
554
  /**
477
555
  * CLI/debug-friendly graph dump built on {@link Graph.describe}.
478
556
  *
@@ -552,8 +630,9 @@ declare class Graph {
552
630
  /**
553
631
  * Debounced persistence wired to graph-wide observe stream (spec §3.8 auto-checkpoint).
554
632
  *
555
- * Checkpoint trigger uses {@link messageTier}: only batches containing tier >= 2 messages
556
- * schedule a save (`DATA`/`RESOLVED`/terminal/destruction), never pure tier-0/1 control waves.
633
+ * Checkpoint trigger uses {@link messageTier}: only batches containing tier >= 3 messages
634
+ * schedule a save (`DATA`/`RESOLVED`/terminal/destruction), never pure tier-0/1/2 control
635
+ * waves (`START`/`DIRTY`/`INVALIDATE`/`PAUSE`/`RESUME`).
557
636
  */
558
637
  autoCheckpoint(adapter: AutoCheckpointAdapter, options?: GraphAutoCheckpointOptions): GraphAutoCheckpointHandle;
559
638
  /**
@@ -576,7 +655,7 @@ declare class Graph {
576
655
  toD2(options?: GraphDiagramOptions): string;
577
656
  /**
578
657
  * When `false`, structured observation options (`causal`, `timeline`),
579
- * `annotate()`, and `traceLog()` are no-ops. Raw `observe()` always works.
658
+ * and `trace()` writes are no-ops. Raw `observe()` always works.
580
659
  *
581
660
  * Default: `true` outside production (`process.env.NODE_ENV !== "production"`).
582
661
  */
@@ -584,20 +663,17 @@ declare class Graph {
584
663
  private _annotations;
585
664
  private _traceRing;
586
665
  /**
587
- * Attaches a reasoning annotation to a node captures *why* an AI agent set a value.
666
+ * Unified reasoning trace: write annotations or read the ring buffer.
588
667
  *
668
+ * Write: `graph.trace("path", "reason")` — attaches a reasoning annotation
669
+ * to a node, capturing *why* an AI agent set a value.
589
670
  * No-op when {@link Graph.inspectorEnabled} is `false`.
590
671
  *
591
- * @param path - Qualified node path.
592
- * @param reason - Free-text note stored in the trace ring buffer.
593
- */
594
- annotate(path: string, reason: string): void;
595
- /**
596
- * Returns a chronological log of all reasoning annotations (ring buffer).
597
- *
598
- * @returns `[]` when {@link Graph.inspectorEnabled} is `false`.
672
+ * Read: `graph.trace()` returns a chronological log of all annotations.
673
+ * Returns `[]` when {@link Graph.inspectorEnabled} is `false`.
599
674
  */
600
- traceLog(): readonly TraceEntry[];
675
+ trace(path: string, reason: string): void;
676
+ trace(): readonly TraceEntry[];
601
677
  /**
602
678
  * Computes structural + value diff between two {@link Graph.describe} snapshots.
603
679
  *
@@ -671,4 +747,4 @@ type ReachableOptions = {
671
747
  */
672
748
  declare function reachable(described: GraphDescribeOutput, from: string, direction: ReachableDirection, options?: ReachableOptions): string[];
673
749
 
674
- export { type AutoCheckpointAdapter as A, reachable as B, type DescribeFilter as D, Graph as G, type ObserveDetail as O, type ReachableDirection as R, type TraceEntry as T, type GraphOptions as a, type GraphAutoCheckpointHandle as b, type GraphAutoCheckpointOptions as c, GRAPH_META_SEGMENT as d, type GraphActorOptions as e, type GraphCheckpointRecord as f, type GraphDescribeOptions as g, type GraphDescribeOutput as h, type GraphDiagramDirection as i, type GraphDiagramOptions as j, type GraphDiffChange as k, type GraphDiffResult as l, type GraphDumpOptions as m, type GraphFactoryContext as n, type GraphNodeFactory as o, type GraphObserveAll as p, type GraphObserveOne as q, type GraphPersistSnapshot as r, type GraphSpyHandle as s, type GraphSpyOptions as t, type GraphSpyTheme as u, type GraphSpyThemeName as v, type ObserveEvent as w, type ObserveOptions as x, type ObserveResult as y, type ReachableOptions as z };
750
+ export { type AutoCheckpointAdapter as A, graphProfile as B, reachable as C, type DescribeFilter as D, Graph as G, type NodeProfile as N, type ObserveDetail as O, type ReachableDirection as R, type TraceEntry as T, type GraphOptions as a, type GraphAutoCheckpointHandle as b, type GraphAutoCheckpointOptions as c, type GraphProfileResult as d, type GraphProfileOptions as e, GRAPH_META_SEGMENT as f, type GraphActorOptions as g, type GraphCheckpointRecord as h, type GraphDescribeOptions as i, type GraphDescribeOutput as j, type GraphDiagramDirection as k, type GraphDiagramOptions as l, type GraphDiffChange as m, type GraphDiffResult as n, type GraphDumpOptions as o, type GraphFactoryContext as p, type GraphNodeFactory as q, type GraphObserveAll as r, type GraphObserveOne as s, type GraphPersistSnapshot as t, type ObserveEvent as u, type ObserveOptions as v, type ObserveResult as w, type ObserveTheme as x, type ObserveThemeName as y, type ReachableOptions as z };
@@ -1,4 +1,67 @@
1
- import { j as DescribeNodeOutput, h as DescribeDetail, i as DescribeField, N as Node, y as VersioningLevel, A as Actor, m as Messages, p as NodeSink } from './meta-BV4pj9ML.js';
1
+ import { i as DescribeNodeOutput, g as DescribeDetail, h as DescribeField, N as Node, y as VersioningLevel, A as Actor, l as Messages, o as NodeSink } from './meta-BnG7XAaE.js';
2
+
3
+ /**
4
+ * Graph profiling and inspection utilities.
5
+ *
6
+ * Provides per-node memory estimation, connectivity stats, and hotspot
7
+ * detection. Non-invasive — reads from `describe()` and node internals
8
+ * without modifying state.
9
+ *
10
+ * @module
11
+ */
12
+
13
+ /** Per-node profile entry. */
14
+ interface NodeProfile {
15
+ /** Qualified path within the graph. */
16
+ path: string;
17
+ /** Node type (state, derived, producer, effect). */
18
+ type: string;
19
+ /** Node status (disconnected, dirty, settled, errored, completed). */
20
+ status: string;
21
+ /** Approximate retained bytes for the node's cached value. */
22
+ valueSizeBytes: number;
23
+ /** Number of downstream subscribers (sinks). */
24
+ subscriberCount: number;
25
+ /** Number of upstream dependencies. */
26
+ depCount: number;
27
+ /** True if this is an effect node with no external subscribers (potential leak). */
28
+ isOrphanEffect: boolean;
29
+ }
30
+ /** Aggregate graph profile. */
31
+ interface GraphProfileResult {
32
+ /** Total node count. */
33
+ nodeCount: number;
34
+ /** Total edge count. */
35
+ edgeCount: number;
36
+ /** Subgraph count. */
37
+ subgraphCount: number;
38
+ /** All node profiles. */
39
+ nodes: NodeProfile[];
40
+ /** Total approximate value memory across all nodes. */
41
+ totalValueSizeBytes: number;
42
+ /** Nodes sorted by valueSizeBytes descending (top N). */
43
+ hotspots: NodeProfile[];
44
+ /** Effect nodes with no external subscribers (potential leaks). */
45
+ orphanEffects: NodeProfile[];
46
+ }
47
+ /** Options for {@link graphProfile}. */
48
+ interface GraphProfileOptions {
49
+ /** Limit hotspot list (default 10). */
50
+ topN?: number;
51
+ /** Include subgraph nodes recursively (default true). */
52
+ recursive?: boolean;
53
+ }
54
+ /**
55
+ * Profile a graph's memory and connectivity characteristics.
56
+ *
57
+ * Uses `describe({ detail: "standard" })` for node metadata and direct
58
+ * `NodeImpl` access for subscriber counts and cached values.
59
+ *
60
+ * @param graph - The graph to profile.
61
+ * @param opts - Optional configuration.
62
+ * @returns Aggregate profile with per-node details and hotspots.
63
+ */
64
+ declare function graphProfile(graph: Graph, opts?: GraphProfileOptions): GraphProfileResult;
2
65
 
3
66
  /**
4
67
  * Reserved segment for meta companion paths: `nodeName::__meta__::metaKey` (GRAPHREFLY-SPEC §3.6).
@@ -165,6 +228,19 @@ type ObserveOptions = {
165
228
  * `"minimal"` filters to DATA-only events.
166
229
  */
167
230
  detail?: ObserveDetail;
231
+ /**
232
+ * When set, auto-enables structured mode and attaches a logger.
233
+ * `"pretty"` renders colored one-line output; `"json"` emits one JSON object per event.
234
+ */
235
+ format?: "pretty" | "json";
236
+ /** Sink for rendered lines (`console.log` by default). Only used when `format` is set. */
237
+ logger?: (line: string, event: ObserveEvent) => void;
238
+ /** Keep only these event types in formatted output. Only used when `format` is set. */
239
+ includeTypes?: ObserveEvent["type"][];
240
+ /** Exclude these event types from formatted output. Only used when `format` is set. */
241
+ excludeTypes?: ObserveEvent["type"][];
242
+ /** Built-in color preset (`ansi` default) or explicit color tokens. Only used when `format` is set. */
243
+ theme?: ObserveThemeName | ObserveTheme;
168
244
  };
169
245
  /** Accumulated observation result (structured mode). */
170
246
  type ObserveResult<T = unknown> = {
@@ -176,10 +252,12 @@ type ObserveResult<T = unknown> = {
176
252
  readonly resolvedCount: number;
177
253
  /** All events in order. */
178
254
  readonly events: ObserveEvent[];
179
- /** True if COMPLETE received without prior ERROR. */
180
- readonly completedCleanly: boolean;
181
- /** True if ERROR received. */
182
- readonly errored: boolean;
255
+ /** True if any observed node sent COMPLETE without prior ERROR on that node. */
256
+ readonly anyCompletedCleanly: boolean;
257
+ /** True if any observed node sent ERROR. */
258
+ readonly anyErrored: boolean;
259
+ /** True if at least one COMPLETE received and no ERROR from any observed node. */
260
+ readonly completedWithoutErrors: boolean;
183
261
  /** Stop observing. */
184
262
  dispose(): void;
185
263
  /**
@@ -195,6 +273,8 @@ type ObserveEvent = {
195
273
  data?: unknown;
196
274
  timestamp_ns?: number;
197
275
  in_batch?: boolean;
276
+ /** Monotonically increasing counter per subscribe-callback invocation. All events in one delivery share the same id. */
277
+ batch_id?: number;
198
278
  trigger_dep_index?: number;
199
279
  trigger_dep_name?: string;
200
280
  /**
@@ -208,30 +288,10 @@ type ObserveEvent = {
208
288
  };
209
289
  dep_values?: unknown[];
210
290
  };
211
- /** Built-in color presets for {@link Graph.spy}. */
212
- type GraphSpyThemeName = "none" | "ansi";
213
- /** ANSI/style overrides for {@link Graph.spy} event rendering. */
214
- type GraphSpyTheme = Partial<Record<ObserveEvent["type"] | "path" | "reset", string>>;
215
- /** Options for {@link Graph.spy}. */
216
- type GraphSpyOptions = ObserveOptions & {
217
- /** Observe one path; omit for graph-wide mode. */
218
- path?: string;
219
- /** Keep only these event types in spy output. */
220
- includeTypes?: ObserveEvent["type"][];
221
- /** Exclude these event types from spy output. */
222
- excludeTypes?: ObserveEvent["type"][];
223
- /** Built-in color preset (`ansi` default) or explicit color tokens. */
224
- theme?: GraphSpyThemeName | GraphSpyTheme;
225
- /** One-line `pretty` output (default) or JSON-per-event. */
226
- format?: "pretty" | "json";
227
- /** Optional sink for rendered lines (`console.log` by default). */
228
- logger?: (line: string, event: ObserveEvent) => void;
229
- };
230
- /** Handle returned by {@link Graph.spy}. */
231
- type GraphSpyHandle = {
232
- readonly result: ObserveResult;
233
- dispose(): void;
234
- };
291
+ /** Built-in color preset names for observe `format` rendering. */
292
+ type ObserveThemeName = "none" | "ansi";
293
+ /** ANSI/style overrides for observe `format` event rendering. */
294
+ type ObserveTheme = Partial<Record<ObserveEvent["type"] | "path" | "reset", string>>;
235
295
  /** Options for {@link Graph.dumpGraph}. */
236
296
  type GraphDumpOptions = {
237
297
  actor?: Actor;
@@ -432,6 +492,14 @@ declare class Graph {
432
492
  describe(options?: GraphDescribeOptions): GraphDescribeOutput;
433
493
  private _collectSubgraphs;
434
494
  private _collectAllEdges;
495
+ /**
496
+ * Snapshot-based resource profile: per-node stats, orphan effect detection,
497
+ * memory hotspots. Zero runtime overhead — walks nodes on demand.
498
+ *
499
+ * @param opts - Optional `topN` for hotspot limit (default 10).
500
+ * @returns Aggregate profile with per-node details, hotspots, and orphan effects.
501
+ */
502
+ resourceProfile(opts?: GraphProfileOptions): GraphProfileResult;
435
503
  private _qualifyEdgeEndpoint;
436
504
  private _collectObserveTargets;
437
505
  private _appendMetaObserveTargets;
@@ -453,6 +521,9 @@ declare class Graph {
453
521
  causal?: true;
454
522
  derived?: true;
455
523
  }): ObserveResult;
524
+ observe(path: string, options: ObserveOptions & {
525
+ format: "pretty" | "json";
526
+ }): ObserveResult;
456
527
  observe(path: string, options?: ObserveOptions): GraphObserveOne;
457
528
  observe(options: ObserveOptions & {
458
529
  structured?: true;
@@ -460,19 +531,26 @@ declare class Graph {
460
531
  causal?: true;
461
532
  derived?: true;
462
533
  }): ObserveResult;
534
+ observe(options: ObserveOptions & {
535
+ format: "pretty" | "json";
536
+ }): ObserveResult;
463
537
  observe(options?: ObserveOptions): GraphObserveAll;
464
538
  private _createObserveResult;
465
539
  private _createObserveResultForAll;
466
540
  /**
467
- * Convenience live debugger over {@link Graph.observe}. Logs protocol events as they flow.
468
- *
469
- * Supports one-node (`path`) and graph-wide modes, event filtering, and JSON/pretty rendering.
470
- * Color themes are built in (`ansi` / `none`) to avoid external dependencies.
471
- *
472
- * @param options - Spy configuration.
473
- * @returns Disposable handle plus a structured observation accumulator.
541
+ * Fallback ObserveResult for single-node when inspector is disabled but `format` is requested.
542
+ * Subscribes to raw messages and accumulates events with timeline info.
543
+ */
544
+ private _createFallbackObserveResult;
545
+ /**
546
+ * Fallback ObserveResult for graph-wide when inspector is disabled but `format` is requested.
474
547
  */
475
- spy(options?: GraphSpyOptions): GraphSpyHandle;
548
+ private _createFallbackObserveResultForAll;
549
+ /**
550
+ * Attaches a format logger to an ObserveResult, rendering events as they arrive.
551
+ * Wraps the result's dispose to flush pending events.
552
+ */
553
+ private _attachFormatLogger;
476
554
  /**
477
555
  * CLI/debug-friendly graph dump built on {@link Graph.describe}.
478
556
  *
@@ -552,8 +630,9 @@ declare class Graph {
552
630
  /**
553
631
  * Debounced persistence wired to graph-wide observe stream (spec §3.8 auto-checkpoint).
554
632
  *
555
- * Checkpoint trigger uses {@link messageTier}: only batches containing tier >= 2 messages
556
- * schedule a save (`DATA`/`RESOLVED`/terminal/destruction), never pure tier-0/1 control waves.
633
+ * Checkpoint trigger uses {@link messageTier}: only batches containing tier >= 3 messages
634
+ * schedule a save (`DATA`/`RESOLVED`/terminal/destruction), never pure tier-0/1/2 control
635
+ * waves (`START`/`DIRTY`/`INVALIDATE`/`PAUSE`/`RESUME`).
557
636
  */
558
637
  autoCheckpoint(adapter: AutoCheckpointAdapter, options?: GraphAutoCheckpointOptions): GraphAutoCheckpointHandle;
559
638
  /**
@@ -576,7 +655,7 @@ declare class Graph {
576
655
  toD2(options?: GraphDiagramOptions): string;
577
656
  /**
578
657
  * When `false`, structured observation options (`causal`, `timeline`),
579
- * `annotate()`, and `traceLog()` are no-ops. Raw `observe()` always works.
658
+ * and `trace()` writes are no-ops. Raw `observe()` always works.
580
659
  *
581
660
  * Default: `true` outside production (`process.env.NODE_ENV !== "production"`).
582
661
  */
@@ -584,20 +663,17 @@ declare class Graph {
584
663
  private _annotations;
585
664
  private _traceRing;
586
665
  /**
587
- * Attaches a reasoning annotation to a node captures *why* an AI agent set a value.
666
+ * Unified reasoning trace: write annotations or read the ring buffer.
588
667
  *
668
+ * Write: `graph.trace("path", "reason")` — attaches a reasoning annotation
669
+ * to a node, capturing *why* an AI agent set a value.
589
670
  * No-op when {@link Graph.inspectorEnabled} is `false`.
590
671
  *
591
- * @param path - Qualified node path.
592
- * @param reason - Free-text note stored in the trace ring buffer.
593
- */
594
- annotate(path: string, reason: string): void;
595
- /**
596
- * Returns a chronological log of all reasoning annotations (ring buffer).
597
- *
598
- * @returns `[]` when {@link Graph.inspectorEnabled} is `false`.
672
+ * Read: `graph.trace()` returns a chronological log of all annotations.
673
+ * Returns `[]` when {@link Graph.inspectorEnabled} is `false`.
599
674
  */
600
- traceLog(): readonly TraceEntry[];
675
+ trace(path: string, reason: string): void;
676
+ trace(): readonly TraceEntry[];
601
677
  /**
602
678
  * Computes structural + value diff between two {@link Graph.describe} snapshots.
603
679
  *
@@ -671,4 +747,4 @@ type ReachableOptions = {
671
747
  */
672
748
  declare function reachable(described: GraphDescribeOutput, from: string, direction: ReachableDirection, options?: ReachableOptions): string[];
673
749
 
674
- export { type AutoCheckpointAdapter as A, reachable as B, type DescribeFilter as D, Graph as G, type ObserveDetail as O, type ReachableDirection as R, type TraceEntry as T, type GraphOptions as a, type GraphAutoCheckpointHandle as b, type GraphAutoCheckpointOptions as c, GRAPH_META_SEGMENT as d, type GraphActorOptions as e, type GraphCheckpointRecord as f, type GraphDescribeOptions as g, type GraphDescribeOutput as h, type GraphDiagramDirection as i, type GraphDiagramOptions as j, type GraphDiffChange as k, type GraphDiffResult as l, type GraphDumpOptions as m, type GraphFactoryContext as n, type GraphNodeFactory as o, type GraphObserveAll as p, type GraphObserveOne as q, type GraphPersistSnapshot as r, type GraphSpyHandle as s, type GraphSpyOptions as t, type GraphSpyTheme as u, type GraphSpyThemeName as v, type ObserveEvent as w, type ObserveOptions as x, type ObserveResult as y, type ReachableOptions as z };
750
+ export { type AutoCheckpointAdapter as A, graphProfile as B, reachable as C, type DescribeFilter as D, Graph as G, type NodeProfile as N, type ObserveDetail as O, type ReachableDirection as R, type TraceEntry as T, type GraphOptions as a, type GraphAutoCheckpointHandle as b, type GraphAutoCheckpointOptions as c, type GraphProfileResult as d, type GraphProfileOptions as e, GRAPH_META_SEGMENT as f, type GraphActorOptions as g, type GraphCheckpointRecord as h, type GraphDescribeOptions as i, type GraphDescribeOutput as j, type GraphDiagramDirection as k, type GraphDiagramOptions as l, type GraphDiffChange as m, type GraphDiffResult as n, type GraphDumpOptions as o, type GraphFactoryContext as p, type GraphNodeFactory as q, type GraphObserveAll as r, type GraphObserveOne as s, type GraphPersistSnapshot as t, type ObserveEvent as u, type ObserveOptions as v, type ObserveResult as w, type ObserveTheme as x, type ObserveThemeName as y, type ReachableOptions as z };
@@ -1,5 +1,5 @@
1
- import { N as Node } from './meta-BV4pj9ML.js';
2
- import { G as Graph } from './graph-Dc-P9BVm.js';
1
+ import { N as Node } from './meta-BnG7XAaE.js';
2
+ import { G as Graph } from './graph-mILUUqW8.js';
3
3
 
4
4
  /** Pluggable measurement backend. */
5
5
  interface MeasurementAdapter {