Repository navigation
fix: scope link and reroute topology by owning graph - #15009
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe 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. ChangesGraph-scoped topology identity
Estimated code review effort: 4 (Complex) | ~60 minutes Mergeability Score: 🟡 Moderate · up to 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
Possibly related PRs
Suggested reviewers: Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
🎭 Playwright: ✅ 1809 passed, 0 failed · 4 flaky📊 Browser Reports
🎨 Storybook: ✅ Built — View Storybook📦 Bundle Size
⚡ Performance Report
Absolute values
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 Report❌ Patch coverage is @@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 5 files with indirect coverage changes 🚀 New features to boost your workflow:
|
7fc5aa4 to
d1fc17a
Compare
There was a problem hiding this comment.
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
📒 Files selected for processing (47)
browser_tests/assets/subgraphs/subgraph-link-identity-collision.jsonbrowser_tests/tests/subgraph/subgraphLinkIdentity.spec.tssrc/components/builder/AppModeWidgetList.vuesrc/components/rightSidePanel/parameters/WidgetItem.test.tssrc/components/rightSidePanel/parameters/WidgetItem.vuesrc/core/graph/subgraph/migration/proxyWidgetMigration.test.tssrc/core/graph/subgraph/migration/proxyWidgetMigration.tssrc/core/graph/subgraph/promotionUtils.test.tssrc/core/graph/widgets/dynamicWidgets.tssrc/extensions/core/widgetInputs.test.tssrc/extensions/core/widgetValuePropagation.test.tssrc/extensions/core/widgetValuePropagation.tssrc/lib/litegraph/src/LGraph.inputSlotRealign.test.tssrc/lib/litegraph/src/LGraph.serialise.test.tssrc/lib/litegraph/src/LGraph.test.tssrc/lib/litegraph/src/LGraph.tssrc/lib/litegraph/src/LGraphCanvas.clipboard.test.tssrc/lib/litegraph/src/LLink.store.test.tssrc/lib/litegraph/src/LLink.tssrc/lib/litegraph/src/Reroute.store.test.tssrc/lib/litegraph/src/Reroute.tssrc/lib/litegraph/src/canvas/LinkConnector.core.test.tssrc/lib/litegraph/src/canvas/LinkConnector.integration.test.tssrc/lib/litegraph/src/linkDeduplication.tssrc/lib/litegraph/src/node/slotLinks.tssrc/lib/litegraph/src/subgraph/SubgraphConversion.test.tssrc/platform/nodeReplacement/useNodeReplacement.test.tssrc/renderer/extensions/minimap/composables/useMinimap.test.tssrc/renderer/extensions/minimap/data/AbstractMinimapDataSource.tssrc/renderer/extensions/minimap/data/MinimapDataSource.test.tssrc/renderer/extensions/minimap/minimapCanvasRenderer.test.tssrc/renderer/extensions/vueNodes/components/NodeSlots.test.tssrc/renderer/extensions/vueNodes/components/NodeSlots.vuesrc/renderer/extensions/vueNodes/composables/useProcessedWidgets.test.tssrc/renderer/extensions/vueNodes/composables/useProcessedWidgets.tssrc/renderer/extensions/vueNodes/composables/useSlotLinkInteraction.tssrc/renderer/extensions/vueNodes/utils/__tests__/nodeDataUtils.test.tssrc/renderer/extensions/vueNodes/utils/nodeDataUtils.tssrc/stores/linkStore.test.tssrc/stores/linkStore.tssrc/stores/rerouteStore.test.tssrc/stores/rerouteStore.tssrc/stores/widgetValueStore.graphReactivity.test.tssrc/systems/badgeSystem.pricing.test.tssrc/systems/badgeSystem.tssrc/types/graphScopeId.tssrc/utils/linkFixer.test.ts
benjcooley
left a comment
There was a problem hiding this comment.
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 makesnew LGraph(serialised)require an active Pinia, and silently hollows out two existing tests (they pass but assert nothing)._addReroutedrops a reroute with no log whilesetReroutestill hands it to the caller;_addLinkdrops a link from_linkswith no signal to its three callers.- Stale JSDoc in
linkStore(no link-id check exists) and ahasUniqueTargetrationale 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.
There was a problem hiding this comment.
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 liftEnforce 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 ownGraphScopeand then
delete it or update its endpoints. Require
topology.graphId === scope.owningGraphIdindeleteLinkand 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 falsefor (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
📒 Files selected for processing (43)
browser_tests/tests/subgraph/subgraphLinkIdentity.spec.tsbrowser_tests/tests/subgraph/subgraphSerialization.spec.tsdocs/architecture/link-topology-store.mddocs/architecture/node-data-store.mddocs/architecture/reroute-chain-store.mddocs/extensions/README.mddocs/extensions/link-registration-migration.mdsrc/lib/litegraph/src/LGraph.test.tssrc/lib/litegraph/src/LGraph.tssrc/lib/litegraph/src/LGraphCanvas.clipboard.test.tssrc/lib/litegraph/src/LGraphCanvas.tssrc/lib/litegraph/src/LGraphGroup.test.tssrc/lib/litegraph/src/LGraphNode.nodeState.test.tssrc/lib/litegraph/src/LGraphNode.test.tssrc/lib/litegraph/src/LGraphNode.tssrc/lib/litegraph/src/LLink.store.test.tssrc/lib/litegraph/src/LLink.tssrc/lib/litegraph/src/LinkMap.tssrc/lib/litegraph/src/Reroute.store.test.tssrc/lib/litegraph/src/Reroute.tssrc/lib/litegraph/src/__fixtures__/duplicateSubgraphNodeIds.tssrc/lib/litegraph/src/canvas/LinkConnector.core.test.tssrc/lib/litegraph/src/canvas/LinkConnector.integration.test.tssrc/lib/litegraph/src/canvas/LinkConnectorSubgraphInputValidation.test.tssrc/lib/litegraph/src/interfaces.tssrc/lib/litegraph/src/linkDeduplication.tssrc/lib/litegraph/src/subgraph/ExecutableNodeDTO.test.tssrc/lib/litegraph/src/subgraph/SubgraphConversion.test.tssrc/lib/litegraph/src/subgraph/SubgraphInput.tssrc/lib/litegraph/src/subgraph/SubgraphOutput.tssrc/lib/litegraph/src/subgraph/subgraphDeduplication.test.tssrc/lib/litegraph/src/subgraph/subgraphDeduplication.tssrc/renderer/extensions/minimap/data/MinimapDataSource.test.tssrc/stores/linkStore.test.tssrc/stores/linkStore.tssrc/stores/nodeDataStore.test.tssrc/stores/nodeDataStore.tssrc/stores/rerouteStore.test.tssrc/stores/rerouteStore.tssrc/types/linkTopology.tssrc/types/nodeState.tssrc/types/rerouteChain.tssrc/utils/linkFixer.test.ts
| 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)) | ||
| } |
There was a problem hiding this comment.
🚀 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
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 winRestrict mutations to the selected owner.
deleteLinkaccepts any scope with the same root ID.validateEndpointUpdateshas the same gap. A caller can obtain a topology throughgetTopology(rootGraphId, id)and then delete or update an owner A link through sibling owner B's scope.Compare
scope.owningGraphIdwith 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 winUse root-wide IDs for reminted floating links.
_lastFloatingLinkIdis local to each graph. Two sibling subgraph definitions can
both mint ID1. The secondregisterLinkTopologycall then rejects the
root-wide collision, andaddFloatingLinkdrops 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
📒 Files selected for processing (34)
browser_tests/tests/subgraph/subgraphLinkIdentity.spec.tsdocs/architecture/ecs-migration-plan.mddocs/architecture/link-topology-store.mdsrc/components/rightSidePanel/parameters/WidgetItem.test.tssrc/core/graph/subgraph/migration/proxyWidgetMigration.test.tssrc/extensions/core/widgetInputs.test.tssrc/extensions/core/widgetValuePropagation.test.tssrc/lib/litegraph/src/LGraph.inputSlotRealign.test.tssrc/lib/litegraph/src/LGraph.test.tssrc/lib/litegraph/src/LGraph.tssrc/lib/litegraph/src/LinkMap.tssrc/lib/litegraph/src/__fixtures__/duplicateLinks.tssrc/lib/litegraph/src/linkDeduplication.tssrc/lib/litegraph/src/subgraph/SubgraphSerialization.test.tssrc/lib/litegraph/src/subgraph/subgraphDeduplication.test.tssrc/lib/litegraph/src/subgraph/subgraphDeduplication.tssrc/platform/nodeReplacement/useNodeReplacement.test.tssrc/renderer/extensions/minimap/composables/useMinimap.test.tssrc/renderer/extensions/minimap/data/MinimapDataSource.test.tssrc/renderer/extensions/minimap/minimapCanvasRenderer.test.tssrc/renderer/extensions/vueNodes/composables/useProcessedWidgets.test.tssrc/renderer/extensions/vueNodes/composables/useProcessedWidgets.tssrc/renderer/extensions/vueNodes/utils/__tests__/nodeDataUtils.test.tssrc/stores/linkStore.test.tssrc/stores/linkStore.tssrc/stores/nodeDataStore.test.tssrc/stores/nodeDataStore.tssrc/stores/rerouteStore.test.tssrc/stores/rerouteStore.tssrc/systems/badgeSystem.pricing.test.tssrc/systems/badgeSystem.tssrc/types/linkTopology.tssrc/types/nodeState.tssrc/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
DrJKL
left a comment
There was a problem hiding this comment.
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:
rootGraphIdselects the shared identity bucket.owningGraphIdselects 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
- Store contracts:
linkStore.ts,rerouteStore.ts,nodeDataStore.ts, andGraphScopehelpers. - Runtime adapters:
LLink.ts,Reroute.ts,LGraphNode.ts, andLinkMap.ts. - Normalization boundary:
subgraphDeduplication.ts, thenLGraph.createSubgraphs()/ workflow configure. - Mutation callers: connector, slot, widget, and renderer call sites; these should derive scope rather than reconstruct it.
- Teardown and serialization: centralized helpers in
LGraph.ts. - Behavioral proof: store tests, subgraph serialization/conversion tests, and the browser identity-collision fixture/spec.
- Migration constraints and deferred choices:
docs/architecture/ecs-migration-plan.md.
Compatibility intentionally retained
graph.linksandgraph.floatingLinksremain 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
left a comment
There was a problem hiding this comment.
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.
registerConfiguredLinkputs link registration back at payload-parse time (LGraph.ts:2673/:2715), souseLinkStoreis populated before nodes are created and configured. The three unguarded readers I traced (createBoundingBoxes.ts:33, and the twocaptureInputLayoutpaths indynamicWidgets.ts) now see real state again. _addLink/_addReroute/registerNodeStatereturn real booleans andsetReroutereturnsundefinedon rejection;LGraphNode.connectroutes throughreplaceLinkTopologyand bails cleanly.- Both hollowed-out tests now capture the id before
clear(). - The
registerLinkJSDoc is accurate now thatbyIdexists, andhasUniqueTargetdropped theSUBGRAPH_OUTPUT_IDexclusion — 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 { |
There was a problem hiding this comment.
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 throughsnapshot(), which allocates a freshMapper call —sizeis 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
Mapstorage 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.
| getActivePinia() && this.rootGraph ? graphScopeOf(this) : undefined, | ||
| (scope, id) => { | ||
| const topology = useLinkStore().getTopology(scope.rootGraphId, id) | ||
| return topology?.graphId === scope.owningGraphId && |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
|
|
||
| for (const { topology } of updates) displace(graphId, topology) | ||
| for (const topology of removals) displace(graphId, topology) | ||
| const changesLinkView = |
There was a problem hiding this comment.
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.
Architecture review proposal: make navigation obey the topology rules established hereNote 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 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
What exists todayThe ECS target explicitly names dedicated stores as runtime sources of truth and names
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
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 targetThe 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:
That invariant is testable. “There are only N watchers” is not. Proposed ownership modelThe 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
Ownership rules1. One graph-transition command boundaryAll 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 observerUse router lifecycle (
3. One stale-work guardUse one monotonic 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
4. Treat
|
| 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
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/replacefor graph navigation. - Exactly one module owns asynchronous navigation intent IDs.
- Blank/default/import/workflow loads share the same transition entry point.
-
litegraph:set-graphhas 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:
- Merge fix: scope link and reroute topology by owning graph #15009’s graph-scoped topology boundary.
- Add router/canvas integration tests that expose current feedback behavior.
- Introduce the single navigation coordinator and intent token.
- Remove duplicate watchers, explicit
updateHash()completion calls, and dead mirrored state as consequences—not as the primary objective. - Update the ECS target diagram to name
NavigationSystemas behavior andsubgraphNavigationStoreas 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.
0098081 to
8a0f977
Compare
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>
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>
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>
## 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>
…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.
Split 2/6 of #14480. Stacked on #15001.
Fixes cross-subgraph-definition topology contamination:
linkStore/rerouteStorebuckets 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:
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 byrootGraphId.linkStore,rerouteStore, andnodeDataStorethe authoritative collision boundaries. Registrations are first-wins; rejected entities remain detached and are not assigned to the requesting owner.linkStore: an entire batch is validated before indexes or topology fields change.LLinkretains the store-held reactive topology object across ID and endpoint updates.NodeSlots.vueanduseProcessedWidgets.ts.Behavior notes:
LGraphfrom serialized data requires an active Pinia because entities register with topology stores during deserialization.