mesh-sdk: refuse every contracts module and domain SDK, module names in the shared packages; the bootstrap equals its contracts' files, one row per seat (ADR 0635 §1, ADR 0636 §8; issue 1966)

Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
2026-11-05 18:27:48 +01:00
parent 0d3a10ff20
commit fa56961ae8
17 changed files with 7787 additions and 15 deletions
+25 -6
View File
@@ -38,6 +38,25 @@ var clientSeats = []string{"operator-channel", "mesh-vault", "node-engine", "npm
// before -views or _read_), but a seat's that go/views records through (mesh-hand-acts) and an import path's mesh-sdk.
var moduleWord = regexp.MustCompile(`\bmesh-(?:delivery|grants|vault|host|config|provisioner|broker|knowledge|enrolment)\b[-a-z]*|\b(?:indexer|assigner|teller|watchman|checker|builder)(?:-views|_read_)`)
// 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.
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" {
return false
}
if len(parts) > 1 && (parts[1] == "contracts" || parts[1] == "sdk") {
return true
}
return repo == "mesh-contracts" || (strings.HasPrefix(repo, "mesh-") && (strings.HasSuffix(repo, "-contracts") || strings.HasSuffix(repo, "-sdk")))
}
// notInSDK are the packages that moved to a seat's client or contract (ADR 0627 §1, §4) and may not come back.
var notInSDK = []string{"asks", "asker", "publish", "composer", "parts", "provider", "handacts", "channel", "provisions", "buildstep", "delivery", "overlay"}
@@ -114,8 +133,8 @@ func TestMeshSDKHoldsOnlyWhatEveryModuleShares(t *testing.T) {
}
for _, imp := range file.Imports {
p, _ := strconv.Unquote(imp.Path.Value)
if strings.HasPrefix(p, "git.novox.be/novox/mesh-contracts") {
t.Errorf("%s imports %s: mesh-sdk imports no contracts module (ADR 0635 §1)", path, p)
if contractsOrDomainSDK(p) {
t.Errorf("%s imports %s: mesh-sdk imports no contracts module and no domain SDK (ADR 0635 §1, ADR 0636 §8)", path, p)
}
}
return nil
@@ -133,8 +152,8 @@ func TestMeshSDKHoldsOnlyWhatEveryModuleShares(t *testing.T) {
// ADR 0635 §1: mesh-sdk imports no contracts module, the seat list being read from the bus.
for _, imp := range file.Imports {
p, _ := strconv.Unquote(imp.Path.Value)
if strings.HasPrefix(p, "git.novox.be/novox/mesh-contracts") {
t.Errorf("%simports %s: mesh-sdk imports no contracts module (ADR 0635 §1)", where, p)
if contractsOrDomainSDK(p) {
t.Errorf("%simports %s: mesh-sdk imports no contracts module and no domain SDK (ADR 0635 §1, ADR 0636 §8)", where, p)
}
}
ast.Inspect(file, func(n ast.Node) bool {
@@ -142,7 +161,7 @@ func TestMeshSDKHoldsOnlyWhatEveryModuleShares(t *testing.T) {
case *ast.BasicLit:
// views is shared by every owner and reader: it names no module, the caller gives the owner's tool and
// stream from the owner's declaration (the lead's ruling, 2026-11-04, the second instance of the kind).
if v, err := strconv.Unquote(n.Value); err == nil && n.Kind == token.STRING && (dir == "views" || strings.HasPrefix(dir, "views/")) &&
if v, err := strconv.Unquote(n.Value); err == nil && n.Kind == token.STRING && (dir == "." || dir == "process" || dir == "seatlist" || dir == "views" || strings.HasPrefix(dir, "views/")) &&
moduleWord.MatchString(v) {
modules = append(modules, where+moduleWord.FindString(v))
}
@@ -205,7 +224,7 @@ func TestMeshSDKHoldsOnlyWhatEveryModuleShares(t *testing.T) {
}
slices.Sort(found)
for _, m := range modules {
t.Errorf("%s: go/views names no module; its caller gives the owner's read tool and views stream from the owner's declaration", m)
t.Errorf("%s: the shared packages (the root, process, seatlist, views) name no module; its caller gives the owner's read tool and views stream from the owner's declaration", m)
}
for _, dir := range found {
if slices.Contains(notInSDK, dir) {