Skip to content

feat(agent): outcome-aware doc_ops_result reconciliation for the pending overlay - #16332

Closed
christian-byrne wants to merge 5 commits into
nathaniel/agent-panel-v1from
fix/s3opt2-outcome-reconciliation
Closed

christian-byrne wants to merge 5 commits into
nathaniel/agent-panel-v1from
fix/s3opt2-outcome-reconciliation

Conversation

@christian-byrne

Copy link
Copy Markdown
Contributor
  • doc_ops_result now drives the pending overlay: applied prefix kept, failed op + unprocessed suffix rolled back, skipped duplicates cleared only on a covering projection
  • ok:false never rolls back the whole batch; malformed/unmatched/redelivered frames are recorded no-ops
  • Pure reconciler module + 11 tests; green (113/113 crdt suite, typecheck, lint, format)
Full context for agent readers

What

Adds opsResultReconciler.ts, the outcome-aware policy layer that consumes each doc_ops_result frame 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 into useAgentCrdtFollower.ts and 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

Outcome Ledger Shadow Rationale
applied prefix kept (applied state) kept visible Cleared only by its authoritative EFFECT (KA-9); clear-on-effect wiring is a separate task, not this PR
failed op removed revert verb Host rejected this exact op; replaying identical content would fail identically
unprocessed suffix removed revert verb Host aborts the remainder at the first rejection; the suffix typically depends on the failed op, so auto-retrying it without its predecessor would replay a broken intent. Re-doing is explicit user action
skipped duplicate removed on covering projection clear verb The op already existed host-side, so no new broadcast will come. Never cleared on the ack itself: cleared immediately when the follower's projected seq already covers the ack seq (the authoritative state is on screen), else on the first projected doc_update whose seq covers it. A seq-less ack is satisfied by any later projected transition

Additional invariants:

  • ok:false ≠ whole-batch rollback. The host applies the valid prefix and still broadcasts; only the failed op and true suffix revert.
  • Validated, not trusted. Malformed frames and frames whose op ids match no unreconciled sent batch are recorded no-ops (matched:false).
  • Redelivery-safe. Each sent batch reconciles at most once; a redelivered result cannot double-revert.
  • Failure without an identifiable op_id: applied prefix kept, remainder reverted as unprocessed.
  • Lifecycle: reconciler.reset() on doc_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_result parsing incl. failed/seq, and sentBatches() on the dispatcher). Everything here is backward-compatible: with no results arriving, nothing changes.

Diagram

doc_ops_result ──▶ reconcile(result, sentBatches)
                     │  validate + correlate (first unreconciled batch
                     │  intersecting mentioned op ids; once per batch)
                     ▼
        ┌────────────┼──────────────────┬─────────────────────┐
     applied       failed          unprocessed             skipped
        │            │                  │                     │
     KEEP        revert shadow     revert shadow      seq covered by
   (await        + take ledger     + take ledger      projection?
    effect)                                            │yes        │no
                                                   clear shadow   await
                                                   + take ledger    │
                                                        ▲           │
                             onAuthoritativeState(seq) ─┘◀─ doc_update
                                                             projected

Verification

  • pnpm vitest run src/workbench/extensions/agent/crdt/ → 13 files, 113 tests passed (11 new in opsResultReconciler.test.ts)
  • pnpm typecheck, eslint, oxfmt --check on touched files → clean
  • Pre-push knip gate → green

Glossary

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.
@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 5 minutes.

View limit details

Limit 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.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 748dd281-9bf7-439e-87cc-8dee63ee53ca

📥 Commits

Reviewing files that changed from the base of the PR and between 583ad3b and a49ac02.

