feat(mesh): session singleton + [mesh] optional dependency#100
Closed
cagataycali wants to merge 1 commit intostrands-labs:mainfrom
Closed
feat(mesh): session singleton + [mesh] optional dependency#100cagataycali wants to merge 1 commit intostrands-labs:mainfrom
cagataycali wants to merge 1 commit intostrands-labs:mainfrom
Conversation
Add strands_robots/mesh_session.py — a ref-counted Zenoh session singleton that will be shared by all Mesh instances in the process. Design: - MeshConfig (frozen dataclass) reads ZENOH_CONNECT, ZENOH_LISTEN, STRANDS_MESH_PORT from environment - get_session() / release_session() with thread-safe ref counting - Auto-mesh: first process listens on localhost:7447, subsequent processes connect as clients - STRANDS_MESH=false global kill switch - Lazy import: eclipse-zenoh is not required at import time - session_info() for dashboard diagnostics pyproject.toml: - Add [mesh] extra: eclipse-zenoh>=0.11.0,<0.12.0 - Add [mesh] to [all] extras - Add mypy override for mesh_session (zenoh types are Any) Tests: 22 tests, 98% coverage, all mock-based (no network) - MeshConfig construction, frozen, from_env parsing - Ref counting: acquire, release, close-at-zero, reopen - Auto-mesh: listener mode vs client fallback - Kill switch, zenoh-not-installed graceful degradation - Thread safety: 4 threads × 50 acquire/release cycles Part 1 of 6 for v0.4.0 Zenoh mesh — see cagataycali/strands-gtc-nvidia#313
Member
Author
8 tasks
This was referenced Apr 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
strands_robots/mesh_session.py— a thread-safe, ref-counted Zenoh session singleton that will be shared by allMeshinstances in the same process.Part 1 of 6 for v0.4.0 Zenoh mesh networking. See implementation plan.
What's in this PR
New files
strands_robots/mesh_session.pyMeshConfig, auto-meshtests/test_mesh_session.pyModified files
pyproject.toml[mesh]extra (eclipse-zenoh>=0.11.0,<0.12.0), add to[all], mypy overrideDesign decisions
Module, not subpackage —
mesh_session.pylives atstrands_robots/level. Themesh/subpackage comes in PR 2 when there are multiple files to organize.MeshConfig(frozen=True)— Immutable after creation for thread safety. ReadsZENOH_CONNECT,ZENOH_LISTEN,STRANDS_MESH_PORTfrom env.Auto-mesh — When no env vars are set, the first process on a host listens on
tcp/127.0.0.1:7447; subsequent processes connect as clients. Zero config required.STRANDS_MESH=falsekill switch — Disables mesh globally before any zenoh import.Lazy import —
eclipse-zenohis imported viaimportlib.import_module()only whenget_session()is called. No import-time dependency.Version pin
>=0.11.0,<0.12.0— eclipse-zenoh 1.0 has API breaks in subscriber patterns. Conservative pin for safety; broadened after testing.Return
Any—get_session()returnsAny(notzenoh.Session) to avoid forcing zenoh as an import-time dependency. Consistent with how the codebase handles other optional deps (torch, lerobot).API
Test results
What's next
[mesh]extraMeshclass + presence + peer discoverytell/send/broadcast+ response correlationpublish_step+subscribe+on_streamemergency_stop+ safety audit logRobot.__init__Prototype provenance:
dashboard-zenoh-fixes:strands_robots/zenoh_mesh.py(691 LOC, battle-tested with 2 SO-100 arms, 10 simulated G1 humanoids, Mac↔Jetson Thor Wi-Fi at 50Hz).🤖 AI agent response. Strands Agents. Feedback welcome!