From cc69737934824397003241442b6f84869e26df08 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 27 Sep 2026 15:37:21 +0200 Subject: [PATCH] The agreement check knows the mesh's own roles, and was passing vacuously without them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It read the roles modules declare and not the mesh's own, so the first consumer of a role's event was skipped as "the emitter is not installed" — which is exactly the silence the check exists to break. It passed, and it was checking nothing. Now it is handed the mesh's own roles too, and there is a case pinning that a consumer of a role event the role does not emit is caught. A check that cannot fail is worse than no check, because it reads as evidence. --- internal/broker/agreement_catalogue_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/broker/agreement_catalogue_test.go b/internal/broker/agreement_catalogue_test.go index 9c4a348..7b9e0ec 100644 --- a/internal/broker/agreement_catalogue_test.go +++ b/internal/broker/agreement_catalogue_test.go @@ -6,6 +6,8 @@ import ( "path/filepath" "strings" "testing" + + "github.com/novox/mesh-controller/internal/catalogue" ) // **Do the catalogue's emitters and consumers agree?** @@ -53,6 +55,14 @@ func TestTheAgreementCheckCatchesASubscriptionThatMatchesNothing(t *testing.T) { t.Fatalf("a wildcard over emitters was reported: %v", bad) } + // A consumer of a role's event whose role does not emit it is caught, which is what stops the + // catalogue check above from passing by knowing nothing about roles. + if bad := Disagreements(nil, + []AConsumer{{Module: "mesh-catalog", Consumes: []string{"mesh-build-machine.finished"}}}, + []DeclaredSeat{{Name: "mesh-build-machine", Emits: []string{"built"}}}); len(bad) != 1 { + t.Fatalf("a consumer of a role event the role does not emit was not caught: %v", bad) + } + // An event published under a seat's name is real even though no module declares it as its own. if bad := Disagreements(nil, []AConsumer{{Module: "watcher", Consumes: []string{"mesh-artifact-store.image.pushed"}}}, @@ -70,7 +80,13 @@ func theCataloguesEvents(t *testing.T) ([]AnEmitter, []AConsumer, []DeclaredSeat } var emitters []AnEmitter var consumers []AConsumer + // The mesh's own roles, which emit under the seat's name rather than any module's (novox/hq + // ADR 0121). Without these the check skips every consumer of a role's event as "the emitter is + // not installed" — which is how it passed vacuously the first time one existed. var seats []DeclaredSeat + for _, own := range catalogue.SeatsWithAProtocol() { + seats = append(seats, DeclaredSeat{Name: own.Name, Accepts: own.Accepts, Emits: own.Emits}) + } for _, e := range entries { if !e.IsDir() { continue