Skip to main content

relate_model/
plan_keys.rs

1//! The plan wire form's key vocabulary (ADR-0344/0345): the names
2//! `PlanNode::to_value` produces and every consumer reads, single-sourced
3//! so drift between producer and consumer is a compile error, not a silent
4//! mismatch. Its own module (the plan-node types and decoder stay in
5//! `plan_wire`); the public path is `wire::plan_keys`.
6
7use crate::wire::KernelRungWire;
8
9pub const OPERATOR_TYPE: &str = "operatorType";
10pub const ARGS: &str = "args";
11pub const IDENTIFIERS: &str = "identifiers";
12pub const CHILDREN: &str = "children";
13pub const ID: &str = "Id";
14pub const DETAILS: &str = "Details";
15pub const ESTIMATED_ROWS: &str = "EstimatedRows";
16/// Which planner ladder level produced `EstimatedRows` (ADR-0708): one of
17/// [`EstimateProvenance::NAMES`](crate::wire::EstimateProvenance::NAMES). Emitted exactly when `EstimatedRows` is, never
18/// alone. The one place the key (and its siblings in ADR-0708) are named.
19pub const ESTIMATE_PROVENANCE: &str = "EstimateProvenance";
20/// The fused parent operator's `Id` (virtual plan operators) — present
21/// exactly on a fused virtual child: a display-only breakdown step of its
22/// fused parent operator, never an executed one. The key's presence IS
23/// the fused fact (the `Batched` flag's presence-only shape); there is no
24/// separate flag. A fused child never carries the PROFILE metric block:
25/// rows, time and memory stay the fused parent's clause totals.
26pub const FUSED_INTO: &str = "FusedInto";
27/// The plan's peak logical workspace bytes (ADR-0463's receipt): the
28/// root's one admission figure, emitted when admission is on.
29pub const PEAK_LOGICAL_BYTES: &str = "PeakLogicalBytes";
30/// The batched `CALL { … } IN TRANSACTIONS` body role marker
31/// (REL8-2047): the `CallSubquery` parent operator's non-negative id on
32/// the root of a body subtree the plan renders as children, so a walk can
33/// tell a body operator from the pipeline's data-flow child — the
34/// `FusedInto` shape for the display-only steps. Absent on every node of
35/// the statement's own pipeline.
36pub const BODY_OF: &str = "BodyOf";
37/// The walk-side keys a fused virtual child never carries (virtual plan
38/// operators): the walk's read kinds and its phase time stay the fused
39/// parent's. The fused-child parser rejects these together with
40/// [`METRIC_BLOCK_KEYS`] at one site — never a hand-listed subset there.
41pub const FUSED_CHILD_NEVER: [&str; 3] = [HOPS, NEIGHBOR_WALKS, WALK_TIME_NS];
42/// The PROFILE metric block's five scalar keys (ADR-0344 phase 2) — one
43/// table for the accessor's scalar read, the fused-child parser's
44/// rejection set and the fixtures, so a sixth scalar metric extends one
45/// list instead of every hand-listed copy.
46pub const METRIC_BLOCK_KEYS: [&str; 5] =
47    [ROWS, TIME_NS, DB_HITS, MEMORY_BYTES, EXPRESSION_BUILT_BYTES];
48/// PROFILE metrics (ADR-0344 phase 2).
49pub const ROWS: &str = "Rows";
50pub const TIME_NS: &str = "TimeNs";
51/// PROFILE metric fields (ADR-0344 metric fields).
52pub const DB_HITS: &str = "DbHits";
53pub const MEMORY_BYTES: &str = "MemoryBytes";
54/// The expression allocation bytes a profiled clause charged against the
55/// ADR-0463 statement budget, emitted with the metric block.
56pub const EXPRESSION_BUILT_BYTES: &str = "ExpressionBuiltBytes";
57/// The store-read mix behind `DbHits` (LABS-369): the kinds the one
58/// total blends — relationship hops, neighbor walks, node-store reads.
59pub const HOPS: &str = "Hops";
60pub const NEIGHBOR_WALKS: &str = "NeighborWalks";
61pub const NODE_READS: &str = "NodeReads";
62/// The phase times the read kinds' store work spent (LABS-448): the
63/// seek (candidate resolution and admission — the `Nodes` kind's
64/// work) and the walk (relationship traversal — the `Rels`/`Degree`
65/// kinds' work), inclusive of a multi-element pattern's nested
66/// phases. Emitted together with the metric block and the kinds.
67pub const SEEK_TIME_NS: &str = "SeekTimeNs";
68/// See [`SEEK_TIME_NS`].
69pub const WALK_TIME_NS: &str = "WalkTimeNs";
70/// The walk's chosen start (LABS-369): the pattern element index, its
71/// direction, and the reason class (`bound-pivot`, `cheapest`,
72/// `seek-anchored`, `index-0`) — the fact an opaque `Expand` hid.
73pub const START_ELEMENT: &str = "StartElement";
74pub const START_BACKWARD: &str = "StartBackward";
75pub const START_REASON: &str = "StartReason";
76/// Which rung served the clause's `MATCH` walk (LABS-1117), one of the
77/// `KERNEL_RUNGS` vocabulary — emitted only when a rung served the
78/// clause, with the metric set (a non-`MATCH` clause and a batch-chain
79/// `MATCH` emit no key).
80pub const KERNEL_RUNG: &str = "KernelRung";
81/// The chain rung's hop count (LABS-1117) — emitted with `KernelRung`
82/// when the rung is the chain, never for another rung.
83pub const KERNEL_HOPS: &str = "KernelHops";
84/// The store's active pattern-engine rung (LABS-1117): `auto`, `nfa`,
85/// or `walk`, emitted on every `MATCH` operator of an EXPLAIN and
86/// PROFILE tree — the one static rung fact the plan can state.
87pub const PATTERN_ENGINE: &str = "PatternEngine";
88/// The kernel-rung vocabulary (LABS-1117), the typed [`KernelRungWire`]'s
89/// name list — one spelling, never a second list and never a fabricated
90/// variant value. The executor's `KernelRung::as_str` reads the same name
91/// constants, and the mapping is pinned by `relate`'s
92/// `decline_and_start_reason_names_match_the_wire_tables`, like the start
93/// reasons and the run-time declines.
94pub const KERNEL_RUNGS: [&str; 3] = KernelRungWire::NAMES;
95/// Whether the clause ran ADR-0468's batch scan/filter/project chain
96/// over `Chunk` (LABS-359) — emitted only when true (like the start
97/// trio's presence-only-when-walked), with the metric set.
98pub const BATCHED: &str = "Batched";
99/// The batch filter's zone skips (LABS-645): conjunct-batch
100/// evaluations the chunk's derived min/max zone metadata provably
101/// replaced with the correct empty survivor set — emitted only when
102/// nonzero (a count's presence-only shape), with the metric set.
103pub const ZONE_SKIPS: &str = "ZoneSkips";
104/// Bound-both-ends ExpandInto probe attempts. Emitted with the ExpandInto
105/// group only when nonzero.
106pub const EXPAND_INTO_PROBES: &str = "ExpandIntoProbes";
107/// ExpandInto probes that scanned from the smaller-degree destination side.
108/// Emitted as part of the ExpandInto group whenever `ExpandIntoProbes > 0`
109/// (including when 0).
110pub const EXPAND_INTO_REVERSED: &str = "ExpandIntoReversed";
111/// The ExpandInto group keys, in canonical wire order (probes, reversed).
112pub const EXPAND_INTO_GROUP_KEYS: [&str; 2] = [EXPAND_INTO_PROBES, EXPAND_INTO_REVERSED];
113/// Hash-join build table rows. Emitted with the HashJoin group only when nonzero.
114pub const HASH_JOIN_BUILD_ROWS: &str = "HashJoinBuildRows";
115/// Hash-join probe stream rows examined.
116pub const HASH_JOIN_PROBE_ROWS: &str = "HashJoinProbeRows";
117/// Candidates rejected by the semi-masker SIP bitset/set.
118pub const SEMI_MASK_REJECTED: &str = "SemiMaskRejected";
119/// The HashJoin group keys, in canonical wire order (build, probe, rejected).
120pub const HASH_JOIN_GROUP_KEYS: [&str; 3] = [
121    HASH_JOIN_BUILD_ROWS,
122    HASH_JOIN_PROBE_ROWS,
123    SEMI_MASK_REJECTED,
124];
125/// Vector scans the packed matrix answered (ADR-0705). Emitted with the
126/// vector-scan group only when a scan ran on the clause.
127pub const VECTOR_SCAN_MATRIX: &str = "VectorScanMatrix";
128/// Vector scans the `Value` sweep answered (the matrix declined). Emitted
129/// with the group whenever a scan ran (including when 0).
130pub const VECTOR_SCAN_VALUE: &str = "VectorScanValue";
131/// The vector-scan group keys, in canonical wire order (matrix, value).
132pub const VECTOR_SCAN_GROUP_KEYS: [&str; 2] = [VECTOR_SCAN_MATRIX, VECTOR_SCAN_VALUE];
133/// The frontier family's run counters (ADR-0478): the BFS's edge
134/// visits, completed levels, and accepted endpoints — emitted only
135/// when the family ran the clause (`levels > 0`), the three together
136/// (a half-present trio is a wire-contract break), with the metric
137/// set.
138pub const FRONTIER_EDGES: &str = "FrontierEdges";
139pub const FRONTIER_LEVELS: &str = "FrontierLevels";
140pub const FRONTIER_ENDPOINTS: &str = "FrontierEndpoints";
141/// The frontier-NFA rung's own PROFILE facts (ADR-0478 §3, ADR-0516),
142/// riding the frontier trio's presence-only-when-engaged group: the
143/// (node, state) cells the runs created, the re-arrival rule memo's
144/// hits and misses, the admission asks by verdict
145/// (representative-proof / search-proven / search-disproven /
146/// declined-exhausted), and the budget fraction the rule's work
147/// spent — the seven integers and the one float emitted together
148/// with the trio, a half-present set a wire-contract break.
149pub const FRONTIER_CELLS: &str = "FrontierCells";
150pub const FRONTIER_MEMO_HITS: &str = "FrontierMemoHits";
151pub const FRONTIER_MEMO_MISSES: &str = "FrontierMemoMisses";
152pub const FRONTIER_REPRESENTATIVE_PROOFS: &str = "FrontierRepresentativeProofs";
153pub const FRONTIER_SEARCH_PROVEN: &str = "FrontierSearchProven";
154pub const FRONTIER_SEARCH_DISPROVEN: &str = "FrontierSearchDisproven";
155pub const FRONTIER_DECLINED_EXHAUSTED: &str = "FrontierDeclinedExhausted";
156pub const FRONTIER_BUDGET_FRACTION: &str = "FrontierBudgetFraction";
157/// The group's ten integer keys in the order of `PlanFrontierWire`'s
158/// fields (edges, levels, endpoints, cells, memo hits, memo misses,
159/// representative proofs, search proven, search disproven, declined
160/// exhausted): the one table the decoder, the producer and any consumer
161/// iterate.
162pub const FRONTIER_GROUP_KEYS: [&str; 10] = [
163    FRONTIER_EDGES,
164    FRONTIER_LEVELS,
165    FRONTIER_ENDPOINTS,
166    FRONTIER_CELLS,
167    FRONTIER_MEMO_HITS,
168    FRONTIER_MEMO_MISSES,
169    FRONTIER_REPRESENTATIVE_PROOFS,
170    FRONTIER_SEARCH_PROVEN,
171    FRONTIER_SEARCH_DISPROVEN,
172    FRONTIER_DECLINED_EXHAUSTED,
173];
174/// The expression-memo group (ADR-0654): the probes, hits, inserts,
175/// refused inserts, table bytes and disabled-memo count the operator's
176/// memos reported, emitted together only on a PROFILE node whose memos
177/// were probed at least once (`MemoProbes > 0`) — absent means no memo
178/// was used. `MemoBytes` is never part of `MemoryBytes` (ADR-0654 §2).
179pub const MEMO_PROBES: &str = "MemoProbes";
180pub const MEMO_HITS: &str = "MemoHits";
181pub const MEMO_INSERTS: &str = "MemoInserts";
182pub const MEMO_REFUSED: &str = "MemoRefused";
183pub const MEMO_BYTES: &str = "MemoBytes";
184pub const MEMO_DISABLED_COUNT: &str = "MemoDisabledCount";
185/// The group's six integer keys in the order of `PlanMemoWire`'s fields
186/// (probes, hits, inserts, refused, bytes, disabled count): the one table
187/// the decoder, the producer and any consumer iterate.
188pub const MEMO_GROUP_KEYS: [&str; 6] = [
189    MEMO_PROBES,
190    MEMO_HITS,
191    MEMO_INSERTS,
192    MEMO_REFUSED,
193    MEMO_BYTES,
194    MEMO_DISABLED_COUNT,
195];
196/// The `CALL { … } IN TRANSACTIONS` batch facts (REL8-2047): the batch
197/// counters — run, committed, rolled back — and the per-batch maxima (the
198/// input batch's and the installed output's retained row bytes, the
199/// scratch the batch created, the redo log's reserved bytes at commit —
200/// the WAL payload it wrote), emitted together only on a PROFILE node
201/// whose arm ran batches (`InTxBatches > 0`), with the metric set — a
202/// half-present set is a wire-contract break.
203pub const IN_TX_BATCHES: &str = "InTxBatches";
204pub const IN_TX_COMMITTED: &str = "InTxCommitted";
205pub const IN_TX_ROLLED_BACK: &str = "InTxRolledBack";
206pub const IN_TX_PEAK_INPUT_ROWS_BYTES: &str = "InTxPeakInputRowsBytes";
207pub const IN_TX_PEAK_OUTPUT_ROWS_BYTES: &str = "InTxPeakOutputRowsBytes";
208pub const IN_TX_PEAK_SCRATCH_BYTES: &str = "InTxPeakScratchBytes";
209pub const IN_TX_PEAK_WAL_BYTES: &str = "InTxPeakWalBytes";
210/// The group's seven integer keys in the order of `PlanInTxWire`'s fields
211/// (batches, committed, rolled back, peak input bytes, peak output bytes,
212/// peak scratch bytes, peak WAL bytes): the one table the decoder, the
213/// producer and any consumer iterate.
214pub const IN_TX_GROUP_KEYS: [&str; 7] = [
215    IN_TX_BATCHES,
216    IN_TX_COMMITTED,
217    IN_TX_ROLLED_BACK,
218    IN_TX_PEAK_INPUT_ROWS_BYTES,
219    IN_TX_PEAK_OUTPUT_ROWS_BYTES,
220    IN_TX_PEAK_SCRATCH_BYTES,
221    IN_TX_PEAK_WAL_BYTES,
222];
223/// The memo types behind the group, one name each from
224/// [`MemoKindWire::NAMES`](crate::wire::MemoKindWire::NAMES) — emitted
225/// only on the plan root, beside the group (ADR-0654 §3).
226pub const MEMO_KINDS: &str = "MemoKinds";
227/// Why the frontier rung did not serve the clause, one of the
228/// `DECLINE_REASONS` vocabulary — emitted with the metric set when the
229/// rung declined at plan time (counters absent: it never ran) or engaged,
230/// ran, and fell through (ADR-0516, counters beside it).
231pub const FRONTIER_DECLINE_REASON: &str = "FrontierDeclineReason";
232/// The decline vocabulary: first the run-time declines (ADR-0516), the
233/// executor's `FrontierRunDecline::as_str` names, then the plan-time
234/// gates' (ADR-0478), `FrontierDecline::as_str` — single-sourced here so
235/// a renamed decline fails loudly at the wire boundary, like the start
236/// reasons. Each name is its own constant, read by the executor's
237/// vocabulary macros and by the table below.
238pub const DECLINE_REARRIVAL_BUDGET: &str = "rearrival-budget";
239pub const DECLINE_TABLE_BUDGET: &str = "table-budget";
240pub const DECLINE_SHORT_CAP: &str = "short-cap";
241pub const DECLINE_MULTIPLE_PATTERNS: &str = "multiple-patterns";
242pub const DECLINE_CARRYING_ROW: &str = "carrying-row";
243pub const DECLINE_MODE: &str = "mode";
244pub const DECLINE_NESTED_SPINE: &str = "nested-spine";
245pub const DECLINE_ALL_REDUCE_GROUP: &str = "all-reduce-group";
246pub const DECLINE_PINNED_BINDING: &str = "pinned-binding";
247pub const DECLINE_CONJUNCT: &str = "conjunct";
248pub const DECLINE_NFA_SHAPE: &str = "nfa-shape";
249pub const DECLINE_GUARDED_GROUP: &str = "guarded-group";
250pub const DECLINE_FULL_ENUMERATION: &str = "full-enumeration";
251pub const DECLINE_ORDERED_CAP: &str = "ordered-cap";
252pub const DECLINE_PATH_COUNT: &str = "path-count";
253pub const DECLINE_PATH_CONSUMER: &str = "path-consumer";
254pub const DECLINE_COST: &str = "cost";
255/// The decline names, in the vocabulary's own order.
256pub const DECLINE_REASONS: [&str; 17] = [
257    DECLINE_REARRIVAL_BUDGET,
258    DECLINE_TABLE_BUDGET,
259    DECLINE_SHORT_CAP,
260    DECLINE_MULTIPLE_PATTERNS,
261    DECLINE_CARRYING_ROW,
262    DECLINE_MODE,
263    DECLINE_NESTED_SPINE,
264    DECLINE_ALL_REDUCE_GROUP,
265    DECLINE_PINNED_BINDING,
266    DECLINE_CONJUNCT,
267    DECLINE_NFA_SHAPE,
268    DECLINE_GUARDED_GROUP,
269    DECLINE_FULL_ENUMERATION,
270    DECLINE_ORDERED_CAP,
271    DECLINE_PATH_COUNT,
272    DECLINE_PATH_CONSUMER,
273    DECLINE_COST,
274];
275/// The start-reason vocabulary (LABS-369), the executor's
276/// `StartReason::as_str` names — single-sourced here so a renamed
277/// reason fails loudly at the wire boundary, like the warning names.
278/// Each name is its own constant, so the variant↔name mapping reads the
279/// same spelling this table does (the shape [`KernelRungWire`] takes for
280/// the rungs).
281pub const REASONS: [&str; 4] = [
282    START_REASON_BOUND_PIVOT,
283    START_REASON_CHEAPEST,
284    START_REASON_SEEK_ANCHORED,
285    START_REASON_INDEX_ZERO,
286];
287/// The bound-pivot start reason: see [`REASONS`].
288pub const START_REASON_BOUND_PIVOT: &str = "bound-pivot";
289/// The cheapest-start reason: see [`REASONS`].
290pub const START_REASON_CHEAPEST: &str = "cheapest";
291/// The seek-anchored start reason: see [`REASONS`].
292pub const START_REASON_SEEK_ANCHORED: &str = "seek-anchored";
293/// The first-element (un-optimised) start reason: see [`REASONS`].
294pub const START_REASON_INDEX_ZERO: &str = "index-0";
295/// The typed warnings the node carries (typed node warnings): a list
296/// of warning maps from the [`PlanWarning`](crate::wire::PlanWarning)
297/// vocabulary, present only when the node carries one. Each map
298/// carries the warning's name and, when the warning has a payload
299/// (the `LabelDisjunctionScan` warning's index pairs), that payload —
300/// one spelling for the producer and every consumer.
301pub const WARNINGS: &str = "warnings";
302/// The warning map's name field (typed node warnings).
303pub const WARNING_NAME: &str = "name";
304/// The warning map's payload field (typed node warnings): the
305/// `LabelDisjunctionScan` warning's index-pair text.
306pub const WARNING_INDEX: &str = "index";
307/// The Neo4j-facing root args (ADR-0357): the plan's rendered text —
308/// Neo4j's plan root carries it and tooling (Browser's Code tab,
309/// strict clients) renders from it. The engine's own args stay as
310/// they are; the one decoration lives on `PlanNode` (the
311/// `relate` crate's `to_neo4j_value`, this vocabulary's only
312/// writer) and each surface calls it at its boundary.
313pub const STRING_REPRESENTATION: &str = "string-representation";
314/// The planner and runtime identity args (ADR-0357): `planner` names
315/// the planner, `planner-impl`/`planner-version` its implementation
316/// and version; `runtime`/`runtime-impl`/`runtime-version` the same
317/// for the runtime; `version` is the Cypher language version — Neo4j's
318/// plan root carries all of them and tooling (cypher-shell's summary
319/// block, Browser's footer) reads them.
320pub const PLANNER_IMPL: &str = "planner-impl";
321/// See [`PLANNER_IMPL`].
322pub const PLANNER: &str = "planner";
323/// See [`PLANNER_IMPL`].
324pub const PLANNER_VERSION: &str = "planner-version";
325/// See [`PLANNER_IMPL`].
326pub const RUNTIME: &str = "runtime";
327/// See [`PLANNER_IMPL`].
328pub const RUNTIME_IMPL: &str = "runtime-impl";
329/// See [`PLANNER_IMPL`].
330pub const RUNTIME_VERSION: &str = "runtime-version";
331/// See [`PLANNER_IMPL`]: the Cypher language version the plan ran
332/// under.
333pub const VERSION: &str = "version";
334/// See [`PLANNER_IMPL`]: Neo4j's `Memory` arg — the root mirrors this
335/// engine's row-materialization bytes under it (ADR-0357).
336pub const MEMORY: &str = "Memory";