📒 Files selected for processing (13)
  • src/renderer/extensions/vueNodes/composables/processedWidgetRenderModel.ts
  • src/workbench/extensions/agent/crdt/devPanelLog.ts
  • src/workbench/extensions/agent/crdt/followerSubscription.test.ts
  • src/workbench/extensions/agent/crdt/humanOpDispatcher.test.ts
  • src/workbench/extensions/agent/crdt/humanOpDispatcher.ts
  • src/workbench/extensions/agent/crdt/layoutFollowerBridge.ts
  • src/workbench/extensions/agent/crdt/opsResultReconciler.test.ts
  • src/workbench/extensions/agent/crdt/opsResultReconciler.ts
  • src/workbench/extensions/agent/crdt/pendingOpLedger.test.ts
  • src/workbench/extensions/agent/crdt/pendingOpLedger.ts
  • src/workbench/extensions/agent/crdt/pendingOpShadow.test.ts
  • src/workbench/extensions/agent/crdt/pendingOpShadow.ts
  • src/workbench/extensions/agent/crdt/useAgentCrdtFollower.ts

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

@github-actions

github-actions Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright: ❌ 1898 passed, 55 failed · 4 flaky

❌ Failed Tests

📊 Browser Reports
  • chromium: View Report (✅ 1887 / ❌ 50 / ⚠️ 4 / ⏭️ 5)
  • chromium-2x: View Report (✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • chromium-0.5x: View Report (✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • mobile-chrome: View Report (✅ 8 / ❌ 5 / ⚠️ 0 / ⏭️ 0)

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 08/31/2026, 01:57:26 AM UTC

Links

📦 Bundle Size

⏳ Size data collection in progress…

⚡ Performance Report

canvas-idle: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 94.1 MB heap
canvas-mouse-sweep: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 84.6 MB heap
canvas-zoom-sweep: · 60.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 0ms TBT · 98.0 MB heap
dom-widget-clipping: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 99.1 MB heap
large-graph-idle: · 60.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 0ms TBT · 114.9 MB heap
large-graph-pan: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 106.9 MB heap
large-graph-zoom: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 107.9 MB heap
legacy-node-drag: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 124.3 MB heap
minimap-idle: · 60.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 0ms TBT · 116.5 MB heap
subgraph-dom-widget-clipping: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 96.5 MB heap
subgraph-idle: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 95.2 MB heap
subgraph-mouse-sweep: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 99.4 MB heap
subgraph-transition-enter: · 60.0 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 153ms TBT · 119.3 MB heap
viewport-pan-sweep: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 92.3 MB heap
vue-large-graph-idle: · 58.1 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 0ms TBT · 189.7 MB heap
vue-large-graph-pan: · 56.3 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 115ms TBT · 197.5 MB heap
workflow-execution: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 92.9 MB heap

ℹ️ No baseline found — significance unavailable.

Absolute values
Metric Value
canvas-idle: avg frame time 17ms
canvas-idle: p95 frame time 17ms
canvas-idle: layout duration 0ms
canvas-idle: style recalc duration 8ms
canvas-idle: layout count 0
canvas-idle: style recalc count 7
canvas-idle: task duration 471ms
canvas-idle: script duration 7ms
canvas-idle: TBT 0ms
canvas-idle: heap used 94.1 MB
canvas-idle: DOM nodes 14
canvas-idle: event listeners 5
canvas-mouse-sweep: avg frame time 17ms
canvas-mouse-sweep: p95 frame time 17ms
canvas-mouse-sweep: layout duration 5ms
canvas-mouse-sweep: style recalc duration 42ms
canvas-mouse-sweep: layout count 14
canvas-mouse-sweep: style recalc count 83
canvas-mouse-sweep: task duration 1111ms
canvas-mouse-sweep: script duration 151ms
canvas-mouse-sweep: TBT 0ms
canvas-mouse-sweep: heap used 84.6 MB
canvas-mouse-sweep: DOM nodes 64
canvas-mouse-sweep: event listeners 6
canvas-zoom-sweep: avg frame time 17ms
canvas-zoom-sweep: p95 frame time 17ms
canvas-zoom-sweep: layout duration 1ms
canvas-zoom-sweep: style recalc duration 17ms
canvas-zoom-sweep: layout count 6
canvas-zoom-sweep: style recalc count 33
canvas-zoom-sweep: task duration 352ms
canvas-zoom-sweep: script duration 11ms
canvas-zoom-sweep: TBT 0ms
canvas-zoom-sweep: heap used 98.0 MB
canvas-zoom-sweep: DOM nodes 77
canvas-zoom-sweep: event listeners 19
dom-widget-clipping: avg frame time 17ms
dom-widget-clipping: p95 frame time 17ms
dom-widget-clipping: layout duration 0ms
dom-widget-clipping: style recalc duration 8ms
dom-widget-clipping: layout count 0
dom-widget-clipping: style recalc count 13
dom-widget-clipping: task duration 666ms
dom-widget-clipping: script duration 139ms
dom-widget-clipping: TBT 0ms
dom-widget-clipping: heap used 99.1 MB
dom-widget-clipping: DOM nodes 18
dom-widget-clipping: event listeners 2
large-graph-idle: avg frame time 17ms
large-graph-idle: p95 frame time 17ms
large-graph-idle: layout duration 0ms
large-graph-idle: style recalc duration 4ms
large-graph-idle: layout count 0
large-graph-idle: style recalc count 5
large-graph-idle: task duration 487ms
large-graph-idle: script duration 28ms
large-graph-idle: TBT 0ms
large-graph-idle: heap used 114.9 MB
large-graph-idle: DOM nodes 9
large-graph-idle: event listeners 5
large-graph-pan: avg frame time 17ms
large-graph-pan: p95 frame time 17ms
large-graph-pan: layout duration 0ms
large-graph-pan: style recalc duration 11ms
large-graph-pan: layout count 0
large-graph-pan: style recalc count 66
large-graph-pan: task duration 2363ms
large-graph-pan: script duration 866ms
large-graph-pan: TBT 0ms
large-graph-pan: heap used 106.9 MB
large-graph-pan: DOM nodes 7
large-graph-pan: event listeners 8
large-graph-zoom: avg frame time 17ms
large-graph-zoom: p95 frame time 17ms
large-graph-zoom: layout duration 12ms
large-graph-zoom: style recalc duration 11ms
large-graph-zoom: layout count 60
large-graph-zoom: style recalc count 66
large-graph-zoom: task duration 2336ms
large-graph-zoom: script duration 815ms
large-graph-zoom: TBT 0ms
large-graph-zoom: heap used 107.9 MB
large-graph-zoom: DOM nodes 24
large-graph-zoom: event listeners 11
legacy-node-drag: avg frame time 17ms
legacy-node-drag: p95 frame time 17ms
legacy-node-drag: layout duration 0ms
legacy-node-drag: style recalc duration 6ms
legacy-node-drag: layout count 0
legacy-node-drag: style recalc count 42
legacy-node-drag: task duration 3349ms
legacy-node-drag: script duration 926ms
legacy-node-drag: TBT 0ms
legacy-node-drag: heap used 124.3 MB
legacy-node-drag: DOM nodes 4
legacy-node-drag: event listeners 192
minimap-idle: avg frame time 17ms
minimap-idle: p95 frame time 17ms
minimap-idle: layout duration 0ms
minimap-idle: style recalc duration 4ms
minimap-idle: layout count 0
minimap-idle: style recalc count 5
minimap-idle: task duration 491ms
minimap-idle: script duration 29ms
minimap-idle: TBT 0ms
minimap-idle: heap used 116.5 MB
minimap-idle: DOM nodes 9
minimap-idle: event listeners 4
subgraph-dom-widget-clipping: avg frame time 17ms
subgraph-dom-widget-clipping: p95 frame time 17ms
subgraph-dom-widget-clipping: layout duration 0ms
subgraph-dom-widget-clipping: style recalc duration 10ms
subgraph-dom-widget-clipping: layout count 0
subgraph-dom-widget-clipping: style recalc count 46
subgraph-dom-widget-clipping: task duration 488ms
subgraph-dom-widget-clipping: script duration 135ms
subgraph-dom-widget-clipping: TBT 0ms
subgraph-dom-widget-clipping: heap used 96.5 MB
subgraph-dom-widget-clipping: DOM nodes 18
subgraph-dom-widget-clipping: event listeners 7
subgraph-idle: avg frame time 17ms
subgraph-idle: p95 frame time 17ms
subgraph-idle: layout duration 0ms
subgraph-idle: style recalc duration 7ms
subgraph-idle: layout count 0
subgraph-idle: style recalc count 9
subgraph-idle: task duration 426ms
subgraph-idle: script duration 7ms
subgraph-idle: TBT 0ms
subgraph-idle: heap used 95.2 MB
subgraph-idle: DOM nodes 17
subgraph-idle: event listeners 6
subgraph-mouse-sweep: avg frame time 17ms
subgraph-mouse-sweep: p95 frame time 17ms
subgraph-mouse-sweep: layout duration 6ms
subgraph-mouse-sweep: style recalc duration 38ms
subgraph-mouse-sweep: layout count 18
subgraph-mouse-sweep: style recalc count 78
subgraph-mouse-sweep: task duration 1032ms
subgraph-mouse-sweep: script duration 110ms
subgraph-mouse-sweep: TBT 0ms
subgraph-mouse-sweep: heap used 99.4 MB
subgraph-mouse-sweep: DOM nodes 67
subgraph-mouse-sweep: event listeners 5
subgraph-transition-enter: avg frame time 17ms
subgraph-transition-enter: p95 frame time 17ms
subgraph-transition-enter: layout duration 16ms
subgraph-transition-enter: style recalc duration 32ms
subgraph-transition-enter: layout count 14
subgraph-transition-enter: style recalc count 18
subgraph-transition-enter: task duration 908ms
subgraph-transition-enter: script duration 30ms
subgraph-transition-enter: TBT 153ms
subgraph-transition-enter: heap used 119.3 MB
subgraph-transition-enter: DOM nodes 13671
subgraph-transition-enter: event listeners 2381
viewport-pan-sweep: avg frame time 17ms
viewport-pan-sweep: p95 frame time 17ms
viewport-pan-sweep: layout duration 0ms
viewport-pan-sweep: style recalc duration 34ms
viewport-pan-sweep: layout count 0
viewport-pan-sweep: style recalc count 247
viewport-pan-sweep: task duration 8525ms
viewport-pan-sweep: script duration 2994ms
viewport-pan-sweep: TBT 0ms
viewport-pan-sweep: heap used 92.3 MB
viewport-pan-sweep: DOM nodes -282
viewport-pan-sweep: event listeners -179
vue-large-graph-idle: avg frame time 17ms
vue-large-graph-idle: p95 frame time 17ms
vue-large-graph-idle: layout duration 0ms
vue-large-graph-idle: style recalc duration 0ms
vue-large-graph-idle: layout count 0
vue-large-graph-idle: style recalc count 0
vue-large-graph-idle: task duration 15390ms
vue-large-graph-idle: script duration 286ms
vue-large-graph-idle: TBT 0ms
vue-large-graph-idle: heap used 189.7 MB
vue-large-graph-idle: DOM nodes -6548
vue-large-graph-idle: event listeners -7457
vue-large-graph-pan: avg frame time 18ms
vue-large-graph-pan: p95 frame time 17ms
vue-large-graph-pan: layout duration 0ms
vue-large-graph-pan: style recalc duration 17ms
vue-large-graph-pan: layout count 0
vue-large-graph-pan: style recalc count 178
vue-large-graph-pan: task duration 20580ms
vue-large-graph-pan: script duration 902ms
vue-large-graph-pan: TBT 115ms
vue-large-graph-pan: heap used 197.5 MB
vue-large-graph-pan: DOM nodes -6548
vue-large-graph-pan: event listeners -7449
workflow-execution: avg frame time 17ms
workflow-execution: p95 frame time 17ms
workflow-execution: layout duration 1ms
workflow-execution: style recalc duration 22ms
workflow-execution: layout count 3
workflow-execution: style recalc count 15
workflow-execution: task duration 115ms
workflow-execution: script duration 6ms
workflow-execution: TBT 0ms
workflow-execution: heap used 92.9 MB
workflow-execution: DOM nodes 129
workflow-execution: event listeners 62
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
    }
  ]
}

@comfy-pr-bot
comfy-pr-bot requested a review from a team as a code owner August 31, 2026 01:55
@github-actions github-actions Bot added the risk:R2 PR risk grade (advisory shadow check; grader-owned) label Aug 31, 2026
@codecov

codecov Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.30650% with 41 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ench/extensions/agent/crdt/useAgentCrdtFollower.ts 0.00% 40 Missing ⚠️
...bench/extensions/agent/crdt/opsResultReconciler.ts 98.57% 1 Missing ⚠️
@@                     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     
Flag Coverage Δ
e2e 66.89% <ø> (-0.01%) ⬇️
unit 75.91% <87.30%> (+0.11%) ⬆️
website-unit ?

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

Files with missing lines Coverage Δ
...vueNodes/composables/processedWidgetRenderModel.ts 97.12% <ø> (ø)
src/workbench/extensions/agent/crdt/devPanelLog.ts 28.57% <ø> (ø)
...rkbench/extensions/agent/crdt/humanOpDispatcher.ts 100.00% <100.00%> (ø)
...ench/extensions/agent/crdt/layoutFollowerBridge.ts 96.87% <100.00%> (+4.16%) ⬆️
...workbench/extensions/agent/crdt/pendingOpLedger.ts 100.00% <100.00%> (ø)
...workbench/extensions/agent/crdt/pendingOpShadow.ts 100.00% <100.00%> (ø)
...bench/extensions/agent/crdt/opsResultReconciler.ts 98.57% <98.57%> (ø)
...ench/extensions/agent/crdt/useAgentCrdtFollower.ts 5.92% <0.00%> (-0.85%) ⬇️

... and 351 files with indirect coverage changes

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

@christian-byrne

Copy link
Copy Markdown
Contributor Author

TL;DR: exact-head review at a49ac021 found two related workflow-isolation bugs and one destructive result-validation bug. These look blocking because they can route or discard human intent; permanent regression tests should accompany the fixes.

Full context for agent readers

issue: switching workflows in useAgentCrdtFollower.ts:404-428 resets projection state but does not call dispatcher.reset() or reconciler.reset(), unlike doc_reset and unmount. Because retryPendingOps() sends through the bridge's current workflow binding, queued operations from workflow A can be retried into workflow B. Would it be cleaner to make the workflow switch a hard dispatcher/reconciler boundary and add an A→B regression covering queued and inflight batches?

issue: opsResultReconciler.ts:87-175 accepts a result after any op_id overlap, records the batch as reconciled, and treats unmentioned members as rollback candidates. A sent [a,b] plus {ok:true, applied:[a]} can therefore discard b, and foreign or contradictory result members can consume a legitimate batch. Could validation require a unique, disjoint, internally consistent partition for the selected batch before mutating reconciledBatches or the ledger, with table/property cases for omitted, duplicate, foreign, contradictory, and reordered outcomes?

issue: DocOpsResult includes workflowId, but opsResultReconciler.ts:73-104 drops it and correlation is op_id-only; layoutFollowerBridge.ts:178-181 forwards these results without the workflow filtering used for updates. A late A result after binding B can mutate B-session overlay bookkeeping. Please bind reconciliation to workflow identity and cover the late-result sequence.

