H-A-458 (1): compare a want's run with the have's only within its branch

A pipeline's key is <branch>.<source>, so every pipeline of a branch has its
own key, and comparing the whole key found no applied run for a stale want of
an older pipeline of the same branch (main.175 after main.180): it was
applied. settleOne now compares the branches, each key without its last
part; a want of another branch still replaces whatever stands. Rows with real
keys: feat.10 applied, feat.9 refused and said, main.5 applied, the have
naming run 5 of main.5.

Review round 2, finding: the whole pipeline key compared instead of its branch.

Builds: design 47 H2 §813 (1); H-A-429 (1), H-A-458 (1)
This commit is contained in:
2026-11-22 03:13:15 +01:00
parent a9d41d44ec
commit 876bf45223
3 changed files with 22 additions and 11 deletions
+14 -4
View File
@@ -84,7 +84,7 @@ type Have struct {
Run string
// Pipeline is the pipeline of the want the module was applied from, its key <branch>.<source>, kept beside Run
// (H-A-429 (1), H-A-458 (1); nodeengine.HaveByNodeModuleValue.Pipeline): a want's run is compared with Run only when
// the want names the same pipeline. Kept and replaced together with Run.
// the want's pipeline is of the same branch (pipelineBranch). Kept and replaced together with Run.
Pipeline string
}
@@ -1536,8 +1536,9 @@ func (a *Agent) settleOne(ctx context.Context, module string) {
}
// Design 47 H2 §813 (1), H-A-384 (2): the run the module was applied from is its have's, never this engine's memory, so
// a restarted engine applies no older run again. Read only for a want that carries one, and compared only within the
// want's pipeline: a want of another pipeline is a placement the assigner made on purpose and replaces whatever stands
// (H-A-429 (1), H-A-458 (1)).
// want's branch: a want of another branch is a placement the assigner made on purpose and replaces whatever stands
// (H-A-429 (1), H-A-458 (1)). A pipeline's key is <branch>.<source>, so every pipeline of a branch has its own key and
// the branch is the key without its last part.
appliedRun := ""
if w.Want.Run != "" {
h, found, unread := a.readHave(ctx, module)
@@ -1548,7 +1549,7 @@ func (a *Agent) settleOne(ctx context.Context, module string) {
a.mu.Unlock()
return
}
if found && h.Pipeline == w.Want.Pipeline {
if found && pipelineBranch(h.Pipeline) == pipelineBranch(w.Want.Pipeline) {
appliedRun = h.Run
}
}
@@ -1903,6 +1904,15 @@ func (a *Agent) takenAtStart(module string, runs compositions.Composed) {
// pipeline (settleOne compares no runs of two, H-A-458 (1)): each is
// the composition run's pipeline sequence in decimal. A want or an apply without one is not ordered by run, nor is a run
// that is no decimal number.
// pipelineBranch is the branch of a pipeline's key <branch>.<source> (design 47 H1, the runner's key; H-A-458 (1)): the
// key without its last part. A key with no source part is its own branch.
func pipelineBranch(key string) string {
if i := strings.LastIndexByte(key, '.'); i >= 0 {
return key[:i]
}
return key
}
func runIsNewer(want, applied string) bool {
if want == "" || applied == "" {
return true
+6 -5
View File
@@ -394,12 +394,13 @@ func testAWantAndItsCompositionApplyTheModuleAndTheHaveNamesBoth(t *testing.T) {
if got := len(b.appliedList()) - before; got != 0 {
t.Errorf("a want of run 10 after a have of run 20: applied %d times, want none", got)
}
// H-A-429 (1), H-A-458 (1): a want's run is compared with the have's only within one pipeline: a lower run of another
// pipeline replaces what stands, and the have keeps that pipeline beside its run; a lower run of the same is refused.
// H-A-429 (1), H-A-458 (1): a want's run is compared with the have's only within one branch, a pipeline's key being
// <branch>.<source>: a lower run of another branch replaces what stands, and the have keeps its pipeline beside its
// run; a lower run of an older pipeline of the same branch is refused.
for _, row := range []struct {
fp, run, pipeline string
applied int
}{{"7", "10", "feat.mesh-host", 1}, {"8", "9", "feat.mesh-host", 0}} {
}{{"7", "10", "feat.10", 1}, {"8", "9", "feat.9", 0}, {"b", "5", "main.5", 1}} {
before := len(b.appliedList())
fpr := fpOf(row.fp)
ckr, crawr, digr := composition(t, "web", fpr, false, archive("a", d2))
@@ -412,8 +413,8 @@ func testAWantAndItsCompositionApplyTheModuleAndTheHaveNamesBoth(t *testing.T) {
t.Errorf("a want of run %s of pipeline %s: applied %d times, want %d", row.run, row.pipeline, got, row.applied)
}
}
if h := b.haves.last("web"); h.Run != "10" || h.Pipeline != "feat.mesh-host" {
t.Errorf("the have names run %q of pipeline %q, want run 10 of feat.mesh-host", h.Run, h.Pipeline)
if h := b.haves.last("web"); h.Run != "5" || h.Pipeline != "main.5" {
t.Errorf("the have names run %q of pipeline %q, want run 5 of main.5", h.Run, h.Pipeline)
}
b.mu.Lock()
said := strings.Join(b.said, "\n")
+2 -2
View File
@@ -772,10 +772,10 @@ func testAnAppliedModulesHaveNamesTheFingerprintAndTheDigestAndFollowsItsHealth(
fp := "src2:" + strings.Repeat("a", 64)
dig := "sha256:" + strings.Repeat("b", 64)
// H-A-458 (1): the run it was applied from is kept with the pipeline of its want.
q.NoteModule(context.Background(), ModuleFact{Module: "web", FP: fp, Composed: dig, Run: "12", Pipeline: "main.mesh-host"})
q.NoteModule(context.Background(), ModuleFact{Module: "web", FP: fp, Composed: dig, Run: "12", Pipeline: "main.12"})
h := l.have(t, "n1.web")
if h.Fp != fp || h.Composed != dig || h.Phase != nodeengineclient.PhaseRunning || h.Health != nodeengineclient.HealthUnknown ||
h.Run != "12" || h.Pipeline != "main.mesh-host" {
h.Run != "12" || h.Pipeline != "main.12" {
t.Fatalf("the have after the apply: %+v", h)
}
// Design 47, *What each step says*: running is said once, when the build is healthy and its manifest is known, on