opid

package
v0.0.0-...-383fb9b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package opid mints and validates wi operation identifiers (op_id), the single volatile field in the envelope (DESIGN §2 determinism: an envelope is byte-identical across runs modulo op_id and timestamps; DESIGN §3.1, §8).

A root op_id is:

op_<base36ts>_<base32rand>

where <base36ts> is the mint time in Unix MILLISECONDS, base36-encoded (lowercase, rough-chronological + human-debuggable), and <base32rand> is randLen random bytes in lowercase, unpadded standard base32 (collision resistance within a millisecond). A child job appends ".<n>" (n >= 1) to its parent's id, and children nest: op_..._....1.2.

New takes its two volatile inputs explicitly — a time and a randomness reader — so it is pure and deterministic under fixed inputs. The CLI Runner wires the real clock and crypto/rand at the boundary (internal/clock owns those, per DESIGN §4); this package owns only the FORMAT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Child

func Child(parent string, n int) (string, error)

Child derives the n-th child id of parent ("<parent>.<n>"). parent must be a valid op_id and n must be >= 1.

func New

func New(now time.Time, r io.Reader) (string, error)

New mints a root op_id from a timestamp and a randomness source. It reads exactly randLen bytes from r and errors (rather than truncating) on a short read, so a malformed id can never be emitted.

func Valid

func Valid(id string) bool

Valid reports whether id matches the frozen op_id grammar (root or child).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL