analysis

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 26 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 analysis is the analysis framework: one contract every way of answering a question about a model implements, one scale for the strength of an answer, a registry of engines and the dispatch that turns a question into the engines that answer it.

A Question names a subject, what is asked of it and what is left free. An Engine covers a set of questions and answers one with a Result whose Strength says how the claim is supported. A Registry holds the engines a binary knows, and Registry.Answer dispatches a question under `auto`: the strongest covering engine answers, a not-covered result advances to the next, and the Plan records every engine consulted.

The engines here — run, explore, sweep and solve — are adapters over the interpreter, runtime.Explore, Context.RunSweep and internal/core/solve.

Index

Constants

View Source
const (
	DefaultCheckDepth  = 10000
	DefaultCheckStates = 1000000
)

The bounds a check searches under when the budget leaves them 0: the moves one schedule may make and the distinct states the search may visit.

View Source
const CheckEngineName = "check"

CheckEngineName is the name of the engine that searches an action's schedules explicitly.

View Source
const DefaultOutputLimit = 64 << 20

DefaultOutputLimit is the bound when OutputLimitEnv is unset or unusable.

View Source
const DefaultToolTimeout = solve.DefaultTimeout

DefaultToolTimeout is how long a tool is given to answer one invocation before the performance fails with a timeout: the solver's default.

View Source
const DefaultUnroll = 4

DefaultUnroll is how many iterations of a body loop a symbolic engine unrolls when Budget.Unroll is zero.

View Source
const EnginesEnv = "OPENSYSML_ENGINES"

EnginesEnv names the environment variable holding the engine manifest: a directory with one JSON entry per external engine or strategy. Either directory may hold any kind.

View Source
const ExploreEngineName = "explore"

ExploreEngineName is the name of the engine that runs every linearization.

View Source
const JobsEnvVar = "OPENSYSML_JOBS"

JobsEnvVar names the variable setting how many runs of one plan go concurrently.

View Source
const ManifestExt = ".json"

ManifestExt is the extension of a manifest entry; other files in the directory are ignored.

View Source
const OutputLimitEnv = "OPENSYSML_TOOL_MAX_OUTPUT"

OutputLimitEnv names the environment variable bounding what one external process may write: one reply or one protocol line on standard output, and the whole of standard error, for tools and engines alike. Bytes, or bytes with a `K`, `M` or `G` suffix.

View Source
const ProgressInterval = 250 * time.Millisecond

ProgressInterval is the least time between two reports of one run: an engine that sends a notification per state costs the pipe, not the report.

View Source
const RunEngineName = "run"

RunEngineName is the name of the engine that runs the interpreter once.

View Source
const SMTEngineName = "smt"

SMTEngineName is the name of the symbolic engine over an SMT solver, which lives in package smt and joins the build's registry through package engines.

View Source
const ServeAll = "all"

ServeAll is the spelling that serves every manifest engine.

View Source
const SolveEngineName = "solve"

SolveEngineName is the name of the engine that puts conditions to an SMT solver.

View Source
const SolveProcess = "an SMT solver: the one " + solve.SolverEnv + " names, else z3 or cvc5 on PATH"

SolveProcess is what the solve engine needs, as its description names it.

View Source
const SweepEngineName = "sweep"

SweepEngineName is the name of the engine that runs a domain row by row.

View Source
const ToolEnginePrefix = "tool:"

ToolEnginePrefix starts the name of every tool engine: `tool:ModelCenter`.

View Source
const ToolTimeoutEnv = "OPENSYSML_TOOL_TIMEOUT"

ToolTimeoutEnv names the environment variable bounding one tool invocation and, for an external engine, one message round trip and the grace a cancel is given.

View Source
const ToolsEnv = "OPENSYSML_TOOLS"

ToolsEnv names the environment variable holding the tool manifest: a directory with one JSON entry per external tool.

View Source
const TransportGRPC = "grpc"

TransportGRPC is a bidirectional streaming RPC to an address; defined, not yet served.

View Source
const TransportStdio = "stdio"

TransportStdio is a child process on a pair of pipes, the one transport this build serves.

Variables

View Source
var BoundNames = []string{"depth", "steps", "runs", "memory"}

BoundNames are the bounds an engine entry may take, as the budget spells them.

View Source
var ErrConstruct = errors.New("construct outside the check engine's search")

ErrConstruct is the typed refusal of a construct the check engine does not search.

View Source
var ErrDomain = errors.New("engine has no domain for that type")

ErrDomain is the typed error for a free input whose declared type the engine cannot narrow to a domain it ranges over.

View Source
var ErrDuplicateEngine = errors.New("engine already registered")

ErrDuplicateEngine is the typed error Register returns for a name already registered.

View Source
var ErrEngineExited = errors.New("engine process exited")

ErrEngineExited is the typed error for an engine process that ended before it answered.

View Source
var ErrEngineFault = errors.New("engine answered with an error")

ErrEngineFault is the typed error for an engine answering a request with an error.

View Source
var ErrEngineRefusal = errors.New("engine does not cover the question")

ErrEngineRefusal is the typed error for an engine answering covers with false.

View Source
var ErrEngineTimeout = errors.New("engine did not answer in time")

ErrEngineTimeout is the typed error for a message unanswered within OPENSYSML_TOOL_TIMEOUT.

View Source
var ErrEngineWithheld = errors.New("engine is not served by this service")

ErrEngineWithheld is the typed error for a manifest engine a service lists but does not run: a request naming it asks to run a program on the server the operator did not grant.

View Source
var ErrFreedom = errors.New("engine cannot leave that free")

ErrFreedom is the typed error a concrete engine refuses with for a question that leaves free what the engine fixes.

View Source
var ErrHandshake = errors.New("engine describes itself otherwise than its manifest entry")

ErrHandshake is the typed error for a describe answer that disagrees with the manifest.

View Source
var ErrInconsistentResult = errors.New("claim and strength do not agree")

ErrInconsistentResult is the typed error for a claim at a strength the scale does not admit.

View Source
var ErrInput = errors.New("engine cannot free that input")

ErrInput is the typed error for a feature a question names as an input that the engine cannot leave free: one the behavior lacks, or one it writes back.

View Source
var ErrInputNotFree = errors.New("a witness input the question does not leave free")

ErrInputNotFree is the typed refusal of a witness input the question does not leave free.

View Source
var ErrJob = errors.New("job index must not be negative")

ErrJob is the typed error for a run asking for a worker at a negative job index.

View Source
var ErrJobs = errors.New("jobs must be a positive integer")

ErrJobs is the typed error for a jobs setting that is not a positive integer.

View Source
var ErrMalformedQuestion = errors.New("question lacks the ask its kind needs")

ErrMalformedQuestion is the typed error for a question missing the ask its kind needs.

View Source
var ErrManifest = errors.New("tool manifest is malformed")

ErrManifest is the typed error every fault in a manifest unwraps to.

View Source
var ErrNoEngine = errors.New("no engine answers this kind of question")

ErrNoEngine is the typed error Answer returns when no registered engine answers the question's kind at all.

View Source
var ErrNoReplay = errors.New("no action to replay the witness on")

ErrNoReplay is the typed refusal of a witness on a question with no action to replay it on.

View Source
var ErrNoRuntime = errors.New("model builds no runtime of a run's own")

ErrNoRuntime is the typed error for a run needing a context the model does not build.

View Source
var ErrNotAsked = errors.New("engine does not answer this kind of question")

ErrNotAsked is the typed error an engine refuses with for a kind it does not answer.

View Source
var ErrNotExternal = errors.New("not an external engine")

ErrNotExternal is the typed error for a name given to serve that is not a manifest engine.

View Source
var ErrNotServed = errors.New("manifest entry is not served in this build")

ErrNotServed is the typed error for a manifest entry this build lists but does not run.

View Source
var ErrOverclaim = errors.New("engine answered above its authority")

ErrOverclaim is the typed error for an engine answering above its declared authority.

View Source
var ErrProcessAbsent = errors.New("engine's process is absent")

ErrProcessAbsent is the typed error an external engine refuses with when its process is not found.

View Source
var ErrProtocol = errors.New("engine broke protocol")

ErrProtocol is the typed error for an engine that broke the message protocol.

View Source
var ErrSessionEnded = errors.New("engine session ended")

ErrSessionEnded is the typed error for a request to an engine whose session in this plan has already ended.

View Source
var ErrSubject = errors.New("engine does not answer for the subject")

ErrSubject is the typed error for a question about a subject the entry does not name.

View Source
var ErrToolAbsent = errors.New("tool's executable is absent")

ErrToolAbsent is the typed error for a manifest entry whose executable is not found.

View Source
var ErrToolVariable = errors.New("tool does not accept the variable")

ErrToolVariable is the typed error for a call using tool variables the manifest entry does not accept.

View Source
var ErrUnansweredRun = errors.New("run ended unanswered")

ErrUnansweredRun is the typed error for a run that ended without an answer after reporting progress.

