From 5885ab600a6a88bee0b414dd36760e8d37ad6bb9 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 5 Nov 2026 15:32:43 +0100 Subject: [PATCH] =?UTF-8?q?mesh-wireguard:=20the=20modules=20the=20mesh=20?= =?UTF-8?q?provides=20itself=20are=20its=20overlay=20package's,=20and=20th?= =?UTF-8?q?e=20seat's=20name=20is=20the=20generated=20package's=20(ADR=200?= =?UTF-8?q?636=20=C2=A76;=20issue=201966)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i --- modules/mesh-wireguard/go/go.mod | 5 ++- modules/mesh-wireguard/go/overlay/overlay.go | 4 +- modules/mesh-wireguard/go/overlay/provided.go | 37 +++++++++++++++++++ .../go/overlay/provided_test.go | 29 +++++++++++++++ 4 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 modules/mesh-wireguard/go/overlay/provided.go create mode 100644 modules/mesh-wireguard/go/overlay/provided_test.go diff --git a/modules/mesh-wireguard/go/go.mod b/modules/mesh-wireguard/go/go.mod index 4d82867..4b8b11e 100644 --- a/modules/mesh-wireguard/go/go.mod +++ b/modules/mesh-wireguard/go/go.mod @@ -2,6 +2,9 @@ module git.novox.be/novox/mesh-networking/modules/mesh-wireguard/go go 1.26.0 -require git.novox.be/novox/mesh-sdk/go v0.1.14-0.20261104174359-05b3e2e1b94f +require ( + git.novox.be/novox/mesh-networking/modules/mesh-connectivity-contracts/go/seats/theprivatenetwork v0.0.0-20261105000000-000000000000 + git.novox.be/novox/mesh-sdk/go v0.1.14-0.20261104174359-05b3e2e1b94f +) require git.novox.be/novox/mesh-contracts/go v0.0.0-20261104174344-ae5266e77639 // indirect diff --git a/modules/mesh-wireguard/go/overlay/overlay.go b/modules/mesh-wireguard/go/overlay/overlay.go index c2dc32a..b114410 100644 --- a/modules/mesh-wireguard/go/overlay/overlay.go +++ b/modules/mesh-wireguard/go/overlay/overlay.go @@ -1,5 +1,7 @@ package overlay +import theprivatenetwork "git.novox.be/novox/mesh-networking/modules/mesh-connectivity-contracts/go/seats/theprivatenetwork" + // The private network as a module rather than as code beside the module system. // // A machine's peer list is derived from every other machine, so it differs on each one and @@ -43,7 +45,7 @@ const Addressing = "mesh-addressing" // for two different purposes. Being **the** one the mesh runs over is singular, and without // saying so a person who chose a different VPN can still end up with this one dragged back in by // something that needed the mesh's own addresses. Which is exactly what happened, once. -const TheNetwork = "the-private-network" +const TheNetwork = theprivatenetwork.Seat // **A resolver's data went the same way as the names.** Two constants used to sit here — a // `mesh-resolver` module that would write the machines as wildcards, and a `resolver-data` diff --git a/modules/mesh-wireguard/go/overlay/provided.go b/modules/mesh-wireguard/go/overlay/provided.go new file mode 100644 index 0000000..d89d7a1 --- /dev/null +++ b/modules/mesh-wireguard/go/overlay/provided.go @@ -0,0 +1,37 @@ +package overlay + +import ( + "encoding/json" + "fmt" + + "git.novox.be/novox/mesh-sdk/go/catalogue" +) + +// The modules the mesh provides itself (issue 1126): no repository holds them, so the indexer reads none; their +// manifests are built in code, here, and always win over any other. Today the private network alone, built by nobody +// and run inside each node's own composition. One predicate for every part that judges or composes a placement: the +// placement's check, the seat's holder, the composer's input and the grants part. + +// ProvidedModules is every module the mesh provides itself, sorted. +func ProvidedModules() []string { return []string{Name} } + +// ProvidedByMesh says whether the mesh provides module itself, so a placement may name it with no repository holding it. +func ProvidedByMesh(module string) bool { return module == Name } + +// ProvidedManifest is a provided module's manifest, as its readers parse it, and its raw JSON; an error for a module the +// mesh does not provide or a manifest its own reader refuses. +func ProvidedManifest(module string) (catalogue.Manifest, []byte, error) { + if !ProvidedByMesh(module) { + return catalogue.Manifest{}, nil, fmt.Errorf("overlay: the mesh provides no module %s", module) + } + raw, err := json.Marshal(Manifest()) + if err != nil { + return catalogue.Manifest{}, nil, err + } + // Decoded as every reader decodes a manifest (novox/hq ADR 0578 §3); its judgement is the indexer's. + m, err := catalogue.Decode(raw) + if err != nil { + return catalogue.Manifest{}, raw, fmt.Errorf("overlay: the manifest the mesh provides for %s does not decode: %w", module, err) + } + return m, raw, nil +} diff --git a/modules/mesh-wireguard/go/overlay/provided_test.go b/modules/mesh-wireguard/go/overlay/provided_test.go new file mode 100644 index 0000000..a16589d --- /dev/null +++ b/modules/mesh-wireguard/go/overlay/provided_test.go @@ -0,0 +1,29 @@ +package overlay + +import ( + "encoding/json" + "testing" +) + +func TestTheMeshProvidesThePrivateNetworkAloneAndItsManifestIsTheModules(t *testing.T) { + useTheSeat(t) + if got := ProvidedModules(); len(got) != 1 || got[0] != Name { + t.Fatalf("ProvidedModules = %v", got) + } + if !ProvidedByMesh(Name) || ProvidedByMesh("web") { + t.Error("the mesh provides mesh-wireguard and nothing else") + } + m, raw, err := ProvidedManifest(Name) + if err != nil { + t.Fatal(err) + } + if want, _ := json.Marshal(Manifest()); string(raw) != string(want) { + t.Errorf("provides\n%s\nthe manifest says\n%s", raw, want) + } + if m.Module != Name { + t.Errorf("the manifest is of %q", m.Module) + } + if _, _, err := ProvidedManifest("web"); err == nil { + t.Error("a module the mesh does not provide has a manifest") + } +}