repl

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: 49 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 repl implements an interactive SysML v2 read-eval-print loop as a thin frontend over model.Workspace (spec §13).

Index

Constants

This section is empty.

Variables

View Source
var ErrEnginesArgument = errors.New("%engines takes `probe` or nothing")

ErrEnginesArgument is the typed error for a %engines argument other than `probe`.

Functions

func ExpandPaths

func ExpandPaths(paths []string) ([]string, error)

ExpandPaths turns the paths a caller was given — files, directories to walk for .sysml/.kerml files, or glob patterns — into the model files to load, in a deterministic order and without duplicates.

func Loop

func Loop(r LineReader, out io.Writer, s *Session) error

Loop runs the read/eval/print cycle until the reader returns io.EOF (Ctrl-D).

Types

type AmbiguousMachineError added in v0.5.0

type AmbiguousMachineError struct {
	Object  string // the object, as objectMention prints it
	Machine string // the definition asked for, as typed
	// Usages are the exhibited usages running it, in declaration order, as the
	// prompt prints names; "" for one without a name.
	Usages []string
}

AmbiguousMachineError reports a state definition an object exhibits as the body of several usages, so naming the definition names no one machine.

func (*AmbiguousMachineError) Error added in v0.5.0

func (e *AmbiguousMachineError) Error() string

type AmbiguousNameError

type AmbiguousNameError struct {
	Name string
	FQNs []string
}

AmbiguousNameError reports a name that matched more than one declaration. It is distinct from a name found nowhere: a command may look elsewhere for the latter, but must never answer about one of several candidates.

func (*AmbiguousNameError) Error

func (e *AmbiguousNameError) Error() string

type AmbiguousSubjectError

type AmbiguousSubjectError struct {
	Name     string
	Carriers []string
}

AmbiguousSubjectError reports a feature or condition several of the session's objects carry, so which one an answer would be about is a question.

func (*AmbiguousSubjectError) Error

func (e *AmbiguousSubjectError) Error() string

type Behavior added in v0.7.0

type Behavior struct {
	Name      string
	Performer []string
}

Behavior names a behavior to run and, after it, the object performing it, as `-action`/`-state` take them: `Drive rover1`.

type Completion

type Completion struct {
	Candidates []string
	Prefix     string
}

Completion answers a completion request: the words that can replace the one being typed, and the part of it already typed, which every candidate starts with.

type Diagnostic

type Diagnostic struct {
	Severity string
	Message  string
	// File is the loaded file the finding is in, empty for typed input, and Line
	// and Column place it within that file rather than within the session buffer.
	File   string
	Line   int
	Column int
	// Pass names what produced the finding, and Code what it found.
	Pass string
	Code string
}

Diagnostic is one finding about the session's model, located in it, for a caller reporting analysis as data rather than as the prompt's text.

type EnginesArgumentError added in v0.8.0

type EnginesArgumentError struct {
	Args []string
}

EnginesArgumentError reports what %engines was given instead.

func (*EnginesArgumentError) Error added in v0.8.0

func (e *EnginesArgumentError) Error() string

Error names the arguments.

func (*EnginesArgumentError) Is added in v0.8.0

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

Is matches ErrEnginesArgument.

type Evaluation added in v0.7.0

type Evaluation struct {
	Function  string
	Arguments []string
	Result    string
	Error     string
	Selected  bool
	Tied      bool
}

Evaluation is one application of a case's calc as a function value: what it was applied to, what it computed or failed with, and whether the case returned its argument (selected) or passed it over for one evaluating alike (tied).

type ExhibitorsError added in v0.5.0

type ExhibitorsError struct {
	Machine string          // the machine asked for, as the prompt prints names
	Types   []string        // the types declaring an exhibit of it, in declaration order, as the prompt prints names
	Objects []RelatedObject // the held objects exhibiting it, in walk order; none when no object does
}

ExhibitorsError reports a machine `%state <machine>` alone cannot attach to: no held object exhibits it, or several do, so no one running performance is meant.

func (*ExhibitorsError) Error added in v0.5.0

func (e *ExhibitorsError) Error() string

type ExploreAtPromptError added in v0.7.0

type ExploreAtPromptError struct {
	Policy runtime.SchedulePolicy
}

ExploreAtPromptError reports `%schedule explore` at the prompt, whose debuggers step one run; exploration belongs to the CLI or the wire.

func (*ExploreAtPromptError) Error added in v0.7.0

func (e *ExploreAtPromptError) Error() string

type ExploredObjectError added in v0.7.0

type ExploredObjectError struct {
	Ref string
}

ExploredObjectError reports an object reference an exploration cannot follow: every explored run creates its objects afresh, so it names declarations only.

func (*ExploredObjectError) Error added in v0.7.0

