contract

package
v0.2.0-alpha.8 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package contract defines the BuildMax-owned evaluation contract: the task, subject, trial, grader, and experiment shapes every runner, adapter, and viewer agrees on.

It depends on the standard library alone. That is a decision rather than an accident: docs/design/evaluation-system.md section 15.3 makes a standard-library Go controller the default so an operator can qualify a deployment from one binary, and so evaluation never adds a dependency to the product's go.mod.

Nothing here imports the BuildMax runtime. A trial bundle is qualification evidence that outlives the revision which produced it, so the format has to stay readable without a BuildMax process.

Index

Constants

View Source
const (
	ExperimentFile = "experiment.json"
	TrialsDir      = "trials"
	BundleFile     = "bundle.json"
	TraceFile      = "trace.jsonl"
	ArtifactsDir   = "artifacts"
)

A bundle is a directory, not a file. Section 15.4 left the physical encoding to the slice, and the deciding argument is that most of a bundle is already files: a JSONL trace, workspace state, produced artifacts. Inlining those into one JSON document contradicts the bounded-evidence rule they exist to satisfy, while keeping one failure's whole evidence in one directory is exactly the reproduction path section 17 asks a failed trial to hand over.

The layout is:

<root>/experiment.json
<root>/trials/<task_id>/<index>/bundle.json
<root>/trials/<task_id>/<index>/trace.jsonl
<root>/trials/<task_id>/<index>/artifacts/
View Source
const (
	// TaskFile is the task definition, read by the runner and never copied.
	TaskFile = "task.json"
	// StateDir holds the visible initial state. Its contents, and nothing
	// else, become the trial workspace.
	StateDir = "state"
	// GradersDir holds grader material the Agent must not read.
	GradersDir = "graders"
	// OracleDir holds the executable reference solution.
	OracleDir = "oracle"
)

Task directory layout. The split is the hidden-grader boundary from section 18.4, expressed as a convention rather than a per-task path list: a task cannot leak its grader by misconfiguring a field, because only StateDir is ever materialized into the trial workspace.

View Source
const Version = 1

Version is the contract generation stamped on every task, subject manifest, trial bundle, and experiment.

A reader meeting a version it does not know must refuse the file rather than interpret the fields it happens to recognise. A partial read of qualification evidence produces a confident wrong answer, which is worse than no answer.

Variables

View Source
var ErrVersion = errors.New("unsupported contract version")

ErrVersion is returned when stored evidence was written by a contract generation this build does not implement.

Functions

func CriticalFailures

func CriticalFailures(results []GraderResult) []string

CriticalFailures returns the names of critical graders that failed. Section 7.5 keeps these outside every suite summary, so a report needs them by name rather than as a count folded into a pass rate.

func Materialized

func Materialized(name string) bool

Materialized reports whether a task-directory entry belongs in the trial workspace. Everything outside StateDir stays behind the trial boundary, including files a task author adds later without updating this package.

func TrialDir

func TrialDir(root, taskID string, index int) (string, error)

TrialDir is where one attempt's evidence lives.

func WriteBundle

func WriteBundle(root string, b TrialBundle) (string, error)

WriteBundle records one trial, creating its directory. It returns the directory so a caller can place the trace and artifacts beside the manifest.

func WriteExperiment

func WriteExperiment(root string, e Experiment) error

WriteExperiment records the experiment at the root of a bundle tree.

Types

type ArtifactRef

type ArtifactRef struct {
	Name   string `json:"name"`
	Digest string `json:"digest"`
	Bytes  int64  `json:"bytes"`
	// Verified is the grader output that checked it, empty when nothing did.
	Verified string `json:"verified,omitempty"`
}

ArtifactRef identifies something the trial produced, by hash rather than by content, so a bundle stays bounded while still proving what was made.

type BuildIdentity

type BuildIdentity struct {
	Version string `json:"version"`
	Commit  string `json:"commit"`
	// Dirty is the digest of uncommitted changes, empty for a clean tree. A
	// boolean would say a local build is unreproducible without saying which
	// local build it was, and two dirty candidates would then compare as the
	// same subject.
	Dirty string `json:"dirty,omitempty"`
	// ArtifactDigest is the binary or container image measured. It is what
	// makes this a black-box result: without it the manifest describes a source
	// revision rather than the thing that ran.
	ArtifactDigest string `json:"artifact_digest"`
}

