同实例第二个目标 KB 与旧库共享源 UUID 时,计划/写入/校验/恢复按目标范围派生稳定身份; 计划持久化 target_id_mode,旧计划与写前镜像不二次映射;资源保持共享 ID。
This commit is contained in:
@@ -98,7 +98,10 @@ type WriteSet struct {
|
||||
// Kind 区分发布执行计划与受限演练恢复计划。空值 = 历史发布计划。
|
||||
// 演练计划必须显式为 restore-drill:它只授权 canary 回放,不含对象/索引
|
||||
// 写项,读取方不能把它当发布计划接管。
|
||||
Kind string `json:"kind,omitempty"`
|
||||
Kind string `json:"kind,omitempty"`
|
||||
// TargetIDMode 记录这份计划是否把源身份映射成目标隔离身份,以及用哪套算法。
|
||||
// 空值 = 历史计划/写前镜像:按原 ID 回放,绝不能在恢复时二次映射。
|
||||
TargetIDMode string `json:"target_id_mode,omitempty"`
|
||||
Index []IndexWrite `json:"index,omitempty"`
|
||||
Objects []ObjectWrite `json:"objects,omitempty"`
|
||||
SchemaDigest string `json:"schema_digest,omitempty"`
|
||||
@@ -203,7 +206,20 @@ func (w *WriteSet) computeDigest() (string, error) {
|
||||
|
||||
// Verify 校验摘要与必备身份。缺任一身份都必须失败:没有绑定就没有"这份记录属于
|
||||
// 这个作业/目标/预备份"的证明,拿它去删目标数据无法追责。
|
||||
const (
|
||||
// TargetIDModeScoped 是目标隔离身份的持久契约标识。
|
||||
// 算法是自定义的 sha256(namespace|tenant|kb|table|source) 16 字节派生,
|
||||
// 只保证确定性与隔离,不自称标准 UUIDv5。
|
||||
TargetIDModeScoped = "scoped-sha256-v1"
|
||||
)
|
||||
|
||||
func (w *WriteSet) Verify() error {
|
||||
if w.TargetIDMode != "" && w.TargetIDMode != TargetIDModeScoped {
|
||||
return fmt.Errorf("unsupported target id mode %q", w.TargetIDMode)
|
||||
}
|
||||
if w.TargetIDMode == TargetIDModeScoped && (w.TenantID == 0 || w.KnowledgeBaseID == "") {
|
||||
return errors.New("target id mode lacks target identity")
|
||||
}
|
||||
if w.ContractVersion != 0 && w.ContractVersion != 1 {
|
||||
return errors.New("unsupported migration contract version")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user