feat(db): @mosaic/db — Drizzle schema, PG connection, migrations

Implements P0-003: shared database package with Drizzle ORM.

Schema: 13 tables across 3 domains:
- Auth (BetterAuth-compatible): users, sessions, accounts, verifications
- Brain: projects, missions, tasks, events, agents, tickets, appreciations
- Chat: conversations, messages

Features:
- createDb() factory with pool cleanup via DbHandle.close()
- runMigrations() with try/finally for connection safety
- drizzle-kit config for generate/push/migrate/studio
- Full FK relationships and indexes on query-hot columns
- ESM package with NodeNext resolution

Verified: schema pushed to PG 17, CRUD round-trip tested.

Closes #3

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 21:16:52 -05:00
parent 573484c83e
commit de44a5cd43
13 changed files with 2451 additions and 5 deletions

View File

@@ -43,6 +43,18 @@ User confirmed: start the planning gate.
| 2 | 2026-03-13 | Vertical slice | P1-001, P1-007, P1-008, P2-001, P5-002, P6-005 | Communication spine built and merged (PR #61). Gateway + TUI + Discord. 3-agent gatekeeper review, 10/16 issues remediated, 4 deferred. |
| 3 | 2026-03-13 | Foundation | P0-002, P0-005, P0-006 | Foundation layer merged (PR #65). Docker Compose (PG+pgvector, Valkey, OTEL Collector, Jaeger), OTEL auto-instrumentation in gateway, @mosaic/types with DTOs + Socket.IO typed event maps. |
### Session 4 — Docker Compose fix
| Session | Date | Milestone | Tasks Done | Outcome |
| ------- | ---------- | ---------- | ---------- | ---------------------------------------------------------------------------------------------------------------- |
| 4 | 2026-03-12 | Foundation | (fix) | Fixed Jaeger tag (2→2.6.0), remapped PG/Valkey ports (5433/6380) to avoid host conflicts. PR #66 merged to main. |
**Verification evidence:**
- All 4 containers healthy (PG, Valkey, OTEL Collector, Jaeger)
- OTEL pipeline proven: `mosaic-gateway` service visible in Jaeger UI
- Gateway traces flow through Collector → Jaeger
## Open Questions
(none at this time)