§717 (3), the builder, the checker and the indexer follow the assignments by the seat, at the holder the seat-holders view names

buildrun's AssignerHolder asked the seat's verb for the holder every 5 seconds. The builder and the checker now follow
mesh-module-assigner's assignments through views.ProcessReader.FollowSeat with the catalog half's holder function (the
checker gains the catalog half's reader of §614 for it); the indexer reads the claimant from its own catalog
(Indexer.ClaimantNow) and follows its seat-holders view again at each refresh of its build modules. AssignerHolder goes; the
manifests consume the seat-holders view (the checker also the catalog half's events and verbs), and the assigner's
seat-holders first-view tool answers the checker and the indexer. The beds give each part a claimant and a seat-holders view
in place of the seat verb's answer; the indexer's beds hold the claimant from the start, so the merge test reads the newest
revision.

Builds: design 47 G §717, §614, A-298, A-302

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
2026-11-12 20:17:36 +01:00
parent 2165b3b296
commit 04bfc92d3d
18 changed files with 267 additions and 182 deletions
@@ -1,45 +0,0 @@
package buildrun
import (
"context"
"time"
mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
"git.novox.be/novox/mesh-sdk/go/seatlist"
)
// **No part names the assigner** (design 47 G A-119, A-126, A-131): the module holding the seat mesh-module-assigner is asked of
// the seat that places modules through mesh-sdk's seatlist.HolderOf, and the names of the view of its state assignments are made
// from it, so a new holder is followed with no change of code. The builder and the checker follow the assignments so.
// AssignerHolder is the module holding the seat mesh-module-assigner now, asked until it answers or ctx ends. 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.
type AssignmentsNames struct{ Holder, Tool, Bucket string }
// AssignmentsOf is the names of the holder's state assignments.
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 buildrun
import (
"context"
"encoding/json"
"errors"
"testing"
"time"
"git.novox.be/novox/mesh-sdk/go/seatlist"
)
// The builder and the checker find 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")
}
}
@@ -283,15 +283,14 @@ func startBedWith(t *testing.T, closed bool) *bed {
"git": "mesh-delivery-forge-bridge", "mesh-catalog": "mesh-delivery-indexer", // the floor's sources are the holders of git and mesh-catalog
"mesh-builds": builds.BuilderModule}) // the builder's own seat, whose verb reserved it answers once its definition is read (A-115, A-278)
readers := []string{"n1_" + builds.BuilderModule, "n2_" + builds.BuilderModule}
// The seat mesh-module-assigner's holder is read from the seat's verb assignments, as the builder finds it at run time (A-119).
assignerSub, err := ctl.Subscribe("mesh.seat.mesh-module-assigner.call.assignments.>", func(m *nats.Msg) {
reply, _ := json.Marshal(map[string]any{"result": map[string]any{"seats": []map[string]any{{"seat": "mesh-module-assigner", "holders": []map[string]string{{"module": testAssigner}}}}}, "node": "ctl"})
_ = m.Respond(reply)
})
if err != nil {
// Design 47 G §717, A-298: the catalog half names testAssigner the claimant of mesh-module-assigner, and its seat-holders view
// names it the seat's holder, so the builder follows the assignments at it; nothing answers the seat's verb assignments.
b.catalog.put(t, meshcatalog.CatalogEntry{Module: testAssigner, Repository: "novox/mesh-catalog", Commit: "c0", Fp: "src2:" + strings.Repeat("a", 64),
ManifestDigest: "sha256:" + strings.Repeat("b", 64), Manifest: map[string]any{"module": testAssigner, "claims": []any{map[string]any{"name": "mesh-module-assigner"}}}})
seatHolders := viewstest.Serve(t, ctx, js, ctl, testAssigner, "seat-holders", testAssigner+".seat-holders", readers...)
if _, err := seatHolders.Put(ctx, "mesh-module-assigner", []byte(`{"seat":"mesh-module-assigner","holders":[{"module":"`+testAssigner+`","node":"n1"}]}`)); err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = assignerSub.Unsubscribe() })
viewstest.Serve(t, ctx, js, ctl, testAssigner, "assignments", testAssigner+".assignments", readers...)
b.builds = mk(builds.BuilderBuildsBucket, builds.BuilderBuildsHistory)
b.instances = mk(instancesBucket, 1)
@@ -990,6 +989,12 @@ func TestTheBuilderAsksTheBuildSeatsAndCallsNoNode(t *testing.T) {
if n := calls.Load(); n != 0 {
t.Errorf("%d tool calls reached a build module", n)
}
// Design 47 G §717, A-298: the assignments are followed at the holder the seat-holders view names, no seat verb asked for it.
for deadline := time.Now().Add(10 * time.Second); !strings.Contains(b.out.String(), "holds "+testAssigner+"'s assignments, the holder of the seat mesh-module-assigner"); time.Sleep(10 * time.Millisecond) {
if time.Now().After(deadline) {
t.Fatalf("the builder did not follow the assignments at the seat's holder:\n%s", b.out.String())
}
}
// 1887/AC1: one ask per build module the build needs (netcheck: a Go and a TypeScript bundle), each on its seat's
// delivery stream.
got := asked()
@@ -119,7 +119,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
// The build modules are no names (design 47 G A-82): the holders of the build seats, the seat list's definitions and the
// catalog half's claims, found at each use.
seatGate := newSeatGate()
seatGate.Holders(branches.SeatHolders(ctx))
// The part's one holder function (A-298): the seat list's callers and the views found by their seat (§717) read it.
holders := branches.SeatHolders(ctx)
seatGate.Holders(holders)
seats := buildrun.NewBuildSeats(seatGate.definitions, versions.HolderOf(branches))
bound := defaultStepBound
if v := strings.TrimSpace(getenv("MESH_BUILDER_STEP_BOUND")); v != "" {
@@ -344,26 +346,21 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
// asked when the bound ends), is call-unanswered in the builder's findings (issue 1966, ADR 0668 §3, ADR 0596 §2).
reads.callsOf(found, pubBoundsKV.KV, heardBy(calls.CallKept), logger.Printf)
b.Forms = reads.built
// The assignments names the nodes the builder counts, once the seat list names the seat's holder and its first view is answered:
// the view is the holder's first-view tool, followed by its views family (A-119, A-131); no assigner module is named.
// The assignments names the nodes the builder counts: the seat mesh-module-assigner's view, followed at the holder the
// seat-holders view names and as it moves (design 47 G §717), its first view the holder's tool named for the state; no
// assigner module is named and nothing asks for the holder on a timer.
assignmentsErrs := make(chan error, 1)
assignments, err := reader.FollowSeat(mma.Seat, mma.StateAssignments, holders)
if err != nil {
return err
}
go func() {
holder, ok := buildrun.AssignerHolder(ctx, calls.Call, 5*time.Second, buildrun.SleepFor, logger.Printf)
if !ok {
return
}
names := buildrun.AssignmentsOf(holder)
assignments, err := reader.Follow(names.Holder, mma.StateAssignments, names.Tool)
if err != nil {
assignmentsErrs <- err
return
}
select {
case <-ctx.Done():
return
case <-assignments.Follower().Ready():
}
pe, err := buildrun.FollowAssignmentsIn(ctx, reader, names.Bucket, gate, b.NodesChanged, logger.Printf)
pe, err := buildrun.FollowAssignmentsIn(ctx, reader, assignments.Bucket(), gate, b.NodesChanged, logger.Printf)
if err != nil {
assignmentsErrs <- err
return