verification

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package verification defines application-neutral post-execution checks, literal activity evidence, verifier registration, and durable reports.

The package deliberately contains no provider, adapter, runtime-store, or host imports. Runtimes issue an ActivityRecorder for one attempt; trusted adapters record only activity observed at the actual client/process boundary. Model text and executor outputs are never interpreted as activity evidence.

Verification runs only after an executor has returned a valid completed result. The no_error check therefore attests that this post-execution boundary was reached; an executor/provider error remains authoritative and does not create a verification report. A generic wait is verified after its resumed execution completes. Durable external work is verified from its terminal observer result, and cannot carry process-local pre-suspension activity across that boundary.

Index

Constants

View Source
const (
	// CheckNoError is the structural completion check. It passes only after the
	// executor returned a valid completed result and output validation reached
	// the verification boundary. Executor/provider failures remain authoritative
	// attempt failures and do not manufacture a verification report.
	CheckNoError          = "no_error"
	CheckOutputSchema     = "output_schema"
	CheckPredicate        = "predicate"
	CheckExpectedToolCall = "expected_tool_call"
	CheckTests            = "tests"
	CheckLint             = "lint"
	BuiltinVersion        = "v1"
)
View Source
const (
	ReportSchemaVersion = "1"

	CodeInvalidCheck diagnostic.Code = "HADR-SOURCE-034"
	CodeUnknownCheck diagnostic.Code = "HADR-SOURCE-035"
)

Variables

View Source
var (
	ErrInvalidSpec     = errors.New("invalid verification spec")
	ErrUnknownVerifier = errors.New("unknown verifier")
	ErrInvalidResult   = errors.New("invalid verification result")
	ErrInvalidDecision = errors.New("invalid reviewer decision")
	ErrRecorderFrozen  = errors.New("verification activity recorder is frozen")
)

Functions

func CloneOutputs

func CloneOutputs(output values.ValueSet) (values.ValueSet, error)

func CloneSchema

func CloneSchema(schema graph.Schema) (graph.Schema, error)

func Resolve

func Resolve(registry Registry, kind string) (Verifier, VerifierSpec, error)

func SpecDigest

func SpecDigest(spec graph.VerificationSpec) (string, error)

SpecDigest hashes only semantic verification fields. Source locations do not affect replay identity.

func ValidateSpec

func ValidateSpec(ctx context.Context, registry Registry, spec *graph.VerificationSpec) []diagnostic.Diagnostic

ValidateSpec resolves and validates every check in source order. Unknown verifier kinds and unsupported extension semantics fail closed. Returned diagnostics are defensively copied and sorted by source location.

Types

type Activity

type Activity struct {
	Sequence uint64       `json:"sequence"`
	Kind     ActivityKind `json:"kind"`
	ToolCall *ToolCall    `json:"tool_call,omitempty"`
	Test     *TestRun     `json:"test,omitempty"`
	Lint     *LintRun     `json:"lint,omitempty"`
}

Activity is a closed, unambiguous evidence envelope. Sequence is assigned by the runtime-issued recorder and defines stable observation order.

func CloneActivities

func CloneActivities(input []Activity) ([]Activity, error)

func (Activity) Validate

func (a Activity) Validate() error

type ActivityKind

type ActivityKind string
const (
	ActivityToolCall ActivityKind = "tool_call"
	ActivityTest     ActivityKind = "test"
	ActivityLint     ActivityKind = "lint"
)

func (ActivityKind) Valid

func (k ActivityKind) Valid() bool

type ActivityOutcome

type ActivityOutcome string
const (
	ActivitySucceeded ActivityOutcome = "succeeded"
	ActivityFailed    ActivityOutcome = "failed"
	ActivitySkipped   ActivityOutcome = "skipped"
)

func (ActivityOutcome) Valid

func (o ActivityOutcome) Valid() bool

type ActivityRecorder

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

ActivityRecorder is a concurrency-safe attempt-local literal evidence sink. Runtimes issue one recorder and freeze it immediately after executor return. Trusted adapters call only the typed recording methods at actual activity boundaries; workflow/model data must never be translated into these calls.

func NewActivityRecorder

func NewActivityRecorder() *ActivityRecorder

NewActivityRecorder creates an empty recorder. Runtime dispatchers, not workflow authors or executor output parsers, own recorder issuance.

func (*ActivityRecorder) Freeze

func (r *ActivityRecorder) Freeze() ([]Activity, error)

Freeze atomically closes recording and returns a defensive snapshot. Exact replay calls return the same immutable snapshot.

func (*ActivityRecorder) RecordLint

func (r *ActivityRecorder) RecordLint(ctx context.Context, run LintRun) error

func (*ActivityRecorder) RecordTest

func (r *ActivityRecorder) RecordTest(ctx context.Context, run TestRun) error

func (*ActivityRecorder) RecordToolCall

func (r *ActivityRecorder) RecordToolCall(ctx context.Context, call ToolCall) error

type CheckOutcome

type CheckOutcome string
const (
	CheckPassed CheckOutcome = "passed"
	CheckFailed CheckOutcome = "failed"
	CheckError  CheckOutcome = "error"
)

func (CheckOutcome) Valid

func (o CheckOutcome) Valid() bool

type CheckResult

