Mutation Execution
Client mutation pipeline, including capability sanitization and optimistic injection.
Overview
When you call table.mutate(...) (or table convenience methods like trash, archive, share), the client runs a mutation pipeline with hooks, codecs, offline routing, and event emission.
Execution Flow
- Validate/enrich metadata -- normalize context and mutation shape.
- Run
beforeMutationhooks -- fail-closed. - Apply outbound date codec -- date fields serialized consistently.
- Sanitize readonly capability fields -- strips server-owned fields from outbound payloads.
- Route execution:
- local-first/offline path when hydration and storage conditions are met,
- remote mutation call otherwise.
- Optimistic capability injection (local paths) -- inject lifecycle values for enabled capabilities to keep local state coherent.
- Run
afterMutationhooks -- fail-open. - Emit events --
mutation_appliedormutation_rejected.
Capability-Specific Client Behavior
Outbound stripping
For capability-enabled resources, client transport/changelog payloads strip readonly fields such as:
createdAt,updatedAtcreatedBy,updatedBytrashedAt,trashedBy
Optimistic record enrichment
On local-first/offline writes, optimistic records are enriched with capability values:
- insert: create + update lifecycle fields
- merge/replace: update lifecycle fields
This is local UX behavior; server still remains source of truth.
Debouncing
Only merge mutations are debounced. Debounced entries update local storage immediately, then append coalesced changelog entries when the debounce window flushes.
Offline and Remote Routing
When remote transport fails with a recognized transport error and storage is configured, mutations are handled through the offline queue path and scheduled for push.