mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 11:11:53 +00:00
## Summary
Architecture documentation proposing an Entity Component System for the
litegraph layer.
```mermaid
graph LR
subgraph Today["Today: Spaghetti"]
God["🍝 God Objects"]
Circ["🔄 Circular Deps"]
Mut["💥 Render Mutations"]
end
subgraph Tomorrow["Tomorrow: ECS"]
ID["🏷️ Branded IDs"]
Comp["📦 Components"]
Sys["⚙️ Systems"]
World["🌍 World"]
end
God -->|"decompose"| Comp
Circ -->|"flatten"| ID
Mut -->|"separate"| Sys
Comp --> World
ID --> World
Sys -->|"query"| World
```
## Changes
- **What**: ADR 0008 + 4 architecture docs (no code changes)
- `docs/adr/0008-entity-component-system.md` — entity taxonomy, branded
IDs, component decomposition, migration strategy
- `docs/architecture/entity-interactions.md` — as-is Mermaid diagrams of
all entity relationships
- `docs/architecture/entity-problems.md` — structural problems with
file:line evidence
- `docs/architecture/ecs-target-architecture.md` — target architecture
diagrams
- `docs/architecture/proto-ecs-stores.md` — analysis of existing Pinia
stores as proto-ECS patterns
## Review Focus
- Does the entity taxonomy (Node, Link, Subgraph, Widget, Slot, Reroute,
Group) cover all cases?
- Are the component decompositions reasonable starting points?
- Is the migration strategy (bridge layer, incremental extraction)
feasible?
- Are there entity interactions or problems we missed?
┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10420-docs-ADR-0008-Entity-Component-System-32d6d73d365081feb048d16a5231d350)
by [Unito](https://www.unito.io)
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Christian Byrne <cbyrne@comfy.org>
3.9 KiB
3.9 KiB
ADR Compliance Audit
Audit the current changes (or a specified PR) for compliance with Architecture Decision Records.
Step 1: Gather the Diff
- If a PR number is provided, run:
gh pr diff $PR_NUMBER - Otherwise, run:
git diff origin/main...HEAD(orgit diff --cachedfor staged changes)
Step 2: Priority 1 — ECS and Command-Pattern Compliance
Read these documents for context:
docs/adr/0003-crdt-based-layout-system.md
docs/adr/0008-entity-component-system.md
docs/architecture/ecs-target-architecture.md
docs/architecture/ecs-migration-plan.md
docs/architecture/appendix-critical-analysis.md
Check A: Command Pattern (ADR 0003)
Every entity state mutation must be a serializable, idempotent, deterministic command — replayable, undoable, transmittable over CRDT.
Flag:
- Direct spatial mutation —
node.pos = ...,node.size = ...,group.pos = ...outside a store/command - Imperative fire-and-forget APIs — Functions that mutate entity state as side effects rather than producing serializable command objects. Systems should produce command batches, not execute mutations directly.
- Void-returning mutation APIs — Entity mutations returning
voidinstead of{ status: 'applied' | 'rejected' | 'no-op' } - Auto-increment IDs — New entity creation via counters without addressing CRDT collision. Concurrent environments need globally unique identifiers.
- Missing transaction semantics — Multi-entity operations without atomic grouping (e.g., node removal = 10+ deletes with no rollback on failure)
Check B: ECS Architecture (ADR 0008)
Flag:
- God-object growth — New methods/properties on
LGraphNode,LGraphCanvas,LGraph,Subgraph - Mixed data/behavior — Component-like structures with methods or back-references
- OOP instance patterns — New
node.somePropertyornode.someMethod()for data that should be a World component - OOP inheritance — New entity subclasses instead of component composition
- Circular entity deps — New
LGraph↔Subgraph,LGraphNode↔LGraphCanvascircular imports - Direct
_version++— Mutating private version counter instead of through public API
Check C: Extension Ecosystem Impact
If any of these patterns are changed, flag and require migration guidance:
onConnectionsChange,onRemoved,onAdded,onConfigurecallbacksonConnectInput/onConnectOutputvalidation hooksonWidgetChangedhandlersnode.widgets.find(w => w.name === ...)access patternsnode.serializeoverridesgraph._version++direct mutation
Reference: 40+ custom node repos depend on these (rgthree-comfy, ComfyUI-Impact-Pack, cg-use-everywhere, etc.)
Step 3: Priority 2 — General ADR Compliance
- Read
docs/adr/README.mdfor the full ADR index - For each ADR (except skip list), read the Decision section
- Check the diff for contradictions
- Only flag ACTUAL violations in changed code
Skip list: ADR 0004 (Rejected — Fork PrimeVue)
Step 4: Generate Report
## ADR Compliance Audit Report
### Summary
- Files audited: N
- Priority 1 findings: N (command-pattern: N, ECS: N, ecosystem: N)
- Priority 2 findings: N
### Priority 1: Command Pattern & ECS
(List each with ADR reference, file, line, description)
### Priority 1: Extension Ecosystem Impact
(List each changed callback/API with affected custom node repos)
### Priority 2: General ADR Compliance
(List each with ADR reference, file, line, description)
### Compliant Patterns
(Note changes that positively align with ADR direction)
Severity
- Must fix: Contradicts accepted ADR, or introduces imperative mutation API without command-pattern wrapper, or breaks extension callback without migration path
- Should discuss: Contradicts proposed ADR direction — either align or propose ADR amendment
- Note: Surfaces open architectural question not yet addressed by ADRs