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

维度SpecPatchEmergencyOverride
持久性持久化到磁盘内存临时
重启后保留丢失
用途配置变更应急调整
范围CellSpec 字段行为参数

HTTP 端点

PATCH /admin/cells/{id}   # 更新 CellSpec(SpecPatch)

不可修改字段的处理

尝试通过 SpecPatch 修改 immutable 字段会被静默忽略(不报错)。

需要修改 ID 或 Timezone → 必须删除并重建 Cell。


相关不变量


相关文档