{
  "docVersion": 1,
  "id": "blog-consistency-0001",
  "name": "Consistency models — one system, four contracts",
  "purpose": "A single-leader replicated store where each read path buys a different consistency model: leader reads are linearizable, follower reads eventual, session pinning gives read-your-writes, quorum reads make staleness tunable.",
  "nodes": {
    "writer": {
      "type": "user",
      "label": "Writer",
      "x": 20,
      "y": 60,
      "runtime": "PUT x=2"
    },
    "reader": {
      "type": "user",
      "label": "Reader",
      "x": 20,
      "y": 420,
      "runtime": "GET x — which x?"
    },
    "leader": {
      "type": "database",
      "label": "Leader",
      "x": 340,
      "y": 230,
      "color": "green",
      "runtime": "all writes land here",
      "notes": "The single source of truth. Reading here after acknowledgment is linearizable — you always see the newest write."
    },
    "f1": {
      "type": "database",
      "label": "Follower 1",
      "x": 700,
      "y": 60,
      "runtime": "lag: ~50ms",
      "color": "amber"
    },
    "f2": {
      "type": "database",
      "label": "Follower 2",
      "x": 700,
      "y": 420,
      "runtime": "lag: ~2s (rebooting)",
      "color": "red"
    }
  },
  "edges": {
    "w1": {
      "from": "writer",
      "to": "leader",
      "fromSide": "right",
      "toSide": "top",
      "label": "write x=2 · ack after commit",
      "animated": true
    },
    "r1": {
      "from": "leader",
      "to": "f1",
      "fromSide": "right",
      "toSide": "left",
      "label": "async replication",
      "style": "dashed"
    },
    "r2": {
      "from": "leader",
      "to": "f2",
      "fromSide": "right",
      "toSide": "left",
      "label": "async replication",
      "style": "dashed"
    },
    "read1": {
      "from": "reader",
      "to": "leader",
      "fromSide": "top",
      "toSide": "bottom",
      "label": "read @ leader → LINEARIZABLE",
      "color": "green"
    },
    "read2": {
      "from": "reader",
      "to": "f2",
      "fromSide": "right",
      "toSide": "left",
      "label": "read @ follower → EVENTUAL (may see x=1)",
      "color": "red",
      "style": "dashed"
    }
  },
  "boxes": {
    "b1": {
      "x": 300,
      "y": -20,
      "w": 560,
      "h": 620,
      "label": "one replica set — the model depends on WHERE you read",
      "color": "blue",
      "opacity": 0.04
    }
  },
  "texts": {
    "t1": {
      "x": 950,
      "y": 100,
      "text": "session guarantees (the practical middle):\nread-your-writes — pin the session to the\nleader (or a caught-up replica) after a write.\nmonotonic reads — never read a replica\nolder than one you already read.",
      "color": "purple",
      "size": 12
    },
    "t2": {
      "x": 950,
      "y": 330,
      "text": "tunable quorum (Dynamo-style):\nwith N=3 replicas, W writes + R reads,\nR + W > N ⇒ every read overlaps the\nnewest write. W=2, R=2 is the classic.",
      "color": "amber",
      "size": 12
    },
    "t3": {
      "x": 20,
      "y": 620,
      "text": "causal: 'reply visible before the question' never happens —\norder is preserved for related events, unrelated ones may interleave.",
      "color": "green",
      "size": 12
    }
  },
  "meta": {
    "createdAt": "2026-07-14T09:00:00.000Z",
    "modifiedAt": "2026-07-14T09:00:00.000Z"
  }
}