watershed Collaborative data structures for Gleam

← Sequences · SharedSequence

Stable identity
beneath every index.

An index only means something against one version of a list. SharedSequence gives every item a stable identity beneath its index: you say insert at 2 or move 4 to 1, but the delta that ships names the item, not the slot. Two surveyors can rearrange the same stretch of river at the same instant: moves follow their waypoint, concurrent inserts both land, and every replica converges on the same order. watershed’s sequence_kernel models that identity and converges.

A shared portage route, live

Three watershed documents share one SharedSequence, an ordered list of waypoints down a river. One client creates it and shares the handle; the others resolve it. They talk to one sluice, the in-memory server that ships in the library. It runs the production client runtime without a network backend. Local edits are drawn in magenta until the sluice stamps them; server-sequenced state is ink.

Select a station to move, rename, or delete it, or press + between stations to insert one. Then stage a race: Race a move has B and C drag the same waypoint opposite ways; Crowd an insert has them insert different waypoints at the same spot. Both converge: a move follows its waypoint and concurrent inserts both survive, because ops name items, not index numbers.

Client A

0 pending
select a station

Client B

0 pending
select a station

Client C

0 pending
select a station
Sequencer SN 0

    Converged all routes identical · nothing pending

    Latency and jitter affect simulated arrival order; animation speed changes playback only.