Repository navigation
Description
Overview
NetworkSyncConnection implements the six methods of the Peer protocol. This work is part of milestone M3 (connection seam refactor).
Background & Motivation
Today the network operations call private HTTP methods on the connection and read raw JSON. The Peer protocol gives operations one interface for transfer sessions, and the network connection becomes one adapter for it. A second adapter for the archive comes later.
This task changes no behavior. The network connection sends the same HTTP requests as before.
Design: spec. Plan: implementation plan, Task 10.
Description & Expected Outcomes
NetworkSyncConnection gets these public methods:
create_transfer_sessionget_transfer_sessionupdate_transfer_sessionclose_transfer_sessionpush_record_chunkpull_record_chunk
Each method sends the same request as the private _… method that it replaces. Methods that return transfer session state return a PeerTransferSession value, not raw JSON. The pull method returns a list of records, and it removes the pagination wrapper when the server sends one.
Deliverables & Contracts
The connection delivers these capabilities:
- The six Peer protocol methods exist on
NetworkSyncConnectionwith the signatures in spec §3.2. - Each method sends the same HTTP method, URL, and body as its private counterpart.
- The private
_…methods keep their names, retries, gzip behavior, andignore_404behavior. - A 404 response on close does not raise an error.
Acceptance Criteria
- For each of the six methods, a test with a mocked
SessionWrapper.requestshows the same method, URL, and body as the private counterpart. - Each method that returns state returns a
PeerTransferSessionequal toPeerTransferSession.from_api_jsonof the response. -
pull_record_chunkreturns the inner list when the response is{"results": [...]}. -
close_transfer_sessiondoes not raise on a 404 response. - The characterization suite passes without edits.
- The full test suite passes.
Technical Pointers & Architecture
- Target Components / Context:
morango/sync/syncsession.py, private HTTP methods at:457-517. - Related Patterns: The request data for create comes from
NetworkOperation.create_transfer_sessionatmorango/sync/operations.py:1209-1217. - Data Model & Schema Considerations: None. The methods use
PeerTransferSessionfrom Typed value for the peer view of a transfer session #369. - Resilience & Failure Modes: HTTP retries and error behavior stay the same as today.
Notes & Tradeoffs
- Dependencies: Blocked by: Typed value for the peer view of a transfer session #369 (
PeerTransferSessionvalue object), Shared connection interface for network and disk syncs #370 (Connectioninterface). Blocks: Contract tests define the Peer protocol against a real server #372, Sync stage operations work with any peer connection #374, Receive pushed data into an archive through the Peer protocol #384. - Testing Requirements: This is a refactor task. The characterization suite from Tests that pin today's async network push and pull behavior #363 and Tests that pin today's legacy network sync behavior #364 must pass without edits.
- Tradeoffs & Alternatives Considered: The spec rejects a disk connection that copies the HTTP method shapes. The Peer protocol uses transfer session values so that both adapters fit it.
- Compatibility & Migrations: No change to the wire format or to public methods that exist today.
Metadata
- Complexity: Medium
- Target Branch: release-v0.9.x
AI Usage
Drafted with Claude (Claude Code) from the approved design spec and implementation plan. The author reviewed the requirements, and the code references were checked against the release-v0.9.x codebase.
Activity