Skip to content

16.1 The model

  • A step is a saved view or a DERIVE rule the world already has — its own, or one a realm ships. No one writes a step signature: what a step needs and makes is read off its Cypher (§16.2).
  • A goal is the only thing written. It is one read-only MATCH … RETURN over world labels and the facts steps make — projected labels and relationships (§7.8), derived labels (§13), views’ output labels.
  • The plan compiles to one standard query. Each chosen view becomes a unit CALL {} subquery, in plan order, and the goal comes last:
CALL {
CALL ai.fromText($email, '(t:Attendee)-[:RAISED]->(i:Issue), (t)-[:WORKS_FOR]->(a:CustomerAccount)')
YIELD t
RETURN count(t) AS projected
}
CALL {
MATCH (li:Issue)<-[:RAISED]-(raiser:Attendee)-[:WORKS_FOR]->(acct:CustomerAccount)-[:HAS_CASE]->(c:SupportCase)
WHERE c.status IN ['open', 'pending']
WITH li, relevant(c, 'the same problem as: ' + li.summary) AS tracked
UNWIND tracked AS tc
CREATE (li)-[:TRACKED_BY]->(tc)
RETURN count(*) AS linked
}
MATCH (raisedBy:Attendee)-[:RAISED]->(untracked:Issue)
WHERE NOT EXISTS { (untracked)-[:TRACKED_BY]->() }
RETURN untracked.summary AS issue, untracked.severity AS severity, raisedBy.name AS person

Nothing is new in Cypher. The compiled statement is an ordinary Virtual Cypher query, held to every rule in this document: ai.fromText inside a unit subquery (§7.8, “where it may be called”), a reduction over elements inside one (§7.7), writes of projected types into the run’s scratch (§7.9). Steps communicate through that scratch, never through variables: a later step reads what an earlier one made by matching its label. One statement is one run, so what the steps project lives exactly as long as the plan.

A DERIVE rule is a step the statement does not call: its conclusion is evaluated whenever a query reads it (§13), so the plan lists it — what it makes, what it needs — and the compiled statement simply reads.