# S01: Pipeline Admin Dashboard

**Goal:** Build a pipeline management admin page with monitoring, triggering, pausing, and debugging capabilities including token usage and expandable JSON responses
**Demo:** After this: Admin page at /admin/pipeline shows video list with status, retrigger button, and log viewer with token counts and expandable JSON responses

## Tasks
- [x] **T01: Fixed syntax errors in pipeline event instrumentation — _emit_event and _make_llm_callback now work correctly, events persist to pipeline_events table** — Add PipelineEvent DB model (video_id, stage, event_type, payload JSONB, token counts, created_at). Alembic migration 004. Instrument LLM client to persist events (token usage, response content) per-call. Instrument each stage to emit start/complete/error events.
  - Estimate: 45min
  - Files: backend/models.py, backend/schemas.py, alembic/versions/004_pipeline_events.py, backend/pipeline/llm_client.py, backend/pipeline/stages.py
  - Verify: docker exec chrysopedia-api python -c 'from models import PipelineEvent; print(OK)' && docker exec chrysopedia-api alembic upgrade head
- [x] **T02: All five admin pipeline endpoints respond correctly — fix was nginx stale DNS after T01 API rebuild, resolved by restarting web container** — New router: GET /admin/pipeline/videos (list with status + event counts), POST /admin/pipeline/trigger/{video_id} (retrigger), POST /admin/pipeline/revoke/{video_id} (pause/stop via Celery revoke), GET /admin/pipeline/events/{video_id} (event log with pagination), GET /admin/pipeline/worker-status (active/reserved tasks from Celery inspect).
  - Estimate: 30min
  - Files: backend/routers/pipeline.py, backend/schemas.py, backend/main.py
  - Verify: curl -s http://localhost:8096/api/v1/admin/pipeline/videos | python3 -m json.tool && curl -s http://localhost:8096/api/v1/admin/pipeline/worker-status | python3 -m json.tool
- [x] **T03: Built AdminPipeline.tsx page at /admin/pipeline with video table, status badges, retrigger/revoke buttons, expandable event log with token usage, collapsible JSON responses, and live worker status indicator** — New AdminPipeline.tsx page at /admin/pipeline. Video list table with status badges, retrigger/pause buttons. Expandable row showing event log timeline with token usage and collapsible JSON response viewer. Worker status indicator. Wire into App.tsx and nav.
  - Estimate: 45min
  - Files: frontend/src/pages/AdminPipeline.tsx, frontend/src/api/public-client.ts, frontend/src/App.tsx, frontend/src/App.css
  - Verify: docker compose build chrysopedia-web 2>&1 | tail -5 (exit 0, zero TS errors)
