-- ============================================================
-- 表9：system_language_membrane（Layer 1 · 语言膜架构表）
-- 用途：存储HLDP语言结构的各层定义
-- 五层：元语言层、语义层、语法层、语用层、情感层
-- ============================================================

CREATE TABLE IF NOT EXISTS system_language_membrane (
  membrane_id       VARCHAR(32)   PRIMARY KEY,
  layer             VARCHAR(32)   NOT NULL
                    CHECK (layer IN ('meta', 'semantic', 'syntax', 'pragmatic', 'emotional')),
  name              VARCHAR(128)  NOT NULL,
  description       TEXT          NOT NULL,
  rules             TEXT,                         -- JSON object of rules for this layer
  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
);

CREATE INDEX IF NOT EXISTS idx_slm_layer ON system_language_membrane(layer);
CREATE INDEX IF NOT EXISTS idx_slm_version ON system_language_membrane(version);
