teams starter.
bijection/tenants.ts
ctx.register(tenants), see
System tables), so nothing is reserved for members
that are not registered. Registration mints the member’s random, opaque tag.
A founding runs at the public label and registers the member in its own
step. It needs the register right for the family from both the caller and
the code: the caller holds it through a role’s register: [tenants] or a
class grant the app declares
(app(tree, { classes: { signedIn: { register: [tenants] } } })), and the
code through the founding mutation’s register: [tenants] (see
Found a family member). Set
{ members: n } only to cap how many are registered at once, charged at the
public label.
Roles clear every member, and a grant of a role is held under one member
(see Grants):
bijection/roles.ts
Register and look up a member
Withkeyed: true, ctx.register(tenants, { key }) associates a business key
with a random member tag. A fresh registration validates the key and refuses
Exists if a live member already holds it. Erasing that member frees the key
for a fresh registration, which mints a new tag.
While its receipt is retained, a retry of the same registration occurrence
returns the original tag, even after erasure or reassignment of the key.
The receipt ignores the supplied business-key value and carries no information
about current membership. This also applies to registrations made without a key.
A new occurrence or an absent receipt follows the fresh registration path.
If a decision depends on who currently holds a business key, base it on
await ctx.get(sys.members({ family: tenants, key })) in the live world. A
keyed family declares presence: "public", so whether a key is taken is a
public fact. The lookup returns the live member’s fact
or null when the key is absent. For a write that depends on the lookup, read it
in the same mutation so the decision carries the read dependency.
Declare the table
bijection/tasks.ts
label: tenants.and(other) keeps each fact at its member joined with another
label.
Write functions under the member
A function withunder: tenants runs under the caller’s member. The caller
chooses it with client.under(tenants.of(organization)), and the frame
clears it only through a grant of the member. Every read and write then
addresses the member’s partition. Here organization is the opaque ID
suffix of the member tag returned by registration or lookup.
Another member’s partition
table.of(member) addresses one member’s partition instead of the frame’s.
A read through it needs a frame that clears that member. A blind write
(put, retract, or insert into a minted table) needs only that the
frame’s label flows to the member’s, so a lower frame can write up into a
member without reading anything there.
on: tasks.of(tenants.of(organization)).changes.
Membership
members({ roles, under: tenants }) from @bijectionhq/library-members is a
subtree of membership functions; with under, the functions that issue roles run
under one member, and accept runs at the public label.
bijection/team.ts
bijection/app.ts
Erasing a member
ctx.erase(tenants.of(organization)) destroys the member’s unit and makes the
facts and values under its label unreadable in every version. See
History and lifetime.