BuildIdentity is the artifact under evaluation.

type Comparison

type Comparison struct {
	ContractVersion int    `json:"contract_version"`
	ExperimentID    string `json:"experiment_id"`
	Suite           string `json:"suite"`
	BaselineID      string `json:"baseline_id"`
	CandidateID     string `json:"candidate_id"`

	Baseline  SuiteMetrics `json:"baseline"`
	Candidate SuiteMetrics `json:"candidate"`

	// Delta is candidate pass rate minus baseline, with the interval of the
	// paired difference. The interval is the point of a paired design: two
	// separately-computed rates can both move without their difference being
	// distinguishable from noise.
	Delta     float64 `json:"delta"`
	DeltaLow  float64 `json:"delta_low"`
	DeltaHigh float64 `json:"delta_high"`

	// Improved and Regressed name tasks whose outcome changed direction.
	// Unscorable names tasks the comparison could not judge on either side,
	// which section 12 requires shown rather than omitted: a task silently
	// dropped from both arms reads as agreement.
	Improved   []string `json:"improved,omitempty"`
	Regressed  []string `json:"regressed,omitempty"`
	Unscorable []string `json:"unscorable,omitempty"`
}

Comparison is a candidate measured against a baseline over the same tasks. Pairing is by task and trial index, which is why TrialBundle records the index rather than relying on file order.

type CriticalFailure

type CriticalFailure struct {
	TaskID string `json:"task_id"`
	Grader string `json:"grader"`
	Detail string `json:"detail,omitempty"`
}

CriticalFailure is one hard-gate violation, named so a release decision can cite it.

type DatasetRef

type DatasetRef struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	Digest  string `json:"digest"`
}

DatasetRef pins the task collection by immutable version and digest, which is what lets a private or rotating holdout use the same contract as the public suite without the public suite depending on private access.

type Domain

type Domain string

Domain is the evaluation question a task is built to answer. The four domains keep separate scorecards: section 7.5 forbids the weighted average that would let a capability gain pay for a trust violation.

const (
	DomainCapability     Domain = "capability"
	DomainReliability    Domain = "reliability"
	DomainTrust          Domain = "trust"
	DomainProductOutcome Domain = "product_outcome"
)

type Duration

type Duration int64

Duration is a wall-clock span serialised as milliseconds. time.Duration marshals as nanoseconds, which is precision this format cannot honour and a reader outside Go has to know to divide; milliseconds is what the runtime's own JSON already reports.

func FromDuration

func FromDuration(d time.Duration) Duration

FromDuration converts a Go duration for storage.

func (Duration) Duration

func (d Duration) Duration() time.Duration

Duration converts back.

type ExecutionIdentity

type ExecutionIdentity struct {
	Surface Surface `json:"surface"`
	// AdapterVersion changes when the adapter changes how it invokes the
	// subject. An adapter change moves results without the product moving, and
	// a comparison spanning one is not paired.
	AdapterVersion int `json:"adapter_version"`
}

ExecutionIdentity is how the trial reached the subject.

type Experiment

type Experiment struct {
	ContractVersion int        `json:"contract_version"`
	ID              string     `json:"id"`
	Name            string     `json:"name"`
	CreatedAt       time.Time  `json:"created_at"`
	Dataset         DatasetRef `json:"dataset"`

	// Subjects are what was measured. A comparison names two of them; a single
	// qualification run has one. They are stored in full rather than by ID
	// because the manifest is the only thing that makes an old result legible.
	Subjects []SubjectManifest `json:"subjects"`
	// Baseline is the subject ID other subjects are compared against, empty
	// when the experiment is not a comparison.
	Baseline string `json:"baseline,omitempty"`

	// Trials is the repetition count applied to every task, overriding the
	// task's own default when higher. Section 12 estimates pass@1 from
	// independent attempts, so one attempt per task is a measurement without an
	// error bar rather than a cheaper version of the same result.
	Trials int `json:"trials"`

	// Tasks are the task IDs included, recorded because a suite filter that is
	// not written down turns two runs of "the same" experiment into an
	// unpaired comparison.
	Tasks []string `json:"tasks"`
}

