Skip to content

Ruthwik/hosted/single session#3127

Draft
ruthwikdasyam wants to merge 3 commits into
mainfrom
ruthwik/hosted/single-session
Draft

Ruthwik/hosted/single session#3127
ruthwikdasyam wants to merge 3 commits into
mainfrom
ruthwik/hosted/single-session

Conversation

@ruthwikdasyam

Copy link
Copy Markdown
Contributor

Contribution path

  • Small, safe change that does not need a tracking issue
  • Linked issue or discussion: DIM-XXX / #XXX / URL

Problem

Solution

How to Test

AI assistance

Checklist

  • I have read and approved the CLA.

A broker session is a single RTCPeerConnection and so lives in one process;
the provider is a per-process singleton, so broker-bound modules spread across
worker processes each opened their own session (the operator only ever reaches
one, leaving the rest dead). Blueprints worked around this by hand-pinning all
broker-bound modules into one worker.

Instead, the workers self-elect a single session owner via a machine-local
flock keyed on BrokerConfig + DIMOS_RUN_ID (no coordinator involvement). The
owner runs the real BrokerProvider plus a SessionRelay; every other worker
resolves to a ProxyBrokerProvider that forwards publish/subscribe/video over a
shared-memory session bus to the owner. Result: exactly one CF session per
blueprint for any n_workers, with the transport/blueprint API unchanged.

- session_bus.py: SHM bridge (session-keyed subjects; reliable CpuShmQueue for
  the control plane, latest-wins for lossy channels, frame subject for video).
- broker_proxy.py: ProxyBrokerProvider, SessionRelay, elect_session_owner.
- broker.py: BrokerConfig._create() self-elects; _OwnerBrokerProvider runs the
  relay and holds the ownership lock over the provider lifecycle.
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 61.39706% with 105 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...tocol/pubsub/impl/webrtc/providers/broker_proxy.py 40.13% 87 Missing and 1 partial ⚠️
...otocol/pubsub/impl/webrtc/providers/session_bus.py 64.28% 15 Missing ⚠️
...os/protocol/pubsub/impl/webrtc/providers/broker.py 93.75% 2 Missing ⚠️
@@            Coverage Diff             @@
##             main    #3127      +/-   ##
==========================================
+ Coverage   72.56%   73.16%   +0.60%     
==========================================
  Files        1025     1035      +10     
  Lines       92256    94071    +1815     
  Branches     8425     8617     +192     
==========================================
+ Hits        66941    68829    +1888     
+ Misses      23013    22900     -113     
- Partials     2302     2342      +40     
Flag Coverage Δ
OS-ubuntu-24.04-arm 66.29% <61.39%> (+0.66%) ⬆️
OS-ubuntu-latest 68.56% <61.39%> (+0.59%) ⬆️
Py-3.10 68.55% <61.39%> (+0.60%) ⬆️
Py-3.11 68.56% <61.39%> (+0.60%) ⬆️
Py-3.12 68.55% <61.39%> (+0.59%) ⬆️
Py-3.13 68.56% <61.39%> (+0.59%) ⬆️
Py-3.14 68.56% <61.39%> (+0.59%) ⬆️
Py-3.14t 68.55% <61.39%> (+0.59%) ⬆️
SelfHosted-Large 30.04% <23.52%> (-0.04%) ⬇️
SelfHosted-Linux 37.10% <23.52%> (-0.23%) ⬇️
SelfHosted-macOS 35.99% <23.52%> (-0.20%) ⬇️

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

Files with missing lines Coverage Δ
...imos/protocol/pubsub/impl/webrtc/test_transport.py 98.46% <100.00%> (+0.24%) ⬆️
...os/protocol/pubsub/impl/webrtc/providers/broker.py 40.60% <93.75%> (+4.76%) ⬆️
...otocol/pubsub/impl/webrtc/providers/session_bus.py 64.28% <64.28%> (ø)
...tocol/pubsub/impl/webrtc/providers/broker_proxy.py 40.13% <40.13%> (ø)

... and 47 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant