# Docker Offline GPU + Proto UDP Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Добавить офлайн GPU Docker-упаковку для live/video запуска и новый опциональный UDP backend испытательного протокола.

**Architecture:** Конфигурация контейнера будет управляться env-переменными поверх текущих дефолтов в `config.py` и `config_intercept.py`. Новый backend `proto_udp` будет встроен в существующий `AutopilotBridge`, а Docker-артефакты обеспечат офлайн runtime с уже установленными зависимостями и моделью.

**Tech Stack:** Python 3.12, PyTorch CUDA, Ultralytics YOLO, OpenCV, Docker, docker-compose, UDP sockets.

---

### Task 1: Add tests for protocol backend and env overrides

**Files:**
- Create: `tests/test_autopilot_proto_udp.py`
- Create: `tests/test_runtime_env.py`

- [ ] **Step 1: Write failing tests for UDP packet packing and backend selection**
- [ ] **Step 2: Run targeted pytest commands and confirm failure**
- [ ] **Step 3: Add failing tests for env override parsing**
- [ ] **Step 4: Run targeted pytest commands and confirm failure**

### Task 2: Implement runtime env overrides

**Files:**
- Create: `runtime_env.py`
- Modify: `config.py`
- Modify: `config_intercept.py`

- [ ] **Step 1: Add minimal env parsing helpers and runtime override API**
- [ ] **Step 2: Apply overrides to source/model/output/backend-related settings**
- [ ] **Step 3: Re-run env override tests until green**

### Task 3: Implement protocol UDP backend

**Files:**
- Modify: `autopilot_bridge.py`
- Modify: `config_intercept.py`

- [ ] **Step 1: Add protocol config defaults**
- [ ] **Step 2: Add packet builder and `proto_udp` backend**
- [ ] **Step 3: Wire backend selection into `AutopilotBridge`**
- [ ] **Step 4: Re-run protocol tests until green**

### Task 4: Make runtime self-contained for container use

**Files:**
- Create: `bytetrack_min_aggressive.py`
- Modify: `main.py`

- [ ] **Step 1: Vendor the local ByteTrack implementation into the project root**
- [ ] **Step 2: Remove dependency on parent-directory import for container runtime**
- [ ] **Step 3: Re-run affected tests and compile checks**

### Task 5: Add Docker packaging

**Files:**
- Create: `Dockerfile`
- Create: `.dockerignore`
- Create: `requirements-docker.txt`
- Create: `docker-compose.yml`
- Create: `docker/entrypoint.sh`
- Create: `README_docker.md`

- [ ] **Step 1: Define offline-friendly GPU image build**
- [ ] **Step 2: Add compose service with GPU/runtime env setup**
- [ ] **Step 3: Document build and launch modes for camera/rtsp/udp/video**

### Task 6: Verify end-to-end artifacts

**Files:**
- Modify: `docs/superpowers/plans/2026-06-29-docker-offline-gpu-proto-udp-implementation.md`

- [ ] **Step 1: Run targeted pytest for new and touched tests**
- [ ] **Step 2: Run `python -m compileall` for changed Python files**
- [ ] **Step 3: Report any remaining runtime limits that require host-side NVIDIA/Docker setup**
