From 00cc0f8ff24c32feb0960f0827771a489ecb0d79 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 12 Nov 2026 06:04:27 +0100 Subject: [PATCH] IX4: the indexer names the trunk main once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit trunkLike takes TrunkBranch where it named the string again, so the first watched branch changes in one place. Builds: design 47 G §7, A-93 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h --- .../internal/index/candidates.go | 2 +- .../internal/index/trunk_named_test.go | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 modules/mesh-delivery-indexer/internal/index/trunk_named_test.go diff --git a/modules/mesh-delivery-indexer/internal/index/candidates.go b/modules/mesh-delivery-indexer/internal/index/candidates.go index cce9eba5..e587ac1c 100644 --- a/modules/mesh-delivery-indexer/internal/index/candidates.go +++ b/modules/mesh-delivery-indexer/internal/index/candidates.go @@ -47,7 +47,7 @@ type Store interface { // trunkLike are the branches that are no group: a pull request from one is nobody's delivery group (the rule of // mesh-catalog modules/mesh-delivery/cmd/mesh-delivery/holder.go:321). -var trunkLike = map[string]bool{"main": true, "master": true, "trunk": true, "": true} +var trunkLike = map[string]bool{TrunkBranch: true, "master": true, "trunk": true, "": true} // writeTries bounds the reads again after a conflict; a message that still conflicts is left to the server to deliver again. const writeTries = 8 diff --git a/modules/mesh-delivery-indexer/internal/index/trunk_named_test.go b/modules/mesh-delivery-indexer/internal/index/trunk_named_test.go new file mode 100644 index 00000000..9ee5cd6c --- /dev/null +++ b/modules/mesh-delivery-indexer/internal/index/trunk_named_test.go @@ -0,0 +1,37 @@ +package index + +import ( + "os" + "path/filepath" + "strings" + "testing" +) + +// A-93, design 47 G §7: the trunk `main` is named once in the indexer, as TrunkBranch; no other non-test source of the module holds the +// string, so the first watched branch changes in one place. +func TestTheTrunkIsNamedOnceInTheIndexer(t *testing.T) { + var named []string + for _, dir := range []string{".", "../../cmd/mesh-delivery-indexer", "../judge"} { + files, err := filepath.Glob(filepath.Join(dir, "*.go")) + if err != nil { + t.Fatal(err) + } + for _, f := range files { + if strings.HasSuffix(f, "_test.go") { + continue + } + src, err := os.ReadFile(f) + if err != nil { + t.Fatal(err) + } + for _, line := range strings.Split(string(src), "\n") { + if t := strings.TrimSpace(line); strings.Contains(line, `"main"`) && !strings.HasPrefix(t, "//") { + named = append(named, filepath.Base(f)) + } + } + } + } + if len(named) != 1 { + t.Errorf(`"main" is named %d times in code (%v), want once: TrunkBranch`, len(named), named) + } +}