Repository navigation
feat(agent): drive tab switching through the activation coordinator - #18326
claude[bot] wants to merge 8 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Repository: Comfy-Org/ComfyUI_frontend/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Wires the GraphDocument activation seam into the real workflow load path,
so op targeting reads the activated document instead of re-deriving which
graph is bound.
The app reuses one root LGraph across tabs and reconfigures it in place, so
"the graph the canvas holds" is a moving target. Consumers that re-derive it
can lag the reconfigure, and a layout change draining on a later microtask
then mints into the previous tab's document.
- documentActivationHost: the coordinator plus the canvas DocumentViewBinding,
publishing one activated {document, root graph} pair. Deactivate retracts
an in-flight activation as well as the published one.
- documentActivationStore: app-wide singleton over the document registry.
- workflowService drives it: beforeLoadNewGraph retracts, afterLoadNewGraph
activates. That is the single funnel all three graph-load paths share
(loadGraphData, loadApiJson, importA1111).
- layoutMintPort drops a root-scoped createNode/deleteNode/clearGraph that
names a graph the activated document does not own, reporting
agent_crdt_op_for_inactive_document. It fails closed while nothing is
activated, which is exactly the handoff window.
🎭 Playwright: ✅ 1944 passed, 0 failed · 1 flaky📊 Browser Reports
🎨 Storybook: ✅ Built — View Storybook📦 Bundle Size
⚡ Performance Report
Absolute values
Raw data{
"timestamp": "2026-09-25T04:38:06.740Z",
"gitSha": "daa5b57dfb8c77fec6dce3e1b9e10ab950ac82d5",
"branch": "agent/tab-switch-activation-hooks",
"measurements": [
{
"name": "canvas-idle",
"durationMs": 2013.0620000000476,
"styleRecalcs": 6,
"styleRecalcDurationMs": 8.048000000000002,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 475.877,
"heapDeltaBytes": 13385516,
"heapUsedBytes": 75055048,
"domNodes": -264,
"jsHeapTotalBytes": 4448256,
"scriptDurationMs": 13.330000000000002,
"eventListeners": -156,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-idle",
"durationMs": 2010.0029999999833,
"styleRecalcs": 8,
"styleRecalcDurationMs": 8.471999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 505.606,
"heapDeltaBytes": 7617592,
"heapUsedBytes": 68513336,
"domNodes": -263,
"jsHeapTotalBytes": 4710400,
"scriptDurationMs": 11.908999999999999,
"eventListeners": -154,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-mouse-sweep",
"durationMs": 1872.5529999999821,
"styleRecalcs": 76,
"styleRecalcDurationMs": 32.733,
"layouts": 14,
"layoutDurationMs": 4.441,
"taskDurationMs": 934.4480000000001,
"heapDeltaBytes": 11737132,
"heapUsedBytes": 73304844,
"domNodes": -263,
"jsHeapTotalBytes": 5496832,
"scriptDurationMs": 176.054,
"eventListeners": -154,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "canvas-mouse-sweep",
"durationMs": 1905.6949999999233,
"styleRecalcs": 77,
"styleRecalcDurationMs": 32.11,
"layouts": 14,
"layoutDurationMs": 4.597,
"taskDurationMs": 923.568,
"heapDeltaBytes": 2496068,
"heapUsedBytes": 64601344,
"domNodes": -262,
"jsHeapTotalBytes": 6545408,
"scriptDurationMs": 172.68100000000004,
"eventListeners": -184,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1738.868000000025,
"styleRecalcs": 31,
"styleRecalcDurationMs": 19.08,
"layouts": 6,
"layoutDurationMs": 1.162,
"taskDurationMs": 386.77000000000004,
"heapDeltaBytes": 2033548,
"heapUsedBytes": 63464308,
"domNodes": 76,
"jsHeapTotalBytes": 4980736,
"scriptDurationMs": 15.604,
"eventListeners": 19,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1738.3050000000821,
"styleRecalcs": 31,
"styleRecalcDurationMs": 17.869,
"layouts": 6,
"layoutDurationMs": 1.19,
"taskDurationMs": 369.285,
"heapDeltaBytes": 2042884,
"heapUsedBytes": 63348648,
"domNodes": 74,
"jsHeapTotalBytes": 4980736,
"scriptDurationMs": 15.351999999999997,
"eventListeners": 19,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "dom-widget-clipping",
"durationMs": 692.5509999999804,
"styleRecalcs": 11,
"styleRecalcDurationMs": 7.680999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 473.842,
"heapDeltaBytes": 18076484,
"heapUsedBytes": 80204760,
"domNodes": 18,
"jsHeapTotalBytes": 5505024,
"scriptDurationMs": 168.64700000000002,
"eventListeners": 0,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "dom-widget-clipping",
"durationMs": 727.8069999999843,
"styleRecalcs": 11,
"styleRecalcDurationMs": 8.585000000000003,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 479.30299999999994,
"heapDeltaBytes": 18074084,
"heapUsedBytes": 80316348,
"domNodes": 18,
"jsHeapTotalBytes": 5767168,
"scriptDurationMs": 173.86200000000002,
"eventListeners": 2,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-idle",
"durationMs": 2028.8140000000112,
"styleRecalcs": 4,
"styleRecalcDurationMs": 4.751000000000002,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 485.36499999999995,
"heapDeltaBytes": 2859632,
"heapUsedBytes": 82282948,
"domNodes": -253,
"jsHeapTotalBytes": -1056768,
"scriptDurationMs": 37.513000000000005,
"eventListeners": -182,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66999999999998,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-idle",
"durationMs": 2037.2150000000602,
"styleRecalcs": 4,
"styleRecalcDurationMs": 3.727999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 622.9630000000001,
"heapDeltaBytes": 4019804,
"heapUsedBytes": 82944628,
"domNodes": -250,
"jsHeapTotalBytes": -794624,
"scriptDurationMs": 39.486999999999995,
"eventListeners": -154,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "large-graph-pan",
"durationMs": 2540.4189999999858,
"styleRecalcs": 66,
"styleRecalcDurationMs": 12.652999999999997,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1785.954,
"heapDeltaBytes": -12957640,
"heapUsedBytes": 66828576,
"domNodes": -229,
"jsHeapTotalBytes": 1826816,
"scriptDurationMs": 886.1320000000001,
"eventListeners": -182,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "large-graph-pan",
"durationMs": 2682.2919999999613,
"styleRecalcs": 67,
"styleRecalcDurationMs": 13.057999999999996,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1824.577,
"heapDeltaBytes": 2846820,
"heapUsedBytes": 83276424,
"domNodes": -254,
"jsHeapTotalBytes": 2052096,
"scriptDurationMs": 907.162,
"eventListeners": -182,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "large-graph-zoom",
"durationMs": 3600.571000000002,
"styleRecalcs": 60,
"styleRecalcDurationMs": 10.401,
"layouts": 60,
"layoutDurationMs": 12.764000000000001,
"taskDurationMs": 1775.0790000000002,
"heapDeltaBytes": 9856048,
"heapUsedBytes": 74513192,
"domNodes": -263,
"jsHeapTotalBytes": 0,
"scriptDurationMs": 816.643,
"eventListeners": 10,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-zoom",
"durationMs": 3622.8810000000067,
"styleRecalcs": 60,
"styleRecalcDurationMs": 10.560999999999998,
"layouts": 60,
"layoutDurationMs": 12.884999999999998,
"taskDurationMs": 1781.633,
"heapDeltaBytes": 9831868,
"heapUsedBytes": 73731928,
"domNodes": -265,
"jsHeapTotalBytes": 0,
"scriptDurationMs": 820.35,
"eventListeners": 10,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "legacy-node-drag",
"durationMs": 3156.4500000000066,
"styleRecalcs": 40,
"styleRecalcDurationMs": 5.281999999999995,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 2004.9070000000002,
"heapDeltaBytes": 20447572,
"heapUsedBytes": 86670512,
"domNodes": 0,
"jsHeapTotalBytes": 417792,
"scriptDurationMs": 1004.4159999999999,
"eventListeners": 188,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "legacy-node-drag",
"durationMs": 3146.0950000000594,
"styleRecalcs": 40,
"styleRecalcDurationMs": 5.3329999999999975,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 2004.7939999999999,
"heapDeltaBytes": 20469120,
"heapUsedBytes": 86691080,
"domNodes": 0,
"jsHeapTotalBytes": 1204224,
"scriptDurationMs": 1013.2269999999999,
"eventListeners": 188,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333338,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "minimap-idle",
"durationMs": 2016.6960000000245,
"styleRecalcs": 5,
"styleRecalcDurationMs": 4.572,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 609.9680000000001,
"heapDeltaBytes": -3295668,
"heapUsedBytes": 83861876,
"domNodes": -249,
"jsHeapTotalBytes": -495616,
"scriptDurationMs": 38.974999999999994,
"eventListeners": -152,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "minimap-idle",
"durationMs": 2054.41600000006,
"styleRecalcs": 5,
"styleRecalcDurationMs": 4.699999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 649.1429999999999,
"heapDeltaBytes": -4679516,
"heapUsedBytes": 82617524,
"domNodes": -254,
"jsHeapTotalBytes": -495616,
"scriptDurationMs": 37.328,
"eventListeners": -182,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 608.5190000000011,
"styleRecalcs": 46,
"styleRecalcDurationMs": 10.928,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 422.29400000000004,
"heapDeltaBytes": 13910020,
"heapUsedBytes": 76666176,
"domNodes": 18,
"jsHeapTotalBytes": 6029312,
"scriptDurationMs": 150.352,
"eventListeners": 8,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 605.4789999999457,
"styleRecalcs": 46,
"styleRecalcDurationMs": 11.639,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 420.76800000000003,
"heapDeltaBytes": 13758576,
"heapUsedBytes": 76847032,
"domNodes": 18,
"jsHeapTotalBytes": 5505024,
"scriptDurationMs": 147.81000000000003,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-idle",
"durationMs": 2022.2519999999804,
"styleRecalcs": 10,
"styleRecalcDurationMs": 10.839000000000002,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 520.8349999999999,
"heapDeltaBytes": 11959076,
"heapUsedBytes": 75034080,
"domNodes": -277,
"jsHeapTotalBytes": 4710400,
"scriptDurationMs": 11.880999999999998,
"eventListeners": -200,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-idle",
"durationMs": 2015.3029999999035,
"styleRecalcs": 9,
"styleRecalcDurationMs": 8.201,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 498.04,
"heapDeltaBytes": 8512352,
"heapUsedBytes": 71734228,
"domNodes": -277,
"jsHeapTotalBytes": 4710400,
"scriptDurationMs": 10.22,
"eventListeners": -200,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1720.9650000000352,
"styleRecalcs": 77,
"styleRecalcDurationMs": 28.900000000000002,
"layouts": 18,
"layoutDurationMs": 4.809000000000001,
"taskDurationMs": 837.6790000000001,
"heapDeltaBytes": 14424048,
"heapUsedBytes": 77630024,
"domNodes": -276,
"jsHeapTotalBytes": 5234688,
"scriptDurationMs": 115.98899999999999,
"eventListeners": -202,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1722.695999999928,
"styleRecalcs": 79,
"styleRecalcDurationMs": 32.248,
"layouts": 18,
"layoutDurationMs": 5.949,
"taskDurationMs": 878.665,
"heapDeltaBytes": -2500304,
"heapUsedBytes": 60516292,
"domNodes": -276,
"jsHeapTotalBytes": 5234688,
"scriptDurationMs": 122.613,
"eventListeners": -232,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-transition-enter",
"durationMs": 1401.8250000000307,
"styleRecalcs": 17,
"styleRecalcDurationMs": 31.021,
"layouts": 5,
"layoutDurationMs": 13.668,
"taskDurationMs": 994.7270000000001,
"heapDeltaBytes": 19621632,
"heapUsedBytes": 100486824,
"domNodes": 13587,
"jsHeapTotalBytes": 11010048,
"scriptDurationMs": 34.49,
"eventListeners": 2385,
"totalBlockingTimeMs": 155,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "viewport-pan-sweep",
"durationMs": 9377.060999999969,
"styleRecalcs": 247,
"styleRecalcDurationMs": 37.83200000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 6419.963,
"heapDeltaBytes": -10283056,
"heapUsedBytes": 68534500,
"domNodes": -248,
"jsHeapTotalBytes": 4186112,
"scriptDurationMs": 3026.1369999999997,
"eventListeners": -134,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.80000000000109
},
{
"name": "viewport-pan-sweep",
"durationMs": 8657.785999999987,
"styleRecalcs": 248,
"styleRecalcDurationMs": 37.916999999999994,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 6098.21,
"heapDeltaBytes": -12285788,
"heapUsedBytes": 66643800,
"domNodes": -249,
"jsHeapTotalBytes": 4448256,
"scriptDurationMs": 2859.871,
"eventListeners": -166,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.670000000000012,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-idle",
"durationMs": 17444.654000000013,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 16981.439,
"heapDeltaBytes": -54873536,
"heapUsedBytes": 159610448,
"domNodes": -6575,
"jsHeapTotalBytes": 1064960,
"scriptDurationMs": 278.219,
"eventListeners": -7478,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.780000000000047,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-idle",
"durationMs": 17274.110999999946,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 16948.090999999997,
"heapDeltaBytes": -39803040,
"heapUsedBytes": 168255720,
"domNodes": -6542,
"jsHeapTotalBytes": 3424256,
"scriptDurationMs": 283.999,
"eventListeners": -7480,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.780000000000047,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-pan",
"durationMs": 21088.037999999982,
"styleRecalcs": 157,
"styleRecalcDurationMs": 21.030999999999967,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 20954.068,
"heapDeltaBytes": -31831144,
"heapUsedBytes": 163214480,
"domNodes": -6542,
"jsHeapTotalBytes": 372736,
"scriptDurationMs": 955.7710000000002,
"eventListeners": -7474,
"totalBlockingTimeMs": 62,
"frameDurationMs": 17.776666666666642,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-pan",
"durationMs": 21431.44600000005,
"styleRecalcs": 154,
"styleRecalcDurationMs": 20.706999999999976,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 21256.084000000003,
"heapDeltaBytes": -33319232,
"heapUsedBytes": 165111176,
"domNodes": -6542,
"jsHeapTotalBytes": 1589248,
"scriptDurationMs": 922.312,
"eventListeners": -7474,
"totalBlockingTimeMs": 12,
"frameDurationMs": 17.776666666666642,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-node-resize-workload",
"durationMs": 6326.976000000002,
"styleRecalcs": 20,
"styleRecalcDurationMs": 79.878,
"layouts": 20,
"layoutDurationMs": 23.921999999999997,
"taskDurationMs": 6254.259999999999,
"heapDeltaBytes": -8554304,
"heapUsedBytes": 193384964,
"domNodes": -6542,
"jsHeapTotalBytes": 16625664,
"scriptDurationMs": 116.52399999999999,
"eventListeners": -7476,
"totalBlockingTimeMs": 416,
"frameDurationMs": 17.776666666666642,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-node-resize-workload",
"durationMs": 4828.9459999999735,
"styleRecalcs": 20,
"styleRecalcDurationMs": 82.09,
"layouts": 20,
"layoutDurationMs": 23.85899999999999,
"taskDurationMs": 4780.839999999999,
"heapDeltaBytes": 1612136,
"heapUsedBytes": 196855552,
"domNodes": -6546,
"jsHeapTotalBytes": 20295680,
"scriptDurationMs": 124.59599999999999,
"eventListeners": -7480,
"totalBlockingTimeMs": 120,
"frameDurationMs": 17.776666666666642,
"p95FrameDurationMs": 16.80000000000109
},
{
"name": "vue-zoom-out-idle",
"durationMs": 8812.072999999999,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 8585.464000000002,
"heapDeltaBytes": 5350872,
"heapUsedBytes": 182014816,
"domNodes": -1,
"jsHeapTotalBytes": 786432,
"scriptDurationMs": 134.83200000000005,
"eventListeners": -10,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.776666666666642,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-zoom-out-idle",
"durationMs": 8699.214999999982,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 8453.369,
"heapDeltaBytes": 16732452,
"heapUsedBytes": 188881448,
"domNodes": 0,
"jsHeapTotalBytes": -2097152,
"scriptDurationMs": 136.096,
"eventListeners": -12,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.779999999999927,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "workflow-execution",
"durationMs": 460.33199999999397,
"styleRecalcs": 16,
"styleRecalcDurationMs": 27.095,
"layouts": 4,
"layoutDurationMs": 2.162,
"taskDurationMs": 136.52599999999998,
"heapDeltaBytes": 5034716,
"heapUsedBytes": 66716256,
"domNodes": 126,
"jsHeapTotalBytes": 262144,
"scriptDurationMs": 12.559000000000001,
"eventListeners": 83,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "workflow-execution",
"durationMs": 475.2680000000282,
"styleRecalcs": 19,
"styleRecalcDurationMs": 21.926,
"layouts": 5,
"layoutDurationMs": 1.78,
"taskDurationMs": 115.25800000000002,
"heapDeltaBytes": 4842508,
"heapUsedBytes": 66395724,
"domNodes": 142,
"jsHeapTotalBytes": 0,
"scriptDurationMs": 11.315000000000001,
"eventListeners": 67,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
}
]
}🔬 E2E CoverageNote Shard completeness could not be verified for this run, so these totals may not be comparable with a whole merge.
Top 10 files by uncovered lines
|
624fac5 to
228153e
Compare
|
CI note on the "Custom Nodes Ecosystem Matrix test" failure reported against the pre-amend commit That failure is not a real test failure and not caused by this PR's diff. Looking at the run, all 8 The amend push triggered a fresh, non-superseded run on the current head ( |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## feat/graph-document-activation-seam #18326 +/- ##
======================================================================
Coverage ? 83.36%
======================================================================
Files ? 2081
Lines ? 121312
Branches ? 31525
======================================================================
Hits ? 101127
Misses ? 20004
Partials ? 181
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @christian-byrne.
Found 10 finding(s).
| Severity | Count |
|---|---|
| 🟠 High | 4 |
| 🟡 Medium | 5 |
| 🟢 Low | 1 |
Panel: 8/8 reviewers contributed findings.
| */ | ||
| const activateLoadedDocument = async (): Promise<void> => { | ||
| const documentId = useWorkspaceStore().workflow.activeWorkflow?.documentId | ||
| if (!documentId || !app.isGraphReady) return |
There was a problem hiding this comment.
🟠 High — When activeWorkflow.documentId is null or app.isGraphReady is false this returns without activating, and a rejected/superseded ActivationOutcome is discarded too — but beforeLoadNewGraph has already retracted the previous binding, so activeRootGraphId() stays null for the rest of that workflow's lifetime. The new fail-closed gate then drops every root-scoped create/delete/clear with no user-visible signal, no retry, and only once-per-tick telemetry. Raised by 5 of 8 reviewers (claude-opus-5-thinking-max adversarial, gemini-3.1-pro adversarial, gemini-3.1-pro edge-case, kimi-k3-max adversarial, kimi-k3-max edge-case).
There was a problem hiding this comment.
Confirmed on the silence, fixed in 08e3674, with one part I read differently.
activateLoadedDocument now reports every ending that leaves nothing activated: document_activation_unavailable when the graph is ready but the active workflow has no documentId, and document_activation_rejected (with the reason and root graph id) when the coordinator refuses. That ends the "only once-per-tick telemetry" problem: the drop is now attributable to the load that caused it, not to the change that later hits the gate.
Where I disagree on the remedy: when there is no documentId there is no GraphDocument for what the canvas is showing, so minting root-scoped ops into the agent's bound document would be minting into a document the canvas does not hold. Dropping is the correct outcome; being quiet about it was the bug. Same for superseded, which means a newer load won and will publish its own binding. !app.isGraphReady stays a silent no-op because there is no canvas and therefore no layout changes to drop.
The rejected path also got narrower rather than just louder: the load path now marks the document loaded itself (see the documentActivationHost.ts thread), so not-loaded can no longer fire for a workflow document a load produced. Test: workflowService.test.ts "reports a load that ends with no document holding the canvas" (red before).
| * rather than the workflow's serialized `activeState`, because that is the | ||
| * graph every layout change will name. | ||
| */ | ||
| const activateLoadedDocument = async (): Promise<void> => { |
There was a problem hiding this comment.
🟠 High — The "all three graph-load paths funnel through afterLoadNewGraph" premise misses Clear Workflow: runMintPortsIntentionalClear(() => app.clean()) reaches LGraph.clear(), which remints the root graph's id without any load and therefore without re-activating. The host keeps publishing the pre-clear id, so every subsequent human create/delete fails isForActivatedDocument and is dropped until the next workflow load, while widget and link mints keep flowing into the same document and reference nodes that were never added. Raised by 3 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gpt-5.6-sol-max edge-case).
There was a problem hiding this comment.
Confirmed and fixed in 08e3674.
LGraph.clear() does remint (this.id = createUuidv4() for a root graph), and Clear Workflow reaches no load path, so the binding kept naming the pre-clear graph and every later create/delete was dropped as foreign.
What changed: the host gained rebindActiveScope(scope) (same document, same canvas, new id, so no detach/attach and no generation race), and app.clean() calls it right after ensureNonZeroUuid(this.rootGraph). It returns false during a load, which already retracted the binding, so the load path is untouched.
One wrinkle worth naming: the store's own clearGraph change carries the pre-clear id and drains a microtask later, so a naive rebind would have made the human clear op itself fail the targeting check. runIntentionalClear now captures the activated root graph id alongside the pre-clear node set, and a clear inside that window is validated against the captured id.
Tests (both red before): app.test.ts "republishes the activated document on the reminted root graph id" and tabSwitchActivation.test.ts "keeps minting after a clear reminted the root graph id in place". The "all three graph-load paths funnel through here" comment now says loads funnel through afterLoadNewGraph and names the clear path as the one swap that does not. The widget/link half of your note is fixed in the mintPortWiring thread.
| return { | ||
| activate(documentId, scope) { | ||
| requested = documentId | ||
| deps.bindScope(documentId, scope) |
There was a problem hiding this comment.
🟠 High — bindScope runs before coordinator.activate() evaluates its isLoaded precondition, and the store's implementation calls hydrateDocument, which itself transitions a document created -> loaded; requesting activation therefore promotes the document and the not-loaded rejection becomes unreachable in production (the host test passes only because its isLoaded Set double is untouched by the bindScope recorder). The registry scope is also written for activations that are later rejected or superseded, so a losing request can leave getDocument(id).scope naming a graph that document never held — commit the scope from the winning attach instead. Raised by 5 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gpt-5.6-sol-max adversarial, kimi-k3-max adversarial, kimi-k3-max edge-case).
There was a problem hiding this comment.
Both halves confirmed and fixed in 08e3674. This was the most useful finding of the set.
Scope commit: the dep is renamed commitScope and is called only when the coordinator returns activated. A rejected or superseded request no longer stamps its document, which matters exactly as you describe: the loser read app.rootGraph.id before the winner reconfigured, so its "own" scope can name the winner's graph. Host tests: "never records the scope of an activation it rejected" and "never records the scope of a superseded activation".
The precondition: rather than commit scope from inside attach (activation is presentation per the ADR, and attach/detach must not touch semantic document state), the created -> loaded promotion moved to the loader. graphDocumentStore gained markLoaded(documentId), a phase-only transition with no scope, and workflowService.activateLoadedDocument calls it before requesting the canvas. Loading a document is the load path's step; the coordinator's isLoaded is now a real check that rejects a document no load produced (unknown or closed).
Pinned against the real registry, not a double: tabSwitchActivation.test.ts "refuses the canvas to a document no load path ever loaded" asserts the not-loaded outcome, a null binding and a null registry scope. It fails on the old code, which activated because the request hydrated the document on its way in.
| // the shared root graph (ADR-GRAPH-DOCUMENT-0024). Synchronous on | ||
| // purpose: from here until the incoming document is activated, no | ||
| // consumer can observe a binding naming a graph this load overwrites. | ||
| useDocumentActivationStore().deactivate() |
There was a problem hiding this comment.
🟠 High — This deactivation is unconditional, but nothing restores the binding on load paths that bail before afterLoadNewGraph — loadGraphData returning false when rootGraph.configure() throws, the A1111 core-nodes-unavailable/not-a1111 early returns, or a throw in the pre-load work such as changeTracker.deactivate(). The canvas still shows an editable graph while activeRootGraphId() stays null, so the fail-closed gate drops every root-scoped edit until the next successful load. Raised by 2 of 8 reviewers (claude-opus-5-thinking-max edge-case, gpt-5.6-sol-max edge-case).
There was a problem hiding this comment.
Confirmed for the pre-load throw, fixed in 08e3674. The other two cases I checked and they do not reach this line.
Fix: deactivate() is now the last statement of beforeLoadNewGraph instead of the first. Nothing in the body touches the shared root graph (draft persistence, warning caching, preview stashing, thumbnail, viewport save), so retracting after it is just as safe, and a throw in there aborts the load with the outgoing graph still on the canvas, where its binding is still the honest one. Test: workflowService.test.ts "keeps the outgoing binding when the pre-load capture throws" (red before), plus "retracts the outgoing binding before the shared graph is touched" so the ordering stays pinned.
A1111: importA1111 returns not-a1111 and core-nodes-unavailable before it invokes beforeGraphClear, which is the callback that runs beforeLoadNewGraph (see pnginfo.ts, the early returns are above the await beforeGraphClear?.() call site, and every outcome after it is imported or imported-without-embeddings, both of which reach afterLoadNewGraph). So those returns never retract anything.
rootGraph.configure() throwing: real, but the consequence is not specific to activation. That path never fires afterConfigureGraph, so the mint load bracket stays open and session.inTeardown() suppresses every mint, root-scoped or not, until the next load's paired hook closes it. That is the documented pre-existing fail-closed posture of the bracket, and the next successful load re-activates. I left it as is rather than inventing a recovery activation, because on that path the canvas holds a partially configured graph whose identity nobody has established.
| operation: LayoutChangeView['operation'], | ||
| action: 'create' | 'delete' | 'clear' | ||
| ): boolean { | ||
| if (operation.graphId === undefined) return true |
There was a problem hiding this comment.
🟡 Medium — A change with no graphId returns true and bypasses activation targeting entirely, including during the no-document handoff window this guard exists to close. The comment defers such changes to the root-vs-subgraph classifier above, but that classifier also returns false for graphId === undefined (it compares equal to an undefined ownerGraphId), so nothing rejects it — the new leaves a change with no graph id to the root-vs-subgraph classifier test pins the bypass. Given the stated fail-closed policy, the unclassifiable case should be the one that drops and reports. Raised by 6 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gemini-3.1-pro adversarial, gemini-3.1-pro edge-case, gpt-5.6-sol-max adversarial, kimi-k3-max adversarial).
There was a problem hiding this comment.
Confirmed as a fail-open hole in the port, fixed in 08e3674, with the caveat that it was not reachable from production.
You are right that the two gates together let it through: the classifier returns false for an undefined graphId and the targeting rule returned true, so an unattributable change minted into whatever document was bound. The reason it never bit is that graphId is required on the store's OperationMeta, so every real LayoutOperation carries one. The optionality lived only in this port's structural view of the change.
So rather than add a third drop branch, I made the view mirror the contract: LayoutChangeView.operation.graphId is now string, not string?. Both undefined branches are gone (isForActivatedDocument and reportUnrepresentableInteriorChange), the compiler enforces it at the seam, and the "leaves a change with no graph id to the root-vs-subgraph classifier" test is deleted rather than inverted. The fixtures across layoutMintPort.test.ts and mintPortWiring.test.ts now carry real graph ids, which also makes them faithful to what the store emits.
Related ordering change in the same commit: for createNode/deleteNode the activation check now runs before the root-vs-subgraph classification. A change for a graph the activated document does not own should be reported as that, not as a subgraph divergence, and it stops a tab switch away from a subgraph-heavy tab from reporting false divergence.
| localActorPrefix: deps.localActorPrefix, | ||
| isEnabled: deps.isEnabled, | ||
| isDocBound: deps.isDocBound, | ||
| activeRootGraphId: deps.activeRootGraphId, |
There was a problem hiding this comment.
🟡 Medium — activeRootGraphId is threaded only into the layout port: attachWidgetMintPort still re-derives its scope from the live canvas graph via deps.getGraph() — the exact re-derivation the new dep's doc comment calls unsafe across an in-place reconfigure — and attachLinkMintPort has no graph check at all. The asymmetry is worse than the prior uniform behavior: node creates are now dropped while set_widget and connect still mint, producing ops that reference nodes absent from that document. Raised by 3 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gpt-5.6-sol-max edge-case).
There was a problem hiding this comment.
Confirmed, and the asymmetry argument is what convinced me to fix it here rather than defer. Fixed in 08e3674.
Widget port: rootGraphId is now deps.activeRootGraphId, so it no longer re-derives from deps.getGraph(). A root-scoped write still mints the root form, an interior write still resolves its path over the live graph, and a write whose owner cannot be resolved against the activated root surfaces instead of minting.
Link port: it takes activeRootGraphId() and drops a connect whose scope.rootGraphId is not the activated root, surfacing it the same way it surfaces a subgraph-interior connect. onDeleted folds the same check into mintable, so a foreign severance is captured but never handed to a delete_node as removed_links and never surfaced as this document's divergence.
The window this actually closes is the one in the afterLoadNewGraph thread: between afterConfigureGraph (bracket open again) and workflowStore.openWorkflow resolving, the canvas holds the incoming graph while the outgoing workflow is still the active and bound one. Layout creates were already failing closed there; connect and set_widget were minting into the outgoing document with the incoming graph's node ids.
Test: mintPortWiring.test.ts "every port targets the activated document, not the live canvas graph" drives the real link and widget stores with the live graph still on ROOT_ID and nothing activated, and asserts zero mints from all three ports. Red before. Link port also has unit coverage for the foreign scope, the null activation and the non-mintable severance.
| if (!gate(change, inTeardown || captured === null)) return | ||
| // clearGraph is root-scoped by construction (layoutStore.clearGraph | ||
| // takes a root graph id), so its own graphId classifies it. | ||
| if (!isForActivatedDocument(operation, 'clear')) return |
There was a problem hiding this comment.
🟡 Medium — intentionalClearNodes is read and nulled at lines 251-252, before this drop, so a stale or foreign clearGraph dropped here still consumes the intentional-clear capture; the genuine clear that follows sees captured === null, is treated as teardown by gate, and never reaches the wire. Move the activation check above the capture consumption — and note that dropping a clear leaves the entire previous node set resident in the document, a far larger divergence than dropping a single node op. Raised by 2 of 8 reviewers (kimi-k3-max adversarial, claude-opus-5-thinking-max adversarial).
There was a problem hiding this comment.
Confirmed and fixed in 08e3674, including the "a dropped clear is a bigger divergence" point.
The clearGraph case now decides targeting before it consumes anything. Order is: local-human provenance, then the targeting check, then consume the capture, then the flag/teardown gate. A stale or foreign clear now returns with the capture intact, so the genuine clear that follows still sees its pre-clear node set and mints.
Splitting the gate was needed to get that order right: gate() mixed provenance with shouldMint, and shouldMint needs captured === null to compute teardown, so the provenance half is now isLocalHumanChange(), checked first. That also keeps a remote apply or another actor's clear from reporting a targeting drop it was never eligible for.
Test: "a foreign clear never consumes the intentional-clear capture" delivers the foreign clear and then the genuine one inside one runIntentionalClear window and asserts the clear mints with the captured nodes. Red before, green after. The same restructure carries the pre-clear root graph id in the window, which is what makes the Clear Workflow rebind work (see the workflowService.ts Clear Workflow thread).
| ): boolean { | ||
| if (operation.graphId === undefined) return true | ||
| const activeRootGraphId = deps.activeRootGraphId() | ||
| if (operation.graphId === activeRootGraphId) return true |
There was a problem hiding this comment.
🟡 Medium — This treats the persisted root graph UUID as document identity, but LGraph.configure() adopts the workflow file's serialized id and a Save-As or externally duplicated workflow keeps it, so two tabs can carry identical root graph ids. A change queued before a switch between such tabs compares equal here and is enqueued into the other tab's document — the cross-document corruption this gate exists to prevent. Compare document identity or a stamped activation generation rather than the persisted graph id alone. Raised by 3 of 8 reviewers (gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case, kimi-k3-max edge-case).
There was a problem hiding this comment.
Pushing back on this one, so no code change. The mechanism you describe is real, but the named reproduction is not, and the remedy belongs elsewhere.
LGraph.configure() does adopt the file's serialized id, but both duplication paths remint before the load: workflowStore.saveAs generates a fresh id and writes it into the copied state ("Generate new id when saving existing workflow as a new file"), and duplicateWorkflow does state.id = generateUUID() for the same reason. Same-path reopens are deduped by getWorkflowByPath, so two tabs sharing a root graph id needs files that were copied outside the app and still carry the same serialized id.
In that state the collision is much deeper than op targeting. The root graph id is the ECS scope key: layout entries are keyed by makeScopedLayoutKey(graphId, nodeId), and widgetValueStore, linkStore, linkPresentationStore, rerouteStore, nodeDataStore, executionOrderStore and layoutStore are all cleared and addressed by that id. Two open tabs with the same id already share and clear each other's state, so tightening this one comparison would hide a broken state rather than fix it. The fix is at load-time identity: remint when the incoming workflow's id is already held by another open tab. That is a behavior change to workflow loading, outside this PR, and I would rather file it than smuggle it in here.
On the suggested alternative: a stamped activation generation cannot be compared here either, because the change carries no stamp. LayoutChange is queued with operation.graphId and nothing else identifying when it was enqueued, so the port only ever sees ids. Stamping would have to happen in the layout store at applyOperation time, which means teaching the renderer about activation.
Happy to file the load-time dedupe ticket if you agree with that split.
| shareId?: string | ||
| ) => { | ||
| await activateLoadedWorkflow(value, workflowData, shareId) | ||
| await activateLoadedDocument() |
There was a problem hiding this comment.
🟡 Medium — Activation lands after activateLoadedWorkflow's awaits (which include workflowStore.openWorkflow I/O), but the mint teardown bracket has already reopened from the afterConfigureGraph hook via notifyMintPortsAfterGraphConfigure(). Layout changes delivered in that window see mints enabled and activeRootGraphId() === null, so they are silently dropped, and if activateLoadedWorkflow throws, activation never runs at all. Raised by 1 of 8 reviewers (claude-opus-5-thinking-max edge-case).
There was a problem hiding this comment.
Window confirmed, and it is now fail-closed everywhere instead of asymmetric. The throw half I read the other way.
The window: 08e3674 makes all three ports apply the same targeting rule, so nothing mints into the outgoing document between the bracket reopening and activation landing. Layout already dropped there; connect and set_widget were the leak (see the mintPortWiring.ts thread). A load that ends with nothing activated now reports rather than going quiet.
Closing the window entirely means closing the mint bracket after activation instead of on the afterConfigureGraph extension hook. I did not do that here: the bracket is driven from extensions/core/agentPanel.ts precisely so platform/workflow does not import the workbench mint wiring, and moving the call into afterLoadNewGraph crosses that boundary (import-x/no-restricted-paths). Activating earlier is not available either, because the incoming documentId comes from activeWorkflow, which activateLoadedWorkflow's openWorkflow is what sets. Follow-up candidate, and worth doing as its own change.
The throw: activating in a finally would be a mispairing, not a recovery. If activateLoadedWorkflow throws, activeWorkflow can still be the outgoing workflow while app.rootGraph already carries the incoming graph, so the fallback would publish {outgoing document, incoming graph} and every change on the new graph would mint into the old document. That is the exact corruption this seam exists to prevent, so leaving the binding retracted is the correct outcome, and the throw itself propagates out of loadGraphData to the caller's error handling.
| view = { documentId, rootGraphId } | ||
| }, | ||
| detach(documentId) { | ||
| if (view?.documentId === documentId) view = null |
There was a problem hiding this comment.
🟢 Low — detach compares only documentId while attach captures rootGraphId, so if a document is re-activated with a rotated graph id and a stale binding's detach runs after the new attach, it nullifies the freshly published view and activeRootGraphId() goes null while that document is still active. Compare the captured rootGraphId too, so a binding can only retract what it published. Raised by 2 of 8 reviewers (gemini-3.1-pro adversarial, gemini-3.1-pro edge-case).
There was a problem hiding this comment.
Right invariant, and fixed in 08e3674, but with binding identity rather than the captured rootGraphId.
Comparing the captured id would have broken the rebind added for Clear Workflow: rebindActiveScope republishes the same document on a reminted root id while the coordinator still holds the binding that attached with the old one, so the stored binding's captured id would no longer match the published view and a later deactivate() would leave a stale binding published forever. That is a worse failure than the one being fixed.
So the view now records the binding that published it, and detach clears only its own: if (view?.documentId === documentId && view.binding === binding). That is the invariant you were reaching for ("a binding can only retract what it published") and it survives an in-place rebind.
Honest about the evidence: I could not construct a reachable sequence on the current coordinator, so there is no red-before test. Every detach call site uses the binding stored with the active entry (previous.binding.detach in activate, previous.binding.detach in deactivate), and this host's attach is a plain assignment that cannot re-enter, so the stale-detach path needs a future binding that can. The guard costs one reference comparison and the DocumentViewBinding contract explicitly allows the coordinator to detach a superseded binding, so it is worth having regardless. Pinned in the other direction by the host test "still retracts on the next load after a rebind", which fails if the identity check strands a rebound view.
Activation targeting was reachable only through the load path, and three graph swaps do not go through it. - Clear Workflow remints the root graph id in place (LGraph.clear), so the activated document kept naming the pre-clear graph and every later op was dropped as foreign. app.clean() now republishes the same document on the reminted id, and an intentional-clear window validates the clearGraph change against the id captured when it opened (the clear remints under it). - beforeLoadNewGraph retracts last, not first: a throw while capturing tab state aborts the load with the outgoing graph still on the canvas, where its binding is still the honest one. - The load path declares the document loaded before asking for the canvas, so the coordinator's isLoaded precondition is a real check instead of one the request itself satisfied, and scope is committed only by the handoff that won - a superseded activation no longer stamps its document with a graph id the winner already owns. - A load that ends with no activation reports instead of leaving op targeting silently fail-closed until the next load. - A layout change with no graphId can no longer bypass targeting: the view type now requires it, as the store's own LayoutOperation does. - The link and widget ports target the activated document too, instead of re-deriving scope from the live canvas graph. Node creates failing closed while connect and set_widget kept minting was the asymmetry. - Only the binding that published a view may retract it, so a stale detach cannot nullify a freshly published one. Claude-Session: https://claude.ai/code/session_01U73XrPUkU81hiq71XZY4mr
…t guard Covers the activation guard with the graph UUIDs from a 2026-09-22 cloud-frontend-staging Sentry report (createNode targeting a foreign graph while a different root graph is bound/activated), instead of only synthetic placeholder ids.
|
Added a regression test using real production data: commit The UUIDs are from an actual cloud-frontend-staging Sentry alert (2026-09-22): a All 41 tests in the file pass, along with Generated by Claude Code |
dante01yoon
left a comment
There was a problem hiding this comment.
Reviewed at 8abb84ba. Stacked PR — base is feat/graph-document-activation-seam (#16375), so I diffed against that branch, not main.
The design reads well: one owner for "which document holds the canvas", consumers reading instead of re-deriving, and the handoff window made explicitly empty rather than racy. The adversarial panel's findings were answered substantively, and the fixes are real rather than cosmetic — I checked them rather than taking the replies at face value.
What I verified in a worktree at the PR head
- 94 tests pass across the five new/changed test files I could execute (
documentActivationHost,tabSwitchActivation,layoutMintPort,linkMintPort,mintPortWiring). - Mutation-tested five of the new guards rather than trusting green. Load-bearing: the targeting rule (11 tests red), the
clearGraphorder fix (1),commitScopeonly onactivated(2), anddeactivate()'s in-flight cancellation (5). The one mutation that survives is droppingview.binding === bindingfromdetach— which is exactly what you said in that thread ("I could not construct a reachable sequence on the current coordinator, so there is no red-before test"). I agree the guard is worth keeping; the mutation just confirms your own account, it isn't a new ask. - Your pushback on the
rootGraph.configure()throw holds.afterConfigureGraphis invoked atapp.ts:1566, after thereturn falseatapp.ts:1505, so the bracket never closes on that path andinTeardown()suppresses every mint regardless of activation. The deactivation is not the operative cause there. - The required-
graphIdnarrowing mirrors the real contract:OperationMeta.graphId: UUIDis non-optional atsrc/renderer/core/layout/types.ts:124. commitScopeaftermarkLoadeddoes land the scope: the reducer'shydratedonly movescreated → loaded, sohydrateDocumentno-ops andrebindScopeperforms the write.- The Clear Workflow rebind is inert during loads, as documented: both in-load
clean()calls (app.ts:1322,app.ts:2341) run afterbeforeLoadNewGraphhas retracted. vue-tsc --noEmit: 28 errors, allTS2307missing-module (vuefire,jsonata) from an incompletenode_modulesin my environment, none in any changed file, and no other error class. CI's typecheck gate is green.
What I could not run, and why it matters for how much weight to give the above: the same missing modules meant workflowService.test.ts and app.test.ts would not load (they fail identically on the stack base, so it is environmental). I read both diffs instead — they do cover the Clear Workflow rebind and the four load-path endings, and they look well-pinned — but I have not executed them.
One item inline that blocks the stack rather than this merge, plus two non-blocking notes.
| // The activation host, not a second derivation off the live canvas graph: | ||
| // the shared `LGraph` already carries the incoming tab's id while the | ||
| // outgoing document is still the bound one. | ||
| rootGraphId: deps.activeRootGraphId, |
There was a problem hiding this comment.
issue: #18109 merged into main on 2026-09-22 04:10 UTC and this branch does not contain it, so as written, landing this stack reverts a shipped fix for the same bug.
What I checked:
git merge-base --is-ancestor f664247 origin/main→ yes. Againstorigin/pr-18326→ no. Against feat(agent): add GraphDocument registry and activation seam #16375's head → also no.boundRootGraphIdappears 11× inmain'slayoutMintPort.ts, 2× inmintPortWiring.ts, 2× inAgentPanelRoot.vue— and 0× anywhere on this branch.- fix(agent-crdt): scope layout mint ops to the bound document's root graph #18109's per-root mint dedupe (
mintedNodeIdsByRoot/mintedNodeIdsForRoot,main'slayoutMintPort.ts:119-125and:244) has no counterpart here.mintedNodeIdsdoes not exist on this branch at all, and did not exist at the stack base either, so it is purely fix(agent-crdt): scope layout mint ops to the bound document's root graph #18109's — it would be lost on a conflict resolution that favours this side, not merged.
The three production files this PR rewrites are exactly the three #18109 changed, and it rewrites the same functions, so this is the shape of conflict that tends to get resolved wholesale in one direction.
The PR body already anticipates this — "Whichever lands second should do that collapse" — and it was accurate when written. #18109 has since landed, and the newest commit here (8abb84ba, 2026-09-23) came about 22 hours after that merge without integrating it.
To be clear about severity: this does not block merging into feat/graph-document-activation-seam, since nothing reaches main yet. It blocks the stack. Could we either do the collapse here, or state where it will happen — a rebase of #16375 onto post-#18109 main? My concern is that otherwise the reconciliation gets decided by whoever resolves the conflict, and the dedupe is the easy half to drop silently.
There was a problem hiding this comment.
Confirmed both halves of this, collapse done in 3283a84 (pushed to this branch).
What I checked against main's current layoutMintPort.ts (git show origin/main:src/workbench/extensions/agent/crdt/layoutMintPort.ts, at f664247):
- Targeting:
boundRootGraphId()is fully subsumed here, not just replaced.main'sforeignBoundRootGraphId/reportOpForUnboundGraphreject an op whosegraphIddoesn't match the bound document's stored root id; this branch'sisForActivatedDocument/activeRootGraphId()does the same comparison through the activation coordinator instead of a workflow-store accessor, and is strictly stricter (fails closed onnullwheremain'sboundRootGraphId() === nulllets an unclassifiable op through — see the separate thread on that). So no gap there. - Dedupe: genuinely missing, exactly as you found.
mintedNodeIdsByRoot/mintedNodeIdsForRoot(main:119-127) is aMap<graphId, Set<nodeId>>that: (1) inhandleCreateNode, skips a create whose id is already in that graph's set (a redo, or a create replaying while switching between two tabs bound to the same root graph) and adds the id once minted; (2) inhandleDeleteNode, evicts the id from its own graph's set on any root-owned delete, unconditionally, before any gating — so a later replay can re-mint; (3) inhandleClearGraph, forgets the whole bucket only on an intentional (human-confirmed) clear, never on an incidental one (a tab switch reconfiguring the shared canvas graph in place). I grepped this branch formintedNodeIds/dedupe— nothing, confirming it isn't just renamed.
Ported into layoutMintPort.ts (not pasted — adapted to this branch's mechanism):
- Same
Map<string, Set<string>>, but keyed byoperation.graphIddirectly rather than aboundRootGraphId()-style accessor read. That's a deliberate simplification, not a shortcut: by the timecreateNode/deleteNodereach the bucket lookup,isForActivatedDocumenthas already guaranteedoperation.graphId === activeRootGraphId(), andgraphIdisstring(required) on this branch'sLayoutChangeView, notstring | nullas onmain. So the "two graphs share the null-keyed bucket while the accessor is unresolved" edge casemain's tests guard against can't arise here — activation fails closed instead of returning an ambiguous key. createNode: dedupe check placed aftergate/isForActivatedDocument/reportUnrepresentableInteriorChange, same ordering asmain.deleteNode: eviction moved to the top of the case, unconditional onownerGraphId === graphId, same asmain's placement relative to its own gate/targeting checks.clearGraph: bucket forgotten only whencaptured !== null(insiderunIntentionalClear), placed right after the capture is consumed and before the finalgatecall.
Tests added to layoutMintPort.test.ts (all red before this commit, green after):
skips a redo that recreates an already-minted node instead of re-minting add_nodemints add_node again for the same id after a delete_node clears the dedupe entryforgets the dedupe bucket on an intentional clear, so a later create re-mintsdoes not let an incidental clearGraph forget the dedupe bucket (regression)does not re-mint a root graph replay after switching away and back to it (regression)— the actual two-tabs-same-root-graph scenario fix(agent-crdt): scope layout mint ops to the bound document's root graph #18109 was fixed for, ported to this branch'sactiveRootGraphIdfixture (switchACTIVATED→OTHER→ back toACTIVATED, assert the replay on return mints nothing whileOTHER's own create for the same colliding node id still mints from its own bucket)
45/45 tests pass in layoutMintPort.test.ts; pnpm typecheck and pnpm lint are clean. mintPortWiring.ts/AgentPanelRoot.vue needed no changes — on main those two files only pass boundRootGraphId through as a wiring dependency, the dedupe itself lives entirely in layoutMintPort.ts, and the same is true here with activeRootGraphId.
(AgentPanelRoot.test.ts has 3 pre-existing, unrelated failures on this branch — media-card attachment/upload tests failing on a Blob.stream is not a function environment issue — confirmed present on the pre-fix commit too via git stash, not something this change touches.)
Generated by Claude Code
| * reads as "the agent quietly stopped seeing my edits". | ||
| */ | ||
| const activateLoadedDocument = async (): Promise<void> => { | ||
| if (!app.isGraphReady) return |
There was a problem hiding this comment.
suggestion: this is the one ending that leaves nothing activated and reports nothing, which reads against the invariant the doc comment just above states — "A load that ends without an activation leaves op targeting fail-closed until the next load, so every such ending is reported: silence there reads as 'the agent quietly stopped seeing my edits'." The documentId branch below and the rejected branch both report; this one returns bare.
I believe it is unreachable in practice: every afterLoadNewGraph call site runs after rootGraph.configure(), so rootGraphInternal is set by then, and I could not find a path that reaches here with it unset. So this is about keeping the stated invariant true rather than closing a live gap — a reportError here (or a comment saying why this ending is exempt) would make the comment and the code agree.
There was a problem hiding this comment.
Confirmed unreachable in production: rootGraphInternal is assigned exactly once, at app.ts:1009 during initial setup(), and never reset anywhere else. Every afterLoadNewGraph call site is a method invoked on an already-set-up app instance, so isGraphReady is always true by the time this runs.
Went with the comment option rather than reportError, since adding telemetry for a branch that can't fire would just be noise. Added in 6514962:
// Exempt from the invariant above: `rootGraphInternal` is set once at
// app setup, before any load path can reach here, so this never fires.
if (!app.isGraphReady) returnGenerated by Claude Code
| if (!gateOpen()) return | ||
| if (!isForActivatedDocument(scope)) { | ||
| surfaceUnrepresentable( | ||
| 'connect on a graph the activated document does not own', |
There was a problem hiding this comment.
suggestion: this new drop path logs one undeduped console.error per link, while the layout port's equivalent new drop path goes through createOncePerTickReporter — added in this same PR, with the comment "a tab switch emits a change per node, and each would otherwise report separately". Link placement has the same burst shape: onPlaced fires per registerLink/replaceLink, and a reconfigure registers every link in the workflow.
Honest caveat on how much this matters: I could not demonstrate the burst. Configure-time registerLink calls land inside the still-open mint bracket, so gateOpen() is false and nothing surfaces; the exposed window is only the narrow one between afterConfigureGraph closing the bracket and activation landing. So this may stay theoretical. It is cheap to make symmetric, though, and the helper is right there.
Related and smaller, in the same spirit: widgetMintPort's console.error now also fires with root === null during a handoff, where its message ("set_widget with an unresolvable owner ... the bound doc diverges from the local graph") names the wrong cause — mid-handoff is not divergence.
There was a problem hiding this comment.
Both fixed in 6514962.
Link port: added a local createOncePerTickReporter mirroring the layout port's, and wired it around the new isForActivatedDocument drop in onPlaced, keyed by `connect:${scope.rootGraphId}:${deps.activeRootGraphId()}` so a burst on the same graph pair reports once, same as the layout port's reportInactiveChangeOnce.
widgetMintPort: the console.error now distinguishes the two causes instead of always blaming divergence:
console.error(
root === null
? '[agent-crdt] set_widget with no activated document (load handoff in progress); not minted'
: '[agent-crdt] set_widget with an unresolvable owner not minted; the bound doc diverges from the local graph',
`${set.graphId}:${String(set.nodeId)}:${set.name}`
)The actual-divergence message (resolveInteriorPath returning null/empty for a real graph) is unchanged.
Generated by Claude Code
| } | ||
| ) | ||
|
|
||
| it('refuses a createNode targeting a foreign graph (real cloud-frontend-staging Sentry data)', () => { |
There was a problem hiding this comment.
nit-pick (non-blocking): this case asserts exactly what the it.for immediately above it already asserts for createNode — same activeRootGraphId, same rootScoped(...) delivery, same two expectations. Only the id strings differ, and the guard is a === string comparison, so UUID-shaped ids exercise no path the placeholder ids miss. As the whole content of its own commit, it adds a maintenance point without adding coverage.
The provenance is genuinely worth keeping. Could the Sentry reference live as a comment on the existing parametrized case ("real ids from a 2026-09-22 cloud-frontend-staging report: …") rather than as a separate case?
There was a problem hiding this comment.
Agreed, done in 6514962. Removed the separate it block and moved the Sentry provenance onto the it.for case as a comment instead:
// ACTIVATED/OTHER stand in for real UUIDs seen in a 2026-09-22
// cloud-frontend-staging Sentry report (27ca8666-fa2b-4ef9-99bc-e005182fadc6 /
// 84826d7d-1b25-4cfb-9d59-2747a4b09a19); the guard is a plain string
// comparison, so the placeholders exercise the same path.
it.for(['createNode', 'deleteNode', 'clearGraph'] as const)(
'drops a root-scoped %s naming a graph the activated document does not own',
...Generated by Claude Code
- workflowService.ts: document why activateLoadedDocument's isGraphReady guard is unreachable in production (rootGraphInternal is set once at app setup, before any load path can reach it), rather than adding a reportError to an invariant-only branch. - layoutMintPort.test.ts: drop the duplicate real-UUID test case for the foreign-graph mint guard; the real Sentry ids now live as a provenance comment on the existing parametrized case instead. - linkMintPort.ts: dedupe the new foreign-graph connect drop with the same createOncePerTickReporter pattern the layout port uses, so a burst of drops on the same graph pair reports once. - widgetMintPort.ts: distinguish the mid-handoff (root === null) case from actual doc divergence in the unresolvable-owner console.error.
…ased targeting #18109 landed on main after this branch forked, adding boundRootGraphId() targeting plus a mintedNodeIdsByRoot dedupe to stop a replayed createNode (litegraph undo/redo, or a create op replaying across two tabs bound to the same root graph) from minting a second add_node for a node the doc already has. This branch's rewrite replaced boundRootGraphId() with the activation coordinator's isForActivatedDocument()/activeRootGraphId(), which subsumes #18109's targeting check, but carried none of its dedupe forward. Port the dedupe into attachLayoutMintPort, keyed by the operation's own graphId (guaranteed to be the activated document's by the time a create or delete reaches the bucket, since isForActivatedDocument already filtered): - createNode skips a replay for an id this port already relayed, and records newly-minted ids in that graph's bucket - deleteNode evicts the id from its own-graph bucket whenever a root-owned delete fires, independent of gating, so a later replay can re-mint - an intentional (human-confirmed) clear forgets the whole bucket; an incidental clearGraph (tab-switch reconfiguring the shared canvas graph in place) leaves it alone
dante01yoon
left a comment
There was a problem hiding this comment.
Re-reviewed the delta 8abb84ba..3283a842 (5 files, +159/-25) rather than the whole PR. All four items from my last review are addressed, and I checked each rather than reading the commit messages:
- #18109's dedupe (the one that blocked the stack) — ported.
mintedNodeIdsByRoot/mintedNodeIdsForRootare present (5× / 2×, againstmain's 6× / 2×), with five new regression tests. Keying onoperation.graphIdinstead ofmain'sboundRootGraphIdis a genuine improvement, not just a transcription: by the time a create reaches the bucket lookup,isForActivatedDocumenthas already established that the key names the activated document, so the ambiguous "activation unresolved" casemainhad to special-case can't arise. The comment says exactly this, and it's right. workflowService.ts:696— took the comment option I offered; the stated invariant and the code now agree.linkMintPort.ts— now routed through a once-per-tick reporter, symmetric with the layout port.widgetMintPort.ts— the message now distinguishesroot === null(handoff in progress) from a genuinely diverged doc.- The test nit — handled better than I asked: the redundant case is gone, the Sentry provenance survives as a comment on the parametrized case, and the slot now holds a real switch-away-and-back regression test.
Validation (isolated worktree at 3283a842):
| What | Result |
|---|---|
5 runnable suites (documentActivationHost, tabSwitchActivation, layoutMintPort, linkMintPort, mintPortWiring) |
98 passed (was 94) |
| Mutation test, 3 new dedupe guards | 2 load-bearing (3 red / 1 red), 1 survives |
| Probe: delete while deactivated, then reactivate | fails on the current head |
Two findings inline, both in the deleteNode forget block. The first is a correctness gap I'd like resolved before this lands — it narrows, but does not close, the hole #18109 fixed, which makes it worth flagging given preserving that fix is exactly what the newest commit set out to do. I've included the probe and what I think is a one-line fix, plus an honest note on how far I could establish reachability.
What I still could not run, unchanged from last time and still environmental: workflowService.test.ts and app.test.ts fail to load with Failed to resolve import "vuefire" — that package is genuinely absent from my node_modules, and both files fail identically on the stack base. I read both diffs again; they cover the Clear Workflow rebind and the four load-path endings and look well-pinned, but I have not executed them. CI's gates are green on this SHA.
| // so it must not forget an entry from the root's bucket for what is | ||
| // really a different node's namespace. | ||
| if (operation.nodeId === undefined) return | ||
| if (operation.ownerGraphId === operation.graphId) { |
There was a problem hiding this comment.
issue: the forget runs before the targeting check, which reintroduces #18109's double-mint when a root-owned delete names a graph that is not the activated document.
The comment above argues the forget must be unconditional because "the document lost this id the moment a same-graph, root-owned deleteNode change fired, regardless of whether this port also gates the delete_node op for echo-suppression, targeting, or teardown". That holds for echo-suppression and teardown — but not for targeting. Targeting drops the op precisely because the op belongs to a different document, so the doc named by operation.graphId is never written and does not lose the node. The bucket forgets an id the doc still holds.
I probed it at the port's own boundary, in the activation-scoped targeting describe:
it('PROBE2: delete while deactivated then reactivate', () => {
activeRootGraphId = ACTIVATED
deliver(rootScoped('createNode', ACTIVATED, '1'))
expect(minted).toHaveLength(1)
activeRootGraphId = OTHER
minted.length = 0
deliver(rootScoped('deleteNode', ACTIVATED, '1'))
expect(minted).toEqual([]) // passes: delete_node correctly dropped
activeRootGraphId = ACTIVATED
minted.length = 0
deliver(rootScoped('createNode', ACTIVATED, '1'))
expect(minted).toEqual([]) // FAILS on the current head
})Last assertion on 3283a84:
AssertionError: expected [ { op: 'add_node', …(4) } ] to deeply equal []
A second add_node for a node the doc already has — the exact shape #18109 fixed.
The fix looks like one line of movement: put the forget after isForActivatedDocument on line 297 and leave it above the gate on line 296. That keeps your stated reasoning intact — echo-suppression and teardown still don't block the forget — and only lets targeting, the one gate that means "this write isn't happening", condition it.
Reachability caveat, so you can weigh this properly: I demonstrated the gap at the port's API, not through the app. For a real sequence you need a root-owned per-node deleteNode to fire while a different root graph is activated. A tab switch reconfiguring the shared graph in place goes through the incidental clearGraph path instead, which you deliberately keep bucket-preserving — so it may be that nothing currently emits a root-owned per-node delete against a non-activated root. You know the change sources here far better than I do. I'd still move the line: it costs nothing and removes the need to keep that argument true as more root graphs become independently activatable, which is the whole direction of this stack.
There was a problem hiding this comment.
Thanks for the probe, fixed. In the deleteNode case, gated and forActivatedDocument are each computed exactly once now: gated = gate(change, inTeardown), then forActivatedDocument = !gated || isForActivatedDocument(operation, 'delete'). The || short-circuits, so isForActivatedDocument is never called once gated is already false, which avoids spurious op_for_inactive_document reports during ordinary echo/teardown gating.
The forget is now conditioned on operation.ownerGraphId === operation.graphId && forActivatedDocument, instead of running unconditionally on the ownership check alone, so a root-owned delete naming a graph that isn't the activated document no longer forgets the bucket. The enqueue path reuses the same two values rather than recomputing them.
Your probe is now 'does not re-mint a node whose delete was dropped for naming a non-activated graph (regression)' in layoutMintPort.test.ts, in the activation-scoped targeting describe block. Confirmed it fails red against the pre-fix code and passes green now.
Generated by Claude Code
| mintedNodeIdsByRoot | ||
| .get(operation.graphId) | ||
| ?.delete(String(operation.nodeId)) | ||
| } |
There was a problem hiding this comment.
suggestion (non-blocking): this condition is the one new guard in the commit that survives mutation — no test goes red without it.
I mutation-tested the three guards added here, the same way as last time:
| Mutation | Result |
|---|---|
drop if (mintedNodeIds.has(nodeIdKey)) return (line 259) |
3 tests red |
replace this condition with if (true) |
45 passed — survives |
make the clear forget unconditional (drop captured !== null, line 325) |
1 test red |
Unlike the surviving mutation in my last review, this one is cheaply constructible — the file already builds interior-scoped ops with ownerGraphId: 'subgraph' (lines 123, 143, 157). This passes on the current head and goes red under the mutation:
it('does not let an interior delete forget the root bucket', () => {
activeRootGraphId = ACTIVATED
deliver(rootScoped('createNode', ACTIVATED, '1'))
expect(minted).toHaveLength(1)
minted.length = 0
// Same root graphId, owned by a subgraph: a different node's namespace
// that happens to reuse the id string '1'.
deliver({
operation: {
type: 'deleteNode',
actor: LOCAL_ACTOR,
graphId: ACTIVATED,
ownerGraphId: 'subgraph',
nodeId: '1',
layout: { position: { x: 1, y: 2 } }
}
} as unknown as LayoutChangeView)
minted.length = 0
deliver(rootScoped('createNode', ACTIVATED, '1'))
expect(minted).toEqual([])
})Without the guard it fails with expected [ { op: 'add_node', …(4) } ] to deeply equal []. Your comment already states this invariant precisely; this just stops a later simplification from quietly deleting it.
There was a problem hiding this comment.
Added essentially as suggested: an interior delete on the same root graphId, with a node id that collides with one minted at the root, exercising the operation.ownerGraphId === operation.graphId guard on its own. Test is 'does not let an interior delete forget the root bucket' in layoutMintPort.test.ts, same describe block as the other new test.
Confirmed it fails under the if (true) mutation of that guard (the interior delete wrongly forgets the root's bucket) and passes against current code.
Generated by Claude Code
…ally lost the node
cf2ed3a to
14ed1dc
Compare
dante01yoon
left a comment
There was a problem hiding this comment.
Re-reviewed the current head after the follow-up. The blocking delete/dedupe path is fixed: a foreign root-owned delete no longer evicts the activated document’s dedupe entry, and the added regression reproduces the prior second-add_node failure. The interior-delete guard is now pinned as well. The activation-scoped targeting, clear rebind, and #18109 dedupe reconciliation remain coherent at this head. Hosted typecheck, lint, unit, E2E, and matrix gates are green; the cancelled snapshot/merge jobs are non-required workflow artifacts.
DrJKL
left a comment
There was a problem hiding this comment.
I did a fresh deep pass at 14ed1dc5 against the effective stacked base, including the load/activation interleavings and all three mint ports. Reluctant approval: I found no issue that should block this PR. The two concrete correctness gaps below are narrow enough to follow up without holding the stack, but they are real and have focused red probes.
Findings without a clean inline anchor
- P2, concurrent direct loads remain completion-ordered. A focused workflow-service probe that starts A, starts B, resolves B, then resolves A leaves A active. Normal
openWorkflow()calls are serialized, so this does not defeat the common tab-switch path. Several directapp.loadGraphData()callers remain outside that queue, though. An app-level test with two real overlapping loads would settle production reachability. I would keep the PR's existing explicit tradeoff, but narrow the body claim that common interleavings converge. - P3, duplicate serialized root IDs remain a systemic identity hole. Save As and in-app duplicate both remint IDs, so the earlier Save-As reproduction is false. Externally copied files can still collide, but the existing ECS stores already key by root ID and alias in that state. This PR should not grow a local activation-generation protocol to hide that broader load-time identity bug. The body should say the guard rejects differing root IDs, not that wrong-document mints are unrepresentable.
- P3, targeting policy now has three owners. Layout, link, and widget ports independently compare activation state and report mismatches; layout and link also copy the same once-per-tick reporter. The behavior is coherent at this head, but the next targeting change has to land three times. A shared predicate/reporter at the wiring seam would reduce that drift.
- P3, the PR description is stale.
app.tsis touched, winner-only scope commit fixed the statedbindScopetradeoff, #18109's dedupe is now integrated, and the stated test counts/results no longer match this head. Please refresh it before the stack lands.
Existing findings checked
- Missing
graphId, rejected/superseded scope writes, stale detach, Clear Workflow rebind, foreign-clear capture consumption, layout/link/widget targeting asymmetry, link-report bursts, and the interior-delete dedupe guard are fixed at this head. - The post-deactivation failed-load state is intentional and already documented.
openWorkflow()restores the retained workflow after a configure failure; direct/import failure paths can remain fail-closed. The pre-existing mint teardown bracket also suppresses the configure-throw path, so activation is not the operative cause there. - The duplicate-root-ID thread identifies a real system-wide limitation, but Save As and in-app duplicate remint IDs, and this PR does not own external-copy identity repair.
- #18109's per-root dedupe is present and its previously reported foreign-delete and interior-delete regressions are covered.
Checked and cleared
- The reproduced foreign-severance and disabled-delete probes were audited against the current source rather than accepted from green tests alone.
- The widened local
LayoutChangeViewpredates this PR; this diff makesgraphIdstricter, so I am not charging the existing structural type copy to this change. - Fallow's only new scoped hotspot is the 96-line layout
onChangebranch. It is hard to read, but the current sequencing is pinned by focused tests and does not justify blocking this behavior change. - The activation host's published view and registry scope have different lifetimes; they are not redundant sources of truth.
Coverage and verification
- Deep lanes: correctness, maintainability, TypeScript/Vue idioms, tests, and documentation, split across activation-lifecycle and mint-delivery ownership shards.
- Focused baseline: 9 files, 339 passed, 1 skipped.
pnpm typecheck: passed.- Focused red probes reproduced the two P2 inline defects. Mutation testing also showed the new link-report coalescing branch has no regression assertion.
- CI is green for this head; cancelled snapshot/merge jobs are non-required workflow artifacts.
| const forActivatedDocument = | ||
| !gated || isForActivatedDocument(operation, 'delete') | ||
| if ( | ||
| operation.ownerGraphId === operation.graphId && |
There was a problem hiding this comment.
P2, non-blocking: !gated covers more than echo/teardown: it also covers isEnabled() === false, isDocBound() === false, and an unrecognized actor. Those cases do not prove this CRDT document lost the node, but this branch still forgets its dedupe entry. A focused create → disabled delete → re-enable/recreate probe produces two add_node mints for the same still-present document node. Please split the reasons that reconcile document membership from product/binding eligibility instead of treating every closed gate as a removal.
There was a problem hiding this comment.
Fixed in 3986119: layoutMintPort.ts#L296-L302.``
Split the two reasons apart as you suggested: forActivatedDocument is now only gated && isForActivatedDocument(...) (computed, with its side-effecting report, only once the gate is actually open), and a new docLostNode = forActivatedDocument || operation.source === 'agent-remote' is what gates forgetting the dedupe entry. Only an actual mint to the wire, or the local echo of a remote-applied removal (KA-6: remote applies never re-mint, so the doc already reflects them), counts as the doc losing the node. The product flag being off, no doc bound, teardown, or an actor this port doesn't recognize as local now leave the entry alone.
Added your exact probe as a regression: create → disable the flag → delete (dropped) → re-enable → recreate now mints once total, not twice. Also added the same case for isDocBound() === false, and a control test confirming a genuinely remote-echoed delete still forgets the entry (so a later create still mints, as it should). I confirmed the disabled-delete test fails against the pre-fix !gated || isForActivatedDocument(...) and passes after.
Generated by Claude Code
| const entry: SeveranceEntry = { | ||
| linkId: topology.id, | ||
| mintable: gateOpen() && isRootScope(scope) | ||
| mintable: |
There was a problem hiding this comment.
P2, non-blocking: this correctly marks a foreign severance non-mintable, but severances.take() below ignores mintable. Before the double-microtask sweep, take() returns that foreign link ID and a local delete_node can carry it in removed_links. The focused port probe receives [41] where [] is required. Either do not capture inactive severances or filter/consume non-mintable entries in take(). The existing test only checks that the delayed divergence logger stays quiet, so it misses this path.
There was a problem hiding this comment.
Fixed in 3986119: linkMintPort.ts#L226 — take() now skips an entry with !entry.mintable before it is ever considered against consumedLinkIds, so a foreign severance is neither returned nor marked consumed (the sweep already skipped it via mintable, so its behavior there is unchanged).
Added a regression to the existing 'never carries a foreign severance into a delete_node mint' test (linkMintPort.test.ts): after a FOREIGN_SCOPE removal, port.severances.take('2') / take('1') now assert []. I confirmed that assertion fails against the pre-fix take() — it returns [41], exactly the probe you described — and passes after this change.
Generated by Claude Code
| deps: DocumentActivationHostDeps | ||
| ): DocumentActivationHost { | ||
| let view: ActiveDocumentView | null = null | ||
| let requested: DocumentId | null = null |
There was a problem hiding this comment.
P3: requested mirrors the coordinator's own pending request only because deactivate() is document-targeted. It remains set after settlement, and the host has to issue two deactivations to mean "cancel whatever may hold the canvas." Letting the coordinator cancel its own pending and active bindings would delete this second state machine and the synchronization proof around it.
There was a problem hiding this comment.
Agreed this is real duplication, deferring rather than fixing here.
Letting the coordinator cancel its own pending-and-active bindings (so deactivate() no longer needs the host's separate requested tracking to mean "cancel whatever may hold the canvas") is a change to activationCoordinator.ts's own cancellation API, one layer down from this host. That's a good simplification, but it touches the coordinator #16375 shipped and this PR's host wraps, rather than being local to the file this thread is on. Leaving it as a follow-up.
Generated by Claude Code
| isLoaded: (documentId) => | ||
| documents.getDocument(documentId)?.state.phase === 'loaded', | ||
| commitScope: (documentId, scope) => { | ||
| if (!documents.hydrateDocument(documentId, scope)) |
There was a problem hiding this comment.
P3: this hydration branch is unreachable under the new contract. The coordinator calls commitScope only after isLoaded succeeded, and the workflow path calls markLoaded before activation, so hydrateDocument must return false here. A direct rebindScope(documentId, scope) would match the actual invariant and avoid suggesting activation can promote a created document.
There was a problem hiding this comment.
Agreed the branch is unreachable under the current contract, deferring rather than changing here.
Replacing if (!documents.hydrateDocument(documentId, scope)) documents.rebindScope(documentId, scope) with a direct rebindScope(documentId, scope) would match the actual invariant (commitScope only runs after isLoaded/markLoaded, so hydrateDocument can't still be looking at a created document here) and stop implying activation can promote one. It's a one-line change, but it's in src/stores/, a frozen directory per this PR's own tradeoffs list, so I'd rather have a human sign off on touching it than fold it into an already-large diff. Leaving it as a follow-up.
Generated by Claude Code
| documentId: DocumentId, | ||
| scope: GraphScope | ||
| ): Promise<ActivationOutcome> | ||
| /** |
There was a problem hiding this comment.
P3: the root-canvas host accepts a general GraphScope, so the type permits rootGraphId !== owningGraphId. The host publishes the first value while committing both, which would make targeting and registry ownership disagree. Current callers preserve equality manually. Accepting a RootGraphId and deriving the owning ID here would encode the host's actual invariant.
There was a problem hiding this comment.
Agreed on the invariant, deferring the change rather than doing it here.
Narrowing activate's scope: GraphScope parameter to RootGraphId and deriving the owning id inside the host would encode rootGraphId === owningGraphId structurally instead of relying on every caller to construct the pair correctly by convention. But that's a signature change to DocumentActivationHost.activate (and to GraphScope construction at both call sites in workflowService.ts and app.ts's Clear Workflow rebind), on top of an already large diff that's had three rounds of review. Leaving it as a follow-up rather than adding another surface change to this PR.
Generated by Claude Code
| function addNode(id: string): void { | ||
| nodes.set(id, { | ||
| id: toNodeId(id), | ||
| serialize: () => ({ id: Number(id), type: 'TestNode' }) |
There was a problem hiding this comment.
P3: this double assertion lets a two-field object impersonate LGraphNode, so changes to real node serialization cannot invalidate the integration fixture. LGraphNode is constructible in tests; using a real node or the repository's typed fixture would keep this test attached to the production contract.
There was a problem hiding this comment.
Fixed in 3986119: tabSwitchActivation.test.ts#L96-L103.``
Used the repository's existing typed fixture helper — createMockLGraphNode from src/utils/__tests__/litegraphTestUtils.ts (backed by @total-typescript/shoehorn's fromPartial) — instead of the double as unknown as LGraphNode assertion. addNode now builds a real, type-checked partial LGraphNode with just id and serialize overridden, so it stays attached to the production shape instead of impersonating it.
Generated by Claude Code
| const outcome = await useDocumentActivationStore().activate( | ||
| documentId, | ||
| scope | ||
| ) |
There was a problem hiding this comment.
P3: ActivationOutcome is a discriminated union, but this consumer only names rejected; activated, superseded, and any future status fall through as equivalent. An exhaustive switch would make a new terminal outcome fail typecheck here instead of silently restoring previews as if activation succeeded.
There was a problem hiding this comment.
Fixed in 3986119: workflowService.ts#L720-L739.``
The bare if (outcome.status === 'rejected') is now a switch that enumerates 'activated'/'superseded' (no-op) and 'rejected' (the existing reportError), with a default: outcome satisfies never. A future ActivationOutcome variant now fails typecheck here instead of silently falling through as a success. Ran pnpm typecheck clean and workflowService.test.ts (107 tests) still passes.
Generated by Claude Code
| * Collapses a burst of identical drops into one signal: a tab switch emits a | ||
| * change per link, and each would otherwise report separately. | ||
| */ | ||
| function createOncePerTickReporter(): ( |
There was a problem hiding this comment.
P3: the new coalescer has no burst/reset assertion. Replacing the duplicate-key guard with a no-op leaves all 14 link-port tests green. A compact test should send two same-key drops in one tick, then one after a microtask, and assert report counts 1 then 2.
There was a problem hiding this comment.
Fixed in 3986119: linkMintPort.test.ts#L245-L261.``
Added the compact test as described: two same-key FOREIGN_SCOPE drops synchronously (consoleError called once), then a third after await Promise.resolve() (consoleError called twice total). I mutation-checked it by replacing the coalescer's duplicate-key guard with a no-op (return (key, report) => { report() }) — the new test fails (2 calls instead of 1 before the tick boundary) while it and the rest of the suite pass unmodified.
Generated by Claude Code
|
I want to record how unusually difficult this has been to review, because the difficulty is itself evidence about the code we are building on. The patch is trying to make one fairly simple statement true: an operation produced for one workflow must never be written into another workflow's document. In a healthier design, that would be enforced by a document-scoped operation queue or an activation token carried with the operation. Here, establishing the same fact requires reconstructing several overlapping state machines spread across the app:
None of those statements is merely background context. A reviewer has to hold all ten in mind at once to determine whether moving one line is correct. The delete path is the clearest example. Whether deleting one entry from
That is why a condition which looks reasonable in isolation, The link path has the same problem in a different form. The new targeting condition correctly marks a foreign severance as non-mintable. That looks fixed until the reviewer follows the entry into the transient severance map, follows the double-microtask cleanup schedule, notices that The workflow side is no easier. The activation lifecycle is split between
Again, comments flatten these cases into claims such as "a failed load leaves nothing activated" or "every graph load funnels through here." Those claims are close enough to sound useful and broad enough to be wrong at important boundaries. The PR description itself became stale while the review was in progress: it says The types do not provide much relief. The tests also mirror the architecture instead of exercising it. The large tab-switch integration suite manually performs deactivate, graph mutation, mark-loaded, and activate steps. It is useful for the host and mint boundary, but it does not execute the workflow adapter whose ordering it is supposed to represent. The host's rapid-switch test proves that the coordinator chooses the newest request presented to it. It does not prove that concurrent workflow loads present requests in user-intent order rather than completion order. A focused probe can resolve B and then A and leave A active, while all of the existing rapid-switch tests remain green. This is the recurring pattern throughout the patch: a local fix is often reasonable, but determining whether it is correct requires reconstructing hidden coupling elsewhere.
Each fix exposes the next hidden dependency. That is a strong sign that we are treating architectural problems with increasingly careful local patches. I am approving because the common tab-switch path is materially safer, the known high-severity review findings were addressed, the focused suite is strong, and the remaining reproduced defects are narrow. This should not be read as confidence that the underlying design is now easy to reason about. It is not. The code currently demands that every reviewer rediscover the same distributed protocol and manually check its interleavings. The follow-up work I would most like to see is not another guard. It is a reduction in the number of independent facts:
Until those ownership problems are fixed, reviews in this area will remain disproportionately expensive. Small diffs will continue to require large proofs, comments will continue to encode invariants the types cannot express, and apparently harmless line movement will continue to reopen bugs in another state machine. The patch is doing serious work to contain that situation. It is also a vivid demonstration that containment is not the same thing as repair. |
Two review-flagged correctness gaps in the tab-switch activation mint ports: - linkMintPort's severance take() ignored the mintable flag, so a foreign (non-activated-document) severance could still be handed back and carried into a local delete_node's removed_links. take() now skips non-mintable entries. - layoutMintPort's deleteNode branch forgot the mint-dedupe entry on every closed gate, including the product flag being off, no doc bound, or an unrecognized actor - none of which mean the CRDT document actually lost the node. Forgetting is now gated on either an actual mint to the wire or a local echo of a remote-applied removal. Also: - workflowService's document-activation outcome switch is now exhaustive over ActivationOutcome instead of only checking for 'rejected'. - tabSwitchActivation.test.ts builds its LGraphNode test fixture through the existing createMockLGraphNode helper instead of a double type assertion. - linkMintPort's once-per-tick drop coalescer now has a regression test pinning its burst/reset behavior. Regression tests included for all of the above; the new layoutMintPort and linkMintPort cases fail against the pre-fix code and pass after.
|
Flagging rather than blocking, found tracing the hook pair: the activation is retracted and republished on every undo and redo. Still true at
In that window The endpoints are fine: ADR-GRAPH-DOCUMENT-0026's Phase 1 calls out this exact hook pair — "cannot simply be renamed into Deactivate/Activate because they also fire on undo/redo … the bus must gate on document-identity change, not on graph load". This PR is the first to hook them. There's no test for it. Three ways to go:
I'd take 3. It matches how this PR already handles its other four tradeoffs, named in the body rather than left to be found, and 1 belongs with the phase that actually builds the bus. What I have not established: whether a user can actually lose an agent edit this way. That needs the CRDT follower proven to be delivering during a |
beforeLoadNewGraph/afterLoadNewGraph also fire on undo and redo
(ChangeTracker.updateState -> app.loadGraphData with
suppressWorkflowReset = false), not just tab switches, and nothing
previously exercised that path. Add a regression asserting the same
{documentId, rootGraphId} is republished at the end of the round trip.
|
@christian-byrne re #18326 (comment) — went with option 3, as you suggested.
No change to the retraction itself — it stays unconditional, per option 3. Generated by Claude Code |
|
Replying to the three "findings without a clean inline anchor" from @DrJKL's review (#pullrequestreview-5312863565), plus confirming the fourth (stale PR description). Individual inline replies to the two correctness bugs and the smaller nits are posted on their respective threads; commit 3986119. Concurrent direct loads (P2). Not fixing the underlying gap here — narrowed the PR body's tradeoffs bullet instead: it now says plainly that Duplicate serialized root IDs (P3). Not growing a local activation-generation protocol for this. Added a tradeoffs bullet noting it's a broader, pre-existing load-time identity issue outside this PR's scope — Save As and in-app duplicate already remint IDs, so the residual case is an externally copied file colliding on id, which the existing ECS stores already key around. Targeting policy duplicated across mint ports (P3). Agreed, and left as a follow-up rather than fixed here — added a tradeoffs bullet naming a shared predicate/reporter at the wiring seam as the right next step, since the layout/link/widget ports each independently compare activation state today. PR description staleness (P3, Generated by Claude Code |
|
Closing per the call on this: close it and re-derive the fix later. The behaviour it fixes is real and still wanted — switching tabs should not stack duplicate copies of your nodes. What does not survive is the branch. Its base ( Re-deriving against current Not a rejection of the fix. Reopen or re-author when the duplicate-nodes bug is picked up against a base that can actually land. |
Requested by Christian Byrne · Slack thread
Stacked on #16375 (base:
feat/graph-document-activation-seam). Implements its follow-up 3, "host-side wiring: activation coordinator driving the real canvas binding (replacing tab-switch ad hoc logic)".This is an architecture demonstration, opened as a draft so the design can be argued about before it is hardened. See Tradeoffs.
Summary
Before. The app keeps one root
LGraphand reconfigures it in place on every workflow load, so "which graph is the canvas showing" is a moving target with no owner. Each consumer re-derives it, and the derivations disagree during a switch. Nothing tells the mint path that a handoff is in progress, so a layoutcreateNodequeued for the incoming tab can drain on a later microtask and mint anadd_nodeinto the previous tab's document. #16375 added a coordinator that models the handoff correctly but left it unwired: nothing ever calledactivate()ordeactivate().After. The load path drives the coordinator, and the coordinator publishes exactly one answer that everyone reads.
beforeLoadNewGraphretracts the outgoing document's canvas binding, synchronously, before anything touches the shared graph.afterLoadNewGraphactivates the incoming document, at the first point where the workflow taking the canvas is actually known.layoutMintPortasks the activation host which root graph is activated, and drops any root-scopedcreateNode/deleteNode/clearGraphnaming a different graph (agent_crdt_op_for_inactive_document).app.clean()(Clear Workflow) republishes the activated binding on the reminted root id, sinceLGraph.clear()remints it in place and reaches no load path.The wrong-document mint stops being a race to win and becomes unrepresentable: an op can only mint into the document whose root graph it names, and during the handoff no document is activated at all, so nothing mints.
Design
src/core/graph/document/documentActivationHost.ts— the seam. Wraps #16375's generation-racedcreateActivationCoordinatorwith the canvas-sideDocumentViewBinding:attachpublishes the{documentId, rootGraphId}pair,detachretracts it. Publishing lives in the binding, so the coordinator's existing ordering guarantees (ordered detach → attach → publish, stale requests can never publish) carry over unchanged rather than being reimplemented.deactivate()retracts the in-flight request as well as the published binding. Without that, a load starting while a previousactivateis still mid-handoff would let that activation publish a graph the canvas had already moved past — the exact window the seam exists to close.src/stores/documentActivationStore.ts— app-wide singleton over the registry.isLoadedis the registry's phase check;commitScopehydrates (or rebinds) the document's ECS scope, and is called only after the coordinator's handoff actually wins (activated), so a rejected or superseded request never stamps a graph id the winner already owns.workflowServicedrives the seam;app.tscarries one rebind for Clear Workflow. The first draft hookedloadGraphDatadirectly, which meant three copy-pasted call-site pairs, sinceloadApiJsonandimportA1111also reconfigure the shared graph without going throughloadGraphData.beforeLoadNewGraph/afterLoadNewGraphis the funnel all three already share and is already wherechangeTracker.deactivate()lives, so activation rides the workflow lifecycle. Clear Workflow is the one graph swap that reaches no load path —LGraph.clear()remints the root id in place — soapp.clean()callsdocumentActivationStore.rebindActiveScope()to republish the same document on the new id; everything else inapp.tsis untouched.Scope from the live root graph.
activateLoadedDocumentreadsapp.rootGraph.id, not the workflow's serializedactiveState.id, because the live graph's id is what every layout change'sgraphIdcarries — comparing against anything else reintroduces a derivation that can disagree.Registry scope now learned at activation. The host is the first caller that knows the root graph id, so
hydrateDocument/rebindScopehappens at bind time instead of lazily on the document's first agent write.Compared with #18109
#18109 fixes the same bug from the other end:
AgentPanelRootre-derivesboundRootGraphId()from the bound workflow'sactiveState.idand threads it down to the mint port. It works, and it is much smaller, but it is a second derivation of a fact nobody owns — hence its care aboutcomputedvs plain accessor,markRaw'd change trackers, and stale latching. Here the fact has one owner and changes exactly once per handoff, so the consumer reads rather than derives.Two consequences worth arguing about:
graphIdmint-dedupe re-keying is orthogonal and still worth having.#18109 has since merged and is integrated into this branch.
mintedNodeIdsByRoot/mintedNodeIdsForRootinlayoutMintPort.tsnow key the dedupe set onoperation.graphIdinstead of re-derivingboundRootGraphId— a genuine improvement overmain's version, not just a transcription: by the time a create reaches the bucket lookup,isForActivatedDocumenthas already established that the key names the activated document, so the ambiguous "activation unresolved" casemainhad to special-case can't arise.Tradeoffs and what is deliberately not hardened
isDocBoundstill compares tab paths.AgentPanelRoot'sisBoundWorkflowActiveis the other ad-hoc derivation, and the coordinator could answer it (boundTab.documentId === activeDocumentId()). Left alone here because it also drives the CRDT follower's subscribe/suspend trigger, so moving it changes follower behaviour and deserves its own PR. The scope check closes the bug without it.loadGraphDatacalls are not serialized here. NormalopenWorkflow()calls are serialized, so this does not defeat the common tab-switch path, but some directapp.loadGraphData()callers remain outside that queue; real serialization belongs in the load path.src/stores/is a frozen directory and the pre-commit warning fires fordocumentActivationStore.ts. Same placement rationale feat(agent): add GraphDocument registry and activation seam #16375 used forgraphDocumentStore.ts: it is a sibling of the registry it wraps.beforeLoadNewGraph/afterLoadNewGraphalso fire on undo and redo, not just tab switches (ChangeTracker.updateStatereaches them withsuppressWorkflowReset = false), so an undo retracts and republishes the activation binding even though the same document owns the canvas before and after. In that windowactiveRootGraphId()is null and root-scoped ops are dropped fail-closed — correct for a tab switch, but an undo drops rather than applies an in-flight op during that window. The round trip itself is covered (workflowService.test.ts, "republishes the same document and root graph id across an undo/redo round trip"), but the in-window drop is not fixed here: ADR-GRAPH-DOCUMENT-0026 Phase 1 calls out this exact hook pair as needing to gate on document-identity change rather than on graph load, and that belongs with the phase that builds the identity/lifecycle bus, not with this PR's retrofit onto the existing hooks.Tests
src/core/graph/document/documentActivationHost.test.ts(17) — publish/retract, the switch handoff, the empty mid-reconfigure window, graph-id rotation in place, refusing an unloaded document, in-flight cancellation, and rapid switching settling on the last request rather than the last to resolve.src/renderer/core/layout/store/tabSwitchActivation.test.ts(8) — the real layout store through the real mint wiring, targeted by the real host and registry: a change draining after a switch reaches no document, a stale change for the previous graph is dropped once the new tab is active, rapid switching leaves one tab holding the canvas, and each tab's scope is learned from its activation.src/workbench/extensions/agent/crdt/layoutMintPort.test.ts(50) — foreign-graph drops for all three root-scoped op types, once-per-tick reporting, recovery when the other graph becomes activated, the fail-closed unactivated case, the fix(agent-crdt): scope layout mint ops to the bound document's root graph #18109 dedupe regressions (root-graph replay, dropped-delete, interior-delete), and the disabled-delete/unbound-doc double-mint regressions for the dedupe-forget invariant.src/workbench/extensions/agent/crdt/linkMintPort.test.ts(15) — foreign-severance capture, the once-per-tick coalescer's burst/reset behavior, and the fix that keeps a foreign, non-mintable severance out ofremoved_links.src/platform/workflow/core/services/workflowService.test.ts— includes an undo/redo round-trip regression:beforeLoadNewGraph/afterLoadNewGraphalso fire on undo/redo, and the same{documentId, rootGraphId}is republished at the end of the round trip (see the known-limitation note above on the in-window drop).Verification
pnpm vitest runon the directly affected suites (documentActivationHost,tabSwitchActivation,layoutStoreMintDelivery,layoutMintPort,linkMintPort,workflowService) — all passing at the current head.pnpm typecheck,pnpm lint(0 errors),pnpm knip,pnpm format— clean at the current head.🤖 Generated with Claude Code
https://claude.ai/code/session_01U73XrPUkU81hiq71XZY4mr