View Source
var ErrUnknownEngine = errors.New("no such engine")

ErrUnknownEngine is the typed error for a selection naming no registered engine.

View Source
var ErrWireValue = errors.New("value is not carried by the engine protocol")

ErrWireValue is the typed error for a value the protocol does not carry.

View Source
var ErrWrongTool = errors.New("call names another tool")

ErrWrongTool is the typed error a tool engine refuses with for a call naming another tool.

View Source
var GraphsVersions = []int{export.GraphsVersion}

GraphsVersions are the versions of the `graphs:<v>` model form this build serves.

View Source
var ProtocolVersions = []int{1}

ProtocolVersions are the versions of the engine message set this build serves.

Functions

func Compose

func Compose(results []Result) (Result, []Disagreement)

Compose is the one result of several engines' answers, taken in engine-name order: a witness stands over the universal claim it refutes (a disagreement) — a violation over holds, a satisfying assignment over unsatisfiable, and to a Sensitive question a replayed sensitivity over the feature held not sensitive — else the strongest strength earned.

func Consistent

func Consistent(claim Claim, strength Strength) error

Consistent is the typed error for a claim at a strength the scale does not admit, nil for a pair it does: nothing at not covered, an existential at witnessed, a concrete claim at observed, a universal at observed, bounded or proved.

func DefaultJobs

func DefaultJobs() int

DefaultJobs is the jobs a plan has when nothing sets them: one per CPU.

func Explores

func Explores(selection Selection, schedule runtime.SchedulePolicy) (runtime.SchedulePolicy, bool)

Explores is the exploration a selection and a schedule together ask of a behavior: the schedule's own when it explores, else the default one when the selection names the explore engine, `-engine explore` being `-schedule explore`.

func JobsFromEnv

func JobsFromEnv() (int, error)

JobsFromEnv is the jobs OPENSYSML_JOBS asks for, DefaultJobs when it is unset or empty; a value that is not a positive integer is reported rather than left at the default.

func Lines

func Lines(listings []Listing) []string

Lines tables listings as a report prints them — name, kind, protocol, authority, kinds, status — then one source line per manifest entry.

func ParseJobs

func ParseJobs(source, text string) (int, error)

ParseJobs reads a jobs setting written at source: a positive integer, else a JobsError.

func ProgressText

func ProgressText(p enginewire.ProgressParams) string

ProgressText spells progress as a report prints it: `runs 120, depth 17, steps 3: text`.

func SensitivityFile

func SensitivityFile(subject, performer, feature, label string) string

SensitivityFile names one witness of a pair of schedules ending with different values of a feature, `test.race-x-A.witness` and `test.race-x-B.witness`: the checked name, the feature's segments and the label, `A` or `B`, of the copy that ran it.

func ToolEngineName

func ToolEngineName(tool string) string

ToolEngineName is the name of the engine answering for the tool named.

func ToolReplyOf

func ToolReplyOf(tool string, stdout []byte) (map[string]runtime.ToolValue, error)

ToolReplyOf reads the tool's standard output as the protocol's one JSON object: the outputs keyed by ToolVariable name, or the tool's own error as a ToolError.

func ToolRequestOf

func ToolRequestOf(call *runtime.ToolCall) ([]byte, error)

ToolRequestOf is the JSON object the protocol writes to the tool for one call: the toolName and uri passed through, the inputs keyed by ToolVariable name. Its bytes are the same for equal inputs, so two invocations compare by them.

func ViolationFile

func ViolationFile(subject, performer string, n int) string

ViolationFile names the witness of the n-th violation of the subject, performed by performer when one is named: `test.race.violation-1.witness`, `Plant.fill@Plant.tank.violation-1.witness`. Its one `-` tells it from a divergence's file, whose tokens carry none.

func WithReporter

func WithReporter(ctx context.Context, report Reporter) context.Context

WithReporter installs the reporter a plan's external engines report progress to.

func WriteWitness

func WriteWitness(path, text string) (err error)

WriteWitness writes the witness text beside path and moves it into place over what the path held, so a link planted there is replaced, never followed to what it points at. The directory is made when it does not exist.

Types

type Answer

type Answer struct {
	Claim Claim
	// Reason says why nothing is claimed when no error does.
	Reason string
	// Err is the failure that ended the execution: a typed runtime error, whose
	// budget the engine reports as a bound reached.
	Err    error
	Values []Evaluation
}

Answer is what one performance established: the claim it supports, the values it produced, and why when it claims nothing.

func CaseAnswer

func CaseAnswer(result runtime.AnalysisResult, err error) Answer

CaseAnswer is what one analysis case run established: its outputs.

func CheckAnswer

func CheckAnswer(result runtime.CheckResult, err error) Answer

CheckAnswer is what a constraint, requirement or satisfaction check established. A false verdict arrives as an error unwrapping to runtime.ErrViolated and is a violation.

func ValuesAnswer

func ValuesAnswer(values []Evaluation, err error) Answer

ValuesAnswer is what a run producing values established: the values, or nothing when it failed.

func VerificationAnswer

func VerificationAnswer(result runtime.VerificationResult, err error) Answer

VerificationAnswer is what one verification case run established: pass holds, fail is violated, and an inconclusive or erroring body establishes nothing.

type Asking

type Asking func(*solve.Solver, context.Context, *solve.Query) (*solve.Result, error)

Asking puts one query to the solver in a method expression's shape. An error is that query's failure, not the question's; nil for both is a query withheld, which stays uncovered.

type Bound

type Bound struct {
	// Name is the bound's, as the budget spells it: runs, depth, steps,
	// elements, solver, configurations.
	Name string
	// Limit is the value the run was held to: a count, or milliseconds for a time.
	Limit int64
	// Reached reports the run stopped at the limit rather than finishing within it.
	Reached bool
}

Bound is one limit a run took, and whether the run reached it.

func (Bound) String

func (b Bound) String() string

String renders the bound as `name=limit`, a reached one marked `(reached)`.

type Bounds

type Bounds []Bound

Bounds is every bound a run took, in the order the budget names them.

func (Bounds) Limit

func (b Bounds) Limit(name string) (int64, bool)

Limit is the limit of the named bound, and whether the run took it at all.

func (Bounds) Reached

func (b Bounds) Reached() bool

Reached reports whether any bound stopped the run.

func (Bounds) String

func (b Bounds) String() string

String renders the bounds as a report qualifies a claim by them: `runs=1024 depth=64`.

type Budget

type Budget struct {
	// Deadline is the wall clock for the whole plan, met as context.DeadlineExceeded; zero means none.
	Deadline time.Time
	// Jobs is how many runs may go concurrently, as -jobs, %jobs or OPENSYSML_JOBS set it
	// and BudgetOf fills it; zero means one. Memory times Jobs is what the fleet may hold.
	Jobs int
	// Runs is how many runs an exploration, rows a sweep or queries a solver
	// may make; the unit is the engine's.
	Runs int
	// Depth is how many moves one run may resolve.
	Depth int
	// Unroll is how many iterations of a body loop a symbolic engine unrolls; zero is
	// DefaultUnroll.
	Unroll int
	// Steps is the step budget of one run, as OPENSYSML_MAX_STEPS names it.
	Steps int
	// Solver is the time one query may take, as OPENSYSML_SMT_TIMEOUT names it.
	Solver time.Duration
	// Memory is the elements one run may hold, as OPENSYSML_MAX_ELEMENTS names it.
	Memory int
}

Budget is what a run may spend; a zero field is the engine's own default. Runs, Depth and Solver are applied by the engines in their own units, Deadline by Registry.Answer to the plan's context; Steps and Memory name the context's.

func BudgetOf

func BudgetOf(limits runtime.Budgets, policy runtime.SchedulePolicy, kind Kind, jobs int) Budget

BudgetOf is the budget a question of kind has under limits, policy and jobs, its Runs in the kind's own unit: an exploring policy's runs for outcomes, the sweep runs for a sweep. Jobs is the surface's setting, DefaultJobs when it is not positive.

type CheckAsk

type CheckAsk struct {
	// Start begins the invocation in a context of the check's own; a replay begins it the same way.
	Start runtime.Starter
	// Performer names the object Start performs the behaviors on, as the surface
	// spelled it, so the witnesses of one behavior on two objects are two sets of
	// files; empty when no object performs it.
	Performer string
	// Properties are evaluated at every stable state; one false is a violation.
	Properties []runtime.CheckProperty
	// Diverge names the features whose final values are compared across the
	// complete schedules; none compares the behaviors' own attributes and final
	// states, and the performing object's features when one performs them.
	Diverge []string
	// WitnessDir is where every violation's and divergent value's witness is
	// written, a file per witness; empty writes none.
	WitnessDir string
}

CheckAsk is what a check question asks over the schedules of one invocation: how its behaviors begin on one clock, what must hold at every stable state, what may not diverge, and where the witnesses go.

type Checked

