anyone and signedIn reach. Nothing is admitted
without one.
A right is one verb over one object at one scope: enter(f) enters a
function, clear(l) reads and commits under a label, issue issues grants,
and read, write, release, revoke, erase and hold work the same
way. The scope is the member the grant holds under, so a grant under
tenant.of("acme") enters, clears and issues only in acme.
A role is a named bundle of rights. A grant carries its role’s name, so a
guard can ask which role an act came through
(a.offer.role).
Exposure: allow
bijection/orders.ts
allow: [roles]declares the entry right: each listed role carriesenterof the function. A function withallowis exposed at its tree path. Withoutallowit is internal.allow: []is refused: leaveallowout instead.role.anyonenames every principal, androle.signedInevery authenticated person.allow: [role.anyone]declares a class grant that the program issues at install and the lock prints; it clears no label above public, so an entry it opens runs at the public label. Nothing is ambient. See Open entries.bijection check --write-lockwrites every role, with the functions it enters and the labels it clears, and every class grant tobijection.lock. Review that diff whenever exposure changes.
Declare roles
bijection/access.ts
A role takes no name: its name is its path (
access.clerk). check reports
AllowBelowLabel when a role in allow does not clear the function’s
under.
Two grants cover together
An act is covered when the caller’s surviving grants, together, hold every right it needs. A person who holdsclerk and financeView as two grants can
call a function that needs both, exactly as if one grant held both:
coverAlone rule
from the guard library to it.
Your code is covered the same way: the function needs its entry, the
clearances of its label, and the reads, writes and releases it performs. The
frame’s clearance is the set of labels that both the caller’s grants and the
code’s grants clear.
Grant and revoke
ctx.grant and ctx.revoke are grave acts: each is named in the code,
listed by bijection check for the function that does it, and the only way
sys.grants changes.
bijection/team.ts
ctx.grant(role, { to, under, until?, from?, only? })issues a new grant of the role totoat the mutation’s exact commit label. It returns the grant’s point,sys.grants(id). Delegations and invitations use the same issue rule. Founding issues the declared founder grant at the fresh member during registration.tois a principal, an agent (agent:…), an invitation bearer (sys.grants.invitation({ token })).fromnames the parent: a grant the frame holds. Without it the host picks one of the issuer’s surviving grants.onlyis the new grant’s entire right set, keyed by verb. For example,only: { enter: [move] }grants entry tomovealone. List clearance inclearwhen the child needs it. Each listed right must be covered by the role, the parent and the code.
- A grant is issued from one parent: a live grant of the issuer that
survived the act’s guards. The parent must carry
issuefor the role at every scope the new grant holds under, and must already hold every right the new grant carries. Nobody issues what they do not hold. - The new grant never goes to the issuer, to the person the issuer acts for, or to anyone on the call chain.
ctx.revoke(grant)ends that grant. Its holder may revoke it, and so may the holder of any grant up its chain. A selection,sys.grants.where({ label, role, holder })orsys.grants.where({ label, role, parent }), ends every live grant it names and refusesAbsentif none match. Useissuerin place ofroleto select an issuer’s trust grants.- A grant lives only while its parent lives. Revoking or expiring a grant ends every grant issued under it.
- When the observer label of the grant is below the frame, pass
{ release }as the last argument to issue or revoke it. The release belongs in the function’sreleases:declaration. - A principal is named by its
PrincipalId, the kind-qualified idctx.frame.as.idanswers:person:and a random ID the host keeps for each sign-in identity (never the provider’s subject).
{ id, holder, rights, parent, roleChain, label, expiresAtMs }:
idandparentare{ label, key }. The opaquekeynames the original issuance.holderis{ kind, id }, aprincipal, aclass(anyoneorsignedIn) or an invitationbearer;rightslists{ verb, object, scope };roleChainis the grant’s role path, then the roles of the grants it was issued from. A grant binds its role by name, so a release that replaces the role keeps the grant;labelis where the grant is observed, andexpiresAtMsits end (null until revoked).
sys.grants.mine() reads the caller’s own live grants from a function
under label.principals.
The six data writes refuse sys tables; only the grave acts change them.
Every issue and revocation is recorded in sys.grantTransitions with who did
it, whom they acted for, the call chain and the grants that admitted it. From
the terminal, call the mutation that performs the act:
act.grant(role) and act.revoke(role) can
refuse an issue or a revocation.
Revocation and expiry
A grant past itsuntil, revoked, or under a parent that is no longer live
admits nothing from then on. A revocation is an assertion, not a retraction:
it asserts the grant again with its until at the revoking instant, so the
grant’s history stays readable. Every decision reads the grants it used, so
revoking a grant conflicts with any transaction still deciding through it:
that transaction is decided again or refused. Work already committed is
decided again at each later step against the submitter’s live grants (see
How an act is decided). Revocation cannot recall data a
frame already read or a release already disclosed.
Session-bound roles
Break-glass access, or a role that needs a fresh second factor, is a short grant plus guards. A lead who holds the role issues a short grant of it to a colleague, and guards keep the grant short and the sign-in fresh:bijection/hr.ts
a.now is the host’s clock. freshMfa refuses acting as hr unless
a.mfaAge, the age in seconds of the caller’s last second factor read from
the verified credential, is at most ten minutes. The caller can supply
neither. breakGlass from the same library adds a stated reason
(library rules), and a guard can also read the
open incident (see fact reads).
Reactions hold roles
A reaction (a function withon:) runs as the installation. It declares the
roles it holds while it runs with roles: [...], and holds nothing else:
Invitations and delegation
@bijectionhq/library-members builds the two common ways to hand authority
on. Both issue grants with ctx.grant, under the same rules:
bijection/sharing.ts
- An invitation is a grant issued to a bearer. At the tenant member,
team.invite({ subject: null, role, email, until })creates a pending invitation and returns{ invitation, token }. The invitee callsteam.accept({ token })at public and reads the returned receipt withteam.acceptance({ receipt }). Members checks the verified email and redemption deadline at the exact tenant member, issues the child grant there and consumes the pending invitation. The inviter cannot redeem their own invitation. - Direct bearer redemption runs at the bearer’s exact label. Use
invitations().redeem({ grant, token })for public bearers or recipients who already clear that label. Use Members for tenant invitations that grant the invitee their first clearance there. - A delegation is a grant issued from one of your own grants to an agent
acting for you.
lend.delegate({ agent, role, until })lends one child of your surviving grant ofrole(one ofupTo), ending atuntil, and no later than the library’suntilfrom now. It keeps that grant’s role, dies with it, and every act the agent performs records you as the person it acts for. Your guards that read your holdings, such as separation of duties, apply to the agent too.lend.revoke({ grant })ends it.
ctx.grant(role, { to: agent, from: grant, under, until, only? }) issues one child of a grant you hold (it keeps that grant’s
role, dies with it, and the agent’s accountable principal is you); or place
delegation({ allow, upTo, until }) from @bijectionhq/library-members and
call its delegate({ agent, role, until? }).
allow names the roles that may call each library’s functions, as on
your own functions.
Membership directory
members({ roles, roster }) from @bijectionhq/library-members is the
membership library: who holds which of the app’s roles, and the functions to
invite and revoke them. It returns a subtree; place it in the tree.
A membership keeps its grants, directory and invitations at a protected
roster label that every managed role clears. The roster is one of the app’s own labels, often the one its
roles already clear. With under: family instead, each member of the family
keeps its own membership.
bijection/app.ts
allow over the managed roles, and
accept, acceptance, acceptPending and me declare allow: [role.signedIn],
a class grant. The roster or member’s
clearance still applies to me.
Unused arguments are
null. An invitation expires after seven days, or at
until if earlier. An invitation bound to an email needs the recipient’s
current sign-in to present the same
trusted verified email.
The invitation’s erasable fact keeps the email and bearer proof at its
roster or member. A declared release publishes the pending locator,
routing label, program issuer, role and deadline. The task compares the
requester’s verified email proof at that member before issuing a child
from the bearer grant. A second release delivers the result to the
requester’s own principal member. Tokenless lookup checks the caller’s
verified address against a protected keyed order. Each matching pending
invitation goes to its exact member, which checks the address and
deadline again. The discovery receipt never includes email or grant IDs.
The issuing program’s grant keeps the bearer invitation live. The
original inviter is accountable at the member and cannot accept their own
invitation. Revoking the bearer grant ends its redemptions.
team.erase({ invitation }) closes the invitation’s email and bearer proof
in every retained version of the fact. For a pending invitation it also
ends the grant and withdraws the public locator. Erasing the retained
versions of an accepted invitation leaves the accepter’s role in force.
With under: tenant (a family), the issuers’ functions (invite, pending,
revoke, erase, list) run under: tenant, the directory and invitations
are the caller’s member’s facts, and grants clear that member. The client picks the
member: client.under(tenant.of("acme")).
The member task issues the role, inserts the directory row and consumes
the invitation in one append. The membership end is independent of the
redemption deadline. With a family, me runs under the caller’s own
principal member and reads the caller’s grants.
Initial owner
Name the founder roles on your app, then name their recipient when you create the installation.bijection/install.ts
person:… ID
ctx.frame.as.id answers) for a direct grant. The lock lists the founder
roles (founders …).
Found a family member
Founding a member is theregister(family) right, held by both the caller
and the code. The caller holds it through a role’s register: [family], or
through a class grant the app declares; the code holds it through the
mutation’s own register: [family]:
classes: { signedIn: { register: [tenant] } } gives the signedIn class
grant the right to found tenant members; anyone takes the same shape.
A founding runs at the public label and registers the member in its own
step. The family’s founder role is then issued by the program’s grant to
the registrant under the new member, in the same commit, so it outlives the
registrant’s other grants and still records who registered. The lock prints
it as founder <family> -> <role> parent program:<app> at register.