RolebookDocs

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

InputLimit
Resource types1 to 128
Roles1 to 128
Actions per resource type1 to 128
Parent chain above a resource type16
Direct rules per role256
Direct rules in the policy4,096
Effective rules per role (own and inherited)4,096
Effective rules summed over all roles16,384
Field patterns per rule1 to 64
Condition nodes per rule / condition depth256 / 16
Policy names (types, actions, roles, fact and field segments)1 to 128 characters
version label1 to 512 characters
Policy snapshot: values / array entries / object keys / depth32,768 / 4,096 / 129 / 54

Bindings and requests

InputLimit
Assignments in one binding256
Group principals in one binding (MAX_PRINCIPALS)64
Assignment snapshot: values / array entries / object keys / depth4,096 / 256 / 64 / 16
Subject, context, resource, and literal snapshots: values / array entries / object keys / depth1,024 / 128 / 64 / 16
String values512 characters
Subject and resource IDs1 to 128 characters
Request permission257 characters
Requested field: length / segments512 characters / 16
Fact path segments after the root16
Resource ancestry entries16
Explanation trace entries64; traceTruncated reports the rest
Condition-tree nodes in a { detail: "conditions" } explanation256 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.