# S03: Preset System + Engine Docker Packaging — UAT

**Milestone:** M001
**Written:** 2026-03-26T04:52:09.425Z

# S03: Preset System + Engine Docker Packaging — UAT

**Milestone:** M001
**Written:** 2026-03-26

## UAT Type

- UAT mode: mixed (artifact-driven for presets, live-runtime for Docker)
- Why this mode is sufficient: Preset system is config + API — tests validate behavior. Docker packaging requires live container verification.

## Preconditions

- Engine venv exists at `engine/.venv/` with all deps installed
- Docker daemon running
- Port 8100 available for test container
- Working directory is project root (`/home/aux/development/xpltdco/kerf-engine`)

## Smoke Test

```bash
cd engine && .venv/bin/python -m pytest tests/ -v -k preset && echo "SMOKE OK"
```
Expected: 28 tests pass, exit 0.

## Test Cases

### 1. All 5 presets load and are returned by GET endpoint

1. Start engine: `cd engine && .venv/bin/python -m uvicorn main:app --port 8099 &`
2. `curl -s http://localhost:8099/engine/presets | python3 -m json.tool`
3. **Expected:** JSON with keys: sign, patch, stencil, detailed, custom. Each has name, description, preprocessing, vectorization, postprocessing sections.

### 2. Default preset is 'sign' when none specified

1. POST a PNG to `/engine/trace` without specifying `preset`
2. **Expected:** Response uses sign preset defaults (potrace mode, alphamax=0.8, opttolerance=0.3)

### 3. Different presets produce different output from same input

1. POST the same PNG to `/engine/trace` with preset=sign
2. POST the same PNG to `/engine/trace` with preset=detailed
3. **Expected:** SVG outputs differ — sign produces fewer nodes (aggressive simplification) vs detailed (max fidelity)

### 4. User params override preset defaults

1. POST to `/engine/trace` with preset=sign and params={"threshold_manual": 200}
2. **Expected:** Response uses threshold_manual=200 (user override) but other params from sign preset

### 5. Unknown preset is rejected

1. POST to `/engine/trace` with preset=nonexistent
2. **Expected:** 400 error with message about invalid preset

### 6. Docker image builds and starts healthy

1. `docker build -f docker/Dockerfile.engine -t kerf-engine:dev .`
2. `docker run --rm -d --name kerf-engine-uat -p 8100:8000 kerf-engine:dev`
3. `sleep 6`
4. `curl -sf http://localhost:8100/engine/health`
5. **Expected:** Returns `{"status":"ok"}`
6. `docker inspect kerf-engine-uat --format='{{json .State.Health.Status}}'`
7. **Expected:** Returns `"healthy"`
8. `docker stop kerf-engine-uat`

### 7. Engine container serves presets endpoint

1. Start container as in test 6
2. `curl -sf http://localhost:8100/engine/presets | python3 -m json.tool`
3. **Expected:** Same 5 presets as local endpoint test
4. `docker stop kerf-engine-uat`

### 8. Engine image contains no App code

1. `docker run --rm kerf-engine:dev ls /app/`
2. **Expected:** Only engine files: main.py, api/, pipeline/, output/, presets/. No app/, frontend/, or node_modules/.

## Edge Cases

### Custom preset with no user params uses pipeline defaults

1. POST to `/engine/trace` with preset=custom and no params
2. **Expected:** Succeeds using pipeline code defaults (potrace mode from custom.json vectorization section)

### Preset with mode override

1. POST to `/engine/trace` with preset=sign (which defaults to potrace) and mode=vtracer
2. **Expected:** Uses vtracer mode but sign preset's preprocessing/postprocessing params

## Failure Signals

- Any preset test fails (28 tests must pass)
- Docker build fails (missing system deps, pip install errors)
- Container starts but /engine/health returns non-200
- Docker health status shows "unhealthy"
- /engine/presets returns fewer than 5 presets
- Same preset applied to different images produces identical SVG (preset not taking effect)

## Not Proven By This UAT

- Preset quality tuning (whether sign preset actually produces good signage output — that requires human visual evaluation)
- Container performance under load
- Container image size optimization
- Production deployment (compose, networking, volumes)

## Notes for Tester

- The ezdxf deprecation warnings in test output are harmless (L004) — ignore them
- Docker build uses cached layers after first build — subsequent builds are fast
- Port 8100 is used for Docker tests to avoid conflicting with local dev on 8000
