MoDiff is an experimental local backend with a separately maintained frontend bundle. Contributions should preserve the local-only security boundary, existing graph/API compatibility, and reproducible dependency state.
Before starting, read SECURITY.md and the relevant guide in docs/README.md.
Use Python 3.12 and create the same managed CPU profile used by baseline CI:
./install.sh --accelerator cpu --backend-only
uv pip install --python .venv/bin/python -r requirements/test.txt
./scripts/with-runtime-env.sh ./.venv/bin/python -m modiff.preflight --json --check-port 8088 --fail-on-errorOn Windows PowerShell, use the corresponding managed commands:
.\install.ps1 -Accelerator cpu -BackendOnly
uv pip install --python .venv/Scripts/python.exe -r requirements/test.txt
.\.venv\Scripts\python.exe -m modiff.preflight --json --check-port 8088 --fail-on-errorChoose the qualified accelerator profile relevant to a hardware-specific change and report that validation separately. Do not use uv sync or uv run: the project is intentionally uv-unmanaged because the installer, not the generic resolver, owns the executable Torch profile.
Do not commit config.ini, .env files, model caches, generated outputs, local logs, virtual environments, or test caches.
- Put backend framework implementation in
modiff/and built-in node implementations inmodules/. - Preserve current HTTP/WebSocket and graph-storage contracts unless a deliberate migration includes client changes and contract tests.
- Keep hardware probes non-fatal and retain CPU fallback when CUDA or MPS discovery fails.
- Treat file access, custom-module installation, remote code, token handling, and mutating routes as security-sensitive changes.
- Avoid importing the full model registry from lightweight diagnostics such as preflight.
Built-in node packages live under modules/<Name>/ and normally contain:
modules/Example/
__init__.py
main.py
Use a thin initializer:
from .main import * # noqa: F401,F403Define executable nodes in main.py as NodeBase subclasses. The registry inspects class metadata with the AST as well as live imports, so keep class-level label, category, params, and related metadata parser-friendly. Prefer module-level constants over environment-dependent expressions inside class metadata. Optional heavyweight dependencies should be imported as late as practical so an unavailable optional feature does not crash discovery of unrelated modules.
Add focused tests for registry visibility, constructor safety, field contracts, and any runtime behavior that can be validated without downloading a large model.
The selected file under requirements/profiles/, pyproject.toml, and modiff/compatibility/accelerators.v1.json jointly define the executable runtime contract. Keep direct wheel URLs hash-verified, keep remote source dependencies pinned to immutable revisions, and retain the exact reviewed Diffusers commit. After an intentional dependency or profile edit, rebuild the relevant managed profile:
./install.sh --accelerator cpu --backend-only --repair
uv pip check --python .venv/bin/pythonUse the corresponding accelerator instead of cpu when the change affects CUDA, ROCm, or MPS. Update the compatibility manifest and public installation guidance only when the evidence supports the claim. MoDiff deliberately has no uv.lock; do not generate one or describe the top-level requirements files as a cross-platform lock.
The baseline backend checks are:
uvx --from ruff==0.12.7 ruff check . --select E9,F
uv pip check --python .venv/bin/python
./scripts/with-runtime-env.sh ./.venv/bin/python -m modiff.preflight --json --check-port 8088 --fail-on-error
./scripts/with-runtime-env.sh ./.venv/bin/python -m pytest -qThe wrapper applies the installed accelerator profile's process environment before Python imports Torch. On Windows, run .venv/Scripts/python.exe directly in the equivalent commands.
On a host with Git Bash or a POSIX shell:
bash -n run.sh scripts/with-runtime-env.shBefore reporting a live smoke test, confirm port 8088 is free or intentionally reuse the running process. A file-level inspection is not evidence that a model workflow completed; distinguish unit/contract tests, registry import checks, live backend HTTP checks, and real model-generation proof.
The editable frontend source is not in this repository. It lives in the separate MoDiff-client checkout. Do not hand-edit minified files under web/assets/.
When a change affects the client/backend contract:
- Update and validate the client source.
- Run
npm ciandnpm run checkin MoDiff-client. - Mirror the contents of its generated
dist/directory into this repository'sweb/directory, deleting stale generated bundle files while preserving backend-ownedweb/user/custom fields. - Verify that
/and/assets/index.jsare served by a fresh backend. Verify/template-gallery/manifest.jsononly for an explicit offline/local Gallery build; a remote-asset build intentionally omits that directory and route. - Include the matching backend and client commit identifiers in the change description when the repositories are published separately.
See README.md for exact-mirror examples.
Update public documentation when commands, extras, routes, storage behavior, trust boundaries, or compatibility guarantees change. Keep claims proportional to the evidence actually run.
A useful change description includes:
- The user-visible problem and intended behavior.
- Backend/client compatibility impact.
- Security or data-migration impact.
- Exact validation commands and results.
- Remaining hardware, model-access, or live-runtime gaps.