diff --git a/cmd/mesh-host/settled.go b/cmd/mesh-host/settled.go index 5a7dd82..bfec0b6 100644 --- a/cmd/mesh-host/settled.go +++ b/cmd/mesh-host/settled.go @@ -11,8 +11,8 @@ import ( // settledEvent is where the status view says a module has settled on a node: its have reached its want, running and healthy // (design 47; the view's `settled`, said once for a module on a node at one composition). The engine hears it for every module // and tells its agent, which tries again, once per settled, a failed apply that waits on that module as the holder of the store -// its image comes from (design 51 *distribution's first delivery*, issue 1966 ENG-11). The grants part grants the engine this -// subject (NodeAgentHears); a refused subscription is said, and made again when the next link opens. +// its image comes from (design 51 *distribution's first delivery*, issue 1966 ENG-11). The engine's manifest consumes it (`mesh-delivery-view.settled`), +// and that line alone grants the engine's account the subject (TestTheSettledEventIsTheManifestsConsume); a refused subscription is said, and made again when the next link opens. const settledEvent = "mesh.mod.mesh-delivery-view.event.settled" // settledBody is what of the event the engine reads: the module that settled, on whichever node. diff --git a/cmd/mesh-host/settled_manifest_test.go b/cmd/mesh-host/settled_manifest_test.go new file mode 100644 index 0000000..24d4b75 --- /dev/null +++ b/cmd/mesh-host/settled_manifest_test.go @@ -0,0 +1,28 @@ +package main + +import ( + "encoding/json" + "os" + "slices" + "strings" + "testing" +) + +// The subject the engine hears for a store settling is the event its manifest consumes: the grants part grants an account +// what its manifest consumes and nothing named in code (novox/hq ADR 0625 ยง4). +func TestTheSettledEventIsTheManifestsConsume(t *testing.T) { + raw, err := os.ReadFile("../../module.json") + if err != nil { + t.Fatal(err) + } + var m struct { + Consumes []string `json:"consumes"` + } + if err := json.Unmarshal(raw, &m); err != nil { + t.Fatal(err) + } + emitter, event, _ := strings.Cut(strings.TrimPrefix(settledEvent, "mesh.mod."), ".event.") + if !slices.Contains(m.Consumes, emitter+"."+event) { + t.Errorf("the engine hears %s, its manifest consumes %v", settledEvent, m.Consumes) + } +} diff --git a/module.json b/module.json index 2f3da06..8c19c88 100644 --- a/module.json +++ b/module.json @@ -20,6 +20,7 @@ "consumes": [ "mesh-catalog.seat-definition-changed", "mesh-catalog.seat-definition-removed", + "mesh-delivery-view.settled", "restic.backed-up" ], "state": [