Skip to content

refactor(transport): implement the connections on Drive - #9564

Merged
rasswanth-s merged 3 commits into
devfrom
rasswanth/drive-split
Oct 20, 2026
Merged

rasswanth-s merged 3 commits into
devfrom
rasswanth/drive-split

Conversation

@rasswanth-s

Copy link
Copy Markdown
Collaborator

Summary

Second part of step 1 of the V1 transport split, built on #9561. ConnectionRouter stops calling GDriveConnection directly and goes through the connections from #9561, implemented on Drive. What is read from and written to Drive does not change, apart from one fix to the order the event log is read in.

Changes

  • syft/sync/connections/drive/drive_connections.py: DriveP2PConnection, DriveOwnerStore, DriveCollections, DrivePeering and DriveWatcherStore, and drive_transport() to build them. Each calls the GDriveConnection method used today. Where a contract builds a method from simpler ones, the Drive class overrides it to keep the one Drive call it makes today.
  • DriveP2PConnection only sends for now: a proposed change goes to the owner's inbox, file events to the scientist's outbox, with the file name as msg_id, and the result is DELIVERED. Reading and archiving messages stay on the GDriveConnection methods. Doing them through receive and ack changes how they behave (one rule for both folders, delete on ack, no read cursor), which lands with send-and-forget. receive and ack raise NotImplementedError.
  • DriveWatcherStore raises NotImplementedError until watcher storage on Drive is built.
  • connection_router.py:
    • Sends go through p2p.send.
    • The event log, checkpoints and rolling state go through owner_store.
    • The peer list, peer requests, key bundles and version files go through peering.
    • Datasets go through collections.
    • The router holds a Transport built from connections[0], and copy_connection calls clone_for_thread() instead of checking isinstance(GDriveConnection). It imports nothing from Drive.
  • base_connection.py: two hooks, as_transport() and clone_for_thread().
  • gdrive_transport.py:
    • implements the two hooks;
    • takes PEERS_META_KEY, SYFT_PEERS_VERSION and the message timestamp parser from naming.py, so there is one copy (they still import from here);
  • peer_manager.py: load_peers takes the peer's platform from the transport instead of creating GdriveFilesPlatform().
  • Fix: the event log is read oldest first. Drive lists files by name, newest first, and the owner restores its state by replaying event-log messages in that order. A client that restored from the event log alone ended with the older version of a file that changed twice. owner_get_all_accepted_event_file_ids, owner_download_all_raw_events_from_syftbox and download_raw_events_since_timestamp now sort by message time.

Testing

  • tests/unit/test_drive_connections.py (20 tests): each Drive connection on the mock Drive; both router sends go through p2p with the right kind; the router keeps its transport until its connection changes; the router source holds no Drive code; restoring from the event log keeps the newest version of a file changed twice. The restore test and the ordering test fail without the fix.
  • tests/unit/test_peers_json_version.py: the fake router gives a transport instead of connection_for_send_message; the assertions are unchanged.
  • The unit, syft-rds, syft-enclave, syft-job and syft-datasets suites pass, and so do the integration tests in mock mode. Two migration tests in test_dataset_multicopy_delivery.py fail on macOS, on dev as well (/tmp against /private/tmp).

Asana task

https://app.asana.com/1/1185126988600652/project/1210542925864934/task/1219496828587148

… router through them

Add DriveP2PConnection (sending), DriveOwnerStore, DriveCollections,
DrivePeering and a DriveWatcherStore placeholder over GDriveConnection, and
route ConnectionRouter through them; it no longer imports Drive code.
Receiving stays on the Drive methods until send-and-forget.

Fix: the event log is read oldest first, so restoring from it keeps the
newest version of a file that changed twice.

@pjwerneck pjwerneck left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Only minor issues. Looks good.

Comment thread syft/sync/connections/connection_router.py
Comment thread syft/sync/connections/drive/drive_connections.py Outdated
Comment thread syft/sync/connections/drive/drive_connections.py Outdated
Base automatically changed from rasswanth/transport-four-protocols to dev October 20, 2026 13:03
@rasswanth-s
rasswanth-s merged commit 418ab98 into dev Oct 20, 2026
21 checks passed
@rasswanth-s
rasswanth-s deleted the rasswanth/drive-split branch October 20, 2026 13:45
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.

2 participants