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