Skip to content

refactor: Added initial stub contracts - #9561

Open
rasswanth-s wants to merge 4 commits into
devfrom
rasswanth/transport-four-protocols
Open

rasswanth-s wants to merge 4 commits into
devfrom
rasswanth/transport-four-protocols

Conversation

@rasswanth-s

Copy link
Copy Markdown
Collaborator

Summary

Changes

Testing

Asana task


PR naming convention

Your PR title must follow this format or merging will be blocked:

type: short description in lowercase

Example titles:

  • feat: add retry logic to job approval
  • fix: handle timeout in notification sender
  • docs: update syft-bg README
  • chore: bump dependencies
  • refactor: split init flow into helpers
  • test: add criteria validation tests
  • ci: add release train workflow

Allowed types:

Type When to use Example
feat New feature or capability feat: add DS rejection emails
fix Bug fix fix: handle empty peer list
docs Documentation only docs: update syft-bg README
chore Maintenance, deps, config chore: bump dependencies
refactor Code restructuring (no behavior change) refactor: split init flow
test Adding or updating tests test: add approval criteria tests
ci CI/CD workflow changes ci: add release train workflow
perf Performance improvement perf: cache Drive API responses
build Build system or dependency changes build: pin syft-bg>=0.2.0

Just edit the PR title to fix any errors — the check re-runs automatically.

Auto-labeling

Labels are applied automatically — you don't need to add them manually:

  • Type labels from your PR title (e.g., feat: adds feature, fix: adds bugfix)
  • Package labels from which files you changed (e.g., editing packages/syft-bg/ adds pkg:syft-bg)

These labels are used to auto-generate categorized release notes.

@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.

Left a few comments. Main points:

  1. The Mailbox contract has a shape that V2 replaces. A contract with the V2 shape now prevents a second rewrite of every caller.
  2. OwnerStorage and WatcherStorage are wrappers that only forward calls to PrivateStore. Two abstract classes give the same separation with one less layer.
  3. Some abstract methods are compositions of other methods. A small set of primitives, plus helper methods on the base class, makes a backend easier to write.
  4. DeliveryTracker differs from the ticket on the first run and on persistence to Drive.

Comment thread syft/sync/transport/protocols.py Outdated
from syft.sync.version.version_info import VersionInfo


class Mailbox(ABC):

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.

Mailbox here uses list->fetch->ack, but the v2 ticket replaces this with send->receive->ack->delivered. Maybe we can define the v2 shape now and move the callers only once, doing the list and fetch inside received.

Comment thread syft/sync/transport/protocols.py Outdated
"""

@abstractmethod
def list(

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.

Why do we have different behavior for PROPOSALS and EVENTS, in the same method? Can't both use the same rules from the start?

Comment thread syft/sync/transport/protocols.py Outdated
"""


class PrivateStore(ABC):

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.

Why are we combining both peer registry, owner, and watcher in a single PrivateStore class, while OwnerStorage and WatcherStorage only forward each call here? It feels like there's an unnecessary layer here. With two OwnerStore and WatcherStore classes instead of a single PrivateStore, there's no need for the intermediary layer.

Comment thread syft/sync/transport/protocols.py Outdated
"""Every events message in my event log."""

@abstractmethod
def fetch_events_since(self, since_timestamp: float) -> list[bytes]:

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.

There's some redundancy in these event log methods. Three primitive methods are enough: append_event, list_event_handles(since) and fetch(handle). The others can be concrete implementations on the base class instead of abstracts to be implemented by the concrete class.

  • fetch_all_events() is fetch_events_since(None)
  • fetch_events_since(t) is fetch for each handle from list_event_handles(t).
  • count_events_since(t) is len(list_event_handles(t)).

Comment thread syft/sync/transport/protocols.py Outdated
def delete_rolling_state(self) -> None:
"""Remove the rolling state."""

# -- peer registry (SYFT_peers.json) ---------------------------------------

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.

The v1 ticket has the peer registry methods in PeeringConnection. It's fine to be in PrivateStore, but the ticket should be updated to avoid confusion.

Comment thread syft/sync/transport/protocols.py Outdated
"""The bytes of one collection file."""


class PeerState(ABC):

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.

The name PeerState is already used by the enum at syft.sync.peers.peer.PeerState. The docstring warns about it, but it should have a different name.

"""Let ``peer`` read the key bundles I publish."""

@abstractmethod
def read_peer_key_bundle(self, peer: str) -> str | None:

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.

This can read the key bundle of a peer, but it cannot read the bundle of this client. The auto encryption settings work (branch pjwerneck/auto-encryption-settings) adds read_own_encryption_bundle to the Drive connection. Please add read_own_key_bundle(peer) here, so the two branches merge without a change to the contract.

"""Let ``peer`` read my version document."""


class Transport(BaseModel):

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.

The ticket calls this Connections not Transport. Transport is a better name, but the ticket should be updated.

Comment thread syft/sync/sync/delivery_tracker.py Outdated
next sync.

Open decisions (see research/merged_transport_plan.md):
- First run with no views: assume current peers hold what they may read

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.

The ticket says: Lost view → PeerReset → resend everything. This docstring proposes that if no view exist, the tracker assumes that each peer already holds all files it can read.

This prevents a full resend after the upgrade, but a peer that does not have a file never gets it.

Comment thread syft/sync/sync/delivery_tracker.py Outdated
- First run with no views: assume current peers hold what they may read
(proposed), or resend everything.
- A rejected peer approved again: reset its view and resend (proposed).
- Enclaves lose the views at every boot until they are also kept on Drive.

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.

The ticket keeps the views on Drive when persist_owner_state is true. It adds deliveries and peer_resets to RollingState and IncrementalCheckpoint, and peer_views to Checkpoint. Deliveries also count toward the upload threshold of the rolling state.

This stub keeps the views only in a local file (line 32). Is persistence to Drive in v2, or later? If it is later, an enclave loses the views at each boot. Then it sends all files again to each peer, or it sends nothing, as decided for line 21.

This branch has not been deployed

No deployments
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