store

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package store persists the store-owned sidecar files of a completed eval run into the canonical run directory <root>/.agents/eval/runs/<run-id>/. It is one participant in an INCREMENTALLY ASSEMBLED directory: the sandbox creates the run dir, the score stage writes iteration-log/{iter-1.yaml,iter-1.score.yaml} into it, and this package writes the two files it owns (taskspec.yaml, eval-run.yaml). The store therefore does NOT own the whole directory — it never publishes it atomically as a unit, never refuses an existing dir, and never deletes it. Crash-safety is per-file: each file it writes appears atomically (temp-then-rename via internal/fsops) or not at all.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyRunID is returned when the run carries no run ID.
	ErrEmptyRunID = errors.New("store: run id is required")
	// ErrUnsafeRunID is returned when the run ID contains a path separator,
	// a ".." segment, or otherwise does not name a single path element — any
	// of which could escape the <root>/.agents/eval/runs/ directory.
	ErrUnsafeRunID = errors.New("store: run id is not a safe path element")
	// ErrNilSpec is returned when the run carries no task spec.
	ErrNilSpec = errors.New("store: task spec is nil")
	// ErrEmptyRoot is returned when the root dir is empty.
	ErrEmptyRoot = errors.New("store: root dir is required")
	// ErrEmptyRecordPath is returned when the run score has no iteration-record
	// path. The score stage writes it (scoringbridge.Result.RecordPath); its
	// absence means the scoring stage did not complete.
	ErrEmptyRecordPath = errors.New("store: score record path is required")
	// ErrEmptyScorePath is returned when the run score has no score-sidecar
	// path (scoringbridge.Result.ScorePath) — the same "scoring did not
	// complete" signal for the score artifact.
	ErrEmptyScorePath = errors.New("store: score sidecar path is required")
)

Typed errors callers can match with errors.Is.

Functions

func RunDir

func RunDir(root, runID string) string

RunDir returns the canonical sidecar directory for root and runID:

<root>/.agents/eval/runs/<runID>

This path matches the default sandbox.Config.RunsRoot layout so the path the sandbox provisions and the path the store writes are always the same.

Types

type PersistedEvalRun

type PersistedEvalRun struct {
	RunID      string        `yaml:"run_id"`
	BaseCommit string        `yaml:"base_commit"`
	TaskID     string        `yaml:"task_id"`
	Language   string        `yaml:"language"`
	Difficulty string        `yaml:"difficulty"`
	Agent      agentIdentity `yaml:"agent"`
	Verify     verifyOutcome `yaml:"verify"`
	Score      scoreOutcome  `yaml:"score"`
}

PersistedEvalRun is the on-disk YAML shape of eval-run.yaml. It aggregates run identity, the agent-runner identity + reproducibility metadata (spec R9 / R10, plan D6), the verification result, and the score summary so the R2 dashboard can render a run without reading all four sidecar files.

type Result

type Result struct {
	// RunDir is the run's sidecar directory (<root>/.agents/eval/runs/<run-id>).
	RunDir string
	// TaskspecPath is the persisted task spec (<RunDir>/taskspec.yaml).
	TaskspecPath string
	// EvalRunPath is the persisted run aggregate (<RunDir>/eval-run.yaml).
	EvalRunPath string
	// IterLogDir is the iteration-log subdirectory (<RunDir>/iteration-log).
	IterLogDir string
	// RecordPath is the iteration record (<IterLogDir>/iter-1.yaml).
	RecordPath string
	// ScorePath is the score sidecar (<IterLogDir>/iter-1.score.yaml).
	ScorePath string
}

Result reports the persisted artifact paths produced by WriteEvalRun. Every path names the canonical location under the run dir.

func WriteEvalRun

func WriteEvalRun(run harness.EvalRun, root string) (Result, error)

WriteEvalRun persists the store-owned files of a completed eval run into the (incrementally assembled) canonical run directory:

<root>/.agents/eval/runs/<run.RunID>/
  taskspec.yaml                    — the eval.TaskSpec        (store-owned)
  eval-run.yaml                    — run aggregate + R9/R10    (store-owned)
  iteration-log/iter-1.yaml        — R1-shaped iteration record (score stage)
  iteration-log/iter-1.score.yaml  — score sidecar             (score stage)

It ensures the run dir (and iteration-log) exist, then writes taskspec.yaml and eval-run.yaml with per-file atomic writes (temp-then-rename via fsops.WriteFileAtomic) — the crash-safety unit is the individual file, so a mid-write failure of one leaves no torn file and never touches the others.

The iteration-log artifacts belong to the score stage. WriteEvalRun ADAPTS to both wirings: when run.Score.RecordPath / ScorePath already resolve to their canonical location inside this run dir (the merged harness, where the score stage wrote them in place), it adopts them — validating they exist, never copying a file onto itself. When they resolve to a scratch location outside the run dir, it copies them in atomically. It never deletes the run dir and never refuses an existing one.

Jump to

Keyboard shortcuts

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