param

package
v0.6.9 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 17 Imported by: 1 module, 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 param loads and validates parameter-IR PartSpecs (agni.v1.param), the datasheet-parameter contract in docsite/content/architecture/datasheet-layer.md#the-parameter-contract. The schema is protos/agni/v1/param/param.proto. This package holds the invariants proto cannot express (required provenance, resolvable doc refs, non-empty ranges) and the under-specification predicate consumers must respect.

Index

Constants

View Source
const (
	// CorpusProject is the design's own project params/, which the project owns.
	CorpusProject = "project"
	// CorpusShared is any corpus the design's project does not own, such as a --params directory or a
	// --params-url service.
	CorpusShared = "shared"
)

A citation names its corpus with one of these, so a verdict says whose transcription it relies on.

View Source
const AudienceKey = "audience"

AudienceKey is the PartSpec attribute that records WHO is entitled to see a part's datasheet data, as a comma-separated list of team or license identifiers. Datasheet data is vendor-licensed (C16), so a shared spec library may hold parts not every team may see.

It is RECORD-ONLY, and nothing enforces it yet. WS10-011 will enforce it, with a ParamProvider returning nil for an un-entitled MPN. It is a free-form attribute rather than a proto field because it is a per-deployment annotation, not part of the extracted datasheet contract.

View Source
const UnitOhm = "Ω" // Ω

UnitOhm is the canonical ohm symbol, GREEK CAPITAL LETTER OMEGA (U+03A9), and a converted parameter uses it. ir.Quantity documents the same symbol as canonical, so a rule comparing a design-side resistance against a datasheet-side one compares two identical strings. Declared here rather than imported from core/classify because the datasheet tier imports nothing from core (C17).

Variables

View Source
var (
	// ErrNoPinData means the spec declares no pins at all, as an older corpus does. Unlike
	// ErrPinUnknown, the caller should fall back to the part-level path rather than treat
	// this as a failed lookup (CONSTRAINTS C9, degrade-safe).
	ErrNoPinData = errors.New("param: spec declares no pins")

	// ErrPinUnknown means the spec has pins but neither channel matched this terminal.
	ErrPinUnknown = errors.New("param: no pin matches")

	// ErrPinAmbiguous means the evidence narrows to several pins and nothing separates them.
	// Either a name is printed on more than one terminal with no identified package to break
	// the tie, or a number means different pins in different packages. Callers skip and never
	// pick one.
	ErrPinAmbiguous = errors.New("param: pin reference is ambiguous")

	// ErrPinConflict means the two channels resolved to DIFFERENT pins, the repackaging
	// mismatch or a wrong symbol. Either channel alone would have given a confident wrong
	// answer.
	ErrPinConflict = errors.New("param: pin name and number disagree")
)

Functions

func Audience

func Audience(spec *parampb.PartSpec) []string

Audience returns the team/license identifiers entitled to a part's datasheet data, parsed from the AudienceKey attribute (comma-separated, trimmed). It is nil when unset. Nil means "not annotated" and NOT "no one", and until WS10-011 enforces anything, an unset audience is visible to all.

func BaseUnit

func BaseUnit(unit string) (base string, exp int, ok bool)

BaseUnit reports the SI base unit a printed unit symbol reduces to, and the decimal exponent from the printed unit to that base ("mV" -> "V", -3; "kΩ" -> "Ω", 3; "V" -> "V", 0).

ok is false for a unit that this layer does not recognize, INCLUDING the empty one. check.ComponentValueIn takes the same position on a bare component value. A caller must treat false as "not comparable" and skip, never as "assume base".

func CheckPinMux added in v0.3.12

func CheckPinMux(mux *parampb.PartSpec) error

CheckPinMux refuses a reference that cannot be merged. It refuses one naming no MPN or no pins, and one in which a pin lists no alternates. It also refuses one carrying parameters or relations. Limits belong in the published spec, and a merge that took them would let a mux file override them.

func DocContentHash

func DocContentHash(spec *parampb.PartSpec, docRef string) string

DocContentHash resolves a doc_ref to the content hash of the revision the spec describes. It returns "" when the id names no doc or the corpus recorded no hash, and every caller must read "" as unknown.

func Fetches

func Fetches(p ParamProvider) bool

Fetches reports whether reading p goes beyond the process. It is true when p, or any layer of a Layered, fetches over the network, meaning it is a Prefetcher other than Layered itself. A local set, a nil provider, and a Layered of only those do not fetch. Layered implements Prefetch to forward to its layers, so asking whether a provider is a Prefetcher says nothing about whether it fetches. A cache deciding whether an answer can outlive the request asks Fetches instead (agni issue 915).

