Runtime Value Model — Graph Execution (v1)¶
1. Purpose¶
This document defines the runtime value model used during query execution in the openCypher-compatible graph workbench.
The runtime value model specifies: - How nodes and relationships are represented at execution time - How rows are structured and propagated through the execution pipeline - How values interact with Cypher expressions, schemas, and adapters (e.g. NetworkX)
This model is intentionally explicit, minimal, and stable, serving as the contract between: - Logical planning - Execution - Schema / ontology layers - Downstream adapters
2. Design Goals¶
The runtime value model MUST:
- Preserve openCypher semantics
- Be independent of storage implementation details
- Support schema / ontology annotations
- Be efficient for adjacency-based traversal
- Be inspectable and debuggable in Python
- Map cleanly to external graph libraries
The model MUST NOT: - Encode planner logic - Encode query semantics - Leak storage internals (e.g. page IDs, offsets)
3. Core Runtime Types¶
3.1 NodeRef¶
NodeRef represents a runtime reference to a node.
Required Fields¶
id: int | str
Stable internal node identifierlabels: frozenset[str]
Set of node labelsproperties: Mapping[str, Value]
Node properties (lazy or eager)
Optional Fields¶
schema: NodeSchema | None
Associated schema / ontology model (if any)provenance: Any | None
Optional provenance metadata
Semantics¶
NodeRefidentity is defined byid- Two
NodeRefs with the sameidMUST be treated as the same node NodeRefMUST be hashable and comparable byid
3.2 EdgeRef¶
EdgeRef represents a runtime reference to a relationship.
Required Fields¶
id: int | str
Stable internal relationship identifiertype: str
Relationship typesrc: NodeRef
Source nodedst: NodeRef
Destination nodeproperties: Mapping[str, Value]
Optional Fields¶
schema: RelationshipSchema | Noneprovenance: Any | None
Semantics¶
EdgeRefidentity is defined byid- Directionality is intrinsic (
src → dst) - For undirected expansion, the same
EdgeRefmay be traversed in either direction
4. Scalar Value Model¶
4.1 Value Type¶
A Value is any of the following:
intfloatboolstrNonelist[Value]dict[str, Value]NodeRefEdgeRef
This aligns with openCypher value semantics.
4.2 Null Semantics¶
Nonerepresents Cyphernull- Any expression involving
nullMUST follow openCypher three-valued logic - Comparisons involving
nullevaluate tonull, notfalse
5. Row Model¶
5.1 Row Definition¶
A Row is an immutable mapping:
Where:
- Keys are variable names bound during execution
- Values are runtime Values
Example:
5.2 Row Semantics¶
- Rows are logically immutable
- Operators produce new rows rather than mutating existing ones
- Variable shadowing is not allowed in v1
6. Interaction with Execution Operators¶
6.1 NodeScan¶
- Emits rows of the form:
6.2 Expand¶
- Consumes rows containing a bound
NodeRef - Emits rows with additional bindings:
6.3 Filter¶
- Evaluates predicates against row values
- Retains rows where predicate evaluates to
TRUE - Drops rows where predicate evaluates to
FALSEorNULL
6.4 Project¶
- Transforms rows into projected output rows
- Output values may be scalars or property accesses
6.5 Distinct¶
- Applies set semantics over projected rows
- Equality is defined over runtime values
7. Property Access Semantics¶
- Property access (
n.age) onNodeReforEdgeRef: - Returns the property value if present
- Returns
Noneif missing - Missing properties are indistinguishable from explicit
nullper openCypher
8. Schema & Ontology Interaction¶
- Runtime values MAY carry optional schema references
- Schemas MUST NOT alter runtime semantics
- Schemas MAY be used to:
- Validate properties
- Annotate values
- Assist adapters (e.g. export)
Schema presence MUST be transparent to execution operators.
9. NetworkX Interoperability¶
9.1 Node Mapping¶
NodeRef.id→ NetworkX node keylabels→ node attributesproperties→ node attributes
9.2 Edge Mapping¶
EdgeRef.id→ edge key (if multigraph)type→ edge attributeproperties→ edge attributes
The runtime model is designed to allow lossless export to NetworkX graphs.
10. Invariants & Guarantees¶
The runtime value model guarantees:
- Stable identity for nodes and relationships
- Deterministic equality and hashing
- Correct Cypher null semantics
- Clear separation from storage internals
11. Non-Goals¶
The runtime value model does NOT: - Encode traversal history or paths - Support path values in v1 - Perform lazy evaluation of expressions
12. Summary¶
The runtime value model provides a clean, minimal execution contract that: - Supports openCypher semantics - Integrates naturally with Pydantic schemas - Enables analytical graph workflows - Remains adaptable for future extensions
It is the foundation upon which execution correctness, interoperability, and extensibility depend.