One tree names everything
app(tree) is the app’s one namespace. A name is a path in the tree:
orders.place is a function, orders.orders a table, access.clerk a role.
No declaration takes a string name. A library is a module or a function that
returns a subtree, and mounting a mountable app is calling it at a path. See
Components.
Facts live in tables
Every read and write names an address: a point such as
orders(id), or a
selection such as orders.where({ customer }).by("placed").first(20). Indexes
are declared, unnamed and matched by structure. Database covers
the declarations, the five reads and the six writes.
A feed that copies an external system’s records into a table makes the feed
that table’s writer. Your app keeps its own decisions in its own tables, beside
those observations, and a later sync does not overwrite them.
Integrations covers sources and feeds.
Labels decide who may know a fact
A label is an audience. A table’slabel labels its facts. A function runs
under one label: everything it reads must be cleared by its frame, and
everything it writes carries that label. A role clears labels, and a
principal holds a role through a grant. A function’s allow lists the roles
that may enter it from outside; without allow a function is internal.
A guard, declared with forbid, refuses acts that the roles would
otherwise allow, such as “no one approves their own expense”. Guards only
refuse. Data moves to a wider audience only through a declared release.
A mutation can use one with ctx.open(sealed, { release }). Access explains labels, roles,
grants and guards.
Functions are queries and mutations
A query reads and commits nothing, and a client can watch it. A mutation runs as one transaction under one label. A strict write such asctx.patch assumes the fact is present, and that
assumption joins the transaction’s read set: if another commit removed the fact,
the transaction refuses Absent. Blind writes, ctx.put and ctx.retract,
read nothing and never refuse; other readers see them exactly.
Every boundary answers a Result: { ok: true, value }, or
{ ok: false, code, message } with an app code from the function’s refuses
or one of the twelve host codes. See Errors.
Effects are tasks toward targets
A function cannot make network requests. A mutation reaches the outside world withctx.submit(target, args, { once, then }). The task commits with the
transaction’s writes, and the host performs it after the commit. once is the
identity of the effect: asking again with the same once returns the original
task. The task’s result is delivered to the continuation named by then.
A lost answer is the host code Unknown: it may have happened. On a call,
call again with the same once, and the host answers the original commit’s
result. On a task the result is final: the host never resends it, and the
same once returns the same settled task, so reconcile with the receiver
(reconciled(target) from @bijectionhq/library-recovery). A task performed by people is a
target with via: [roles], settled with ctx.answer. Standing sources such as
every, cron, route.post and selection.changes start reactions through a
mutation’s on. See Effects.
Grave acts change who can do what
A small set of named acts changes the host’s own facts insys: grant and
revoke, open(sealed, { release }), erase, branch, land and discard, pin and
unpin, and answer and withdraw. The six data writes cannot touch sys.
bijection check lists every function’s grave acts in bijection.lock, the
committed file that reviewers read to see what a deployment exposes.
Worlds hold alternatives
A function reads and writes at the head by default. A branch is a writable world over a version: changes made in it stay there untilctx.land applies
them to the head, or ctx.discard ends it. A trial runs a call in a
discarded world and reports what it would write, without committing anything.
See Branches.
Clients watch values
Useapi<typeof App>() for typed callable paths. Pass those refs to the
client returned by connect(url).