Help us shape the future of Go! Take the 2026 Go Developer Survey

oracle

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package oracle owns the frozen legacy evidence format and its integrity checks.

Index

Constants

View Source
const Version = 1

Variables

This section is empty.

Functions

func ConfigureCommand

func ConfigureCommand(cmd *exec.Cmd)

ConfigureCommand cancels all compiler descendants with their command owner.

func CountSymbols

func CountSymbols(data []byte) (functions int, definedSymbols int, auditFunctions int, err error)

CountSymbols is shared by the live footprint gate and the legacy recorder.

func Digest

func Digest(data []byte) string

Digest returns the lowercase hexadecimal SHA-256 digest of data.

func Directory

func Directory() string

Directory returns FOUNDRY_ORACLE_READ when set, otherwise locates the oracle directory from the working directory. Lookup failures panic.

func Inventory

func Inventory(dir string) (map[string]bool, []string, error)

Inventory finds stable assertion sites and their owning test-file entry points.

func JSON

func JSON(value any) ([]byte, error)

JSON returns indented JSON followed by a newline, together with any encoding error.

func ModelSnapshot

func ModelSnapshot(value any) string

ModelSnapshot returns the oracle's model snapshot representation.

func Publish

func Publish(dir string, b Bundle, refreeze bool) error

Publish publishes a reviewed legacy capture bundle.

func ReadJSON

func ReadJSON(path string, value any) error

ReadJSON reads a file and decodes its JSON into the supplied destination.

func SelectedSites

func SelectedSites(dir string, tests []string) (map[string]bool, error)

SelectedSites returns the assertion sites selected by the supplied tests.

func Snapshot

func Snapshot(value any) string

Snapshot records structure, not Go formatting. Named model identities are intentionally erased so separately generated and handwritten models compare. Kind tags, lengths, field names and presence survive that normalization.

func Unconsumed

func Unconsumed(b Bundle, prefix string, consumed map[string]bool, selection Selection) ([]string, error)

Unconsumed checks every frozen occurrence selected by the test flags, including tests that emitted no observations and selected parents of filtered subtests.

func Validate

func Validate(b Bundle) error

Validate checks bundle version, nonempty records and sources, source hashes, record identities, and provenance.

Types

type AuditedSource

type AuditedSource struct {
	PostgresTests []string `json:"postgres_tests,omitempty"`
	SHA256        string   `json:"sha256"`
	Tests         []string `json:"paired_tests,omitempty"`
}

AuditedSource records a source hash and its paired test inventories.

type BuildEnvironment

type BuildEnvironment struct {
	GOFLAGS      string
	GOWORK       string
	GOENV        string
	GOOS         string
	GOARCH       string
	CGO_ENABLED  string
	GOEXPERIMENT string
	GOTOOLCHAIN  string
	GOMOD        string
	GOROOT       string
	GOVERSION    string
	GCFlags      string
}

BuildEnvironment is the effective `go env -json` snapshot in each module. GOFLAGS is fixed: overlays, alternate modfiles, tags, gcflags and ldflags are not accepted inputs to an oracle freeze. Workspace and persistent GOENV are off.

func (BuildEnvironment) Validate

func (b BuildEnvironment) Validate(dir string) error

Validate checks the required canonical build provenance and absolute paths.

type Bundle

type Bundle struct {
	Version int               `json:"version"`
	Sources map[string]string `json:"source_sha256"`
	Records map[string]Record `json:"records"`
}

Bundle contains versioned frozen oracle records and their source hashes.

func Load

func Load(dir string) (Bundle, error)

Load checks the separate publication receipt before decoding evidence. A missing bundle is allowed only while the checked-in receipt explicitly says pending.

type ComparisonAudit

type ComparisonAudit struct {
	Files map[string]AuditedSource `json:"files"`
}

ComparisonAudit is the historical capture census. Its PostgreSQL entry points remain the source of backend requirements for replay; source hashes describe the retired checkout and are not regenerated from replacement declarations.

type Provenance

type Provenance struct {
	WorkingDirectory string           `json:"working_directory"`
	Build            BuildEnvironment `json:"build"`
	Commit           string           `json:"commit"`
	Sources          string           `json:"source_manifest_sha256"`
	Command          []string         `json:"command"`
	Toolchain        string           `json:"toolchain"`
	Platform         string           `json:"platform"`
}

Provenance records the source, command, toolchain, platform, and build environment for oracle evidence.

type Record

type Record struct {
	Package    string     `json:"package,omitempty"`
	Site       string     `json:"site"`
	Kind       string     `json:"kind"`
	Transcript string     `json:"transcript"`
	Provenance Provenance `json:"provenance"`
}

Record contains an oracle transcript, assertion identity, kind, and provenance.

type Replay

type Replay struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Replay is owned by one test package; the prefix separates identical test names in different fixture packages. Main enforces consumption after all subtests exit.

func NewReplay

func NewReplay(prefix string) *Replay

NewReplay creates a replay tracker for the supplied assertion prefix.

func NewReplayAt

func NewReplayAt(prefix, directory string) *Replay

NewReplayAt selects an independent frozen bundle, without changing fixture defaults.

func (*Replay) Equal

func (r *Replay) Equal(t *testing.T, site, current string) bool

Equal compares the current transcript with its indexed frozen record and reports missing or differing evidence to the test.

func (*Replay) Finish

func (r *Replay) Finish(code int) int

Finish checks consumption after a test runner shared by internal and external tests.

func (*Replay) Main

func (r *Replay) Main(m *testing.M) int

Main runs the test suite and passes its exit code through Finish.

func (*Replay) Match

func (r *Replay) Match(t *testing.T, site, current string) bool

Match replays an existing legacy observation.

type Selection

type Selection struct {
	// contains filtered or unexported fields
}

Selection follows Go's slash-separated test regex syntax. Expected records come only from the frozen inventory and flags, never from observed callbacks.

func SelectTests

func SelectTests(run, skip string) (Selection, error)

SelectTests parses test run and skip patterns into an oracle selection.

func (Selection) Includes

func (s Selection) Includes(test string) bool

Includes reports whether a test matches the selection, excluding disabled roots and descendants of skipped ancestors.

type State

type State struct {
	Version int    `json:"version"`
	Phase   string `json:"phase"`
	SHA256  string `json:"bundle_sha256,omitempty"`
	Command string `json:"authorization_command,omitempty"`
}

State records oracle lifecycle phase and optional bundle digest and authorization command.

Directories

Path Synopsis
cmd
freeze-oracles command
Command freeze-oracles publishes a reviewed framework legacy capture bundle.
Command freeze-oracles publishes a reviewed framework legacy capture bundle.

Jump to

Keyboard shortcuts

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