crabidy/plan/captures.md

3.0 KiB

Plan: captures

Ordered tasks; each names its verification (tests in fsdy/src/lib.rs, crabidy-server/src/capture.rs, crabidy-server/src/capture_store.rs and/or gates in quality/captures.md). Stubs, the proto field, tidal's flag rule, and the full orchestrator/TUI plumbing exist; the new tests fail on todo!() at plan time.

  • T1 — fsdy file-playable constructor. TrackFile::from_track_with_file: metadata like from_track, playable file = <relative sibling>. Verifies: from_track_with_file_plays_the_relative_sibling.
  • T2 — capture.rs naming + extension helpers. audio_file_name (shared ordered_name semantics via a public fsdy seam) and extension_for (Content-Type map, URL-path fallback, bin). Verifies: extension_prefers_content_type_then_url_then_bin, audio_files_pair_with_their_toml_names.
  • T3 — shared walk. Move the bookmark walk into capture::capture_into/write_tree parameterized by Caps and Sink; per-track writes go through write_track (Sink::Link = today's link file). Rewire BookmarkStore onto it (delete its copy; keep its public API and BOOKMARK_CAPS-equivalent behavior). Verifies: all existing bookmark_store::tests unchanged; gates "Shared walk".
  • T4 — download sink. Downloader::new (connect timeout), Sink::Download in write_track: per-track deadline around URL fetch, GET, and the streamed body against bytes_left, error_for_status, extension from the response, audio first then toml (from_track_with_file). Verifies: download_capture_writes_audio_next_to_pointing_tomls, download_capture_is_all_or_nothing, download_capture_enforces_its_caps; gates "Download sink".
  • T5 — CaptureStore. open (create dir + build downloader), capture → blessing check (source_allows_download: node or track parent) then capture_with_caps(DOWNLOAD_CAPS)capture_into. Verifies: capture_requires_the_root_download_blessing, capturing_a_single_blessed_track_writes_one_pair, capture_validates_names_and_overwrites; gates "Opt-in".
  • T6 — TUI tests. Binding test for W (Library scope, shift), selected_downloadable gating (queueable-but-not-downloadable stays closed; tracks inherit the node flag), overlay label capture, submit carries download: true. Verifies: new cbd-tui tests; gates "TUI".
  • T7 — full verification. Whole workspace suite green; clippy/fmt/taplo/markdownlint clean; walk every gate in quality/captures.md and tick it; no todo!() left.
  • T8 — live smoke test. Capture a real Tidal track with download through the provider layer into a temp store (a single track keeps the probe cheap; the multi-track walk is unit-covered), verify the audio exists with a plausible size, replay through a /captures instance, and play-resolve it — remove any temporary probe afterwards.
  • T9 — docs. plan/summary.md section incl. deviations; reconcile architecture/captures.md (tidal flag rule, anything else that moved).