OpenSysML

# OpenSysML MDK — Runtime Environment and Development Kit [![CircleCI](https://dl.circleci.com/status-badge/img/gh/Open-MBEE/OpenSysML/tree/main.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/gh/Open-MBEE/OpenSysML/tree/main) [![Quality gate](https://sonarcloud.io/api/project_badges/measure?project=Open-MBEE_OpenSysML&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Open-MBEE_OpenSysML) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=Open-MBEE_OpenSysML&metric=coverage)](https://sonarcloud.io/component_measures?id=Open-MBEE_OpenSysML&metric=coverage) [![Maintainability](https://sonarcloud.io/api/project_badges/measure?project=Open-MBEE_OpenSysML&metric=sqale_rating)](https://sonarcloud.io/component_measures?id=Open-MBEE_OpenSysML&metric=Maintainability) [![Reliability](https://sonarcloud.io/api/project_badges/measure?project=Open-MBEE_OpenSysML&metric=reliability_rating)](https://sonarcloud.io/component_measures?id=Open-MBEE_OpenSysML&metric=Reliability) [![Security](https://sonarcloud.io/api/project_badges/measure?project=Open-MBEE_OpenSysML&metric=security_rating)](https://sonarcloud.io/component_measures?id=Open-MBEE_OpenSysML&metric=Security) [![Release](https://img.shields.io/github/v/release/Open-MBEE/OpenSysML?label=release)](https://github.com/Open-MBEE/OpenSysML/releases/latest) [![Go reference](https://pkg.go.dev/badge/github.com/Open-MBEE/OpenSysML.svg)](https://pkg.go.dev/github.com/Open-MBEE/OpenSysML) [![PyPI](https://img.shields.io/pypi/v/opensysml?label=pypi)](https://pypi.org/project/opensysml/) [![Python versions](https://img.shields.io/pypi/pyversions/opensysml)](https://pypi.org/project/opensysml/) [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE) [![Documentation](https://img.shields.io/badge/docs-runtime.opensysml.org-blue)](https://runtime.opensysml.org/) The OpenSysML Runtime Environment and Development Kit (OpenSysML MDK) is a SysML v2 and KerML 1.1 implementation in Go. It provides a language server, an interactive REPL, an execution runtime, an embeddable Go API, and Python, Node/TypeScript, Java, Rust, Julia and MATLAB client libraries, covering the lifecycle from authoring through execution with the integrated tooling systems engineers expect from a modern language ecosystem. It is the runtime of [OpenSysML](https://opensysml.org/), the open source SysML v2 suite of the [OpenMBEE](https://www.openmbee.org) community; this repository is the MDK, and the pages below use "OpenSysML" for it where no confusion with the suite is possible. The MDK is the second generation of OpenMBEE's Model Development Kit, expanded and updated for SysML v2; its [Cameo plugin](editors/mdk/README.md) is OpenSysML MDK for Cameo. **It runs the model.** A validator reads declarations; an expression evaluator computes a value from the ones it is handed. OpenSysML materializes the instances a model describes, evaluates their features through the whole part tree with units carried and checked, performs actions on those objects and advances state machines on a clock, and decides requirements, analysis objectives and satisfaction claims against what it finds. Because it runs the model, it finds what reading cannot: a mass rollup whose one unvalued leaf makes the total incomputable, a calculation whose result comes out in the wrong dimension, a well-formed action with no step to start at. The [runtime showcase](examples/runtime-showcase/README.md) is a set of small models built around exactly those questions, run and reported; the first of the [examples](#examples) below is the shortest version. It is fast. The public [Apollo 11 SysML v2 model](https://github.com/airbus/apollo-11-sysml-v2) — 28 files, 7,200 lines — parses in **8 ms** (42 MB/s on one core) and loads, resolves and validates against the full standard library in **0.27 s**. The measurement and how to repeat it are in [performance](docs/internals/performance.md#a-real-model-apollo-11). The same model is where the runtime earns its keep: the pinned OMG pilot validator passes it without a finding and OpenSysML reports no error, yet its calculations and its mission action each stop at a defect only execution reaches — see [the showcase's Apollo 11 section](examples/runtime-showcase/README.md#apollo-11). The basis for these claims, and their limits, are documented in [spec compliance](docs/project/spec-compliance.md) and the [pilot differential](docs/project/pilot-differential.md): every diagnostic is compared against the pinned OMG pilot implementation over that implementation's own corpora, and no conformance certification is claimed. ## Quick start **Introductory material:** [the guide](docs/guide/) and the [document generation manual](docs/manual/README.md) **Complete searchable documentation:** — the same pages as [docs/](docs/), rendered from `develop`. ### Install **Install script** — picks the release build for this machine, verifies it against the release's `SHA256SUMS.txt`, and installs `sysml` and `sysml-lsp`: ```bash # Linux and macOS: /usr/local/bin when writable, otherwise ~/.local/bin curl -fsSL https://opensysml.org/install.sh | sh ``` ```powershell # Windows: %LOCALAPPDATA%\Programs\OpenSysML, added to the user PATH irm https://opensysml.org/install.ps1 | iex ``` Both scripts take a release (`--version v0.9.1`, `nightly`), a tool list (`--tools sysml`, `sysml-lsp`, `sysml-grpc`, `sysml-jupyter-kernel`, `sysml-mcp`, or `all` for every tool the chosen release published, read from its `SHA256SUMS.txt`) and a destination (`--prefix`, or `-InstallDir` on Windows), and `--dry-run` shows the choice without installing; `sh -s -- --help` lists the rest. The scripts are [`install.sh`](install.sh) and [`install.ps1`](install.ps1) in this repository, so a checkout runs them as `./install.sh`. **Download pre-built binaries by hand:** ```bash # Linux x64 (use opensysml-linux-arm64.tar.gz on arm64) wget https://github.com/Open-MBEE/OpenSysML/releases/latest/download/opensysml-linux-amd64.tar.gz tar xzf opensysml-linux-amd64.tar.gz && sudo mv sysml sysml-lsp /usr/local/bin/ # macOS (Intel or Apple Silicon) — see the note below brew install Open-MBEE/tap/opensysml ``` **With a Go toolchain (no download, never quarantined):** ```bash go install github.com/Open-MBEE/OpenSysML/cmd/sysml@latest go install github.com/Open-MBEE/OpenSysML/cmd/sysml-lsp@latest ``` `sysml -version` then reports the release it was built from (`sysml v0.11.0`), or the commit when installed from a checkout. **Or build from source:** ```bash make build ./bin/sysml ``` > **macOS — use the install script or Homebrew.** The released binaries are not Developer ID > signed or notarized, so a tarball downloaded *in a browser* carries `com.apple.quarantine` > and Gatekeeper shows "cannot be opened because the developer cannot be verified". The > install script and Homebrew both download with `curl`, which never sets that attribute, so > neither meets the prompt. > When the tarball is downloaded directly (`curl -fL ... opensysml-darwin-arm64.tar.gz`, followed > by `xattr -d com.apple.quarantine`), see > [the guide](docs/guide/01-install.md#macos-gatekeeper). Signing and notarization are the > intended long-term resolution — > [docs/project/macos-distribution.md](docs/project/macos-distribution.md). > > Install by the **fully-qualified** name. Homebrew 6 requires third-party taps to be trusted > before their Ruby is loaded, and `brew install Open-MBEE/tap/opensysml` trusts just that > formula. `brew tap Open-MBEE/tap && brew install opensysml` needs > `brew trust --formula Open-MBEE/tap/opensysml` in between. ### Examples **A model that runs.** `saturnIBAscent` is an analysis case bound to a two-stage rocket; its outputs are computed from the rocket equation over the stages' masses and specific impulses, with units, and its objective is a requirement. Arguments in parentheses rebind its inputs: ```bash $ sysml -quiet -analysis DeltaVBudget::saturnIBAscent examples/runtime-showcase/delta-v-budget.sysml ✓ package DeltaVBudget ✓ DeltaVBudget::saturnIBAscent stage1DeltaV = [3037.6966629706967 [SI::'m/s']] stage2DeltaV = [6432.955324716369 [SI::'m/s']] margin = [70.65198768706614 [SI::'m/s']] objective reachesOrbit: satisfied standing: value (observed: 1 run under reverse) $ sysml -quiet -analysis "DeltaVBudget::saturnIBAscent(required = 9800 ['m/s'])" examples/runtime-showcase/delta-v-budget.sysml ✓ package DeltaVBudget ✗ DeltaVBudget::saturnIBAscent(required = 9800 ['m/s']) stage1DeltaV = [3037.6966629706967 [SI::'m/s']] stage2DeltaV = [6432.955324716369 [SI::'m/s']] margin = [-329.34801231293386 [SI::'m/s']] objective reachesOrbit: not satisfied: margin > 0 ['m/s'] standing: value (observed: 1 run under reverse) ``` The same file's `InjectionDeltaV` types a gravitational parameter as a force. Every name resolves and every operator applies, so validation passes it; the runtime computes the number and refuses to store it as a speed: ```bash $ sysml -quiet -calc "DeltaVBudget::InjectionDeltaV(3.986E14 [SI::N], 6563000 [SI::m], 384400000 [SI::m])" examples/runtime-showcase/delta-v-budget.sysml ✓ package DeltaVBudget sysml: calc invocation failed: calc DeltaVBudget::InjectionDeltaV: result: type mismatch: cannot write 3135.1638390999387 [kg**0.5/s] (dimension M^0.5·T^-1) to a feature typed by SpeedValue (dimension L·T^-1) standing: not covered (…) ``` The [runtime showcase](examples/runtime-showcase/README.md) continues from here: a recursive mass rollup, a reliability requirement asserted of two missions, a mission action that branches on its remaining budget, a clocked state machine, and the Apollo 11 model under the same tool. **Interactive modeling:** ```bash $ sysml sysml> part def Wheel { attribute diameter = 16.0; } ✓ part def Wheel sysml> %instantiate Wheel ✓ Created instance of Wheel ID: 1 Use %features Wheel to inspect sysml> %features Wheel Instance: Wheel (ID: 1) Features: diameter = 16.0 ownedPorts = [] performedActions = [] ownedActions = [] exhibitedStates = [] ownedStates = [] shape = [] envelopingShapes = [] boundingShapes = [] voids = [] isSolid = true subitems = [] subparts = [] checkedConstraints = [] ``` **Behavioral execution:** ```bash sysml> calc add { in x; in y; x + y } ✓ calc add sysml> %calc add 10 20 ✓ add(10, 20) = [30] standing: value (observed: 1 run under reverse) sysml> constraint ValidSpeed { 65 <= 120 } ✓ constraint ValidSpeed sysml> %constraint ValidSpeed ✓ Constraint ValidSpeed passed standing: holds (observed: 1 run under reverse) ``` **Action & state debugging:** ```bash sysml> action MyWorkflow { attribute result = 0; first start; then action compute { assign result := 42; } then done; } ✓ action MyWorkflow sysml> %action MyWorkflow ✓ Started action executor for "MyWorkflow" State: Running Tokens: 1 Use %step to advance, %tokens to inspect, %continue to run to completion sysml> %break compute ✓ Breakpoint set at node "compute" %continue runs until a token reaches it sysml> %continue ⏸ Paused at breakpoint "compute" State: Suspended Tokens: 1 Use %tokens to inspect, %step or %continue to resume sysml> %tokens Active tokens (1): Token 1 @ compute Values: result = 0 sysml> %continue ✓ Action completed Final state: Completed Results: result = 42 sysml> state TrafficLight { entry; then red; state red; state green; transition first red then green; } ✓ state TrafficLight sysml> %state TrafficLight ✓ Started state machine executor for "TrafficLight" Current state: red Time: 0.0 Events: 1 Use %events to see queue, %current for state, %advance