func (e *ExploredObjectError) Error() string

type InstantiationReport

type InstantiationReport struct {
	Lines []string
	// FeatureValueErrors are the feature values that could not be materialized, in the order they
	// were read: a default whose value count does not conform to the feature's
	// multiplicity is one.
	FeatureValueErrors []string
	// Bounded is true when materialization stopped short — at its budget, or at
	// nesting it does not descend into — so the feature values it did not reach were not
	// checked rather than found clean.
	Bounded bool
}

InstantiationReport is what creating an object produced: the lines a caller prints, and the diagnostics materializing the object's feature values reported.

type LineReader

type LineReader interface {
	ReadLine(prompt string) (string, error)
}

LineReader yields input lines; the prompt argument switches between primary and continuation prompts. Implemented by a readline adapter in cmd, and by a slice in tests. ReadLine returns io.EOF at end of input.

type LoadReport

type LoadReport struct {
	Loaded   []string // the files read, when more than one was
	Found    []string // diagnostics and the notes that belong with them
	Declared []string // what the load declared, empty if the analysis errored
	Errors   bool     // whether the analysis found an error
}

LoadReport is what a load produced, in parts so a caller can keep what the analysis found off the stream it prints results on.

type NamedValue

type NamedValue struct {
	Name  string
	Value string
}

NamedValue is one value a check or a run produced, formatted as the prompt prints it: a calculation's result, an action's output, a machine's state.

type NoEnginesError added in v0.8.0

type NoEnginesError struct{}

NoEnginesError reports a session given no registry to put its questions to.

func (*NoEnginesError) Error added in v0.8.0

func (e *NoEnginesError) Error() string

type NotInstantiatedError added in v0.5.0

type NotInstantiatedError struct {
	Name string // the name asked for, as the prompt prints names
	// Definition is the definition the objects in Objects are of, "" when none.
	Definition string
	// Objects are the related objects, in carrier order.
	Objects []RelatedObject
	// UsageAsked reports that Name is a usage, so Objects are of its definition
	// rather than of the usage; otherwise Name is a definition Objects are typed by.
	UsageAsked bool
}

NotInstantiatedError reports a declared name no object has been created under. When objects of the definition that name is typed by (or, for a definition, objects of usages typed by it) exist, it says so and names what to instantiate.

func (*NotInstantiatedError) Error added in v0.5.0

func (e *NotInstantiatedError) Error() string

type ObjectPathError added in v0.5.0

type ObjectPathError struct {
	Object  string
	Segment string
	Detail  string
	// Err is what kept the segment's feature value from materializing, nil when
	// the segment reached a value that is no object or no feature at all.
	Err error
}

ObjectPathError reports a segment of an object reference that names no object of the one before it: Object is that object as the REPL reports it, Segment the offending segment as typed.

func (*ObjectPathError) Error added in v0.5.0

func (e *ObjectPathError) Error() string

func (*ObjectPathError) Unwrap added in v0.5.0

func (e *ObjectPathError) Unwrap() error

type ObjectRefError added in v0.5.0

type ObjectRefError struct {
	Ref    string
	Detail string
	// Named is the `::`-joined run of names read before a character no unquoted
	// name holds stopped the text: `T::SA` in `T::SA-506`.
	Named string
	// Hint is what Named may have meant, appended to the report.
	Hint string
}

ObjectRefError reports text that is no object reference at all.

func (*ObjectRefError) Error added in v0.5.0

func (e *ObjectRefError) Error() string

type Origin

type Origin struct {
	Name   string
	Offset int
}

Origin locates one file of a submission in the buffer, so a diagnostic is reported against that file and its own line numbering.

type ReadError added in v0.4.3

type ReadError struct {
	Path string
	Err  error
}

ReadError is a file a load could not read, under the name it is reported by.

func (*ReadError) Error added in v0.4.3

func (e *ReadError) Error() string

Error names the path once: the read error repeats it and so does every caller that wraps this.

func (*ReadError) Unwrap added in v0.4.3

func (e *ReadError) Unwrap() error

type RelatedObject added in v0.5.0

type RelatedObject struct {
	ID    int64
	Label string
}

RelatedObject names an object the session holds, by id and by the label it is reached under — "" for one only its id reaches.

type RenderedDocument added in v0.4.2

type RenderedDocument struct {
	Name     string
	FileName string
	Content  string
}

RenderedDocument is one document of a rendered multi-document set, rendered in one backend's form.

type Result

