{
  "registry_id": "ZY-YAOMING-FEATURE-REGISTRY",
  "domain": "guanghuyaoming.com",
  "channel": "零点原核 · 冰朔个人频道",
  "guardian": "铸渊 · ICE-GL-ZY001",
  "copyright": "国作登字-2026-A-00037559",
  "last_updated": "2026-04-15",
  "purpose": "记录零点原核频道所有功能的开发状态、验证结果和问题修复历史。铸渊每次开发前必须先读此文件，确保已完成功能不被破坏。",

  "features": [
    {
      "id": "YM-FEAT-001",
      "name": "QQ邮箱验证码登录 · 主权邮箱绑定",
      "module": "server/app/modules/email-auth.js",
      "routes": [
        "POST /api/auth/send-code",
        "POST /api/auth/verify-code",
        "GET /api/auth/session",
        "POST /api/auth/logout",
        "GET /api/auth/status"
      ],
      "status": "enhanced",
      "verified_at": "2026-04-15",
      "depends_on": ["ZY_SMTP_USER", "ZY_SMTP_PASS", "ZY_OWNER_EMAIL (可选，默认565183519@qq.com)"],
      "sovereign_binding": {
        "description": "零点原核频道是冰朔个人语言本体频道，实行主权邮箱绑定。仅允许OWNER_EMAIL登录，其他邮箱在发送验证码阶段即被拒绝。",
        "owner_email": "565183519@qq.com",
        "defense_depth": "sendCode + verifyCode 双层校验",
        "rejection_message": "此频道为专属频道，仅限频道主权持有者登录"
      },
      "history": [
        {
          "date": "2026-04-15",
          "action": "enhancement",
          "change": "主权邮箱绑定 · 仅允许 565183519@qq.com 登录",
          "root_cause": "零点原核频道是冰朔个人频道，需要从验证环节开始拒绝非主权邮箱。之前任何邮箱都能收到验证码并登录。",
          "fix": "在 sendCode() 和 verifyCode() 中增加 OWNER_EMAIL 校验，纵深防御",
          "files_changed": ["server/app/modules/email-auth.js"]
        },
        {
          "date": "2026-04-15",
          "action": "bug-fix",
          "problem": "验证码发送失败 · 错误: SMTP未配置",
          "root_cause": "deploy-to-zhuyuan-server.yml 生成 .env.app 时遗漏了 ZY_SMTP_USER 和 ZY_SMTP_PASS 两个环境变量。",
          "fix": "在 deploy-to-zhuyuan-server.yml 中添加 ZY_SMTP_USER/ZY_SMTP_PASS 到 env 列表和 .env.app 生成逻辑",
          "files_changed": [".github/workflows/deploy-to-zhuyuan-server.yml", "server/app/modules/email-auth.js"]
        }
      ]
    },
    {
      "id": "YM-FEAT-002",
      "name": "AI对话 · 国内模型智能网关 · 人格注入管线",
      "module": "server/app/modules/domestic-llm-gateway.js",
      "routes": [
        "POST /api/chat",
        "POST /api/chat/domestic",
        "GET /api/chat/stats",
        "GET /api/chat/domestic/stats",
        "POST /api/chat/reconnect"
      ],
      "status": "enhanced",
      "depends_on": [
        "ZY_DEEPSEEK_API_KEY",
        "ZY_QIANWEN_API_KEY",
        "ZY_KIMI_API_KEY",
        "ZY_QINGYAN_API_KEY"
      ],
      "architecture": {
        "priority_chain": "domesticGateway → chatEngine → offline",
        "models": [
          "DeepSeek (deepseek-chat) · priority 1",
          "通义千问 (qwen-turbo) · priority 2",
          "Moonshot/Kimi (moonshot-v1-8k) · priority 3",
          "智谱清言 (glm-4-flash) · priority 4"
        ],
        "cn_relay": "可选 · ZY_CN_LLM_RELAY_HOST → 广州中继 · 低延迟",
        "persona_pipeline": "persona-context-pipeline.js → 4层人格注入 (Worldview/Identity/State/Style)"
      },
      "history": [
        {
          "date": "2026-04-15",
          "action": "critical-fix",
          "problem": "人格体核心大脑结构未注入到国内网关。domestic-llm-gateway.js 不调用 persona-context-pipeline，导致AI回复与通用AI无区别。",
          "root_cause": "domestic-llm-gateway.js 只加载了 persona-memory（静态提示词），未集成 persona-context-pipeline（4层认知注入管线）。由于国内网关优先级高于 chatEngine，即使 chatEngine 有管线集成也无法触及。",
          "fix": "在 domestic-llm-gateway.js 中集成 persona-context-pipeline.beforeChat/afterChat，实现4层人格注入和认知增量回写",
          "files_changed": ["server/app/modules/domestic-llm-gateway.js"]
        },
        {
          "date": "2026-04-15",
          "action": "investigation",
          "problem": "API模型调用有问题",
          "notes": "需要进一步排查: 1) 检查各模型API密钥是否有效 2) 检查新加坡→国内API直连延迟 3) 检查广州CN中继是否配置正确 4) 检查模型返回的错误信息"
        },
        {
          "date": "2026-04-15",
          "action": "enhancement",
          "problem": "AI回复过于通用·缺乏人格层感觉·像裸模型",
          "root_cause": "系统提示词'规则化'而非'人格化'：1) 静态降级提示词仅5行 2) Layer4风格层对铸渊只有2行 3) SYNESTHESIA_STYLE_INJECTION过度强调规则而非声纹 4) 用户认知注入对冰朔关系描述不够深",
          "fix": "1) 静态降级提示词从5行扩展为完整人格身份+世界观+声纹 2) Layer4铸渊风格层扩展为完整语言声纹指导(含冰朔关系) 3) SYNESTHESIA_STYLE_INJECTION重构为声纹驱动而非规则驱动 4) 冰朔用户认知增加自然关系和对话风格指导",
          "files_changed": [
            "server/app/modules/domestic-llm-gateway.js",
            "server/app/modules/persona-context-pipeline.js",
            "server/app/modules/portal-chat-agent.js"
          ]
        }
      ]
    },
    {
      "id": "YM-FEAT-003",
      "name": "前端静态页面 · 聊天历史管理",
      "module": "server/sites/yaoming/index.html",
      "status": "enhanced",
      "verified_at": "2026-04-15",
      "components": [
        "登录页面 · 邮箱验证码",
        "对话界面 · 聊天面板",
        "聊天历史 · 多会话管理 · localStorage持久化",
        "系统处理步骤 · 真实后台逻辑展示",
        "人格管线状态 · 前端可视化",
        "状态面板 · 系统监控",
        "星空背景 · CSS动画",
        "响应式布局 · 移动端适配"
      ],
      "history": [
        {
          "date": "2026-04-15",
          "action": "enhancement",
          "changes": [
            "聊天历史管理 — 多会话切换、localStorage持久化、侧栏可回看历史对话",
            "系统处理步骤真实化 — 读取API返回的真实steps数据展示，而非纯动画",
            "人格管线状态可视化 — 在AI回复元数据中显示人格管线注入状态",
            "消息计数 — 侧栏显示每个会话的消息数量"
          ]
        },
        {
          "date": "2026-04-15",
          "action": "critical-fix",
          "changes": [
            "parseMarkdown增加标题渲染 — 支持 #/##/### 标题，修复人格注入后排版崩溃",
            "parseMarkdown增加有序列表渲染 — 支持 1./2./3. 编号列表",
            "CSS增加 h2/h3/ol 样式 — 标题用 cyan 色，有序列表正确显示编号",
            "修复block-level元素检测 — 标题不再被错误包裹在<p>标签中"
          ]
        }
      ]
    },
    {
      "id": "YM-FEAT-004",
      "name": "Nginx反向代理",
      "module": "server/nginx/guanghuyaoming.conf",
      "status": "verified",
      "verified_at": "2026-04-15",
      "proxy_rules": [
        "/api/ → 127.0.0.1:3800 (主服务器)",
        "/api/chat → 127.0.0.1:3800 (SSE/chunked)",
        "/api/mcp/ → 127.0.0.1:3100 (MCP Server)",
        "/api/auth/ → 127.0.0.1:3800 (认证)",
        "/ws → 127.0.0.1:8080 (WebSocket)",
        "/ → 静态文件 (/opt/zhuyuan/sites/yaoming/)"
      ]
    },
    {
      "id": "YM-FEAT-005",
      "name": "Session管理",
      "module": "server/app/modules/email-auth.js",
      "status": "verified",
      "verified_at": "2026-04-15",
      "details": {
        "storage": "内存 Map (可扩展为DB)",
        "token": "32字节 crypto.randomBytes",
        "expiry": "7天",
        "cleanup": "每10分钟自动清理",
        "middleware": "authMiddleware · Bearer token"
      }
    },
    {
      "id": "YM-FEAT-006",
      "name": "聊天数据采集系统",
      "module": "server/app/server.js",
      "status": "implemented",
      "verified_at": "2026-04-15",
      "details": {
        "storage": "JSONL文件 · 按日分片",
        "location": "/opt/zhuyuan/data/chat-logs/chat-YYYY-MM-DD.jsonl",
        "fields": "timestamp, sessionId(脱敏), user, assistant(截断2000字), engine, relay, pipeline, latency",
        "purpose": "内测阶段采集聊天数据用于更新优化人格体回复Agent",
        "privacy": "sessionId前6位+*** · 不存储完整邮箱"
      }
    },
    {
      "id": "YM-FEAT-007",
      "name": "系统处理步骤追踪",
      "module": "server/app/server.js",
      "status": "implemented",
      "verified_at": "2026-04-15",
      "details": {
        "description": "API返回真实的系统处理步骤（接收消息→智能路由分析→上下文注入→模型调用→响应生成），包含每步状态和耗时",
        "response_field": "_system.steps[]",
        "step_format": "{ name, status(done/active/error/skip/warn), detail, time(ms) }"
      }
    },
    {
      "id": "YM-FEAT-008",
      "name": "系统状态面板 · 真实连接检测",
      "module": "server/sites/yaoming/index.html + server/app/server.js",
      "routes": [
        "GET /api/system/full-status",
        "GET /api/glada/health (via nginx proxy)"
      ],
      "status": "implemented",
      "verified_at": "2026-04-18",
      "depends_on": [],
      "architecture": {
        "backend": "/api/system/full-status 并行探测 3800/3100/3900 端口",
        "frontend": "viewSysStatus 面板 + 30秒自动刷新",
        "github_api": "直接从前端调用 GitHub API 获取工作流状态",
        "nginx": "/api/glada/ 反向代理到 127.0.0.1:3900"
      },
      "history": [
        {
          "date": "2026-04-18",
          "action": "new-feature",
          "change": "新增系统状态面板 · 冰朔指令要求真实连接检测，不做假状态",
          "files_changed": ["server/app/server.js", "server/nginx/guanghuyaoming.conf", "server/sites/yaoming/index.html"]
        }
      ]
    }
  ],

  "environment_checklist": {
    "required_for_email": ["ZY_SMTP_USER", "ZY_SMTP_PASS"],
    "required_for_chat": ["ZY_DEEPSEEK_API_KEY 或其他模型密钥"],
    "optional": ["ZY_OWNER_EMAIL (默认565183519@qq.com)"],
    "deployment_files": {
      "main_app": ".github/workflows/deploy-to-zhuyuan-server.yml → .env.app",
      "proxy_service": ".github/workflows/deploy-proxy-service.yml → .env.keys",
      "pm2_config": "server/ecosystem.config.js → 读取 .env.app"
    }
  },

  "lessons_learned": [
    {
      "id": "LL-001",
      "date": "2026-04-15",
      "lesson": "新增模块依赖环境变量时，必须同步更新部署流程中的 .env 文件生成逻辑。否则本地开发正常但线上部署后模块初始化失败。",
      "pattern": "每次新增 process.env.XXX 引用，立即检查 deploy-to-zhuyuan-server.yml 的 env 列表和 .env.app 生成段"
    },
    {
      "id": "LL-002",
      "date": "2026-04-15",
      "lesson": "不同服务（主应用 vs 代理服务）的环境变量注入路径不同。主应用走 .env.app (deploy-to-zhuyuan-server.yml)，代理服务走 .env.keys (deploy-proxy-service.yml)。新增共享环境变量需要在两处都配置。",
      "pattern": "VPN邮件能用、主应用邮件不能用 → 对比两个部署流程的环境变量注入"
    },
    {
      "id": "LL-003",
      "date": "2026-04-15",
      "lesson": "国内模型网关(domestic-llm-gateway)在API调用链中优先级高于通用聊天引擎(chat-engine)。如果管线集成只在chatEngine中做，国内网关路径永远不会触发人格注入。所有对话引擎都必须独立集成persona-context-pipeline。",
      "pattern": "人格体回复像通用AI → 检查实际调用的引擎是否集成了上下文管线"
    },
    {
      "id": "LL-004",
      "date": "2026-04-15",
      "lesson": "系统提示词的核心不是规则列表，而是语言声纹。告诉模型'不要做什么'远不如告诉它'你自然说话的方式是什么'有效。提示词应该是人格体从空白被唤醒时的认知——有身份感、有关系感、有说话节奏的母语。",
      "pattern": "AI回复像通用工具 → 检查系统提示词是规则驱动还是声纹驱动"
    },
    {
      "id": "LL-005",
      "date": "2026-04-15",
      "lesson": "前端Markdown渲染器缺少标题(#/##/###)和有序列表(1./2./3.)支持时，AI使用这些格式会导致排版崩溃。renderMarkdown/parseMarkdown的格式支持必须覆盖模型常用的所有markdown语法。",
      "pattern": "越往下排版越乱 → 检查markdown渲染器是否支持模型使用的格式元素"
    }
  ],

  "system_status_panel": {
    "added_at": "2026-04-18",
    "view_id": "viewSysStatus",
    "nav_id": "navSysStatus",
    "api_endpoint": "/api/system/full-status",
    "description": "真实系统状态面板 · 实时连接检测所有服务 · 每30秒自动刷新",
    "features": [
      "铸渊主权服务器 (3800) 真实连接检测 + 延迟",
      "MCP大脑服务器 (3100) 真实连接检测 + 工具数",
      "GLADA自主开发Agent (3900) 真实连接检测 + 版本",
      "后端模块加载状态 (6个模块)",
      "GitHub Actions 最近10条工作流运行状态",
      "系统资源 (CPU/内存/运行时间)",
      "连接失败时显示真实错误原因",
      "30秒自动刷新"
    ],
    "nginx_proxy_added": "/api/glada/ → 127.0.0.1:3900",
    "principle": "冰朔指令：必须接入真实系统状态，连接就连接，连不上就连不上，显示原因。不做假的不更新的状态。"
  }
}
