Concepts
Querying
Inspect exact facts in a solved result, then optionally explain their presence or absence.Queries inspect a successfully solved result. A membership query asks whether one exact fact is present. The result includes policy facts, the runtime input snapshot and the conclusions derived by rules.
For programming details, see C Stable querying, Python querying and TypeScript querying.
Why querying exists
Solving computes the consequences of a policy; querying extracts the answer the application needs.
| Question | Example | Answer after a successful query |
|---|---|---|
| Is this authorization fact present? | allow("alice", "roadmap.pdf") | Present or absent. |
| Is this observable input fact present? | owns("alice", "roadmap.pdf") | Present or absent, if owns/2 is query-enabled. |
An absent fact is an ordinary negative answer. An invalid predicate, an incorrect arity or a forbidden observation is an API error, not “absent”.
Where querying fits
Successful solvecomplete result snapshot
Membership querycheck one concrete fact
Answerpresent or absent
Optional explanationWhy-true or Why-false
- Successful solve → Membership query
- Membership query → Answer
- Answer → Optional explanation
The query does not solve the policy again or add facts. The result remains unchanged and can be queried repeatedly until it is released.
Ground-only queries
Ground means every term is a concrete value: for example, the user
"alice" and the document "roadmap.pdf". A variable such as User
does not name one exact fact.
% Fully ground: one exact fact
allow("alice", "roadmap.pdf")
% A variable is not accepted by the ground-query API
allow(User, "roadmap.pdf")
Membership can inspect query-enabled facts from all three origins:
EDB, POLICY_FACT and IDB. Native result enumeration has a different
scope: it lists derived IDB facts, subject to the same observation checks.
Enumeration is not a wildcard membership query or a listing of all base facts.
Public Query Whitelist
The domain must grant a predicate the QUERY permission.
For manifest-loaded policies, the manifest's queries field adds a
second restriction: only listed predicates may be publicly inspected.
{
"queries": [
{ "name": "allow", "arity": 2 }
]
}| Predicate | Outcome |
|---|---|
allow/2, declared query-enabled and listed above | Observation permitted. |
debug/2, not listed | Observation refused, even if facts were derived for it. |
An empty or omitted queries list exposes no predicates through this gate.
The whitelist restricts observation, not computation: other predicates
may still be evaluated and used to derive allow/2.
Inline loading — no whitelist
Inline loading has no manifest whitelist. All predicates granted QUERY
by the selected domain can be inspected. This is also the typed WASM
wrapper's loading model; see its query reference.
Why-true and Why-false
After a successful membership query, an explanation can describe one retained witness for a present derived fact or the bounded obstacles for an absent fact. It never replaces the membership answer. See Explanations for what these two kinds of evidence promise.
Explanation memory and explanation limits
Caller-provided storage and session workspace manage the same explanation machinery; more memory does not enlarge its exploration limits. A truncated document, insufficient workspace and a short output buffer are different outcomes. See bounded, truncated, or failed explanations and the C querying guide.
What you have learned
KEEP THIS MODEL
Decide from membership, explain afterward- Ask about one concrete fact
Query one fully specified fact after a successful solve.
- Respect the observation boundary
Observe only predicates allowed by the domain and, for a manifest, its whitelist.
- An error is not an absent fact
Keep errors distinct from an ordinary absent fact.
- Explanations describe the answer
Use the Explanations concept page to interpret a witness or bounded refutation; never authorize from explanation text alone.
- Release in ownership order
Release explanation handles, then the result, when finished.