Limits
The hard bounds that keep policy compilation and evaluation finite.
Rolebook bounds every input, so policy compilation and every check finish in bounded time and memory.
Inputs beyond these limits deny at binding or check time. Invalid policy data, including a policy over
a limit, fails definePolicy() with an Error instead.
Policy
| Input | Limit |
|---|---|
| Resource types | 1 to 128 |
| Roles | 1 to 128 |
| Actions per resource type | 1 to 128 |
| Parent chain above a resource type | 16 |
| Direct rules per role | 256 |
| Direct rules in the policy | 4,096 |
| Effective rules per role (own and inherited) | 4,096 |
| Effective rules summed over all roles | 16,384 |
| Field patterns per rule | 1 to 64 |
| Condition nodes per rule / condition depth | 256 / 16 |
| Policy names (types, actions, roles, fact and field segments) | 1 to 128 characters |
version label | 1 to 512 characters |
| Policy snapshot: values / array entries / object keys / depth | 32,768 / 4,096 / 129 / 54 |
Bindings and requests
| Input | Limit |
|---|---|
| Assignments in one binding | 256 |
Group principals in one binding (MAX_PRINCIPALS) | 64 |
| Assignment snapshot: values / array entries / object keys / depth | 4,096 / 256 / 64 / 16 |
| Subject, context, resource, and literal snapshots: values / array entries / object keys / depth | 1,024 / 128 / 64 / 16 |
| String values | 512 characters |
| Subject and resource IDs | 1 to 128 characters |
| Request permission | 257 characters |
| Requested field: length / segments | 512 characters / 16 |
| Fact path segments after the root | 16 |
| Resource ancestry entries | 16 |
| Explanation trace entries | 64; traceTruncated reports the rest |
Condition-tree nodes in a { detail: "conditions" } explanation | 256 shared by the rules that do not decide the request, plus the deciding rule’s whole tree (512 at most); conditionTraceTruncated reports a tree it shortened |
A request permission that is not a string, or is longer than 257 characters, is reported as an empty
permission on the denial, so decisions never echo unbounded caller input into logs or responses.
Keys and values inside snapshots
Every object key in subject attributes, resource attributes, context, and nested literal values follows
the policy-name grammar: it starts with an ASCII letter and continues with
letters, digits, ., _, or -, up to 128 characters. Any other key denies the whole binding or
request (INVALID_SUBJECT, INVALID_REQUEST, or RESOURCE_MISMATCH), and trustedResource() throws
on one. Values must be JSON-like: strings, finite numbers, booleans, null, plain objects, and dense
arrays.
That means a database row passed through as attributes can deny for reasons that look like
authorization bugs: a key such as _id, $ref, first name, or a non-ASCII name; a Date object
(pass a number or an ISO string); a string over 512 characters, such as a description; more than 64
keys; or an undefined from a nullable column. Map the row to the few facts the policy reads instead.
Sharing packages
The sharing packages add their own bounds, listed with each API: for example 200 resources per
readAccessBatch(), 256 candidate hints, 100 items per listing or audit page, 64 groups per subject,
32 custom roles per tenant, and a 1 MiB policy document. See the
@rolebook/sharing API.
Boundary and adversarial tests for the core limits live in tests/v4-limits-and-closure.test.ts in the
repository.