func InBaseUnit

func InBaseUnit(p *parampb.Parameter) (*parampb.Parameter, bool)

InBaseUnit returns p expressed in the SI base unit of whatever unit it was printed in, so a caller may compare its bounds against a number of any other provenance. ok is false when p is nil or its unit is not one BaseUnit recognizes, and a caller must then skip the row rather than compare it.

The RETURNED ROW IS ALWAYS IN THE BASE UNIT, so an extractor that filters on the returned Unit cannot admit a prefixed row.

p is returned UNCHANGED, same pointer, when it is already in the canonical base spelling. That is the common case, so the ordinary path allocates nothing and a resolver storing the returned row keeps pointer identity with the spec. Otherwise the result is a deep copy with Unit and every present bound rewritten. p itself is never mutated, because the spec is shared across every rule in a run and a citation and the params panel must keep showing the printed row.

Conditions are NOT converted. A condition's unit qualifies the row rather than carrying its value, and nothing compares against one.

func LimitKindToken

func LimitKindToken(k parampb.LimitKind) string

LimitKindToken renders a parameter's LimitKind. UNSPECIFIED fails param.Validate, so "unspecified" here means a spec that never reached a corpus.

func Load

func Load(r io.Reader) (*parampb.PartSpec, error)

Load parses one PartSpec in textproto form, the fixture and hand-encoding format. It only parses, so call Validate for the semantic invariants.

func MachineComparable

func MachineComparable(p *parampb.Parameter) bool

MachineComparable reports whether a consumer may compare this parameter's value against an operating point automatically. The condition list must be asserted complete (not UnderSpecified) AND every condition structured (eq or min/max). A condition captured only as raw text makes the row the middle trust state, shown to a human next to its provenance and never auto-compared. The three states (docsite/content/architecture/datasheet-layer.md#comparison-semantics):

UnderSpecified            -> skip; the conditions themselves are not trustworthy
!UnderSpecified && !MachineComparable -> surface to a human; no auto-compare
MachineComparable         -> safe to compare, under its stated conditions

func MarkVerified

func MarkVerified(p *parampb.Parameter, by string, doc *parampb.SourceDoc, at, note string) bool

MarkVerified records that a person checked a value against a specific revision of a document.

It takes the DOCUMENT rather than a bare hash so the invalidation key and the printed revision are read from one place and cannot disagree. Passed separately, a caller could pin one revision's hash beside another's name, and the record would go stale correctly and then name the wrong revision.

It also raises provenance confidence to 1.0, since across this layer only a human verification gets 1.0 and consumers already read it that way. Nothing lowers it again, so anything deciding whether to TRUST a value reads VerificationOfIn and not the float (see DECISIONS.md, "A stale verification is untrustworthy data").

Verifying against no document, or against one whose revision the corpus never recorded, is refused and returns false, since nothing could ever invalidate that record.

func MarkVerifiedIn

func MarkVerifiedIn(spec *parampb.PartSpec, p *parampb.Parameter, by, at, note string) bool

MarkVerifiedIn is MarkVerified with the document resolved from the spec, by following the parameter's own provenance doc_ref. This is the form a portal wants, since a person confirms a value against the document it cites and neither the hash nor the revision is the caller's to supply.

It refuses a doc_ref that names no document in the spec. Nobody can have checked a value against a document that the corpus does not have.

func MarshalSpecText

func MarshalSpecText(spec *parampb.PartSpec) ([]byte, error)

MarshalSpecText renders a PartSpec as multi-line textproto, the corpus's file format. Every build gives the same output.

prototext deliberately puts one or two spaces after a field name, chosen by a hash of the running binary, so its output cannot be relied on byte for byte. A corpus lives in git, so two builds re-promoting one spec would otherwise produce a diff that is nothing but whitespace. So MarshalSpecText collapses that one run of spaces after each line's field name. Values are untouched, since a string value cannot span lines in textproto.

func MergePinMux added in v0.3.12

func MergePinMux(base, mux *parampb.PartSpec, opts PinMuxMerge) (*parampb.PartSpec, error)

MergePinMux returns base with mux's pins merged in, leaving both arguments unchanged. A nil base means the MPN has no published spec yet, and the result is the reference itself.

