Documentation
¶
Overview ¶
Package assert is the fixed registry of named deterministic checks a `gate` node may name (yaah-0u0v.21).
An allowlist, not a namespace ¶
A document names one of the checks below by name. A name this package does not hold makes the gate unrunnable — it does not fall back to an expression evaluator, a shell command, or a model. That is the deliberate half of the gate design ("named asserts only"): a deterministic scheduler can only promise a deterministic answer for code it ships, and a free-form expression language is a second language to specify, sandbox, and validate. The validator (validate's WF037) and the scheduler both read this ONE list, so a document that validates is a document the scheduler can evaluate, and there is no second copy of the vocabulary to drift.
The signature ¶
func(Input) (bool, string)
Input carries the check's subject and its declared arguments; the answer is the verdict plus one short sentence saying why. Every check is pure: no clock, no I/O, no randomness, and no map iteration whose order could reach the answer. The scheduler evaluates a check inside a reducer cycle and records both values it returned; nothing re-runs it.
The subject ¶
A check that reads a value (Spec.ReadsValue) is handed it in Input.Value. The subject is the recorded value of the step named by the reserved argument "from" — and, when the author names none, the recorded values of the gate's own needs, in declaration order. Input.Value is nil when the subject step produced nothing, so a check can tell "no value at all" from "an empty value" and both answers stay honest: an assert that cannot be proven is not a pass.
Arguments ¶
Spec.Args declares the argument keys a check reads and the kind each must have; every declared argument is required, every undeclared one is refused. Problem answers "would this assert run at all" from the declarations alone, which is what makes the same sentence usable as a validation finding and as a run-time refusal.
Index ¶
Constants ¶
const SubjectKey = "from"
SubjectKey is the reserved argument that names the step whose recorded value is the check's subject. It is not passed to the check: it selects its input.
Variables ¶
This section is empty.
Functions ¶
func Names ¶
func Names() []string
Names returns every registered assert name, sorted. The slice is a copy: the allowlist is a package invariant, not a caller's to edit.
func Problem ¶
Problem reports why one assert declaration cannot run, or "" when it can. It answers from the declaration alone — the name, the argument keys, the argument kinds, and the shape of the subject reference — so a validator can report it before a run and a scheduler can refuse it without ever calling the check. The message is a phrase, not a sentence with a leading code: the caller states which rule or which node found it.
Types ¶
type ArgKind ¶
type ArgKind string
ArgKind is the shape a declared argument must have. The set is deliberately small: an assert's arguments are literal document data, and a kind the vocabulary cannot express is a check that needs a different declaration rather than a looser one.
const ( // ArgNumber is an integer or floating-point number. ArgNumber ArgKind = "number" )
Argument kinds.
type Input ¶
type Input struct {
// Value is the subject: the recorded value of the step named by "from", or
// the gate's needs' values in declaration order. nil means no value was
// produced.
Value any
// Args are the check's declared arguments, exactly as the document wrote
// them. The reserved "from" key is not present.
Args map[string]any
}
Input is what one check is evaluated against.
type Spec ¶
type Spec struct {
// Name is the allowlist key a document names.
Name string
// Doc states, in one line, what a pass means. It is the sentence a reader
// of the registry needs; the checks themselves document the reasons.
Doc string
// ReadsValue reports that the check reads Input.Value. A check that does
// not read one is a check over its arguments alone, and naming "from" for
// it is refused rather than ignored.
ReadsValue bool
// Args declares the accepted argument keys and their required kinds. Every
// declared argument is required; an empty map means the check takes none.
Args map[string]ArgKind
// Check is the evaluation.
Check Check
}
Spec is one registry entry: what the check is called, what it means, what it reads, and the arguments it accepts.