engine

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 31 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 engine is an in-process engine over SysML text. It serves the execution RPCs of SysMLService — ParseSources, Evaluate, Instantiate, ExecuteAction and ExecuteState — with the same proto3 JSON answers as default-capabilities sysml-grpc, and also serves RenderView. The engine's RenderView JSON keeps its drawing shape (flattened fill/border and optional x/y/width/height), not the protojson of RenderViewResponse. WebAssembly clients decode the execution results with generated types they already hold, and no protobuf runtime is linked in, which keeps the js/wasm build small.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine serves the execution RPCs of SysMLService over protojson-shaped JSON. Calls are handled sequentially in the caller's goroutine — deterministic and free of locking — so an Engine is not safe for concurrent use.

func New

func New() (*Engine, error)

New builds an engine over the frozen standard library snapshot, under the runtime budgets a default sysml-grpc NewService runs with.

func NewWithLibrary

func NewWithLibrary(index *symbols.Index, src libs.Source, maxModels int) (*Engine, error)

NewWithLibrary builds an engine over a shared standard library snapshot. A nonpositive maxModels disables automatic eviction.

func (*Engine) Call

func (e *Engine) Call(ctx context.Context, method string, params []byte) (result []byte, err error)

Call runs the method named — a method name of SysMLService — on params, the protojson request body, and returns the protojson response body. A name the engine does not serve is refused Unimplemented, and a request that does not decode InvalidArgument, matching what stdiorpc's DiscardUnknown decode means by each.

func (*Engine) Evict

func (e *Engine) Evict(hash string)

Evict removes a cached model; absent hashes are ignored.

func (*Engine) Serve

func (e *Engine) Serve(ctx context.Context, r io.Reader, w io.Writer) error

Serve reads Content-Length-delimited frames from r and writes answers to w until r reaches its end, speaking the JSON half of stdiorpc's protocol: the same framing, envelope and error codes, with a protobuf frame refused since this product carries no protobuf. Calls are handled sequentially and answered in order.

type Error

type Error = jsonrpc.Error

Error is a refused call: the canonical status code and its message.

type F64

type F64 float64

F64 is a proto3 double under protojson: a number, or the strings "NaN", "Infinity" and "-Infinity" that protojson uses where JSON has no spelling.

func (F64) MarshalJSON

func (v F64) MarshalJSON() ([]byte, error)

MarshalJSON writes the number, or the protojson string for a non-finite one.

func (*F64) UnmarshalJSON

func (v *F64) UnmarshalJSON(data []byte) error

UnmarshalJSON reads the number, or one of the protojson non-finite spellings.

type I64

type I64 int64

I64 is a proto3 int64/uint64 under protojson: on the wire a decimal string. Input accepts the string or, as protojson does, the bare number.

func (I64) MarshalJSON

func (v I64) MarshalJSON() ([]byte, error)

MarshalJSON writes the decimal string protojson writes.

func (*I64) UnmarshalJSON

func (v *I64) UnmarshalJSON(data []byte) error

UnmarshalJSON reads the decimal string, or the bare number.

type JArray

type JArray struct {
	Dimensions []I64     `json:"dimensions,omitempty"`
	Elements   []*JValue `json:"elements,omitempty"`
}

type JComplex

type JComplex struct {
	Real      F64 `json:"real,omitempty"`
	Imaginary F64 `json:"imaginary,omitempty"`
}

type JDiagnostic

type JDiagnostic = fsyntax.Diagnostic

JDiagnostic is the Diagnostic message, shaped in frontend/syntax where the syntactic command answers with it too.

type JEnumLiteral

type JEnumLiteral struct {
	LiteralId     string  `json:"literalId,omitempty"`
	EnumerationId string  `json:"enumerationId,omitempty"`
	Name          string  `json:"name,omitempty"`
	Value         *JValue `json:"value,omitempty"`
}

type JEvaluateRequest

type JEvaluateRequest struct {
	ModelHash       string `json:"modelHash,omitempty"`
	Expression      string `json:"expression,omitempty"`
	ContextSymbolId string `json:"contextSymbolId,omitempty"`
	SubjectSymbolId string `json:"subjectSymbolId,omitempty"`
}

type JEvaluateResponse

