From d3f9a1855d825c71992f22e09fdb9905dcf263f9 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 22 Oct 2026 20:35:29 +0200 Subject: [PATCH] Mark the delivery gate's asks, merges, owed and source readable, as mesh-delivery's parts read them (issue 1790) --- .../cmd/mesh-delivery-gate/keeps.go | 4 ++-- .../cmd/mesh-delivery-gate/keeps_test.go | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/keeps.go b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/keeps.go index 74013044..f7698298 100644 --- a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/keeps.go +++ b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/keeps.go @@ -4,9 +4,9 @@ import "git.novox.be/novox/mesh-sdk/go/announce" // Kept is every state this module keeps on the bus and whether other modules may read it (novox/hq ADR 0495 clause 2; // issue 1790): the module says it itself, from its code, before it serves, and a reader is granted what it said -// (clause 3). A state is readable when another module's manifest reads it. keeps_test.go holds the list to the +// (clause 3). A state is readable when another module's manifest reads it (keeps_test.go names the readers). keeps_test.go holds the list to the // manifest's `state`, and keeps_integration_test.go that the module announces it on a bus. -var Kept = []announce.State{{Name: "asks"}, {Name: "deliveries"}, {Name: "groups"}, {Name: "merges"}, {Name: "owed"}, {Name: "pulls"}, {Name: "source"}} +var Kept = []announce.State{{Name: "asks", Readable: true}, {Name: "deliveries"}, {Name: "groups"}, {Name: "merges", Readable: true}, {Name: "owed", Readable: true}, {Name: "pulls"}, {Name: "source", Readable: true}} // announceKept says Kept through keeps, which is stdio.Keeps. func announceKept(keeps func(...announce.State) error) error { return keeps(Kept...) } diff --git a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/keeps_test.go b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/keeps_test.go index bfccf856..37900997 100644 --- a/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/keeps_test.go +++ b/modules/mesh-delivery-gate/cmd/mesh-delivery-gate/keeps_test.go @@ -8,6 +8,16 @@ import ( "testing" ) +// readers is the gate's own declaration of who reads its states (ADR 0495 clause 3: a read is granted only when the owner +// announced the state readable), kept here and not read from other repositories' manifests (clause 1). Each line names +// the modules of mesh-delivery whose manifest reads the state, as of R4e. +var readers = map[string][]string{ + "asks": {"mesh-delivery-teller", "mesh-delivery-view"}, + "merges": {"mesh-delivery-forge-bridge"}, + "owed": {"mesh-delivery-forge-bridge"}, + "source": {"mesh-delivery-indexer", "mesh-delivery-checker"}, +} + // 1790/S: the states the module announces are the states its manifest declares, no more, no fewer, and the readable // ones are the states other modules' manifests read. func TestTheStatesTheModuleAnnouncesAreTheStatesItsManifestDeclares(t *testing.T) { @@ -42,10 +52,9 @@ func TestTheStatesTheModuleAnnouncesAreTheStatesItsManifestDeclares(t *testing.T if !slices.Equal(declared, announced) { t.Errorf("announces %v, the manifest declares %v", announced, declared) } - want := map[string]bool{} for _, s := range Kept { - if s.Readable != want[s.Name] { - t.Errorf("state %s readable = %v, other modules' manifests read it: %v", s.Name, s.Readable, want[s.Name]) + if want := len(readers[s.Name]) > 0; s.Readable != want { + t.Errorf("state %s readable = %v, but its readers are %v", s.Name, s.Readable, readers[s.Name]) } } }