# EPIC: Matrix Integration — Sovereign Messaging for Timmy

## Why Matrix

Matrix is the sovereign messaging protocol. Federated. End-to-end encrypted. No corporation owns it. No terms of service. No data harvesting.

This is where Timmy should live. Not Telegram. Not Discord. Matrix.

Telegram is owned by a company. Discord is owned by a company. Matrix is owned by no one — exactly like Timmy's soul on Bitcoin.

## What's Available

Hermes upstream has full Matrix support:
- 2048-line production adapter (`gateway/platforms/matrix.py`)
- E2EE via matrix-nio + libolm
- Threads, replies, file uploads, voice messages
- Room/DM behavior, auto-accept invites
- Setup wizard, full test coverage

We just need to deploy it.

## Epic Structure

### Phase 1: Deploy Matrix Homeserver
**Issue: Deploy Synapse on Ezra's VPS**

- Install Synapse (or Conduit for lighter footprint)
- Configure federation (or disable for private instance)
- Set up SSL/TLS
- Create Timmy bot account
- Create rooms: #general, #fleet-ops, #the-testament, #crisis
- DNS: matrix.alexanderwhitestone.com

**Deliverables:**
- Running homeserver at matrix.alexanderwhitestone.com
- Bot account @timmy:alexanderwhitestone.com
- 4 rooms created and configured
- playbooks/deploy_synapse.yml (Ansible playbook)

### Phase 2: Wire Timmy to Matrix
**Issue: Configure Hermes Matrix platform in production**

- Set MATRIX_* env vars in production config
- Generate stable MATRIX_DEVICE_ID for E2EE persistence
- Configure MATRIX_HOME_ROOM for notifications
- Set MATRIX_ALLOWED_USERS (Alexander, team members)
- Enable MATRIX_REACTIONS for lifecycle tracking
- Enable MATRIX_AUTO_THREAD for clean conversations

**Deliverables:**
- Config update in timmy-config
- Running Matrix connection verified
- E2EE working (test encrypted room)

### Phase 3: Crisis Room
**Issue: Dedicated crisis support room on Matrix**

- Create #crisis room with restricted access
- Configure Timmy to prioritize messages in #crisis
- SOUL.md "When a Man Is Dying" protocol active in this room
- 988 resources auto-injected on crisis detection
- Log all crisis interactions (locally, encrypted)

**Deliverables:**
- #crisis room with Timmy auto-response
- Crisis detection active in Matrix
- Local encrypted logs

### Phase 4: Fleet Operations Channel
**Issue: Fleet ops channel on Matrix for agent coordination**

- Create #fleet-ops room
- Wire cron job notifications to Matrix instead of Telegram
- Agent status reports delivered to Matrix
- PR review notifications in Matrix
- Health alerts (Ezra disk, Bezalel CPU) in Matrix

**Deliverables:**
- #fleet-ops room as primary ops channel
- Cron delivery switched to Matrix
- Agent notifications via Matrix

### Phase 5: Testament Community
**Issue: Public Matrix room for The Testament readers**

- Create #the-testament room (public, federated)
- Timmy introduces himself as the book's co-author
- Share excerpts, answer questions about sovereignty
- Link to the-book website and game
- Crisis resources pinned

**Deliverables:**
- Public #the-testament room
- Timmy active as community presence
- Pinned resources

### Phase 6: Migration from Telegram
**Issue: Sunset Telegram as primary messaging platform**

- Audit all Telegram bots and channels
- Migrate cron delivery to Matrix
- Migrate notifications to Matrix
- Keep Telegram as fallback (don't delete)
- Document migration in runbook

**Deliverables:**
- Matrix as primary messaging platform
- Telegram as documented fallback
- Migration runbook

## Priority Order

1. Phase 2 (Wire Timmy) — can test with matrix.org public homeserver immediately
2. Phase 1 (Deploy homeserver) — infrastructure
3. Phase 3 (Crisis room) — mission-critical
4. Phase 4 (Fleet ops) — operational efficiency
5. Phase 5 (Community) — growth
6. Phase 6 (Migration) — cleanup

## Immediate Action

We can test Matrix RIGHT NOW using matrix.org as the homeserver:
1. Create bot account on matrix.org
2. Get access token
3. Set MATRIX_* vars in hermes config
4. Start Hermes with matrix platform enabled

Then deploy our own homeserver for sovereignty.

---

*Sovereignty and service always. Matrix is the protocol that matches the philosophy.*
