@memoarchitect/ontology 0.6.3 → 0.6.5

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 (46) hide show
  1. package/README.md +25 -3
  2. package/examples/embedded-infusion-pump/model/catalog/embedded_infusion_pump.sysml +1 -1
  3. package/examples/gpca-pump/analysis/Samples/01-model-overview.ipynb +148 -0
  4. package/examples/gpca-pump/analysis/Samples/02-architecture-hotspots.ipynb +301 -0
  5. package/examples/gpca-pump/analysis/Samples/03-model-quality.ipynb +229 -0
  6. package/examples/gpca-pump/analysis/Samples/04-change-impact-explorer.ipynb +200 -0
  7. package/examples/gpca-pump/analysis/Samples/05-model-charts.ipynb +188 -0
  8. package/examples/gpca-pump/analysis/Samples/06-ownership-graph.ipynb +173 -0
  9. package/examples/gpca-pump/analysis/Samples/07-model-inventory-table.ipynb +180 -0
  10. package/examples/gpca-pump/analysis/Samples/README.md +37 -0
  11. package/examples/gpca-pump/model/catalog/gpca_architecture.sysml +21 -11
  12. package/examples/gpca-pump/model/catalog/gpca_behavior_actions.sysml +1 -1
  13. package/examples/gpca-pump/model/catalog/gpca_behavior_modes.sysml +7 -1
  14. package/examples/gpca-pump/model/catalog/gpca_cybersecurity.sysml +1 -1
  15. package/examples/gpca-pump/model/catalog/gpca_interfaces.sysml +34 -5
  16. package/examples/gpca-pump/model/catalog/gpca_requirements.sysml +104 -104
  17. package/examples/gpca-pump/model/catalog/gpca_risk.sysml +9 -0
  18. package/examples/gpca-pump/model/catalog/gpca_trace.sysml +36 -12
  19. package/examples/gpca-pump/model/views/logical_device_interconnect_view.sysml +3 -3
  20. package/examples/sysml-diagram-samples/model/samples/requirements_view.sysml +2 -2
  21. package/examples/sysml-diagram-samples/model/samples/use_case_view.sysml +4 -4
  22. package/methodologies/default/memo.package.yaml +1 -1
  23. package/methodologies/gpca/memo.package.yaml +1 -1
  24. package/ontology/memo.package.yaml +1 -1
  25. package/package.json +5 -3
  26. package/profile/memo.package.yaml +1 -1
  27. package/src/architecture/implementation/software/structure/memo_software_structure.sysml +3 -3
  28. package/src/architecture/implementation/ui/memo_ui.sysml +1 -1
  29. package/src/architecture/operational/context/stakeholders/memo_stakeholders.sysml +2 -2
  30. package/src/architecture/operational/context/use_context/memo_use_context.sysml +26 -1
  31. package/src/architecture/operational/scenarios/memo_scenarios.sysml +1 -1
  32. package/src/architecture/operational/use_cases/memo_use_cases.sysml +1 -1
  33. package/src/architecture/operational/workflows/memo_workflows.sysml +2 -2
  34. package/src/architecture/realization/deployment/memo_deployment.sysml +2 -2
  35. package/src/assurance/cybersecurity/memo_cybersecurity.sysml +0 -1
  36. package/src/assurance/requirements/memo_requirements.sysml +1 -1
  37. package/src/assurance/requirements/needs/memo_needs.sysml +1 -1
  38. package/src/compliance/artifacts/memo_artifacts.sysml +0 -1
  39. package/src/core/common/memo_common.sysml +3 -1
  40. package/src/core/enumerations/memo_enumerations.sysml +17 -1
  41. package/src/core/relationships/memo_relationships.sysml +9 -5
  42. package/src/memo_namespaces.sysml +2 -2
  43. package/src/methodology/profiles/memo_profiles.sysml +6 -22
  44. package/src/rules/ontology/ontology_invariants.sysml +13 -0
  45. package/src/viewpoints/context/context_viewpoint.sysml +10 -1
  46. package/src/viewpoints/definitions/memo_viewpoint_definitions.sysml +2 -0
