Use monotonic ULIDs as the default node ID generator

Open
#318 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
typescript
Domain
backend

Research direction

Start at Session.generate_id(), where the current crypto.randomUUID() fallback is described. Evaluate the proposed monotonic ULID implementation or package, preserving the custom generate_id override; done means the default produces sortable, monotonic 26-character IDs while existing applications can retain their generator.

Written by the indexing model from the issue text.

Description

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
Dominant language
TypeScript
Stars
691
Forks
20
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from michael/svedit

All issues in michael/svedit

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.