Sync stage operations work with any peer connection

Aperta
#374 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
30/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

Start with morango/sync/operations.py:1201-1620 and the linked design spec and implementation plan, noting that #368, #371, and #373 are prerequisites. Review the characterization and network contract suites, then update the operation structure and test patch target described in the issue; done means all listed acceptance suites pass, including SQLite and PostgreSQL.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

DEV: backend P0 - critical

Overview

One set of Peer*Operation classes drives the peer side of each transfer stage, through the Peer protocol. This work is part of milestone M4.

Background & Motivation

Today the Network*Operation classes call private HTTP methods on the connection. This ties the client-side stage logic to the network. Shared operations let the network and disk connections use the same logic. Import and resume support for disk can then reuse the same code later.

This task changes no behavior for network syncs.

Design: spec. Plan: implementation plan, Task 13.

Description & Expected Outcomes

A PeerOperation base class handles every PeerSessionContext. Its helper methods call the Peer protocol and read PeerTransferSession values.

Eight shared operations get the bodies of the current network operations:

  • PeerInitializeOperation
  • PeerSerializeOperation
  • PeerQueueOperation
  • PeerPushTransferOperation
  • PeerPullTransferOperation
  • PeerDequeueOperation
  • PeerDeserializeOperation
  • PeerCleanupOperation

Two new base classes handle one connection type each. NetworkOperation handles NetworkSessionContext, and DiskOperation handles DiskSessionContext. The LegacyNetwork* operations become subclasses of NetworkOperation, because legacy peers are always servers.

Deliverables & Contracts

The operations deliver these capabilities:

  • Each Peer*Operation returns the same status as the current network operation for the same state.
  • No operation reads or calls a private _… member of the connection.
  • The push operation reads its records with _serialize_buffer_chunk and the local database from the context.
Acceptance Criteria
  • A fake Peer protocol connection shows the same status as the current operations for all eight stages. The push case uses two chunks.
  • A test fails if an operation touches a connection attribute that starts with _.
  • The characterization suite passes without edits.
  • The network half of the contract suite passes without edits.
  • The full test suite passes on SQLite and with tox -e postgres.

Technical Pointers & Architecture

  • Target Components / Context: morango/sync/operations.py:1201-1620.
  • Related Patterns: get_buffers validation at morango/sync/operations.py:1256-1289 stays the same.
  • Data Model & Schema Considerations: None.
  • Resilience & Failure Modes: remote_proceed_to keeps its handling of completed and in-progress statuses.

Notes & Tradeoffs

  • Dependencies: Blocked by: #368 (_serialize_buffer_chunk), #371 (Peer protocol on the network connection), #373 (context hierarchy). Blocks: #375.
  • Testing Requirements: This is a refactor task. The characterization suite from #363 and #364 must pass without edits. One existing test changes: tests/testapp/tests/integration/test_syncsession.py:374 patches NetworkOperation.put_buffers. The method moves to PeerOperation, so the patch target changes to it.
  • Tradeoffs & Alternatives Considered: The spec rejects separate Disk*Operation classes for every stage. They copy the client-side logic, and pull and resume need that logic again later.
  • Compatibility & Migrations: #375 keeps the old Network*Operation names.

Metadata

  • Complexity: High
  • 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.

Lingua principale
Python
Stelle
15
Fork
27
Merge medio
6g 44m
PR unite (30g)
13

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di learningequality/morango

Tutte le issue di learningequality/morango

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.