CellSpec 运行时修改(SpecPatch)
wesgine CellSpec 的运行时热更新与冷更新机制。
SpecPatch 概述
SpecPatch 允许在 Cell 运行时修改 CellSpec 的可变字段,无需删除重建。
hyp.Cells().UpdateSpec(ctx, cellID, SpecPatch{
Locale: ptr("en-US"),
Quotas: &newQuotas,
Governance: &newGovernance,
})
字段可变性标记
CellSpec 字段通过 struct tag 标记可变性:
| 标记 | 含义 | 示例 |
|---|---|---|
wesgine:"immutable" | 创建后不可修改 | ID, Timezone |
wesgine:"mutable" | 可随时修改 | Locale, Quotas |
wesgine:"restricted" | 需要特殊条件 | Compliance |
热更新 vs 冷更新
| 类型 | 生效时机 | 示例字段 |
|---|---|---|
| 热更新 | 立即生效,无需重启 | Locale, Quotas, Governance |
| 冷更新 | 需要 Cell 重启 | Channels, Email, MCPs |
SpecPatch 可修改的字段
type SpecPatch struct {
Locale *string
Governance *CellGovernance
Compliance *string
Quotas *CellQuotas
AllowedModels *[]string
LogicalModelGroups *[]LogicalModelGroup
DisallowActorProvider *bool
ProviderStrategy *string
PrivateProviders *[]ProviderConfig
Channels *[]ChannelConfig
Email *[]EmailConfig
MCPs *[]MCPServerConfig
// ... 其他可变字段
}
SpecPatch vs EmergencyOverride
| 维度 | SpecPatch | EmergencyOverride |
|---|---|---|
| 持久性 | 持久化到磁盘 | 内存临时 |
| 重启后 | 保留 | 丢失 |
| 用途 | 配置变更 | 应急调整 |
| 范围 | CellSpec 字段 | 行为参数 |
HTTP 端点
PATCH /admin/cells/{id} # 更新 CellSpec(SpecPatch)
不可修改字段的处理
尝试通过 SpecPatch 修改 immutable 字段会被静默忽略(不报错)。
需要修改 ID 或 Timezone → 必须删除并重建 Cell。
相关不变量
- INV-CELL-08:Cell.Start 的合法输入
相关文档
- CellSpec 概览 →
cell-spec-overview.md - CellSpec 不可变字段 →
cellspec-immutable-fields.md - 紧急覆盖 →
emergency-override.md - Cell 注册表 →
cell-registry.md