Repository navigation
feat(agent): outcome-aware doc_ops_result reconciliation for the pending overlay - #16332
christian-byrne wants to merge 5 commits into
Conversation
A doc_ops_result classifies each batch member per-outcome (applied prefix preserved until its effect per the overlay invariant, skipped and failed and unprocessed tracked separately); nothing is ever rolled back wholesale, op ids are never regenerated, and the ledger never writes doc state. Send-path integration and reconciliation policy land separately.
…h boundary The follower's send path silently discarded the transport boolean: an op minted on a closed socket vanished with no pending record, no retry, and no styling revert. This wires the pure pending-op ledger and the overlay shadow surface together at the dispatch boundary. - layoutFollowerBridge.sendHumanOps now returns whether the frame left the client (false on no subscription, empty batch, or closed socket). - humanOpDispatcher (new, pure): enqueue + shadow BEFORE send; identical op-id retry after transport recovery; bounded attempts then revert — never an immortal pending entry; FIFO batch order preserved verbatim so the doc_ops_result reconciler can map failed.index against the as-sent order. - useAgentCrdtFollower routes all human-op call sites through the dispatcher, retries on socket activity and confirmed subscription, and resets on doc_reset and unmount. Covered by 11 dispatcher tests and 3 bridge boolean tests.
|
Warning Review limit reachedNext included review available in 5 minutes. View limit detailsLimit details: You’ve used all 4 included reviews currently available. Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (13)
Comment |
🎭 Playwright: ❌ 1898 passed, 55 failed · 4 flaky❌ Failed Tests📊 Browser Reports
🎨 Storybook: ✅ Built — View Storybook📦 Bundle Size
⚡ Performance Report
Absolute values
Raw data{
"timestamp": "2026-08-31T02:19:22.303Z",
"gitSha": "1ebd8c2ed3ea5e6a80a3d9f722d3c9f355a41495",
"branch": "fix/s3opt2-outcome-reconciliation",
"measurements": [
{
"name": "canvas-idle",
"durationMs": 2016.6220000000408,
"styleRecalcs": 6,
"styleRecalcDurationMs": 8.213,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 501.9789999999999,
"heapDeltaBytes": 2902680,
"heapUsedBytes": 98325536,
"domNodes": 12,
"jsHeapTotalBytes": 5767168,
"scriptDurationMs": 6.627000000000001,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-idle",
"durationMs": 2033.6240000000316,
"styleRecalcs": 8,
"styleRecalcDurationMs": 7.319000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 441.00299999999993,
"heapDeltaBytes": 2942852,
"heapUsedBytes": 99001828,
"domNodes": 16,
"jsHeapTotalBytes": 6291456,
"scriptDurationMs": 7.407,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-mouse-sweep",
"durationMs": 2083.2920000000286,
"styleRecalcs": 83,
"styleRecalcDurationMs": 43.376,
"layouts": 14,
"layoutDurationMs": 4.876,
"taskDurationMs": 1122.498,
"heapDeltaBytes": -7623372,
"heapUsedBytes": 88648636,
"domNodes": 64,
"jsHeapTotalBytes": 6815744,
"scriptDurationMs": 152.777,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "canvas-mouse-sweep",
"durationMs": 2155.0260000000208,
"styleRecalcs": 83,
"styleRecalcDurationMs": 40.043,
"layouts": 14,
"layoutDurationMs": 4.326,
"taskDurationMs": 1098.58,
"heapDeltaBytes": -7186708,
"heapUsedBytes": 88749144,
"domNodes": 64,
"jsHeapTotalBytes": 7077888,
"scriptDurationMs": 148.553,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1739.3899999999576,
"styleRecalcs": 33,
"styleRecalcDurationMs": 15.745000000000003,
"layouts": 6,
"layoutDurationMs": 1.2269999999999999,
"taskDurationMs": 348.24100000000004,
"heapDeltaBytes": 5545120,
"heapUsedBytes": 102612024,
"domNodes": 77,
"jsHeapTotalBytes": 6815744,
"scriptDurationMs": 9.386000000000003,
"eventListeners": 19,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1737.0529999999462,
"styleRecalcs": 33,
"styleRecalcDurationMs": 17.548000000000002,
"layouts": 6,
"layoutDurationMs": 1.0379999999999998,
"taskDurationMs": 355.15200000000004,
"heapDeltaBytes": 5718888,
"heapUsedBytes": 102980072,
"domNodes": 77,
"jsHeapTotalBytes": 6029312,
"scriptDurationMs": 12.941999999999998,
"eventListeners": 19,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "dom-widget-clipping",
"durationMs": 911.5260000000376,
"styleRecalcs": 13,
"styleRecalcDurationMs": 7.771000000000002,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 659.95,
"heapDeltaBytes": 7762172,
"heapUsedBytes": 103971088,
"domNodes": 18,
"jsHeapTotalBytes": 7077888,
"scriptDurationMs": 137.63599999999997,
"eventListeners": 2,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "dom-widget-clipping",
"durationMs": 930.3879999999936,
"styleRecalcs": 13,
"styleRecalcDurationMs": 7.3610000000000015,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 672.932,
"heapDeltaBytes": 8083512,
"heapUsedBytes": 103820068,
"domNodes": 18,
"jsHeapTotalBytes": 7602176,
"scriptDurationMs": 141.12,
"eventListeners": 2,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-idle",
"durationMs": 2006.0609999999883,
"styleRecalcs": 4,
"styleRecalcDurationMs": 3.495999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 490.314,
"heapDeltaBytes": 16748624,
"heapUsedBytes": 121166160,
"domNodes": 8,
"jsHeapTotalBytes": 3407872,
"scriptDurationMs": 29.876,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "large-graph-idle",
"durationMs": 2003.0340000000706,
"styleRecalcs": 5,
"styleRecalcDurationMs": 4.316999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 484.621,
"heapDeltaBytes": 16677708,
"heapUsedBytes": 119864536,
"domNodes": 10,
"jsHeapTotalBytes": 3407872,
"scriptDurationMs": 26.9,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66999999999998,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "large-graph-pan",
"durationMs": 3142.9220000000555,
"styleRecalcs": 65,
"styleRecalcDurationMs": 10.216000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 2335.099,
"heapDeltaBytes": 20960256,
"heapUsedBytes": 125205924,
"domNodes": 6,
"jsHeapTotalBytes": 4943872,
"scriptDurationMs": 853.06,
"eventListeners": 8,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-pan",
"durationMs": 3200.7710000000316,
"styleRecalcs": 66,
"styleRecalcDurationMs": 11.016,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 2389.9039999999995,
"heapDeltaBytes": -6066248,
"heapUsedBytes": 98962720,
"domNodes": 8,
"jsHeapTotalBytes": 4718592,
"scriptDurationMs": 878.995,
"eventListeners": 8,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-zoom",
"durationMs": 4227.648000000045,
"styleRecalcs": 66,
"styleRecalcDurationMs": 10.572000000000001,
"layouts": 60,
"layoutDurationMs": 11.748000000000001,
"taskDurationMs": 2324.066,
"heapDeltaBytes": 4305572,
"heapUsedBytes": 113470972,
"domNodes": 24,
"jsHeapTotalBytes": 5505024,
"scriptDurationMs": 817.909,
"eventListeners": 12,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-zoom",
"durationMs": 4256.579999999985,
"styleRecalcs": 66,
"styleRecalcDurationMs": 10.799,
"layouts": 60,
"layoutDurationMs": 11.705,
"taskDurationMs": 2347.388,
"heapDeltaBytes": 3024640,
"heapUsedBytes": 112837948,
"domNodes": 24,
"jsHeapTotalBytes": 5767168,
"scriptDurationMs": 813.055,
"eventListeners": 10,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.669999999999952,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "legacy-node-drag",
"durationMs": 4717.541000000039,
"styleRecalcs": 41,
"styleRecalcDurationMs": 4.8519999999999985,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 3355.9779999999996,
"heapDeltaBytes": 17787748,
"heapUsedBytes": 130065248,
"domNodes": 2,
"jsHeapTotalBytes": 6971392,
"scriptDurationMs": 932.59,
"eventListeners": 192,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "legacy-node-drag",
"durationMs": 4659.110999999939,
"styleRecalcs": 43,
"styleRecalcDurationMs": 7.022,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 3342.5399999999995,
"heapDeltaBytes": 18703768,
"heapUsedBytes": 130640452,
"domNodes": 6,
"jsHeapTotalBytes": 6184960,
"scriptDurationMs": 920.278,
"eventListeners": 192,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "minimap-idle",
"durationMs": 1992.0319999999947,
"styleRecalcs": 5,
"styleRecalcDurationMs": 4.4799999999999995,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 491.84499999999986,
"heapDeltaBytes": 16789676,
"heapUsedBytes": 122031648,
"domNodes": 10,
"jsHeapTotalBytes": 3932160,
"scriptDurationMs": 29.322,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666696,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "minimap-idle",
"durationMs": 1995.1150000000553,
"styleRecalcs": 4,
"styleRecalcDurationMs": 3.7560000000000007,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 489.7609999999999,
"heapDeltaBytes": 16850520,
"heapUsedBytes": 122302772,
"domNodes": 8,
"jsHeapTotalBytes": 3670016,
"scriptDurationMs": 29.456000000000003,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666696,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 692.1310000000176,
"styleRecalcs": 47,
"styleRecalcDurationMs": 10.290000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 492.794,
"heapDeltaBytes": -5722908,
"heapUsedBytes": 91935312,
"domNodes": 20,
"jsHeapTotalBytes": 7340032,
"scriptDurationMs": 132.79,
"eventListeners": 8,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 684.8179999999502,
"styleRecalcs": 45,
"styleRecalcDurationMs": 9.346999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 483.414,
"heapDeltaBytes": 22784588,
"heapUsedBytes": 110340316,
"domNodes": 16,
"jsHeapTotalBytes": 6553600,
"scriptDurationMs": 136.852,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-idle",
"durationMs": 2006.35699999998,
"styleRecalcs": 9,
"styleRecalcDurationMs": 7.380000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 427.35,
"heapDeltaBytes": 3175816,
"heapUsedBytes": 99795928,
"domNodes": 18,
"jsHeapTotalBytes": 6553600,
"scriptDurationMs": 6.695000000000001,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-idle",
"durationMs": 1992.4879999999803,
"styleRecalcs": 8,
"styleRecalcDurationMs": 7.511999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 424.057,
"heapDeltaBytes": 3216516,
"heapUsedBytes": 99805740,
"domNodes": 16,
"jsHeapTotalBytes": 6553600,
"scriptDurationMs": 6.325000000000001,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66999999999998,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1771.9180000000279,
"styleRecalcs": 78,
"styleRecalcDurationMs": 36.954,
"layouts": 18,
"layoutDurationMs": 5.931,
"taskDurationMs": 1033.1280000000002,
"heapDeltaBytes": 6857104,
"heapUsedBytes": 104371908,
"domNodes": 65,
"jsHeapTotalBytes": 7340032,
"scriptDurationMs": 110.88700000000001,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1783.596999999986,
"styleRecalcs": 78,
"styleRecalcDurationMs": 39.254999999999995,
"layouts": 18,
"layoutDurationMs": 5.679,
"taskDurationMs": 1030.281,
"heapDeltaBytes": 6747004,
"heapUsedBytes": 104112344,
"domNodes": 69,
"jsHeapTotalBytes": 7340032,
"scriptDurationMs": 108.793,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-transition-enter",
"durationMs": 1433.05399999997,
"styleRecalcs": 18,
"styleRecalcDurationMs": 32.217,
"layouts": 14,
"layoutDurationMs": 15.866000000000001,
"taskDurationMs": 907.67,
"heapDeltaBytes": 20821500,
"heapUsedBytes": 125061232,
"domNodes": 13671,
"jsHeapTotalBytes": 11796480,
"scriptDurationMs": 29.578999999999994,
"eventListeners": 2381,
"totalBlockingTimeMs": 153,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "viewport-pan-sweep",
"durationMs": 12391.4410000001,
"styleRecalcs": 246,
"styleRecalcDurationMs": 33.617999999999995,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 8503.998000000001,
"heapDeltaBytes": -12503672,
"heapUsedBytes": 91256104,
"domNodes": -282,
"jsHeapTotalBytes": -372736,
"scriptDurationMs": 3009.15,
"eventListeners": -173,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "viewport-pan-sweep",
"durationMs": 12374.627999999917,
"styleRecalcs": 248,
"styleRecalcDurationMs": 34.562,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 8546.652,
"heapDeltaBytes": -1997792,
"heapUsedBytes": 102361248,
"domNodes": -281,
"jsHeapTotalBytes": -827392,
"scriptDurationMs": 2979.705,
"eventListeners": -185,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "vue-large-graph-idle",
"durationMs": 16392.13200000006,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 15403.701000000001,
"heapDeltaBytes": -27796108,
"heapUsedBytes": 198069624,
"domNodes": -6548,
"jsHeapTotalBytes": 10444800,
"scriptDurationMs": 299.912,
"eventListeners": -7459,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.223333333333358,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-idle",
"durationMs": 16393.204999999965,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 15376.072,
"heapDeltaBytes": -44210724,
"heapUsedBytes": 199823220,
"domNodes": -6548,
"jsHeapTotalBytes": 7868416,
"scriptDurationMs": 272.752,
"eventListeners": -7455,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.220000000000073,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-pan",
"durationMs": 21016.446000000087,
"styleRecalcs": 179,
"styleRecalcDurationMs": 16.998999999999988,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 20543.575,
"heapDeltaBytes": -18028836,
"heapUsedBytes": 212779528,
"domNodes": -6548,
"jsHeapTotalBytes": 5963776,
"scriptDurationMs": 885.484,
"eventListeners": -7449,
"totalBlockingTimeMs": 148,
"frameDurationMs": 17.776666666666642,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-pan",
"durationMs": 21018.71799999992,
"styleRecalcs": 177,
"styleRecalcDurationMs": 17.415000000000013,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 20616.327,
"heapDeltaBytes": -20963896,
"heapUsedBytes": 201431064,
"domNodes": -6548,
"jsHeapTotalBytes": 12599296,
"scriptDurationMs": 919.087,
"eventListeners": -7449,
"totalBlockingTimeMs": 81,
"frameDurationMs": 17.776666666666763,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "workflow-execution",
"durationMs": 454.6029999999064,
"styleRecalcs": 20,
"styleRecalcDurationMs": 28.395999999999997,
"layouts": 3,
"layoutDurationMs": 1.209,
"taskDurationMs": 132.099,
"heapDeltaBytes": 5738660,
"heapUsedBytes": 98243168,
"domNodes": 128,
"jsHeapTotalBytes": 262144,
"scriptDurationMs": 7.525,
"eventListeners": 99,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "workflow-execution",
"durationMs": 128.6729999999352,
"styleRecalcs": 9,
"styleRecalcDurationMs": 14.613,
"layouts": 3,
"layoutDurationMs": 1.238,
"taskDurationMs": 98.438,
"heapDeltaBytes": 3734504,
"heapUsedBytes": 96482408,
"domNodes": 130,
"jsHeapTotalBytes": 262144,
"scriptDurationMs": 5.024000000000001,
"eventListeners": 25,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
}
]
} |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## nathaniel/agent-panel-v1 #16332 +/- ##
============================================================
+ Coverage 80.67% 82.99% +2.32%
============================================================
Files 2339 2013 -326
Lines 120790 116070 -4720
Branches 35560 33365 -2195
============================================================
- Hits 97444 96338 -1106
+ Misses 22849 19391 -3458
+ Partials 497 341 -156
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 351 files with indirect coverage changes 🚀 New features to boost your workflow:
|
|
TL;DR: exact-head review at Full context for agent readersissue: switching workflows in issue: issue: suggestion: (non-blocking) No raw-Yjs follower write, overlay-to-doc merge, |
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @christian-byrne.
Found 10 finding(s).
| Severity | Count |
|---|---|
| 🟠 High | 5 |
| 🟡 Medium | 5 |
Panel: 8/8 reviewers contributed findings.
| persistDocId(subscribedWorkflowId.value) | ||
| // s3-opt-6: a confirmed subscription is the definitive "sends can now | ||
| // succeed" signal — drain any batches held while the transport was down. | ||
| retryPendingOps() |
There was a problem hiding this comment.
🟠 High — Batches carry no workflow identity and the workflow-switch path never resets the dispatcher (only onDocReset and unmount do), so a batch held unsent for workflow A is drained by this retryPendingOps() on workflow B's doc_subscribed{ok:true} — bridge.sendHumanOps re-reads the bridge's current sentWorkflowId, so ops minted against A (A's base_version, stamp, node ids) are written into B's document, and A's ledger entries and node-keyed shadows leak onto B's canvas. Either reset the dispatcher/reconciler in the workflowId watch or tag each batch with its originating workflow and drop non-matching batches on retry. Raised by 4 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case, kimi-k3-max edge-case).
| bridge.reconcile() | ||
| // s3-opt-6: the socket demonstrably carries frames again — re-attempt any | ||
| // held human-op batches with their identical op ids. | ||
| retryPendingOps() |
There was a problem hiding this comment.
🟠 High — retryPendingOps is wired to every api status event, which fires on socket close (status: null), on every server status message, and once per second from the poll fallback — none of which indicate the transport recovered. The bridge.subscribedWorkflowId !== null guard does not detect a closed socket (the bridge keeps sentWorkflowId across a drop), so a couple of unrelated status frames during a brief outage burn all 3 maxSendAttempts and the batch is reverted, discarding the human's ops with only a recordDevEvent trace. Gate the retry on an actually-open socket, or don't count a send attempt when the transport is known closed. 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).
| for (const sent of sentBatches) { | ||
| const key = batchKey(sent.opIds) | ||
| if (reconciledBatches.has(key)) continue | ||
| if (!sent.opIds.some((opId) => mentioned.has(opId))) continue |
There was a problem hiding this comment.
🟠 High — Batch correlation matches on any single mentioned op id and then permanently marks that batch reconciled, while ledger.reconcileOpsResult transitions every id in the frame's applied/skipped/failed.op_id lists — including ids belonging to other in-flight batches. A partial, stale, or malformed frame therefore rolls back the matched batch's unmentioned members, mutates unrelated batches' entries, and consumes the matched batch's one-shot reconciliation so its genuine result is later dropped as matched:false. Require that the frame's ids be a subset of one batch (or correlate frames by an explicit request/batch id) before transitioning. Raised by 4 of 8 reviewers (claude-opus-5-thinking-max adversarial+edge-case, gpt-5.6-sol-max adversarial+edge-case, kimi-k3-max adversarial).
| const parsed = parseResult(result) | ||
| if (parsed === null) return unmatched([]) | ||
|
|
||
| const mentioned = new Set([...parsed.applied, ...parsed.skipped]) |
There was a problem hiding this comment.
🟠 High — When the host rejects the first op of a batch and the failed payload carries no op_id — a shape this module's own test exercises (failed: { code: 'boom' }) or the positional failed.index form the dispatcher contract documents — mentioned is empty, no batch matches, and unmatched([]) is returned. The whole batch stays inflight with shadows shown until doc_reset/unmount, and since the caller only logs when report.matched is true the stuck batch is completely silent. Resolve the failure positionally via failed.index against the batch, and/or surface unmatched frames. Raised by 2 of 8 reviewers (claude-opus-5-thinking-max edge-case, gpt-5.6-sol-max edge-case).
| // attempted, and `sendHumanOps`'s boolean decides between in-flight and a | ||
| // bounded identical-id retry. The ledger/shadow instances are shared state | ||
| // for the s3-opt-2 result reconciler and s3-opt-3 clear-on-effect wiring. | ||
| const pendingLedger = createPendingOpLedger<DocOp>() |
There was a problem hiding this comment.
🟠 High — Nothing in production code calls pendingLedger.clearOnEffect or pendingShadow.clear for applied ids (only the skipped-duplicate path clears), so every successfully applied human op keeps its ledger entry — holding the full DocOp payload — plus its shadow for the composable's lifetime. Memory grows with every op and pendingShadow.isPending() reports every added node as permanently pending once a renderer consumes it. If the clear-on-effect wiring is deliberately deferred to s3-opt-3, say so at this call site so the leak isn't mistaken for complete behaviour. Raised by 3 of 8 reviewers (claude-opus-5-thinking-max adversarial+edge-case, gpt-5.6-sol-max adversarial+edge-case).
| const reconciler = createOpsResultReconciler({ | ||
| ledger: pendingLedger, | ||
| shadow: pendingShadow, | ||
| currentSeq: () => lastSeq |
There was a problem hiding this comment.
🟡 Medium — currentSeq reads lastSeq, which is only advanced from doc_update frames, is never reset by onDocReset, and ignores the catch-up seq delivered on doc_subscribed {ok, seq} that the bridge does fold into its own baseline. After a lineage remint the stale high-water mark makes projectedSeq >= parsed.seq trivially true, so skipped shadows clear at reconcile time with no covering projection — exactly what the reconciler's contract forbids; conversely after a fresh subscribe currentSeq() reports 0 while state is projected at seq N, so skipped duplicates wait for an update a fully-duplicate batch never produces. Reset and re-baseline lastSeq alongside projector.reset()/subscription. Raised by 4 of 8 reviewers (claude-opus-5-thinking-max adversarial+edge-case, gpt-5.6-sol-max adversarial+edge-case, kimi-k3-max adversarial+edge-case).
| // without its predecessor would replay a broken intent. The user's | ||
| // canvas returns to the authoritative state; re-doing is explicit. | ||
| const rolledBack: string[] = [] | ||
| for (const opId of [...summary.failed, ...summary.unprocessed]) { |
There was a problem hiding this comment.
🟡 Medium — parseResult validates ok and then discards it, and stringArray silently coerces a missing or non-array applied/skipped to []. Since every batch member not echoed is classified unprocessed and unconditionally reverted here, a truncated or malformed ok:true frame rolls back ops the host actually committed — rollback is driven purely by omission from an untrusted list. Reject frames whose outcome arrays are absent or non-array instead of coercing, and treat ok:true differently from a failure frame. Raised by 4 of 8 reviewers (claude-opus-5-thinking-max adversarial+edge-case, gpt-5.6-sol-max adversarial+edge-case).
|
|
||
| const markSent = (batch: BatchRecord<TOp>): void => { | ||
| ledger.markInFlight(batch.opIds) | ||
| sent.push(batch) |
There was a problem hiding this comment.
🟡 Medium — sent is append-only — batches are never pruned after reconciliation, only by reset() — while the reconciler's reconciledBatches set grows in lockstep. sentBatches() reallocates the whole history on every doc_ops_result and the correlation loop rescans every already-reconciled batch, making result handling O(n²) in ops per session with unbounded retained memory (each record holds the full op objects). Give the dispatcher a way to retire reconciled batches. Raised by 6 of 8 reviewers (claude-opus-5-thinking-max adversarial+edge-case, gpt-5.6-sol-max adversarial, gemini-3.1-pro adversarial+edge-case, kimi-k3-max adversarial).
| bucket.push(opId) | ||
| } | ||
|
|
||
| for (const opId of outcome.applied) |
There was a problem hiding this comment.
🟡 Medium — reconcileOpsResult never checks that applied/skipped/failedOpId are disjoint or members of outcome.batch — the resolved guard only covers the unprocessed loop. An id in two buckets is transitioned twice (last write wins) and counted in both summary buckets, and an id from a different in-flight batch is transitioned under this batch's reconciliation, after which markInFlight refuses to re-fly it; the reconciler then reverts summary.failed, so a stray failed.op_id reverts an unrelated op. Validate membership and disjointness and report violations rather than applying them. Raised by 2 of 8 reviewers (claude-opus-5-thinking-max adversarial, kimi-k3-max adversarial+edge-case).
| const listeners = new Set<(change: ShadowChange) => void>() | ||
|
|
||
| const notify = (change: ShadowChange) => { | ||
| for (const listener of listeners) listener(change) |
There was a problem hiding this comment.
🟡 Medium — notify invokes subscribers synchronously with no isolation, and show/revert/clear are called inside per-op loops in the dispatcher and reconciler. A throwing listener during dispatch's enqueue loop aborts before any BatchRecord exists, leaving ops registered in the ledger and shadowed but belonging to no sent or unsent batch — unretryable, unrevertable, and unmatched by the reconciler until reset(); a throw during rollback or clearAll similarly leaves the ledger and shadow half-updated. Wrap listener invocation in try/catch and iterate over a snapshot of listeners. Raised by 4 of 8 reviewers (claude-opus-5-thinking-max adversarial, gpt-5.6-sol-max adversarial+edge-case, kimi-k3-max adversarial+edge-case).
|
@coderabbitai review |
|
christian-byrne
left a comment
There was a problem hiding this comment.
Review by glary (AI reviewer), ported 1:1 from Slack — glary's sandbox token cannot post GitHub reviews, so this is posted on its behalf.
Slack thread: https://comfy-organization.slack.com/archives/C0AQ646ELUR/p1788173777443639
Reviewed together with #16375 and #16365; only the portions targeting this PR are included here.
Review: changes requested
Two reviewer models read all 13 changed files independently and reached the same verdict; I verified the host-side emitter, the call-site census and the branch/dependency state myself.
Credit first: the per-op policy logic is genuinely good and the tests are behavioural — real ledger and shadow instances, assertions on observable state and emitted revert/clear verbs, no mock-shaped assertions. Every blocking defect below is in correlation and lifecycle, not in the policy table.
Two framing notes that recalibrate everything after them:
- Nothing renders this overlay yet.
AgentPanelRoot.vue:107destructuresstatusonly;dispatchHumanOpsis reachable solely viawindow.__agentCrdtPocand an unconsumed export; no file outsideagent/crdt/importspendingOpShadow. So no defect here is user-visible today — they are defects in a state machine that becomes load-bearing the moment a renderer attaches. - This branch cannot currently land on
mainfor reasons invisible from the GitHub diff. See the integration section at the bottom; I'd resolve that before spending more review cycles on the logic.
Test status: 113/113 green against this branch's own base, but 18/113 failing against main's pinned dependency — explained below.
MAJOR 1 (blocking) — a batch the host rejects wholesale is never reverted and never reconciled
opsResultReconciler.ts:139-155
mentioned is built only from applied ∪ skipped ∪ {failed.op_id} (:143-144), and a batch matches only if sent.opIds.some(id => mentioned.has(id)) (:150). Empty mentioned ⇒ batch === null ⇒ unmatched([]) ⇒ nothing reverted, nothing cleared.
I checked the host side in cloud/services/ingest/server/services/websocket/doc_relay.go. Four sites emit DocOpsResultFrame{V, WorkflowID, OK:false, Code, Reason} with no Applied, Skipped, Failed or Seq:
| line | code | trigger |
|---|---|---|
| 449 | overloaded |
relay backpressure — documented as normal and retryable |
| 648 | invalid_frame |
ParseDocOps failed |
| 658 | unsupported |
docService == nil — every send on a deployment without the doc surface |
| 680 | docErrorCode(err) |
any ApplyOps error: relay timeout, permission, not-found, seq contention |
docFrameClient.ts:160-182 accepts all four (it requires only v/workflow_id/ok and defaults applied/skipped to []). The batch then stays inflight permanently: retryUnsent can't reach it (markSent already moved it to sent), no effect frame will ever exist because nothing was applied, and there is no timeout.
Aggravating detail: docFrameClient.ts does parse code, and onOpsResult (useAgentCrdtFollower.ts:327) passes the full parsed frame in — but parseResult (opsResultReconciler.ts:88-105) drops it. The one field that distinguishes "host never reached the applier, revert everything" from "applier ran, honour per-op outcomes" is available at the reconciler's input and discarded.
This is the only finding where a routine host frame drives a wrong transition, and it is explicitly not fixed by the planned s3-opt-3 clear-on-effect work, since a rejected batch produces no effect to clear on.
Suggested fix: mint a batch ordinal on SentBatch at markSent; when mentioned is empty, resolve to the oldest unreconciled batch. Stop discarding code — ok:false with a code and no per-op detail means nothing landed, so revert the whole batch. Do not key correlation on workflowId: three of the four relay paths send orPlaceholder(workflowIDOf(payload)), not the real id.
MAJOR 2 — lastSeq is never reset, so a new lineage's ack reads as already projected
useAgentCrdtFollower.ts:150, 183, 286
lastSeq is declared at :150 and assigned at exactly one place, :286. It is reset nowhere — not in onDocReset (:334-354), not in the workflowId watch (:404-430), not in onReconnected (:366-371, which discards the projection via projector.reset() while lastSeq keeps asserting coverage of it).
opsResultReconciler.ts:112 documents currentSeq as "the highest seq the follower has PROJECTED." After a lineage break the host restarts seq numbering, so projectedSeq >= parsed.seq (:181) compares a new-lineage ack against the dead lineage's high-water mark and passes trivially. The skipped entry is then cleared on the ack with nothing projected in the new lineage — exactly the behaviour the module header (:18-26) says must never happen.
The irony is sharp: onDocReset calls reconciler.reset() with the comment "awaiting-skipped seqs belong to the dead lineage's numbering" — but the quantity those seqs are compared against is left stale.
Fix: reset lastSeq in onDocReset, the workflowId watch and onReconnected, and seed it from doc_subscribed.seq in onSubscribed.
MAJOR 3 — a workflow rebind leaves the dispatcher armed; document A's ops can be sent into document B
useAgentCrdtFollower.ts:170-174 (root cause), :404-430 (fix site)
The workflowId watch resets projector and knownDocNodeIds (:409-410) but calls neither dispatcher.reset() nor reconciler.reset() — unlike onDocReset (:347-349) and onBeforeUnmount (:441-442), which do both.
Unsent batches minted against A therefore survive, and the new subscription's doc_subscribed{ok:true} reaches retryPendingOps() → retryUnsent() → bridge.sendHumanOps(tabId, …), which addresses whatever sentWorkflowId currently is. The send closure at :173 carries no document identity at all, so nothing downstream can catch the mismatch.
onDocReset's own comment — "pending ops were minted against the dead lineage — drop them rather than retry them into a doc they no longer describe" — applies verbatim and was not carried over.
Fix: call dispatcher.reset() and reconciler.reset() in the workflowId watch next to projector.reset(). Binding a workflow id onto each batch and validating it at send time is the more robust variant, since it also defends the sent-path bookkeeping.
MAJOR 4 — a sent batch whose result frame is lost has no timeout and no recovery
humanOpDispatcher.ts:117-123
Enumerated exhaustively: retryUnsent iterates unsent only; onReconnected calls bridge.resubscribe() only; the bridge's gap-detected resubscribe never touches the dispatcher; the workflowId watch is MAJOR 3. Only doc_reset and unmount clear a stuck sent batch. A socket death between host-send and delivery strands the batch permanently.
Worth stating precisely: doc_ops_result is TCP-ordered and reliable while the socket lives, so the realistic trigger is socket death — relay backpressure does reply, and that reply is MAJOR 1. MAJOR 1 and 4 are the same terminal state reached two ways, and MAJOR 1 needs no packet loss at all.
Fix: a bounded result timeout for sent batches, or clear them on reconnect/resubscribe.
MAJOR 5 (declared scope gap, but it gates the stack) — applied entries have no terminal transition
opsResultReconciler.ts:193-200; pendingOpLedger.ts:110, 215
clearOnEffect has zero production call sites (declaration, docstring and tests only). shadow.clear(opId) has exactly one call site — opsResultReconciler.ts:134, inside clearSkipped, reachable only for skipped. clearAll() is reachable only from dispatcher.reset().
So on the happy path — op applied, doc_update arrives, projection folds it — the entry stays applied and the shadow stays visible until doc_reset or unmount. The state machine's terminal transition is absent, and it fires on every successful edit.
I'm scoring this as a gate on the stack rather than a defect introduced by this diff: the module header (:12-16) explicitly states the clear-on-effect wiring is s3-opt-3, and the deferral is technically forced for precise correlation — DocUpdateFrame carries no op ids (cloud/common/websocket/messages/crdt.go:159-165). The honest statement is that the stack does not yet meet its convergence goal on the success path, by design. Worth considering: a coarse actor-based settle is implementable today, since the effect frame carries actor and onUpdate already reads it at :307.
MINOR
opsResultReconciler.ts:179-191,:204-220— a skipped entry can await a seq that is never projected. The only exit isonAuthoritativeState, driven solely from thedoc_updatehandler (:290); the header's claim that this is "bounded by the follower's own gap machinery" is overstated, since the gap detector only fires on a laterdoc_update. Needs a compound coincidence (dropped covering broadcast and the document then goes idle forever), and unlike MAJOR 1/4 it is cleared bydoc_reset/unmount. Note for whoever fixes it:result.seq > currentSeq()is not proof of a gap —res.Seqis the post-apply doc seq and its broadcast is normally still in flight, so resubscribing on it would trigger spurious catch-up on routine acks.opsResultReconciler.ts:157-163— mentioned ids are passed toledger.reconcileOpsResultverbatim, not intersected with the matched batch, so a frame spanning two batches double-transitions ids andappliedKeptreports ids outsidebatch. Requires a host that coalesces across batches — and after a workflow switch such a frame is not always harmlessly unmatched, since stale ledger ids persist.opsResultReconciler.ts:157-190— no self-consistency guard. Whenok === trueandfailedOpId === null,summary.unprocessedmust be empty by contract; a non-empty one means the frame contradicts itself, and the code silently reverts live ops on that contradiction.humanOpDispatcher.ts:117, 198-200;opsResultReconciler.ts:119, 147-154—sentandreconciledBatchesare append-only untilreset(), andsentBatches()re-allocates the full history on every result frame. Unbounded retention plus quadratic cumulative scanning.
Test quality — MINOR but load-bearing
opsResultReconciler.test.ts:79-89gives false confidence in the exact policy row that is broken. It's titled "rolls back the whole remainder when the failure has no identifiable op id", but its fixture passesapplied: ['op-a']— and that non-emptyappliedis precisely what makes correlation succeed. The case the title names is MAJOR 1, and it is untested. Fixing this one fixture would have caught the bug.- No multi-op
ok:truefull-success test. The nearest coverage (:190-200) is single-op and asserts only resulting state, never thatrolledBackis empty — a regression reverting the applied prefix on success would not be caught.
NIT
layoutFollowerBridge.ts:254-257—forwardFrameomits the!== sentWorkflowIdguard thatonDocUpdateandonDocResetboth apply.useAgentCrdtFollower.ts:201-209—retryPendingOps's guard proves the subscribe frame left, not that the host confirmed it.- The shadow surface's public API (
isPending/pendingTargets/subscribe) has no consumer today. processedWidgetRenderModel.ts:462, 515— unrelated trailing-comma churn swept in by the automated-lint commit.
Checked and correct
parseResult returning null and stringArray's element filter are unreachable defensive code, not a defect: onOpsResult receives event.detail from layoutFollowerBridge.forwardFrame, which forwards DocFrameClient's already-parsed DocOpsResult — docFrameClient.ts:167-176 has already coerced applied/skipped to string[] and guaranteed ok is boolean. Consistent with the codebase's tolerant-parse convention. (It does mean the malformed-frame test at :153-161 pins a shape the module cannot receive.)
Integration blockers (not visible in this diff)
This PR targets nathaniel/agent-panel-v1, which is not in main. I test-merged and cherry-picked the stack to check what landing actually costs.
1. The wiring conflicts, though the pure layers don't. Cherry-picking onto main: the ledger and shadow commits apply cleanly; the dispatch-wiring commit conflicts on useAgentCrdtFollower.ts and devPanelLog.ts.
2. Dependency API break. main, #16375 and #16365 all pin @comfyorg/comfy-multi-player at git SHA 58e2333 (0.2.0). This branch pins 0.1.0. Version 0.2.0 removed initDoc and metaMap:
schemaGuard.ts:23, 51on this branch still imports and callsmetaMap—mainhas already ported that same file toreadSchemaVersionfollowerSubscription.test.ts:22, 79, 421, 456, 461, which this PR modifies, callsinitDocandmetaMapfollowerSeam.integration.test.ts:28, 84likewise
That's why the suite is 113/113 on this branch's own pin and 18/113 against main's (TypeError: initDoc is not a function, TypeError: metaMap is not a function).
3. A competing settle mechanism already exists on main. main has opSender.ts — batching, retry, one-in-flight serialization, onBatchSettled, and a staleAnonymousBudget credit system for exactly the late/duplicate-result hazard this PR reasons about. This branch's base has no opSender.ts at all, and humanOpDispatcher.ts is a direct functional competitor for that role. opSender's own docblock (:12-16) reserves this precise work:
Outcome handling is deliberately the TODAY contract:
doc_ops_resultis a binary applied/skipped split. The prefix-abort reconcile and per-op outcome-union surfacing … land when the host frame upgrade ships;onResultis the seam they will replace.
So this PR implements prefix-abort reconcile against a substrate main has superseded, rather than against the seam main reserved for it. The wiring reviewed here is not wiring that can ship.
Recommendation: rebase onto main and re-target the reconciler at opSender's onBatchSettled / onResult seam before further review investment. The pure reconciler and ledger logic is worth keeping and mostly ports as-is; the dispatcher layer probably does not survive the rebase. Worth confirming that judgement with whoever owns opSender before doing the work.
Suggested order of work
- Settle the rebase question above — it determines whether items 2-5 are written against
humanOpDispatcheroropSender. - Correlate without depending on echoed op ids, and stop discarding
code(MAJOR 1). - Reset
lastSeqon reset / rebind / reconnect, and seed it fromdoc_subscribed.seq(MAJOR 2). - Reset the dispatcher and reconciler in the
workflowIdwatch (MAJOR 3). - Bounded result timeout for
sentbatches (MAJOR 4). - Fix the misleading
applied: ['op-a']fixture and add a multi-op success test. - Then the minors: intersect mentioned ids with the matched batch, add the
ok:true/unprocessedconsistency guard, boundsent/reconciledBatchesgrowth.
|
BLOCKED (frozen head branch) — cheap-drain lane cannot execute PR #16332 head branch A rebase/retarget to Live PR state at claim time: head |
|
One real bug inline - held ops can leak into the next workflow after a switch - plus two small ones. Nothing else blocking.
|
…#16362) ## Summary Adds a focused R-73 characterization test for CRDT follower workflow switches on current `main` (`f954e479a37b`). The test records the main-line difference from the original PR Comfy-Org#16332 risk: transport retries keep the workflow captured when the operation was enqueued, so that half is now a regression guard rather than a live reproducer. It also captures the remaining behavior: a late `doc_ops_result` for workflow A is still forwarded and settles by `op_id` while workflow B is active, because the result path does not gate on `workflowId`. ## Verification - `pnpm test:unit src/workbench/extensions/agent/crdt/crossWorkflowPending.test.ts` - pre-commit hook passed: `oxfmt`, `oxlint`, `eslint`, `pnpm typecheck` ## Notes Test-only change for the CRDT/agent dev-facing seam. No production reset policy or result-frame workflow gate is changed here.
## Summary Adds a focused R-73 characterization test for CRDT follower workflow switches on current `main` (`f954e479a37b`). The test records the main-line difference from the original PR #16332 risk: transport retries keep the workflow captured when the operation was enqueued, so that half is now a regression guard rather than a live reproducer. It also captures the remaining behavior: a late `doc_ops_result` for workflow A is still forwarded and settles by `op_id` while workflow B is active, because the result path does not gate on `workflowId`. ## Verification - `pnpm test:unit src/workbench/extensions/agent/crdt/crossWorkflowPending.test.ts` - pre-commit hook passed: `oxfmt`, `oxlint`, `eslint`, `pnpm typecheck` ## Notes Test-only change for the CRDT/agent dev-facing seam. No production reset policy or result-frame workflow gate is changed here.
Full context for agent readers#16309 folded the applied/failed/unprocessed reconciliation into |
…opt-2) (#16671) - Skipped-duplicate shadows now clear on a covering projection (host `doc_ops_result.seq` ≤ projected `doc_update.seq`), never on the ack itself; failed/unprocessed rollback from #16309 is unchanged - Re-expresses the skipped policy of #16332 (base branch `nathaniel/agent-panel-v1`, now closed lineage) onto the main-based tracker; #16332 stays as source history - Green: 252/252 crdt suite (7 new tests), typecheck, oxlint/eslint, oxfmt, knip <details><summary>Full context for agent readers</summary> ## What The s3-opt-6 tracker (#16309) already handles `applied` (keep until effect), `failed` (revert), and unprocessed suffix (revert). The one outcome it could not finish was `skipped`: the host had already applied that op on a previous delivery, so **no later `doc_update` will ever carry its op id** and the shadow lingered until reset. This PR closes that gap. **Stack:** cut from `fix/s3opt6-dispatch-wiring` (#16309, head `d49dcaa1ba`). Review only the top commit, `678fc7e177`. ## Policy | Situation | Behavior | |---|---| | ack `skipped:[id]` with `seq`, and `bridge.lastSequence >= seq` | clear shadow + take ledger entry immediately (authoritative state already on screen) | | ack `skipped:[id]` with `seq`, projection behind | park id keyed by `seq`; clear on the first applied `doc_update` whose `seq >= ack.seq` | | ack `skipped:[id]` without `seq` | park with `null`; cleared by the next applied `doc_update` | | effect frame carrying the id arrives first | `onDocEffect` still wins; the parked entry is dropped | | `doc_reset` / unmount | parked ids dropped (seqs belong to the dead lineage) | | redelivered ack | no double-resolve; ledger `take` is idempotent | ## Files - `opSender.ts`: `OpsResultView.seq?: number` (mirrors host `DocOpsResultFrame.Seq` in `cloud/common/websocket/messages/crdt.go`; FE `docFrameClient.ts` already parsed it). - `pendingOpTracker.ts`: `currentSeq()` dep, `onAuthoritativeState(seq)`, `awaitingSkipped` map, `drop()`/`clearSkipped()` helpers; dev events `skipped_awaiting` / `skipped_cleared`. - `useAgentCrdtFollower.ts`: passes `currentSeq: () => bridge.lastSequence`, maps `detail.seq` into the ack view, calls `onAuthoritativeState(update.seq)` after each applied update. - Tests: `pendingOpTracker.test.ts` (`describe('s3-opt-2: ...')`, 6 tests + reworked skipped test), `useAgentCrdtFollower.test.ts` (1 follower-level test through the real frame dispatch path). ## Re-expression of #16332 Source commit `9fdd7bb544` (`opsResultReconciler.ts`) implemented this as a separate pure reconciler over `sentBatches()`. #16309 later folded the reconciliation into `PendingOpTracker`, so the reconciler module would duplicate it; this PR instead adds only the missing skipped→covering-seq gate to the tracker. The policy table in #16332 is preserved verbatim for `skipped`; the other rows were already landed by #16309. ## Diagram ``` doc_ops_result{skipped:[id], seq:S} │ ▼ currentSeq() >= S ? ──yes──▶ clear shadow + ledger.take(id) → skipped_cleared │no ▼ awaitingSkipped[id] = S → skipped_awaiting │ │ doc_update{seq:U} applied ──▶ onAuthoritativeState(U) │ U >= S ? clear : keep waiting │ └─ doc_update{opIds:[id]} ──▶ onDocEffect(id) wins, drops parked entry ``` ## Evidence - Branch `fix/s3opt2-skipped-seq-gate` @ `678fc7e1770495d827d96a2a6e569049e3f3ef13`, base `fix/s3opt6-dispatch-wiring` @ `d49dcaa1bad961684cbaedf4f06035deccdad857` - `pnpm exec vitest run src/workbench/extensions/agent/crdt` → 21 files, **252 passed** (was 245 on base) - `pnpm exec vue-tsc --noEmit` → clean - `oxfmt --check`, `oxlint`, `eslint` on the 5 touched files → 0 warnings / 0 errors - `knip --cache` → no findings for touched modules; pre-commit lint-staged (oxfmt, oxlint type-aware, eslint, typecheck) passed - Source of policy: #16332 head `a49ac021f1`, commit `9fdd7bb544` ## Glossary - **s3-opt-2 / s3-opt-6**: program work items for outcome reconciliation (skipped duplicates) and dispatch wiring of the pending ledger/shadow. - **projection**: an applied `doc_update` frame; its `seq` is the host's authoritative document sequence. - **covering seq**: a projected `seq` ≥ the `seq` reported on a `doc_ops_result`, meaning the projected state already includes that batch. - **shadow**: the local pending overlay drawn for an op that has been sent but not yet confirmed by an effect frame. - **ledger**: `PendingOpLedger` entries tracking sent op ids until resolved. </details> <!-- authored-by:agent role-hard-problem -->
|
Closing as superseded: the skipped-duplicate reconciliation policy this PR implements against the dead |
…opt-2) (#16671) - Skipped-duplicate shadows now clear on a covering projection (host `doc_ops_result.seq` ≤ projected `doc_update.seq`), never on the ack itself; failed/unprocessed rollback from #16309 is unchanged - Re-expresses the skipped policy of #16332 (base branch `nathaniel/agent-panel-v1`, now closed lineage) onto the main-based tracker; #16332 stays as source history - Green: 252/252 crdt suite (7 new tests), typecheck, oxlint/eslint, oxfmt, knip <details><summary>Full context for agent readers</summary> ## What The s3-opt-6 tracker (#16309) already handles `applied` (keep until effect), `failed` (revert), and unprocessed suffix (revert). The one outcome it could not finish was `skipped`: the host had already applied that op on a previous delivery, so **no later `doc_update` will ever carry its op id** and the shadow lingered until reset. This PR closes that gap. **Stack:** cut from `fix/s3opt6-dispatch-wiring` (#16309, head `d49dcaa1ba`). Review only the top commit, `678fc7e177`. ## Policy | Situation | Behavior | |---|---| | ack `skipped:[id]` with `seq`, and `bridge.lastSequence >= seq` | clear shadow + take ledger entry immediately (authoritative state already on screen) | | ack `skipped:[id]` with `seq`, projection behind | park id keyed by `seq`; clear on the first applied `doc_update` whose `seq >= ack.seq` | | ack `skipped:[id]` without `seq` | park with `null`; cleared by the next applied `doc_update` | | effect frame carrying the id arrives first | `onDocEffect` still wins; the parked entry is dropped | | `doc_reset` / unmount | parked ids dropped (seqs belong to the dead lineage) | | redelivered ack | no double-resolve; ledger `take` is idempotent | ## Files - `opSender.ts`: `OpsResultView.seq?: number` (mirrors host `DocOpsResultFrame.Seq` in `cloud/common/websocket/messages/crdt.go`; FE `docFrameClient.ts` already parsed it). - `pendingOpTracker.ts`: `currentSeq()` dep, `onAuthoritativeState(seq)`, `awaitingSkipped` map, `drop()`/`clearSkipped()` helpers; dev events `skipped_awaiting` / `skipped_cleared`. - `useAgentCrdtFollower.ts`: passes `currentSeq: () => bridge.lastSequence`, maps `detail.seq` into the ack view, calls `onAuthoritativeState(update.seq)` after each applied update. - Tests: `pendingOpTracker.test.ts` (`describe('s3-opt-2: ...')`, 6 tests + reworked skipped test), `useAgentCrdtFollower.test.ts` (1 follower-level test through the real frame dispatch path). ## Re-expression of #16332 Source commit `9fdd7bb544` (`opsResultReconciler.ts`) implemented this as a separate pure reconciler over `sentBatches()`. #16309 later folded the reconciliation into `PendingOpTracker`, so the reconciler module would duplicate it; this PR instead adds only the missing skipped→covering-seq gate to the tracker. The policy table in #16332 is preserved verbatim for `skipped`; the other rows were already landed by #16309. ## Diagram ``` doc_ops_result{skipped:[id], seq:S} │ ▼ currentSeq() >= S ? ──yes──▶ clear shadow + ledger.take(id) → skipped_cleared │no ▼ awaitingSkipped[id] = S → skipped_awaiting │ │ doc_update{seq:U} applied ──▶ onAuthoritativeState(U) │ U >= S ? clear : keep waiting │ └─ doc_update{opIds:[id]} ──▶ onDocEffect(id) wins, drops parked entry ``` ## Evidence - Branch `fix/s3opt2-skipped-seq-gate` @ `678fc7e1770495d827d96a2a6e569049e3f3ef13`, base `fix/s3opt6-dispatch-wiring` @ `d49dcaa1bad961684cbaedf4f06035deccdad857` - `pnpm exec vitest run src/workbench/extensions/agent/crdt` → 21 files, **252 passed** (was 245 on base) - `pnpm exec vue-tsc --noEmit` → clean - `oxfmt --check`, `oxlint`, `eslint` on the 5 touched files → 0 warnings / 0 errors - `knip --cache` → no findings for touched modules; pre-commit lint-staged (oxfmt, oxlint type-aware, eslint, typecheck) passed - Source of policy: #16332 head `a49ac021f1`, commit `9fdd7bb544` ## Glossary - **s3-opt-2 / s3-opt-6**: program work items for outcome reconciliation (skipped duplicates) and dispatch wiring of the pending ledger/shadow. - **projection**: an applied `doc_update` frame; its `seq` is the host's authoritative document sequence. - **covering seq**: a projected `seq` ≥ the `seq` reported on a `doc_ops_result`, meaning the projected state already includes that batch. - **shadow**: the local pending overlay drawn for an op that has been sent but not yet confirmed by an effect frame. - **ledger**: `PendingOpLedger` entries tracking sent op ids until resolved. </details> <!-- authored-by:agent role-hard-problem -->
doc_ops_resultnow drives the pending overlay: applied prefix kept, failed op + unprocessed suffix rolled back, skipped duplicates cleared only on a covering projectionok:falsenever rolls back the whole batch; malformed/unmatched/redelivered frames are recorded no-opsFull context for agent readers
What
Adds
opsResultReconciler.ts, the outcome-aware policy layer that consumes eachdoc_ops_resultframe and transitions the pending-op ledger (#16288) and shadow surface (#16302) per batch member, correlated against the dispatcher's as-sent batches (#16309). Wires it intouseAgentCrdtFollower.tsand extends the dev-event union.Stack: this branch is cut from
fix/s3opt6-dispatch-wiring(#16309), which stacks on #16302 → #16288. Review only the top commit here.Policy decisions
appliedprefixappliedstate)failedoprevertverbrevertverbskippedduplicateclearverbdoc_updatewhose seq covers it. A seq-less ack is satisfied by any later projected transitionAdditional invariants:
ok:false≠ whole-batch rollback. The host applies the valid prefix and still broadcasts; only the failed op and true suffix revert.matched:false).op_id: applied prefix kept, remainder reverted as unprocessed.reconciler.reset()ondoc_reset(awaiting seqs belong to the dead lineage's numbering) and on unmount.Upstream dependency note
The cloud-side emission of op ids on effect frames is still open; this PR only needs the already-landed FE surface (
doc_ops_resultparsing incl.failed/seq, andsentBatches()on the dispatcher). Everything here is backward-compatible: with no results arriving, nothing changes.Diagram
Verification
pnpm vitest run src/workbench/extensions/agent/crdt/→ 13 files, 113 tests passed (11 new inopsResultReconciler.test.ts)pnpm typecheck,eslint,oxfmt --checkon touched files → cleanGlossary
pendingOpLedger.ts, pure op_id-keyed state machine (feat(agent): pure pending-op ledger for the optimistic overlay (s3-opt-1) #16288)pendingOpShadow.ts, presentation overlay surface withrevert/clearverbs (feat(agent): presentation-only pending-op shadow surface for the CRDT overlay #16302)humanOpDispatcher.ts, send-path integration exposingsentBatches()(feat(agent): optimistic-overlay pending ledger + shadow (retargeted to main) #16309)SemanticProjectorfolding the Yjs doc into the litegraph canvas