Skip to content

feat: complete backend — WorkflowBuilder, LoRAManager, Switchboard UI, 184 tests, ruff/mypy/env tooling#2

Merged
POWDER-RANGER merged 1 commit intomainfrom
genspark_ai_developer
Feb 25, 2026
Merged

feat: complete backend — WorkflowBuilder, LoRAManager, Switchboard UI, 184 tests, ruff/mypy/env tooling#2
POWDER-RANGER merged 1 commit intomainfrom
genspark_ai_developer

Conversation

@POWDER-RANGER
Copy link
Owner

@POWDER-RANGER POWDER-RANGER commented Feb 25, 2026

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

Fix File Detail
CORS hardened backend/rain_backend.py allow_origins=["*"] replaced with ALLOWED_ORIGINS env-var driven list; dev fallback to localhost:3000 only
WorkflowBuilder created backend/workflow_builder.py Dynamic workflow assembly — build_txt2img(), build_img2img(), build_upscale_pass(), from_template(), list_templates()
LoRAManager created backend/lora_manager.py Registry seeded from config, filesystem scan, get()/load(), build_lora_chain(), merge_configs(), LoRANotFoundError
Test suite created tests/ 184 tests, 0 failures across 5 test modules
rain_backend refactored backend/rain_backend.py Uses WorkflowBuilder instead of inline 60-line node dict; on_event → lifespan

🟡 Medium-Priority

Addition File Detail
Workflow templates workflows/*.json 5 JSON templates: txt2img draft/quality/final, img2img refine, synthwave LoRA
Workflow README workflows/README.md Template table, placeholder docs, usage example
Switchboard UI switchboard/index.html Self-contained vanilla-JS dashboard: Dashboard, Generate (with chip selectors), Queue, Presets, Config, API Logs panels

🟢 Low-Priority / Infrastructure

Addition File Detail
Linter config ruff.toml Ruff rules: E/W/F/I/B/UP/N/SIM/RUF, line-length 100
Type-check config mypy.ini Strict-ish MyPy, Python 3.10, ignore_missing_imports
Env template .env.example All env vars documented with comments
Architecture docs docs/ARCHITECTURE.md Full rewrite — component status table, REST matrix, request flow, circuit breaker table, WB node map, LoRA manager API, CORS section

Test Results

184 passed, 1 warning in 3.18s

Coverage across:

  • tests/test_api_endpoints.py — all 9 REST endpoints including edge cases
  • tests/test_circuit_breaker.py — all 3 CB states, retry logic, dedup
  • tests/test_endpoints.py — additional endpoint contracts (duplicate coverage)
  • tests/test_workflow_builder.py — txt2img, img2img, upscale, templates, LoRA injection
  • tests/test_lora_manager.py — scan, load, chain, merge, slug helper

Breaking Changes

None — this PR only adds new modules and tightens CORS (was insecure *).

Existing deployments need to set ALLOWED_ORIGINS before upgrading, or the backend defaults to http://localhost:3000 only (with a logged warning).


Still Pending (not in this PR)

  • Git LFS migration for DEVIANT2026_small.gif (12 MB binary in history)
  • Audio-visual sync module (backend/av_sync.py)

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
@codecov
Copy link

codecov bot commented Feb 25, 2026

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 ☂️

@POWDER-RANGER POWDER-RANGER merged commit 5422233 into main Feb 25, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant