0006. Ledger IDs are UUIDv7, generated by the ledger
| Status | Accepted |
| Date | 2026-11-10 |
| Answers | Architecture §4 |
| Implemented in | 1.04 (identifier types), 1.08 (uuid columns) |
Context
Section titled “Context”Accounts, entries, lines and holds need IDs that are unique everywhere, safe to expose in an API, and efficient as primary keys in PostgreSQL. Random IDs scatter writes across a B-tree index. Sequential integers reveal volumes and are easy to guess.
The draft spec let clients generate transfer IDs so that a retry reuses the same ID. ADR-0008 gives clients an idempotency key for that purpose instead.
Decision
Section titled “Decision”Every ledger record ID is a UUIDv7, stored as PostgreSQL uuid, and
generated by the ledger, not by the client.
- UUIDv7 starts with a millisecond timestamp, so new rows land at the end of the index, like a sequence.
- Each kind of ID has its own Rust type (
AccountId,EntryId, …), so an account ID can never be passed where an entry ID is expected. - Order is never taken from the ID. The ledger’s
recorded_timeand entry sequence are authoritative for ordering. - Retries are matched by the client’s idempotency key (ADR-0008), not by the ID.
- Offline receipts are identified by
(device_id, counter), which the device signs (ADR-0010).
Alternatives considered
Section titled “Alternatives considered”| Option | For | Against |
|---|---|---|
| UUIDv7, generated by the ledger (chosen) | Unique without coordination. Index-friendly. Does not reveal counts. The ledger controls the clock. | 16 bytes instead of 8. Reveals the creation time to the millisecond. |
| UUIDv4 (random) | Unique, reveals nothing. | Random inserts fragment the primary-key index. |
BIGSERIAL sequence |
Small and fast. | Reveals volume and is guessable. Hard to merge or generate outside the database. |
| Client-generated IDs | Retries are idempotent by ID. | Clients can choose colliding IDs, or skew the time order. Mixes identity with retry safety. |
Consequences
Section titled “Consequences”Positive:
- IDs can be shown to clients and in receipts without leaking business volume.
- Typed IDs catch a whole class of bugs at compile time.
Negative:
- A client learns the ID only from the ledger’s response. If the response is lost, it looks the entry up by idempotency key (ADR-0008).
Makes out of date: spec §3.1 (“generated by the client”). Rewritten in step 1.04.