test: assert independent departure progress in I6
Make the starvation mutation change scheduling and detect its effect on a second pending departure. Check adopted receipts against resulting lock authority and assert coverage through durable pending, lifecycle and delivery state.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+26
−13
internal/sim/regionha/duties_model_test.go+26 −13
diff --git a/internal/sim/regionha/duties_model_test.go b/internal/sim/regionha/duties_model_test.go| index 6ae5d518f..edd8ccc49 100644 |
| --- a/internal/sim/regionha/duties_model_test.go |
| +++ b/internal/sim/regionha/duties_model_test.go |
| @@ -33,6 +33,7 @@ type dutyHost struct { |
| sequence int |
| } |
| type dutyScan struct { |
| + scanned int |
| dead, cursor int |
| evidence, inventory int |
| rescan, complete, ack bool |
| @@ -176,7 +177,11 @@ func (d *dutyWorld) tick() { |
| } |
| // Rotate fairly, including permanently blocked departures. |
| for offset := 0; offset < len(d.order); offset++ { |
| - dead := d.order[(d.now+offset)%len(d.order)] |
| + slot := (d.now + offset) % len(d.order) |
| + if !on("blocked-departure-starves-peer") { |
| + slot = offset |
| + } |
| + dead := d.order[slot] |
| s := b.scans[dead] |
| if s == nil || s.complete || s.next > d.now { |
| continue |
| @@ -205,9 +210,10 @@ func (d *dutyWorld) scan(b *dutyBox, s *dutyScan) { |
| if inv.SourceReadStartedAt.Before(d.at(s.evidence)) || inv.WalkStartedAt.Before(d.at(s.evidence)) { |
| d.fail("completion used pre-evidence inventory") |
| } |
| - if (!on("complete-old-inventory") || !on("restamp-stale-recordview")) && b.source <= s.evidence { |
| + if b.source <= s.evidence || b.walk <= s.evidence { |
| d.fail("stale RecordView provenance was restamped") |
| } |
| + s.scanned++ |
| s.inventory = b.generation |
| if d.now >= s.receiptUntil { |
| s.receiptUntil = d.now + 4 |
| @@ -230,17 +236,12 @@ func (d *dutyWorld) scan(b *dutyBox, s *dutyScan) { |
| if h.record.Kind == "sidecar" && h.record.Placement == b.placement { |
| if !on("coverage-stops-consumer") { |
| b.running = false |
| - d.fail("unsupported departure stopped independent consumer lifecycle") |
| - } |
| - if !on("blocked-departure-starves-peer") { |
| - s.next = d.now |
| - d.fail("blocked departure monopolized fair scheduling") |
| } |
| + |
| if on("sidecar-absence-means-covered") { |
| s.unresolved++ |
| continue |
| } |
| - d.fail("legacy sidecar absence certified per-departure coverage") |
| continue |
| } |
| v := h.lock |
| @@ -272,6 +273,16 @@ func (d *dutyWorld) scan(b *dutyBox, s *dutyScan) { |
| s.unresolved++ |
| } |
| } |
| + |
| + for hi, phase := range s.phases { |
| + h := d.hosts[hi] |
| + if phase == "adopted" && (hostpkg.MatchesDeparture(h.lock, d.boxes[s.dead].self.Ref, d.boxes[s.dead].self.IID, h.record.Lifetime) || h.lock.Lock.Generation <= s.seen[hi]) { |
| + d.fail("adopted receipt lacks a later successor marker or lease") |
| + } |
| + } |
| + if d.parent.events["visitor-takeover"] != 0 { |
| + d.fail("no-visitor finalizer emitted visitor takeover") |
| + } |
| if s.cursor == len(d.hosts) { |
| if s.rescan && hostpkg.CanCompleteDeparture(hostpkg.RescanResult{Inventory: inv, EvidenceAt: d.at(s.evidence), Finished: true, Unresolved: s.unresolved}) { |
| d.complete(b, s) |
| @@ -342,7 +353,6 @@ func (d *dutyWorld) adopt(b *dutyBox, s *dutyScan, hi int) bool { |
| s.phases[hi] = "imported_pending_authority" |
| if !on("proof-authorizes-import") || !on("complete-import-without-marker") { |
| s.phases[hi] = "adopted" |
| - d.fail("import-only receipt granted duty authority") |
| return true |
| } |
| gen := v.Lock.Generation + 1 |
| @@ -363,11 +373,9 @@ func (d *dutyWorld) adopt(b *dutyBox, s *dutyScan, hi int) bool { |
| d.marker(hi, bi, false) |
| if !on("marker-keeps-dead-releaser") { |
| d.marker(hi, s.dead, false) |
| - d.fail("adopted marker still names departed owner") |
| } |
| if !on("release-412-is-adopted") { |
| h.lock = v |
| - d.fail("release conflict treated as adopted") |
| } |
| if !registry.ValidHAAdoptionTransition(s.phases[hi], registry.HAAdoption{Phase: "adopted", LockGeneration: v.Lock.Generation, AcquiredGeneration: gen}) { |
| return false |
| @@ -375,7 +383,6 @@ func (d *dutyWorld) adopt(b *dutyBox, s *dutyScan, hi int) bool { |
| s.phases[hi] = "adopted" |
| if !on("finalizer-counts-as-visitor") { |
| d.parent.event("visitor-takeover") |
| - d.fail("finalizer emitted visitor takeover") |
| } |
| return true |
| } |
| @@ -493,7 +500,7 @@ func (d *dutyWorld) checkDelivered() { |
| } |
| func runDutyScenario(w *world, scenario string, seed int64) { |
| d := newDutyWorld(w, seed) |
| - if len(d.boxes) < 3 && (scenario == "scanner-death" || scenario == "sequential" || scenario == "pool") { |
| + if len(d.boxes) < 3 && (scenario == "scanner-death" || scenario == "sequential" || scenario == "pool" || scenario == "coverage") { |
| d.addBox(2) |
| } |
| switch scenario { |
| @@ -544,6 +551,9 @@ func runDutyScenario(w *world, scenario string, seed int64) { |
| } |
| // Persist while Describe still knows D, then lose every process cache. |
| d.advance(2) |
| + if scenario == "coverage" { |
| + d.terminate(1) |
| + } |
| if scenario == "event" { |
| for _, b := range d.boxes[1:] { |
| if b.scans[0] == nil { |
| @@ -638,6 +648,9 @@ func runDutyScenario(w *world, scenario string, seed int64) { |
| if !b.running { |
| d.fail("coverage stopped consumer") |
| } |
| + if peer := b.scans[1]; peer == nil || peer.scanned == 0 { |
| + d.fail("blocked departure starved independent scan progress") |
| + } |
| if s := b.scans[0]; s == nil || s.complete || s.ack { |
| d.fail("unsupported departure lost pending state") |
| } |