Skip to content

WriteMode

WriteMode = "optimistic" | "pessimistic"

Defined in: packages/contracts/src/config.ts:93

Write-mode (ADR-0022): how a write reaches the server — the write-side twin of Retention.

  • optimistic (default) — the write enters the local journal with an optimistic overlay, the UI updates immediately, and the convergence loop flushes the journal as one all-or-nothing batch; the canonical row returns via the sync echo. The path that has always existed.
  • pessimistic — the write is server-authoritative: it flush-routes to an authoritative endpoint that applies it in its own isolated, serialised transaction and returns a per-mutation result (accepted, or rejected-with-typed-reason) before the UI shows success. For invariants the client cannot evaluate locally — a capacity/quota/uniqueness gate enforced by a server-side rule.

Write-mode is a property of an atomic write-unit, not a single table (ADR-0022 §1): a unit is uniformly one mode. The static write-unit is the consistency group — so, like SubscriptionTiming and Retention, every table sharing a consistencyGroup must agree (validated). A dynamic override is the imperative transaction({ mode }) block, which scopes a mode to an ad-hoc set of mutations.