Documentation
¶
Overview ¶
Package grounding is the harness's free, deterministic quality check: did the model invent values not present in the source? No inference, sub-millisecond string ops. It is the keystone label generator for the self-learning loop (conformal calibration, health monitoring, router training all train on it).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check reports whether structured output is grounded in the source input. ok=false means grounding does not apply (classify/triage are grammar-pinned to a label set, nothing to verify; or the output has no checkable values).
- extract: every leaf string/number value must appear in the source (extraction is verbatim — a value not in the source is a hallucination). A string may match as a phrase; a JSON number is compared by VALUE against the numbers the source writes, in either locale (see numberValues).
- summarize: every NUMBER in the summary must appear in the source, by value (the clearest invented-fact signal; entity paraphrasing is intentionally not flagged to avoid false positives).
The pipeline ACTS on a false result only for extract (retry/escalate); for summarize it is logged as a quality signal but not actioned.
func CheckFields ¶
CheckFields is the per-field variant of Check for extract: it returns the list of TOP-LEVEL field names whose value is not grounded in the source. ok=false means grounding does not apply (non-extract task). Nested values are attributed to their top-level key. Used to name offenders in a targeted corrective re-prompt (lightweight atomic-claim verification).
Types ¶
type ProofResult ¶ added in v0.206.0
type ProofResult struct {
Name string `json:"name"`
Checked int `json:"checked"`
Failures []string `json:"failures,omitempty"`
// Applicable is false when the validator found nothing of its kind to inspect. A caller
// must branch on this before treating Failures as meaningful.
Applicable bool `json:"applicable"`
}
ProofResult is one validator's finding. Checked is the population it actually examined, so "0 failures" over 0 candidates can never be read as a clean bill of health — the silent -failure shape this estate keeps hitting.
func ProveCitedSpans ¶ added in v0.206.0
func ProveCitedSpans(input string, data []byte) ProofResult
ProveCitedSpans checks that every quoted span in the output appears CONTIGUOUSLY in the source.
This is the gap Check() cannot close: it tests values one at a time, so a quote assembled from words that each appear somewhere in the source passes it while being invented as a quote. Comparison is whitespace-normalised and case-insensitive, because a model reflowing or re-casing a genuine quote is a formatting difference, not a fabrication — flagging that would bury the real signal in noise.
func ProvePathsExist ¶ added in v0.206.0
func ProvePathsExist(data []byte, statFn func(string) error) ProofResult
ProvePathsExist checks every path-shaped leaf value against the filesystem.
statFn is injected so the validator is testable without touching real files; nil uses os.Stat. This is the seam, and the real implementation is unit-tested directly rather than only through it — a seam that stands in for untested logic is how a gate ends up certifying nothing.
func (ProofResult) OK ¶ added in v0.206.0
func (p ProofResult) OK() bool
OK reports a pass. An inapplicable validator is NOT a pass — it is a non-answer, and collapsing the two is how "we ran the checks" comes to mean nothing.