type Checked struct {
	Report     *runtime.CheckReport
	Violations []string
	Divergent  [][]string
}

Checked is a check's report with where its witnesses were written: a path per violation and per divergent value, in the report's order; none without a directory.

type Claim

type Claim int

Claim is what a result asserts about its question.

const (
	// ClaimNone asserts nothing; the result's Reason says why.
	ClaimNone Claim = iota
	// ClaimHolds asserts the condition holds for what the question left free.
	ClaimHolds
	// ClaimViolated asserts an execution violates the condition.
	ClaimViolated
	// ClaimSensitive asserts the behavior's result depends on its schedule.
	ClaimSensitive
	// ClaimValue asserts the values in Values are what the subject produces.
	ClaimValue
	// ClaimTable asserts the rows in Values are the domain's, one per row.
	ClaimTable
	// ClaimOutcomes asserts the outcomes in Values are what the behavior can do.
	ClaimOutcomes
	// ClaimSatisfiable asserts an assignment in Values meets the conditions.
	ClaimSatisfiable
	// ClaimUnsatisfiable asserts no assignment meets the conditions.
	ClaimUnsatisfiable
	// ClaimUnbounded asserts an objective has no optimum: better values exist without limit.
	ClaimUnbounded
)

func ParseClaim

func ParseClaim(text string) (Claim, bool)

ParseClaim reads a claim as Claim.String spells it.

func (Claim) Concrete

func (c Claim) Concrete() bool

Concrete reports whether the claim is the values concrete executions produced — a value, a table — which are only ever observed.

func (Claim) Existential

func (c Claim) Existential() bool

Existential reports whether the claim is that some execution exists — a violation, a sensitivity, a satisfying assignment — for which witnessed is the one strength that is a claim at all.

func (Claim) String

func (c Claim) String() string

String names the claim as a plan spells it.

func (Claim) Universal

func (c Claim) Universal() bool

Universal reports whether the claim is over everything the question left free — holds, an outcome set, unsatisfiable, unbounded — graded proved, bounded or observed.

type ComputeAsk

type ComputeAsk struct {
	Call *runtime.ToolCall
}

ComputeAsk is the invocation a Compute question asks for: one performance of an action annotated ToolExecution, as the runtime hands it to the tool.

type ConstructError

type ConstructError struct {
	Engine    string
	Construct string
}

ConstructError names the construct the check engine met and does not search.

func (*ConstructError) Error

func (e *ConstructError) Error() string

Error names the engine and the construct.

func (*ConstructError) Is

func (e *ConstructError) Is(target error) bool

Is matches ErrConstruct.

type Coverage

type Coverage struct {
	Covered bool
	// Refusal names the construct, condition or absent process the engine
	// cannot handle; nil when covered.
	Refusal error
}

Coverage is what Covers answers: covered, or refused for a typed reason.

type Description

type Description struct {
	// Questions are the kinds the engine answers.
	Questions []Kind
	// Process names the external process the engine needs, empty for none.
	Process string
	// Bounds names the bounds the engine takes, in the order it reports them.
	Bounds []string
	// Replays reports whether the engine's witnesses replay through the interpreter.
	Replays bool
	// Authority is the strongest evidence the engine can ever produce.
	Authority Strength
}

Description is an engine's capability declaration.

func (Description) Answers

func (d Description) Answers(k Kind) bool

Answers reports whether the engine declares the kind.

type Disagreement

type Disagreement struct {
	// Stands names the engine whose witnessed result the composition kept.
	Stands string
	// Demoted names the engine whose result was demoted, and Claimed is that result as it answered.
	Demoted string
	Claimed Result
	// Reason is the disagreement as the demoted result's Reason spells it.
	Reason string
}

Disagreement is two engines contradicting each other about one question: a witnessed existential claim against a universal claim it refutes. The interpreter is normative, so the witness stands and the other result is demoted to not covered with the disagreement as its reason.

type DomainError

type DomainError struct {
	Engine  string
	Feature string
	// Type is the declared type, as written; "" when the feature declares none.
	Type string
	// Reason says what the type lacks, when the engine can say more than its name.
	Reason string
}

DomainError reports a free input of a type the engine has no domain for; the question is not covered, since ranging over an unconstrained variable would claim what the model does not say.

func (*DomainError) Error

func (e *DomainError) Error() string

Error names the engine, the feature and its type.

func (*DomainError) Is

func (e *DomainError) Is(target error) bool

Is matches ErrDomain.

type DuplicateEngineError

type DuplicateEngineError struct {
	Name string
}

DuplicateEngineError reports a second registration under one name.

func (*DuplicateEngineError) Error

func (e *DuplicateEngineError) Error() string

Error names the engine.

func (*DuplicateEngineError) Is

func (e *DuplicateEngineError) Is(target error) bool

Is matches ErrDuplicateEngine.

type Engine

type Engine interface {
	// Name is the engine's stable identity.
	Name() string
	// Describe reports what the engine can do, fixed at registration.
	Describe() Description
	// Covers says, before any work, whether the engine can answer q for this model;
	// a refusal names what it cannot handle and is never a result.
	Covers(model *Model, q Question) Coverage
	// Run answers q within the budget, in a context of its own. It never
	// mutates model; it stops when ctx is done and reports how far it got.
	Run(ctx context.Context, model *Model, q Question, budget Budget) (Result, error)
}

Engine is one registered way of answering questions about a model.

func NewCheck

func NewCheck() Engine

NewCheck returns the check engine.

func NewExplore

func NewExplore() Engine

NewExplore returns the explore engine.

func NewRun

func NewRun() Engine

NewRun returns the run engine.

func NewSweep

func NewSweep() Engine

NewSweep returns the sweep engine.

type EngineEntry

type EngineEntry struct {
	// File is the entry read; Dir its directory, which a relative command is confined to.
	File string
	Dir  string
	// Kind is engine, policy or sampler.
	Kind EntryKind
	// Name is the engine's registered name, as -engine selects it.
	Name    string
	Version string
	// Command is the executable and its arguments as written; Executable the resolved path
	// of Command[0], confined to Dir when relative.
	Command    []string
	Executable string
	// Transport is stdio or grpc; Address is where a grpc engine listens.
	Transport string
	Address   string
	// Module is a WebAssembly module in place of Command; defined, served by a later stage.
	Module string
	// Protocol is the version of the message set the engine speaks.
	Protocol int
	// Answers, Subjects, Bounds and Witness are the engine's Description. Subjects are
	// declaration kinds as the notation spells them without def (action, state, calc);
	// empty means any subject.
	Answers  []Kind
	Subjects []string
	Bounds   []string
	Witness  WitnessKind
	// Model names the forms of the model the engine reads; sources is always sent.
	Model []ModelForm
	// Authority is the strongest strength the engine says it produces for a universal claim.
	Authority Strength
	// Concurrent says whether one process may hold several run requests open at once.
	Concurrent bool
}

EngineEntry is one `engine`, `policy` or `sampler` entry of a manifest, as the framework's Description written down: the fields the host checks before any process runs.

func (EngineEntry) Description

func (e EngineEntry) Description() Description

Description is the entry as the framework describes an engine.

func (EngineEntry) Forms

func (e EngineEntry) Forms() []ModelForm

Forms are the model forms a run carries: sources always, then what the entry asked for.

func (EngineEntry) Origin

func (e EngineEntry) Origin() Origin

Origin is where the entry comes from, as a listing prints it.

func (EngineEntry) Present

func (e EngineEntry) Present() error

Present checks the entry's program is there without running it: a regular file, executable by someone for a command. It is the one check a listing makes of the file system.

func (EngineEntry) Program

func (e EngineEntry) Program() string

Program is the resolved executable or module path the entry runs, empty for a grpc engine.

func (EngineEntry) Served

func (e EngineEntry) Served() error

Served reports whether this build runs the entry, and the typed reason when it does not: strategies, WebAssembly modules, the grpc transport and the rdf form are later stages.

type EngineExitedError

type EngineExitedError struct {
	Engine  string
	Process string
	// Started reports whether the process had answered describe before it ended.
	Started bool
	Err     error
	Stderr  string
}

EngineExitedError reports the process ending: at start, or during a request. Stderr is what it wrote to standard error, within the output bound.

func (*EngineExitedError) Error

func (e *EngineExitedError) Error() string

Error names the engine, the process and how it ended.

func (*EngineExitedError) Is

func (e *EngineExitedError) Is(target error) bool

Is matches ErrEngineExited.

func (*EngineExitedError) Unwrap

func (e *EngineExitedError) Unwrap() error

Unwrap is the process error.

type EngineFaultError

type EngineFaultError struct {
	Engine  string
	Method  string
	Code    string
	Message string
}

EngineFaultError is the engine's error answer: its code and message.

func (*EngineFaultError) Error

func (e *EngineFaultError) Error() string

Error names the engine, the code and the message.

func (*EngineFaultError) Is

func (e *EngineFaultError) Is(target error) bool

