Skip to content

fix: scope link and reroute topology by owning graph - #15009

Merged
DrJKL merged 15 commits into
feature/ecs-migrationfrom
drjkl/split-graph-scoped-topology
Aug 13, 2026
Merged

DrJKL merged 15 commits into
feature/ecs-migrationfrom
drjkl/split-graph-scoped-topology

Conversation

@DrJKL

@DrJKL DrJKL commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Split 2/6 of #14480. Stacked on #15001.

Fixes cross-subgraph-definition topology contamination: linkStore/rerouteStore buckets were keyed only by root graph id, but every subgraph definition numbers links from 1 and shares the IO pseudo-node ids (−10/−20). Two definitions under one root therefore shared an origin index and reroute membership — one definition's links joined another definition's reroute chains, driving wrong reroute pruning on configure. Repro: browser_tests/tests/subgraph/subgraphLinkIdentity.spec.ts + fixture.

Changes:

  • Adds GraphScope (rootGraphId, owningGraphId) and scopes topology queries, owner-local iteration, and teardown to the graph that directly owns each entity. Root-wide identity lookup remains keyed by rootGraphId.
  • Makes linkStore, rerouteStore, and nodeDataStore the authoritative collision boundaries. Registrations are first-wins; rejected entities remain detached and are not assigned to the requesting owner.
  • Shares link and reroute ID allocation across a root and its subgraphs. Serialized subgraphs are deduplicated before registration so link, reroute, node, widget, and promoted-widget references are remapped together.
  • Keeps endpoint swaps, rotations, and removals atomic within linkStore: an entire batch is validated before indexes or topology fields change. LLink retains the store-held reactive topology object across ID and endpoint updates.
  • Treats configure payloads as authoritative for their owner by clearing owner-local registrations before rebuilding them, with empty root-bucket pruning.
  • Derives topology scope from the directly owning graph at callers such as NodeSlots.vue and useProcessedWidgets.ts.
  • Positions promoted DOM widgets immediately on mount instead of waiting for a watched value to change.
  • Removes redundant graph-local collision checks, floating-link ID bookkeeping, unreachable tuple deduplication, obsolete compatibility types, and mock-only tests.
  • Documents root-vs-owner query guidance, topology transaction boundaries, and the deferred measurement of root-wide group scans before introducing another persistent index.

Behavior notes:

  • Constructing or configuring an LGraph from serialized data requires an active Pinia because entities register with topology stores during deserialization.
  • Runtime duplicate IDs are rejected by the root-scoped store; persisted collisions are remapped before object registration.
  • Registration failures remain explicit return values and do not throw errors.

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6c6b024d-7e44-40b5-8f73-6732af320203

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR replaces root-graph-only topology identifiers with root and owning graph scopes. It updates stores, graph lifecycle code, subgraph normalization, connection replacement, integrations, tests, and architecture documentation. It adds browser coverage for colliding subgraph link identities.

Changes

Graph-scoped topology identity

