- Add JWT token auth to OPC WebSocket (unauthenticated → 403, per-user tracking) - Externalize Transmission RPC credentials to TRANSMISSION_USER/PASS env vars - Remove hardcoded SECRET_KEY fallback from dev compose - Rate-limit passkey register options endpoint at 5/minute - Add PDD (docs/improvement-plan.md) and sprint specs (specs/) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4.2 KiB
Sprint 05 — Operations & Resilience
Depends on: S04 (CI must be reliable before automating ops) Duration: ~12h Goal: Add health checks, resource limits, log rotation, fix Immich uploads, back up dashboard data, add monitoring endpoint.
S05.1 — Add HEALTHCHECK to claude-dev image
-
Files:
claude-dev/Dockerfile,claude-dev/docker-compose.yml -
Estimate: 1h
-
Done means: Dockerfile has
HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD claude --version || exit 1.docker psshows healthy. -
Verify by:
- Deploy claude-dev →
docker psshows "(healthy)" - Break
claudebinary → container shows "(unhealthy)" after 3 failures
- Deploy claude-dev →
-
Risk:
claude --versionmay require network access. Test on NAS first. Alternative:pgrep -f claudeor simplecurl localhost:<port>. -
S05.1 — Add HEALTHCHECK to claude-dev image
S05.2 — Add resource limits to production containers
-
Files:
claude-dev/docker-compose.yml,dashboard/docker-compose.yml -
Estimate: 1.5h
-
Done means: Production compose files have
mem_limit,cpus, andrestart_policy. Limits are generous: 2GB dashboard, 1GB claude-dev, 0.5GB sidecars. -
Verify by:
docker statsshows containers respecting limits- Normal operation unaffected
docker compose up -dapplies limits without restarting
-
Risk: Limits too tight → OOM kills. Start generous, adjust after a week of monitoring.
-
S05.2 — Add resource limits to production containers
S05.3 — Implement audit log rotation
-
Files:
dashboard/backend/main.py:161,171-188 -
Estimate: 2h
-
Done means: Audit logging uses
RotatingFileHandlerwith max 10MB and 5 backups. -
Verify by:
- Write 11MB of audit entries → file rotates,
audit.log.1created - Original
audit.logstarts fresh - Old backups capped at 5 files
- Write 11MB of audit entries → file rotates,
-
Risk: Log format change may affect parsing in
system.py:82-116. Test the log reader with rotated files. -
S05.3 — Implement audit log rotation
S05.4 — Fix Immich ML model downloads
-
Files:
immich/docker-compose.yml,immich/.env -
Estimate: 3h (investigation + fix)
-
Done means: Immich mobile upload works. ML models download successfully or ML is gracefully disabled.
-
Verify by:
- Upload photo from phone → succeeds (no timeout)
ssh nas "docker logs immich_machine_learning"→ no "Failed to load detection model" errors- If ML disabled: photo upload works, smart search unavailable (acceptable)
-
Risk: Most complex item. May require pre-downloading models, configuring mirror, increasing timeouts, or disabling ML temporarily. Environment-specific (China network to modelscope.cn).
-
S05.4 — Fix Immich ML model downloads
S05.5 — Add dashboard data to backup script
-
Files:
backup.sh -
Estimate: 1.5h
-
Done means:
backup.shcopiesopc.db,auth.json,rbac.json, and audit log to backup tarball. Restore procedure documented. -
Verify by:
- Run
backup.sh→ tarball contains dashboard data files - Extract tarball → files are valid (SQLite DB opens, JSON parses)
- Run
-
Risk:
auth.jsoncontains passkey data — ensure backup stored securely. -
S05.5 — Add dashboard data to backup script
S05.6 — Add minimal health check endpoint
-
Files:
dashboard/backend/main.pyorrouters/health.py -
Estimate: 1h
-
Done means:
GET /api/healthreturns{"status":"ok","db":true,"docker":true,"disk":{"free_gb":123}}. Non-200 triggers optional Telegram notification. -
Verify by:
- All services healthy →
/api/healthreturns 200 - Docker socket unreachable → returns 503 with
docker: false - Cron job calls
/api/healthevery 5 minutes
- All services healthy →
-
Risk: Health endpoint must be lightweight. Cache results for 30 seconds.
-
S05.6 — Add minimal health check endpoint
Exit criteria
docker psshows claude-dev as "(healthy)"- Production containers have CPU/memory limits in compose
- Audit log rotates at 10MB with 5 backups
- Photo upload from phone succeeds
backup.shincludes dashboard data filesGET /api/healthreturns component statuses- All backend tests pass
- All frontend tests pass