carlos / platform Public

edge: Task 3 fix round 1: a real (b) check, the model's sizes asserted, alias rows marked platform in the differential, the stamped alias aimed at another target

(b) was two checks that could never fire. It is now: beside a stamped
ready no hold answers, and the winner is the one with every hold and
every candidate the spec suppresses taken out. The three enumeration
counts are asserted. Every alias row of the no-hold differential carries
the platform mark, so buildCandidates' and foldHomes' alias rule is
exercised. TestStampedCandidateIsNeverSuppressed's alias case asks for
rankAlias pointing at otherHost.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 1a2ebeed305283a76331c61b27d7e25a7ab3691f parent 5adafb5
2 files changed, +59 −29
  • internal/edge/alias_test.go +16 −11
  • internal/edge/rank_property_test.go +43 −18
diff --git a/internal/edge/alias_test.go b/internal/edge/alias_test.go
index 6ab4d9c7f..a72abb37e 100644
--- a/internal/edge/alias_test.go
+++ b/internal/edge/alias_test.go
@@ -797,27 +797,32 @@ func TestHoldingAliasNeverBeatsAReadyRouteOfAnotherTarget(t *testing.T) {
// TestStampedCandidateIsNeverSuppressed: a stamped ready candidate (a
// claims-on box's publication; holds are never stamped) of the moving
-// target survives every hold of that target, real or alias, local or
-// remote, at any higher pair, even at (0, 0) itself, and then the ready
-// stage decides as the fold does: the stamp beats a surviving unstamped
-// ready of a higher pair.
+// target survives every hold of that target, local or remote, at any
+// higher pair, even at (0, 0) itself, and then the ready stage decides as
+// the fold does: the stamp beats a surviving unstamped ready of a higher
+// pair. Once for the moving host's own route (rankHost, against its real
+// holds) and once for its alias (rankAlias, pointing at otherHost, against
+// otherHost's alias holds).
func TestStampedCandidateIsNeverSuppressed(t *testing.T) {
- for _, alias := range []bool{false, true} {
- stamped := rready(1, "annie", rankHost, alias, 0, 0, 4)
+ for _, tc := range []struct {
+ name, target string
+ alias bool
+ }{{rankHost, rankHost, false}, {rankAlias, otherHost, true}} {
+ stamped := rready(1, "annie", tc.target, tc.alias, 0, 0, 4)
holds := []candidate{
- rhold(0, "betty", rankHost, false, 2, 2), rhold(2, "carol", rankHost, true, 2, 2), lhold(rankHost, alias, 2, 2, "mv_local"),
+ rhold(0, "betty", tc.target, tc.alias, 2, 2), rhold(2, "carol", tc.target, tc.alias, 2, 2), lhold(tc.target, tc.alias, 2, 2, "mv_local"),
}
for _, h := range holds {
for _, p := range permutations([]candidate{stamped, h}) {
- wantRemote(t, rank(rankHost, p, rankNow), "annie", "a stamped ready is never suppressed")
+ wantRemote(t, rank(tc.name, p, rankNow), "annie", "a stamped ready is never suppressed")
}
}
for _, p := range permutations(append([]candidate{stamped}, holds...)) {
- wantRemote(t, rank(rankHost, p, rankNow), "annie", "nor by every hold together")
+ wantRemote(t, rank(tc.name, p, rankNow), "annie", "nor by every hold together")
}
- newer := rready(3, "dora", rankHost, alias, 2, 2, 0)
+ newer := rready(3, "dora", tc.target, tc.alias, 2, 2, 0)
for _, p := range permutations([]candidate{stamped, newer, holds[0]}) {
- wantRemote(t, rank(rankHost, p, rankNow), "annie", "beside an equal-pair unstamped survivor, the stamp wins the fold")
+ wantRemote(t, rank(tc.name, p, rankNow), "annie", "beside an equal-pair unstamped survivor, the stamp wins the fold")
}
}
}
diff --git a/internal/edge/rank_property_test.go b/internal/edge/rank_property_test.go
index 07401bb3d..d4d07293d 100644
--- a/internal/edge/rank_property_test.go
+++ b/internal/edge/rank_property_test.go
@@ -31,7 +31,11 @@ package edge
// file's age.
// - The classes are fixed marks (platform on a real candidate in the
// first file or local, wildcard on a ready candidate in the second), so
-// varying a pair never changes them.
+// varying a pair never changes them. That an alias never carries the
+// platform class is a property of these fixtures here; the admission
+// that enforces it is pinned by TestRemoteCandidatesKeepTheAdmissions
+// and exercised by TestRankEqualsFoldWithoutHolds, whose alias rows are
+// all marked platform.
import (
"fmt"
@@ -381,12 +385,7 @@ func TestRankingProperties(t *testing.T) {
continue
}
anyReady = true
- if m.stamp != 0 {
- anyStamped = true
- if specSuppressed(set, i) {
- fail(set, "(b) spec: a stamped candidate suppressed")
- }
- }
+ anyStamped = anyStamped || m.stamp != 0
if specSuppressed(set, i) {
continue
}
@@ -428,9 +427,6 @@ func TestRankingProperties(t *testing.T) {
if d.kind != decHolding || d.hold != cs[holdWin].hold {
fail(set, "(n) decision %s, want the sorted fold's %s", describeDecision(d), cs[holdWin].app)
}
- if anyStamped {
- fail(set, "(b) a stamped ready lost to a hold")
- }
default:
if d.kind != decNone {
fail(set, "decision %s, want none: no live ready or hold", describeDecision(d))
@@ -443,6 +439,27 @@ func TestRankingProperties(t *testing.T) {
fail(set, "(c)/(e) a hold beat a surviving ready candidate")
}
+ // (b): with a stamped ready candidate in the set no hold answers, and
+ // the winner is the one the set has with every hold and every
+ // candidate the spec suppresses taken out, so the holds did nothing
+ // to the stamped one. (Taking out the holds alone is not the same
+ // set: the unstamped candidates they suppress come back, a local
+ // ready or a real route beside a stamped alias, and may win.)
+ if anyStamped {
+ if d.kind == decHolding {
+ fail(set, "(b) a hold answered beside a stamped ready: %s", describeDecision(d))
+ }
+ var bare []candidate
+ for i, m := range set {
+ if m.kind == candReady && !specSuppressed(set, i) {
+ bare = append(bare, cs[i])
+ }
+ }
+ if db := rank(modelName, bare, rankNow); !sameWinner(d, db) {
+ fail(set, "(b) with the holds the answer is %s, with them and what they suppress removed %s", describeDecision(d), describeDecision(db))
+ }
+ }
+
// (d): removing a suppressed candidate changes no winner.
for i := range set {
if !specSuppressed(set, i) {
@@ -494,7 +511,9 @@ func TestRankingProperties(t *testing.T) {
}
}
})
- t.Logf("%d candidate sets", sets)
+ if sets != 504206 {
+ t.Fatalf("%d candidate sets, want 504206: the enumeration changed", sets)
+ }
}
// TestLocalReadyIsUnstamped: this box's own ready candidate is never
@@ -618,7 +637,9 @@ func TestHoldingSortedFold(t *testing.T) {
return false
})
})
- t.Logf("%d holding sets", sets)
+ if sets != 148980 {
+ t.Fatalf("%d holding sets, want 148980: the enumeration changed", sets)
+ }
}
// The no-hold differential (invariant (a), Review Focus 2): with no live
@@ -675,17 +696,19 @@ func todaysDispatch(table map[string]upstream, files map[string]edgesFileView, s
return diffWant{}
}
-// diffHostEntry is one file's publication of diffHost: none, a real route
-// or an alias (of modelPrimary, or naming no target), at each pair,
-// stamped or not; the real one in the first file carries platform.
+// diffHostEntries is one file's publication of diffHost: none, a real
+// route or an alias (of modelPrimary, or naming no target), at each pair,
+// stamped or not. The real one carries the platform mark in the first file
+// only; every alias carries it, so the differential runs buildCandidates'
+// and foldHomes' rule that an alias is never the platform class.
func diffHostEntries(first bool) []*edgesHostView {
out := []*edgesHostView{nil}
for p, pair := range modelPairs {
for stamp := int64(0); stamp < 2; stamp++ {
out = append(out,
&edgesHostView{Role: edgeRoleHome, Platform: first, Incarnation: pair[0], ServingSeq: pair[1], Stamp: stamp, App: fmt.Sprintf("real%d%d", p, stamp)},
- &edgesHostView{Role: edgeRoleHome, Alias: true, TargetHost: modelPrimary, Incarnation: pair[0], ServingSeq: pair[1], Stamp: stamp, App: fmt.Sprintf("alias%d%d", p, stamp)},
- &edgesHostView{Role: edgeRoleHome, Alias: true, Incarnation: pair[0], ServingSeq: pair[1], Stamp: stamp, App: fmt.Sprintf("legacy%d%d", p, stamp)})
+ &edgesHostView{Role: edgeRoleHome, Alias: true, Platform: true, TargetHost: modelPrimary, Incarnation: pair[0], ServingSeq: pair[1], Stamp: stamp, App: fmt.Sprintf("alias%d%d", p, stamp)},
+ &edgesHostView{Role: edgeRoleHome, Alias: true, Platform: true, Incarnation: pair[0], ServingSeq: pair[1], Stamp: stamp, App: fmt.Sprintf("legacy%d%d", p, stamp)})
}
}
return out
@@ -897,6 +920,8 @@ func TestRankEqualsFoldWithoutHolds(t *testing.T) {
}
}
}
- t.Logf("%d resolutions", cases)
+ if cases != 415872 {
+ t.Fatalf("%d resolutions, want 415872: the enumeration changed", cases)
+ }
})
}