From cffabdf21df52560e9964642f842cfcbfd011627 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 5 Nov 2026 19:42:00 +0100 Subject: [PATCH] =?UTF-8?q?mesh-sdk:=20the=20refusal=20of=20contracts=20mo?= =?UTF-8?q?dules=20and=20domain=20SDKs=20reads=20every=20path=20segment,?= =?UTF-8?q?=20so=20a=20folder=20module=20counts=20(ADR=200635=20=C2=A71,?= =?UTF-8?q?=20ADR=200636=20=C2=A78;=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 --- go/packages_list_test.go | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/go/packages_list_test.go b/go/packages_list_test.go index bcef968..a861aee 100644 --- a/go/packages_list_test.go +++ b/go/packages_list_test.go @@ -40,21 +40,23 @@ var moduleWord = regexp.MustCompile(`\bmesh-(?:delivery|grants|vault|host|config // contractsOrDomainSDK says an import path is a module mesh-sdk may not import (ADR 0635 §1, ADR 0636 §8): the mesh's // contracts modules (mesh-contracts, mesh--contracts, a repository's `contracts` folder) and the domain SDKs -// (mesh--sdk, a repository's `sdk` folder). Names no module: it reads the shape of the path. +// (mesh--sdk, a repository's `sdk` folder), whether a repository or a folder module of one: any path segment that +// is, or ends in, `contracts` or `sdk`. Names no module: it reads the shape of the path. func contractsOrDomainSDK(path string) bool { rest, ok := strings.CutPrefix(path, "git.novox.be/novox/") if !ok { return false } parts := strings.Split(rest, "/") - repo := parts[0] - if repo == "mesh-sdk" { + if parts[0] == "mesh-sdk" { return false } - if len(parts) > 1 && (parts[1] == "contracts" || parts[1] == "sdk") { - return true + for _, seg := range parts { + if seg == "contracts" || seg == "sdk" || strings.HasSuffix(seg, "-contracts") || strings.HasSuffix(seg, "-sdk") { + return true + } } - return repo == "mesh-contracts" || (strings.HasPrefix(repo, "mesh-") && (strings.HasSuffix(repo, "-contracts") || strings.HasSuffix(repo, "-sdk"))) + return false } // notInSDK are the packages that moved to a seat's client or contract (ADR 0627 §1, §4) and may not come back. @@ -330,3 +332,23 @@ func TestMeshSDKHoldsOnlyWhatEveryModuleShares(t *testing.T) { // sdkModule is mesh-sdk's Go module path. const sdkModule = "git.novox.be/novox/mesh-sdk/go" + +// ADR 0635 §1, ADR 0636 §8: the refusal reads every segment of an import path, so a contracts module or a domain SDK +// that is a folder module of a repository (mesh-networking's modules/mesh-connectivity-contracts) is refused too. +func TestContractsAndDomainSDKsAreRecognisedInEverySegment(t *testing.T) { + for path, want := range map[string]bool{ + "git.novox.be/novox/mesh-contracts/go/seats/meshconfig": true, + "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog": true, + "git.novox.be/novox/mesh-delivery/sdk": true, + "git.novox.be/novox/mesh-networking/modules/mesh-connectivity-contracts/go/seats/x": true, + "git.novox.be/novox/mesh-networking/modules/mesh-connectivity-sdk": true, + "git.novox.be/novox/mesh-sdk/go/catalogue": false, + "git.novox.be/novox/mesh-sdk/go/seatlist": false, + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-indexer": false, + "github.com/nats-io/nats.go": false, + } { + if got := contractsOrDomainSDK(path); got != want { + t.Errorf("contractsOrDomainSDK(%q) = %v, want %v", path, got, want) + } + } +}