Commit Graph
8 Commits
Author SHA1 Message Date
Mak5er 1806c149fd fix: align CI checks with current baseline 2026-06-26 03:04:34 +03:00
Mak5er 62050a0f2c perf: comprehensive production audit and hardening (Phase 1-4)
43 files changed, 828 insertions, 408 deletions. Key changes:

== Phase 1 - Critical fixes ==
- Fix shared mutable state in ResilientDownloader (class-level _inflight_downloads)
- Add threading.Lock to request dedup (race condition on concurrent claims)
- Fix ban_middleware fail-closed: DB error -> fallback to 'active' instead of 'restricted'
- Fix COUNT(*) anti-pattern: 5 methods fetched entire user table into memory
- Remove 6 duplicated function definitions in user_messages.py (silent shadowing)
- Extract metadata from Cobalt responses (Instagram no longer discards descriptions)
- Add SSRF validation for COBALT_API_URL (private IP blocking, scheme enforcement)
- Docker: healthcheck, resource limits, restart: on-failure:5
- Fix migration crash-loop (try/except guardrails + dialect detection bug)

== Phase 2 - Performance hardening ==
- Exponential backoff+jitter in cobalt_client and retry_async_operation (removed 9 fixed delays)
- Add asyncio.wait_for timeouts to Instagram/Pinterest downloads
- TikTok preflight size check before download
- SQLAlchemy pool event listeners (perf metrics on checkout/overflow)
- DownloadedFile TTL cleanup (date_added index + daily cron cleanup)
- Per-request UUID request_id in ChatTrackerMiddleware for end-to-end tracing
- private_chat_guard caching (60s TTL, reduces Telegram API calls)
- Antiflood O(k) eviction instead of O(n) full scan
- TikTok: Semaphore(3)+sliding-window rate limiter instead of global asyncio.Lock

== Phase 3 - CI hardening ==
- CI: lint job (ruff + mypy), docker smoke tests migrations, --cov-fail-under=80
- Upgrade dependency-audit Python 3.12 -> 3.14
- Fix 7 '# type: ignore' decorators with ParamSpec
- Migration 000005: ix_analytics_events_user_id + ix_downloaded_files_date_added
- Race-condition tests for dedup, queue shutdown, per-user slots

== Phase 4 - Architecture ==
- .dockerignore (exclude .git, tests, __pycache__, .env from Docker image)
- Consolidate 3 FakeYoutubeDL/DummyYDL classes into conftest.py
- Extract _download_youtube_media() from 70-line closure
- BasePlatformMediaService ABC in services/platforms/__init__.py
- Remove empty profiling/ directory

Tests: 349 passed, 0 failed (4 skipped: PostgreSQL-dependent)
2026-06-16 01:01:06 +03:00
Mak5er d4160b197b fix: make tests resolve project modules in CI 2026-04-10 00:20:58 +03:00
Mak5er c4fd448f37 fix: dedupe repeated media link requests 2026-04-09 02:08:46 +03:00
Mak5er 29795b9710 refactor: move runtime dependencies into app context 2026-04-07 00:24:38 +03:00
Mak5er bbe6737d85 refactor: normalize config names to upper snake case
- switch runtime imports to ADMIN_ID/CUSTOM_API_URL and drop lowercase module aliases
- keep backward-compatible env fallback for existing deployments
- update docs/tests and remove the completed config naming finding from the review backlog
2026-04-06 23:50:41 +03:00
Mak5er a115061ca8 Add CI test workflow and improve coverage 2026-04-06 13:59:27 +03:00
Mak5er dda200cc0c Add full quality option to video info keyboard and include full_quality router 2025-12-15 23:58:07 +02:00