determinism

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

Keys is Determinism::KEYS: every name `report` accounts for, in the Ruby module's own order.

Functions

func Clock

func Clock(env Env) func() time.Time

Clock is the pinned instant in the shape the store takes, or nil when unset.

func CoalesceScope

func CoalesceScope(env Env) (string, bool)

CoalesceScope is the journal's per-process coalescing scope, or ok=false.

func Hostname

func Hostname(env Env) func() string

Hostname is Config's host provider: never nil, and the unpinned provider is the one Config defaulted to before.

func Now

func Now(env Env) (time.Time, bool, error)

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

func NowForAdapter(env Env) (time.Time, error)

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]`.

func Reset

func Reset()

Reset drops the memoized sequences. Test-only, exactly as Determinism.reset! is: a test that pinned one spec must not leak its position into the next.

func Winsize

func Winsize(env Env) (rows, columns int, ok bool)

Winsize is [rows, columns] when both are pinned to positive integers, so the caller falls back to querying a real terminal only when they are not.

Types

type Env

type Env map[string]string

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.

func OSEnv

func OSEnv() Env

OSEnv snapshots the real environment.

func (Env) Get

func (e Env) Get(name string) string

Get is the `ENV[name].to_s` spelling: unset reads as the empty string.

func (Env) Lookup

func (e Env) Lookup(name string) (string, bool)

Lookup reports the value and whether the name is set at all.

func (Env) Requested

func (e Env) Requested(name string) (string, bool)

Requested is the probe's `requested` helper: the raw value, or "" when the name is unset or blank. A pin nobody asked for is not a pin that was dropped.

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.

Jump to

Keyboard shortcuts

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