Saara · Architecture note

The ledger can't conflict.

How Saara syncs across every device with no server in the middle — and why the math guarantees it agrees.

merge = A ∪ B  ·  A ∪ B = B ∪ A  ·  (A ∪ B) ∪ C = A ∪ (B ∪ C)  ·  A ∪ A = A
The one-line idea

A bag of unique facts that only grows

The ledger is a bag of facts you can only ever add to. Syncing is pouring two bags together and keeping one of each. Pour in any order, as many times as you like — you always end up with the same bag. No server decides who wins. Convergence is math, not coordination.

Definition

What a CRDT is

CRDT — Conflict-free Replicated Data Type. A data structure built so independent copies on different devices can be edited offline and then merged automatically, with no coordinator, always landing on the same result. No locks, no central authority picking a winner, no manual merge conflict.

The simplest CRDT

Grow-only set (G-Set)

A set you can only add to, never remove. Merging two replicas is just their union — every element either side has seen. Union works flawlessly because of three algebraic properties:

A ∪ B = B ∪ A
Commutative
Sync order doesn't matter.
(A∪B)∪C
Associative
Any grouping of syncs is fine.
A ∪ A = A
Idempotent
Re-syncing changes nothing.

Any set of devices, merging in any order, any number of times → the same final set. That is the whole reason no server is needed.

See it converge

Two devices, any order, same result

Each device holds some events. They overlap on e2. Merge them in whichever order you like — both bags end up identical, and merging again does nothing.

Device A3 facts
Device B2 facts
Two devices, different bags. Sync either way to see them agree.
The real design

Saara is two CRDTs, stacked

● preserves

The ledger → a G-Set

Every TaskTransition has a unique id. Merge = insert the entries you don't already hold. It can never conflict and never loses an event. Your reliability score is a fold over this ledger — so every device that merged the same events computes the same numbers.

▲ resolves

The row state → an LWW-Register

The current row values (title, area, due date) use last-writer-wins by updatedAt. Also a CRDT — always agrees — but lossy: two devices editing the same field concurrently keep only the newer edit.

// ledger, append-only — the whole reason merging can't conflict
if (!await _exists(db.taskTransitions, e.id)) {
  await db.into(db.taskTransitions).insert(e);
}

Net effect: history + score are never lost (G-Set); field values always agree but a simultaneous same-field edit can drop the loser (LWW). Not a bug — two CRDT semantics doing their different jobs.

Beyond two devices

Events gossip transitively

The transport (Wi-Fi QR sync) is pairwise — two devices at a time. But each device exports the entire ledger it holds, including events it learned from others. So facts spread across the whole fleet:

Laptop 1Mobile 1Mobile 1 now holds Laptop 1's events
Mobile 1Laptop 2Laptop 2 gets Laptop 1's events too
Laptop 2Mobile 2Mobile 2 now holds everything

You don't need to pair every device with every other — just enough sync paths that events can reach everyone.

Portability & the honest edge

The ledger is its own backup

Switching devices isn't a "restore" — a new device just merges the ledger and folds the same history into the same state.

Because there's no server, the safety net is only as fresh as your last sync or export. A device lost or wiped before syncing its newest events has no cloud copy to fall back on.

The escape hatch is already built: the encrypted export file is a full ledger snapshot — drop one into a folder or share it to yourself for a portable, restore-anywhere backstop, without reintroducing a server.

Where it could go

Serverless invites — blockchain's good half, not the chain

Sharing an invite is just emitting a signed ledger event and getting it into another user's ledger. "Blockchain" bundles three things; Saara wants only two:

The real constraint is transport, not trust. An invite-as-signed-blob over any channel (WhatsApp, Signal, email) is truly serverless. Only live device-to-device over the internet hits NAT/firewalls and needs a minimal, blind rendezvous that sees only ciphertext.

The special part: signed events let a person carry a portable, verifiable reliability record — proof they kept their word that no server owns and no one can forge. Self-sovereign reputation — the teeth behind P-Integrity's "others own the mirror."

TL;DR
  • CRDT = merge without coordination, always converges.
  • G-Set = add-only set, merge = union (commutative · associative · idempotent).
  • Saara's ledger is a G-Set → never conflicts, never loses history or scores.
  • Saara's row state is an LWW-Register → always agrees, may drop a concurrent field edit.
  • N devices converge; events gossip transitively over pairwise syncs.
  • Backup = "as good as your last sync/export"; the ledger is its own backup.