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