Expand description
Lowercase ULID minting and validation (SPEC § The id field, format v0.4).
A ULID is a 128-bit identifier — a 48-bit
millisecond timestamp followed by 80 random bits — rendered as 26
characters of Crockford base32. db.md’s canonical form is lowercase
(YAML-clean, shell-friendly, reads like the rest of the frontmatter).
dbmd write mints one for every new content file that carries no id;
the leading timestamp makes freshly minted ids time-sortable, and the 80
random bits make offline minting coordination-free.
Std-only by design. The toolkit’s dependency discipline (zero AI deps,
minimal tree) rules out pulling a ulid/rand stack for one mint call.
Randomness comes from RandomState — std’s hasher keys are seeded from
OS entropy — mixed with the wall clock, the PID, and a process-global
counter. That is not cryptographic randomness and does not need to be:
the id’s contract is store-scoped uniqueness (DUP_ID is the backstop),
not unguessability.
Functions§
- is_ulid
- True when
sis a well-formed lowercase ULID: exactly 26 chars, all lowercase Crockford base32, first char0–7(so the value fits 128 bits). Uppercase or mixed-case forms are not the db.md canonical form and return false — as does any other opaque id, which stays legal in a store (SPEC: the ULID form is recommended, never a validation gate). - mint
- Mint a fresh lowercase ULID: 48-bit Unix-millisecond timestamp + 80 random bits, encoded as 26 chars of lowercase Crockford base32.