grounding

package
v0.209.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 8 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 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

func Check(task core.TaskType, input string, data []byte) (grounded bool, ok bool)

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

func CheckFields(task core.TaskType, input string, data []byte) (ungrounded []string, ok bool)

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.

Jump to

Keyboard shortcuts

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