SpiceDB Consistency Modes: Match Freshness to Each Permission Check
SpiceDB lets each permission check choose its own consistency mode so you can balance staleness, latency, and load.
09 Jul 2026, 11:40 UTC

You revoked access, but the user still has it
Imagine you delete a relationship tuple that grants a contractor access to a project folder. Seconds later, the contractor opens the folder and it still loads. SpiceDB accepted your delete, but the permission check that ran a moment afterward answered from a replica that had not yet seen the change.
This is the core tension in distributed authorization: speed versus freshness. SpiceDB lets every CheckPermission, Expand, and Lookup request choose its own consistency mode. You do not have to force every check to wait for global agreement, nor do you have to accept stale answers everywhere.
The three consistency modes
A relationship tuple is SpiceDB's unit of permission: it records that a subject has a relation to a resource, such as user:alice#editor on document:proj-42. A consistency mode tells SpiceDB how up-to-date its data must be before it answers your check.
| Mode | What it waits for | Best for |
|---|---|---|
FullyConsistent | The latest committed write is visible before answering. | Revoking access, admin actions, security-critical checks. |
AtLeastAsFresh | A freshness point you supply, often a replication token. | Checks immediately after your own write, when you can track the token. |
Eventual | Nothing; reads from the nearest available replica or cache. | UI menus, dashboards, non-blocking previews where brief staleness is acceptable. |
Worked example: checking a document edit after a revoke
Suppose your API revokes an editor by deleting a tuple, then immediately renders the document page. If the page calls CheckPermission with Eventual, the answer can still say MEMBER because the replica has not converged.
Here is the decision pattern in pseudocode. Exact field names and enum spelling vary by SpiceDB version, so check your generated client or API reference before copying.
// Pseudocode; adapt to your SpiceDB client version
func canEdit(client, docID, userID, justRevoked bool) (bool, error) {
req := &CheckPermissionRequest{
Resource: &ObjectReference{ObjectType: "document", ObjectId: docID},
Permission: "edit",
Subject: &ObjectReference{ObjectType: "user", ObjectId: userID},
}
if justRevoked {
req.Consistency = &Consistency{Mode: Consistency_FullyConsistent}
} else {
req.Consistency = &Consistency{Mode: Consistency_Eventual}
}
return client.CheckPermission(ctx, req)
}
Run this where your application calls SpiceDB, typically in authorization middleware or the service layer. You need network access to the SpiceDB cluster and valid credentials. The risk of FullyConsistent is higher latency and more load on the underlying datastore because the check must synchronize before replying. The risk of Eventual is a stale allow or deny immediately after a tuple write.
Using AtLeastAsFresh safely
AtLeastAsFresh lets you bound staleness relative to a known event instead of waiting for every replica. You pass a freshness token captured from a previous write or watch. This mode only helps if callers reliably track and pass valid tokens; missing or malformed tokens weaken the guarantee.
Practical check: after writing a tuple, capture the response token, pass it to the next CheckPermission call, and confirm the new relationship is reflected. If your client library does not expose the token, fall back to FullyConsistent for post-write checks until you can propagate tokens.
Limitations and how to verify
- Exact enum names, default consistency, and token formats differ across SpiceDB versions and between single-node and clustered dispatch deployments.
Eventualcan return stale decisions immediately after a tuple is created or deleted, which breaks fast-moving security flows such as instant revocation.FullyConsistentincreases p99 latency and datastore pressure under heavy write traffic.
Verify in staging, not production. Write a relationship tuple, immediately call CheckPermission with FullyConsistent and then with Eventual, and compare whether the new tuple appears in each response. Measure p99 latency and error rates for each mode under realistic write load before changing defaults in production. If Eventual returns the old answer while FullyConsistent returns the new one, you have confirmed the staleness window for your cluster topology.
Closing
Treat consistency as a per-request setting, not a deployment-wide default. Use FullyConsistent for revocations and security boundaries, Eventual for casual reads, and AtLeastAsFresh only when your callers can carry freshness tokens reliably. Check your SpiceDB version's API reference, run the staging comparison above, and ship the mode that matches each operation's tolerance for staleness.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.