Is matches ErrEngineFault.

type EngineRefusalError

type EngineRefusalError struct {
	Engine string
	Reason string
}

EngineRefusalError is the engine's own refusal of a question, with the reason it gave.

func (*EngineRefusalError) Error

func (e *EngineRefusalError) Error() string

Error names the engine and its reason.

func (*EngineRefusalError) Is

func (e *EngineRefusalError) Is(target error) bool

Is matches ErrEngineRefusal.

type EngineTimeoutError

type EngineTimeoutError struct {
	Engine  string
	Method  string
	Timeout time.Duration
}

EngineTimeoutError reports a request unanswered within the timeout: describe or covers within the round-trip bound, or a cancelled run within the grace after cancel.

func (*EngineTimeoutError) Error

func (e *EngineTimeoutError) Error() string

Error names the engine, the request and the bound.

func (*EngineTimeoutError) Is

func (e *EngineTimeoutError) Is(target error) bool

Is matches ErrEngineTimeout.

type EngineWithheldError

type EngineWithheldError struct {
	Name string
}

EngineWithheldError names the engine a service withholds.

func (*EngineWithheldError) Error

func (e *EngineWithheldError) Error() string

Error reads `engine 'spin-bridge' is not served by this service`.

func (*EngineWithheldError) Is

func (e *EngineWithheldError) Is(target error) bool

Is matches ErrEngineWithheld.

type EntryKind

type EntryKind string

EntryKind is what a manifest entry registers: a tool the model names, an engine, or a strategy a later build serves.

const (
	// KindTool is an executable a ToolExecution names; the default when `kind` is absent.
	KindTool EntryKind = "tool"
	// KindEngine is an external analysis engine answering questions over the protocol.
	KindEngine EntryKind = "engine"
	// KindPolicy is an external scheduling policy, not served in this build.
	KindPolicy EntryKind = "policy"
	// KindSampler is an external sweep sampler, not served in this build.
	KindSampler EntryKind = "sampler"
)

type Evaluation

type Evaluation struct {
	// Name is the feature, output, row or query the evaluation is of.
	Name string
	// Value is a feature value or output.
	Value runtime.Value
	// Row is one row of a sweep.
	Row *runtime.SweepRow
	// Explored is the outcome set an exploration reached.
	Explored *runtime.Exploration
	// Solved is a solver's answer to one query.
	Solved *solve.Result
	// Checked is what a search of an action's schedules found, with its witnesses written.
	Checked *Checked
	// Err is what failed this unit.
	Err error
}

Evaluation is one thing the question asked for, as the engine established it: exactly one of Value, Row, Explored, Solved and Checked is set, or Err when this unit failed.

func OutputValues

func OutputValues(outputs []runtime.CalcOutputValue) []Evaluation

OutputValues is a case's or calculation's outputs as evaluations.

func ValuesOf

func ValuesOf(held map[string]runtime.Value) []Evaluation

ValuesOf is a behavior's outputs or state data as evaluations, in name order.

type External

type External interface {
	Engine
	// Process names the process found (`z3 at /usr/bin/z3`), or reports its
	// absence as the typed error Covers refuses with.
	Process() (string, error)
}

External is an engine that needs a process outside the build, and reports whether it found one.

func ExternalsFromEnv

func ExternalsFromEnv(workspaces ...string) ([]External, error)

ExternalsFromEnv reads both manifests the environment names as engines: one `tool:<name>` per tool entry and one engine per engine, policy or sampler entry, in manifest then entry order, each whether or not its program is found or this build serves it; none when both are unset. A manifest that cannot be read is a ManifestError.

func NewSolve

func NewSolve(discover func() (*solve.Solver, error)) External

NewSolve returns the solve engine over the solver discover finds; nil discovers as solve.Discover does.

func NewTool

func NewTool(entry ToolEntry) External

NewTool returns the `tool:<name>` engine of a manifest entry. It registers whether or not the executable is found and refuses through Covers while it is not.

type Freedom

type Freedom int

Freedom is what a question leaves free; a set of the flags below.

const (
	// FreeNothing fixes every choice: one execution, or one per row.
	FreeNothing Freedom = 0
	// FreeSchedule leaves the scheduling of concurrent behavior open.
	FreeSchedule Freedom = 1 << iota
	// FreeInputs leaves unbound inputs open.
	FreeInputs
)

func (Freedom) Has

func (f Freedom) Has(flag Freedom) bool

Has reports whether the freedom includes f.

func (Freedom) String

func (f Freedom) String() string

String names what is free: `nothing`, `the schedule`, `the inputs`, or both.

type FreedomError

type FreedomError struct {
	Engine string
	Free   Freedom
}

FreedomError reports a question leaving free what the engine fixes: inputs to one that runs concrete values only, the schedule to one that runs under one policy.

func (*FreedomError) Error

func (e *FreedomError) Error() string

Error names the engine and what it cannot leave free.

func (*FreedomError) Is

func (e *FreedomError) Is(target error) bool

Is matches ErrFreedom.

type HandshakeError

type HandshakeError struct {
	Engine   string
	Field    string
	Manifest string
	Answer   string
}

HandshakeError reports the field of describe that differs from the manifest entry.

func (*HandshakeError) Error

func (e *HandshakeError) Error() string

Error names the engine, the field and both spellings.

func (*HandshakeError) Is

func (e *HandshakeError) Is(target error) bool

Is matches ErrHandshake.

type HoldsAsk

type HoldsAsk struct {
	// Behavior is the action definition or usage whose schedules are asked about.
	Behavior *symbols.Symbol
	// Scope is the scope Behavior's body resolves in; Behavior's own when nil.
	Scope *symbols.Scope
	// Conditions are the requirements and constraints asked to hold at every
	// move, each as `-check-property` names it; none asks only that no schedule deadlocks.
	Conditions []*symbols.Symbol
	// Start begins one run of Behavior in a fresh context, as an explored run is
	// begun: the executor made, on the object performing it when there is one.
	Start Start
	// Inputs names features of Behavior or its performer to leave free although
	// the model binds them, as `-check-input` spells them.
	Inputs []string
	// Assume are the constraints or requirements assumed over the initial state.
	Assume []*symbols.Symbol
	// Diverge names the features whose final values a Sensitive question compares
	// across the complete schedules, as `-check-diverge` spells them; none compares
	// the action's own attributes, and the performing object's when one performs it.
	Diverge []string
	// Performer names the object performing Behavior, "" when the action runs on
	// its own; a witness file is named after the subject and it.
	Performer string
	// WitnessDir is where a violation's or a sensitivity's witnesses are written, "" for nowhere.
	WitnessDir string
}

HoldsAsk is the behavior a Holds or Sensitive question is about, the conditions asked to hold over its schedules, the features whose final values a Sensitive question compares across them, and how one run of it begins in a fresh context.

type InconsistentResultError

type InconsistentResultError struct {
	Engine   string
	Claim    Claim
	Strength Strength
}

InconsistentResultError reports a result whose claim and strength the scale does not admit together: a defect in the engine, never an answer.

func (*InconsistentResultError) Error

func (e *InconsistentResultError) Error() string

Error names the pair, and the engine when known.

func (*InconsistentResultError) Is

func (e *InconsistentResultError) Is(target error) bool

Is matches ErrInconsistentResult.

type Input

type Input struct {
	// Name is the feature as the performance holds it.
	Name string
	// Type is the declared type, as written; "" when the feature declares none.
	Type string
	// Sort is the solver sort the feature's values range over (Int, Real, Bool, an
	// enumeration's datatype).
	Sort string
	// Domain says what the sort is narrowed to (`>= 0`, the constructors, an
	// interval); "" when the sort alone is the domain.
	Domain string
	// Free reports whether the engine ranged over the domain; false pins Value.
	Free bool
	// Optional reports a free input whose multiplicity admits no value (`[0..1]`):
	// the engine ranged over its absence too, which a witness spells `null`.
	Optional bool
	// Value is the value pinned, or the one a witness chose for a free input,
	// spelled as the witness file's input line spells it; "" for a free input
	// of a claim with no witness, or a pinned one held without a value.
	Value string
}

Input is one feature of the behavior or its performer an engine ranged over or pinned in the initial state: free in the domain its declared type narrows the sort to, or fixed at the value the model binds it to.

func (Input) String

func (in Input) String() string

String spells the input as a report lists it: `x : Integer free`, `n : Natural free in >= 0`, `x : Integer free or absent`, `mode = Mode::Fast`.

type InputError

type InputError struct {
	Engine  string
	Feature string
	Reason  string
}

InputError reports a named input the engine refuses to leave free, and why.

func (*InputError) Error

func (e *InputError) Error() string

Error names the engine, the feature and the reason.

func (*InputError) Is

func (e *InputError) Is(target error) bool

Is matches ErrInput.

type InputNotFreeError

type InputNotFreeError struct {
	Engine  string
	Feature string
}

InputNotFreeError names the input an engine's witness fixed that the question had bound.

func (*InputNotFreeError) Error

func (e *InputNotFreeError) Error() string

Error names the engine and the input.

func (*InputNotFreeError) Is

func (e *InputNotFreeError) Is(target error) bool

Is matches ErrInputNotFree.

type JobsError

type JobsError struct {
	Source string
	Value  string
}

JobsError reports a jobs setting no plan can run under: the value as written and where it was written, the variable or the flag.

func (*JobsError) Error

func (e *JobsError) Error() string

Error names the source and the value, and what a usable one is.

func (*JobsError) Is

func (e *JobsError) Is(target error) bool

Is matches ErrJobs.

type Kind

type Kind int

Kind is what a question asks of its subject.

const (
	// Evaluate asks for one execution under stated bindings and a stated
	// scheduling policy: a calc, a case, a behavior, or a condition on a subject.
	Evaluate Kind = iota
	// Outcomes asks what a behavior can do over every schedule.
	Outcomes
	// Holds asks whether a condition holds over a behavior or a case, with the
	// schedule and/or the unbound inputs free within stated bounds.
	Holds
	// Sensitive asks whether a behavior's result depends on its schedule.
	Sensitive
	// Satisfiable asks whether some assignment to the unbound features meets a
	// set of conditions.
	Satisfiable
	// Sweep asks a calc or case once per row of a domain the rows enumerate or sample.
	Sweep
	// Compute asks an external tool once, as an action annotated ToolExecution names it.
	Compute
)

func CheckKind

func CheckKind(check *CheckAsk, holds *HoldsAsk, unroll int) Kind

CheckKind is what a check asks: Sensitive once a feature is named to compare across the schedules; else Holds once a property or condition is stated, an input released, an assumption made or the unroll bound set (what a symbolic engine alone answers or reads); else Outcomes.

func ParseKind

func ParseKind(text string) (Kind, bool)

ParseKind reads a kind of question as Kind.String spells it.

func (Kind) String

func (k Kind) String() string

String names the kind as a plan spells it.

type Linearization

type Linearization func(*runtime.Context) (runtime.Outcome, error)

Linearization runs the behavior once in a fresh context under the context's schedule, in the shape runtime.Explore drives.

type Listing

type Listing struct {
	Status
	Description
	Origin
	// Withheld is the typed reason the registry lists the engine but does not run it; nil
	// when it is served.
	Withheld error
}

Listing is one engine as -engines, %engines and ListEngines report it: its capability declaration beside the state of its process and where it comes from.

func (Listing) Kinds

func (l Listing) Kinds() string

Kinds spells the question kinds the engine answers, comma-separated.

func (Listing) OriginText

func (l Listing) OriginText() string

OriginText is the manifest entry's source line, empty for a built-in engine: `spin-bridge 1.4.0: engine from /etc/opensysml/engines/spin-bridge.json, runs /opt/spin-bridge/bin/spin-bridge, not admitted`.

func (Listing) Ready

func (l Listing) Ready() bool

Ready reports whether the engine can run: it is served, and it needs no process or its process is found.

func (Listing) Served

func (l Listing) Served() bool

Served reports whether the registry runs the engine when a question reaches it.

func (Listing) StatusText

func (l Listing) StatusText() string

StatusText is the engine's state in a word: `ready`, `ready (z3 at /usr/bin/z3)`, `unavailable: <why>` or `withheld: <why>`.

type MalformedQuestionError

type MalformedQuestionError struct {
	Kind Kind
	// Missing names the field the kind needs.
	Missing string
}

MalformedQuestionError reports a question whose kind's ask is missing.

func (*MalformedQuestionError) Error

func (e *MalformedQuestionError) Error() string

Error names the kind and the field.

func (*MalformedQuestionError) Is

func (e *MalformedQuestionError) Is(target error) bool

Is matches ErrMalformedQuestion.

type Manifest

type Manifest struct {
	// Dir is the directory read.
	Dir string
	// Env names the variable that named Dir.
	Env string
	// Tools are the `tool` entries.
	Tools []ToolEntry
	// Engines are the `engine`, `policy` and `sampler` entries.
	Engines []EngineEntry
}

Manifest is what one manifest directory registers, each list in name order.

func ManifestsFromEnv

func ManifestsFromEnv(workspaces ...string) ([]*Manifest, error)

ManifestsFromEnv reads both manifest directories the environment names, OPENSYSML_TOOLS then OPENSYSML_ENGINES, skipping one unset and refusing one under a workspace; a manifest that cannot be read is a ManifestError.

func ReadManifest

func ReadManifest(dir, env string, workspaces ...string) (*Manifest, error)

ReadManifest reads the manifest in dir, named by the environment variable env: every `.json` file is one entry of the kind its `kind` field says, `tool` when absent. Every fault is a ManifestError; a duplicate name among entries of one kind is one too. A dir under one of the workspaces is refused unread: a manifest comes from the environment, never from a workspace or a model.

func (*Manifest) Externals

func (m *Manifest) Externals() []External

Externals is the manifest's entries as engines: its tools, then its engines.

type ManifestError

type ManifestError struct {
	// Env names the variable that named the directory; ToolsEnv when empty.
	Env string
	// Path is the directory or the entry file at fault.
	Path string
	// Detail is what is wrong.
	Detail string
	// Err is the fault as the file system or the decoder reported it, when one did.
	Err error
}

ManifestError reports one fault in a manifest: the directory or entry it is in and what is wrong with it.

func (*ManifestError) Error

func (e *ManifestError) Error() string

Error names the variable, the path and the fault.

func (*ManifestError) Is

func (e *ManifestError) Is(target error) bool

Is matches ErrManifest.

func (*ManifestError) Unwrap

func (e *ManifestError) Unwrap() error

Unwrap returns the underlying report.

type Manifested

type Manifested interface {
	External
	Origin() Origin
}

Manifested is an engine registered from a manifest entry, which reports its origin.

func NewEngine

func NewEngine(entry EngineEntry) Manifested

NewEngine is the engine of a manifest entry: registered whether or not this build serves it, listing the typed reason through Process and refusing every question through Covers.

type Mode

type Mode int

Mode is how a plan chooses the engines it puts a question to.

const (
	// SelectAuto puts the question to the strongest covering engine, and to the
	// next on a not-covered result; the plan names each.
	SelectAuto Mode = iota
	// SelectNamed puts the question to exactly one engine; its refusal or
	// not-covered result is the result.
	SelectNamed
	// SelectAll puts the question to every covering engine, in name order, and
	// composes what they answered.
	SelectAll
)

type Model

type Model struct {
	// Context is the surface's own runtime over the model; nil when the surface holds none.
	Context func() (*runtime.Context, error)
	// Semantics builds a worker's own model-derived part — resolver, semantic model and
	// the runtime's memo tables — over the shared frozen index.
	Semantics func() (*runtime.Model, error)
	// Fresh builds a run's own context on a worker, under the surface's limits.
	Fresh func(*Worker) (*runtime.Context, error)
	// contains filtered or unexported fields
}

Model is the model a question is about, reached through the runtime contexts a surface builds over it: an evaluation runs in the surface's own where it holds one, every other run in a context of the run's own, on the worker the plan builds (see Worker).

func Held

func Held(ctx *runtime.Context) *Model

Held is the model as a surface reaches it through a context it holds: an execution runs in ctx, under its limits, and no run of its own is built.

func (*Model) NewContext

func (m *Model) NewContext(budget Budget) (*runtime.Context, error)

NewContext builds a run's own context on the plan's first worker, taking the budget's Steps as MaxSteps and Memory as MaxElements; a zero field, like every other bound, keeps Fresh's.

func (*Model) NewContextOn

func (m *Model) NewContextOn(job int, budget Budget) (*runtime.Context, error)

NewContextOn builds a run's own context on the plan's worker for job, under the budget as NewContext takes it.

func (*Model) Worker

func (m *Model) Worker() (*Worker, error)

Worker is the plan's first worker, the one every run of a plan under one job is made on.

func (*Model) WorkerAt

func (m *Model) WorkerAt(job int) (*Worker, error)

WorkerAt is the plan's worker for job, built on first use and kept for every later run under that job; the plan's jobs run concurrently, each on a worker of its own.

type ModelForm

type ModelForm string

ModelForm is one form of the model an engine reads.

const (
	// FormSources is every document of the model as text with the library version.
	FormSources ModelForm = "sources"
	// FormRDF is the model as Turtle; defined, served by a later stage.
	FormRDF ModelForm = "rdf"
)

func GraphsForm

func GraphsForm(v int) ModelForm

GraphsForm is the `graphs:<v>` form at version v.

func (ModelForm) GraphsVersion

func (f ModelForm) GraphsVersion() (int, bool)

GraphsVersion reads the version of a `graphs:<v>` form; false for any other form.

type NoEngineError

type NoEngineError struct {
	Kind Kind
}

