A3b entries-released: each catalog revision taken in releases the entries read by fingerprint

Builds: design 47 H2 H-A-682 (2)
This commit is contained in:
2026-11-25 18:51:59 +01:00
parent 18e5be507d
commit b636ccdf7f
2 changed files with 37 additions and 0 deletions
@@ -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
@@ -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)
}
}