Skip to content
CompliatoryPublic

About

Medical-device manufacturer framework in C++23 — IEC 62304 Class B/C compliance modeling, Vulkan/Vulkan SC UI, zero-SOUP ML, byte-verified evidence

Topics

Resources

Contributing

Security policy

Stars

48 stars

Watchers

2 watching

Forks

Latest commit

 

History

810 Commits

Folders and files

Repository files navigation

MduX

An experimental C++23-modules UI library for medical-device software, built on Vulkan.

⚠️ Experimental proof-of-concept. Not for production use.

MduX explores whether C++23 modules, import std, and a mechanically enforced trust-zone split can carry the kind of evidence a regulated codebase needs. It requires cutting-edge toolchains and changes shape as that exploration continues.

This repository establishes no certification, validation, production readiness, or regulatory compliance. Nothing in it has been assessed by a notified body. The regulatory material under docs/ records how such work would be organised. It is not evidence that it has been done.

Status Version Windows CI Linux (GCC 16) CI macOS Apple Silicon CI Lint Compliance Docs

CodeQL OSV-Scanner OpenSSF Scorecard License: EUPL-1.2

What this actually is

A library with three zones, checked at configure time rather than by review (ADR-004):

  • Governed (MduXCore) — reaches std and nothing else. Frame description, evidence primitives, governance records, ML inference. Never throws.
  • Adapter (MduX) — the Vulkan renderer. The only zone that links Vulkan.
  • Host tools — bakers that run at authoring time and are never linked into a device target.

mdux_verify_trust_zones() walks the full link graph and fails the configure step if a governed target ever reaches Vulkan or a windowing library.

What it is not: a UI toolkit. The component dictionary is closed and compiled — a Label, a Button, a NumericDisplay and the rest are validated, laid out and budget-checked at build time — but the runtime draws only a Panel and a Label, so most of the dictionary has no appearance yet. See Implementation status. It is also not a quality-management system, a risk engine, or a lifecycle framework; there is no mdux::risk, mdux::qms or mdux::lifecycle namespace, and no code here generates a Design History File, a Risk Management File, or an audit trail.

Two ideas worth the tour

Evidence is baked, committed, and re-derived. A host tool turns a recipe into generated/<kind>/<id>/ — package.json, report.json, a payload — and those files are committed. CI re-runs the baker and asserts byte-identity. Five artifacts live there today: two shader packages, two ML model packages and one font package. A normal build never writes into the source tree (ADR-007).

Embedded ML with no foreign inference stack. mdux.ml.kernels is imported by both the device runtime and the host golden-vector generator — the same object file, so a golden-vector mismatch on device means the FPU or the toolchain differs, not that two implementations drifted. Classifier1D::create() verifies the weight digest and re-runs every golden vector bit-for-bit before it will construct, and refuses to if any diverge (ADR-008).

Quick look

import std;
import mdux;
import mdux.core.units;
import mdux.draw;

mdux::initialize();

// Governed: no Vulkan types, no allocation, storage supplied by the caller.
static std::array<mdux::draw::UiVertex, 64> vertices;
static std::array<mdux::draw::Index, 96> indices;
static std::array<mdux::draw::DrawCommand, 8> commands;
constexpr mdux::draw::DrawBudget budget{.maxVertices = 64, .maxIndices = 96, .maxCommands = 8};

auto list = mdux::draw::DrawList::create(vertices, indices, commands, budget);
if (!list.has_value()) {
    return handleError(mdux::draw::describe(list.error()));
}

// Every add* records the primitive completely or records nothing and returns an error.
// A frame that does not fit its budget is refused, never truncated.
constexpr mdux::core::ColorRgba8 statusGreen{.r = 60, .g = 107, .b = 44, .a = 255};
if (auto added = list->addSolidRect({.x = 16, .y = 64, .width = 120, .height = 24}, statusGreen);
    !added.has_value()) {
    return handleError(mdux::draw::describe(added.error()));
}

Every symbol above exists. A module is consumed with import, not #include of a .cppm, and mdux::initialize() takes no arguments — there is no MedicalDeviceContext.

examples/SimpleMedicalUiExample.cpp is the complete governed half, which needs no device and no window. examples/VulkanSCTriangleExample.cpp is the device half.

Getting started

Build, test, and consumption instructions are in docs/getting-started.md, including the honest limitations.

The short version:

mkdir build && cd build
cmake .. -G Ninja
cmake --build .
ctest --output-on-failure

