Currently, Session.generate_id() falls back to crypto.randomUUID() when no custom generate_id function is provided.
I think monotonic ULIDs would be a better default.
Why?
Svedit treats node IDs as opaque strings, but all the applications I have built on top of Svedit store nodes as standalone records rather than as a single document JSON. In those systems, documents are simply arrays of node IDs, and nodes such as quotes, tasks, or figures become first-class objects that can be viewed/ searched independently.
Using monotonic ULIDs provides a few nice properties at essentially no cost:
- IDs are lexicographically sortable by creation time.
- Creation order can be recovered without requiring a separate
createdAt field.
- Simpler implementation of views like "All Quotes", "Recently Created Blocks", etc.
- Better database index locality compared to random UUIDs.
- Shorter IDs (26 characters vs. 36 for UUIDs).
Monotonic ULIDs (vs. regular ULIDs) also preserve ordering when multiple IDs are generated within the same millisecond.
Downsides
- Requires a small ULID implementation (either via the
ulid package or an embedded implementation).
Migration
- Existing applications could override
generate_id if they want to keep the old uuid
Currently,
Session.generate_id()falls back tocrypto.randomUUID()when no customgenerate_idfunction is provided.I think monotonic ULIDs would be a better default.
Why?
Svedit treats node IDs as opaque strings, but all the applications I have built on top of Svedit store nodes as standalone records rather than as a single document JSON. In those systems, documents are simply arrays of node IDs, and nodes such as quotes, tasks, or figures become first-class objects that can be viewed/ searched independently.
Using monotonic ULIDs provides a few nice properties at essentially no cost:
createdAtfield.Monotonic ULIDs (vs. regular ULIDs) also preserve ordering when multiple IDs are generated within the same millisecond.
Downsides
ulidpackage or an embedded implementation).Migration
generate_idif they want to keep the old uuid