type JEvaluateResponse struct {
	Result      *JValue        `json:"result,omitempty"`
	Error       string         `json:"error,omitempty"`
	Diagnostics []*JDiagnostic `json:"diagnostics,omitempty"`
}

type JExecuteActionRequest

type JExecuteActionRequest struct {
	ModelHash         string             `json:"modelHash,omitempty"`
	ActionSymbolId    string             `json:"actionSymbolId,omitempty"`
	Inputs            map[string]*JValue `json:"inputs,omitempty"`
	Schedule          string             `json:"schedule,omitempty"`
	PerformerSymbolId string             `json:"performerSymbolId,omitempty"`
}

type JExecuteActionResponse

type JExecuteActionResponse struct {
	Outputs             map[string]*JValue `json:"outputs,omitempty"`
	Error               string             `json:"error,omitempty"`
	Diagnostics         []*JDiagnostic     `json:"diagnostics,omitempty"`
	FinalTime           F64                `json:"finalTime,omitempty"`
	PerformerAttributes map[string]*JValue `json:"performerAttributes,omitempty"`
}

type JExecuteStateRequest

type JExecuteStateRequest struct {
	ModelHash            string   `json:"modelHash,omitempty"`
	StateMachineSymbolId string   `json:"stateMachineSymbolId,omitempty"`
	Events               []string `json:"events,omitempty"`
	Schedule             string   `json:"schedule,omitempty"`
	PerformerSymbolId    string   `json:"performerSymbolId,omitempty"`
	Trace                bool     `json:"trace,omitempty"`
}

type JExecuteStateResponse

type JExecuteStateResponse struct {
	StatesVisited []string           `json:"statesVisited,omitempty"`
	FinalContext  map[string]*JValue `json:"finalContext,omitempty"`
	Error         string             `json:"error,omitempty"`
	Diagnostics   []*JDiagnostic     `json:"diagnostics,omitempty"`
	FinalTime     F64                `json:"finalTime,omitempty"`
	Trace         []JTraceEvent      `json:"trace,omitempty"`
	TraceDropped  int                `json:"traceDropped,omitempty"`
}

type JFeatureValue

type JFeatureValue struct {
	FeatureName  string    `json:"featureName,omitempty"`
	Value        *JValue   `json:"value,omitempty"`
	Values       []*JValue `json:"values,omitempty"`
	Materialized bool      `json:"materialized,omitempty"`
	Error        string    `json:"error,omitempty"`
}

JFeatureValue is the FeatureValue message.

type JFunction

type JFunction struct {
	CalcId string `json:"calcId,omitempty"`
	SelfId I64    `json:"selfId,omitempty"`
}

type JInstance

type JInstance struct {
	Id            I64                       `json:"id,omitempty"`
	TypeSymbolId  string                    `json:"typeSymbolId,omitempty"`
	FeatureValues map[string]*JFeatureValue `json:"featureValues,omitempty"`
}

JInstance is the Instance message.

type JInstantiateRequest

type JInstantiateRequest struct {
	ModelHash string `json:"modelHash,omitempty"`
	SymbolId  string `json:"symbolId,omitempty"`
}

type JInstantiateResponse

type JInstantiateResponse struct {
	Instance    *JInstance     `json:"instance,omitempty"`
	Error       string         `json:"error,omitempty"`
	Diagnostics []*JDiagnostic `json:"diagnostics,omitempty"`
	Instances   []*JInstance   `json:"instances,omitempty"`
}

type JMeasurementRef

type JMeasurementRef struct {
	Unit     string     `json:"unit,omitempty"`
	UnitTerm *JUnitTerm `json:"unitTerm,omitempty"`
	UnitId   string     `json:"unitId,omitempty"`
}

type JMetaobject

type JMetaobject struct {
	ElementId   string `json:"elementId,omitempty"`
	MetaclassId string `json:"metaclassId,omitempty"`
}

type JMultiplicityInfo

type JMultiplicityInfo struct {
	Lower string `json:"lower,omitempty"`
	Upper string `json:"upper,omitempty"`
}

type JParseSourcesRequest

type JParseSourcesRequest struct {
	Documents         []*JSourceDocument `json:"documents,omitempty"`
	StrictConformance bool               `json:"strictConformance,omitempty"`
}

type JParseSourcesResponse

