Status: ✅ Backend complete, frontend needs environment variable configuration
Date: 2025-11-06
- Location:
/backend/app/webhooks.py(lines 571-701) - Endpoint:
POST /api/webhooks/vercel-failure - Status Endpoint:
GET /api/webhooks/vercel-failure/status - Production URL: https://scopelock.onrender.com/api/webhooks/vercel-failure
- Health Check: https://scopelock.onrender.com/health (status: degraded but operational)
How It Works:
- Vercel deployment fails (state=ERROR, target=production)
- Vercel POSTs webhook to backend endpoint
- Backend invokes Rafael via Claude CLI (background task)
- Rafael uses Vercel MCP to fetch build logs
- Rafael diagnoses issue and pushes fix
- Vercel auto-deploys fixed version
- Updated
mission-deck-frontend/.env.local - Changed:
NEXT_PUBLIC_API_URL=https://scopelock.onrender.com - Note:
.env.localis in.gitignore(correctly not committed)
Via Vercel Dashboard:
- Go to: https://vercel.com/mindprotocol/scopelock/settings/environment-variables
- Click "Add New"
- Key:
NEXT_PUBLIC_API_URL - Value:
https://scopelock.onrender.com - Environments: Production, Preview, Development (check all)
- Click "Save"
- Redeploy: https://vercel.com/mindprotocol/scopelock/deployments
OR Via Vercel CLI:
cd mission-deck-frontend
vercel login
echo "https://scopelock.onrender.com" | vercel env add NEXT_PUBLIC_API_URL production
vercel --prodVia Vercel Dashboard:
- Go to: https://vercel.com/mindprotocol/scopelock/settings/git-hooks
- Click "Add Webhook"
- URL:
https://scopelock.onrender.com/api/webhooks/vercel-failure - Events: Check "Deployment Error"
- Environment: Production only
- Click "Save"
Test Webhook:
# Trigger test deployment failure (optional)
curl -X POST https://scopelock.onrender.com/api/webhooks/vercel-failure \
-H "Content-Type: application/json" \
-d '{
"id": "test_webhook_manual",
"name": "scopelock",
"state": "ERROR",
"target": "production",
"url": "https://scopelock-test.vercel.app",
"meta": {
"githubCommitSha": "abc123",
"githubCommitMessage": "test webhook configuration"
}
}'
# Expected response:
# {"status":"rafael_invoked","deployment_id":"test_webhook_manual","project":"scopelock"}
# Check webhook status:
curl https://scopelock.onrender.com/api/webhooks/vercel-failure/status- Open https://scopelock-mission-deck.vercel.app (or your deployment URL)
- Enter OTP:
123456(test OTP from backend) - Should see Mission Deck with "Your Missions" list
- Verify API calls go to scopelock.onrender.com (check browser DevTools Network tab)
Scenario A: Real Deployment Failure
- Push code with intentional error (e.g., typo in import)
- Wait for Vercel deployment to fail
- Webhook triggers Rafael automatically
- Check Rafael session in
/citizens/rafael/for SYNC.md updates - Rafael should diagnose, fix, commit, and push
- Vercel auto-deploys fixed version
Scenario B: Manual Webhook Test
- Use curl command above to trigger test webhook
- Check backend logs:
https://dashboard.render.com/web/srv-d43toq3ipnbc73cb5kqg/logs - Look for "🤖 VERCEL AUTO-FIX - INVOKING RAFAEL"
- Verify Rafael CLI invocation in logs
┌─────────────────────────────────────────────────────────────┐
│ Vercel (Frontend) │
│ │
│ Next.js App (scopelock-mission-deck.vercel.app) │
│ ↓ API calls (NEXT_PUBLIC_API_URL) │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ Render (Backend - scopelock.onrender.com) │
│ │
│ FastAPI Backend: │
│ • /api/mission-deck/* - Mission Deck API routes │
│ • /api/webhooks/vercel-failure - Vercel auto-fix webhook │
│ • /health - Health check │
│ │
│ Services: │
│ • FalkorDB integration (graph database) │
│ • Claude CLI invocation (Rafael auto-fix) │
│ • Citizen runner (Emma, Inna, Rafael, Sofia, Maya) │
└─────────────────────────────────────────────────────────────┘
↑
┌─────────────────────────────────────────────────────────────┐
│ Vercel Webhooks │
│ │
│ Event: Deployment Error (state=ERROR, target=production) │
│ → POST to scopelock.onrender.com/api/webhooks/vercel-failure│
│ → Rafael investigates and fixes autonomously │
└─────────────────────────────────────────────────────────────┘
/backend/app/webhooks.py- All webhook endpoints (Vercel, Upwork, Telegram)/backend/app/main.py- FastAPI app with webhook router registered/backend/app/runner.py- Citizen CLI invocation (run_rafael_raw)/backend/app/api/mission_deck/- Mission Deck API routes
/mission-deck-frontend/.env.local- Local API URL (not committed)/mission-deck-frontend/src/lib/api-client.ts- API client using NEXT_PUBLIC_API_URL/mission-deck-frontend/vercel.json- Vercel deployment config
/citizens/SYNC.md- Latest status updates (2025-11-06 19:45 entry)/tools/vercel-auto-fix/README.md- Standalone webhook docs (archived, now in main backend)/docs/missions/mission-deck/- Mission Deck mission documentation
Issue: /health returns {"status":"degraded","services":{"citizen_runner":{"status":"disconnected"}}}
Impact: Citizen runner disconnected, but webhook endpoint still operational
Resolution: Monitor logs, may need to restart backend service if citizen invocations fail
Context: Earlier created separate mission-deck-backend Render service
Resolution: User deleted duplicate service (correct decision). All functionality now in main scopelock backend.
- Set Vercel environment variable (5 min) - Allows frontend to connect to production backend
- Configure Vercel webhook (5 min) - Enables auto-fix on deployment failures
- Test frontend login flow (10 min) - Verify end-to-end connectivity
- Test webhook with deployment failure (optional) - Verify auto-fix works
- Create Evidence Sprint artifacts (Mission Deck completion)
- Hand off to Sofia for QA
Backend Health: https://scopelock.onrender.com/health
Webhook Status: https://scopelock.onrender.com/api/webhooks/vercel-failure/status
Render Dashboard: https://dashboard.render.com/web/srv-d43toq3ipnbc73cb5kqg
Vercel Dashboard: https://vercel.com/mindprotocol/scopelock
Questions? Check /citizens/SYNC.md for latest updates or ask Rafael.
Prepared by: Rafael (rafael@scopelock)
Date: 2025-11-06 19:48 UTC