---
description: Run deployment verification and health checks (M9)
argument-hint: "[deployment-url]"
allowed-tools: Bash, Read, Write, Glob, Grep
---

Run deployment verification against a deployed app.

## Steps

1. **Validate deployment URL**
   - Require deployment URL as argument
   - Validate URL format

2. **Detect deployment provider**
   - Use `deploy_detect` MCP tool
   - Check for Vercel, AWS, GCP, Railway, Render, Fly

3. **Load deployment config**
   - Look for `.vaspera/deploy.yaml`
   - If not found, offer to generate sample config

4. **Run health checks**
   - Check configured health endpoints
   - Default: `/`, `/api/health`
   - Measure response times and status codes

5. **Run smoke tests**
   - Execute tests from config
   - Check status codes, latency, response bodies

6. **Analyze results**
   - Calculate health score (0-100)
   - Calculate smoke test score (0-100)
   - Calculate overall deploy score

7. **Present results**
   ```
   Deployment Verification Results
   ================================
   Provider: Vercel (detected)
   URL: https://my-app.vercel.app

   Health Checks:
   ┌────────────────┬──────────┬──────────┬────────────┐
   │ Endpoint       │ Status   │ Code     │ Time (ms)  │
   ├────────────────┼──────────┼──────────┼────────────┤
   │ /              │ ✅ healthy│ 200      │ 89         │
   │ /api/health    │ ✅ healthy│ 200      │ 45         │
   │ /api/data      │ ⚠️ degraded│ 200     │ 612        │
   └────────────────┴──────────┴──────────┴────────────┘

   Smoke Tests:
   ┌────────────────────────┬──────────┬────────────┐
   │ Test                   │ Status   │ Time (ms)  │
   ├────────────────────────┼──────────┼────────────┤
   │ Homepage loads         │ ✅ PASS  │ 89         │
   │ API health check       │ ✅ PASS  │ 45         │
   │ User can login         │ ❌ FAIL  │ 1200       │
   └────────────────────────┴──────────┴────────────┘

   Scores:
   - Health: 87/100
   - Smoke Tests: 67/100
   - Overall: 77/100

   Certification Level: 🟡 APPROVED
   → Ship with monitoring
   ```

8. **Vercel-specific actions** (if Vercel detected)
   - List recent deployments
   - Promote preview to production
   - Rollback to previous version

## Config Format

Config is defined in `.vaspera/deploy.yaml`:

```yaml
provider: vercel  # Optional, auto-detected

healthEndpoints:
  - /
  - /api/health
  - /api/ready

smokeTests:
  - name: "Homepage loads"
    endpoint: "/"
    method: GET
    expectedStatus: 200

  - name: "API health check"
    endpoint: "/api/health"
    method: GET
    expectedStatus: 200
    assertions:
      - type: latency
        operator: lt
        value: 500

  - name: "User can login"
    endpoint: "/api/auth/login"
    method: POST
    expectedStatus: 200
    body:
      email: "test@example.com"
      password: "testpass"

canary:
  enabled: true
  trafficPercent: 10
  duration: "10m"
  thresholds:
    errorRate: 0.01
    p95Latency: 500
  rollbackOnFailure: true

rollback:
  autoRollback: true
  retainVersions: 5
```

## MCP Tools Used

- `deploy_detect` — Detect deployment provider
- `deploy_verify` — Full verification
- `deploy_health` — Quick health check
- `deploy_config_generate` — Create sample config
- `deploy_vercel_list` — List Vercel deployments
- `deploy_vercel_promote` — Promote to production
- `deploy_vercel_rollback` — Rollback deployment

## Vercel Integration

Set `VERCEL_TOKEN` for full Vercel integration:
```bash
export VERCEL_TOKEN=your_token_here
```

Commands available with Vercel token:
- List recent deployments
- Promote preview to production
- Rollback to previous version

## Important

- Always verify deployment URLs before promoting to production
- Smoke tests hit the actual deployment — use test data
- Canary analysis requires the app to be running for the duration
- Rollbacks are immediate — verify the target deployment first
