I6 (4a): the indexer builds no candidate for a source-only check

A run member or mover named source.<owner>.<name> 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
This commit is contained in:
2026-11-22 02:07:36 +01:00
parent f838a6c34c
commit 6b0ccc5d27
2 changed files with 36 additions and 4 deletions
@@ -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.<owner>.<name>) 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.<owner>.<name>
// (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 {
@@ -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} {