Requires GCC 16+, MSVC 17.14+ or Clang 20+, CMake 4.0+, Ninja, and the Vulkan SDK 1.3+.

The verified macOS configuration is narrower: Apple Silicon, upstream Clang 23.1.6 with libc++, CMake 4.3.6, Ninja, and the LunarG Vulkan SDK/MoltenVK. Reproduce it with cmake --preset ninja-macos-clang; AppleClang, GCC on macOS, and Intel Macs are rejected.

-G Ninja is the one flag you cannot drop. CMake implements C++ modules for the Ninja and Visual Studio generators only, and Visual Studio cannot do import std — so Ninja is the entire supported set, and configuring without it stops with a message saying exactly that. To stop typing it, export CMAKE_GENERATOR=Ninja once and plain cmake .. works from then on.

If your default g++ is older than 16, point at a newer one with the standard variables: CXX=g++-16 CC=gcc-16 cmake .. -G Ninja.

CMakePresets.json also defines ninja-gcc, ninja-msvc, ninja-macos-clang and friends. Those exist so each CI leg can invoke a named configuration this repository owns rather than a command line that merely resembles one. They are not needed to build by hand, and nothing above uses them.

Implementation status

Derived from the targets and tests that build on develop.

Area Status What is actually there
Governed core (MduXCore, never links Vulkan)
mdux.core.result, mdux.core.units Implemented Result over std::expected; Px, Rect, ColorRgba8, Extent2D
mdux.draw Implemented 24-byte UiVertex, fixed-budget DrawList, explicit refusal on overflow
mdux.evidence.* Implemented SHA-256, canonical JSON, BakeReport
mdux.governance* Implemented governance records, compliance program types, traceability matrix export
mdux.shader.schema Implemented canonical shader package types; names no Vulkan type
mdux.ml.schema, .kernels, .runtime Implemented f32 kernels, fail-closed Classifier1D, no heap in predict()
Adapter zone (Vulkan)
mdux.render.vulkan Implemented pipeline built from a baked package, fixed-budget record()
mdux.render.offscreen Implemented headless target and CPU readback, used by the pixel test
mdux.vulkansc.* Partial memory-pool and device-object patterns; not true Vulkan SC
Host tools (never linked into a device target)
mdux-shaderbake, mdux-shaderemit Implemented SPIR-V reflection, byte-verified packages, generated C++
mdux-mlbake, mdux-mlemit Implemented safetensors import, golden generation, byte-verified model packages, generated constexpr metadata
MduXMeduiLib Implemented The .medui compiler end to end: parsing, semantic validation, integer-only bounded layout, per-locale text budgets, golden references, the canonical package, two C++ emitters, and the mdux-meduic / mdux-medui-check tools (#15)
Machine-readable .medui contract Implemented mdux-meduic --grammar emits the language as canonical JSON — tokens, productions, the component dictionary, field domains, the closed named-value sets, theme tokens and every diagnostic — read from the compiler's own tables rather than restated, and committed as docs/medui/grammar.json. mdux-meduic --explain MEDUI-E034 answers for one code and exits non-zero on one that is not registered (#263)
MduXVerifyUiLib, mdux-verify-ui Implemented host-only rendered-truth driver: artifact-derived obligations across every approved locale, offscreen Vulkan execution, and distinct failed-check / impossible-run outcomes (#253). Gated in CI as verify.screen.<id> on all four legs, with a PNG diff image uploaded on failure (#255, extended to Windows by #282)
Text and glyph rendering Implemented host-side shaping into baked runs, an R8 coverage atlas, and a governed draw path; a compiled screen's Label is joined to a text package at run time and drawn (#14, #242). A Button's label is drawn over its face since #261, which is where the rest of that sentence — a button is more than its text — was settled
Live-data components Implemented a NumericDisplay and a SignalTrace paint the field they reserve (#255) and the live content inside it: a waveform expanded from a caller-owned ring buffer (#257), and digits substituted into a pattern whose widest rendering the compiler measured against the node (#258). A Clock draws too; a StatusIndicator draws the state it is bound to, out of a list the compiler closed (#259); and a TextInput draws its value and caret on a fixed-pitch grid whose worst case the compiler measured against the box (#260) — display only, since #17 cuts input-method editing. All refuse rather than approximate — an over-long ring, a value with more digits than its slots, a state index the list does not have, a value longer than its field — and none allocates in a frame
Controls (Button, CriticalButton) Implemented #261. Both draw a face — the whole rectangle in the one token the node carries — with the label's word over it once a locale is bound. resolvePress() turns a surface coordinate into the control under it, the requirement it is traced to, and either a member of the closed SystemEvent set or a Button's product action name. A critical control naming an action outside that set, or declaring no requirement, refuses the press rather than reporting a no-op nothing performs. This completes the component dictionary (#17)
Host-tool manifest Implemented docs/tools/manifest.json lists every host tool with its entry point, command grammar, options, linked library, diagnostic-code family and the artifacts it bakes — generated from add_executable() and the mdux_bake_artifact() call sites rather than written, so a tool added to the build without regenerating fails CI (#265)
mdux-meduic --dump-ir Implemented the compiler's resolved intermediate representation as canonical JSON: the bounded box tree after layout, every authored field with its value, the RGBA each Theme.Colors.<Token> resolves to as u32 bit patterns, and the text budget each node was measured against (#265)
Recipe schemas Implemented one JSON Schema per baked kind under docs/recipes/, documenting the resolved option set each baker records in report.json — defaults expanded, per ADR-007 decision 4. Validated against every committed report in both directions by check_schema_type_drift.py, so a baker that adds an option and not the schema fails CI (#264)
mdux-docs-lint, mdux-evidence-lint Implemented run in CI
Regulatory material
Standards corpus under docs/ Documentation only five clause-structured references with generated indexes and schemas
Software Development File Documentation only templates and records under software_development_file/
Risk management, QMS, lifecycle code Not started no mdux::risk, mdux::qms or mdux::lifecycle exists

.medui reaches pixels today, and the path is built rather than planned. An authored screen is compiled by mdux-meduic into generated/screen/<id>/ — a package, a golden sidecar and a bake report, byte-compared across MSVC and GCC. Two emitters render that package as constexpr C++ carrying static_assert(screen.validate().has_value()), a governed runtime turns it into draw commands without allocating, and mdux.render.vulkan draws them. ScreenPixelTests walks the whole chain and compares the result pixel by pixel under lavapipe in CI.

A font package and a text package are both baked and committed (generated/font/dejavu-ui/, generated/text/endoscope-monitor-en-us/), so the committed screen carries a t("STR-KEY") and its box is measured, at build time, against the widest translation every approved locale holds, and its label reaches the display: the governed runtime joins the compiled screen to the text package for the locale it is running and records the baked glyph runs (#242). One limit is worth stating beside that: the remaining components are still counted as deferred, because a Button is more than its text and live-data components have no geometry until a frame exists (#17). The committed screen renders a bar and a title — from files an author wrote, through every stage, with nothing hand-carried between them.

The HTML/CSS path that earlier revisions described was deleted by #127 — MedicalUiRenderer::render() recorded no Vulkan commands. mdux.draw plus mdux.render.vulkan replaced it.

Regulatory material, and what it is for

docs/iec62304/, docs/iso13485/, docs/iso14971/, docs/iec62366/, docs/iec81001/ and docs/iec60601-1-8/ are clause-structured reference modules with per-clause indexes and JSON Schemas, linted in CI. They state, per clause, either the concrete mechanism this repository provides or that none exists — the second answer appears often, and deliberately.

docs/governance/ holds the citation convention, the SOUP register, and a record of every retired document and why.

MduX is a software library, not a manufacturer. It runs no management review, no CAPA process and no supplier qualification, and it has no customers of its own. Integrating it does not transfer any regulatory obligation away from the manufacturer. See docs/regulatory-compliance.md for the scope limits this project claims, and ADR-006 for why no normative standard text appears in this tree.

Documentation

docs/architecture.md what is in the tree, and what is planned
docs/getting-started.md building, testing, consuming, and the limitations
docs/adr/ the decision trail — start with ADR-004
docs/regulatory-compliance.md what this project does and does not claim
CONTRIBUTING.md style, formatting, PR conventions
AGENTS.md guidance for coding agents and contributors

The roadmap is tracked as GitHub epics #7–#19.

Contributing

See CONTRIBUTING.md. In short: match the surrounding style, add tests proportionate to the change, update the affected documentation and ADRs, and do not introduce a certification or compliance claim.

License

Available under the European Union Public Licence 1.2, or under separate commercial terms. See LICENSING.md.

Contact

Open an issue.

About

Medical-device manufacturer framework in C++23 — IEC 62304 Class B/C compliance modeling, Vulkan/Vulkan SC UI, zero-SOUP ML, byte-verified evidence

Topics

Resources

Contributing

Security policy

Stars

48 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages