Skip to content

refactor: unify social identity to user_id, eliminate entity_id #194

@nmhjklnm

Description

@nmhjklnm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions