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/// Why the frontier rung did not serve the clause, one of the
115/// `DECLINE_REASONS` vocabulary — emitted with the metric set when the
116/// rung declined at plan time (counters absent: it never ran) or engaged,
117/// ran, and fell through (ADR-0516, counters beside it).
118pub const FRONTIER_DECLINE_REASON: &str = "FrontierDeclineReason";
119/// The decline vocabulary: first the run-time declines (ADR-0516), the
120/// executor's `FrontierRunDecline::as_str` names, then the plan-time
121/// gates' (ADR-0478), `FrontierDecline::as_str` — single-sourced here so
122/// a renamed decline fails loudly at the wire boundary, like the start
123/// reasons. Each name is its own constant, read by the executor's
124/// vocabulary macros and by the table below.
125pub const DECLINE_REARRIVAL_BUDGET: &str = "rearrival-budget";
126pub const DECLINE_TABLE_BUDGET: &str = "table-budget";
127pub const DECLINE_MULTIPLE_PATTERNS: &str = "multiple-patterns";
128pub const DECLINE_CARRYING_ROW: &str = "carrying-row";
129pub const DECLINE_MODE: &str = "mode";
130pub const DECLINE_NESTED_SPINE: &str = "nested-spine";
131pub const DECLINE_ALL_REDUCE_GROUP: &str = "all-reduce-group";
132pub const DECLINE_PINNED_BINDING: &str = "pinned-binding";
133pub const DECLINE_CONJUNCT: &str = "conjunct";
134pub const DECLINE_NFA_SHAPE: &str = "nfa-shape";
135pub const DECLINE_GUARDED_GROUP: &str = "guarded-group";
136pub const DECLINE_FULL_ENUMERATION: &str = "full-enumeration";
137pub const DECLINE_ORDERED_CAP: &str = "ordered-cap";
138pub const DECLINE_PATH_COUNT: &str = "path-count";
139pub const DECLINE_PATH_CONSUMER: &str = "path-consumer";
140pub const DECLINE_COST: &str = "cost";
141/// The decline names, in the vocabulary's own order.
142pub const DECLINE_REASONS: [&str; 16] = [
143 DECLINE_REARRIVAL_BUDGET,
144 DECLINE_TABLE_BUDGET,
145 DECLINE_MULTIPLE_PATTERNS,
146 DECLINE_CARRYING_ROW,
147 DECLINE_MODE,
148 DECLINE_NESTED_SPINE,
149 DECLINE_ALL_REDUCE_GROUP,
150 DECLINE_PINNED_BINDING,
151 DECLINE_CONJUNCT,
152 DECLINE_NFA_SHAPE,
153 DECLINE_GUARDED_GROUP,
154 DECLINE_FULL_ENUMERATION,
155 DECLINE_ORDERED_CAP,
156 DECLINE_PATH_COUNT,
157 DECLINE_PATH_CONSUMER,
158 DECLINE_COST,
159];
160/// The start-reason vocabulary (LABS-369), the executor's
161/// `StartReason::as_str` names — single-sourced here so a renamed
162/// reason fails loudly at the wire boundary, like the warning names.
163/// Each name is its own constant, so the variant↔name mapping reads the
164/// same spelling this table does (the shape [`KernelRungWire`] takes for
165/// the rungs).
166pub const REASONS: [&str; 4] = [
167 START_REASON_BOUND_PIVOT,
168 START_REASON_CHEAPEST,
169 START_REASON_SEEK_ANCHORED,
170 START_REASON_INDEX_ZERO,
171];
172/// The bound-pivot start reason: see [`REASONS`].
173pub const START_REASON_BOUND_PIVOT: &str = "bound-pivot";
174/// The cheapest-start reason: see [`REASONS`].
175pub const START_REASON_CHEAPEST: &str = "cheapest";
176/// The seek-anchored start reason: see [`REASONS`].
177pub const START_REASON_SEEK_ANCHORED: &str = "seek-anchored";
178/// The first-element (un-optimised) start reason: see [`REASONS`].
179pub const START_REASON_INDEX_ZERO: &str = "index-0";
180/// The typed warnings the node carries (typed node warnings): a list
181/// of warning maps from the [`PlanWarning`](crate::wire::PlanWarning)
182/// vocabulary, present only when the node carries one. Each map
183/// carries the warning's name and, when the warning has a payload
184/// (the `LabelDisjunctionScan` warning's index pairs), that payload —
185/// one spelling for the producer and every consumer.
186pub const WARNINGS: &str = "warnings";
187/// The warning map's name field (typed node warnings).
188pub const WARNING_NAME: &str = "name";
189/// The warning map's payload field (typed node warnings): the
190/// `LabelDisjunctionScan` warning's index-pair text.
191pub const WARNING_INDEX: &str = "index";
192/// The Neo4j-facing root args (ADR-0357): the plan's rendered text —
193/// Neo4j's plan root carries it and tooling (Browser's Code tab,
194/// strict clients) renders from it. The engine's own args stay as
195/// they are; the one decoration lives on `PlanNode` (the
196/// `relate` crate's `to_neo4j_value`, this vocabulary's only
197/// writer) and each surface calls it at its boundary.
198pub const STRING_REPRESENTATION: &str = "string-representation";
199/// The planner and runtime identity args (ADR-0357): `planner` names
200/// the planner, `planner-impl`/`planner-version` its implementation
201/// and version; `runtime`/`runtime-impl`/`runtime-version` the same
202/// for the runtime; `version` is the Cypher language version — Neo4j's
203/// plan root carries all of them and tooling (cypher-shell's summary
204/// block, Browser's footer) reads them.
205pub const PLANNER_IMPL: &str = "planner-impl";
206/// See [`PLANNER_IMPL`].
207pub const PLANNER: &str = "planner";
208/// See [`PLANNER_IMPL`].
209pub const PLANNER_VERSION: &str = "planner-version";
210/// See [`PLANNER_IMPL`].
211pub const RUNTIME: &str = "runtime";
212/// See [`PLANNER_IMPL`].
213pub const RUNTIME_IMPL: &str = "runtime-impl";
214/// See [`PLANNER_IMPL`].
215pub const RUNTIME_VERSION: &str = "runtime-version";
216/// See [`PLANNER_IMPL`]: the Cypher language version the plan ran
217/// under.
218pub const VERSION: &str = "version";
219/// See [`PLANNER_IMPL`]: Neo4j's `Memory` arg — the root mirrors this
220/// engine's row-materialization bytes under it (ADR-0357).
221pub const MEMORY: &str = "Memory";