vectorhydration

package
v2.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BootstrapResamples = 100000
	AllocationCap      = 25000.0
)
View Source
const (
	SchemaVersion       = "vec-bench-stat/v2"
	CampaignID          = "VEC-BENCH-STAT"
	AmendmentVersion    = "1.0.0-draft.1"
	CampaignVersion     = AmendmentVersion
	PhaseSchemaVersion  = "1.0.0"
	RunSchemaVersion    = "1.0.0"
	SourceSchemaVersion = "1.0.0"
	GuardMargin         = 0.10
	LCBThreshold        = 5.10
	PairedBlocksPerCell = 20
	BenchmarkPackage    = "./internal/store/sqlite"
	LegacyBenchmark     = "BenchmarkHydrateLegacyGetByID_N100"
	BatchBenchmark      = "BenchmarkHydrateBatchGetByIDs_N100"
)
View Source
const (
	BinaryIdentitySchemaVersion   = "binary-identity/v1"
	ProtocolIdentitySchemaVersion = "protocol-identity/v1"
)
View Source
const (
	ApprovedBuildIdentity = "go-test-c-trimpath-v1"
	QualificationPhase    = "qualification"
	HeldOutPhase          = "held-out"
)

Variables

View Source
var RequiredCells = [...]int{1, 2, 4}

Functions

func CanonicalArgv

func CanonicalArgv(r ProcessRequest) []string

func Collect

func Collect(ctx context.Context, manifest Manifest, cfg CollectorConfig) error

Collect executes every schedule entry once for every requested measurement. A failed process is retained as a Result and never causes a replacement run.

func ExtractImmutableArchive

func ExtractImmutableArchive(data []byte, destination string) error

func ExtractImmutableArchiveWithOps

func ExtractImmutableArchiveWithOps(data []byte, destination string, ops ArchiveOps) (err error)

func HashArchive

func HashArchive(data []byte) string

func HashArgv

func HashArgv(r ProcessRequest) string

func StableNames

func StableNames(names []string) []string

func ToolIdentity

func ToolIdentity(executable string) (path, digest string, err error)

func ToolVersion

func ToolVersion(ctx context.Context, executor Executor, tool string) (string, error)

func ValidateOutput

func ValidateOutput(dir string) error

func ValidatePublicationBinding

func ValidatePublicationBinding(binding PublicationBinding, binary BinaryIdentity, protocol ProtocolIdentity) error

func VerifyToolIdentity

func VerifyToolIdentity(ctx context.Context, executor Executor, tool, digest, version string) error

Types

type AnalysisInput

type AnalysisInput struct {
	Manifest Manifest
	Results  []Result
	Raw      map[string][]byte
	Gates    ExternalGates
	Binary   BenchmarkBinary
}

type AnalysisReport

type AnalysisReport struct {
	Status      string // PASS, FAIL, BLOCKED, or INCONCLUSIVE
	Cells       []CellReport
	Seed        uint64
	Resamples   int
	GuardMargin float64
	Reasons     []string
}

func Analyze

func Analyze(in AnalysisInput) AnalysisReport

func AnalyzePublication

func AnalyzePublication(dir string, gates ExternalGates, binary BenchmarkBinary) (AnalysisReport, error)

type ArchiveOps

type ArchiveOps struct {
	RemoveAll func(string) error
	Stat      func(string) (os.FileInfo, error)
}

type ArchivedSource

type ArchivedSource struct {
	Commit, ArchiveSHA256 string
	Bytes                 []byte
}

func ArchiveSource

func ArchiveSource(ctx context.Context, executor Executor, root, commit string) (ArchivedSource, error)

type BenchmarkBinary

type BenchmarkBinary struct {
	SourceCommit, ToolIdentity, BinaryPath, SHA256 string
	Build                                          ProcessRequest
	BuildArgv                                      []string
}

func PrepareBenchmarkBinary

func PrepareBenchmarkBinary(ctx context.Context, manifest Manifest, sourceRoot, outputPath string, executor Executor) (BenchmarkBinary, error)

type BinaryIdentity

type BinaryIdentity struct {
	SchemaVersion    string `json:"schema_version"`
	BinarySHA256     string `json:"binary_sha256"`
	SourceCommit     string `json:"source_commit"`
	SourceTreeSHA256 string `json:"source_tree_sha256"`
	ToolSHA256       string `json:"tool_sha256"`
	ArgvSHA256       string `json:"argv_sha256"`
	ToolVersion      string `json:"tool_version"`
	BuildIdentity    string `json:"build_identity"`
}

