fix(library): 收口 B1-R1/B2-R1/B5-R1 并让恢复链经过正式队列终态

B1-R1: 演练写集改为受限 restore-drill(V2 信封/contract 1/schema 摘要,零对象、零索引、零本地映射,来源身份必填)。B2-R1: verify 作业先建不可变 operation 并携带 operation_id,同 job recover 的网关 claim 同时携带原 operation 与 recovery 身份。B5-R1: 前端按 scope 世代与动作序号丢弃迟到响应,不污染新 scope 或父级旧回调。harness 的 recovery 改由生产 jobs.Worker.RunOnce 消费并读回 jobs 终态;原失败窗口作业保持 failed,不改写历史。
This commit is contained in:
姚章浩
2026-11-03 13:02:42 +08:00
parent f9457fab52
commit b4add6c9b0
12 changed files with 1515 additions and 18 deletions
+4 -4
View File
@@ -23,7 +23,7 @@ func TestCanaryPersistsAndRegistersEvidenceBeforeWrite(t *testing.T) {
root := t.TempDir()
ledger := drillLedger()
registered, marked, written := false, false, false
err := writeDrillCanary(context.Background(), root, &ledger, "canary-id",
err := writeDrillCanary(context.Background(), root, &ledger, "canary-id", nil,
func(context.Context) error {
if !registered {
t.Fatal("risk marker preceded durable registration")
@@ -67,7 +67,7 @@ func TestCanaryNeverWritesWithoutDurableLedger(t *testing.T) {
}
ledger := drillLedger()
marked, written := false, false
err := writeDrillCanary(context.Background(), root, &ledger, "canary-id",
err := writeDrillCanary(context.Background(), root, &ledger, "canary-id", nil,
func(context.Context) error { marked = true; return nil },
func(context.Context) error { marked = true; return nil },
func(context.Context) error { written = true; return nil })
@@ -80,7 +80,7 @@ func TestCanaryNeverWritesWithoutDurableLedger(t *testing.T) {
func TestCanaryNeverWritesWhenRegistrationFails(t *testing.T) {
ledger := drillLedger()
marked, written := false, false
err := writeDrillCanary(context.Background(), t.TempDir(), &ledger, "canary-id",
err := writeDrillCanary(context.Background(), t.TempDir(), &ledger, "canary-id", nil,
func(context.Context) error { marked = true; return nil },
func(context.Context) error { return errors.New("governance registration unavailable") },
func(context.Context) error { written = true; return nil })
@@ -92,7 +92,7 @@ func TestCanaryNeverWritesWhenRegistrationFails(t *testing.T) {
func TestCanaryNeverWritesWhenRiskMarkerFails(t *testing.T) {
ledger := drillLedger()
written := false
err := writeDrillCanary(context.Background(), t.TempDir(), &ledger, "canary-id",
err := writeDrillCanary(context.Background(), t.TempDir(), &ledger, "canary-id", nil,
func(context.Context) error { return errors.New("journal unavailable") },
func(context.Context) error { return nil },
func(context.Context) error { written = true; return nil })