From 592b4002bd8935597e7568f0960fecfb4ff31823 Mon Sep 17 00:00:00 2001 From: jochen Date: Sat, 14 Nov 2026 23:18:36 +0100 Subject: [PATCH] Node-engine: a running module with no fingerprint is held in its answer, never removed (A-410) Builds: design 47 G A-410 --- internal/compose/frombus/answer.go | 14 ++++++++++++ internal/compose/frombus/answer_rows_test.go | 24 ++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/internal/compose/frombus/answer.go b/internal/compose/frombus/answer.go index 9e0ecb9d..99328dc9 100644 --- a/internal/compose/frombus/answer.go +++ b/internal/compose/frombus/answer.go @@ -141,6 +141,20 @@ func Answer(ctx context.Context, r Reader, mesh Mesh, s Scope, fps map[string]st a.Differs = slices.DeleteFunc(cmp.Differs, func(d nodeengine.CandidateDiffers) bool { return !notFailed(d.Module) }) cmp.Added = slices.DeleteFunc(cmp.Added, func(d nodeengine.CandidateAdded) bool { return !notFailed(d.Module) }) skipped = slices.DeleteFunc(skipped, func(m string) bool { return !notFailed(m) }) + // A module the node runs and an assignment names, but that no build can be given to compose at (what runs of it carries + // no fingerprint, it having started before the node-engine wrote them, and the declaration gives none), is held: kept as + // it runs, said as held with why, never removed and never stopped for it. Only a module no assignment names is removed + // (A-410). + for _, m := range skipped { + if !runs[m] { + continue + } + a.Removed = slices.DeleteFunc(a.Removed, func(x string) bool { return x == m }) + a.Held = append(a.Held, nodeengine.CandidateRefusal{Module: m, + Why: "what runs of " + m + " has no fingerprint and none is given to compose it at, so it is kept as it runs", + Today: "running, kept as it runs"}) + } + skipped = slices.DeleteFunc(skipped, func(m string) bool { return runs[m] }) // What the proposal adds, by node and module: placed by a candidate and not by the trunk on that node. added := map[string]bool{} diff --git a/internal/compose/frombus/answer_rows_test.go b/internal/compose/frombus/answer_rows_test.go index fb0e77a7..3e50bd69 100644 --- a/internal/compose/frombus/answer_rows_test.go +++ b/internal/compose/frombus/answer_rows_test.go @@ -12,6 +12,7 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" engcomp "github.com/novox/mesh-host/internal/compositions" + "maps" "os" "reflect" "slices" @@ -193,6 +194,29 @@ func answerNamesEveryRefusalAndLeavesAnOldBuildToTheNode(t *testing.T) { if a = Answer(ctx, b, Mesh{}, Scope{Node: "n1", Assignments: given(b), InOwn: []string{"spiegel"}}, fps, withMembership, "p-h1", 3); a.Verdict != nodeengine.CandidateAnswerVerdictSame { t.Errorf("the node's own with its bus membership is answered %+v, want the same", a) } + // (C) A module the node runs and an assignment names, given no fingerprint to compose at (it started before the node + // wrote them): held as it runs, never removed (A-410). One no assignment names is removed. + noFp := maps.Clone(fps) + delete(noFp, "lemurs") + unmarked := make([]engcomp.Composed, 0, len(running)) + for _, c := range running { + if c.Module == "lemurs" { + c.FP = "" + } + unmarked = append(unmarked, c) + } + unmarked = append(unmarked, engcomp.Composed{Node: "n1", Module: "gone", FP: fp("1")}) + a = Answer(ctx, b, Mesh{}, Scope{Node: "n1", Assignments: given(b), InOwn: []string{"spiegel"}}, noFp, unmarked, "p-h1", 3) + if !reflect.DeepEqual(a.Removed, []string{"gone"}) { + t.Errorf("removed %v, want only the module no assignment names", a.Removed) + } + heldIt := false + for _, h := range a.Held { + heldIt = heldIt || h.Module == "lemurs" && h.Why != "" + } + if !heldIt || len(a.Added) != 0 { + t.Errorf("a running module with no fingerprint is answered held %+v added %+v, want held with why and not added", a.Held, a.Added) + } // Without what runs, the fold composes spiegel from its manifest, as before, and the composition refuses it. if _, _, held, err := Compose(ctx, b, Mesh{}, Scope{Node: "n1", InOwn: []string{"spiegel"}}, fps); err != nil || !strings.Contains(held["spiegel"], "spiegel has not been built for this mesh") {