Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
# Shared runtime helpers
## clocks
`albedo/clock.gleam` owns Gleam clock access. Use `system_ms` or
`system_seconds` for durable timestamps and expiry, `monotonic_ms` for elapsed
time and deadlines, and `os_system_ms` only when OS-clock semantics are required.
Store slow-query timing uses `clock.monotonic_ms`. Reuse these functions instead
of adding local clock externals or wrappers. Timers and waits go through
`clock.send_after`, `clock.sleep` and `clock.delay_ms` (`albedo_clock` from
Erlang), which divide the delay by `ALBEDO_TEST_TIME_SCALE`. Only a test that
sets it in its fixture's `prepare` gets faster time; a durable timestamp or
deadline compared against a scaled timer must be scaled the same way (the warm
plan and cache fade do). A provider request's budgets (connect, send, headers,
first event, keepalive) are a peer's network time and are never scaled; a test
shortens them with `ALBEDO_PROVIDER_TIMEOUT_MS`. Erlang native time units are
VM-dependent; request an explicit unit rather than dividing native ticks.
## Unicode scalar limits
`albedo/text_scalars.gleam` owns scalar counting and slicing. Its `length`,
`take`, `drop`, and `tail` scan UTF-8 without creating a whole codepoint list;
retained slices are copied so they release the source binary. Scalars are not
graphemes. Use these helpers for bounded previews and names, including from
Erlang through `'albedo@text_scalars':take(Text, Limit)`. The kernel job summary
retains at most 4096 scalars; truncating it must not allocate a list for the
entire command.
HTTP response previews and operation validation also use `text_scalars.take`;
their scalar-prefix adapters do not maintain a separate native implementation.
## component runtime
The runtime owns the daemon scope, and each session owns the child scope of its composition (robot-docs/components.md). Closing a composition closes its scope; the session closes its own when it replaces it or ends, and the runtime's stop closes the daemon scope.
The runtime composes sessions and keeps nothing about one…