Layer / File(s) Summary
Scoped stores and lifecycle
src/types/*, src/stores/*, src/lib/litegraph/src/LGraph.ts, src/lib/litegraph/src/LLink.ts, src/lib/litegraph/src/Reroute.ts, src/lib/litegraph/src/LinkMap.ts
Topology stores now use root and owning graph scopes. Registration, lookup, deletion, clearing, collision rejection, and ownership checks use scoped identifiers.
Collision-safe subgraphs and connections
src/lib/litegraph/src/subgraph/*, src/lib/litegraph/src/LGraphCanvas.ts, src/lib/litegraph/src/linkDeduplication.ts
Subgraph loading remaps colliding entity IDs. Link replacement validates registration before disconnecting existing links. Failed link and reroute registration stops state updates and notifications.
Graph integrations and validation
src/components/*, src/core/*, src/extensions/*, src/renderer/*, src/systems/*, src/platform/*, src/lib/litegraph/src/*test.ts, src/stores/*test.ts, browser_tests/*
Consumers derive scopes from current graphs. Tests cover scoped ownership, duplicate registration, cleanup, floating links, subgraph collisions, and public topology views.
Architecture and migration contracts
docs/architecture/*, docs/extensions/*
Documentation describes root-wide link identity, owner-qualified indexes, store-backed compatibility views, lifecycle behavior, and failed registration handling.

Estimated code review effort: 4 (Complex) | ~60 minutes

Mergeability Score: 🟡 Moderate · up to 58840

This PR changes graph topology ownership, identity allocation, and connection replacement behavior. The current implementation can allow equivalent node IDs to occupy separate indexes and can leave a subgraph connection referencing a link that was removed during replacement cleanup, causing incorrect topology state. These bounded correctness risks should be fixed or explicitly accepted before merging.

Sequence Diagram(s)

sequenceDiagram
  participant LGraph
  participant LinkStore
  participant RerouteStore
  participant GraphConsumer
  LGraph->>LinkStore: register link topology with GraphScope
  LGraph->>RerouteStore: register reroute chain with GraphScope
  GraphConsumer->>LinkStore: query scoped connectivity
  GraphConsumer->>RerouteStore: query scoped membership
  LGraph->>LinkStore: clear owner or root graph
  LGraph->>RerouteStore: clear owner or root graph
Loading

Possibly related PRs

Suggested reviewers: christian-byrne, jtydhr88


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Adr Compliance For Entity/Litegraph Changes ⚠️ Warning ADR 0008: LGraph teardown and SubgraphInput/Output changes alter node-removal and connection-event callbacks; the PR adds link-registration guidance but no callback migration guidance. See docs/adr/. Document the changed onRemoved/onConnectionsChange callback ordering and suppression behavior, or preserve the prior extension callback contract; update the ADR 0008 guidance in docs/adr/.
End-To-End Regression Coverage For Fixes ❓ Inconclusive The changed-file list and description are available, but the PR title and commit subjects are not; the required bug-fix signal cannot be verified under this check. Provide the PR title and commit subjects, then reassess the explicit bug-fix language condition.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the primary change: scoping link and reroute topology by owning graph.
Description check ✅ Passed The description clearly explains the issue, implementation, behavior changes, review considerations, and reproduction coverage.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch drjkl/split-graph-scoped-topology

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright: ✅ 1809 passed, 0 failed · 4 flaky

📊 Browser Reports
  • chromium: View Report (✅ 1788 / ❌ 0 / ⚠️ 4 / ⏭️ 5)
  • chromium-2x: View Report (✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • chromium-0.5x: View Report (✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • mobile-chrome: View Report (✅ 18 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • New-test walkthrough (chromium, recorded video): View Report

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 08/13/2026, 06:17:42 PM UTC

Links

📦 Bundle Size

⏳ Size data collection in progress…

⚡ Performance Report

canvas-idle: · 60.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 0ms TBT · 59.7 MB heap
canvas-mouse-sweep: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 61.5 MB heap
canvas-zoom-sweep: · 60.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 0ms TBT · 50.3 MB heap
dom-widget-clipping: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 63.4 MB heap
large-graph-idle: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 65.4 MB heap
large-graph-pan: · 60.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 0ms TBT · 75.8 MB heap
large-graph-zoom: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 72.4 MB heap
legacy-node-drag: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 55.3 MB heap
minimap-idle: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 67.7 MB heap
subgraph-dom-widget-clipping: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 61.4 MB heap
subgraph-idle: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 59.8 MB heap
subgraph-mouse-sweep: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 51.2 MB heap
subgraph-transition-enter: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 119ms TBT · 93.2 MB heap
viewport-pan-sweep: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 77.4 MB heap
vue-large-graph-idle: · 55.4 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 171.0 MB heap
vue-large-graph-pan: · 54.6 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 1292ms TBT · 166.3 MB heap
workflow-execution: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 49.8 MB heap

ℹ️ No baseline found — significance unavailable.

Absolute values
Metric Value
canvas-idle: avg frame time 17ms
canvas-idle: p95 frame time 17ms
canvas-idle: layout duration 0ms
canvas-idle: style recalc duration 5ms
canvas-idle: layout count 0
canvas-idle: style recalc count 7
canvas-idle: task duration 521ms
canvas-idle: script duration 26ms
canvas-idle: TBT 0ms
canvas-idle: heap used 59.7 MB
canvas-idle: DOM nodes -134
canvas-idle: event listeners -76
canvas-mouse-sweep: avg frame time 17ms
canvas-mouse-sweep: p95 frame time 17ms
canvas-mouse-sweep: layout duration 4ms
canvas-mouse-sweep: style recalc duration 41ms
canvas-mouse-sweep: layout count 12
canvas-mouse-sweep: style recalc count 80
canvas-mouse-sweep: task duration 1226ms
canvas-mouse-sweep: script duration 161ms
canvas-mouse-sweep: TBT 0ms
canvas-mouse-sweep: heap used 61.5 MB
canvas-mouse-sweep: DOM nodes -282
canvas-mouse-sweep: event listeners -170
canvas-zoom-sweep: avg frame time 17ms
canvas-zoom-sweep: p95 frame time 17ms
canvas-zoom-sweep: layout duration 1ms
canvas-zoom-sweep: style recalc duration 17ms
canvas-zoom-sweep: layout count 6
canvas-zoom-sweep: style recalc count 32
canvas-zoom-sweep: task duration 392ms
canvas-zoom-sweep: script duration 28ms
canvas-zoom-sweep: TBT 0ms
canvas-zoom-sweep: heap used 50.3 MB
canvas-zoom-sweep: DOM nodes 77
canvas-zoom-sweep: event listeners 19
dom-widget-clipping: avg frame time 17ms
dom-widget-clipping: p95 frame time 17ms
dom-widget-clipping: layout duration 0ms
dom-widget-clipping: style recalc duration 6ms
dom-widget-clipping: layout count 0
dom-widget-clipping: style recalc count 10
dom-widget-clipping: task duration 438ms
dom-widget-clipping: script duration 39ms
dom-widget-clipping: TBT 0ms
dom-widget-clipping: heap used 63.4 MB
dom-widget-clipping: DOM nodes 16
dom-widget-clipping: event listeners 2
large-graph-idle: avg frame time 17ms
large-graph-idle: p95 frame time 17ms
large-graph-idle: layout duration 0ms
large-graph-idle: style recalc duration 4ms
large-graph-idle: layout count 0
large-graph-idle: style recalc count 6
large-graph-idle: task duration 816ms
large-graph-idle: script duration 296ms
large-graph-idle: TBT 0ms
large-graph-idle: heap used 65.4 MB
large-graph-idle: DOM nodes -282
large-graph-idle: event listeners -154
large-graph-pan: avg frame time 17ms
large-graph-pan: p95 frame time 17ms
large-graph-pan: layout duration 0ms
large-graph-pan: style recalc duration 13ms
large-graph-pan: layout count 0
large-graph-pan: style recalc count 67
large-graph-pan: task duration 2732ms
large-graph-pan: script duration 1239ms
large-graph-pan: TBT 0ms
large-graph-pan: heap used 75.8 MB
large-graph-pan: DOM nodes -283
large-graph-pan: event listeners -165
large-graph-zoom: avg frame time 17ms
large-graph-zoom: p95 frame time 17ms
large-graph-zoom: layout duration 9ms
large-graph-zoom: style recalc duration 14ms
large-graph-zoom: layout count 60
large-graph-zoom: style recalc count 68
large-graph-zoom: task duration 2959ms
large-graph-zoom: script duration 1387ms
large-graph-zoom: TBT 0ms
large-graph-zoom: heap used 72.4 MB
large-graph-zoom: DOM nodes 27
large-graph-zoom: event listeners 13
legacy-node-drag: avg frame time 17ms
legacy-node-drag: p95 frame time 17ms
legacy-node-drag: layout duration 0ms
legacy-node-drag: style recalc duration 5ms
legacy-node-drag: layout count 0
legacy-node-drag: style recalc count 42
legacy-node-drag: task duration 2817ms
legacy-node-drag: script duration 711ms
legacy-node-drag: TBT 0ms
legacy-node-drag: heap used 55.3 MB
legacy-node-drag: DOM nodes -289
legacy-node-drag: event listeners -126
minimap-idle: avg frame time 17ms
minimap-idle: p95 frame time 17ms
minimap-idle: layout duration 0ms
minimap-idle: style recalc duration 4ms
minimap-idle: layout count 0
minimap-idle: style recalc count 5
minimap-idle: task duration 828ms
minimap-idle: script duration 301ms
minimap-idle: TBT 0ms
minimap-idle: heap used 67.7 MB
minimap-idle: DOM nodes -283
minimap-idle: event listeners -153
subgraph-dom-widget-clipping: avg frame time 17ms
subgraph-dom-widget-clipping: p95 frame time 17ms
subgraph-dom-widget-clipping: layout duration 0ms
subgraph-dom-widget-clipping: style recalc duration 8ms
subgraph-dom-widget-clipping: layout count 0
subgraph-dom-widget-clipping: style recalc count 45
subgraph-dom-widget-clipping: task duration 528ms
subgraph-dom-widget-clipping: script duration 139ms
subgraph-dom-widget-clipping: TBT 0ms
subgraph-dom-widget-clipping: heap used 61.4 MB
subgraph-dom-widget-clipping: DOM nodes 15
subgraph-dom-widget-clipping: event listeners 8
subgraph-idle: avg frame time 17ms
subgraph-idle: p95 frame time 17ms
subgraph-idle: layout duration 0ms
subgraph-idle: style recalc duration 8ms
subgraph-idle: layout count 0
subgraph-idle: style recalc count 10
subgraph-idle: task duration 483ms
subgraph-idle: script duration 18ms
subgraph-idle: TBT 0ms
subgraph-idle: heap used 59.8 MB
subgraph-idle: DOM nodes -138
subgraph-idle: event listeners -100
subgraph-mouse-sweep: avg frame time 17ms
subgraph-mouse-sweep: p95 frame time 17ms
subgraph-mouse-sweep: layout duration 5ms
subgraph-mouse-sweep: style recalc duration 38ms
subgraph-mouse-sweep: layout count 16
subgraph-mouse-sweep: style recalc count 77
subgraph-mouse-sweep: task duration 1129ms
subgraph-mouse-sweep: script duration 113ms
subgraph-mouse-sweep: TBT 0ms
subgraph-mouse-sweep: heap used 51.2 MB
subgraph-mouse-sweep: DOM nodes -297
subgraph-mouse-sweep: event listeners -203
subgraph-transition-enter: avg frame time 17ms
subgraph-transition-enter: p95 frame time 17ms
subgraph-transition-enter: layout duration 11ms
subgraph-transition-enter: style recalc duration 29ms
subgraph-transition-enter: layout count 14
subgraph-transition-enter: style recalc count 18
subgraph-transition-enter: task duration 958ms
subgraph-transition-enter: script duration 55ms
subgraph-transition-enter: TBT 119ms
subgraph-transition-enter: heap used 93.2 MB
subgraph-transition-enter: DOM nodes 13671
subgraph-transition-enter: event listeners 2381
viewport-pan-sweep: avg frame time 17ms
viewport-pan-sweep: p95 frame time 17ms
viewport-pan-sweep: layout duration 0ms
viewport-pan-sweep: style recalc duration 40ms
viewport-pan-sweep: layout count 0
viewport-pan-sweep: style recalc count 247
viewport-pan-sweep: task duration 9741ms
viewport-pan-sweep: script duration 4374ms
viewport-pan-sweep: TBT 0ms
viewport-pan-sweep: heap used 77.4 MB
viewport-pan-sweep: DOM nodes -281
viewport-pan-sweep: event listeners -127
vue-large-graph-idle: avg frame time 18ms
vue-large-graph-idle: p95 frame time 17ms
vue-large-graph-idle: layout duration 0ms
vue-large-graph-idle: style recalc duration 0ms
vue-large-graph-idle: layout count 0
vue-large-graph-idle: style recalc count 0
vue-large-graph-idle: task duration 18624ms
vue-large-graph-idle: script duration 1281ms
vue-large-graph-idle: TBT 0ms
vue-large-graph-idle: heap used 171.0 MB
vue-large-graph-idle: DOM nodes -6548
vue-large-graph-idle: event listeners -7470
vue-large-graph-pan: avg frame time 18ms
vue-large-graph-pan: p95 frame time 17ms
vue-large-graph-pan: layout duration 0ms
vue-large-graph-pan: style recalc duration 28ms
vue-large-graph-pan: layout count 0
vue-large-graph-pan: style recalc count 178
vue-large-graph-pan: task duration 23948ms
vue-large-graph-pan: script duration 1912ms
vue-large-graph-pan: TBT 1292ms
vue-large-graph-pan: heap used 166.3 MB
vue-large-graph-pan: DOM nodes -6548
vue-large-graph-pan: event listeners -7464
workflow-execution: avg frame time 17ms
workflow-execution: p95 frame time 17ms
workflow-execution: layout duration 1ms
workflow-execution: style recalc duration 25ms
workflow-execution: layout count 3
workflow-execution: style recalc count 16
workflow-execution: task duration 135ms
workflow-execution: script duration 10ms
workflow-execution: TBT 0ms
workflow-execution: heap used 49.8 MB
workflow-execution: DOM nodes 125
workflow-execution: event listeners 97
Raw data
{
  "timestamp": "2026-08-13T18:28:52.069Z",
  "gitSha": "b3b6a365b8df23f753bb9595259aac130eee961d",
  "branch": "drjkl/split-graph-scoped-topology",
  "measurements": [
    {
      "name": "canvas-idle",
      "durationMs": 2094.449999999995,
      "styleRecalcs": 7,
      "styleRecalcDurationMs": 5.455999999999999,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 584.441,
      "heapDeltaBytes": -21188560,
      "heapUsedBytes": 47554264,
      "domNodes": -282,
      "jsHeapTotalBytes": 20156416,
      "scriptDurationMs": 29.112,
      "eventListeners": -155,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66999999999998,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "canvas-idle",
      "durationMs": 2017.934000000082,
      "styleRecalcs": 7,
      "styleRecalcDurationMs": 5.047,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 457.8420000000001,
      "heapDeltaBytes": 8626852,
      "heapUsedBytes": 77599960,
      "domNodes": 14,
      "jsHeapTotalBytes": 20709376,
      "scriptDurationMs": 23.294999999999995,
      "eventListeners": 4,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "canvas-mouse-sweep",
      "durationMs": 2206.9059999999754,
      "styleRecalcs": 80,
      "styleRecalcDurationMs": 42.416000000000004,
      "layouts": 12,
      "layoutDurationMs": 3.7920000000000003,
      "taskDurationMs": 1230.9470000000001,
      "heapDeltaBytes": 2230064,
      "heapUsedBytes": 70823552,
      "domNodes": -281,
      "jsHeapTotalBytes": 20549632,
      "scriptDurationMs": 164.76,
      "eventListeners": -155,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "canvas-mouse-sweep",
      "durationMs": 2242.050000000063,
      "styleRecalcs": 80,
      "styleRecalcDurationMs": 39.118,
      "layouts": 12,
      "layoutDurationMs": 3.695,
      "taskDurationMs": 1221.4910000000002,
      "heapDeltaBytes": -10851688,
      "heapUsedBytes": 58054332,
      "domNodes": -282,
      "jsHeapTotalBytes": 21336064,
      "scriptDurationMs": 157.479,
      "eventListeners": -185,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "canvas-zoom-sweep",
      "durationMs": 1755.6519999999978,
      "styleRecalcs": 32,
      "styleRecalcDurationMs": 18.706,
      "layouts": 6,
      "layoutDurationMs": 0.712,
      "taskDurationMs": 398.381,
      "heapDeltaBytes": -15843228,
      "heapUsedBytes": 52983612,
      "domNodes": 77,
      "jsHeapTotalBytes": 20971520,
      "scriptDurationMs": 29.999000000000006,
      "eventListeners": 19,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "canvas-zoom-sweep",
      "durationMs": 1738.4319999999889,
      "styleRecalcs": 31,
      "styleRecalcDurationMs": 15.276000000000002,
      "layouts": 6,
      "layoutDurationMs": 0.585,
      "taskDurationMs": 385.67900000000003,
      "heapDeltaBytes": -16089872,
      "heapUsedBytes": 52514016,
      "domNodes": 77,
      "jsHeapTotalBytes": 20971520,
      "scriptDurationMs": 26.679000000000002,
      "eventListeners": 19,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "dom-widget-clipping",
      "durationMs": 717.3700000000167,
      "styleRecalcs": 9,
      "styleRecalcDurationMs": 5.326999999999998,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 430.78499999999997,
      "heapDeltaBytes": -2188444,
      "heapUsedBytes": 66592120,
      "domNodes": 14,
      "jsHeapTotalBytes": 20971520,
      "scriptDurationMs": 37.752,
      "eventListeners": 2,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "dom-widget-clipping",
      "durationMs": 757.3390000000018,
      "styleRecalcs": 11,
      "styleRecalcDurationMs": 6.756000000000002,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 445.426,
      "heapDeltaBytes": -2460292,
      "heapUsedBytes": 66398128,
      "domNodes": 18,
      "jsHeapTotalBytes": 21757952,
      "scriptDurationMs": 41.086,
      "eventListeners": 2,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "large-graph-idle",
      "durationMs": 2053.2680000000028,
      "styleRecalcs": 6,
      "styleRecalcDurationMs": 4.9769999999999985,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 806.6089999999999,
      "heapDeltaBytes": 4710036,
      "heapUsedBytes": 67851504,
      "domNodes": -280,
      "jsHeapTotalBytes": 2719744,
      "scriptDurationMs": 288.77699999999993,
      "eventListeners": -155,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333335,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "large-graph-idle",
      "durationMs": 2051.4929999999367,
      "styleRecalcs": 5,
      "styleRecalcDurationMs": 3.778000000000002,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 826.182,
      "heapDeltaBytes": 4708936,
      "heapUsedBytes": 69390744,
      "domNodes": -283,
      "jsHeapTotalBytes": 2719744,
      "scriptDurationMs": 302.649,
      "eventListeners": -153,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66999999999998,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "large-graph-pan",
      "durationMs": 3364.2469999999776,
      "styleRecalcs": 67,
      "styleRecalcDurationMs": 12.798,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 2739.847,
      "heapDeltaBytes": 22810520,
      "heapUsedBytes": 87880440,
      "domNodes": -281,
      "jsHeapTotalBytes": 4485120,
      "scriptDurationMs": 1233.9799999999998,
      "eventListeners": -149,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "large-graph-pan",
      "durationMs": 3339.5359999999528,
      "styleRecalcs": 66,
      "styleRecalcDurationMs": 12.471,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 2724.326,
      "heapDeltaBytes": 6020804,
      "heapUsedBytes": 71143000,
      "domNodes": -285,
      "jsHeapTotalBytes": 3698688,
      "scriptDurationMs": 1243.339,
      "eventListeners": -181,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "large-graph-zoom",
      "durationMs": 4977.938000000051,
      "styleRecalcs": 68,
      "styleRecalcDurationMs": 14.664,
      "layouts": 60,
      "layoutDurationMs": 8.661,
      "taskDurationMs": 3030.534,
      "heapDeltaBytes": -4416284,
      "heapUsedBytes": 67003268,
      "domNodes": 28,
      "jsHeapTotalBytes": 6553600,
      "scriptDurationMs": 1423.8310000000001,
      "eventListeners": 14,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "large-graph-zoom",
      "durationMs": 4783.336000000077,
      "styleRecalcs": 67,
      "styleRecalcDurationMs": 13.197000000000001,
      "layouts": 60,
      "layoutDurationMs": 8.496,
      "taskDurationMs": 2887.7450000000003,
      "heapDeltaBytes": 12882836,
      "heapUsedBytes": 84857172,
      "domNodes": 26,
      "jsHeapTotalBytes": 6815744,
      "scriptDurationMs": 1350.639,
      "eventListeners": 12,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.670000000000012,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "legacy-node-drag",
      "durationMs": 4148.5729999999985,
      "styleRecalcs": 42,
      "styleRecalcDurationMs": 5.762,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 2825.0710000000004,
      "heapDeltaBytes": -13778872,
      "heapUsedBytes": 57689272,
      "domNodes": -286,
      "jsHeapTotalBytes": 9011200,
      "scriptDurationMs": 711.3190000000001,
      "eventListeners": -140,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "legacy-node-drag",
      "durationMs": 4145.992999999976,
      "styleRecalcs": 41,
      "styleRecalcDurationMs": 5.023999999999997,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 2809.485,
      "heapDeltaBytes": -14675924,
      "heapUsedBytes": 58337360,
      "domNodes": -291,
      "jsHeapTotalBytes": 7962624,
      "scriptDurationMs": 710.565,
      "eventListeners": -112,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "minimap-idle",
      "durationMs": 2066.808999999978,
      "styleRecalcs": 4,
      "styleRecalcDurationMs": 3.4049999999999985,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 838.018,
      "heapDeltaBytes": 5354728,
      "heapUsedBytes": 70235096,
      "domNodes": -284,
      "jsHeapTotalBytes": 3244032,
      "scriptDurationMs": 305.757,
      "eventListeners": -153,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "minimap-idle",
      "durationMs": 2074.5620000000145,
      "styleRecalcs": 5,
      "styleRecalcDurationMs": 3.9380000000000006,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 818.0679999999999,
      "heapDeltaBytes": 6692176,
      "heapUsedBytes": 71734940,
      "domNodes": -282,
      "jsHeapTotalBytes": 3244032,
      "scriptDurationMs": 296.92400000000004,
      "eventListeners": -153,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66999999999998,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "subgraph-dom-widget-clipping",
      "durationMs": 748.6319999999864,
      "styleRecalcs": 46,
      "styleRecalcDurationMs": 9.914,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 537.241,
      "heapDeltaBytes": -5195760,
      "heapUsedBytes": 64384480,
      "domNodes": 18,
      "jsHeapTotalBytes": 21757952,
      "scriptDurationMs": 141.145,
      "eventListeners": 8,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "subgraph-dom-widget-clipping",
      "durationMs": 731.734000000074,
      "styleRecalcs": 43,
      "styleRecalcDurationMs": 6.983,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 519.385,
      "heapDeltaBytes": -5032464,
      "heapUsedBytes": 64358888,
      "domNodes": 12,
      "jsHeapTotalBytes": 22282240,
      "scriptDurationMs": 137.219,
      "eventListeners": 8,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333335,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "subgraph-idle",
      "durationMs": 2023.836000000017,
      "styleRecalcs": 9,
      "styleRecalcDurationMs": 7.3980000000000015,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 507.317,
      "heapDeltaBytes": -20020528,
      "heapUsedBytes": 49280100,
      "domNodes": -295,
      "jsHeapTotalBytes": 19107840,
      "scriptDurationMs": 17.672,
      "eventListeners": -203,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "subgraph-idle",
      "durationMs": 2004.0370000000394,
      "styleRecalcs": 10,
      "styleRecalcDurationMs": 7.656,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 459.63000000000005,
      "heapDeltaBytes": 6675520,
      "heapUsedBytes": 76161192,
      "domNodes": 20,
      "jsHeapTotalBytes": 20709376,
      "scriptDurationMs": 17.591,
      "eventListeners": 4,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "subgraph-mouse-sweep",
      "durationMs": 1874.557999999979,
      "styleRecalcs": 76,
      "styleRecalcDurationMs": 35.845,
      "layouts": 16,
      "layoutDurationMs": 4.209,
      "taskDurationMs": 1107.8249999999998,
      "heapDeltaBytes": -18156672,
      "heapUsedBytes": 51409200,
      "domNodes": -299,
      "jsHeapTotalBytes": 19369984,
      "scriptDurationMs": 111.39,
      "eventListeners": -203,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "subgraph-mouse-sweep",
      "durationMs": 1890.863999999965,
      "styleRecalcs": 77,
      "styleRecalcDurationMs": 39.858,
      "layouts": 16,
      "layoutDurationMs": 4.864999999999999,
      "taskDurationMs": 1150.954,
      "heapDeltaBytes": -13429176,
      "heapUsedBytes": 56045580,
      "domNodes": -294,
      "jsHeapTotalBytes": 18845696,
      "scriptDurationMs": 113.67399999999999,
      "eventListeners": -203,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "subgraph-transition-enter",
      "durationMs": 1401.3410000000022,
      "styleRecalcs": 18,
      "styleRecalcDurationMs": 29.403999999999993,
      "layouts": 14,
      "layoutDurationMs": 11.112,
      "taskDurationMs": 958.01,
      "heapDeltaBytes": 30237580,
      "heapUsedBytes": 97686152,
      "domNodes": 13671,
      "jsHeapTotalBytes": 9175040,
      "scriptDurationMs": 54.730000000000004,
      "eventListeners": 2381,
      "totalBlockingTimeMs": 119,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "viewport-pan-sweep",
      "durationMs": 12943.07299999997,
      "styleRecalcs": 246,
      "styleRecalcDurationMs": 39.717,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 9906.821,
      "heapDeltaBytes": 25001596,
      "heapUsedBytes": 89645664,
      "domNodes": -282,
      "jsHeapTotalBytes": 5009408,
      "scriptDurationMs": 4470.079,
      "eventListeners": -127,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "viewport-pan-sweep",
      "durationMs": 12424.125000000004,
      "styleRecalcs": 247,
      "styleRecalcDurationMs": 40.036,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 9574.975999999999,
      "heapDeltaBytes": 9913720,
      "heapUsedBytes": 72762600,
      "domNodes": -280,
      "jsHeapTotalBytes": 4485120,
      "scriptDurationMs": 4278.641,
      "eventListeners": -127,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "vue-large-graph-idle",
      "durationMs": 18586.95399999999,
      "styleRecalcs": 0,
      "styleRecalcDurationMs": 0,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 18569.363,
      "heapDeltaBytes": -32688244,
      "heapUsedBytes": 172908376,
      "domNodes": -6548,
      "jsHeapTotalBytes": 5824512,
      "scriptDurationMs": 1267.25,
      "eventListeners": -7471,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 18.333333333333332,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "vue-large-graph-idle",
      "durationMs": 18692.741999999955,
      "styleRecalcs": 0,
      "styleRecalcDurationMs": 0,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 18679.144999999997,
      "heapDeltaBytes": -7961996,
      "heapUsedBytes": 185699076,
      "domNodes": -6548,
      "jsHeapTotalBytes": 6086656,
      "scriptDurationMs": 1294.026,
      "eventListeners": -7469,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 17.780000000000047,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-large-graph-pan",
      "durationMs": 23867.141000000003,
      "styleRecalcs": 180,
      "styleRecalcDurationMs": 27.585000000000026,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 23847.319,
      "heapDeltaBytes": -11962644,
      "heapUsedBytes": 179917148,
      "domNodes": -6548,
      "jsHeapTotalBytes": 3657728,
      "scriptDurationMs": 1899.4530000000002,
      "eventListeners": -7465,
      "totalBlockingTimeMs": 1301,
      "frameDurationMs": 18.329999999999927,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "vue-large-graph-pan",
      "durationMs": 24067.607000000065,
      "styleRecalcs": 176,
      "styleRecalcDurationMs": 28.658999999999992,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 24047.784,
      "heapDeltaBytes": -36224452,
      "heapUsedBytes": 168942380,
      "domNodes": -6548,
      "jsHeapTotalBytes": 3465216,
      "scriptDurationMs": 1924.0239999999997,
      "eventListeners": -7463,
      "totalBlockingTimeMs": 1283,
      "frameDurationMs": 18.329999999999927,
      "p95FrameDurationMs": 16.80000000000291
    },
    {
      "name": "workflow-execution",
      "durationMs": 457.9680000000508,
      "styleRecalcs": 15,
      "styleRecalcDurationMs": 24.784,
      "layouts": 2,
      "layoutDurationMs": 0.5260000000000001,
      "taskDurationMs": 126.28099999999998,
      "heapDeltaBytes": -14174072,
      "heapUsedBytes": 52182900,
      "domNodes": 124,
      "jsHeapTotalBytes": 9699328,
      "scriptDurationMs": 9.906000000000002,
      "eventListeners": 97,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000273
    },
    {
      "name": "workflow-execution",
      "durationMs": 464.6579999999858,
      "styleRecalcs": 17,
      "styleRecalcDurationMs": 26.186999999999994,
      "layouts": 4,
      "layoutDurationMs": 1.3679999999999999,
      "taskDurationMs": 143.251,
      "heapDeltaBytes": -14173764,
      "heapUsedBytes": 52254584,
      "domNodes": 125,
      "jsHeapTotalBytes": 10223616,
      "scriptDurationMs": 10.562000000000001,
      "eventListeners": 97,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    }
  ]
}

@codecov

codecov Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.24668% with 33 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/lib/litegraph/src/subgraph/SubgraphInput.ts 56.52% 10 Missing ⚠️
src/services/subgraphService.ts 0.00% 10 Missing ⚠️
src/lib/litegraph/src/subgraph/SubgraphOutput.ts 42.85% 4 Missing ⚠️
src/components/builder/AppModeWidgetList.vue 0.00% 3 Missing ⚠️
src/lib/litegraph/src/subgraph/SubgraphNode.ts 0.00% 2 Missing ⚠️
...ib/litegraph/src/subgraph/subgraphDeduplication.ts 96.55% 2 Missing ⚠️
src/lib/litegraph/src/node/slotLinks.ts 75.00% 1 Missing ⚠️
src/stores/nodeDataStore.ts 98.11% 1 Missing ⚠️
@@                    Coverage Diff                    @@
##           feature/ecs-migration   #15009      +/-   ##
=========================================================
+ Coverage                  81.03%   81.06%   +0.03%     
=========================================================
  Files                       1897     1898       +1     
  Lines                     109750   109820      +70     
  Branches                   34669    34185     -484     
=========================================================
+ Hits                       88933    89026      +93     
+ Misses                     20423    20402      -21     
+ Partials                     394      392       -2     
Flag Coverage Δ
unit 72.90% <91.22%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/components/graph/widgets/DomWidget.vue 90.69% <ø> (+1.16%) ⬆️
...omponents/rightSidePanel/parameters/WidgetItem.vue 86.25% <100.00%> (ø)
...e/graph/subgraph/migration/proxyWidgetMigration.ts 92.24% <100.00%> (+0.02%) ⬆️
src/core/graph/widgets/dynamicWidgets.ts 89.97% <ø> (ø)
src/extensions/core/widgetValuePropagation.ts 84.84% <ø> (ø)
src/lib/litegraph/src/LGraph.ts 78.18% <100.00%> (-0.25%) ⬇️
src/lib/litegraph/src/LGraphCanvas.ts 65.00% <ø> (-0.05%) ⬇️
src/lib/litegraph/src/LGraphNode.ts 65.19% <ø> (-0.04%) ⬇️
src/lib/litegraph/src/LLink.ts 50.00% <ø> (ø)
src/lib/litegraph/src/Reroute.ts 63.25% <ø> (ø)
... and 20 more

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DrJKL DrJKL added the refactor label Aug 10, 2026
Base automatically changed from drjkl/split-id-allocation to feature/ecs-migration August 10, 2026 23:26
@DrJKL
DrJKL force-pushed the drjkl/split-graph-scoped-topology branch from 7fc5aa4 to d1fc17a Compare August 10, 2026 23:40

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@browser_tests/tests/subgraph/subgraphLinkIdentity.spec.ts`:
- Around line 16-39: Update the topology assertion around the evaluated subgraph
nodes to resolve each reroute from its local reroutes map and include its
linkIds in the returned data. Assert that both definitions have reroute
membership with linkIds equal to [1], while preserving the existing
definitionId, parentId, and sorting checks.

In `@src/stores/linkStore.test.ts`:
- Around line 440-457: Add an assertion to the floating-link re-keying test
around updateEndpoint that verifies the link is indexed under its new real
origin, using the store’s origin lookup API and the expected link ID. Keep the
existing target lookup assertion unchanged.

In `@src/stores/rerouteStore.ts`:
- Around line 42-73: Extract the shared scoped-bucket operations used by
getBucket, graphBucket, pruneBucket, clearGraph, and clearOwner into a generic
helper parameterized by bucket payload creation and emptiness checks. Update
both rerouteStore and linkStore to use this helper while preserving their
existing bucket types, partitioning, and cleanup behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 61fc1000-1a2f-4c22-9b52-61da1ed3a3d2

📥 Commits

Reviewing files that changed from the base of the PR and between 0098081 and d1fc17a.

📒 Files selected for processing (47)
  • browser_tests/assets/subgraphs/subgraph-link-identity-collision.json
  • browser_tests/tests/subgraph/subgraphLinkIdentity.spec.ts
  • src/components/builder/AppModeWidgetList.vue
  • src/components/rightSidePanel/parameters/WidgetItem.test.ts
  • src/components/rightSidePanel/parameters/WidgetItem.vue
  • src/core/graph/subgraph/migration/proxyWidgetMigration.test.ts
  • src/core/graph/subgraph/migration/proxyWidgetMigration.ts
  • src/core/graph/subgraph/promotionUtils.test.ts
  • src/core/graph/widgets/dynamicWidgets.ts
  • src/extensions/core/widgetInputs.test.ts
  • src/extensions/core/widgetValuePropagation.test.ts
  • src/extensions/core/widgetValuePropagation.ts
  • src/lib/litegraph/src/LGraph.inputSlotRealign.test.ts
  • src/lib/litegraph/src/LGraph.serialise.test.ts
  • src/lib/litegraph/src/LGraph.test.ts
  • src/lib/litegraph/src/LGraph.ts
  • src/lib/litegraph/src/LGraphCanvas.clipboard.test.ts
  • src/lib/litegraph/src/LLink.store.test.ts
  • src/lib/litegraph/src/LLink.ts
  • src/lib/litegraph/src/Reroute.store.test.ts
  • src/lib/litegraph/src/Reroute.ts
  • src/lib/litegraph/src/canvas/LinkConnector.core.test.ts
  • src/lib/litegraph/src/canvas/LinkConnector.integration.test.ts
  • src/lib/litegraph/src/linkDeduplication.ts
  • src/lib/litegraph/src/node/slotLinks.ts
  • src/lib/litegraph/src/subgraph/SubgraphConversion.test.ts
  • src/platform/nodeReplacement/useNodeReplacement.test.ts
  • src/renderer/extensions/minimap/composables/useMinimap.test.ts
  • src/renderer/extensions/minimap/data/AbstractMinimapDataSource.ts
  • src/renderer/extensions/minimap/data/MinimapDataSource.test.ts
  • src/renderer/extensions/minimap/minimapCanvasRenderer.test.ts
  • src/renderer/extensions/vueNodes/components/NodeSlots.test.ts
  • src/renderer/extensions/vueNodes/components/NodeSlots.vue
  • src/renderer/extensions/vueNodes/composables/useProcessedWidgets.test.ts
  • src/renderer/extensions/vueNodes/composables/useProcessedWidgets.ts
  • src/renderer/extensions/vueNodes/composables/useSlotLinkInteraction.ts
  • src/renderer/extensions/vueNodes/utils/__tests__/nodeDataUtils.test.ts
  • src/renderer/extensions/vueNodes/utils/nodeDataUtils.ts
  • src/stores/linkStore.test.ts
  • src/stores/linkStore.ts
  • src/stores/rerouteStore.test.ts
  • src/stores/rerouteStore.ts
  • src/stores/widgetValueStore.graphReactivity.test.ts
  • src/systems/badgeSystem.pricing.test.ts
  • src/systems/badgeSystem.ts
  • src/types/graphScopeId.ts
  • src/utils/linkFixer.test.ts

Comment thread src/stores/linkStore.test.ts Resolved
Comment thread src/stores/rerouteStore.ts Resolved

@benjcooley benjcooley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the whole change (stores, litegraph chokepoints, ~20 threaded callers, docs, tests). The core is genuinely good: createGraphScopedBuckets is a clean shared lifecycle, the reactivity model survives owner-clear/prune (verified the missing-scope read path stays tracked), the ADR-0003 store boundaries are respected, the docs were updated honestly rather than left stale, and the store-level tests are strong.

One blocking issue and a few smaller ones.

Blocking — the fix: defer imported link registration commit moves link registration in configure() to after the node create/configure loops. useLinkStore is then empty for that whole window, and three readers in that window are not app.configuringGraph-guarded. Concretely createBoundingBoxes now leaves width/height visible on load even when background is linked, and both dynamic-widget paths (autogrow, dynamic combo) call captureInputLayout with an empty link map, so replaceNodeInputs performs no re-keying and no removal. Details inline on the registration loop. If the deferral is load-bearing for _removeDuplicateLinks, that reasoning should be a comment in the code — right now the commit has no message body and the diff doesn't explain itself.

Should fix

  • LGraph.clear() minting a root uuid quietly makes new LGraph(serialised) require an active Pinia, and silently hollows out two existing tests (they pass but assert nothing).
  • _addReroute drops a reroute with no log while setReroute still hands it to the caller; _addLink drops a link from _links with no signal to its three callers.
  • Stale JSDoc in linkStore (no link-id check exists) and a hasUniqueTarget rationale that owner-scoping just invalidated.

Follow-up, out of scope but adjacent — this PR formalises per-owner link-id namespaces, but layoutStore link geometry is still globally keyed: linkLayouts: Map<LinkId, LinkLayout> (layoutStore.ts:138) and makeLinkSegmentKey(linkId, rerouteId) (layoutUtils.ts:6) carry no graph scope, unlike makeScopedLayoutKey for reroutes. Two definitions holding link id 1 write to the same entry, and LLink.disconnect → deleteLinkLayout(1) will drop the sibling's. Worth an issue.

Nit on the repro fixture — subgraph-link-identity-collision.json gives the two definitions reroute ids 101/201. That is realistic (reroute ids are root-unique by allocation) but it means the test only exercises link-id + IO-pseudo-node-id collision. Fine as-is; just noting the coverage boundary.

Also: the PR description advertises a per-owner byId index, a getLink accessor, and registerLink rejecting same-bucket link-id collisions. None of those are in the diff — please update it, since these split descriptions are the record for the 6-part series.

Comment thread src/lib/litegraph/src/LGraph.ts Resolved
Comment thread src/lib/litegraph/src/LGraph.ts Resolved
Comment thread src/lib/litegraph/src/LGraph.ts Resolved
Comment thread src/lib/litegraph/src/LGraph.ts Resolved
Comment thread src/stores/linkStore.ts Resolved
Comment thread src/stores/linkStore.ts Resolved
Comment thread src/lib/litegraph/src/LGraphNode.ts Resolved
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Aug 11, 2026
@DrJKL
DrJKL requested a review from benjcooley August 11, 2026 18:52

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 15

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/stores/linkStore.ts (1)

225-263: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Enforce the owner for scoped mutations.

Lines 225-263 validate only the root bucket and topology identity. A caller can
pass a sibling owner's registered topology with its own GraphScope and then
delete it or update its endpoints. Require
topology.graphId === scope.owningGraphId in deleteLink and endpoint-batch
validation before any displacement.

Proposed fix
 function deleteLink(scope: GraphScope, topology: LinkTopology): boolean {
+  if (topology.graphId !== scope.owningGraphId) return false
   const bucket = roots.get(scope.rootGraphId)
   if (!bucket || !displace(bucket, topology)) return false
 for (const topology of participants) {
-  if (!bucket || !ownsPlacement(bucket, topology)) {
+  if (
+    !bucket ||
+    topology.graphId !== scope.owningGraphId ||
+    !ownsPlacement(bucket, topology)
+  ) {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/stores/linkStore.ts` around lines 225 - 263, Enforce scope ownership in
deleteLink and validateEndpointUpdates by requiring each topology’s graphId to
equal scope.owningGraphId before calling displace or performing endpoint
validation. Return the existing unowned-topology error for mismatches, while
preserving current root-bucket and placement checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/architecture/link-topology-store.md`:
- Around line 43-47: Update the targetIndex and originIndex key descriptions in
the link-topology-store documentation to include OwningGraphId alongside the
node ID and slot. Ensure both examples clearly show graph-scoped keys,
preserving the existing explanation of each index’s purpose.
- Around line 61-63: Change the fenced architecture diagram in
docs/architecture/link-topology-store.md lines 61-63 to use a language
identifier such as text; update both fenced diagrams in
docs/architecture/node-data-store.md lines 24-51 and the fenced diagram in
docs/architecture/reroute-chain-store.md lines 49-51 similarly, preserving their
diagram contents.

In `@src/lib/litegraph/src/LGraph.ts`:
- Around line 1685-1695: Update LGraph.setReroute to retry with a newly minted
reroute id when an internally generated id collides with an existing root-wide
reroute, while preserving hard rejection for explicitly supplied ids. Return or
otherwise expose the id actually assigned, and update createReroute and
LGraphNode.connectFloatingReroute to use that result instead of minting or
assuming a separate id.
- Around line 1841-1856: Update createSubgraph to return or apply the
deduplicated normalized data, and update _convertToSubgraphImpl and configure to
use that normalized result instead of the original data when calling
Subgraph.configure. Preserve the existing subgraph registration and
subgraph-created event behavior while ensuring every caller configures with
repaired link IDs.
- Around line 1103-1116: Refactor the group-ID allocation around add so
root-wide group IDs are collected once per configure/unpack operation instead of
rebuilding rootGroups for every insertion. Reuse a Set of taken IDs or an
equivalent LGraphState reservation mechanism, have each mint attempt consult and
update that shared state, and ensure add, configure, and _unpackSubgraphImpl
preserve unique IDs across root and subgraph groups.

In `@src/lib/litegraph/src/LGraphNode.ts`:
- Around line 3147-3150: Make topology registration atomic in LGraphNode: at
src/lib/litegraph/src/LGraphNode.ts lines 3147-3150, restore the previously
replaced input link when graph._addLink(link) rejects before returning; at lines
3182-3199, validate the later addFloatingLink result and, on rejection, remove
the newly created reroute and return undefined rather than leaving an orphaned
reroute.

In `@src/lib/litegraph/src/LinkMap.ts`:
- Around line 20-22: Update the size getter in LinkMap to return the size of the
existing snapshot directly, using snapshot().size instead of spreading values()
into an array.
- Around line 56-60: Update LinkMap.set so the id !== link.id guard logs a
console.error diagnostic before returning, matching LLink.id’s existing
“refusing to change a registered link id” guard style; preserve the current
no-op behavior after logging.

In `@src/lib/litegraph/src/LLink.store.test.ts`:
- Line 32: Add vi.restoreAllMocks() in the test suite’s afterEach cleanup for
the console.error spy created by the relevant test setup, ensuring the original
console.error implementation is restored after each test.

In `@src/lib/litegraph/src/LLink.ts`:
- Around line 141-146: Update the id setter in LLink so every assignment on a
registered link returns after the existing changed-ID check, including same-ID
assignments. Preserve the current error for differing IDs, and avoid replacing
_state while _graphScope is set so the store-held reactive proxy remains intact.

In `@src/lib/litegraph/src/Reroute.store.test.ts`:
- Line 85: Replace the non-null assertions on all setReroute results in
Reroute.store.test.ts with Vitest assert(...) checks, matching the pattern used
in src/stores/rerouteStore.test.ts. Ensure each result is asserted before
property access or further use so failed registration reports at the setReroute
call site while preserving the existing test behavior.
- Around line 65-72: Update the rejection test around setReroute and
createReroute to remove the graph._addReroute mock and reproduce rejection using
the same colliding-chain store setup as the preceding test. Keep the existing
undefined-result and link.parentId assertions so the real store-wide hasReroute
guard and failure path are exercised.

In `@src/lib/litegraph/src/subgraph/SubgraphInput.ts`:
- Around line 105-108: Ensure link IDs are free across the entire root graph
before disconnecting incumbents in SubgraphInput and SubgraphOutput, and apply
the same protection in LGraphNode.connectSlots. If _addLink fails, log the
failure and preserve or restore the incumbent connection; in SubgraphOutput also
remove the floating link and clear reroute.floating so no remnant remains.
Update src/lib/litegraph/src/subgraph/SubgraphInput.ts:105-108 and
src/lib/litegraph/src/subgraph/SubgraphOutput.ts:76-79 as specified;
LGraphNode.connectSlots requires the same change, while the separate
LGraph.ts:1685-1695 reroute issue needs no direct change here.

In `@src/stores/rerouteStore.test.ts`:
- Around line 240-248: Update the duplicate reroute fixture in the test around
registerReroute so it is created without a graphId before calling
store.registerReroute. Preserve the existing registration and rejection
assertions, ensuring the graphId expectation verifies that registerReroute does
not mutate the rejected candidate with graphASibling ownership.

In `@src/stores/rerouteStore.ts`:
- Around line 123-129: Update the collision error in the registration logic
around existing and scope.owningGraphId to report both the requesting owner and
the incumbent owner associated with existing. Preserve the rejection behavior
while identifying which graph currently holds the reroute ID and which graph
attempted the conflicting registration.

---

Outside diff comments:
In `@src/stores/linkStore.ts`:
- Around line 225-263: Enforce scope ownership in deleteLink and
validateEndpointUpdates by requiring each topology’s graphId to equal
scope.owningGraphId before calling displace or performing endpoint validation.
Return the existing unowned-topology error for mismatches, while preserving
current root-bucket and placement checks.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 19e3f47e-2a92-4602-b3e2-843c6cdffc6b

📥 Commits

Reviewing files that changed from the base of the PR and between d1fc17a and 0a7ee12.

📒 Files selected for processing (43)
  • browser_tests/tests/subgraph/subgraphLinkIdentity.spec.ts
  • browser_tests/tests/subgraph/subgraphSerialization.spec.ts
  • docs/architecture/link-topology-store.md
  • docs/architecture/node-data-store.md
  • docs/architecture/reroute-chain-store.md
  • docs/extensions/README.md
  • docs/extensions/link-registration-migration.md
  • src/lib/litegraph/src/LGraph.test.ts
  • src/lib/litegraph/src/LGraph.ts
  • src/lib/litegraph/src/LGraphCanvas.clipboard.test.ts
  • src/lib/litegraph/src/LGraphCanvas.ts
  • src/lib/litegraph/src/LGraphGroup.test.ts
  • src/lib/litegraph/src/LGraphNode.nodeState.test.ts
  • src/lib/litegraph/src/LGraphNode.test.ts
  • src/lib/litegraph/src/LGraphNode.ts
  • src/lib/litegraph/src/LLink.store.test.ts
  • src/lib/litegraph/src/LLink.ts
  • src/lib/litegraph/src/LinkMap.ts
  • src/lib/litegraph/src/Reroute.store.test.ts
  • src/lib/litegraph/src/Reroute.ts
  • src/lib/litegraph/src/__fixtures__/duplicateSubgraphNodeIds.ts
  • src/lib/litegraph/src/canvas/LinkConnector.core.test.ts
  • src/lib/litegraph/src/canvas/LinkConnector.integration.test.ts
  • src/lib/litegraph/src/canvas/LinkConnectorSubgraphInputValidation.test.ts
  • src/lib/litegraph/src/interfaces.ts
  • src/lib/litegraph/src/linkDeduplication.ts
  • src/lib/litegraph/src/subgraph/ExecutableNodeDTO.test.ts
  • src/lib/litegraph/src/subgraph/SubgraphConversion.test.ts
  • src/lib/litegraph/src/subgraph/SubgraphInput.ts
  • src/lib/litegraph/src/subgraph/SubgraphOutput.ts
  • src/lib/litegraph/src/subgraph/subgraphDeduplication.test.ts
  • src/lib/litegraph/src/subgraph/subgraphDeduplication.ts
  • src/renderer/extensions/minimap/data/MinimapDataSource.test.ts
  • src/stores/linkStore.test.ts
  • src/stores/linkStore.ts
  • src/stores/nodeDataStore.test.ts
  • src/stores/nodeDataStore.ts
  • src/stores/rerouteStore.test.ts
  • src/stores/rerouteStore.ts
  • src/types/linkTopology.ts
  • src/types/nodeState.ts
  • src/types/rerouteChain.ts
  • src/utils/linkFixer.test.ts

Comment on lines +1103 to +1116
const rootGroups = [
...this.rootGraph.groups,
...[...this.rootGraph.subgraphs.values()].flatMap(
(subgraph) => subgraph.groups
)
]
if (
node.id == null ||
node.id === -1 ||
rootGroups.some((group) => group.id === node.id)
) {
do node.id = mintGroupId(state)
while (rootGroups.some((group) => group.id === node.id))
}

@coderabbitai coderabbitai Bot Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win

Hoist the root-wide group-id scan out of add.

rootGroups materialises the root groups plus a flatMap over every subgraph's groups on each group insertion. configure calls add once per group (Line 2858), and _unpackSubgraphImpl calls it per unpacked group (Line 2292). The do…while rebuilds nothing but re-scans the same array per mint attempt.

For a workflow with G root groups and S subgraph-definition groups the load path becomes O(G × (G + S)). Workflows with many subgraph definitions pay this on every load.

Build a Set of taken ids once and consult it, or reserve ids in LGraphState the way link and node ids are reserved.

♻️ Proposed fix
-      const rootGroups = [
-        ...this.rootGraph.groups,
-        ...[...this.rootGraph.subgraphs.values()].flatMap(
-          (subgraph) => subgraph.groups
-        )
-      ]
-      if (
-        node.id == null ||
-        node.id === -1 ||
-        rootGroups.some((group) => group.id === node.id)
-      ) {
-        do node.id = mintGroupId(state)
-        while (rootGroups.some((group) => group.id === node.id))
-      }
+      const takenGroupIds = new Set<GroupId>()
+      for (const group of this.rootGraph.groups) takenGroupIds.add(group.id)
+      for (const subgraph of this.rootGraph.subgraphs.values()) {
+        for (const group of subgraph.groups) takenGroupIds.add(group.id)
+      }
+      if (node.id == null || node.id === -1 || takenGroupIds.has(node.id)) {
+        do node.id = mintGroupId(state)
+        while (takenGroupIds.has(node.id))
+      }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/litegraph/src/LGraph.ts` around lines 1103 - 1116, Refactor the
group-ID allocation around add so root-wide group IDs are collected once per
configure/unpack operation instead of rebuilding rootGroups for every insertion.
Reuse a Set of taken IDs or an equivalent LGraphState reservation mechanism,
have each mint attempt consult and update that shared state, and ensure add,
configure, and _unpackSubgraphImpl preserve unique IDs across root and subgraph
groups.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferred and documented in f7f79c6a6, with the wording refined in 86385927d. LGraph.add() still performs the root-wide scan, so this is not marked fixed. The migration addendum records the quadratic load risk, explains why rebuilding a Set per insertion has the same asymptotic cost, and requires representative load, deserialization, paste, and unpack measurements before adding persistent index state.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DrJKL, acknowledged. The performance finding remains deferred.

The documented measurement gate is appropriate. A persistent group-ID index should be added only after representative load, deserialization, paste, and unpack measurements show that the current root-wide scan is a material cost.


✏️ Learnings added
Learnt from: DrJKL
Repo: Comfy-Org/ComfyUI_frontend PR: 15009
File: src/lib/litegraph/src/LGraph.ts:1106-1119
Timestamp: 2026-08-11T21:27:48.633Z
Learning: For `src/lib/litegraph/src/LGraph.ts`, `LGraph.add()` currently performs a root-wide group-ID scan to prevent group-ID collisions. The known quadratic load-risk is intentionally deferred. Before adding persistent group-ID index state, collect representative measurements for load, deserialization, paste, and subgraph unpack operations; rebuilding a `Set` for each insertion does not improve the asymptotic cost.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

Comment thread src/lib/litegraph/src/LGraph.ts Resolved
Comment thread src/lib/litegraph/src/LGraph.ts Resolved
Comment thread src/stores/rerouteStore.test.ts Resolved
Comment thread src/stores/rerouteStore.ts Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/stores/linkStore.ts (1)

225-229: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Restrict mutations to the selected owner.

deleteLink accepts any scope with the same root ID. validateEndpointUpdates has the same gap. A caller can obtain a topology through getTopology(rootGraphId, id) and then delete or update an owner A link through sibling owner B's scope.

Compare scope.owningGraphId with the registered topology owner before destructive operations.

Proposed fix
-  function ownsPlacement(
-    bucket: RootTopologyBucket,
-    topology: LinkTopology
-  ): boolean {
-    return toRaw(bucket.byId.get(topology.id)) === toRaw(topology)
+  function ownsPlacement(
+    bucket: RootTopologyBucket,
+    scope: GraphScope,
+    topology: LinkTopology
+  ): boolean {
+    return (
+      topology.graphId === scope.owningGraphId &&
+      toRaw(bucket.byId.get(topology.id)) === toRaw(topology)
+    )
   }

   function deleteLink(scope: GraphScope, topology: LinkTopology): boolean {
     const bucket = roots.get(scope.rootGraphId)
-    if (!bucket || !displace(bucket, topology)) return false
+    if (!bucket || !ownsPlacement(bucket, scope, topology)) return false
+    if (!displace(bucket, topology)) return false
@@
-      if (!bucket || !ownsPlacement(bucket, topology)) {
+      if (!bucket || !ownsPlacement(bucket, scope, topology)) {

Also applies to: 232-237, 256-262

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/stores/linkStore.ts` around lines 225 - 229, Restrict destructive link
mutations to the selected owner: in deleteLink and validateEndpointUpdates,
compare scope.owningGraphId with the registered topology owner before calling
displace or applying updates, and reject mismatches without mutating state.
Preserve existing behavior for matching owners and root cleanup.
src/lib/litegraph/src/LGraph.ts (1)

1565-1572: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Use root-wide IDs for reminted floating links.

_lastFloatingLinkId is local to each graph. Two sibling subgraph definitions can
both mint ID 1. The second registerLinkTopology call then rejects the
root-wide collision, and addFloatingLink drops that link.

Mint automatic floating-link IDs from shared root state, or check the root-wide
topology store before accepting them. Add coverage for two owners under one root
graph.

Also applies to: 2791-2797

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/litegraph/src/LGraph.ts` around lines 1565 - 1572, Update
addFloatingLink and its related registration path (including
registerLinkTopology) so reminted floating-link IDs are unique across the shared
root graph, not only within each graph’s local links and floatingLinksInternal
collections. Use the existing root-wide ID/topology state when generating or
validating IDs, and add coverage for two subgraph owners under one root graph
generating links without collision.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/architecture/ecs-migration-plan.md`:
- Around line 932-937: Align the reroute membership contract across the
migration plan: reconcile the cached-membership statement near the reroute
guidance with the `LinkTopology.parentId`-derived model described earlier.
Explicitly define the cache/index and its lifecycle, or consistently state that
membership is derived and not stored; update both sections so extension authors
have one unambiguous implementation model.

---

Outside diff comments:
In `@src/lib/litegraph/src/LGraph.ts`:
- Around line 1565-1572: Update addFloatingLink and its related registration
path (including registerLinkTopology) so reminted floating-link IDs are unique
across the shared root graph, not only within each graph’s local links and
floatingLinksInternal collections. Use the existing root-wide ID/topology state
when generating or validating IDs, and add coverage for two subgraph owners
under one root graph generating links without collision.

In `@src/stores/linkStore.ts`:
- Around line 225-229: Restrict destructive link mutations to the selected
owner: in deleteLink and validateEndpointUpdates, compare scope.owningGraphId
with the registered topology owner before calling displace or applying updates,
and reject mismatches without mutating state. Preserve existing behavior for
matching owners and root cleanup.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d172bb23-36ca-4aa8-8a7d-b00600889cb0

📥 Commits

Reviewing files that changed from the base of the PR and between 0a7ee12 and d9e9430.

📒 Files selected for processing (34)
  • browser_tests/tests/subgraph/subgraphLinkIdentity.spec.ts
  • docs/architecture/ecs-migration-plan.md
  • docs/architecture/link-topology-store.md
  • src/components/rightSidePanel/parameters/WidgetItem.test.ts
  • src/core/graph/subgraph/migration/proxyWidgetMigration.test.ts
  • src/extensions/core/widgetInputs.test.ts
  • src/extensions/core/widgetValuePropagation.test.ts
  • src/lib/litegraph/src/LGraph.inputSlotRealign.test.ts
  • src/lib/litegraph/src/LGraph.test.ts
  • src/lib/litegraph/src/LGraph.ts
  • src/lib/litegraph/src/LinkMap.ts
  • src/lib/litegraph/src/__fixtures__/duplicateLinks.ts
  • src/lib/litegraph/src/linkDeduplication.ts
  • src/lib/litegraph/src/subgraph/SubgraphSerialization.test.ts
  • src/lib/litegraph/src/subgraph/subgraphDeduplication.test.ts
  • src/lib/litegraph/src/subgraph/subgraphDeduplication.ts
  • src/platform/nodeReplacement/useNodeReplacement.test.ts
  • src/renderer/extensions/minimap/composables/useMinimap.test.ts
  • src/renderer/extensions/minimap/data/MinimapDataSource.test.ts
  • src/renderer/extensions/minimap/minimapCanvasRenderer.test.ts
  • src/renderer/extensions/vueNodes/composables/useProcessedWidgets.test.ts
  • src/renderer/extensions/vueNodes/composables/useProcessedWidgets.ts
  • src/renderer/extensions/vueNodes/utils/__tests__/nodeDataUtils.test.ts
  • src/stores/linkStore.test.ts
  • src/stores/linkStore.ts
  • src/stores/nodeDataStore.test.ts
  • src/stores/nodeDataStore.ts
  • src/stores/rerouteStore.test.ts
  • src/stores/rerouteStore.ts
  • src/systems/badgeSystem.pricing.test.ts
  • src/systems/badgeSystem.ts
  • src/types/linkTopology.ts
  • src/types/nodeState.ts
  • src/types/rerouteChain.ts
💤 Files with no reviewable changes (5)
  • src/types/nodeState.ts
  • src/types/linkTopology.ts
  • src/stores/rerouteStore.test.ts
  • src/types/rerouteChain.ts
  • src/stores/nodeDataStore.test.ts

Comment thread docs/architecture/ecs-migration-plan.md Resolved
@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Aug 12, 2026

@DrJKL DrJKL left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer guide: architecture and change breakdown

This PR is easiest to review as four boundaries rather than as 81 individual files.

1. Ownership model: root-wide identity, owner-local topology

A root graph and its subgraph definitions share one identity domain, but queries and teardown must stay within the graph that directly owns each entity.

┌──────────────────────────────── Root graph bucket ────────────────────────────────┐
│                                                                                   │
│  Root-wide identity                         Owner-local indexes                    │
│  ┌──────────────────────┐                  ┌───────────────────────────────────┐  │
│  │ LinkId → topology    │                  │ root owner → entity IDs           │  │
│  │ RerouteId → chain    │                  │ subgraph A → entity IDs           │  │
│  │ NodeId → node state  │                  │ subgraph B → entity IDs           │  │
│  └──────────────────────┘                  └───────────────────────────────────┘  │
│            │                                           │                          │
│            └───────────────┬───────────────────────────┘                          │
│                            ▼                                                      │
│             slot indexes use owner-qualified keys                                │
│             owningGraphId : nodeId : slot                                        │
└───────────────────────────────────────────────────────────────────────────────────┘

GraphScope carries both IDs:

  • rootGraphId selects the shared identity bucket.
  • owningGraphId selects owner-local iteration, slot queries, and teardown.
  • Store registration is idempotent only for the same owner and raw entity identity. Collision checks happen at the store mutation boundary, not in each caller.

Floating links are not a separate entity type. They occupy the same root-wide link identity map and are filtered into the graph.floatingLinks compatibility view because one endpoint is absent; they are omitted from slot indexes until connected.

2. Loading and deserialization: normalize once, then register

Serialized workflows cannot safely register duplicate IDs and repair references afterward. The PR moves that work ahead of object registration and shares it across workflow load, direct subgraph creation, paste, and conversion.

Serialized root + definitions
            │
            ▼
┌──────────────────────────────┐
│ Clone caller-owned payload   │
│ Keep first malformed         │
│ same-owner duplicate         │
└──────────────┬───────────────┘
               ▼
┌──────────────────────────────┐
│ Reserve/remap root-wide IDs  │
│ nodes, groups, links,        │
│ floating links, reroutes     │
│ and every serialized ref     │
└──────────────┬───────────────┘
               ▼
┌──────────────────────────────┐
│ Create all subgraph shells   │
│ Configure leaves first       │
└──────────────┬───────────────┘
               ▼
┌──────────────────────────────┐
│ Register through stores      │
│ owner + identity validated   │
└──────────────────────────────┘

Important contracts:

  • Input payloads are not mutated.
  • Definitions are available before nested nodes configure.
  • References are remapped together with IDs, including proxy/promoted widgets and reroute/link references.
  • Malformed duplicates within one owner are deterministic first-wins because references cannot distinguish duplicate definitions of the same ID.
  • Registration rejection remains an explicit result; this PR does not introduce thrown registration errors.

3. Runtime mutation: one validation and atomic-update seam

Link endpoint changes, rotations, swaps, and replacements now validate the complete requested update in linkStore before changing topology or indexes.

Graph / connector request
          │
          ▼
┌─────────────────────────────┐
│ Central store mutation      │
│ - authorize owner           │
│ - validate identity         │
│ - validate target slots     │
│ - validate full batch       │
└──────────────┬──────────────┘
               │ valid
               ▼
┌─────────────────────────────┐
│ Update topology + indexes   │
│ as one store transaction    │
└─────────────────────────────┘

This removes caller-specific preflight and rollback compensation. Cross-store command transactions remain later ECS migration work, but there is now one mutation point to wrap with atomic check/rollback.

4. Serialization and teardown: project and detach by direct owner

Root and subgraph serialization consume one owner-local topology projection while preserving the existing wire split between links, floatingLinks, and reroutes. This also preserves persistent dangling links inside subgraphs across round trips.

Clear/removal uses the inverse ownership path:

Snapshot owned nodes
        │
        ▼
Run lifecycle callbacks while topology is observable
        │
        │ callback failure remains fail-fast
        ▼ finally
Detach exact links → reroutes → nodes → layout
        │
        ▼
Root only: defensively clear shared store buckets
        │
        ▼
Reset graph collections/canvas, then propagate original failure

The removal guard prevents callback-driven recursive removal from duplicating or skipping lifecycle calls. Entities added during a callback are included in final detachment. The migration document records alternatives if extension callback failure semantics need to change later.

Suggested review order

  1. Store contracts: linkStore.ts, rerouteStore.ts, nodeDataStore.ts, and GraphScope helpers.
  2. Runtime adapters: LLink.ts, Reroute.ts, LGraphNode.ts, and LinkMap.ts.
  3. Normalization boundary: subgraphDeduplication.ts, then LGraph.createSubgraphs() / workflow configure.
  4. Mutation callers: connector, slot, widget, and renderer call sites; these should derive scope rather than reconstruct it.
  5. Teardown and serialization: centralized helpers in LGraph.ts.
  6. Behavioral proof: store tests, subgraph serialization/conversion tests, and the browser identity-collision fixture/spec.
  7. Migration constraints and deferred choices: docs/architecture/ecs-migration-plan.md.

Compatibility intentionally retained

  • graph.links and graph.floatingLinks remain map-like filtered views.
  • The serialized regular/floating link split remains unchanged.
  • Direct-owner query semantics are explicit; callers should not manually pair root and owner IDs.
  • Snapshot iterator compatibility, cross-store transactional rollback, bare-link layout identity, and group-scan optimization remain documented follow-ups rather than additional mechanisms in this PR.

@benjcooley benjcooley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the delta (4584a54 → e7667ed, 37 commits). All seven findings from my last pass are addressed — thank you, that was a thorough response:

  • Blocking issue resolved. registerConfiguredLink puts link registration back at payload-parse time (LGraph.ts:2673 / :2715), so useLinkStore is populated before nodes are created and configured. The three unguarded readers I traced (createBoundingBoxes.ts:33, and the two captureInputLayout paths in dynamicWidgets.ts) now see real state again.
  • _addLink / _addReroute / registerNodeState return real booleans and setReroute returns undefined on rejection; LGraphNode.connect routes through replaceLinkTopology and bails cleanly.
  • Both hollowed-out tests now capture the id before clear().
  • The registerLink JSDoc is accurate now that byId exists, and hasUniqueTarget dropped the SUBGRAPH_OUTPUT_ID exclusion — the owner-prefixed keys make it unnecessary, which was the point.
  • The description was rewritten and is accurate, including the new Pinia requirement.

Not approving, and here is the honest reason. This is no longer the change I reviewed. The delta rewrites LGraph._links and floatingLinks from real Maps into LinkMap views over useLinkStore behind a MapProxyHandler proxy, moves link-id identity back to a root-wide byId authority, reintroduces load-time link-id dedup across sibling definitions via normalizeSubgraphDefinitions (+182 lines), and deletes graphScopedBuckets.ts so the bucket lifecycle is now hand-rolled in three stores. The PR is at 3639/1532 across 81 files, and it is advertised as split 2 of 6 — the repo's own guideline asks for a split past ~300 lines of non-test code.

I can't vouch for the LinkMap architecture at the depth I gave the original scoping change in this pass, and I don't think anyone should merge it on a skim. Concretely, I'd suggest landing the bucket scoping (which is well-tested and does fix the repro) and taking LinkMap — making the store the single source of truth for link identity — as its own PR with its own review. If that split isn't practical this late, please at least call the graph.links contract change out prominently in the description; right now the biggest extension-facing change in the PR is only visible by reading LinkMap.ts.

Three inline notes on the new surface. Two smaller items I'm not blocking on: deleting graphScopedBuckets duplicates five near-identical functions across linkStore / rerouteStore / nodeDataStore (CodeRabbit flagged the same), and the reroute-chain doc's claim that ids are per-owner now sits awkwardly next to a root-wide id authority.

Still open from last time, unchanged and still out of scope: layoutStore link geometry is globally keyed (linkLayouts: Map<LinkId, LinkLayout>, makeLinkSegmentKey) with no graph scope. Worth an issue.

return this.snapshot().keys()
}

override set(id: LinkId, link: LLink): this {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set() discards the result of add (_addLink / addFloatingLink, both of which now return boolean) and unconditionally returns this. A caller following the Map contract has no way to learn the link was rejected — same silent-failure shape as the old _addLink, just relocated. Either log here or document that LinkMap.set is best-effort.

More generally, this class is the largest extension-facing change in the PR and it isn't in docs/extensions/link-registration-migration.md. LGraph.links / floatingLinks are typed Map<LinkId, LLink> on ReadonlyLinkNetwork but are no longer real maps:

  • size (line 20) and every iterator go through snapshot(), which allocates a fresh Map per call — size is now O(n), not O(1).
  • reads return empty when there is no active Pinia (see the scope thunk in LGraph.ts:546).
  • the inherited Map storage is never populated, so anything reaching past the overridden methods sees an empty map.

Nothing in-tree does .size in a loop, so I'm not flagging perf as a defect — but 40+ custom-node repos touch node.graph.links, and the migration doc currently only says floatingLinks "remains the filtered compatibility view." Please spell out the graph.links contract change there.

Comment thread src/lib/litegraph/src/LGraph.ts Outdated
getActivePinia() && this.rootGraph ? graphScopeOf(this) : undefined,
(scope, id) => {
const topology = useLinkStore().getTopology(scope.rootGraphId, id)
return topology?.graphId === scope.owningGraphId &&

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getActivePinia() && this.rootGraph ? … : undefined makes every graph.links read degrade to an empty map rather than fail, so a missing Pinia surfaces as "this graph has no links" instead of an error — the worst failure mode for a data-integrity change.

It is also inconsistent with resetAfterClear (612-618), which calls usePreviewExposureStore() / useLinkStore() / useRerouteStore() / useNodeDataStore() with no such guard and will throw. So new LGraph(serialised) outside Pinia still throws — the guard here only hides the failure at one of the two boundaries. The PR description and migration doc both now state Pinia is required, which is the right call; given that, prefer failing loudly here too rather than returning an empty scope.

id, registration logs an error, leaves the incoming link detached, and returns
`undefined`. It does not silently replace the live link or assign the incoming
link another identity. `graph.floatingLinks` remains the filtered compatibility
view for one-ended links.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please extend this with the graph.links contract change, not just addFloatingLink. LGraph.links and LGraph.floatingLinks are now LinkMap views over useLinkStore behind a MapProxyHandler: size is O(n), iteration allocates, set() can silently no-op, and reads return empty without an active Pinia. Extensions that hold a reference to graph.links and treat it as a plain Map are the population most likely to break.

@benjcooley benjcooley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the two new commits (e7667ed → 7254f5d).

fix: cache graph-scoped link views addresses the LinkMap cost I raised — size and iteration are O(1) on a cache hit now, and the invalidation contract is documented in link-topology-store.md rather than left implicit. The new reuses link views until membership changes test covers the endpoint-only case and the floating flip, which are exactly the two cases that matter. Good commit.

One new verified issue: the cache makes graph.links non-reactive. On a cache hit current() returns without reading anything reactive — getLinkStoreRevision() is a plain module-level counter and scope() isn't reached — so a Vue effect reading graph.links while the cache is warm registers no dependency and never re-runs. No in-tree reactive consumer today (I checked .vue, composables/, renderer/, stores/), so it's latent, but LGraph.links is public and this cuts against the point of the migration. Making the counter a shallowRef fixes it for free. Inline, plus a smaller note on the conditional bump in updateEndpoints.

One characteristic worth knowing rather than fixing: because a mutation invalidates the shared counter, a loop that interleaves delete and read — LLink.disconnect in a batch node deletion, say — rebuilds the view once per iteration, so bulk deletes are O(n²) in the graph's total link count. Strictly better than before this commit, and fine at normal graph sizes; just don't reach for graph.links.get inside a mutation loop.

My standing objection from the previous review is unchanged: these commits don't touch it. The PR is still 81 files carrying both the bucket-scoping fix and the LinkMap rewrite of LGraph._links, still labelled split 2 of 6. I'd still like to see LinkMap reviewed as its own change.


private current(): Map<LinkId, LLink> {
const revision = this.revision()
if (revision === this.cachedRevision) return this.cachedLinks

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cache silently makes graph.links non-reactive.

On a cache hit this returns before touching anything reactive: this.revision() reads a plain module-level let in linkStore.ts:85, and this.scope() — which would have read the rootGraph.id shallowRef — isn't reached. Before this commit, every read went through graphTopologies → roots.get(...), so a Vue effect reading graph.links registered a dependency on the store and re-ran on change. Now an effect that reads it while the cache is warm registers zero dependencies and will never be invalidated by a link mutation.

I grepped src/**/*.vue, composables/, renderer/ and stores/ and found no reactive consumer of graph.links today, so this is latent rather than a live bug — but LGraph.links is public API and the entire point of this migration is making the stores the reactive source of truth, so the next consumer to reach for it gets a stale view with no error.

