Claims
Choose one permanent claimant for a named responsibility.
Three hikers want one gate key
Alice, Bob, and Carol all volunteer to hold the only gate key.
Each hiker's notebook begins with gate-key: unclaimed.
They send separate requests to the ranger, who can accept only one.
Until the ranger numbers the requests and announces the result, every notebook
still shows the key as unclaimed.
No merge rule fits. Keeping every request would give one key to three hikers, and last-writer-wins would take the key from a hiker who already holds it. Someone has to decide, and here the ranger does.
Translate the story into a map
In the data model, the gate key becomes the key
gate-key, and the winning hiker becomes its value. A
Claims value is a map
of these named, write-once entries.
This makes SharedMap the closest structure by shape: both structures are sequenced maps whose keys can change independently.
Their update rules are opposite. SharedMap keeps the last numbered change for a key and can later replace or clear that value. Claims accepts only the first numbered claim for a key. That value is permanent. A later claim cannot overwrite it, and there is no release, delete, or reset operation.
This rule is often called first-writer-wins. In Claims, “first” means the first operation accepted by the sequencer. It does not mean the earliest client clock, the first button press, or the first message to reach an arbitrary replica.
| Mechanic | Claims | SharedMap |
|---|---|---|
| Shape | Named key to claimant | Named key to value |
| Winner | First numbered claim | Last numbered change |
| Later write | Rejected | Replaces the value |
| Delete | Not supported | Supported |
From three pending claims to one permanent entry
-
Submit against an empty key. Alice, Bob, and
Carol can each create a pending claim for
gate-key. A pending claim does not yet make its author the owner. - Assign the accepted order. The sequencer gives each operation a sequence number. The lowest accepted number for this empty key determines the winner.
- Apply one decision everywhere. The author receives an acknowledgement, and the other replicas receive the numbered operation. All replicas record the same claimant.
-
Reject later claims. After the key is filled,
claim_oncereturnsAlreadyClaimed. Starting again requires a new key, a new claim namespace, or a new Claims state.
The demo's Reset button creates a new demo room. It does not delete or release a claim through the Claims API.
Run the conflict
Turn off Auto-deliver, submit concurrent claims, and inspect the pending requests. Turn Auto-deliver back on to let the sequencer choose the permanent value.
Claim one shared key
Each client can submit one request for gate-key. Turn off Auto-deliver to inspect the pending requests before the sequencer accepts them.
Coordination rule The sequencer numbers claim requests. The first accepted claim fills that key permanently; later claims cannot replace or remove it.
Alice
Claims state gate-key: unclaimed
Pending request Claim gate-key Alice's claim · awaits a number
Sequencer
Numbers accepted operations before replicas apply them
- No operations accepted yet.
Bob
Claims state gate-key: unclaimed
Pending request Claim gate-key Bob's claim · awaits a number
Carol
Claims state gate-key: unclaimed
Pending request Claim gate-key Carol's claim · awaits a number
- gate-key: unclaimed
Run the worked example
Queue all three claim requests together, or reset and submit one request at a time.
Enable JavaScript to run the race. The expected result remains in the lesson.
Ready: gate-key: unclaimed
Read the result
The sequencer accepts Alice's claim first. Every replica records Alice as the permanent owner, and later claims for gate-key are rejected.
A claim can never be released
Claims has no release, delete, or reset. If Alice loses the gate key or leaves the trail, the key still names her; the application must start a new key. Like every sequenced structure, Claims also needs the ranger station to decide.
The next lesson, FifoWorkQueue, hands out work one job at a time, and a worker can give a job back.
Sources and implementation
Sources:
Watershed's claims_kernel.
Implementation: The demo calls claims_kernel.claim_once, claims_kernel.ack_local, claims_kernel.apply_remote, and claims_kernel.get
through the Gleam toolkit. The displayed client records and shared
view come from those kernel results.