Pixir.SessionId (pixir v0.1.12)

Copy Markdown View Source

Canonical validation for Pixir Session identifiers.

Session ids become Registry keys, filename components, recovery-command arguments, and durable evidence references. This module is therefore the only grammar authority: callers validate before any Registry lookup, path construction, filesystem operation, command rendering, or Provider projection.

Valid ids are 1..235 bytes of valid UTF-8. The first codepoint is a Unicode letter, number, or underscore; later codepoints may additionally be Unicode combining marks, hyphens, or dots. The 235-byte ceiling leaves room for Pixir's longest generated Log suffix, .ndjson.tmp-<8 hex>, inside a 255-byte filename component.

Invalid-id errors deliberately never echo, normalize, decode, clean, or basename-reduce the caller's value. The stable reason and bounded metadata are sufficient for agents and presenters to correct the input without reflecting hostile content.

Summary

Functions

Maximum accepted UTF-8 byte length for a Session id.

Whether a value satisfies the canonical Session-id grammar.

Validate a Session id without returning or echoing the supplied value.

Types

reason()

@type reason() ::
  :not_string
  | :empty
  | :invalid_utf8
  | :too_long
  | :invalid_start
  | :invalid_character

Functions

max_bytes()

@spec max_bytes() :: pos_integer()

Maximum accepted UTF-8 byte length for a Session id.

valid?(value)

@spec valid?(term()) :: boolean()

Whether a value satisfies the canonical Session-id grammar.

validate(value)

@spec validate(term()) :: :ok | {:error, map()}

Validate a Session id without returning or echoing the supplied value.