mesh-sdk: the refusal of contracts modules and domain SDKs reads every path segment, so a folder module counts (ADR 0635 §1, ADR 0636 §8; issue 1966)

Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
2026-11-05 19:42:00 +01:00
parent a3fee9f85b
commit cffabdf21d
+28 -6
View File
@@ -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-<domain>-contracts, a repository's `contracts` folder) and the domain SDKs
// (mesh-<domain>-sdk, a repository's `sdk` folder). Names no module: it reads the shape of the path.
// (mesh-<domain>-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)
}
}
}