mbse 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. mbse-0.1.0/.devcontainer/Dockerfile +54 -0
  2. mbse-0.1.0/.devcontainer/devcontainer.json +19 -0
  3. mbse-0.1.0/.github/workflows/ci.yml +23 -0
  4. mbse-0.1.0/.github/workflows/release.yml +30 -0
  5. mbse-0.1.0/.gitignore +11 -0
  6. mbse-0.1.0/.vscode/settings.json +27 -0
  7. mbse-0.1.0/.vscode/tasks/open_example_model.sh +7 -0
  8. mbse-0.1.0/.vscode/tasks/run_ci.sh +20 -0
  9. mbse-0.1.0/.vscode/tasks/run_opencode_web_gui.sh +15 -0
  10. mbse-0.1.0/.vscode/tasks.json +29 -0
  11. mbse-0.1.0/LICENSE +21 -0
  12. mbse-0.1.0/PKG-INFO +169 -0
  13. mbse-0.1.0/README.md +147 -0
  14. mbse-0.1.0/pyproject.toml +82 -0
  15. mbse-0.1.0/setup.cfg +4 -0
  16. mbse-0.1.0/src/mbse/examples/elevator/README.md +39 -0
  17. mbse-0.1.0/src/mbse/examples/elevator/__init__.py +53 -0
  18. mbse-0.1.0/src/mbse/examples/elevator/__main__.py +6 -0
  19. mbse-0.1.0/src/mbse/examples/elevator/check_car_clearance.json +28 -0
  20. mbse-0.1.0/src/mbse/examples/elevator/choose_direction.json +56 -0
  21. mbse-0.1.0/src/mbse/examples/elevator/context.json +76 -0
  22. mbse-0.1.0/src/mbse/examples/elevator/elevator_hsm.json +294 -0
  23. mbse-0.1.0/src/mbse/examples/elevator/executables.py +119 -0
  24. mbse-0.1.0/src/mbse/examples/elevator/operate_doors.json +59 -0
  25. mbse-0.1.0/src/mbse/examples/elevator/plan_trip.json +27 -0
  26. mbse-0.1.0/src/mbse/examples/elevator/project.json +6 -0
  27. mbse-0.1.0/src/mbse/examples/elevator/travel_to_target.json +47 -0
  28. mbse-0.1.0/src/mbse/examples/elevator/wait_for_doorway_clearance.json +28 -0
  29. mbse-0.1.0/src/mbse/model/activity/activity_model.json +134 -0
  30. mbse-0.1.0/src/mbse/model/activity/activity_model.py +84 -0
  31. mbse-0.1.0/src/mbse/model/activity/doc/activity_model.md +43 -0
  32. mbse-0.1.0/src/mbse/model/context/context_model.json +37 -0
  33. mbse-0.1.0/src/mbse/model/context/context_model.py +55 -0
  34. mbse-0.1.0/src/mbse/model/context/doc/context_model.md +12 -0
  35. mbse-0.1.0/src/mbse/model/doc/model.md +34 -0
  36. mbse-0.1.0/src/mbse/model/hsm/doc/hsm_model.md +114 -0
  37. mbse-0.1.0/src/mbse/model/hsm/hsm_model.json +259 -0
  38. mbse-0.1.0/src/mbse/model/hsm/hsm_model.py +496 -0
  39. mbse-0.1.0/src/mbse/model/mbse_model.json +328 -0
  40. mbse-0.1.0/src/mbse/model/mbse_model.py +67 -0
  41. mbse-0.1.0/src/mbse/model/project/doc/project_model.md +22 -0
  42. mbse-0.1.0/src/mbse/model/project/project_model.json +32 -0
  43. mbse-0.1.0/src/mbse/model/project/project_model.py +26 -0
  44. mbse-0.1.0/src/mbse/model/project/project_registry.py +171 -0
  45. mbse-0.1.0/src/mbse/runtime/activity/activity_runtime.py +386 -0
  46. mbse-0.1.0/src/mbse/runtime/activity/doc/activity_runtime.md +39 -0
  47. mbse-0.1.0/src/mbse/runtime/doc/runtime.md +60 -0
  48. mbse-0.1.0/src/mbse/runtime/hsm/doc/hsm_runtime.md +60 -0
  49. mbse-0.1.0/src/mbse/runtime/hsm/hsm_runtime.py +984 -0
  50. mbse-0.1.0/src/mbse/runtime/runtime.py +481 -0
  51. mbse-0.1.0/src/mbse/runtime/runtime_signals.py +7 -0
  52. mbse-0.1.0/src/mbse.egg-info/PKG-INFO +169 -0
  53. mbse-0.1.0/src/mbse.egg-info/SOURCES.txt +131 -0
  54. mbse-0.1.0/src/mbse.egg-info/dependency_links.txt +1 -0
  55. mbse-0.1.0/src/mbse.egg-info/entry_points.txt +3 -0
  56. mbse-0.1.0/src/mbse.egg-info/requires.txt +7 -0
  57. mbse-0.1.0/src/mbse.egg-info/scm_file_list.json +127 -0
  58. mbse-0.1.0/src/mbse.egg-info/scm_version.json +8 -0
  59. mbse-0.1.0/src/mbse.egg-info/top_level.txt +2 -0
  60. mbse-0.1.0/src/mbse_web_viewer/render/activity/activity_render.dot.j2 +37 -0
  61. mbse-0.1.0/src/mbse_web_viewer/render/activity/activity_render.py +487 -0
  62. mbse-0.1.0/src/mbse_web_viewer/render/activity/activity_render_helpers.py +360 -0
  63. mbse-0.1.0/src/mbse_web_viewer/render/activity/activity_render_types.py +107 -0
  64. mbse-0.1.0/src/mbse_web_viewer/render/activity/doc/activity_render.md +12 -0
  65. mbse-0.1.0/src/mbse_web_viewer/render/doc/render.md +12 -0
  66. mbse-0.1.0/src/mbse_web_viewer/render/hsm/doc/hsm_render.md +44 -0
  67. mbse-0.1.0/src/mbse_web_viewer/render/hsm/hsm_render.dot.j2 +82 -0
  68. mbse-0.1.0/src/mbse_web_viewer/render/hsm/hsm_render.py +765 -0
  69. mbse-0.1.0/src/mbse_web_viewer/render/hsm/hsm_render_helpers.py +900 -0
  70. mbse-0.1.0/src/mbse_web_viewer/render/hsm/hsm_render_types.py +178 -0
  71. mbse-0.1.0/src/mbse_web_viewer/server/controller.py +653 -0
  72. mbse-0.1.0/src/mbse_web_viewer/server/debugging/activity_breakpoints.py +141 -0
  73. mbse-0.1.0/src/mbse_web_viewer/server/debugging/hsm_breakpoints.py +345 -0
  74. mbse-0.1.0/src/mbse_web_viewer/server/doc/server.md +59 -0
  75. mbse-0.1.0/src/mbse_web_viewer/server/highlighting/activity_highlighting.py +176 -0
  76. mbse-0.1.0/src/mbse_web_viewer/server/highlighting/hsm_highlighting.py +710 -0
  77. mbse-0.1.0/src/mbse_web_viewer/server/http_server.py +347 -0
  78. mbse-0.1.0/src/mbse_web_viewer/server/model_catalog.py +64 -0
  79. mbse-0.1.0/src/mbse_web_viewer/server/session.py +69 -0
  80. mbse-0.1.0/src/mbse_web_viewer/server/viewer_app.py +74 -0
  81. mbse-0.1.0/src/mbse_web_viewer/static/assets/debugger-pause.svg +4 -0
  82. mbse-0.1.0/src/mbse_web_viewer/static/assets/debugger-play.svg +3 -0
  83. mbse-0.1.0/src/mbse_web_viewer/static/assets/debugger-reset.svg +4 -0
  84. mbse-0.1.0/src/mbse_web_viewer/static/assets/debugger-step-into.svg +4 -0
  85. mbse-0.1.0/src/mbse_web_viewer/static/assets/debugger-step-out.svg +4 -0
  86. mbse-0.1.0/src/mbse_web_viewer/static/assets/debugger-step.svg +4 -0
  87. mbse-0.1.0/src/mbse_web_viewer/static/doc/static.md +22 -0
  88. mbse-0.1.0/src/mbse_web_viewer/static/index.html +153 -0
  89. mbse-0.1.0/src/mbse_web_viewer/static/viewer.css +664 -0
  90. mbse-0.1.0/src/mbse_web_viewer/static/viewer.js +698 -0
  91. mbse-0.1.0/src/mbse_web_viewer/static/viewer_api.js +16 -0
  92. mbse-0.1.0/src/mbse_web_viewer/static/viewer_breakpoints.js +389 -0
  93. mbse-0.1.0/src/mbse_web_viewer/static/viewer_debugger.js +64 -0
  94. mbse-0.1.0/src/mbse_web_viewer/static/viewer_declared_values.js +172 -0
  95. mbse-0.1.0/src/mbse_web_viewer/static/viewer_highlights.js +140 -0
  96. mbse-0.1.0/src/mbse_web_viewer/static/viewer_models.js +84 -0
  97. mbse-0.1.0/src/mbse_web_viewer/static/viewer_state.js +61 -0
  98. mbse-0.1.0/src/mbse_web_viewer/static/viewer_utils.js +16 -0
  99. mbse-0.1.0/src/mbse_web_viewer/static/viewer_viewport.js +285 -0
  100. mbse-0.1.0/tests/__init__.py +1 -0
  101. mbse-0.1.0/tests/mbse/examples/test_elevator_example.py +101 -0
  102. mbse-0.1.0/tests/mbse/model/activity/doc/test_activity_model.md +7 -0
  103. mbse-0.1.0/tests/mbse/model/activity/test_activity_model.py +99 -0
  104. mbse-0.1.0/tests/mbse/model/context/doc/test_context_model.md +7 -0
  105. mbse-0.1.0/tests/mbse/model/context/test_context_model.py +80 -0
  106. mbse-0.1.0/tests/mbse/model/hsm/doc/test_hsm_model.md +7 -0
  107. mbse-0.1.0/tests/mbse/model/hsm/test_hsm_model.py +302 -0
  108. mbse-0.1.0/tests/mbse/model/project/test_project_model.py +218 -0
  109. mbse-0.1.0/tests/mbse/runtime/activity/doc/test_activity_runtime.md +11 -0
  110. mbse-0.1.0/tests/mbse/runtime/activity/test_activity_runtime.py +268 -0
  111. mbse-0.1.0/tests/mbse/runtime/hsm/doc/test_hsm_runtime.md +10 -0
  112. mbse-0.1.0/tests/mbse/runtime/hsm/test_hsm_runtime.py +601 -0
  113. mbse-0.1.0/tests/mbse/runtime/test_runtime.py +630 -0
  114. mbse-0.1.0/tests/mbse_web_viewer/render/activity/test_activity_render.py +152 -0
  115. mbse-0.1.0/tests/mbse_web_viewer/render/hsm/doc/test_hsm_render.md +7 -0
  116. mbse-0.1.0/tests/mbse_web_viewer/render/hsm/test_hsm_render.py +166 -0
  117. mbse-0.1.0/tests/mbse_web_viewer/server/doc/test_hsm_server.md +8 -0
  118. mbse-0.1.0/tests/mbse_web_viewer/server/test_hsm_server.py +1266 -0
  119. mbse-0.1.0/tests/reference_model/__init__.py +1 -0
  120. mbse-0.1.0/tests/reference_model/activity/__init__.py +1 -0
  121. mbse-0.1.0/tests/reference_model/activity/doc/reference_activity_model.md +9 -0
  122. mbse-0.1.0/tests/reference_model/activity/reference_activity_executables.py +41 -0
  123. mbse-0.1.0/tests/reference_model/activity/reference_activity_model.json +48 -0
  124. mbse-0.1.0/tests/reference_model/context/__init__.py +1 -0
  125. mbse-0.1.0/tests/reference_model/context/doc/reference_context_model.md +8 -0
  126. mbse-0.1.0/tests/reference_model/context/reference_context_model.json +40 -0
  127. mbse-0.1.0/tests/reference_model/hsm/__init__.py +1 -0
  128. mbse-0.1.0/tests/reference_model/hsm/doc/reference_hsm_model.md +9 -0
  129. mbse-0.1.0/tests/reference_model/hsm/reference_hsm_executables.py +75 -0
  130. mbse-0.1.0/tests/reference_model/hsm/reference_hsm_model.json +348 -0
  131. mbse-0.1.0/tests/reference_model/project/__init__.py +1 -0
  132. mbse-0.1.0/tests/reference_model/project/doc/reference_project.md +6 -0
  133. mbse-0.1.0/tests/reference_model/project/reference_project.json +6 -0
@@ -0,0 +1,54 @@
1
+ FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.04
2
+
3
+ # Prevent interactive prompts during package installations
4
+ ENV DEBIAN_FRONTEND=noninteractive
5
+
6
+ ################################################################################
7
+ # Common packages
8
+ ################################################################################
9
+
10
+ RUN apt-get update && apt-get install -y \
11
+ curl \
12
+ default-jre-headless \
13
+ graphviz \
14
+ git \
15
+ wget \
16
+ sudo \
17
+ locales \
18
+ python3 \
19
+ python3-pip \
20
+ python3-dev \
21
+ python3-setuptools \
22
+ python3-venv \
23
+ python-is-python3 \
24
+ xdg-utils \
25
+ && apt-get clean \
26
+ && rm -rf /var/lib/apt/lists/*
27
+
28
+ # Install common Python tooling globally in the devcontainer so it is available
29
+ # to the whole workspace without introducing an additional virtual environment
30
+ # layer. --break-system-packages is intentional here because this is a controlled
31
+ # development container image rather than a shared host Python installation.
32
+ RUN python -m pip install --break-system-packages \
33
+ Jinja2 \
34
+ jsonschema \
35
+ pytest \
36
+ quickjs
37
+
38
+ # Configure locale (UTF-8)
39
+ ENV LANG=C.UTF-8
40
+ ENV LC_ALL=C.UTF-8
41
+
42
+ ################################################################################
43
+ # AI support with OpenCode
44
+ ################################################################################
45
+
46
+ # Switch to container user so AI tooling installs in the correct user paths
47
+ USER vscode
48
+ ENV HOME=/home/vscode
49
+
50
+ # Install OpenCode
51
+ RUN curl -fsSL https://opencode.ai/install | bash
52
+
53
+ # Create ~/.local/state as vscode so OpenCode has write permissions
54
+ RUN mkdir -p /home/vscode/.local/state
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "MBSE",
3
+ "dockerFile": "Dockerfile",
4
+ "mounts": [
5
+ // Load OpenCode state (including credentials and sessions) from host.
6
+ "source=${localEnv:HOME}/.local/share/opencode,target=/home/vscode/.local/share/opencode,type=bind"
7
+ ],
8
+ "customizations": {
9
+ "vscode": {
10
+ "extensions": [
11
+ "ms-python.python",
12
+ "mhutchie.git-graph",
13
+ "spencerwmiles.vscode-task-buttons",
14
+ "bierner.markdown-preview-github-styles",
15
+ "ms-vscode.live-server"
16
+ ]
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,23 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [main]
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ with:
14
+ fetch-depth: 0
15
+ - uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.11"
18
+ - run: sudo apt-get update && sudo apt-get install --yes graphviz
19
+ - run: python -m pip install --upgrade pip
20
+ - run: python -m pip install -e ".[test]" build
21
+ - run: ruff check .
22
+ - run: pytest
23
+ - run: python -m build
@@ -0,0 +1,30 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+
7
+ permissions:
8
+ contents: read
9
+ id-token: write
10
+
11
+ jobs:
12
+ publish:
13
+ runs-on: ubuntu-latest
14
+ environment:
15
+ name: pypi
16
+ url: https://pypi.org/p/mbse
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ with:
20
+ fetch-depth: 0
21
+ - uses: actions/setup-python@v5
22
+ with:
23
+ python-version: "3.11"
24
+ - run: sudo apt-get update && sudo apt-get install --yes graphviz
25
+ - run: python -m pip install --upgrade pip
26
+ - run: python -m pip install -e ".[test]" build
27
+ - run: ruff check .
28
+ - run: pytest
29
+ - run: python -m build
30
+ - uses: pypa/gh-action-pypi-publish@release/v1
mbse-0.1.0/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .pytest_cache/
4
+ .venv/
5
+ .viewer-js-venv/
6
+ .python-packages/
7
+ .mbse-rendered/
8
+ .mbse-cli-state/
9
+ *.egg-info/
10
+ build/
11
+ dist/
@@ -0,0 +1,27 @@
1
+ {
2
+ "workbench.tree.indent": 16,
3
+ "workbench.tree.expandMode": "doubleClick",
4
+ "editor.autoIndent": "full",
5
+ "editor.insertSpaces": true,
6
+ "editor.tabSize": 2,
7
+ "editor.detectIndentation": false,
8
+ "git.autofetch": true,
9
+ "debug.showInStatusBar": "always",
10
+ "VsCodeTaskButtons.tasks": [
11
+ {
12
+ "label": "🌐 OpenCode web GUI",
13
+ "task": "run_opencode_web_gui"
14
+ },
15
+ {
16
+ "label": "▶️ Open elevator example",
17
+ "task": "open_example_model"
18
+ },
19
+ {
20
+ "label": "✅ Run CI",
21
+ "task": "run_ci"
22
+ }
23
+ ],
24
+ "files.associations": {
25
+ "*.py": "python"
26
+ }
27
+ }
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ echo "Open elevator example"
5
+
6
+ cd "$(dirname "$0")/../.."
7
+ exec env PYTHONPATH=src python -m mbse.examples.elevator --open-browser
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ cd "$(dirname "$0")/../.."
5
+
6
+ PYTHON=".venv/bin/python"
7
+
8
+ if [ ! -x "$PYTHON" ]; then
9
+ python -m venv .venv
10
+ fi
11
+
12
+ if ! command -v dot >/dev/null; then
13
+ echo "Graphviz is required: install it and ensure 'dot' is on PATH."
14
+ exit 1
15
+ fi
16
+
17
+ "$PYTHON" -m pip install -e ".[test]" build
18
+ "$PYTHON" -m ruff check .
19
+ "$PYTHON" -m pytest
20
+ "$PYTHON" -m build
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ echo "🌐 OpenCode web GUI"
5
+
6
+ # Validate required commands.
7
+ if ! command -v opencode >/dev/null 2>&1; then
8
+ echo "❌ Error: opencode not found."
9
+ exit 1
10
+ fi
11
+
12
+ HOSTNAME="0.0.0.0"
13
+ PORT="4096"
14
+
15
+ exec opencode web --hostname "${HOSTNAME}" --port "${PORT}"
@@ -0,0 +1,29 @@
1
+ {
2
+ "version": "2.0.0",
3
+ "options": {
4
+ "env": {
5
+ "TASKS_PATH": "${workspaceFolder}/.vscode/tasks"
6
+ }
7
+ },
8
+ "tasks": [
9
+ {
10
+ "label": "run_opencode_web_gui",
11
+ "type": "shell",
12
+ "command": "${TASKS_PATH}/run_opencode_web_gui.sh"
13
+ },
14
+ {
15
+ "label": "open_example_model",
16
+ "type": "shell",
17
+ "command": "${TASKS_PATH}/open_example_model.sh"
18
+ },
19
+ {
20
+ "label": "run_ci",
21
+ "type": "shell",
22
+ "command": "${TASKS_PATH}/run_ci.sh",
23
+ "group": {
24
+ "kind": "test",
25
+ "isDefault": true
26
+ }
27
+ }
28
+ ]
29
+ }
mbse-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MBSE
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
mbse-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,169 @@
1
+ Metadata-Version: 2.4
2
+ Name: mbse
3
+ Version: 0.1.0
4
+ Summary: Python runtime and local web viewer for MBSE JSON models.
5
+ License-Expression: MIT
6
+ Project-URL: Repository, https://github.com/ferran-bofill-elausa/mbse
7
+ Project-URL: Issues, https://github.com/ferran-bofill-elausa/mbse/issues
8
+ Keywords: mbse,modeling,runtime,state-machine
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Requires-Python: >=3.11
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: Jinja2<4,>=3.1
16
+ Requires-Dist: jsonschema<5,>=4.26
17
+ Requires-Dist: referencing<1,>=0.36
18
+ Provides-Extra: test
19
+ Requires-Dist: pytest<10,>=9; extra == "test"
20
+ Requires-Dist: ruff<1,>=0.11; extra == "test"
21
+ Dynamic: license-file
22
+
23
+ # MBSE
24
+
25
+ Python runtime and local web viewer for MBSE JSON models.
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ pip install mbse
31
+ ```
32
+
33
+ The web viewer requires [Graphviz](https://graphviz.org/) and its `dot`
34
+ command on `PATH`.
35
+
36
+ ```bash
37
+ # Ubuntu/Debian
38
+ sudo apt install graphviz
39
+
40
+ # macOS
41
+ brew install graphviz
42
+ ```
43
+
44
+ On Windows, install Graphviz from its [download page](https://graphviz.org/download/)
45
+ and add its `bin` directory to `PATH`.
46
+
47
+ ## Model Validation And Discovery
48
+
49
+ Load a project to validate its project document and every recognized MBSE JSON
50
+ model below `project_root`. The registry rejects duplicate model ids, multiple
51
+ contexts, and invalid entrypoints.
52
+
53
+ ```python
54
+ from mbse.model.project.project_registry import ProjectRegistry
55
+
56
+ registry = ProjectRegistry.load("project.json")
57
+ models = registry.iterExecutableModels()
58
+ print([model.getDocumentId() for model in models])
59
+ ```
60
+
61
+ The registry validates JSON shape. Action-language handlers are normal Python
62
+ imports and must be available in the active environment when the runtime
63
+ executes them.
64
+
65
+ ## Automated Runtime Tests
66
+
67
+ ```python
68
+ from mbse.model.project.project_registry import ProjectRegistry
69
+ from mbse.runtime.runtime import Runtime
70
+
71
+ registry = ProjectRegistry.load("project.json")
72
+ runtime = Runtime()
73
+ runtime.init(registry)
74
+ runtime.play()
75
+ runtime.sendEvent("start") # A declared HSM event.
76
+
77
+ assert runtime.getState()["id"] == "running"
78
+ ```
79
+
80
+ Use `getExecutionLog()`, `getVariable()`, and `getState()` for assertions.
81
+ `sendEvent()` and `getState()` require an HSM project entrypoint. See the
82
+ [Runtime Layer](src/mbse/runtime/doc/runtime.md) for stepping and inspection.
83
+
84
+ ## Web Viewer
85
+
86
+ ```bash
87
+ mbse-view project.json --open-browser
88
+ ```
89
+
90
+ Run the packaged elevator example with nested Activity models:
91
+
92
+ ```bash
93
+ mbse-example-view
94
+ ```
95
+
96
+ The viewer lists every executable model, renders its diagram, and provides
97
+ events, typed variables, execution logs, model-call stepping, and breakpoints.
98
+ It is a local debugging tool that listens on `127.0.0.1` by default.
99
+
100
+ The viewer requires an HSM project entrypoint. Activity models can be rendered,
101
+ listed, and debugged when called from that entrypoint.
102
+
103
+ ## Documentation
104
+
105
+ - [Model Layer](src/mbse/model/doc/model.md): JSON schemas, validation, and
106
+ project discovery.
107
+ - [Context Model](src/mbse/model/context/doc/context_model.md),
108
+ [HSM Model](src/mbse/model/hsm/doc/hsm_model.md),
109
+ [Activity Model](src/mbse/model/activity/doc/activity_model.md), and
110
+ [Project Model](src/mbse/model/project/doc/project_model.md): authoring
111
+ formats.
112
+ - [Runtime Layer](src/mbse/runtime/doc/runtime.md): execution and test API.
113
+ - [HSM Runtime](src/mbse/runtime/hsm/doc/hsm_runtime.md) and
114
+ [Activity Runtime](src/mbse/runtime/activity/doc/activity_runtime.md):
115
+ execution semantics.
116
+ - [Viewer Server](src/mbse_web_viewer/server/doc/server.md),
117
+ [Render Layer](src/mbse_web_viewer/render/doc/render.md), and
118
+ [Browser Viewer](src/mbse_web_viewer/static/doc/static.md): local visual
119
+ debugging architecture.
120
+ - [Reference Project](tests/reference_model/project/doc/reference_project.md):
121
+ runnable multi-model fixture used by the test suite.
122
+ - [Elevator Example](src/mbse/examples/elevator/README.md): packaged viewer
123
+ demonstration with nested Activity models.
124
+ - [Test Suite](tests/): executable coverage and fixture documentation.
125
+
126
+ ## Development
127
+
128
+ ```bash
129
+ python -m venv .venv
130
+ source .venv/bin/activate
131
+ pip install -e ".[test]"
132
+ ruff check .
133
+ pytest
134
+ ```
135
+
136
+ VS Code users can run the `✅ Run CI` status-bar button to create `.venv` when
137
+ needed and execute the same validation steps as CI locally.
138
+
139
+ ## Releases
140
+
141
+ ### One-Time Setup
142
+
143
+ Configure a branch protection rule for `main` that requires pull requests and
144
+ the `CI / test` status check before merging. Do not push directly to `main`.
145
+
146
+ Configure a PyPI pending publisher with:
147
+
148
+ - Project name: `mbse`
149
+ - GitHub owner: `<owner>`
150
+ - Repository: `<repository>`
151
+ - Workflow: `release.yml`
152
+ - Environment: `pypi`
153
+
154
+ ### Change Flow
155
+
156
+ 1. Create a branch and open a pull request against `main`.
157
+ 2. Merge only after `CI / test` passes.
158
+
159
+ ### Release Flow
160
+
161
+ 1. After the release changes are merged, create and push a version tag:
162
+
163
+ ```bash
164
+ git tag v0.1.0
165
+ git push origin v0.1.0
166
+ ```
167
+
168
+ The publish workflow validates, builds, and uploads the package to PyPI. A
169
+ failed workflow never uploads a package, but does not remove the pushed tag.
mbse-0.1.0/README.md ADDED
@@ -0,0 +1,147 @@
1
+ # MBSE
2
+
3
+ Python runtime and local web viewer for MBSE JSON models.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install mbse
9
+ ```
10
+
11
+ The web viewer requires [Graphviz](https://graphviz.org/) and its `dot`
12
+ command on `PATH`.
13
+
14
+ ```bash
15
+ # Ubuntu/Debian
16
+ sudo apt install graphviz
17
+
18
+ # macOS
19
+ brew install graphviz
20
+ ```
21
+
22
+ On Windows, install Graphviz from its [download page](https://graphviz.org/download/)
23
+ and add its `bin` directory to `PATH`.
24
+
25
+ ## Model Validation And Discovery
26
+
27
+ Load a project to validate its project document and every recognized MBSE JSON
28
+ model below `project_root`. The registry rejects duplicate model ids, multiple
29
+ contexts, and invalid entrypoints.
30
+
31
+ ```python
32
+ from mbse.model.project.project_registry import ProjectRegistry
33
+
34
+ registry = ProjectRegistry.load("project.json")
35
+ models = registry.iterExecutableModels()
36
+ print([model.getDocumentId() for model in models])
37
+ ```
38
+
39
+ The registry validates JSON shape. Action-language handlers are normal Python
40
+ imports and must be available in the active environment when the runtime
41
+ executes them.
42
+
43
+ ## Automated Runtime Tests
44
+
45
+ ```python
46
+ from mbse.model.project.project_registry import ProjectRegistry
47
+ from mbse.runtime.runtime import Runtime
48
+
49
+ registry = ProjectRegistry.load("project.json")
50
+ runtime = Runtime()
51
+ runtime.init(registry)
52
+ runtime.play()
53
+ runtime.sendEvent("start") # A declared HSM event.
54
+
55
+ assert runtime.getState()["id"] == "running"
56
+ ```
57
+
58
+ Use `getExecutionLog()`, `getVariable()`, and `getState()` for assertions.
59
+ `sendEvent()` and `getState()` require an HSM project entrypoint. See the
60
+ [Runtime Layer](src/mbse/runtime/doc/runtime.md) for stepping and inspection.
61
+
62
+ ## Web Viewer
63
+
64
+ ```bash
65
+ mbse-view project.json --open-browser
66
+ ```
67
+
68
+ Run the packaged elevator example with nested Activity models:
69
+
70
+ ```bash
71
+ mbse-example-view
72
+ ```
73
+
74
+ The viewer lists every executable model, renders its diagram, and provides
75
+ events, typed variables, execution logs, model-call stepping, and breakpoints.
76
+ It is a local debugging tool that listens on `127.0.0.1` by default.
77
+
78
+ The viewer requires an HSM project entrypoint. Activity models can be rendered,
79
+ listed, and debugged when called from that entrypoint.
80
+
81
+ ## Documentation
82
+
83
+ - [Model Layer](src/mbse/model/doc/model.md): JSON schemas, validation, and
84
+ project discovery.
85
+ - [Context Model](src/mbse/model/context/doc/context_model.md),
86
+ [HSM Model](src/mbse/model/hsm/doc/hsm_model.md),
87
+ [Activity Model](src/mbse/model/activity/doc/activity_model.md), and
88
+ [Project Model](src/mbse/model/project/doc/project_model.md): authoring
89
+ formats.
90
+ - [Runtime Layer](src/mbse/runtime/doc/runtime.md): execution and test API.
91
+ - [HSM Runtime](src/mbse/runtime/hsm/doc/hsm_runtime.md) and
92
+ [Activity Runtime](src/mbse/runtime/activity/doc/activity_runtime.md):
93
+ execution semantics.
94
+ - [Viewer Server](src/mbse_web_viewer/server/doc/server.md),
95
+ [Render Layer](src/mbse_web_viewer/render/doc/render.md), and
96
+ [Browser Viewer](src/mbse_web_viewer/static/doc/static.md): local visual
97
+ debugging architecture.
98
+ - [Reference Project](tests/reference_model/project/doc/reference_project.md):
99
+ runnable multi-model fixture used by the test suite.
100
+ - [Elevator Example](src/mbse/examples/elevator/README.md): packaged viewer
101
+ demonstration with nested Activity models.
102
+ - [Test Suite](tests/): executable coverage and fixture documentation.
103
+
104
+ ## Development
105
+
106
+ ```bash
107
+ python -m venv .venv
108
+ source .venv/bin/activate
109
+ pip install -e ".[test]"
110
+ ruff check .
111
+ pytest
112
+ ```
113
+
114
+ VS Code users can run the `✅ Run CI` status-bar button to create `.venv` when
115
+ needed and execute the same validation steps as CI locally.
116
+
117
+ ## Releases
118
+
119
+ ### One-Time Setup
120
+
121
+ Configure a branch protection rule for `main` that requires pull requests and
122
+ the `CI / test` status check before merging. Do not push directly to `main`.
123
+
124
+ Configure a PyPI pending publisher with:
125
+
126
+ - Project name: `mbse`
127
+ - GitHub owner: `<owner>`
128
+ - Repository: `<repository>`
129
+ - Workflow: `release.yml`
130
+ - Environment: `pypi`
131
+
132
+ ### Change Flow
133
+
134
+ 1. Create a branch and open a pull request against `main`.
135
+ 2. Merge only after `CI / test` passes.
136
+
137
+ ### Release Flow
138
+
139
+ 1. After the release changes are merged, create and push a version tag:
140
+
141
+ ```bash
142
+ git tag v0.1.0
143
+ git push origin v0.1.0
144
+ ```
145
+
146
+ The publish workflow validates, builds, and uploads the package to PyPI. A
147
+ failed workflow never uploads a package, but does not remove the pushed tag.
@@ -0,0 +1,82 @@
1
+ [build-system]
2
+ requires = ["setuptools>=69", "setuptools-scm>=8", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "mbse"
7
+ dynamic = ["version"]
8
+ description = "Python runtime and local web viewer for MBSE JSON models."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ keywords = ["mbse", "modeling", "runtime", "state-machine"]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ ]
19
+ dependencies = [
20
+ "Jinja2>=3.1,<4",
21
+ "jsonschema>=4.26,<5",
22
+ "referencing>=0.36,<1",
23
+ ]
24
+
25
+ [project.scripts]
26
+ mbse-view = "mbse_web_viewer.server.viewer_app:main"
27
+ mbse-example-view = "mbse.examples.elevator:main"
28
+
29
+ [project.urls]
30
+ Repository = "https://github.com/ferran-bofill-elausa/mbse"
31
+ Issues = "https://github.com/ferran-bofill-elausa/mbse/issues"
32
+
33
+ [project.optional-dependencies]
34
+ test = [
35
+ "pytest>=9,<10",
36
+ "ruff>=0.11,<1",
37
+ ]
38
+
39
+ [tool.setuptools.packages.find]
40
+ where = ["src"]
41
+ namespaces = true
42
+
43
+ [tool.setuptools_scm]
44
+ version_scheme = "no-guess-dev"
45
+ local_scheme = "no-local-version"
46
+
47
+ [tool.setuptools.package-data]
48
+ "*" = [
49
+ "*.css",
50
+ "*.html",
51
+ "*.j2",
52
+ "*.js",
53
+ "*.json",
54
+ "*.md",
55
+ "*.svg",
56
+ ]
57
+
58
+ [tool.ruff]
59
+ line-length = 80
60
+ indent-width = 2
61
+ target-version = "py311"
62
+
63
+ [tool.ruff.lint]
64
+ # TODO: Restore "I" and fix the existing import ordering violations.
65
+ select = [
66
+ "E", # pycodestyle errors
67
+ "F", # pyflakes (real errors)
68
+ ]
69
+
70
+ # TODO: Fix the existing violations and remove these exceptions.
71
+ ignore = [
72
+ "E402", # Module docstrings intentionally follow future imports.
73
+ "E501", # Existing source has not yet been wrapped to the configured width.
74
+ ]
75
+
76
+ [tool.ruff.format]
77
+ quote-style = "double"
78
+ indent-style = "space"
79
+ line-ending = "lf"
80
+
81
+ [tool.pytest.ini_options]
82
+ testpaths = ["tests"]
mbse-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+