diff --git a/go/delivery/verdicts.go b/go/delivery/verdicts.go index f54c0f3..0f73bfe 100644 --- a/go/delivery/verdicts.go +++ b/go/delivery/verdicts.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "slices" + "strconv" "strings" "time" @@ -235,10 +236,10 @@ func AcceptedOf(digest string, v ManifestVerdict, m catalogue.Manifest) Manifest // EventID is the event's id, one per manifest digest and judge, so the bus takes it once: // `manifest-accepted--`. The empty one of a module leaving the trunk carries no digest, so it is named by -// its module: `manifest-accepted-left--`. +// its module and the indexer's revision: `manifest-accepted-left--`, so two leaves are both kept. func (a ManifestAccepted) EventID() string { if a.Digest == "" { - return ManifestAcceptedEvent + "-left-" + a.Module + "-" + a.Judge + return ManifestAcceptedEvent + "-left-" + a.Module + "-" + strconv.FormatUint(a.Revision, 10) } return ManifestAcceptedEvent + "-" + a.Digest + "-" + a.Judge } diff --git a/go/delivery/verdicts_test.go b/go/delivery/verdicts_test.go index dc48d77..090af8a 100644 --- a/go/delivery/verdicts_test.go +++ b/go/delivery/verdicts_test.go @@ -103,10 +103,11 @@ func TestAManifestVerdictIsTheContractReadersTake(t *testing.T) { if id := heard.EventID(); id != "manifest-accepted-"+digest+"-src2:j" { t.Fatalf("the accepted event's id is %q", id) } - // The empty one of a module leaving the trunk has no digest: its id names the module, so two modules' differ. - if a, b := (ManifestAccepted{Module: "a", Judge: "j"}).EventID(), (ManifestAccepted{Module: "b", Judge: "j"}).EventID(); a == b || - a != "manifest-accepted-left-a-j" { - t.Fatalf("the ids of two modules leaving are %q and %q", a, b) + // The empty one of a module leaving the trunk has no digest: its id names the module and the revision, so two + // modules' differ, and so do two leaves of one module. + if a, b, again := (ManifestAccepted{Module: "a", Judge: "j", Revision: 7}).EventID(), (ManifestAccepted{Module: "b", Judge: "j", Revision: 7}).EventID(), + (ManifestAccepted{Module: "a", Judge: "j", Revision: 9}).EventID(); a == b || a == again || a != "manifest-accepted-left-a-7" { + t.Fatalf("the ids of modules leaving are %q, %q and %q", a, b, again) } // Both verdict events carry the indexer's revision (ADR 0622 ยง2), and one without it reads as revision 0. for _, ev := range []any{ManifestAccepted{Module: "m", Revision: 41}, ManifestRefused{Module: "m", Revision: 41}} {