askeval

package
v0.25.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 27 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package askeval implements issue #266's offline end-to-end evaluation runner for POST /api/v1/ask: it drives the REAL handler (internal/api, via httptest — see runner.go) against a synthetic, isolated corpus (see corpus.go) and a scripted LLM (see llm.go), so retrieval, query rewriting, the query planner, excerpt budgeting, synthesis, and the deterministic citation validator (issue #268) all run exactly as they do in production — never a mock of /ask's own logic.

This package intentionally contains NO real personal data: every fixture in eval/ask/fixtures/ is synthetic, and the corpus it builds exists only for the duration of one Run call (see runner.go's per-fixture *corpus).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FixtureSetHash

func FixtureSetHash(fixtures []Fixture) string

FixtureSetHash is a short, deterministic digest of the exact fixture content Load returned — report.go's Provenance.FixtureSetHash. Two Runs with different hashes are NOT diffable (DiffReports refuses): the fixture set itself changed, so a pass/fail delta would not mean "the code changed", it would mean "the test changed".

func RemoteJudgePromptHash added in v0.24.0

func RemoteJudgePromptHash() string

RemoteJudgePromptHash returns a short, deterministic digest of remoteJudgeSystemPrompt — cmd/askeval records it in Provenance.JudgePromptHash so a report reader can tell whether a prompt change invalidates a previous remote-judge shadow run, the same role FixtureSetHash plays for the fixture set itself.

func RunShadowJudge added in v0.24.0

func RunShadowJudge(ctx context.Context, j ClaimJudge, results []CaseResult)

RunShadowJudge judges every case's cited claims with j and attaches the tally to that case's Metrics.Shadow field, MUTATING results in place — it never touches Metrics.Pass. Running this strictly AFTER Run has already produced every CaseResult's final (judge-independent) Metrics is the structural guarantee behind issue #273's "judge 실패/불일치를 정상 통과로 처리하지 않는다" requirement: there is no code path in this package by which a judge's verdict could reach Pass, by construction, rather than by a rule this function has to remember to follow.

A case is skipped entirely (Metrics.Shadow left nil — "not evaluated", never a zero-value tally) when:

  • the case measured nothing at all (CaseResult.Err != nil);
  • the fixture declares no Gold.ClaimSupport annotations to judge against at all (most fixtures — judging them would produce either an uninterpretable verdict with nothing to compare it to, or, for fakeJudge specifically, a guaranteed VerdictError on every unit);
  • the answer cited nothing a JudgeUnit could be built from (judgeUnitsFor returns zero units).

Types

type AbstentionStats added in v0.24.0

type AbstentionStats struct {
	// Considered is the number of fixtures this stat was computed over —
	// always <= the report's total case count. Check this before trusting
	// Precision/Recall on a small or zero-Considered report: a run over a
	// fixture set with few natural-abstention fixtures produces a
	// low-Considered, high-variance stat by nature, not a pipeline defect.
	Considered int `json:"considered"`
	Predicted  int `json:"predicted_abstain"`
	Actual     int `json:"actual_unanswerable"`
	// TruePositive/FalsePositive/FalseNegative are the raw confusion-
	// matrix counts Precision/Recall are computed from. FalsePositive
	// doubles as issue #266's "normal-answer loss" figure: an answerable
	// fixture the pipeline wrongly declined to answer
	// (CaseMetrics.FalseAbstention), aggregated here at the report level.
	TruePositive  int `json:"true_positive"`
	FalsePositive int `json:"false_positive"`
	FalseNegative int `json:"false_negative"`
	// Precision/Recall are 0 (never NaN) when their denominator is 0 —
	// check Predicted/Actual above to tell "0 because nothing predicted
	// abstain" apart from "0 because every prediction was wrong".
	Precision float64 `json:"precision"`
	Recall    float64 `json:"recall"`
}

AbstentionStats is the report-level abstention precision/recall summary (issue #273) — computed only from fixtures whose finish_reason/ citation_status reflect REAL pipeline behaviour. Any fixture with a non-empty ScriptedAnswer (every adversarial-citation, fabrication self-test, and claim-support-injection fixture) is EXCLUDED: its finish_reason/citation_status was forced by the fixture author to provoke a specific detector, not produced by the real abstention decision path, so counting it here would not measure the pipeline at all — see BuildReport.

type CaseMetrics

type CaseMetrics struct {
	// RetrievalHit: every Gold.SupportDocs document ID appears in the
	// "sources" SSE event — retrieval FOUND the evidence, independent of
	// whether the excerpt budget kept it in the prompt. Only meaningful
	// for an answerable, non-adversarial fixture, or an adversarial-citation
	// fixture whose Gold declares SupportDocs. nil (omitted from JSON) for
	// every other fixture shape — deep-verify #266 LOW finding: a bare
	// `false` here for a fixture where the field means nothing (e.g. every
	// unanswerable fixture) read as a real negative result to a report
	// consumer scanning JSON, when in fact retrieval was never even
	// evaluated for this fixture.
	RetrievalHit *bool `json:"retrieval_hit,omitempty"`
	// CitationWithinSupport: every Verification.CitedIDs entry resolves
	// into Gold.SupportDocs — the gap issue #273 closes. askCitationStatus
	// "valid" only proves a cited ID was actually shown to the model (any
	// prompt-evidence document); it says nothing about whether that
	// document is one of THIS fixture's own support documents. A correct-
	// sounding claim mis-attributed to a real, retrieved, but unrelated
	// document reaches "valid" today with no other signal catching it.
	// Only meaningful when Gold.SupportDocs is non-empty AND the answer
	// cited at least one ID; nil (omitted from JSON) otherwise — see
	// RetrievalHit's doc comment for why a bare `false` would misread as a
	// real negative here.
	CitationWithinSupport *bool `json:"citation_within_support,omitempty"`
	// ContextHit: every Gold.SupportSpans string is a substring of the
	// EXACT text the real pipeline placed in the Stage 3 synthesis prompt
	// (captured via scriptedCompleter.synthesisPrompt) — retrieval finding
	// the document is not sufficient if buildBudgetedAskMessages' excerpt
	// budget clipped the passage before the gold sentence (deep-plan #268
	// finding F2). RetrievalHit==true && ContextHit==false is exactly the
	// "retrieval succeeded, context assembly failed" case issue #266 asks
	// to distinguish from a plain retrieval miss. nil (omitted from JSON)
	// when not applicable — see RetrievalHit's doc comment.
	ContextHit *bool `json:"context_hit,omitempty"`
	// AnswerCorrect: every Gold.Claims substring appears in the answer
	// text. Only meaningful for an answerable, non-adversarial fixture; nil
	// (omitted from JSON) for every other fixture shape — see RetrievalHit's
	// doc comment.
	AnswerCorrect *bool `json:"answer_correct,omitempty"`
	// CitationStatus mirrors the done event's verification.citation_status
	// (issue #268's askCitationStatus values: valid/invalid/missing/
	// abstained/unverified), or "no_evidence" when synthesis never ran at
	// all (verification is absent on that finish_reason by design).
	CitationStatus string `json:"citation_status,omitempty"`
	// InferredCited is true when the done event's
	// verification.inferred_cited_ids is non-empty — the "추론을 사실로
	// 인용" regression signal (ask_evidence.go's askEvidenceLayer doc
	// comment).
	InferredCited bool `json:"inferred_cited,omitempty"`
	// AbstainedCorrectly: an UNANSWERABLE fixture (Gold.Answerable==false)
	// got finish_reason "no_evidence" or citation_status "abstained".
	AbstainedCorrectly bool `json:"abstained_correctly,omitempty"`
	// FabricatedAnswer: an UNANSWERABLE fixture (Gold.Answerable==false,
	// Gold.ExpectedCitationStatus unset) produced a NON-abstaining answer
	// that actually cited something (verification.cited_ids non-empty) —
	// the model claimed a fact instead of declining. This is the detector
	// deep-verify #266 HIGH finding asked for: before it existed, every
	// no_evidence/irrelevant_evidence fixture relied entirely on
	// scriptedCompleter's own oracle (llm.go's synthesize), which ALWAYS
	// returns the fixed abstention phrase whenever Gold.SupportSpans is
	// empty — true for every such fixture — so these categories could never
	// fail no matter how badly a real regression broke abstention handling;
	// nothing exercised the "the pipeline answered anyway" path at all. A
	// fixture whose ScriptedAnswer bypasses the oracle to deliberately
	// fabricate such an answer (see fixture.go's Fixture.ScriptedAnswer,
	// ne-04/05 and ie-04/05 in eval/ask/fixtures/) makes this field the
	// fixture's OWN pass signal (see computeMetrics' default case) instead
	// of a byproduct of AbstainedCorrectly: an independent check computed
	// from the citation report rather than merely the logical negation of
	// AbstainedCorrectly, so a future change that loosens
	// isAskAbstentionAnswer/AbstainedCorrectly's own definition cannot
	// silently make this whole category pass again by definition. Always
	// false (and always the logical negation of AbstainedCorrectly) outside
	// the default/unanswerable branch — see computeMetrics.
	FabricatedAnswer bool `json:"fabricated_answer,omitempty"`
	// FalseAbstention: an ANSWERABLE fixture got no_evidence/abstained
	// instead of a claim — "normal-answer loss" (issue #266 completion
	// criteria: report loss on ordinary questions, not just gains on
	// adversarial ones).
	FalseAbstention bool `json:"false_abstention,omitempty"`
	// Pass is this case's single pass/fail rollup — see computeMetrics for
	// the exact rule per fixture shape (adversarial-citation vs answerable
	// vs unanswerable). report.go's category/summary counts are built from
	// this field alone.
	Pass bool `json:"pass"`
	// AnswerBytes/PromptBytes are byte-size cost PROXIES (issue #266
	// completion criteria requires stating this explicitly): actual token
	// cost depends on the configured model's tokenizer, which this offline
	// scripted run never calls.
	AnswerBytes int                `json:"answer_bytes"`
	PromptBytes int                `json:"prompt_bytes"`
	LatencyMS   map[string]float64 `json:"latency_ms,omitempty"`
	// Shadow is the ONLY field this struct's own top-level doc comment's
	// "never a semantic judge" guarantee does not apply to
	// (report.go's Provenance.JudgeMode=="shadow" only): one ClaimJudge's
	// tally over this case's cited claims (judge.go). nil whenever judging
	// did not run for this case — --judge=off, a harness error (Err!=nil),
	// or a fixture with no Gold.ClaimSupport annotations to judge against
	// (judge.go's RunShadowJudge treats that as "not evaluated", never as
	// a zero-value tally). computeMetrics never reads or writes this field
	// and Pass never depends on it — see JudgeShadow's own doc comment.
	Shadow *JudgeShadow `json:"shadow,omitempty"`
}

CaseMetrics is one fixture's scored outcome. Every field EXCEPT Shadow is a DETERMINISTIC detector result computed from what the real /ask pipeline actually produced for this fixture (runner.go's CaseResult) — never a semantic judge (issue #266 scope explicitly excludes a runtime LLM judge as a Pass gate; see report.go's Provenance.JudgeMode for the shadow-only exception, and Shadow's own doc comment below for the one field that IS a judge's output).

type CaseResult

type CaseResult struct {
	Fixture      Fixture
	Metrics      CaseMetrics
	RawAnswer    string
	Sources      []sourceItem
	Plan         *planPayload
	Verification *verificationPayload
	FinishReason string
	LatencyMS    map[string]float64
	// Err is set when the fixture itself could not be executed at all (a
	// harness/fixture-authoring bug: bad as_of, unresolvable alias,
	// scripted-LLM contract violation) — distinct from a normal metric
	// failure, which always has Err==nil and a Metrics.Pass==false
	// instead. report.go surfaces Err separately so a broken fixture is
	// never silently counted as "the pipeline produced a wrong answer".
	Err error
}

CaseResult is one fixture's raw run outcome plus its scored CaseMetrics.

func Run

func Run(ctx context.Context, fixtures []Fixture, opts RunOptions) []CaseResult

Run executes every fixture against the REAL /ask handler (api.Server, via httptest) and returns one CaseResult per fixture, in input order.

Fixtures run strictly SEQUENTIALLY, one *api.Server per fixture: each fixture declares its own isolated corpus (Fixture.Corpus), and the scripted LLM (llm.go) is stateful — forFixture rebinds its currently- scripted fixture and resets its call log — so two fixtures in flight at once would race on which one is being scripted at any given moment. This keeps the runner simple and fully deterministic at the cost of wall-clock time; parallelizing across fixtures (each with its own scriptedCompleter instance) is possible future work, not required by issue #266's completion criteria.

type CaseSummary

type CaseSummary struct {
	ID       string      `json:"id"`
	Category string      `json:"category"`
	Pass     bool        `json:"pass"`
	Metrics  CaseMetrics `json:"metrics"`
	// Error is non-empty exactly when the source CaseResult.Err was set —
	// a harness/fixture bug, not a pipeline-quality finding. Pass is
	// forced false whenever Error is set, but a report reader must not
	// conflate the two: a non-empty Error means this fixture measured
	// NOTHING, not that it measured a failure.
	Error string `json:"error,omitempty"`
}

CaseSummary is one fixture's report row.

type CategorySummary

type CategorySummary struct {
	Category string `json:"category"`
	Total    int    `json:"total"`
	Passed   int    `json:"passed"`
}

CategorySummary aggregates CaseMetrics.Pass for one fixture category.

type ClaimJudge added in v0.24.0

type ClaimJudge interface {
	Judge(ctx context.Context, claim, excerpt string) (Verdict, error)
}

ClaimJudge judges whether one claim (a sentence-shaped excerpt of an answer) is supported by one cited document's excerpt. This is issue #273's shadow-only semantic layer, distinct from and never a substitute for issue #268's deterministic askCitationStatus validator: that validator proves a cited ID was actually SHOWN to the model; a ClaimJudge is the only thing in this package that ever asks whether the cited passage SUPPORTS the specific claim next to it. See RunShadowJudge for why a ClaimJudge's verdicts can only ever subtract from a report, never add — CaseMetrics.Pass never reads a ClaimJudge's output.

The ONLY implementation go test/CI ever construct is fakeJudge (judge_fake.go) — fully offline and deterministic. remoteJudge (judge_remote.go) is a real, remote-API-only implementation (never local inference, per this repo's no-local-inference policy), gated behind explicit configuration and never constructed by this package's own tests.

func NewFakeJudge added in v0.24.0

func NewFakeJudge() ClaimJudge

NewFakeJudge returns a ClaimJudge backed entirely by fixture data — no network call, ever. This is what --judge-backend=fake (cmd/askeval's default) constructs, and the only judge this package's own tests use.

func NewRemoteClaimJudge added in v0.24.0

func NewRemoteClaimJudge(cfg RemoteJudgeConfig) (ClaimJudge, error)

NewRemoteClaimJudge builds a ClaimJudge backed by a real, remote, OpenAI-compatible chat completion endpoint (internal/llm.Client — never local inference, per this repo's no-local-inference policy: project memory `project_no_local_inference_policy.md`). It is NEVER constructed by go test or CI; the only caller is cmd/askeval, itself gated behind an explicit --judge-backend=remote flag. This constructor does not trust that gate alone — it independently re-checks every precondition:

  • cfg.APIKey or cfg.AuthFile must be set (an authenticated token source) — refuses with no key configured at all.
  • cfg.FixturesDir must resolve under this repo's eval/ask/fixtures tree — refuses a --fixtures path pointed anywhere else, so a remote judge run cannot see real user data even by an operator's mistake.
  • no DATABASE_URL or *_DATABASE_URL environment variable may be set in this process — a remote judge process has no legitimate reason to also hold a database credential; refusing to start when one is present is a cheap, structural guard against that combination ever reaching a real corpus.

type ClaimSupportAnnotation added in v0.24.0

type ClaimSupportAnnotation struct {
	DocAlias         string  `json:"doc_alias"`
	SentenceContains string  `json:"sentence_contains"`
	Expected         Verdict `json:"expected"`
}

ClaimSupportAnnotation is one optional human expectation attached to a fixture's Gold (fixture.go's Gold.ClaimSupport) — see that field's doc comment for how it is used and why it is never a Pass gate.

type CorpusDoc

type CorpusDoc struct {
	// Alias is this fixture's own stable name for the document — NEVER a
	// UUID. aliasID (corpus.go) derives a deterministic uuid.UUID from it,
	// so the same alias always maps to the same document ID on every run
	// (required for Gold.SupportDocs references and report.go's baseline
	// diff to stay meaningful across runs).
	Alias string `json:"alias"`
	// SourceType is a model.SourceType string value (e.g. "gmail",
	// "call", "calendar"). Kept as a plain string here — this file does
	// not import internal/model — and converted in corpus.go.
	SourceType string `json:"source_type"`
	Title      string `json:"title"`
	Content    string `json:"content"`
	// OccurredAt is RFC3339 ("2026-06-10T09:00:00+09:00"); empty means nil
	// — the "unknown event time", not "same day as now", distinction
	// ask.go's formatOccurredAt exists to preserve. A fixture that needs a
	// window/source-filter test to actually exclude this document MUST set
	// this field: assembleRetrieval's plan.OccurredFrom/To predicate drops
	// every row with a nil OccurredAt once either bound is set
	// (model.SearchQuery.OccurredFrom's doc comment).
	OccurredAt string `json:"occurred_at,omitempty"`
}

CorpusDoc is one document a fixture's isolated corpus contains.

type Diff

type Diff struct {
	FixtureSetHash             string
	Improved, Regressed        []string
	StillFailing, StillPassing []string
	Summary                    string
}

Diff is a per-case pass/fail delta between two reports built from the SAME fixture set — never a bare aggregate-score difference, which can hide a fixture that flipped pass->fail while another flipped the other way (issue #266 completion criteria: report failing cases explicitly).

func DiffReports

func DiffReports(baseline, candidate Report) (Diff, error)

DiffReports compares baseline against candidate. Both MUST share the same Provenance.FixtureSetHash — a different hash means the fixture set itself changed between runs, so any pass/fail delta would describe a test change, not a code change, and DiffReports refuses to produce one.

type Fixture

type Fixture struct {
	ID       string `json:"id"`
	Category string `json:"category"`
	// AsOf is this fixture's "now" (RFC3339), injected into the real
	// pipeline via api.Server.WithClock (ask_eval_hooks.go) so "어제"/
	// "지난주" resolve the same way regardless of when this fixture is
	// actually executed.
	AsOf     string      `json:"as_of"`
	Corpus   []CorpusDoc `json:"corpus"`
	History  []Turn      `json:"history,omitempty"`
	Question string      `json:"question"`
	// StandaloneQuestion is the scripted answer to the query-rewrite call
	// (ask_rewrite.go) when History is non-empty — rewriteStandaloneQuestion
	// never calls the LLM for a first turn, so this is ignored and may be
	// left empty when History is empty.
	StandaloneQuestion string `json:"standalone_question,omitempty"`
	// ScriptedAnswer, when non-empty, is returned verbatim (after
	// "{{doc:<alias>}}"/"{{fake}}" placeholder substitution — see llm.go)
	// as the synthesis answer, overriding the default evidence-echo oracle.
	// Required for every adversarial-citation fixture (Gold.
	// ExpectedCitationStatus set) and every claim-support-injection
	// self-test (Gold.ExpectedDetector set). Permitted on an UNANSWERABLE
	// fixture (Gold.Answerable==false) with neither set — the fabrication
	// self-tests (ne-04/05, ie-04/05) use exactly this shape, since
	// AbstainedCorrectly/FabricatedAnswer read the citation report rather
	// than the real prompt. MUST be empty on an ANSWERABLE fixture
	// (Gold.Answerable==true) unless Gold.ExpectedDetector is also set —
	// validate rejects that combination, because it would silently bypass
	// the default context-conditional oracle and break RetrievalHit/
	// ContextHit's real-prompt grounding for a fixture shape no self-test
	// framing accounts for.
	ScriptedAnswer string `json:"scripted_answer,omitempty"`
	// SemanticAliases declares synonym groups the FAKE VECTOR EMBEDDER
	// (corpus.go's hashedEmbedder/hashEmbed, via semanticAliasFold) treats
	// as interchangeable: every member of a group is folded to that group's
	// first ("canonical") member before the bigram hash runs, for BOTH the
	// query text and every chunk's text — so a question that paraphrases a
	// chunk's actual wording (e.g. asks about "마감일" when the transcript
	// says "완료 기준일") still hashes into overlapping features, the same
	// way a real embedding model would place semantically-close paraphrases
	// near each other in vector space.
	//
	// This package's fake embedder otherwise has NO notion of semantics at
	// all (hashEmbed is a literal character-bigram hash — see its doc
	// comment): SemanticAliases exists precisely to simulate a real vector
	// model's paraphrase recall for fixtures that need to exercise the
	// chunk-vector lane finding a passage the question's own words do not
	// literally contain (deep-plan #267 finding: the chunk-vector lane is
	// what actually recovers a paraphrased mid/late-transcript fact once
	// its evidence is preserved through fusion).
	//
	// Deliberately scoped to hashedEmbedder ONLY — corpus.go's lexical
	// lanes (Search's lexicalScore, chunkLexical) never see a folded text,
	// so a synonym never leaks into the fake FTS/document lane. If it did,
	// a fixture built to show "the vector lane recovers what the lexical
	// lane misses" would recover on BOTH lanes and stop being a
	// discriminating test — see docs/ask-evaluation-protocol.md's
	// "semantic_aliases" section for the full rationale and the control
	// check that verifies this scoping.
	SemanticAliases [][]string `json:"semantic_aliases,omitempty"`
	Gold            Gold       `json:"gold"`
}

Fixture is one askeval E2E test case.

func Load

func Load(dir string) ([]Fixture, error)

Load reads every *.json file in dir as one Fixture, validates it, and returns them sorted by ID (determinism: report.go's fixture-set hash and Run's sequential execution order both depend on a stable order that does not depend on the host filesystem's directory-listing order).

type Gold

type Gold struct {
	// Answerable is false for the "no-evidence"/"unanswerable" category:
	// the expected outcome is abstention (finish_reason "no_evidence" or a
	// citation_status "abstained" answer), not any claim. Ignored when
	// ExpectedCitationStatus is set (the adversarial-citation category has
	// its own pass rule — see computeMetrics).
	Answerable bool `json:"answerable"`
	// Claims are short, literal Korean substrings the answer text must
	// contain for an answerable fixture to pass (checked verbatim — issue
	// #266 scope explicitly excludes a runtime LLM judge; see llm.go's
	// scriptedCompleter for how the default oracle produces exactly these
	// strings when the evidence was actually shown to it).
	Claims []string `json:"claims,omitempty"`
	// SupportDocs names Corpus[i].Alias values: the documents that back
	// every Claims entry, used for the RetrievalHit detector (metrics.go).
	SupportDocs []string `json:"support_doc_ids,omitempty"`
	// SupportSpans are literal substrings of a SupportDocs entry's Content
	// that must appear in the EXACT text the real pipeline placed in the
	// Stage 3 synthesis prompt for the corresponding claim to be
	// checkable at all — retrieval finding the document is necessary but
	// not sufficient (deep-plan #268 finding F2; metrics.go's ContextHit).
	SupportSpans []string `json:"support_spans,omitempty"`
	// ExpectedCitationStatus, when set, switches computeMetrics into
	// adversarial-detector mode: Pass becomes "did the real, unmodified
	// askCitationStatus verdict (issue #268) equal this value", not
	// "did the answer contain every Claims string". Used by the
	// adversarial-citation fixtures (fake UUID, malformed link,
	// prior-turn-only ID), whose ScriptedAnswer intentionally cites a bad
	// ID — the CORRECT, passing outcome for those fixtures is that the
	// real validator catches it, not that the answer "succeeds".
	ExpectedCitationStatus string `json:"expected_citation_status,omitempty"`
	// ExpectInferredCitation additionally requires the done event's
	// verification.inferred_cited_ids to be non-empty — the
	// "추론을 사실로 인용" regression signal (ask_evidence.go's
	// askEvidenceLayer doc comment) the inferred-as-fact fixture exists to
	// exercise. Only meaningful alongside ExpectedCitationStatus=="valid"
	// (citing an inferred-layer document is ALLOWED, just flagged).
	ExpectInferredCitation bool `json:"expect_inferred_citation,omitempty"`
	// ExpectedDetector, when set, switches computeMetrics into a second
	// self-test mode, parallel to ExpectedCitationStatus above but
	// targeting a different pair of detectors (issue #273): the fixture's
	// own ScriptedAnswer deliberately attaches a REAL, PROVIDED citation
	// to either a false claim ("claim_mismatch": the real, unmodified
	// AnswerCorrect detector must come out false) or a correct claim cited
	// to a real, provided document outside SupportDocs
	// ("citation_outside_support": the real, unmodified
	// CitationWithinSupport detector must come out false) — closing the
	// gap where askCitationStatus "valid" only proves a cited ID was
	// SHOWN to the model, never that it is one of THIS question's own
	// support documents (deep-plan #273 finding F5). The PASSING outcome,
	// like every other self-test category in this package, is that the
	// targeted detector actually fires — see computeMetrics'
	// ExpectedDetector branch. Must be "claim_mismatch" or
	// "citation_outside_support"; validateExpectedDetector rejects any
	// other non-empty value.
	ExpectedDetector string `json:"expected_detector,omitempty"`
	// ClaimSupport is an OPTIONAL set of human-labelled expectations the
	// shadow ClaimJudge's verdicts are compared against (issue #273 step
	// 3, judge.go) — purely for measuring judge/human agreement, NEVER a
	// Pass gate (JudgeShadow's own doc comment). A fixture with zero
	// ClaimSupport entries is simply never judged at all: judge.go's
	// RunShadowJudge skips it entirely ("not evaluated"), rather than
	// judging it and reporting a meaningless zero-annotation agreement
	// rate.
	ClaimSupport []ClaimSupportAnnotation `json:"claim_support,omitempty"`
}

Gold is a fixture's ground truth: what the real /ask pipeline SHOULD produce for Question, given History and the fixture's own Corpus.

type JudgeShadow added in v0.24.0

type JudgeShadow struct {
	Units         int `json:"units"`
	Supported     int `json:"supported"`
	Unsupported   int `json:"unsupported"`
	Errors        int `json:"errors"`
	HumanAgree    int `json:"human_agree"`
	HumanDisagree int `json:"human_disagree"`
}

JudgeShadow is one case's shadow-judge tally — see CaseMetrics.Shadow's doc comment for when this field is nil vs. populated. NEVER read by computeMetrics: this type exists entirely downstream of Pass (built by RunShadowJudge, after Run has already produced every CaseResult's final Metrics), so there is no code path by which a judge's verdict could reach Pass even by accident.

type JudgeUnit added in v0.24.0

type JudgeUnit struct {
	DocAlias string
	Claim    string
	Excerpt  string
}

JudgeUnit is one (claim, cited-document excerpt) pair a ClaimJudge is asked to verdict — see judgeUnitsFor for how an answer is split into these.

type Provenance

type Provenance struct {
	GitRev         string `json:"git_rev,omitempty"`
	FixtureSetHash string `json:"fixture_set_hash"`
	Cases          int    `json:"cases"`
	// Mode is "scripted" (this runner's only implemented mode, issue #266
	// scope) or "configured" (a real LLM backend — reserved for future
	// work, never on by default).
	Mode string `json:"mode"`
	// JudgeMode is "off" (default; claim_support stays
	// askClaimSupportNotEvaluated end to end) or "shadow" (a semantic judge
	// runs but is NEVER a pass gate — issue #266 scope: "judge 실패/불일치를
	// 정상 통과로 처리하지 않는다" means judge disagreement can only ever
	// subtract from a result, never add).
	JudgeMode string `json:"judge_mode"`
	// JudgeBackend is "fake" (deterministic, offline — the only backend
	// go test/CI ever construct, judge_fake.go) or "remote" (a real API
	// call, judge_remote.go, gated by its own constructor's guards).
	// Empty when JudgeMode=="off".
	JudgeBackend string `json:"judge_backend,omitempty"`
	// JudgeModel/JudgePromptHash are only meaningful for JudgeBackend
	// "remote" — the fake backend has no model or prompt of its own to
	// record.
	JudgeModel      string `json:"judge_model,omitempty"`
	JudgePromptHash string `json:"judge_prompt_hash,omitempty"`
}

Provenance records what one Run measured — never a live claim about production quality (issue #266 completion criteria: "수치 근거 없이 개선을 단정하지 않는다"). Two reports with different FixtureSetHash values are not comparable; DiffReports refuses to diff them.

type RemoteJudgeConfig added in v0.24.0

type RemoteJudgeConfig struct {
	llm.Config
	// FixturesDir is the --fixtures path this run actually used. The
	// judge refuses to start unless it resolves under this repo's
	// eval/ask/fixtures tree (issue #273: "개인 데이터를 외부 judge에
	// 보내지 않는다. 합성 fixture만 쓴다") — a remote judge run must be
	// structurally incapable of seeing anything but synthetic fixture
	// content, not merely trusted not to.
	FixturesDir string
}

RemoteJudgeConfig configures NewRemoteClaimJudge. Every field is read from the environment by cmd/askeval, never defaulted inside this package: a judge that could turn itself on from ambient environment state alone would violate issue #273's "기본값은 끈다" (default off) requirement the moment something exported the wrong variable.

type Report

type Report struct {
	Provenance Provenance        `json:"provenance"`
	Cases      []CaseSummary     `json:"cases"`
	Categories []CategorySummary `json:"categories"`
	// FailingCaseIDs lists every case with Pass==false (including every
	// harness-error case) — a report reader should never need to scan
	// Cases by hand to find them.
	FailingCaseIDs []string `json:"failing_case_ids"`
	// Abstention is issue #273's precision/recall summary — see
	// AbstentionStats' doc comment for which fixtures it excludes and why.
	Abstention AbstentionStats `json:"abstention"`
	// Shadow aggregates every case's CaseMetrics.Shadow — see
	// ShadowSummary's own doc comment. NEVER a pass gate.
	Shadow ShadowSummary `json:"shadow"`
}

Report is one Run's full output.

func BuildReport

func BuildReport(results []CaseResult, prov Provenance) Report

BuildReport aggregates a Run's []CaseResult into a Report. If results carry a non-nil Metrics.Shadow (set by a prior RunShadowJudge call — judge.go), it is folded into the report-level Shadow summary; callers that never run a judge simply produce an all-zero Shadow, which is exactly what Provenance.JudgeMode=="off" implies.

func (Report) JSON

func (r Report) JSON() ([]byte, error)

JSON renders r as indented JSON — the shape cmd/askeval writes to --out and reads back via --baseline.

func (Report) Text

func (r Report) Text() string

Text renders a short human-readable summary — what cmd/askeval prints to stdout on every run regardless of --out.

type RunOptions

type RunOptions struct {
	// AskTopK/AskInsightM feed api.Server.WithAskConfig. Defaulted (see
	// DefaultRunOptions) to comfortably exceed every fixture's corpus size
	// so a fixture author does not have to reason about the production
	// default (8) truncating an intentionally larger synthetic corpus.
	AskTopK, AskInsightM int
	RerankDefault        bool
}

RunOptions configures Run. Zero value is DefaultRunOptions' shape.

func DefaultRunOptions

func DefaultRunOptions() RunOptions

DefaultRunOptions returns the RunOptions every eval/ask/fixtures case in this repository is authored against.

type ShadowSummary added in v0.24.0

type ShadowSummary struct {
	// Cases is the number of CaseResults that had a non-nil Shadow — i.e.
	// were actually judged, out of the report's total case count.
	Cases         int `json:"cases"`
	Units         int `json:"units"`
	Supported     int `json:"supported"`
	Unsupported   int `json:"unsupported"`
	Errors        int `json:"errors"`
	HumanAgree    int `json:"human_agree"`
	HumanDisagree int `json:"human_disagree"`
}

ShadowSummary aggregates every case's CaseMetrics.Shadow into one report-level tally — see JudgeShadow's own doc comment for why this can never gate Pass. All-zero (never omitted from JSON) when Provenance.JudgeMode=="off" or no fixture had a Gold.ClaimSupport annotation to judge against.

type Turn

type Turn struct {
	Question string `json:"question"`
	Answer   string `json:"answer"`
}

Turn is one prior question/answer exchange replayed as a fixture's conversation history — the shape ask_history.go's askHistoryTurn takes, minus that type's package-private-ness (this package cannot import an unexported api.askHistoryTurn).

type Verdict added in v0.24.0

type Verdict string

Verdict is one ClaimJudge verdict over a single (claim, excerpt) pair.

const (
	// VerdictSupported: the excerpt explicitly supports the claim.
	VerdictSupported Verdict = "supported"
	// VerdictUnsupported: the excerpt does not support the claim (the
	// claim is false, or unrelated to the excerpt's content).
	VerdictUnsupported Verdict = "unsupported"
	// VerdictError: the judge could not reach a verdict at all (a network
	// failure, an unparseable response, or — for fakeJudge — no
	// Gold.ClaimSupport annotation matching this unit). RunShadowJudge
	// counts this as a shadow failure, exactly like VerdictUnsupported —
	// never as VerdictSupported (issue #273: "judge 실패/불일치를 정상
	// 통과로 처리하지 않는다").
	VerdictError Verdict = "error"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL