From b636ccdf7fd294e947acbe2973752468d0869679 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 18:51:59 +0100 Subject: [PATCH] A3b entries-released: each catalog revision taken in releases the entries read by fingerprint Builds: design 47 H2 H-A-682 (2) --- .../cmd/mesh-delivery-assigner/halves.go | 7 +++++ .../mesh-delivery-assigner/halvesnone_test.go | 30 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/halves.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/halves.go index e7ed8cc32..3363b0b7f 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/halves.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/halves.go @@ -54,6 +54,13 @@ func (h *halves) follow() error { h.changed(branch, module, entry, deleted) } b.Adopted = h.adopted + // An entry read by fingerprint is kept until the next catalog revision taken in (design 47 H2 H-A-682 (2)): each revision + // held releases them, and a want at an older fingerprint asks its entry again. + b.Held = func(string, meshcatalog.CatalogRevision) { + for _, r := range b.Entries.Rows() { + b.Entries.Release(r.Fingerprint) + } + } // The one handler of registration-changed is the follower's (H-A-270 (3)): the pipeline ends are told each change from it, // never from a second handler on the hub. reconcile := b.Registrations.Follower.Changed diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/halvesnone_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/halvesnone_test.go index 35d7fedf4..02331e0c4 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/halvesnone_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/halvesnone_test.go @@ -105,3 +105,33 @@ func TestAModulesWatchedBranchesAreItsRegistrations(t *testing.T) { }) } } + +// H-A-682 (2): the entries read by fingerprint are kept until the next catalog revision the assigner takes in, and each revision +// held releases them. +func TestACatalogRevisionTakenInReleasesTheEntriesKept(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + defer cancel() + call := func(key string, _ any) (json.RawMessage, error) { + if key == mcc.EntryVerb { + return json.Marshal(seat.EntryAnswer{Entry: seat.CatalogEntry{Module: "m", Needs: []string{"x"}}}) + } + return nil, errors.New("not answered here") + } + reader := &views.ProcessReader{Module: "mesh-delivery-assigner", Call: call, Logf: t.Logf} + h := &halves{w: newWorld(), call: call, reader: reader, wake: func() {}, logf: t.Logf, ctx: ctx} + if err := h.follow(); err != nil { + t.Fatal(err) + } + answered := make(chan struct{}, 1) + h.branches.Entries.Changed = func(mcc.EntryRow) { answered <- struct{}{} } + h.branches.Entries.Need(ctx, "src2:old") + select { + case <-answered: + case <-ctx.Done(): + t.Fatal("the entry is never answered") + } + h.branches.Held("main", seat.CatalogRevision{Branch: "main", Revision: 2}) + if rows := h.branches.Entries.Rows(); len(rows) != 0 { + t.Errorf("a catalog revision taken in leaves the entries kept: %+v", rows) + } +}