mesh-config: the start waits for an owner view's Ready, the handlers ask the views' Unread beside the own copies' (review r1 finding 3)

Builds: design 47 H2 H-A-708 (2), row S8
This commit is contained in:
2026-11-25 18:57:21 +01:00
parent 1ebb59a9d7
commit a37cde8bcc
3 changed files with 33 additions and 15 deletions
+10 -6
View File
@@ -58,14 +58,18 @@ func (r runtimeStore) Get(state, key string) (*Entry, error) {
return &Entry{Key: e.Key, Value: e.Value, Revision: e.Revision}, nil
}
// Away is the fault `away` while a copy of this module's own states is not read yet: a verb or tool handler asks it
// (asking), the module's own start never does (design 47 H2 H-A-708 (2)). The first views of the owners stay the fault
// `away` at the read itself, since a picture not answered yet is no answer for a pass to resolve from.
// Away is the fault `away` while a copy of this module's own states or a first view of an owner is not read yet: a verb or
// tool handler asks it (asking); the module's own start waits for them instead (design 47 H2 H-A-708 (2)).
func (r runtimeStore) Away() error {
if r.own == nil {
return nil
if r.own != nil {
if err := r.own.Unread(); err != nil {
return err
}
}
return r.own.Unread()
if theViews != nil {
return theViews.Unread()
}
return nil
}
// asking is a tool whose handler answers `away` at once while what it reads is not read yet (design 47 H2 H-A-708 (2)).
@@ -95,16 +95,25 @@ func (o *ownerViews) read(state string) (*views.Follower, bool) {
return f, ok
}
// Unread is the fault `away` naming the owner verb of the first view not answered yet, nil when every one is: a verb or tool
// handler asks it before it reads (design 47 H2 H-A-708 (2)).
func (o *ownerViews) Unread() error {
for _, f := range followed {
if err := o.by[f.Read].Unread(); err != nil {
return err
}
}
return nil
}
// get is one key of a followed state.
func (o *ownerViews) get(state, key string) (*Entry, bool, error) {
f, ok := o.read(state)
if !ok {
return nil, false, nil
}
// A first view not answered yet is the fault `away`, naming the view's owner verb (design 47 H2 H-A-708 (2)).
if err := f.Unread(); err != nil {
return nil, true, err
}
// The module's own read waits for the first view, never reads an empty picture (design 47 H2 H-A-708 (2), row S8).
<-f.Ready()
v, held := f.Get(key)
if !held {
return nil, true, nil
@@ -118,9 +127,7 @@ func (o *ownerViews) keys(state string) ([]string, bool, error) {
if !ok {
return nil, false, nil
}
if err := f.Unread(); err != nil {
return nil, true, err
}
<-f.Ready()
var out []string
for k := range f.Values() {
out = append(out, k)
@@ -9,6 +9,7 @@ import (
"testing"
"time"
stdio "git.novox.be/novox/mesh-sdk/go"
"git.novox.be/novox/mesh-sdk/go/busretry"
"git.novox.be/novox/mesh-sdk/go/views"
)
@@ -36,9 +37,15 @@ func TestAFollowedStateIsReadFromItsOwnersFirstViewAndEvents(t *testing.T) {
o := newOwnerViews(ask, func() { changed.Add(1) }, nopFindings{})
// H-A-708 (2): a read before the first view is answered `away`, naming the view's owner verb, at once.
var away *busretry.Away
if _, followed, err := o.get(WantsRead, "want.g14.dunst"); !followed || !errors.As(err, &away) || away.Part != "mesh-delivery-assigner.assigner_read_wants" ||
if err := o.Unread(); !errors.As(err, &away) || !strings.HasPrefix(away.Part, "mesh-delivery-") ||
!strings.HasPrefix(away.Words, "not read yet since ") {
t.Fatalf("before the first view: followed %v, %v", followed, err)
t.Fatalf("before the first view, a handler's ask: %v", err)
}
c := &Config{Store: runtimeStore{}}
theViews = o
defer func() { theViews = nil }()
if _, err := asking(c, stdio.Tool{Run: func(map[string]any) (any, error) { return nil, nil }}).Run(nil); !errors.As(err, &away) {
t.Fatalf("a tool's handler before an owner view is ready: %v", err)
}
if !o.reader.Follows("mesh-delivery-assigner.wants") {
t.Error("the wants view is not one of the reader's (A-28)")