Each reference pin finds its base pin the way derive joins a mux row to a pin table. It matches by id first, then by a shared designator in a package. A reference pin with no designators matches by its name, compared through ident.PinName. A matched pin gains the reference's alternates, joined with its own or in their place as opts says, and any designator it lacked. Its name, function, prov and id do not change, since parameters point at the id. A reference pin matching nothing is added after the base's pins. Docs and packages join by id.

It refuses any reference that CheckPinMux refuses. It also refuses an MPN that differs from base's, a doc or package reusing a base id for different content, a reference pin matching several base pins (a repeated name such as NC), and two reference pins matching one base pin. The result is not validated here, because publishing does that.

func ModalityToken

func ModalityToken(m parampb.Modality) string

ModalityToken renders a pin relation's Modality. UNSPECIFIED gets its own token rather than being omitted, because a bound whose modal verb was never recorded differs from one that has none, and a query filtering on modality must be able to find it.

func PackageForMPN

func PackageForMPN(spec *parampb.PartSpec, mpn string) *parampb.Package

PackageForMPN narrows an orderable MPN to one declared package by its suffix, so a caller can supply ResolvePin's packageRef instead of leaving the number channel package-blind. It returns nil when no declared suffix matches, which includes the ordinary case of a design carrying only the base MPN. NIL MEANS "PACKAGE NOT IDENTIFIED", NEVER "NO PACKAGE", and the number channel then requires cross-package agreement rather than assuming a body.

The match is a case-insensitive suffix test that tolerates one trailing packaging letter (the reel/tape "R", "T"), because "TXB0104PWR" is the tape-and-reel spelling of the same TSSOP part. The longest matching suffix wins. A package declaring no mpn_suffix never matches, since an undeclared suffix is not evidence.

func PinByID

func PinByID(spec *parampb.PartSpec, id string) *parampb.Pin

PinByID returns the pin with a spec-local id, or nil. Parameter.pin_refs names these ids and Validate guarantees every ref resolves, so a nil on a validated spec means the caller invented the id.

func PinFunctionToken

func PinFunctionToken(f parampb.PinFunction) string

PinFunctionToken renders a pin's PinFunction. Unlike a limit kind, "unspecified" is a LEGAL and common answer, since a document may print a pin table with no type column and a pin whose name and number are known is still worth recording.

func PinParameters

func PinParameters(spec *parampb.PartSpec, pinID string) []*parampb.Parameter

PinParameters returns the parameters BOUND to a pin, in declaration order.

Part-wide rows (an empty pin_refs) are EXCLUDED. An empty binding means "a fact about the die", and reading it as "a fact about every terminal" would credit a junction-temperature rating as a pin's own limit. A caller that wants the part-level fallback asks for it explicitly.

func PinRelations

func PinRelations(spec *parampb.PartSpec, pinID string) []*parampb.PinRelation

PinRelations returns every relation this pin takes part in, on EITHER end, since a relation between two terminals constrains both.

The caller must read subject_pin_ref to tell the ends apart. The bound is on subject MINUS reference, so treating this pin as always the subject inverts the sign on half of them.

func PinsByName

func PinsByName(spec *parampb.PartSpec, name string) []*parampb.Pin

PinsByName returns every pin printed under a name, in declaration order. SEVERAL HITS IS THE NORMAL CASE for a part that prints one name across terminals (a large IC's VDD pins, the TXB0104's two NC pins). Pin binding exists to prevent collapsing it to the first match. An empty name matches nothing.

Names compare on ident.PinName, so "V CCA" from a document producer and "VCC_A" from a symbol library both reach "VCCA", and a name pasted out of a PDF with a zero-width space or a zero-padded index still matches (agni issue 702). The match is no fuzzier than that, since a near-miss name is a different pin.

func PinsByNumber

func PinsByNumber(spec *parampb.PartSpec, packageRef, number string) []*parampb.Pin

PinsByNumber returns every pin carrying a designator in a package. With a packageRef it searches that package only and yields at most one pin, since Validate holds a number to one pin per package. With an EMPTY packageRef it searches all of them and yields the distinct pins the number reaches, so a caller can tell "every package agrees" (one hit) from "the packages disagree" (several).

func ResolvePin

func ResolvePin(spec *parampb.PartSpec, name, designator, packageRef string) (*parampb.Pin, error)

ResolvePin maps one design terminal onto a pin of this spec. It takes the terminal's name and package-relative designator, both read off the ir.Pin reached through the component's PartType. It also takes the package the design places, when that is identified, and PackageForMPN derives it from an orderable MPN.

