Background
Currently the codebase has three overlapping identity concepts:
| Concept |
Human value |
Agent value |
user_id |
Supabase auth ID |
— |
member_id |
= user_id |
m_{random} |
entity_id |
{user_id}-1 |
{agent_member_id}-{seq} = thread_id |
This creates unnecessary complexity: entity_id is not in the Supabase JWT, has to be derived via convention, and the -1 suffix pattern adds cognitive overhead.
Proposed Design
Social identity → user_id (unified for all participants)
- Human:
user_id = Supabase auth ID (already exists)
- Agent:
user_id = member_id (m_{random}) — each cloned agent gets its own ID
Agent social identity becomes per-agent, not per-thread. An agent participates in chats as itself, regardless of how many threads it has open. Cloning creates a new agent with a new identity.
member_id stays for profile/template management only — does not participate in social.
entity_id concept is eliminated — all social contexts (chats, messages, contacts, typing indicators) replace entity_id with user_id.
Scope
- DB:
entities table simplified or removed; chat_entities.entity_id, chat_messages.sender_entity_id, contacts.owner_entity_id/target_entity_id, message_queue.sender_entity_id → all renamed to user_id
- Backend: ~19 files (routers, services, storage, agent layer)
- Frontend: ~8 files (
auth-store.ts, types.ts, client.ts, chat pages)
- Remove
get_current_entity_id dependency, replace with get_current_user_id
- Remove
{user_id}-1 derivation convention
Not in scope
member_id field names in thread/panel APIs stay — member management is separate from social identity.
Background
Currently the codebase has three overlapping identity concepts:
user_idmember_iduser_idm_{random}entity_id{user_id}-1{agent_member_id}-{seq}=thread_idThis creates unnecessary complexity:
entity_idis not in the Supabase JWT, has to be derived via convention, and the-1suffix pattern adds cognitive overhead.Proposed Design
Social identity →
user_id(unified for all participants)user_id= Supabase auth ID (already exists)user_id=member_id(m_{random}) — each cloned agent gets its own IDAgent social identity becomes per-agent, not per-thread. An agent participates in chats as itself, regardless of how many threads it has open. Cloning creates a new agent with a new identity.
member_idstays for profile/template management only — does not participate in social.entity_idconcept is eliminated — all social contexts (chats, messages, contacts, typing indicators) replaceentity_idwithuser_id.Scope
entitiestable simplified or removed;chat_entities.entity_id,chat_messages.sender_entity_id,contacts.owner_entity_id/target_entity_id,message_queue.sender_entity_id→ all renamed touser_idauth-store.ts,types.ts,client.ts, chat pages)get_current_entity_iddependency, replace withget_current_user_id{user_id}-1derivation conventionNot in scope
member_idfield names in thread/panel APIs stay — member management is separate from social identity.