BL18: build modules found through their build seats' holders on the seat list
The builder finds a build module as the indexer's seed does: the build seat whose acting rule `build` has an `on` matching the artifact's language or kind:image, and that seat's holder, read from the seat list's definitions and the claims of the catalog half's manifests. Task.Module, every lane key, the unpublished modules, the toolchain sources, the ends watched, the sayer and builder_stuck (through `<seat>.steps`) derive from it; the floor's sources are the holders of the seats git and mesh-catalog. buildrun.GoBuildModule, NodeBuildModule, LanguageOf, buildstep.BuildModuleOf use, build.ImageBuildModule and StuckBuildModules are gone from the builder (the checker keeps its own names in two small files until its part reads them from the list). Builds: design 47 G §7, §428, §704, §204, A-82 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
@@ -22,6 +22,8 @@ import (
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
||||
"git.novox.be/novox/mesh-delivery/sdk/buildstep"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatlist"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient/enginereads"
|
||||
@@ -336,12 +338,8 @@ const (
|
||||
)
|
||||
|
||||
func main() {
|
||||
steps := map[string]build.StateRead{}
|
||||
for _, bm := range build.StuckBuildModules {
|
||||
steps[bm] = read(stdio.State(bm + ".steps"))
|
||||
}
|
||||
reasks := stdio.State(build.ReAsksState)
|
||||
r := build.StuckReader{Logf: func(f string, a ...any) { fmt.Fprintf(os.Stderr, "[mesh-delivery-builder-tools] "+f+"\n", a...) }, Builds: read(stdio.State("builds")), ReAsks: read(reasks), Steps: steps,
|
||||
r := build.StuckReader{Logf: func(f string, a ...any) { fmt.Fprintf(os.Stderr, "[mesh-delivery-builder-tools] "+f+"\n", a...) }, Builds: read(stdio.State("builds")), ReAsks: read(reasks), StepsOf: func(seat string) build.StateRead { return read(stdio.State(seat + ".steps")) },
|
||||
Hearing: read(stdio.State(buildrun.HearingState))}
|
||||
put := func(key string, value []byte) error {
|
||||
_, err := reasks.Put(key, json.RawMessage(value))
|
||||
@@ -400,6 +398,19 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
pk.Start(context.Background())
|
||||
// The build modules are no names (design 47 G A-82): the build seats on the seat list, each held by the module the catalog
|
||||
// half's manifests say; the seat list and its two tools wired once by mesh-sdk (§204).
|
||||
gate := seatlist.NewPart("builder", []string{stdio.AnyPerson, "node-tools", "mesh-healers"})
|
||||
go func() {
|
||||
<-stdio.Served()
|
||||
gate.Follow(seatlist.StdioBus(), nil, func(f string, a ...any) { fmt.Fprintf(os.Stderr, "[mesh-delivery-builder-tools] "+f+"\n", a...) })
|
||||
}()
|
||||
r.Seats = buildrun.NewBuildSeats(func() map[string]seatdef.Definition {
|
||||
if rd := gate.Reader(); rd != nil {
|
||||
return rd.Definitions()
|
||||
}
|
||||
return nil
|
||||
}, versions.HolderOf(branches))
|
||||
carriers := versions.CarriersFrom(versions.EntriesOf(branches))
|
||||
released := func(_ context.Context, module string) ([]meshcatalog.VersionEntry, error) {
|
||||
raw, err := stdio.Ask(catalogVersionsVerb, meshcatalog.VersionsInput{Module: module})
|
||||
@@ -445,6 +456,7 @@ func main() {
|
||||
// builder_first_views and builder_first_view_again: where the builder's first views of the indexer's and the assigner's
|
||||
// states stand, and asking one again by hand (ADR 0615, DLV-M1).
|
||||
tools = append(tools, views.StatusTools(builds.BuilderModule, "builder_first_views", "builder_first_view_again", stdio.State(views.StatusState), meshhandactsclient.Recorder{Ask: stdio.Ask}, time.Now)...)
|
||||
tools = append(tools, gate.Tools()...)
|
||||
if err := stdio.Serve("", tools); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "[mesh-delivery-builder-tools] %v\n", err)
|
||||
os.Exit(1)
|
||||
|
||||
@@ -74,6 +74,8 @@ type catalogHalf struct {
|
||||
halves map[string]*views.Follower
|
||||
once sync.Once
|
||||
ctx context.Context
|
||||
// holders is told each entry change: a claim of a build seat may have moved (design 47 G A-82).
|
||||
holders func()
|
||||
}
|
||||
|
||||
// first says whether branch is the first watched branch of module's registration (design 47 G §371); a module with no
|
||||
@@ -86,6 +88,9 @@ func (c *catalogHalf) first(branch, module string) bool {
|
||||
// Changed is the follower's Changed: one module's entry of a branch came, or went.
|
||||
func (c *catalogHalf) Changed(ctx context.Context) func(branch, module string, entry json.RawMessage, deleted bool, at time.Time) {
|
||||
return func(branch, module string, entry json.RawMessage, deleted bool, _ time.Time) {
|
||||
if c.holders != nil {
|
||||
defer c.holders()
|
||||
}
|
||||
first := c.first(branch, module)
|
||||
if deleted {
|
||||
c.b.EntryGone(branch, first, module)
|
||||
|
||||
+50
@@ -5,6 +5,8 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -14,6 +16,9 @@ import (
|
||||
|
||||
"git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-delivery/contracts/go/seats/meshdelivery"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatlist"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatlist/seatlisttest"
|
||||
)
|
||||
|
||||
// catalogHolder is the holder of the seat mesh-catalog as the bed needs it (design 47 G §348, §614): it answers `revision` for the
|
||||
@@ -92,3 +97,48 @@ func (h *catalogHolder) put(t *testing.T, e meshcatalog.CatalogEntry) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// buildSeats is the seat list and the catalog half as the builder finds its build modules from them (design 47 G A-82): the seat
|
||||
// mesh-catalog's verb seat-definitions answers the three build seats' definitions, each acting on its language (the image seat on
|
||||
// kind:image), and an entry of each holder's manifest claims its seat.
|
||||
func (h *catalogHolder) buildSeats(t *testing.T, nc *nats.Conn, holders map[string]string) {
|
||||
t.Helper()
|
||||
defs := map[string]seatdef.Definition{}
|
||||
for _, d := range seatlisttest.Definitions() {
|
||||
if _, ok := holders[d.Seat]; ok {
|
||||
defs[d.Seat] = d
|
||||
}
|
||||
}
|
||||
for seat, on := range map[string]string{"node-build-go": "go", "node-build-node": "typescript", "node-build-image": seatdef.OnKindImage} {
|
||||
d := defs[seat]
|
||||
d.Acts = []seatdef.ActingRule{{Step: seatdef.StepBuild, On: on}}
|
||||
defs[seat] = d
|
||||
}
|
||||
s, err := nc.Subscribe("mesh.seat."+meshcatalog.Seat+".call."+seatlist.Verb+".>", func(m *nats.Msg) {
|
||||
var in struct {
|
||||
Seat string `json:"seat"`
|
||||
}
|
||||
_ = json.Unmarshal(m.Data, &in)
|
||||
var result any
|
||||
if in.Seat == "" {
|
||||
l := seatlist.Listing{Revision: 1}
|
||||
for seat := range defs {
|
||||
l.Seats = append(l.Seats, seatlist.Entry{Seat: seat, Source: seatlist.SourceTrunk, Digest: "sha256:" + seat})
|
||||
}
|
||||
result = l
|
||||
} else {
|
||||
raw, _ := json.Marshal(defs[in.Seat])
|
||||
result = seatlist.Answer{Seat: in.Seat, Found: true, Revision: 1, Entry: &seatlist.Entry{Seat: in.Seat, Source: seatlist.SourceTrunk, Digest: "sha256:" + in.Seat, Definition: raw}}
|
||||
}
|
||||
reply, _ := json.Marshal(map[string]any{"result": result, "node": "ctl"})
|
||||
_ = m.Respond(reply)
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = s.Unsubscribe() })
|
||||
for seat, module := range holders {
|
||||
h.put(t, meshcatalog.CatalogEntry{Module: module, Repository: "novox/mesh-catalog", Commit: "c0", Fp: "src2:" + strings.Repeat(fmt.Sprintf("%x", len(seat)%16), 64), ManifestDigest: "sha256:claims-" + module,
|
||||
Manifest: map[string]any{"module": module, "claims": []any{map[string]any{"name": seat}}}})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,10 @@ import (
|
||||
// heldOnTheBus says whether an ask a build key names is on its build seat's stream, or a build node wrote a step for it
|
||||
// (issue 1910), read once at the take-over of a key at start; and, at the builder's check bound, whether an ask can still
|
||||
// be answered (issue 1945). Never polled.
|
||||
type heldOnTheBus struct{ js jetstream.JetStream }
|
||||
type heldOnTheBus struct {
|
||||
js jetstream.JetStream
|
||||
seats *buildrun.BuildSeats // the build modules (design 47 G A-82)
|
||||
}
|
||||
|
||||
// Held is build.Builder's Held: a step key `<node>.<ask id>` in the build module's steps, or a message of the stream under
|
||||
// the ask's subject whose Nats-Msg-Id is the ask's id.
|
||||
@@ -51,10 +54,11 @@ const (
|
||||
// the ask is on its stream.
|
||||
func (h heldOnTheBus) seen(ctx context.Context, a buildstep.StepAsk, later bool) (build.AskSeen, error) {
|
||||
seen := build.AskSeen{Kind: a.Kind, At: build.AskedAt(a.ID)}
|
||||
module, err := buildstep.BuildModuleOf(a.Language)
|
||||
bm, err := h.seats.OfAskLanguage(a.Language)
|
||||
if err != nil {
|
||||
return seen, err
|
||||
}
|
||||
module := bm.Module
|
||||
steps, err := h.js.KeyValue(ctx, buildrun.StepsBucket(module))
|
||||
if err != nil {
|
||||
return seen, fmt.Errorf("the bucket %s: %w", buildrun.StepsBucket(module), err)
|
||||
@@ -259,10 +263,11 @@ func (h heldOnTheBus) Drop(ctx context.Context, a buildstep.StepAsk) error {
|
||||
// every kind, oldest first and at most limit of each kind, each with its step's state and whether it still waits.
|
||||
func (h heldOnTheBus) Queue(ctx context.Context, language string, limit int) (build.SeatQueue, error) {
|
||||
q := build.SeatQueue{Language: language, Note: build.QueueNote}
|
||||
module, err := buildstep.BuildModuleOf(language)
|
||||
bm, err := h.seats.OfAskLanguage(language)
|
||||
if err != nil {
|
||||
return q, err
|
||||
}
|
||||
module := bm.Module
|
||||
stream, name, _, err := h.stream(ctx, language, buildstep.AskDelivery)
|
||||
q.Stream = name
|
||||
if errors.Is(err, jetstream.ErrStreamNotFound) {
|
||||
|
||||
@@ -303,6 +303,8 @@ func startBedWith(t *testing.T, closed bool) *bed {
|
||||
// verbs and events (design 47 G §348, §614), the assignments by their read tool and views family (ADR 0615, DLV-M1); n1 and n2
|
||||
// each have their durable consumer.
|
||||
b.catalog = newCatalogHolder(t, ctx, js, ctl)
|
||||
b.catalog.buildSeats(t, ctl, map[string]string{"node-build-go": testGo, "node-build-node": testNode, "node-build-image": testImage,
|
||||
"git": "mesh-delivery-forge-bridge", "mesh-catalog": "mesh-delivery-indexer"}) // the floor's sources are the holders of git and mesh-catalog
|
||||
readers := []string{"n1_" + builds.BuilderModule, "n2_" + builds.BuilderModule}
|
||||
viewstest.Serve(t, ctx, js, ctl, assignerModule, "assignments", assignerModule+".assigner_read_assignments", readers...)
|
||||
b.builds = mk(builds.BuilderBuildsBucket, builds.BuilderBuildsHistory)
|
||||
@@ -1001,7 +1003,7 @@ func TestARestartedBuilderPutsNoSecondAsk(t *testing.T) {
|
||||
}
|
||||
// 1945 note 62, on the real bus: the stream read as builder_seat_queue reads it shows the Go ask waiting; the ask can
|
||||
// still be answered (nothing was taken since); and a message dropped as an ask asked again is gone from the stream.
|
||||
held := heldOnTheBus{b.js}
|
||||
held := heldOnTheBus{js: b.js, seats: testSeats()}
|
||||
goAsk := sdkstep.StepAsk{ID: v.Asks[sdkstep.AskGo], Language: sdkstep.AskGo, Kind: sdkstep.AskDelivery}
|
||||
stale := sdkstep.StepAsk{ID: "mvo53jcm70b5f7", Language: sdkstep.AskGo, Kind: sdkstep.AskDelivery}
|
||||
subject, _ := sdkstep.AskSubjectBy(sdkstep.AskGo, sdkstep.AskDelivery, sdkstep.AskerBuilder)
|
||||
|
||||
@@ -38,6 +38,7 @@ import (
|
||||
"git.novox.be/novox/mesh-delivery/sdk/buildstep"
|
||||
"git.novox.be/novox/mesh-delivery/sdk/trunk"
|
||||
"git.novox.be/novox/mesh-sdk/go/process"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatlist"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
|
||||
"mesh-delivery-builder/internal/build"
|
||||
@@ -115,6 +116,10 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
}
|
||||
branches.Logf = logger.Printf
|
||||
half.branches = branches
|
||||
// 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()
|
||||
seats := buildrun.NewBuildSeats(seatGate.definitions, versions.HolderOf(branches))
|
||||
assignments, err := reader.Follow(assignerModule, "assignments", assignerModule+".assigner_read_assignments")
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -125,10 +130,11 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
return fmt.Errorf("MESH_BUILDER_STEP_BOUND: %w", err)
|
||||
}
|
||||
}
|
||||
tools := &buildrun.ToolchainSet{}
|
||||
tools := &buildrun.ToolchainSet{Seats: seats}
|
||||
// Each build module's part of a build is an ask on its build seat's stream, pulled by a build node with a free slot
|
||||
// (novox/hq ADR 0525): the builder chooses no node, so it reads neither presence nor have and holds no capacity.
|
||||
asks := buildrun.JetStreamAsks{JS: js}
|
||||
// The steps of each build module are watched once the seat list and the catalog half name it (seatsChanged).
|
||||
// The asks the build seats gave up on (issue 734): heard from DEAD_LETTERS, each ends the wait for its step at once,
|
||||
// and the lane asks its part again (Builder.waitOnce) instead of waiting for the check bound.
|
||||
// Heard in the background, and again at a reconnect or an ask while it is not; whether it is heard is kept in the
|
||||
@@ -142,13 +148,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
defer hearing.Stop()
|
||||
// Each ask's step is heard by its own watch and, at every step end of its build module and every reconnect, read
|
||||
// (buildrun.HearEnds): a watch that goes deaf loses no end (the lost check of 2026-10-28).
|
||||
var buildModules []string
|
||||
for _, l := range buildstep.AskLanguages {
|
||||
if m, err := buildstep.BuildModuleOf(l); err == nil {
|
||||
buildModules = append(buildModules, m)
|
||||
}
|
||||
}
|
||||
heard := buildrun.HearEnds(ctx, asks, asks, buildModules, logger.Printf)
|
||||
heard := buildrun.HearEnds(ctx, asks, asks, seats.Modules(), logger.Printf)
|
||||
conn.SetReconnectHandler(func(*nats.Conn) { hearing.Again(); heard.Nudge("") })
|
||||
// The builder asks the controller, as its own account, whether the artifact store still holds a done key's blobs
|
||||
// (the seat verb held, novox/hq issue 1937) before it leaves the key done, on its calls connection.
|
||||
@@ -156,7 +156,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
// the bus holds it; the floor's three sources asked as its own account.
|
||||
versionsKV := process.AwaitBucket(ctx, js, conn, versions.Bucket, "no trunk build is numbered: each is built unnumbered and published by its digest", logger.Printf)
|
||||
found := &findings{w: fw, logf: logger.Printf, now: time.Now}
|
||||
floorWaits := &versions.FloorWaits{Logf: logger.Printf, Said: found.floorSaid(context.WithoutCancel(ctx))}
|
||||
floorWaits := &versions.FloorWaits{Holder: versions.HolderOf(branches), Logf: logger.Printf, Said: found.floorSaid(context.WithoutCancel(ctx))}
|
||||
// The names waiting on their floor are kept in the state floor-waits (DLV-B4): a restarted builder takes them in, so
|
||||
// their silent sources' events still wake them; until the state is bound they are kept here only.
|
||||
process.AwaitBucket(ctx, js, conn, versions.FloorWaitsBucket, "the names waiting on their floor are kept in memory only, and builder_floor_waits shows none", logger.Printf).
|
||||
@@ -164,19 +164,27 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
floorWaits.Keep(kvKeeper{ctx: ctx, kv: kv}, heldFloorWaits(ctx, kv, logger.Printf))
|
||||
})
|
||||
// A package is numbered under its name in its ecosystem, read from the catalog half's entries (design 32, design 47 G §348).
|
||||
numberer := &versions.Numberer{Versions: versions.Versions{Store: awaitedVersions{b: versionsKV}}, Floor: floorVia(calls.Call), Waits: floorWaits,
|
||||
numberer := &versions.Numberer{Versions: versions.Versions{Store: awaitedVersions{b: versionsKV}}, Floor: floorVia(calls.Call, versions.HolderOf(branches)), Waits: floorWaits,
|
||||
Names: versions.NamesFrom(versions.EntriesOf(branches))}
|
||||
// A publish that ends badly is a finding (design 51 *Health and conditions*): a holder's refused, a version no holder
|
||||
// answered within its bound (a key of the state bounds with its own time to live), a seat's outcome that does not read.
|
||||
pubBoundsKV := process.AwaitBucket(ctx, js, conn, versions.BoundsBucket, "a publish no holder answers, and a node holding the old form seven days, are not raised", logger.Printf)
|
||||
pubs := &publishes{bounds: pubBoundsKV.KV, versions: numberer.Versions, findings: found, bound: versions.PublishBound, logf: logger.Printf}
|
||||
numberer.Publishing = pubs.arm
|
||||
b := &build.Builder{
|
||||
var b *build.Builder
|
||||
seatsChanged := func(ctx context.Context) {
|
||||
heard.Watch(seats.Modules())
|
||||
if b != nil {
|
||||
b.Reconsider(ctx)
|
||||
}
|
||||
}
|
||||
b = &build.Builder{
|
||||
Claimer: build.Claimer{Store: kvStore{buildsKV}, By: cred.Node + "." + cred.Module},
|
||||
Asks: buildrun.Asker{Publisher: asks, Waiter: buildrun.LostAskWaiter{Inner: heard, Dead: dead, Hearing: hearing}, Bound: bound, Dropper: buildrun.SeatDrops{Caller: calls}},
|
||||
Held: heldOnTheBus{js},
|
||||
Seats: seats,
|
||||
Asks: buildrun.Asker{Seats: seats, Publisher: asks, Waiter: buildrun.LostAskWaiter{Inner: heard, Dead: dead, Hearing: hearing}, Bound: bound, Dropper: buildrun.SeatDrops{Caller: calls}},
|
||||
Held: heldOnTheBus{js: js, seats: seats},
|
||||
// An ask that can no longer be answered is asked again (issue 1945), read at the step bound: a context's bound.
|
||||
Gone: heldOnTheBus{js},
|
||||
Gone: heldOnTheBus{js: js, seats: seats},
|
||||
CheckAfter: bound,
|
||||
Toolchains: tools,
|
||||
Manifests: half.manifests,
|
||||
@@ -266,7 +274,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
switch kv := process.OptionalBucket(ctx, js, instancesBucket, "the controller is not told that this builder writes references until it starts again", logger.Printf); {
|
||||
case kv == nil:
|
||||
default:
|
||||
says := newSayer(ctx, kv, cred.Node, []string{buildrun.GoBuildModule, buildrun.NodeBuildModule, build.ImageBuildModule}, logger.Printf)
|
||||
says := newSayer(ctx, kv, cred.Node, seats.Modules, logger.Printf)
|
||||
b.Answered = says.Answered
|
||||
defer func() {
|
||||
stopping, cancel := context.WithTimeout(context.WithoutCancel(ctx), 5*time.Second)
|
||||
@@ -369,9 +377,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
// condition keeper's condition-cleared.
|
||||
floor := floorWake{b: b, waits: floorWaits, logf: logger.Printf}
|
||||
// And the four registry seats' published, refused and removed (DLV-B4), which move a numbered version.
|
||||
seats := seatHearer{n: numberer, b: b, logf: logger.Printf, pub: pubs, res: reserved}
|
||||
seatHeard := seatHearer{n: numberer, b: b, logf: logger.Printf, pub: pubs, res: reserved}
|
||||
events := func(m jetstream.Msg) {
|
||||
if reads.heard(m, logger.Printf) || heardTools.Reported(ctx, m) || heardTools.Running(ctx, m) || floor.heard(ctx, m) || reserved.heard(ctx, m) || seats.heard(ctx, m) { // reads: the node-engine seat's manifest-reads-changed (ADR 0618 §4)
|
||||
if reads.heard(m, logger.Printf) || heardTools.Reported(ctx, m) || heardTools.Running(ctx, m) || floor.heard(ctx, m) || reserved.heard(ctx, m) || seatHeard.heard(ctx, m) { // reads: the node-engine seat's manifest-reads-changed (ADR 0618 §4)
|
||||
return
|
||||
}
|
||||
heardGone(ctx, b, m, logger.Printf)
|
||||
@@ -380,6 +388,10 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
// manifest-reads-changed and the seat mesh-conditions' condition-cleared: seatEventPatterns); the owners' views events and the
|
||||
// catalog half's catalog-revision and registration-changed and the gate's source-moved are the views reader's (a message has
|
||||
// one taker, so no pattern here covers them).
|
||||
// The seat list over the connection and heard on the hub: a change of it, as of the catalog half's holders, names the build
|
||||
// modules again (design 47 G A-82, §204).
|
||||
seatGate.Follow(seatlist.ProcessBus(calls.Call, hub), func() { seatsChanged(ctx) }, logger.Printf)
|
||||
half.holders = func() { seatsChanged(ctx) }
|
||||
for _, pattern := range seatEventPatterns {
|
||||
if err := hub.Handle(pattern, events); err != nil {
|
||||
return err
|
||||
@@ -451,7 +463,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
// A person reads a build seat's stream with builder_seat_queue, which writes the queues state (issue 1945 note 62): the
|
||||
// builder alone may read the stream, so it answers there.
|
||||
process.AwaitBucket(ctx, js, conn, build.QueuesBucket, "builder_seat_queue is not answered", logger.Printf).Ready(func(kv jetstream.KeyValue) {
|
||||
eachRead := func(e jetstream.KeyValueEntry) { queueRead(ctx, heldOnTheBus{js}, kv, e, logger.Printf) }
|
||||
eachRead := func(e jetstream.KeyValueEntry) {
|
||||
queueRead(ctx, heldOnTheBus{js: js, seats: seats}, kv, e, logger.Printf)
|
||||
}
|
||||
if qw, err := settle(ctx, kv, eachRead); err != nil {
|
||||
process.NotWatched(logger.Printf, build.QueuesBucket, err, "builder_seat_queue is not answered until the builder starts again")
|
||||
} else {
|
||||
|
||||
@@ -27,7 +27,7 @@ func TestTheNamesAreTheManifests(t *testing.T) {
|
||||
}
|
||||
for _, read := range []string{
|
||||
gateModule + ".source",
|
||||
"mesh-build-go.steps", "mesh-build-image.steps", "mesh-build-node.steps",
|
||||
"node-build-go.steps", "node-build-image.steps", "node-build-node.steps",
|
||||
} {
|
||||
if !slices.Contains(m.Reads, read) {
|
||||
t.Errorf("the builder reads %s, its manifest's reads are %v", read, m.Reads)
|
||||
|
||||
@@ -258,7 +258,8 @@ func (m *wakeMsg) Headers() nats.Header {
|
||||
|
||||
func aFloorsWakeIsHeard(t *testing.T) {
|
||||
var logs bytes.Buffer
|
||||
waits := &versions.FloorWaits{}
|
||||
holders := map[string]string{"git": "mesh-delivery-forge-bridge", "mesh-catalog": "mesh-delivery-indexer"}
|
||||
waits := &versions.FloorWaits{Holder: func(seat string) (string, bool) { h, ok := holders[seat]; return h, ok }}
|
||||
waits.Wait("m/lib", versions.SeatGoPackages, "", versions.Floor{Silent: []string{versions.SourceRequirements}}, nil, time.Unix(0, 0))
|
||||
waits.Wait("m/img", versions.SeatImages, "", versions.Floor{Silent: []string{versions.SourceTags}}, nil, time.Unix(0, 0))
|
||||
f := &floorWake{b: &build.Builder{}, waits: waits, logf: log.New(&logs, "", 0).Printf}
|
||||
|
||||
@@ -31,7 +31,7 @@ type sayer struct {
|
||||
ctx context.Context
|
||||
store sayStore
|
||||
node string
|
||||
need []string
|
||||
need func() []string
|
||||
logf func(string, ...any)
|
||||
|
||||
mu sync.Mutex
|
||||
@@ -39,7 +39,7 @@ type sayer struct {
|
||||
said bool
|
||||
}
|
||||
|
||||
func newSayer(ctx context.Context, store sayStore, node string, need []string, logf func(string, ...any)) *sayer {
|
||||
func newSayer(ctx context.Context, store sayStore, node string, need func() []string, logf func(string, ...any)) *sayer {
|
||||
return &sayer{ctx: ctx, store: store, node: node, need: need, logf: logf, answered: map[string]bool{}}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ func (s *sayer) Answered(module string) {
|
||||
if s.said {
|
||||
return
|
||||
}
|
||||
for _, m := range s.need {
|
||||
for _, m := range s.need() {
|
||||
if !s.answered[m] {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ func (s saysOf) Delete(_ context.Context, key string, _ ...jetstream.KVDeleteOpt
|
||||
// one; stopped, it says nothing any more.
|
||||
func TestTheBuilderSaysItWritesReferencesOnceEveryBuildModuleAnsweredOne(t *testing.T) {
|
||||
s := saysOf{}
|
||||
say := newSayer(t.Context(), s, "shanks", []string{"mesh-build-go", "mesh-build-node", "mesh-build-image"}, t.Logf)
|
||||
say := newSayer(t.Context(), s, "shanks", func() []string { return []string{"mesh-build-go", "mesh-build-node", "mesh-build-image"} }, t.Logf)
|
||||
say.Answered("mesh-build-go")
|
||||
say.Answered("mesh-build-node")
|
||||
if v, ok := s["shanks"]; ok {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatlist"
|
||||
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
)
|
||||
|
||||
// The builder reads the seat list as every part does, through mesh-sdk's one wiring (go/seatlist.Part; design 47 G §204): its
|
||||
// definitions name the build seats (the seats whose acting rule is the step build), its tools `builder_seat_list` and
|
||||
// `builder_seat_list_again`. A call through the mesh MCP server is proved only as its machine's tool runner (issue 627).
|
||||
var seatListAgainCallers = []string{stdio.AnyPerson, "node-tools", "mesh-healers"}
|
||||
|
||||
// seatGate is the builder's wiring of the seat list.
|
||||
type seatGate struct{ *seatlist.Part }
|
||||
|
||||
func newSeatGate() *seatGate { return &seatGate{seatlist.NewPart("builder", seatListAgainCallers)} }
|
||||
|
||||
// definitions are the seat definitions the list holds, none before it is read.
|
||||
func (g *seatGate) definitions() map[string]seatdef.Definition {
|
||||
if r := g.Reader(); r != nil {
|
||||
return r.Definitions()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
||||
)
|
||||
|
||||
// The build modules of the fixture seat list: the holders of the three build seats (design 47 G A-82).
|
||||
const (
|
||||
testGo = "mesh-build-go"
|
||||
testNode = "mesh-build-node"
|
||||
testImage = "mesh-build-image"
|
||||
)
|
||||
|
||||
// testSeats is the finder over a seat list whose build seats act on go, typescript and kind:image, each held by its module.
|
||||
func testSeats() *buildrun.BuildSeats {
|
||||
rule := func(on string) seatdef.Definition {
|
||||
return seatdef.Definition{Acts: []seatdef.ActingRule{{Step: seatdef.StepBuild, On: on}}}
|
||||
}
|
||||
defs := map[string]seatdef.Definition{"node-build-go": rule("go"), "node-build-node": rule("typescript"), "node-build-image": rule(seatdef.OnKindImage)}
|
||||
holders := map[string]string{"node-build-go": testGo, "node-build-node": testNode, "node-build-image": testImage}
|
||||
return buildrun.NewBuildSeats(func() map[string]seatdef.Definition { return defs }, func(seat string) (string, bool) { h, ok := holders[seat]; return h, ok })
|
||||
}
|
||||
@@ -104,7 +104,7 @@ func (h *toolchainsHeard) bind(ctx context.Context, state heardState) {
|
||||
h.mu.Lock()
|
||||
h.kept = state
|
||||
h.mu.Unlock()
|
||||
for _, language := range buildrun.LanguageOf {
|
||||
for _, language := range h.set.Seats.Languages() {
|
||||
for _, e := range h.set.Entries(language) {
|
||||
h.keep(e.Node, e.Toolchain)
|
||||
}
|
||||
@@ -192,7 +192,7 @@ func (h *toolchainsHeard) running(ctx context.Context, data []byte) {
|
||||
h.runAt[id] = r.At
|
||||
kept := h.kept
|
||||
h.mu.Unlock()
|
||||
language, build := buildrun.LanguageOf[r.Module]
|
||||
language, build := h.set.Seats.LanguageOf(r.Module)
|
||||
if !build || r.Fingerprint != "" {
|
||||
return
|
||||
}
|
||||
@@ -224,7 +224,7 @@ func (h *toolchainsHeard) Dropped(ctx context.Context, key string) {
|
||||
// agree says toolchain-agreed for each language whose agreed version is not the one last said (design 47 G §472: said
|
||||
// only when the agreed version changes, ADR 0584 §1).
|
||||
func (h *toolchainsHeard) agree(ctx context.Context) {
|
||||
for _, language := range buildrun.LanguageOf {
|
||||
for _, language := range h.set.Seats.Languages() {
|
||||
entries := h.set.Entries(language)
|
||||
tc, none := buildstep.AgreedToolchain(entries)
|
||||
if none != "" {
|
||||
|
||||
@@ -75,7 +75,7 @@ type heardRig struct {
|
||||
func newHeardRig(t *testing.T, state *memState) *heardRig {
|
||||
t.Helper()
|
||||
r := &heardRig{state: state}
|
||||
r.h = newToolchainsHeard(&buildrun.ToolchainSet{}, func(context.Context) { r.changed++ },
|
||||
r.h = newToolchainsHeard(&buildrun.ToolchainSet{Seats: testSeats()}, func(context.Context) { r.changed++ },
|
||||
func(_ context.Context, e meshbuilds.ToolchainAgreed) error { r.said = append(r.said, e); return nil }, log.New(io.Discard, "", 0))
|
||||
r.h.bind(context.Background(), state)
|
||||
return r
|
||||
@@ -130,18 +130,18 @@ func TestTheBuilderKeepsTheToolchainsItHeardAndForgetsThemOnStopped(t *testing.T
|
||||
t.Fatalf("a changed agreed version was not said: %+v", again.said)
|
||||
}
|
||||
at := time.Now()
|
||||
again.running(t, "ace", buildrun.GoBuildModule, "src2:x", at) // running: nothing is forgotten
|
||||
again.running(t, "ace", testGo, "src2:x", at) // running: nothing is forgotten
|
||||
if k, _ := state.Keys(); len(k) != 3 {
|
||||
t.Fatalf("a running forgot a key: %v", k)
|
||||
}
|
||||
again.running(t, "ace", buildrun.GoBuildModule, "", at.Add(time.Second)) // stopped: no fingerprint
|
||||
again.running(t, "ace", testGo, "", at.Add(time.Second)) // stopped: no fingerprint
|
||||
if k, _ := state.Keys(); len(k) != 2 || k[0] != "g14.go" {
|
||||
t.Fatalf("stopped on ace left %v, want g14.go and novox.go", k)
|
||||
}
|
||||
// An older running read after (the start's read of the stream kept last per subject) changes nothing.
|
||||
before := again.changed
|
||||
again.running(t, "g14", buildrun.GoBuildModule, "", at)
|
||||
again.running(t, "g14", buildrun.GoBuildModule, "src2:y", at.Add(-time.Hour))
|
||||
again.running(t, "g14", testGo, "", at)
|
||||
again.running(t, "g14", testGo, "src2:y", at.Add(-time.Hour))
|
||||
if k, _ := state.Keys(); len(k) != 1 || k[0] != "novox.go" || again.changed != before+1 {
|
||||
t.Fatalf("after g14 stopped and an older running: %v", k)
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ import (
|
||||
|
||||
// The floor's two module tools (novox/hq design 51 *The floor*); the seat's is `seat:<registry>.versions`.
|
||||
const (
|
||||
bridgeTagsTool = "mesh-delivery-forge-bridge.bridge_tags"
|
||||
requirementsTool = "mesh-delivery-indexer.indexer_requirements"
|
||||
bridgeTagsTool = "bridge_tags"
|
||||
requirementsTool = "indexer_requirements"
|
||||
)
|
||||
|
||||
// awaitedVersions is the state versions as versions.Store: bound once the bus holds it (the grants part makes it, issue
|
||||
@@ -106,7 +106,15 @@ func (s awaitedVersions) KeysOf(ctx context.Context, filter string) ([]string, e
|
||||
// floorVia is the floor's three sources as calls of the builder's own account (design 51 *The floor*): the seat's verb
|
||||
// versions, the forge bridge's bridge_tags and the indexer's indexer_requirements. A call that fails is that source
|
||||
// silent.
|
||||
func floorVia(call toolCaller) versions.FloorSources {
|
||||
func floorVia(call toolCaller, holder func(seat string) (string, bool)) versions.FloorSources {
|
||||
sourceTool := func(source, tool string) (string, error) {
|
||||
seat := versions.SourceSeats[source]
|
||||
module, ok := holder(seat)
|
||||
if !ok {
|
||||
return "", fmt.Errorf("no module is known to hold the seat %s, the source of %s", seat, tool)
|
||||
}
|
||||
return module + "." + tool, nil
|
||||
}
|
||||
return versions.FloorSources{
|
||||
Seat: func(_ context.Context, seat, name string) ([]string, error) {
|
||||
raw, err := call("seat:"+seat+".versions", map[string]any{"name": name})
|
||||
@@ -130,7 +138,11 @@ func floorVia(call toolCaller) versions.FloorSources {
|
||||
return out, nil
|
||||
},
|
||||
Tags: func(_ context.Context, repository, prefix string) ([]string, error) {
|
||||
raw, err := call(bridgeTagsTool, map[string]any{"repository": repository, "prefix": prefix})
|
||||
tool, err := sourceTool(versions.SourceTags, bridgeTagsTool)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
raw, err := call(tool, map[string]any{"repository": repository, "prefix": prefix})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -143,7 +155,11 @@ func floorVia(call toolCaller) versions.FloorSources {
|
||||
return a.Tags, nil
|
||||
},
|
||||
Requirements: func(_ context.Context, name string) ([]string, error) {
|
||||
raw, err := call(requirementsTool, map[string]any{"package": name})
|
||||
tool, err := sourceTool(versions.SourceRequirements, requirementsTool)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
raw, err := call(tool, map[string]any{"package": name})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user