mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-13 20:52:03 +00:00
feat: classify match integrity separately from delivery
This commit is contained in:
@@ -20,6 +20,24 @@ const (
|
||||
IntegrityReview IntegrityState = "REVIEW"
|
||||
)
|
||||
|
||||
type IntegrityEvidence struct {
|
||||
RosterAuthoritative bool
|
||||
SimulationAuthoritative bool
|
||||
ResultAuthoritative bool
|
||||
RegionalPlayFair bool
|
||||
DeliveryAvailable bool
|
||||
}
|
||||
|
||||
// ClassifyIntegrity deliberately ignores DeliveryAvailable when deciding
|
||||
// rating eligibility: a healthy match remains rated while the control plane
|
||||
// is temporarily unable to acknowledge its result.
|
||||
func ClassifyIntegrity(evidence IntegrityEvidence) IntegrityState {
|
||||
if !evidence.RosterAuthoritative || !evidence.SimulationAuthoritative || !evidence.ResultAuthoritative || !evidence.RegionalPlayFair {
|
||||
return IntegritySuppressed
|
||||
}
|
||||
return IntegrityCertified
|
||||
}
|
||||
|
||||
var (
|
||||
ErrResultBinding = fmt.Errorf("result workload binding rejected")
|
||||
ErrResultConflict = fmt.Errorf("conflicting result")
|
||||
|
||||
@@ -94,3 +94,20 @@ func TestResultDeliveryHealthSeparatesOutageFromIntegrity(t *testing.T) {
|
||||
t.Fatalf("committed delivery status = %+v err=%v", committed, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIntegrityClassifierDoesNotSuppressHealthyResultForDeliveryOutage(t *testing.T) {
|
||||
healthy := IntegrityEvidence{RosterAuthoritative: true, SimulationAuthoritative: true, ResultAuthoritative: true, RegionalPlayFair: true, DeliveryAvailable: false}
|
||||
if got := ClassifyIntegrity(healthy); got != IntegrityCertified {
|
||||
t.Fatalf("delivery outage changed integrity: %s", got)
|
||||
}
|
||||
for _, evidence := range []IntegrityEvidence{
|
||||
{SimulationAuthoritative: true, ResultAuthoritative: true, RegionalPlayFair: true},
|
||||
{RosterAuthoritative: true, ResultAuthoritative: true, RegionalPlayFair: true},
|
||||
{RosterAuthoritative: true, SimulationAuthoritative: true, RegionalPlayFair: true},
|
||||
{RosterAuthoritative: true, SimulationAuthoritative: true, ResultAuthoritative: true},
|
||||
} {
|
||||
if got := ClassifyIntegrity(evidence); got != IntegritySuppressed {
|
||||
t.Fatalf("incomplete integrity was certified: %+v -> %s", evidence, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user