Design 47 H1: registration-missing clears when no running pipeline waits on the registration

Review round 1. A pipeline that ended (failed, cancelled) with a mover
still waiting left the finding for ever. It is now judged at every
pipeline's end and in Waiting: cleared when the registration is held, or
when no running pipeline still has an unplaced mover of the module.

Builds: design 47 H H-A-262, H-A-265
This commit is contained in:
2026-11-21 13:18:41 +01:00
parent 93efda5db3
commit 3160bb1fb8
5 changed files with 80 additions and 12 deletions
@@ -162,6 +162,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
Fills: fills, Recovered: kvRecoveries{ctx, recovered}.Has, Holders: rv.Holders.Holders, Ended: hearer.EndedAtPlacing,
Findings: rv.Findings, Observer: cred.Module} // a mover waiting on its registration is registration-missing (H-A-262)
hearer.AskSteps = starter.AskSteps
hearer.RegistrationWaits = func() { starter.JudgeRegistrationMissing(store) } // at every end (H-A-265 (4))
// Every ask but a test run's is bounded until its holder's first word (H-A-235, H-A-238), its bounds keys of the state
// bounds.
askBound, err := askUnansweredBound(getenv)
@@ -6,12 +6,13 @@ import (
mcc "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient"
condseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions"
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
"git.novox.be/novox/mesh-sdk/go/keys"
)
// RegistrationMissingKind is the runner's finding of a mover that waits on its module's registration (design 47 H H-A-262,
// G A-327): scope module, id the module, raised while a mover of a running pipeline has no registration to place its steps
// from, cleared when the registration arrives.
// from, cleared when the registration arrives or no running pipeline still waits on it (H-A-265 (4)).
const RegistrationMissingKind = "registration-missing"
// registrationMissingID is the finding's id: the module, escaped as a key's name is.
@@ -37,8 +38,8 @@ func (s *Starter) registrationMissing(module, key string) {
}
}
// registrationArrived clears registration-missing of module when the findings hold it (H-A-262).
func (s *Starter) registrationArrived(module string) {
// registrationArrived clears registration-missing of module, saying why, when the findings hold it (H-A-262, H-A-265 (4)).
func (s *Starter) registrationArrived(module, why string) {
if s.Findings == nil {
return
}
@@ -47,19 +48,21 @@ func (s *Starter) registrationArrived(module string) {
if f.Scope != mcc.ScopeModule || f.ID != id || f.Kind != RegistrationMissingKind {
continue
}
if err := s.Findings.Clear(context.Background(), mcc.ScopeModule, id, RegistrationMissingKind, "the registration of "+module+" arrived"); err != nil {
if err := s.Findings.Clear(context.Background(), mcc.ScopeModule, id, RegistrationMissingKind, why); err != nil {
s.logf("the finding %s of %s is not cleared: %v", RegistrationMissingKind, module, err)
}
return
}
}
// registrationsArrived clears registration-missing of every module the registrations held now name (Waiting: the
// registrations' first view, or a restart that heard the registration before).
func (s *Starter) registrationsArrived() {
if s.Findings == nil || s.Registration == nil {
// JudgeRegistrationMissing clears registration-missing of every module the registrations held now name, and of every module
// no running pipeline still has an unplaced mover of (H-A-265 (4)): a pipeline that ended, failed (H-A-163) or cancelled,
// with the mover still waiting leaves no finding behind. It is judged at a pipeline's end and in Waiting.
func (s *Starter) JudgeRegistrationMissing(store Updater) {
if s.Findings == nil {
return
}
var modules []string
for _, f := range s.Findings.Held() {
if f.Scope != mcc.ScopeModule || f.Kind != RegistrationMissingKind {
continue
@@ -68,8 +71,41 @@ func (s *Starter) registrationsArrived() {
if err != nil {
module = f.ID
}
if _, ok := s.Registration(module); ok {
s.registrationArrived(module)
if s.Registration != nil {
if _, ok := s.Registration(module); ok {
s.registrationArrived(module, "the registration of "+module+" arrived")
continue
}
}
modules = append(modules, module)
}
if len(modules) == 0 || store == nil {
return
}
pkeys, err := allKeys(store)
if err != nil {
s.logf("the finding %s is not judged: the pipelines are not listed: %v", RegistrationMissingKind, err)
return
}
waiting := map[string]bool{}
for _, key := range pkeys {
p, _, err := store.Get(key)
if err != nil {
s.logf("the finding %s is not judged: the pipeline %s is not read: %v", RegistrationMissingKind, key, err)
return
}
if p.Outcome != seat.PipelineOutcomeRunning {
continue
}
for _, m := range modules {
if Moves(p, m) && !placed(p, m) {
waiting[m] = true
}
}
}
for _, m := range modules {
if !waiting[m] {
s.registrationArrived(m, "no running pipeline still waits on the registration of "+m)
}
}
}
@@ -672,7 +672,7 @@ func (s *Starter) Registered(store Updater, reg catalog.Registration, view func(
if reg.Module == "" {
return 0, nil
}
defer s.registrationArrived(reg.Module) // the finding of a mover that waited on it goes (H-A-262)
defer s.registrationArrived(reg.Module, "the registration of "+reg.Module+" arrived") // the finding of a mover that waited on it goes (H-A-262)
return s.placeWaiting(store, func(p seat.Pipeline) bool { return Moves(p, reg.Module) && !placed(p, reg.Module) },
func(module string) (catalog.Registration, bool) { return reg, module == reg.Module },
view, "the registration of "+reg.Module+", which arrived after the pipeline started")
@@ -686,7 +686,7 @@ func (s *Starter) Waiting(store Updater, branch string, view func(branch string)
if s.Registration == nil {
return 0, nil
}
defer s.registrationsArrived() // the finding of a mover whose registration is held now goes (H-A-262)
defer s.JudgeRegistrationMissing(store) // the finding of a mover registered now, or no longer waited on, goes (H-A-262, H-A-265 (4))
return s.placeWaiting(store, func(p seat.Pipeline) bool {
if branch != "" && p.Branch != branch {
return false
@@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
condseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions"
"slices"
"strings"
"testing"
@@ -316,6 +317,30 @@ func TestAPipelineStartedBeforeItsRegistrationIsPlacedWhenItArrives(t *testing.T
if _, ok := findings.held["module.contracts."+RegistrationMissingKind]; !ok {
t.Errorf("placing next.8 raised %v, want registration-missing of contracts", findings.held)
}
// H-A-265 (4): a pipeline that ends with the mover still waiting (failed, H-A-163) leaves no finding: judged at its end
// (the hearer's said) and in Waiting, it clears once no running pipeline has an unplaced mover of the module.
next8, rev8, _ := store.Get("next.8")
next8.Outcome = seat.PipelineOutcomeFailed
if _, err := store.Update("next.8", next8, rev8); err != nil {
t.Fatal(err)
}
h := &Hearer{Store: store.memStore, Say: func(string, any) error { return nil }, RegistrationWaits: func() { s.JudgeRegistrationMissing(store.memStore) }}
if err := h.said(next8, nil, true); err != nil {
t.Fatal(err)
}
if _, ok := findings.held["module.contracts."+RegistrationMissingKind]; ok {
t.Errorf("next.8 ended with contracts unplaced and no other pipeline waits on it, yet its registration-missing is held")
}
// Still waited on by a running pipeline, it stays at an end; the registrations held naming it clear it in Waiting.
findings.held["module.contracts."+RegistrationMissingKind] = condseat.Finding{Scope: "module", ID: "contracts", Kind: RegistrationMissingKind}
taken = catalog.TakeInTaken{Branch: "next", Source: 9, Entries: []catalog.TakeInEntry{{Module: "contracts", Commit: "c5", Fingerprint: "src2:ff"}}}
if n, err := s.TakenIn(taken, late); n != 1 || err != nil {
t.Fatalf("the take-in of contracts started %d (%v)", n, err)
}
s.JudgeRegistrationMissing(store.memStore)
if _, ok := findings.held["module.contracts."+RegistrationMissingKind]; !ok {
t.Errorf("next.9 still waits on contracts' registration, yet its registration-missing was cleared")
}
s.Registration = func(string) (catalog.Registration, bool) { return reg, true }
if _, err := s.Waiting(store.memStore, "", late); err != nil {
t.Fatal(err)
@@ -147,6 +147,9 @@ type Hearer struct {
Now func() time.Time
// Failures says a failed head as the finding pipeline-failed (§33); nil says none.
Failures *Failures
// RegistrationWaits judges, at every pipeline's end, the finding registration-missing of the modules no running pipeline
// still waits on (Starter.JudgeRegistrationMissing, H-A-265 (4)); nil judges none.
RegistrationWaits func()
// Ager ages the runner's own kept data at each step's end (§330); nil ages none.
Ager *Ager
// Fills says the stores' fill at each step's end (§366); nil says none.
@@ -466,6 +469,9 @@ func (h *Hearer) said(p seat.Pipeline, asked []int, ended bool) error {
}
if ended {
h.Failures.Ended(p)
if h.RegistrationWaits != nil {
h.RegistrationWaits()
}
err := h.say(seat.EventPipelineEnded, p, nil)
// Every end, a cancel's alike, places the next waiting (§748, H-A-53), said or not.
if h.Turn != nil {