D2 judge-seat-reads: a read of a seat holder's state is judged against the seat's states
`reads` `seat:<seat>.<state>` (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
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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>.<name>`},
|
||||
{`{"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))
|
||||
|
||||
Reference in New Issue
Block a user