Documentation
¶
Overview ¶
Package determinism turns harness pins into the injectable values the read path already accepts. It is the Go counterpart of lib/tasks/determinism.rb and exists for the porting conformance harness and for nothing else.
The design rules are the Ruby module's, unchanged: every accessor reports "unset" rather than substituting a value of its own, and it configures nothing that is not already a seam.
Index ¶
- Constants
- Variables
- func Clock(env Env) func() time.Time
- func CoalesceScope(env Env) (string, bool)
- func Hostname(env Env) func() string
- func Now(env Env) (time.Time, bool, error)
- func NowForAdapter(env Env) (time.Time, error)
- func Reset()
- func Winsize(env Env) (rows, columns int, ok bool)
- type Env
- type IDSequence
Constants ¶
const ( NameNow = "TASKS_PIN_NOW" NameIDs = "TASKS_PIN_IDS" NameCoalesceScope = "TASKS_PIN_COALESCE_SCOPE" NameDelegationKeys = "TASKS_PIN_DELEGATION_KEYS" NameHostname = "TASKS_PIN_HOSTNAME" NameLines = "LINES" NameColumns = "COLUMNS" NameTestTodaySequence = "TASKS_TEST_TODAY_SEQUENCE" NameDevice = "TASKS_DEVICE" NameTZ = "TZ" NameLang = "LANG" NameLCAll = "LC_ALL" )
The pinned names, spelled exactly as lib/tasks/determinism.rb spells them.
Variables ¶
var Keys = []string{ NameNow, NameIDs, NameCoalesceScope, NameDelegationKeys, NameHostname, NameLines, NameColumns, NameTestTodaySequence, NameDevice, NameTZ, NameLang, NameLCAll, }
Keys is Determinism::KEYS: every name `report` accounts for, in the Ruby module's own order.
Functions ¶
func CoalesceScope ¶
CoalesceScope is the journal's per-process coalescing scope, or ok=false.
func Hostname ¶
Hostname is Config's host provider: never nil, and the unpinned provider is the one Config defaulted to before.
func Now ¶
Now is the frozen UTC instant TASKS_PIN_NOW names, or ok=false when the pin is unset. An unparseable pin is an error rather than a silent fall back to the wall clock: a harness that fell back would produce a green run that proves nothing.
func NowForAdapter ¶
NowForAdapter resolves the whole clock precedence in one place: TASKS_PIN_NOW dominates, then TASKS_TEST_TODAY_SEQUENCE (noon UTC of the current date), then the wall clock. Presence, not non-emptiness, triggers step 2 — the Ruby seam it mirrors reads `if ENV[name]`.
Types ¶
type Env ¶
Env is a process environment. A name absent from the map is unset; a name present with an empty value is set-and-empty, which several pins treat differently from unset — TASKS_TEST_TODAY_SEQUENCE keys off presence alone, exactly as `if ENV[name]` does under Ruby's truthiness.
type IDSequence ¶
type IDSequence struct {
// contains filtered or unexported fields
}
IDSequence is a monotonic, reproducible hex mint. Stateful on purpose: one invocation can perform several mutations and each must draw the next token.
func DelegationKeySource ¶
func DelegationKeySource(env Env) (*IDSequence, error)
DelegationKeySource is the process-wide mint for delegation coalescing keys, or nil when TASKS_PIN_DELEGATION_KEYS is unset.
func IDSource ¶
func IDSource(env Env) (*IDSequence, error)
IDSource is a fresh id mint, or nil when TASKS_PIN_IDS is unset.
func NewIDSequence ¶
func NewIDSequence(spec string, width int, name string) (*IDSequence, error)
NewIDSequence parses a pin spec: comma-separated tokens, each `width` hex characters or the literal "seq".
func SharedDelegationKeySource ¶
func SharedDelegationKeySource(env Env) (*IDSequence, error)
SharedDelegationKeySource is DelegationKeySource memoized per spec, for the same reason: one invocation may build more than one application.
func SharedIDSource ¶
func SharedIDSource(env Env) (*IDSequence, error)
SharedIDSource is IDSource memoized per spec: the same env yields the same sequence, and changing the pin rebuilds it. Adapters that mint ids more than once in a process should use this rather than IDSource.
func (*IDSequence) Call ¶
func (s *IDSequence) Call() string
Call draws the next token: the queued ones in order, then the last one incremented as a counter of the same width.
func (*IDSequence) Width ¶
func (s *IDSequence) Width() int
Width is the token length in hex characters.