Learn / Who changes state

The two write paths

Every change to your Model takes one of two paths depending on whether it is a domain transition or an infrastructure installation:

  1. Application transitions travel from a user click, AI agent call, Behavior, or Command through a Message into update, which returns the next Model via modifyFields.
  2. Infrastructure installations write an already-derived snapshot (a Sync checkpoint, a restored URL slice from Mirror, a Remote cache update, or SSR state) through a structural seam: ModelRef.set, ModelRef.modify, or WritableProjection.set.

ModelRef.modify is a convenience wrapper around ModelRef.set(f(get)) so container-aware .at and .index updates keep working. Never call ModelRef.set or WritableProjection.set from application click handlers or components to shortcut a Message — doing so bypasses update, breaks replay, and hides state changes from subscribers.

Who owns each kind of change

SituationOwnerChange mechanism
Local UI or domain stateApplicationMessage → update → modifyFields
Child Submodel stateSubmodelChild Message → child update → modifyFields
Server dataServerRemote Message → Data.reduce
Replicated user operationApplication + durable logMessage → update → modifyFields
Sync checkpointAuthoritative replicaWritableProjection.set
URL or storage restorationLocal applicationMirror → WritableProjection.set
AI agent actionApplicationAgent → Message → update
UI widget behaviorApplicationBehavior → Message → update