Skip to content

refactor: share one connection router across a manager's parts - #9597

Merged
koenvanderveen merged 1 commit into
devfrom
koen/one-router-per-manager
Oct 29, 2026
Merged

koenvanderveen merged 1 commit into
devfrom
koen/one-router-per-manager

Conversation

@koenvanderveen

@koenvanderveen koenvanderveen commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Step 1 of making the P2P part of a manager's transport swappable (WebRTC next to Drive). Before this, a manager built four routers (peer manager, owner syncer, watcher syncer, watcher cache), each with its own connection and transport. Now it builds one and every part shares it.

Changes

  • SyftboxManager.from_config builds the peer store (PeerManager.peer_store_from_config) and one ConnectionRouter, then passes the router to each part's from_config next to its config.
  • Rule, written in the docstrings: configs hold plain values only. A live object several parts share is built once in SyftboxManager.from_config and passed in as a required argument.
  • connection_configs moves off the four part configs onto SyftboxManagerConfig. That field didn't exist before: for_colab passed it and pydantic silently dropped it.
  • Removed _set_peer_store (it rewired four routers after construction). _peer_store is now a property that reads the router's store. _add_connection and reset_all_connection_caches work on one router.

Tests

  • New tests/unit/test_shared_router.py: every part shares one router and peer store, from_config builds exactly one connection, a mock connection is added once and backs the transport.
  • Three tests that build a part on its own now pass an empty router via router_without_connections().
  • Unit and migration tests: 824 passed. syft-rds sync and version-mismatch tests: 30 passed. syft-enclave test_encryption.py: 4 passed.

SyftboxManager.from_config builds the peer store and one ConnectionRouter, and passes the router to each part's from_config next to its plain config. Configs keep plain values only; connection_configs moves to SyftboxManagerConfig, where for_colab already passed it but pydantic dropped it.
@koenvanderveen
koenvanderveen merged commit 4703c36 into dev Oct 29, 2026
22 checks passed
@koenvanderveen
koenvanderveen deleted the koen/one-router-per-manager branch October 29, 2026 14:24
koenvanderveen added a commit that referenced this pull request Oct 30, 2026
Resolve the overlap with the transport PRs on dev (#9594, #9595, #9597, #9599):

- The manager builds the transport at init, as on dev. as_transport, the
  router's connection list and transport_for_thread are gone.
- Each Drive component holds the DriveLayout and its own Drive code, as on
  this branch.
- Each component copies itself for another thread with clone_for_thread, as
  on dev. The copy runs over a layout clone with a new Drive service, which
  GDriveClient builds with its new_service factory.
- Inbox and outbox reading move into DriveP2PConnection, with dev's parallel
  receive and batched archive. delete_all moves into DriveOwnerStore.
  GDriveConnection only logs in and builds the layout.
- Tests reach Drive through drive_layout_of(transport), which replaces
  gdrive_connection_of.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant