# Uni-Wizard v4 — Deployment Checklist

## Pre-Deployment

- [ ] VPS provisioned (Ubuntu 22.04 LTS recommended)
- [ ] SSH access configured
- [ ] Firewall rules set (ports 22, 80, 443, 3000, 8643)
- [ ] Domain/DNS configured (optional)
- [ ] SSL certificates ready (optional)

## Base System

- [ ] Update system packages
  ```bash
  sudo apt update && sudo apt upgrade -y
  ```
- [ ] Install base dependencies
  ```bash
  sudo apt install -y python3 python3-pip python3-venv sqlite3 curl git
  ```
- [ ] Create timmy user
  ```bash
  sudo useradd -m -s /bin/bash timmy
  ```
- [ ] Configure sudo access (if needed)

## Gitea Setup

- [ ] Gitea installed and running
- [ ] Repository created: `Timmy_Foundation/timmy-home`
- [ ] API token generated
- [ ] Webhooks configured (optional)
- [ ] Test API access
  ```bash
  curl -H "Authorization: token TOKEN" http://localhost:3000/api/v1/user
  ```

## Uni-Wizard Installation

- [ ] Clone repository
  ```bash
  sudo -u timmy git clone http://143.198.27.163:3000/Timmy_Foundation/timmy-home.git /opt/timmy/repo
  ```
- [ ] Run setup script
  ```bash
  sudo ./scripts/setup-uni-wizard.sh
  ```
- [ ] Verify installation
  ```bash
  /opt/timmy/venv/bin/python -c "from uni_wizard import Harness; print('OK')"
  ```

## Configuration

- [ ] Edit config file
  ```bash
  sudo nano /opt/timmy/config/uni-wizard.yaml
  ```
- [ ] Set Gitea API token
- [ ] Configure house identity
- [ ] Set log level (INFO for production)
- [ ] Verify config syntax
  ```bash
  /opt/timmy/venv/bin/python -c "import yaml; yaml.safe_load(open('/opt/timmy/config/uni-wizard.yaml'))"
  ```

## LLM Setup (if using local inference)

- [ ] llama.cpp installed
- [ ] Model downloaded (e.g., Hermes-4 14B)
- [ ] Model placed in `/opt/timmy/models/`
- [ ] llama-server configured
- [ ] Test inference
  ```bash
  curl http://localhost:8080/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{"model": "hermes4", "messages": [{"role": "user", "content": "Hello"}]}'
  ```

## Service Startup

- [ ] Start Uni-Wizard
  ```bash
  sudo systemctl start uni-wizard
  ```
- [ ] Start health daemon
  ```bash
  sudo systemctl start timmy-health
  ```
- [ ] Start task router
  ```bash
  sudo systemctl start timmy-task-router
  ```
- [ ] Enable auto-start
  ```bash
  sudo systemctl enable uni-wizard timmy-health timmy-task-router
  ```

## Verification

- [ ] Check service status
  ```bash
  sudo systemctl status uni-wizard
  ```
- [ ] View logs
  ```bash
  sudo journalctl -u uni-wizard -f
  ```
- [ ] Test health endpoint
  ```bash
  curl http://localhost:8082/health
  ```
- [ ] Test tool execution
  ```bash
  /opt/timmy/venv/bin/uni-wizard execute system_info
  ```
- [ ] Verify Gitea polling
  ```bash
  tail -f /opt/timmy/logs/task-router.log | grep "Polling"
  ```

## Syncthing Mesh (if using multiple VPS)

- [ ] Syncthing installed on all nodes
- [ ] Devices paired
- [ ] Folders shared
  - `/opt/timmy/logs/`
  - `/opt/timmy/data/`
- [ ] Test sync
  ```bash
  touch /opt/timmy/logs/test && ssh other-vps "ls /opt/timmy/logs/test"
  ```

## Security

- [ ] Firewall configured
  ```bash
  sudo ufw status
  ```
- [ ] Fail2ban installed (optional)
- [ ] Log rotation configured
  ```bash
  sudo logrotate -d /etc/logrotate.d/uni-wizard
  ```
- [ ] Backup strategy in place
- [ ] Secrets not in git
  ```bash
  grep -r "password\|token\|secret" /opt/timmy/repo/
  ```

## Monitoring

- [ ] Health checks responding
- [ ] Metrics being collected
- [ ] Alerts configured (optional)
- [ ] Log aggregation setup (optional)

## Post-Deployment

- [ ] Document any custom configuration
- [ ] Update runbooks
- [ ] Notify team
- [ ] Schedule first review (1 week)

## Rollback Plan

If deployment fails:

```bash
# Stop services
sudo systemctl stop uni-wizard timmy-health timmy-task-router

# Disable auto-start
sudo systemctl disable uni-wizard timmy-health timmy-task-router

# Restore from backup (if available)
# ...

# Or reset to clean state
sudo rm -rf /opt/timmy/
sudo userdel timmy
```

## Success Criteria

- [ ] All services running (`systemctl is-active` returns "active")
- [ ] Health endpoint returns 200
- [ ] Can execute tools via CLI
- [ ] Gitea integration working (issues being polled)
- [ ] Logs being written without errors
- [ ] No critical errors in first 24 hours

---

**Deployed by:** _______________  
**Date:** _______________  
**VPS:** _______________
