fix(library): 目标隔离映射兼容旧计划与真实回归
build / build (push) Successful in 1m41s

空 mode 计划不映射;索引 source_id 按语义映射;relation 按字段表解析。
隔离回归按持久映射 ID 断言,DS02 故障注入真实命中。
This commit is contained in:
姚章浩
2026-11-04 12:40:12 +08:00
parent e0fc2c32b8
commit 0d9091e464
15 changed files with 428 additions and 91 deletions
@@ -6,6 +6,8 @@ import (
"fmt"
"sort"
"knowledge-governance/internal/libraryrelease"
"knowledge-governance/internal/librarysnapshot"
)
@@ -32,13 +34,15 @@ func (t *ProductionLibraryTarget) disableTargetMapping() {
// targetMappingApplies 只在"把目标快照写进目标"时启用映射;
// 备份/恢复快照里的 ID 是目标自己的既有身份,二次映射会把恢复写坏。
func (t *ProductionLibraryTarget) targetMappingApplies(snapshotID string) bool {
if t.preserveChunkSequence || snapshotID == "" {
// 只有持久计划显式声明 scoped 契约时才映射。空 mode 是历史计划:
// 它登记的就是原身份,重映射会把恢复/重试写到别的 ID 上。
if t.targetIDMode != libraryrelease.TargetIDModeScoped || t.preserveChunkSequence || snapshotID == "" {
return false
}
if t.activePlan != nil {
return snapshotID == t.activePlan.TargetSnapshotID
if t.activePlan == nil {
return false
}
return true
return snapshotID == t.activePlan.TargetSnapshotID
}
// archivedRowIdentitiesFor 返回写入后的目标身份集合(映射开启时)或归档原身份。