Contributing
Contribution workflow for all MDK repositories
Thank you for your interest in contributing to MDK. MDK is released under the Apache License 2.0.
By contributing, you agree that:
- You retain copyright over your contributions
- You grant a perpetual, worldwide, royalty-free license for their use
- Contributions are provided "AS IS", without warranty
This document outlines the contribution workflow for the MDK repository, from setting up your development environment to submitting pull requests, and participating in releases.
Table of contents
- Security
- Release a Worker or app
- Monorepo structure
- Get started
- Development environment setup
- Dependencies and supply chain
- Pull request workflow
- PR review
- Code standards
- Versioning and tagging
- Links
Security
If you discover a security vulnerability, do not report it in a public issue.
Please follow the private disclosure instructions in SECURITY.md.
Release a Worker or app
Ship your Worker or app from your own package or repository so other operators can add it to their sites. Publishing makes an integration available to install; catalog listings are maintained separately.
Release your package
| Integration | Prepare and verify | Distribution |
|---|---|---|
| Worker | Follow Worker development and integration testing | Share your package or repository and its device configuration requirements |
| App | Follow app packaging and publishing | Ship the manifests, controllers, and built UI described by the app guide |
Include setup requirements, supported capabilities, configuration, permissions, and release information in your package's README. The CLI installation reference explains how operators add packages from npm or GitHub to their stack.
Listing criteria
Maintainers review a listing request against checks you can run yourself, in your own CI.
| Integration | Criterion | What it covers |
|---|---|---|
| Worker | mdk validate worker --path <dir> --smoke exits 0 | Contract and mock-device checks |
| App | mdk validate app --path <dir> --smoke --strict exits 0 | Manifest, permission, and route checks |
The criteria cover conformance only. A listing is not a security review of the package: an operator reviews a third-party Worker or
app before installing it, and the mdk-worker-security and mdk-app-security skills support that review.
List a Worker
Request a listing in the supported Workers catalog by opening an issue with a link to your Worker contract, or propose an entry in the external Worker registry via your own PR. The catalog maintenance process defines the source fields and verification used for that listing.
List an app
Request a listing in the supported apps reference by opening an issue, or propose an entry in that reference via your own PR. Include the app's package or repository, purpose, installation instructions, and requested permissions in either case. Maintainers review the proposed addition; publishing alone does not add a catalog entry.
Monorepo structure
MDK is a monorepo with separate backend backend/ and frontend ui/ workspaces:
Choose the backend or frontend workflow that matches the area you are contributing to.
Root configuration must be domain-aware
The repo top level is a fixed set of domains (ui/, backend/, docs/, examples/) plus tooling and repo-meta files.
Shared root config (today just .gitignore) is read across all of them, so every pattern must be written so it cannot
silently match another domain's source:
- Anchor anything that targets one domain's build or runtime output. Use
/name/for the repo root ordomain/**/name/for a subtree. A barestatus/store/tmp/Checklist*matches a file or directory of that name anywhere, including UI source such asui/packages/ui-foundation/src/store/. - Keep per-domain ignores in that domain's own
.gitignore(ui/.gitignore, the per-package backend.gitignores), not the root. Things likedist,.turbo, andbuildbelong to a domain. - Lint/format/type config is domain-owned, not shared at the root.
ui/ships its own.oxlintrc.json/tsconfig.base.json/.prettierrc; backend uses@bitfinex/lint-js(bfx-lint-js), whose ruleset ships with the dependency and needs no config file. Do not add a root-level lint/tsconfig/prettier that would apply across domains. - A genuinely shared convention is fine if it applies identically to every domain - e.g. committing
config/*.json.examplewhile ignoring the generatedconfig/*.json. Note it as shared so the intent is clear.
Get started
Prerequisites
Before contributing, ensure you have the following installed:
Development environment setup
1. Fork and clone
- Fork the repository on GitHub.
- Clone your fork locally and navigate into the project directory:
git clone https://github.com/username/mdk.git
cd mdk- Add the upstream remote:
git remote add upstream https://github.com/tetherto/mdk.git2. Stay in sync
Keep your fork in sync with the main repository. For example:
git fetch upstream
git merge --ff-only upstream/main # fails loudly if main has divergedInstall and build
From the repository root, install dependencies and build:
npm run setup # install root and UI workspaces
npm run build # build all domainsThe root workspace contains backend packages, tools, and the demo site; the UI has its own workspace. The root commands include both.
Check your changes
Before submitting changes, run the checks relevant to your work from the repository root:
npm run test # run tests
npm run lint # run linters
npm run typecheck # check types
npm run check:deps # check backend dependency pins, after a dependency changeIntegration tests can fail with CHANNEL_CLOSED on macOS when endpoint-security or
traffic-inspecting network tools are running. Run them on Linux or in CI.
Select checks according to the affected packages and behavior. Documentation-only changes need the documentation checks rather than the full application test suite.
Work on one domain
For a backend-only checkout, install the root workspace and scope checks to its members:
npm install
npm run lint --workspaces --if-present
npm test --workspaces --if-presentFor frontend-only work, use the shared setup and build instructions, then start the development server from the UI workspace:
cd ui
npm run devThe UI contribution guide covers package-specific workflows.
Dependencies and supply chain
Every third-party dependency is code that runs on an operator's site. A pull request that adds, removes, or updates one follows the rules in this section. Maintainers review dependency changes against them, and CI checks some of them.
MDK's own workspace packages are outside these rules: the release process sets their versions.
Pin what you add
| Dependency | Rule |
|---|---|
Registry package: runtime dependencies of a backend/ package | Give an exact version, such as 1.4.2. npm run check:deps rejects a range here, and CI runs it on every pull request |
| Registry package: anywhere else | Give a bounded version or range, such as 1.4.2 or ^1.4.2. Never use latest, *, or an open-ended range such as >=1.0.0 |
| Git or URL | Pin a full commit SHA. A branch or tag is not a pin |
| Third-party GitHub Action | Pin a full commit SHA and name the version in a trailing comment |
These cases are exempt:
overridesentries. An override sets the version of a transitive dependency, so a floor such as>=8.12.2is deliberate there: it keeps the fix while letting later releases through. Add one only when no direct dependency change can do the job, and record why in Root overrides.- Workflows and actions from this repository's own GitHub organization. A shared workflow, such as the Vale prose lint, can track a branch. The SHA rule covers code the organization does not control.
Inside this repository and in CI, a version range in package.json is not the pin. The lockfile is: it records the exact
version and integrity hash of every package, transitive ones included.
The lockfile does not reach operators. npm leaves it out of a published package, so installing a published MDK package resolves
dependencies from that package's package.json. That is why the runtime dependencies of a backend/ package must be exact.
Root overrides
package.json cannot carry comments, so the reason for each entry in the root overrides block is kept here. A pull request
that adds, changes or removes an override updates this table in the same change.
| Override | Why | Drop when |
|---|---|---|
crypto-js | Stands in a local package, examples/mvp-site/lib/mdk-crypto-lib, for the registry one | |
serialport | Stands in an empty package (npm:noop) for the registry one | |
katex | Sets the version of a transitive dependency. micromark-extension-math asks for ^0.16.0, and every 0.16 release is affected by GHSA-238p-pmpm-9mq7 | micromark-extension-math accepts a fixed katex |
run-con > ini | Holds ini at ^6.0.0. Its code matches 7.0.0, but its engines accept any Node 24, so a root install on Node below 24.15 does not warn | The root engines.node floor reaches >=24.15 |
Commit the lockfile with the change
Regenerate the lockfile in the same pull request, from the directory that owns it: the repository root for backend packages and
tools, ui/ for the UI workspace. A standalone example, such as examples/mvp-site/ui/ or
examples/mdk-ui-shell-template/, owns its own lockfile: regenerate it from that example's directory. To find the owner, walk up
from the changed package.json to the nearest package-lock.json.
npm install --package-lock-only --ignore-scripts --no-audit --no-fundKeep the lockfile diff limited to the packages the pull request changes. Unrelated version changes hide the lines a reviewer needs to read, so revert them before you push.
Make the case for a new dependency
A pull request that adds a dependency states the following in its description:
- What the package does, and why existing code, an existing dependency, or the platform cannot do it
- Its license
- Who publishes it and how actively it is maintained
- Whether it relies on an install script. Most CI jobs skip install scripts with
--ignore-scripts, but the CLI package test and end-to-end jobs run a plainnpm ci, andnpm run setupruns a plainnpm installon a contributor's machine. An install script therefore runs in CI and on developer machines.
MDK is licensed under Apache-2.0, so a new dependency needs a license compatible with it. A permissive license, such as MIT, BSD, ISC, or Apache-2.0, is acceptable. A copyleft license, such as GPL, LGPL, or AGPL, or a package with no stated license, needs maintainer sign-off before the pull request merges. CI does not fail on a license, so the reviewer makes this call from the description.
Wait before adopting a fresh release
Prefer a version that has been published for at least 3 days. Compromised releases are typically detected and removed within hours or days, so the wait keeps them out of the lockfile. The period matches common tooling defaults, such as the npm release-age preset in Renovate.
Check a version's age
List the publish date of every version:
npm view <package> timeThis is a recommendation, not a blocking rule, and nothing automated checks it. When a newer release is the better choice, such as one that fixes a security issue, say why in the pull request.
The wait protects this repository's lockfiles only. As with pinning, it does not reach an operator who installs a published MDK package.
What CI checks
| Check | Fails when |
|---|---|
| Lockfile consistency | A lockfile is out of sync with its package.json, or no lockfile covers a package |
| Dependency review | The pull request introduces a dependency with a known vulnerability of moderate severity or higher |
| Security audit | An installed package has a known vulnerability of high or critical severity that is not allowlisted |
| Dependency pins | A backend/ package's third-party runtime dependency is not an exact version or differs from another package's, or a backend package requires a module it does not declare or declares one it never requires. Run npm run check:deps locally; CI runs it as part of the release consistency check |
The CI workflow defines these checks. Dependency review and the release consistency check run on every pull request. The security audit runs only on a pull request, and only for some changed paths:
| A pull request that changes | Security audit |
|---|---|
ui/ | The UI workspace |
backend/core/ or backend/workers/ | The root workspace |
A workflow, action, or script under .github/ | Both |
Only root files, such as the root package.json or lockfile | Both |
Only backend/tests/, examples/, or packages/, or a mix of these with root files | None |
| Only documentation | None |
When your change gets no audit, run npm audit yourself in the directory that owns the lockfile.
The other rules in this section, such as pinning outside backend/, the release wait and the case for a new dependency, have no
automated check, so reviewers apply them by reading the package.json and lockfile diffs.
Pull request workflow
Conventional types
MDK uses Conventional Commits-style types for both branch names and PR titles.
| Type | Use for |
|---|---|
feat | New features |
fix | Bug fixes |
docs | Documentation changes |
refactor | Code refactoring without behavior change |
test | Test additions or changes |
chore | Tooling, dependencies, repo maintenance |
perf | Performance improvements |
style | Formatting only (no logic change) |
ci | CI configuration changes |
build | Build system or external dependency changes |
Branch naming convention
Create branches using the following pattern:
{type}/{short-description}Where {type} is one of the conventional types.
Branch naming examples
# New feature
git checkout -b feat/mdk-new-device
# Bug fix
git checkout -b fix/timeout-handlingCommit message template
The repository ships a commit message template at .gitmessage that pre-fills the
commit editor with the expected format (type, summary, body, and Task Id/Related PR references).
Enable it once per clone:
git config commit.template .gitmessageThis is a local convenience only — it is not enforced, and the conventional types above remain the source of truth for commit, branch, and PR naming.
Pull request steps
- Sync your local main with upstream
main. - Create a branch from local
main. - Make your code changes.
- Write or update tests.
- Run the applicable checks for your changes, using scoped commands when appropriate.
- Commit changes with meaningful messages.
- Push your branch and open a Pull Request targeting the upstream
main.
PR checklist
Before submitting your PR, ensure that:
- Affected code builds using the build instructions
- Applicable tests, linting, and type checks pass using the check instructions
- New features include tests
- Dependency changes follow the dependency rules, with the regenerated lockfile in the same PR
- Behavior, config, API, or CLI changes either include their documentation in the same PR or check the
docs-requiredbox in the PR template to request input from the docs maintainer
Where documentation is included, you may request a review round from a maintainer with
docs-review.
- Generated pages affected by the change are regenerated, using the command named in that file's
DO NOT EDITheader (a Worker contract, a plugin manifest, or devkit component source each rewrite a different file)
The docs-freshness workflow enforces this on every PR as a required check: a stale
generated page, a skipped generator, or a broken generator all fail the run. CI only detects the drift, it never regenerates
for you. Run npm run regenerate-docs and commit the result in the same PR.
PR title format
Use the following convention:
{type}({scope}): {description}Where {type} is one of the conventional types and {scope} is the affected area,
for example miner or ui.
Examples:
feat(miner): add Antminer S21 supportfix(timeout): resolve action timeout handlingdocs(api): update stats documentation
PR review
All pull requests go through the following review steps:
- Automated checks: Linting and tests must pass.
- Code review: At least 2 maintainer approvals are required.
- Feedback resolution: All requested changes must be addressed.
- Squash and merge: Maintainers squash commits to keep history clean.
Workflow diagram
Code standards
Backend JavaScript follows the @bitfinex/lint-js ruleset (bfx-lint-js, run by npm run lint) to keep the codebase consistent
and easy to review across repositories.
Key rules:
- 2-space indentation
- No semicolons
- Single quotes for strings
- Space after keywords (
if,for,while) - No unused variables
Versioning and tagging
MDK follows Semantic Versioning:
- MAJOR (
1.x.x): breaking changes - MINOR (
x.1.x): new backward-compatible features - PATCH (
x.x.1): backward-compatible bug fixes
The versioning and deprecation policy defines which interfaces this covers and how a deprecation is announced and removed. A change that deprecates an interface follows it.
When the MDK team provides a release, they are cut from a release/<version> branch, verified in CI,
promoted to the public repo, then tagged. For the full release process and checklist, see RELEASING.md.
Happy contributing, and thanks for helping improve MDK! 🚀