package/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # @memoarchitect/ontology
2
2
 
3
+ [Product website](https://memoarchitect.com/memo.html) ·
4
+ [Documentation](https://memoarchitect.com/memo/) ·
5
+ [GitHub repository](https://github.com/memoarchitect/memo) ·
6
+ [npm package](https://www.npmjs.com/package/@memoarchitect/ontology)
7
+
3
8
  **MEMO — Medical Engineering Modelling Ontology** — the pure SysML v2 content layer.
4
9
 
5
10
  A standalone, tool-portable SysML v2 / KerML ontology for medical-device architecture
@@ -18,24 +23,41 @@ pin an exact release; the package has no repository or runtime dependency on Mem
18
23
  Tools or Memo Architect.
19
24
 
20
25
  ```bash
21
- pnpm add @memoarchitect/ontology@0.6.2
26
+ pnpm add @memoarchitect/ontology@0.6.4
22
27
  ```
23
28
 
29
+ > **Pre-1.0 notice:** ontology names, relationships, and package layout may
30
+ > change before 1.0. Use the exact npm version above or a
31
+ > [tagged release](https://github.com/memoarchitect/memo/releases) rather than
32
+ > tracking `main` for reproducible project work.
33
+
24
34
  For coordinated development, the private `memo-meta` workspace checks out
25
35
  Ontology, Tools, and Architect as sibling repositories and links this package
26
36
  into its dependants with meta-only pnpm overrides.
27
37
 
38
+ `VERSION` is the sole release-version source for this repository. Run
39
+ `pnpm version:sync` after changing it; CI rejects unsynchronized manifests and
40
+ automatically creates the matching `v<version>` tag when the change reaches
41
+ `main`.
42
+
28
43
  ## Documentation
29
44
 
30
- Start with the [user guide](docs/index.md) to learn MEMO's layer model, choose
45
+ Start with the [published documentation](https://memoarchitect.com/memo/) to learn
46
+ MEMO's layer model, choose
31
47
  elements and relationships, and follow the GPCA pump example. The reference
32
- section describes packages, source layout, and maintenance. Build the site with:
48
+ section describes packages, source layout, and maintenance. Its source starts at
49
+ [`docs/index.md`](docs/index.md). Build the site with:
33
50
 
34
51
  ```bash
35
52
  python3 -m pip install "mkdocs>=1.6" "mkdocs-material>=9.5" "pymdown-extensions>=10.0"
36
53
  pnpm run docs:build
37
54
  ```
38
55
 
56
+ Related products: [MEMO Tools documentation](https://memoarchitect.com/memo-tools/)
57
+ and [repository](https://github.com/memoarchitect/memo-tools) ·
58
+ [MEMO Architect documentation](https://memoarchitect.com/memo-architect/)
59
+ and [repository](https://github.com/memoarchitect/memo-architect).
60
+
39
61
  ## Layout
40
62
 
41
63
  The package exposes four logical MEMO packages through `memo.manifest.yaml`.
@@ -14,7 +14,7 @@ package memo_examples_embedded_infusion_pump {
14
14
 
15
15
  // Module view (IEC 62304).
16
16
  part swInfusionControl : SoftwareModule {
17
- attribute :>> moduleKind = ModuleKind::item;
17
+ attribute :>> moduleKind = ModuleKind::'item';
18
18
  attribute :>> id = "EIP-SW-001"; attribute :>> name = "InfusionControlItem";
19
19
  attribute :>> iec62304Role = "software item, class C";
20
20
  attribute :>> safetyClass = SafetyClassKind::C;
@@ -0,0 +1,148 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "memo-1",
6
+ "metadata": {},
7
+ "source": [
8
+ "# Model overview\n",
9
+ "\n",
10
+ "Visual summary of model size, semantic content, and diagnostics.\n",
11
+ "\n",
12
+ "This sample uses only standard SysML v2 concepts and automatically discovers the project's `model/` or `src/` directory."
13
+ ]
14
+ },
15
+ {
16
+ "cell_type": "code",
17
+ "execution_count": 1,
18
+ "id": "memo-2",
19
+ "metadata": {
20
+ "execution": {
21
+ "iopub.execute_input": "2026-07-29T22:31:46.345732Z",
22
+ "iopub.status.busy": "2026-07-29T22:31:46.345598Z",
23
+ "iopub.status.idle": "2026-07-29T22:31:46.699014Z",
24
+ "shell.execute_reply": "2026-07-29T22:31:46.698564Z"
25
+ }
26
+ },
27
+ "outputs": [
28
+ {
29
+ "name": "stdout",
30
+ "output_type": "stream",
31
+ "text": [
32
+ "Loaded 42 SysML files from /Users/poojakashyap/sandbox/memo-meta/memo/examples/gpca-pump/model\n"
33
+ ]
34
+ }
35
+ ],
36
+ "source": [
37
+ "from pathlib import Path\n",
38
+ "from collections import Counter, defaultdict\n",
39
+ "import syside\n",
40
+ "\n",
41
+ "def find_sysml_root(start=Path.cwd()):\n",
42
+ " \"\"\"Find the nearest model/ or src/ folder containing textual SysML.\"\"\"\n",
43
+ " for directory in (start, *start.parents):\n",
44
+ " for folder_name in ('model', 'src'):\n",
45
+ " candidate = directory / folder_name\n",
46
+ " if candidate.is_dir() and next(candidate.rglob('*.sysml'), None):\n",
47
+ " return candidate\n",
48
+ " raise FileNotFoundError('No model/ or src/ directory containing .sysml files was found')\n",
49
+ "\n",
50
+ "SYSML_ROOT = find_sysml_root()\n",
51
+ "SYSML_FILES = sorted(SYSML_ROOT.rglob('*.sysml'))\n",
52
+ "model, diagnostics = syside.try_load_model([str(path) for path in SYSML_FILES])\n",
53
+ "print(f'Loaded {len(SYSML_FILES)} SysML files from {SYSML_ROOT}')"
54
+ ]
55
+ },
56
+ {
57
+ "cell_type": "code",
58
+ "execution_count": 2,
59
+ "id": "memo-3",
60
+ "metadata": {
61
+ "execution": {
62
+ "iopub.execute_input": "2026-07-29T22:31:46.700004Z",
63
+ "iopub.status.busy": "2026-07-29T22:31:46.699937Z",
64
+ "iopub.status.idle": "2026-07-29T22:31:46.707568Z",
65
+ "shell.execute_reply": "2026-07-29T22:31:46.707310Z"
66
+ }
67
+ },
68
+ "outputs": [
69
+ {
70
+ "data": {
71
+ "text/html": [
72
+ "<h3>Semantic inventory</h3><table><tr><th>Element type</th><th>Count</th><th>Relative size</th></tr><tr><td>AttributeUsage</td><td>5,056</td><td><div style=\"background:#2d8d70;height:12px;width:320px\"></div></td></tr><tr><td>ConnectionUsage</td><td>691</td><td><div style=\"background:#2d8d70;height:12px;width:44px\"></div></td></tr><tr><td>PartUsage</td><td>425</td><td><div style=\"background:#2d8d70;height:12px;width:27px\"></div></td></tr><tr><td>RequirementUsage</td><td>105</td><td><div style=\"background:#2d8d70;height:12px;width:7px\"></div></td></tr><tr><td>ActionUsage</td><td>44</td><td><div style=\"background:#2d8d70;height:12px;width:3px\"></div></td></tr><tr><td>Package</td><td>42</td><td><div style=\"background:#2d8d70;height:12px;width:3px\"></div></td></tr><tr><td>StateUsage</td><td>10</td><td><div style=\"background:#2d8d70;height:12px;width:2px\"></div></td></tr><tr><td>ActionDefinition</td><td>6</td><td><div style=\"background:#2d8d70;height:12px;width:2px\"></div></td></tr><tr><td>PortDefinition</td><td>1</td><td><div style=\"background:#2d8d70;height:12px;width:2px\"></div></td></tr><tr><td>PartDefinition</td><td>0</td><td><div style=\"background:#2d8d70;height:12px;width:2px\"></div></td></tr><tr><td>RequirementDefinition</td><td>0</td><td><div style=\"background:#2d8d70;height:12px;width:2px\"></div></td></tr><tr><td>PortUsage</td><td>0</td><td><div style=\"background:#2d8d70;height:12px;width:2px\"></div></td></tr><tr><td>ConnectionDefinition</td><td>0</td><td><div style=\"background:#2d8d70;height:12px;width:2px\"></div></td></tr><tr><td>StateDefinition</td><td>0</td><td><div style=\"background:#2d8d70;height:12px;width:2px\"></div></td></tr><tr><td>AttributeDefinition</td><td>0</td><td><div style=\"background:#2d8d70;height:12px;width:2px\"></div></td></tr></table>"
73
+ ],
74
+ "text/plain": [
75
+ "<IPython.core.display.HTML object>"
76
+ ]
77
+ },
78
+ "metadata": {},
79
+ "output_type": "display_data"
80
+ },
81
+ {
82
+ "data": {
83
+ "text/plain": [
84
+ "{'SysML files': 42, 'Errors': 8009, 'Warnings': 0, 'Information': 0}"
85
+ ]
86
+ },
87
+ "execution_count": 2,
88
+ "metadata": {},
89
+ "output_type": "execute_result"
90
+ }
91
+ ],
92
+ "source": [
93
+ "from IPython.display import HTML, display\n",
94
+ "\n",
95
+ "semantic_types = [\n",
96
+ " 'Package', 'PartDefinition', 'PartUsage', 'RequirementDefinition',\n",
97
+ " 'RequirementUsage', 'ActionDefinition', 'ActionUsage', 'PortDefinition',\n",
98
+ " 'PortUsage', 'ConnectionDefinition', 'ConnectionUsage', 'StateDefinition',\n",
99
+ " 'StateUsage', 'AttributeDefinition', 'AttributeUsage'\n",
100
+ "]\n",
101
+ "counts = {}\n",
102
+ "for type_name in semantic_types:\n",
103
+ " node_type = getattr(syside, type_name, None)\n",
104
+ " if node_type is not None:\n",
105
+ " counts[type_name] = len(list(model.elements(node_type)))\n",
106
+ "\n",
107
+ "largest = max(counts.values(), default=1)\n",
108
+ "rows = ''.join(\n",
109
+ " f'<tr><td>{name}</td><td>{count:,}</td><td><div style=\"background:#2d8d70;height:12px;width:{max(2, count * 320 / largest):.0f}px\"></div></td></tr>'\n",
110
+ " for name, count in sorted(counts.items(), key=lambda item: item[1], reverse=True)\n",
111
+ ")\n",
112
+ "display(HTML(f'<h3>Semantic inventory</h3><table><tr><th>Element type</th><th>Count</th><th>Relative size</th></tr>{rows}</table>'))\n",
113
+ "\n",
114
+ "{\n",
115
+ " 'SysML files': len(SYSML_FILES),\n",
116
+ " 'Errors': len(list(diagnostics.errors)),\n",
117
+ " 'Warnings': len(list(diagnostics.warnings)),\n",
118
+ " 'Information': len(list(diagnostics.infos)),\n",
119
+ "}"
120
+ ]
121
+ }
122
+ ],
123
+ "metadata": {
124
+ "kernelspec": {
125
+ "display_name": "Python 3 (ipykernel)",
126
+ "language": "python",
127
+ "name": "python3"
128
+ },
129
+ "language_info": {
130
+ "codemirror_mode": {
131
+ "name": "ipython",
132
+ "version": 3
133
+ },
134
+ "file_extension": ".py",
135
+ "mimetype": "text/x-python",
136
+ "name": "python",
137
+ "nbconvert_exporter": "python",
138
+ "pygments_lexer": "ipython3",
139
+ "version": "3.12.13"
140
+ },
141
+ "memo": {
142
+ "description": "Visual summary of model size, semantic content, and diagnostics.",
143
+ "starter": true
144
+ }
145
+ },
146
+ "nbformat": 4,
147
+ "nbformat_minor": 5
148
+ }
@@ -0,0 +1,301 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "memo-1",
6
+ "metadata": {},
7
+ "source": [
8
+ "# Architecture hotspots\n",
9
+ "\n",
10
+ "Find busy containers, deep ownership paths, and dominant semantic types.\n",
11
+ "\n",
12
+ "This sample uses only standard SysML v2 concepts and automatically discovers the project's `model/` or `src/` directory."
13
+ ]
14
+ },
15
+ {
16
+ "cell_type": "code",
17
+ "execution_count": 1,
18
+ "id": "memo-2",
19
+ "metadata": {
20
+ "execution": {
21
+ "iopub.execute_input": "2026-07-29T22:31:48.480637Z",
22
+ "iopub.status.busy": "2026-07-29T22:31:48.480406Z",
23
+ "iopub.status.idle": "2026-07-29T22:31:48.765461Z",
24
+ "shell.execute_reply": "2026-07-29T22:31:48.765134Z"
25
+ }
26
+ },
27
+ "outputs": [
28
+ {
29
+ "name": "stdout",
30
+ "output_type": "stream",
31
+ "text": [
32
+ "Loaded 42 SysML files from /Users/poojakashyap/sandbox/memo-meta/memo/examples/gpca-pump/model\n"
33
+ ]
34
+ }
35
+ ],
36
+ "source": [
37
+ "from pathlib import Path\n",
38
+ "from collections import Counter, defaultdict\n",
39
+ "import syside\n",
40
+ "\n",
41
+ "def find_sysml_root(start=Path.cwd()):\n",
42
+ " \"\"\"Find the nearest model/ or src/ folder containing textual SysML.\"\"\"\n",
43
+ " for directory in (start, *start.parents):\n",
44
+ " for folder_name in ('model', 'src'):\n",
45
+ " candidate = directory / folder_name\n",
46
+ " if candidate.is_dir() and next(candidate.rglob('*.sysml'), None):\n",
47
+ " return candidate\n",
48
+ " raise FileNotFoundError('No model/ or src/ directory containing .sysml files was found')\n",
49
+ "\n",
50
+ "SYSML_ROOT = find_sysml_root()\n",
51
+ "SYSML_FILES = sorted(SYSML_ROOT.rglob('*.sysml'))\n",
52
+ "model, diagnostics = syside.try_load_model([str(path) for path in SYSML_FILES])\n",
53
+ "print(f'Loaded {len(SYSML_FILES)} SysML files from {SYSML_ROOT}')"
54
+ ]
55
+ },
56
+ {
57
+ "cell_type": "code",
58
+ "execution_count": 2,
59
+ "id": "memo-3",
60
+ "metadata": {
61
+ "execution": {
62
+ "iopub.execute_input": "2026-07-29T22:31:48.768663Z",
63
+ "iopub.status.busy": "2026-07-29T22:31:48.768585Z",
64
+ "iopub.status.idle": "2026-07-29T22:31:48.814237Z",
65
+ "shell.execute_reply": "2026-07-29T22:31:48.813848Z"
66
+ }
67
+ },
68
+ "outputs": [
69
+ {
70
+ "name": "stdout",
71
+ "output_type": "stream",
72
+ "text": [
73
+ "Top containers by directly owned semantic elements\n"
74
+ ]
75
+ },
76
+ {
77
+ "data": {
78
+ "text/plain": [
79
+ "[(19,\n",
80
+ " 'RequirementUsage',\n",
81
+ " 'memo_examples_gpca_pump_model_catalog_gpca_requirements::reqWatchdogSafeState'),\n",
82
+ " (19,\n",
83
+ " 'RequirementUsage',\n",
84
+ " 'memo_examples_gpca_pump_model_catalog_gpca_requirements::reqDoorOpen'),\n",
85
+ " (18,\n",
86
+ " 'RequirementUsage',\n",
87
+ " 'memo_examples_gpca_pump_model_catalog_gpca_requirements::reqPowerLossRetention'),\n",
88
+ " (18,\n",
89
+ " 'RequirementUsage',\n",
90
+ " 'memo_examples_gpca_pump_model_catalog_gpca_requirements::reqPost'),\n",
91
+ " (18,\n",
92
+ " 'RequirementUsage',\n",
93
+ " 'memo_examples_gpca_pump_model_catalog_gpca_requirements::reqDrugLibraryLimits'),\n",
94
+ " (18,\n",
95
+ " 'ActionUsage',\n",
96
+ " 'memo_examples_gpca_pump_model_catalog_gpca_behavior_actions::infusionDeliveryFlow'),\n",
97
+ " (17,\n",
98
+ " 'ViewUsage',\n",
99
+ " 'memo_examples_gpca_pump_model_views_logical_system_decomposition_view::gpcaSystemDecompositionView'),\n",
100
+ " (16,\n",
101
+ " 'ViewUsage',\n",
102
+ " 'memo_examples_gpca_pump_model_views_software_software_architecture_view::gpcaSoftwareArchitectureView'),\n",
103
+ " (16,\n",
104
+ " 'ViewUsage',\n",
105
+ " 'memo_examples_gpca_pump_model_views_risk_risk_chain_view::gpcaRiskChainView'),\n",
106
+ " (16,\n",
107
+ " 'ViewUsage',\n",
108
+ " 'memo_examples_gpca_pump_model_views_operational_use_case_view::gpcaUseCaseView'),\n",
109
+ " (16,\n",
110
+ " 'ViewUsage',\n",
111
+ " 'memo_examples_gpca_pump_model_views_logical_mode_state_view::gpcaModeStateView'),\n",
112
+ " (16,\n",
113
+ " 'ViewUsage',\n",
114
+ " 'memo_examples_gpca_pump_model_views_logical_logical_architecture_view::gpcaLogicalArchitectureView'),\n",
115
+ " (16,\n",
116
+ " 'ViewUsage',\n",
117
+ " 'memo_examples_gpca_pump_model_views_logical_device_interconnect_view::gpcaDeviceInterconnectView'),\n",
118
+ " (16,\n",
119
+ " 'ViewUsage',\n",
120
+ " 'memo_examples_gpca_pump_model_views_document_dhf_index_view::dhfIndexView'),\n",
121
+ " (16,\n",
122
+ " 'ViewUsage',\n",
123
+ " 'memo_examples_gpca_pump_model_views_document_architecture_description_view::architectureDescriptionView'),\n",
124
+ " (16,\n",
125
+ " 'ViewUsage',\n",
126
+ " 'memo_examples_gpca_pump_model_views_cybersecurity_cybersecurity_view::gpcaCybersecurityView'),\n",
127
+ " (16,\n",
128
+ " 'ViewUsage',\n",
129
+ " 'memo_examples_gpca_pump_model_views_context_system_context_view::gpcaSystemContextView'),\n",
130
+ " (16,\n",
131
+ " 'ViewUsage',\n",
132
+ " 'memo_examples_gpca_pump_model_views_behavior_action_flow_view::gpcaActionFlowView'),\n",
133
+ " (15,\n",
134
+ " 'ViewUsage',\n",
135
+ " 'memo_examples_gpca_pump_model_views_verification_verification_coverage_view::gpcaVerificationCoverageView'),\n",
136
+ " (15,\n",
137
+ " 'ViewUsage',\n",
138
+ " 'memo_examples_gpca_pump_model_views_risk_fmea_view::gpcaFmeaView'),\n",
139
+ " (15,\n",
140
+ " 'ViewUsage',\n",
141
+ " 'memo_examples_gpca_pump_model_views_requirements_requirements_trace_view::gpcaRequirementsTraceView'),\n",
142
+ " (15,\n",
143
+ " 'ViewUsage',\n",
144
+ " 'memo_examples_gpca_pump_model_views_physical_physical_bom_view::gpcaPhysicalBomView'),\n",
145
+ " (15,\n",
146
+ " 'ViewUsage',\n",
147
+ " 'memo_examples_gpca_pump_model_views_operational_scenario_sequence_view::gpcaScenarioSequenceView'),\n",
148
+ " (15,\n",
149
+ " 'ViewUsage',\n",
150
+ " 'memo_examples_gpca_pump_model_views_functional_function_browser_view::gpcaFunctionBrowserView'),\n",
151
+ " (15,\n",
152
+ " 'ViewUsage',\n",
153
+ " 'memo_examples_gpca_pump_model_views_functional_function_allocation_view::gpcaFunctionAllocationView')]"
154
+ ]
155
+ },
156
+ "metadata": {},
157
+ "output_type": "display_data"
158
+ },
159
+ {
160
+ "name": "stdout",
161
+ "output_type": "stream",
162
+ "text": [
163
+ "Deepest ownership paths\n"
164
+ ]
165
+ },
166
+ {
167
+ "data": {
168
+ "text/plain": [
169
+ "[(5, 'ReferenceUsage', 'sensorStatus'),\n",
170
+ " (5, 'ReferenceUsage', 'sensorStatus'),\n",
171
+ " (5, 'ReferenceUsage', 'flowCommand'),\n",
172
+ " (5, 'ReferenceUsage', 'flowCommand'),\n",
173
+ " (5, 'ReferenceUsage', 'authorizedBolus'),\n",
174
+ " (5, 'ReferenceUsage', 'authorizedBolus'),\n",
175
+ " (5, 'ReferenceUsage', 'alarmSignal'),\n",
176
+ " (5, 'ReferenceUsage', 'alarmSignal'),\n",
177
+ " (5, 'ReferenceUsage', 'actuation'),\n",
178
+ " (5, 'ReferenceUsage', 'actuation'),\n",
179
+ " (4, 'AttributeUsage', '<unnamed>'),\n",
180
+ " (4, 'AttributeUsage', '<unnamed>'),\n",
181
+ " (4, 'AttributeUsage', '<unnamed>'),\n",
182
+ " (4, 'AttributeUsage', '<unnamed>'),\n",
183
+ " (4, 'AttributeUsage', '<unnamed>'),\n",
184
+ " (4, 'AttributeUsage', '<unnamed>'),\n",
185
+ " (4, 'AttributeUsage', '<unnamed>'),\n",
186
+ " (4, 'AttributeUsage', '<unnamed>'),\n",
187
+ " (4, 'AttributeUsage', '<unnamed>'),\n",
188
+ " (4, 'AttributeUsage', '<unnamed>'),\n",
189
+ " (4, 'AttributeUsage', '<unnamed>'),\n",
190
+ " (4, 'AttributeUsage', '<unnamed>'),\n",
191
+ " (4, 'AttributeUsage', '<unnamed>'),\n",
192
+ " (4, 'AttributeUsage', '<unnamed>'),\n",
193
+ " (4, 'AttributeUsage', '<unnamed>')]"
194
+ ]
195
+ },
196
+ "metadata": {},
197
+ "output_type": "display_data"
198
+ },
199
+ {
200
+ "name": "stdout",
201
+ "output_type": "stream",
202
+ "text": [
203
+ "Most common semantic types\n"
204
+ ]
205
+ },
206
+ {
207
+ "data": {
208
+ "text/plain": [
209
+ "[('AttributeUsage', 5056),\n",
210
+ " ('ConnectionUsage', 691),\n",
211
+ " ('PartUsage', 425),\n",
212
+ " ('ReferenceUsage', 174),\n",
213
+ " ('RequirementUsage', 105),\n",
214
+ " ('ItemUsage', 49),\n",
215
+ " ('ActionUsage', 44),\n",
216
+ " ('SuccessionAsUsage', 29),\n",
217
+ " ('VerificationCaseUsage', 27),\n",
218
+ " ('ViewUsage', 26),\n",
219
+ " ('InterfaceUsage', 14),\n",
220
+ " ('StateUsage', 10),\n",
221
+ " ('AllocationUsage', 6),\n",
222
+ " ('ActionDefinition', 6),\n",
223
+ " ('FlowUsage', 5),\n",
224
+ " ('ItemDefinition', 5),\n",
225
+ " ('UseCaseUsage', 1),\n",
226
+ " ('PortDefinition', 1),\n",
227
+ " ('ConjugatedPortDefinition', 1),\n",
228
+ " ('InterfaceDefinition', 1)]"
229
+ ]
230
+ },
231
+ "execution_count": 2,
232
+ "metadata": {},
233
+ "output_type": "execute_result"
234
+ }
235
+ ],
236
+ "source": [
237
+ "from IPython.display import display\n",
238
+ "\n",
239
+ "semantic_elements = (\n",
240
+ " list(model.elements(syside.Usage, include_subtypes=True))\n",
241
+ " + list(model.elements(syside.Definition, include_subtypes=True))\n",
242
+ ")\n",
243
+ "\n",
244
+ "def safe_name(element):\n",
245
+ " value = element.qualified_name or element.name or element.declared_name\n",
246
+ " return str(value) if value else '<unnamed>'\n",
247
+ "\n",
248
+ "def ownership_depth(element):\n",
249
+ " depth, current, seen = 0, element.owner, set()\n",
250
+ " while current is not None and id(current) not in seen:\n",
251
+ " seen.add(id(current))\n",
252
+ " depth += 1\n",
253
+ " current = getattr(current, 'owner', None)\n",
254
+ " return depth\n",
255
+ "\n",
256
+ "containers = []\n",
257
+ "for element in semantic_elements:\n",
258
+ " children = [child for child in element.owned_elements if isinstance(child, (syside.Usage, syside.Definition))]\n",
259
+ " if children:\n",
260
+ " containers.append((len(children), type(element).__name__, safe_name(element)))\n",
261
+ "\n",
262
+ "print('Top containers by directly owned semantic elements')\n",
263
+ "display(sorted(containers, reverse=True)[:25])\n",
264
+ "\n",
265
+ "print('Deepest ownership paths')\n",
266
+ "display(sorted(\n",
267
+ " ((ownership_depth(item), type(item).__name__, safe_name(item)) for item in semantic_elements),\n",
268
+ " reverse=True,\n",
269
+ ")[:25])\n",
270
+ "\n",
271
+ "print('Most common semantic types')\n",
272
+ "Counter(type(item).__name__ for item in semantic_elements).most_common(30)"
273
+ ]
274
+ }
275
+ ],
276
+ "metadata": {
277
+ "kernelspec": {
278
+ "display_name": "Python 3 (ipykernel)",
279
+ "language": "python",
280
+ "name": "python3"
281
+ },
282
+ "language_info": {
283
+ "codemirror_mode": {
284
+ "name": "ipython",
285
+ "version": 3
286
+ },
287
+ "file_extension": ".py",
288
+ "mimetype": "text/x-python",
289
+ "name": "python",
290
+ "nbconvert_exporter": "python",
291
+ "pygments_lexer": "ipython3",
292
+ "version": "3.12.13"
293
+ },
294
+ "memo": {
295
+ "description": "Find busy containers, deep ownership paths, and dominant semantic types.",
296
+ "starter": true
297
+ }
298
+ },
299
+ "nbformat": 4,
300
+ "nbformat_minor": 5
301
+ }