Network connection speaks the transport-neutral Peer protocol

オープン
#371 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python

調査の方向性

Start in morango/sync/syncsession.py at the private HTTP methods around lines 457-517, then compare request data with NetworkOperation.create_transfer_session in morango/sync/operations.py:1209-1217. Add the six Peer methods while preserving request behavior, convert returned state through PeerTransferSession, unwrap pull results, and verify the characterization and full test suites pass.

索引モデルが issue の本文から書いたものです。

説明

DEV: backend P0 - critical TAG: tech update / debt

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_session
  • get_transfer_session
  • update_transfer_session
  • close_transfer_session
  • push_record_chunk
  • pull_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 NetworkSyncConnection with 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, and ignore_404 behavior.
  • A 404 response on close does not raise an error.
Acceptance Criteria
  • For each of the six methods, a test with a mocked SessionWrapper.request shows the same method, URL, and body as the private counterpart.
  • Each method that returns state returns a PeerTransferSession equal to PeerTransferSession.from_api_json of the response.
  • pull_record_chunk returns the inner list when the response is {"results": [...]}.
  • close_transfer_session does 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_session at morango/sync/operations.py:1209-1217.
  • Data Model & Schema Considerations: None. The methods use PeerTransferSession from #369.
  • Resilience & Failure Modes: HTTP retries and error behavior stay the same as today.

Notes & Tradeoffs

  • Dependencies: Blocked by: #369 (PeerTransferSession value object), #370 (Connection interface). Blocks: #372, #374, #384.
  • Testing Requirements: This is a refactor task. The characterization suite from #363 and #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.

主要言語
Python
スター
15
フォーク
27
平均マージ
6日 44分
マージ済み PR(30日)
13

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

learningequality/morango のほかの issue

learningequality/morango の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。