mesh-wireguard: the modules the mesh provides itself are its overlay package's, and the seat's name is the generated package's (ADR 0636 §6; issue 1966)
Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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`
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user