Documentation
¶
Overview ¶
Package health is a workspace's dashboard (spec_044_health): the facts about what it holds and how its runs go, taken from what it already records (no model call), and the judge's verdicts on each item's quality, kept with their history.
Index ¶
- Constants
- Variables
- func Due(it Item, latest map[string]Verdict, model string, force bool) bool
- func Evidence(it Item) string
- func Grade(score float64) string
- func Prompt(it Item, file string) string
- func Scores(items []Item, latest map[string]Verdict) (overall float64, byKind map[string]float64)
- type Day
- type EvalResult
- type EvalRun
- type EvalStats
- type Facts
- type Inputs
- type Item
- type Run
- type RunStats
- type Score
- type Signal
- type Source
- type State
- type Store
- type Verdict
Constants ¶
const ( KindAgent = "agent" KindSkill = "skill" KindRule = "rule" KindGuardrail = "guardrail" KindEval = "eval" KindWorkflow = "workflow" KindWorker = "worker" )
The kinds of item, in the order the dashboard shows them.
const ( FlagUncovered = "uncovered" // an agent no eval checks FlagStale = "stale" // an agent changed since its evals last ran FlagUnused = "unused" // a skill or rule nothing uses, a worker that hasn't run FlagNeverRun = "never_run" // a workflow or eval never run FlagFailing = "failing" // most of its recent runs failed FlagDisabled = "disabled" // a worker switched off FlagOff = "off" // a guardrail switched off )
What an item's flags say about it.
const ( RunDone = "done" RunFailed = "failed" RunStopped = "stopped" )
The statuses a Run has.
const Days = 30
Days is how many days the charts cover.
const Instruction = `` /* 745-byte string literal not displayed */
Instruction tells the judge its job.
const Keep = 90 * 24 * time.Hour
Keep is how long verdicts are kept, for trends (HL-11).
const RubricVersion = 1
RubricVersion changes when the rubrics do: every item is judged again.
const Window = 30 * 24 * time.Hour
Window is how far back the facts look.
Variables ¶
var ErrNoVerdict = errors.New("the judge's answer isn't a verdict")
ErrNoVerdict means the judge's answer isn't one.
var Rubrics = map[string][]string{
KindAgent: {
"Its instructions are clear and complete: what it's for, how it works, when it's done",
"Its tools fit what it's for, and no more",
"Its evals cover what it does",
"Its runs succeed",
},
KindSkill: {
"Its description says when to use it (it's what makes an agent choose it)",
"Its instructions can be followed step by step",
"Its scripts run and pass the policy (or it needs none)",
"Something uses it",
},
KindRule: {
"It can be judged pass or fail from a prompt or an answer alone",
"It isn't redundant with another rule or guardrail",
"It fires when it should, and only then",
},
KindGuardrail: {
"What it checks is clear and can be decided",
"Its action fits the risk (block, redact or warn)",
"It fires when it should, and only then",
},
KindEval: {
"Its cases cover the agent's job, the hard cases too",
"Its expected outputs and thresholds are sensible",
"It tells good from bad (not always passing or always failing)",
},
KindWorkflow: {
"Its steps are well defined and in a sensible order",
"It handles failure (retries, error links, timeouts)",
"Its cost and duration fit what it does",
"Its runs succeed",
"Its permission mode fits what it does",
},
KindWorker: {
"Its permissions are as tight as its work allows",
"Its schedule and limits fit its work",
"Its runs succeed",
},
}
Rubrics are what the judge scores, per kind (HL-10).
Functions ¶
func Due ¶
Due reports whether an item needs judging: it loads, and has no verdict for its content under this rubric version and model setting (or force).
func Grade ¶
Grade is a score's letter (HL-12): A from 4.5, B from 3.5, C from 2.5, else D; "" for none.
func Prompt ¶
Prompt is what the judge gets for it: the rubric, the item's file and its evidence (what the facts say about it).
Types ¶
type EvalResult ¶
EvalResult is one case's result for one agent.
type EvalRun ¶
type EvalRun struct {
Started time.Time
Results []EvalResult
}
EvalRun is one run of an eval: when, and its cases' results.
type EvalStats ¶
type EvalStats struct {
// Runs are the eval runs in the window.
Runs int
Last time.Time
Passed int
Cases int
}
EvalStats are an agent's or an eval's latest results.
type Facts ¶
type Facts struct {
At time.Time
Items []Item
// Days are the runs per day, oldest first, the last of them today.
Days []Day
Signals []Signal
}
Facts are a workspace's dashboard without the judge's verdicts.
type Inputs ¶
type Inputs struct {
Now time.Time
// DefaultAgent is who an eval naming no agent checks.
DefaultAgent string
Agents []Source
Skills []Source
Rules []Source
Guardrails []Source
Evals []Source
Workflows []Source
Workers []Source
// Audit is the workspace's audit entries in the window.
Audit []audit.Entry
}
Inputs are what the facts are made from: the workspace's items and their records, gathered by the engine.
type Item ¶
type Item struct {
Kind, Name, Path, Detail string
Problem string
Hash string
Flags []string
// Uses are its runs (a workflow, a worker, an eval), activations (a
// skill) or verdicts (a rule, a guardrail) in the window: the weight of
// its grade.
Uses int
// Fired is how often a rule or a guardrail stopped, warned or revised.
Fired int
Runs *RunStats
Evals *EvalStats
// Daily are its uses per day, as Days.
Daily []int
}
Item is one agent, skill, rule, guardrail, eval, workflow or worker.
type Run ¶
type Run struct {
Started time.Time
Duration time.Duration
// Status is done, failed or stopped.
Status string
CostUSD float64
// FailedStep is the step a workflow run failed at.
FailedStep string
}
Run is one run of a workflow or a worker, as the facts count it.
type RunStats ¶
type RunStats struct {
Runs, Done, Failed, Stopped int
CostUSD float64
Median time.Duration
Last time.Time
// FailingStep is the step its runs fail at most.
FailingStep string
}
RunStats are a workflow's or a worker's runs in the window.
func (RunStats) SuccessRate ¶
SuccessRate is the share of runs done (0 without runs).
type Score ¶
type Score struct {
Line string `json:"line"`
Score int `json:"score"`
Reason string `json:"reason"`
}
Score is one rubric line's.
type Signal ¶
type Signal struct {
// Kind is denial, guardrail or rule.
Kind string
About string
Count int
Last time.Time
// Detail is the latest one's why.
Detail string
}
Signal is a safety signal in the window: the auto reviewer's denials, a guardrail's or a rule's decisions, by what they were about.
type Source ¶
type Source struct {
Name, Path string
// Detail is what kind of that kind it is: a skill's type, a rule's
// stage, a guardrail's built-in check.
Detail string
Problem string
// Hash is the file's content's (verdicts follow it).
Hash string
Modified time.Time
// Agents are those a rule, a skill or an eval is for (empty: all, or
// for an eval its default agent).
Agents []string
// Skills are those an agent step, a meta skill or an eval uses.
Skills []string
// Off is a guardrail switched off or a worker disabled.
Off bool
// Cases is an eval's number of cases.
Cases int
Runs []Run
EvalRuns []EvalRun
}
Source is one item as the engine read it.
type State ¶
type State struct {
// LastCheck is when the last check ended (zero: never checked, and
// the schedule waits for a first check by hand).
LastCheck time.Time `json:"last_check"`
LastCost float64 `json:"last_cost_usd,omitempty"`
// Judged and Errors are what the last check judged, and the items it
// couldn't, with why.
Judged int `json:"judged,omitempty"`
Errors []string `json:"errors,omitempty"`
// Skipped is why the last scheduled check didn't run.
Skipped string `json:"skipped,omitempty"`
}
State is what the store remembers of the checks.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store keeps a workspace's verdicts and its checks' state, in a folder of the service's storage.
func (*Store) All ¶
All are the verdicts kept, oldest first (what could be read, when the file can't be read whole).
type Verdict ¶
type Verdict struct {
Kind string `json:"kind"`
Name string `json:"name"`
Hash string `json:"hash"`
Rubric int `json:"rubric"`
// Model is the model that answered; Ref the one set to judge ("" the
// default), which a check compares.
Model string `json:"model"`
Ref string `json:"ref,omitempty"`
At time.Time `json:"at"`
Scores []Score `json:"scores"`
// Overall is 1–5.
Overall float64 `json:"overall"`
Summary string `json:"summary,omitempty"`
// Fixes are concrete changes, each a suggestion.
Fixes []string `json:"fixes,omitempty"`
CostUSD float64 `json:"cost_usd,omitempty"`
}
Verdict is the judge's on one item as it was (its hash), under one rubric version and model.