Showcase: ReBAC Authorization (Zanzibar)
The impulse-authz showcase models enterprise hierarchical permissions (users, groups, roles, datasets) and demonstrates how Impulse Graph powers sub-microsecond, fine-grained Relationship-Based Access Control (ReBAC)—modeled after Google's Zanzibar architecture—directly inside your application process.
1. The Real-World Problem
In modern enterprise software, permissions aren't just simple role strings—they form a deep hierarchy of relationships:
- A
Userbelongs to aGroup(which may be nested inside parentGroups). - A
Groupis assigned aRole. - A
RolegrantsPermissionover aFolderorResource(which itself has childDocuments).
Answering "Can User \(U\) edit Document \(D\)?"—or worse, "Which of these 10,000 search results is User \(U\) allowed to see?"—requires walking a multi-hop graph on every single API request. Traditional SQL recursive CTEs or external authorization microservices add milliseconds of network and join latency to every call.
2. How Impulse Graph Solves It
Because authorization policies are read-heavy and change at a human/administrative cadence, they fit Impulse Graph's "mmap and go" model naturally:
- Multi-Domain Set Traversal: Starting from a
User, the query steps acrossMEMBER_OF(with transitive group nesting viarepeatUntilStable),HAS_ROLE, andGRANTS_ACCESS_TOto reach theResourcedomain. - Set Semantics Eliminate Redundant Paths: If a user belongs to 5 overlapping groups that all grant access to the same parent folder, Impulse collapses those converging paths into a single bit at each step—never walking the folder's children multiple times.
- Zero-Allocation Early Exit & Point Tests: When an intermediate frontier empties (e.g. a user belongs to no groups granting access), the VM halts immediately (
FLAG_HALT_ON_EMPTY). Single-resource access is verified via an \(O(1)\) bit test over the resulting off-heap BitSet (toBitSet().get((int) targetDenseId)) without heap allocations.
Benchmark Context
Sub-microsecond query latencies (0.026 µs – 0.552 µs) were measured in empirical microbenchmarks (JsonVsCsrBenchmarkRunner) evaluating multi-hop CSR traversals over a simulated directory corpus of 600,000 users with realistic group/role hierarchies (compared directly against Jackson JSON serialization cost).
// 1. Check if 'usr_alice' has transitive access to 'doc_quarterly_report'
long targetDocId = snap.domain("Resource").toDenseId("doc_quarterly_report");
boolean isAllowed = snap.domain("User")
.fromKey("usr_alice")
// Walk direct and nested group memberships until fixed-point
.out("MEMBER_OF")
.repeatUntilStable("PARENT_GROUP")
.out("HAS_ROLE")
.out("GRANTS_ACCESS_TO")
.toBitSet()
.get((int) targetDocId);
// 2. Or retrieve the full BitSet of all accessible resources in one pass
// to filter a search result list in-process in nanoseconds:
ImpulseBitSet accessibleResources = snap.domain("User")
.fromKey("usr_alice")
.out("MEMBER_OF")
.repeatUntilStable("PARENT_GROUP")
.out("HAS_ROLE")
.out("GRANTS_ACCESS_TO")
.toBitSet();
3. Keeping Permissions Fresh: Periodic Rebuild & Atomic Swap
How do permission changes propagate without introducing reader locks?
- Administrative permission updates write to your system-of-record database (e.g., PostgreSQL).
- A background worker periodically compiles a fresh
.impsauthorization snapshot in seconds from your primary database (e.g. via JDBC or CDC Kafka stream) and publishes it to blob storage or local NVMe. - Application pods
mmapthe new.impsfile in< 1 msand perform a zero-downtime Blue/Green atomic pointer swap (see Changing Data & Live Updates). Active API requests continue running with zero locks and zero GC pauses.