diff --git a/modules/mesh-delivery-indexer/internal/index/takein_source.go b/modules/mesh-delivery-indexer/internal/index/takein_source.go index 115b121c..5543f6f8 100644 --- a/modules/mesh-delivery-indexer/internal/index/takein_source.go +++ b/modules/mesh-delivery-indexer/internal/index/takein_source.go @@ -26,7 +26,8 @@ func TakenID(branch string, source int64) string { // repository it moves, the trees at the named commit through the seat git (wholeAt) and the fingerprints of the modules // registered for it; its movers (moversOf) against the branch's newest catalog revision; one catalog revision of the branch, // ., carrying the movers and pinned for the take-in's pipeline when it has one (KeepBranchEntries); and -// take-in.taken once, with branch, source, revision, call and one entry per mover. A revision already kept under that name (a +// take-in.taken once, with branch, source, revision, call and one entry per mover; a branch's first revision (start) has no +// mover (§768). A revision already kept under that name (a // restart before the acknowledgement) is said again from its kept movers, recomputing nothing (H-A-92). The first watched // branch is taken in on the indexer's own view; another on its newest revision's, computed and kept only as that revision. // An error leaves the source-moved held: ErrOldForm never takes it in, ErrObjectsFull waits for room (§744), any other is the @@ -87,6 +88,9 @@ func (ix *Indexer) TakeInSource(ctx context.Context, e meshdelivery.SourceMovedE return taken, err } movers := moversOf(before, entries, moved) + if e.Start { + movers = nil // a branch's first revision moves nothing: its entries are the base later take-ins are held against (§768, H-A-19) + } if err := ix.KeepBranchEntries(ctx, e.Branch, e.Source, entries, movers); err != nil { return taken, err } diff --git a/modules/mesh-delivery-indexer/internal/index/takein_source_test.go b/modules/mesh-delivery-indexer/internal/index/takein_source_test.go index 6d0d4e24..82a260ba 100644 --- a/modules/mesh-delivery-indexer/internal/index/takein_source_test.go +++ b/modules/mesh-delivery-indexer/internal/index/takein_source_test.go @@ -92,3 +92,27 @@ func TestASourceRevisionIsTakenInAsOneRevision(t *testing.T) { t.Errorf("a source-moved with no call answered %v, want ErrOldForm", err) } } + +// Design 47 H §768, §743, H-A-19: a branch's first source revision (start true) is taken in with no mover, says take-in.taken +// with no entries and pins nothing; its entries are the base a later take-in's movers are judged against. +func TestAFirstSourceRevisionIsTakenInWithNoMover(t *testing.T) { + ctx := context.Background() + ix, objects, _, f := takeInIndexer(t) + start := meshdelivery.SourceMovedEvent{V: 1, Branch: "main", Source: 1, Call: "seed.operator.20261120", Start: true, + Heads: []meshdelivery.SourceMovedEventHeadsItem{{Repository: f.Repository, Commit: f.Merge}}} + taken, err := ix.TakeInSource(ctx, start) + if err != nil || len(taken.Entries) != 0 || taken.Revision != 1 { + t.Fatalf("the first revision said %+v (%v), want revision 1 with no entries", taken, err) + } + if keys, _ := ix.Pins.Keys(ctx); len(keys) != 0 { + t.Errorf("the first revision pinned %v", keys) + } + if _, entries, err := ReadRevision(ctx, objects, "main.1"); err != nil || len(entries) != 1 || entries[0].Commit != f.Merge { + t.Fatalf("main.1 holds %+v (%v), want avahi at the head", entries, err) + } + next := start + next.Source, next.Call, next.Start = 2, "0123456789abcdef", false + if again, err := ix.TakeInSource(ctx, next); err != nil || len(again.Entries) != 0 { + t.Errorf("a later take-in of the same head said %+v (%v), want no mover against the first revision", again, err) + } +}