From af8de82d59ad9528fc72c39c5353700013c77239 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 12 Nov 2026 01:19:33 +0100 Subject: [PATCH] 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 --- modules/mesh-delivery-indexer/judge/rules.go | 13 +++++++++++++ .../mesh-delivery-indexer/judge/rules_test.go | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/modules/mesh-delivery-indexer/judge/rules.go b/modules/mesh-delivery-indexer/judge/rules.go index 3aca3716..e00d44d3 100644 --- a/modules/mesh-delivery-indexer/judge/rules.go +++ b/modules/mesh-delivery-indexer/judge/rules.go @@ -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)) diff --git a/modules/mesh-delivery-indexer/judge/rules_test.go b/modules/mesh-delivery-indexer/judge/rules_test.go index 7ff73f7e..95dc1160 100644 --- a/modules/mesh-delivery-indexer/judge/rules_test.go +++ b/modules/mesh-delivery-indexer/judge/rules_test.go @@ -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:.`, 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) + } + } +}