fix(snapshot): 阻止旧策略作业重放冒充新验收口径
build / build (push) Successful in 1m6s

This commit is contained in:
姚章浩
2026-10-28 08:05:39 +08:00
parent 76f687b52d
commit 3dc854de4b
3 changed files with 28 additions and 0 deletions
+7
View File
@@ -1,5 +1,12 @@
# Changelog
## 开发快照 snapshot/v0.1.105 - 2026-10-28
### Fixed
- 修复成功作业重放遗漏验收策略检查的问题:旧快照缺少当前策略标识时明确拒绝,不静默升级验收口径,不返回成功状态或快照 ID,也不重新暂停测试写入服务。
- 新策略的正常重放与跨库、归档丢失等保护保持有效;此修复不代表内容/问答/性能验收绑定或整库业务链已经完成。
## 开发快照 snapshot/v0.1.104 - 2026-10-28
### Changed
@@ -64,6 +64,9 @@ func CaptureLibrary(ctx context.Context, freeze *libraryfreeze.Coordinator, arch
if err != nil {
return libraryfreeze.Result{}, errors.New("captured library archive no longer verifies")
}
if saved.ValidationPolicy != librarysnapshot.ArtifactAcceptancePolicy {
return libraryfreeze.Result{}, errors.New("library capture validation policy conflicts with existing job")
}
if saved.Scope != req.Scope || saved.TenantID != req.Identity.TenantID || saved.KnowledgeBaseID != req.Identity.KnowledgeBaseID || saved.Compatibility != req.Compatibility || !saved.CreatedAt.Equal(req.CreatedAt) {
return libraryfreeze.Result{}, errors.New("library capture request conflicts with existing job")
}
@@ -133,6 +133,24 @@ func TestLibraryCaptureMaintenanceOwnsArchiveAndRestoresOnFailure(t *testing.T)
if got, err := CaptureLibrary(context.Background(), freeze, archive, db, search, &libraryCandidateReader{}, ready, req); err == nil || got.State == "succeeded" {
t.Fatal("missing archive returned a successful candidate")
}
// Simulate a durable successful job created before the policy marker.
// Replaying it must not silently upgrade its validation contract.
saved.ValidationPolicy = ""
legacyID, err := archive.Seal(saved)
if err != nil {
t.Fatal(err)
}
req.JobID = "legacy-capture-job"
if _, err := freeze.RunPrepared(context.Background(), req.JobID, func(context.Context) error { return nil }, func(context.Context) (string, error) { return legacyID, nil }); err != nil {
t.Fatal(err)
}
stops, previousChecks := writer.stops, checks
if got, err := CaptureLibrary(context.Background(), freeze, archive, db, search, &libraryCandidateReader{}, ready, req); err == nil || got.State == "succeeded" || got.SnapshotID != "" {
t.Fatal("legacy policy replay silently upgraded to artifact acceptance")
}
if writer.stops != stops || checks != previousChecks {
t.Fatal("policy conflict touched current source")
}
})
}
}