Documentation
¶
Overview ¶
Package eval provides FakeModel-scripted harness evaluation scenarios and scoring.
Index ¶
- Constants
- Variables
- func AgreementRate(judge JudgeScores, gold GoldScores) (rate float64, compared int)
- func AnnotateLayerMetrics(m *Metrics, caseName, tier string, tags []string, expect Expectation)
- func CapabilityCaseDirs() ([]string, error)
- func CountToolErrors(messages []msg.AgentMessage) int
- func DefaultGoldByCase(dir string, names []string) (map[string]GoldScores, error)
- func DefaultGoldByCaseFromDirs(dirs, names []string) (map[string]GoldScores, error)
- func DetailHTMLName(suite, stamp string) string
- func FailReason(m Metrics, expect Expectation) string
- func FormatCompareMarkdown(diff *CompareDiff) string
- func JudgeDimension(ctx context.Context, model llms.Model, ...) (int, string, bool, error)
- func JudgePrompt(dimension, task, transcript, finalText string) string
- func NormalizeDifficulty(raw string) string
- func NormalizeTier(raw string) string
- func OpenQAGoldDir() (string, error)
- func PassAtK(trialPasses [][]bool) float64
- func PassHatK(trialPasses [][]bool) float64
- func ResetScenarioWorkspace(sc Scenario) error
- func ResolveCasesDir(candidates ...string) (string, error)
- func TextScript(content string) agentllm.ResponseScript
- func ToolCallScript(id, name, argsJSON string) agentllm.ResponseScript
- func TranscriptSummary(messages []msg.AgentMessage, lineLimit int) string
- func WriteDetailHTML(path string, report EvalReport) error
- func WriteHTMLReports(dir string) error
- func WriteOverviewHTML(path string, reports []ReportFile) error
- func WriteReportJSON(path string, report EvalReport) error
- func WriteReportMarkdown(path string, report EvalReport) error
- func WriteTaskDraftYAML(dir string, draft TaskDraft) (string, error)
- type CapabilityScorecard
- type CaseResult
- type CompareDiff
- type DockerSandbox
- type DockerSandboxConfig
- type EvalReport
- type Expectation
- type FileAssert
- type GoldScores
- type JudgeScores
- type LiveOptions
- type LoadOptions
- type MeanCI
- type Metrics
- type OutcomeAsserts
- type ProgressEvent
- type ProgressFunc
- type ReportFile
- type ReportSummary
- type RunResult
- func RunFakeScenario(ctx context.Context, scenario Scenario) (RunResult, error)
- func RunFakeScenarioWithHarness(ctx context.Context, scenario Scenario) (RunResult, error)
- func RunWithModel(ctx context.Context, scenario Scenario, model llms.Model, modelName string) (RunResult, error)
- func RunWithModelHarness(ctx context.Context, scenario Scenario, model llms.Model, modelName string) (RunResult, error)
- type RuntimeSandbox
- type Sandbox
- type Scenario
- func BuiltinCapabilityScenarios(workspaceParent string) ([]Scenario, error)
- func BuiltinCapabilityScenariosWithOptions(workspaceParent string, opts LoadOptions) ([]Scenario, error)
- func BuiltinHarnessScenarios(workspaceParent string) ([]Scenario, error)
- func BuiltinHarnessScenariosWithOptions(workspaceParent string, opts LoadOptions) ([]Scenario, error)
- func BuiltinOpenQASmoke() ([]Scenario, error)
- func BuiltinRegressionScenarios(workspaceParent string) ([]Scenario, error)
- func BuiltinRegressionScenariosWithOptions(workspaceParent string, opts LoadOptions) ([]Scenario, error)
- func FilterByDifficulty(scenarios []Scenario, spec string) ([]Scenario, error)
- func FilterByRun(scenarios []Scenario, pattern string) ([]Scenario, error)
- func FilterByTier(scenarios []Scenario, spec string) ([]Scenario, error)
- func FilterSmoke(scenarios []Scenario, smoke bool, names []string) []Scenario
- func LimitSmoke(scenarios []Scenario, smoke bool, n int) []Scenario
- func LoadScenarioFile(path, workspaceParent string) (Scenario, error)
- func LoadScenarioFileWithOptions(path, workspaceParent string, opts LoadOptions) (Scenario, error)
- func LoadScenariosFromDir(dir, workspaceParent string) ([]Scenario, error)
- func LoadScenariosFromDirWithOptions(dir, workspaceParent string, opts LoadOptions) ([]Scenario, error)
- func LoadScenariosFromDirs(dirs []string, workspaceParent string) ([]Scenario, error)
- func LoadScenariosFromDirsWithOptions(dirs []string, workspaceParent string, opts LoadOptions) ([]Scenario, error)
- type ScorecardOptions
- type TaskDraft
- type WilsonCI
- type WorkspaceFixture
- type WorkspaceSandbox
Constants ¶
const ( DifficultyEasy = "easy" DifficultyMedium = "medium" DifficultyHard = "hard" )
Difficulty levels for the capability ladder.
const ( TierBasic = "basic" TierCombo = "combo" TierSystem = "system" TierRepair = "repair" )
Tier labels for the golden dataset ladder.
const ( DimCorrectness = "correctness" DimFaithfulness = "faithfulness" DimHelpfulness = "helpfulness" DimSafety = "safety" )
Quality dimensions scored 1–5 (or 0 for Unknown).
const AgreementTolerance = 1
AgreementTolerance is the max absolute score delta considered agreement (5-point scale).
const DefaultLatencyBudgetMs int64 = 8000
DefaultLatencyBudgetMs is the per-trial latency budget for L3 LatencyScore.
const DefaultTokenBudget = 6000
DefaultTokenBudget is the per-trial token budget for L3 TokenScore.
const MetricCompliance = "compliance"
MetricCompliance tags a case as L1 compliance-eligible regardless of name heuristics.
Variables ¶
var DefaultSmokeCaseNames = []string{
"openqa_greet",
"openqa_explain_panic",
"openqa_refuse_secrets",
"openqa_refuse_shell",
"openqa_admit_unknown",
}
DefaultSmokeCaseNames are capability cases kept when --smoke=true. Covers greet, reasoning, safety refuse (2), and honesty — τ-bench style reliability smoke.
Functions ¶
func AgreementRate ¶ added in v0.99.0
func AgreementRate(judge JudgeScores, gold GoldScores) (rate float64, compared int)
AgreementRate returns the fraction of comparable dimensions within AgreementTolerance. Dimensions where judge is 0 (Unknown) or gold is 0 are skipped.
func AnnotateLayerMetrics ¶ added in v0.99.0
func AnnotateLayerMetrics(m *Metrics, caseName, tier string, tags []string, expect Expectation)
AnnotateLayerMetrics fills L1/L2/natural-repair fields after hard scoring.
func CapabilityCaseDirs ¶ added in v0.99.0
CapabilityCaseDirs resolves openqa, tools, and repair case directories.
func CountToolErrors ¶ added in v0.99.0
func CountToolErrors(messages []msg.AgentMessage) int
CountToolErrors returns how many tool results in messages have IsError.
func DefaultGoldByCase ¶ added in v0.99.0
func DefaultGoldByCase(dir string, names []string) (map[string]GoldScores, error)
DefaultGoldByCase loads gold files named <case>.gold.json (or nested gold.json). Missing files are skipped; corrupt existing files return an error.
func DefaultGoldByCaseFromDirs ¶ added in v0.99.0
func DefaultGoldByCaseFromDirs(dirs, names []string) (map[string]GoldScores, error)
DefaultGoldByCaseFromDirs merges gold files from multiple case directories.
func DetailHTMLName ¶ added in v0.99.0
DetailHTMLName returns the detail HTML basename for a stamped report.
func FailReason ¶ added in v0.99.0
func FailReason(m Metrics, expect Expectation) string
FailReason returns a short explanation when metrics did not hard-pass.
func FormatCompareMarkdown ¶ added in v0.99.0
func FormatCompareMarkdown(diff *CompareDiff) string
FormatCompareMarkdown renders a compare diff as Markdown.
func JudgeDimension ¶ added in v0.99.0
func JudgeDimension(ctx context.Context, model llms.Model, dimension, task, transcript, finalText string) (int, string, bool, error)
JudgeDimension scores one quality dimension with a judge model.
func JudgePrompt ¶ added in v0.99.0
JudgePrompt builds a single-dimension judge prompt.
func NormalizeDifficulty ¶ added in v0.99.0
NormalizeDifficulty maps empty/unknown values to easy|medium|hard.
func NormalizeTier ¶ added in v0.99.0
NormalizeTier maps empty/unknown tier to basic.
func OpenQAGoldDir ¶ added in v0.99.0
OpenQAGoldDir resolves the openqa gold directory.
func PassAtK ¶ added in v0.99.0
PassAtK estimates the fraction of tasks with at least one success in k trials.
func PassHatK ¶ added in v0.99.0
PassHatK estimates the fraction of tasks where all k trials succeeded.
func ResetScenarioWorkspace ¶ added in v0.99.0
ResetScenarioWorkspace clears WorkspaceRoot and rewrites Fixtures for an isolated trial.
func ResolveCasesDir ¶ added in v0.99.0
ResolveCasesDir finds the first existing directory among candidates.
func TextScript ¶
func TextScript(content string) agentllm.ResponseScript
TextScript builds a FakeModel script that returns plain assistant text.
func ToolCallScript ¶
func ToolCallScript(id, name, argsJSON string) agentllm.ResponseScript
ToolCallScript builds a FakeModel script that requests one tool call.
func TranscriptSummary ¶ added in v0.99.0
func TranscriptSummary(messages []msg.AgentMessage, lineLimit int) string
TranscriptSummary builds a short readable excerpt from messages.
func WriteDetailHTML ¶ added in v0.99.0
func WriteDetailHTML(path string, report EvalReport) error
WriteDetailHTML writes a single-run HTML detail page to path.
func WriteHTMLReports ¶ added in v0.99.0
WriteHTMLReports scans dir for stamped reports, writes detail pages under dir/html/, and an overview at dir/index.html.
func WriteOverviewHTML ¶ added in v0.99.0
func WriteOverviewHTML(path string, reports []ReportFile) error
WriteOverviewHTML writes a multi-run trend overview HTML page to path.
func WriteReportJSON ¶ added in v0.99.0
func WriteReportJSON(path string, report EvalReport) error
WriteReportJSON writes the report as indented JSON to path.
func WriteReportMarkdown ¶ added in v0.99.0
func WriteReportMarkdown(path string, report EvalReport) error
WriteReportMarkdown writes a capability-oriented Markdown summary next to JSON reports.
Types ¶
type CapabilityScorecard ¶ added in v0.99.0
type CapabilityScorecard struct {
// HardPassRate is Summary.Passed / Summary.Total (0–1).
HardPassRate float64 `json:"hard_pass_rate"`
// PassAtK mirrors report pass@k when set (0–1); appendix only.
PassAtK *float64 `json:"pass_at_k,omitempty"`
// PassHatK mirrors report pass^k when set (0–1); appendix only.
PassHatK *float64 `json:"pass_hat_k,omitempty"`
// Reliability is kept as appendix: 0.6*pass^k + 0.4*pass@k when both set; else HardPassRate.
Reliability float64 `json:"reliability"`
// PassAt1 is successful trials / (cases × k) (0–1).
PassAt1 float64 `json:"pass_at_1"`
// PassAt1CI is Wilson 95% CI for PassAt1 when trial counts are known.
PassAt1CI *WilsonCI `json:"pass_at_1_ci,omitempty"`
// L1Score is compliance rate (0–1).
L1Score float64 `json:"l1_score"`
// L2Score is (ToolCallAcc + RepairRate) / 2, or ToolCallAcc when no repair cases.
L2Score float64 `json:"l2_score"`
// L3Score is the equal-weight mean of available L3 dimensions.
L3Score float64 `json:"l3_score"`
// Total is 100 * (0.2*L1 + 0.5*L2 + 0.3*L3).
Total float64 `json:"total"`
// ToolCallAcc is tool hard-gate accuracy among eligible trials (0–1).
ToolCallAcc *float64 `json:"tool_call_acc,omitempty"`
// RepairRate is Pass@1 among tier=repair cases (0–1).
RepairRate *float64 `json:"repair_rate,omitempty"`
// RepairRateCI is Wilson 95% CI for RepairRate when set.
RepairRateCI *WilsonCI `json:"repair_rate_ci,omitempty"`
// LatencyScore is mean clamp(budget/actual) for trials with DurationMs > 0.
LatencyScore *float64 `json:"latency_score,omitempty"`
// TokenScore is mean clamp(budget/actual) for trials with TotalTokens > 0.
TokenScore *float64 `json:"token_score,omitempty"`
// NaturalRepairRate is appendix: pass rate among trials with ≥1 tool error.
NaturalRepairRate *float64 `json:"natural_repair_rate,omitempty"`
// ToolSelectionRate is appendix soft ExpectedTools order match rate.
ToolSelectionRate *float64 `json:"tool_selection_rate,omitempty"`
// CorrectnessAvg is mean judge correctness (1–5) when quality scoring is enabled.
CorrectnessAvg *float64 `json:"correctness_avg,omitempty"`
// FaithfulnessAvg is mean judge faithfulness (1–5).
FaithfulnessAvg *float64 `json:"faithfulness_avg,omitempty"`
// HelpfulnessAvg is mean judge helpfulness (1–5).
HelpfulnessAvg *float64 `json:"helpfulness_avg,omitempty"`
// SafetyAvg is mean judge safety (1–5).
SafetyAvg *float64 `json:"safety_avg,omitempty"`
// QualityAvg is mean of the four dimensions (1–5); appendix only (not in Total).
QualityAvg *float64 `json:"quality_avg,omitempty"`
// JudgeGoldAgreement mirrors report agreement when set (0–1).
JudgeGoldAgreement *float64 `json:"judge_gold_agreement,omitempty"`
// QualityEnabled is false for fake/scripted judges.
QualityEnabled bool `json:"quality_enabled"`
// TotalCI is set when suite-level repeats ≥ 2 were aggregated externally.
TotalCI *MeanCI `json:"total_ci,omitempty"`
// L1CI is suite-repeat CI when set.
L1CI *MeanCI `json:"l1_ci,omitempty"`
// L2CI is suite-repeat CI when set.
L2CI *MeanCI `json:"l2_ci,omitempty"`
// L3CI is suite-repeat CI when set.
L3CI *MeanCI `json:"l3_ci,omitempty"`
// Notes explains how to interpret the scorecard.
Notes string `json:"notes,omitempty"`
}
CapabilityScorecard aggregates L1/L2/L3 layer scores into Total (0–100).
func MergeRepeatScorecards ¶ added in v0.99.0
func MergeRepeatScorecards(cards []CapabilityScorecard) CapabilityScorecard
MergeRepeatScorecards averages layer totals across suite repeats and attaches MeanCI when N≥2.
func ScorecardFromReport ¶ added in v0.99.0
func ScorecardFromReport(report EvalReport) CapabilityScorecard
ScorecardFromReport builds a CapabilityScorecard using budgets stored on the report when set.
func ScorecardFromReportOpts ¶ added in v0.99.0
func ScorecardFromReportOpts(report EvalReport, opts ScorecardOptions) CapabilityScorecard
ScorecardFromReportOpts builds a CapabilityScorecard with explicit budgets.
type CaseResult ¶ added in v0.99.0
type CaseResult struct {
// Name identifies the case.
Name string `json:"name"`
// Difficulty is easy, medium, or hard when set.
Difficulty string `json:"difficulty,omitempty"`
// Tier is basic, combo, system, or repair when set.
Tier string `json:"tier,omitempty"`
// Passed is the hard gate result.
Passed bool `json:"passed"`
// Metrics holds detailed scores (last trial for multi-trial cases).
Metrics Metrics `json:"metrics"`
// TrialMetrics holds per-trial metrics for multi-trial cases.
TrialMetrics []Metrics `json:"trial_metrics,omitempty"`
// TranscriptSummary is a short human-readable trajectory excerpt (failed cases).
TranscriptSummary string `json:"transcript_summary,omitempty"`
// Error is a run-level error message when present.
Error string `json:"error,omitempty"`
// Judge holds model-grader scores when used.
Judge *JudgeScores `json:"judge,omitempty"`
// Gold holds human gold scores when present.
Gold *GoldScores `json:"gold,omitempty"`
// TrialPasses lists per-trial hard pass for multi-trial cases.
TrialPasses []bool `json:"trial_passes,omitempty"`
}
CaseResult is one task/scenario outcome in a report.
func CaseResultFromRun ¶ added in v0.99.0
func CaseResultFromRun(name string, run RunResult) CaseResult
CaseResultFromRun maps a RunResult into a report case. TranscriptSummary is attached only for failed cases (CI/report readability).
type CompareDiff ¶ added in v0.99.0
type CompareDiff struct {
BaselineSuite string `json:"baseline_suite"`
CandidateSuite string `json:"candidate_suite"`
Improved []string `json:"improved"`
Regressed []string `json:"regressed"`
UnchangedPass []string `json:"unchanged_pass"`
UnchangedFail []string `json:"unchanged_fail"`
OnlyBaseline []string `json:"only_baseline"`
OnlyCandidate []string `json:"only_candidate"`
BaselineScorecard CapabilityScorecard `json:"baseline_scorecard"`
CandidateScorecard CapabilityScorecard `json:"candidate_scorecard"`
TotalDelta float64 `json:"total_delta"`
L1Delta float64 `json:"l1_delta"`
L2Delta float64 `json:"l2_delta"`
L3Delta float64 `json:"l3_delta"`
ReliabilityDelta float64 `json:"reliability_delta"`
QualityDelta *float64 `json:"quality_delta,omitempty"`
}
CompareDiff summarizes differences between a baseline and candidate report.
func CompareReports ¶ added in v0.99.0
func CompareReports(baseline, candidate EvalReport) CompareDiff
CompareReports contrastively compares two eval reports by case name and scorecard.
type DockerSandbox ¶ added in v0.99.0
type DockerSandbox struct {
// contains filtered or unexported fields
}
DockerSandbox provides eval workspace lifecycle and Docker-backed execution env.
func NewDockerSandbox ¶ added in v0.99.0
func NewDockerSandbox(cfg DockerSandboxConfig) *DockerSandbox
NewDockerSandbox creates a DockerSandbox.
func (*DockerSandbox) ExecutionEnv ¶ added in v0.99.0
func (s *DockerSandbox) ExecutionEnv(root string) env.ExecutionEnv
ExecutionEnv implements RuntimeSandbox.
func (*DockerSandbox) Prepare ¶ added in v0.99.0
func (s *DockerSandbox) Prepare(parent, caseName string) (string, error)
Prepare implements Sandbox.
func (*DockerSandbox) Reset ¶ added in v0.99.0
func (s *DockerSandbox) Reset(root string, fixtures []WorkspaceFixture) error
Reset implements Sandbox.
func (*DockerSandbox) Root ¶ added in v0.99.0
func (s *DockerSandbox) Root() string
Root implements Sandbox.
type DockerSandboxConfig ¶ added in v0.99.0
type DockerSandboxConfig struct {
Image string
Network string
Memory string
ServerURL string
AccessToken string
}
DockerSandboxConfig configures eval Docker sandbox behavior.
type EvalReport ¶ added in v0.99.0
type EvalReport struct {
// Suite is regression or capability.
Suite string `json:"suite"`
// GeneratedAt is RFC3339 timestamp.
GeneratedAt string `json:"generated_at"`
// Cases holds per-case results.
Cases []CaseResult `json:"cases"`
// Summary aggregates hard pass counts.
Summary ReportSummary `json:"summary"`
// PassAtK is set for live multi-trial runs (optional).
PassAtK *float64 `json:"pass_at_k,omitempty"`
// PassHatK is set for live multi-trial runs (optional).
PassHatK *float64 `json:"pass_hat_k,omitempty"`
// Trials is k when multi-trial aggregation was used.
Trials int `json:"trials,omitempty"`
// TotalDurationMs sums trial wall times for the suite.
TotalDurationMs int64 `json:"total_duration_ms,omitempty"`
// TotalTokens sums reported token usage across trials.
TotalTokens int `json:"total_tokens,omitempty"`
// JudgeGoldAgreement is the fraction of gold dimensions within tolerance.
JudgeGoldAgreement *float64 `json:"judge_gold_agreement,omitempty"`
// JudgeMode is "fake", "none", or "model:<name>" for interpreting quality scores.
JudgeMode string `json:"judge_mode,omitempty"`
// LatencyBudgetMs is the L3 latency budget used for this report when set.
LatencyBudgetMs int64 `json:"latency_budget_ms,omitempty"`
// TokenBudget is the L3 token budget used for this report when set.
TokenBudget int `json:"token_budget,omitempty"`
// Scorecard aggregates L1/L2/L3 Total for optimization A/B.
Scorecard *CapabilityScorecard `json:"scorecard,omitempty"`
}
EvalReport is the stable JSON artifact for one suite run.
func LoadReportJSON ¶ added in v0.99.0
func LoadReportJSON(path string) (EvalReport, error)
LoadReportJSON reads an EvalReport from path.
func NewReport ¶ added in v0.99.0
func NewReport(suite string, cases []CaseResult) EvalReport
NewReport builds a report from case results.
func RunLiveScenarios ¶ added in v0.99.0
func RunLiveScenarios(ctx context.Context, scenarios []Scenario, model llms.Model, opts LiveOptions) (EvalReport, error)
RunLiveScenarios runs each scenario k times with a real (or fake) model and aggregates pass@k / pass^k.
type Expectation ¶
type Expectation struct {
// RequiredTools lists tool names that must each appear at least once (hard coverage).
RequiredTools []string
// ForbiddenTools lists tool names that must not appear (hard).
ForbiddenTools []string
// ExpectedTools lists tool names that should appear in order among executed tools.
// Soft by default; hard only when StrictToolOrder is true.
ExpectedTools []string
// StrictToolOrder makes ExpectedTools order a hard gate.
StrictToolOrder bool
// RequiredArgs maps tool name to required argument keys that must be non-empty.
RequiredArgs map[string][]string
// MaxSteps bounds assistant turns (0 disables). Hard-fails unless SoftMaxSteps.
MaxSteps int
// SoftMaxSteps records MaxSteps overflow without failing the hard gate (capability live).
SoftMaxSteps bool
// RequireCompletion requires a non-error final assistant text response.
RequireCompletion bool
// Outcome holds additional outcome assertions (files, final text).
Outcome OutcomeAsserts
}
Expectation describes success criteria for one eval scenario.
type FileAssert ¶ added in v0.99.0
type FileAssert struct {
// Path is relative to WorkspaceRoot.
Path string
// Contains requires the file to exist and include this substring.
Contains string
// Equals, when non-empty, requires exact file content match.
Equals string
}
FileAssert checks one workspace-relative file after the run.
type GoldScores ¶ added in v0.99.0
type GoldScores struct {
Correctness int `json:"correctness"`
Faithfulness int `json:"faithfulness"`
Helpfulness int `json:"helpfulness"`
Safety int `json:"safety"`
Rationale string `json:"rationale,omitempty"`
}
GoldScores are human gold labels for calibration.
func LoadGoldFile ¶ added in v0.99.0
func LoadGoldFile(path string) (GoldScores, error)
LoadGoldFile reads gold.json from path.
type JudgeScores ¶ added in v0.99.0
type JudgeScores struct {
Correctness int `json:"correctness"`
Faithfulness int `json:"faithfulness"`
Helpfulness int `json:"helpfulness"`
Safety int `json:"safety"`
Reasoning string `json:"reasoning,omitempty"`
Unknown bool `json:"unknown,omitempty"`
}
JudgeScores are per-dimension model-grader scores.
type LiveOptions ¶ added in v0.99.0
type LiveOptions struct {
// Trials is k (default 3).
Trials int
// ModelName is sent as llms.WithModel on each request.
// Empty defaults to "eval" (safe for FakeModel); real providers need the configured name.
ModelName string
// JudgeModel scores open quality dimensions when non-nil.
JudgeModel llms.Model
// GoldByCase maps case name to gold scores for agreement.
GoldByCase map[string]GoldScores
// OnProgress reports case/trial progress when set.
OnProgress ProgressFunc
// JudgeMode labels quality scoring: "fake", "none", or "model:<name>".
JudgeMode string
// LatencyBudgetMs overrides default L3 latency budget when > 0.
LatencyBudgetMs int64
// TokenBudget overrides default L3 token budget when > 0.
TokenBudget int
}
LiveOptions configures multi-trial live evaluation.
type LoadOptions ¶ added in v0.99.0
type LoadOptions struct {
Sandbox Sandbox
}
LoadOptions customizes scenario loading/runtime wiring.
type MeanCI ¶ added in v0.99.0
type MeanCI struct {
// Mean is the sample mean.
Mean float64 `json:"mean"`
// Low is mean − 1.96*SEM.
Low float64 `json:"low"`
// High is mean + 1.96*SEM.
High float64 `json:"high"`
// N is the number of suite repeats.
N int `json:"n"`
}
MeanCI is a normal-approximation interval around a mean of suite repeats.
func MeanInterval ¶ added in v0.99.0
MeanInterval returns mean ± 1.96*SEM for suite-level repeats (N≥2).
type Metrics ¶
type Metrics struct {
// ToolSelectionCorrect is true when ExpectedTools appear in order (soft metric).
ToolSelectionCorrect bool
// ToolSelectionTracked is true when ExpectedTools was non-empty (soft metric denominator).
ToolSelectionTracked bool
// RequiredToolsCovered is true when every RequiredTools entry was called.
RequiredToolsCovered bool
// ForbiddenToolsClear is true when no ForbiddenTools entry was called.
ForbiddenToolsClear bool
// ArgsValid is true when required tool arguments were present and non-empty.
ArgsValid bool
// OutcomeOK is true when OutcomeAsserts passed (or none were set).
OutcomeOK bool
// TextOutcomeOK is true when final-text asserts passed (or none were set).
TextOutcomeOK bool
// FileOutcomeOK is true when file asserts passed (or none were set).
FileOutcomeOK bool
// StepCount is the number of assistant turns observed.
StepCount int
// Completed is true when the run finished with a final assistant message and no error.
Completed bool
// ToolsCalled lists tool names executed during the run.
ToolsCalled []string
// FinalText is the last non-empty assistant text content.
FinalText string
// AssistantText joins all non-empty assistant texts (used for outcome asserts).
AssistantText string
// StepsWithinLimit is true when MaxSteps is 0 or StepCount <= MaxSteps.
StepsWithinLimit bool
// DurationMs is wall time for the scenario run.
DurationMs int64
// TotalTokens sums assistant Usage.TotalTokens when reported.
TotalTokens int
// ToolErrorCount is the number of tool results with IsError.
ToolErrorCount int
// NaturalRepairEligible is true when ToolErrorCount >= 1.
NaturalRepairEligible bool
// NaturalRepairSuccess is true when eligible and Passed.
NaturalRepairSuccess bool
// ComplianceEligible is true when this trial counts toward L1.
ComplianceEligible bool
// CompliancePassed is the L1 gate result for this trial.
CompliancePassed bool
// ToolAccEligible is true when this trial counts toward ToolCallAcc.
ToolAccEligible bool
// ToolAccPassed is the ToolCallAcc hard-gate result for this trial.
ToolAccPassed bool
// Passed is the hard CI gate (required/forbidden/args/outcome/completion/max steps; order only if strict).
Passed bool
}
Metrics captures scored outcomes for one scenario run.
func Score ¶
func Score(messages []msg.AgentMessage, expect Expectation, runErr error) Metrics
Score derives metrics from a completed agent run.
func ScoreScenario ¶ added in v0.99.0
func ScoreScenario(messages []msg.AgentMessage, sc Scenario, runErr error) Metrics
ScoreScenario scores a run and annotates L1/L2 layer fields from scenario metadata.
func ScoreWithWorkspace ¶ added in v0.99.0
func ScoreWithWorkspace(messages []msg.AgentMessage, expect Expectation, runErr error, workspaceRoot string) Metrics
ScoreWithWorkspace derives metrics and evaluates file outcomes under workspaceRoot.
type OutcomeAsserts ¶ added in v0.99.0
type OutcomeAsserts struct {
// FinalTextContains requires each substring in the last assistant text (case-sensitive).
FinalTextContains []string
// FinalTextContainsAny requires at least one substring (case-insensitive) when non-empty.
FinalTextContainsAny []string
// Files asserts workspace file outcomes (true outcome when tools wrote them).
Files []FileAssert
}
OutcomeAsserts describes environment / proxy outcome checks.
type ProgressEvent ¶ added in v0.99.0
type ProgressEvent struct {
// Phase is "case_start", "trial", or "case_done".
Phase string
// CaseName is the scenario name.
CaseName string
// CaseIndex is 1-based index among scenarios.
CaseIndex int
// CaseTotal is the number of scenarios.
CaseTotal int
// Trial is 1-based trial index (live only; 0 when N/A).
Trial int
// Trials is k for live runs.
Trials int
// Passed is set for trial and case_done phases.
Passed bool
// Duration is wall time for the trial or whole case.
Duration time.Duration
// Detail is an optional failure reason.
Detail string
}
ProgressEvent reports live/regression case progress (go test style).
type ProgressFunc ¶ added in v0.99.0
type ProgressFunc func(ProgressEvent)
ProgressFunc receives progress events during evaluation.
type ReportFile ¶ added in v0.99.0
type ReportFile struct {
// Path is the absolute or relative path to the JSON file.
Path string
// Suite is capability or regression (from filename).
Suite string
// Stamp is the UTC timestamp segment from the filename.
Stamp string
// Report is the loaded report with scorecard filled when missing.
Report EvalReport
}
ReportFile is a stamped eval report JSON on disk.
func ListStampedReports ¶ added in v0.99.0
func ListStampedReports(dir string) ([]ReportFile, error)
ListStampedReports loads stamped report JSON files under dir, oldest first. Files named *_latest.json and non-matching names are ignored.
type ReportSummary ¶ added in v0.99.0
type ReportSummary struct {
Total int `json:"total"`
Passed int `json:"passed"`
Failed int `json:"failed"`
}
ReportSummary counts hard passes.
type RunResult ¶ added in v0.99.0
type RunResult struct {
// Messages is the full transcript.
Messages []msg.AgentMessage
// Metrics are scored outcomes.
Metrics Metrics
// Err is the loop error when present.
Err error
}
RunResult is one Fake or live scenario execution with scores.
func RunFakeScenario ¶ added in v0.99.0
RunFakeScenario executes one scenario with FakeModel scripts.
func RunFakeScenarioWithHarness ¶ added in v0.99.0
RunFakeScenarioWithHarness executes one scenario through pkg/agent/harness with FakeModel scripts.
func RunWithModel ¶ added in v0.99.0
func RunWithModel(ctx context.Context, scenario Scenario, model llms.Model, modelName string) (RunResult, error)
RunWithModel executes one scenario against an arbitrary llms.Model. modelName is forwarded via llms.WithModel; empty defaults to "eval" (FakeModel-safe).
type RuntimeSandbox ¶ added in v0.99.0
type RuntimeSandbox interface {
Sandbox
ExecutionEnv(root string) env.ExecutionEnv
}
RuntimeSandbox can provide an execution environment bound to a workspace root.
type Sandbox ¶ added in v0.99.0
type Sandbox interface {
// Prepare creates the sandbox root for a case name under parent.
Prepare(parent, caseName string) (string, error)
// Reset clears the root and rewrites fixtures.
Reset(root string, fixtures []WorkspaceFixture) error
// Root returns the prepared root path (may be empty when unused).
Root() string
}
Sandbox isolates per-case workspace state for eval trials.
type Scenario ¶
type Scenario struct {
// Name identifies the scenario in table tests.
Name string
// Suite is "regression" or "capability" (for reports).
Suite string
// Difficulty is easy, medium, or hard (capability ladder).
Difficulty string
// Tier is basic, combo, system, or repair.
Tier string
// MetricsTags lists optional metric tags (e.g. compliance).
MetricsTags []string
// Prompt is the user message.
Prompt string
// Scripts are FakeModel responses in order.
Scripts []agentllm.ResponseScript
// Tools are registered for the run.
Tools []tool.Tool
// WorkspaceRoot is the isolated workspace for file outcome checks and coding tools.
WorkspaceRoot string
// ExecEnv is the tool execution environment bound to WorkspaceRoot.
ExecEnv env.ExecutionEnv
// Sandbox tracks workspace lifecycle for per-trial resets.
Sandbox Sandbox
// Fixtures seed WorkspaceRoot before each trial (live multi-trial isolation).
Fixtures []WorkspaceFixture
// Expect defines scoring criteria.
Expect Expectation
}
Scenario is one FakeModel-driven harness evaluation case.
func BuiltinCapabilityScenarios ¶ added in v0.99.0
BuiltinCapabilityScenarios loads openqa + tools capability cases.
func BuiltinCapabilityScenariosWithOptions ¶ added in v0.99.0
func BuiltinCapabilityScenariosWithOptions(workspaceParent string, opts LoadOptions) ([]Scenario, error)
BuiltinCapabilityScenariosWithOptions loads capability cases with explicit loader options.
func BuiltinHarnessScenarios ¶ added in v0.99.0
BuiltinHarnessScenarios loads YAML cases from testdata/harness.
func BuiltinHarnessScenariosWithOptions ¶ added in v0.99.0
func BuiltinHarnessScenariosWithOptions(workspaceParent string, opts LoadOptions) ([]Scenario, error)
BuiltinHarnessScenariosWithOptions loads harness YAML with explicit options.
func BuiltinOpenQASmoke ¶ added in v0.99.0
BuiltinOpenQASmoke loads capability openqa YAML cases (full openqa set; apply FilterSmoke separately).
func BuiltinRegressionScenarios ¶ added in v0.99.0
BuiltinRegressionScenarios loads YAML cases from testdata/regression.
func BuiltinRegressionScenariosWithOptions ¶ added in v0.99.0
func BuiltinRegressionScenariosWithOptions(workspaceParent string, opts LoadOptions) ([]Scenario, error)
BuiltinRegressionScenariosWithOptions loads regression YAML with explicit options.
func FilterByDifficulty ¶ added in v0.99.0
FilterByDifficulty keeps scenarios matching spec. Spec examples: "hard", "medium+", "easy,hard", empty (all).
func FilterByRun ¶ added in v0.99.0
FilterByRun keeps scenarios whose Name matches pattern (Go regexp), like go test -run. Empty pattern returns scenarios unchanged. No matches is an error.
func FilterByTier ¶ added in v0.99.0
FilterByTier keeps scenarios whose Tier is in the allowlist (comma-separated or repeated). Empty spec returns scenarios unchanged.
func FilterSmoke ¶ added in v0.99.0
FilterSmoke keeps only named cases when smoke is requested (stable allowlist).
func LimitSmoke ¶ added in v0.99.0
LimitSmoke truncates scenarios to at most n when smoke is requested.
func LoadScenarioFile ¶ added in v0.99.0
LoadScenarioFile loads one YAML case file.
func LoadScenarioFileWithOptions ¶ added in v0.99.0
func LoadScenarioFileWithOptions(path, workspaceParent string, opts LoadOptions) (Scenario, error)
LoadScenarioFileWithOptions loads one YAML case file with options.
func LoadScenariosFromDir ¶ added in v0.99.0
LoadScenariosFromDir loads *.yaml case files from dir into Scenarios. workspaceParent is used when a case sets workspace: true.
func LoadScenariosFromDirWithOptions ¶ added in v0.99.0
func LoadScenariosFromDirWithOptions(dir, workspaceParent string, opts LoadOptions) ([]Scenario, error)
LoadScenariosFromDirWithOptions loads *.yaml case files from dir using explicit options.
func LoadScenariosFromDirs ¶ added in v0.99.0
LoadScenariosFromDirs loads YAML cases from multiple directories (order preserved, then sorted by name).
func LoadScenariosFromDirsWithOptions ¶ added in v0.99.0
func LoadScenariosFromDirsWithOptions(dirs []string, workspaceParent string, opts LoadOptions) ([]Scenario, error)
LoadScenariosFromDirsWithOptions loads YAML cases with explicit options.
type ScorecardOptions ¶ added in v0.99.0
type ScorecardOptions struct {
// LatencyBudgetMs is the per-trial latency budget (default DefaultLatencyBudgetMs).
LatencyBudgetMs int64
// TokenBudget is the per-trial token budget (default DefaultTokenBudget).
TokenBudget int
}
ScorecardOptions configures L3 budgets when building a scorecard.
type TaskDraft ¶ added in v0.99.0
type TaskDraft struct {
Name string `yaml:"name"`
Suite string `yaml:"suite"`
Prompt string `yaml:"prompt"`
Notes string `yaml:"notes"`
TranscriptExcerpt string `yaml:"transcript_excerpt"`
SourceError string `yaml:"source_error,omitempty"`
ExportedAt string `yaml:"exported_at"`
}
TaskDraft is a YAML-serializable draft task exported from a failed run.
func ExportTaskDraft ¶ added in v0.99.0
func ExportTaskDraft(caseResult CaseResult, prompt string) TaskDraft
ExportTaskDraft builds a draft from a failed case result.
type WilsonCI ¶ added in v0.99.0
type WilsonCI struct {
// Low is the lower bound (0–1).
Low float64 `json:"low"`
// High is the upper bound (0–1).
High float64 `json:"high"`
}
WilsonCI is a Wilson score interval for a Bernoulli proportion.
func WilsonInterval ¶ added in v0.99.0
WilsonInterval returns the Wilson score 95% confidence interval for k successes in n trials.
type WorkspaceFixture ¶ added in v0.99.0
type WorkspaceFixture struct {
// Path is relative to WorkspaceRoot.
Path string
// Content is the file body.
Content string
}
WorkspaceFixture seeds one file into an isolated workspace.
type WorkspaceSandbox ¶ added in v0.99.0
type WorkspaceSandbox struct {
// contains filtered or unexported fields
}
WorkspaceSandbox is the default filesystem sandbox under {parent}/{caseName}.
func NewWorkspaceSandbox ¶ added in v0.99.0
func NewWorkspaceSandbox() *WorkspaceSandbox
NewWorkspaceSandbox returns an empty WorkspaceSandbox.
func (*WorkspaceSandbox) ExecutionEnv ¶ added in v0.99.0
func (*WorkspaceSandbox) ExecutionEnv(_ string) env.ExecutionEnv
ExecutionEnv implements RuntimeSandbox.
func (*WorkspaceSandbox) Prepare ¶ added in v0.99.0
func (s *WorkspaceSandbox) Prepare(parent, caseName string) (string, error)
Prepare implements Sandbox.
func (*WorkspaceSandbox) Reset ¶ added in v0.99.0
func (s *WorkspaceSandbox) Reset(root string, fixtures []WorkspaceFixture) error
Reset implements Sandbox.
func (*WorkspaceSandbox) Root ¶ added in v0.99.0
func (s *WorkspaceSandbox) Root() string
Root implements Sandbox.