Cheap fix: make the counter a shallowRef in the store and have getLinkStoreRevision() return .value. The cache still short-circuits, but reading it registers the dependency, so reactivity is restored at no cost.

Comment thread src/stores/linkStore.ts Outdated

for (const { topology } of updates) displace(graphId, topology)
for (const topology of removals) displace(graphId, topology)
const changesLinkView =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHOULD-FIX: this is a correctness-critical optimization on a cold path. updateEndpoints is called from realignInputLinkSlots (once per configure) and replaceNodeInputs — nowhere hot — so skipping the bump buys one avoided map rebuild while making the cache's validity depend on the implicit invariant "an endpoint-only patch never changes the id set or the link objects."

That invariant holds today (ids are immutable once registered, placeValidated reuses the same reactive proxy, and the floating flip is checked), and I'm glad it's now written down in link-topology-store.md. But it isn't stated at the call site, and if EndpointPatch ever grows a field that affects membership this serves a stale map with no symptom. I'd just bump unconditionally unless you have a measurement that says otherwise.

Separately, let revision = 0 at module scope (line 85) lives outside the Pinia store, so createTestingPinia() resets the store state but not the counter — a LinkMap that survives a Pinia swap will serve its stale cache.

@DrJKL

DrJKL commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Architecture review proposal: make navigation obey the topology rules established here

