@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.
- package/dist/ai.js +3 -3
- package/dist/catalog.d.ts +16 -0
- package/dist/catalog.js +34 -32
- package/dist/chunks/{AiManager-CrbvKdEK.js → AiManager-4iQpsJW1.js} +4 -4
- package/dist/chunks/{DataSource-qU-nLhXN.js → DataSource-BL2UzPff.js} +2 -2
- package/dist/chunks/GraphSession-BhuHSXIo.js +12819 -0
- package/dist/chunks/{GraphtyLogger-DOTwCiMR.js → GraphtyLogger-B_O67a6c.js} +1 -1
- package/dist/chunks/{VoiceInputAdapter-D4NrRL_1.js → VoiceInputAdapter-Cc6mHXTI.js} +1 -1
- package/dist/chunks/{XRPivotCameraController-Uqa47vmo.js → XRPivotCameraController-BLa89LXn.js} +2 -2
- package/dist/chunks/{algorithms-D-ab-Auu.js → algorithms-BJ6DQMOe.js} +931 -781
- package/dist/chunks/{capability-check-Vw3IcqiE.js → capability-check-Am2zliFj.js} +1 -1
- package/dist/chunks/{detect-B4Qrw976.js → detect-fyuVnlCT.js} +1 -1
- package/dist/chunks/{format-detection-r2IfNFXO.js → format-detection-BHwrAVzW.js} +1 -1
- package/dist/chunks/{index-J9MgLio9.js → index-BkBLbvui.js} +2691 -2434
- package/dist/chunks/optionsFromZod-CKMYSwTz.js +3636 -0
- package/dist/chunks/{paletteRegistry-Kt-6CeoN.js → paletteRegistry-BCFSwJGK.js} +224 -189
- package/dist/chunks/parse-BMTqt4SS.js +3658 -0
- package/dist/chunks/{types-C_c53VgR.js → types-DFchv4Ny.js} +4 -1
- package/dist/custom-elements.json +1 -1
- package/dist/extend.d.ts +10 -8
- package/dist/extend.js +6 -6
- package/dist/graphty-catalog.json +75 -38
- package/dist/graphty.bundle.js +55368 -48970
- package/dist/graphty.js +19 -19
- package/dist/index.d.ts +1 -1
- package/dist/logging.js +2 -2
- package/dist/schema.d.ts +15 -1
- package/dist/schema.js +1 -1
- package/dist/session.d.ts +30 -7
- package/dist/session.js +40 -37
- package/dist/src/Graph.d.ts +35 -7
- package/dist/src/acceleration/types.d.ts +79 -43
- package/dist/src/algorithms/Algorithm.d.ts +52 -4
- package/dist/src/algorithms/BFSAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/BellmanFordAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/BetweennessCentralityAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/BipartiteMatchingAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/ClosenessCentralityAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/ConnectedComponentsAlgorithm.d.ts +4 -1
- package/dist/src/algorithms/DFSAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/DegreeAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/DijkstraAlgorithm.d.ts +6 -0
- package/dist/src/algorithms/EigenvectorCentralityAlgorithm.d.ts +2 -0
- package/dist/src/algorithms/FloydWarshallAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/GirvanNewmanAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/HITSAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/KCoreAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/KatzCentralityAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/KruskalAlgorithm.d.ts +4 -1
- package/dist/src/algorithms/LabelPropagationAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/LeidenAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/LinkPredictionAlgorithm.d.ts +4 -1
- package/dist/src/algorithms/LouvainAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/MaxFlowAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/MinCutAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/PageRankAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/PrimAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/StronglyConnectedComponentsAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/input/ScopedInput.d.ts +185 -0
- package/dist/src/algorithms/input/derivedInputs.d.ts +199 -0
- package/dist/src/algorithms/input/maskBack.d.ts +37 -0
- package/dist/src/algorithms/metrics/MetricAlgorithm.d.ts +3 -3
- package/dist/src/algorithms/results/DeclaredAlgorithm.d.ts +4 -3
- package/dist/src/algorithms/results/types.d.ts +28 -6
- package/dist/src/algorithms/utils/communityUtils.d.ts +0 -48
- package/dist/src/algorithms/utils/graphUtils.d.ts +2 -68
- package/dist/src/algorithms/utils/snapshotGraph.d.ts +3 -1
- package/dist/src/catalog/algorithms.d.ts +3 -0
- package/dist/src/catalog/layouts.d.ts +2 -0
- package/dist/src/catalog/sets/canonical.d.ts +68 -0
- package/dist/src/catalog/sets/hash.d.ts +126 -0
- package/dist/src/catalog/sets/parse.d.ts +115 -0
- package/dist/src/catalog/types.d.ts +329 -8
- package/dist/src/data/GraphStore.d.ts +73 -1
- package/dist/src/data/edgeIdentity.d.ts +202 -1
- package/dist/src/data/ingest.d.ts +3 -1
- package/dist/src/data/report.d.ts +20 -0
- package/dist/src/graphty-element.d.ts +42 -6
- package/dist/src/layout/D3GraphLayoutEngine.d.ts +11 -0
- package/dist/src/layout/LayoutEngine.d.ts +56 -0
- package/dist/src/layout/NGraphLayoutEngine.d.ts +10 -0
- package/dist/src/layout/SimulationLayoutEngine.d.ts +11 -0
- package/dist/src/managers/AlgorithmManager.d.ts +8 -0
- package/dist/src/managers/DataManager.d.ts +11 -0
- package/dist/src/managers/LayoutManager.d.ts +126 -2
- package/dist/src/managers/StatsManager.d.ts +1 -0
- package/dist/src/session/GraphSession.d.ts +48 -0
- package/dist/src/session/attributes.d.ts +121 -1
- package/dist/src/session/cost/estimate.d.ts +20 -0
- package/dist/src/session/cost/index.d.ts +1 -1
- package/dist/src/session/planning.d.ts +32 -2
- package/dist/src/session/query.d.ts +7 -0
- package/dist/src/session/results/ResultsApi.d.ts +14 -1
- package/dist/src/session/runs/Run.d.ts +65 -4
- package/dist/src/session/runs/RunsApi.d.ts +58 -2
- package/dist/src/session/runs/runId.d.ts +55 -6
- package/dist/src/session/runs/types.d.ts +36 -8
- package/dist/src/session/scope/ElementMask.d.ts +14 -1
- package/dist/src/session/scope/ScopeApi.d.ts +160 -31
- package/dist/src/session/scope/index.d.ts +1 -1
- package/dist/src/session/selection/SelectionApi.d.ts +15 -10
- package/dist/src/session/selection/index.d.ts +1 -1
- package/dist/src/session/selection/targets.d.ts +6 -7
- package/dist/src/session/sets/SetsApi.d.ts +110 -0
- package/dist/src/session/sets/algebra.d.ts +124 -0
- package/dist/src/session/sets/cache.d.ts +197 -0
- package/dist/src/session/sets/captures.d.ts +83 -0
- package/dist/src/session/sets/dependencies.d.ts +167 -0
- package/dist/src/session/sets/layers.d.ts +101 -0
- package/dist/src/session/sets/notify.d.ts +122 -0
- package/dist/src/session/sets/offers.d.ts +103 -0
- package/dist/src/session/sets/path.d.ts +37 -0
- package/dist/src/session/sets/prepare.d.ts +209 -0
- package/dist/src/session/sets/resolve.d.ts +311 -0
- package/dist/src/session/sets/signature.d.ts +77 -0
- package/dist/src/session/sets/status.d.ts +98 -0
- package/dist/src/session/sets/store.d.ts +196 -0
- package/dist/src/session/sets/types.d.ts +386 -0
- package/dist/src/session/styles/Layer.d.ts +9 -2
- package/dist/src/session/styles/StylesApi.d.ts +5 -2
- package/dist/src/session/styles/explain.d.ts +5 -2
- package/dist/src/session/styles/predicate.d.ts +41 -2
- package/dist/src/session/styles/repaint.d.ts +19 -0
- package/dist/src/session/styles/selector.d.ts +16 -5
- package/dist/src/session/types.d.ts +18 -0
- package/dist/src/session/visibility/VisibilityApi.d.ts +47 -3
- package/dist/src/session/visibility/filter.d.ts +86 -51
- package/dist/src/session/visibility/index.d.ts +1 -1
- package/dist/src/testing/fakeAccelerator.d.ts +5 -0
- package/dist/src/utils/queue-migration.d.ts +17 -0
- package/package.json +15 -9
- package/dist/chunks/GraphSession-DuAhRgCd.js +0 -8622
- package/dist/chunks/optionsFromZod-B9RncoTX.js +0 -2578
- package/dist/chunks/scales-CJCRwi2J.js +0 -3220
- package/dist/src/algorithms/utils/index.d.ts +0 -6
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* Nothing here reaches Babylon.js, Lit or the DOM.
|
|
29
29
|
*/
|
|
30
30
|
import { type GraphSnapshot } from "@graphty/graph-format";
|
|
31
|
-
import type { EdgeId, NodeId, Path, Query,
|
|
31
|
+
import type { EdgeId, NodeId, Path, Query, ScopeInput, SelectionDirection } from "../../catalog/types";
|
|
32
32
|
import type { ResultsApi, RunRef } from "../results/types";
|
|
33
33
|
import { ElementMask, type MaskIdSpace } from "../scope/ElementMask";
|
|
34
34
|
import type { ScopeResolver } from "../scope/ScopeApi";
|
|
@@ -42,8 +42,7 @@ import type { ScopeResolver } from "../scope/ScopeApi";
|
|
|
42
42
|
* ignoring case. A key no node carries is searched as plain substring text.
|
|
43
43
|
*/
|
|
44
44
|
export type SelectionTextMode = "substring" | "exact" | "regex" | "attribute";
|
|
45
|
-
|
|
46
|
-
export type SelectionDirection = "in" | "out" | "all";
|
|
45
|
+
export type { SelectionDirection } from "../../catalog/types";
|
|
47
46
|
/** Elements named outright, by the ids a consumer already holds. */
|
|
48
47
|
export interface ElementIdTarget {
|
|
49
48
|
/** The nodes. Ids the graph no longer holds are ignored, the way a scope ignores them. */
|
|
@@ -81,7 +80,7 @@ export type SelectionTarget = ElementIdTarget | NeighborhoodTarget
|
|
|
81
80
|
/** Every element a predicate matches, narrowed to a scope when one is named. */
|
|
82
81
|
| {
|
|
83
82
|
readonly where: Query;
|
|
84
|
-
readonly scope?:
|
|
83
|
+
readonly scope?: ScopeInput;
|
|
85
84
|
}
|
|
86
85
|
/**
|
|
87
86
|
* Every node a text search finds, narrowed to a scope when one is named.
|
|
@@ -94,15 +93,15 @@ export type SelectionTarget = ElementIdTarget | NeighborhoodTarget
|
|
|
94
93
|
| {
|
|
95
94
|
readonly text: string;
|
|
96
95
|
readonly mode?: SelectionTextMode;
|
|
97
|
-
readonly scope?:
|
|
96
|
+
readonly scope?: ScopeInput;
|
|
98
97
|
}
|
|
99
98
|
/** A pasted list of ids, which may name nodes, edges, or nothing at all. */
|
|
100
99
|
| {
|
|
101
100
|
readonly ids: readonly string[];
|
|
102
101
|
}
|
|
103
|
-
/** Everything a scope covers. */
|
|
102
|
+
/** Everything a scope covers. An inline `{ define }` may name edges by session edge id. */
|
|
104
103
|
| {
|
|
105
|
-
readonly scope:
|
|
104
|
+
readonly scope: ScopeInput;
|
|
106
105
|
}
|
|
107
106
|
/**
|
|
108
107
|
* The highest-ranked elements of a finished run. A tie group is taken whole and only when it
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The synchronous doors of `session.sets`: the reads that only look at records and the
|
|
3
|
+
* writes that resolve nothing (design/sets/sets-design.md sections 13.2, 13.3, 15.2).
|
|
4
|
+
*
|
|
5
|
+
* Each write door does the one thing a pure `prepare` cannot: it reaches the graph to turn a
|
|
6
|
+
* session edge id into the edge's stable identity, and it mints the id and the order. Then, in one
|
|
7
|
+
* store write group, it prepares one operation and writes the result. A no-op writes nothing and
|
|
8
|
+
* emits nothing.
|
|
9
|
+
*
|
|
10
|
+
* Built by the session and published on it as `session.sets`.
|
|
11
|
+
*/
|
|
12
|
+
import { type GraphSnapshot } from "@graphty/graph-format";
|
|
13
|
+
import type { EdgeId, EdgeMember, RuleTree, RunId, Scope, SetCreatedFrom, SetDefinitionInput, SetId } from "../../catalog/types";
|
|
14
|
+
import type { SessionAttributes } from "../types";
|
|
15
|
+
import { type Materialiser } from "./algebra";
|
|
16
|
+
import { type DependencySources } from "./dependencies";
|
|
17
|
+
import type { Offering } from "./offers";
|
|
18
|
+
import { type StatusRun, type StatusSources } from "./status";
|
|
19
|
+
import { SetsStore } from "./store";
|
|
20
|
+
import type { SetsApi, SetUser } from "./types";
|
|
21
|
+
/** What the doors read from the rest of the session. */
|
|
22
|
+
interface SetsDependencies {
|
|
23
|
+
/**
|
|
24
|
+
* A session edge's stable identity.
|
|
25
|
+
* @param id - The session edge id.
|
|
26
|
+
* @returns The member, or undefined when the graph holds no such edge.
|
|
27
|
+
*/
|
|
28
|
+
edgeMember(id: EdgeId): EdgeMember | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the graph's edge pairs are ordered (it was declared directed at ingest). False: an
|
|
31
|
+
* edge member given in stable form is stored with its ends in canonical order, so both
|
|
32
|
+
* spellings of one undirected edge are one member. Absent: members are stored as given.
|
|
33
|
+
*/
|
|
34
|
+
readonly pairsOrdered?: () => boolean;
|
|
35
|
+
/** The most edge members one member edit may touch. */
|
|
36
|
+
readonly maxEdgeMembers?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Where the references a rule makes are looked up (kept sets, saved scopes, the visibility
|
|
39
|
+
* filter), so a write that would make a cycle is refused. Absent: the kept sets alone.
|
|
40
|
+
*/
|
|
41
|
+
readonly dependencies?: DependencySources;
|
|
42
|
+
/** The runs, for status and "Used by". Absent: no run exists. */
|
|
43
|
+
readonly runs?: {
|
|
44
|
+
get(id: RunId): StatusRun | undefined;
|
|
45
|
+
list(): readonly StatusRun[];
|
|
46
|
+
};
|
|
47
|
+
/** What the last pass over a kept set found. Absent: status reads no pass. */
|
|
48
|
+
readonly outcome?: StatusSources["outcome"];
|
|
49
|
+
/**
|
|
50
|
+
* The resolve step of `createFrom`, `combine` and `createPath`. Absent: those doors refuse
|
|
51
|
+
* with `E_UNSUPPORTED`.
|
|
52
|
+
*/
|
|
53
|
+
readonly materialise?: Materialiser;
|
|
54
|
+
/** Offers and Memberships. Absent: `offers` and `containing` refuse with `E_UNSUPPORTED`. */
|
|
55
|
+
readonly offering?: Pick<Offering, "offers" | "memberships">;
|
|
56
|
+
/**
|
|
57
|
+
* The token of a run's current execution, which an offer must still hold. Absent: the
|
|
58
|
+
* `runs` dependency's, else no execution is current and every offer is stale.
|
|
59
|
+
* @param run - The run.
|
|
60
|
+
* @returns The token, or undefined when the run has no result.
|
|
61
|
+
*/
|
|
62
|
+
readonly executionOf?: (run: RunId) => string | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* The live users of sets beyond kept sets and runs (style layers and the visibility filter),
|
|
65
|
+
* each with the scope or filter tree it names, for `usedBy`. Absent: none.
|
|
66
|
+
* @returns The users.
|
|
67
|
+
*/
|
|
68
|
+
readonly users?: () => Iterable<{
|
|
69
|
+
readonly user: SetUser;
|
|
70
|
+
readonly scope: Scope | RuleTree;
|
|
71
|
+
}>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A session edge's stable identity, read from the current snapshot: its file id at the configured
|
|
75
|
+
* `edgeIdPath` when there is one, else its ordinal among its pair's edges in its load, else the id
|
|
76
|
+
* minted from its counter.
|
|
77
|
+
* @param snapshot - The current snapshot.
|
|
78
|
+
* @param id - The session edge id.
|
|
79
|
+
* @param attributes - The edge's attribute bag by row, where the file id is read.
|
|
80
|
+
* @param edgeIdPath - The configured file-id path, or null.
|
|
81
|
+
* @returns The member, or undefined when the snapshot holds no such edge.
|
|
82
|
+
*/
|
|
83
|
+
export declare function sessionEdgeMember(snapshot: GraphSnapshot, id: EdgeId, attributes: (row: number) => SessionAttributes | undefined, edgeIdPath: string | null): EdgeMember | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Keep a definition, recording what it was created from: the door the element's own verbs (a
|
|
86
|
+
* promoted selection) dispatch through, since the published `create` always records `user`.
|
|
87
|
+
* Internal.
|
|
88
|
+
* @param api - Doors {@link createSetsApi} built.
|
|
89
|
+
* @param definition - The definition.
|
|
90
|
+
* @param name - The name; "Set N" when absent.
|
|
91
|
+
* @param createdFrom - What the set was created from.
|
|
92
|
+
* @returns The minted id.
|
|
93
|
+
* @throws An Error for doors it did not build; otherwise as `create` refuses.
|
|
94
|
+
*/
|
|
95
|
+
export declare function createSetAs(api: SetsApi, definition: SetDefinitionInput, name: string | undefined, createdFrom: SetCreatedFrom): SetId;
|
|
96
|
+
/**
|
|
97
|
+
* The store behind a set of doors, for the internal readers that resolve kept sets. Internal.
|
|
98
|
+
* @param api - Doors {@link createSetsApi} built.
|
|
99
|
+
* @returns The store.
|
|
100
|
+
* @throws An Error for doors it did not build.
|
|
101
|
+
*/
|
|
102
|
+
export declare function setsStoreOf(api: SetsApi): SetsStore;
|
|
103
|
+
/**
|
|
104
|
+
* Build the synchronous doors over a store.
|
|
105
|
+
* @param dependencies - Where session edge ids are looked up.
|
|
106
|
+
* @param store - The slice; a fresh one when absent.
|
|
107
|
+
* @returns The doors.
|
|
108
|
+
*/
|
|
109
|
+
export declare function createSetsApi(dependencies: SetsDependencies, store?: SetsStore): SetsApi;
|
|
110
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Set algebra and the resolve step of the materialising doors (design/sets/sets-design.md
|
|
3
|
+
* sections 4.1, 5.1, 7 and 13.3).
|
|
4
|
+
*
|
|
5
|
+
* `combineMasks` is the edge rule of section 7 over bitmaps: every operand induced gives an
|
|
6
|
+
* induced result, anything else is edge-first. The {@link Materialiser} is the asynchronous half
|
|
7
|
+
* of `createFrom`, `combine` and `createPath`: it resolves its source against the current graph
|
|
8
|
+
* and builds a concrete fixed or path definition with every edge member already in stable form,
|
|
9
|
+
* so the synchronous commit that follows only sorts, interns and freezes.
|
|
10
|
+
*
|
|
11
|
+
* Nothing here mints, names or writes: the doors do that in one tick after this resolves.
|
|
12
|
+
*
|
|
13
|
+
* Node-safe.
|
|
14
|
+
*/
|
|
15
|
+
import { type GraphSnapshot, type U32 } from "@graphty/graph-format";
|
|
16
|
+
import type { EdgeId, EdgeMember, EdgeReading, NodeId, Scope, SetCombine, SetCreatedFrom, SetDefinition } from "../../catalog/types";
|
|
17
|
+
import type { ElementMask } from "../scope/ElementMask";
|
|
18
|
+
import type { Offering } from "./offers";
|
|
19
|
+
import { type Resolution } from "./resolve";
|
|
20
|
+
import type { SetOffer } from "./types";
|
|
21
|
+
/** The four combinations, in the order the doors check them. */
|
|
22
|
+
export declare const SET_COMBINES: readonly SetCombine[];
|
|
23
|
+
/** One operand of a combination: its two bitmaps, and whether it reads `induced`. */
|
|
24
|
+
export interface AlgebraOperand {
|
|
25
|
+
readonly nodes: U32;
|
|
26
|
+
readonly edges: U32;
|
|
27
|
+
readonly induced: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Combine resolved operands by the edge rule of design 7. Every operand induced: the nodes are the
|
|
31
|
+
* op on the node bitmaps and the edges are induced from them. Otherwise edge-first: the edges are
|
|
32
|
+
* the op on the edge bitmaps and the nodes are the op on the node bitmaps plus those edges'
|
|
33
|
+
* endpoints, so every member edge keeps both endpoints.
|
|
34
|
+
* @param op - The combination.
|
|
35
|
+
* @param operands - Two or more operands over one snapshot.
|
|
36
|
+
* @param graph - The snapshot.
|
|
37
|
+
* @returns The combined bitmaps.
|
|
38
|
+
*/
|
|
39
|
+
export declare function combineMasks(op: SetCombine, operands: readonly AlgebraOperand[], graph: GraphSnapshot): AlgebraOperand;
|
|
40
|
+
/** A source resolved into what `set.create` records: nothing minted, every edge member stable. */
|
|
41
|
+
export interface Concrete {
|
|
42
|
+
/** A fixed or path definition in stable form. */
|
|
43
|
+
readonly definition: SetDefinition;
|
|
44
|
+
/** Each edge member with the session edge it came from, so the door can seed it (design 4.2). */
|
|
45
|
+
readonly refs: readonly (readonly [EdgeId, EdgeMember])[];
|
|
46
|
+
/**
|
|
47
|
+
* The seeds of a prebuilt definition, member key to counter, built in the asynchronous step so
|
|
48
|
+
* the commit adopts them instead of computing one key per member.
|
|
49
|
+
*/
|
|
50
|
+
readonly seeds?: ReadonlyMap<string, number>;
|
|
51
|
+
readonly createdFrom: SetCreatedFrom;
|
|
52
|
+
}
|
|
53
|
+
/** The resolve step of the materialising doors. Injectable, so a test can hold it open. */
|
|
54
|
+
export interface Materialiser {
|
|
55
|
+
/**
|
|
56
|
+
* A scope's or an offer's current members as a fixed definition (design 15.2 `createFrom`
|
|
57
|
+
* defaults; an offer keeps its reading and is created from `result`).
|
|
58
|
+
* @param source - A canonical scope, or an offer.
|
|
59
|
+
* @param reading - The caller's reading, or undefined for the default.
|
|
60
|
+
* @returns The concrete definition.
|
|
61
|
+
*/
|
|
62
|
+
from(source: Scope | SetOffer, reading: EdgeReading | undefined): Promise<Concrete>;
|
|
63
|
+
/**
|
|
64
|
+
* Two or more scopes combined into a fixed definition (design 7).
|
|
65
|
+
* @param op - The combination.
|
|
66
|
+
* @param of - Canonical scopes.
|
|
67
|
+
* @param reading - The caller's reading, or undefined for the default.
|
|
68
|
+
* @returns The concrete definition.
|
|
69
|
+
*/
|
|
70
|
+
combine(op: SetCombine, of: readonly Scope[], reading: EdgeReading | undefined): Promise<Concrete>;
|
|
71
|
+
/**
|
|
72
|
+
* The selected edges ordered into a walk, or a path offer in its result's order.
|
|
73
|
+
* @param source - `"selection"`, or a path offer.
|
|
74
|
+
* @returns The concrete path definition.
|
|
75
|
+
*/
|
|
76
|
+
path(source: "selection" | SetOffer): Promise<Concrete>;
|
|
77
|
+
}
|
|
78
|
+
/** What the resolve step reads from the session. */
|
|
79
|
+
interface MaterialiseSources {
|
|
80
|
+
/** The current snapshot. */
|
|
81
|
+
snapshot(): GraphSnapshot;
|
|
82
|
+
/**
|
|
83
|
+
* A scope's resolution against the current snapshot.
|
|
84
|
+
* @param scope - A canonical scope.
|
|
85
|
+
* @returns The resolution and the snapshot it was resolved against.
|
|
86
|
+
* @throws A `GraphtyError` when the scope cannot be resolved.
|
|
87
|
+
*/
|
|
88
|
+
resolve(scope: Scope): {
|
|
89
|
+
readonly resolution: Resolution;
|
|
90
|
+
readonly graph: GraphSnapshot;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* How a scope reads, following a `{ set }` to its definition.
|
|
94
|
+
* @param scope - A canonical scope.
|
|
95
|
+
* @returns The reading.
|
|
96
|
+
*/
|
|
97
|
+
readingOf(scope: Scope): EdgeReading;
|
|
98
|
+
/**
|
|
99
|
+
* A session edge's stable identity.
|
|
100
|
+
* @param id - The session edge id.
|
|
101
|
+
* @returns The member, or undefined when the graph holds no such edge.
|
|
102
|
+
*/
|
|
103
|
+
edgeMember(id: EdgeId): EdgeMember | undefined;
|
|
104
|
+
/** The selection's two masks, synced to the current snapshot. Absent refuses `"selection"`. */
|
|
105
|
+
readonly selection?: () => {
|
|
106
|
+
readonly nodes: ElementMask<NodeId>;
|
|
107
|
+
readonly edges: ElementMask<EdgeId>;
|
|
108
|
+
};
|
|
109
|
+
/** The offers' edge-count pass and path order. Absent: an offer resolves, and counts nothing. */
|
|
110
|
+
readonly offering?: Pick<Offering, "countEdges" | "orderOf">;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Whether a source is an offer rather than a scope.
|
|
114
|
+
* @param source - A scope or an offer.
|
|
115
|
+
* @returns True for an offer.
|
|
116
|
+
*/
|
|
117
|
+
export declare function isOffer(source: unknown): source is SetOffer;
|
|
118
|
+
/**
|
|
119
|
+
* Build the resolve step over a session.
|
|
120
|
+
* @param sources - What it reads.
|
|
121
|
+
* @returns The resolve step.
|
|
122
|
+
*/
|
|
123
|
+
export declare function createMaterialiser(sources: MaterialiseSources): Materialiser;
|
|
124
|
+
export {};
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The resolution cache, the summary cache and the cached resolver of kept sets
|
|
3
|
+
* (design/sets/sets-design.md section 6.2).
|
|
4
|
+
*
|
|
5
|
+
* RESOLUTIONS are pulled, never pushed: nothing is recomputed until something reads it. An entry
|
|
6
|
+
* is keyed by what was resolved -- a kept set's frozen definition, or an inline scope's canonical
|
|
7
|
+
* key -- and holds the one resolution of the latest input signature (`./signature`) it was asked
|
|
8
|
+
* under. A read under another signature misses and replaces it, so an entry of an older serial is
|
|
9
|
+
* never served. Keying a kept set by its definition rather than its record is what lets a rename
|
|
10
|
+
* hit, and an undo that restores the identical record hit again.
|
|
11
|
+
*
|
|
12
|
+
* The cache is bounded in BYTES, not entries: 64 MB by default, counted as the byte length of each
|
|
13
|
+
* entry's two bitmaps (no two entries share one). Entries whose key is pinned (a style layer or the
|
|
14
|
+
* visibility filter names it) are counted separately and never evicted, and may exceed the bound;
|
|
15
|
+
* unpinned entries may use whatever the pins leave, and never less than 16 MB, so runs and counts
|
|
16
|
+
* do not thrash. Eviction is least recently used first.
|
|
17
|
+
*
|
|
18
|
+
* SUMMARIES hold one entry per kept set id: the latest signature and its counts, so a panel
|
|
19
|
+
* counting 200 sets never needs 200 resolutions resident and nothing grows under streaming data.
|
|
20
|
+
*
|
|
21
|
+
* OFFER COUNTS hold one entry per run: what `./offers` counted of the run's current execution
|
|
22
|
+
* over one snapshot. They are keyed by the run and valid for exactly one (execution, store,
|
|
23
|
+
* snapshot serial); anything else misses and replaces the entry.
|
|
24
|
+
*
|
|
25
|
+
* Nothing here reaches Babylon.js, Lit or the DOM.
|
|
26
|
+
*/
|
|
27
|
+
import type { SetDefinition, SetId } from "../../catalog/types";
|
|
28
|
+
import { type Resolution, type ResolveContext } from "./resolve";
|
|
29
|
+
import { type SignatureMemo } from "./signature";
|
|
30
|
+
/** Counts the cache tests read. */
|
|
31
|
+
export declare const cacheCounters: {
|
|
32
|
+
hits: number;
|
|
33
|
+
misses: number;
|
|
34
|
+
evictions: number;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* A kept set's counts under one signature, and the outcome of the pass that produced them, which
|
|
38
|
+
* status reads without resolving.
|
|
39
|
+
*/
|
|
40
|
+
interface SetSummary {
|
|
41
|
+
readonly signature: string;
|
|
42
|
+
/** The definition the pass resolved, so an outcome is never read for a later definition. */
|
|
43
|
+
readonly definition: SetDefinition;
|
|
44
|
+
readonly nodeCount: number;
|
|
45
|
+
readonly edgeCount: number;
|
|
46
|
+
readonly missingNodes: number;
|
|
47
|
+
readonly missingEdges: number;
|
|
48
|
+
readonly ambiguousEdges: number;
|
|
49
|
+
/** Why the pass resolved nothing, when it could not evaluate the definition. */
|
|
50
|
+
readonly problem?: Resolution["problem"];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* What `./offers` counted of one run's execution over one snapshot: members per item key, and the
|
|
54
|
+
* edge-count pass once it has run.
|
|
55
|
+
*/
|
|
56
|
+
export interface OfferCounts {
|
|
57
|
+
readonly execution: string | undefined;
|
|
58
|
+
/** Identity of the store the snapshot came from. */
|
|
59
|
+
readonly store: number;
|
|
60
|
+
readonly serial: number;
|
|
61
|
+
/** Item key (`itemKeyOf`) to its value and the nodes whose values name it. */
|
|
62
|
+
readonly nodes: ReadonlyMap<string, {
|
|
63
|
+
readonly value: string | number | boolean;
|
|
64
|
+
readonly count: number;
|
|
65
|
+
}>;
|
|
66
|
+
/** The edge-count pass: item key to its edges and, read `listed`, its nodes with the edges' endpoints. */
|
|
67
|
+
pass?: ReadonlyMap<string, {
|
|
68
|
+
readonly edges: number;
|
|
69
|
+
readonly nodes: number;
|
|
70
|
+
}>;
|
|
71
|
+
}
|
|
72
|
+
/** One session's resolution cache, its summaries and its signature memo. */
|
|
73
|
+
export declare class SetsCache {
|
|
74
|
+
private readonly options;
|
|
75
|
+
/** The signature memo every resolution through this cache shares. */
|
|
76
|
+
readonly memo: SignatureMemo;
|
|
77
|
+
/** Summaries by set id. */
|
|
78
|
+
readonly summaries: Map<string, SetSummary>;
|
|
79
|
+
/** Offer counts by run id. */
|
|
80
|
+
readonly offers: Map<string, OfferCounts>;
|
|
81
|
+
/** Entries, least recently used first. */
|
|
82
|
+
private readonly entries;
|
|
83
|
+
/** How many holders pin each key. */
|
|
84
|
+
private readonly pins;
|
|
85
|
+
private unpinned;
|
|
86
|
+
private pinned;
|
|
87
|
+
/**
|
|
88
|
+
* An empty cache.
|
|
89
|
+
* @param options - The bounds.
|
|
90
|
+
* @param options.limit - The byte bound; {@link RESOLUTION_BYTES} by default.
|
|
91
|
+
* @param options.reserve - The bytes always left to unpinned entries; {@link UNPINNED_RESERVE_BYTES}.
|
|
92
|
+
*/
|
|
93
|
+
constructor(options?: {
|
|
94
|
+
readonly limit?: number;
|
|
95
|
+
readonly reserve?: number;
|
|
96
|
+
});
|
|
97
|
+
/**
|
|
98
|
+
* The bytes cached, pinned and unpinned.
|
|
99
|
+
* @returns The byte count.
|
|
100
|
+
*/
|
|
101
|
+
get bytes(): number;
|
|
102
|
+
/**
|
|
103
|
+
* The bytes pinned entries hold.
|
|
104
|
+
* @returns The byte count.
|
|
105
|
+
*/
|
|
106
|
+
get pinnedBytes(): number;
|
|
107
|
+
/**
|
|
108
|
+
* How many entries are cached.
|
|
109
|
+
* @returns The count.
|
|
110
|
+
*/
|
|
111
|
+
get size(): number;
|
|
112
|
+
/**
|
|
113
|
+
* Every cached resolution with its key, least recently used first. For the accounting test.
|
|
114
|
+
* @returns The entries.
|
|
115
|
+
*/
|
|
116
|
+
cached(): [unknown, Resolution][];
|
|
117
|
+
/**
|
|
118
|
+
* The resolution cached for a key under a signature.
|
|
119
|
+
* @param key - What was resolved.
|
|
120
|
+
* @param signature - Its input signature now.
|
|
121
|
+
* @returns The resolution, or undefined on a miss.
|
|
122
|
+
*/
|
|
123
|
+
lookup(key: unknown, signature: string): Resolution | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* The resolution cached for a key under a signature, counting nothing and moving nothing: for
|
|
126
|
+
* a reader that only uses a resolution when one happens to be there.
|
|
127
|
+
* @param key - What was resolved.
|
|
128
|
+
* @param signature - Its input signature now.
|
|
129
|
+
* @returns The resolution, or undefined when none is cached under that signature.
|
|
130
|
+
*/
|
|
131
|
+
peek(key: unknown, signature: string): Resolution | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Cache a resolution, replacing the key's entry, then evict past the bound.
|
|
134
|
+
* @param key - What was resolved.
|
|
135
|
+
* @param signature - The signature it was resolved under.
|
|
136
|
+
* @param resolution - The resolution.
|
|
137
|
+
*/
|
|
138
|
+
store(key: unknown, signature: string, resolution: Resolution): void;
|
|
139
|
+
/**
|
|
140
|
+
* Pin a key: its entry is never evicted while any pin holds.
|
|
141
|
+
* @param key - The key.
|
|
142
|
+
* @returns A function that releases this pin.
|
|
143
|
+
*/
|
|
144
|
+
pin(key: unknown): () => void;
|
|
145
|
+
/**
|
|
146
|
+
* Count an entry's bytes in its bucket.
|
|
147
|
+
* @param key - Its key.
|
|
148
|
+
* @param bytes - Its bytes; negative to uncount.
|
|
149
|
+
*/
|
|
150
|
+
private account;
|
|
151
|
+
/**
|
|
152
|
+
* Remove a key's entry.
|
|
153
|
+
* @param key - The key.
|
|
154
|
+
*/
|
|
155
|
+
private drop;
|
|
156
|
+
/** Evict unpinned entries, least recently used first, while they are over their budget. */
|
|
157
|
+
private evict;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* What a kept set covers, through the context's cache when it has one. Also records the set's
|
|
161
|
+
* summary.
|
|
162
|
+
* @param record - The set: its id and frozen definition.
|
|
163
|
+
* @param record.id - Its id.
|
|
164
|
+
* @param record.definition - Its definition.
|
|
165
|
+
* @param context - What the resolution reads; `context.cache` is consulted when present.
|
|
166
|
+
* @returns The resolution.
|
|
167
|
+
*/
|
|
168
|
+
export declare function resolveSet(record: {
|
|
169
|
+
readonly id: SetId;
|
|
170
|
+
readonly definition: SetDefinition;
|
|
171
|
+
}, context: ResolveContext): Resolution;
|
|
172
|
+
/**
|
|
173
|
+
* A kept set's counts: from its summary while the signature holds, else resolved.
|
|
174
|
+
* @param record - The set.
|
|
175
|
+
* @param record.id - Its id.
|
|
176
|
+
* @param record.definition - Its definition.
|
|
177
|
+
* @param context - What the resolution reads; needs `context.cache`.
|
|
178
|
+
* @returns The counts.
|
|
179
|
+
*/
|
|
180
|
+
export declare function countsOf(record: {
|
|
181
|
+
readonly id: SetId;
|
|
182
|
+
readonly definition: SetDefinition;
|
|
183
|
+
}, context: ResolveContext): Pick<SetSummary, "nodeCount" | "edgeCount" | "missingNodes" | "missingEdges">;
|
|
184
|
+
/**
|
|
185
|
+
* What the last pass over a kept set found, when that pass resolved its current definition: why it
|
|
186
|
+
* resolved nothing, and how many edge members more than one edge carries. Never resolves.
|
|
187
|
+
* @param cache - The cache.
|
|
188
|
+
* @param record - The set.
|
|
189
|
+
* @param record.id - Its id.
|
|
190
|
+
* @param record.definition - Its definition.
|
|
191
|
+
* @returns The outcome, or undefined when no pass has resolved this definition.
|
|
192
|
+
*/
|
|
193
|
+
export declare function outcomeOf(cache: SetsCache, record: {
|
|
194
|
+
readonly id: SetId;
|
|
195
|
+
readonly definition: SetDefinition;
|
|
196
|
+
}): Pick<SetSummary, "problem" | "ambiguousEdges"> | undefined;
|
|
197
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Held-item captures (design/sets/sets-design.md section 5.2).
|
|
3
|
+
*
|
|
4
|
+
* A rule's `item` leaf that carries a `run` HOLDS that run (execution) of its result. When the run
|
|
5
|
+
* re-executes in place, the values that execution published are replaced, so before they go the
|
|
6
|
+
* re-run captures the members of every item a live reference holds: a sorted id list per item,
|
|
7
|
+
* stored on the run under the execution, as `held: { [execution]: { [itemKey]: capture } }`. The
|
|
8
|
+
* holding reference then resolves to the capture and reads "Earlier run".
|
|
9
|
+
*
|
|
10
|
+
* A capture is STATE, not cache: it is written only by a run command (a re-run), and each run
|
|
11
|
+
* command carries a capture forward only while live state still holds its execution. Nothing
|
|
12
|
+
* prunes it from anywhere else, so what a saved file holds never depends on when something ran.
|
|
13
|
+
* With no capture (a file written without it), the reference resolves to nothing and its status
|
|
14
|
+
* says `values-not-kept`.
|
|
15
|
+
*
|
|
16
|
+
* Nothing here reaches Babylon.js, Lit or the DOM.
|
|
17
|
+
*/
|
|
18
|
+
import { type GraphSnapshot } from "@graphty/graph-format";
|
|
19
|
+
import type { EdgeMember, ItemKey, NodeId, ResultItem, RunId } from "../../catalog/types";
|
|
20
|
+
import type { CapturedHalves, FilterRunResult } from "../visibility/filter";
|
|
21
|
+
import { type EdgeMemberList } from "./prepare";
|
|
22
|
+
import { type ResolveContext } from "./resolve";
|
|
23
|
+
/** One held item's members, as a re-run captured them. Frozen. */
|
|
24
|
+
export interface Capture {
|
|
25
|
+
/** Present when the item's field lives on nodes: the node ids, sorted. */
|
|
26
|
+
readonly nodes?: readonly NodeId[];
|
|
27
|
+
/**
|
|
28
|
+
* Present when it lives on edges: the edges' stable identities, sorted by key, in the compact
|
|
29
|
+
* column form a fixed set holds them in.
|
|
30
|
+
*/
|
|
31
|
+
readonly edges?: EdgeMemberList;
|
|
32
|
+
}
|
|
33
|
+
/** One run's captures: by held execution, then by item key ({@link itemKeyOf}). */
|
|
34
|
+
export type HeldCaptures = ReadonlyMap<string, ReadonlyMap<string, Capture>>;
|
|
35
|
+
/**
|
|
36
|
+
* An item key as a string: the field, and the value with its type, so `1` and `"1"` differ.
|
|
37
|
+
* @param key - The key.
|
|
38
|
+
* @returns The string.
|
|
39
|
+
*/
|
|
40
|
+
export declare function itemKeyOf(key: ItemKey): string;
|
|
41
|
+
/**
|
|
42
|
+
* The items of one run that the holders hold by execution, in the definitions, scopes and rule
|
|
43
|
+
* trees given and the definitions they carry inline.
|
|
44
|
+
* @param holders - Definitions, scopes or rule trees (kept sets' definitions, the visibility filter).
|
|
45
|
+
* @param run - The run.
|
|
46
|
+
* @returns Execution to item key to key.
|
|
47
|
+
*/
|
|
48
|
+
export declare function heldItems(holders: Iterable<unknown>, run: RunId): Map<string, Map<string, ItemKey>>;
|
|
49
|
+
/**
|
|
50
|
+
* The members one item of a result holds now, as a capture.
|
|
51
|
+
* @param result - The run's current result, by dense index.
|
|
52
|
+
* @param key - The item's key.
|
|
53
|
+
* @param snapshot - The snapshot the result is read against.
|
|
54
|
+
* @param edgeMemberOf - An edge row's stable identity.
|
|
55
|
+
* @returns The capture: a half only where the result publishes the field per element.
|
|
56
|
+
*/
|
|
57
|
+
export declare function captureItem(result: FilterRunResult, key: ItemKey, snapshot: GraphSnapshot, edgeMemberOf: (row: number) => EdgeMember | undefined): Capture;
|
|
58
|
+
/**
|
|
59
|
+
* The captures a re-run leaves on its run: for every item a holder holds, the capture of the
|
|
60
|
+
* execution being replaced when it is that one, else the one already kept. An execution nothing
|
|
61
|
+
* holds any more is not carried forward.
|
|
62
|
+
* @param prior - The run's captures before the re-run.
|
|
63
|
+
* @param held - What the holders hold of this run ({@link heldItems}).
|
|
64
|
+
* @param current - The execution being replaced, or undefined when the run has no result.
|
|
65
|
+
* @param capture - Captures one item of the result being replaced; absent when there is none.
|
|
66
|
+
* @returns The run's captures after the re-run.
|
|
67
|
+
*/
|
|
68
|
+
export declare function nextCaptures(prior: HeldCaptures, held: ReadonlyMap<string, ReadonlyMap<string, ItemKey>>, current: string | undefined, capture: ((key: ItemKey) => Capture) | undefined): HeldCaptures;
|
|
69
|
+
/**
|
|
70
|
+
* The capture a run keeps for one held item, if any.
|
|
71
|
+
* @param captures - The run's captures.
|
|
72
|
+
* @param item - The item, with its execution.
|
|
73
|
+
* @returns The capture, or undefined.
|
|
74
|
+
*/
|
|
75
|
+
export declare function captureOf(captures: HeldCaptures, item: ResultItem): Capture | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* A capture as bitmaps over the context snapshot, rebound like a fixed set's members: node ids
|
|
78
|
+
* through the id map, edges by stable identity. Memoised per capture and snapshot.
|
|
79
|
+
* @param capture - The capture.
|
|
80
|
+
* @param context - What the resolution reads.
|
|
81
|
+
* @returns The halves.
|
|
82
|
+
*/
|
|
83
|
+
export declare function capturedHalves(capture: Capture, context: ResolveContext): CapturedHalves;
|