type JParseSourcesResponse struct {
	ModelHash   string         `json:"modelHash,omitempty"`
	Diagnostics []*JDiagnostic `json:"diagnostics,omitempty"`
}

type JQuantity

type JQuantity struct {
	IntMagnitude    *I64       `json:"intMagnitude,omitempty"`
	RealMagnitude   *F64       `json:"realMagnitude,omitempty"`
	Unit            string     `json:"unit,omitempty"`
	UnitTerm        *JUnitTerm `json:"unitTerm,omitempty"`
	BigIntMagnitude *string    `json:"bigIntMagnitude,omitempty"`

	RationalMagnitude *JRational `json:"rationalMagnitude,omitempty"`
}

JQuantity is the Quantity message; Magnitude is its oneof.

func (*JQuantity) UnmarshalJSON

func (q *JQuantity) UnmarshalJSON(data []byte) error

UnmarshalJSON rejects a quantity setting both magnitude arms of its oneof.

type JRational

type JRational struct {
	Numerator   string `json:"numerator,omitempty"`
	Denominator string `json:"denominator,omitempty"`
}

JRational is the Rational message: an exact rational in lowest terms.

type JRenderCanvas

type JRenderCanvas struct {
	Unit   string   `json:"unit,omitempty"`
	Width  *float64 `json:"width,omitempty"`
	Height *float64 `json:"height,omitempty"`
}

type JRenderEdge

type JRenderEdge struct {
	From     string         `json:"from"`
	To       string         `json:"to"`
	FromPort string         `json:"fromPort,omitempty"`
	ToPort   string         `json:"toPort,omitempty"`
	Label    string         `json:"label"`
	Kind     string         `json:"kind"`
	Style    *JRenderStyle  `json:"style,omitempty"`
	Route    []JRenderPoint `json:"route,omitempty"`
}

type JRenderNode

type JRenderNode struct {
	ID              string        `json:"id"`
	Kind            string        `json:"kind"`
	Name            string        `json:"name"`
	NameSynthesized bool          `json:"nameSynthesized,omitempty"`
	Type            string        `json:"type"`
	Detail          string        `json:"detail"`
	Parent          string        `json:"parent,omitempty"`
	Fill            string        `json:"fill,omitempty"`
	Border          string        `json:"border,omitempty"`
	Style           *JRenderStyle `json:"style,omitempty"`
	X               *float64      `json:"x,omitempty"`
	Y               *float64      `json:"y,omitempty"`
	Width           *float64      `json:"width,omitempty"`
	Height          *float64      `json:"height,omitempty"`
	Collapsed       bool          `json:"collapsed,omitempty"`
	Ports           []JRenderPort `json:"ports,omitempty"`
}

type JRenderPoint

type JRenderPoint struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

type JRenderPort

type JRenderPort struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Type      string `json:"type,omitempty"`
	Direction string `json:"direction,omitempty"`
}

type JRenderRow

type JRenderRow struct {
	Cells []string `json:"cells"`
}

type JRenderStyle

type JRenderStyle struct {
	Fill     string  `json:"fill,omitempty"`
	Line     string  `json:"line,omitempty"`
	Text     string  `json:"text,omitempty"`
	Font     string  `json:"font,omitempty"`
	FontSize float64 `json:"fontSize,omitempty"`
	Bold     bool    `json:"bold,omitempty"`
	Italic   bool    `json:"italic,omitempty"`
}

type JRenderViewRequest

type JRenderViewRequest struct {
	ModelHash string `json:"modelHash,omitempty"`
	View      string `json:"view,omitempty"`
	Ports     string `json:"ports,omitempty"`
}

type JRenderViewResponse

type JRenderViewResponse struct {
	View    string         `json:"view"`
	Kind    string         `json:"kind"`
	Stated  string         `json:"stated"`
	Notices []string       `json:"notices"`
	Canvas  *JRenderCanvas `json:"canvas,omitempty"`
	Nodes   []JRenderNode  `json:"nodes"`
	Edges   []JRenderEdge  `json:"edges"`
	Columns []string       `json:"columns,omitempty"`
	Rows    []JRenderRow   `json:"rows,omitempty"`
}

type JSourceDocument

type JSourceDocument struct {
	FilePath *string `json:"filePath,omitempty"`
	Content  *string `json:"content,omitempty"`
	Language string  `json:"language,omitempty"`
	Name     string  `json:"name,omitempty"`
}

