Foundational interfaces for the thesmos ecosystem.
core is a stdlib-only Go module that defines the contract
seams every other thesmos library and framework depends on:
- Clock — abstracts
time.Now,time.Sleep, and timers so libraries remain deterministic under simulation and test. Returns Hybrid Logical Clock instants for distributed callers and a stdlibtime.Timeprojection for the common case. Implementations:clock/hlc(production HLC),clock/fake(virtual time). See RFC-0001. - Rand — unified randomness seam exposing both
Uint64andRead([]byte). Implementations:rand/pcg(non-crypto PCG),rand/crypto(CSPRNG overcrypto/rand),rand/seeded(HMAC-SHA-256 deterministic CSPRNG),rand/fixed(constant for tests). See RFC-0002. - Crypto — cryptographic-hash seam producing comparable
fixed-shape digests covering 256/384/512-bit outputs in one
type, with a stable per-implementation
IDand long-termAlgorithmidentifier so receipts and audit chains survive algorithm rotation.Hash(data),Combine(left, right), andStream(for inputs that don't fit in memory) cover leaf commitments, Merkle / chain construction, and large-payload hashing. Implementations:crypto/sha256,crypto/sha512(SHA-384, SHA-512),crypto/sha3(SHA3-256, SHA3-384, SHA3-512). See RFC-0003. - HMAC — keyed-authentication peer of the hash seam.
crypto.MACmirrorscrypto.Hasher's shape (sameDigestoutput, sameID+Algorithmmodel, sameStream) with first-class constant-timeVerifyand aDigest.ConstantTimeEqualhelper for streaming verification. Implementations:crypto/hmac/sha256,crypto/hmac/sha512(HMAC-SHA-384, HMAC-SHA-512),crypto/hmac/sha3(HMAC-SHA3-{256,384,512}). See RFC-0012. - Sign — asymmetric-signing seam.
crypto/sign.Signer/Verifiersplit (verifier-only consumers don't construct a signer),KeyIDvalue type with canonical per-algorithm derivation, optionalStreamingSigner/StreamingVerifiercapability interfaces for hash-then-sign algorithms. Implementations:crypto/sign/ed25519(Ed25519 PureEdDSA per RFC 8032 §5.1.6),crypto/sign/ecdsap384(ECDSA P-384 + SHA-384 per FIPS 186-5, ASN.1 DER signatures, also satisfies the streaming interfaces). See RFC-0013. - Telemetry — metric and trace seams for hot-path
observability emission, with attribute pre-binding via
.With([]Attr)keeping the emit path zero-allocation while preservingcontext.Contextfor OTel exemplar correlation, baggage, and trace-stitching. Kind-taggedAttrbridges to stdliblog/slog. Implementations:telemetry/noop. See RFC-0004. - Epoch — in-process strictly-monotonic 64-bit counter for
leader generations, schema versions, optimistic-concurrency
tokens.
epoch.Epochvalue type plus thread-safeepoch.Counter. See RFC-0005. - Tag — snapshot-immutable string key/value pairs used in
place of
map[string]stringon value-type structs that cross async-buffered, cached, or cross-goroutine boundaries. See RFC-0006. - Version — opaque CAS token (
Version),WriteOptionswith IfMatch / IfNoneMatch preconditions, andVersioned[T]for read-your-writes optimistic-concurrency loops. See RFC-0007. - Page — pagination request (
PagewithWithDefaulthelper) and response (Cursor[T]) shape withSliceCursor[T]andMapCursor[K, V]generic helpers. Range-over-func iteration makes "forgot to check err" syntactically impossible. See RFC-0008. - ID — fixed-max-size identifier value type (
id.ID) covering 128-, 160-, and 256-bit shapes in one comparable type, with four generator subpackages:id/ulid(128-bit time-sortable Crockford base32),id/uuidv4(128-bit random RFC 4122),id/ksuid(160-bit K-sortable base62 — alphanumeric encoding and 128-bit entropy floor for gov / defense / fintech / health consumers),id/fixed(constant for fixtures). Every subpackage shipsFormatandParsefor canonical serialization. See RFC-0009. - Pool — typed
sync.Poolwrappers:Pool[T any]for arbitrary values,ResetPool[T Resettable]that auto-clears state onPut(preventing cross-tenant data leaks at the type level), andNewBufferPoolfor the*bytes.Buffercase. See RFC-0010. - Arena — bump allocator for hot-path variable-length
output.
Append/Allocreturn three-index-capped sub-slices into a contiguous backing buffer; epoch-taggedMarker+SliceSincecapture multi-call regions safely. Pool integration viaReset(satisfiespool.Resettable) keeps the backing buffer warm across requests. See RFC-0011.
These interfaces — and the others added over time — share three properties:
- Stdlib-only.
corehas zero non-stdlib imports. The dependency guard fails CI on any new import outside$gostdand the module itself. (ADR-0001) - Single module. One
go.mod. Submodules are not needed because there are no heavy deps to isolate. (ADR-0002) - Apache 2.0. Unencumbered for production and downstream redistribution. (ADR-0003)
Pre-1.0. Interfaces are added incrementally as their shape stabilises in
consumer libraries. Breaking changes are possible until v1.0.0; once
tagged, the standard Go module versioning rules apply.
go get go.thesmos.sh/coreModule path: go.thesmos.sh/core · Repo: github.com/thesmos-ai/core
- ADRs — accepted architectural decisions
- RFCs — proposals under discussion or accepted as direction
- Contributing — local setup, conventions, PR flow
- Security — vulnerability disclosure policy