Generates and sanitizes human-readable session names in <adjective>-<noun> format.
Names are embedded in SQLite filenames alongside the session id:
<sessions_dir>/<id>_<name>.db. Both components are URL-safe and contain
only [a-z0-9-] characters, with _ reserved as the separator.
Generation
generate/1 picks a random adjective + noun pair and retries (up to a
configurable limit) if the resulting name already exists on disk.
Sanitization
sanitize/1 normalises a user-provided string to the same character class:
lowercase, spaces and underscores become hyphens, and any other character
outside [a-z0-9-] is stripped. The result is truncated to 64 characters.
If sanitization produces an empty string, {:error, :invalid} is returned.
Summary
Functions
Generate a unique <adjective>-<noun> name not already present in
sessions_dir. Retries up to 20 times on collision.
Sanitize a user-provided string to a valid session name.
Functions
Generate a unique <adjective>-<noun> name not already present in
sessions_dir. Retries up to 20 times on collision.
Returns {:ok, name} or {:error, :exhausted} if all retries collide.
Sanitize a user-provided string to a valid session name.
- Lowercased.
- Spaces and underscores converted to hyphens.
- Characters outside
[a-z0-9-]stripped. - Consecutive hyphens collapsed to one.
- Leading and trailing hyphens removed.
- Truncated to 64 characters.
Returns {:ok, name} or {:error, :invalid} if the result is empty.