From 03894e5e512e6f20b81e1b6b58d401b41377c62d Mon Sep 17 00:00:00 2001 From: jochen Date: Sat, 24 Oct 2026 17:25:05 +0200 Subject: [PATCH] Delete whatTheMergeTouched, IsStaleRefusal and WriterEpoch, unused since the push went (release 6, issue 1945 B8) --- cmd/mesh-controller/bindings_test.go | 1 - cmd/mesh-controller/order_test.go | 92 ---------------------------- cmd/mesh-controller/signals_test.go | 3 +- cmd/mesh-controller/upgrades.go | 8 --- internal/link/watched.go | 12 ---- 5 files changed, 2 insertions(+), 114 deletions(-) diff --git a/cmd/mesh-controller/bindings_test.go b/cmd/mesh-controller/bindings_test.go index 7467d485..8cd06d61 100644 --- a/cmd/mesh-controller/bindings_test.go +++ b/cmd/mesh-controller/bindings_test.go @@ -75,4 +75,3 @@ func TestBindingFindingsSayAKeptMoveAndAMoveNothingAskedFor(t *testing.T) { t.Error("two consumers, one condition") } } - diff --git a/cmd/mesh-controller/order_test.go b/cmd/mesh-controller/order_test.go index 5aa455b1..9163e23f 100644 --- a/cmd/mesh-controller/order_test.go +++ b/cmd/mesh-controller/order_test.go @@ -75,52 +75,6 @@ func fromRepo(module, repository, path string) inventory.Entry { } } -// A merge rebuilds the modules whose own directories it changed, and everything when what it changed -// is shared. One repository holding many modules is the ordinary case here, and rebuilding all of -// them for a change to one is what exhausted a registry's pull limit the first night this ran. -func TestAMergeRebuildsTheModulesItChanged(t *testing.T) { - const repo = "http://forge.internal:20000/novox/mesh-catalog.git" - gitea := fromRepo("gitea", repo, "modules/gitea") - keycloak := fromRepo("keycloak", repo, "modules/keycloak") - known := []inventory.Entry{gitea, keycloak, fromRepo("plex", repo, "modules/plex")} - candidates := []inventory.Entry{gitea, keycloak} - merge := func(paths []string, truncated bool) link.SourceMoved { - return link.SourceMoved{Owner: "novox", Repo: "mesh-catalog", Base: "main", - Paths: paths, PathsTruncated: truncated} - } - named := func(entries []inventory.Entry) string { - var names []string - for _, e := range entries { - names = append(names, e.Manifest.Module) - } - return strings.Join(names, ",") - } - for _, c := range []struct { - what string - m link.SourceMoved - want string - }{ - {"one module's own files", merge([]string{"modules/gitea/index.ts", "modules/gitea/client.ts"}, false), "gitea"}, - {"two modules' files", merge([]string{"modules/gitea/index.ts", "modules/keycloak/module.json"}, false), "gitea,keycloak"}, - {"a file at the root no build reads (issue 280)", merge([]string{"tsconfig.json"}, false), ""}, - {"a module the mesh does not hold", merge([]string{"modules/plex/index.ts"}, false), ""}, - {"nothing said about the files", merge(nil, false), "gitea,keycloak"}, - {"more files than were listed", merge([]string{"modules/gitea/index.ts"}, true), "gitea,keycloak"}, - // novox/hq issue 252: a module the mesh has never registered is still a module, when the merge - // shows it is one — and a directory that may be shared code is still shared. - {"a new module beside a held one", merge([]string{"modules/gitea/x", "modules/newmod/module.json"}, false), "gitea"}, - {"a new module's other files", merge([]string{"modules/newmod/index.ts", "modules/newmod/module.json"}, false), ""}, - {"a module removed", merge([]string{"modules/gone/module.json"}, false), ""}, - {"a directory with no manifest", merge([]string{"modules/lib/x.go"}, false), ""}, - {"a file directly among the modules", merge([]string{"modules/README.md"}, false), ""}, - {"a root file beside a module's", merge([]string{"merge-check.sh", "modules/keycloak/x.ts"}, false), "keycloak"}, - } { - if got := named(whatTheMergeTouched(candidates, known, c.m, nil)); got != c.want { - t.Errorf("%s: rebuilt %q, wanted %q", c.what, got, c.want) - } - } -} - // A module whose recipe packages source from another repository is affected when that repository // moves — the manifest the mesh keeps says nothing about it, so the record of what the build read is // the only thing that can say so. @@ -203,52 +157,6 @@ func TestAModuleBuiltAtACommitStillFollowsItsBranch(t *testing.T) { } } -// novox/hq issues 278 and 280: a merge touching the code of a module the mesh does not hold — the -// catalogue's reference module, whose manifest it left alone — read as shared and rebuilt every module -// built from the repository (103 of them on 2026-10-06, 88 byte-identical); so did a merge-check.sh added at -// the root. No build reads a file outside its module's directory, so neither rebuilds anything, said by the -// announcer or not. -func TestAChangeInsideAModuleIsThatModulesHeldOrNot(t *testing.T) { - const repo = "http://forge.internal:20000/novox/mesh-catalog.git" - gitea := fromRepo("gitea", repo, "modules/gitea") - keycloak := fromRepo("keycloak", repo, "modules/keycloak") - known := []inventory.Entry{gitea, keycloak} - candidates := []inventory.Entry{gitea, keycloak} - merge := func(paths, modules []string, said bool) link.SourceMoved { - return link.SourceMoved{Owner: "novox", Repo: "mesh-catalog", Base: "main", Paths: paths, - ModuleDirs: modules, ModuleDirsSaid: said} - } - named := func(entries []inventory.Entry) string { - var names []string - for _, e := range entries { - names = append(names, e.Manifest.Module) - } - return strings.Join(names, ",") - } - showcase := []string{"modules/showcase/index.ts"} - for _, c := range []struct { - what string - m link.SourceMoved - want string - }{ - {"a module held by none, said", merge(showcase, []string{"modules/showcase"}, true), ""}, - {"beside a held one's change", merge(append([]string{"modules/gitea/index.ts"}, showcase...), - []string{"modules/gitea", "modules/showcase"}, true), "gitea"}, - {"deeper inside it", merge([]string{"modules/showcase/daemon/index.ts"}, []string{"modules/showcase"}, true), ""}, - {"a directory holding no manifest, read by no build", merge([]string{"modules/lib/x.go"}, nil, true), ""}, - {"one of two files in no module", merge([]string{"modules/showcase/index.ts", "modules/lib/x.go"}, - []string{"modules/showcase"}, true), ""}, - {"the root is never a module directory", merge([]string{"tsconfig.json"}, []string{"", "/", "."}, true), ""}, - {"not said: still no build reads it", merge(showcase, []string{"modules/showcase"}, false), ""}, - {"an old announcer saying nothing", merge(showcase, nil, false), ""}, - {"a manifest the merge removed, said or not", merge([]string{"modules/gone/module.json", "modules/gone/x.ts"}, nil, true), ""}, - } { - if got := named(whatTheMergeTouched(candidates, known, c.m, nil)); got != c.want { - t.Errorf("%s: rebuilt %q, wanted %q", c.what, got, c.want) - } - } -} - // What the announcer says reaches the controller as it is sent: the two fields, by their names on the // wire, and an older announcement without them reads as not said. func TestTheAnnouncerSaysWhichDirectoriesAreModules(t *testing.T) { diff --git a/cmd/mesh-controller/signals_test.go b/cmd/mesh-controller/signals_test.go index 80834150..673a0987 100644 --- a/cmd/mesh-controller/signals_test.go +++ b/cmd/mesh-controller/signals_test.go @@ -3,6 +3,7 @@ package main import ( "context" "errors" + "fmt" "os" "path/filepath" "regexp" @@ -40,7 +41,7 @@ func calm(now time.Time) *signalFacts { // refusedBy is n refusals of one writer, the last a moment ago. func refusedBy(now time.Time, epoch int64, n int) []link.WriterRefusals { - return []link.WriterRefusals{{Writer: link.WriterEpoch(epoch), Epoch: epoch, Count: n, + return []link.WriterRefusals{{Writer: fmt.Sprintf("the controller of epoch %d", epoch), Epoch: epoch, Count: n, Receivers: []string{"anchor", "laptop"}, Last: now.Add(-time.Second)}} } diff --git a/cmd/mesh-controller/upgrades.go b/cmd/mesh-controller/upgrades.go index fb17aaf6..f17c80be 100644 --- a/cmd/mesh-controller/upgrades.go +++ b/cmd/mesh-controller/upgrades.go @@ -646,11 +646,3 @@ func sayUpgrade(module string, u inventory.Upgrade) string { return fmt.Sprintf("when %s moves, one machine running it is sent the new version first and judged at "+ "the gate; the rest follow once it passes, and a build that fails is put back there%s", module, from) } - -// whatTheMergeTouched narrows the modules built from a repository to the ones the merge changed: touchedBy's first answer -// (novox/hq issue 280, ADR 0238). -func whatTheMergeTouched(candidates, known []inventory.Entry, m link.SourceMoved, - read map[string][]inventory.ReadRepository) []inventory.Entry { - touched, _, _ := touchedBy(candidates, known, m, read) - return touched -} diff --git a/internal/link/watched.go b/internal/link/watched.go index 38bb8e5c..2a7c3003 100644 --- a/internal/link/watched.go +++ b/internal/link/watched.go @@ -172,9 +172,6 @@ func (p PowerState) Away() bool { return p.State == "sleeping" || p.State == "sh // one it holds (mesh-host `refuseOlder`, novox/hq issue 107): the receiver's refusal S13 counts. const StaleRefusal = "is older than what the mesh last said to this node" -// IsStaleRefusal says a report's refusal is the node-engine refusing a declaration older than it holds. -func IsStaleRefusal(refused string) bool { return strings.Contains(refused, StaleRefusal) } - // A Refusal is one receiver refusing something older than what it holds (novox/hq to-be 45 §6, ADR 0227 // rule 2): a machine refusing a declaration, or this controller refusing an account. type Refusal struct { @@ -189,15 +186,6 @@ type Refusal struct { At time.Time } -// WriterEpoch is how a refused declaration's writer is said before it is named: by the epoch it -// claimed, or as a controller that claimed none. -func WriterEpoch(epoch int64) string { - if epoch > 0 { - return fmt.Sprintf("the controller of epoch %d", epoch) - } - return "a controller that claimed no epoch" -} - // WriterNodeEngine is a machine's node-engine as the writer of an account the controller refused. func WriterNodeEngine(node string) string { return "the node-engine on " + node }