将可维护总表与可替换2.0镜像分离,稳定来源关联和原始事件键保留; 源端更新/删除不覆盖主表或人工复核。首次收录保留原评估审计, 主表输入/复核独立持久化;历史原标注不冒充新AI或冻结证据。 历史导入绑定源哈希、逐行批准清单与真实恢复备份;三字段精确去重, 批次及原字段留档,重复执行不覆盖后续修改。仅操作本地治理库。 验证:完整make verify退出0;镜像与区域两组隔离PG race退出0; 真实恢复数据隔离导入12522、跳过792、暂缓1,总表15050; 重放保留模拟修改,结构down拒绝丢历史;真实浏览器第41周551条完整, 历史原标注和独立主表复核读回通过,移动布局及JS异常0。
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package qaopsmirror
|
||||
|
||||
import (
|
||||
"context"
|
||||
"knowledge-governance/internal/dobotaiops"
|
||||
pg "knowledge-governance/internal/platform/postgres"
|
||||
"knowledge-governance/internal/qaopsquality"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestMasterHumanReviewIsIndependentOfSourceInputUpdates(t *testing.T) {
|
||||
p := mirrorFixture(t)
|
||||
ctx := context.Background()
|
||||
s := NewStore(p, "fixture-master-quality")
|
||||
queue := pg.NewStore(p)
|
||||
source := &fixtureSource{rows: []dobotaiops.MirrorRecord{fixtureEntry("master-review", "first")}}
|
||||
job := claimMirrorJob(t, s, queue, "review-first")
|
||||
if e := s.HandleSync(ctx, *job, func(context.Context) (Source, error) { return source, nil }); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if e := queue.Complete(ctx, job.ID, job.LeaseOwner, time.Now()); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
rec, e := s.GetMasterRecord(ctx, s.tenant, "master-review")
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
quality := s.MasterQualityStore()
|
||||
key := []dobotaiops.QualityKey{{ID: rec.ID, InputHash: rec.QualityInputHash}}
|
||||
views, e := quality.ReadViews(ctx, key)
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
v := views[rec.ID]
|
||||
request := qaopsquality.SaveRequest{InputHash: v.InputHash, InputEpoch: v.InputEpoch, BaseRevision: v.Revision, Nonce: "fixture_master_review_001", Reason: "fixture only", Fields: qaopsquality.Fields{Coverage: "covered", Correctness: "correct", ProductCategory: "fixture-local"}}
|
||||
if _, e = quality.Save(ctx, rec, request, "fixture-admin"); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
source.rows = []dobotaiops.MirrorRecord{fixtureEntry("master-review", "changed at source")}
|
||||
job = claimMirrorJob(t, s, queue, "review-source-change")
|
||||
if e = s.HandleSync(ctx, *job, func(context.Context) (Source, error) { return source, nil }); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
views, e = quality.ReadViews(ctx, key)
|
||||
if e != nil || views[rec.ID].State != "reviewed" || views[rec.ID].Effective.ProductCategory != "fixture-local" {
|
||||
t.Fatal("source sync invalidated a locally-owned master review", e)
|
||||
}
|
||||
current, e := qaopsquality.NewStore(p, s.tenant).ReadViews(ctx, []dobotaiops.QualityKey{{ID: rec.ID, InputHash: sourceRecordHash(t, source.rows[0])}})
|
||||
if e != nil || current[rec.ID].Revision != 0 {
|
||||
t.Fatal("master review modified original source evaluation", e)
|
||||
}
|
||||
}
|
||||
func sourceRecordHash(t *testing.T, r dobotaiops.MirrorRecord) string {
|
||||
t.Helper()
|
||||
v, e := dobotaiops.DecodeMirrorPayload(string(r.Payload))
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
return v.QualityInputHash
|
||||
}
|
||||
Reference in New Issue
Block a user