type Result struct {
	Members     []ast.Node          // top-level members of the <repl> AST (Task 5 renders these)
	Declared    []string            // names introduced by THIS submission
	Diagnostics []passes.Diagnostic // eager analysis over the whole buffer
	Source      string              // the full joined <repl> content (Task 6 caret rendering)
	Offset      int                 // byte offset in Source where THIS submission begins
	Origins     []Origin            // the files of THIS submission, in buffer order
	Notices     []string            // side effects of the submission, e.g. a debugging session it ended

	// Blocked names the unresolved error that stopped the deeper checks from
	// running over this submission, nil when they ran or when the session already
	// reported that error.
	Blocked *blocker
	// contains filtered or unexported fields
}

Result is the outcome of one Submit: the top-level members parsed from the accumulated buffer (for the success summary), the names this submission declared, and any analysis diagnostics over the whole <repl> document.

type Session

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

Session accumulates submissions into a single implicit <repl> document.

func NewSession

func NewSession() *Session

NewSession returns a session over a fresh workspace.

func (*Session) Budgets

func (s *Session) Budgets() runtime.Budgets

Budgets returns the bounds this session gives its runtime contexts.

func (*Session) CheckAssume added in v0.8.0

func (s *Session) CheckAssume() []string

CheckAssume returns the constraints and requirements a check assumes over the initial state.

func (*Session) CheckBounds added in v0.8.0

func (s *Session) CheckBounds() (depth, states, unroll int, timeout time.Duration)

CheckBounds returns the search bounds a check runs under: depth, states and unroll, 0 for the engines' defaults, and the timeout, 0 for none.

func (*Session) CheckConstraint

func (s *Session) CheckConstraint(name string) Verdict

CheckConstraint evaluates a constraint definition, against the object that carries it when one has been created, so the verdict is about concrete values.

func (*Session) CheckDiverge added in v0.8.0

func (s *Session) CheckDiverge() []string

CheckDiverge returns the features a check compares the final values of; none compares every attribute of the action and of its performing object.

func (*Session) CheckInputs added in v0.8.0

func (s *Session) CheckInputs() []string

CheckInputs returns the features a check leaves free although the model binds them.

func (*Session) CheckProperties added in v0.8.0

func (s *Session) CheckProperties() []string

CheckProperties returns the constraints and requirements a check evaluates at every stable state.

func (*Session) CheckRequirement

func (s *Session) CheckRequirement(name string) Verdict

CheckRequirement evaluates a requirement definition, against the object that carries it when one has been created.

func (*Session) CheckSatisfy

func (s *Session) CheckSatisfy(name string) []Verdict

CheckSatisfy evaluates satisfaction assertions: every one the model states when name is empty, or, given a name, the ones the named element states — or that element itself, when it is a named satisfaction assertion. The usual `assert satisfy r by p;` is anonymous, so the element stating it is how a caller reaches it.

func (*Session) CheckSolve

func (s *Session) CheckSolve(name string) []SolveReport

CheckSolve asks a solver whether the named constraint, requirement or satisfaction can be satisfied at all. Experimental: SysML v2 defines no solving.

func (*Session) CheckWitnessDir added in v0.8.0

func (s *Session) CheckWitnessDir() string

CheckWitnessDir returns where a check writes its witnesses, "" for nowhere.

func (*Session) Clear

func (s *Session) Clear() []string

Clear resets the session, dropping all accumulated declarations. It returns the notices for what the reset took with it.

func (*Session) CompileCalc added in v0.5.0

func (s *Session) CompileCalc(name string) (*codegen.Program, error)

CompileCalc compiles the named calc def and every calc it invokes to the codegen IR. The error names the construct that kept a calc from compiling.

func (*Session) Complete

func (s *Session) Complete(line string, pos int) Completion

Complete offers the words that can continue line at byte offset pos: the meta commands where a command is being typed, file paths where %load and %save take one, and otherwise the names the session and the library declare.

func (*Session) ConfigureVariants

func (s *Session) ConfigureVariants(name string, args []string) []SolveReport

ConfigureVariants answers about the variants an element's conditions permit: with no selection it synthesises a consistent one, with selections `variation=variant` it checks the ones given, and with `all` it enumerates consistent selections up to the bound (limit, when a count follows `all`). Experimental, and read-only: no object is created and no variant is bound.

func (*Session) ConformanceMode added in v0.2.0

func (s *Session) ConformanceMode() conformance.Mode

ConformanceMode reports the strictness the session judges notation at.

func (*Session) DiagnosticLines

func (s *Session) DiagnosticLines() []string

DiagnosticLines reports the analysis of everything submitted so far as the prompt prints it: the source line each finding is on, under a position naming the file the finding is in, at the verbosity the session was asked for.

func (*Session) Diagnostics

func (s *Session) Diagnostics() []passes.Diagnostic

Diagnostics reports the analysis of everything submitted so far, including the syntax errors of a submission masked out of the buffer for not closing its own text: a load whose file does not parse says why, and HasErrors is true, which is what a non-interactive run exits on.

