MH-2b: the node-engine reads the want by the real contract: composed, kept-on and newest go

A want carries no composed digest, no keeping node and no newest build (design 47 H 750,
H-A-37): the agent takes the digest from the composition the node made for the want's
build, the shadow's resolution around a missing entry (A-405) and KeptBuildOf's keeping node
go, and the artifact is fetched from the store. Tests of the removed behaviour go.

Builds: design 47 H §750; H-A-37

Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
2026-11-20 03:09:22 +01:00
parent ee017fe306
commit dd2b3a16df
14 changed files with 43 additions and 165 deletions
+20 -17
View File
@@ -303,10 +303,13 @@ type againAsk struct {
}
type wantNow struct {
Want meshwants.WantsByWantNodeModuleValue
Node bool // the node's own want
Present bool
Rev uint64
Want meshwants.WantsByWantNodeModuleValue
// Composed is the digest of the composition the node made for the want's build (the node's own want carries it): a want names a
// build and a version, never a digest (design 47 H §750).
Composed string
Node bool // the node's own want
Present bool
Rev uint64
}
type compNow struct {
@@ -804,7 +807,7 @@ func (a *Agent) takeWant(u Update) string {
a.sayOnce("want:node", fmt.Sprintf("the node's own want is not one: %v", err))
return ""
}
w.Present, w.Want = true, meshwants.WantsByWantNodeModuleValue{Fp: "", Composed: nw.Composed}
w.Present, w.Want, w.Composed = true, meshwants.WantsByWantNodeModuleValue{}, nw.Composed
}
a.wants[NodeModule] = w
return NodeModule
@@ -1450,25 +1453,25 @@ func (a *Agent) settleOne(ctx context.Context, module string) {
return // waits for the node's own composition of the want's build
}
// The composition the node composed for the want's build is the one it applies (ADR 0547 §2).
w.Want.Composed = comp.Dig
w.Composed = comp.Dig
if a.waitsForYes(ctx, module, w, comp) {
return
}
} else if (!have || comp.Err != nil || comp.Dig != w.Want.Composed) && w.Want.Composed != "" {
} else if (!have || comp.Err != nil || comp.Dig != w.Composed) && w.Composed != "" {
// The composition the want names may be an older revision of the key, replaced by a newer one at the same
// fingerprint (a want held there keeps its digest): taken from the revisions the bucket keeps (ADR 0539 clause 1).
if old, found := a.revisionNamed(ctx, module, w.Want.Fp, w.Want.Composed); found {
if old, found := a.revisionNamed(ctx, module, w.Want.Fp, w.Composed); found {
comp, have = old, true
}
}
if !have || comp.Err != nil {
return // waits for the composition; a change of its key settles the module again
}
if comp.Dig != w.Want.Composed {
if comp.Dig != w.Composed {
// A composition whose digest no want names is not applied.
a.mu.Lock()
a.sayOnce("digest:"+module, fmt.Sprintf("the composition of %s at %s has digest %s, and its want names %s; nothing is applied until they agree",
module, w.Want.Fp, comp.Dig, w.Want.Composed))
module, w.Want.Fp, comp.Dig, w.Composed))
a.mu.Unlock()
return
}
@@ -1485,10 +1488,10 @@ func (a *Agent) settleOne(ctx context.Context, module string) {
a.mu.Lock()
r, runs := a.running[module]
// A module whose last apply failed runs no composition whole, whatever it ran before (ranFailed).
runsWant := runs && r.Fp == w.Want.Fp && r.Composed == w.Want.Composed && r.Phase != nodeengineclient.PhaseRemoved &&
runsWant := runs && r.Fp == w.Want.Fp && r.Composed == w.Composed && r.Phase != nodeengineclient.PhaseRemoved &&
r.Phase != nodeengineclient.PhaseFailed
att, tried := a.attempt[module]
same := tried && att.FP == w.Want.Fp && att.Composed == w.Want.Composed
same := tried && att.FP == w.Want.Fp && att.Composed == w.Composed
if same && att.Held {
// Held for a failed backup: looked at before what runs, since a hold may name what the want names (its have kept
// the composition it held, nats on novox, 2026-11-04), and an answer in a later revision of the want would then
@@ -1592,7 +1595,7 @@ func (a *Agent) baseline(ctx context.Context, module string, w wantNow, comp com
a.sayOnce("held:"+module, fmt.Sprintf("%s is held for a failed backup (%s) at this start: it keeps what "+
"its have names, %s, and waits for the operator's answer; its want (revision %d) carries none",
module, h.Detail, short(h.Composed), w.Rev))
a.attempt[module] = attempt{FP: w.Want.Fp, Composed: w.Want.Composed, WantRev: w.Rev, CompRev: comp.Rev, Held: true,
a.attempt[module] = attempt{FP: w.Want.Fp, Composed: w.Composed, WantRev: w.Rev, CompRev: comp.Rev, Held: true,
AnsweredRev: w.Rev}
if h.Composed != "" {
a.running[module] = nodeengine.HaveByNodeModuleValue{Fp: h.FP, Composed: h.Composed, Phase: nodeengineclient.PhaseRunning}
@@ -1611,7 +1614,7 @@ func (a *Agent) baseline(ctx context.Context, module string, w wantNow, comp com
if marked {
h.Detail = ""
}
if h.FP == w.Want.Fp && h.Composed == w.Want.Composed &&
if h.FP == w.Want.Fp && h.Composed == w.Composed &&
(h.Phase == "" || h.Phase == string(nodeengineclient.PhaseRunning) || marked) {
if a.inactiveAtStart(ctx, module, comp) {
return false
@@ -1646,10 +1649,10 @@ func (a *Agent) baseline(ctx context.Context, module string, w wantNow, comp com
return false
}
a.mu.Lock()
a.running[module] = nodeengine.HaveByNodeModuleValue{Fp: w.Want.Fp, Composed: w.Want.Composed, Phase: nodeengineclient.PhaseRunning}
a.running[module] = nodeengine.HaveByNodeModuleValue{Fp: w.Want.Fp, Composed: w.Composed, Phase: nodeengineclient.PhaseRunning}
a.mu.Unlock()
a.runsChanged(module + " was taken from the kept declaration")
a.writeHave(ctx, Have{Module: module, FP: w.Want.Fp, Composed: w.Want.Composed, Phase: string(nodeengineclient.PhaseRunning)})
a.writeHave(ctx, Have{Module: module, FP: w.Want.Fp, Composed: w.Composed, Phase: string(nodeengineclient.PhaseRunning)})
return true
}
@@ -1668,7 +1671,7 @@ func (a *Agent) inactiveAtStart(ctx context.Context, module string, comp compNow
}
func (a *Agent) apply(ctx context.Context, module string, w wantNow, comp compNow, others []compositions.Composed) {
fp, dig := w.Want.Fp, w.Want.Composed
fp, dig := w.Want.Fp, w.Composed
a.mu.Lock()
_, ranBefore := a.running[module]
ranBefore = ranBefore || a.prior[module]