# Milestone 1: Contracts, Toolchain & Database Hardening (Complete — M1.8 moved to M3.1) x 2026-10-31 (A) Create services/contracts workspace package with pyproject.toml (module-name = 'magnetflix') +contracts @workspace x 2026-10-31 (A) Reconfigure buf.gen.yaml to output stubs into services/contracts/src, generate stubs + docs/api_spec.md, and track in Git +proto @contracts x 2026-10-31 (A) Update services/worker and services/bff to depend on magnetflix-contracts via workspace dependency +deps @workspace x 2026-10-31 (A) Update pyproject.toml to include tests/ in pyright, remove exclusions masking broken imports, and add test rule to Makefile +ci @workspace x 2026-10-31 (A) Update services/worker/Dockerfile and services/bff/Dockerfile to copy services/contracts, and copy alembic/ into worker image +docker @deploy x 2026-10-31 (A) Create Alembic migration 002_add_info_hash_and_partial_unique_index.py adding info_hash column and uq_download_jobs_active_imdb_id index +db @worker x 2026-10-31 (A) Update DownloadJob ORM model and write unit tests in tests/test_db.py verifying duplicate active insertion rejection +test @worker # Next Immediate Deliverable — Milestone 2: Safe Walking Skeleton MVP (See docs/roadmap.md for M3-M5) (A) [M2.1] Implement Two-Tier Media Sanitizer in services/worker/src/worker/sanitizer.py (os.walk followlinks=False, reject symlinks/special/S_ISREG hardlinks/traversal/dangerous exts even inside Sample/, ignore clutter, discard samples & < MIN_VIDEO_BYTES video only, select largest video + subtitles) +sanitizer @worker (A) [M2.1] Write unit tests in tests/test_sanitizer.py covering traversal, symlinks, hardlinks, dangerous ext inside Sample/, clutter ignore, subtitle size preservation, and largest video selection +test @worker (B) [M2.2] Implement Stage 1 TmdbClient in services/worker/src/worker/metadata.py (lazy TMDB_API_KEY, ^tt\d{7,10}$ validation, /find/{imdb_id} v3 query, movie_results & release_date checks) +metadata @worker (B) [M2.2] Implement core atomic relocator in services/worker/src/worker/relocator.py (sanitize_title, [imdbid-...] dup scan in MEDIA_DIR, disk_usage 1.05x check, .staging_ copy + os.replace swap, deterministic subtitle collision suffix) +relocator @worker (B) [M2.2] Write unit tests in tests/test_metadata.py and tests/test_relocator.py +test @worker (B) [M2.3] Implement lazy TransmissionClient wrapper in services/worker/src/worker/transmission.py via asyncio.to_thread +transmission @worker (B) [M2.3] Implement minimal PipelineCoordinator in services/worker/src/worker/pipeline.py (urn:btih:<40-hex> + active dup/library checks, tracked asyncio.Task, 2s polling, short-lived sessions, finally cleanup) +pipeline @worker (B) [M2.3] Implement gRPC PipelineServiceServicer in services/worker/src/worker/service.py & worker/main.py (SubmitDownload, GetJob omitting null completed_at, ListJobs offset/created_at DESC, UNIMPLEMENTED StreamJobStatus, SIGTERM shutdown) +grpc @worker (B) [M2.3] Write tests in tests/test_transmission.py, tests/test_pipeline.py, and tests/test_grpc_service.py +test @worker (B) [M2.4] Implement minimal FastAPI BFF in services/bff/src/bff/grpc_client.py, main.py, and services/bff/src/bff/templates/index.html (AUTH_ENABLED app default true, /healthz, POST/GET /api/v1/downloads, 3s polling form, gRPC->HTTP mapping) +api @bff (B) [M2.4] Write API tests in tests/test_bff_routes.py +test @bff (B) [M2.4] Author local docker-compose.yml (transmission healthcheck + incomplete-dir disabled, worker PUID:PGID + alembic upgrade head, bff AUTH_ENABLED=false, pre-created dirs) and run >= 100 MB public-domain torrent E2E verification +compose @deploy