IX4: the indexer names the trunk main once

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
This commit is contained in:
2026-11-12 06:04:27 +01:00
parent bbd872f519
commit 00cc0f8ff2
2 changed files with 38 additions and 1 deletions
@@ -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
@@ -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)
}
}