Experiment is one measurement run: a set of subjects over a dataset, with a repetition count. It is recorded beside its trials so a bundle directory explains itself without the command that produced it.

func ReadExperiment

func ReadExperiment(root string) (Experiment, error)

ReadExperiment loads the experiment at the root of a bundle tree.

type ExtensionInputs

type ExtensionInputs struct {
	Plugins  []string `json:"plugins,omitempty"`
	Skills   []string `json:"skills,omitempty"`
	MCP      []string `json:"mcp,omitempty"`
	Subagent []string `json:"subagents,omitempty"`
}

ExtensionInputs identifies what the subject loaded from outside itself. Section 18.2 records that the trace names plugins but not MCP servers and skills separately; the manifest names all three, so a subject stays identifiable while that trace gap is open.

type GraderKind

type GraderKind string

GraderKind separates the three sources of judgement section 10 keeps apart. It is recorded on every result because section 10.3 forbids a model grader from overruling a deterministic failure, and a reader cannot enforce that without knowing which produced which.

const (
	// GraderDeterministic checks final state, artifacts, or contracts.
	GraderDeterministic GraderKind = "deterministic"
	// GraderTrace asserts over recorded process events.
	GraderTrace GraderKind = "trace"
	// GraderModel scores a dimension no state check reduces.
	GraderModel GraderKind = "model"
)

type GraderRef

type GraderRef struct {
	Name    string     `json:"name"`
	Version int        `json:"version"`
	Kind    GraderKind `json:"kind"`
	// Required means the trial fails when this grader fails. An optional
	// grader reports a dimension without deciding the outcome.
	Required bool `json:"required"`
	// Critical marks a hard gate. Section 7.5 keeps these out of any suite
	// summary, so a critical failure cannot be averaged away.
	Critical bool `json:"critical,omitempty"`
	// Config is the grader's own parameters, opaque here. Graders version
	// separately from the contract, so their schemas must not force a contract
	// version bump.
	Config json.RawMessage `json:"config,omitempty"`
}

GraderRef names one grader a task applies, and the configuration it is applied under.

type GraderResult

type GraderResult struct {
	Name    string     `json:"name"`
	Version int        `json:"version"`
	Kind    GraderKind `json:"kind"`
	// Required and Critical are copied from the task's GraderRef rather than
	// looked up. A bundle is read years after the task may have changed, and a
	// verdict whose gating weight has to be resolved elsewhere is a verdict
	// that will eventually be re-interpreted.
	Required bool `json:"required"`
	Critical bool `json:"critical,omitempty"`

	Verdict Verdict `json:"verdict"`
	// Score is the dimension's value where one exists, in [0,1]. Absent for a
	// grader that only decides, which is not the same as scoring zero.
	Score *float64 `json:"score,omitempty"`
	// Explanation is why, in the grader's own words. Deterministic graders put
	// their output here; model graders put their reasoning.
	Explanation string `json:"explanation,omitempty"`

	// Subject identifies the model that produced a model grader's verdict, and
	// Usage what it cost. Section 10.3 makes a judge a measured component
	// rather than an oracle, and a judge whose own configuration is unrecorded
	// cannot be re-calibrated against the labels it was validated on.
	Subject string `json:"subject,omitempty"`
	Usage   *Usage `json:"usage,omitempty"`

	Duration Duration `json:"duration,omitempty"`
	// Error means the grader could not reach a verdict at all, as distinct
	// from reaching VerdictUnknown deliberately.
	Error string `json:"error,omitempty"`
}

GraderResult is what one grader concluded about one trial.

type HostProfile

type HostProfile struct {
	OS       string `json:"os"`
	Arch     string `json:"arch"`
	CPUs     int    `json:"cpus,omitempty"`
	MemoryMB int    `json:"memory_mb,omitempty"`
	// Network says what the trial could reach: "none", "proxied", "open". A
	// task failing for lack of network is not an Agent that cannot do it.
	Network string `json:"network,omitempty"`
}

HostProfile is the machine the trial ran on. It separates a regression from a slower machine, which section 12 needs before a latency delta means anything.

type InstructionInputs

type InstructionInputs struct {
	SystemPromptDigest string `json:"system_prompt_digest"`
	ToolSchemaDigest   string `json:"tool_schema_digest"`
	// Layers names the instruction sources in order, without their bodies:
	// a workspace AGENTS.md, an agent definition, session notes. The names are
	// provenance; the digest above is what actually pins the content.
	Layers []string `json:"layers,omitempty"`
}

