Issue #29: Download Attempt — Interface Shrink to 4 Params #29

Closed
opened 2026-06-04 13:50:54 +02:00 by AlexKucera · 1 comment
AlexKucera commented 2026-06-04 13:50:54 +02:00 (Migrated from github.com)

Parent

#25 — PRD 001: Deepen Architecture — Module Depth & Domain Alignment

What to build

Shrink download_book() from 9 parameters to 4 domain-aligned parameters. Introduce DownloadResult dataclass. Move history writing out of download_book() to the caller.

End state:

  • New interface: download_book(book: Book, session: LibroFmSession, plan: OutputPlan, reporter: DownloadReporter) -> DownloadResult
  • DownloadResult frozen dataclass: status (downloaded/skipped/failed), path (Path | None), format (str | None), error (str | None)
  • History writing no longer happens inside download_book(); caller inspects result and writes
  • Format strategy + extras flags consumed from OutputPlan (not raw Config)
  • Progress callback obtained from reporter (not passed as separate param)
  • Cancel event handled internally or via reporter contract

Acceptance criteria

  • download_book() has exactly 4 parameters (plus self)
  • DownloadResult frozen dataclass with correct shape for all three statuses
  • History is NOT written by download_book(); caller writes after inspecting result
  • All download tests exercise new interface; no test passes raw Config or history to download_book()
  • M4B→MP3 fallback flow produces correct DownloadResult at each stage
  • Cancel/interrupt path produces correct DownloadResult(status="failed")

Blocked by

  • #27 — needs LibroFmSession (not old LibroFmClient)
  • #28 — needs OutputPlan (paths + format + extras)
## Parent #25 — PRD 001: Deepen Architecture — Module Depth & Domain Alignment ## What to build Shrink `download_book()` from 9 parameters to 4 domain-aligned parameters. Introduce `DownloadResult` dataclass. Move history writing out of `download_book()` to the caller. **End state:** - New interface: `download_book(book: Book, session: LibroFmSession, plan: OutputPlan, reporter: DownloadReporter) -> DownloadResult` - `DownloadResult` frozen dataclass: status (downloaded/skipped/failed), path (Path | None), format (str | None), error (str | None) - History writing no longer happens inside `download_book()`; caller inspects result and writes - Format strategy + extras flags consumed from `OutputPlan` (not raw Config) - Progress callback obtained from reporter (not passed as separate param) - Cancel event handled internally or via reporter contract ## Acceptance criteria - [ ] `download_book()` has exactly 4 parameters (plus self) - [ ] `DownloadResult` frozen dataclass with correct shape for all three statuses - [ ] History is NOT written by `download_book()`; caller writes after inspecting result - [ ] All download tests exercise new interface; no test passes raw Config or history to `download_book()` - [ ] M4B→MP3 fallback flow produces correct `DownloadResult` at each stage - [ ] Cancel/interrupt path produces correct `DownloadResult(status="failed")` ## Blocked by - #27 — needs `LibroFmSession` (not old `LibroFmClient`) - #28 — needs `OutputPlan` (paths + format + extras)
AlexKucera commented 2026-06-05 07:34:10 +02:00 (Migrated from github.com)

✅ Complete — all 6 AC met, 368 tests pass.

Summary: download_book() shrunk from 9→4 domain-aligned params returning frozen DownloadResult. History writing moved to caller. OutputPlan.format_strategy added. Cancel wired through reporter.

Commit: 9ac581e on feature/improve-codebase

✅ Complete — all 6 AC met, 368 tests pass. **Summary:** `download_book()` shrunk from 9→4 domain-aligned params returning frozen `DownloadResult`. History writing moved to caller. `OutputPlan.format_strategy` added. Cancel wired through reporter. **Commit:** `9ac581e` on `feature/improve-codebase`
Sign in to join this conversation.