Note

This is a follow-up architecture proposal, not a request to expand or block this PR.

PR #15009 is already a substantial, focused correction to topology identity and ownership. The proposal below is to reuse its architectural rules for graph/workflow navigation in a separate stacked change against feature/ecs-migration.

Important

The central observation: #15009 makes topology safer by giving each concern one authority, explicit scope, and a validate-before-commit boundary. Navigation currently spreads authority across the canvas, two stores, router state, reactive watchers, and workflow completion callbacks. The safest follow-up is not simply “remove watches”; it is one owner per transition.

Executive comparison

Principle established by #15009 Topology implementation Current navigation implementation Proposed follow-up
Explicit scope GraphScope separates root identity from direct owner identity (source) Workflow, root graph, current graph, and route hash are inferred independently Carry explicit workflow/root/graph scope in every transition command
One authority per concern A root topology bucket is the sole link-ID authority; owner and endpoint indexes are derived (source) Canvas graph, currentGraph, activeSubgraph, navigation stack, and URL all participate in deciding the active graph NavigationSystem decides; stores record committed state; URL and canvas are outputs
Ownership validation Mutations prove that the caller owns the registered topology before changing it (source) Asynchronous workflow completion has no single transition owner Monotonic intent token rejects stale completions
Transaction boundary Endpoint batches are fully validated before indexes are displaced and rebuilt (source) Route, graph, stack, viewport, and workflow state settle through separate callbacks Resolve and validate first; commit one transition; publish derived effects afterward
One reactive object, no mirror reconciliation The ECS ADR records the store-proxy adoption pattern specifically to prevent class/store disagreement (source) Multiple reactive representations are reconciled through feedback and suppression One committed navigation state; all other views derive from it

