I1 fix: §802's whole criterion is a step of the indexer's whole packages test

Review round 1 found §802's whole criterion (a commit touching two test
files of two modules of 36 moves those two and their importers alone)
unit-tested only. It becomes a step of
TestASourceRevisionMovingMeshSDKNamesItAndItsImporters, the indexer whole
against an embedded bus: the catalogue holds 36 modules, lib-a and lib-b
among them, required by app-a (require) and app-b (require and replace);
a commit changing lib-a's and lib-b's trees alone moves lib-a, lib-b,
app-a and app-b and none of the other 32. The step fails when the
repository's commit enters the tree input, and when a derived directory
does not.

Builds: design 47 H2 §802; H-A-453 (3)
This commit is contained in:
2026-11-22 03:31:00 +01:00
parent c0489000ba
commit dde4108504
@@ -6,6 +6,8 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"maps"
"os"
"reflect"
"slices"
@@ -67,11 +69,18 @@ func untilModule(t *testing.T, ctx context.Context, js jetstream.JetStream, name
// and not plain; the packages key of mesh-sdk/go names that commit with a digest per package. Design 47 H2 §804: a key a dry
// run left in the state dry-runs is gone at the start, and the take-in of a branch moving mesh-sdk again, a dry run, leaves
// the trunk's packages state byte for byte as before and no key in dry-runs once it answered.
//
// Design 47 H2 §802 (H-A-453 (3)): the catalogue holds 36 modules, among them lib-a and lib-b, required by app-a (a require) and
// app-b (a require and a replace by a directory); a source revision moving the catalogue to a commit that changes a test file
// of lib-a and one of lib-b, and so their trees alone, moves lib-a, lib-b and their importers alone, never the other 32
// modules whose repository's commit moved too.
func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) {
const (
sdkGo = "git.novox.be/novox/mesh-sdk/go"
m1, m2, m3 = "1111111111111111111111111111111111111111", "2222222222222222222222222222222222222222", "4444444444444444444444444444444444444444"
catalogMerge = "3333333333333333333333333333333333333333"
catalogTests = "5555555555555555555555555555555555555555" // a test file of lib-a and one of lib-b changed
catalogModule = "git.novox.be/novox/mesh-catalog/modules/"
goModContent = "module importer\n\nrequire git.novox.be/novox/mesh-sdk/go v0.0.0-00010101000000-000000000000\n"
sdkRoot1, sdk2 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
sdk3 = "cccccccccccccccccccccccccccccccccccccccc"
@@ -131,14 +140,35 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) {
if _, err := dryRuns.Put(ctx, index.DryRunPrefix("beta", "0123")+index.PackagesState+".left", []byte(`{"value":"e30="}`)); err != nil {
t.Fatal(err)
}
forge.put(catalogMerge, repoAt{trees: map[string]string{"modules/importer": "t1", "modules/plain": "t2"},
catalogue := repoAt{trees: map[string]string{"modules/importer": "t1", "modules/plain": "t2"},
files: map[string]string{"modules/importer/module.json": named("importer"), "modules/plain/module.json": named("plain"),
"modules/importer/go.mod": goModContent, "modules/importer/go.sum": "golang.org/x/sys v0.1.0 h1:x=\n",
"modules/plain/go.mod": "module plain\n\nrequire golang.org/x/sys v0.1.0\n", "modules/plain/go.sum": "golang.org/x/sys v0.1.0 h1:x=\n"}})
regs := registerAvahi(t, ctx, js, "main")
for _, r := range []meshcatalog.Registration{{V: 1, Module: "importer", Origin: "novox/mesh-catalog", Path: "modules/importer", Branches: []string{"main"}},
"modules/plain/go.mod": "module plain\n\nrequire golang.org/x/sys v0.1.0\n", "modules/plain/go.sum": "golang.org/x/sys v0.1.0 h1:x=\n"},
paths: map[string]map[string]string{"": {"modules/lib-a": "a1", "modules/lib-b": "b1"}}}
registrations := []meshcatalog.Registration{{V: 1, Module: "importer", Origin: "novox/mesh-catalog", Path: "modules/importer", Branches: []string{"main"}},
{V: 1, Module: "plain", Origin: "novox/mesh-catalog", Path: "modules/plain", Branches: []string{"main"}},
{V: 1, Module: "mesh-sdk", Origin: "novox/mesh-sdk", Path: ".", Branches: []string{"main", "beta"}}} {
{V: 1, Module: "mesh-sdk", Origin: "novox/mesh-sdk", Path: ".", Branches: []string{"main", "beta"}}}
// §802: 34 more modules of the catalogue, 36 with importer and plain: the libraries, their importers and 30 others.
goMods := map[string]string{"lib-a": "module " + catalogModule + "lib-a\n", "lib-b": "module " + catalogModule + "lib-b\n",
"app-a": "module app-a\n\nrequire " + catalogModule + "lib-a v0.0.0-00010101000000-000000000000\n",
"app-b": "module app-b\n\nrequire " + catalogModule + "lib-b v0.0.0-00010101000000-000000000000\n\nreplace " + catalogModule + "lib-b => ../lib-b\n"}
for i := range 30 {
goMods[fmt.Sprintf("m%02d", i)] = fmt.Sprintf("module m%02d\n\nrequire golang.org/x/sys v0.1.0\n", i)
}
for module, goMod := range goMods {
dir := "modules/" + module
catalogue.trees[dir] = "t-" + module
catalogue.files[dir+"/module.json"], catalogue.files[dir+"/go.mod"], catalogue.files[dir+"/go.sum"] = named(module), goMod, "golang.org/x/sys v0.1.0 h1:x=\n"
registrations = append(registrations, meshcatalog.Registration{V: 1, Module: module, Origin: "novox/mesh-catalog", Path: dir, Branches: []string{"main"}})
}
forge.put(catalogMerge, catalogue)
tests := catalogue
tests.trees = maps.Clone(catalogue.trees)
tests.trees["modules/lib-a"], tests.trees["modules/lib-b"] = "t-lib-a-2", "t-lib-b-2"
tests.paths = map[string]map[string]string{"": {"modules/lib-a": "a2", "modules/lib-b": "b2"}}
forge.put(catalogTests, tests)
regs := registerAvahi(t, ctx, js, "main")
for _, r := range registrations {
raw, _ := json.Marshal(r)
if _, err := regs.Put(ctx, index.RegistrationKey(r.Module), raw); err != nil {
t.Fatal(err)
@@ -207,6 +237,18 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) {
return v != nil && err == nil && pub.Commit == m2 && len(pub.Packages) == 3
})
// §802: a commit of the catalogue changing a test file of lib-a and one of lib-b moves those two and their importers alone.
heard.acked(t, "main")
say(12, false, meshdelivery.SourceMovedEventHeadsItem{Repository: "novox/mesh-catalog", Commit: catalogTests})
movers = nil
for _, e := range heard.next(t, "main", 12).Entries {
movers = append(movers, e.Module)
}
slices.Sort(movers)
if !slices.Equal(movers, []string{"app-a", "app-b", "lib-a", "lib-b"}) {
t.Errorf("the catalogue's commit changing lib-a's and lib-b's tests moves %v of its 36 modules, want lib-a, lib-b and their importers alone", movers)
}
// A branch's take-in moving mesh-sdk to m3 is a dry run: its packages stay in dry-runs while it runs, the trunk's are
// untouched, and its keys go once it answered (§804).
heard.acked(t, "main")