Tool runner: hear an adopted seat event by its key's prefixes, say an unheard key once

The mesh-catalog seat definition publishes catalog-revision on
mesh.seat.mesh-catalog.event.catalog-revision.<branch>, so the bus key is
mesh-catalog.catalog-revision.<branch>; the exact-key lookup missed and the event
was dropped silently. Look up the key and its shorter prefixes (as mesh-sdk's
views.adoptedHears does) and say an event no view hears once per key.

Builds: design 47 G (catalog half's revision events)

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
2026-11-14 04:26:14 +01:00
parent 7a6174bb3e
commit 30027347e9
2 changed files with 54 additions and 14 deletions
@@ -156,10 +156,14 @@ func TestTheRunnerHoldsTheFourStatesFromTheOwnersFirstViewsAndTheirEvents(t *tes
o.catalog, o.modules = 4, []string{"web", "db", fixtureHolder}
o.mu.Unlock()
ev, _ := json.Marshal(catalogseat.CatalogRevisionEvent{V: 1, Branch: "main", Kind: meshcatalogclient.KindTrunk, Revision: 4})
if err := o.deliver(bus.Envelope{Key: catalogseat.Seat + "." + catalogseat.EventCatalogRevision, Body: ev}); err != nil {
if err := o.deliver(bus.Envelope{Key: catalogseat.Seat + "." + catalogseat.EventCatalogRevision + ".main", Body: ev}); err != nil {
t.Fatal(err)
}
eventually(t, "the catalog-revision was not taken", func() bool { m, err := v.Modules(); return err == nil && len(m) == 3 })
// An event no view hears is said once per key, not dropped silently.
for i := 0; i < 2; i++ {
_ = o.deliver(bus.Envelope{Key: "some-seat.unknown-event.x", Body: json.RawMessage(`"x"`)})
}
// And the halves by branch, with their revision, which mesh_wait names checking an emitter (design 34 every-event §14).
if h, err := v.Halves(); err != nil || h["main"].Revision.Revision != 4 || len(h["main"].Entries) != 3 {
t.Errorf("the halves: %+v, %v", h, err)
@@ -207,6 +211,9 @@ func TestTheRunnerHoldsTheFourStatesFromTheOwnersFirstViewsAndTheirEvents(t *tes
}
lmu.Lock()
defer lmu.Unlock()
if n := strings.Count(strings.Join(logs, "\n"), "heard by no view"); n != 1 {
t.Errorf("an unheard event was said %d times, want once: %v", n, logs)
}
if !strings.Contains(strings.Join(logs, "\n"), "a gap in") {
t.Errorf("the gap was not said in the log: %v", logs)
}