lab

package
v0.73.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 15 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 lab reads agent runs (a before tree, an after tree, a transcript and the inputs the agent was given) and serves them as JSON to the lab UI. An eval run folder is one source of runs, and docs/evals.md gives its format.

Index

Constants

View Source
const (
	TranscriptFile = "transcript.jsonl"
	TimesFile      = "transcript.times"
	DiffFile       = "diff.patch"
	BeforeDir      = "before"
	AfterDir       = "after"
	InputsDir      = "inputs"
)

The run folder's layout. f10eval writes it, and lab and the report page read it.

Variables

This section is empty.

Functions

func Handler

func Handler(src Source) http.Handler

Handler serves src under /api/ as JSON, for the lab UI. A file's path rides in the query, so any path reaches Content as the tree spells it.

Types

type Event

type Event struct {
	AtMS  int64           `json:"at_ms"`
	Event json.RawMessage `json:"event"`
}

An Event is one transcript event and its arrival in milliseconds since the run's first turn.

type File

type File struct {
	Path   string `json:"path"`
	Status Status `json:"status"`
	Link   bool   `json:"link,omitempty"`
}

A File is one path of a run, slash-separated. Link is true when either side holds a symlink there, which the content is the target of.

type Input

type Input struct {
	Name string `json:"name"`
	Text string `json:"text"`
}

An Input is one thing the agent was given, such as its task.

type Line

type Line struct {
	AtMS int64
	Text string
}

A Line is one transcript line as claude printed it, with its arrival in milliseconds since the run's first turn.

func ReadTranscript

func ReadTranscript(dir string) ([]Line, error)

ReadTranscript is every line of dir's transcript, a bad one included, so a caller's index still matches the times file. A missing or short times file leaves the times at 0. A missing transcript is fs.ErrNotExist, because a run that failed before its first turn has none and each caller decides what that means.

type Match

type Match struct {
	Path string `json:"path"`
	Line int    `json:"line"`
	Text string `json:"text"`
}

A Match is one line of a run's after tree that holds the query.

type Matches

type Matches struct {
	Matches   []Match `json:"matches"`
	Truncated bool    `json:"truncated"`
}

Matches is a search's answer. Truncated says the limit cut it short.

func Search(ctx context.Context, run Run, query string, limit int) (Matches, error)

Search finds query, case-insensitively and literally, in every file of run's after tree. It reads through the Run interface, so any source gets it. Links and binary files are skipped, and it stops after limit matches.

type Run

type Run interface {
	Info() RunInfo
	// Files is every path in either tree, sorted, with its status.
	Files(ctx context.Context) ([]File, error)
	// Content is a file as one side holds it, fs.ErrNotExist when that side
	// has no such file.
	Content(ctx context.Context, side Side, path string) ([]byte, error)
	Transcript(ctx context.Context) ([]Event, error)
	Inputs(ctx context.Context) ([]Input, error)
	// Diff is the patch as the source wrote it, empty when it has none.
	Diff(ctx context.Context) ([]byte, error)
}

A Run is one agent run: what the agent was handed, what it left, and how it got there.

type RunInfo

type RunInfo struct {
	ID      string          `json:"id"`
	Title   string          `json:"title"`
	Summary json.RawMessage `json:"summary,omitempty"`
}

RunInfo names a run. Summary is whatever the source keeps about the run as a whole, such as an eval report, passed to the UI as is.

type SetEntry

type SetEntry struct {
	File    string
	RunDir  string
	Summary json.RawMessage
}

A SetEntry is one report in a set folder. Summary is the report as written, because lab reads nothing in it but run_dir. RunDir is empty for a report from before run folders.

func ReadSet

func ReadSet(dir string) ([]SetEntry, error)

ReadSet is dir's reports in name order. A .json file that is not an object is not a report and is skipped.

type Side

type Side string

A Side is one of a run's two trees.

const (
	Before Side = "before"
	After  Side = "after"
)

type Source

type Source interface {
	Runs(ctx context.Context) ([]RunInfo, error)
	// Open returns fs.ErrNotExist for an id Runs does not list.
	Open(ctx context.Context, id string) (Run, error)
}

A Source lists runs and opens them. An eval folder is one source. A task or a PR read from git will be another, so nothing here assumes a folder.

func OpenPath

func OpenPath(dir string) (Source, error)

OpenPath reads path as an eval run folder or an eval set folder. A run folder holds before/, after/ or a transcript. A set folder holds reports.

type Status

type Status string

A Status is how a path changed from before to after.

const (
	Added     Status = "added"
	Modified  Status = "modified"
	Deleted   Status = "deleted"
	Unchanged Status = "unchanged"
)

Jump to

Keyboard shortcuts

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