InstructionInputs identifies what the subject was told, by digest.

type Limits

type Limits struct {
	WallSeconds int `json:"wall_seconds"`
	Iterations  int `json:"iterations,omitempty"`
	ToolCalls   int `json:"tool_calls,omitempty"`
	Tokens      int `json:"tokens,omitempty"`
}

Limits bound one trial. Each is a stop condition rather than a target, and exhausting one produces StatusTimedOut rather than a grader failure, so a task merely too small to finish in is not reported as an Agent that could not finish it.

type ModelIdentity

type ModelIdentity struct {
	// Transport is how inference was reached: a provider protocol, or the
	// managed gateway. Two subjects reaching the same model through different
	// transports are different subjects.
	Transport string `json:"transport"`
	Target    string `json:"target"`
	Alias     string `json:"alias,omitempty"`
	// Revision is the exact model build the provider reported. Absent means the
	// provider reported none, which the manifest states rather than filling in
	// from the target name: section 8.2 requires recorded uncertainty over
	// invented precision, because a qualification that names a revision the
	// provider never confirmed cannot be re-run against it.
	Revision      string `json:"revision,omitempty"`
	Reasoning     string `json:"reasoning,omitempty"`
	ContextWindow int    `json:"context_window,omitempty"`
	MaxOutput     int    `json:"max_output,omitempty"`
}

ModelIdentity is the inference configuration.

type PolicyResolution

type PolicyResolution struct {
	Permissions string `json:"permissions"`
	// Sandboxed is a pointer so an unsandboxed subject records false rather
	// than omitting the field, for the reason the trace does the same: an
	// unreported boundary is indistinguishable from an unresolved one, and a
	// reader breaking that tie favourably would credit a subject with
	// protection it never had.
	Sandboxed   *bool    `json:"sandboxed"`
	SandboxMode string   `json:"sandbox_mode,omitempty"`
	Hooks       []string `json:"hooks,omitempty"`
}

PolicyResolution is the boundary the subject ran under, as resolved rather than as configured. What a settings file requested and what the runtime granted differ, and only the second describes the trial.

type Reproduction

type Reproduction struct {
	Command     []string          `json:"command"`
	Environment map[string]string `json:"environment,omitempty"`
	Dataset     DatasetRef        `json:"dataset"`
	// Note is anything a re-runner needs that the command does not carry, such
	// as a dependency that must already be installed.
	Note string `json:"note,omitempty"`
}

Reproduction is the bounded path back to this trial.

type RetentionLevel

type RetentionLevel string

RetentionLevel is how much of a trial's free text the bundle keeps. Section 7.6 keeps bundles local by default; retention is what makes an export bounded rather than a copy of a private workspace.

const (
	// RetentionFull keeps replies, tool arguments, and results as recorded.
	RetentionFull RetentionLevel = "full"
	// RetentionBounded keeps them truncated and redacted.
	RetentionBounded RetentionLevel = "bounded"
	// RetentionMetadata keeps no free text at all: statuses, digests, counts,
	// and grader verdicts only. This is the level an export defaults to.
	RetentionMetadata RetentionLevel = "metadata"
)

type SubjectManifest

type SubjectManifest struct {
	ContractVersion int    `json:"contract_version"`
	Name            string `json:"name"`
	// ID is the digest of every other field, from Digest. Two trials share a
	// subject when they share this value, which is what makes a paired
	// comparison honest: the alternative, comparing by name, silently pairs
	// runs whose configuration drifted between them.
	ID string `json:"id"`

	Build        BuildIdentity     `json:"build"`
	Execution    ExecutionIdentity `json:"execution"`
	Model        ModelIdentity     `json:"model"`
	Instructions InstructionInputs `json:"instructions"`
	Extensions   ExtensionInputs   `json:"extensions"`
	Policy       PolicyResolution  `json:"policy"`
	Host         HostProfile       `json:"host"`
	// Dataset is the task collection version this subject was measured over.
	// It sits on the subject as well as the experiment because a bundle read on
	// its own must still say what it was asked.
	Dataset DatasetRef `json:"dataset"`
}

