Skip to content
Open Saka

uuid::v7

Time-ordered UUIDs (version 7): make new ones and read the time they hold. A UUIDv7 holds a Unix millisecond in its 48-bit unix_ts_ms field, then version, variant, and counter bits (RFC 9562). Each runtime lifetime issues one strictly increasing sequence. Generation runs only as a statement, so expressions cannot issue identifiers. Identifiers disclose creation time and are predictable from their neighbors; never use them as secrets.

Write these names after uuid::v7::, as in uuid::v7::new.

new

proc new()! uuid

Issues one UUIDv7 greater than every identifier this runtime lifetime issued before.

many

proc many(count! num)* num -> uuid

Issues count increasing UUIDv7 identifiers as index -> id, with indices from zero and multiplicity one. They exceed every identifier this runtime lifetime issued before. The count must be a nonnegative integer within the Bag-total limit; otherwise the call fails with Conflict. Work limits use ordinary LimitExceeded failures without publishing partial results.

time

def time(id! uuid)? num

Returns the Unix millisecond in the unix_ts_ms field of a UUIDv7, or an empty Bag for identifiers of other versions, whose leading bits are not timestamps. Filters such as ids if id => uuid::v7::time(id) >= t therefore select only UUIDv7 identifiers.

at

def at(ms! num)! uuid

Returns the least UUIDv7 whose timestamp is ms; no UUIDv7 from that millisecond is smaller. Use it for keys and cursors, and filter by uuid::v7::time to select identifiers by time. The millisecond must be an integer from 0 up to but excluding 2^48; otherwise the call fails with Conflict.