Documentation
¶
Index ¶
- Constants
- Variables
- func Capabilities() []string
- func CheckArrayShape(dimensions []int64, count int) error
- func CheckTensorShape(dimensions []int64, count int) error
- func ComplexToProto(z complex128) *pb.Complex
- func DiagnosticToProto(diag passes.Diagnostic, sf *source.SourceFile) *pb.Diagnostic
- func InstanceGraphToProto(rt *runtime.Context, inst *runtime.Instance, idx *symbols.Index) (*pb.Instance, []*pb.Instance)
- func InstanceToProto(rt *runtime.Context, inst *runtime.Instance, idx *symbols.Index) *pb.Instance
- func MeasurementRefToProto(ref *runtime.MeasurementRef) *pb.MeasurementRef
- func ParserDiagnosticToProto(diag parser.Diagnostic, sf *source.SourceFile) *pb.Diagnostic
- func ProtoToComplex(pc *pb.Complex) complex128
- func ProtoToMeasurementRef(pm *pb.MeasurementRef, idx *symbols.Index, sem *semantics.Model) (runtime.Value, error)
- func ProtoToQuantity(pq *pb.Quantity, idx *symbols.Index, sem *semantics.Model) (runtime.Value, error)
- func ProtoToRuntimeValue(rt *runtime.Context, pv *pb.Value, idx *symbols.Index, sem *semantics.Model) (runtime.Value, error)
- func ProtoToValueIn(pv *pb.Value, idx *symbols.Index, sem *semantics.Model) (runtime.Value, error)
- func QuantityToProto(q *runtime.Quantity) *pb.Quantity
- func QueryPropertyNames() []string
- func RunNoteDiagnosticsToProto(notes []runtime.RunNote, model *CachedModel) []*pb.Diagnostic
- func SymbolToProtoIn(sym *symbols.Symbol, sc *SymbolContext) *pb.SymbolInfo
- func ValueCarriesComplex(pv *pb.Value) bool
- func ValueCarriesFunction(pv *pb.Value) bool
- func ValueCarriesInfinity(pv *pb.Value) bool
- func ValueCarriesMeasurementRef(pv *pb.Value) bool
- func ValueCarriesSet(pv *pb.Value) bool
- func ValueCarriesStructured(pv *pb.Value) bool
- func ValueCarriesTensor(pv *pb.Value) bool
- func ValueToProto(val runtime.Value, idx *symbols.Index) *pb.Value
- func ValueToProtoIn(rt *runtime.Context, val runtime.Value, idx *symbols.Index) *pb.Value
- type Cache
- type CachedDocument
- type CachedModel
- func (m *CachedModel) DocumentRoots() []*symbols.Scope
- func (m *CachedModel) Primary() *CachedDocument
- func (m *CachedModel) PrimaryRoot() *symbols.Scope
- func (m *CachedModel) RuntimeSemantics() (*runtimeSemantics, func())
- func (m *CachedModel) SoleDocument() (*CachedDocument, error)
- func (m *CachedModel) SymbolContext() *SymbolContext
- type ConnectAdapter
- func (a *ConnectAdapter) ApplyEdits(ctx context.Context, req *connect.Request[pb.ApplyEditsRequest]) (*connect.Response[pb.ApplyEditsResponse], error)
- func (a *ConnectAdapter) Convert(ctx context.Context, req *connect.Request[pb.ConvertRequest]) (*connect.Response[pb.ConvertResponse], error)
- func (a *ConnectAdapter) Evaluate(ctx context.Context, req *connect.Request[pb.EvaluateRequest]) (*connect.Response[pb.EvaluateResponse], error)
- func (a *ConnectAdapter) EvaluateCalc(ctx context.Context, req *connect.Request[pb.EvaluateCalcRequest]) (*connect.Response[pb.EvaluateCalcResponse], error)
- func (a *ConnectAdapter) ExecuteAction(ctx context.Context, req *connect.Request[pb.ExecuteActionRequest]) (*connect.Response[pb.ExecuteActionResponse], error)
- func (a *ConnectAdapter) ExecuteState(ctx context.Context, req *connect.Request[pb.ExecuteStateRequest]) (*connect.Response[pb.ExecuteStateResponse], error)
- func (a *ConnectAdapter) GetDiagnostics(ctx context.Context, req *connect.Request[pb.DiagnosticsRequest]) (*connect.Response[pb.DiagnosticsResponse], error)
- func (a *ConnectAdapter) GetServerInfo(ctx context.Context, req *connect.Request[pb.ServerInfoRequest]) (*connect.Response[pb.ServerInfoResponse], error)
- func (a *ConnectAdapter) GetSymbol(ctx context.Context, req *connect.Request[pb.GetSymbolRequest]) (*connect.Response[pb.SymbolResponse], error)
- func (a *ConnectAdapter) Instantiate(ctx context.Context, req *connect.Request[pb.InstantiateRequest]) (*connect.Response[pb.InstantiateResponse], error)
- func (a *ConnectAdapter) ParseFile(ctx context.Context, req *connect.Request[pb.ParseFileRequest]) (*connect.Response[pb.ParseFileResponse], error)
- func (a *ConnectAdapter) ParseSources(ctx context.Context, req *connect.Request[pb.ParseSourcesRequest]) (*connect.Response[pb.ParseSourcesResponse], error)
- func (a *ConnectAdapter) Query(ctx context.Context, req *connect.Request[pb.QueryRequest]) (*connect.Response[pb.QueryResponse], error)
- func (a *ConnectAdapter) RenderDocument(ctx context.Context, req *connect.Request[pb.RenderDocumentRequest]) (*connect.Response[pb.RenderDocumentResponse], error)
- func (a *ConnectAdapter) RunAnalysis(ctx context.Context, req *connect.Request[pb.RunAnalysisRequest]) (*connect.Response[pb.RunAnalysisResponse], error)
- func (a *ConnectAdapter) RunDocumentQuery(ctx context.Context, req *connect.Request[pb.RunDocumentQueryRequest]) (*connect.Response[pb.RunDocumentQueryResponse], error)
- func (a *ConnectAdapter) RunSweep(ctx context.Context, req *connect.Request[pb.RunSweepRequest]) (*connect.Response[pb.RunSweepResponse], error)
- func (a *ConnectAdapter) VerifyConstraint(ctx context.Context, req *connect.Request[pb.VerifyConstraintRequest]) (*connect.Response[pb.VerifyConstraintResponse], error)
- func (a *ConnectAdapter) VerifyRequirement(ctx context.Context, req *connect.Request[pb.VerifyRequirementRequest]) (*connect.Response[pb.VerifyRequirementResponse], error)
- func (a *ConnectAdapter) VerifySatisfaction(ctx context.Context, req *connect.Request[pb.VerifySatisfactionRequest]) (*connect.Response[pb.VerifySatisfactionResponse], error)
- type GraphBounds
- type InstanceGraph
- type QueryError
- type QueryErrorKind
- type Service
- func (s *Service) ApplyEdits(ctx context.Context, req *pb.ApplyEditsRequest) (*pb.ApplyEditsResponse, error)
- func (s *Service) Close()
- func (s *Service) Convert(ctx context.Context, req *pb.ConvertRequest) (*pb.ConvertResponse, error)
- func (s *Service) Evaluate(ctx context.Context, req *pb.EvaluateRequest) (*pb.EvaluateResponse, error)
- func (s *Service) EvaluateCalc(ctx context.Context, req *pb.EvaluateCalcRequest) (*pb.EvaluateCalcResponse, error)
- func (s *Service) ExecuteAction(ctx context.Context, req *pb.ExecuteActionRequest) (*pb.ExecuteActionResponse, error)
- func (s *Service) ExecuteState(ctx context.Context, req *pb.ExecuteStateRequest) (*pb.ExecuteStateResponse, error)
- func (s *Service) GetDiagnostics(ctx context.Context, req *pb.DiagnosticsRequest) (*pb.DiagnosticsResponse, error)
- func (s *Service) GetServerInfo(ctx context.Context, req *pb.ServerInfoRequest) (*pb.ServerInfoResponse, error)
- func (s *Service) GetSymbol(ctx context.Context, req *pb.GetSymbolRequest) (*pb.SymbolResponse, error)
- func (s *Service) Instantiate(ctx context.Context, req *pb.InstantiateRequest) (*pb.InstantiateResponse, error)
- func (s *Service) ParseFile(ctx context.Context, req *pb.ParseFileRequest) (*pb.ParseFileResponse, error)
- func (s *Service) ParseSources(ctx context.Context, req *pb.ParseSourcesRequest) (*pb.ParseSourcesResponse, error)
- func (s *Service) Prewarm()
- func (s *Service) Query(ctx context.Context, req *pb.QueryRequest) (*pb.QueryResponse, error)
- func (s *Service) RenderDocument(ctx context.Context, req *pb.RenderDocumentRequest) (*pb.RenderDocumentResponse, error)
- func (s *Service) RunAnalysis(ctx context.Context, req *pb.RunAnalysisRequest) (*pb.RunAnalysisResponse, error)
- func (s *Service) RunDocumentQuery(ctx context.Context, req *pb.RunDocumentQueryRequest) (*pb.RunDocumentQueryResponse, error)
- func (s *Service) RunSweep(ctx context.Context, req *pb.RunSweepRequest) (*pb.RunSweepResponse, error)
- func (s *Service) VerifyConstraint(ctx context.Context, req *pb.VerifyConstraintRequest) (*pb.VerifyConstraintResponse, error)
- func (s *Service) VerifyRequirement(ctx context.Context, req *pb.VerifyRequirementRequest) (*pb.VerifyRequirementResponse, error)
- func (s *Service) VerifySatisfaction(ctx context.Context, req *pb.VerifySatisfactionRequest) (*pb.VerifySatisfactionResponse, error)
- type SymbolContext
Constants ¶
const ( QueryPropID = corequery.PropertyID QueryPropType = corequery.PropertyType QueryPropName = corequery.PropertyName QueryPropDeclaredName = corequery.PropertyDeclaredName QueryPropShortName = corequery.PropertyShortName QueryPropDeclaredShortName = corequery.PropertyDeclaredShortName QueryPropDocumentation = corequery.PropertyDocumentation QueryPropQualifiedName = corequery.PropertyQualifiedName QueryPropOwner = corequery.PropertyOwner QueryPropIsAbstract = corequery.PropertyIsAbstract QueryPropElementType = corequery.PropertyElementType QueryPropMultiplicityLower = corequery.PropertyMultiplicityLower QueryPropMultiplicityUpper = corequery.PropertyMultiplicityUpper )
Query property names, as the SysML v2 API & Services standard's clients write them. docs/reference/api.md documents what each one reports.
const CapabilityApplyEdits = "apply_edits"
CapabilityApplyEdits names the capability of the ApplyEdits RPC, which edits a parsed model's own source, preserving everything the edit did not touch.
const CapabilityAuthoring = "authoring"
CapabilityAuthoring names add-member and delete source authoring operations.
const CapabilityCaseEvaluations = "case_evaluations"
CapabilityCaseEvaluations names the capability of reporting each application an analysis run made of one of the case's calcs as a function value — a trade study's evaluation of each alternative — and of keeping what a failed run computed beside its error.
const CapabilityComplexValues = "complex_values"
CapabilityComplexValues names the capability of carrying a complex number as Value.complex, rather than reporting it as an unsupported null.
const CapabilityConvert = "convert"
CapabilityConvert names the capability of the Convert RPC, which writes a model back out as SysML notation or RDF Turtle. The RDF direction is experimental, which the response says per conversion.
const CapabilityDiagnosticCodes = "diagnostic_codes"
CapabilityDiagnosticCodes names the capability of populating Diagnostic.code, so an empty code is a finding none was assigned rather than an older service.
const CapabilityDocumentQuery = "document_query"
CapabilityDocumentQuery names the capability of the RunDocumentQuery RPC, which runs a named document query and answers with typed rows.
const CapabilityEnumValues = "enum_values"
CapabilityEnumValues names the capability of carrying an enumeration literal as Value.enum_literal, rather than reporting it as an unsupported null.
const CapabilityEvaluateSubject = "evaluate_subject"
CapabilityEvaluateSubject names the capability of evaluating an expression against an instantiated subject.
const CapabilityFeatureValues = "feature_values"
CapabilityFeatureValues names the capability of populating Instance.feature_values, which replaced the pre-0.1.0 Instance.slots.
const CapabilityFinalTime = "final_time"
CapabilityFinalTime names the capability of populating final_time on ExecuteActionResponse and ExecuteStateResponse, the run's simulation clock when it ended. Without it the field is 0 whatever the run waited on.
const CapabilityFunctionValues = "function_values"
CapabilityFunctionValues names the capability of carrying a calc held as a value as Value.function, named by its declaration, rather than reporting it as an unsupported null.
const CapabilityInfinityValue = "infinity_value"
CapabilityInfinityValue names the capability of carrying the unbounded value `*` as Value.infinity, rather than reporting it as an unsupported null.
const CapabilityInlineLanguage = "inline_language"
CapabilityInlineLanguage names explicit language selection for inline content.
const CapabilityMeasurementRefs = "measurement_refs"
CapabilityMeasurementRefs names the capability of carrying a bare measurement reference as Value.measurement_ref, rather than reporting it as an unsupported null. Distinct from structured_values, which predates the arm.
const CapabilityOSLCQuery = "oslc_query"
CapabilityOSLCQuery names the capability of evaluating OSLC Query text.
const CapabilityParseSources = "parse_sources"
CapabilityParseSources names the ParseSources RPC, which parses several documents as one model so a name one declares resolves in another.
const CapabilityQuery = "query"
CapabilityQuery names the capability of the Query RPC, which evaluates a SysML v2 API & Services Query over a parsed model.
const CapabilityRenderDocument = "render_document"
CapabilityRenderDocument names the capability of the RenderDocument RPC, which renders a named document to Markdown.
const CapabilitySchedule = "schedule"
CapabilitySchedule names the `schedule` field of ExecuteActionRequest, ExecuteStateRequest and RunAnalysisRequest, which selects the scheduling policy a run resolves its choice points under. A service without it runs every request under the default, so a client must not send the field to one.
const CapabilityScheduleExplore = "schedule_explore"
CapabilityScheduleExplore names the capability of answering a request under `explore[:runs=<n>,depth=<d>]` with `outcomes` and an `exploration` status.
const CapabilitySetValues = "set_values"
CapabilitySetValues names the capability of carrying a unique, unordered collection as Value.set, rather than reporting it as an unsupported null.
const CapabilityStrictConformance = "strict_conformance"
CapabilityStrictConformance names ParseFileRequest.strict_conformance, which asks whether the source is conforming SysML v2.
const CapabilityStructuredValues = "structured_values"
CapabilityStructuredValues names the capability of carrying an array, a vector and a vector quantity as Value.array, Value.vector and Value.vector_quantity, rather than reporting them as unsupported nulls.
const CapabilitySymbolAttributes = "symbol_attributes"
CapabilitySymbolAttributes names the capability of populating SymbolInfo.attributes, rather than always reporting none.
const CapabilityTensorValues = "tensor_values"
CapabilityTensorValues names the capability of carrying a tensor quantity of any rank as Value.tensor_quantity, rather than as an unsupported null.
const CapabilityTypeFacts = "type_facts"
CapabilityTypeFacts names the capability of populating SymbolInfo.type_info, .multiplicity and .specializations, which typed code generation requires.
const CapabilityUnsetValue = "unset_value"
CapabilityUnsetValue names the capability of reporting a valueless feature of a value type as Value.unset, rather than as the empty object it materializes.
const CapabilityVerification = "verification"
CapabilityVerification names the capability of the verification RPCs, which answer the questions the REPL's %constraint, %requirement, %satisfy and %calc answer.
const CapabilityVerificationVerdicts = "verification_verdicts"
CapabilityVerificationVerdicts names the capability of reporting what the body of a verification case answered as VerificationVerdict, and of running a verification case through RunAnalysis.
const DefaultIndexPrewarm = 4
DefaultIndexPrewarm is the value IndexPrewarmEnvVar takes when unset: any positive value prewarms, since one library index now serves every model.
const IndexPrewarmEnvVar = "OPENSYSML_GRPC_INDEX_POOL"
IndexPrewarmEnvVar names the variable saying whether the service builds the standard library index before the requests that need it. Zero disables prewarming, so the first request builds it. The legacy SYSML_GRPC_INDEX_POOL name remains accepted; the OPENSYSML_ name wins when both are set.
const SyntaxDiagnosticCode = "syntax"
SyntaxDiagnosticCode is the code every reporter gives a parser error; the parser itself codes only warnings.
Variables ¶
var ( // ErrQuantityNeedsIndex reports a quantity converted from the wire without // the model's symbols, which its base units can only be resolved against. ErrQuantityNeedsIndex = errors.New("a quantity needs the model's symbols to be converted from the wire") // ErrUnknownBaseUnit reports a base unit the model does not declare, so no // unit can be rebuilt from the reduction naming it. ErrUnknownBaseUnit = errors.New("unknown base unit") // ErrNotAMeasurementUnit reports a reduction naming a symbol that is not a // measurement unit, which nothing is measured in. ErrNotAMeasurementUnit = errors.New("not a measurement unit") // ErrUnitScaleUnusable reports a unit reduction whose scale is zero, undefined // or not finite, which no magnitude can be converted through. ErrUnitScaleUnusable = errors.New("unit scale is not a usable ratio") // ErrUnitExponentUnusable reports a unit factor raised to a power that is not // a finite number, which measures no dimension. ErrUnitExponentUnusable = errors.New("unit exponent is not a finite number") // ErrUnitNotReduced reports a named unit sent without its reduction, over // which alone commensurability is decided. ErrUnitNotReduced = errors.New("unit carries no reduction to base units") // ErrUnitTextMismatch reports a unit whose text names units that do not // reduce to the unit_term sent with it, so the two describe different units. ErrUnitTextMismatch = errors.New("unit as written does not reduce to its unit_term") // ErrUnsetNotAccepted reports the unset arm arriving as an input. It reports // that a feature value holds no value, which is something to read, not to supply. ErrUnsetNotAccepted = errors.New("unset is not a value a caller can supply") // ErrInfinityNotAsserted reports the infinity arm arriving as false. The arm // is the unbounded value itself, so false states no value at all. ErrInfinityNotAsserted = errors.New("the infinity arm states no value unless it is true") // ErrArrayDimensionNotPositive reports an array sent with a dimension of no // extent, which Collections::Array declares as dimensions: Positive. ErrArrayDimensionNotPositive = errors.New("array dimension is not positive") // ErrArrayShapeMismatch reports an array whose elements do not fill its // dimensions, so no row-major reading of them has that shape. ErrArrayShapeMismatch = errors.New("array elements do not fill its dimensions") // ErrVectorComponentNotNumeric reports a vector component sent as something // other than an Integer or a Real, which a numerical vector has none of. ErrVectorComponentNotNumeric = errors.New("vector component is not a number") // ErrVectorQuantityEmpty reports a vector quantity of no components, whose // num is Number[1..*]. ErrVectorQuantityEmpty = errors.New("vector quantity has no components") // ErrMeasurementRefNeedsIndex reports a measurement reference converted from // the wire without the model's symbols, which its units resolve against. ErrMeasurementRefNeedsIndex = errors.New("a measurement reference needs the model's symbols to be converted from the wire") // ErrMeasurementRefEmpty reports a measurement reference sent with no unit // text, no reduction and no declaration: nothing it could refer to. ErrMeasurementRefEmpty = errors.New("measurement reference names no unit") // ErrUnknownMeasurementUnit reports a unit_id the model does not declare // uniquely, so no reference can name the declaration. ErrUnknownMeasurementUnit = errors.New("unknown measurement unit") // ErrUnitIDMismatch reports a unit_id whose declaration the unit text sent // with it does not spell, so the two name different units. ErrUnitIDMismatch = errors.New("unit as written does not spell unit_id") // ErrFunctionNeedsRuntime reports a Function read with no runtime to bind // its calc in: only a runtime can turn a calc's name into a callable value. ErrFunctionNeedsRuntime = errors.New("function needs a runtime to bind its calc") // ErrFunctionUnbound reports a Function naming no calc of the model read as // a function, or an object the runtime does not hold. ErrFunctionUnbound = errors.New("function names no calc of this model") // ErrSetElementRepeated reports a set sent with an element twice, which a // set holds once; a sender meaning both meant a sequence. ErrSetElementRepeated = errors.New("set element is repeated") // ErrTensorDimensionNotPositive reports a tensor sent with a dimension of no // extent, which its TensorMeasurementReference declares as Positive. ErrTensorDimensionNotPositive = errors.New("tensor dimension is not positive") // ErrTensorShapeMismatch reports a tensor whose components do not fill its // dimensions, so no row-major reading of them has that shape. ErrTensorShapeMismatch = errors.New("tensor components do not fill its dimensions") // ErrTensorComponentMissing reports a tensor component sent as an empty // message, which carries no quantity. ErrTensorComponentMissing = errors.New("tensor component carries no quantity") )
Functions ¶
func Capabilities ¶
func Capabilities() []string
Capabilities returns the capability names this build of the service reports.
func CheckArrayShape ¶ added in v0.6.0
CheckArrayShape reports whether count elements fill dimensions in row-major order: every dimension positive and their product (one for rank 0) count.
func CheckTensorShape ¶ added in v0.7.0
CheckTensorShape is CheckArrayShape for a tensor's components, reported as the tensor errors.
func ComplexToProto ¶ added in v0.5.0
func ComplexToProto(z complex128) *pb.Complex
ComplexToProto marshals a complex number as its rectangular parts.
func DiagnosticToProto ¶
func DiagnosticToProto(diag passes.Diagnostic, sf *source.SourceFile) *pb.Diagnostic
DiagnosticToProto converts a passes.Diagnostic to protobuf.
func InstanceGraphToProto ¶
func InstanceGraphToProto(rt *runtime.Context, inst *runtime.Instance, idx *symbols.Index) (*pb.Instance, []*pb.Instance)
InstanceGraphToProto converts inst and every instance reachable from it. The root is returned first; runtime instances live only for the duration of a request, so the whole reachable graph is serialized while the context is alive.
Expansion stops at a child whose type is already on the path, at maxGraphDepth and at maxGraphInstances: reading a composite feature value materializes the object it holds, so a self-referential part would otherwise instantiate forever. An unexpanded child stays a bare instance id.
func InstanceToProto ¶
InstanceToProto converts runtime.Instance to protobuf Instance. Feature values are read through Instance.GetFeatureValue, so a derived default is evaluated against the instance rather than reported as unmaterialized. Features are read in name order, because reading one materializes the object it holds, so map order would decide the ids those objects are given.
func MeasurementRefToProto ¶ added in v0.6.0
func MeasurementRefToProto(ref *runtime.MeasurementRef) *pb.MeasurementRef
MeasurementRefToProto marshals a bare reference: the unit as written, what it reduces to, and the one declaration it names when it names one.
func ParserDiagnosticToProto ¶
func ParserDiagnosticToProto(diag parser.Diagnostic, sf *source.SourceFile) *pb.Diagnostic
ParserDiagnosticToProto converts a parser error to protobuf.
func ProtoToComplex ¶ added in v0.5.0
func ProtoToComplex(pc *pb.Complex) complex128
ProtoToComplex is the complex number a Complex message carries; an empty message is zero, as every proto3 default is.
func ProtoToMeasurementRef ¶ added in v0.6.0
func ProtoToMeasurementRef(pm *pb.MeasurementRef, idx *symbols.Index, sem *semantics.Model) (runtime.Value, error)
ProtoToMeasurementRef rebuilds a bare reference from the wire: by the declaration unit_id names, checked against the unit text and reduction sent with it, or else by the unit text read exactly as a Quantity's is.
func ProtoToQuantity ¶
func ProtoToQuantity(pq *pb.Quantity, idx *symbols.Index, sem *semantics.Model) (runtime.Value, error)
ProtoToQuantity rebuilds a quantity from the wire: the magnitude as sent, in the unit as written — read as the product of the named units it composes, so an operation over it cancels and merges them — over the base units idx resolves its reduction to.
func ProtoToRuntimeValue ¶ added in v0.7.0
func ProtoToRuntimeValue(rt *runtime.Context, pv *pb.Value, idx *symbols.Index, sem *semantics.Model) (runtime.Value, error)
ProtoToRuntimeValue is ProtoToValueIn for a value bound for the runtime rt, which is what a function's calc is bound in and its object looked up in; rt may be nil for a value naming no function.
func ProtoToValueIn ¶
ProtoToValueIn converts a protobuf Value to a runtime.Value in the model idx and sem describe, resolving a quantity's base units against them. Inverse of ValueToProto. A function, which only a runtime can bind, is refused: read one with ProtoToRuntimeValue.
func QuantityToProto ¶
QuantityToProto marshals a quantity: the magnitude in the unit written, plus what that unit reduces to. Reports nil for a magnitude that is not a number.
func QueryPropertyNames ¶
func QueryPropertyNames() []string
QueryPropertyNames returns every queryable property name, sorted. It is what an unknown-property error lists, and what docs/reference/api.md's table documents.
func RunNoteDiagnosticsToProto ¶ added in v0.7.0
func RunNoteDiagnosticsToProto(notes []runtime.RunNote, model *CachedModel) []*pb.Diagnostic
RunNoteDiagnosticsToProto converts what a run noted about itself — its choice points and the guards it could not evaluate — to informational diagnostics, located in their model document; one outside the model carries no span.
func SymbolToProtoIn ¶
func SymbolToProtoIn(sym *symbols.Symbol, sc *SymbolContext) *pb.SymbolInfo
SymbolToProtoIn converts a Symbol to protobuf SymbolInfo in an existing conversion context.
func ValueCarriesComplex ¶ added in v0.5.0
ValueCarriesComplex reports whether a value, or any value nested in it, is a Complex: the kind the complex_values capability governs.
func ValueCarriesFunction ¶ added in v0.7.0
ValueCarriesFunction reports whether a value, or any value nested in it, is a Function: the kind function_values governs.
func ValueCarriesInfinity ¶ added in v0.7.0
ValueCarriesInfinity reports whether a value, or any value nested in it, is the unbounded value: the kind infinity_value governs.
func ValueCarriesMeasurementRef ¶ added in v0.6.0
ValueCarriesMeasurementRef reports whether a value, or any value nested in it, is a MeasurementRef: the kind measurement_refs governs.
func ValueCarriesSet ¶ added in v0.7.0
ValueCarriesSet reports whether a value, or any value nested in it, is a ValueSet: the kind set_values governs.
func ValueCarriesStructured ¶ added in v0.6.0
ValueCarriesStructured reports whether a value, or any value nested in it, is an Array, a Vector or a VectorQuantity: the kinds structured_values governs.
func ValueCarriesTensor ¶ added in v0.7.0
ValueCarriesTensor reports whether a value, or any value nested in it, is a TensorQuantity: the kind tensor_values governs.
func ValueToProto ¶
ValueToProto converts runtime.Value to protobuf Value. An enumeration literal is named by its declaration, which idx supplies the qualified name of.
func ValueToProtoIn ¶
ValueToProtoIn converts a value read from a live context, which is what tells an object holding no value from one with features: the former crosses as the unset arm, as every other surface reads it. rt may be nil for a value no context materialized.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is an LRU cache for parsed models keyed by content hash
func NewCache ¶
NewCache creates a cache with the specified max size. It returns an error if maxSize is not positive.
func (*Cache) Get ¶
func (c *Cache) Get(hash string) (*CachedModel, bool)
Get retrieves a model from cache, returns (model, true) on hit
func (*Cache) Put ¶
func (c *Cache) Put(hash string, model *CachedModel)
Put adds a model to cache, evicting LRU if at capacity
type CachedDocument ¶ added in v0.4.2
type CachedDocument struct {
Root *ast.RootNamespace
Source *source.SourceFile // For diagnostic line/col mapping
ParseDiags []parser.Diagnostic // Parser diagnostics
PassesDiags []passes.Diagnostic // Semantic pass diagnostics (name-resolution, type, constraint)
}
CachedDocument is one parsed document of a model.
type CachedModel ¶
type CachedModel struct {
// Documents are the model's documents, at least one, in the order the parse
// request named them. They share Index, so a name one declares resolves in
// another and an import between them is satisfied.
Documents []*CachedDocument
Index *symbols.Index // For symbol lookups by FQN
Library libs.Source // the files the library in Index was built from, for their spans' text
// contains filtered or unexported fields
}
CachedModel holds parsed model data with semantic analysis results
func (*CachedModel) DocumentRoots ¶ added in v0.4.2
func (m *CachedModel) DocumentRoots() []*symbols.Scope
DocumentRoots are the root scopes of the model's documents, in order, skipping any the index does not hold.
func (*CachedModel) Primary ¶ added in v0.4.2
func (m *CachedModel) Primary() *CachedDocument
Primary is the document a model is named by: the only one of a single-document model, and the first named of a multi-document one, whose root namespace is where a name with nothing else to resolve against is looked up.
func (*CachedModel) PrimaryRoot ¶ added in v0.4.2
func (m *CachedModel) PrimaryRoot() *symbols.Scope
PrimaryRoot is the root scope of the document the model is named by.
func (*CachedModel) RuntimeSemantics ¶ added in v0.5.0
func (m *CachedModel) RuntimeSemantics() (*runtimeSemantics, func())
RuntimeSemantics locks and returns the model's shared runtime resolver and semantic model, built on first use, with the function releasing them.
func (*CachedModel) SoleDocument ¶ added in v0.4.2
func (m *CachedModel) SoleDocument() (*CachedDocument, error)
SoleDocument is the model's one document, for an operation defined on a single document's own source — editing it, or writing it back out. A model of several documents is refused rather than answered about one of them.
func (*CachedModel) SymbolContext ¶
func (m *CachedModel) SymbolContext() *SymbolContext
SymbolContext returns the conversion context for this model, building it on first use. Name resolution and the semantic relations derived from it are memoized in it, so every symbol converted from one cached model shares one.
type ConnectAdapter ¶ added in v0.3.0
type ConnectAdapter struct {
// contains filtered or unexported fields
}
ConnectAdapter serves the same Service through the Connect handler signatures, so one implementation answers every protocol Connect speaks.
func NewConnectAdapter ¶ added in v0.3.0
func NewConnectAdapter(svc *Service) *ConnectAdapter
NewConnectAdapter wraps a Service as a Connect handler.
func (*ConnectAdapter) ApplyEdits ¶ added in v0.3.0
func (a *ConnectAdapter) ApplyEdits(ctx context.Context, req *connect.Request[pb.ApplyEditsRequest]) (*connect.Response[pb.ApplyEditsResponse], error)
ApplyEdits edits a parsed model's own source.
func (*ConnectAdapter) Convert ¶ added in v0.3.0
func (a *ConnectAdapter) Convert(ctx context.Context, req *connect.Request[pb.ConvertRequest]) (*connect.Response[pb.ConvertResponse], error)
Convert writes a model out as SysML notation or RDF Turtle.
func (*ConnectAdapter) Evaluate ¶ added in v0.3.0
func (a *ConnectAdapter) Evaluate(ctx context.Context, req *connect.Request[pb.EvaluateRequest]) (*connect.Response[pb.EvaluateResponse], error)
Evaluate evaluates an expression against a parsed model.
func (*ConnectAdapter) EvaluateCalc ¶ added in v0.3.0
func (a *ConnectAdapter) EvaluateCalc(ctx context.Context, req *connect.Request[pb.EvaluateCalcRequest]) (*connect.Response[pb.EvaluateCalcResponse], error)
EvaluateCalc evaluates a calculation with the arguments given.
func (*ConnectAdapter) ExecuteAction ¶ added in v0.3.0
func (a *ConnectAdapter) ExecuteAction(ctx context.Context, req *connect.Request[pb.ExecuteActionRequest]) (*connect.Response[pb.ExecuteActionResponse], error)
ExecuteAction runs an action to completion.
func (*ConnectAdapter) ExecuteState ¶ added in v0.3.0
func (a *ConnectAdapter) ExecuteState(ctx context.Context, req *connect.Request[pb.ExecuteStateRequest]) (*connect.Response[pb.ExecuteStateResponse], error)
ExecuteState runs a state machine over the events given.
func (*ConnectAdapter) GetDiagnostics ¶ added in v0.3.0
func (a *ConnectAdapter) GetDiagnostics(ctx context.Context, req *connect.Request[pb.DiagnosticsRequest]) (*connect.Response[pb.DiagnosticsResponse], error)
GetDiagnostics returns the diagnostics of a parsed model.
func (*ConnectAdapter) GetServerInfo ¶ added in v0.3.0
func (a *ConnectAdapter) GetServerInfo(ctx context.Context, req *connect.Request[pb.ServerInfoRequest]) (*connect.Response[pb.ServerInfoResponse], error)
GetServerInfo reports what this build of the service can do.
func (*ConnectAdapter) GetSymbol ¶ added in v0.3.0
func (a *ConnectAdapter) GetSymbol(ctx context.Context, req *connect.Request[pb.GetSymbolRequest]) (*connect.Response[pb.SymbolResponse], error)
GetSymbol returns symbol information by qualified name.
func (*ConnectAdapter) Instantiate ¶ added in v0.3.0
func (a *ConnectAdapter) Instantiate(ctx context.Context, req *connect.Request[pb.InstantiateRequest]) (*connect.Response[pb.InstantiateResponse], error)
Instantiate materializes an instance of a definition.
func (*ConnectAdapter) ParseFile ¶ added in v0.3.0
func (a *ConnectAdapter) ParseFile(ctx context.Context, req *connect.Request[pb.ParseFileRequest]) (*connect.Response[pb.ParseFileResponse], error)
ParseFile parses a model and returns its hash.
func (*ConnectAdapter) ParseSources ¶ added in v0.4.2
func (a *ConnectAdapter) ParseSources(ctx context.Context, req *connect.Request[pb.ParseSourcesRequest]) (*connect.Response[pb.ParseSourcesResponse], error)
ParseSources parses several documents as one model.
func (*ConnectAdapter) Query ¶ added in v0.3.0
func (a *ConnectAdapter) Query(ctx context.Context, req *connect.Request[pb.QueryRequest]) (*connect.Response[pb.QueryResponse], error)
Query evaluates a SysML v2 API & Services Query over a parsed model.
func (*ConnectAdapter) RenderDocument ¶ added in v0.4.2
func (a *ConnectAdapter) RenderDocument(ctx context.Context, req *connect.Request[pb.RenderDocumentRequest]) (*connect.Response[pb.RenderDocumentResponse], error)
RenderDocument renders a named document to Markdown.
func (*ConnectAdapter) RunAnalysis ¶ added in v0.6.0
func (a *ConnectAdapter) RunAnalysis(ctx context.Context, req *connect.Request[pb.RunAnalysisRequest]) (*connect.Response[pb.RunAnalysisResponse], error)
RunAnalysis runs an analysis case with the subject and arguments given.
func (*ConnectAdapter) RunDocumentQuery ¶ added in v0.4.2
func (a *ConnectAdapter) RunDocumentQuery(ctx context.Context, req *connect.Request[pb.RunDocumentQueryRequest]) (*connect.Response[pb.RunDocumentQueryResponse], error)
RunDocumentQuery runs a named document query and answers with typed rows.
func (*ConnectAdapter) RunSweep ¶ added in v0.7.0
func (a *ConnectAdapter) RunSweep(ctx context.Context, req *connect.Request[pb.RunSweepRequest]) (*connect.Response[pb.RunSweepResponse], error)
RunSweep runs one analysis case or calc once per row of a parameter sweep.
func (*ConnectAdapter) VerifyConstraint ¶ added in v0.3.0
func (a *ConnectAdapter) VerifyConstraint(ctx context.Context, req *connect.Request[pb.VerifyConstraintRequest]) (*connect.Response[pb.VerifyConstraintResponse], error)
VerifyConstraint evaluates a constraint and returns its verdict.
func (*ConnectAdapter) VerifyRequirement ¶ added in v0.3.0
func (a *ConnectAdapter) VerifyRequirement(ctx context.Context, req *connect.Request[pb.VerifyRequirementRequest]) (*connect.Response[pb.VerifyRequirementResponse], error)
VerifyRequirement evaluates a requirement and returns its verdict.
func (*ConnectAdapter) VerifySatisfaction ¶ added in v0.3.0
func (a *ConnectAdapter) VerifySatisfaction(ctx context.Context, req *connect.Request[pb.VerifySatisfactionRequest]) (*connect.Response[pb.VerifySatisfactionResponse], error)
VerifySatisfaction evaluates satisfaction relationships in a model.
type GraphBounds ¶ added in v0.5.0
GraphBounds is how far InstanceGraphToProtoWithin expands an object graph: nested objects to Depth, and Instances objects in all.
func DefaultGraphBounds ¶ added in v0.5.0
func DefaultGraphBounds() GraphBounds
DefaultGraphBounds are the bounds the service serializes an instance graph under.
type InstanceGraph ¶ added in v0.5.0
type InstanceGraph struct {
Root *pb.Instance
All []*pb.Instance // the root first
// Truncated reports that the instance bound cut the graph short.
Truncated bool
// Errors are the typed failures behind every FeatureValue.Error in All.
Errors []error
}
InstanceGraph is an object graph serialized by InstanceGraphToProtoWithin.
func InstanceGraphToProtoWithin ¶ added in v0.5.0
func InstanceGraphToProtoWithin(rt *runtime.Context, inst *runtime.Instance, idx *symbols.Index, bounds GraphBounds) InstanceGraph
InstanceGraphToProtoWithin is InstanceGraphToProto under the given bounds; the type cycle guard applies whatever the bounds.
type QueryError ¶
type QueryError struct {
Kind QueryErrorKind
Message string
}
QueryError is a query the service refuses to evaluate. It reports itself as INVALID_ARGUMENT, since every kind is a fault in the query, not in the model.
func (*QueryError) Error ¶
func (e *QueryError) Error() string
type QueryErrorKind ¶
type QueryErrorKind int
QueryErrorKind classifies why a query could not be evaluated. Every kind fails the call: answering with no elements would read as "nothing matched".
const ( // QueryErrUnknownProperty is a property no queryable property names. QueryErrUnknownProperty QueryErrorKind = iota + 1 // QueryErrMalformedConstraint is a constraint with no form, no operator or // no operand. QueryErrMalformedConstraint // QueryErrUnorderedProperty is > or < on a property that is not ordered. QueryErrUnorderedProperty // QueryErrUnparsableValue is an operand the operator cannot compare. QueryErrUnparsableValue // QueryErrUnknownScope is a scope naming an element the model does not have. QueryErrUnknownScope )
type Service ¶
type Service struct {
pb.UnimplementedSysMLServiceServer
// contains filtered or unexported fields
}
Service implements SysMLServiceServer
func NewService ¶
NewService creates a gRPC service with specified cache size, reporting version as its build version. It returns an error if cacheSize is not positive, if a budget variable holds anything but a positive integer, or if the prewarm setting is not a non-negative integer. It does not load the standard library: call Prewarm to have that happen in the background, ahead of the requests that need it.
func NewServiceWithUnavailableCapabilitiesForTesting ¶ added in v0.3.0
func NewServiceWithUnavailableCapabilitiesForTesting(cacheSize int, version string, unavailable []string) (*Service, error)
NewServiceWithUnavailableCapabilitiesForTesting creates a service that deliberately lacks named capabilities for conformance testing.
func (*Service) ApplyEdits ¶
func (s *Service) ApplyEdits(ctx context.Context, req *pb.ApplyEditsRequest) (*pb.ApplyEditsResponse, error)
ApplyEdits edits the source a model was parsed from and returns the edited notation, so a client can change a model and write it back with its comments and layout intact. Argument faults fail the call; an edit the engine refuses is reported in the response's error, failure kind and diagnostics.
func (*Service) Close ¶
func (s *Service) Close()
Close waits for a background library build in flight and releases the service's reference to the shared index. The service still answers afterwards, building the library on the request that needs it.
func (*Service) Convert ¶
func (s *Service) Convert(ctx context.Context, req *pb.ConvertRequest) (*pb.ConvertResponse, error)
Convert writes a model in another representation, so a client can save a model it read rather than only inspect it. Argument faults fail the call; a model the converter refuses is reported in the response's error and diagnostics.
func (*Service) Evaluate ¶
func (s *Service) Evaluate(ctx context.Context, req *pb.EvaluateRequest) (*pb.EvaluateResponse, error)
Evaluate evaluates a SysML expression in the context of a parsed model
func (*Service) EvaluateCalc ¶
func (s *Service) EvaluateCalc(ctx context.Context, req *pb.EvaluateCalcRequest) (*pb.EvaluateCalcResponse, error)
EvaluateCalc invokes a calculation, as the REPL's %calc does: a calc usage named with no arguments is evaluated from its own members and reports every output feature it computes (SysML 7.17); anything else is invoked with the arguments given, bound positionally.
func (*Service) ExecuteAction ¶
func (s *Service) ExecuteAction(ctx context.Context, req *pb.ExecuteActionRequest) (*pb.ExecuteActionResponse, error)
ExecuteAction executes an action definition
func (*Service) ExecuteState ¶
func (s *Service) ExecuteState(ctx context.Context, req *pb.ExecuteStateRequest) (*pb.ExecuteStateResponse, error)
ExecuteState executes a state machine
func (*Service) GetDiagnostics ¶
func (s *Service) GetDiagnostics(ctx context.Context, req *pb.DiagnosticsRequest) (*pb.DiagnosticsResponse, error)
GetDiagnostics retrieves all diagnostics for a parsed model (parser + semantic passes)
func (*Service) GetServerInfo ¶
func (s *Service) GetServerInfo(ctx context.Context, req *pb.ServerInfoRequest) (*pb.ServerInfoResponse, error)
GetServerInfo reports the service's build version and capabilities. A service too old to have this RPC fails the call with UNIMPLEMENTED, which is itself the answer that it predates every capability.
func (*Service) GetSymbol ¶
func (s *Service) GetSymbol(ctx context.Context, req *pb.GetSymbolRequest) (*pb.SymbolResponse, error)
GetSymbol retrieves symbol information by FQN
func (*Service) Instantiate ¶
func (s *Service) Instantiate(ctx context.Context, req *pb.InstantiateRequest) (*pb.InstantiateResponse, error)
Instantiate creates a runtime instance of a part/usage
func (*Service) ParseFile ¶
func (s *Service) ParseFile(ctx context.Context, req *pb.ParseFileRequest) (*pb.ParseFileResponse, error)
ParseFile parses a SysML file and caches the result
func (*Service) ParseSources ¶ added in v0.4.2
func (s *Service) ParseSources(ctx context.Context, req *pb.ParseSourcesRequest) (*pb.ParseSourcesResponse, error)
ParseSources parses several documents as one model, so a name one document declares resolves in another.
func (*Service) Prewarm ¶
func (s *Service) Prewarm()
Prewarm starts building the service's standard library index in the background, so the first model to arrive is not the one that pays for the library. It returns immediately and is safe to call more than once.
func (*Service) Query ¶
func (s *Service) Query(ctx context.Context, req *pb.QueryRequest) (*pb.QueryResponse, error)
Query evaluates a SysML v2 API & Services Query against a parsed model.
func (*Service) RenderDocument ¶ added in v0.4.2
func (s *Service) RenderDocument(ctx context.Context, req *pb.RenderDocumentRequest) (*pb.RenderDocumentResponse, error)
RenderDocument renders a named document to Markdown, as -render-document does.
func (*Service) RunAnalysis ¶ added in v0.6.0
func (s *Service) RunAnalysis(ctx context.Context, req *pb.RunAnalysisRequest) (*pb.RunAnalysisResponse, error)
RunAnalysis runs an analysis case, as the REPL's %analysis does: the subject named is instantiated and bound, the arguments bind the case's inputs, and the response carries every output with the verdict of each objective and assertion (SysML 7.22).
func (*Service) RunDocumentQuery ¶ added in v0.4.2
func (s *Service) RunDocumentQuery(ctx context.Context, req *pb.RunDocumentQueryRequest) (*pb.RunDocumentQueryResponse, error)
RunDocumentQuery runs a named document query with parameter bindings, the answer %run-query gives, as typed rows rather than formatted lines.
func (*Service) RunSweep ¶ added in v0.7.0
func (s *Service) RunSweep(ctx context.Context, req *pb.RunSweepRequest) (*pb.RunSweepResponse, error)
RunSweep runs one analysis case or calc once per row of a parameter sweep, as the CLI's -sweep and the REPL's %sweep do: every row is an ordinary run with the swept parameters bound to that row's values. A run that failed is that row's error; only a plan that no run follows from fails the table.
func (*Service) VerifyConstraint ¶
func (s *Service) VerifyConstraint(ctx context.Context, req *pb.VerifyConstraintRequest) (*pb.VerifyConstraintResponse, error)
VerifyConstraint evaluates a constraint definition or usage, as the REPL's %constraint does.
func (*Service) VerifyRequirement ¶
func (s *Service) VerifyRequirement(ctx context.Context, req *pb.VerifyRequirementRequest) (*pb.VerifyRequirementResponse, error)
VerifyRequirement evaluates a requirement definition or usage, as the REPL's %requirement does.
func (*Service) VerifySatisfaction ¶
func (s *Service) VerifySatisfaction(ctx context.Context, req *pb.VerifySatisfactionRequest) (*pb.VerifySatisfactionResponse, error)
VerifySatisfaction evaluates the satisfaction assertions a model states, as the REPL's %satisfy does: every one, or, given a symbol, the ones that element states — or that element itself when it is a named satisfy assertion.
type SymbolContext ¶
type SymbolContext struct {
Index *symbols.Index
Resolver *resolve.Resolver
Semantics *semantics.Model
// contains filtered or unexported fields
}
SymbolContext holds what converting a symbol to proto needs besides the symbol: its index, and the resolver and semantic model that answer what its declared names refer to. Their memoization is why it is shared per model.
The resolver and semantic model memoize into plain maps, so a shared context must be used by one goroutine at a time; Lock serializes concurrent conversions of the same model.
func NewSymbolContext ¶
func NewSymbolContext(idx *symbols.Index) *SymbolContext
NewSymbolContext builds a conversion context over a symbol index.
func (*SymbolContext) Lock ¶
func (sc *SymbolContext) Lock() func()
Lock takes exclusive use of the context's resolver and semantic model, and returns the function releasing it.