CAT-N3: the events' body in the field names of the seat mesh-broker's message said

module, local-name, storage-type, template, options, configuration, bus-name,
asked, held, fill, snapshot and why as the seat's definition in mesh-contracts
names them, so taking its generated type changes no byte; binding (a ledger's
several names) and revision (the indexer's, of the verdict acted on) beside,
asked of the definition.

Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
This commit is contained in:
2026-11-04 12:34:59 +01:00
parent 3e019c5d7e
commit cdddeee4ea
2 changed files with 38 additions and 15 deletions
+31 -15
View File
@@ -41,22 +41,37 @@ const (
EventDropped = "dropped"
)
// Event is the body of every bus module event: the entry, its binding (the names on the bus), the settings asked and
// held by bus object, why (refused, drifted), and the indexer's revision of the verdict it acted on.
// Event is the body of every bus module event, in the field names of the seat mesh-broker's definition (its message
// `said`, mesh-contracts go/seats/meshbroker Said): the entry (module, local name, storage type, template, options,
// configuration), its bus name, the settings asked and held by bus object, its fill, the snapshot a recreate or drop
// took, and why (refused, drifted). Beside the definition's fields: binding, the names a module receives (a ledger's
// history, state, indexes and snapshot, which one bus name cannot carry), and revision, the indexer's revision of the
// verdict it acted on; both asked of the definition.
//
// Written here until mesh-contracts holds the generated type of the seat mesh-broker's definition (ADR 0613 §1); the
// field names are that definition's.
// Written here until this module takes mesh-contracts' generated type; the swap changes no byte of the body.
type Event struct {
V int `json:"v"`
Module string `json:"module"`
Local string `json:"local"`
Storage string `json:"storage"`
Template string `json:"template,omitempty"`
Binding membership.BusBinding `json:"binding"`
Asked map[string]Settings `json:"asked,omitempty"`
Held map[string]Settings `json:"held,omitempty"`
Why string `json:"why,omitempty"`
Revision uint64 `json:"revision"`
V int `json:"v"`
Module string `json:"module"`
Local string `json:"local-name"`
Storage string `json:"storage-type,omitempty"`
Template string `json:"template,omitempty"`
Options map[string]json.RawMessage `json:"options,omitempty"`
Configuration map[string]json.RawMessage `json:"configuration,omitempty"`
BusName string `json:"bus-name"`
Binding membership.BusBinding `json:"binding"`
Asked map[string]Settings `json:"asked,omitempty"`
Held map[string]Settings `json:"held,omitempty"`
Fill *EventFill `json:"fill,omitempty"`
Snapshot string `json:"snapshot,omitempty"`
Why string `json:"why,omitempty"`
Revision uint64 `json:"revision"`
}
// EventFill is an entry's fill as an event says it: its messages, its bytes and its cap.
type EventFill struct {
Count uint64 `json:"count"`
Bytes uint64 `json:"bytes"`
Cap int64 `json:"cap"`
}
// Accepted is a manifest-accepted the keeper heard, or a module of its first view: the module, its manifest's digest,
@@ -538,7 +553,8 @@ func (k *Keeper) emit(event string, p Plan, revision uint64, why string, asked,
if k.Emit == nil {
return
}
body := Event{V: 1, Module: p.Module, Local: p.Local, Storage: p.Storage, Template: p.Template, Binding: p.Binding,
body := Event{V: 1, Module: p.Module, Local: p.Local, Storage: p.Storage, Template: p.Template, Options: p.Entry.Options,
Configuration: p.Entry.Configuration, BusName: BusName(p.Module, p.Local), Binding: p.Binding,
Asked: asked, Held: held, Why: why, Revision: revision}
if event == EventDropped {
// A dropped entry's names only: the binding to remove.
@@ -291,6 +291,13 @@ func TestTheKeeperMakesWhatAVerdictAsksForAndSaysIt(t *testing.T) {
if b := out.bodies[1]; b.Binding.Stream != "m_log" || b.Binding.Subject != "mesh.bus.m.log" || b.Revision != 3 || b.Asked["m_log"].MaxBytes == 0 {
t.Errorf("created carries %+v: the binding, the revision and the settings asked", b)
}
// In the field names of the seat mesh-broker's message said (mesh-contracts), beside binding and revision.
raw, _ := json.Marshal(out.bodies[1])
for _, w := range []string{`"module":"m"`, `"local-name":"log"`, `"storage-type":"stream"`, `"template":"log"`, `"bus-name":"m_log"`, `"binding":{`, `"revision":3`} {
if !strings.Contains(string(raw), w) {
t.Errorf("the body %s lacks %s", raw, w)
}
}
}},
{"a replay not newer is not applied", func(t *testing.T, k *Keeper, bus *fakeBus, out *said) {
k.Heard(Accepted{Module: "m", Digest: "d2", Revision: 9, BusState: []catalogue.BusStateEntry{drafts}})