From cc3f7e8e0154745f549c8764b9672d946f790ff5 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 30 Oct 2026 20:30:37 +0100 Subject: [PATCH] Retire the kept read though mesh-wireguard has no fingerprint, since the node's own composes it from the manifest the mesh provides (issue 774) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The review of d5e8458 found that mesh-wireguard, provided by the mesh and never wanted at a fingerprint, kept the kept declaration read on every node for ever, against ADR 0550 ยง2 once the lease is written. A selfcompose row shows the node's own composes it from delivery.ProvidedManifest with nothing running, so the kept read holds nothing of it. Quick fix: name mesh-wireguard in allHave. Thorough fix: allHave counts every module delivery.ProvidedByMesh says the mesh provides as covered. Chose thorough: one list of provided modules, mesh-sdk's. --- cmd/mesh-host/trust.go | 4 +++- cmd/mesh-host/whatruns_test.go | 11 +++++++++++ internal/selfcompose/selfcompose_test.go | 22 ++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/cmd/mesh-host/trust.go b/cmd/mesh-host/trust.go index 5e81454..caac1d7 100644 --- a/cmd/mesh-host/trust.go +++ b/cmd/mesh-host/trust.go @@ -273,7 +273,9 @@ func allHave(p delivery.Placement, has func(module string) (delivery.Have, bool, if !ok { return false, m.Module + " has no have yet" } - if h.Phase != delivery.PhaseRemoved && !strings.HasPrefix(h.FP, delivery.SourcePrefix2) { + // A module the mesh provides (mesh-wireguard) never has a fingerprint: the node's own composes it from the manifest + // mesh-sdk provides (delivery.ProvidedManifest), never from the kept declaration, so it keeps no read. + if h.Phase != delivery.PhaseRemoved && !strings.HasPrefix(h.FP, delivery.SourcePrefix2) && !delivery.ProvidedByMesh(m.Module) { return false, m.Module + " runs at a build of the old form (" + h.Build + "), which only the kept declaration records" } } diff --git a/cmd/mesh-host/whatruns_test.go b/cmd/mesh-host/whatruns_test.go index 321180d..05d809f 100644 --- a/cmd/mesh-host/whatruns_test.go +++ b/cmd/mesh-host/whatruns_test.go @@ -12,6 +12,7 @@ import ( "git.novox.be/novox/mesh-sdk/go/declaration" "git.novox.be/novox/mesh-sdk/go/delivery" + "git.novox.be/novox/mesh-sdk/go/overlay" "github.com/novox/mesh-host/internal/agent" "github.com/novox/mesh-host/internal/liveness" @@ -133,6 +134,16 @@ func TestDeclaredNowReadsWhatRunsWhenTheAgentIsRunning(t *testing.T) { t.Errorf("%s: %v (%s)", row.name, got, why) } } + // The module the mesh provides never has a fingerprint, and keeps no read (review of issue 774). + withWireguard := delivery.Placement{Node: "n1", Modules: []delivery.PlacedModule{{Module: "zsh"}, {Module: overlay.Name}}} + if got, why := allHave(withWireguard, func(m string) (delivery.Have, bool, error) { + if m == overlay.Name { + return oldForm, true, nil + } + return newForm, true, nil + }); !got { + t.Errorf("%s without a fingerprint beside zsh at the new form keeps the read: %s", overlay.Name, why) + } if got, _ := allHave(delivery.Placement{Node: "n1"}, nil); got { t.Error("a node with nothing placed retires the read") } diff --git a/internal/selfcompose/selfcompose_test.go b/internal/selfcompose/selfcompose_test.go index d8eb1f4..7139041 100644 --- a/internal/selfcompose/selfcompose_test.go +++ b/internal/selfcompose/selfcompose_test.go @@ -20,6 +20,7 @@ import ( "git.novox.be/novox/mesh-sdk/go/compose" "git.novox.be/novox/mesh-sdk/go/compose/frombus" "git.novox.be/novox/mesh-sdk/go/delivery" + "git.novox.be/novox/mesh-sdk/go/overlay" "github.com/nats-io/nats.go" "github.com/novox/mesh-host/internal/agent" @@ -398,6 +399,27 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) { if len(*told4) != 1 || !strings.HasPrefix((*told4)[0], "held power: ") || !strings.Contains((*told4)[0], `"shows" is none of them`) { t.Errorf("the agent was told %q, want power held alone, naming its item", *told4) } + // Review of issue 774 (the kept read): mesh-wireguard, which the mesh provides and which never has a fingerprint, is + // folded in the node's own and composed from the manifest mesh-sdk provides (delivery.ProvidedManifest), not from + // what runs nor the kept declaration: with nothing running (the kept read retired, Running empty) the node's own + // still carries its resources, so retiring the read removes nothing of it. + c5, told5 := fresh(env.Get) + p5 := c5.placements["n1"] + p5.Modules = append(append([]delivery.PlacedModule{}, p5.Modules...), delivery.PlacedModule{Module: overlay.Name}) + p5.Decided.Endpoint = "n1.example:51820" + c5.placements["n1"] = p5 + c5.inOwn[overlay.Name] = true + nodeKey5, _ := delivery.ComposedNodeKey("n1") + var own5 string + for _, u := range c5.compose(ctx) { + if u.Key == nodeKey5 { + own5 = string(u.Value) + } + } + if len(*told5) != 0 || !strings.Contains(own5, overlay.Name+".") { + t.Errorf("the node's own with %s folded and nothing running: told %q, carries %s: %.300s", overlay.Name, *told5, + overlay.Name, own5) + } // A read the bus did not answer, timed out or not, is tried again later; the run's own end and a refusal are not. if !BusFailed(fmt.Errorf("the revisions of it2.mailer.domain: %w", context.DeadlineExceeded)) || !BusFailed(fmt.Errorf("x: %w", nats.ErrNoResponders)) ||