From 21523a449fa8cf37f37b29a8fd71ed6e08faadb1 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 15 Nov 2026 15:58:00 +0100 Subject: [PATCH] assigner: a put may hold the build a node runs now A put of ace's assigner at the build it runs (a hand start) was refused, since the builder's store holds no build of it, so the trunk's newest build would replace it. Where the store holds none, a put naming the fingerprint the node's running statement names is held there with the composition the node's have names; the store is not asked. A have naming no composition at that fingerprint refuses it, saying so. Builds: design 47 G A-427, A-426 --- .../internal/assign/put.go | 17 +++++++++++++++++ .../internal/assign/wants_test.go | 15 +++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/modules/mesh-delivery-assigner/internal/assign/put.go b/modules/mesh-delivery-assigner/internal/assign/put.go index bec0609e..1c26bb7a 100644 --- a/modules/mesh-delivery-assigner/internal/assign/put.go +++ b/modules/mesh-delivery-assigner/internal/assign/put.go @@ -79,6 +79,23 @@ func StepPut(w PutWorld) PutNext { if !w.Assigned { return say(puts.Refused, "%s is not assigned to %s: a put moves a module where it stands assigned (propose its assignments first)", w.Module, w.Node) } + if p.Step != puts.Wanted && p.Step != puts.Holding && w.Build == "" { + // Only where the builder's store holds no build of it: one it built goes the put's whole way (composition, the yes). + if r := w.Running; r != nil && !r.Stopped && r.Fingerprint != "" && r.Fingerprint == p.FP { + // The build the node runs now (design 47 G A-427): read from the node's running statement, held there with the + // composition its have names, and the builder's store is not asked for it (a part started by hand has none there). + if h := w.Have; h == nil || h.Fp != p.FP || h.Composed == "" { + return say(puts.Refused, "%s runs %s at %s, and its have names no composition at that fingerprint, so the want cannot name what runs", w.Node, w.Module, fp) + } + p.Composed = w.Have.Composed + words := fmt.Sprintf("the want of %s on %s names %s, the build it runs now (composition %s), from its running statement; the builder's store is not asked", + w.Module, w.Node, fp, short(p.Composed)) + if p.Hold { + words += ", held until released" + } + return PutNext{Put: applied(w, p.Said(w.Now, puts.Wanted, words))} + } + } switch w.Build { case builds.BuildDone: case builds.BuildFailed: diff --git a/modules/mesh-delivery-assigner/internal/assign/wants_test.go b/modules/mesh-delivery-assigner/internal/assign/wants_test.go index b2f428ae..5854eddb 100644 --- a/modules/mesh-delivery-assigner/internal/assign/wants_test.go +++ b/modules/mesh-delivery-assigner/internal/assign/wants_test.go @@ -882,6 +882,21 @@ func stepsOfAPut(t *testing.T) { {"not assigned", func() PutWorld { w := bus(); w.Assigned = false; return w }, puts.Refused, "not assigned", false, false, false}, {"no build yet of the newest", func() PutWorld { w := bus(); w.Build = ""; return w }, puts.Build, "builds by itself", false, false, false}, {"no build of an older one", func() PutWorld { w := bus(); w.Build, w.Newest = "", fpOf('c'); return w }, puts.Refused, "holds no build", false, false, false}, + // A-427: the build the node runs now is put from its running statement, held with the have's composition, the + // builder's store not asked (a part started by hand has no build there); a have naming no composition refuses it. + {"the build the node runs now, not in the builder's store: held there", func() PutWorld { + w := bus() + w.Build, w.Newest = "", fpOf('c') + w.Running = &nodeengine.Running{Node: "novox", Module: "nats", Fingerprint: fNew} + w.Have = &nodeengine.HaveByNodeModuleValue{Fp: fNew, Composed: dig(fNew), Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK} + return w + }, puts.Holding, "held there until released", false, false, false}, + {"the build the node runs now, its have naming no composition: refused", func() PutWorld { + w := bus() + w.Build, w.Newest = "", fpOf('c') + w.Running = &nodeengine.Running{Node: "novox", Module: "nats", Fingerprint: fNew} + return w + }, puts.Refused, "names no composition", false, false, false}, {"a failed build", func() PutWorld { w := bus(); w.Build, w.BuildWords = builds.BuildFailed, "go vet"; return w }, puts.Refused, "go vet", false, false, false}, {"no composition yet: waits", func() PutWorld { w := bus(); w.Composed = nil; return w }, puts.Compose, "no composition of nats for novox", false, false, false}, {"composed, grant not naming the node", func() PutWorld { w := bus(); w.Granted = false; return w }, puts.Compose, "does not name novox", false, false, false},