Sync vault notes: April-November 2026 sessions, projects, and architecture

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
garfieldandClaude Sonnet 5.5 committed 2026-11-13 11:00:53 -05:00
1 parent fe4fe656be
commit 994c7ae577
379 files changed
+55216 -107

No files matched your search

+105
View File
@@ -0,0 +1,105 @@
# Daily Note — 2026-06-10
## SquareMCP / Hermes MCP — Session Summary
Two major deployments today: Twilio WhatsApp inbound webhook + Meta webhook security hardening.
---
## 1. Twilio WhatsApp Inbound Webhook — Deployed
**What:** `POST /webhook/twilio/whatsapp` — inbound WhatsApp messages from Twilio land here. The pilot approval loop (Alex replies "1/2/3" → draft approved → tracking link created → confirmation sent) is now wired.
**Commit:** `e5152ee` — `feat(webhook): Twilio WhatsApp inbound route + Meta webhook hardening` (Claude Sonnet 4.6)
**New files:**
- `src/webhooks/twilio-whatsapp.ts` — HMAC-SHA1 validation, Redis dedup, approval handler, Redis seed
- `src/webhooks/twilio-whatsapp.test.ts` — 18 tests, all passing
**Modified:**
- `src/index.ts` — import + `initTwilioWebhookMapping()` in main() + `app.post('/webhook/twilio/whatsapp')` + Meta fail-open fix + timingSafeEqual length guard
**Features:**
- Twilio signature validation (HMAC-SHA1)
- Redis dedup (`wa_msg_seen:MessageSid`, 24h TTL)
- `pilot_owner_phone` allowlist
- 7-day staleness check on drafts
- Tracking link creation via `createTrackingLink()`
- Draft status update to `approved`
- Confirmation message back to Alex
- Graceful fallback messages (no drafts, expired drafts, invalid reply, media not supported)
**Deployed image:** `hermes-mcp@sha256:172a9a0b703beb49113e5922fe16cf7ec2b6342975440291189c156100d128b2`
---
## 2. Meta Webhook Security Hardening — Deployed
**What:** Two critical security bugs fixed in the existing Meta WhatsApp webhook handler.
**Bug 1 — Fail-open when `WHATSAPP_APP_SECRET` unset:**
- **Before:** If `WHATSAPP_APP_SECRET` was not set, the webhook skipped validation entirely and returned `200` to any request. Any attacker could POST to `/webhook/whatsapp` and trigger WhatsApp message processing.
- **After:** Returns `503` with "Webhook validation not configured" and logs an error. Fail-closed.
**Bug 2 — `timingSafeEqual` length mismatch → `RangeError` → `500`:**
- **Before:** A malformed `x-hub-signature-256` header with wrong length caused `crypto.timingSafeEqual` to throw `RangeError`, resulting in a `500` server error.
- **After:** Length guard added before `timingSafeEqual`. Returns `403` for length mismatch.
**Post-deploy verification:**
| Test | Before | After | Status |
|------|--------|-------|--------|
| Meta webhook, no signature | `200` (fail-open) | `503` (fail-closed) | ✅ Confirmed |
| Meta webhook, malformed signature | `500` (crash) | `403` (rejected) | ✅ Confirmed |
| Twilio route, no signature | `404` (not exist) | `403` (rejected) | ✅ Confirmed |
| Twilio route, bad signature | `404` (not exist) | `403` (rejected) | ✅ Confirmed |
| Health endpoint | `200` | `200` | ✅ Confirmed |
---
## Deployment Log
| Service | Image SHA | Status |
|---------|-----------|--------|
| `hermes-mcp` | `sha256:172a9a0b703beb49113e5922fe16cf7ec2b6342975440291189c156100d128b2` | ✅ Rolled out |
---
## Remaining Config (needs user input)
### `WHATSAPP_APP_SECRET`
- **Source:** Meta developer console → App → Settings → Basic → App Secret
- **Purpose:** Activates HMAC validation on the Meta webhook (`POST /webhook/whatsapp`)
- **Current state:** Not set → Meta webhook returns `503` (fail-closed, secure but non-functional for Meta inbound)
- **Action:** Add to `hermes-k8s.yaml` and restart deployment
### `PILOT_CUSTOMER_ID`
- **Source:** `SELECT id FROM customers WHERE pilot_active = 1 LIMIT 1;`
- **Purpose:** Seeds the Twilio webhook mapping so inbound messages to +19547385805 are routed to the correct customer
- **Current state:** No pilot customer exists yet → `initTwilioWebhookMapping()` logs warning, inbound messages dropped
- **Action:** Create Lodge Brothers customer with `pilot_active = 1` and `pilot_owner_phone`, then set env var and restart
### Twilio Console Configuration
- **URL:** `https://hermes.squaremcp.com/webhook/twilio/whatsapp`
- **Method:** POST
- **Number:** +19547385805
- **Action:** Configure in Twilio Console → Phone Numbers → Messaging → WhatsApp webhook
---
## Vault Notes
- [[SquareMCP/2026-06-10-twilio-whatsapp-webhook-deployment.md]]
- [[SquareMCP/2026-06-10-twilio-whatsapp-inbound-webhook-eng-review.md]]
- [[SquareMCP/2026-06-10-twilio-whatsapp-inbound-webhook.md]]
---
## Next Up
- [ ] Get `WHATSAPP_APP_SECRET` from Meta → add to K8s → restart pod
- [ ] Get `PILOT_CUSTOMER_ID` (create Alex/Lodge Brothers customer) → add to K8s → restart pod
- [ ] Configure Twilio Console webhook URL for +19547385805
- [ ] Lodge Brothers beta: pilot draft cron (weekly Claude API draft generation)
- [ ] Lodge Brothers beta: actual Facebook publish after approval
- [ ] Lodge Brothers beta: lead dashboard (`GET /dashboard`)