From 76df3cb420c6abb10c93b0172b7cf5d316a7eef1 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 19 Nov 2026 23:22:40 +0100 Subject: [PATCH] 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 --- node-tools/cmd/node-tools/seatlist.go | 20 ++++++++++++----- node-tools/cmd/node-tools/seatlist_test.go | 26 ++++++++++++++++++---- node-tools/internal/runtime/caller_test.go | 8 ++++--- 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/node-tools/cmd/node-tools/seatlist.go b/node-tools/cmd/node-tools/seatlist.go index fb37013..db08cd0 100644 --- a/node-tools/cmd/node-tools/seatlist.go +++ b/node-tools/cmd/node-tools/seatlist.go @@ -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 } diff --git a/node-tools/cmd/node-tools/seatlist_test.go b/node-tools/cmd/node-tools/seatlist_test.go index 1df4cb4..2f5f941 100644 --- a/node-tools/cmd/node-tools/seatlist_test.go +++ b/node-tools/cmd/node-tools/seatlist_test.go @@ -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) } }) } diff --git a/node-tools/internal/runtime/caller_test.go b/node-tools/internal/runtime/caller_test.go index fd8c2f7..40fb1ff 100644 --- a/node-tools/internal/runtime/caller_test.go +++ b/node-tools/internal/runtime/caller_test.go @@ -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++ {