13.6 What a rule set may assume about its facts
A rule body reads what is already in the graph. It cannot fetch.
That one sentence decides whether a rule set is sound, and it is the difference between a rule that answers and a rule that answers understatedly. Three situations, and only the third needs work:
| Your facts | Complete? | What to do |
|---|---|---|
| Stored, seeded, promoted, or a materialized view | yes | nothing — write the rules |
| A producer returning a whole record per anchor | yes | nothing — one fetch is the entire fact set for that anchor |
| Gathered by WALKING — each hop is another fetch | not by default | declare requires: |
The second case is the common producer shape and it is why most rule sets need no thought here: one call to a company register returns an officer’s entire appointment history, so a rule about that officer’s appointments has everything.
The third case is a dependency tree, a citation graph, an ownership chain — anything where reaching depth 3 means three rounds of fetching. Without a declared demand, such a rule set concludes over whatever prefix the consumer’s query happened to materialize, which its author never sees.
Declare what you need:
name: npm/reaches-unmaintainedderives: ReachesUnmaintainedrequires: - materialize: "MATCH (r:Release)-[:HAS_DEPENDENCY*1..$depth]->(:Dependency) RETURN 1" description: "The dependency tree has to exist before 'reaches' means anything."params: depth: { type: int, default: 3 }rules: - derive: "(d:ReachesUnmaintained)" from: | MATCH (d:Dependency)-[:HAS_HEALTH]->(h:ProjectHealth) WHERE h.overallScore < 5A demand is ordinary read-only Cypher, validated like a rule body. It runs before any rule evaluates, in the same transaction, and after the consumer’s query has materialized its own anchors — so it DEEPENS what is already there rather than re-anchoring it. It may reference the rule set’s declared params, so depth is tunable per invocation with a default you choose.
When the facts are incomplete anyway, the engine says so. A rule set that evaluates while any
fetch was capped, refused, truncated or left a demand unmet reports PARTIAL_RESULT and states that
its membership — and any count or total over it — is a lower bound, naming the unmet demand
where there is one. Report it to your reader as a lower bound; never present a derived count as a
total. This is not a failure and not “nothing was derived”.
A demand too big to fetch while somebody waits is offered, not dropped. A demand is fetched like
a query, so it meets the same per-join anchor budget (maxAnchors: by default 200 keys to a per-key
source or a model producer). Past it, the demand is not impossible, only big — “extract the ownership
each of 309 documents states” is 309 model calls, once, and then cached in the graph. So it is priced
before your rules run (§13.7), and:
- Where there is someone to ask — a background run, a watched ask — the query is parked with a question naming your rule set, the producer, the number of keys and what they cost (model calls for a model producer, calls for a remote), and the usual four choices. Proceed or background fetches the demand under that approval and then runs the rules, so the answer is complete, with no lower bound.
- Where there is not — a view invoked synchronously, a scheduled refresh — the demand stays unmet
and the answer is the
PARTIAL_RESULTlower bound described below, whoseUNMET_DEMANDreason says the same query can run in the background and how far an approved run may go. - The same holds for a demand within the anchor budget whose model calls exceed what one request may spend inline (8 cold model calls by default): offered as a background run, quoted in model calls, rather than refused part-way through.
- An approved run may go up to 1,000 anchors for a model producer and 5,000 calls for a remote. A
maxAnchorsyou declare on the join is never lifted by approval and never offered: it is your statement about the source. A demand within budget is untouched by any of this.
The rule of thumb: make the fact set complete, and prefer making it complete cheaply. Loading the data (a local table, a promoted watchlist) beats demanding a deep walk, and a demand beats hoping the consumer’s query walked far enough.