BinaryIdentity seals the exact executable and toolchain used by a campaign.

func PrepareIdentity

func PrepareIdentity(ctx context.Context, executor Executor, sourceRoot, commit string, build ProcessRequest, binary string) (identity BinaryIdentity, err error)

PrepareIdentity is the sole trust pipeline: tool precheck, exact archive, owned extraction, build, tool postcheck, binary hash.

func (BinaryIdentity) CanonicalJSON

func (b BinaryIdentity) CanonicalJSON() ([]byte, error)

func (BinaryIdentity) Digest

func (b BinaryIdentity) Digest() (string, error)

func (BinaryIdentity) Hash

func (b BinaryIdentity) Hash() (string, error)

func (*BinaryIdentity) UnmarshalJSON

func (b *BinaryIdentity) UnmarshalJSON(data []byte) error

func (BinaryIdentity) Validate

func (b BinaryIdentity) Validate() error

type CampaignManifest

type CampaignManifest struct {
	Version string `json:"version"`
	ID      string `json:"id"`
}

type CellReport

type CellReport struct {
	Cell, SampleSize int
	Median, LCB      float64
	Passed           bool
}

type Clock

type Clock interface{ Now() time.Time }

type CollectorConfig

type CollectorConfig struct {
	OutputDir    string
	Measurements []Measurement
	Command      Command
	Executor     Executor
	Clock        Clock
}

type Command

Command receives the sealed schedule entry. It must return the complete command identity, including environment, for one fresh process.

type Execution

type Execution struct {
	Stdout, Stderr        []byte
	ExitCode              int
	StartedAt, FinishedAt time.Time
	Err                   error
	PID                   int
	ProcessIdentity       string
}

type Executor

type Executor interface {
	Execute(context.Context, ProcessRequest) Execution
}

type ExternalGates

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

ExternalGates contains only preregistered file digests and structured gate files. Gate outcomes are never accepted from caller-provided booleans.

func LoadExternalGates

func LoadExternalGates(registryPath, expectedRegistrySHA256 string, artifactPaths map[string]string) (ExternalGates, error)

LoadExternalGates loads only externally supplied, regular files. It does not create or approve either trust registries or gate artifacts.

type ExtractedSource

type ExtractedSource struct {
	Path   string
	Remove func(string) error
}

func ExtractSource

func ExtractSource(source ArchivedSource) (ExtractedSource, error)

type GateArtifact

type GateArtifact struct {
	Content []byte `json:"-"`
	SHA256  string `json:"-"`
}

type Manifest

type Manifest struct {
	SchemaVersion    string                `json:"schema_version"`
	Campaign         CampaignManifest      `json:"campaign"`
	Phase            PhaseManifest         `json:"phase"`
	Run              RunManifest           `json:"run"`
	SourceMachine    SourceMachineManifest `json:"source_machine"`
	SourceCommit     string                `json:"source_commit"`
	BenchmarkPackage string                `json:"benchmark_package"`
	LegacyBenchmark  string                `json:"legacy_benchmark"`
	BatchBenchmark   string                `json:"batch_benchmark"`
	Seed             uint64                `json:"seed"`
	Schedule         []ScheduleEntry       `json:"schedule"`
}

func (Manifest) CanonicalJSON

func (m Manifest) CanonicalJSON() ([]byte, error)

func (Manifest) ManifestDigest

func (m Manifest) ManifestDigest() string

func (Manifest) SHA256

func (m Manifest) SHA256() (string, error)

func (*Manifest) UnmarshalJSON

func (m *Manifest) UnmarshalJSON(data []byte) error

func (Manifest) Validate

func (m Manifest) Validate() error

type Measurement

type Measurement string
const (
	MeasurementLegacy Measurement = "legacy"
	MeasurementBatch  Measurement = "batch"
)

type OSExecutor

type OSExecutor struct{}

OSExecutor captures both streams and makes process identity unambiguous for a run.

func (OSExecutor) Execute

type Order

type Order string
const (
	OrderAB Order = "AB"
	OrderBA Order = "BA"
)

type PhaseManifest

type PhaseManifest struct {
	Version string `json:"version"`
	ID      string `json:"id"`
}

type ProcessRequest

type ProcessRequest struct {
	Executable string   `json:"executable"`
	Args       []string `json:"args"`
	Dir        string   `json:"dir"`
	Env        []string `json:"env"`
	Identity   string   `json:"identity,omitempty"`
}

type ProtocolIdentity

