@graphty/graphty-element 2.5.1 → 2.6.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 (135) hide show
  1. package/dist/ai.js +3 -3
  2. package/dist/catalog.d.ts +16 -0
  3. package/dist/catalog.js +34 -32
  4. package/dist/chunks/{AiManager-CrbvKdEK.js → AiManager-4iQpsJW1.js} +4 -4
  5. package/dist/chunks/{DataSource-qU-nLhXN.js → DataSource-BL2UzPff.js} +2 -2
  6. package/dist/chunks/GraphSession-BhuHSXIo.js +12819 -0
  7. package/dist/chunks/{GraphtyLogger-DOTwCiMR.js → GraphtyLogger-B_O67a6c.js} +1 -1
  8. package/dist/chunks/{VoiceInputAdapter-D4NrRL_1.js → VoiceInputAdapter-Cc6mHXTI.js} +1 -1
  9. package/dist/chunks/{XRPivotCameraController-Uqa47vmo.js → XRPivotCameraController-BLa89LXn.js} +2 -2
  10. package/dist/chunks/{algorithms-D-ab-Auu.js → algorithms-BJ6DQMOe.js} +931 -781
  11. package/dist/chunks/{capability-check-Vw3IcqiE.js → capability-check-Am2zliFj.js} +1 -1
  12. package/dist/chunks/{detect-B4Qrw976.js → detect-fyuVnlCT.js} +1 -1
  13. package/dist/chunks/{format-detection-r2IfNFXO.js → format-detection-BHwrAVzW.js} +1 -1
  14. package/dist/chunks/{index-J9MgLio9.js → index-BkBLbvui.js} +2691 -2434
  15. package/dist/chunks/optionsFromZod-CKMYSwTz.js +3636 -0
  16. package/dist/chunks/{paletteRegistry-Kt-6CeoN.js → paletteRegistry-BCFSwJGK.js} +224 -189
  17. package/dist/chunks/parse-BMTqt4SS.js +3658 -0
  18. package/dist/chunks/{types-C_c53VgR.js → types-DFchv4Ny.js} +4 -1
  19. package/dist/custom-elements.json +1 -1
  20. package/dist/extend.d.ts +10 -8
  21. package/dist/extend.js +6 -6
  22. package/dist/graphty-catalog.json +75 -38
  23. package/dist/graphty.bundle.js +55368 -48970
  24. package/dist/graphty.js +19 -19
  25. package/dist/index.d.ts +1 -1
  26. package/dist/logging.js +2 -2
  27. package/dist/schema.d.ts +15 -1
  28. package/dist/schema.js +1 -1
  29. package/dist/session.d.ts +30 -7
  30. package/dist/session.js +40 -37
  31. package/dist/src/Graph.d.ts +35 -7
  32. package/dist/src/acceleration/types.d.ts +79 -43
  33. package/dist/src/algorithms/Algorithm.d.ts +52 -4
  34. package/dist/src/algorithms/BFSAlgorithm.d.ts +3 -0
  35. package/dist/src/algorithms/BellmanFordAlgorithm.d.ts +3 -0
  36. package/dist/src/algorithms/BetweennessCentralityAlgorithm.d.ts +3 -0
  37. package/dist/src/algorithms/BipartiteMatchingAlgorithm.d.ts +3 -0
  38. package/dist/src/algorithms/ClosenessCentralityAlgorithm.d.ts +3 -0
  39. package/dist/src/algorithms/ConnectedComponentsAlgorithm.d.ts +4 -1
  40. package/dist/src/algorithms/DFSAlgorithm.d.ts +3 -0
  41. package/dist/src/algorithms/DegreeAlgorithm.d.ts +3 -0
  42. package/dist/src/algorithms/DijkstraAlgorithm.d.ts +6 -0
  43. package/dist/src/algorithms/EigenvectorCentralityAlgorithm.d.ts +2 -0
  44. package/dist/src/algorithms/FloydWarshallAlgorithm.d.ts +3 -0
  45. package/dist/src/algorithms/GirvanNewmanAlgorithm.d.ts +3 -0
  46. package/dist/src/algorithms/HITSAlgorithm.d.ts +3 -0
  47. package/dist/src/algorithms/KCoreAlgorithm.d.ts +3 -0
  48. package/dist/src/algorithms/KatzCentralityAlgorithm.d.ts +3 -0
  49. package/dist/src/algorithms/KruskalAlgorithm.d.ts +4 -1
  50. package/dist/src/algorithms/LabelPropagationAlgorithm.d.ts +3 -0
  51. package/dist/src/algorithms/LeidenAlgorithm.d.ts +3 -0
  52. package/dist/src/algorithms/LinkPredictionAlgorithm.d.ts +4 -1
  53. package/dist/src/algorithms/LouvainAlgorithm.d.ts +3 -0
  54. package/dist/src/algorithms/MaxFlowAlgorithm.d.ts +3 -0
  55. package/dist/src/algorithms/MinCutAlgorithm.d.ts +3 -0
  56. package/dist/src/algorithms/PageRankAlgorithm.d.ts +3 -0
  57. package/dist/src/algorithms/PrimAlgorithm.d.ts +3 -0
  58. package/dist/src/algorithms/StronglyConnectedComponentsAlgorithm.d.ts +3 -0
  59. package/dist/src/algorithms/input/ScopedInput.d.ts +185 -0
  60. package/dist/src/algorithms/input/derivedInputs.d.ts +199 -0
  61. package/dist/src/algorithms/input/maskBack.d.ts +37 -0
  62. package/dist/src/algorithms/metrics/MetricAlgorithm.d.ts +3 -3
  63. package/dist/src/algorithms/results/DeclaredAlgorithm.d.ts +4 -3
  64. package/dist/src/algorithms/results/types.d.ts +28 -6
  65. package/dist/src/algorithms/utils/communityUtils.d.ts +0 -48
  66. package/dist/src/algorithms/utils/graphUtils.d.ts +2 -68
  67. package/dist/src/algorithms/utils/snapshotGraph.d.ts +3 -1
  68. package/dist/src/catalog/algorithms.d.ts +3 -0
  69. package/dist/src/catalog/layouts.d.ts +2 -0
  70. package/dist/src/catalog/sets/canonical.d.ts +68 -0
  71. package/dist/src/catalog/sets/hash.d.ts +126 -0
  72. package/dist/src/catalog/sets/parse.d.ts +115 -0
  73. package/dist/src/catalog/types.d.ts +329 -8
  74. package/dist/src/data/GraphStore.d.ts +73 -1
  75. package/dist/src/data/edgeIdentity.d.ts +202 -1
  76. package/dist/src/data/ingest.d.ts +3 -1
  77. package/dist/src/data/report.d.ts +20 -0
  78. package/dist/src/graphty-element.d.ts +42 -6
  79. package/dist/src/layout/D3GraphLayoutEngine.d.ts +11 -0
  80. package/dist/src/layout/LayoutEngine.d.ts +56 -0
  81. package/dist/src/layout/NGraphLayoutEngine.d.ts +10 -0
  82. package/dist/src/layout/SimulationLayoutEngine.d.ts +11 -0
  83. package/dist/src/managers/AlgorithmManager.d.ts +8 -0
  84. package/dist/src/managers/DataManager.d.ts +11 -0
  85. package/dist/src/managers/LayoutManager.d.ts +126 -2
  86. package/dist/src/managers/StatsManager.d.ts +1 -0
  87. package/dist/src/session/GraphSession.d.ts +48 -0
  88. package/dist/src/session/attributes.d.ts +121 -1
  89. package/dist/src/session/cost/estimate.d.ts +20 -0
  90. package/dist/src/session/cost/index.d.ts +1 -1
  91. package/dist/src/session/planning.d.ts +32 -2
  92. package/dist/src/session/query.d.ts +7 -0
  93. package/dist/src/session/results/ResultsApi.d.ts +14 -1
  94. package/dist/src/session/runs/Run.d.ts +65 -4
  95. package/dist/src/session/runs/RunsApi.d.ts +58 -2
  96. package/dist/src/session/runs/runId.d.ts +55 -6
  97. package/dist/src/session/runs/types.d.ts +36 -8
  98. package/dist/src/session/scope/ElementMask.d.ts +14 -1
  99. package/dist/src/session/scope/ScopeApi.d.ts +160 -31
  100. package/dist/src/session/scope/index.d.ts +1 -1
  101. package/dist/src/session/selection/SelectionApi.d.ts +15 -10
  102. package/dist/src/session/selection/index.d.ts +1 -1
  103. package/dist/src/session/selection/targets.d.ts +6 -7
  104. package/dist/src/session/sets/SetsApi.d.ts +110 -0
  105. package/dist/src/session/sets/algebra.d.ts +124 -0
  106. package/dist/src/session/sets/cache.d.ts +197 -0
  107. package/dist/src/session/sets/captures.d.ts +83 -0
  108. package/dist/src/session/sets/dependencies.d.ts +167 -0
  109. package/dist/src/session/sets/layers.d.ts +101 -0
  110. package/dist/src/session/sets/notify.d.ts +122 -0
  111. package/dist/src/session/sets/offers.d.ts +103 -0
  112. package/dist/src/session/sets/path.d.ts +37 -0
  113. package/dist/src/session/sets/prepare.d.ts +209 -0
  114. package/dist/src/session/sets/resolve.d.ts +311 -0
  115. package/dist/src/session/sets/signature.d.ts +77 -0
  116. package/dist/src/session/sets/status.d.ts +98 -0
  117. package/dist/src/session/sets/store.d.ts +196 -0
  118. package/dist/src/session/sets/types.d.ts +386 -0
  119. package/dist/src/session/styles/Layer.d.ts +9 -2
  120. package/dist/src/session/styles/StylesApi.d.ts +5 -2
  121. package/dist/src/session/styles/explain.d.ts +5 -2
  122. package/dist/src/session/styles/predicate.d.ts +41 -2
  123. package/dist/src/session/styles/repaint.d.ts +19 -0
  124. package/dist/src/session/styles/selector.d.ts +16 -5
  125. package/dist/src/session/types.d.ts +18 -0
  126. package/dist/src/session/visibility/VisibilityApi.d.ts +47 -3
  127. package/dist/src/session/visibility/filter.d.ts +86 -51
  128. package/dist/src/session/visibility/index.d.ts +1 -1
  129. package/dist/src/testing/fakeAccelerator.d.ts +5 -0
  130. package/dist/src/utils/queue-migration.d.ts +17 -0
  131. package/package.json +15 -9
  132. package/dist/chunks/GraphSession-DuAhRgCd.js +0 -8622
  133. package/dist/chunks/optionsFromZod-B9RncoTX.js +0 -2578
  134. package/dist/chunks/scales-CJCRwi2J.js +0 -3220
  135. package/dist/src/algorithms/utils/index.d.ts +0 -6
