Expand description
Canonical stable identifiers for sessions, forks, events, and transcript messages.
Newly minted identities use RFC 9562 UUIDv7 — the 48 most-significant bits are the Unix-epoch timestamp in milliseconds (monotonic per process, sort- equivalent to creation order), the next 4 bits are the version, the next 2 bits are the variant, and the remaining 62 bits are random.
Identity is implemented in pure Rust (no uuid crate, no rand crate) so
F1 stays within the protocol crate’s locked dependency set. The PRNG is a
splitmix64 seeded from system time + process id + an atomic counter, so
on any single platform a sequence of mints produced at distinct timestamps
is unique with overwhelming probability and still satisfies the RFC’s
“unpredictable” requirement (the 62 random bits are sufficient for the
version-7 collision domain and there is no security claim at stake here;
the F1 deliverable explicitly says “stable identity, not security”).
Producers (the engine loop) still pick constant message ids (final,
forced-stop, graceful-summary, …) and seq independently of the
database row sequence. The id helpers below derive every message identity
from the persisted row sequence at the storage boundary, so every message
gets a <kind>-<row_seq> identity and React keys stay unique and stable
(per the rendering-lists contract).
Functions§
- assistant_
message_ id - Canonical id for an assistant message at
row_seq. - is_
canonical_ uuid_ v7 - Predicate — cheaply identifies any RFC 9562 v7 UUID string. Used by the storage boundary to decide whether an incoming identity is the new canonical shape (mint-vs-rewrite).
- message_
id - Build the canonical id for a transcript message at
row_seq. Independent of the payload-supplied id so two rows whose producers both chose the same constant id are still uniquely keyed by their persisted sequence. - tool_
call_ origin_ id - Canonical id for a
ToolCallStartedorigin row. This is the row-level identity an awaited engine dispatch consults; the protocol event itself still carries aseq-derived display id, but the durable record uses this shape so a tool result can deterministically find its origin at replay time. - tool_
result_ id - Canonical id for a
TranscriptMessagecarried inside a tool result. - uuid_v7
- Mint a UUIDv7 string. Output format is the canonical hyphenated
36-character lowercase form, equivalent to a UUID-printable BNF: 8-4-4-4-12
hex with
version=7andvariant=8/9/a/b.