Documentation
¶
Overview ¶
Package eval is `idea eval`: a fixed suite of small greenfield ideas run end to end through a real, in-process daemon -- idea → PRD review → plan → change set → apply → verify -- with an automatic judgment policy standing in for the human, reporting per case and in aggregate whether each review converged, where a human would have been needed, and what it cost.
It exists because there was no measurement at all. The README's real-model numbers ("the PRD review did not converge in 2 of 2 runs") came from two hand-driven runs, and nothing could tell whether a change to the review loop made that better or worse. A suite run against the deterministic scripted provider is a CI regression gate (eval_test.go); the same suite run with --model against a real provider is the measurement.
Index ¶
- Constants
- func RunScheduled(ctx context.Context, req daemon.EvalRequest) (daemon.EvalResult, error)
- func Scenarios() []string
- func SuiteNames() []string
- type Aggregate
- type Case
- type CaseResult
- type Check
- type CheckResult
- type Expect
- type Options
- type Policy
- type Regression
- type Report
- type ScriptedProvider
- type Stage
- type Stop
- type Suite
Constants ¶
const ( StopPRDReview = "prd_review" StopPlanReview = "plan_review" StopPlanDependencies = "plan_dependencies" StopChangeSetReview = "change_set_review" )
Human-judgment stop points (Stop.Stage).
const ( CheckPassed = "passed" CheckFailed = "failed" CheckSkipped = "skipped" )
Check outcomes.
const ( // ScenarioDemo is the built-in demo provider, unchanged: a reviewer that // never finds anything. The trivially converging baseline. ScenarioDemo = "demo" // ScenarioTypical raises two cited findings in cycle 1 (one blocking, one // medium) and none once the revision has addressed them: an ordinary, // converging review. ScenarioTypical = "typical" // ScenarioRephrasingReviewer is the measured non-convergence reproduced: // every cycle it re-raises, reworded and without justification, the same // concern the revision already addressed, plus an uncited scope-expansion // "high" (SSO, audit logging) the idea never asked for. The legacy loop // never converges on it; the guarded loop converges at cycle 2. ScenarioRephrasingReviewer = "rephrasing_reviewer" // ScenarioScopeCreep only ever raises uncited "high" findings for things // the idea did not ask for. Guarded converges in one cycle, with the // findings kept as advisories. ScenarioScopeCreep = "scope_creep" // ScenarioGenuineBlocker raises a critical contradiction the idea itself // contains, and re-raises it every cycle with a reason. No revision can // fix it, so it must still park for a human -- the case that proves the // convergence rules do not simply wave blockers through. ScenarioGenuineBlocker = "genuine_blocker" )
Scenario names (Case.Scenario).
const CostRegressionRatio = 1.25
CostRegressionRatio is how much more a case may cost than its baseline before it counts as a regression. Real-model spend varies run to run, so only a clear jump is flagged; a scripted run costs nothing either way.
const DefaultSuite = "default"
DefaultSuite is the suite `idea eval` runs when none is named.
const ProviderName = "eval-scripted"
ProviderName is the registry name the scripted provider is registered under; a scripted case's harness.yaml selects it as its default model.
Variables ¶
This section is empty.
Functions ¶
func RunScheduled ¶
func RunScheduled(ctx context.Context, req daemon.EvalRequest) (daemon.EvalResult, error)
RunScheduled is the daemon's scheduled eval (harness.yaml automations.eval): one capped run against a real model, its report written as <stamp>.json and <stamp>.md under req.ReportDir, compared with req.Baseline when there is one. The daemon registers it with daemon.SetEvalRunner; it lives here because this package drives a daemon in-process and so cannot be imported by it.
Types ¶
type Aggregate ¶
type Aggregate struct {
Cases int `json:"cases"`
Completed int `json:"completed"`
PRDConverged int `json:"prd_converged"`
MeanPRDCycles float64 `json:"mean_prd_cycles"`
PlanConverged int `json:"plan_converged"`
ProducedChangeSet int `json:"produced_change_set"`
Applied int `json:"applied"`
VerifyPassed int `json:"verify_passed"`
HumanStops int `json:"human_stops"`
HumanStopsByStage map[string]int `json:"human_stops_by_stage,omitempty"`
Errors int `json:"errors"`
ExpectationFailures int `json:"expectation_failures"`
CostUSD float64 `json:"cost_usd"`
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
WallSeconds float64 `json:"wall_seconds"`
}
Aggregate summarizes a run.
type Case ¶
type Case struct {
Name string `yaml:"name" json:"name"`
Title string `yaml:"title" json:"title"`
Idea string `yaml:"idea" json:"idea"`
// Scenario selects the scripted provider's behaviour when the suite runs
// without --model (see scenario.go). Ignored against a real model.
Scenario string `yaml:"scenario" json:"scenario,omitempty"`
// Harness is YAML appended to the case project's harness.yaml -- e.g. a
// review.convergence override, so the suite can run one scenario under
// both the guarded and the legacy loop.
Harness string `yaml:"harness" json:"harness,omitempty"`
// Checks are the case's acceptance checks: shell commands run in the
// project directory after every change set is applied. They are what
// "verify passed" means against a real coding agent. The built-in
// internal executor writes a placeholder file, so against it they are
// skipped and reported as such -- never counted as passing.
Checks []Check `yaml:"checks" json:"checks,omitempty"`
// Expect is what the scripted scenario must produce. Checked only when
// the suite runs against the scripted provider: a real model's behaviour
// is the measurement, not an assertion.
Expect *Expect `yaml:"expect" json:"expect,omitempty"`
}
Case is one seed idea and what it should achieve.
type CaseResult ¶
type CaseResult struct {
Name string `json:"name"`
Scenario string `json:"scenario,omitempty"`
Reached Stage `json:"reached"`
PRDConverged bool `json:"prd_converged"`
PRDCycles int `json:"prd_cycles"`
PRDOutcome string `json:"prd_outcome,omitempty"`
PlanConverged bool `json:"plan_converged"`
ChangeSets int `json:"change_sets"`
AppliedChangeSets int `json:"applied_change_sets"`
VerifyPassed bool `json:"verify_passed"`
Checks []CheckResult `json:"checks,omitempty"`
ChecksSkipped bool `json:"checks_skipped,omitempty"`
HumanStops []Stop `json:"human_stops"`
Calls int `json:"calls"`
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
CostUSD float64 `json:"cost_usd"`
WallSeconds float64 `json:"wall_seconds"`
// ReRaised and Demoted total the review telemetry over every cycle.
ReRaised int `json:"reraised"`
Demoted map[string]int `json:"demoted,omitempty"`
// Telemetry is every review cycle's convergence record, oldest first.
Telemetry []domain.ReviewTelemetry `json:"telemetry,omitempty"`
Error string `json:"error,omitempty"`
ExpectationFailures []string `json:"expectation_failures,omitempty"`
}
CaseResult is one case's measurement.
type CheckResult ¶
type CheckResult struct {
Name string `json:"name"`
Status string `json:"status"`
Output string `json:"output,omitempty"`
}
CheckResult is one acceptance check's outcome.
type Expect ¶
type Expect struct {
PRDConverged *bool `yaml:"prd_converged" json:"prd_converged,omitempty"`
PRDCycles *int `yaml:"prd_cycles" json:"prd_cycles,omitempty"`
PlanConverged *bool `yaml:"plan_converged" json:"plan_converged,omitempty"`
HumanStops *int `yaml:"human_stops" json:"human_stops,omitempty"`
Reached string `yaml:"reached" json:"reached,omitempty"`
}
Expect is a scripted case's expected outcome. Nil fields are not checked.
type Options ¶
type Options struct {
Suite Suite
// Model, when set ("provider/model"), runs every case against that real
// model instead of the scripted provider. The provider's key must be in
// the environment (or the case project's .env) -- the in-process daemon
// reads it exactly as `idea daemon` would.
Model string
// Harness is extra harness.yaml appended to every case's project (after
// the case's own), e.g. an executor block for a real coding agent.
Harness string
Policy Policy
// WorkDir holds every case's state root and project directory. Empty is
// a fresh temporary directory, removed afterwards unless Keep is set.
WorkDir string
Keep bool
// CaseTimeout bounds one case end to end (default 20 minutes; a scripted
// case takes well under a second).
CaseTimeout time.Duration
// CheckTimeout bounds one acceptance check (default 2 minutes).
CheckTimeout time.Duration
// Log receives daemon logs; nil discards them.
Log *slog.Logger
// Progress, when set, is told as each case starts and finishes.
Progress func(c Case, r *CaseResult)
// MaxCostUSD caps the whole run's spend (0: no cap). Each case's
// initiative is held to what is left of it -- the case daemon's own
// spending cap (budget.default_initiative_usd) stops it before the call
// that would go over -- and no case starts once it is spent. The
// scheduled eval (harness.yaml automations.eval) always sets one.
MaxCostUSD float64
}
Options configures a run.
type Policy ¶
type Policy string
Policy is the automatic judgment policy: what the eval does where the workflow stops for a human.
const ( // PolicyApprove accepts, at every stop, what a human accepting the // work as it stands would: `idea approve`, `idea approve-plan`, // `idea review --accept-findings`, `idea revise-plan` for an unresolved // dependency. Each is recorded as a human-judgment stop, and the run // goes on, so everything downstream is still measured. PolicyApprove Policy = "approve" // PolicyStop ends the case at its first human-judgment stop. PolicyStop Policy = "stop" )
type Regression ¶
type Regression struct {
Case string `json:"case"`
Metric string `json:"metric"`
Baseline string `json:"baseline"`
Current string `json:"current"`
}
Regression is one way a run is worse than its baseline.
func Compare ¶
func Compare(base, cur *Report) ([]Regression, error)
Compare returns every way cur is worse than base, case by case (matched by name; a case only one side has is skipped, so a filtered run can still be compared). Only outcomes are compared -- how far a case got, whether each review converged and in how many cycles, how many times a human was needed, whether verification passed, whether it errored -- plus cost when both runs were billed. Wall time is reported but never compared: it measures the machine and the provider's queue as much as the harness.
Comparing a scripted run with a real one is refused: neither predicts the other, and a "regression" between them would be noise.
type Report ¶
type Report struct {
Suite string `json:"suite"`
// Provider is "scripted" (no --model: deterministic, CI) or "real".
Provider string `json:"provider"`
Model string `json:"model,omitempty"`
Policy Policy `json:"policy"`
StartedAt time.Time `json:"started_at"`
FinishedAt time.Time `json:"finished_at"`
Cases []CaseResult `json:"cases"`
Aggregate Aggregate `json:"aggregate"`
// Regressions is filled when the run was compared to a baseline.
Regressions []Regression `json:"regressions,omitempty"`
Baseline string `json:"baseline,omitempty"`
// MaxCostUSD is the run's spending cap (0: none), and StoppedAtCap says
// whether it ran out before every case had run.
MaxCostUSD float64 `json:"max_cost_usd,omitempty"`
StoppedAtCap bool `json:"stopped_at_cap,omitempty"`
}
Report is one eval run.
func LoadReport ¶
LoadReport reads a report written by WriteJSON (a saved baseline).
func Run ¶
Run runs every case of the suite and returns the report. A case that fails is recorded as failed and the run continues; Run itself errors only when it cannot run at all.
func (*Report) Failed ¶
Failed reports whether the run should fail a gate: a scripted case missed its expectation, or the baseline comparison found a regression.
type ScriptedProvider ¶
type ScriptedProvider struct {
// contains filtered or unexported fields
}
ScriptedProvider is a model.Provider for one case's scenario. Each case gets its own (and its own daemon), so the call counts that pick a cycle's script are per case.
func NewScriptedProvider ¶
func NewScriptedProvider(scenario string) *ScriptedProvider
NewScriptedProvider returns the scripted provider for a scenario ("" is ScenarioDemo).
func (*ScriptedProvider) Capabilities ¶
func (p *ScriptedProvider) Capabilities() model.Capabilities
Capabilities implements model.Provider.
func (*ScriptedProvider) Name ¶
func (p *ScriptedProvider) Name() string
Name implements model.Provider.
type Stage ¶
type Stage string
Stage is how far a case got, in pipeline order (see stageRank).
const ( StageNone Stage = "none" StagePRD Stage = "prd" // a PRD was written and reviewed StagePRDApproved Stage = "prd_approved" // the PRD review converged, or was approved StagePlanApproved Stage = "plan_approved" // the plan review converged, or was approved StageChangeSet Stage = "change_set" // a change set was produced StageApplied Stage = "applied" // every change set applied StageVerified Stage = "verified" // the verification gate passed StageComplete Stage = "complete" // `idea next` answers done )
type Stop ¶
Stop is one place the workflow needed a human. The routine gates every run has by design -- approving a reviewed change set, applying it, recording verification -- are not stops; a stop is the workflow parking, or a review refusing approval.
type Suite ¶
type Suite struct {
Name string `yaml:"name" json:"name"`
Description string `yaml:"description" json:"description,omitempty"`
Cases []Case `yaml:"cases" json:"cases"`
}
Suite is a named, fixed list of cases.