Shared connection interface for network and disk syncs

Abierto
#370 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Refactorización
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

Resolve the dependency on #369, then read morango/sync/syncsession.py around Connection, NetworkSyncConnection, and TransferClient.init. Review the characterization suite from #363 and #364 and tests/testapp/tests/sync/test_context.py before changing the interface. Done means the acceptance criteria pass, including deprecated aliases and keywords, no Morango reads of server_info, and unchanged characterization tests.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

P0 - critical TAG: dev experience TAG: new feature

Overview

This task (milestone M3) turns the empty Connection class into an abstract interface. NetworkSyncConnection implements it, and TransferClient depends only on it. The task also renames the server names that both connection types use to peer names, with deprecated aliases.

Background & Motivation

TransferClient depends on the network connection in two ways. It creates a NetworkSessionContext directly, and it reads server_info. A disk connection needs its own session context, so the connection must create it.

The word "server" does not fit a disk peer. The design uses "peer" in shared code. Hosts such as Kolibri still use server_info and the server_cert keyword, so these names stay as deprecated aliases.

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

User Story

As a Kolibri developer,
I want one connection interface for network and disk syncs,
So that sync code works with either connection type without changes.

Description & Expected Outcomes

Connection groups its members by caller: peer identity, sync session lifecycle, certificates, and the Peer protocol. The Peer protocol methods are declared here. #371 implements them for the network.

NetworkSyncConnection gets peer_info, connection_kind, and create_session_context(). The old server_info property still works and emits DeprecationWarning. create_sync_session accepts peer_cert. The old server_cert keyword still works and emits DeprecationWarning.

TransferClient builds its session context from create_session_context(), and it reads capabilities from the connection.

Deliverables & Contracts

The task delivers:

  • Connection as an abstract base class with the members in spec §3.2.
  • NetworkSyncConnection.peer_info, connection_kind = "network", and create_session_context().
  • create_sync_session(client_cert, peer_cert=None, chunk_size=None, server_cert=None).
  • A TransferClient that uses only Connection members.
Acceptance Criteria
  • NetworkSyncConnection is a subclass of Connection.
  • server_info emits DeprecationWarning and returns the same value as peer_info.
  • create_sync_session with the server_cert keyword emits DeprecationWarning and behaves like peer_cert.
  • create_sync_session with neither certificate raises ValueError.
  • The TransferClient context holds a LocalSessionContext and the context from create_session_context().
  • Morango code has no reads of server_info.
  • The characterization suite passes without edits.

Technical Pointers & Architecture

  • Target Components: morango/sync/syncsession.py:111 (Connection), :125-517 (NetworkSyncConnection), :609-626 (TransferClient.__init__).
  • Related Patterns: The deprecated names follow the same pattern as the deprecated Network* operations in #375.
  • Data Model & Schema Considerations: None. The model fields server_fsic, server_certificate, and is_server keep their names.
  • Resilience & Failure Modes: None.

Notes & Tradeoffs

  • Dependencies: Blocked by: #369 (Typed value for the peer view of a transfer session). Blocks: #371, #373, #383.
  • Testing Requirements: This is a refactor. The characterization suite from #363 and #364 must pass without edits. Tests in tests/testapp/tests/sync/test_context.py build mocks with server_info. Do not change them.
  • Tradeoffs & Alternatives Considered: A split into two interfaces was rejected. The disk transfer methods need the archive and certificates of the connection, so a split spreads connection details across two objects.
  • Compatibility & Migrations: Kolibri must move from server_info to peer_info, and from server_cert to peer_cert. The deprecated names stay until a later release.

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.

Lenguaje dominante
Python
Estrellas
15
Forks
27
Merge medio
6 d 44 min
PR fusionados (30 d)
13

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de learningequality/morango

Todos los issues de learningequality/morango

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.