Shared identifier and bearer-token generation helpers.
ids owns the small set of ID formats reused across leather's persistent
stores and runtime surfaces. It generates timestamp-bucketed identifiers for
hides, queue items, artifacts, and related records, plus cryptographically
random hex tokens for secrets such as DevTools bearer auth.
| Symbol | Signature | Description |
|---|---|---|
TimestampHex |
func TimestampHex(prefix string) string |
Return an ID of the form <prefix>_<yyyymmdd>_<HHMM>_<8hex>. |
RandHex |
func RandHex(n int) (string, error) |
Return n cryptographically random bytes hex-encoded as a 2n-character string. |
TimestampHex intentionally uses a non-cryptographic random suffix because its
job is uniqueness, not secrecy. The current 32-bit suffix was chosen to reduce
burst-load collisions in minute buckets used by fan-in and queue flows.
RandHex is the security-sensitive half of the package. It delegates to
crypto/rand and wraps errors so callers can distinguish entropy failures from
ordinary runtime issues.
Stdlib only.
flowchart LR
CALLERS[artifact/hide/queue/tool/cli] --> TS[TimestampHex]
CALLERS --> RH[RandHex]
TS --> IDS[stable runtime IDs]
RH --> TOKENS[bearer tokens / secrets]
internal/ids/ids_test.go covers output shape and prefix formatting. The
package is small enough that its direct tests focus on formatting and length
guarantees rather than orchestration behaviour.