Concepts
Explanations
Read a witness or a bounded refutation after a successful membership answer.An explanation helps an application describe a decision it has already obtained from a successful membership query. Why-true and Why-false read the solved state; they do not solve the policy again or change its facts.
Why explanations exist
A membership answer says whether one concrete fact is present. An explanation gives a reader or an application evidence about that answer: a retained derivation for a derived fact, or obstacles encountered while exploring why a fact is absent.
Explanation text may contain exact policy and request values. Treat those values as sensitive when displaying, storing or transmitting a document.
Where they fit
First solve successfully, then obtain a successful membership answer. Choose the matching explanation afterward; an API error is not an absent fact, and explanation text is never a substitute for the authorization decision.
- Why-trueone retained derivation
- Why-falsebounded failed-branch diagnostics
The explanation reads the immutable final policy-fact, EDB and IDB state. It never derives a new fact or changes the retained Why-true witness.
Why-true: one witness
Why-true answers an existential question: at least one derivation exists, so one retained witness is enough. It shows rules, premises and their origins for that witness, not every possible derivation.
A present base fact need not have a derived witness: Why-true can report not-derived. That does not make the fact false. An aggregate premise records the observed group and aggregate value; it does not expand into a derivation for every member of the relation.
Why-false: a bounded refutation
Why-false is not the mirror of Why-true. Its natural question is universal: every candidate rule and substitution would have to fail. Its evidence therefore has the shape of failed branches rather than one successful path, but the engine explores and retains that evidence within fixed bounds.
Each retained diagnostic records the positive supports already found and the first obstacle preventing that branch from deriving its target. A missing positive fact, a contradicted negation, a false comparison or a failed filter describe different obstacles. Asking Why-false about a present fact reports not-applicable.
The exploration is bounded, not an exhaustive proof of every possible failed derivation. For concrete documents, statuses and obstacle names, use the explanation document reference. The quickstart shows allowed and blocked requests; the Structured explanations guide reads the evidence as data.
Bounded, truncated, or failed
Both explanation kinds can successfully return a document marked truncated. Why-true then emits no partial witness steps; Why-false can retain partial diagnostics and names the bounds it hit. Neither changes the solved membership answer.
A truncated document is different from PAYLOAD_TOO_LARGE, which rejects an undersized output text buffer without writing a partial document. Insufficient preparation workspace is a separate storage error. Allocating more text storage cannot increase the exploration limits.
Caller-owned storage and optional session workspace are two memory-management paths to the same explanation machinery. For preparation, leases, cache lifetime and fixed application buffers, see the C querying guide. Python prepares the native explanation and returns its document as a string; Python objects and conversions still allocate.
What an explanation promises, and what it does not
The public contract defines the MAELYS-DATALOG-v2 envelope, its document kind, statuses and canonical records. Explanation calls read the retained solved state; they do not derive facts. A backend must expose the required capability, and a missing capability is UNSUPPORTED.
complete means the bounded explanation finished without a reported limit hit. It is not a formal proof of absence. An absent fact is absent from the least model for the exact loaded policy and runtime inputs, not established as false in the outside world.
Canonical ordering makes document identity independent of optimizer execution order: diagnostics retain original body indices and are ordered by rule, substitution and obstacle identity. When diagnostic storage is bounded, the canonical top-k is retained rather than an arbitrary execution prefix. Canonical bytes are not an engine signature and do not authenticate their own provenance.
The backend's exploration bounds may change with the engine; applications cannot assume every backend offers the same explanation capabilities. A Why-false diagnostic does not compute a minimal repair or tell an application which permission to grant. Persisted evidence should preserve the engine and policy identities used to obtain it.
What you have learned
KEEP THIS MODEL
Decide first, explain the answer afterward- Membership supplies the decision
Explain only after a successful solve and membership query; an error is not absence.
- The evidence has two different shapes
Why-true retains one witness; Why-false explores failed branches within bounds.
- Keep the outcomes distinct
A truncated document, a short output buffer and an API failure are different results.
- Stay within the promise
Complete bounded diagnostics are not a formal absence proof or a statement about the outside world.