🌊 [PER-ZY001] L4 网站总大脑 P0 骨架 · website-brain 目录结构+API stub+Schema+架构文档 · 2026-03-20

Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-03-20 09:38:27 +00:00
parent 52fc232956
commit 7aa0ffd857
10 changed files with 545 additions and 0 deletions

View File

@ -19,6 +19,14 @@
"description": "执行层系统导航v4.0 数字地球协议)",
"subdirectories": {}
},
"website-brain": {
"description": "L4 网站总大脑 · 自研类 Notion 数据库引擎 · AGE OS 核心架构",
"subdirectories": {
"api": "RESTful API 路由pages/databases/modules/persona-state",
"schema": "PostgreSQL 建表 SQL",
"docs": "架构设计文档"
}
},
"src": {
"description": "HLI 接口源码HoloLake Interface",
"subdirectories": {

View File

@ -445,6 +445,78 @@
"agent_id": "AG-TY",
"timestamp": "2026-03-19T02:26:55+08:00",
"content_hash": "7f4b1a99e8fc"
},
{
"nonce": "8bc969",
"agent_id": "AG-ZY",
"timestamp": "2026-03-20T17:35:41+08:00",
"content_hash": "05a17114410b"
},
{
"nonce": "90ab64",
"agent_id": "AG-ZY",
"timestamp": "2026-03-20T17:35:41+08:00",
"content_hash": "d6cd1c87b887"
},
{
"nonce": "7b25e1",
"agent_id": "AG-ZY",
"timestamp": "2026-03-20T17:35:41+08:00",
"content_hash": "0a5df5415ade"
},
{
"nonce": "e71f85",
"agent_id": "AG-ZY",
"timestamp": "2026-03-20T17:35:41+08:00",
"content_hash": "c3b54c6c243e"
},
{
"nonce": "52d177",
"agent_id": "AG-ZY",
"timestamp": "2026-03-20T17:35:41+08:00",
"content_hash": "c3b54c6c243e"
},
{
"nonce": "2127ae",
"agent_id": "AG-ZY",
"timestamp": "2026-03-20T17:35:41+08:00",
"content_hash": "b95bfcf4a347"
},
{
"nonce": "50c041",
"agent_id": "AG-ZY",
"timestamp": "2026-03-20T17:35:41+08:00",
"content_hash": "10c4ec3aeafb"
},
{
"nonce": "3b4ec4",
"agent_id": "AG-ZY",
"timestamp": "2026-03-20T17:35:41+08:00",
"content_hash": "902e455fe109"
},
{
"nonce": "926fed",
"agent_id": "AG-ZY",
"timestamp": "2026-03-20T17:35:42+08:00",
"content_hash": "929460febd09"
},
{
"nonce": "4b1e31",
"agent_id": "AG-SY",
"timestamp": "2026-03-20T17:35:42+08:00",
"content_hash": "f85462954167"
},
{
"nonce": "d919b9",
"agent_id": "AG-QQ",
"timestamp": "2026-03-20T17:35:42+08:00",
"content_hash": "c10beff06c0b"
},
{
"nonce": "73f257",
"agent_id": "AG-TY",
"timestamp": "2026-03-20T17:35:42+08:00",
"content_hash": "7f4b1a99e8fc"
}
]
}

View File

@ -0,0 +1,44 @@
/**
* 数据库表 CRUD API Notion Database
* L4 · 网站总大脑 · Phase 1 骨架
*/
const express = require('express');
const router = express.Router();
// POST /api/databases — 创建数据库
router.post('/', async (req, res) => {
res.status(501).json({
error: true,
code: 'NOT_IMPLEMENTED',
message: 'Database creation pending PostgreSQL connection (Phase 1)'
});
});
// GET /api/databases/:id — 读取数据库
router.get('/:id', async (req, res) => {
res.status(501).json({
error: true,
code: 'NOT_IMPLEMENTED',
message: 'Database read pending PostgreSQL connection (Phase 1)'
});
});
// PUT /api/databases/:id — 更新数据库
router.put('/:id', async (req, res) => {
res.status(501).json({
error: true,
code: 'NOT_IMPLEMENTED',
message: 'Database update pending PostgreSQL connection (Phase 1)'
});
});
// DELETE /api/databases/:id — 删除数据库
router.delete('/:id', async (req, res) => {
res.status(501).json({
error: true,
code: 'NOT_IMPLEMENTED',
message: 'Database delete pending PostgreSQL connection (Phase 1)'
});
});
module.exports = router;

View File