NoEngineError reports a kind no registered engine declares.

func (*NoEngineError) Error

func (e *NoEngineError) Error() string

Error names the kind.

func (*NoEngineError) Is

func (e *NoEngineError) Is(target error) bool

Is matches ErrNoEngine.

type NoReplayError

type NoReplayError struct {
	Engine string
	Kind   Kind
}

NoReplayError names the question a schedule witness cannot be replayed for.

func (*NoReplayError) Error

func (e *NoReplayError) Error() string

Error names the engine and the question's kind.

func (*NoReplayError) Is

func (e *NoReplayError) Is(target error) bool

Is matches ErrNoReplay.

type NoRuntimeError

type NoRuntimeError struct {
	Engine string
}

NoRuntimeError reports an engine refusing a model that builds no context its runs need.

func (*NoRuntimeError) Error

func (e *NoRuntimeError) Error() string

Error names the engine.

func (*NoRuntimeError) Is

func (e *NoRuntimeError) Is(target error) bool

Is matches ErrNoRuntime.

type NotAskedError

type NotAskedError struct {
	Engine string
	Kind   Kind
}

NotAskedError reports a question of a kind the engine does not answer.

func (*NotAskedError) Error

func (e *NotAskedError) Error() string

Error names the engine and the kind.

func (*NotAskedError) Is

func (e *NotAskedError) Is(target error) bool

Is matches ErrNotAsked.

type NotExternalError

type NotExternalError struct {
	Name string
	// Known lists the manifest engines that can be served.
	Known []string
}

NotExternalError reports a name asked to be served that names no manifest engine: a built-in, a tool or nothing at all.

func (*NotExternalError) Error

func (e *NotExternalError) Error() string

Error names the engine and the ones that could have been meant.

func (*NotExternalError) Is

func (e *NotExternalError) Is(target error) bool

Is matches ErrNotExternal.

type NotServedError

type NotServedError struct {
	Name string
	Kind EntryKind
	// Reason names what the entry needs that this build does not have.
	Reason string
}

NotServedError reports an entry a later build serves: listed with the reason, never run.

func (*NotServedError) Error

func (e *NotServedError) Error() string

Error names the entry and the reason.

func (*NotServedError) Is

func (e *NotServedError) Is(target error) bool

Is matches ErrNotServed.

type Origin

type Origin struct {
	// Kind is the manifest entry's kind; empty for a built-in engine.
	Kind EntryKind
	// Version is the entry's.
	Version string
	// File is the manifest entry; Command the executable it resolved to.
	File    string
	Command string
	// Transport and Protocol are an engine entry's; empty and zero for a tool.
	Transport string
	Protocol  int
}

Origin is where an engine comes from: the build for one built in, otherwise the manifest entry that registered it and what it runs.

func (Origin) KindText

func (o Origin) KindText() string

KindText names the origin's kind as a listing prints it: `built-in` for the build's own.

func (Origin) ProtocolText

func (o Origin) ProtocolText() string

ProtocolText names how the engine is spoken to: `-` for one built in, `object` for a tool's one JSON object each way, `<transport>/<protocol>` for an engine entry.

type OverclaimError

type OverclaimError struct {
	Engine    string
	Claimed   Strength
	Authority Strength
}

OverclaimError reports a result whose strength exceeds what its engine's Description says it can earn: a defect in the engine, never a stronger answer.

func (*OverclaimError) Error

func (e *OverclaimError) Error() string

Error names the engine and the two strengths.

func (*OverclaimError) Is

func (e *OverclaimError) Is(target error) bool

Is matches ErrOverclaim.

type Performance

type Performance func(*runtime.Context) (Answer, error)

Performance makes one execution in the given context and reports what it established. An error is a fault, not a failed execution, which is an Answer claiming nothing.

type Plan

type Plan struct {
	Question  Question
	Selection Selection
	Steps     []Step
	// Result is the first covered answer under auto or a named engine, and the
	// composition of every finished engine's answer under all; when no engine
	// covered the question it is the last not-covered result, or one naming
	// every refusal.
	Result Result
	// Disagreements are the contradictions the composition under all resolved,
	// each in the interpreter's favor; empty under auto or a named engine.
	Disagreements []Disagreement
	// Workers is how many workers the plan built over every fleet its engines ran on, and
	// Warming the time building them took, summed.
	Workers int
	Warming time.Duration
}

Plan is how a question was answered: the selection made, every engine consulted in the order the selection ranks them, and the answer that stood.

func Perform

func Perform[T any](
	ctx context.Context,
	r *Registry,
	req Request,
	call func(*runtime.Context) (T, error),
	answer func(T, error) Answer,
) (T, Plan, error)

Perform puts one execution (call, in the request's model's context) to the registry; answer says what it established. A dispatch fault or refusal is the execution's error, and the plan is how it was answered.

func (Plan) Refusals

func (p Plan) Refusals() []error

Refusals is every pre-run refusal in the plan, in step order.

func (Plan) Refused

func (p Plan) Refused() error

Refused is the typed error for a plan no engine ran: every refusal it met. It is nil when some engine ran, whatever it answered.

func (Plan) Results

func (p Plan) Results() []Result

Results is every result the plan's engines answered, in step order, a demoted one as demoted; nil when no engine ran.

func (Plan) Standing

func (p Plan) Standing() string

Standing is the plan's result's standing, followed by the plan when it consulted more than one engine or was made under all: `; all: run holds (observed), solve refused (…)`.

type Prober

type Prober interface {
	External
	Probe() (string, error)
}

Prober is an engine that can start its process once to check it against its manifest, as -engines -probe asks; Probe answers as Process does, after the handshake.

type ProcessAbsentError

type ProcessAbsentError struct {
	Engine string
	// Process is what the engine needs, as its Description names it.
	Process string
	// Err is the probe's own report of the absence.
	Err error
}

ProcessAbsentError reports an external engine whose process was not found.

func (*ProcessAbsentError) Error

func (e *ProcessAbsentError) Error() string

Error is the probe's own report, which already names what is absent and how to supply it; without one, Engine and Process say whose need it is.

func (*ProcessAbsentError) Is

func (e *ProcessAbsentError) Is(target error) bool

Is matches ErrProcessAbsent.

func (*ProcessAbsentError) Unwrap

func (e *ProcessAbsentError) Unwrap() error

Unwrap returns the probe's report.

type ProgressReport

type ProgressReport struct {
	Engine   string
	Progress enginewire.ProgressParams
}

ProgressReport is one coalesced progress notification of an external engine's run.

type ProtocolError

type ProtocolError struct {
	Engine string
	Detail string
}

ProtocolError reports a line the host could not take as a message: not JSON, no jsonrpc member, no id, a member of the wrong type, an error code outside the protocol's, a line or standard error over the output bound, a witness of the wrong kind. The session is ended with it.

func (*ProtocolError) Error

func (e *ProtocolError) Error() string

Error names the engine and what broke.

func (*ProtocolError) Is

func (e *ProtocolError) Is(target error) bool

Is matches ErrProtocol.

type Question

type Question struct {
	Kind Kind
	// Subject names the element asked about, as the surface spelled it.
	Subject string
	// Schedule is the scheduling policy the question states: the one an
	// evaluation runs under, or the exploring one whose budget bounds outcomes.
	Schedule runtime.SchedulePolicy
	// Free is what the question leaves open.
	Free Freedom
	// Perform makes the one execution an Evaluate question asks for.
	Perform Performance
	// Linearize makes one run of the behavior an Outcomes question asks about,
	// in a context of the run's own.
	Linearize Linearization
	// Sweep is the domain and the row of a Sweep question.
	Sweep *SweepAsk
	// Solve is the queries of a Satisfiable question and how each is asked.
	Solve *SolveAsk
	// Holds is the behavior, the condition and the start of one run of a Holds question.
	Holds *HoldsAsk
	// Compute is the tool invocation a Compute question asks for.
	Compute *ComputeAsk
	// Check is the action an Outcomes or Holds question asks the check engine to
	// search the schedules of, with what must hold and what may not diverge.
	Check *CheckAsk
}

Question is what is asked, independently of who answers it: a subject, what is asked of it, what is fixed and what is free, and the ask for its kind saying how one unit is made.

type RefusedError

type RefusedError struct {
	Kind     Kind
	Refusals []error
}

RefusedError reports a question every engine declaring its kind refused.

func (*RefusedError) Error

func (e *RefusedError) Error() string

Error is the one refusal's text when one engine refused, else every refusal named by its engine.

func (*RefusedError) Unwrap

func (e *RefusedError) Unwrap() []error

Unwrap exposes each refusal to errors.Is and errors.As.

type Registry

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

Registry holds the engines one owner answers with. There is no package-level registry: a binary builds one with Default, a test with NewRegistry, and neither sees the other's.

func Default

func Default() *Registry

Default returns a registry of the framework's own engines: run, explore, check, sweep and solve. Solve registers whether or not a solver is found and refuses through Covers. The build's registry, which adds the engines of other packages, is engines.Default.

