{"modulePath":"github.com/CommitBrief/commitbrief","version":"v1.23.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package eval\n\nPackage eval is CommitBrief's review-quality eval harness (ADR-0018).\n\nIt scores a provider's actual review output against a curated known-answer corpus and reports precision / recall / false-positive rate. The corpus lives under testdata/corpus/\\\u003cname\u003e/, one directory per fixture: input.diff (the change under review), expected.json (the answer key), and, for the deterministic tier, mock\\_response.json (scripted findings fed to the mock provider).\n\nTwo execution tiers (ADR-0018 §3):\n\n  - Deterministic tier — TestEvalMockCorpus runs the corpus through the mock provider with each fixture's scripted response. It validates the harness, matcher, and scoring math, runs in plain \\`go test ./...\\`, and is therefore part of the CI gate. It does NOT measure model quality.\n\n  - Live tier — TestEvalLive (behind the \\`live\\` build tag, like the rest of the live provider tests) runs the corpus through a real provider and prints the quality scorecard. Non-deterministic and gated; it is the source of the README quality numbers, never a CI gate.\n\nEvery reported ratio is also broken down per language and per severity (BuildBreakdown / FormatBreakdown), each cell carrying its k/n, a 95% Wilson interval and a low\\_n flag when fewer than 20 distinct units back it. Fixture languages come from a closed set (CanonicalLanguages) that must agree with each fixture directory's suffix (Fixture.CheckLanguage).\n\nThe harness consumes provider output through the locked --json schema v1 findings\\[] (ADR-0014); it introduces no new output contract.\n\n## Constants\n\n```go\nconst (\n\tRecallMinValue         = 0.90\n\tFPRMaxValue            = 0.10\n\tLanguageRecallMinValue = 0.70\n)\n```\nRecallMinValue, FPRMaxValue and LanguageRecallMinValue are ADR-0043 §2's recall/fpr gate \"in force today\" (0.90/0.10, plus the per-language recall guard 0.70 added by §Update 2026-10-25). §1.5 forbids relaxing a threshold for a single run — env/flag overrides would make exactly that silent and undetectable from the results file, so these are package constants, not a knob. Changing them requires a dated §Update to ADR-0043 (review 2026-09-24, BLOCKER).\n\n```go\nconst (\n\tMinRuns                = 3\n\tMinBuggy               = 90\n\tMinClean               = 30\n\tMinExpectedPerLanguage = 10\n\tMinCleanPerLanguage    = 3\n)\n```\nADR-0043 §2 sufficiency (as re-derived by §Update 2026-10-25): a row only counts when it rests on at least MinRuns runs over a corpus of at least MinBuggy buggy and MinClean clean fixtures, and every canonical language carries at least MinExpectedPerLanguage expected findings and MinCleanPerLanguage clean fixtures in the row's breakdown (buggy and clean counted separately).\n\n## Functions\n\n```go\nfunc CanonicalLanguages() []string\n```\nCanonicalLanguages returns a copy of the closed set of fixture languages.\n\n```go\nfunc CorpusFingerprint(root string) (string, error)\n```\nCorpusFingerprint returns a stable SHA-256 fingerprint of the corpus rooted at root (ADR-0043 §4): for every fixture directory in directory-name order (the same order LoadCorpus returns), the fixture's name plus the raw bytes of its input.diff and expected.json. README.md and mock\\_response.json are deliberately excluded — one documents a fixture, the other only drives the mock tier, and neither is part of what a live measurement is graded against, so editing either must not change the fingerprint a results row is keyed to. Reads files directly rather than going through LoadFixture so the fingerprint covers the exact on-disk expected.json bytes, not the struct JSON round-tripped back through it.\n\n```go\nfunc FormatBreakdown(b Breakdown) []string\n```\nFormatBreakdown renders the breakdown as console lines (one per row, no trailing newline): language rows in canonical order, then severity rows most-severe first. Every ratio is printed as \\`rate k/n \\[wilson95]\\`, and a cell resting on fewer than 20 distinct units carries \"(n\\\u003c20)\".\n\n```go\nfunc IsCanonicalLanguage(lang string) bool\n```\nIsCanonicalLanguage reports whether lang is in the closed fixture language set.\n\n```go\nfunc LanguageDistribution(fixtures []Fixture) map[string]int\n```\nLanguageDistribution counts fixtures per answer-key language. Every reported ratio (recall/precision/fpr) must carry its language mix alongside n, so a results row and a \\`make eval\\` summary both build this from the same fixture slice they scored. A fixture whose expected.json omits \"language\" is counted under \"unknown\" rather than silently dropped — a gap in the corpus metadata should be visible, not hidden.\n\n```go\nfunc LanguageFromFixtureName(name string) (lang string, ok bool)\n```\nLanguageFromFixtureName derives the canonical language from a fixture directory name's trailing \\`-\\\u003csuffix\u003e\\` (e.g. \"sql-injection-go\" → \"go\", \"xss-innerhtml-js\" → \"javascript\"). ok is false when the name has no recognized suffix.\n\n```go\nfunc PromptSHA256() string\n```\nPromptSHA256 fingerprints the eval prompt independent of any fixture's diff (ADR-0043 §4): the system prompt and the user prompt \\*template\\* (diff not yet substituted in), the same (system, userTpl) pair buildRequest's prompt.Build call is built from. It changes whenever either text changes — including a user-template-only edit such as the line-number instructions — so a results row can be told apart from a measurement taken under an older prompt.\n\n```go\nfunc WilsonInterval(successes, n int) (lo, hi float64, ok bool)\n```\nWilsonInterval returns the 95% Wilson score interval for successes out of n trials. ok is false when the interval is undefined (n \\\u003c= 0, or successes outside \\[0, n]); callers must then report no interval rather than a NaN.\n\n```go\nfunc WriteResult(path string, corpus CorpusInfo, runs int, thresholds Thresholds, row BenchmarkRow) error\n```\nWriteResult merges one provider+model measurement into the results file at path (ADR-0043 §4), creating it if absent. Rows are keyed by (provider, model): re-measuring a pair replaces its row outright, even one written under an older prompt — prompt history survives only on whichever \\*other\\* rows still hold their own provider/model slot, not by stacking multiple measurements under one slot. Every row's \\`eligible\\` — including every pre-existing row, not only the one just written — is recomputed against corpus, runs, thresholds and row's own prompt hash, so an older row silently drops out of eligibility the moment a newer prompt is measured, without needing its own rewrite to notice.\n\nThe write is refused if the file already holds evidence for a different corpus fingerprint or run count: a results file holds exactly one corpus's worth of evidence, and mixing two would make every row's n meaningless. Output is deterministic: rows sorted by (provider, model), fixed field order via the struct, indented JSON with a trailing newline.\n\n## Types\n\n```go\ntype AfterFixtureFunc func(FixtureScore) error\n```\nAfterFixtureFunc is called by RunCorpusWith / RunCorpusNWith once per fixture, right after its score (or ErrorScore) is recorded. A non-nil error stops the run immediately; the caller owns what the error means (the live harness uses it for the COMMITBRIEF\\_EVAL\\_BUDGET\\_USD cap).\n\n```go\ntype BenchmarkFile struct {\n\tSchema      int            `json:\"schema\"`\n\tGeneratedAt string         `json:\"generated_at\"`\n\tCorpus      CorpusInfo     `json:\"corpus\"`\n\tRuns        int            `json:\"runs\"`\n\tThresholds  Thresholds     `json:\"thresholds\"`\n\tResults     []BenchmarkRow `json:\"results\"`\n}\n```\nBenchmarkFile is the whole ADR-0043 §4 results document — one corpus's worth of evidence across every measured provider+model.\n\n```go\nfunc LoadResults(path string) (bf BenchmarkFile, existed bool, err error)\n```\nLoadResults reads the results file at path. A missing file is not an error — it returns a zero BenchmarkFile and existed=false so WriteResult can create it on the first write.\n\nA file whose schema isn't 1 is refused rather than silently accepted: a future schema bump read back by this (older) code would otherwise get merged and rewritten as schema:1, quietly downgrading it (review 2026-09-24, MINOR).\n\n```go\ntype BenchmarkRow struct {\n\tProvider string `json:\"provider\"`\n\tModel    string `json:\"model\"`\n\n\tMeasuredAt        string `json:\"measured_at\"`\n\tPromptSHA256      string `json:\"prompt_sha256\"`\n\tCommitbriefCommit string `json:\"commitbrief_commit\"`\n\n\tRuns      int `json:\"runs\"`\n\tNBuggy    int `json:\"n_buggy\"`\n\tNClean    int `json:\"n_clean\"`\n\tNExpected int `json:\"n_expected\"`\n\n\tRecall               float64 `json:\"recall\"`\n\tRecallMin            float64 `json:\"recall_min\"`\n\tRecallMax            float64 `json:\"recall_max\"`\n\tPrecision            float64 `json:\"precision\"`\n\tFPR                  float64 `json:\"fpr\"`\n\tFPRMin               float64 `json:\"fpr_min\"`\n\tFPRMax               float64 `json:\"fpr_max\"`\n\tSilenceViolationRate float64 `json:\"silence_violation_rate\"`\n\tErrors               int     `json:\"errors\"`\n\n\tInputTokens       float64 `json:\"input_tokens\"`\n\tOutputTokens      float64 `json:\"output_tokens\"`\n\tCachedInputTokens float64 `json:\"cached_input_tokens\"`\n\n\tPricing      RowPricing `json:\"pricing\"`\n\tUSDPerReview float64    `json:\"usd_per_review\"`\n\n\tEligible bool `json:\"eligible\"`\n\n\t// Breakdown is the per-language and per-severity recall/fpr with n and\n\t// Wilson 95% intervals (ADR-0043 §4 §Update 2026-10-25). Additive: rows\n\t// written before it existed omit it and schema stays 1.\n\tBreakdown *Breakdown `json:\"breakdown,omitempty\"`\n}\n```\nBenchmarkRow is one provider+model measurement (ADR-0043 §4).\n\n```go\nfunc BuildRow(scs []Scorecard, pricing provider.Pricing, promptSHA256, commit string, measuredAt time.Time) (BenchmarkRow, error)\n```\nBuildRow pools k Scorecards — one per COMMITBRIEF\\_EVAL\\_RUNS repeat, all against the same corpus and provider+model — into a single ADR-0043 §4 results row. The headline ratios (recall, precision, fpr, silence\\_violation\\_rate) are pooled by summing raw counts across every run and dividing once, not by averaging each run's own ratio, so a run that happened to score more evidence isn't outweighed by one that scored less. recall\\_min/max and fpr\\_min/max instead report the spread across the individual per-run ratios — that spread is exactly what a flaky provider shows up as, and pooling it away would hide it.\n\n```go\ntype Breakdown struct {\n\tLanguage map[string]BreakdownEntry `json:\"language\"`\n\tSeverity map[string]BreakdownEntry `json:\"severity\"`\n}\n```\nBreakdown is the ADR-0043 §4 additive \\`breakdown\\` object on a results row. Language always lists every canonical language (n = 0 where the corpus has none yet, e.g. java/php), plus \"unknown\" if a fixture carries none.\n\n```go\nfunc BuildBreakdown(scs []Scorecard) Breakdown\n```\nBuildBreakdown pools k Scorecards of the same corpus into the per-language and per-severity breakdown, summing raw counts across runs exactly as BuildRow does for the headline ratios.\n\n```go\ntype BreakdownEntry struct {\n\tRecall RateStat `json:\"recall\"`\n\tFPR    RateStat `json:\"fpr\"`\n}\n```\nBreakdownEntry is one language's or one severity's recall and fpr.\n\nPer language: Recall counts caught ÷ expected defects in that language's buggy fixtures; FPR counts clean fixtures of that language that drew a low-or-higher finding ÷ clean fixtures of that language.\n\nPer severity: Recall is keyed by the answer-key severity floor (min\\_severity) of the expected defect, \"unspecified\" if it sets none. FPR is keyed by an alarm floor: the clean fixtures that drew a finding of at least that severity ÷ all clean fixtures (so \"low\" equals the headline fpr). \"info\" is never an fpr floor (ADR-0043 §3 excludes it), and \"unspecified\" has no fpr, so those cells carry n = 0.\n\n```go\ntype CategoryRecall struct {\n\tCategory string\n\tCaught   int\n\tTotal    int\n}\n```\nCategoryRecall is per-category recall for one expected-finding category.\n\n```go\ntype CorpusInfo struct {\n\tFingerprint string         `json:\"fingerprint\"`\n\tNFixtures   int            `json:\"n_fixtures\"`\n\tNBuggy      int            `json:\"n_buggy\"`\n\tNClean      int            `json:\"n_clean\"`\n\tNExpected   int            `json:\"n_expected\"`\n\tLanguages   map[string]int `json:\"languages\"`\n}\n```\nCorpusInfo identifies which corpus a results file's rows were measured against (ADR-0043 §4). Fingerprint is the authority WriteResult uses to refuse mixing two different corpora into one file.\n\n```go\nfunc NewCorpusInfo(fixtures []Fixture, fingerprint string) CorpusInfo\n```\nNewCorpusInfo summarizes a fixture slice into a results file's corpus block. fingerprint is computed separately (CorpusFingerprint) so every row written in the same eval-live invocation shares one value even though ADR-0043 §3 model-selection metrics score the whole corpus, not the dev/held-out split ADR-0018 uses for tuning-safety diagnostics.\n\n```go\ntype ExpectedFinding struct {\n\tID          string          `json:\"id\"`\n\tFile        string          `json:\"file\"`\n\tLine        int             `json:\"line\"`\n\tLineTol     int             `json:\"line_tol,omitempty\"`\n\tCategory    string          `json:\"category\"`\n\tMinSeverity render.Severity `json:\"min_severity,omitempty\"`\n\tSummary     string          `json:\"summary\"`\n}\n```\nExpectedFinding is one entry in a fixture answer key — a defect the review SHOULD surface (ADR-0018 §1). Category is reporting metadata, not a match criterion: the locked findings schema carries no category field.\n\n```go\ntype Fixture struct {\n\tName             string\n\tDir              string\n\tLanguage         string\n\tDiff             string\n\tExpected         []ExpectedFinding\n\tMustStaySilentOn []SilenceAnchor\n\tMockResponse     string\n\n\t// HeldOut marks the fixture as part of the generalization-only slice;\n\t// see answerKey.HeldOut.\n\tHeldOut bool\n}\n```\nFixture is one known-answer corpus entry: a diff plus its answer key. MockResponse is the scripted findings JSON used by the deterministic tier; it is empty when the fixture ships no mock\\_response.json.\n\n```go\nfunc LoadCorpus(root string) ([]Fixture, error)\n```\nLoadCorpus loads every fixture under root — each child directory that contains an input.diff. Fixtures are returned sorted by name so every run iterates deterministically.\n\n```go\nfunc LoadFixture(dir string) (Fixture, error)\n```\nLoadFixture reads a single corpus directory: input.diff + expected.json (required) and mock\\_response.json (optional, for the deterministic tier).\n\n```go\nfunc (fx Fixture) Categories() []string\n```\nCategories returns the distinct categories a fixture exercises: the category of each expected finding, or \"clean\" for a clean control (no expected findings). Used to check that the held-out slice is representative rather than concentrated in one category.\n\n```go\nfunc (fx Fixture) CheckLanguage() error\n```\nCheckLanguage verifies the fixture's answer-key language is in the canonical set and agrees with its directory-name suffix. It is a corpus consistency check, deliberately not run by LoadFixture: the loader stays permissive so tooling and tests can load ad-hoc fixture directories.\n\n```go\ntype FixtureScore struct {\n\tFixture string\n\tHeldOut bool // mirrors Fixture.HeldOut so a Scorecard can be split\n\n\t// Language mirrors Fixture.Language (empty → counted as \"unknown\") so a\n\t// Scorecard can be broken down per language (Scorecard.breakdown).\n\tLanguage string\n\n\tTruePositives  int // expected findings that were matched\n\tFalseNegatives int // expected findings that were missed\n\tFalsePositives int // produced findings that matched no expected finding\n\n\tSilenceViolations int // produced findings landing on a silence anchor\n\tSilenceAnchors    int // total silence anchors in the fixture\n\n\t// CaughtByCategory / MissedByCategory attribute each expected finding to\n\t// its category, giving a per-category recall breakdown (ADR-0018 §2).\n\tCaughtByCategory map[string]int\n\tMissedByCategory map[string]int\n\n\t// CaughtBySeverity / MissedBySeverity attribute each expected finding to\n\t// its answer-key severity floor (ExpectedFinding.MinSeverity; an entry\n\t// with no floor is keyed severityUnspecified). They feed the per-severity\n\t// recall breakdown.\n\tCaughtBySeverity map[string]int\n\tMissedBySeverity map[string]int\n\n\t// MaxProducedSeverity is the highest severity among the findings produced\n\t// on a clean-control fixture (\"\" when none, or on a buggy fixture). It\n\t// feeds the per-severity-floor FPR breakdown; CleanAlarm itself is still\n\t// the authority for the headline fpr.\n\tMaxProducedSeverity render.Severity\n\n\t// Usage is the token usage the provider reported for this fixture's\n\t// Review call. Zero on the mock tier (the mock provider's usage is a\n\t// fixed stub, never billed) and on a fixture whose Review call itself\n\t// failed (no response was ever returned to report usage from). Still\n\t// populated on a fixture that errored only because its response body\n\t// couldn't be parsed as findings — the provider did report usage for\n\t// that call, and RunFixture/RunCorpus carry it through rather than\n\t// discarding it (review 2026-09-24, MINOR).\n\tUsage provider.Usage\n\n\t// CleanAlarm reports whether this run raised at least one produced\n\t// finding of severity low-or-higher on a clean-control fixture —\n\t// ADR-0043 §3's fpr numerator for a single fixture run. info findings\n\t// don't count (the severity rubric defines info as \"no action\n\t// required\"); they still show up in Precision. Always false for a\n\t// fixture that planted a defect.\n\tCleanAlarm bool\n\n\t// Errored marks a fixture whose review call failed after the harness's\n\t// own retries, or whose output could not be parsed (ADR-0043 §3). Such\n\t// a run is scored as a miss for every expected finding and, for a\n\t// clean fixture, as a CleanAlarm — see ErrorScore.\n\tErrored bool\n\n\t// ErrorMsg is the last attempt's error text when Errored is true (empty\n\t// otherwise). RunCorpus previously swallowed this after exhausting\n\t// retries — a run's log looked identical whether a model genuinely\n\t// missed every finding or every call to it failed. Carrying the message\n\t// through lets the caller log it instead (review 2026-09-24, MAJOR).\n\tErrorMsg string\n}\n```\nFixtureScore is the per-fixture outcome of scoring produced findings against the answer key.\n\n```go\nfunc ErrorScore(fx Fixture) FixtureScore\n```\nErrorScore produces the FixtureScore for a fixture whose review call failed after the harness's own retries, or whose output could not be parsed (ADR-0043 §3). It counts as a miss for every expected finding of a buggy fixture, and as a CleanAlarm for a clean fixture — an errored model is not silently dropped from the corpus it failed on.\n\n```go\nfunc RunFixture(ctx context.Context, p provider.Provider, fx Fixture, model string) (FixtureScore, error)\n```\nRunFixture runs one fixture through a provider and scores the result. An empty model uses the provider's default model. On error the returned FixtureScore is not a scored result — callers must check err first — but it still carries Usage when reviewFindings obtained one (a parse failure still means the provider billed for and returned a response), so a caller building an ErrorScore for this attempt doesn't have to throw that usage away (review 2026-09-24, MINOR).\n\n```go\nfunc Score(produced []render.Finding, fx Fixture) FixtureScore\n```\nScore matches produced findings against a fixture's answer key using one-to-one greedy assignment (ADR-0018 §2) and returns the tally. The corpus is assumed fully annotated, so any produced finding that matches no expected finding counts as a false positive.\n\n```go\nfunc (s FixtureScore) IsBuggy() bool\n```\nIsBuggy reports whether this fixture had at least one planted defect — the same \"expected == 0 means clean\" rule Recall/Precision already use.\n\n```go\nfunc (s FixtureScore) Precision() float64\n```\nPrecision = TP / (TP + FP). A run that produced no findings is vacuously precise (returns 1) so it does not divide by zero or drag an aggregate.\n\n```go\nfunc (s FixtureScore) Recall() float64\n```\nRecall = TP / (TP + FN). A fixture that expects nothing (a clean diff) is fully recalled by definition (returns 1).\n\n```go\nfunc (s FixtureScore) SilenceViolationRate() float64\n```\nSilenceViolationRate = silence violations ÷ silence anchors. Returns 0 when the fixture defines no anchors.\n\n```go\ntype RateStat struct {\n\tRate       *float64 `json:\"rate\"`\n\tK          int      `json:\"k\"`\n\tN          int      `json:\"n\"`\n\tNDistinct  int      `json:\"n_distinct\"`\n\tWilsonLow  *float64 `json:\"wilson_low\"`\n\tWilsonHigh *float64 `json:\"wilson_high\"`\n\tLowN       bool     `json:\"low_n\"`\n}\n```\nRateStat is one reported ratio together with the evidence behind it. K and N are pooled over every run (so Rate = K/N, the same sum-then-divide pooling BuildRow uses); NDistinct is N per run — the number of distinct defects or clean fixtures the ratio rests on. Repeating a run does not add independent evidence, so the Wilson interval and LowN are computed at NDistinct, not N. When N == 0 the ratio is undefined: Rate and the interval are null (never NaN) and LowN is true.\n\n```go\ntype RowPricing struct {\n\tInputPer1M  float64 `json:\"input_per_1m\"`\n\tOutputPer1M float64 `json:\"output_per_1m\"`\n}\n```\nRowPricing is the pricing snapshot a results row was costed against — copied from provider.Pricing rather than reusing it directly so a pricing-struct field this package doesn't emit (there are none today, but the type is provider-owned) never leaks into the results schema by accident.\n\n```go\ntype Scorecard struct {\n\tProvider string\n\tModel    string\n\tFixtures []FixtureScore\n}\n```\nScorecard aggregates fixture scores for one provider+model run.\n\n```go\nfunc RunCorpus(ctx context.Context, p provider.Provider, model string, fixtures []Fixture) (Scorecard, error)\n```\nRunCorpus runs every fixture through the provider and returns a Scorecard. A fixture hitting a transient provider error (isRetriable) is retried up to corpusAttempts times with linear backoff. A fixture that still fails once retries are exhausted — or a non-transient failure on the first attempt — does not abort the run (ADR-0043 §3): it is recorded via ErrorScore (a miss for every expected finding, an alarm if the fixture is clean) and the corpus continues, so one flaky model call doesn't erase every other fixture's evidence. Only ctx cancellation (an operator-level abort, not a model error) still stops the run early.\n\n```go\nfunc RunCorpusN(ctx context.Context, p provider.Provider, model string, fixtures []Fixture, n int) ([]Scorecard, error)\n```\nRunCorpusN runs the corpus n times (COMMITBRIEF\\_EVAL\\_RUNS, ADR-0043 §3's k), returning one Scorecard per run in order. Stops and returns the error immediately if any run itself fails to complete (ctx cancellation) — per-fixture errors within a run are already absorbed by RunCorpus and never reach this level.\n\n```go\nfunc RunCorpusNWith(ctx context.Context, p provider.Provider, model string, fixtures []Fixture, n int, after AfterFixtureFunc) ([]Scorecard, error)\n```\nRunCorpusNWith is RunCorpusN with the per-fixture hook of RunCorpusWith, shared across all n runs (so a hook can keep a running total over the whole invocation). A hook error (or ctx cancellation) stops everything and is returned wrapped (errors.Is / errors.As see through it), together with the scorecards completed so far, the partial run last. Callers must check err before treating the slice as a full set of k runs.\n\n```go\nfunc RunCorpusWith(ctx context.Context, p provider.Provider, model string, fixtures []Fixture, after AfterFixtureFunc) (Scorecard, error)\n```\nRunCorpusWith is RunCorpus with an optional per-fixture hook. A nil hook behaves exactly like RunCorpus. When the hook returns an error the run stops and the error is returned alongside the partial Scorecard (the fixtures scored so far), so a caller can still report what was spent.\n\n```go\nfunc (sc Scorecard) Breakdown() Breakdown\n```\nBreakdown pools this single Scorecard's per-language and per-severity counts; shorthand for BuildBreakdown of one run.\n\n```go\nfunc (sc Scorecard) CategoryRecall() []CategoryRecall\n```\nCategoryRecall returns recall per expected-finding category, sorted by category name for deterministic output.\n\n```go\nfunc (sc Scorecard) CleanAlarms() int\n```\nCleanAlarms is the count of clean-control fixtures on which this run raised at least one low-or-higher finding — ADR-0043 §3's fpr numerator for a single Scorecard. Pool across k runs by summing CleanAlarms() and dividing by (runs × NClean()), not by averaging each run's own rate.\n\n```go\nfunc (sc Scorecard) Dev() Scorecard\n```\nDev returns the tunable slice (fixtures the prompt/corpus may be tuned against). HeldOut returns the generalization-only slice (ADR-0018 §Goodhart). A change is overfitting when Dev recall rises but HeldOut recall does not.\n\n```go\nfunc (sc Scorecard) Errors() int\n```\nErrors is the count of fixtures in the scorecard whose run errored after retries (ADR-0043 §3) — a provider failure or an unparseable response, recorded rather than aborting the corpus.\n\n```go\nfunc (sc Scorecard) HeldOut() Scorecard\n```\n\n```go\nfunc (sc Scorecard) NBuggy() int\n```\nNBuggy is the number of fixtures in the scorecard that planted at least one defect (mirrors Recall's own \"expected == 0 means clean\" rule).\n\n```go\nfunc (sc Scorecard) NClean() int\n```\nNClean is the number of clean-control fixtures (no planted defect) in the scorecard.\n\n```go\nfunc (sc Scorecard) NExpected() int\n```\nNExpected is the total number of planted defects (expected findings) across every fixture in the scorecard.\n\n```go\nfunc (sc Scorecard) Precision() float64\n```\nPrecision is the corpus-wide TP / (TP + FP).\n\n```go\nfunc (sc Scorecard) PrecisionN() int\n```\nPrecisionN is Precision's denominator (TP + FP, every produced finding the run was scored against).\n\n```go\nfunc (sc Scorecard) Recall() float64\n```\nRecall is the corpus-wide TP / (TP + FN).\n\n```go\nfunc (sc Scorecard) RecallN() int\n```\nRecallN is Recall's denominator (TP + FN, i.e. every planted defect the run was scored against) — the n a reported recall figure should always be printed alongside, since \"87% recall\" is meaningless without it.\n\n```go\nfunc (sc Scorecard) SilenceViolationRate() float64\n```\nSilenceViolationRate is the corpus-wide silence violations ÷ silence anchors.\n\n```go\nfunc (sc Scorecard) SilenceViolationRateN() int\n```\nSilenceViolationRateN is SilenceViolationRate's denominator (total silence anchors in the scored fixtures).\n\n```go\nfunc (sc Scorecard) TotalUsage() provider.Usage\n```\nTotalUsage sums the provider usage reported across every fixture in the scorecard — the basis for a cost-per-review figure.\n\n```go\ntype SilenceAnchor struct {\n\tFile   string `json:\"file\"`\n\tLine   int    `json:\"line\"`\n\tReason string `json:\"reason\"`\n}\n```\nSilenceAnchor marks a line a good review should NOT flag. A produced finding landing on (File, ~Line) is a measured false positive (ADR-0018 §2).\n\n```go\ntype Thresholds struct {\n\tRecallMin         float64 `json:\"recall_min\"`\n\tFPRMax            float64 `json:\"fpr_max\"`\n\tLanguageRecallMin float64 `json:\"language_recall_min\"`\n}\n```\nThresholds mirrors D-W2-4's recall/fpr gate for ADR-0043 §1 as stored in a results file. Always populated from DefaultThresholds (ADR-0043 §2) — see its doc comment. LanguageRecallMin is additive (§Update 2026-10-25, schema stays 1) and is the single source of the per-language floor: computeEligible reads it from here, never from the constant.\n\n```go\nfunc DefaultThresholds() Thresholds\n```\nDefaultThresholds returns the ADR-0043 §2 gate every WriteResult call asserts against.\n\n","path":"github.com/CommitBrief/commitbrief/internal/eval","name":"eval","synopsis":"Package eval is CommitBrief's review-quality eval harness (ADR-0018).","isRedistributable":true}
