N1 fix r3: the keeper's patterns leave out what its views reader adopts; the row follows the catalog half before the reader starts

Builds: design 47 H2b §836 5. (H-A-876)
This commit is contained in:
2026-11-27 04:26:00 +01:00
parent 0b8be7fff5
commit 727e7fe90f
2 changed files with 17 additions and 9 deletions
+3 -6
View File
@@ -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,
}
@@ -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) })