type CheckResult struct {
	Index   int               `json:"index"`
	Kind    string            `json:"kind"`
	Version string            `json:"version"`
	Outcome CheckOutcome      `json:"outcome"`
	Code    string            `json:"code"`
	Message string            `json:"message"`
	Details map[string]string `json:"details,omitempty"`
	Source  *graph.SourceRef  `json:"source,omitempty"`
}

CheckResult is one durable, source-mapped verifier decision.

func (CheckResult) Validate

func (r CheckResult) Validate() error

type LintRun

type LintRun struct {
	Name    string          `json:"name"`
	Outcome ActivityOutcome `json:"outcome"`
}

LintRun is literal evidence emitted by a trusted linter boundary.

type MemoryRegistry

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

MemoryRegistry is a concurrency-safe exact-kind verifier registry. Verifier kinds are intentionally unversioned in graph checks; their immutable version remains visible in the registry result and durable report.

func NewDefaultRegistry

func NewDefaultRegistry() *MemoryRegistry

NewDefaultRegistry returns all deterministic core verifiers. It performs no host/provider I/O and never reads the ambient environment.

func NewRegistry

func NewRegistry() *MemoryRegistry

func SnapshotRegistry

func SnapshotRegistry(source Registry) (*MemoryRegistry, error)

SnapshotRegistry freezes an exact verifier implementation/spec catalog for a compiler or runtime consumer. Subsequent registrations in the source registry cannot change validation or execution semantics mid-lifecycle.

func (*MemoryRegistry) List

func (r *MemoryRegistry) List() []VerifierSpec

func (*MemoryRegistry) Lookup

func (r *MemoryRegistry) Lookup(kind string) (Verifier, bool)

func (*MemoryRegistry) Register

func (r *MemoryRegistry) Register(verifier Verifier) error

type Registry

type Registry interface {
	Register(Verifier) error
	Lookup(kind string) (Verifier, bool)
	List() []VerifierSpec
}

type Report

type Report struct {
	SchemaVersion string        `json:"schema_version"`
	SpecDigest    string        `json:"spec_digest"`
	Status        ReportStatus  `json:"status"`
	Reason        string        `json:"reason,omitempty"`
	Checks        []CheckResult `json:"checks,omitempty"`
	Evidence      []Activity    `json:"evidence,omitempty"`
}

Report is the durable verification data-plane payload. SpecDigest binds it to the source declaration; Evidence contains only frozen literal activity.

func CloneReport

func CloneReport(report Report) (Report, error)

func (Report) Validate

func (r Report) Validate() error

type ReportStatus

type ReportStatus string
const (
	ReportPassed ReportStatus = "passed"
	ReportFailed ReportStatus = "failed"
	ReportNotRun ReportStatus = "not_run"
)

func (ReportStatus) Valid

func (s ReportStatus) Valid() bool

type Request

type Request struct {
	Check        graph.VerificationCheck
	OutputSchema graph.Schema
	Outputs      values.ValueSet
	Evidence     []Activity
}

Request is a defensive verifier input. OutputSchema is the registered kind's trusted output schema; Outputs and Evidence are typed runtime observations.

type ReviewerDecision

type ReviewerDecision struct {
	Passed  bool              `json:"passed"`
	Code    string            `json:"code"`
	Message string            `json:"message"`
	Details map[string]string `json:"details,omitempty"`
}

ReviewerDecision is the strict provider-neutral result expected from future LLM/reviewer adapters. Passing requires an explicit boolean plus stable code and message; unknown fields, duplicate fields, and trailing documents fail.

func ParseReviewerDecision

func ParseReviewerDecision(data []byte) (ReviewerDecision, error)

func (ReviewerDecision) Validate

func (d ReviewerDecision) Validate() error

type TestRun

type TestRun struct {
	Name    string          `json:"name"`
	Outcome ActivityOutcome `json:"outcome"`
}

TestRun is literal evidence emitted by a trusted test harness boundary.

type ToolCall

type ToolCall struct {
	Server  string          `json:"server"`
	Tool    string          `json:"tool"`
	Outcome ActivityOutcome `json:"outcome"`
}

ToolCall is literal evidence emitted at an actual tool client boundary. It intentionally excludes arguments, results, credentials, and arbitrary transport metadata.

type Verifier

type Verifier interface {
	Spec() VerifierSpec
	ValidateConfig(context.Context, graph.VerificationCheck) []diagnostic.Diagnostic
	Verify(context.Context, Request) (CheckResult, error)
}

type VerifierMode

type VerifierMode string
const (
	ModeDeterministic VerifierMode = "deterministic"
	ModeReviewer      VerifierMode = "reviewer"
)

func (VerifierMode) Valid

func (m VerifierMode) Valid() bool

type VerifierSpec

type VerifierSpec struct {
	Kind             string         `json:"kind"`
	Version          string         `json:"version"`
	Mode             VerifierMode   `json:"mode"`
	ConfigSchema     graph.Schema   `json:"config_schema"`
	RequiredEvidence []ActivityKind `json:"required_evidence,omitempty"`
}

VerifierSpec is immutable registry metadata. ConfigSchema describes the opaque graph check config; RequiredEvidence is an inspectable fail-closed declaration used by compilers and policy before execution.

func (VerifierSpec) Validate

func (s VerifierSpec) Validate() error

Jump to

Keyboard shortcuts

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