You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `query` package implements SpiceDB's query plan system for evaluating permissions and relationships. It provides a tree-based iterator architecture for efficient graph traversal and permission checking.
4
+
5
+
## Overview
6
+
7
+
Query plans are built from schema definitions and executed to answer three fundamental questions:
8
+
9
+
1.**Check**: Does a specific subject have access to a resource?
10
+
2.**IterSubjects**: Which subjects have access to a given resource?
11
+
3.**IterResources**: Which resources can a given subject access?
12
+
13
+
Each iterator in the tree implements these three methods, allowing complex permission queries to be evaluated by composing simple operations.
14
+
15
+
## Iterator Types
16
+
17
+
Iterators are organized into several categories based on their role in the query plan:
18
+
19
+
| Iterator | Description |
20
+
|----------|-------------|
21
+
|**LEAF ITERATORS**|**Data source iterators with no subiterators**|
22
+
| DatastoreIterator | Queries the datastore for stored relationships. The fundamental data source for all queries. |
23
+
| FixedIterator | Contains pre-computed paths. Used in testing and as frontier in recursive queries. |
24
+
| SelfIterator | Produces reflexive relations (object→object). Used for `self` keyword checks. |
25
+
| RecursiveSentinelIterator | Placeholder marking recursion points during tree construction. Replaced at runtime. |
26
+
|||
27
+
|**UNARY ITERATORS**|**Wrap a single child iterator**|
28
+
| AliasIterator | Rewrites the relation field of paths. Maps computed permissions to their defining relation. |
29
+
|||
30
+
|**BINARY ITERATORS**|**Combine two child iterators**|
31
+
| ArrowIterator | Graph walk operator (`→`). Chains two iterators for path composition. |
32
+
| IntersectionArrowIterator | Conditional intersection. Implements `all()` semantics - ALL left subjects must satisfy right. |
33
+
| ExclusionIterator | Set difference (`-`). Removes excluded paths from main set. |
Results are returned as `PathSeq` (Go 1.23 iterators - `iter.Seq2[Path, error]`), allowing lazy evaluation and streaming of results without materializing entire result sets in memory.
74
+
75
+
### Context
76
+
77
+
The `Context` type carries execution state including:
0 commit comments