Issue #31: Sync Run Pipeline + CLI Slimming (HITL) #31

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

Parent

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

What to build

Extract the entire Sync Run pipeline from cli.run() into a standalone sync_run() function. Slim cli.py to a thin argparse→exit adapter (~80 lines). Introduce SyncRunResult. This is the capstone issue that wires all previous deep modules together.

End state:

  • New file: librofm_downloader/sync_run.py
  • sync_run(config, secrets_path, history_path, *, verbose, limit, workers, select_mode) -> SyncRunResult
  • 12 sequential stages: resolve paths → load config → authenticate → fetch library → intake (Book) → filter/limit/select → resolve plans → download all → write history → summary → return result
  • Early-return on fatal error (auth failure, empty library after filter)
  • cli.py: parse args → call sync_run() → translate exit code → sys.exit(). ≤80 lines.
  • SyncRunResult frozen dataclass: downloaded_count, skipped_count, failed_count, failed_books, skipped_books, interrupted
  • OrchestratorResult deprecated; download_all_books() returns SyncRunResult
  • Filtering/limiting lives in sync_run (not orchestrator)
  • Select mode plug point at stage 7 (ADR #6 integration point, not implemented)
  • Verbose output printed by sync_run() itself

Migration: ~24 test classes move from test_cli.py to new test_sync_run.py. CLI tests keep only argparse + exit-code translation.

Acceptance criteria

  • sync_run() callable and returns correct SyncRunResult for: happy path, auth failure, empty library, mixed results, Ctrl+C
  • cli.py ≤80 lines; contains only argparse + exit code translation
  • No test in test_cli.py patches load_config/LibroFmSession/DownloadHistory/download_book/DownloadReporter
  • All migrated tests pass in test_sync_run.py
  • Filtering (already-downloaded + limit) produces correct book list
  • History written exactly once per successful download (in sync_run, not in download_book)
  • Select mode stage 7 is a clear if/branch point (implementation deferred)
  • HITL review required before merge — this is the largest change and ties everything together

Blocked by

  • #29 — needs DownloadResult and slimmed download_book()
  • #30 — needs reporter bound-callable shape
## Parent #25 — PRD 001: Deepen Architecture — Module Depth & Domain Alignment ## What to build Extract the entire Sync Run pipeline from `cli.run()` into a standalone `sync_run()` function. Slim `cli.py` to a thin argparse→exit adapter (~80 lines). Introduce `SyncRunResult`. This is the capstone issue that wires all previous deep modules together. **End state:** - New file: `librofm_downloader/sync_run.py` - `sync_run(config, secrets_path, history_path, *, verbose, limit, workers, select_mode) -> SyncRunResult` - 12 sequential stages: resolve paths → load config → authenticate → fetch library → intake (Book) → filter/limit/select → resolve plans → download all → write history → summary → return result - Early-return on fatal error (auth failure, empty library after filter) - `cli.py`: parse args → call `sync_run()` → translate exit code → `sys.exit()`. ≤80 lines. - `SyncRunResult` frozen dataclass: downloaded_count, skipped_count, failed_count, failed_books, skipped_books, interrupted - `OrchestratorResult` deprecated; `download_all_books()` returns `SyncRunResult` - Filtering/limiting lives in sync_run (not orchestrator) - Select mode plug point at stage 7 (ADR #6 integration point, not implemented) - Verbose output printed by `sync_run()` itself **Migration:** ~24 test classes move from `test_cli.py` to new `test_sync_run.py`. CLI tests keep only argparse + exit-code translation. ## Acceptance criteria - [ ] `sync_run()` callable and returns correct `SyncRunResult` for: happy path, auth failure, empty library, mixed results, Ctrl+C - [ ] `cli.py` ≤80 lines; contains only argparse + exit code translation - [ ] No test in `test_cli.py` patches load_config/LibroFmSession/DownloadHistory/download_book/DownloadReporter - [ ] All migrated tests pass in `test_sync_run.py` - [ ] Filtering (already-downloaded + limit) produces correct book list - [ ] History written exactly once per successful download (in sync_run, not in download_book) - [ ] Select mode stage 7 is a clear if/branch point (implementation deferred) - [ ] **HITL review required before merge** — this is the largest change and ties everything together ## Blocked by - #29 — needs `DownloadResult` and slimmed `download_book()` - #30 — needs reporter bound-callable shape
AlexKucera commented 2026-06-05 14:52:11 +02:00 (Migrated from github.com)

✅ Merged via f371152 — sync_run pipeline extracted, CLI slimmed to 65-line adapter, 374 tests passing.

✅ Merged via f371152 — sync_run pipeline extracted, CLI slimmed to 65-line adapter, 374 tests passing.
Sign in to join this conversation.