func DefaultFromEnv

func DefaultFromEnv(workspaces ...string) (*Registry, error)

DefaultFromEnv returns the default registry with every entry of the manifests OPENSYSML_TOOLS and OPENSYSML_ENGINES name: one `tool:<name>` engine per tool entry and one engine per engine, policy or sampler entry. A manifest that cannot be read, or lies under one of the workspaces, is a ManifestError. Each registers whether or not its executable is found or this build serves it, and refuses through Covers; a name registered twice across the manifests is a DuplicateEngineError.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty registry.

func (*Registry) Answer

func (r *Registry) Answer(ctx context.Context, model *Model, q Question, budget Budget) (Plan, error)

Answer answers q under `auto`: engines of q's kind strongest first, a refusal or a not-covered result advancing (and kept in the plan), an error from Run stopping the plan. A Deadline in the budget bounds the plan through ctx; meeting it is an error like any other, checked before each engine is consulted and before an answer is taken from it. The plan works on a copy of model, so its worker is its own and model is never written.

func (*Registry) AnswerWith

func (r *Registry) AnswerWith(ctx context.Context, model *Model, q Question, budget Budget, selection Selection) (Plan, error)

AnswerWith answers q under the selection: as Answer does under auto; putting it to one engine alone under a named selection, whose refusal or not-covered result is the result; and under all to every covering engine, up to the budget's Jobs of them at once with the Jobs shared out among them, composing what they answered as if they had run one after another in name order. Under all a deadline met cancels the engine that met it and every one not finished, each named in the plan with the bound it reached, and the finished engines' results stand composed; only a plan no engine finished fails with the deadline. The plan works on copies of model, one fleet of workers per engine under all, so model is never written.

func (*Registry) Check

func (r *Registry) Check(ctx context.Context, req Request, kind Kind, free Freedom, check *CheckAsk, holds *HoldsAsk, run Linearization) (Plan, error)

Check puts an action's schedules to the registry as a question of kind, free being what the asker leaves open beside them: check is the explicit-state search's ask, holds the symbolic one, and run performs the action once for an engine exploring it. A Holds or Sensitive question over a start leaving an input unbound has the inputs free too.

func (*Registry) Engines

func (r *Registry) Engines() []Engine

Engines returns every registered engine in name order.

func (*Registry) Explore

func (r *Registry) Explore(ctx context.Context, req Request, run Linearization) (Plan, error)

Explore puts a behavior's outcomes to the registry: run performs it once per linearization the request's schedule asks for, each in a context its model makes. The plan's result holds the Exploration reached.

func (*Registry) External

func (r *Registry) External() []Manifested

External is the engine's manifest entries: every Manifested engine that is not a tool.

func (*Registry) Listings

func (r *Registry) Listings() []Listing

Listings lists every engine in name order with its description, status and origin; no process is started.

func (*Registry) Names

func (r *Registry) Names() []string

Names is every registered engine's name, in name order.

func (*Registry) Probed

func (r *Registry) Probed() []Listing

Probed lists as Listings does, but starts each external engine's process once and checks its handshake against its manifest, reporting the outcome as the status.

func (*Registry) Register

func (r *Registry) Register(e Engine) error

Register adds an engine; a second engine with the same name is a typed error, not a silent replacement.

func (*Registry) Select

func (r *Registry) Select(text string) (Selection, error)

Select parses a selection and checks that a named engine is registered and served, so a misspelling or a withheld engine is refused where it is written rather than run as a refusal.

func (*Registry) Serving

func (r *Registry) Serving(names []string) (*Registry, error)

Serving returns the registry as a service runs it: every manifest engine not named is withheld — listed, refused when selected or reached — and `all` names every one. A name that is not a manifest engine is a NotExternalError; tools and built-ins are served as they are.

func (*Registry) Solve

func (r *Registry) Solve(ctx context.Context, req Request, queries []*solve.Query, ask Asking) (Plan, error)

Solve puts an element's condition sets to the registry under the request's selection, ask being the operation made of each; the request's model is what an engine outside the process is sent, nil when there is none. The plan's result holds the answers in order, and the error is an absent solver.

func (*Registry) Statuses

func (r *Registry) Statuses() []Status

Statuses lists every engine in name order with the state of its process.

func (*Registry) Sweep

func (r *Registry) Sweep(ctx context.Context, req Request, plan runtime.SweepPlan, row runtime.SweepRun) (Plan, error)

Sweep puts a domain to the registry: row runs the subject once per row of the plan, each in a context of its own the request's model builds; the answered plan's result tables the rows.

func (*Registry) ToolRunner

func (r *Registry) ToolRunner(ctx context.Context, held *runtime.Context, budget Budget, selection Selection) runtime.ToolRunner

ToolRunner is the runner a surface attaches to a context it drives outside any plan — the prompt's action debugger — so a tool-computed action it steps is put to the registry as a Compute question under the selection, as one performed inside a plan is. Divergence between equal-input answers is remembered for as long as the runner is attached.

type Reporter

type Reporter func(ProgressReport)

Reporter takes the progress reports a plan's external engines send, at most one per ProgressInterval per open run; the surface that installs one prints them.

func ReporterFrom

func ReporterFrom(ctx context.Context) Reporter

ReporterFrom is the reporter WithReporter installed, nil when none was.

type Request

type Request struct {
	Model     *Model
	Subject   string
	Schedule  runtime.SchedulePolicy
	Budget    Budget
	Selection Selection
}

Request is what every question put to the registry carries: the model it is asked of, the subject and schedule it runs under, and the budget and selection it is answered with.

type Result

type Result struct {
	Question Question
	// Engine names who answered, and its version where it has one.
	Engine string
	// Claim is what is asserted.
	Claim Claim
	// Strength is how the claim is supported.
	Strength Strength
	// Bounds is every bound the run took, and which were reached.
	Bounds Bounds
	// Witness is a schedule the interpreter replays, when the claim has one.
	Witness *Witness
	// Contrast is the second schedule of a sensitivity: replayed beside Witness, it gives the
	// named feature another value. Nil for every other claim.
	Contrast *Witness
	// Executions are the concrete executions a universal claim was observed on when an
	// engine chose them and the interpreter replayed each; nil when none were.
	Executions []Witness
	// Inputs are the features of the initial state a symbolic engine ranged over
	// or pinned, each with its domain and, for a witness, its value.
	Inputs []Input
	// Assumptions name the constraints assumed over the initial state.
	Assumptions []string
	// Reason says why, when nothing is claimed: the construct, the unknown,
	// the budget, the disagreement.
	Reason string
	// Values are the feature values, outputs, rows or answers the question asked for.
	Values []Evaluation
	// Reply is what an external process answered, spelt canonically, when the engine ran one
	// for a Compute; invocations of equal inputs compare by it.
	Reply   string
	Elapsed time.Duration
	// Workers is how many workers the plan built for the engine's runs, and Warming the
	// time building them took; a plan in the surface's own context builds none.
	Workers int
	Warming time.Duration
}

Result is what one engine answered to one question.

func (Result) Check

func (r Result) Check() *Checked

Check is what the check engine found, nil for another engine's result.

func (Result) Covered

func (r Result) Covered() bool

Covered reports whether the result claims anything.

func (Result) Exploration

func (r Result) Exploration() *runtime.Exploration

Exploration is the outcome set an Outcomes result reached, nil for any other result.

func (Result) Standing

func (r Result) Standing() string

Standing is the line a report prints after a verdict: the claim, the strength it earned, and what earned it — `holds (observed: 1 run under reverse)`, `not covered (<reason>)`.

func (Result) Table

func (r Result) Table() runtime.SweepTable

Table is the rows of a Sweep result as runtime.RunSweep tables them.

type Selection

type Selection struct {
	Mode Mode
	// Engine is the one engine a SelectNamed selection puts the question to.
	Engine string
}

Selection is the engine choice a surface makes: `auto`, `all`, or one engine by name.

func All

func All() Selection

All is the selection that runs every covering engine.

func Auto

func Auto() Selection

Auto is the selection every surface makes when none is stated.

func Only

func Only(engine string) Selection

Only is the selection of the one engine named.

func ParseSelection

func ParseSelection(text string) Selection

ParseSelection reads a selection as a flag spells it; empty is `auto`, which is what an unset field means on the wire.

func (Selection) String

func (s Selection) String() string

String spells the selection as a flag takes it: `auto`, `all`, or the engine's name.

type SessionEndedError

type SessionEndedError struct {
	Engine string
	Err    error
}

SessionEndedError reports a request after the session ended, with why it ended.

func (*SessionEndedError) Error

func (e *SessionEndedError) Error() string

Error names the engine and the end.

func (*SessionEndedError) Is

func (e *SessionEndedError) Is(target error) bool

Is matches ErrSessionEnded.

func (*SessionEndedError) Unwrap

func (e *SessionEndedError) Unwrap() error

Unwrap is why the session ended.

type SolveAsk

type SolveAsk struct {
	Queries []*solve.Query
	Ask     Asking
}

SolveAsk is the queries a satisfiability question puts to a solver, one per condition set, and how each is asked.

type Start

type Start func(*runtime.Context) (*runtime.ActionExecutor, error)

Start begins one run of a behavior in the given context and returns the executor about to run it. An error is a fault of the start, not an outcome of the run.

type Status

type Status struct {
	Engine string
	// Process names the process found; empty for an in-process engine or an absent one.
	Process string
	// Err is the absence of the process, nil when the engine can run.
	Err error
}

Status is an engine as the registry lists it: for one that needs a process, the process found or the typed error for its absence.

type Step

type Step struct {
	Engine string
	// Refusal is why Covers refused, nil when the engine ran.
	Refusal error
	// Result is what Run answered, nil when the engine refused, faulted or was cancelled.
	Result *Result
	// Err is the fault that stopped the plan at this engine: what Run reported, or the
	// context's error when it was met before the engine ran or before its answer was taken.
	Err error
	// Cancelled marks an engine the plan under all stopped before it answered: the one
	// that met the deadline, and every one not finished by then.
	Cancelled bool
	// Bounds is the bound a cancelled engine reached: the plan's deadline, when one was set.
	Bounds Bounds
}

Step is one engine's part in a plan: a refusal before running, the result it answered, the fault that stopped the plan, or its cancellation under all.

func (Step) Standing

func (s Step) Standing() string

Standing is one step as the plan's standing lists it: what the engine answered, refused with, faulted on, or was cancelled at.

type Strength

type Strength int

Strength is how a claim is supported, ranked so a greater Strength is never weaker evidence: Proved > Bounded > Witnessed (the one strength of an existential) > Observed > NotCovered.

const (
	// NotCovered claims nothing: a refusal, a solver unknown, a budget reached
	// without completing, a witness that did not replay.
	NotCovered Strength = iota
	// Observed means the claim held on the concrete executions that were run,
	// which fixed something the question left free.
	Observed
	// Witnessed means a concrete execution exhibits the claim and the
	// interpreter has replayed it.
	Witnessed
	// Bounded means the claim holds for everything free within the stated
	// bounds, which the result names.
	Bounded
	// Proved means the claim holds for everything the question left free, with
	// no bound reached.
	Proved
)

func ParseStrength

func ParseStrength(text string) (Strength, bool)

ParseStrength reads a strength as Strength.String spells it.

func (Strength) String

func (s Strength) String() string

String names the strength as a report prints it.

type SubjectError

type SubjectError struct {
	Engine   string
	Subject  string
	Family   string
	Subjects []string
}

SubjectError reports a question about a subject whose declaration kind is outside the entry's subjects; Family is the kind found, empty for a subject the model does not declare.

func (*SubjectError) Error

func (e *SubjectError) Error() string

Error names the engine, the subject with its kind, and the kinds the engine answers for.

func (*SubjectError) Is

func (e *SubjectError) Is(target error) bool

Is matches ErrSubject.

type SweepAsk

type SweepAsk struct {
	Plan runtime.SweepPlan
	Row  runtime.SweepRun
}

SweepAsk is the plan of a sweep and the run of one row of it.

type ToolAbsentError

type ToolAbsentError struct {
	Tool       string
	Executable string
	Err        error
}

ToolAbsentError reports a registered tool whose executable is not found.

func (*ToolAbsentError) Error

func (e *ToolAbsentError) Error() string

Error names the tool and its executable.

func (*ToolAbsentError) Is

func (e *ToolAbsentError) Is(target error) bool

Is matches ErrToolAbsent.

func (*ToolAbsentError) Unwrap

func (e *ToolAbsentError) Unwrap() error

Unwrap returns the lookup's report.

type ToolEntry

type ToolEntry struct {
	// File is the manifest entry the tool was read from; empty for one built in code.
	File string `json:"-"`
	// Kind is `tool` or absent.
	Kind EntryKind `json:"kind,omitempty"`
	// ToolName is what a ToolExecution's toolName names.
	ToolName string `json:"toolName"`
	// Version is the tool's, reported beside its executable.
	Version string `json:"version,omitempty"`
	// Executable runs the tool: an absolute path, a path relative to the manifest directory,
	// or a name looked up on PATH.
	Executable string `json:"executable"`
	// Variables are the ToolVariable names the tool accepts.
	Variables []string `json:"variables"`
}

ToolEntry is one entry of the tool manifest: the tool a ToolExecution names, its version, the executable that answers for it, and the tool-variable names it accepts.

func LoadManifest

func LoadManifest(dir string) ([]ToolEntry, error)

LoadManifest reads the tool entries of the manifest in dir: every `.json` file is one entry. A directory that cannot be read, an entry that is not one JSON object of its kind's fields, an entry without a toolName, executable or variables, one listing a variable twice, or two entries naming one tool is a ManifestError. Entries come back in tool-name order; entries of the other kinds are read and checked but not returned.

func (ToolEntry) Accepts

func (e ToolEntry) Accepts(variable string) bool

Accepts reports whether the tool accepts the tool variable named.

type ToolVariableError

type ToolVariableError struct {
	Tool      string
	Variables []string
}

ToolVariableError reports the tool variables a call uses that the tool's entry does not list.

func (*ToolVariableError) Error

func (e *ToolVariableError) Error() string

Error names the tool and the variables.

func (*ToolVariableError) Is

func (e *ToolVariableError) Is(target error) bool

Is matches ErrToolVariable.

type UnansweredRunError

type UnansweredRunError struct {
	Engine   string
	Progress enginewire.ProgressParams
	Err      error
}

UnansweredRunError is why a run ended unanswered, with the last progress it reported.

func (*UnansweredRunError) Error

func (e *UnansweredRunError) Error() string

Error names the end and the last progress.

func (*UnansweredRunError) Is

func (e *UnansweredRunError) Is(target error) bool

Is matches ErrUnansweredRun.

func (*UnansweredRunError) Unwrap

func (e *UnansweredRunError) Unwrap() error

Unwrap is the end itself.

type UnknownEngineError

type UnknownEngineError struct {
	Name string
	// Known is every registered name, so the message can list the choices.
	Known []string
}

UnknownEngineError reports a selection naming an engine the registry does not hold.

func (*UnknownEngineError) Error

func (e *UnknownEngineError) Error() string

Error names the engine and lists the registered ones.

func (*UnknownEngineError) Is

func (e *UnknownEngineError) Is(target error) bool

Is matches ErrUnknownEngine.

type WireValueError

type WireValueError struct {
	Name string
	Held string
}

WireValueError names a value the protocol does not carry.

func (*WireValueError) Error

func (e *WireValueError) Error() string

Error names the value and what it holds.

func (*WireValueError) Is

func (e *WireValueError) Is(target error) bool

Is matches ErrWireValue.

type Withheld

type Withheld interface {
	Engine
	Withheld() error
}

Withheld is an engine a registry lists but does not run, with the typed reason.

type Witness

type Witness struct {
	Schedule runtime.SchedulePolicy
	Inputs   []runtime.InputTaken
	Choices  []runtime.ChoiceTaken
	// Written is the file the witness was written to, "" when none was asked for.
	Written string
}

Witness is an execution the interpreter replays to exhibit a claim: the policy it ran under, the inputs it fixed before its first move and the choices it took.

type WitnessKind

type WitnessKind string

WitnessKind is the shape of witness an engine's manifest declares it produces.

const (
	// WitnessNone declares no replayable witness; an existential claim is then not covered.
	WitnessNone WitnessKind = "none"
	// WitnessSchedule declares schedule witnesses in the replay format.
	WitnessSchedule WitnessKind = "schedule"
	// WitnessAssignment declares assignment witnesses: values of the free features.
	WitnessAssignment WitnessKind = "assignment"
)

type Worker

type Worker struct {
	Model *runtime.Model
	// Warming is the time building the worker took: the cost of one more worker.
	Warming time.Duration
}

Worker is one model-derived runtime part — resolver, semantic model and the runtime's memo tables — over the shared frozen index; all memoize into plain maps, so a worker serves one plan's runs, one at a time, and never another plan's.

type WrongToolError

type WrongToolError struct {
	Engine string
	Tool   string
}

WrongToolError reports a Compute question put to the engine of a tool it does not name.

func (*WrongToolError) Error

func (e *WrongToolError) Error() string

Error names the engine and the tool the call named.

func (*WrongToolError) Is

func (e *WrongToolError) Is(target error) bool

Is matches ErrWrongTool.

Directories

Path Synopsis
Package enginewire is the message set an external engine and the host exchange over standard input and output: JSON-RPC 2.0 objects, one per line.
Package enginewire is the message set an external engine and the host exchange over standard input and output: JSON-RPC 2.0 objects, one per line.

Jump to

Keyboard shortcuts

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