soulsync/core/download_engine
Broque Thomas a5fde0502a Engine state: nested-dict layout for O(source) iteration
Per JohnBaumb's review: iter_records_for_source() walked every
(source, id) tuple across the entire engine state to filter one
source — O(total_records) instead of O(source_records). Fine in
practice because total active downloads is usually small, but the
shape was wrong.

Switched the engine's _records storage from a single composite-key
dict (Dict[Tuple[str, str], DownloadRecord]) to a nested dict
(Dict[str, Dict[str, DownloadRecord]]). Per-source iteration now
only touches that source's bucket. add/get/update/remove all
adjusted to the nested layout. remove_record drops the empty source
bucket so future iterations don't see stale source keys.

Public surface unchanged. New test pins the empty-bucket-cleanup
behavior.
2026-05-05 11:46:44 -07:00
..
__init__.py E1: Add RateLimitPolicy declaration mechanism 2026-05-04 14:38:20 -07:00
engine.py Engine state: nested-dict layout for O(source) iteration 2026-05-05 11:46:44 -07:00
rate_limit.py E1: Add RateLimitPolicy declaration mechanism 2026-05-04 14:38:20 -07:00
worker.py Cin review: alias resolution, atomic terminal write, generic accessors 2026-05-04 22:58:46 -07:00