Medlar/Plans/02 Engine/S006-manager.md
2026-11-25 02:34:27 -06:00

1.5 KiB

S006 — Download manager, events and snapshots

Category 02 Engine · Model: Opus · Effort: medium · Depends on: S005 · Size: M · Human: no Files touched: crates/core/src/{manager,events,snapshot,speed}, crates/core/tests/manager

Goal

Many downloads with a lifecycle, and the one API that UI, CLI and connector use. FEATURES 1.1, 2.3 (order only), 7.3 (redownload), parts of 7.2.

Read

  • crates/core/src (model, store, segment)
  • docs/DECISIONS.md

Steps

  • Commands: add, start, pause, resume, stop, remove (keep or bin files), redownload, move, rename; all idempotent and safe in any state
  • Running set chosen by active limit, priority and order; per-host caps respected
  • Snapshot for the UI: cheap, lock-free to read, only changed tasks copied; 10,000 tasks test
  • Speed and time-left smoothing that doesn't jump; per-second history ring per task and total
  • Per-task log with redaction; counters for statistics
  • Start-up restore and clean shutdown: pause everything in under 2 s
  • Dev binary or test example that downloads from the test server with text progress
  • docs/PROGRESS.md entry, tick Plans/INDEX.md, commit S006: …, push

End criteria

  • nice cargo test -j 2 -p medlar-core --test manager green, with a concurrent command fuzz of 10,000 random operations and no deadlock or illegal state

Pitfalls

The UI thread must never wait on the engine.

Handoff (→ PROGRESS.md)

Command and snapshot API, frozen for UI plans.