Learn / Events, folds and gates

Message allowlists, authorization rules, and laws

Declaring a MessageSet restricts which kinds of change a caller can ask for:

  • A Sync replica rejects any Message outside durable.
  • An AI agent can send only the Messages exposed in its capability set (Agents).
  • A client cannot originate a Message marked serverOnly.

If your union contains no Message that deletes an audit record, neither a view nor an agent can delete one. The only bypass is structural installation (checkpoints or URL restoration) through declared infrastructure seams; see the two write paths.

An allowlist alone still lets invalid states pass. Decide between authorize and laws (or Entity.invariant for Remote rows) by what they check:

  • authorize checks one Message before it runs. A durable Message with no entry in authorize passes authorization by default. Whenever you add a new durable Message, check whether existing authorize rules should apply to it too.
  • laws check every Message after it runs. Because atMost100Todos inspects after.todos.length, adding an ImportedTodos Message later is automatically held to the 100-item cap.
  • Entity.invariant checks every row write. On database-backed Entities, invariants run on every Write regardless of which mutation triggered it; see What every row holds.

Rules run once at admission

A Message is checked when the server admits it to the journal. Once committed, it is a historical fact:

  • Replicas never re-run authorize during replay.
  • Tightening an authorize rule or law later applies to new submissions without invalidating past snapshots.
  • On database rows, an existing row that predates a new invariant is judged by the row the next write leaves behind, allowing a repair write to succeed.