0272. Pure batteries: encoding, UUID and RE2-style regex
- Status: Accepted (maintainer, 2026-11-22: "follow the existing plans" for R2; the plan's recommended defaults are adopted here and can be revisited)
- Date: 2026-11-22
- Plan: CB0 (batteries plan, CB3–CB7); M20 tasks for each slice
- Builds on: ADR-0245 (toolchain batteries), ADR-0089 (edition members), ADR-0262 (entropy), ADR-0263 (wallclock)
Context
ADR-0245 puts regex, base64, random/UUID and wall-clock time in
the toolchain set. OS entropy and the UTC wall clock already ship
as the accepted entropy and wallclock
FFI plugins. Encoding, UUID and regex are still missing. The
batteries plan left four questions for CB0: placement,
Clock/Random capabilities, the regex
subset and time zones.
Decision
- Placement. The new batteries are pure Tenon
packages shipped as edition 2026 members
(
crates/tenon/src/editions.rs), likecodec,showandargs:encoding(base64 std/url, padded/raw, and hex),uuidandregex. They do not add an embeddedstd.*namespace. Each package has aDOCS.mdwithin the 1,500-token cap and a short plugin index line. - No new capabilities.
uuidstays pure.v4takes 16 random bytes andv7takes a millisecond timestamp plus random bytes, through aUuidGenvalue that keeps v7 strictly increasing within one millisecond and when the clock steps back (RFC 9562 section 6.2). Apps feed it fromentropyandwallclock, which keep their existingfficapability.Clock/Randomcapability types and ceilings are not added now. - Regex. An RE2-style subset written in pure
Tenon: no backreferences and no lookaround. It uses a Pike VM with
captures, so matching is linear in the input, and it caps
repetition counts and program size (
TooLarge). Semantics follow RE2 and Go: leftmost-first,$only at the end of text unlessmis set, and Go's empty-match rules forfind_all,replace_allandsplit. Unsupported syntax fails with a positioned error. - Encoding is strict. Decoders reject characters outside the alphabet, bad padding and non-zero pad bits (RFC 4648 section 3.5). Whitespace is an error.
- Time zones. UTC only for v1 (ADR-0263 already
formats and parses RFC 3339
Z).
Alternatives considered
- An embedded
std.*namespace: needs new resolution rules and a std track that ADR-0245 defers. Clock/Randomcapability types now: this is language work. The plugins already fail closed and work today.- A backtracking regex: it can hit ReDoS and gives no linear-time guarantee.
Consequences
CB3 (encoding) and CB5–CB7 (regex) are new edition packages with the lowest conflict risk. CB4 (UUID) does not wait for capability work. Adding edition members grows the edition index, so check the edition-index token budget in each PR.