@@ -44,8 +44,13 @@ export type EdgeId = string;
44
44
  export type RunId = string;
45
45
  /** The identity of a style layer. Element-minted and stable; never an array index. */
46
46
  export type LayerId = string;
47
- /** The identity of a saved scope. */
48
- export type ScopeId = string;
47
+ /**
48
+ * The identity of a kept set. Element-minted; every minted id starts with `set_` and everything
49
+ * after that prefix is opaque. An id is never reissued within a project, and a rename keeps it.
50
+ */
51
+ export type SetId = string;
52
+ /** The identity of a saved scope: a kept set, so the same type as {@link SetId}. */
53
+ export type ScopeId = SetId;
49
54
  /** A JMESPath expression over the published result root. */
50
55
  export type Path = string;
51
56
  /** A JMESPath predicate. The same dialect everywhere an expression is accepted. */
@@ -290,7 +295,11 @@ export type Binding = {
290
295
  };
291
296
  /** Declarative attribute-to-channel bindings. */
292
297
  export type Encoding = Partial<Record<Channel, Binding>>;
293
- /** What a layer matches. Spelled out rather than implied, so it is greppable and lintable. */
298
+ /**
299
+ * What a layer matches. Spelled out rather than implied, so it is greppable and lintable.
300
+ *
301
+ * OPEN UNION: kinds may be added in a minor release; handle unknown kinds.
302
+ */
294
303
  export type Selector = {
295
304
  match: "expression";
296
305
  where: Query;
@@ -313,6 +322,16 @@ export type Selector = {
313
322
  n: number;
314
323
  } | {
315
324
  match: "everything";
325
+ }
326
+ /**
327
+ * The members of a scope, usually a kept set: `{ match: "member", of: { set: id } }`. The
328
+ * layer follows the set: a redefinition repaints exactly the elements that moved. A removed
329
+ * set paints from its kept record, so removing a set never blanks a layer; a scope that
330
+ * cannot be evaluated paints nothing and never throws.
331
+ */
332
+ | {
333
+ match: "member";
334
+ of: Scope;
316
335
  };
317
336
  /** Who put a layer in the stack. Every layer names its source. */
318
337
  export type LayerSource = {
@@ -386,6 +405,19 @@ export interface AlgorithmDescriptor {
386
405
  accelerator?: boolean;
387
406
  connected?: boolean;
388
407
  };
408
+ /**
409
+ * What a run over a scope computes on. `"subgraph"`: the scope's own nodes and edges, so a
410
+ * small scope is estimated and run as small. `"none"`: the whole graph, keeping only the
411
+ * scope's values, so the run is estimated -- and refused -- as a whole-graph run.
412
+ *
413
+ * DERIVED, NOT AUTHORED: `Algorithm.register` fills it from the class's `static scopeInput`,
414
+ * which is the one declaration the run, its caveat and this field all read. A plugin leaves
415
+ * it out of the descriptor it writes; one that disagrees with the class is refused.
416
+ *
417
+ * OPEN UNION: values may be added in a minor release (`"mask"` is reserved); treat an
418
+ * unknown value as `"none"`.
419
+ */
420
+ scopeInput?: "none" | "subgraph";
389
421
  }
390
422
  /** One layout the element can place a graph with. */
391
423
  export interface LayoutDescriptor {
@@ -410,15 +442,24 @@ export interface LayoutDescriptor {
410
442
  * nothing.
411
443
  */
412
444
  honoursWeights: boolean;
445
+ /**
446
+ * Whether the default engine accepts a scope: `setLayout(type, opts, { scope })` moves only
447
+ * the scope's nodes and holds every other node still.
448
+ *
449
+ * A picker reads it to know where a "Lay out this set" control does something. Of the
450
+ * element's own engines, the five live simulations answer true; a one-shot arrangement
451
+ * refuses a scope with `E_UNSUPPORTED`.
452
+ */
453
+ scoped: boolean;
413
454
  }
414
455
  /**
415
456
  * A layout descriptor as a third party's engine class authors it.
416
457
  *
417
- * `honoursWeights` is missing from it because the engine class already declares that fact as a
418
- * static, and a fact written in two places is a fact that can disagree with itself.
419
- * `LayoutEngine.register` reads the static and publishes the complete descriptor.
458
+ * `honoursWeights` and `scoped` are missing from it because the engine class already declares
459
+ * those facts as statics, and a fact written in two places is a fact that can disagree with
460
+ * itself. `LayoutEngine.register` reads the statics and publishes the complete descriptor.
420
461
  */
421
- export type AuthoredLayoutDescriptor = Omit<LayoutDescriptor, "honoursWeights">;
462
+ export type AuthoredLayoutDescriptor = Omit<LayoutDescriptor, "honoursWeights" | "scoped">;
422
463
  /** One file format the element can read, write, or both. */
423
464
  export interface FormatDescriptor {
424
465
  id: FormatId;
@@ -556,14 +597,294 @@ export interface QueryValidation {
556
597
  candidates: readonly string[];
557
598
  }[];
558
599
  }
559
- /** What a run, a layout or an export is allowed to look at. */
600
+ /**
601
+ * What an operation runs over: a set reference.
602
+ *
603
+ * `{ define }` carries a set definition inline, with edge members in stable form; a write
604
+ * position that also accepts session edge ids takes {@link ScopeInput}. The keyword `"search"` is
605
+ * reserved for a later release and refused.
606
+ *
607
+ * OPEN UNION: forms may be added in a minor release; handle unknown forms.
608
+ */
560
609
  export type Scope = "visible" | "graph" | "selection" | "largest-component" | {
561
610
  set: ScopeId;
562
611
  } | {
563
612
  where: Query;
564
613
  } | {
565
614
  nodes: readonly NodeId[];
615
+ } | {
616
+ define: SetDefinition;
617
+ };
618
+ /**
619
+ * A {@link Scope} as a write position accepts it: an inline definition may name edges by session
620
+ * {@link EdgeId}. Every getter returns the canonical {@link Scope}, with stable members.
621
+ */
622
+ export type ScopeInput = Exclude<Scope, {
623
+ define: unknown;
624
+ }> | {
625
+ define: SetDefinitionInput;
626
+ };
627
+ /**
628
+ * Which way an edge is followed: arriving (`in`), leaving (`out`) or both (`all`). What a degree
629
+ * leaf counts and which way a neighbourhood selection walks.
630
+ */
631
+ export type SelectionDirection = "in" | "out" | "all";
632
+ /**
633
+ * A rule tree: what the visibility filter keeps, and what a rule set holds.
634
+ *
635
+ * Every leaf speaks about nodes, edges or both, and is SILENT about the rest: `all` and `any` fold
636
+ * the halves that are not silent, and `not` negates only those. `edges` speaks edges; `member`
637
+ * speaks the referenced set's nodes, and its edges only when that set is read `listed` or
638
+ * `clipped` (`"visible"` is); `item` and `threshold` speak the half or halves their field lives
639
+ * on; every other leaf speaks nodes. A group with no members constrains nothing.
640
+ *
641
+ * OPEN UNION: leaf kinds may be added in a minor release; handle unknown kinds.
642
+ */
643
+ export type RuleTree = {
644
+ readonly kind: "expression";
645
+ readonly where: Query;
646
+ } | {
647
+ readonly kind: "range";
648
+ readonly attribute: Path;
649
+ readonly min?: number;
650
+ readonly max?: number;
651
+ } | {
652
+ readonly kind: "categories";
653
+ readonly attribute: Path;
654
+ readonly values: readonly string[];
655
+ } | {
656
+ readonly kind: "degree";
657
+ readonly min?: number;
658
+ readonly max?: number;
659
+ readonly direction?: SelectionDirection;
660
+ } | {
661
+ readonly kind: "component";
662
+ readonly id: number;
663
+ } | {
664
+ readonly kind: "neighborhood";
665
+ readonly seeds: readonly NodeId[];
666
+ readonly depth: number;
667
+ } | {
668
+ readonly kind: "edges";
669
+ readonly where: Query;
670
+ }
671
+ /**
672
+ * The members of a scope, usually a kept set: `{ kind: "member", of: { set: id } }`. A removed
673
+ * set is read from its kept record, so removing a set never changes what a rule holds.
674
+ */
675
+ | {
676
+ readonly kind: "member";
677
+ readonly of: Scope;
678
+ }
679
+ /**
680
+ * The elements one item of a result holds: community 3, the path's nodes and edges. Speaks
681
+ * the half or halves the result publishes the key's field on (`onPath` speaks both).
682
+ */
683
+ | {
684
+ readonly kind: "item";
685
+ readonly item: ResultItem;
686
+ }
687
+ /**
688
+ * The elements whose value for a path passes one cut. The population is the elements that
689
+ * carry a finite number for the path; each half that has one speaks, ranked on its own.
690
+ * Reserved, refused until built: `percentile`, `z` and `population`.
691
+ */
692
+ | {
693
+ readonly kind: "threshold";
694
+ /** A value path: `results.<run>.<field>` or `data.<field>`. */
695
+ readonly path: Path;
696
+ /** The top `n`, whole tie groups only (the `TopRanking` tie policy). Exactly one cut. */
697
+ readonly top?: number;
698
+ /** Strictly above this value. Exactly one cut. */
699
+ readonly above?: number;
700
+ } | {
701
+ readonly kind: "all";
702
+ readonly of: readonly RuleTree[];
703
+ } | {
704
+ readonly kind: "any";
705
+ readonly of: readonly RuleTree[];
706
+ } | {
707
+ readonly kind: "not";
708
+ readonly of: RuleTree;
566
709
  };
710
+ /**
711
+ * Which edges come with a set's nodes. Stored, never inferred from whether edges are present.
712
+ *
713
+ * - `induced`: the node half plus every edge between its nodes (NetworkX `G.subgraph(nodes)`).
714
+ * - `listed`: the edge half plus its endpoints, plus the node half (NetworkX
715
+ * `G.edge_subgraph(edges)` plus any listed nodes). Paths, edge sets and edge rules.
716
+ * - `clipped`: the node half, plus the edge half clipped to edges whose endpoints are both in the
717
+ * node half. Rules only: exactly what the visibility filter shows. A fixed set given `clipped`
718
+ * is stored `listed`, which holds the same members.
719
+ *
720
+ * OPEN UNION: kinds may be added in a minor release; handle unknown kinds.
721
+ */
722
+ export type EdgeReading = "induced" | "listed" | "clipped";
723
+ /**
724
+ * An edge member, by its stable identity: the endpoints plus exactly one discriminator, `id`,
725
+ * `key` or the pair `ordinal` and `among`. The validator refuses any other combination.
726
+ *
727
+ * OPEN: may gain optional members in a minor release.
728
+ */
729
+ export interface EdgeMember {
730
+ /** The node the edge leaves, as loaded. */
731
+ readonly source: NodeId;
732
+ /** The node the edge enters, as loaded. */
733
+ readonly target: NodeId;
734
+ /**
735
+ * The file's edge id, read at the element's configured `edgeIdPath`, or for an edge added in
736
+ * the session without one, the id the element minted for it (`graphty:e<n>`).
737
+ */
738
+ readonly id?: string | number;
739
+ /** The file's parallel-edge key. Reserved: refused until the element reads one. */
740
+ readonly key?: string | number;
741
+ /**
742
+ * Last resort, for a file edge without an id: the edge's position, counting from 0, among
743
+ * every edge of its pair in the load that ingested it, in ingest order. Present with `among`
744
+ * or not at all.
745
+ */
746
+ readonly ordinal?: number;
747
+ /** That pair's edge count in that load. Present with `ordinal` or not at all. */
748
+ readonly among?: number;
749
+ }
750
+ /**
751
+ * An edge as a write position accepts it: a session {@link EdgeId}, or its stable
752
+ * {@link EdgeMember}. The element stores the stable form; every getter returns it.
753
+ */
754
+ export type EdgeRef = EdgeId | EdgeMember;
755
+ /**
756
+ * What a set holds.
757
+ *
758
+ * - `fixed`: a member list. Ids, never row indices; ids the graph no longer holds read missing
759
+ * and are never pruned. A fixed set read `induced` stores no edges unless some were listed.
760
+ * - `rule`: a query or a rule tree, re-evaluated as the data changes.
761
+ * - `path`: a walk, in order, node-first. Repeats allowed; one node is a zero-length path. It
762
+ * resolves to its distinct nodes and the edges its steps name, read `listed`.
763
+ *
764
+ * OPEN UNION: kinds may be added in a minor release; handle unknown kinds.
765
+ */
766
+ export type SetDefinition = {
767
+ readonly kind: "fixed";
768
+ /** Canonical order, no duplicates. */
769
+ readonly nodes: readonly NodeId[];
770
+ /** Canonical order, no duplicates. Only edges listed explicitly; an induced set derives its edges. */
771
+ readonly edges?: readonly EdgeMember[];
772
+ readonly reading: "induced" | "listed";
773
+ } | {
774
+ readonly kind: "rule";
775
+ /** A JMESPath predicate over nodes, or a rule tree ({@link RuleTree}). */
776
+ readonly where: Query | RuleTree;
777
+ readonly reading: EdgeReading;
778
+ } | {
779
+ readonly kind: "path";
780
+ /** The walk, in order. */
781
+ readonly nodes: readonly NodeId[];
782
+ /**
783
+ * Optional; when present, exactly `nodes.length - 1` entries. Entry i names the edge, or
784
+ * the group of parallel or reciprocal edges, joining `nodes[i]` and `nodes[i + 1]`.
785
+ * `null`: every edge between that pair.
786
+ */
787
+ readonly edges?: readonly (EdgeMember | readonly EdgeMember[] | null)[];
788
+ /** Steps must follow declared edge direction. Default false. */
789
+ readonly directed?: boolean;
790
+ };
791
+ /**
792
+ * A {@link SetDefinition} as a write position accepts it: edges may be named by session
793
+ * {@link EdgeId} wherever an {@link EdgeMember} appears, and a fixed set may say `clipped` (stored
794
+ * as `listed`). Every getter returns the canonical {@link SetDefinition}.
795
+ */
796
+ export type SetDefinitionInput = {
797
+ readonly kind: "fixed";
798
+ readonly nodes: readonly NodeId[];
799
+ readonly edges?: readonly EdgeRef[];
800
+ readonly reading: EdgeReading;
801
+ } | Extract<SetDefinition, {
802
+ kind: "rule";
803
+ }> | {
804
+ readonly kind: "path";
805
+ readonly nodes: readonly NodeId[];
806
+ readonly edges?: readonly (EdgeRef | readonly EdgeRef[] | null)[];
807
+ readonly directed?: boolean;
808
+ };
809
+ /**
810
+ * How an item is found in a result. A field matches when it equals the value or, for an
811
+ * array-valued field, contains it.
812
+ *
813
+ * OPEN UNION: forms may be added in a minor release; handle unknown forms.
814
+ */
815
+ export type ItemKey = {
816
+ /** The result field, such as `group` for a community or `onPath` for a path. */
817
+ readonly field: string;
818
+ /** The value an element's field equals, or its array contains, to be in the item. */
819
+ readonly value: string | number | boolean;
820
+ };
821
+ /**
822
+ * The id of a result: what a style layer, a rule or an item address binds to. The same string as
823
+ * the {@link RunId} a run answers to, because a result is named by its first run and keeps the
824
+ * name while later runs replace its values.
825
+ */
826
+ export type ResultId = RunId;
827
+ /**
828
+ * One item of a result: community 3 of a Louvain result, the path of a Dijkstra result.
829
+ *
830
+ * OPEN: may gain optional members in a minor release.
831
+ */
832
+ export interface ResultItem {
833
+ /** The result that holds the item. */
834
+ readonly result: ResultId;
835
+ /**
836
+ * Present: holds that one run of the result, as it was. Absent: follows the result's current
837
+ * run. Opaque; compare for equality only.
838
+ */
839
+ readonly run?: string;
840
+ /** How the item's elements are found in that result. */
841
+ readonly key: ItemKey;
842
+ }
843
+ /**
844
+ * How two or more sets combine into one.
845
+ *
846
+ * OPEN UNION: operations may be added in a minor release; handle unknown operations.
847
+ */
848
+ export type SetCombine = "union" | "intersection" | "difference" | "symmetric-difference";
849
+ /**
850
+ * A reference as {@link SetCreatedFrom} records it: a scope, or an inline member list replaced by
851
+ * its sizes, so a large operand is never stored twice.
852
+ */
853
+ export type SetOperand = Scope | {
854
+ readonly inline: {
855
+ readonly nodes: number;
856
+ readonly edges: number;
857
+ };
858
+ };
859
+ /**
860
+ * How a set came to exist. Written once, when the set is created.
861
+ *
862
+ * OPEN UNION: kinds may be added in a minor release; handle unknown kinds.
863
+ */
864
+ export type SetCreatedFrom = {
865
+ readonly kind: "user";
866
+ } | {
867
+ readonly kind: "selection";
868
+ } | {
869
+ readonly kind: "scope";
870
+ readonly from: SetOperand;
871
+ }
872
+ /** `item.run` is always present: the set holds the run it was created from. */
873
+ | {
874
+ readonly kind: "result";
875
+ readonly item: ResultItem;
876
+ } | {
877
+ readonly kind: "combine";
878
+ readonly op: SetCombine;
879
+ readonly of: readonly SetOperand[];
880
+ };
881
+ /**
882
+ * What kind of walk a path set is, most specific first: `cycle` (a closed trail), `simple` (no
883
+ * node repeats), `trail` (no edge repeats), `walk` (anything else).
884
+ *
885
+ * OPEN UNION: kinds may be added in a minor release; handle unknown kinds.
886
+ */
887
+ export type PathKind = "simple" | "trail" | "walk" | "cycle";
567
888
  /**
568
889
  * The catalogue: everything the element can offer, as data.
569
890
  *
@@ -1,5 +1,7 @@
1
1
  import { type ColumnHandle, type DerivedGraph, type FreezeReport, GraphBuilder, type GraphSnapshot, type U32 } from "@graphty/graph-format";
2
+ import { type InputCounters } from "../session/attributes";
2
3
  import type { DirectionProvenance } from "../session/types";
4
+ import { type EdgeCounter } from "./edgeIdentity";
3
5
  import { ElementPositions } from "./positions";
4
6
  /** The payload of `snapshot-replaced` (graph-format design 14.4 rule 11). */
5
7
  export interface SnapshotReplacement {
@@ -28,6 +30,19 @@ export interface GraphStoreOptions {
28
30
  readonly onNodeRemap: (remap: U32) => void;
29
31
  /** Called before onReplaced when the freeze renumbered edges, so edgesByIndex can be re-keyed. */
30
32
  readonly onEdgeRemap: (remap: U32) => void;
33
+ /**
34
+ * The edge counter `nextEdgeId()` draws from. Its owner (`DataManager`, a headless
35
+ * `GraphSession`) hands the same object to every store it builds, so a Clear or a replacing
36
+ * import never rewinds it and no edge id is issued twice in a session. A store built without
37
+ * one counts from 0 on its own.
38
+ */
39
+ readonly edgeCounter?: EdgeCounter;
40
+ /**
41
+ * The input counters every freeze advances the tick of (design/sets 6.2). Handed in by the
42
+ * same owner, for the same reason, as the edge counter; a store built without them keys its
43
+ * own under itself, which is what a headless session reads.
44
+ */
45
+ readonly inputs?: InputCounters;
31
46
  }
32
47
  /**
33
48
  * The element's ONE graph-format builder and the snapshot it freezes to (graph-format design 14.4).
@@ -60,11 +75,30 @@ export declare class GraphStore {
60
75
  /** Handle of the element-assigned edge counter column. */
61
76
  readonly edgeIdColumn: ColumnHandle;
62
77
  private readonly options;
78
+ private readonly counter;
79
+ private readonly nodeHashColumn;
80
+ private readonly edgeHashColumn;
81
+ private readonly edgeOrdinalColumn;
82
+ private readonly edgeAmongColumn;
83
+ /** Node rows below this have their hash; rows from here to `nodeBound` are new. */
84
+ private nodeMark;
85
+ /** Edges ingested outside a load and not yet completed: row, counter, file id. */
86
+ private sessionEdges;
87
+ /** Rows of the open load, in ingest order, remapped by every compacting freeze. */
88
+ private loadRows;
89
+ private loadLength;
90
+ /** File ids of the open load's edges, aligned with `loadRows`; sparse. */
91
+ private loadFileIds;
92
+ /** Open `openLoad()` calls; loads that overlap are completed as one. */
93
+ private loadDepth;
94
+ /** Whether edge pairs are ordered, latched when the first edge is completed. */
95
+ private pairsOrdered;
96
+ /** The counters whose tick every freeze advances. */
97
+ private readonly inputs;
63
98
  private readonly undirectedCache;
64
99
  private cache;
65
100
  private cachedRevision;
66
101
  private revision;
67
- private edgeIdCounter;
68
102
  private pending;
69
103
  private pendingPositions;
70
104
  private publishing;
@@ -109,6 +143,25 @@ export declare class GraphStore {
109
143
  * @throws Error when the store has been disposed
110
144
  */
111
145
  nextEdgeId(): number;
146
+ /**
147
+ * Record an ingested edge for the completion pass. `ingestEdge` calls this for every edge it
148
+ * stamps; an edge added to the builder directly (a test fixture) gets no identity values.
149
+ * @param row - the edge row
150
+ * @param counter - the counter stamped into its `graphty.edgeId` cell
151
+ * @param fileId - the file id read at the configured `edgeIdPath`, if any
152
+ */
153
+ recordIngestedEdge(row: number, counter: number, fileId?: string | number): void;
154
+ /**
155
+ * Open a load: every edge ingested until the matching `closeLoad()` belongs to it, and its
156
+ * ordinals are counted over it as a whole however many chunks and freezes it spans
157
+ * (design 12.3: a load is one import). Edges ingested with no load open are session edges.
158
+ */
159
+ openLoad(): void;
160
+ /**
161
+ * Close a load. When the last open load closes, it is completed there and then. A disposed
162
+ * store ignores this, so a load's cleanup may run after a Clear replaced its store.
163
+ */
164
+ closeLoad(): void;
112
165
  /**
113
166
  * The current snapshot, freezing first when the graph has changed since the last one.
114
167
  *
@@ -203,6 +256,25 @@ export declare class GraphStore {
203
256
  * torn down -- and then re-clear a `pending` that `dispose()` had already cleared.
204
257
  */
205
258
  private publish;
259
+ /**
260
+ * The completion pass (design 12.2, 12.3): hash new nodes, complete session edges, and, when
261
+ * no load is open, complete the load's edges -- ordinal and among per pair over the load's
262
+ * surviving edges, and the edge hash, in one sorted pass.
263
+ */
264
+ private completeIdentity;
265
+ /**
266
+ * Whether pairs are ordered, latched the first time an edge is completed: ordered only when the
267
+ * graph was declared directed by then. Recorded as a graph attribute so every snapshot says
268
+ * which rule its edge hashes follow.
269
+ * @returns the latched value
270
+ */
271
+ private latchPairsOrdered;
272
+ /**
273
+ * Move the pass's marks and the open load's rows into the index space of a freeze just
274
+ * committed. Allocation-free.
275
+ * @param edgeRemap - the freeze's edge remap, or null when nothing was renumbered
276
+ */
277
+ private followIdentityRemap;
206
278
  /**
207
279
  * Refuse a call on a store that has been disposed.
208
280
  * @param what - the method name, for the message