node-tools: the unanswered end of the seat list's first read is said also when it ends after the bound (A-490m)

Builds: design 47 G A-490m

Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
2026-11-19 23:22:40 +01:00
parent d1dc482b05
commit 76df3cb420
3 changed files with 41 additions and 13 deletions
+14 -6
View File
@@ -63,17 +63,25 @@ func startSeatListOn(b seatlist.Bus, bound <-chan time.Time, logf func(string, .
return nil
}
catalogue.UseSeats(reader.Seats())
// a first read that ended without an answer is no failure of the reader, which holds the bootstrap and waits for the seat's next
// event: so it is said here, where nothing else would say it, whether it ends before the bound or after it (a read the bus does
// not answer is asked again for about 30 s, so it ends after the bound); the runner then reads again where a bundle asks a verb of
// a seat the list defines that its definition does not name (design 47 G A-490m)
sayUnanswered := func() {
if st := reader.Status(); !st.Heard {
logf("node-tools: the first read of the seat list ended without an answer (%s); the runner serves with the bootstrapped seats and reads again when a bundle asks a verb of a seat the list defines that its definition does not name", st.LastError)
}
}
select {
case <-reader.Ready():
catalogue.UseSeats(reader.Seats())
// a first read that ended without an answer is no failure of the reader, which holds the bootstrap and waits for the seat's
// next event: so it is said here, where nothing else would say it (the runner then reads again where a bundle asks a verb
// its definitions do not name)
if st := reader.Status(); !st.Heard {
logf("node-tools: the first read of the seat list ended without an answer (%s); the runner serves with the bootstrapped seats and reads again when a bundle asks a verb they do not name", st.LastError)
}
sayUnanswered()
case <-bound:
logf("node-tools: the seat list is not read yet; the runner serves with the bootstrapped seats and reads on")
go func() {
<-reader.Ready()
sayUnanswered()
}()
}
return reader
}
+22 -4
View File
@@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"strings"
"sync"
"sync/atomic"
"testing"
"time"
@@ -34,17 +35,21 @@ func TestTheRunnerWaitsForTheFirstReadOfTheSeatListOnlyToItsBound(t *testing.T)
}{
{"the first read ends before the bound, unanswered", true, "the first read of the seat list ended without an answer", true},
{"the bound passes with the seat silent", false, "the seat list is not read yet", false},
{"the bound passes, then the read ends unanswered", false, "the first read of the seat list ended without an answer", false},
} {
t.Run(row.name, func(t *testing.T) {
b := &busOfAStandIn{release: make(chan struct{})}
bound := make(chan time.Time, 1)
var mu sync.Mutex
var said []string
saidAgain := make(chan struct{}, 4)
say := func(f string, a ...any) { mu.Lock(); said = append(said, f); mu.Unlock(); saidAgain <- struct{}{} }
if row.release {
close(b.release)
} else {
bound <- time.Time{}
}
r := startSeatListOn(b, bound, func(f string, a ...any) { said = append(said, f) })
r := startSeatListOn(b, bound, say)
if r == nil {
t.Fatal("no reader")
}
@@ -57,12 +62,25 @@ func TestTheRunnerWaitsForTheFirstReadOfTheSeatListOnlyToItsBound(t *testing.T)
if ended != row.wantReady {
t.Errorf("first read ended = %v, want %v", ended, row.wantReady)
}
if got := strings.Join(said, ";"); !strings.Contains(got, row.wantSaid) {
t.Errorf("said %q, want %q", got, row.wantSaid)
}
if !row.release {
close(b.release)
<-r.Ready()
// the read that ends after the bound is said by a goroutine of its own: wait for it, to a deadline that only a fault reaches
if strings.Contains(row.wantSaid, "first read") {
for i := 0; i < 2; i++ {
select {
case <-saidAgain:
case <-time.After(5 * time.Second):
t.Fatal("the unanswered end of the first read was never said")
}
}
}
}
mu.Lock()
got := strings.Join(said, ";")
mu.Unlock()
if !strings.Contains(got, row.wantSaid) {
t.Errorf("said %q, want %q", got, row.wantSaid)
}
})
}
+5 -3
View File
@@ -167,7 +167,7 @@ func TestTheSubjectThatNamesNoCallerStillWorksAndNamesNone(t *testing.T) {
}{
{"a defined seat's verb the read names", "seat:mesh-wants.input", func(h *map[string]seatdef.Definition) error { *h = fresh; return nil }, "chunked", "", 1},
{"a read that fails", "seat:mesh-wants.input", func(h *map[string]seatdef.Definition) error { return errors.New("the seat does not answer") }, "", "does not answer", 1},
{"a read that still does not name it", "seat:mesh-wants.input@g14", func(h *map[string]seatdef.Definition) error { return nil }, "", "names no verb input", 1},
{"a read that still does not name it", "seat:mesh-wants.input@node-a", func(h *map[string]seatdef.Definition) error { return nil }, "", "names no verb input", 1},
{"a seat the list does not define", "seat:issue-tracker.list", func(h *map[string]seatdef.Definition) error { return nil }, "plain", "", 0},
{"a module's tool", "mesh-delivery-indexer.indexer", func(h *map[string]seatdef.Definition) error { return nil }, "plain", "", 0},
{"a verb the list names without chunks", "seat:mesh-wants.revision", func(h *map[string]seatdef.Definition) error { return nil }, "plain", "", 0},
@@ -191,8 +191,10 @@ func TestTheSubjectThatNamesNoCallerStillWorksAndNamesNone(t *testing.T) {
for i := 0; i < 3; i++ {
go func() { got, err := c.chunkedAsked("seat:mesh-wants.input"); done <- got && err == nil }()
}
for c.rereadWaiting() < 2 {
runtime.Gosched()
for deadline := time.Now().Add(5 * time.Second); c.rereadWaiting() < 2; runtime.Gosched() {
if time.Now().After(deadline) {
t.Fatal("two asks never joined the read running")
}
}
close(release)
for i := 0; i < 3; i++ {