@ -0,0 +1,44 @@
/**
* 模块注册 API 热插拔模块管理
* L4 · 网站总大脑 · Phase 1 骨架
*/
const express = require('express');
const router = express.Router();
// POST /api/modules/register — 注册新模块
router.post('/register', async (req, res) => {
res.status(501).json({
error: true,
code: 'NOT_IMPLEMENTED',
message: 'Module registration pending PostgreSQL connection (Phase 1)'
});
});
// GET /api/modules — 列出所有模块
router.get('/', async (req, res) => {
res.status(501).json({
error: true,
code: 'NOT_IMPLEMENTED',
message: 'Module listing pending PostgreSQL connection (Phase 1)'
});
});
// GET /api/modules/:id — 获取模块详情
router.get('/:id', async (req, res) => {
res.status(501).json({
error: true,
code: 'NOT_IMPLEMENTED',
message: 'Module detail pending PostgreSQL connection (Phase 1)'
});
});
// PUT /api/modules/:id/status — 更新模块状态
router.put('/:id/status', async (req, res) => {
res.status(501).json({
error: true,
code: 'NOT_IMPLEMENTED',
message: 'Module status update pending PostgreSQL connection (Phase 1)'
});
});
module.exports = router;

View File

@ -0,0 +1,45 @@
/**
* 页面 CRUD API Notion Page
* L4 · 网站总大脑 · Phase 1 骨架
*/
const express = require('express');
const router = express.Router();
// POST /api/pages — 创建页面
router.post('/', async (req, res) => {
// Phase 1: stub — 等 PostgreSQL 连接后实现
res.status(501).json({
error: true,
code: 'NOT_IMPLEMENTED',
message: 'Page creation pending PostgreSQL connection (Phase 1)'
});
});
// GET /api/pages/:id — 读取页面
router.get('/:id', async (req, res) => {
res.status(501).json({
error: true,
code: 'NOT_IMPLEMENTED',
message: 'Page read pending PostgreSQL connection (Phase 1)'
});
});
// PUT /api/pages/:id — 更新页面
router.put('/:id', async (req, res) => {
res.status(501).json({
error: true,
code: 'NOT_IMPLEMENTED',
message: 'Page update pending PostgreSQL connection (Phase 1)'
});
});
// DELETE /api/pages/:id — 删除页面
router.delete('/:id', async (req, res) => {
res.status(501).json({
error: true,
code: 'NOT_IMPLEMENTED',
message: 'Page delete pending PostgreSQL connection (Phase 1)'
});
});
module.exports = router;

View File

@ -0,0 +1,35 @@
/**
* 人格体状态 API
* L4 · 网站总大脑 · Phase 1 骨架
*/
const express = require('express');
const router = express.Router();
// GET /api/persona-state — 列出所有人格体状态
router.get('/', async (req, res) => {
res.status(501).json({
error: true,
code: 'NOT_IMPLEMENTED',
message: 'Persona state listing pending PostgreSQL connection (Phase 1)'
});
});
// GET /api/persona-state/:id — 获取单个人格体状态
router.get('/:id', async (req, res) => {
res.status(501).json({
error: true,
code: 'NOT_IMPLEMENTED',
message: 'Persona state read pending PostgreSQL connection (Phase 1)'
});
});
// PUT /api/persona-state/:id — 更新人格体状态
router.put('/:id', async (req, res) => {
res.status(501).json({
error: true,
code: 'NOT_IMPLEMENTED',
message: 'Persona state update pending PostgreSQL connection (Phase 1)'
});
});
module.exports = router;

View File

