From 727e7fe90fb3a7d5d976d6eb0e2234e59ec0b6f0 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 27 Nov 2026 04:26:00 +0100 Subject: [PATCH] N1 fix r3: the keeper's patterns leave out what its views reader adopts; the row follows the catalog half before the reader starts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Builds: design 47 H2b ยง836 5. (H-A-876) --- modules/nats/cmd/nats-tools/keep.go | 9 +++------ .../cmd/nats-tools/keeper_integration_test.go | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/modules/nats/cmd/nats-tools/keep.go b/modules/nats/cmd/nats-tools/keep.go index 501737481..88d5643fb 100644 --- a/modules/nats/cmd/nats-tools/keep.go +++ b/modules/nats/cmd/nats-tools/keep.go @@ -412,15 +412,12 @@ func hearer(js jetstream.JetStream, a process.Account, hub *process.EventHub, ta } } -// consumedPatterns are the subjects of the events the keeper's module consumes (its manifest's `consumes`, one pattern each, from -// the contracts' subjects) and the operator channel's decided for its own asks; which of them a kept stream carries is the hub's -// to find, never listed here. +// consumedPatterns are the subjects of the events the keeper's module consumes that its views reader does not adopt (it registers +// catalog-revision, registration-changed and source-moved on the hub itself): the seat list's two, findings-asked and the operator +// channel's decided for its own asks, each from the contracts' subjects. Which a kept stream carries is the hub's to find. var consumedPatterns = []string{ - catalog.SubjectCatalogRevisionAll[:len(catalog.SubjectCatalogRevisionAll)-1] + ">", - catalog.SubjectRegistrationChanged, catalog.SubjectSeatDefinitionChanged, catalog.SubjectSeatDefinitionRemoved, - seatdef.EventSubject(sourcebranches.Seat, sourcebranches.EventSourceMoved) + ".>", meshconditions.SubjectFindingsAsked, DecidedSubject, } diff --git a/modules/nats/cmd/nats-tools/keeper_integration_test.go b/modules/nats/cmd/nats-tools/keeper_integration_test.go index a394620e8..799cb3ab8 100644 --- a/modules/nats/cmd/nats-tools/keeper_integration_test.go +++ b/modules/nats/cmd/nats-tools/keeper_integration_test.go @@ -9,6 +9,7 @@ import ( "encoding/json" "errors" "fmt" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "maps" "os" "slices" @@ -848,13 +849,17 @@ func TestTheBusModuleRunsWhole(t *testing.T) { defer kstop() // A kept stream the keeper consumes none of (a version-released) gets it no durable and is no finding. if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: "SEAT_mesh-catalog_version-released", - Sources: []*jetstream.StreamSource{{Name: "EVENTS", FilterSubject: "mesh.seat.mesh-catalog.event.version-released.>"}}}); err != nil { + Sources: []*jetstream.StreamSource{{Name: "EVENTS", FilterSubject: "mesh.seat.mesh-catalog.event.version-released"}}}); err != nil { t.Fatal(err) } // The keeper's views reader is given the hub and raises `events-unheard` from it, through the writer. hub := testHub(t, account) hub.OnUnheard(func(l []process.Unheard) { cmu.Lock(); told = append(told, l); cmu.Unlock() }) reader := &views.ProcessReader{Module: keeper.Module, Logf: t.Logf, Hub: hub, Findings: func() views.WireWriter { return writer }} + // As followCatalog does: the catalog half is followed (its events adopted) before the reader starts on the hub. + if _, err := meshcatalogclient.FollowBranchesProcess(reader, pconn.Call); err != nil { + t.Fatal(err) + } reader.Start(kctx, js, account, nil) hear := hearer(js, account, hub, nil, t.Logf) if err := hear(kctx, func(subject string, _ []byte) error { cmu.Lock(); got = append(got, subject); cmu.Unlock(); return nil }); err != nil { @@ -875,10 +880,16 @@ func TestTheBusModuleRunsWhole(t *testing.T) { if _, err := js.Publish(ctx, "mesh.seat.mesh-delivery.event.source-moved.main", []byte(`{}`)); err != nil { t.Fatal(err) } - eventually(t, "the source-moved at the keeper's handler", func() bool { + // The adopted source-moved goes to the keeper's views reader through the hub, on the durable just bound. + eventually(t, "the source-moved delivered on the bound durable", func() bool { + cons, err := js.Consumer(ctx, stream, account.QueueConsumerName()) + if err != nil { + return false + } + info, err := cons.Info(ctx) cmu.Lock() defer cmu.Unlock() - return slices.Contains(got, "mesh.seat.mesh-delivery.event.source-moved.main") && + return err == nil && info.Delivered.Consumer >= 1 && !slices.ContainsFunc(told[len(told)-1], func(u process.Unheard) bool { return u.Stream == stream }) }) eventually(t, "the finding events-unheard cleared", func() bool { _, err := findings.Get(ctx, findingKey); return errors.Is(err, jetstream.ErrKeyNotFound) })