两层架构

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 1Container(Hypervisor)n=1 透明、n≥2 调度
Layer 2Kernel(Loop 五件套)Cognitive / Context / Execution / Memory / Govern
Layer 3CellRuntime Instance + Tenant Unit + Portable Snapshot
Layer 4Actor请求主体

Gateway 双模式

模式函数路径
单 Cellgateway.ServeSingleCell(cell, opts)无 cellID 路径
多 Cellgateway.ServeMultiCell(hyp, opts)/cells/{id}/*

依赖方向

Shared Kernel     ← 零依赖
Subsystem BC      ← 只依赖 Shared Kernel
Coordination      ← 依赖 Subsystem 接口
Infrastructure    ← 实现 Subsystem 接口
Cell              ← 组装以上一切
Hypervisor        ← 管理 Cell 生命周期

约束:


安全默认

默认说明
NewHypervisor()零 I/O、零 goroutine
Cells().Create(spec)显式行为(无 auto-create)
未知错误拒绝(fail-closed)
未声明 GovernanceDefaultGovernance() = ModeOpen

相关文档