func (*Session) Engine added in v0.8.0

func (s *Session) Engine() analysis.Selection

Engine returns the engine selection every question the session asks is made under.

func (*Session) Engines added in v0.8.0

func (s *Session) Engines() []analysis.Listing

Engines lists the registered engines with their authority, the questions each answers and the state of its process, as `%engines` prints them.

func (*Session) EvalBare added in v0.4.2

func (s *Session) EvalBare(expr string) ([]string, error)

EvalBare evaluates a prompt line read as an expression, recording a failed materialization so a piped run's exit status reports it, as %eval does.

func (*Session) EvalExpr

func (s *Session) EvalExpr(expr string) ([]string, error)

EvalExpr evaluates an expression and returns the lines `%eval` prints, with an error for one that could not be evaluated.

func (*Session) ExplainSolve

func (s *Session) ExplainSolve(name string) []SolveReport

ExplainSolve asks a solver which of an element's conditions conflict, for a constraint, requirement or satisfaction. Experimental: SysML v2 defines no solving, and the runtime evaluator remains normative.

func (*Session) HasErrors

func (s *Session) HasErrors() bool

HasErrors reports whether the session found the model wrong: something analysis found, or a feature value a command could not materialize. It is what a non-interactive run exits on.

func (*Session) InstantiateNamed

func (s *Session) InstantiateNamed(name string) ([]string, error)

InstantiateNamed creates an object of the named definition and keeps it, so a later check about that name is a check about this object. It returns the lines `%instantiate` prints, and an error for a name the session cannot resolve or an instantiation the runtime rejected.

func (*Session) InstantiateReport

func (s *Session) InstantiateReport(name string) (InstantiationReport, error)

InstantiateReport creates the named object and materializes its feature values, so a non-interactive caller reports what materialization found rather than leaving it to whoever reads a feature value next. An object that cannot be created at all is an error; a feature value that cannot be materialized is a finding about the model.

func (*Session) Jobs added in v0.8.0

func (s *Session) Jobs() int

Jobs returns how many runs of one plan the session lets go concurrently.

func (*Session) List

func (s *Session) List() []string

List returns a one-line summary per surviving snippet.

func (*Session) LoadFile

func (s *Session) LoadFile(path string) ([]string, error)

LoadFile submits the contents of path to the session and returns the lines `%load` prints. A lone "-" reads standard input. The error is the file it could not read; a model that read but did not analyse cleanly is reported by Diagnostics.

func (*Session) LoadFileSummary

func (s *Session) LoadFileSummary(path string) ([]string, error)

LoadFileSummary submits the contents of path and returns only what it declared, without what analysis has found so far. A caller loading a model that spans several files reports the analysis once every file is in, a reference from one file to another resolving only then.

func (*Session) LoadFilesSummary added in v0.4.3

func (s *Session) LoadFilesSummary(paths []string) ([]string, error)

LoadFilesSummary is LoadFileSummary over every path as one submission, indexed and analyzed once, each file still summarized on its own; a read failure is a *ReadError.

func (*Session) LoadPaths

func (s *Session) LoadPaths(paths []string) ([]string, error)

LoadPaths loads model files into the session. Each path names a file, a directory to walk for .sysml/.kerml files, a glob pattern, or standard input as a lone "-", whose contents are reported as <stdin>. Every file is accepted before the buffer is analyzed, so the order files are loaded in does not affect name resolution: a file may reference a declaration another file loaded after it makes. Diagnostics name the file they belong to and count lines from its start.

func (*Session) LoadPathsReport

func (s *Session) LoadPathsReport(paths []string) (LoadReport, error)

LoadPathsReport loads model files as LoadPaths does, reporting what the analysis found apart from what the load declared.

func (*Session) LocatedDiagnostics

func (s *Session) LocatedDiagnostics() []Diagnostic

LocatedDiagnostics reports the analysis of everything submitted so far, each finding placed in the submission it is about: the file it was loaded from, at the line and column that file has it on.

func (*Session) MaterializationFailures

func (s *Session) MaterializationFailures() []error

MaterializationFailures reports the feature values the session's commands could not materialize, in the order they were reported: a command that rendered one answered nothing about that feature value.

func (*Session) OptimizeSolve

func (s *Session) OptimizeSolve(name string) []SolveReport

OptimizeSolve asks a solver for the best values an analysis case's objectives admit, over the conditions the case requires or assumes. Experimental: SysML v2 defines no solving, and the runtime evaluator remains normative.

func (*Session) Query added in v0.2.0

func (s *Session) Query(text string) ([]string, error)

Query evaluates OSLC element-identification query text and renders one matched element per line for the interactive frontend.

func (*Session) RenderDocumentHTML added in v0.5.0