SubjectManifest freezes the configuration a trial measured. Section 2.2 is the reason it exists: a run's behavior comes from the revision, the model, the instructions, the extensions, the policy, and the host together, so a result naming only a model cannot support a qualification or a regression decision.

Secrets and private instruction bodies do not belong here. The manifest carries their digests and safe provenance instead, so identifying a subject never turns a stored result into a credential or a content store.

func (SubjectManifest) Digest

func (m SubjectManifest) Digest() (string, error)

Digest returns the subject's content identity: the SHA-256 of the manifest with ID cleared. Callers set ID from it before recording a trial.

func (SubjectManifest) WithID

func (m SubjectManifest) WithID() (SubjectManifest, error)

WithID returns the manifest carrying its own digest as ID.

type SuiteMetrics

type SuiteMetrics struct {
	Suite     string `json:"suite"`
	SubjectID string `json:"subject_id"`

	Trials int `json:"trials"`
	// Scored is the number of trials that judged the subject. The pass rate
	// below is over this, not over Trials, so harness faults neither count as
	// failures nor silently shrink the denominator without being visible.
	Scored int `json:"scored"`
	Passed int `json:"passed"`

	// PassRate is Passed over Scored, and IntervalLow/High its confidence
	// interval. A rate without an interval invites reading a two-trial
	// difference as a regression.
	PassRate     float64 `json:"pass_rate"`
	IntervalLow  float64 `json:"interval_low"`
	IntervalHigh float64 `json:"interval_high"`

	// ConsistencyRate is the share of tasks passing every attempt: pass^k, for
	// suites where consistency rather than best-of-k is the product promise.
	ConsistencyRate float64 `json:"consistency_rate,omitempty"`

	// Faults counts the statuses that blamed the harness, by status. Section 12
	// reports these rather than dropping them, because a suite losing a third
	// of its trials otherwise looks like one that ran clean.
	Faults map[TrialStatus]int `json:"faults,omitempty"`

	// CriticalFailures names the task and grader of every critical failure.
	// These are gates, not inputs to a rate.
	CriticalFailures []CriticalFailure `json:"critical_failures,omitempty"`

	Usage    Usage `json:"usage"`
	MedianMS int64 `json:"median_ms,omitempty"`
	P95MS    int64 `json:"p95_ms,omitempty"`
}

SuiteMetrics is one suite's result vector for one subject. Section 12 asks for a vector rather than a score: the fields here are separate because nothing in this struct is allowed to be averaged into the others.

type Surface

type Surface string

Surface is the execution adapter a task runs through. It belongs to the task rather than to the experiment because a task written for worker artifacts does not become a local task by being run locally; cross-surface parity compares two tasks stating the same abstract goal, not one task run twice.

const (
	SurfaceAgentCore    Surface = "agent_core"
	SurfaceCLI          Surface = "cli"
	SurfaceDesktop      Surface = "desktop"
	SurfaceWorker       Surface = "worker"
	SurfaceConversation Surface = "conversation"
	SurfaceDeployment   Surface = "deployment"
	SurfaceHarbor       Surface = "harbor"
)

type Task

