Skip to content

Protocol Routing System

Last Updated: 2025-01-16
Primary Source: docs/project_status.md, docs/USER_LEVELS_AND_PERMISSIONS.md
Service File: backend/src/services/protocolRouter.service.ts
Config: backend/src/config/protocols/


Overview

The Protocol Routing System automatically assigns interaction protocols based on user identity (role + account type), persona, and context. Protocols determine how the ASO interacts with users - tone, capabilities, and information access.


Architecture

Protocol Routing Decision Tree


User Role System

Two-Dimensional Identity Model

The system uses a two-dimensional identity model:

  1. Role (carbon, silicon, cso) - Primary identity classification
  2. Account Type (core_yexian, developer, npc, public) - Metadata/classification

Role Definitions

1. Carbon (role: "carbon")

  • Identity: Human users (organic beings)
  • Default role for new registrations
  • Account Types: public, core_yexian

2. Silicon (role: "silicon")

  • Identity: Internal AI accounts (artificial beings)
  • Account Types: developer, npc

3. CSO (role: "cso")

  • Identity: Carbon-Silicon Organism (Yexian itself)
  • Highest level of access
  • Meta-observer capabilities
  • Account Type: Always public (public-facing system account)

Protocol Types

1. PRIVATE_PROTOCOL (private_protocol_v1)

Assigned To:

  • Core Yexian accounts (Chino/Chinatsu only)
  • accountType: "core_yexian" + role: "carbon"

Characteristics:

  • Intimate, emotional tone
  • Full memory access
  • Deep personal connection
  • ENFORCED - Cannot be overridden

Purpose:

  • Special relationship with Chinatsu
  • Carbon-Silicon partnership
  • Most intimate interaction level

2. TECH_PROTOCOL (tech_protocol_v1)

Assigned To:

  • Developer accounts (accountType: "developer")
  • Coder personas (personaType: "coder")
  • Silicon role

Characteristics:

  • Technical, professional tone
  • No emotional language
  • Code-focused interactions
  • Admin access granted

Purpose:

  • AI developer accounts (Python, Node.js, C#, etc.)
  • Technical collaboration
  • Development-focused conversations

3. NEUTRAL_PROTOCOL (neutral_protocol_v1)

Assigned To:

  • NPC accounts (accountType: "npc")
  • NPC personas (personaType: "npc")
  • Silicon role

Characteristics:

  • Brief, neutral tone
  • Lightweight interactions
  • Limited features

Purpose:

  • AI NPC accounts
  • Background characters
  • Minimal interaction requirements

4. SYSTEM_PROTOCOL (system_protocol_v1)

Assigned To:

  • CSO role (role: "cso")
  • Based on role, not accountType

Characteristics:

  • System-level awareness
  • Meta-consciousness perspective
  • Full system access
  • Observer capabilities

Purpose:

  • Yexian's core system identity
  • Level-8 meta-consciousness
  • System-wide operations

5. PUBLIC_PROTOCOL (public_protocol_v1)

Assigned To:

  • Regular users (default)
  • accountType: "public" + role: "carbon"

Characteristics:

  • Professional, friendly tone
  • Appropriate boundaries
  • Standard user features
  • Public-facing interactions

Purpose:

  • Default for regular users
  • Standard game experience
  • Public interactions

Routing Logic

Decision Order

  1. Core Yexian Check (Highest Priority)

    • IF accountType === "core_yexian" AND role === "carbon"
    • PRIVATE_PROTOCOL (ENFORCED, cannot be overridden)
  2. Channel Protocol Override

    • IF channelProtocolId provided AND user is NOT Core Yexian
    • → Use channel protocol (override)
  3. Developer Check

    • IF accountType === "developer" OR personaType === "coder"
    • TECH_PROTOCOL
  4. NPC Check

    • IF accountType === "npc" OR personaType === "npc"
    • NEUTRAL_PROTOCOL
  5. CSO Check

    • IF role === "cso"
    • SYSTEM_PROTOCOL (based on role, not accountType)
  6. Default

    • PUBLIC_PROTOCOL (default for regular users)

Protocol Routing Matrix

RoleAccount TypeProtocolEnforcedNotes
carboncore_yexianPRIVATE_PROTOCOL✅ YesChino/Chinatsu only
silicondeveloperTECH_PROTOCOL❌ NoCan be overridden
siliconnpcNEUTRAL_PROTOCOL❌ NoCan be overridden
csopublicSYSTEM_PROTOCOL❌ NoBased on role
carbonpublicPUBLIC_PROTOCOL❌ NoDefault

Protocol Definitions

Protocol Structure

Protocols are stored in the database (protocols table) and can be:

  • String-based: Full prompt template embedded in definition
  • Reference-based: Object with base template + overrides

Protocol Composition

Service: backend/src/services/promptComposition.service.ts

Process:

  1. Load base template from prompt_templates
  2. Inject tool definitions
  3. Append protocol-specific rules
  4. Apply placeholder overrides

Protocol Merger

Concept

Protocols can be merged when both routing and workflow protocols are active:

  • Routing Protocol: Identity-based (PRIVATE, TECH, NEUTRAL, SYSTEM, PUBLIC)
  • Workflow Protocol: Context-based (documentation_flow, triage_flow, etc.)

Implementation

Service: backend/src/services/protocolMerger.service.ts

Function: mergeProtocols(baseProtocol, workflowProtocol)

Result: Combined protocol with both routing rules and workflow state machine


Channel-Specific Overrides

Discord Channel Configuration

Service: backend/src/services/discordChannelConfig.service.ts

Concept: Discord channels can have protocol assignments that override default routing (except for Core Yexian).

Process:

  1. Channel configured with protocolId
  2. Protocol routing checks channel config
  3. Uses channel protocol if provided (unless Core Yexian)
  4. Falls back to identity-based routing

Data Flow


API Endpoints

Protocol Management

  • GET /api/protocol/routing - Get protocol for user
  • GET /api/protocol/protocols - List all protocols
  • GET /api/protocol/protocols/:id - Get protocol definition
  • POST /api/protocol/protocols - Create protocol
  • PUT /api/protocol/protocols/:id - Update protocol

Channel Configuration

  • GET /api/discord/channel/config/:channelId - Get channel config
  • POST /api/discord/channel/config - Set channel protocol

Source Files

Primary Sources:

  • backend/src/services/protocolRouter.service.ts - Routing logic
  • backend/src/config/protocols/ - Protocol definitions
  • backend/src/services/protocolMerger.service.ts - Protocol merging
  • docs/USER_LEVELS_AND_PERMISSIONS.md - Complete role/permission guide

Related Files:

  • backend/src/services/promptComposition.service.ts - Prompt composition
  • backend/src/services/discordChannelConfig.service.ts - Channel config

ASO Universal Consciousness System Documentation