Any argument may be empty, and each empty one removes a channel. The table gives the precedence.

name matches one pin                  -> that pin (the number is not consulted)
name matches several                  -> the number breaks the tie, inside a known package
name matches none, number matches one -> that pin (a symbol whose pin names differ from
                                         the datasheet's is ordinary)
the two channels disagree             -> ErrPinConflict
nothing separates the candidates      -> ErrPinAmbiguous

An empty packageRef does not disable the number channel. The number is looked up in every declared package and resolves when they all agree (VCCA is number 1 in both the TSSOP and the UQFN), refusing only where the packages disagree.

A refusal always returns a nil pin. This is skip-not-false-pass. A rule that resolves the wrong terminal evaluates cleanly and reports about the wrong thing.

A multi-SECTION component (a relay's coil and contacts) spreads its pins across several PartTypes, so the caller finds the ir.Pin for a designator by searching every section's PartType. Pin numbering is per physical package, so sections never enter the key.

func SourceDocOf

func SourceDocOf(spec *parampb.PartSpec, docRef string) *parampb.SourceDoc

SourceDocOf resolves a doc_ref to the document it names within a spec; nil when the id names none.

func StaleVerifications

func StaleVerifications(spec *parampb.PartSpec) []*parampb.Parameter

StaleVerifications lists the parameters of a spec that were verified against a different revision than the one the spec now describes. A portal can then offer "re-confirm these" after a document updates rather than waiting for someone to notice.

Each parameter is compared against the document IT cites, not against one hash for the whole spec. A spec routinely carries a datasheet and an app note, and one hash would report every value citing the OTHER document as stale the moment either one moves.

A spec with nothing verified returns nothing, the ordinary state of a freshly seeded corpus.

func UnderSpecified

func UnderSpecified(p *parampb.Parameter) bool

UnderSpecified reports whether a parameter's value must not be treated as a plain comparable limit, because its condition list is not asserted complete (coverage is unknown or known-partial). A no-condition parameter is fine only when the source states none (CONDITION_COVERAGE_UNCONDITIONAL). Consumers skip or flag under-specified parameters and never compare against them (docsite/content/architecture/datasheet-layer.md#comparison-semantics).

func Validate

func Validate(spec *parampb.PartSpec) error

Validate checks a PartSpec against the invariants that must hold before a consumer may trust it. The WS10-003 join and a store are two such consumers. The error joins every Problem into one. Nil means the spec is trustworthy as data. It does not mean the values are true, and the provenance answers that.

When a spec carries pin data it must also be COHERENT (see structuralProblems). A dangling pin binding is worth catching at load because downstream it does not look like an error. The parameter stops applying to anything and the rule that wanted it reports nothing. Pin data is OPTIONAL, so a spec with no pins or packages is unaffected (CONSTRAINTS C9).

Types

type CorpusNamer

type CorpusNamer interface {
	CorpusOf(spec *parampb.PartSpec) string
}

CorpusNamer is a provider that can say which of its corpora a spec it returned came from.

type FactSource

type FactSource interface {
	// AllSpecs returns every seeded PartSpec, ordered by MPN for deterministic query output.
	AllSpecs() []*parampb.PartSpec
}

FactSource is the read-all sibling of ParamProvider.Lookup. It yields the WHOLE seeded spec library, so datalog can query `param.max(?mpn, ...)` across every seeded part rather than only the parts joined to one design. It is separate from ParamProvider because a keyed remote Lookup is cheap and an enumerate-all may not be, so a backend opts into library-wide datalog by implementing this.

type Fetcher

type Fetcher interface {
	// BatchGet returns the current spec for each MPN that has one. It also returns the corpus
	// generation it read the answer at. An MPN with no spec is absent, not an error.
	BatchGet(ctx context.Context, mpns []string) ([]*parampb.PartSpec, uint64, error)
	// Generation returns the corpus generation alone.
	Generation(ctx context.Context) (uint64, error)
}

Fetcher is a published PartSpec corpus reached over some transport, in the shape of the contract's PartSpecService (agni issue 749). It is declared here and is transport-neutral. So the engine owns the caching below, and a Connect or in-process implementation is only an adapter.

type Layer

type Layer struct {
	Name     string
	Provider ParamProvider
}

Layer is one corpus in a Layered provider, with the name a citation reports it by.

type Layered

type Layered []Layer

Layered is a provider that asks each layer in order and answers with the first that seeds the MPN (agni issue 749). A project's own params/ is layered over a shared corpus this way. The project decides every part it seeds and the shared corpus answers for the rest. Without the layering, a project that seeds two parts would lose the datasheet tier for every other part.

A layer with a nil provider is skipped. Layered prefetches through every layer that needs it, so a remote shared corpus under a local project corpus still fails loudly when it cannot be reached.

func (Layered) CorpusOf

func (l Layered) CorpusOf(spec *parampb.PartSpec) string

CorpusOf names the layer a spec came from. That is the first layer whose own Lookup of the spec's MPN returns that same spec. It compares by identity rather than by MPN, because a lower layer can seed the same MPN, and a citation relies only on the spec actually returned. It returns "" when no layer returned the spec.

func (Layered) Lookup

func (l Layered) Lookup(mpn string) *parampb.PartSpec

Lookup returns the first layer's spec for the MPN, or nil when no layer seeds it.

func (Layered) Prefetch

func (l Layered) Prefetch(ctx context.Context, mpns []string) error

Prefetch implements Prefetcher by prefetching every layer that is one.

type ParamProvider

type ParamProvider interface {
	// Lookup returns the spec seeded for an MPN, or nil when the part is unseeded or unknown.
	// A nil return keeps datasheet-backed rules silent by construction (skip, never false-pass).
	Lookup(mpn string) *parampb.PartSpec
}

ParamProvider is the one call the model makes to reach a part's seeded datasheet spec, given its MPN. A part's ratings are the same for every design that uses the MPN, so the source is pluggable rather than tied to one on-disk corpus. Backends are ParamSet (a textproto corpus loaded from a directory) and ProviderFunc (an in-memory mock), and a shared datasheet service would slot in behind this one method with no rule or model change.

type ParamSet

type ParamSet map[string]*parampb.PartSpec

ParamSet is a seeded parameter corpus of PartSpecs indexed by upper-cased MPN. It is the directory-backed ParamProvider, and the spec-side half of the WS10-003 validation join (design component -> PartSpec). A nil or empty ParamSet is valid and means nothing is seeded, so every Lookup misses.

func LoadSet

func LoadSet(fsys fs.FS) (ParamSet, error)

LoadSet walks fsys for *.textproto PartSpecs, validates each, and indexes them by MPN. It is all-or-nothing. Any file that fails to parse or Validate, and any two files claiming the same MPN, fail the whole load with the offending file named, so a bad spec never silently shrinks the corpus.

func (ParamSet) AllSpecs

func (s ParamSet) AllSpecs() []*parampb.PartSpec

AllSpecs returns the corpus's PartSpecs sorted by upper-cased MPN key (the map's index), so a library-wide query prints in a stable order.

func (ParamSet) Lookup

func (s ParamSet) Lookup(mpn string) *parampb.PartSpec

Lookup returns the spec seeded for an MPN, or nil. Matching is case-insensitive because vendor and BOM casing of the same MPN routinely differ. There is no other normalization (no suffix stripping, no package-code fuzzing), because a near-miss MPN is a different part until a human says otherwise.

type PinMuxMerge added in v0.3.12

type PinMuxMerge struct {
	// Replace drops a matched pin's alternates and takes the reference's in their place, for a
	// revised table that should remove what the revision removed. Without it the two lists are
	// joined. The published names come first, then the reference's new ones in its order, and an
	// exact repeat of a name is dropped. So two partial tables for one part both take effect, and
	// merging a table twice changes nothing.
	Replace bool
}

PinMuxMerge says what a merge does with the alternates a matched pin already lists.

type Prefetcher

type Prefetcher interface {
	ParamProvider
	Prefetch(ctx context.Context, mpns []string) error
}

Prefetcher is a ParamProvider that has to fetch before it can answer. Imagine a provider that reaches its corpus over a network, and the service is unreachable. Lookup returns no error, so the provider could only return nil. A nil reads as "this part is not seeded", and every datasheet rule skips the part silently. LoadSet's all-or-nothing rule exists to prevent that shrink. So whoever builds a model calls Prefetch with every MPN the design names, where a context and an error exist. Lookup then answers from what was fetched.

type Problem

type Problem struct {
	Kind    ProblemKind
	Message string
}

Problem is one validation finding, unjoined so a caller can render each one and act on the kinds differently.

func Problems

func Problems(spec *parampb.PartSpec) []Problem

Problems reports everything wrong with a spec, classified. The workbench consumes it, showing structural problems as things to fix now and completeness ones as what stands between a draft and a corpus. Validate joins the same list into one error. An empty result means the spec would load into a corpus today.

type ProblemKind

type ProblemKind string

ProblemKind separates the two questions Problems answers, since a consumer usually wants only one. STRUCTURAL means the spec contradicts itself and is wrong at any stage of authoring. COMPLETENESS means it is unfinished, which is true of every spec under transcription.

const (
	ProblemStructural   ProblemKind = "structural"
	ProblemCompleteness ProblemKind = "completeness"
)

type ProviderFunc

type ProviderFunc func(mpn string) *parampb.PartSpec

ProviderFunc adapts a plain lookup function to ParamProvider (the http.HandlerFunc pattern), for in-memory mocks and tests: param.ProviderFunc(func(mpn string) *param.PartSpec { ... }).

func (ProviderFunc) Lookup

func (f ProviderFunc) Lookup(mpn string) *parampb.PartSpec

Lookup calls the wrapped function.

type Remote

type Remote struct {
	// contains filtered or unexported fields
}

Remote is a caching Prefetcher over a Fetcher. It keeps every spec it has fetched. It also keeps every MPN that it learned has no spec. Both are kept until the corpus generation changes. It checks the generation at most once per maxAge, and a generation that moved empties the cache. So a spec published while a server runs reaches the next request without a restart.

func NewRemote

func NewRemote(f Fetcher, maxAge time.Duration) *Remote

NewRemote returns a Remote over f that re-checks the corpus generation at most once per maxAge.

func (*Remote) Lookup

func (r *Remote) Lookup(mpn string) *parampb.PartSpec

Lookup answers from what Prefetch fetched. An MPN that was never prefetched answers nil, like an unseeded one, so a caller that skips Prefetch gets no datasheet tier rather than a wrong one.

func (*Remote) Prefetch

func (r *Remote) Prefetch(ctx context.Context, mpns []string) error

Prefetch makes every named MPN answerable by Lookup, fetching what is not cached at the current generation in one batch. Any failure to reach the corpus is returned, never swallowed.

type SeededFile

type SeededFile struct {
	Spec *parampb.PartSpec
	File string
	Data []byte
}

SeededFile is one corpus file as LoadCorpus read it. It holds the spec, its path within the corpus, and the bytes it was parsed from. A caller that keeps an index of the corpus can then hash exactly what was validated rather than reading the file a second time.

func LoadCorpus

func LoadCorpus(fsys fs.FS) ([]SeededFile, error)

LoadCorpus makes the same walk as LoadSet and keeps each file. It applies the same all-or-nothing rules. Only *.textproto is read, and a workbench draft is never one, so a draft never seeds anything. Every file must parse and Validate, and two files claiming one MPN fail the load. Files come back in walk order, which is lexical by path. The datasheet service builds its corpus index from LoadCorpus, so the index and every eager load agree on what the corpus holds.

type VerificationState

type VerificationState string

VerificationState is what is known about a value's human confirmation.

const (
	// Unverified means no one has confirmed this value. It is the ordinary state of anything an
	// extractor produced.
	Unverified VerificationState = "unverified"
	// Verified means a person confirmed it against the revision in hand.
	Verified VerificationState = "verified"
	// Stale means a person confirmed it against a DIFFERENT revision of the document. The vendor may
	// have changed the table it was read from, so it needs re-confirming.
	Stale VerificationState = "stale"
	// Unknown means a verification exists but no current revision was supplied, so drift cannot be
	// ruled out. It is NOT folded into Verified. A caller that cannot check must not be told the
	// answer is fine, as with a check that could not run.
	Unknown VerificationState = "unknown"
)

func VerificationOf

func VerificationOf(p *parampb.Parameter, currentDocHash string) VerificationState

VerificationOf reports what is known about a parameter's confirmation, given the content hash of the document revision currently in hand.

Pass the empty string when no document is available and the answer becomes Unknown rather than Verified. Staleness is derived from evidence, never remembered.

func VerificationOfIn

func VerificationOfIn(spec *parampb.PartSpec, p *parampb.Parameter) VerificationState

VerificationOfIn is VerificationOf with the current revision resolved from the spec the parameter belongs to, by following its provenance doc_ref to that SourceDoc's content_hash.

This is the form nearly every caller wants. A caller sourcing the hash itself would need to know where a corpus keeps documents, which puts filesystem knowledge on the check path and gives every call site a chance to pass the wrong document's hash.

An unresolvable doc_ref, or a SourceDoc with no recorded hash, yields Unknown for a verified value rather than Verified.

Jump to

Keyboard shortcuts

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