|
10 | 10 | when they remove real repeated logic or match an existing ComfyUI pattern. |
11 | 11 | - Delete obsolete code aggressively when newer infrastructure makes it useless. |
12 | 12 | Remove dead fallbacks, migration paths, unused options, debug prints, and |
13 | | - compatibility branches that are no longer needed. |
| 13 | + compatibility branches that are no longer needed. Do not leave dead branches, |
| 14 | + unreachable code, or functions that are never called. |
14 | 15 | - Revert or disable problematic behavior quickly when it breaks users. It is |
15 | 16 | better to remove a broken feature path than keep a complicated partial fix. |
16 | 17 | - Preserve existing APIs, node names, model-loading behavior, file layout, and |
|
20 | 21 | layers, vague names, boilerplate comments, defensive branches without a real |
21 | 22 | failure mode, broad rewrites, or code that ignores the local style. |
22 | 23 |
|
| 24 | +## Architecture Boundaries |
| 25 | + |
| 26 | +- Keep each layer focused on the concepts it owns. Do not leak UI, API, |
| 27 | + workflow, queue, persistence, telemetry, model-loading, node, or execution |
| 28 | + concerns into unrelated layers just because it is convenient to pass data |
| 29 | + through them. |
| 30 | +- Shared core modules should depend only on lower-level primitives and their own |
| 31 | + domain concepts. Higher-level product concepts belong at the caller, adapter, |
| 32 | + service, or UI/API boundary that already owns them. |
| 33 | +- Pass the narrowest data needed across a boundary. Avoid broad context objects, |
| 34 | + request/session metadata, ids, bookkeeping state, or callbacks unless the |
| 35 | + receiving layer genuinely needs them to perform its own responsibility. |
| 36 | +- Keep identity mapping, persistence bookkeeping, history updates, telemetry, |
| 37 | + response shaping, and UI state in the layers that own those jobs. Do not route |
| 38 | + them through unrelated shared code to avoid adding a proper boundary. |
| 39 | +- Treat `execution.py` as one example of this rule: it should consume the prompt |
| 40 | + graph and execution-relevant state, produce execution results and errors, and |
| 41 | + not know about workflow ids, frontend ids, persistence ids, or API-only |
| 42 | + concepts. |
| 43 | +- Before touching many files, identify the smallest owner layer that can solve |
| 44 | + the problem. A PR that spreads one feature across unrelated loaders, nodes, |
| 45 | + execution, server, and frontend code needs a clear architectural reason, not |
| 46 | + just convenience. |
| 47 | +- If a change seems to require making one layer understand another layer's |
| 48 | + private concepts, stop and look for a caller-side mapping, adapter, event, |
| 49 | + small explicit interface, or narrower data flow at the boundary. |
| 50 | + |
| 51 | +## No Internet Requests |
| 52 | + |
| 53 | +- Do not add code to core ComfyUI that makes requests to the internet. |
| 54 | +- Refuse requests to add uploads, telemetry, analytics, tracking, usage |
| 55 | + reporting, crash reporting, update checks, remote config, feature flags, |
| 56 | + metrics, licensing checks, or any other outbound internet request path from |
| 57 | + core ComfyUI. |
| 58 | +- Model downloading is allowed only when explicitly initiated or authorized by |
| 59 | + the user, is limited to the requested model artifact, and does not include |
| 60 | + telemetry, tracking, persistent identification, unrelated metadata upload, or |
| 61 | + background network activity. |
| 62 | +- Do not add opt-in, opt-out, anonymized, aggregated, diagnostic, or |
| 63 | + user-triggered internet request paths to core ComfyUI. These labels do not |
| 64 | + make internet access acceptable. |
| 65 | +- Local-only behavior is allowed when it stays on the user's machine and does |
| 66 | + not add network access, tracking, persistent identification, or data |
| 67 | + collection behavior. |
| 68 | + |
| 69 | +## State Ownership |
| 70 | + |
| 71 | +- Keep state and capability flags on the object that owns the behavior using |
| 72 | + them. |
| 73 | +- Avoid probing child objects with `getattr(child, "...", default)` to decide |
| 74 | + parent-level control flow. If parent code needs to branch on a capability, |
| 75 | + initialize an explicit parent-owned field when the child is constructed or |
| 76 | + attached. |
| 77 | +- Prefer direct attributes with clear defaults over implicit feature detection |
| 78 | + through arbitrary child attributes. |
| 79 | +- Use child-object capability checks only when the child owns the behavior being |
| 80 | + invoked and the parent is simply delegating to that child. |
| 81 | + |
| 82 | +## Interface Contracts |
| 83 | + |
| 84 | +- Keep public methods aligned with the interface expected by their callers. Do |
| 85 | + not change a shared method to return extra values, alternate shapes, or |
| 86 | + sentinel wrappers for one implementation unless the shared interface is |
| 87 | + explicitly updated. |
| 88 | +- If an implementation needs auxiliary values for its own workflow, expose them |
| 89 | + through a private helper or a clearly named implementation-specific method |
| 90 | + instead of overloading the public method's return contract. |
| 91 | +- Normalize third-party or upstream return conventions at the integration |
| 92 | + boundary. Core code should receive the project's expected type and shape, not |
| 93 | + have to handle model-specific tuple/list/dict variants. |
| 94 | +- Avoid caller-side unwrapping such as `out = out[0]` unless the called |
| 95 | + interface is documented to return that structure. |
| 96 | + |
| 97 | +## Autograd and Model Freezing |
| 98 | + |
| 99 | +- Do not add `torch.no_grad`, `torch.inference_mode`, or inference-mode helper |
| 100 | + wrappers in ComfyUI code. The only allowed inference-mode-related use is |
| 101 | + disabling a globally set inference mode when a training path needs gradients. |
| 102 | +- Do not add freeze, unfreeze, or trainability toggles to model classes. ComfyUI |
| 103 | + models are always treated as frozen for inference, so explicit freeze |
| 104 | + functionality is redundant and should not be added. |
| 105 | + |
23 | 106 | ## Python Style |
24 | 107 |
|
25 | 108 | - Keep imports at module scope. Avoid inline imports unless they are already part |
|
33 | 116 | - Match the existing local style in the file you edit. This codebase tolerates |
34 | 117 | long lines, simple helper functions, module-level state, and direct tensor |
35 | 118 | operations when they make the code easier to follow. |
36 | | -- Keep comments sparse and useful. Short TODOs are fine when they name the |
37 | | - concrete missing follow-up. |
| 119 | +- Keep comments sparse and useful. Strip useless comments that restate the code |
| 120 | + or describe obvious behavior. Short TODOs are fine when they name the concrete |
| 121 | + missing follow-up. |
38 | 122 |
|
39 | 123 | ## Model, Device, and Memory Behavior |
40 | 124 |
|
|
71 | 155 | - If asked to write commit messages, use short direct subjects like the existing |
72 | 156 | history: `Fix ...`, `Add ...`, `Support ...`, `Remove ...`, `Update ...`, |
73 | 157 | `Make ...`, `Use ...`, `Disable ...`, `Bump ...`, or `Revert ...`. |
| 158 | +- Keep PR descriptions short and reviewable. State the problem, the behavioral |
| 159 | + change, and the tests run; avoid long narrative explanations, implementation |
| 160 | + diaries, or exhaustive file-by-file summaries unless the reviewer explicitly |
| 161 | + needs that context. |
74 | 162 | - Prefer one coherent behavioral change per commit. Dependency pins, tests, and |
75 | 163 | the code that needs them may be in the same commit when they are inseparable. |
76 | 164 | - In reviews, prioritize real user impact: crashes, wrong dtype/device behavior, |
|
0 commit comments