What exists today

The ECS target explicitly names dedicated stores as runtime sources of truth and names subgraphNavigationStore as the owner of the active subgraph path (target architecture). The implementation currently divides that responsibility:

  1. canvasStore listens to litegraph:set-graph and writes currentGraph and isInSubgraph (source).
  2. GraphCanvas.vue independently consumes the same event and asks workflowStore to update its active graph (source).
  3. subgraphNavigationStore synchronously watches workflowStore.activeSubgraph to capture viewport and stack state (source).
  4. The navigation store watches canvasStore.currentGraph to write the URL and watches the URL to call canvas.setGraph() (source).
  5. Successful app.loadGraphData() completion explicitly invokes updateHash() again (source).
  6. Blank and default workflow replacements call app.loadGraphData() directly (source).
flowchart LR
    Canvas["LGraphCanvas.graph"]
    Event["litegraph:set-graph"]
    CanvasStore["canvasStore.currentGraph"]
    GraphCanvas["GraphCanvas listener"]
    WorkflowStore["workflowStore.activeSubgraph"]
    NavStore["subgraphNavigationStore<br/>path + viewport + URL policy"]
    Route["routeHash"]
    App["app.loadGraphData completion"]

    Canvas --> Event
    Event --> CanvasStore
    Event --> GraphCanvas
    GraphCanvas --> WorkflowStore
    WorkflowStore -->|"sync watch"| NavStore
    CanvasStore -->|"watch"| NavStore
    NavStore -->|"push / replace"| Route
    Route -->|"watch → setGraph"| Canvas
    App -->|"explicit updateHash"| NavStore

    classDef authority fill:#7f1d1d,color:#fff,stroke:#ef4444,stroke-width:2px
    class CanvasStore,WorkflowStore,NavStore,Route,App authority
Loading

Warning

No individual arrow is inherently wrong. The risk comes from the cycle having several nodes that can initiate or reinterpret the same transition. Correctness then depends on callback ordering, router scheduling, Vue flush timing, and suppression state rather than a single enforceable invariant.

Why “just reduce the watch count” is the wrong target

The watchers are symptoms of divided ownership, not the root defect. Replacing them with event listeners while preserving the same feedback graph would retain the same races under different syntax.

The meaningful invariant should be:

For navigation intent n, exactly one coordinator may commit the active workflow/graph. Any asynchronous completion carrying an intent older than n is observational only and cannot change canvas, route, stack, or viewport state.

That invariant is testable. “There are only N watchers” is not.


Proposed ownership model

The ECS ADR already provides the vocabulary for this boundary: commands describe mutation intent, systems validate and execute commands, and each store owns its transaction boundary (ADR 0008). Navigation should follow that model.

flowchart LR
    subgraph Intents["Intent sources"]
        UI["UI navigation command"]
        Router["Router afterEach<br/>initial / back / forward"]
        Load["Workflow load completion"]
    end

    Coordinator["NavigationSystem<br/>single transition owner"]

    subgraph Validation["Resolve before commit"]
        Token["Current intent token?"]
        Scope["Workflow/root/graph scope valid?"]
        Target["Target graph reachable?"]
    end

    Canvas["LGraphCanvas.setGraph"]
    Event["litegraph:set-graph<br/>commit acknowledgement"]
    State["subgraphNavigationStore<br/>committed path + transition state"]
    Workflow["workflowStore<br/>derive active graph"]
    History["Router push / replace<br/>outbound effect only"]
    Viewport["Viewport save / restore"]

    UI --> Coordinator
    Router --> Coordinator
    Load --> Coordinator
    Coordinator --> Validation
    Validation -->|"accepted"| Canvas
    Validation -->|"stale / invalid"| Drop["Reject without side effects"]
    Canvas --> Event
    Event --> State
    State --> Workflow
    State --> History
    State --> Viewport

    classDef owner fill:#14532d,color:#fff,stroke:#22c55e,stroke-width:2px
    class Coordinator owner
    classDef rejected fill:#7f1d1d,color:#fff,stroke:#ef4444,stroke-width:2px
    class Drop rejected
Loading

Ownership rules

1. One graph-transition command boundary

All graph replacement paths—open workflow, blank workflow, default workflow, imported workflow, route recovery, and direct subgraph navigation—submit a navigation command. None independently updates both canvas and route.

type NavigationIntent =
  | { type: 'open-workflow'; workflowPath: string; intentId: number }
  | { type: 'open-graph'; rootGraphId: string; graphId: string; intentId: number }
  | { type: 'route'; hash: string; history: 'external'; intentId: number }

This is conceptually consistent with the ADR’s command/system split; it need not make transient browser navigation undoable or CRDT-replicated.

2. One inbound router observer

Use router lifecycle (afterEach or equivalent) for initial URL and browser back/forward input. Route-driven navigation carries history: 'external' and therefore never creates another history entry.

Intent source Canvas action History action
UI opens subgraph setGraph(target) push(target)
Workflow replacement install root graph replace(root)
Browser back/forward setGraph(resolvedHash) none
Invalid/stale hash recover to root replace(root)
Stale workflow completion none none

3. One stale-work guard

Use one monotonic intentId at asynchronous workflow-load boundaries. Do not combine a FIFO queue, per-path pending maps, close counters, suppression depth, deferred route state, and blocked hashes unless a separately demonstrated invariant requires each one.

sequenceDiagram
    actor User
    participant N as NavigationSystem
    participant Loader as Workflow loader
    participant Canvas
    participant Router

    User->>N: Open workflow A
    N->>N: intent = 41
    N->>Loader: load A (41)

    User->>N: New blank workflow
    N->>N: intent = 42
    N->>Loader: load blank (42)
    Loader-->>N: blank ready (42)
    N->>Canvas: commit blank
    N->>Router: replace blank root

    Loader-->>N: A ready (41)
    N-->>Loader: reject stale completion
    Note over Canvas,Router: intent 42 remains committed
Loading

4. Treat litegraph:set-graph as commit acknowledgement

canvasStore already receives newGraph and oldGraph at the canvas boundary (source). One owner should consume that transition to atomically derive:

  • current graph;
  • active subgraph/path;
  • navigation stack;
  • outgoing and incoming viewport keys;
  • whether an outbound history update is required.

Other consumers may observe committed state, but they should not reinterpret the transition or initiate compensating graph changes.

5. Make the store match the architecture document

The target architecture names subgraphNavigationStore as the active-path source of truth (source). The follow-up should either:

  • make that true by storing one committed navigation state there; or
  • revise the document and explicitly designate another owner.

Retaining a private navigation activeSubgraph, a workflow-store activeSubgraph, a canvas-store currentGraph, and a route hash as mutually correcting authorities should not be the permanent bridge.


Failure containment

Invariant matrix
Failure Required invariant Recovery owner
Workflow load rejects Previously committed canvas, route, and navigation state remain coherent NavigationSystem
Older load completes late Completion cannot mutate any committed state Intent-token validation
Hash targets another open workflow Resolve workflow and graph before changing canvas or history Route-command handler
Hash target disappears during load Commit root recovery once; do not bounce through graph/hash watchers NavigationSystem
Viewport restore schedules stale animation frames Frame verifies committed transition/graph token Viewport effect
Extension callback throws during graph configuration No success commit or outbound route update Workflow loader + coordinator
State-machine sketch
stateDiagram-v2
    [*] --> Idle
    Idle --> Resolving: navigation command
    Resolving --> Loading: workflow data required
    Resolving --> Committing: graph already available
    Loading --> Committing: completion token is current
    Loading --> Idle: stale completion
    Loading --> Recovering: current completion failed
    Committing --> Idle: set-graph acknowledged
    Recovering --> Idle: root committed + route replaced

    note right of Loading
      No canvas, route, stack,
      or viewport ownership transfer
      before token validation
    end note
Loading

Verification proposal

Tip

Preserve the strong testing style used by this PR: test the ownership boundary and the destructive interleaving, not implementation counters.

Minimum integration suite

  • Use createRouter(createMemoryHistory()); do not emulate router writes with a synchronously assigned ref.
  • Drive the actual litegraph:set-graph → store → route path.
  • Verify UI subgraph navigation adds exactly one history entry.
  • Verify back/forward changes the canvas without adding history.
  • Start slow workflow A, then blank/default B; resolve A last and prove B remains active.
  • Reject a workflow load while starting from a subgraph and prove canvas ID, route hash, active path, and viewport key agree.
  • Navigate to a graph in another open workflow and prove stale completion cannot restore the previous workflow.
  • Drain router promises, Vue ticks, and queued load continuations before final assertions.
  • Assert behavior, not watcher counts, queue depths, or suppression fields.

Structural acceptance criteria

  • Exactly one module may call router.push/replace for graph navigation.
  • Exactly one module owns asynchronous navigation intent IDs.
  • Blank/default/import/workflow loads share the same transition entry point.
  • litegraph:set-graph has one state-owning consumer; additional consumers are read-only effects.
  • The active graph path has one source of truth.
  • A failed or stale transition performs zero success-side effects.

Scope recommendation

Caution

Do not fold this into #15009. The topology change already spans identity, registration, serialization, teardown, and store-backed class state. Navigation deserves its own stacked PR with its own red/green race evidence.

A clean sequence would be:

  1. Merge fix: scope link and reroute topology by owning graph #15009’s graph-scoped topology boundary.
  2. Add router/canvas integration tests that expose current feedback behavior.
  3. Introduce the single navigation coordinator and intent token.
  4. Remove duplicate watchers, explicit updateHash() completion calls, and dead mirrored state as consequences—not as the primary objective.
  5. Update the ECS target diagram to name NavigationSystem as behavior and subgraphNavigationStore as committed data.

Bottom line

#15009 demonstrates the right architecture locally:

Scope explicitly → validate ownership → commit once → derive indexes/views → reject stale or foreign mutation.

Navigation should use exactly that playbook. The goal is not fewer Vue primitives for aesthetic reasons. The goal is to make it impossible for the route, canvas, workflow completion, and reactive stores to each believe they own the same transition.

@DrJKL
DrJKL force-pushed the feature/ecs-migration branch from 0098081 to 8a0f977 Compare August 12, 2026 20:39
@DrJKL
DrJKL requested review from a team and jtydhr88 as code owners August 12, 2026 20:39
@dosubot dosubot Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Aug 13, 2026
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:XXL This PR changes 1000+ lines, ignoring generated files. labels Aug 13, 2026
@DrJKL
DrJKL merged commit 1ca38cb into feature/ecs-migration Aug 13, 2026
59 checks passed
@DrJKL
DrJKL deleted the drjkl/split-graph-scoped-topology branch August 13, 2026 18:36
DrJKL added a commit that referenced this pull request Aug 14, 2026
Centralizes entity layout ownership and command submission on top of
#15009's graph identity, collision, and teardown boundaries.

Nodes, groups, and reroutes now hold instance-bound `{ graphId, id }`
attachments. Only the attached instance can mutate canonical geometry;
stale instances become inert without delete/recreate compensation.

Changes:
- Replaces ID-derived registration with `graphLayoutAttachment.ts`,
covering attach, adopt, detach, geometry writes, and batched teardown.
- Acquires reroute topology/map ownership before layout ownership, so
collision losers cannot adopt incumbent geometry.
- Centralizes group ID allocation at creation through the graph-state
high-water mark.
- Uses deep Yjs observation and emits geometry invalidation once per
transaction, including group- and reroute-only changes.
- Queues listener delivery after committed store writes, allowing nested
observer mutations as ordinary follow-up transactions.
- Requires mutation producers to supply `LayoutSource`; the store stamps
its session actor at submission. DOM measurement conventions are
explicit rather than ambient process state.
- Narrows `useLayoutMutations` to its four production behaviors and
removes redundant command `entity`, operation ID, and apply-result
fields.
- Makes node layout refs read-only and updates migration documentation
to match the command/attachment boundary.

Review focus:
- Attachment lifetime and stale-instance isolation in
`graphLayoutAttachment.ts`.
- Root versus partial-subgraph teardown through #15009's centralized
lifecycle.
- Topology-before-layout ordering in `_addReroute`.
- Explicit source/measurement semantics at mutation call sites.
- Transaction and notification timing in `layoutStore.ts`.

Validation:
- Full GitHub CI passed, including unit tests, all Playwright shards,
type/lint/format checks, Storybook, and performance tests.
- The branch is net −170 lines against `feature/ecs-migration`.

---------

Co-authored-by: Amp <amp@ampcode.com>
DrJKL added a commit that referenced this pull request Aug 15, 2026
Split 3/6 of #14480. Stacked on #15009.

The original version replaced every rewired link with a fresh ID. #15009
now addresses that root cause more simply: endpoint changes are
validated and applied atomically at the link-store mutation boundary
while preserving link identity. This PR has therefore been reduced to
the remaining independent cleanup.

`LGraph._unpackSubgraphImpl()` previously rewrote the registered links
in the shared subgraph definition while calculating their parent-graph
endpoints. Unpacking one instance could transiently reindex or partially
mutate topology still used by another instance.

This change computes mapped origin/target endpoints in local variables,
leaving the source definition and its store registration untouched. The
behavioral test keeps another instance of the definition alive, unpacks
one instance, and verifies both the original topology and copied parent
link.

Deliberately omitted:
- no `linkReplacement.ts`
- no fresh IDs for endpoint changes
- no immutable/warn-and-ignore endpoint setters
- no second topology mutation boundary outside `linkStore`

Test plan:
- `pnpm test:unit
src/lib/litegraph/src/subgraph/SubgraphConversion.test.ts`
- typecheck, changed-file lint/format, and diff checks

---------

Co-authored-by: Amp <amp@ampcode.com>
christian-byrne added a commit that referenced this pull request Aug 23, 2026
Adds e2e coverage for `Convert to Subgraph` with a **partial**
selection.

## The gap

`browser_tests/tests/subgraph/subgraphCrud.spec.ts:68` is the only e2e
test of subgraph creation. It calls `comfyPage.keyboard.selectAll()`
first, so every node is inside the selection, **there are zero boundary
links**, and the entire rewiring block in `_convertToSubgraphImpl`
(`src/lib/litegraph/src/LGraph.ts:1861-1939`) never executes. It then
asserts node counts, never link topology.

Partial selection — what users actually do — had no e2e coverage at all.
That block reconnects boundary links by positional index
(`subgraphNode.inputs[i - 1]`, `subgraphNode.outputs[i - 1]`) against a
slot array built independently in `mapSubgraphInputsAndLinks`, so a
drift there is silent.

## What it does

Packs `KSampler` + `VAE Decode` out of the default workflow and asserts:

- the exact post-conversion link table, with the new subgraph node
rendered as `HOST` (five boundary inputs rewired onto it, one boundary
output to SaveImage, and the two `CheckpointLoaderSimple → CLIP` links
that lie entirely outside the selection left untouched)
- every rewired link lands on a type-compatible slot
- the result survives a serialize/reload round trip

## Status — currently red, cause not yet established

Please do not read the red as a confirmed product bug yet; I do not want
to overstate it.

The first run failed, but **my expected link count was wrong** (I
asserted six root links and forgot the two external-only CLIP links; the
correct total is eight). That error is fixed in `0566c82c5a`, which now
asserts the full topology rather than a count.

What the first run reported that is *not* explained by my arithmetic
error, and is still open:

- the `4:2` VAE boundary link was absent from the links targeting the
host
- one host input slot was left unconnected
- SaveImage's input was not fed by the host
- nine root links, where the corrected expectation is eight

Against that, a faithful unit-level reduction of the same graph shape
(same node/slot/type layout, same selection) **passes**: all five host
inputs connect, SaveImage is fed by the host, and the link count is
eight. So either the trigger is something the reduction lacks (real node
defs, widget-backed inputs, the app's `SubgraphNode` registration path),
or the browser selection was not the two nodes I assumed. The corrected
assertion prints the actual table on failure, which should settle it on
the next run.

I have deliberately **not** written a fix. Test-only PR.

## Related

- Does **not** overlap
#15002 (subgraph
**unpack**, FE-1539 — different action, different code path
`_unpackSubgraphImpl`).
- Does **not** overlap
#15009 /
#15018, which are
based on `feature/ecs-migration` and change `src/stores/linkStore.ts` /
`rerouteStore.ts` — files that do not exist on `main`.
- Does **not** overlap
#14569 (preview/output
display only).

---------

Co-authored-by: Connor Byrne <c.byrne@comfy.org>
Co-authored-by: Alexander Brown <drjkl@comfy.org>
Co-authored-by: DrJKL <DrJKL0424@gmail.com>
Co-authored-by: Amp <amp@ampcode.com>
balpreetgrowthnatives pushed a commit to balpreetgrowthnatives/ComfyUI_frontend that referenced this pull request Aug 24, 2026
## Summary

Still-draft feature branch for migrating entity state from LiteGraph
objects and runtime mirrors into dedicated stores with derived, reactive
views.

This consolidates the reviewed ECS migration slices, strengthens their
coverage, incorporates the layout-state follow-up, and documents the
current migration status and remaining work.

## Changes

- Move widget values and node shell state into dedicated stores.
- Make link topology the source of truth for connectivity.
- Store reroute chains while deriving membership and floating-link
state.
- Derive widgeted input connectivity, badges, and promoted widget rows
from store-backed state.
- Remove the input and output runtime link mirrors.
- Keep DOM measurements separate from persisted node layout state.
- Add migration coverage, extension guidance, and architecture/status
documentation.

Reviewed PRs merged into this feature branch:

- [Comfy-Org#13322 — Move widgets out of node
data](Comfy-Org#13322)
- [Comfy-Org#13434 — Host-scoped promoted widget
rows](Comfy-Org#13434)
- [Comfy-Org#13436 — Link topology
store](Comfy-Org#13436)
- [Comfy-Org#13449 — Reroute chain
store](Comfy-Org#13449)
- [Comfy-Org#13451 — Derived floating links and reroute
cleanup](Comfy-Org#13451)
- [Comfy-Org#13455 — Store-backed widgeted input
connectivity](Comfy-Org#13455)
- [Comfy-Org#13458 — Badge store and
system](Comfy-Org#13458)
- [Comfy-Org#13479 — Remove the output-link runtime
mirror](Comfy-Org#13479)
- [Comfy-Org#13498 — Remove the input-link runtime
mirror](Comfy-Org#13498)
- [Comfy-Org#13528 — Cross-stack migration audit
fixes](Comfy-Org#13528)
- [Comfy-Org#13686 — Derive badges on
read](Comfy-Org#13686)
- [Comfy-Org#13963 — Node data
store](Comfy-Org#13963)
- [Comfy-Org#14110 — Centralize node, group, and reroute
geometry](Comfy-Org#14110)
- [Comfy-Org#14128 — Register node geometry at
attach](Comfy-Org#14128)
- [Comfy-Org#14133 — Read node geometry from the
store](Comfy-Org#14133)
- [Comfy-Org#14758 — Keep DOM measurements out of saved node
sizes](Comfy-Org#14758)
- [Comfy-Org#15001 — Extract entity ID
allocation](Comfy-Org#15001)
- [Comfy-Org#15009 — Scope link and reroute topology by owning
graph](Comfy-Org#15009)
- [Comfy-Org#15017 — Centralize layout ownership and command
submission](Comfy-Org#15017)
- [Comfy-Org#15018 — Preserve subgraph topology during
unpack](Comfy-Org#15018)
- [Comfy-Org#15019 — Transfer node ownership during
replacement](Comfy-Org#15019)
- [Comfy-Org#15330 — Map migration status and remaining
work](Comfy-Org#15330)

## Review Focus

- Store ownership and synchronization boundaries.
- Serialization, undo/redo, subgraph, and extension compatibility.
- Whether remaining direct entity state should migrate before this
feature leaves draft.

## Status

Still draft. The branch is rebased onto `main`; CI is running against
the rebased history.

---------

Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Christian Byrne <cbyrne@comfy.org>
Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Matt Miller <mattmiller@comfy.org>
DrJKL pushed a commit that referenced this pull request Aug 25, 2026
…n art in blueprint theme

Weight rooms by how much review the constituent PRs actually drew:

- New room: The Registry Office (Identity & Ownership). Registration
  policy was the migration's dominant bug class (#13528, #15009, #15017,
  #15019). Its challenge is the real clipboard-hijack bug: refuse
  foreign overwrites vs first-wins vs last-wins.
- New room: The Hall of Mirrors (Compatibility). The mirror-deletion PRs
  (#13479, #13498) were the most heavily reviewed of the migration. Its
  challenge covers the throw vs warn-and-ignore shim decision that
  review settled, plus frozen arrays and zero-warning telemetry tests.
- 12 rooms, 11 challenges; exits rewired; renderer room gains the
  measurement ledger (deleted 197us/op operation log, reverted WeakMap
  cache); Eternal Refactor ending names real remaining work.
- Full V2 asset regen (70 images) in a new vintage-blueprint theme:
  cyan-white linework on midnight-blue drafting paper, Krea 2 Turbo on
  Comfy Cloud. Prompt records updated in the four prompt JSONs; stale
  unreferenced icons removed.
- Prose pass over room and challenge text against AI-writing checklists;
  walkthrough rewritten (map, 24-press route, 22 artifacts); CHANGELOG
  added.

Validated: JS syntax, all 54 icon references resolve, headless run of
the full optimal route reaches The ECS Enlightenment with no console
errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants