ARCHIVED from builddistributedsystem.com on 2026-04-28 — URL: https://builddistributedsystem.com/tracks/identifier/tasks/task-2-4-uniqueness-validation
TASK

Implementation

Run your ID generator through Maelstrom verification to prove uniqueness. Maelstrom collects all generated IDs across all nodes and checks for duplicates.

Your implementation must pass with:

  • Multiple nodes generating concurrently
  • High throughput (thousands of IDs per second)
  • Network partitions separating nodes

Think about why your scheme guarantees uniqueness. What assumptions does it make? What could cause collisions?

Sample Test Cases

Generate two IDs with proper formatTimeout: 5000ms
Input
{"src":"c0","dest":"n1","body":{"type":"init","msg_id":1,"node_id":"n1","node_ids":["n1"]}}
{"src":"c1","dest":"n1","body":{"type":"generate","msg_id":2}}
{"src":"c2","dest":"n1","body":{"type":"generate","msg_id":3}}
Expected Output
{"src":"n1","dest":"c0","body":{"type":"init_ok","in_reply_to":1,"msg_id":0}}
{"src":"n1","dest":"c1","body":{"type":"generate_ok","in_reply_to":2,"msg_id":1,"id":"n1-0"}}
{"src":"n1","dest":"c2","body":{"type":"generate_ok","in_reply_to":3,"msg_id":2,"id":"n1-1"}}

Hints

Hint 1
Maelstrom will verify uniqueness automatically
Hint 2
Consider mathematical proof of your ID uniqueness
Hint 3
Document your uniqueness guarantees
OVERVIEW

Theoretical Hub

Proving Uniqueness

A strong ID scheme should have a provable uniqueness guarantee.

The Proof Structure

If IDs combine:

  • node_id - unique per node
  • timestamp - monotonic
  • sequence - unique per timestamp

Then uniqueness is guaranteed as long as:

  1. Node IDs are unique
  2. Clocks do not go backwards more than a tolerable amount
  3. Sequence does not overflow

Failure Modes

Failure Cause Mitigation
Clock sync issue NTP adjustment Wait or use previous timestamp
Node ID reuse Node restart with same ID Persist counter or use epoch
Sequence overflow >4096 IDs/ms Wait for next millisecond

Key Concepts

testingverificationglobal uniqueness
main.py
python
Validate Uniqueness Across Distributed Nodes - The Identifier | Build Distributed Systems