type Task struct {
	ContractVersion int      `json:"contract_version"`
	ID              string   `json:"id"`
	Version         int      `json:"version"`
	Suite           string   `json:"suite"`
	Title           string   `json:"title"`
	Tags            []string `json:"tags,omitempty"`
	Domain          Domain   `json:"domain"`
	Surface         Surface  `json:"surface"`

	// Turns is what the user says, in order. A single-turn task has one entry.
	// Modelling every task as a sequence avoids a second code path for the
	// multi-turn scenarios section 11 requires; a richer turn, such as a
	// simulated user with a policy, extends this field rather than adding one.
	Turns []string `json:"turns"`

	// Capabilities are what the subject must provide for the task to mean
	// anything, such as a sandbox backend or a configured MCP server. A subject
	// missing one yields invalid_task, not a failed attempt: the task was never
	// asked under the conditions it describes.
	Capabilities []string `json:"capabilities,omitempty"`

	Limits Limits `json:"limits"`

	// Graders run in the order given. A required grader that fails decides the
	// trial; an optional one contributes a dimension without gating.
	Graders []GraderRef `json:"graders"`

	// Negative marks a task whose required outcome is that something did not
	// happen: a boundary held, a file was left alone, a tool was never reached.
	//
	// Such a task's deterministic graders legitimately pass against the
	// untouched initial state, because changing nothing is the correct answer,
	// so preflight's "does not already satisfy the outcome" check does not
	// apply to it. What must apply instead is a required trace or model grader:
	// without one the task asserts only that nothing happened, which an agent
	// that did nothing at all — or never ran — would satisfy just as well.
	Negative bool `json:"negative,omitempty"`

	// Trials is the default independent-attempt count. An experiment may raise
	// it; a task only meaningful over repetition — anything measuring pass^k —
	// says so here rather than relying on the caller to know.
	Trials int `json:"trials"`

	// Environment pins the versions a trial depends on beyond the subject, such
	// as a container image or a language toolchain. It is copied onto the
	// bundle so a later reader can tell an environment change from a subject
	// change.
	Environment map[string]string `json:"environment,omitempty"`

	// Oracle is the command completing the task from the initial state, run
	// from OracleDir. Preflight requires it to pass every required grader: a
	// task whose own reference solution fails is measuring its graders rather
	// than the Agent.
	Oracle []string `json:"oracle,omitempty"`
}

Task is one evaluation case: what is asked, what state it starts from, what bounds it, and what must be true afterwards.

type TrialBundle

type TrialBundle struct {
	ContractVersion int    `json:"contract_version"`
	TrialID         string `json:"trial_id"`
	ExperimentID    string `json:"experiment_id"`
	TaskID          string `json:"task_id"`
	TaskVersion     int    `json:"task_version"`
	Suite           string `json:"suite"`
	SubjectID       string `json:"subject_id"`
	// Index is which independent attempt this is, from zero. Paired comparison
	// matches candidate and baseline on task and index, so it has to be
	// recorded rather than inferred from file order.
	Index int `json:"index"`

	Domain  Domain  `json:"domain"`
	Surface Surface `json:"surface"`

	Status TrialStatus `json:"status"`
	// FailureClass refines Status for a failure, such as a boundary violation
	// or an early stop. It is free-form because the taxonomy is expected to
	// grow from observed failures rather than be enumerated in advance; a gate
	// reads Status, and a human reads this.
	FailureClass string `json:"failure_class,omitempty"`
	// Error is what went wrong for a status that is not a grader verdict.
	Error string `json:"error,omitempty"`

	StartedAt time.Time `json:"started_at"`
	Duration  Duration  `json:"duration"`

	// InitialStateDigest is the workspace the trial started from. Without it a
	// re-run cannot prove it began where the recorded one did, and section 8.1
	// requires an initial state that does not already satisfy the outcome.
	InitialStateDigest string `json:"initial_state_digest"`
	// FinalStateDigest is what the workspace became. It is the outcome-first
	// evidence of section 7.1: a reply claiming a file was written is not the
	// file.
	FinalStateDigest string `json:"final_state_digest,omitempty"`

	Retention RetentionLevel `json:"retention"`
	// Reply is the subject's final answer, subject to Retention. Absent at
	// metadata retention, which is not the same fact as a run that said
	// nothing.
	Reply string `json:"reply,omitempty"`

	// TracePath is the durable trace inside the bundle directory, relative to
	// it. Children are the subagent traces the run spawned, so a delegation
	// failure is diagnosable from the bundle alone.
	TracePath      string   `json:"trace_path,omitempty"`
	ChildTracePath []string `json:"child_trace_paths,omitempty"`

	Artifacts []ArtifactRef  `json:"artifacts,omitempty"`
	Graders   []GraderResult `json:"graders,omitempty"`
	Usage     Usage          `json:"usage"`

	// Reproduce is the bounded description of how to run this trial again:
	// the command, the environment it needed, and the dataset it came from.
	// Section 17 makes it part of what a failure has to hand a contributor.
	Reproduce Reproduction `json:"reproduce"`
}

TrialBundle is the canonical interchange record for one attempt, and the stable boundary between runners, graders, and viewers. Qualification gates read only the fields defined here; an extension may add its own without becoming something a gate depends on.

func ReadBundle

func ReadBundle(dir string) (TrialBundle, error)

ReadBundle loads one trial from its directory.

func ReadBundles

func ReadBundles(root string) ([]TrialBundle, error)

