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:
- Application transitions travel from a user click, AI agent call, Behavior, or Command through a
Messageintoupdate, which returns the nextModelviamodifyFields. - 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, orWritableProjection.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
| Situation | Owner | Change mechanism |
|---|---|---|
| Local UI or domain state | Application | Message → update → modifyFields |
| Child Submodel state | Submodel | Child Message → child update → modifyFields |
| Server data | Server | Remote Message → Data.reduce |
| Replicated user operation | Application + durable log | Message → update → modifyFields |
| Sync checkpoint | Authoritative replica | WritableProjection.set |
| URL or storage restoration | Local application | Mirror → WritableProjection.set |
| AI agent action | Application | Agent → Message → update |
| UI widget behavior | Application | Behavior → Message → update |