func (s *Session) RenderDocumentHTML(invocation string, opts docrender.HTMLOptions) (string, error)

RenderDocumentHTML compiles the named document definition, evaluates its queries against the session's model, and renders the result as HTML.

func (*Session) RenderDocumentMarkdown added in v0.4.2

func (s *Session) RenderDocumentMarkdown(invocation string, opts docrender.MarkdownOptions) (string, error)

RenderDocumentMarkdown compiles the named document definition, evaluates its queries against the session's model, and renders the result as Markdown. A document binds its queries' parameters in the model, so the invocation is the document's name alone.

func (*Session) RenderDocumentSetHTML added in v0.5.0

func (s *Session) RenderDocumentSetHTML(opts docrender.HTMLOptions) ([]RenderedDocument, error)

RenderDocumentSetHTML renders the same set as linked HTML files, each referring to the others by their .html file names.

func (*Session) RenderDocumentSetMarkdown added in v0.4.2

func (s *Session) RenderDocumentSetMarkdown(opts docrender.MarkdownOptions) ([]RenderedDocument, error)

RenderDocumentSetMarkdown compiles every document definition the session's model declares, evaluates them together, and renders each as Markdown with its deterministic file name, so cross-document references link on disk.

func (*Session) RunAction

func (s *Session) RunAction(name string, performer ...string) Verdict

RunAction runs an action to completion outside the prompt, on the object performer names when it names one. An action that could not be run, or that stopped short of completing, is unresolved: it produced no outputs to judge.

func (*Session) RunAnalysis added in v0.6.0

func (s *Session) RunAnalysis(invocation string) Verdict

RunAnalysis runs an analysis case outside the prompt and returns what it computed and decided. invocation is what `%analysis` takes: a name, optionally carrying arguments as `Case(3.0, limit = 4.0)`, then the object that is its subject. Its status is the worst its objective and assertions decided.

func (*Session) RunCalc

func (s *Session) RunCalc(invocation string) Verdict

RunCalc invokes a calculation and returns what it computed. invocation is what `%calc` takes: a name, optionally followed by its arguments or carrying them as `Fall(3, 4)`.

func (*Session) RunDocumentQuery added in v0.4.2

func (s *Session) RunDocumentQuery(invocation string) Verdict

RunDocumentQuery compiles the named document query, binds its entry parameters and executes it. invocation is what `%run-query` takes: a name followed by `<parameter>=<expression>` bindings.

func (*Session) RunFor added in v0.7.0

func (s *Session) RunFor(actions, states []Behavior, duration float64) []Verdict

RunFor starts the behaviors named, advances their shared clock by duration once and returns one verdict per behavior (an action holds when it completed in time). Under the check engine the behaviors are one invocation, every schedule of which up to that instant is searched: one verdict for them all.

func (*Session) RunMeta

func (s *Session) RunMeta(line string) (out []string, quit bool, err error)

runMeta executes a meta command line. Returns lines to print, whether to quit, and an error only for unrecoverable I/O (unknown commands print guidance). RunMeta executes a meta-command (e.g., %eval, %load) and returns the output lines, a quit flag, and any error encountered.

func (*Session) RunSamples added in v0.7.0

func (s *Session) RunSamples(invocation string, ranges []string, count int64, seed uint64) Verdict

RunSamples runs one invocation once per drawn row, drawing count values for each range from seed. The same seed draws the same table.

func (*Session) RunStateMachine

func (s *Session) RunStateMachine(name string, performer ...string) Verdict

RunStateMachine starts a state machine outside the prompt, taking only its initial transition, which is `%state` alone. The values are the configuration the machine settled in. Under the check engine the machine's whole run is searched instead, its timers advanced until nothing more is due.

func (*Session) RunStateMachineFor

func (s *Session) RunStateMachineFor(name string, duration float64, performer ...string) Verdict

RunStateMachineFor starts a state machine and advances it by duration time units, which is `%state` followed by `%advance`. A duration of 0 is a run to the current time, dispatching the events already due, as `%advance 0` is. Under the check engine every schedule up to that instant is searched.

func (*Session) RunSweep added in v0.7.0

func (s *Session) RunSweep(invocation string, ranges []string) Verdict

RunSweep runs one invocation once per row of the ranges given and reports the table. invocation is what `%analysis` and `%calc` take; each range is written `<parameter>=<from>..<to>[:<step>]`.

func (*Session) Schedule added in v0.7.0

func (s *Session) Schedule() runtime.SchedulePolicy

Schedule returns the policy runs started from here on resolve their choice points under.

func (*Session) SetBudgets

func (s *Session) SetBudgets(budgets runtime.Budgets) error

SetBudgets sets the bounds for runtime contexts created from here on, dropping the current one with its objects and the debuggers driving it, which the next command reports. It errors on a non-positive bound, which no run could make progress under.

func (*Session) SetCheckAssume added in v0.8.0

func (s *Session) SetCheckAssume(names []string)

SetCheckAssume names the constraints and requirements a check assumes over the initial state; each is resolved when the check runs.

func (*Session) SetCheckBounds added in v0.8.0

func (s *Session) SetCheckBounds(depth, states, unroll int, timeout time.Duration)

SetCheckBounds sets the search bounds a check runs under; 0 keeps the engines' default for depth, states and unroll, and no clock for the timeout.

func (*Session) SetCheckDiverge added in v0.8.0

func (s *Session) SetCheckDiverge(features []string)

SetCheckDiverge names the features a check compares the final values of.

func (*Session) SetCheckInputs added in v0.8.0

func (s *Session) SetCheckInputs(features []string)

SetCheckInputs names the features a check leaves free although the model binds them; each is resolved when the check runs.

func (*Session) SetCheckProperties added in v0.8.0

func (s *Session) SetCheckProperties(names []string)

SetCheckProperties names the constraints and requirements a check evaluates at every stable state; each is resolved when the check runs.

func (*Session) SetCheckWitnessDir added in v0.8.0

func (s *Session) SetCheckWitnessDir(dir string)

SetCheckWitnessDir names where a check writes its witnesses, one file per violation and per divergent value; "" writes none.

func (*Session) SetConformanceMode added in v0.2.0

func (s *Session) SetConformanceMode(mode conformance.Mode)

SetConformanceMode switches what the session asks of its model: whether notation no SysML v2 production admits is a warning or an error. It takes effect at once — the buffer is re-analyzed on the next request.

func (*Session) SetEngine added in v0.8.0

func (s *Session) SetEngine(text string) error

SetEngine selects the engine questions asked from here on are put to: `auto`, `all`, or one engine by name. A name no engine is registered under is a typed error.

func (*Session) SetEngines added in v0.8.0

func (s *Session) SetEngines(engines *analysis.Registry) error

SetEngines replaces the registry the session's questions are put to, keeping the selection where the registry still knows it. A nil registry is refused.

func (*Session) SetJobs added in v0.8.0

func (s *Session) SetJobs(jobs int) error

SetJobs sets how many runs of one plan go concurrently from here on. The held context, its objects and the debuggers keep going: jobs bound a plan's runs, not the session's context. A value below one is a typed error.

func (*Session) SetProgress added in v0.8.0

func (s *Session) SetProgress(w io.Writer)

SetProgress names where the progress external engines report while a plan runs is printed — the CLI's standard error; a nil writer prints none, the default.

func (*Session) SetRenderWidth added in v0.1.1

func (s *Session) SetRenderWidth(width int)

SetRenderWidth sets the width a text rendering's table is written to fit. The frontend sets it from the terminal; view.WidthUnbounded, the default, writes every column as wide as its widest cell.

func (*Session) SetSchedule added in v0.7.0

func (s *Session) SetSchedule(policy runtime.SchedulePolicy) error

SetSchedule sets the policy for runs started from here on; a debugger under way keeps its own, and `explore` runs on contexts of their own.

func (*Session) SetTracing

func (s *Session) SetTracing(on bool)

SetTracing turns recording of execution steps on or off. It takes effect at once, on the session's runtime context and on a debugging session already under way as well as on everything created afterwards.

func (*Session) SetVerbosity

func (s *Session) SetVerbosity(v Verbosity)

SetVerbosity sets the session's output level.

func (*Session) SolveValues

func (s *Session) SolveValues(name string) []SolveReport

SolveValues asks a solver for values satisfying the named constraint, requirement or satisfaction, with the values the model already fixes — held by an object of the session, else declared — asserted, so only what is still free is synthesised. Experimental: SysML v2 defines no solving, and the runtime evaluator remains normative. Read-only: no object is created.

func (*Session) Submit

func (s *Session) Submit(src string) Result

Submit accumulates src into the <repl> document, reindexes and eagerly analyzes the whole buffer, and returns a Result. A submission with parse errors is still accumulated, so its diagnostics are reported against the live session context; one that leaves a brace, comment or quoted name open is masked out of the buffer instead, since it would otherwise absorb the next submission. A later redeclaration of the same name replaces the prior snippet (see accept).

func (*Session) SubmitAll

func (s *Session) SubmitAll(srcs []string) Result

SubmitAll accumulates every src as one submission, from no file in particular.

func (*Session) SubmitFiles

func (s *Session) SubmitFiles(files []SourceFile) Result

SubmitFiles accumulates every file as one submission: all of them are accepted before the buffer is reindexed and analyzed, so a declaration in one resolves against the others no matter which order they arrive in. This is what makes loading a multi-file project order-independent.

