E4b: keep the run a module was applied from in its have

The engine kept the applied run in its memory only, so a restarted engine
applied an older run's want again. The have, the record of what the engine
applied, carries the run (the node-engine seat's form 2): the engine reads
it from the have before it applies a want that carries one, a write that
names none keeps the last have's, and every have is written at the seat's
form.

Builds: design 47 H2 §813 (1); H-A-355, H-A-384 (2), H-A-388 (1)
This commit is contained in:
2026-11-22 00:19:47 +01:00
parent fea6836f9e
commit f4f5615bfb
6 changed files with 67 additions and 22 deletions
+2
View File
@@ -413,6 +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
h.Health = s.healthOf(module, f)
if h.Detail == "" {
h.Detail = s.wordsOf(module, h.Health)
+6 -5
View File
@@ -256,11 +256,12 @@ func TestAnAppliedModuleIsWrittenRunningAndAFailedOneFailed(t *testing.T) {
}
}
// 1132/AC5: a have equal to the bucket's value is not written; a different one is written over the last revision.
// 1132/AC5: a have equal to the bucket's value is not written; a different one is written over the last revision. Each
// is written at the seat's form (H-A-388).
func TestAHaveIsWrittenOnlyWhenItDiffers(t *testing.T) {
l := newHaveLink()
l.put(t, "n1.a", nodeengine.HaveByNodeModuleValue{V: sdkkeys.Version, Build: "b-1", Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK})
l.put(t, "n1.b", nodeengine.HaveByNodeModuleValue{V: sdkkeys.Version, Build: "b-0", Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK})
l.put(t, "n1.a", nodeengine.HaveByNodeModuleValue{V: sdkkeys.Version, Form: nodeengine.Form, Build: "b-1", Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK})
l.put(t, "n1.b", nodeengine.HaveByNodeModuleValue{V: sdkkeys.Version, Form: nodeengine.Form, Build: "b-0", Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK})
q, _ := aHaveQueue(l)
q.SayFacts(context.Background(), appliedModules())
if l.kv["n1.a"].rev != 1 {
@@ -711,8 +712,8 @@ func TestARefusedRemovalIsWrittenByTheNextPass(t *testing.T) {
// before: one of them the new declaration lacks is written removed, one that is not in the bucket is not created.
func TestARestartedNodeEngineWritesTheRemovalFromTheReportsBefore(t *testing.T) {
l := newHaveLink()
l.put(t, "n1.a", nodeengine.HaveByNodeModuleValue{V: sdkkeys.Version, Build: "b-1", Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK})
l.put(t, "n1.b", nodeengine.HaveByNodeModuleValue{V: sdkkeys.Version, Build: "b-2", Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK})
l.put(t, "n1.a", nodeengine.HaveByNodeModuleValue{V: sdkkeys.Version, Form: nodeengine.Form, Build: "b-1", Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK})
l.put(t, "n1.b", nodeengine.HaveByNodeModuleValue{V: sdkkeys.Version, Form: nodeengine.Form, Build: "b-2", Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK})
q, _ := aHaveQueue(l) // fresh: nothing written by this process
r := onlyA()
r.Before = []string{"a", "b", "c"}
+2
View File
@@ -649,4 +649,6 @@ type ModuleFact struct {
PullWait *nodeengine.PullWait
// Wait is the hold or wait the module has, with the ask-at and act of a recovery wait (nodeengine.HaveByNodeModuleValue.Wait, design 47 G §560).
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
}