JSourceDocument is the SourceDocument message; Source is its oneof.

func (*JSourceDocument) UnmarshalJSON

func (d *JSourceDocument) UnmarshalJSON(data []byte) error

UnmarshalJSON rejects a document naming both of its source arms.

type JSpan

type JSpan = fsyntax.Span

JSpan is the Span message.

type JTensorQuantity

type JTensorQuantity struct {
	Dimensions []I64        `json:"dimensions,omitempty"`
	Components []*JQuantity `json:"components,omitempty"`
}

type JTraceEvent

type JTraceEvent struct {
	Kind         string   `json:"kind"`
	At           F64      `json:"at"`
	Object       string   `json:"object,omitempty"`
	Machine      string   `json:"machine,omitempty"`
	State        string   `json:"state,omitempty"`
	From         string   `json:"from,omitempty"`
	To           string   `json:"to,omitempty"`
	Target       string   `json:"target,omitempty"`
	Event        string   `json:"event,omitempty"`
	Payload      []string `json:"payload,omitempty"`
	Alternatives []string `json:"alternatives,omitempty"`
	Taken        string   `json:"taken,omitempty"`
	Text         string   `json:"text"`
}

JTraceEvent is one documented state-machine execution record.

type JUndetermined

type JUndetermined struct {
	Reason string             `json:"reason,omitempty"`
	Count  *JMultiplicityInfo `json:"count,omitempty"`
}

type JUnitFactor

type JUnitFactor struct {
	UnitId   string `json:"unitId,omitempty"`
	Exponent F64    `json:"exponent,omitempty"`
}

type JUnitTerm

type JUnitTerm struct {
	ScaleNum F64            `json:"scaleNum,omitempty"`
	ScaleDen F64            `json:"scaleDen,omitempty"`
	Factors  []*JUnitFactor `json:"factors,omitempty"`
}

type JValue

type JValue struct {
	IntValue       *I64             `json:"intValue,omitempty"`
	BigIntValue    *string          `json:"bigIntValue,omitempty"`
	RealValue      *F64             `json:"realValue,omitempty"`
	BoolValue      *bool            `json:"boolValue,omitempty"`
	StringValue    *string          `json:"stringValue,omitempty"`
	InstanceId     *I64             `json:"instanceId,omitempty"`
	Sequence       *JValueSequence  `json:"sequence,omitempty"`
	Null           *string          `json:"null,omitempty"`
	Quantity       *JQuantity       `json:"quantity,omitempty"`
	EnumLiteral    *JEnumLiteral    `json:"enumLiteral,omitempty"`
	Unset          *bool            `json:"unset,omitempty"`
	Complex        *JComplex        `json:"complex,omitempty"`
	Array          *JArray          `json:"array,omitempty"`
	Vector         *JVector         `json:"vector,omitempty"`
	VectorQuantity *JVectorQuantity `json:"vectorQuantity,omitempty"`
	MeasurementRef *JMeasurementRef `json:"measurementRef,omitempty"`
	Infinity       *bool            `json:"infinity,omitempty"`
	Function       *JFunction       `json:"function,omitempty"`
	Set            *JValueSet       `json:"set,omitempty"`
	TensorQuantity *JTensorQuantity `json:"tensorQuantity,omitempty"`
	Metaobject     *JMetaobject     `json:"metaobject,omitempty"`
	Undetermined   *JUndetermined   `json:"undetermined,omitempty"`
	RationalValue  *JRational       `json:"rationalValue,omitempty"`
}

JValue is the Value message: a oneof, so exactly one arm is ever set.

func (*JValue) UnmarshalJSON

func (v *JValue) UnmarshalJSON(data []byte) error

UnmarshalJSON rejects a value setting two arms of the oneof, as protojson rejects it: a request naming more than one arm is ambiguous, not a pick.

type JValueSequence

type JValueSequence struct {
	Elements []*JValue `json:"elements,omitempty"`
}

type JValueSet

type JValueSet struct {
	Elements []*JValue `json:"elements,omitempty"`
}

type JVector

type JVector struct {
	Components []*JValue `json:"components,omitempty"`
}

type JVectorQuantity

type JVectorQuantity struct {
	Components []*JQuantity `json:"components,omitempty"`
}

Jump to

Keyboard shortcuts

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