buildstep: BuildModuleOf goes, a build module is the holder of its build seat on the seat list

No caller is left (the checker, the watchman and the view find the holders; the builder's reader looks a step up by its seat).

Builds: design 47 G A-82
Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
2026-11-12 01:38:34 +01:00
parent 565a90c71d
commit 9a3af4a44b
3 changed files with 0 additions and 49 deletions
@@ -1,41 +0,0 @@
package main
import (
"context"
"time"
mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
"git.novox.be/novox/mesh-sdk/go/seatlist"
)
// assignerHolder is the module holding the seat mesh-module-assigner now, asked of the seat list through mesh-sdk's seatlist.HolderOf
// until it answers or ctx ends (design 47 G A-119, A-126): the builder names no assigner module, so a new holder is followed with no
// change of code. wait is the pause between two asks that failed; sleep says false when ctx ended during it.
func assignerHolder(ctx context.Context, call seatlist.HolderCaller, wait time.Duration, sleep func(context.Context, time.Duration) bool, logf func(string, ...any)) (string, bool) {
for {
holder, err := seatlist.HolderOf(call, mma.Seat)
if err == nil {
return holder, true
}
logf("who holds the seat %s is not known yet, so no node is counted by the assignments: %v", mma.Seat, err)
if !sleep(ctx, wait) {
return "", false
}
}
}
// assignmentsNames are the names made from the holder: the view's first-view tool `<holder>.assignments` and the
// bucket `<holder>_assignments` of the state, both made from the holder found at run time.
type assignmentsNames struct{ Holder, Tool, Bucket string }
func assignmentsOf(holder string) assignmentsNames {
return assignmentsNames{Holder: holder, Tool: holder + "." + mma.StateAssignments, Bucket: holder + "_" + mma.StateAssignments}
}
// sleepFor waits d, a context's bound, and says whether ctx is still alive.
func sleepFor(ctx context.Context, d time.Duration) bool {
w, cancel := context.WithTimeout(ctx, d)
defer cancel()
<-w.Done()
return ctx.Err() == nil
}
@@ -1,37 +0,0 @@
package main
import (
"context"
"encoding/json"
"errors"
"testing"
"time"
"git.novox.be/novox/mesh-sdk/go/seatlist"
)
// The builder finds the assigner's holder at run time: asked again while the seat list does not answer, and the names of the view
// are made from the holder (design 47 G A-119), not fixed in code.
func TestTheAssignerHolderIsFoundAtRunTime(t *testing.T) {
asks, slept := 0, 0
call := func(key string, _ any) (json.RawMessage, error) {
if key != seatlist.HolderKey() {
t.Errorf("asked %q, want %q", key, seatlist.HolderKey())
}
if asks++; asks == 1 {
return nil, errors.New("down")
}
return json.RawMessage(`{"seats":[{"seat":"mesh-module-assigner","holders":[{"module":"acme-assigner"}]}]}`), nil
}
holder, ok := assignerHolder(context.Background(), call, time.Second, func(context.Context, time.Duration) bool { slept++; return true }, func(string, ...any) {})
if !ok || holder != "acme-assigner" || slept != 1 {
t.Fatalf("holder = %q, %v after %d pauses, want acme-assigner after one", holder, ok, slept)
}
if n := assignmentsOf(holder); n.Tool != "acme-assigner.assignments" || n.Bucket != "acme-assigner_assignments" {
t.Errorf("names = %+v", n)
}
if _, ok := assignerHolder(context.Background(), func(string, any) (json.RawMessage, error) { return nil, errors.New("down") }, time.Second,
func(context.Context, time.Duration) bool { return false }, func(string, ...any) {}); ok {
t.Error("a holder was found though ctx ended")
}
}