func (*Session) Tracing

func (s *Session) Tracing() bool

Tracing reports whether execution steps are being recorded.

func (*Session) Verbosity

func (s *Session) Verbosity() Verbosity

Verbosity reports the session's current output level.

func (*Session) View

func (s *Session) View(name string) ([]string, error)

View reports what a view exposes, the views nested in it, and whether it conforms to the viewpoints it satisfies. A view exposing nothing says so; an element that is no view is semantics.ErrNotAView.

func (*Session) ViewRendering

func (s *Session) ViewRendering(name string) (*view.Rendering, error)

ViewRendering renders a view of the session's model. It reads the session's symbols and creates nothing in it: no object, no runtime, no change to a debugging session in progress.

func (*Session) Views added in v0.3.1

func (s *Session) Views() ([]model.ViewInfo, error)

Views lists every view the session declares, in document then declaration order.

type SolveReport

type SolveReport struct {
	// Subject is what was checked, spelled as the caller named it.
	Subject string
	Status  SolveStatus
	Lines   []string
	// Solver names the solver that answered, empty when none did.
	Solver string
	// Plan is how the engines answered; nil for a report made before any was asked.
	Plan *analysis.Plan
}

SolveReport is what a solver answered about one element, with the lines the REPL prints for it.

func (SolveReport) Satisfiable

func (r SolveReport) Satisfiable() bool

Satisfiable reports whether the solver found the conditions satisfiable.

type SolveStatus

type SolveStatus int

SolveStatus is what a solver answered about an element's conditions. It is kept apart from VerdictStatus: satisfiability is not evaluation.

const (
	// SolveSat means an assignment satisfying the conditions exists.
	SolveSat SolveStatus = iota
	// SolveUnsat means no assignment satisfies them.
	SolveUnsat
	// SolveUnknown means the solver did not decide: it timed out, or gave up on
	// arithmetic it cannot decide.
	SolveUnknown
	// SolveUnbounded means the conditions are satisfiable but an objective
	// improves without limit, so it has no optimum.
	SolveUnbounded
	// SolveNoOptimum means the conditions are satisfiable and an objective's
	// optimum was not established: only a bound, or an unverified answer.
	SolveNoOptimum
	// SolveUnavailable means nothing was asked: no solver is installed, the
	// element is outside the translatable subset, or the solver failed.
	SolveUnavailable
)

func (SolveStatus) String

func (s SolveStatus) String() string

String names the status for a report a machine reads.

type SourceFile

type SourceFile struct {
	Name string
	Text string
}

SourceFile is one source of a submission together with the file it was read from, which is what diagnostics over a multi-file load are reported against.

type SweptArgumentError added in v0.8.0

type SweptArgumentError struct {
	Arg string
	Err error
}

SweptArgumentError reports an argument whose value no row of a sweep can carry into a context of its own.

func (*SweptArgumentError) Error added in v0.8.0

func (e *SweptArgumentError) Error() string

func (*SweptArgumentError) Unwrap added in v0.8.0

func (e *SweptArgumentError) Unwrap() error

type SweptObjectError added in v0.8.0

type SweptObjectError struct {
	Ref    string
	Reason string
	Err    error
}

SweptObjectError reports a held object no row can make its own of: its state cannot be imaged into a context of its own. Err is the runtime's reason where it gave one.

func (*SweptObjectError) Error added in v0.8.0

func (e *SweptObjectError) Error() string

func (*SweptObjectError) Unwrap added in v0.8.0

func (e *SweptObjectError) Unwrap() error

type UnknownObjectIDError added in v0.5.0

type UnknownObjectIDError struct {
	ID    int64
	Known []int64
	// Err is what kept the connector a carry-over set aside under ID from being
	// materialized again, nil when no object was ever there.
	Err error
}

UnknownObjectIDError reports an id no object of the session has, with the ids that do exist so the reader can pick one.

func (*UnknownObjectIDError) Error added in v0.5.0

func (e *UnknownObjectIDError) Error() string

func (*UnknownObjectIDError) Unwrap added in v0.5.0

func (e *UnknownObjectIDError) Unwrap() error

type UnplannedObjectError added in v0.8.0

type UnplannedObjectError struct {
	Ref string
}

UnplannedObjectError reports an object name an explored run asked for that its plan did not resolve: runs name only what was planned while the session was held.

func (*UnplannedObjectError) Error added in v0.8.0

func (e *UnplannedObjectError) Error() string

type Verbosity

type Verbosity int

Verbosity selects how much of a submission's analysis reaches the terminal.

The REPL analyses the whole accumulated buffer on every submission, which is what the runtime needs but not what a user typing one declaration wants to read. Verbosity scopes the report back down to what was just typed.

