两层架构
wesgine 的 Hypervisor + Cell 两层架构:控制面与数据面的职责分离。
架构全景
┌──────────────────────────────────────────────┐
│ Application Layer (wesclaw / wescode / …) │
└──────────────────┬───────────────────────────┘
│ SDK API (Go / HTTP)
┌──────────────────▼───────────────────────────┐
│ Hypervisor (控制面,薄,全局唯一) │
│ 只做三件事: │
│ Cell 生命周期 / 共享 Provider 池 / 跨 Cell 观测│
└──────────────────┬───────────────────────────┘
│ manages
┌──────────────────▼───────────────────────────┐
│ Cell (数据面,厚,每租户一份,完全隔离) │
└──────────────────────────────────────────────┘
心智模型
不是"一个引擎里装了很多 Cell"。
而是"Hypervisor 里跑了很多个独立的 wesgine 实例"。
Hypervisor(控制面)
绝对禁止
hyp.Chat() / hyp.Run() / hyp.Memory() / hyp.Sessions() 等业务方法。
只做三件事
| 职责 | API |
|---|---|
| Cell 生命周期 | Cells().Create/Get/GetOrCreate/List/Stop/Delete/Export/Import/UpdateSpec/Restart/ResetFaults |
| 共享 Provider 池 | SharedProviders().List/Reconfigure |
| 跨 Cell 只读观测 | Observe().Snapshot/PerCellStats/CrashLog/ProviderLatencyStats/ListRuns |
| Token 管理 | Tokens().IssueAdminToken/RevokeAdminToken |
Hypervisor 生命周期
hyp, _ := wesgine.NewHypervisor(ctx, HypervisorConfig{...})
hyp.Start(ctx) // 只挂身份骨架,永不 Cell.Start
hyp.ActivatePersisted(ctx) // HTTP serve 后打开数据面
hyp.Stop(ctx) // 排空全部 Cell + 温度调度器
Cell(数据面)
25 个 Handle
cell.Runtime() // Run / Chat
cell.Agents() cell.Memory() cell.Sessions()
cell.Knowledge() cell.Skills() cell.Tools()
cell.HITL() cell.Learn() cell.Channels()
cell.Email() cell.MCPs() cell.Cron()
cell.HeadlessBrowser() cell.Playwright() cell.Desktop()
cell.Policy() cell.Quotas() cell.Tokens()
cell.Observe() cell.Providers() cell.Config()
cell.TaskMemory() cell.Events() cell.Workspace()
Cell = 三位一体
| 面 | 说明 |
|---|---|
| Runtime Instance | 完整的 AI Agent 运行时 |
| Tenant Unit | 租户隔离单元 |
| Portable Snapshot | 可导出/导入的快照 |
四层心智模型
| 层 | 角色 | 说明 |
|---|---|---|
| Layer 1 | Container(Hypervisor) | n=1 透明、n≥2 调度 |
| Layer 2 | Kernel(Loop 五件套) | Cognitive / Context / Execution / Memory / Govern |
| Layer 3 | Cell | Runtime Instance + Tenant Unit + Portable Snapshot |
| Layer 4 | Actor | 请求主体 |
Gateway 双模式
| 模式 | 函数 | 路径 |
|---|---|---|
| 单 Cell | gateway.ServeSingleCell(cell, opts) | 无 cellID 路径 |
| 多 Cell | gateway.ServeMultiCell(hyp, opts) | /cells/{id}/* |
依赖方向
Shared Kernel ← 零依赖
Subsystem BC ← 只依赖 Shared Kernel
Coordination ← 依赖 Subsystem 接口
Infrastructure ← 实现 Subsystem 接口
Cell ← 组装以上一切
Hypervisor ← 管理 Cell 生命周期
约束:
- Hypervisor 不 import Cell 内部包
- Cell 之间不互相 import
- 子系统 BC 不感知 Cell
安全默认
| 默认 | 说明 |
|---|---|
NewHypervisor() | 零 I/O、零 goroutine |
Cells().Create(spec) | 显式行为(无 auto-create) |
| 未知错误 | 拒绝(fail-closed) |
| 未声明 Governance | DefaultGovernance() = ModeOpen |
相关文档
- 六公理 →
six-axioms.md - Cell 生命周期 →
cell-lifecycle.md - HTTP Gateway →
http-gateway.md - CellSpec 概览 →
cellspec-overview.md