assigner: at the put of a run that waited for a package its readers wait for a build node again (issue 1984, review round 1)

Once a run's wait for a package's publish ended and its run ask was put,
`waits` was deleted but its readers' newest wait-held still said they
waited for the package's publish, until ask-taken's wait-ended. Now the
start that deletes `waits` as it writes the run's program says its
readers' wait-held for a build node again, under their held id with
.put added, so the bus's duplicate window keeps it apart from the first;
the composition and the validate run alike.

Tests: TestTheCompositionStepRunsOneAskPerMachine, the wait's rows: after
the put each machine's newest wait-held is for a build node under its
held id with .put; TestTheValidateStepRefusesAManifestProblemAndACycle,
revision 14: the reader is said waiting for mesh-sdk's publish, then for
a build node again at the put. Both failed first without the say at the
put.

Builds: design 47 H2 H-A-632 (hq c7f31726, f9be4ef0); H-A-630 (5) (hq 1cdfa6ff); H-A-629 (1), (2) (hq 8aa70271)
This commit is contained in:
2026-11-23 23:19:56 +01:00
parent 5884f8ed7b
commit 773ba91222
5 changed files with 59 additions and 6 deletions
@@ -67,6 +67,18 @@ func waitOf(run meshwants.CompositionRun, reader meshwants.CompositionReader) me
// sayWaits says, for each reader, its wait held or ended (how: ran, superseded); a wait that cannot be said is journaled.
func (r *compositionRuns) sayWaits(run meshwants.CompositionRun, readers []meshwants.CompositionReader, how string) {
r.sayWaitsOf(run, readers, how, "")
}
// sayWaitsAtPut says, at the put of the run ask of a run whose wait for a package's publish ended, its readers' wait-held for a
// build node again, under their held id with .put added, so the bus's duplicate window does not take it for the first one's
// (design 47 H2 H-A-632).
func (r *compositionRuns) sayWaitsAtPut(run meshwants.CompositionRun) {
r.sayWaitsOf(run, run.Readers, "", ".put")
}
// sayWaitsOf is sayWaits, each held id with after added.
func (r *compositionRuns) sayWaitsOf(run meshwants.CompositionRun, readers []meshwants.CompositionReader, how, after string) {
if r.say == nil {
return
}
@@ -76,6 +88,7 @@ func (r *compositionRuns) sayWaits(run meshwants.CompositionRun, readers []meshw
if run.Waits != nil && how == "" { // a wait-held of its own, so the bus's duplicate window does not take it for the first one's
id += "." + run.Waits.Package
}
id += after
if how != "" {
w.How, event, id = how, meshwants.EventWaitEnded, strings.TrimSuffix(id, ".held")+".ended"
}
@@ -326,18 +326,24 @@ func (r *compositionRun) start(ctx context.Context, key string, run meshwants.Co
end(node + ": " + err.Error())
return
}
if _, _, err := r.runs.change(key, func(c *meshwants.CompositionRun) bool {
waited := false
written, _, err := r.runs.change(key, func(c *meshwants.CompositionRun) bool {
waited = false
if c.Ask != ask || c.Ended != nil {
return false
}
c.Program = &meshwants.CompositionRunProgram{Repository: program.Repository, Commit: program.Commit, Directory: program.Dir, Fingerprint: engineFp}
c.Input = digest
c.Waits = nil // its wait ends as its run ask is put (H-A-629 (1))
waited, c.Waits = c.Waits != nil, nil // its wait ends as its run ask is put (H-A-629 (1))
return true
}); err != nil {
})
if err != nil {
end(node + ": the run's program and input are not written: " + err.Error())
return
}
if waited { // its readers wait for a build node again, no longer for the package's publish (H-A-632)
r.runs.sayWaitsAtPut(written)
}
a := buildstep.StepAsk{ID: ask, Kind: buildstep.AskCheck, Language: buildstep.AskGo, Asker: runAsker, At: r.now().UTC(),
Run: &buildstep.RunJob{Program: program, Heads: []buildstep.RunHead{}, Input: ref, Reader: "the composition of " + node + " by the node-engine at " + program.Commit},
Packages: pins} // the composer is built against its entry's pins, each empty one filled (H-A-203, H-A-192, H-A-628 (2))
@@ -323,9 +323,15 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) {
u.mu.Unlock()
return put(ctx, a)
}
lastHeld := map[string]string{} // by machine: what its newest wait-held waits on, and its id
u.runs.say = func(event string, body any, id string) error {
w := body.(meshwants.Wait)
journal.logf("said %s on %s: %s (%s)", event, w.On, w.Words, id)
if event == meshwants.EventWaitHeld {
u.mu.Lock()
lastHeld[w.Node] = w.On + " (" + id + ")"
u.mu.Unlock()
}
return nil
}
phase := &stepPhase{}
@@ -452,6 +458,15 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) {
t.Errorf("after the publish %s's composer is built against %v, want x/go at v0.1.9", node, a.Packages)
}
}
// H-A-632: at the put each reader's newest wait-held is for a build node again, under its held id with .put added.
for _, node := range []string{"ace", "g14"} {
u.mu.Lock()
got := lastHeld[node]
u.mu.Unlock()
if !strings.HasPrefix(got, waitOnBuildNode+" (") || !strings.HasSuffix(got, ".held.put)") {
t.Errorf("%s: after the put the newest wait-held of %s waits on %s, want a build node under its held id with .put", how, node, got)
}
}
for _, key := range keys {
if got := atPut[key]; got != "waits <nil>, bound " {
t.Errorf("as the run ask of %s was put its wait stood: %s; want waits and the bound gone (§720: an ask in the queue has no clock)", key, got)
@@ -327,18 +327,24 @@ func (r *compositionRun) startValidate(ctx context.Context, key string, run mesh
couldNot(err.Error())
return
}
if _, _, err := r.runs.change(key, func(c *meshwants.CompositionRun) bool {
waited := false
written, _, err := r.runs.change(key, func(c *meshwants.CompositionRun) bool {
waited = false
if c.Ask != ask || c.Ended != nil {
return false
}
c.Program = &meshwants.CompositionRunProgram{Repository: program.Repository, Commit: program.Commit, Directory: program.Dir, Fingerprint: entry.Fp}
c.Input = digest
c.Waits = nil // its wait ends as its run ask is put (H-A-629 (1))
waited, c.Waits = c.Waits != nil, nil // its wait ends as its run ask is put (H-A-629 (1))
return true
}); err != nil {
})
if err != nil {
couldNot("the run's program and input are not written: " + err.Error())
return
}
if waited { // its readers wait for a build node again, no longer for the package's publish (H-A-632)
r.runs.sayWaitsAtPut(written)
}
a := buildstep.StepAsk{ID: ask, Kind: buildstep.AskCheck, Language: buildstep.AskGo, Asker: runAsker, At: r.now().UTC(),
Run: &buildstep.RunJob{Program: program, Heads: []buildstep.RunHead{}, Input: ref, Reader: "the manifest validator of " + step.Pipeline + " at " + program.Commit},
Packages: pins} // the validator is built against its entry's pins at the step's revision, each empty one filled (H-A-203, H-A-192, H-A-205, H-A-628 (2))
@@ -119,6 +119,15 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) {
var requests []composer.Request
keeper := testKeeper(&objectsMem{objs: map[string][]byte{}}, time.Now)
runs := newCompositionRuns(newRunsMem(), defaultRunSettings, time.Now, t.Logf)
var held []string // the wait-helds of the reader ask-left said, what each waits on and its id (H-A-630 (5), H-A-632)
runs.say = func(event string, body any, id string) error {
if w := body.(meshwants.Wait); event == meshwants.EventWaitHeld && strings.Contains(id, ".ask-left.") {
mu.Lock()
held = append(held, w.On+" ("+id+")")
mu.Unlock()
}
return nil
}
r := &compositionRun{runs: runs, keeper: keeper, reads: &compositionReads{}, call: call, callFile: callFile, own: context.Background(), now: time.Now, logf: t.Logf,
put: func(_ context.Context, a buildstep.StepAsk) error {
body, err := keeper.body(a.Run.Input.Digest)
@@ -271,4 +280,8 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) {
if run.Ended == nil || run.Outcome != meshwants.CompositionRunOutcomePassed || len(asks) != 5 || asks[4].Packages["git.novox.be/novox/mesh-sdk/go"] != "v0.1.36" {
t.Errorf("the validate run its starting step left ended %v %s %q with %d validator asks, want it put after the publish and passed", run.Ended, run.Outcome, run.Said, len(asks))
}
if len(held) < 2 || !strings.HasPrefix(held[len(held)-2], waitOnPublish+"git.novox.be/novox/mesh-sdk/go (") ||
!strings.HasPrefix(held[len(held)-1], waitOnBuildNode+" (") || !strings.HasSuffix(held[len(held)-1], ".held.put)") {
t.Errorf("the validate run's reader was said waiting %v; want mesh-sdk's publish, then a build node again at the put (H-A-632)", held)
}
}