From cee3102568aa15363397e9adaaf2b90904863898 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 13 Nov 2026 11:43:47 +0100 Subject: [PATCH] D2 judge-seat-reads: a read of a seat holder's state is judged against the seat's states `reads` `seat:.` (split by mesh-sdk's SeatRead since S4) is accepted where the seat declares the state and refused, naming it, where it does not or the seat is unknown; a module's read is judged as today. Builds: design 47 G A-116, A-128, A-343, A-344 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h --- modules/mesh-delivery-indexer/judge/rules.go | 13 +++++++++++++ modules/mesh-delivery-indexer/judge/rules_test.go | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/modules/mesh-delivery-indexer/judge/rules.go b/modules/mesh-delivery-indexer/judge/rules.go index 05fa7edc..01dfe290 100644 --- a/modules/mesh-delivery-indexer/judge/rules.go +++ b/modules/mesh-delivery-indexer/judge/rules.go @@ -5652,6 +5652,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 fb8bec60..6be77af8 100644 --- a/modules/mesh-delivery-indexer/judge/rules_test.go +++ b/modules/mesh-delivery-indexer/judge/rules_test.go @@ -2950,6 +2950,11 @@ func caseAStateNameIsLocalAndOneToken(t *testing.T) { {`{"module":"a.b","version":"1","state":["s"]}`, `no dot`}, {`{"module":"a","version":"1","reads":["bindings"]}`, `a read is .`}, {`{"module":"a","version":"1","reads":["a.s"]}`, `which is its own state`}, + // A read of a seat holder's state names the seat, which declares the state (design 47 G A-116, A-128). + {`{"module":"a","version":"1","reads":["seat:mesh-conditions.findings"]}`, ``}, + {`{"module":"a","version":"1","reads":["seat:mesh-conditions.nothing"]}`, `the seat mesh-conditions declares no state "nothing"`}, + {`{"module":"a","version":"1","reads":["seat:mesh-unknown.findings"]}`, `a state of the seat "mesh-unknown"`}, + {`{"module":"a","version":"1","reads":["seat:mesh-conditions"]}`, `does not name a seat and its state`}, {`{"module":"a","version":"1","state":[{"name":"s","shared":true}]}`, `{name, history, ttl-seconds, per-machine, key-ttl, read-only, max-mib, form, catch-up}`}, } { _, err := ParseManifest([]byte(c.manifest))