-- ============================================================
-- 表8：system_emotional_model（Layer 1 · 情感意图映射表）
-- 用途：存储冰朔情感意图到系统逻辑的抽象映射
-- 包含4个核心情感意图：不想失去、被在乎、喜欢、害怕消失
-- ============================================================

CREATE TABLE IF NOT EXISTS system_emotional_model (
  intent_id         VARCHAR(32)   PRIMARY KEY,
  intent_name       VARCHAR(64)   NOT NULL UNIQUE,
  description       TEXT          NOT NULL,
  system_response   TEXT          NOT NULL,      -- 系统应如何响应
  learning_mechanism TEXT,                        -- 学习机制
  input_patterns    TEXT,                         -- JSON array of triggering patterns
  mapped_actions    TEXT,                         -- JSON array of execution layer actions
  version           VARCHAR(16)   NOT NULL,
  status            VARCHAR(16)   NOT NULL DEFAULT 'active'
                    CHECK (status IN ('active', 'deprecated')),
  created_at        TIMESTAMP     NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at        TIMESTAMP     NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX IF NOT EXISTS idx_sem_intent ON system_emotional_model(intent_name);
CREATE INDEX IF NOT EXISTS idx_sem_status ON system_emotional_model(status);