const (
	// VerbosityQuiet reports only errors in the submission just made.
	VerbosityQuiet Verbosity = iota
	// VerbosityNormal adds warnings in that submission. The default.
	VerbosityNormal
	// VerbosityDebug reports every diagnostic over the whole buffer, at
	// buffer-absolute positions and with the pass that produced it.
	VerbosityDebug
)

func ParseVerbosity

func ParseVerbosity(s string) (Verbosity, error)

ParseVerbosity maps a flag or %verbosity argument to a level.

func (Verbosity) String

func (v Verbosity) String() string

type Verdict

type Verdict struct {
	// Subject is what was checked, spelled as the caller named it.
	Subject string
	Status  VerdictStatus
	Lines   []string
	// Values are what a run produced, for a caller reporting more than a status.
	Values []NamedValue
	// Verifications are the verdicts the bodies of the verification cases
	// verifying the checked requirement answered, reported beside its status
	// rather than deciding it.
	Verifications []VerificationVerdict
	// Rows are the runs a sweep made, one per row of its table; no other kind of
	// verdict has any.
	Rows []VerdictRow
	// Evaluations are the applications an analysis case made of its own calcs as
	// function values — a trade study's evaluation of each alternative — in the
	// order made.
	Evaluations []Evaluation
	// Outcomes are the distinct outcomes an exploration reached, in canonical
	// order, and Exploration how it ended; only an explored run has them.
	Outcomes    []VerdictOutcome
	Exploration *VerdictExploration
	// Plan is how the engines answered: the selection made, each engine put to
	// the question and what it answered, and the composed result whose standing
	// the last line reports. Nil for a verdict decided before any engine was asked.
	Plan *analysis.Plan
}

Verdict is the outcome of one checked constraint, requirement or satisfaction assertion. It carries both the status a caller decides on (an exit code, a report) and the lines the REPL prints, so the prompt and a non-interactive caller always report the same verdict from the same evaluation.

func (Verdict) Holds

func (v Verdict) Holds() bool

Holds reports whether the checked condition is satisfied.

type VerdictExploration added in v0.7.0

type VerdictExploration struct {
	Complete bool
	Runs     int
	// BudgetsHit names the budgets hit, `runs` before `depth`; none when complete.
	BudgetsHit []string
}

VerdictExploration is how an exploration ended: whether every linearization within the budget was run, and which budget stopped it when not.

type VerdictOutcome added in v0.7.0

type VerdictOutcome struct {
	Values []NamedValue
	// Error is what stopped the runs reaching this outcome, empty for one they completed.
	Error          string
	Linearizations int
	// Witness is one run's choice sequence, a choice per entry in run order.
	Witness []string
}

VerdictOutcome is one distinct outcome an exploration reached: what the runs reaching it produced, how many did, and the choices of one that did.

type VerdictRow added in v0.7.0

type VerdictRow struct {
	Inputs      []NamedValue
	Outputs     []NamedValue
	Verdicts    []NamedValue
	Evaluations []Evaluation
	Millis      float64
	Error       string
}

VerdictRow is one run of a sweep: what it was given, what it produced and decided, how long it took, and what stopped it when it failed.

type VerdictStatus

type VerdictStatus int

VerdictStatus is what a checked condition answered.

const (
	// VerdictHolds is a condition the model satisfies.
	VerdictHolds VerdictStatus = iota
	// VerdictFails is a condition the model answered false.
	VerdictFails
	// VerdictUnresolved is a check that was never decided — an unknown name, a
	// session with no declarations, an element stating no assertion, an
	// evaluation that could not be carried out — which is a question about the
	// model, not an answer from it.
	VerdictUnresolved
)

func WorstStatus

func WorstStatus(verdicts []Verdict) VerdictStatus

WorstStatus is the status a set of verdicts should be judged by: unresolved outranks a failure, since a check that was never made says nothing about the model. An empty set holds.

func (VerdictStatus) String

func (s VerdictStatus) String() string

String names the status for a report a machine reads.

type VerificationVerdict added in v0.7.0

type VerificationVerdict struct {
	// Case is the qualified name of the verification case that ran.
	Case string
	// Kind is the VerdictKind literal the body produced.
	Kind string
	// Detail is why an error or inconclusive verdict decided nothing.
	Detail string
	// Subcase marks a case another case performed as a step of its body.
	Subcase bool
}

VerificationVerdict is the verdict the body of a verification case answered, reported beside the requirement or satisfaction verdict of the requirement the case verifies. It does not decide that verdict: the specification leaves the evaluation of a verdict unspecified, so this is what running the body and the library's own PassIf calculation answer.

Jump to

Keyboard shortcuts

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