suggestion: (non-blocking) sent and reconciledBatches are append-only until reset, making each result scan grow with session history. Consuming the matched sent record or using a stable batch token would bound this metadata and simplify correlation.

No raw-Yjs follower write, overlay-to-doc merge, op_id regeneration, or FIFO retry regression was found. I treated clear-on-authoritative-effect as separately scoped work, not a defect in this PR.

@christian-byrne christian-byrne self-assigned this Aug 31, 2026
@christian-byrne christian-byrne added the cursor-review Trigger multi-model Cursor agent review on this PR label Aug 31, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 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])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 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>()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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]) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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).

@christian-byrne

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@christian-byrne christian-byrne left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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:

  1. Nothing renders this overlay yet. AgentPanelRoot.vue:107 destructures status only; dispatchHumanOps is reachable solely via window.__agentCrdtPoc and an unconsumed export; no file outside agent/crdt/ imports pendingOpShadow. So no defect here is user-visible today — they are defects in a state machine that becomes load-bearing the moment a renderer attaches.
  2. This branch cannot currently land on main for 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 is onAuthoritativeState, driven solely from the doc_update handler (: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 later doc_update. Needs a compound coincidence (dropped covering broadcast and the document then goes idle forever), and unlike MAJOR 1/4 it is cleared by doc_reset/unmount. Note for whoever fixes it: result.seq > currentSeq() is not proof of a gap — res.Seq is 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 to ledger.reconcileOpsResult verbatim, not intersected with the matched batch, so a frame spanning two batches double-transitions ids and appliedKept reports ids outside batch. 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. When ok === true and failedOpId === null, summary.unprocessed must 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 — sent and reconciledBatches are append-only until reset(), and sentBatches() 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-89 gives 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 passes applied: ['op-a'] — and that non-empty applied is 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:true full-success test. The nearest coverage (:190-200) is single-op and asserts only resulting state, never that rolledBack is empty — a regression reverting the applied prefix on success would not be caught.

NIT

  • layoutFollowerBridge.ts:254-257 — forwardFrame omits the !== sentWorkflowId guard that onDocUpdate and onDocReset both 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, 51 on this branch still imports and calls metaMap — main has already ported that same file to readSchemaVersion
  • followerSubscription.test.ts:22, 79, 421, 456, 461, which this PR modifies, calls initDoc and metaMap
  • followerSeam.integration.test.ts:28, 84 likewise

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_result is a binary applied/skipped split. The prefix-abort reconcile and per-op outcome-union surfacing … land when the host frame upgrade ships; onResult is 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

  1. Settle the rebase question above — it determines whether items 2-5 are written against humanOpDispatcher or opSender.
  2. Correlate without depending on echoed op ids, and stop discarding code (MAJOR 1).
  3. Reset lastSeq on reset / rebind / reconnect, and seed it from doc_subscribed.seq (MAJOR 2).
  4. Reset the dispatcher and reconciler in the workflowId watch (MAJOR 3).
  5. Bounded result timeout for sent batches (MAJOR 4).
  6. Fix the misleading applied: ['op-a'] fixture and add a multi-op success test.
  7. Then the minors: intersect mentioned ids with the matched batch, add the ok:true/unprocessed consistency guard, bound sent/reconciledBatches growth.

@christian-byrne

Copy link
Copy Markdown
Contributor Author

BLOCKED (frozen head branch) — cheap-drain lane cannot execute act-fe-16332-rebase.

PR #16332 head branch fix/s3opt2-outcome-reconciliation is registered in program/frozen-branches.md (line 13): retarget requires high-tier CRDT seam reconciliation vs #16288/#16302/#16373; commits would deepen the divergence. Unfreeze condition: high-tier reconciliation lane completes; branches become source-history-only.

A rebase/retarget to main would force-push the rebased result onto this frozen head branch, which the freeze registry forbids. No branch, base, or review thread was mutated.

Live PR state at claim time: head a49ac021f193fc6b6ce81004f2319c9877f77399, base nathaniel/agent-panel-v1, MERGEABLE, OPEN, non-draft, author christian-byrne. Same class as the BLOCKED sibling act-fe-16309-rebase-482f0636 (same base branch, tier:high, blocked on CRDT seam redesign). Reassign to a high-tier CRDT-seam reconciliation lane; do not re-claim from cheap-drain.

@CodeJuggernaut

Copy link
Copy Markdown
Contributor

One real bug inline - held ops can leak into the next workflow after a switch - plus two small ones. Nothing else blocking.

src/workbench/extensions/agent/crdt/devPanelLog.ts:21

Severity: Minor

What: Four new kinds joined the DevEventKind union, but the hand-maintained EVENT_KINDS array (CrdtDevPanel.vue:65) was not updated, and its readonly DevEventKind[] type cannot catch the drift.

Why this is an issue: The new events render in the unfiltered log but cannot be selected, isolated, or copied - the exact tooling for debugging the dispatch/reconcile path this PR adds.

Proposed Fix: Append 'human_ops_rejected', 'human_ops_retry', 'ops_result_reconciled', 'skipped_shadows_cleared' to EVENT_KINDS.

src/workbench/extensions/agent/crdt/opsResultReconciler.ts:155

Severity: Note

What: unmatched([...mentioned]) reports every id the frame mentioned as unknown, whose JSDoc promises "ids the ledger does not hold".

Why this is an issue: On a redelivered batch the two disagree - ids report unknown while still held as applied. Harmless today (the only caller gates on matched), misleading the first time someone logs it or drives retry off it.

Proposed Fix: Narrow the JSDoc ("on an unmatched frame this is all mentioned ids") or filter to ids the ledger truly lacks.

pull Bot pushed a commit to Penguinjanator/ComfyUI_frontend that referenced this pull request Sep 1, 2026
…#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.
christian-byrne added a commit that referenced this pull request Sep 2, 2026
## 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.
@huang47 huang47 added the risk:high PR risk grade (advisory shadow check; grader-owned) label Sep 2, 2026 — with ChatGPT Codex Connector
@huang47 huang47 removed the risk:R2 PR risk grade (advisory shadow check; grader-owned) label Sep 2, 2026
@christian-byrne

Copy link
Copy Markdown
Contributor Author
Full context for agent readers

#16309 folded the applied/failed/unprocessed reconciliation into PendingOpTracker, so the standalone opsResultReconciler.ts from 9fdd7bb544 would now duplicate it. #16671 (fix/s3opt2-skipped-seq-gate @ 678fc7e177) adds only the remaining piece: skipped ids park keyed by the ack seq and clear on the first projected doc_update with seq >= ack.seq (or immediately if bridge.lastSequence already covers it; seq-less acks clear on the next projection). Policy table row for skipped preserved verbatim; 252/252 crdt tests, typecheck, lint, format green.

christian-byrne added a commit that referenced this pull request Sep 2, 2026
…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 -->
@christian-byrne

Copy link
Copy Markdown
Contributor Author

Closing as superseded: the skipped-duplicate reconciliation policy this PR implements against the dead nathaniel/agent-panel-v1 base has been re-expressed on the main-based tracker in #16671 (merged, 678fc7e177), per that PR's own body ("Re-expresses the skipped policy of #16332 ... onto the main-based tracker; #16332 stays as source history"). applied/failed/unprocessed-suffix outcomes landed earlier via #16309's stack (#16288 merged, #16302/#16309 open on main). No further retarget of this branch is planned; it stays as source history only.

christian-byrne added a commit that referenced this pull request Sep 6, 2026
…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 -->
@DrJKL DrJKL added agent Comfy Agent product, integration, tests or product documentation agent-crdt Agent document synchronization, graph projection or CRDT operations agent-test-unit Touches Agent-related unit/component tests or their support agent-ui Agent panel, composer, transcript or other user-interface components labels Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Comfy Agent product, integration, tests or product documentation agent-crdt Agent document synchronization, graph projection or CRDT operations agent-test-unit Touches Agent-related unit/component tests or their support agent-ui Agent panel, composer, transcript or other user-interface components cursor-review Trigger multi-model Cursor agent review on this PR risk:high PR risk grade (advisory shadow check; grader-owned)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants