Give archive metadata a typed, immutable form

未关闭
#377 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
70/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
backend, database

调研方向

Start with the planned new module morango/sync/archive.py and the ArchiveManifestEntry model from #376, then compare peer-info construction with MorangoInfoViewSet at morango/api/viewsets.py:491. Run the unit tests in tests/testapp/tests/sync/test_archive.py; done means round-trip equality, peer-info keys, unknown-key preservation, immutable fields, and replace() behavior.

由索引模型根据 Issue 内容生成。

描述

DEV: backend P0 - critical TAG: new feature

Overview

An ArchiveManifest value object gives the archive metadata typed fields, and it converts to and from the stored rows. This work is part of milestone M5.

Background & Motivation

The metadata rows hold JSON strings. Callers must not parse these strings themselves. A typed value object keeps the parsing in one place. It also gives the disk connection its peer info, in the same shape that a morango server gives.

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

Description & Expected Outcomes

ArchiveManifest has one field for each metadata key in spec §3.4. It converts to a list of ArchiveManifestEntry rows and back. If the rows contain a key that the reader does not know, the manifest keeps it. This lets metadata from a newer writer survive a read.

The manifest gives a peer info dict with the same shape as the morango info endpoint. A replace method returns a changed copy and does not change the original.

Deliverables & Contracts

The value object delivers these capabilities:

  • Conversion to and from ArchiveManifestEntry rows, with JSON values.
  • to_peer_info(), with the keys instance_id, instance_hash, version, and capabilities, plus the keys of instance_info.
  • replace(**changes), which returns a new manifest.
  • Immutable fields.
Acceptance Criteria
  • A manifest converted to rows and back is equal to the original.
  • to_peer_info() contains the four keys and the merged instance_info keys.
  • An unknown row key survives the conversion to a manifest and back to rows.
  • replace(filter="x") returns a new manifest, and the original is not changed.

Technical Pointers & Architecture

  • Target Components / Context: New module morango/sync/archive.py.
  • Related Patterns: The peer info shape comes from MorangoInfoViewSet at morango/api/viewsets.py:491.
  • Data Model & Schema Considerations: Uses the ArchiveManifestEntry model from #376. The code must work on Python 3.6, so dataclasses is not available.
  • Resilience & Failure Modes: None.

Notes & Tradeoffs

  • Dependencies: Blocked by: #376 (ArchiveManifestEntry model). Blocks: #378, #382.
  • Testing Requirements: Unit tests in tests/testapp/tests/sync/test_archive.py.
  • Tradeoffs & Alternatives Considered: The spec keeps the table as key and value rows, and it gives callers only the typed form.
  • Compatibility & Migrations: Unknown keys survive, so an older reader does not lose data from a newer writer.

Metadata

  • Complexity: Low
  • 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 分钟
30 天内合并 PR
13

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

learningequality/morango 的其他 Issue

查看 learningequality/morango 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。