Documentation
¶
Overview ¶
Package quality stores and retrieves per-version quality scores.
Index ¶
- func RegisterRoutes(api huma.API, store *Store, skills *skill.Store)
- type Executor
- type Record
- type RecordOutput
- type Series
- type SeriesPoint
- type Store
- func (s *Store) GetVersion(ctx context.Context, skillID string, version int) (*Record, error)
- func (s *Store) History(ctx context.Context, skillID string) ([]Record, error)
- func (s *Store) Latest(ctx context.Context, skillID string, version int) (*Record, error)
- func (s *Store) LatestAcrossVersions(ctx context.Context, skillID string) (*Record, error)
- func (s *Store) Upsert(ctx context.Context, rec Record) error
- func (s *Store) WithExecutor(e Executor) *Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Executor ¶
type Executor interface {
Exec(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error)
QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
}
Executor is the subset of *pgxpool.Pool that Store's queries need.
type Record ¶
type Record struct {
SkillID string
Version int
Headline float64
HeadlineCILow float64 // legacy; new rows carry zeroes
HeadlineCIHigh float64
// Nil means not measured. Lift is reported only; the gate reads Headline.
PrimaryScore *float64
Baseline *float64
Lift *float64
Pillars json.RawMessage
PanelMatrix json.RawMessage
RobustnessGap *float64 // nil = not computed; zero = floor kept up
DriftGrade string
DriftBreakdown json.RawMessage
Verified bool
PanelComplete bool
SuiteDerived bool
SuiteRef string
EngineVersion string
ModelPanel json.RawMessage
Tier string
UpliftSource string
// JudgeModel is nil for rows written before this field existed. series.go
// maps nil to a shared "unknown judge" value so those rows still group.
JudgeModel *string
JobID string
ScoredAt time.Time
CriticalForbidViolations int
ReportJSON json.RawMessage
}
Record is one scored measurement of a skill version.
func FromReport ¶
FromReport maps a report onto a record. Pure: no database or I/O.
func FromReportRaw ¶
FromReportRaw is FromReport plus the raw bytes. The caller passes what it received rather than re-marshalling, because a round trip drops unknown fields.
type RecordOutput ¶
type RecordOutput struct {
SkillID string `json:"skill_id"`
Version int `json:"version"`
Headline float64 `json:"headline_score"`
HeadlineCILow float64 `json:"headline_ci_low,omitempty"`
HeadlineCIHigh float64 `json:"headline_ci_high,omitempty"`
PrimaryScore *float64 `json:"primary_score,omitempty"`
Baseline *float64 `json:"baseline,omitempty"`
Lift *float64 `json:"lift,omitempty"`
Pillars json.RawMessage `json:"pillar_breakdown"`
PanelMatrix json.RawMessage `json:"panel_matrix"`
RobustnessGap *float64 `json:"robustness_gap,omitempty"`
DriftGrade string `json:"drift_grade,omitempty"`
DriftBreakdown json.RawMessage `json:"drift_breakdown"`
Verified bool `json:"verified"`
PanelComplete bool `json:"panel_complete"`
SuiteDerived bool `json:"suite_derived"`
SuiteRef string `json:"suite_ref"`
EngineVersion string `json:"engine_version"`
ModelPanel json.RawMessage `json:"model_panel"`
Tier string `json:"tier"`
UpliftSource string `json:"uplift_source,omitempty"`
JudgeModel *string `json:"judge_model,omitempty"`
JobID string `json:"job_id,omitempty"`
ScoredAt time.Time `json:"scored_at"`
CriticalForbidViolations int `json:"critical_forbid_violations"`
ReportJSON json.RawMessage `json:"-"`
}
RecordOutput is the wire shape for a Record.
type Series ¶
type Series struct {
Key string `json:"key"`
Current bool `json:"current"`
Reason string `json:"reason"`
Points []SeriesPoint `json:"points"`
}
Series is a run of scores that may be charted together.
func BuildSeries ¶
BuildSeries groups a skill's history into comparable runs. History arrives newest-first; the first record's group is the current series.
type SeriesPoint ¶
type SeriesPoint struct {
Version int `json:"version"`
Headline float64 `json:"headline_score"`
HeadlineCILow float64 `json:"headline_ci_low,omitempty"`
HeadlineCIHigh float64 `json:"headline_ci_high,omitempty"`
Lift *float64 `json:"lift,omitempty"`
Verified bool `json:"verified"`
ScoredAt time.Time `json:"scored_at"`
}
SeriesPoint is one scored version on a trend line.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists Records to skill_quality.
func (*Store) GetVersion ¶
GetVersion returns the score for one version, including the full report.
func (*Store) History ¶
History returns every scored row for a skill, across all versions, newest first.
func (*Store) Latest ¶
Latest returns the newest scored row for a skill version. Returns (nil, nil) when the version has never been scored.
func (*Store) LatestAcrossVersions ¶
LatestAcrossVersions returns the newest scored row across all versions.
func (*Store) Upsert ¶
Upsert inserts a new row. History is kept because version-over-version comparison depends on earlier rows surviving a re-score.
func (*Store) WithExecutor ¶
WithExecutor returns a Store whose queries run against e instead of the pool.