fix(cmux-next): replay agent page events across bridge gaps

Merged
TE
14d ago
+768-30

Summary

Agent-page host events are now buffered during a WebView bridge gap and replayed in order on reconnect. Replay-state events stay ahead of gap events, events arriving during subscription handoff cannot overtake the queue, and cancellation returns an undelivered suffix when no listener remains. The bounded queue applies backpressure instead of silently evicting events, and page-reset drops are requeued.

Leo said yes.

Performance evidence

The opt-in Swift harness uses 1,024 ordered events on the page-provider bridge and asserts all 1,024 are delivered in order. The same before/after benchmark was submitted at the final head, but the fleet is currently host-lock saturated:

  • baseline parent: earlier attempts 3dab501dc0cdad7327cc73d2 and e19... failed before timing because the benchmark source lacked its CmuxNextSettings import; that harness compile defect is fixed in this branch.
  • fixed head a2176e62e5fcf06d227de90cfefd933bbe990be4: final focused/benchmark submissions were cancelled after the branch changed; the fleet is currently host-lock saturated and produced no terminal benchmark receipt.
  • No publish_main_ms or replay_window_ms value is claimed until a terminal fleet receipt exists.

Validation

  • AgentPageProviderEventsTests covers replay ordering, fan-out, cancelled-replay recovery, reset-drop ordering, backpressure, reconnect clearing, and pending replay recovery.
  • Opt-in fixed 1,024-event harness: AgentPageProviderBridgeGapBench.
  • Independent Codex review of exact head a2176e62e5fcf06d227de90cfefd933bbe990be4: pending; prior exact-source review SHIP on the unchanged implementation before the base-only rebase.
  • Exact head: a2176e62e5fcf06d227de90cfefd933bbe990be4.
  • No new timers or observers were added.
  • No capture: bridge buffering/replay behavior only; no visual surface change.

Agent session: big-red