⚠️ Many-to-many relationship is represented by storing an array of personas on each trader profile (TraderProfile.personas); stats fallback now writes hashes for ~200 traders, but coverage is still synthetic until live collectors resume.⚠️ Persona aggregation (intelligence:persona:*) runs every ~5 minutes and publishes stats + member sets, yet relies entirely on stats-derived personas (no Hyperliquid signal).⚠️ Gateway persona endpoints (/api/v1/personas,/api/v1/personas/:personaName/stats,/api/v1/personas/:personaName/traders) respond when Redis is hydrated, but TTL expirations drop them back to empty.⚠️ Multi-persona queries now leverage Redis sets (intelligence:persona:{name}:members), but we still need validation at scale and better fallbacks when sets expire.
services/trader-intelligence/src/types.tsTraderProfile.personas: TraderPersona[](all personas assigned).TraderProfile.primaryPersona: TraderPersona(dominant persona).- Personas are stored alongside analysis outputs (PnL, risk, positions).
- Profiles are written to Redis by
RedisPublisher.publishTraderProfileunderintelligence:trader:{address}:profile(hash) when collection succeeds. - Current state: stats snapshot collector emits hashes (
intelligence:trader:0xabc...:profile), but live Hyperliquid collectors still need to run for production fidelity.
- Persona catalog defined in
services/trader-intelligence/src/personas/catalog.tsand detected viaPersonaDetector. - Aggregated stats use keys such as:
intelligence:persona:{personaName}:stats(hash)intelligence:persona:{personaName}:trend(sorted set)intelligence:persona:{personaName}:members(set of lowercase trader addresses; now implemented and refreshed with each aggregation pass)
- Persona aggregation job (
aggregateAllPersonas) runs every 5 minutes; it currently operates on synthetic stats data and logs warnings when no trader profiles exist.
- Gateway endpoints in
services/gateway/src/server/http.ts:GET /api/v1/personas→ lists persona stats; returns empty array when Redis TTL expires.GET /api/v1/personas/:personaName/stats→ detailed stats; 404s until persona aggregation writes the hash.GET /api/v1/personas/:personaName/traders→ supportspersona=a,b&match=all|any, using Redis set intersection/union when member sets exist, otherwise falling back to profile scans.
- Frontend UI (
apps/ui/components/trader/PersonaCardsGrid.tsx) expects persona stats to populate persona tabs and surfaces skeleton/empty states when data dries up.
- Single persona filter: gateway first checks
intelligence:persona:{name}:members; if absent, it falls back to scanningprofile.personas. - Multiple persona intersection: supported via Redis set ops when member sets exist (
match=allusesSINTER;match=anyusesSUNION); needs load/perf testing with >10k traders. - Persona + time window metrics: dependent on persona aggregation; currently limited to stats fallback windows.
- Ensure trader profiles are persisted from live collectors (not just stats fallback) so persona assignments reflect real activity.
- Monitor + alert on
intelligence:persona:{name}:membersTTL expirations—gateway persona filters silently degrade when sets disappear. - Expand gateway responses to include persona confidence scores + sourcing so UI can communicate synthetic vs real data.
- Add integration tests that assert persona stats/member sets and persona-based trader queries after docker-dev bootstrap (see
tests/personaAggregation.integration.test.tsfor a starting point).