Guard / How Guard works
Where the boundary sits: authority vs. validity, and limits
Two boundaries keep this model sound:
- Authority never excuses an invalid row, and a valid row never grants access. Guards are alternatives (
[G.isAssignee, G.isAdmin]) that change whenever roles change, while invariants hold for everyone, admins included. That is whyLaws.checkreads only your writes and Entity invariants — never your Guards, not evenalways— and why refusals stay distinct:Forbidden(not allowed),Unmet(precondition not met), andInvalid(result breaks an invariant). - Runtime guards check one request; intervals track one variable at a time. Running a guard guarantees that this request obeyed the rules, not that every future input will. Likewise,
Laws.check's interval pass tracks each number independently, so awhencomparing two unknowns (such asamount <= balance) reportsUndecidedinstead of guessing, leaving relational rules to runtime checks, multi-step tests, or an external solver.
Where to go next
- Wire sign-in to a guard set: read Auth and Guard.
- Decide whether a rule belongs in a Schema, an invariant, a
when, or a Guard: read Laws: where a rule goes. - Look up every Guard option and server adapter: read the
foldkit-guardREADME.