diff --git a/modules/nats/cmd/nats-tools/keep.go b/modules/nats/cmd/nats-tools/keep.go index 09d7bd408..f1a529cf5 100644 --- a/modules/nats/cmd/nats-tools/keep.go +++ b/modules/nats/cmd/nats-tools/keep.go @@ -21,8 +21,9 @@ import ( "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient" occ "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient" oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel" + catalog "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog" stdio "git.novox.be/novox/mesh-sdk/go" - "git.novox.be/novox/mesh-sdk/go/delivery" + "git.novox.be/novox/mesh-sdk/go/catalogue" "git.novox.be/novox/mesh-sdk/go/process" "git.novox.be/novox/mesh-sdk/go/seatdef" @@ -36,24 +37,28 @@ import ( // each verdict asks for, and acts on the persons' requests its tools put in its own state requests (requests.go) as they // are written or answered. It serves nothing (ADR 0436 §3). -// AcceptedOf reads a manifest-accepted body: mesh-sdk's delivery.ManifestAccepted, with the indexer's revision of the -// verdict when the event carries it (a field mesh-sdk is asked to add; 0 until then). +// AcceptedOf reads a manifest-accepted body: the seat mesh-catalog's typed event, with the indexer's revision of the +// verdict when the event carries it (0 from an indexer that does not say it). func AcceptedOf(body []byte) (keeper.Accepted, error) { - var a struct { - delivery.ManifestAccepted - Revision uint64 `json:"revision"` - } + var a catalog.ManifestAcceptedEvent if err := json.Unmarshal(body, &a); err != nil { return keeper.Accepted{}, err } if a.Module == "" { return keeper.Accepted{}, fmt.Errorf("a manifest-accepted names no module") } - return keeper.Accepted{Module: a.Module, Digest: a.Digest, Revision: a.Revision, BusState: a.BusState}, nil + var state []catalogue.BusStateEntry // the seat types an entry as the manifest wrote it; the keeper reads the catalogue's form + if raw, err := json.Marshal(a.BusState); err != nil || json.Unmarshal(raw, &state) != nil { + return keeper.Accepted{}, fmt.Errorf("the bus-state of the manifest-accepted of %s is not readable", a.Module) + } + if len(a.BusState) == 0 { + state = nil + } + return keeper.Accepted{Module: a.Module, Digest: a.Digest, Revision: uint64(max(a.Revision, 0)), BusState: state}, nil } // AcceptedSubject is the seat mesh-catalog's manifest-accepted on the shared events stream. -var AcceptedSubject = "mesh.seat.mesh-catalog.event." + delivery.ManifestAcceptedEvent +var AcceptedSubject = catalog.SubjectManifestAccepted // The router's records of asks, read under this module's own name (ADR 0259 §3), as the mail sender reads them. const asksBucket = "messenger_asks" @@ -324,7 +329,7 @@ func Keep(ctx context.Context, k *keeper.Keeper, hear func(context.Context, func wake(asked)() return nil } - if subject != AcceptedSubject && !strings.HasSuffix(subject, ".event."+delivery.ManifestAcceptedEvent) { + if subject != AcceptedSubject && !strings.HasSuffix(subject, ".event."+catalog.EventManifestAccepted) { return nil } a, err := AcceptedOf(body) diff --git a/modules/nats/go.mod b/modules/nats/go.mod index 951629f3f..5a01c69c4 100644 --- a/modules/nats/go.mod +++ b/modules/nats/go.mod @@ -3,6 +3,7 @@ module nats-tools go 1.26.0 require ( + git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel v0.0.0-00010101000000-000000000000 @@ -14,6 +15,7 @@ require ( ) require ( + git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog v0.0.0-00010101000000-000000000000 git.novox.be/novox/mesh-contracts/go v0.0.0-20261104174344-ae5266e77639 // indirect github.com/antithesishq/antithesis-sdk-go v0.8.0-default-no-op // indirect github.com/google/go-tpm v0.9.8 // indirect