From 7d87dde0a41c91445e14c37af4b9fa8de0a72ed0 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 02:57:04 +0100 Subject: [PATCH] H-A-458 (1): compare a want's run with the have's only within its pipeline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A want of another pipeline is a placement the assigner made on purpose, so a lower run of it was refused against a run of another branch the engine had applied. The have now keeps the pipeline of the want it was applied from beside its run (the node-engine seat's form 4), settleOne compares the runs only when the pipelines are equal, and a want of another pipeline replaces whatever stands. Rows: a lower run of another pipeline is applied, a lower run of the same is refused and said; the have names both. Review round 1, finding: the applied run's branch. Builds: design 47 H2 §813 (1); H-A-429 (1), H-A-458 (1) --- cmd/mesh-host/nodeagent.go | 4 ++-- internal/agent/agent.go | 22 +++++++++++++++------- internal/agent/agent_test.go | 23 ++++++++++++++++++++++- internal/link/have.go | 4 ++-- internal/link/have_test.go | 6 ++++-- internal/link/messages.go | 3 +++ 6 files changed, 48 insertions(+), 14 deletions(-) diff --git a/cmd/mesh-host/nodeagent.go b/cmd/mesh-host/nodeagent.go index 7e6e8eb8..d28a669e 100644 --- a/cmd/mesh-host/nodeagent.go +++ b/cmd/mesh-host/nodeagent.go @@ -109,7 +109,7 @@ func (h sessionHaves) ReadErr(ctx context.Context, module string) (agent.Have, b return agent.Have{}, false, err } return agent.Have{Module: module, FP: got.Fp, Composed: got.Composed, Phase: string(got.Phase), Detail: got.Detail, - Sealed: got.SealedAt, Wait: got.Wait, Run: got.Run}, true, nil + Sealed: got.SealedAt, Wait: got.Wait, Run: got.Run, Pipeline: got.Pipeline}, true, nil } func (h sessionHaves) Write(ctx context.Context, x agent.Have) { @@ -126,7 +126,7 @@ func (h sessionHaves) Write(ctx context.Context, x agent.Have) { } h.session.NoteModule(ctx, link.ModuleFact{Module: x.Module, FP: x.FP, Composed: x.Composed, Phase: phase, Failed: phase == string(nodeengineclient.PhaseFailed), Detail: shorten(x.Detail), Judgement: x.Judgement, Waits: x.Waits, - BuildAlone: x.BuildAlone, Kept: x.Kept, Sealed: x.Sealed, PullWait: x.PullWait, Wait: x.Wait, Run: x.Run}) + BuildAlone: x.BuildAlone, Kept: x.Kept, Sealed: x.Sealed, PullWait: x.PullWait, Wait: x.Wait, Run: x.Run, Pipeline: x.Pipeline}) } func (h sessionHaves) Removed(ctx context.Context, module string) { diff --git a/internal/agent/agent.go b/internal/agent/agent.go index cf450d61..d78e0358 100644 --- a/internal/agent/agent.go +++ b/internal/agent/agent.go @@ -82,6 +82,10 @@ type Have struct { // H-A-384 (2), H-A-388; nodeengine.HaveByNodeModuleValue.Run): kept in the have, so a restarted engine applies no // older run again. A write that names none keeps the one the module's last have said (writeHave). Run string + // Pipeline is the pipeline of the want the module was applied from, its key ., 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. + Pipeline string } // Haves is the node's have bucket as the agent uses it. @@ -753,9 +757,10 @@ func (a *Agent) writeHave(ctx context.Context, h Have) { h.Sealed = last.Sealed } } - // The run the module was applied from stays in its have until an apply from another run (H-A-384 (2)). + // The run the module was applied from stays in its have until an apply from another run (H-A-384 (2)), with + // the pipeline it was of (H-A-458 (1)). if h.Run == "" { - h.Run = last.Run + h.Run, h.Pipeline = last.Run, last.Pipeline } } } @@ -1530,7 +1535,9 @@ func (a *Agent) settleOne(ctx context.Context, module string) { a.mu.Unlock() } // 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. + // 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)). appliedRun := "" if w.Want.Run != "" { h, found, unread := a.readHave(ctx, module) @@ -1541,7 +1548,7 @@ func (a *Agent) settleOne(ctx context.Context, module string) { a.mu.Unlock() return } - if found { + if found && h.Pipeline == w.Want.Pipeline { appliedRun = h.Run } } @@ -1872,7 +1879,7 @@ func (a *Agent) apply(ctx context.Context, module string, w wantNow, comp compNo delete(a.notComposed, module) // the apply says what it runs now a.running[module] = nodeengine.HaveByNodeModuleValue{Fp: fp, Composed: dig, Phase: nodeengineclient.PhaseRunning} a.applied[module] = comp - run := w.Want.Run + run, pipeline := w.Want.Run, w.Want.Pipeline a.mu.Unlock() if run != "" { a.env.Say(fmt.Sprintf("applied %s from run %s", what, run)) @@ -1881,7 +1888,7 @@ func (a *Agent) apply(ctx context.Context, module string, w wantNow, comp compNo if a.env.Settled != nil { a.env.Settled(module) } - a.writeHave(ctx, Have{Module: module, FP: fp, Composed: dig, Phase: string(nodeengineclient.PhaseRunning), Detail: res.Detail, Run: run}) + a.writeHave(ctx, Have{Module: module, FP: fp, Composed: dig, Phase: string(nodeengineclient.PhaseRunning), Detail: res.Detail, Run: run, Pipeline: pipeline}) a.catchUp(ctx, module, catchUps) } @@ -1892,7 +1899,8 @@ func (a *Agent) takenAtStart(module string, runs compositions.Composed) { } } -// runIsNewer says whether a want's run orders after the run a module was applied from (design 47 H2 §813 (1)): each is +// runIsNewer says whether a want's run orders after the run a module was applied from (design 47 H2 §813 (1)), both of one +// 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. func runIsNewer(want, applied string) bool { diff --git a/internal/agent/agent_test.go b/internal/agent/agent_test.go index d41804f6..d5a968b1 100644 --- a/internal/agent/agent_test.go +++ b/internal/agent/agent_test.go @@ -394,11 +394,32 @@ 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. + for _, row := range []struct { + fp, run, pipeline string + applied int + }{{"7", "10", "feat.mesh-host", 1}, {"8", "9", "feat.mesh-host", 0}} { + before := len(b.appliedList()) + fpr := fpOf(row.fp) + ckr, crawr, digr := composition(t, "web", fpr, false, archive("a", d2)) + b.comps.put(ckr, crawr) + wkr, _ := wantFor(t, "web", fpr, digr, "") + rawr, _ := bucketstest.Want(meshwants.WantsByWantNodeModuleValue{Fp: fpr, Run: row.run, Pipeline: row.pipeline}) + b.wants.put(wkr, rawr) + b.idle() + if got := len(b.appliedList()) - before; got != row.applied { + 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) + } b.mu.Lock() said := strings.Join(b.said, "\n") b.mu.Unlock() for _, want := range []string{"from run 7", "from run 8", "carries run 5, and the engine applied it from run 7", - "carries run 10, and the engine applied it from run 20"} { + "carries run 10, and the engine applied it from run 20", "carries run 9, and the engine applied it from run 10"} { if !strings.Contains(said, want) { t.Errorf("the journal does not say %q:\n%s", want, said) } diff --git a/internal/link/have.go b/internal/link/have.go index 63d28d87..c94c77a4 100644 --- a/internal/link/have.go +++ b/internal/link/have.go @@ -413,8 +413,8 @@ func (q *Session) writeHaves(ctx context.Context, bus Bus) { h.PullWait = f.PullWait } h.Wait = f.Wait - // The seat's form 2 carries the run the module was applied from (H-A-388). - h.Run, h.Form = f.Run, nodeengine.Form + // The seat's form 2 carries the run the module was applied from (H-A-388), form 4 the pipeline beside it (H-A-458 (1)). + h.Run, h.Pipeline, h.Form = f.Run, f.Pipeline, nodeengine.Form h.Health = s.healthOf(module, f) if h.Detail == "" { h.Detail = s.wordsOf(module, h.Health) diff --git a/internal/link/have_test.go b/internal/link/have_test.go index 5cea7449..d1fdc7c0 100644 --- a/internal/link/have_test.go +++ b/internal/link/have_test.go @@ -771,9 +771,11 @@ func testAnAppliedModulesHaveNamesTheFingerprintAndTheDigestAndFollowsItsHealth( q, _ := aHaveQueue(l) fp := "src2:" + strings.Repeat("a", 64) dig := "sha256:" + strings.Repeat("b", 64) - q.NoteModule(context.Background(), ModuleFact{Module: "web", FP: fp, Composed: dig}) + // 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"}) h := l.have(t, "n1.web") - if h.Fp != fp || h.Composed != dig || h.Phase != nodeengineclient.PhaseRunning || h.Health != nodeengineclient.HealthUnknown { + if h.Fp != fp || h.Composed != dig || h.Phase != nodeengineclient.PhaseRunning || h.Health != nodeengineclient.HealthUnknown || + h.Run != "12" || h.Pipeline != "main.mesh-host" { 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 diff --git a/internal/link/messages.go b/internal/link/messages.go index 9c2490a9..5f21990e 100644 --- a/internal/link/messages.go +++ b/internal/link/messages.go @@ -651,4 +651,7 @@ type ModuleFact struct { Wait *nodeengine.Wait // Run is the composition run the module was applied from (nodeengine.HaveByNodeModuleValue.Run, design 47 H2 §813 (1), H-A-388). Run string + // Pipeline is the pipeline of the want it was applied from, kept beside Run (nodeengine.HaveByNodeModuleValue.Pipeline, + // H-A-458 (1)). + Pipeline string }