type ProtocolIdentity struct {
	SchemaVersion           string  `json:"schema_version"`
	Campaign                string  `json:"campaign"`
	Amendment               string  `json:"amendment"`
	Phase                   string  `json:"phase"`
	ManifestSHA256          string  `json:"manifest_sha256"`
	ScheduleSHA256          string  `json:"schedule_sha256"`
	LegacyMeasurementSHA256 string  `json:"legacy_measurement_sha256"`
	BatchMeasurementSHA256  string  `json:"batch_measurement_sha256"`
	Resamples               int     `json:"resamples"`
	Confidence              float64 `json:"confidence"`
	LCBThreshold            float64 `json:"lcb_threshold"`
	GuardThreshold          float64 `json:"guard_threshold"`
	EnvironmentSHA256       string  `json:"environment_sha256"`
}

ProtocolIdentity seals the statistical protocol and all immutable inputs.

func (ProtocolIdentity) CanonicalJSON

func (p ProtocolIdentity) CanonicalJSON() ([]byte, error)

func (ProtocolIdentity) Digest

func (p ProtocolIdentity) Digest() (string, error)

func (ProtocolIdentity) Hash

func (p ProtocolIdentity) Hash() (string, error)

func (*ProtocolIdentity) UnmarshalJSON

func (p *ProtocolIdentity) UnmarshalJSON(data []byte) error

func (ProtocolIdentity) Validate

func (p ProtocolIdentity) Validate() error

type PublicationBinding

type PublicationBinding struct {
	BinaryIdentitySHA256   string `json:"binary_identity_sha256"`
	ProtocolIdentitySHA256 string `json:"protocol_identity_sha256"`
}

func (PublicationBinding) Validate

func (b PublicationBinding) Validate(binary BinaryIdentity, protocol ProtocolIdentity) error

type Result

type Result struct {
	Cell            int            `json:"cell"`
	Block           int            `json:"block"`
	Order           Order          `json:"order"`
	BlockID         string         `json:"block_id"`
	RunID           string         `json:"run_id"`
	Sequence        int            `json:"sequence"`
	Measurement     Measurement    `json:"measurement"`
	Request         ProcessRequest `json:"request"`
	PID             int            `json:"pid"`
	ProcessIdentity string         `json:"process_identity"`
	StartedAt       time.Time      `json:"started_at"`
	FinishedAt      time.Time      `json:"finished_at"`
	ExitCode        int            `json:"exit_code"`
	Failed          bool           `json:"failed"`
	Error           string         `json:"error,omitempty"`
	Benchmark       string         `json:"benchmark,omitempty"`
	NsPerOp         float64        `json:"ns_per_op,omitempty"`
	BytesPerOp      float64        `json:"bytes_per_op,omitempty"`
	AllocsPerOp     float64        `json:"allocs_per_op,omitempty"`
	StdoutSHA256    string         `json:"stdout_sha256"`
	StderrSHA256    string         `json:"stderr_sha256"`
	RawStdout       string         `json:"raw_stdout"`
	RawStderr       string         `json:"raw_stderr"`
}

type RunManifest

type RunManifest struct {
	Version string `json:"version"`
	ID      string `json:"id"`
}

type ScheduleEntry

type ScheduleEntry struct {
	Cell    int    `json:"gomaxprocs"`
	Block   int    `json:"block"`
	Order   Order  `json:"order"`
	BlockID string `json:"block_id"`
	RunID   string `json:"run_id"`
}

func Schedule

func Schedule(seed uint64, campaign, phase, run string) ([]ScheduleEntry, error)

Schedule creates a deterministic, round-robin cell schedule. Each cell's twenty paired blocks are independently shuffled from the recorded seed and contain ten observations in each order.

type SourceMachineManifest

type SourceMachineManifest struct {
	Version string `json:"version"`
	ID      string `json:"id"`
	OS      string `json:"os"`
	Arch    string `json:"arch"`
	CPU     string `json:"cpu"`
}

type TrustRegistry

type TrustRegistry struct {
	SchemaVersion    string            `json:"schema_version"`
	CampaignID       string            `json:"campaign_id"`
	AmendmentVersion string            `json:"amendment_version"`
	PhaseID          string            `json:"phase"`
	SourceCommit     string            `json:"source_commit"`
	TestBinarySHA256 string            `json:"test_binary_sha256"`
	Gates            map[string]string `json:"gates"`
}

Directories

Path Synopsis
cmd
runner command
Command runner is the deliberately small, strict entry point for collection.
Command runner is the deliberately small, strict entry point for collection.

Jump to

Keyboard shortcuts

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