Development¶
Contributions are welcome. The repository is matthiaskoenig/simrun; development happens against the develop branch via pull requests.
Branch model¶
Two branches are permanent:
developis the default branch and the branch everything is integrated into. The documentation on matthiaskoenig.github.io/simrun is published from it.maintracks the latest published release. It is fast-forwarded to the released commit by thesync-mainjob of theCI-CDworkflow after the package went to PyPI, somainand the newest version on PyPI always agree. Nothing is developed onmainand nothing is merged into it by hand.
Work happens on short lived branches off develop, which GitHub deletes after the merge. Releases are tagged on develop, see Release.
Pull requests¶
Neither branch accepts a direct push, every change goes through a pull request against develop. This includes the maintainer, there is no bypass.
A pull request can only be merged once the four required checks are green:
| check | workflow | content |
|---|---|---|
tests |
ci-cd.yml |
the Rust workspace, the wheels, the python tests on python 3.14 and 3.15 on Linux and the web app |
ruff |
lint.yml |
ruff check and ruff format --check, with the ruff of uv.lock |
ty |
lint.yml |
ty check |
docs |
docs.yml |
the strict zensical build including the API reference and the agent files |
tests aggregates the jobs rust lints, rust tests, wheels, the python tests (test, a matrix of the pythons) and the job frontend (the web app with the WebAssembly module of the Rust workspace) into a single job, so the name of the required check stays the same when the matrix changes. The python tests run against the wheel which the job wheels built (x86_64 manylinux), installed into the environment of the lock. The job wheels installs every wheel into a fresh environment as pip install simrun does, so its dependencies are resolved from PyPI and not from the lock (which would hide a dependency the package needs and does not declare), imports every module and runs the binaries, the example workflow on the local service, the web app and a round trip of the MCP server, see the wheel simrun. A pull request which changes only files no Rust job reads (the documentation, the release notes, the web app, the cluster and smoke tests, the other workflows, the markdown files at the root) skips the Rust jobs, the wheels and the python tests (the job changes); tests accepts the skip only then.
The tests on the k3d cluster, the job cluster (cluster.yml), take about half an hour and are no required check. They run on every push to develop, on a release, which waits for them, and when CI-CD is started by hand (workflow_dispatch). A pull request which changes what runs on the cluster gets the label cluster: the tests run once the label is added and with every push after it.
Every job sets up its environment with the action .github/actions/setup: uv with its cache of the packages and the interpreters, the python of the job and uv sync --locked with the extras of the job, i.e. the versions of uv.lock. The key of the cache of uv has the os and the python version but not the job, so jobs on the same python would race to save it and warn Unable to reserve cache: only the jobs of the test matrix save the cache (save-cache: "true"), the others restore it. The action syncs without the project (--no-install-project), whose build compiles the Rust workspace: a job which needs the package installs the wheel of the job wheels or builds it (rust tests installs the checkout with the binaries of the profile dev, which its tests reuse). The jobs run the same commands as a local environment (pytest, ty check, zensical build). A run of a pull request is cancelled by the next push to it; a push to develop or main is never cancelled, a release waits for the run of its commit. The release builds the distributions without the cache (cache: "false"). Dependabot proposes its updates once a month.
Further rules of a pull request:
- conversations have to be resolved before the merge
- an approval is dismissed when new commits are pushed
- the history stays linear, i.e., a pull request is merged with squash or rebase; merge commits are disabled
- the maintainer is the code owner of the repository (
.github/CODEOWNERS) and is requested for review on every pull request. The rulesets themselves do not require an approval: on a personal repository a ruleset cannot ask for an approval only from somebody else, and requiring one would block the pull requests of the maintainer, who cannot approve their own
Auto-merge is enabled for the repository, so a pull request can be queued and is merged as soon as the checks pass.
Repository policies¶
The protection is implemented with repository rulesets. They are part of the repository in .github/rulesets/ instead of only living in the web interface, so a change to a policy is reviewed like any other change:
| ruleset | applies to | rules |
|---|---|---|
develop.json |
develop |
pull request required, the four checks above, resolved conversations, linear history, no force push, no deletion. No bypass, for anybody. |
main.json |
main |
linear history, no force push, no deletion, no bypass. The fast-forward of the release workflow needs none, only a force push would be rejected |
tags.json |
all tags | a tag cannot be deleted or moved, so a release tag keeps pointing at what was released |
Changing a policy means changing the json and applying it:
The script is idempotent: it updates the rulesets which exist and creates the missing ones. It also sets the merge settings of the repository, i.e., auto-merge, delete branch on merge, and squash and rebase as the only merge methods. It needs the github cli authenticated as a user with admin permission on the repository.
Setup development environment¶
Development needs uv and a checkout of the repository:
A single sync creates the virtual environment in .venv, installs simrun into it in editable mode (the python package of src/simrun and the binaries of the checkout, built by maturin from crates/simrun, which needs the Rust toolchain of rust-toolchain.toml, see the wheel simrun) and adds the complete tooling, in the versions of uv.lock:
MATURIN_PEP517_ARGS="--profile dev" builds the binaries in the profile dev, in seconds after a change instead of the minutes of a release build; without it maturin builds the release profile. uv builds them again when a source of the workspace changes (the cache-keys of pyproject.toml). For the binaries of cargo instead, cargo build -p simrun and SIMRUN_HARNESS_BIN=$PWD/target/debug: a binary finds the others in that directory.
The dev extra contains everything used below, i.e., pytest, ruff, ty, tox with tox-uv, pre-commit, zensical, maturin, bump-my-version and the packages of the cluster tests, so nothing has to be installed separately. The python version is taken from .python-version (currently 3.14). The tools are then run either with uv run <command>, which uses the environment without activating it, or from the activated environment (source .venv/bin/activate). The commands in this document are written without the uv run prefix; prepend it if the environment is not activated.
The last step installs the git hook:
uv run pre-commit install # install the hook, once per checkout
uv run pre-commit run --all-files # check the current state of the repository
From now on every commit is checked with ruff (lint and format) and ty, i.e., the same checks that run in continuous integration. On a commit only the changed files are looked at, --all-files checks the whole repository and is what a newly added hook should be tried with. The release manifests of Argo Workflows and Kueue in deploy/cluster are committed as released and excluded from the hooks.
Dependencies¶
The environment is resolved from uv.lock, which is committed. It pins every package of the environment, i.e. the dependencies and the tools of dev, so a local uv sync and continuous integration install the same versions and a result can be reproduced; the image of the service installs the dependencies of the python package and the plugins with the same lock. Every job which syncs through the action .github/actions/setup runs against the lock, and the ruff check installs the ruff version of the lock (version-file: uv.lock), so continuous integration and uv run ruff agree.
Three things do not use the lock on purpose. The install of a wheel in the job wheels resolves from pyproject.toml as pip install simrun does, i.e. the newest releases within the bounds, so a release of a dependency which breaks simrun shows up there before the lock is moved to it. The tox environments resolve from pyproject.toml as well, with the wheel built from the checkout. The release builds the wheels with uvx maturin and checks them with uvx twine. The Rust workspace has its own lock, Cargo.lock, which every build uses (--locked). The lower bounds in pyproject.toml are what a user of the library installs against, the lock only records the versions the development runs with.
After changing a dependency in pyproject.toml run uv lock: the action syncs with uv sync --locked, which fails when pyproject.toml and the lock disagree, so the change and the uv lock which records it go into the same pull request. uv lock --upgrade moves every package of the lock to its newest release, uv lock --upgrade-package <name> a single one.
Dependabot keeps the lock current: once a month it opens one pull request which bumps the packages of the lock together, with the prefix build, and one which bumps the GitHub Actions, with the prefix ci. Its versioning-strategy: lockfile-only only changes uv.lock, the lower bounds in pyproject.toml are never raised by it and change by hand. The revisions of the ruff and ty hooks in .pre-commit-config.yaml are the versions of the lock, which dependabot does not update: when such a pull request moves ruff or ty, raise the revision of the hook to the same version. The web app in frontend/ has a lock of its own, frontend/package-lock.json, which a third monthly pull request moves, also with the prefix build; it leaves TypeScript below 7, whose native compiler has no API for vue-tsc and openapi-typescript, and the types of node at the node of continuous integration, 24.
Testing¶
The Rust tests run with cargo, see the Rust workspace and Testing. The python tests of the package of the plugins are written with pytest, tox runs them against every supported python version (py3.14, py3.15, see envlist in tox.ini), against the wheel built from the checkout:
tox r -e py3.14 # a single environment
tox run-parallel # every supported python, before a pull request is opened
This needs the interpreters, which uv installs with uv python install 3.14 3.15. To run the tests directly against the development environment use pytest; the tests run in parallel, -n auto in the addopts of pyproject.toml gives pytest-xdist one worker per core, -n 0 runs everything in one process, which the debugger needs. The tests on the k3d cluster are described in Testing.
Rust workspace¶
simrun is written in Rust and WebAssembly (the design is docs/superpowers/specs/2026-11-29-rust-wasm-design.md); python is the language of the python task types, whose package is src/simrun. The workspace is Cargo.toml at the root of the repository with the crates in crates/, on the toolchain of rust-toolchain.toml (rustup installs it with the targets wasm32-unknown-unknown and wasm32-wasip1):
| crate | content |
|---|---|
simrun-core |
the model of a workflow and its validation (/validate), YAML read as PyYAML's yaml.safe_load reads it and a workflow written compactly (/workflows/yaml), the validation of settings against the JSON Schema of a task type with the semantics and the messages of pydantic, the manifests of the task types (simrun.task-type/1), the planner, the learned resources (resource_key and their resolution), the estimate of a workflow (/estimate), the admission of a machine, the ledger as a state machine, the records of the store, the environment SIMRUN_* and the commands of a pod (podspec) and the CWL document of a run (cwl) |
simrun-wasm |
simrun-core in the browser for the web app: wasm32-unknown-unknown with wasm-bindgen, the class Simrun of the manifests of a service with validate, validateYaml, estimate, workflowYaml, plan, taskTypes and browserTasks (which implementation of each task runs in the browser, or why none does: browser.rs) and taskPlans (which tasks have a plan and which module of the page plans each before a submission), the client of the API of simrun-client (errorDetail, the message of a refusal as the command line gives it, submissionBody), and pythonJson (JSON as python's json.dumps writes it, simrun_core::pyjson), JSON text in and out |
simrun-unit |
the unit ABI simrun.unit/1 (Unit ABI): its messages, the native trait of an implementation (Units, Instance, TaskFs) and, with the feature guest, the exports of a wasm32-wasip1 unit module (export_units!) |
simrun-unit-example |
demo.squares as a unit implementation: native in the harness and a unit module, the template of a module and the example of the conformance kit |
simrun-exec |
the harness: the carriers (native, wasm in wasmtime, serve, command, and python, the carrier serve of python -m simrun.unit_serve), the host services, the ledger on a filesystem, cgroup v2 and the memory of a worker, the entries of simrun-worker, simrun-merge and simrun-exec and the conformance kit |
simrun-backend-local |
the local backend: the tasks of the runs as processes of the harness on this machine, cores shared across runs, docker run for command tasks, retries of a stop, pid files and orphans, the venv of a run with snapshots; its tests build the binaries (cargo build -p simrun --bins, or SIMRUN_HARNESS_BIN) and compare the outputs of a native, a wasm and a python task with the fixtures |
simrun-backend-argo |
the cluster backend without its I/O: the Argo workflow of a run as JSON (to_argo: <task>-w0, <task>-extra, the retry strategy and the podSpecPatch of the retry memory, the Kueue labels and priorities, the mounts, reservations and groups, label_value), the status of a workflow from the nodes of its DAG (workflow_status: the phases of a retried node, the failed attempts with their exit codes and kills for memory), the quantities of Kubernetes, the requests of a pod, the nodes of the planner of the worker nodes and the pods of a cluster, the placements of the pods of the runs, the pods of the logs of a task, the patches of a reservation (the taint and the label simrun/reserved), the URL of the manifest of an image in the registry, the Job of buildctl and the ConfigMap of its build context; and kube, its I/O: the ArgoBackend over kube-rs, a runtime of its own on which the synchronous calls of the trait Backend run while their caller waits, the watch of the workflows of the runs, the pods, their logs, the nodes, the reservations, the BuildKit Jobs and the registry (tests/kube.rs against an API server in memory) |
simrun-service |
the service: the HTTP API in axum (api, every route of openapi.json with its bodies, status codes and refusals, and the WebAssembly modules of the wasm implementations of its manifests at /task-types/{name}/modules/{file}), tokens and identities, the settings, the registry of the task types of the service (the built-in types, the manifests of SIMRUN_TASK_TYPES and share/simrun/task-types/, the python plugins of its python, the units a python type counts through python -m simrun.unit_serve), the edit sessions, the snapshots of uploads, compare, the records with their index, the learned resources, the controller, the environments of the runs (environment: the lock of uv lock in a writable shadow tree against the snapshots, the build requirements with the pins of data/build_constraints.txt, the Dockerfile and the name of an image), the submission (the environment of a run with a model project, its image built once through the backend, the workflow), the local service of a project (local, .simrun/, see Local mode) and the service of a cluster (cluster) |
simrun-client |
the client: the calls of the API over HTTP (ureq) with the retries of wait, the event stream of a run and the uploads of snapshots (missing, the tar of the lacking files, sent again after a 409 and once after a file changed), the snapshots of working trees with git (git: the scan, the provenance and a snapshot into a store mounted here) and their assembly in a store (snapshot, which the service uses for uploads), the plan of the tasks of the types installed here (plan: the registry of the harness, a python type through python -m simrun.unit_serve in the working tree of the model, the others through their carriers) and the local service of a project as a client finds and starts it (local: ensure_local, stop_local, the python of the plugins and the web app of an installation); without the feature native only the protocol of the API (api: the routes, the bodies, the message of a refusal, the events of a stream) |
simrun-cli |
the command line (clap): every command and option, --json, the tables and lines of rich (rich, render: its widths, wrapping and justification, checked by the fixtures tests/data/output.json), the live view of a run, simrun edit (edit) and simrun cwl |
simrun-mcp |
the MCP server on stdio: the tools of data/tools.json, the answers with store, the refusals as {"error", "status"} |
simrun |
the binaries of the wheel simrun (maturin, bindings = "bin", see the wheel simrun): simrun (the command line), simrun-mcp (the MCP server), simrun-serve (the service of a cluster: the settings of SIMRUN_CONFIG, the backend of the setting backend, see Service), simrun-local (the local service), simrun-worker, simrun-merge, simrun-exec (the harness of the pods) and simrun-abi (the conformance kit); its tests run the binaries on task directories with every carrier and the kit on the example module and on faulty ones, and its build script refuses a build for Windows |
cargo fmt --all # format
cargo clippy --workspace --all-targets -- -D warnings # lints, pedantic (workspace.lints of Cargo.toml)
cargo test --workspace # the unit tests and the golden tests
cargo build -p simrun # the binaries into target/debug, SIMRUN_HARNESS_BIN=$PWD/target/debug
# the example unit module and the conformance kit (the tests build the module themselves)
cargo build --target wasm32-wasip1 --profile unit -p simrun-unit-example
cargo run -p simrun --bin simrun-abi -- check target/wasm32-wasip1/unit/simrun_unit_example.wasm --settings '{"n": 5}'
# the module of the web app into frontend/packages/simrun-core/src/pkg (cargo, then wasm-bindgen-cli of the
# version of Cargo.lock: cargo install wasm-bindgen-cli --version <version> --locked) and its golden tests in node
(cd frontend && npm run wasm)
node crates/simrun-wasm/tests/goldens.mjs frontend/packages/simrun-core/src/pkg
Heavy builds are capped in memory on a workstation, e.g. systemd-run --user --scope -q -p MemoryMax=24G -p MemorySwapMax=0 -- cargo test --workspace.
macOS. The workspace builds and its tests pass on macOS (arm64 and x86_64) for the local mode (the command line, the local service, the harness, the MCP server, simrun-abi; the service of a cluster and the Argo backend only compile): the code of Linux is gated with #[cfg(target_os = "linux")], so macOS has no cgroup (no limit, no usage, no kills of the out of memory killer), reads the process tree, CPU time and memory (the physical footprint) of a worker, the start and command line of a process and the memory of the machine through libproc and sysctl (simrun_exec::darwin, the one module with unsafe code) and pins no process to CPUs. The job rust tests (macos) of ci-cd.yml runs the tests on macos-15 and macos-15-intel, and the job wheels builds the wheels of macOS natively (without zig) and installs and runs them as the ones of Linux; the release publishes them with the others.
The fixtures. The goldens of the tests are the expected answers of the components on a corpus of cases. In crates/simrun-core/tests/data/goldens/: the YAML of the examples, of the smoke workflows and of the documentation and YAML edge cases (yaml.json), the workflows of the corpus with the answers of /validate and of load_workflow (workflows-*.json), every setting of every task type changed to a palette of values (settings/<type>.json, the errors and the dump of the settings model), the plans (planner.json), the views of /task-types (views-*.json), the YAML of /workflows/yaml (workflow-yaml.json), the learned resources (resources.json), the answers of /estimate and /estimate/context (estimate.json), the admission of a machine (admission.json), the transitions of the ledger (ledger.json), the records (records.json), the environment and the commands of a pod (podspec.json), the CWL documents and their refusals (cwl.json) and the Dockerfiles and image references of environments (environment.json); the outputs of demo.squares in crates/simrun-backend-local/tests/data/squares.json; the Argo workflows, statuses, requests, nodes, placements, logs, reservations and builds in crates/simrun-backend-argo/tests/data/; the outputs of the command line in crates/simrun-cli/tests/data/output.json; the tools of the MCP server in crates/simrun-mcp/data/tools.json; the manifests of sbmlsim in crates/simrun-core/tests/data/manifests/sbmlsim/; and the recorded exchanges of the service (requests, status, headers and bodies of nine scenarios on its fake backend with the settings of a cluster) in crates/simrun-service/tests/data/exchanges/, which crates/simrun-service/tests/contract.rs replays against the service, checking every answer against the response schema of openapi.json and the routes of the router against its paths and methods. cargo test and the node test of the module compare the implementation with them. A change of the behaviour changes its fixture by hand, in the same commit as the code, and says so in the pull request. The manifests of the built-in types, crates/simrun-core/manifests/, are the ones the python package writes (tests/test_manifest.py).
The document of the API. frontend/src/api/openapi.json is the document of the HTTP API, maintained by hand; the contract tests check the service against it and the web app is typed from it (npm run types in frontend/, which writes src/api/schema.d.ts, checked by the job frontend). A change of a route or a body changes the document, the recordings it touches and the types together.
The module in the web app. The module, its typed wrapper and the browser backend are the npm package simrun-core (frontend/packages/simrun-core, see the package simrun-core). npm run wasm in frontend/ (the script scripts/wasm.mjs of the package) builds simrun-wasm with the profile wasm (opt-level = "z", LTO) into CARGO_TARGET_DIR or target/, writes the bindings of wasm-bindgen --target web without the name section into the gitignored frontend/packages/simrun-core/src/pkg, which vite bundles into frontend/dist (and the wheels carry as data), and fails when the module grows past its budget of 1.25 MB (1.19 MB, 0.42 MB with gzip). It also builds the example unit module (simrun-unit-example for wasm32-wasip1, the profile unit) into src/pkg/demo_squares.wasm of the package, the native entry demo.squares of the browser backend, which a page fetches only when a run needs it (a budget of 450 KB, 400 KB, 133 KB with gzip). npm run dev, build, test and typecheck run it first. The web app loads the core once, when the Editor or the browser backend first needs it (src/core.ts of the package).
The browser backend. frontend/packages/simrun-core/src/browser/ runs a workflow in the page (Running in the browser): executor.ts (the coordinator: the runs, their records and files in the store, the tasks side by side, the ledger, the batches of units, the merge, resume and cancel), worker-host.ts and unit.worker.ts (a web worker with one instance, started by worker.ts), unit.ts (the exports of the ABI, the memory cap), wasi.ts and memfs.ts (the host of WASI preview 1 over files in memory), store.ts (OPFS, or memory), ledger.ts (the transitions of simrun_core::ledger, replaying ledger.json in its test), services.ts (the host services of the page), archive.ts (the zip of a download, the tar of an upload) and formats.ts (the records as pydantic writes them, their plans kept as the core wrote them); src/stores/browser.ts and src/stores/targets.ts of the web app connect it to the Executions and the Editor. Its vitest runs the example module in node, with workers in the same thread (testing.ts) and a store in memory, for 1, 2 and 8 workers, and checks the files against those of the local service. A page of the app is cross-origin isolated (the headers of /ui/ of both services and of the dev server), so a unit which sleeps blocks its worker with Atomics.wait. wasm-opt -Oz (binaryen) makes it 7 % smaller but compresses worse with gzip, so it is not used; the Unicode tables of regex (about 230 KB) stay, since a pattern of a schema matches as pydantic's does.
The state of the service. The records of the runs (simrun_core::store) have every field, in a fixed order, and are written as pydantic's model_dump_json(indent=2) writes them (the floats as pydantic writes them, the datetimes with their offset, naive ones without); crates/simrun-core/tests/records.rs and crates/simrun-service/tests/records.rs read every record of records.json and write it again. The index of the runs (simrun_service::index) and the learned resources (simrun_service::resources) are tables of one SQLite file, which the service creates at its start. Nothing of the store or the SQLite file of an earlier release is migrated or kept on a rewrite.
In continuous integration two jobs test the workspace in parallel: rust lints the format check and the lints (also of the module for wasm32-wasip1), rust tests the tests with cargo-nextest (the integration tests of crates/simrun build the example unit module and run the conformance kit on it; the environment of the job has the python package of the checkout, so the tests of a python plugin run) and the doc tests. Each has a cache of its own (Swatinem/rust-cache), saved from develop only. The job frontend builds the module (.github/actions/wasm: the toolchain, the cache and the wasm-bindgen of Cargo.lock) and runs the node test of the fixtures through it and then the checks of the web app. The debug builds compile cranelift and the other crates of wasmtime which compile a unit module with optimizations ([profile.dev.package.*] of Cargo.toml), which makes the tests which run a module several times faster.
The wheel simrun¶
simrun on PyPI is one wheel per platform, built by maturin from pyproject.toml ([tool.maturin]: bindings = "bin", the crate crates/simrun, python-source = "src"): the binaries of crates/simrun in the scripts of the wheel (simrun, simrun-mcp, simrun-serve, simrun-local, simrun-worker, simrun-merge, simrun-exec, simrun-abi), the python package src/simrun of the plugins (its only dependency pydantic) and the built web app as data (build/wheel-data/data/share/simrun/web, installed into <prefix>/share/simrun/web; optional, the build backend creates the directory empty when the web app is not built). The version is static in pyproject.toml, the crate crates/simrun and src/simrun/__init__.py, moved together by bump-my-version (tests/test_version.py). The build backend is build_backend/simrun_build.py, maturin which refuses a build on Windows with a message, so pip install simrun there stops with the reason instead of somewhere in the Rust build.
A binary finds the others beside it (or in SIMRUN_HARNESS_BIN), the web app in share/simrun/web of its prefix or, in a checkout (target/<profile>/ or .venv/bin/ next to crates/simrun), in frontend/dist, and the python of the plugins as SIMRUN_PYTHON, else beside it, else python3 of PATH.
The release publishes the wheels for linux x86_64 and aarch64, manylinux_2_28 and musllinux_1_2 (the binaries linked statically with musl, for Alpine and other images without glibc), for macOS arm64 and x86_64 (built natively, without zig), and the sdist, built by the job wheels of ci-cd.yml with maturin and zig on a runner of each architecture, after the job frontend built the web app (its artifact web):
mkdir -p build/wheel-data/data/share/simrun && cp -r frontend/dist build/wheel-data/data/share/simrun/web
uvx --from "maturin[zig]==1.16.0" maturin build --release --locked --zig \
--compatibility manylinux_2_28 --out dist
uvx --from "maturin[zig]==1.16.0" maturin build --release --locked --zig \
--target x86_64-unknown-linux-musl --compatibility musllinux_1_2 --out dist # rustup target add x86_64-unknown-linux-musl
uvx --from "maturin[zig]==1.16.0" maturin sdist --out dist
The job checks that each wheel has the version, every binary, the python package and the web app, and installs it: a manylinux wheel into a fresh environment with its dependencies from PyPI, where it imports every module, runs the binaries, examples/squares.yaml on the local service, the web app at /ui/ and a round trip of the MCP server; a musllinux one in an Alpine container. It runs on a push to develop and on a tag for every platform, and for a pull request which needs the Rust jobs for x86_64 manylinux only, whose wheel the python tests install; the cache of each build is saved from develop. simrun 0.5 shipped its binaries in a second wheel, simrun-bin, which is not released any more.
The package simrun-core¶
The core of the browser is the npm package simrun-core, for the web app and for other web pages (as sbmlsim-core ships sbmlsim-core): the module of simrun-wasm with its bindings (src/pkg, built by npm run wasm), the typed wrapper (src/core.ts, the entry simrun-core, with the types of the API of src/types.ts and src/schema.d.ts, generated from openapi.json by npm run types), the browser backend (src/browser/, the entry simrun-core/browser and each of its modules as simrun-core/browser/<module>) and the example unit module demo_squares.wasm. Its version is the version of simrun; bump-my-version moves it in package.json of the package and in frontend/package-lock.json (tests/test_version.py). The package lives in frontend/packages/simrun-core, a workspace of the npm project of the web app (workspaces of frontend/package.json), so npm ci in frontend/ links it into node_modules/simrun-core and the app imports it like any other page does (simrun-core, simrun-core/browser/executor, ...). The app and its tests use the sources of the package, through the export condition source (resolve.conditions of vite.config.ts, customConditions of tsconfig.json), so the app needs no build of the package; vitest runs the tests of the package with those of the app, and npm run typecheck checks the package with its own tsconfig.json. A published package has the build in dist/: the modules as JavaScript with their declarations (tsc -p tsconfig.build.json), pkg/ with the WebAssembly modules and the bindings, schema.d.ts and the license, made by scripts/build.mjs, the prepack of the package:
cd frontend
npm run package # simrun-core-<version>.tgz, npm pack of the workspace
node packages/simrun-core/scripts/check-package.mjs simrun-core-*.tgz # the tarball in a project of its own
check-package.mjs installs the tarball into a new project in a temporary directory, runs test/package/consumer.mjs there, which imports simrun-core and simrun-core/browser as a page would, validates examples/squares.yaml with the core (the manifests of the golden estimate.json) and runs demo.squares with the browser backend in node (MemoryStore, inProcessWorker), and compiles test/package/consumer.ts with tsc against the declarations of the package. The job frontend runs both on every pull request, the job npm of a release before it publishes.
Linting and formatting¶
Linting and formatting use ruff:
The rules are in .ruff.toml; among them the docstring rules (D, google convention), which are enforced for the package and not for tests/, and the rules of logging calls (G): library code logs with lazy %s formatting rather than f-strings.
Type checking¶
Type checking is performed with ty:
ty resolves the imports in the environment of the project, which uv sync --extra dev creates; the ty check of continuous integration runs the same command and the pre-commit hook runs it on every commit. The configuration lives in [tool.ty] in pyproject.toml. Warnings are treated as errors, so the codebase is kept free of diagnostics. Suppress an unavoidable diagnostic with a rule specific # ty: ignore[rule-name] rather than a blanket comment.
Documentation¶
The documentation is built with Zensical, the static site generator of the Material for MkDocs authors. The sources are markdown files in docs/, the site is configured in zensical.toml in the repository root. Nothing rendered is committed: the site is built by the documentation workflow on every push and published to matthiaskoenig.github.io/simrun from the develop branch.
Build the site into site/, strict as continuous integration builds it, i.e. a warning fails the build:
For writing, the preview rebuilds on save:
The API reference is rendered from the docstrings by mkdocstrings; a page in docs/api/ only contains the module directive:
Docstrings are therefore the place to document functions and classes, the markdown files provide the narrative around them. Adding a module to the reference means adding such a page, an entry to nav in zensical.toml and a row of docs/api/index.md. Markdown carries no hard line wraps: a paragraph, a list item or a table row is a single line.
Files for agents¶
Agents and language models read markdown, not rendered html. scripts/llms_txt.py writes the files of the llms.txt convention into the built site, i.e., llms.txt as an annotated index of all pages, llms-full.txt with the complete documentation in a single file, and the markdown of every page next to its html. The markdown of the API reference is generated from the docstrings with inspect, since the pages themselves only contain the mkdocstrings directive.
The documentation workflow runs both steps, so the files are regenerated with every push. docs/robots.txt points crawlers at the sitemap and at these files.
Release¶
A release is made from develop. Since develop only accepts pull requests, the release is prepared on a branch and tagged once that pull request is merged:
- branch off
develop:git switch -c release/x.y.z develop - write the release notes for the version in
release-notes/x.y.z.mdand add them todocs/release-notes.md - make sure everything passes:
tox run-parallel,ruff check,uv run ty check - check the version bump:
uvx bump-my-version bump [major|minor|patch] --dry-run -vv - bump the version:
uvx bump-my-version bump [major|minor|patch], which updatessrc/simrun/__init__.py,CITATION.cff(its version anddate-released, the day of the bump), the version of the wheel (pyproject.toml,crates/simrun/Cargo.toml) and of the service (crates/simrun-service/src/lib.rs), the version of the npm package simrun-core (frontend/packages/simrun-core/package.jsonandfrontend/package-lock.json), the deployment, anduv.lockandCargo.lockwithuv lockandcargo update --workspace --offline(itspre_commit_hooks), and commits. It does not create the tag; a squash or rebase merge would rewrite the commit and leave the tag behind on a commit which is not part ofdevelop - push the branch, open the pull request against
developand merge it once the checks are green -
tag the merged commit on
developand push the tag:This starts the
CI-CDworkflow, which checks that the tag is the version of the package, builds the web app (the jobfrontend) and the wheels of every platform and the sdist (the jobwheels), publishes them to PyPI, creates the GitHub release fromrelease-notes/x.y.z.mdand fast-forwardsmainto the tagged commit; after the release the jobnpmpacks the npm package simrun-core of the tag, checks the tarball and publishes it to npm with provenance. It does not run the test matrix again: the merge intodevelopran it on the same commit, and the jobtested on developwaits for that run and stops the release unless it passed, so the tag can be pushed right after the merge. Next to it the tests on the k3d cluster run on the tag, and the release waits for them. Check the version before pushing, a tag cannot be moved or deleted afterwards.The wheels and the sdist contain the built web app as data of the wheel, which the binaries serve at
/ui/: the jobfrontendbuilds it (with its WebAssembly module, which needs the Rust toolchain and the wasm-bindgen ofCargo.lock, see the module in the web app) and the jobwheelsputs it into the gitignoredbuild/wheel-data/data/share/simrun/webbefore maturin builds. The directory is optional: the build backend creates it empty when it is missing, and a wheel built without the web app has none (a checkout servesfrontend/distonce built). To build the wheel with the web app locally: -
test the installation from PyPI in a fresh environment:
-
once Zenodo has archived the release, update the citation information, i.e.,
doiinCITATION.cffand the DOI badge and the citation ofREADME.mdanddocs/index.md, anddate-releasedwhen the tag was pushed on a later day than the bump.bump-my-versionupdates the version and the date, not the DOI, which is only known after the release. These changes go in through a pull request like everything else
PyPI, npm and Zenodo¶
The package is published with trusted publishing: the job release runs in the GitHub environment pypi with the permission id-token: write, and PyPI accepts the distributions of this workflow without a token. The publisher is registered on PyPI for the project simrun (and for simrun-bin, the wheel of the binaries up to 0.5, which is not released any more) with the owner matthiaskoenig, the repository simrun, the workflow ci-cd.yml and the environment pypi (for a new project as a pending publisher, which its first upload turns into the project).
The npm package simrun-core is published with the trusted publishing of npm as well: the job npm of ci-cd.yml runs in the GitHub environment npm with the permission id-token: write and runs npm publish --provenance --access public (npm 11.5.1 or newer, which the job checks), without a token. The trusted publisher of the package on npmjs.com (its settings, Trusted publishing, GitHub Actions) names the owner matthiaskoenig, the repository simrun, the workflow ci-cd.yml and the environment npm. npm configures a trusted publisher only for a package which exists, unlike the pending publishers of PyPI, so the first version of a package is published by hand by its owner, once; a version which is on npm already is not published again by the job.
Zenodo archives every GitHub release of the repository with the metadata of .zenodo.json and gives it a DOI; the first release creates the concept DOI, which stands for every version and goes into the badge and the citation.