From 6b0ccc5d27ce8e2d80ba5c217eff4c4dcc2fd1c4 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 02:07:36 +0100 Subject: [PATCH] I6 (4a): the indexer builds no candidate for a source-only check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A run member or mover named source.. is a source-only registration's check, which the runner runs as one step: StartRun builds it no candidate and keeps no run, and its pipeline-ended keeps none either. Builds: design 47 H2 §815; H-A-438, H-A-442 --- .../internal/index/runcandidates.go | 21 +++++++++++++++---- .../internal/index/runcandidates_test.go | 19 +++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/index/runcandidates.go b/modules/mesh-delivery-indexer/internal/index/runcandidates.go index 9353b42b1..74d365871 100644 --- a/modules/mesh-delivery-indexer/internal/index/runcandidates.go +++ b/modules/mesh-delivery-indexer/internal/index/runcandidates.go @@ -67,7 +67,9 @@ func (r Run) done() bool { } // StartRun takes a run on request in, as the runner said it started: its members are kept in the state runs and its -// candidate is written; a run every member of which has ended already (its ends heard first) is dropped instead. +// candidate is written; a run every member of which has ended already (its ends heard first) is dropped instead. A member +// that is a source-only registration (its module the key source..) gets no candidate: the runner runs its check +// as one step (design 47 H2 §815; H-A-442), so a run of such members alone keeps and writes nothing. func (ix *Indexer) StartRun(ctx context.Context, e meshpipelinerunner.RunStarted) error { group, err := RunGroup(e.Run) if err != nil { @@ -76,9 +78,13 @@ func (ix *Indexer) StartRun(ctx context.Context, e meshpipelinerunner.RunStarted if len(e.Members) == 0 { return fmt.Errorf("%w: the run %s names no member", ErrUnreadable, e.Run) } + members := slices.DeleteFunc(slices.Clone(e.Members), func(m meshpipelinerunner.Member) bool { return isSourceMember(m.Module) }) + if len(members) == 0 { + return nil // a source-only check: no candidate, no run kept + } ix.runMu.Lock() defer ix.runMu.Unlock() - r, err := ix.updateRun(ctx, group, func(r *Run) { r.Members = slices.Clone(e.Members) }) + r, err := ix.updateRun(ctx, group, func(r *Run) { r.Members = members }) if err != nil { return err } @@ -88,11 +94,18 @@ func (ix *Indexer) StartRun(ctx context.Context, e meshpipelinerunner.RunStarted return ix.writeRunCandidate(ctx, group, r.Members) } +// isSourceMember says a run's member or mover is a source-only registration, named by its key source.. +// (design 47 H2 §815; H-A-438). +func isSourceMember(module string) bool { + _, _, source := meshcatalog.ParseRegistrationsBySourceOwnerNameKey(module) + return source +} + // EndRunPipeline takes one pipeline-ended in: of a run's pipeline, its module is kept as ended, and once every member's has // ended the candidate and the run's key are removed. A pipeline of no run is none of this. func (ix *Indexer) EndRunPipeline(ctx context.Context, e meshpipelinerunner.PipelineEnded) error { - if e.Run == "" { - return nil + if e.Run == "" || !slices.ContainsFunc(e.Movers, func(m meshpipelinerunner.MoverEnded) bool { return !isSourceMember(m.Module) }) { + return nil // no run, or a source-only check's, which keeps no run (StartRun) } group, err := RunGroup(e.Run) if err != nil { diff --git a/modules/mesh-delivery-indexer/internal/index/runcandidates_test.go b/modules/mesh-delivery-indexer/internal/index/runcandidates_test.go index 3d4403852..553a8196d 100644 --- a/modules/mesh-delivery-indexer/internal/index/runcandidates_test.go +++ b/modules/mesh-delivery-indexer/internal/index/runcandidates_test.go @@ -114,6 +114,25 @@ func TestARunsCandidateIsBuiltOnItsStartAndDroppedWhenEveryMembersPipelineEnded( t.Errorf("candidates %v, want none", k) } }) + // Design 47 H2 §815 (H-A-438, H-A-442): a source-only check's member is its registration's key; the runner runs it as one + // step, so the indexer builds it no candidate and keeps no run, at its start or its end. + t.Run("a source-only check gets no candidate and no run", func(t *testing.T) { + ix, cands, runs, _ := bed(t) + source := started + source.Members = []meshpipelinerunner.Member{{Module: "source.novox.hq", Commit: c1}} + if err := ix.StartRun(ctx, source); err != nil { + t.Errorf("a source-only check's start: %v", err) + } + if err := ix.EndRunPipeline(ctx, ended("source.novox.hq")); err != nil { + t.Error(err) + } + if k, _ := cands.Keys(ctx); len(k) != 0 { + t.Errorf("candidates %v, want none", k) + } + if k, _ := runs.Keys(ctx); len(k) != 0 { + t.Errorf("runs %v, want none", k) + } + }) t.Run("a member's take-in starts from its own branch only when its registration watches it", func(t *testing.T) { reg := meshcatalog.Registration{Branches: []string{"main", "beta"}} for branch, want := range map[string]string{"beta": "beta", "main": TrunkBranch, "feature/1966-x": TrunkBranch, "": TrunkBranch} {