Hypervisor API
Hypervisor 是 wesgine 的控制面,全局唯一,管理 Cell 生命周期、共享 Provider 池和跨 Cell 只读观测。
核心职责(三件事)
| 职责 | 说明 |
|---|---|
| Cell 生命周期 | 创建、获取、停止、删除、导入导出 |
| 共享 Provider 池 | 全局 LLM 服务管理 |
| 跨 Cell 只读观测 | 健康快照、统计聚合 |
绝对禁止:hyp.Chat() / hyp.Run() / hyp.Memory() 等业务方法。
Cell 管理 API
hyp.Cells().Create(ctx, CellSpec) (*Cell, error)
hyp.Cells().Get(cellID) (*Cell, error)
hyp.Cells().GetOrCreate(ctx, CellSpec) (*Cell, error)
hyp.Cells().List(ctx) ([]CellSummary, error)
hyp.Cells().Stop(ctx, cellID) error
hyp.Cells().Delete(ctx, cellID) error
hyp.Cells().Export(ctx, cellID) (io.Reader, error)
hyp.Cells().Import(ctx, r io.Reader, opts) (string, error)
hyp.Cells().UpdateSpec(ctx, cellID, patch) error
hyp.Cells().Restart(ctx, cellID) error
hyp.Cells().ResetFaults(ctx, cellID) error
生命周期方法
hyp.Start(ctx) error // 只挂身份骨架,永不 Cell.Start
hyp.Stop(ctx) error // 排空全部 Cell + 温度调度器
hyp.ActivatePersisted(ctx) // HTTP serve 后打开数据面
hyp.Version() string
hyp.LifecycleState() string // starting | ready | draining
hyp.StartedAt() time.Time
hyp.Claims() *license.Claims
共享 Provider
hyp.SharedProviders().List() []ProviderInfo
hyp.SharedProviders().Reconfigure(ctx, cfg) (*ReconfigureResult, error)
观测
hyp.Observe().Snapshot() HypervisorSnapshot
hyp.Observe().PerCellStats(ctx, cellIDs...) ([]CellStats, error)
hyp.Observe().CrashLog(ctx) ([]CrashEvent, error)
hyp.Observe().ProviderLatencyStats(ctx) ([]ProviderLatency, error)
hyp.Observe().ListRuns(ctx, filter) ([]RunTraceSummary, error)
Token 管理
hyp.Tokens().IssueAdminToken(ttl) string
hyp.Tokens().RevokeAdminToken(id) error
Admin HTTP 端点
GET /admin/cells 列出所有 Cell
POST /admin/cells 创建 Cell
POST /admin/cells/import 导入 Cell
GET /admin/cells/{id} Cell 详情
PATCH /admin/cells/{id} 更新 CellSpec
PUT /admin/cells/{id} 幂等 upsert
DELETE /admin/cells/{id} 删除 Cell
POST /admin/cells/{id}/stop 停止 Cell
POST /admin/cells/{id}/restart 重启 Cell
POST /admin/cells/{id}/reset-faults 重置故障
GET /admin/cells/{id}/export 导出 Cell
GET /admin/shared-providers 共享 Provider 列表
POST /admin/shared-providers 配置共享 Provider
POST /admin/tokens 签发 Admin Token
DELETE /admin/tokens/{id} 吊销 Admin Token
GET /admin/observe/snapshot Hypervisor 快照
GET /admin/observe/per-cell-stats 各 Cell 统计
GET /admin/observe/provider-latency Provider 延迟
GET /admin/observe/runs 跨 Cell Run 列表
GET /admin/observe/crash-log 崩溃日志
关键不变量
- INV-CELL-06:身份连续,registry 有 ID ⇔ 内存必有骨架
- INV-CELL-07:孤儿目录改名仅在 Create 成功之后
- INV-CELL-08:Cell.Start 合法输入 = 身份 + 已 Bind 的进程 hook