I4 fix: §805's whole criterion is a step of the indexer's whole packages test

Review round 1 found §805's whole criterion (a release of a module
importing twenty packages of its own pipeline keeps one re-pin revision)
unit-tested only. It becomes a step of
TestASourceRevisionMovingMeshSDKNamesItAndItsImporters, the indexer whole
against an embedded bus: twenty version-reserved of mesh-sdk in main's
revision are kept in heard, its pipeline-started keeps one re-pin revision
(importer its mover, pinned to the reserved version), and the next
pipeline's reservation keeps the revision after it. The bed's indexer
durable on EVENTS now takes version-reserved, as the manifest's consumes
name it. The step fails when pipeline-started does not settle the
gathering.

Builds: design 47 H2 §805; H-A-453 (3)
This commit is contained in:
2026-11-22 03:37:26 +01:00
parent dde4108504
commit 342da2c625
2 changed files with 71 additions and 5 deletions
@@ -31,6 +31,7 @@ import (
"git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
@@ -395,7 +396,7 @@ func startIndexerRun(t *testing.T, put func(context.Context, buildLog), before .
"mesh.seat.mesh-catalog.event.seat-definition-removed", "mesh.seat.mesh-catalog.event.manifest-accepted", "mesh.seat.mesh-catalog.event.version-released",
"mesh.seat.mesh-catalog.event.versions-filled",
"mesh.seat.mesh-conditions.event.>", "mesh.seat.operator-channel.event.>", "mesh.seat.go-package-registry.event.>", "mesh.seat.npm-package-registry.event.>",
"mesh.seat.mesh-module-assigner.event.>", "mesh.seat.node-build-go.event.>"}}); err != nil { // not the seats kept in streams of their own (wanted and running, above)
"mesh.seat.mesh-module-assigner.event.>", "mesh.seat.node-build-go.event.>", meshbuilds.SubjectVersionReserved}}); err != nil { // not the seats kept in streams of their own (wanted and running, above)
t.Fatal(err)
}
// The indexer's durable on the shared events stream (process.EventHub), which carries its own room (design 47 H §744, H-A-50).
@@ -798,8 +799,9 @@ func serveAssignerAssignments(t *testing.T, ctx context.Context, js jetstream.Je
t.Fatal(err)
}
if _, err := js.CreateOrUpdateConsumer(ctx, "EVENTS", jetstream.ConsumerConfig{Durable: "n1_mesh-delivery-indexer", AckPolicy: jetstream.AckExplicitPolicy,
// and the build seat's step-ended the manifest's consumes names (design 47 G §713: the end of a validation ask).
FilterSubjects: []string{"mesh.mod." + assignerHolderModule + ".event.views.>", meshcatalog.SubjectRoom, nodebuildgo.SubjectStepEndedAll}}); err != nil {
// and the build seat's step-ended the manifest's consumes names (design 47 G §713: the end of a validation ask), and the
// builder's version-reserved, which no stream of its own keeps (design 47 H2 §805).
FilterSubjects: []string{"mesh.mod." + assignerHolderModule + ".event.views.>", meshcatalog.SubjectRoom, nodebuildgo.SubjectStepEndedAll, meshbuilds.SubjectVersionReserved}}); err != nil {
t.Fatal(err)
}
em := views.Emitter{Owner: assignerHolderModule, Subject: process.Account{Node: "n1", Module: assignerHolderModule}.EventSubject,
@@ -19,6 +19,7 @@ import (
"github.com/nats-io/nats.go/jetstream"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo"
@@ -74,6 +75,11 @@ func untilModule(t *testing.T, ctx context.Context, js jetstream.JetStream, name
// 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.
//
// Design 47 H2 §805 (H-A-453 (3)): the builder's twenty version-reserved of mesh-sdk in that revision's pipeline (twenty
// artifacts of its Go package, as repin_test.go reads them) are kept in heard and gathered, and its pipeline-started keeps one
// re-pin revision of main, importer its mover pinned to the reserved version; the next pipeline's reservation keeps the
// revision after it, so none came between.
func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) {
const (
sdkGo = "git.novox.be/novox/mesh-sdk/go"
@@ -106,7 +112,7 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) {
"package.json": "3333333333333333333333333333333333333333", "package-lock.json": "4444444444444444444444444444444444444444",
"tsconfig.json": "5555555555555555555555555555555555555555"}}}
}
var packages, dryRuns jetstream.KeyValue
var packages, dryRuns, heardKV jetstream.KeyValue
var heard *takeIns
js, ctx, _, _ := startIndexer(t, func(context.Context, buildLog) {}, func(ctx context.Context, js jetstream.JetStream) {
var err error
@@ -133,6 +139,10 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) {
forge.put(m1, sdkAt(sdkRoot1, "f5", "6666666666666666666666666666666666666666"))
forge.put(m2, sdkAt(sdk2, "f6", "7777777777777777777777777777777777777777"))
forge.put(m3, sdkAt(sdk3, "f7", "8888888888888888888888888888888888888888"))
// The state heard, declared key-ttl, where a reservation is kept and its gathering held open (§805).
if heardKV, err = js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: index.Bucket(testIndexer, index.HeardState), History: 64, LimitMarkerTTL: time.Minute}); err != nil {
t.Fatal(err)
}
// A dry run's key left by an indexer that stopped mid-run (§804).
if dryRuns, err = js.KeyValue(ctx, index.Bucket(testIndexer, index.DryRunsState)); err != nil {
t.Fatal(err)
@@ -241,7 +251,8 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) {
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 {
taken = heard.next(t, "main", 12)
for _, e := range taken.Entries {
movers = append(movers, e.Module)
}
slices.Sort(movers)
@@ -249,6 +260,59 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) {
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)
}
// §805: twenty reservations of mesh-sdk's packages in main's revision of source 12, kept and gathered; its pipeline-started
// keeps one re-pin revision of main, and the next pipeline's reservation the one after it.
objects := newBusObjects(js, testAccount, index.CatalogRevisionsObjects)
untilRevision := func(n int64) meshcatalog.CatalogRevision {
t.Helper()
obs, err := js.ObjectStore(ctx, objects.bucket())
if err != nil {
t.Fatal(err)
}
wctx, cancel := context.WithTimeout(ctx, waitBound)
defer cancel()
w, err := obs.Watch(wctx)
if err != nil {
t.Fatal(err)
}
defer func() { _ = w.Stop() }()
name := index.BranchObject("main", n)
for range w.Updates() {
if rev, _, err := index.ReadRevision(ctx, objects, name); err == nil {
return rev
}
}
t.Fatalf("%s is not kept after %s", name, waitBound)
return meshcatalog.CatalogRevision{}
}
reserve := func(revision int64, version string, artifacts int) {
t.Helper()
for i := range artifacts {
raw, _ := json.Marshal(meshbuilds.VersionReservedEvent{Module: "mesh-sdk", Artifact: fmt.Sprintf("mesh-sdk:p%d", i), Path: sdkGo, Version: version,
Fingerprint: "f-" + version, Revision: index.BranchObject("main", revision)})
if _, err := js.Publish(ctx, meshbuilds.SubjectVersionReserved, raw); err != nil {
t.Fatal(err)
}
}
untilKey(t, ctx, heardKV, index.ReservedKey(index.BranchObject("main", revision), "mesh-sdk"), func(v []byte) bool {
var r index.Reserved
return v != nil && json.Unmarshal(v, &r) == nil && len(r.Reservations) == artifacts
})
}
r := taken.Revision
reserve(r, "0.1.28", 20)
sayPipeline(t, ctx, js, false, "main", r)
if rev := untilRevision(r + 1); rev.CallKind != meshcatalog.CatalogRevisionCallKindRelease || !strings.Contains(rev.Call, index.BranchObject("main", r)+"'s") ||
len(rev.Movers) != 1 || rev.Movers[0].Module != "importer" {
t.Errorf("main.%d = %+v, want one re-pin revision of the twenty reservations, importer its mover", r+1, rev)
}
untilModule(t, ctx, js, "importer", func(m meshcatalog.ModulesByModuleValue) bool { return m.Packages[sdkGo] == "v0.1.28" })
reserve(r+1, "0.1.29", 1)
sayPipeline(t, ctx, js, false, "main", r+1)
if rev := untilRevision(r + 2); !strings.Contains(rev.Call, index.BranchObject("main", r+1)+"'s") {
t.Errorf("main.%d = %+v, want the next pipeline's re-pin: the twenty reservations kept more than one revision", r+2, rev)
}
// 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")