pub fn new_run_id(agent_name: &str) -> StringExpand description
Generate a unique run ID: <agent_name>-<timestamp>-<random>.
The suffix is random, not derived. A derived suffix like
(now ^ (now >> 16) ^ counter) over a process-local counter defends a
lev run --count N batch inside one process but degenerates to a pure
function of the current second across separate processes: three concurrent
lev run invocations all mint fetcher-1785127214-8b48 and silently share
one run directory. Nothing downstream detects that - create_dir_all is a
no-op on an existing directory and the persistence worker then
last-writer-wins over meta.json / context.json / run.lvr, interleaving
two runs’ state irrecoverably.
The <name>-<secs>-<hex> shape is preserved: the timestamp keeps IDs sorting
and reading chronologically, and the dashboard’s short-ID display
(split('-').next_back()) still lands on the unique component.
The name is folded to ASCII alphanumerics, which is stricter than it
looks necessary. The id becomes a directory name, and run_dir resolves an
id that is not a safe path component to <invalid>. A Unicode fold let an
agent named café mint café-...: the daemon created that directory
happily, and then every CLI read of the run looked in <invalid> and found
nothing. The minter has to satisfy the rule the readers enforce.