Comfy-Org / Comfy-Org/ComfyUI_frontend
Work off the 42 src/lib -> app-layer import violations and promote the lib layer zone to error
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 702
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 512
Description
`src/lib/` is vendored leaf code, but it currently imports from `renderer/`, `stores/`, `platform/`, `workbench/`, and `components/`. That is a dependency inversion: the library the app vendors depends on the app that vendors it.
The layer-zone rule in `eslint.config.ts` (`import-x/no-restricted-paths`) covers `src/base/`, `src/platform/`, `src/workbench/`, and `src/world/`, but no zone matched `src/lib/**`, so these imports passed silently.
The `src/lib/**` zone landed on `main` at **warning** severity in PR #14872 (merge `11162c045cdaf69228b5a17ab39752316444ec1f`), so it reports violations without breaking `main`. This issue now tracks the corrective follow-up: preserve the D-enf-05 growth-ratchet recommendation, use an accurate transitional boundary message, and handle the unsunsetted runtime inversions without reverting the merge.
> **Edit 2026-08-29:** #14872 has merged. Christian ruled "no need to revert" and to fix the policy gap later. The violation table below remains a filing-time snapshot; current counts and the ratchet/message correction are tracked separately.
## Violations (42 import declarations, 18 files)
### `@/renderer` (25)
| Location | Import |
| --- | --- |
| `src/lib/litegraph/src/LGraph.ts:10` | `@/renderer/core/layout/operations/layoutMutations` |
| `src/lib/litegraph/src/LGraph.ts:11` | `@/renderer/core/layout/types` |
| `src/lib/litegraph/src/LGraphCanvas.ts:7` | `@/renderer/core/canvas/useAutoPan` |
| `src/lib/litegraph/src/LGraphCanvas.ts:8` | `@/renderer/core/canvas/litegraph/litegraphLinkAdapter` |
| `src/lib/litegraph/src/LGraphCanvas.ts:9` | `@/renderer/core/canvas/litegraph/litegraphLinkAdapter` |
| `src/lib/litegraph/src/LGraphCanvas.ts:10` | `@/renderer/core/canvas/litegraph/slotCalculations` |
| `src/lib/litegraph/src/LGraphCanvas.ts:11` | `@/renderer/core/layout/operations/layoutMutations` |
| `src/lib/litegraph/src/LGraphCanvas.ts:12` | `@/renderer/core/layout/store/layoutStore` |
| `src/lib/litegraph/src/LGraphCanvas.ts:13` | `@/renderer/core/layout/types` |
| `src/lib/litegraph/src/LGraphNode.ts:7` | `@/renderer/core/canvas/litegraph/slotCalculations` |
| `src/lib/litegraph/src/LGraphNode.ts:8` | `@/renderer/core/canvas/litegraph/slotCalculations` |
| `src/lib/litegraph/src/LGraphNode.ts:9` | `@/renderer/core/layout/operations/layoutMutations` |
| `src/lib/litegraph/src/LGraphNode.ts:10` | `@/renderer/core/layout/store/layoutStore` |
| `src/lib/litegraph/src/LGraphNode.ts:11` | `@/renderer/core/layout/types` |
| `src/lib/litegraph/src/LGraphNode.ts:12` | `@/renderer/core/layout/utils/geometry` |
| `src/lib/litegraph/src/LLink.ts:7` | `@/renderer/core/layout/operations/layoutMutations` |
| `src/lib/litegraph/src/LLink.ts:8` | `@/renderer/core/layout/types` |
| `src/lib/litegraph/src/Reroute.ts:1` | `@/renderer/core/layout/operations/layoutMutations` |
| `src/lib/litegraph/src/Reroute.ts:5` | `@/renderer/core/layout/types` |
| `src/lib/litegraph/src/canvas/getCanvasContextMenuTarget.ts:1` | `@/renderer/core/layout/store/layoutStore` |
| `src/lib/litegraph/src/types/widgets.ts:1` | `@/renderer/core/layout/types` |
| `src/lib/litegraph/src/LGraphCanvas.cloneZIndex.test.ts:5` | `@/renderer/core/layout/store/layoutStore` |
| `src/lib/litegraph/src/LGraphCanvas.cloneZIndex.test.ts:6` | `@/renderer/core/layout/types` |
| `src/lib/litegraph/src/LGraphCanvas.cloneZIndex.test.ts:7` | `@/renderer/core/layout/types` |
| `src/lib/litegraph/src/LGraphCanvas.slotHitDetection.test.ts:9` | `@/renderer/core/layout/store/layoutStore` |
### `@/stores` (13)
| Location | Import |
| --- | --- |
| `src/lib/litegraph/src/LGraph.ts:14` | `@/stores/previewExposureStore` |
| `src/lib/litegraph/src/LGraph.ts:15` | `@/stores/widgetValueStore` |
| `src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts:7` | `@/stores/widgetValueStore` |
| `src/lib/litegraph/src/subgraph/SubgraphNode.ts:42` | `@/stores/previewExposureStore` |
| `src/lib/litegraph/src/subgraph/SubgraphNode.ts:43` | `@/stores/widgetValueStore` |
| `src/lib/litegraph/src/widgets/BaseWidget.ts:20` | `@/stores/widgetValueStore` |
| `src/lib/litegraph/src/LGraph.test.ts:18` | `@/stores/previewExposureStore` |
| `src/lib/litegraph/src/LGraph.test.ts:19` | `@/stores/widgetValueStore` |
| `src/lib/litegraph/src/LGraphCanvas.clipboard.test.ts:26` | `@/stores/previewExposureStore` |
| `src/lib/litegraph/src/subgraph/SubgraphNode.test.ts:21` | `@/stores/widgetValueStore` |
| `src/lib/litegraph/src/subgraph/SubgraphWidgetPromotion.test.ts:26` | `@/stores/previewExposureStore` |
| `src/lib/litegraph/src/subgraph/SubgraphWidgetPromotion.test.ts:27` | `@/stores/widgetValueStore` |
| `src/lib/litegraph/src/widgets/BaseWidget.test.ts:9` | `@/stores/widgetValueStore` |
### `@/platform` (2)
| Location | Import |
| --- | --- |
| `src/lib/litegraph/src/utils/namedValuesShadowDiffTelemetry.ts:1` | `@/platform/nodeReplacement/cnrIdUtil` |
| `src/lib/litegraph/src/utils/namedValuesShadowDiffTelemetry.ts:2` | `@/platform/telemetry` |
### `@/components` (1)
| Location | Import |
| --- | --- |
| `src/lib/litegraph/src/types/widgets.ts:2` | `@/components/curve/types` |
### `@/workbench` (1)
| Location | Import |
| --- | --- |
| `src/lib/litegraph/src/LGraphNode.widgetOrder.test.ts:10` | `@/workbench/utils/nodeDefOrderingUtil` |
## Plan to reach `error`
The warnings cluster into four fixes, roughly in dependency order:
1. **Type-only imports → move the type down.** `@/renderer/core/layout/types` (`Bounds`, `NodeLayout`, `LayoutSource`, `Size`) and `@/components/curve/types` (`CurveData`) are consumed by litegraph purely as types. These are geometry/data shapes with no renderer behaviour — relocate them to `src/lib/litegraph/src/types/` or `src/base/`, and re-export from the current path so app-layer callers are unaffected. This alone clears ~14 warnings including both lines of `src/lib/litegraph/src/types/widgets.ts`.
2. **Store reads → inject an accessor.** `widgetValueStore` and `previewExposureStore` are called from `LGraph`, `SubgraphNode`, `ExecutableNodeDTO`, and `BaseWidget`. Invert with a narrow port defined in `src/lib/litegraph/` that the app registers at bootstrap, rather than litegraph reaching into Pinia. Clears 13 (6 source + 7 test).
3. **Layout mutations / canvas adapters → renderer-owned.** `layoutMutations`, `layoutStore`, `slotCalculations`, `litegraphLinkAdapter`, `useAutoPan`, and `geometry` are the hard cases: real behavioural coupling between the canvas classes and the renderer's layout system. These need the same port treatment as (2) but with a wider surface, and are the natural follow-on to the ongoing layout/ECS work.
4. **Telemetry → platform port.** `namedValuesShadowDiffTelemetry.ts` is the only `@/platform` consumer; give it an injected telemetry sink or move the file out of `src/lib/`.
Test-file warnings (7) can be cleared alongside their source files, or immediately by moving the fixtures they need.
Once the count hits zero, flip the `src/lib/**` zone from `'warn'` to `'error'` in `eslint.config.ts`.
Contributor guide
Assessment
This issue has not been assessed yet.