AETHEX Implementation Status & Roadmap Audit
Date: Current Build Scope: Cross-reference AETHEX Technical Roadmap (Phases 1-4) against current codebase Status: 60% Implemented, 30% Partially Implemented, 10% Not Yet Implemented
Executive Summary
The AETHEX project has made significant progress on Discord integration (Phase 2: Dual-Auth) and database schema (Phase 2/3). However, critical gaps exist in CSP configuration (Phase 1), RLS performance optimization (Phase 3), and CI/CD pipeline (Phase 4).
Key Findings:
✅ Discord OAuth backend fully implemented
✅ Database schema for Discord integration complete
✅ Discord bot (Discord.js) deployed and operational
⚠️ CSP for Discord Activity partially configured (frame-ancestors missing)
⚠️ RLS policies use per-row auth.uid() calls (performance anti-pattern)
❌ CI/CD pipeline not yet established (GitHub Actions missing)
PHASE 1: Vercel CSP Configuration for Discord Activity Embedding
Current State
File: code/vercel.json
What's Configured ✅
Critical Issues ⚠️
frame-ancestors 'none'- BLOCKS Discord Activity iFrameCurrent policy:
frame-ancestors 'none'Required policy:
frame-ancestors 'self' https://*.discordsays.comImpact: Discord Activity cannot embed the app
Missing Supabase URL in
connect-srcCurrent:
connect-src 'self' https: wss:(too broad, catch-all)Should be explicit:
connect-src 'self' https://kmdeisowhtsalsekkzqd.supabase.co https://xakdofkmympbhxkbkxbh.supabase.co wss:
style-src 'unsafe-inline'still presentAcceptable for now (React UI libraries need this)
Consider replacing with nonces in future
Recommendation
Priority: CRITICAL - Blocking Discord Activity
Replace the CSP header in vercel.json line 47:
PHASE 2: Discord SDK Dual-Authentication Flow
Current State
Backend Implementation ✅ FULLY COMPLETE
File: code/api/discord/oauth/callback.ts (196 lines)
What's Working:
✅ Receives Discord OAuth code
✅ Exchanges code for Discord access token
✅ Fetches user profile via Discord API
✅ Creates/links user in Supabase
✅ Sets session cookies (sb-access-token, sb-refresh-token)
✅ Redirects to /onboarding or /dashboard
Code Flow (lines 48-120):
Verified Working: OAuth button in Login.tsx redirects to /api/discord/oauth/start → Discord auth → callback → dashboard
Frontend Implementation ⚠️ PARTIALLY COMPLETE
Files:
code/client/contexts/DiscordActivityContext.tsx(137 lines)code/client/pages/Activity.tsx(152 lines)
What's Working:
✅ Discord SDK initialization in context
✅ Detects iFrame context (frame_id query param)
✅ Calls /api/discord/activity-auth endpoint
✅ Sets Supabase session
✅ Activity page with profile display
What's Missing:
❌ Custom dual-auth flow (Phase 2 Section A step 10)
Current: Uses standard
supabase.auth.setSession()Needed: Call
discordSdk.commands.authenticate()with Discord tokenImpact: Discord SDK commands unavailable inside Activity
Code Gap (DiscordActivityContext.tsx line ~80):
Recommendation
Priority: HIGH - Enables Discord Activity commands
Update code/client/contexts/DiscordActivityContext.tsx to complete the dual-auth flow:
In the
activity-authresponse, includediscord_token(not just Supabase session)After
setSession(), call:
PHASE 3: Supabase RLS Performance Optimization
Current State
Files:
code/supabase/migrations/20250107_add_discord_integration.sql(line 62)code/supabase/migrations/20250107_add_web3_and_games.sql(lines 108-121)code/supabase/migrations/20251018_fix_team_memberships_rls.sql(lines 15, 21, 34)
RLS Policy Audit
Anti-Pattern Policies Found ⚠️
Policy 1: Discord Links (20250107_add_discord_integration.sql:62)
Policy 2: Web3 Nonces (20250107_add_web3_and_games.sql:109)
Policy 3: Team Memberships (20251018_fix_team_memberships_rls.sql:15)
Impact Analysis
Current behavior: Database calls
auth.uid()for EVERY row scannedPerformance cost: O(n) where n = number of rows
Real-world: Querying 10,000 rows = 10,000 function calls
Observed symptoms: High database CPU, query timeouts (likely from advisor warnings)
Recommendation
Priority: HIGH - Resolves performance bottleneck
Create new migration: code/supabase/migrations/20250120_optimize_rls_auth_calls.sql
Apply the optimization pattern to ALL auth.uid() calls:
Complete Fix:
Verification: After applying migration, Supabase advisors should report resolved performance warnings.
PHASE 4: Establishing Supabase CI/CD Pipeline
Current State
Files: None found for .github/workflows/
What's Missing ❌
GitHub Actions workflow file:
.github/workflows/supabase-deploy.ymlNot created
Would handle automated schema deployments
GitHub Environments:
No
stagingenvironment configuredNo
productionenvironment configuredNo repository secrets configured
Local Development Setup:
No evidence of
supabase startusageNo migration generation workflow documented
Migrations likely created manually or directly in dashboard
Recommendation
Priority: MEDIUM - Improves maintainability
Step 1: Create GitHub Actions Workflow
Create file: .github/workflows/supabase-deploy.yml
Step 2: Configure GitHub Environments
In repository settings (Settings → Environments):
Staging Environment:
Branch:
developSecrets:
SUPABASE_ACCESS_TOKEN: Personal token from supabase.com/account/tokensSUPABASE_PROJECT_ID: Project ID for aethex-stagingSUPABASE_DB_PASSWORD: Staging database password
Production Environment:
Branch:
mainSecrets:
SUPABASE_ACCESS_TOKEN: (same as above)SUPABASE_PROJECT_ID: Project ID for aethex-productionSUPABASE_DB_PASSWORD: Production database password
Step 3: Document Migration Workflow
Create: code/docs/SUPABASE_MIGRATION_WORKFLOW.md
Edit migration in
supabase/migrations/Test locally:
Commit and push to feature branch
Create PR against
developOn merge to
develop: Staging deployment triggered automaticallyAfter verification, merge
develop→mainProduction deployment triggered automatically
Last updated
