feat: complete backend — WorkflowBuilder, LoRAManager, Switchboard UI, 184 tests, ruff/mypy/env tooling#2
Merged
POWDER-RANGER merged 1 commit intomainfrom Feb 25, 2026
Conversation
New modules
-----------
backend/workflow_builder.py — WorkflowBuilder: dynamic ComfyUI workflow
graph construction (txt2img, img2img, upscale);
JSON template loading from workflows/; LoRA chain
injection; preset + resolution patching.
backend/lora_manager.py — LoRAManager: runtime LoRA registry; auto-scans
loras/ for *.safetensors|*.ckpt|*.pt|*.bin|*.pth;
build_lora_chain() multi-node injection;
merge_configs() blend modes (average/max/sum_clamp);
LoRANotFoundError; seeded from LORA_MAPPINGS.
switchboard/index.html — Standalone HTML5 dashboard (zero build step):
Health | Queue | Generate | Batch | Presets | Config
panels; live auto-refresh; image preview; toast
notifications; dark neon UI.
Modified
--------
backend/rain_backend.py — Refactored _build_txt2img_workflow() to delegate
to WorkflowBuilder; CORS now driven by
ALLOWED_ORIGINS env var (no wildcard default).
docs/ARCHITECTURE.md — Fully updated: all implemented components,
module map, WorkflowBuilder/LoRAManager docs,
CORS hardening notes, Switchboard UI guide,
test-run instructions.
Tooling
-------
ruff.toml — Ruff linter + formatter config (line 100, py310,
E/W/F/I/N/UP/B/C4/SIM/TID/RUF rules).
mypy.ini — mypy strict config for backend/, relaxed for
tests/ and examples/; per-module third-party
ignore rules.
.env.example — Documented template for all supported env vars
(COMFYUI_HOST/PORT, ALLOWED_ORIGINS, RAINGOD_LORA_DIR,
LOG_LEVEL, OUTPUT_DIR, DEFAULT_CHECKPOINT, USE_GPU).
Workflow templates
------------------
workflows/txt2img_fast.json 20-step DPM++ 2M fast sampler
workflows/txt2img_quality.json 40-step quality sampler
workflows/txt2img_ultra.json 60-step ultra sampler
workflows/txt2img_draft.json Draft/preview sampler
workflows/txt2img_final.json Final high-quality sampler
workflows/txt2img_lora_synthwave.json Quality + pre-wired synthwave LoRA
workflows/txt2img_synthwave_lora.json Alias template
workflows/img2img_refine.json img2img refinement workflow
Test suite (184 tests, 0 failures)
-----------------------------------
tests/conftest.py Shared fixtures: mock ComfyUIClient, tmp dirs
tests/test_endpoints.py 50+ endpoint tests (all 9 routes)
tests/test_api_endpoints.py Additional endpoint coverage
tests/test_circuit_breaker.py CircuitBreaker + client unit tests
tests/test_workflow_builder.py WorkflowBuilder unit tests
tests/test_lora_manager.py LoRAManager unit tests
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements every high- and medium-priority action item identified in the live audit, converting the RAINGOD ComfyUI Integration from a skeleton with missing files into a fully working, tested, and documented backend service.
What Changed
🔴 High-Priority Fixes
backend/rain_backend.pyallow_origins=["*"]replaced withALLOWED_ORIGINSenv-var driven list; dev fallback tolocalhost:3000onlybackend/workflow_builder.pybuild_txt2img(),build_img2img(),build_upscale_pass(),from_template(),list_templates()backend/lora_manager.pyget()/load(),build_lora_chain(),merge_configs(),LoRANotFoundErrortests/backend/rain_backend.pyWorkflowBuilderinstead of inline 60-line node dict;on_event→ lifespan🟡 Medium-Priority
workflows/*.jsonworkflows/README.mdswitchboard/index.html🟢 Low-Priority / Infrastructure
ruff.tomlmypy.iniignore_missing_imports.env.exampledocs/ARCHITECTURE.mdTest Results
Coverage across:
tests/test_api_endpoints.py— all 9 REST endpoints including edge casestests/test_circuit_breaker.py— all 3 CB states, retry logic, deduptests/test_endpoints.py— additional endpoint contracts (duplicate coverage)tests/test_workflow_builder.py— txt2img, img2img, upscale, templates, LoRA injectiontests/test_lora_manager.py— scan, load, chain, merge, slug helperBreaking Changes
None — this PR only adds new modules and tightens CORS (was insecure
*).Existing deployments need to set
ALLOWED_ORIGINSbefore upgrading, or the backend defaults tohttp://localhost:3000only (with a logged warning).Still Pending (not in this PR)
DEVIANT2026_small.gif(12 MB binary in history)backend/av_sync.py)