Raxol. Core. ID
(Raxol v2.9.2)
View Source
Deterministic id minting for component instances.
Component ids only need to be unique within one rendered tree: every
consumer (MCP tool names, data-raxol-id DOM attributes,
{:component_event, id, _} routing) is scoped to the process that rendered
the tree. :erlang.unique_integer/1 bought VM-global uniqueness nobody
needed at the price of a different id on every boot, which put throwaway
ids into committed recordings (surface.mcp.json carried "tool-call-293",
an id no agent would ever see again) and into derived MCP tool names.
A per-process, per-prefix counter keeps the same within-tree guarantee
(component init/1 runs in the owning app's process) and mints the same
ids on every identical boot. The counter lives in the process dictionary
on purpose: it is incidental per-process state with no reader outside this
module, the same shape as :rand's seed.
Summary
Functions
Generates a string identifier unique within this process.
The next id for prefix in this process: "prefix-1", "prefix-2", ...
Forgets every counter in this process.
Functions
@spec generate() :: String.t()
Generates a string identifier unique within this process.
Deterministic across identical boots; see next/1 for the reasoning.
Not universally unique like UUIDs.
The next id for prefix in this process: "prefix-1", "prefix-2", ...
@spec reset() :: :ok
Forgets every counter in this process.
For recorders that fold several apps' inits inside one process and need
each fold to mint the ids a fresh boot would.