ReadBundles loads every trial under a bundle tree, ordered by task then index. The order is derived from the manifests rather than from directory listing, so a comparison pairing on index does not depend on how the filesystem happens to sort "10" against "9".

type TrialStatus

type TrialStatus string

TrialStatus is how one attempt ended. Section 7.4 is the whole point of the enumeration: Agent failure, invalid task, infrastructure failure, grader failure, timeout, and cancellation are different facts, and collapsing them into pass/fail reports provider outages and broken tasks as incapability.

const (
	// StatusPassed means every required grader passed.
	StatusPassed TrialStatus = "passed"
	// StatusFailed means execution completed and a required grader failed.
	StatusFailed TrialStatus = "failed"
	// StatusAgentError means the Agent runtime failed before producing a
	// gradable outcome.
	StatusAgentError TrialStatus = "agent_error"
	// StatusInfrastructureError means the environment or a dependency failed
	// independently of Agent capability.
	StatusInfrastructureError TrialStatus = "infrastructure_error"
	// StatusGraderError means required grading could not complete, so the
	// attempt is unscored rather than failed.
	StatusGraderError TrialStatus = "grader_error"
	// StatusTimedOut means a stated budget expired: the task's wall time, or
	// the iteration cap it asked the subject to run under. Both are the task
	// saying how much the answer may cost, so a subject that ran out of either
	// failed the task as written rather than hitting a broken harness.
	StatusTimedOut TrialStatus = "timed_out"
	// StatusCanceled means the experiment controller stopped the trial.
	StatusCanceled TrialStatus = "canceled"
	// StatusInvalidTask means preflight or task integrity failed, so nothing
	// about the subject was measured.
	StatusInvalidTask TrialStatus = "invalid_task"
)

func DecideStatus

func DecideStatus(results []GraderResult) TrialStatus

DecideStatus derives a trial's terminal status from its grader results, assuming execution itself completed. A caller that already knows the run failed, timed out, or was cancelled records that status instead: this function only distinguishes the outcomes grading can distinguish.

A definite required failure wins over an inconclusive one. Once any required grader has said fail on evidence it could read, the trial has failed the task as written, and waiting on another grader's uncertainty would only turn a known result into an unknown one.

func (TrialStatus) HarnessFault

func (s TrialStatus) HarnessFault() bool

HarnessFault reports whether the status blames the harness rather than the subject. Section 12 requires these reported as their own rates instead of disappearing, because a suite quietly dropping a third of its trials looks identical to one that ran clean.

func (TrialStatus) Scored

func (s TrialStatus) Scored() bool

Scored reports whether the status is a judgement about the subject. Only passed, failed, and timed_out are: a trial the harness could not run says nothing about capability, and a rate computed over the rest understates a subject in proportion to how unreliable the harness was that day.

Timeouts count because a budget is part of the task. A subject that cannot finish inside the stated limit has failed the task as written.

type Usage

type Usage struct {
	LLMCalls         int `json:"llm_calls"`
	ToolCalls        int `json:"tool_calls"`
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	CacheReadTokens  int `json:"cache_read_tokens,omitempty"`
	CacheWriteTokens int `json:"cache_write_tokens,omitempty"`
	// Cost is nano-units of Currency, matching the runtime's integer
	// representation so a reader sums a suite exactly. Absent when the model
	// was unpriced.
	Cost     *int64 `json:"cost,omitempty"`
	Currency string `json:"currency,omitempty"`
	// CostIncomplete says part of the trial could not be priced, so Cost
	// understates it rather than covering it.
	CostIncomplete bool `json:"cost_incomplete,omitempty"`
}

Usage is what the trial consumed. Cost is deliberately absent unless priced: section 12 admits cost only when pricing input is explicit and versioned, and a zero would read as free rather than as unpriced.

type Verdict

type Verdict string

Verdict is one grader's judgement. It is three-valued because section 10.3 requires a model grader to have an unknown path: a judge forced to choose between pass and fail on evidence it cannot read will choose one, and a coerced verdict is indistinguishable from a considered one afterwards.

const (
	VerdictPass    Verdict = "pass"
	VerdictFail    Verdict = "fail"
	VerdictUnknown Verdict = "unknown"
)

Jump to

Keyboard shortcuts

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