Fix 9.7d: the judge accepts a read of a seat's state where the seat declares it
Builds: design 47 G A-128 (A-116) Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
@@ -5529,6 +5529,19 @@ func StateProblems(m catalogue.Manifest) []string {
|
||||
}
|
||||
}
|
||||
for _, r := range m.Reads {
|
||||
if seat, state, isSeat, err := catalogue.SeatRead(r); isSeat {
|
||||
// A read of a seat holder's state (design 47 G A-116, A-128): the seat declares the state; the holder is resolved
|
||||
// where it is read.
|
||||
switch s, known := catalogue.SeatNamed(seat); {
|
||||
case err != nil:
|
||||
problems = append(problems, fmt.Sprintf("%s reads %v", m.Module, err))
|
||||
case !known:
|
||||
problems = append(problems, fmt.Sprintf("%s reads %q, a state of the seat %q, "+catalogue.UndeclaredSeat, m.Module, r, seat))
|
||||
case !slices.Contains(s.States, state):
|
||||
problems = append(problems, fmt.Sprintf("%s reads %q, and the seat %s declares no state %q (design 47 G A-128)", m.Module, r, seat, state))
|
||||
}
|
||||
continue
|
||||
}
|
||||
module, _, err := catalogue.ReadState(r)
|
||||
if err != nil {
|
||||
problems = append(problems, fmt.Sprintf("%s reads %v", m.Module, err))
|
||||
|
||||
@@ -6402,3 +6402,22 @@ func TestRulesOther(t *testing.T) {
|
||||
t.Run("TakesSettingsIsRefusedWhereItCannotMeanAnything", caseTakesSettingsIsRefusedWhereItCannotMeanAnything)
|
||||
t.Run("TheInstallationCheckReadsADefault", caseTheInstallationCheckReadsADefault)
|
||||
}
|
||||
|
||||
// A read of a seat holder's state, `seat:<seat>.<state>`, is accepted where the seat declares the state and refused, by name,
|
||||
// where it does not or the seat is unknown (design 47 G A-116, A-128).
|
||||
func TestASeatNamedReadIsJudgedAgainstTheSeatsStates(t *testing.T) {
|
||||
was := catalogue.Seats()
|
||||
t.Cleanup(func() { catalogue.UseSeats(was) })
|
||||
catalogue.UseSeats([]catalogue.Seat{{Name: "mesh-provisioner", Scope: catalogue.ScopeMesh, Decision: "test", States: []string{"plans"}}})
|
||||
for _, row := range []struct{ read, says string }{
|
||||
{"seat:mesh-provisioner.plans", ""},
|
||||
{"seat:mesh-provisioner.nothing", `declares no state "nothing"`},
|
||||
{"seat:mesh-unknown.plans", "mesh-unknown"},
|
||||
{"seat:mesh-provisioner", "does not name a seat and its state"},
|
||||
} {
|
||||
problems := strings.Join(StateProblems(catalogue.Manifest{Module: "reader", Reads: []string{row.read}}), "\n")
|
||||
if row.says == "" && problems != "" || row.says != "" && !strings.Contains(problems, row.says) {
|
||||
t.Errorf("%s: problems %q, want %q", row.read, problems, row.says)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user