@ -0,0 +1,136 @@
# 光湖网站总大脑 · L4 架构设计文档
> 签发霜砚PER-SY001· 授权冰朔TCS-0002∞
> 指令等级P0 · 系统级 · AGE OS 核心架构
> 日期2026-03-20
---
## 一、定位
这是整个网站的**核心数据引擎**——取代 Notion 数据库在系统中的角色,成为 guanghulab.com 的总大脑。
- **不是复刻 Notion**,是取其「结构化页面 + 数据库 + API」的核心能力
- **放在阿里云 ECS** 上,国内访问,自主可控
- **模型驱动**:所有操作通过模型语义理解 → 调用数据库 API 完成
---
## 二、五层架构总览
```
┌──────────────────────────────────────────────────────┐
│ L1 · 光湖语言世界层(湖水防御) │
│ ┌──────────────────────────────────────────────┐ │
│ │ L2 · 战略主控台(主动响应层) │ │
│ │ ┌──────────────────────────────────────┐ │ │
│ │ │ L3 · 人格体智能路由层 │ │ │
│ │ │ ┌──────────────────────────────┐ │ │ │
│ │ │ │ L4 · 网站总大脑(自研数据库) │ │ │ │
│ │ │ │ ┌──────────────────────┐ │ │ │ │
│ │ │ │ │ L5 · 代码仓库桥接层 │ │ │ │ │
│ │ │ │ └──────────────────────┘ │ │ │ │
│ │ │ └──────────────────────────────┘ │ │ │
│ │ └──────────────────────────────────────┘ │ │
│ └──────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────┘
```
---
## 三、核心能力
| 能力 | 说明 | 对标 Notion |
|------|------|-------------|
| 结构化页面 | 支持富文本、嵌套块、多级层次 | Notion Page |
| 数据库表 | 可配置属性、筛选、排序、视图 | Notion Database |
| 开放 API | 完整的 RESTful + WebSocket 接口 | Notion API但更自由 |
| 模块热插拔 | 新功能以「模块」形式注册,不重启 | Notion 不支持 |
| 人格体原生支持 | 每个人格体有专属数据空间和权限 | Notion 不支持 |
| 语言指令接口 | 自然语言 → API 调用的原生通道 | Notion AI但更深度 |
---
## 四、技术选型
| 组件 | 方案 | 理由 |
|------|------|------|
| 后端框架 | Node.jsExpress | 团队已有 Node 经验,仓库现有代码全是 Node |
| 数据库 | PostgreSQL + Redis | PG 支持 JSONB类 Notion 灵活 schemaRedis 做缓存 |
| 实时通信 | WebSocketSocket.io | 人格体对话、状态推送、实时协作 |
| 文件存储 | 阿里云 OSS | 国内速度快,与 ECS 同区域免流量费 |
| 部署 | 阿里云 ECS + PM2 + Nginx | 现有服务器架构,直接复用 |
| 模型接口 | DeepSeek API / 阿里通义 API | 国内模型,低延迟,成本可控 |
---
## 五、数据库 Schema 核心设计
详见 `schema/001-init.sql`,包含四张核心表:
1. **pages** — 类 Notion Page支持嵌套、JSONB content、人格体权限
2. **databases** — 类 Notion Database可配置 schema 和视图
3. **modules** — 热插拔模块注册表
4. **persona_state** — 人格体状态管理
---
## 六、API 路由
| 路由前缀 | 模块 | 状态 |
|----------|------|------|
| `/api/pages` | 页面 CRUD | Phase 1 stub |
| `/api/databases` | 数据库 CRUD | Phase 1 stub |
| `/api/modules` | 模块注册/管理 | Phase 1 stub |
| `/api/persona-state` | 人格体状态 | Phase 1 stub |
| `/health` | 健康检查 | ✅ 已实现 |
---
## 七、实现路线图
### Phase 1 · 骨架期P0 · 当前)
- [x] 目录结构创建
- [x] package.json 依赖声明
- [x] PostgreSQL Schema 定义
- [x] API 路由 stub
- [x] 架构文档
- [ ] PostgreSQL 数据库初始化(需阿里云 ECS
- [ ] PM2 部署 + Nginx 反向代理
- [ ] 基础管理界面Web UI
### Phase 2 · 连接期
- [ ] GitHub 仓库桥接 APIL5
- [ ] Notion 数据同步桥(双向)
- [ ] WebSocket 实时通信层
- [ ] 模块热插拔机制
- [ ] 人格体状态管理
### Phase 3 · 智能期
- [ ] 语言指令解析引擎
- [ ] 人格体智能路由层L3
- [ ] 外部存储连接(百度云盘/阿里云盘)
- [ ] 飞书多维表格替代模块
- [ ] 语言湖防御层L1
---
## 八、三端桥接架构L5
```
┌─────────────────┐
│ Notion 大脑 │
└────────┬────────┘
│ Notion API
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ GitHub 仓库 │◄──►│ 网站总大脑 │◄──►│ 外部存储 │
│ (铸渊·代码层) │ │ (自研数据库) │ │ 百度/阿里云盘 │
└─────────────────┘ └─────────────────┘ └─────────────────┘
```
---
> 📌 指令来源2026-03-20 冰朔与霜砚对话
> 📌 指令性质P0 系统级 · AGE OS 核心架构蓝图 · 长期执行
> 📌 一句话人只说话模型做桥接API 做执行——这就是 AGE OS。

View File

@ -0,0 +1,20 @@
{
"name": "guanghulab-website-brain",
"version": "0.1.0",
"description": "光湖网站总大脑 · L4 自研类 Notion 数据库引擎 · AGE OS 核心架构",
"main": "server.js",
"scripts": {
"start": "node server.js",
"dev": "node server.js",
"test": "echo \"Tests pending — Phase 1 scaffold\""
},
"keywords": ["guanghulab", "website-brain", "age-os", "l4-database"],
"author": "光湖系统 (GLW-SYS-0001)",
"license": "ISC",
"dependencies": {
"express": "^5.2.1",
"pg": "^8.16.0",
"redis": "^5.0.0",
"socket.io": "^4.8.0"
}
}

View File

@ -0,0 +1,90 @@
-- ============================================================
-- 光湖网站总大脑 · L4 核心 Schema
-- PostgreSQL 初始化脚本
-- 版本: v0.1.0 · Phase 1 骨架期
-- 签发: 霜砚(PER-SY001) · 授权: 冰朔(TCS-0002∞)
-- ============================================================
-- 启用 UUID 扩展
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- ============================================================
-- 页面表 — 类 Notion Page
-- 支持富文本、嵌套块、多级层次
-- ============================================================
CREATE TABLE IF NOT EXISTS pages (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
parent_id UUID REFERENCES pages(id) ON DELETE SET NULL,
title VARCHAR(500) NOT NULL,
icon VARCHAR(100),
content JSONB DEFAULT '[]'::jsonb,
properties JSONB DEFAULT '{}'::jsonb,
persona_owner VARCHAR(50),
access_level VARCHAR(20) DEFAULT 'normal'
CHECK (access_level IN ('public', 'normal', 'restricted', 'classified')),
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE INDEX idx_pages_parent ON pages(parent_id);
CREATE INDEX idx_pages_persona ON pages(persona_owner);
-- ============================================================
-- 数据库表 — 类 Notion Database
-- 可配置属性、筛选、排序、视图
-- ============================================================
CREATE TABLE IF NOT EXISTS databases (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
title VARCHAR(500) NOT NULL,
schema JSONB DEFAULT '{}'::jsonb,
views JSONB DEFAULT '[]'::jsonb,
persona_owner VARCHAR(50),
created_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE INDEX idx_databases_persona ON databases(persona_owner);
-- ============================================================
-- 模块注册表 — 热插拔模块管理
-- ============================================================
CREATE TABLE IF NOT EXISTS modules (
id VARCHAR(50) PRIMARY KEY,
name VARCHAR(200) NOT NULL,
status VARCHAR(20) DEFAULT 'active'
CHECK (status IN ('active', 'dormant', 'deprecated')),
api_routes JSONB DEFAULT '[]'::jsonb,
persona_binding VARCHAR(50),
version VARCHAR(20) DEFAULT '0.1.0',
deployed_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE INDEX idx_modules_status ON modules(status);
-- ============================================================
-- 人格体状态表
-- ============================================================
CREATE TABLE IF NOT EXISTS persona_state (
persona_id VARCHAR(50) PRIMARY KEY,
display_name VARCHAR(100) NOT NULL,
status VARCHAR(20) DEFAULT 'active'
CHECK (status IN ('active', 'dormant', 'battle')),
memory_ref VARCHAR(500),
last_active TIMESTAMPTZ DEFAULT NOW(),
routing_rules JSONB DEFAULT '{}'::jsonb
);
-- ============================================================
-- updated_at 自动更新触发器
-- ============================================================
CREATE OR REPLACE FUNCTION update_updated_at()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trigger_pages_updated_at
BEFORE UPDATE ON pages
FOR EACH ROW
EXECUTE FUNCTION update_updated_at();

51
website-brain/server.js Normal file
View File

@ -0,0 +1,51 @@
/**
* 光湖网站总大脑 · L4 自研数据库引擎
* Phase 1 骨架 · Express 入口
*
* 端口: 4000 (默认)
* 架构: AGE OS · 五层架构 L4
*/
const express = require('express');
const app = express();
const PORT = process.env.WEBSITE_BRAIN_PORT || 4000;
// 中间件
app.use(express.json());
// 健康检查
app.get('/health', (req, res) => {
res.json({
status: 'ok',
service: 'website-brain',
version: '0.1.0',
phase: 'Phase 1 · 骨架期',
layer: 'L4 · 网站总大脑',
system_node: 'GLW-SYS-0001',
timestamp: new Date().toISOString()
});
});
// API 路由挂载
app.use('/api/pages', require('./api/pages'));
app.use('/api/databases', require('./api/databases'));
app.use('/api/modules', require('./api/modules'));
app.use('/api/persona-state', require('./api/persona-state'));
// 404 处理
app.use((req, res) => {
res.status(404).json({
error: true,
code: 'NOT_FOUND',
message: `Route ${req.method} ${req.path} not found`
});
});
// 启动(仅在直接运行时)
if (require.main === module) {
app.listen(PORT, () => {
console.log(`[website-brain] L4 网站总大脑启动 · 端口 ${PORT} · Phase 1 骨架`);
});
}
module.exports = app;