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]
+5 -42
View File
@@ -141,7 +141,7 @@ type bed struct {
func newBed(t *testing.T) *bed {
b := &bed{t: t, wants: newFeed(), comps: newFeed(), haves: &haves{}}
b.env = Env{Node: node, Wants: b.wants, Composed: b.comps, Haves: b.haves,
b.env = Env{Node: node, SelfComposed: true, Wants: b.wants, Composed: b.comps, Haves: b.haves,
Apply: func(_ context.Context, c compositions.Composed, others []compositions.Composed) Result {
if b.during != nil {
b.during()
@@ -260,10 +260,10 @@ func encodedAs(t *testing.T, c compositions.Composed, key string) (string, []byt
return key, raw, digest
}
func wantFor(t *testing.T, module, fp, digest, backup string) (string, []byte) {
func wantFor(t *testing.T, module, fp, _, backup string) (string, []byte) {
t.Helper()
key := meshwants.WantsByWantNodeModuleKey(node, module)
raw, err := bucketstest.Want(meshwants.WantsByWantNodeModuleValue{Fp: fp, Composed: digest, Backup: backup})
raw, err := bucketstest.Want(meshwants.WantsByWantNodeModuleValue{Fp: fp, Backup: backup})
if err != nil {
t.Fatal(err)
}
@@ -317,17 +317,6 @@ func TestAWantAndItsCompositionApplyTheModuleAndTheHaveNamesBoth(t *testing.T) {
return slices.Equal(b.settled, []string{"web"}) && b.settledRan[0]
})
// A want naming a digest the composition at that fingerprint does not have: nothing is applied.
fp2 := fpOf("b")
ck2, craw2, _ := composition(t, "web", fp2, false, file("web", "x", "2"))
b.comps.put(ck2, craw2)
wk2, wraw2 := wantFor(t, "web", fp2, "sha256:"+strings.Repeat("0", 64), "")
b.wants.put(wk2, wraw2)
time.Sleep(100 * time.Millisecond)
if got := b.appliedList(); len(got) != 1 {
t.Fatalf("a want naming another digest applied the composition: %v", got)
}
// Design 47 H section 750: a want names a version, never a part's digest, so the node-engine reads no digests of a want:
// a composition fetching archives is applied, and no have is held for a difference between a want and its digests.
d1, d2 := "sha256:"+strings.Repeat("1", 64), "sha256:"+strings.Repeat("2", 64)
@@ -1035,8 +1024,8 @@ func TestTheOrderTheChangedWantsAreAppliedIn(t *testing.T) {
if m.runs != "" {
b.runs[m.name] = fpOf(m.runs)
}
ck, craw, dig := composition(t, m.name, fp, false, file(m.name, "x", "1"))
raw, err := bucketstest.Want(meshwants.WantsByWantNodeModuleValue{Fp: fp, Composed: dig, Pipeline: m.pipeline, Rank: m.rank})
ck, craw, _ := composition(t, m.name, fp, false, file(m.name, "x", "1"))
raw, err := bucketstest.Want(meshwants.WantsByWantNodeModuleValue{Fp: fp, Pipeline: m.pipeline, Rank: m.rank})
if err != nil {
t.Fatal(err)
}
@@ -1520,32 +1509,6 @@ func TestACompositionWhoseResourcesWereRemovedIsAppliedAgain(t *testing.T) {
}
}
// The composition a want names is applied from the key's history when a newer one has replaced it under the same key:
// a want held at a fingerprint keeps naming the digest it was written with, and the controller writes every new
// composition at that fingerprint over the same key (ADR 0539 clause 1, the sweep's kept revisions; issue 1945, live on
// 2026-10-25: shanks' node-tools composition had digest 575a5c96, its held want named a36e63c8, and nothing was applied).
func TestTheRevisionAWantNamesIsAppliedFromHistory(t *testing.T) {
b := newBed(t)
fp := fpOf("a")
ck, oldRaw, oldDig := composition(t, "node-tools", fp, false, file("node-tools", "x", "old"))
_, newRaw, _ := composition(t, "node-tools", fp, false, file("node-tools", "x", "new"))
b.comps.before(ck, newRaw) // the key's latest value
wk, wraw := wantFor(t, "node-tools", fp, oldDig, "")
b.wants.before(wk, wraw)
b.env.Revisions = func(_ context.Context, key string) ([]Update, error) {
if key != ck {
return nil, nil
}
return []Update{{Key: ck, Value: oldRaw, Revision: 3}, {Key: ck, Value: newRaw, Revision: 7}}, nil
}
stop := b.run()
defer stop()
eventually(t, "the revision the want names was not applied", func() bool { return len(b.appliedList()) == 1 })
if h := b.haves.last("node-tools"); h.Composed != oldDig {
t.Fatalf("the have names %s, want %s", h.Composed, oldDig)
}
}
// 1945/AC18 and issue 924 (unit): what runs of a module the agent has not taken yet carries the filled paths the
// filling judges by. From the kept declaration while the module has no have naming a composition ("not named as filled"
// for claude-code and screen-lock, 2026-10-25); from the composition its have names once it has one, the kept
+1 -1
View File
@@ -179,7 +179,7 @@ func (a *Agent) Composition(ctx context.Context, module, digest string, diff boo
fp := ""
if w.Present {
fp = w.Want.Fp
view.Want = &WantView{FP: w.Want.Fp, Composed: w.Want.Composed, Yes: w.Want.Yes, Removed: w.Want.Removed,
view.Want = &WantView{FP: w.Want.Fp, Composed: w.Composed, Yes: w.Want.Yes, Removed: w.Want.Removed,
Self: w.Want.Self, Backup: w.Want.Backup, Words: w.Want.Words, Revision: w.Rev}
} else if have != nil {
fp = have.FP
+1 -1
View File
@@ -218,7 +218,7 @@ func (a *Agent) keptStep(ctx context.Context, module string, w wantNow, comp com
if !ranBefore || r == nil || r.FormChanges == nil || w.Want.Backup == meshwants.WantsByWantNodeModuleValueBackupSkip {
return false, nil
}
fp, dig := w.Want.Fp, w.Want.Composed
fp, dig := w.Want.Fp, w.Composed
a.mu.Lock()
prev, runs := a.running[module]
a.mu.Unlock()
+2 -2
View File
@@ -253,8 +253,8 @@ func testAMoveAcrossAFormChange(t *testing.T) {
t.Fatalf("the have %+v", h)
}
before := len(b.appliedList())
_, _, dig2 := composition(t, "db", fpOf("b"), true, file("db", "x", "2"))
raw, err := bucketstest.Want(meshwants.WantsByWantNodeModuleValue{Fp: fpOf("b"), Composed: dig2, Revert: meshwants.WantsByWantNodeModuleValueRevertLive,
_, _, _ = composition(t, "db", fpOf("b"), true, file("db", "x", "2"))
raw, err := bucketstest.Want(meshwants.WantsByWantNodeModuleValue{Fp: fpOf("b"), Revert: meshwants.WantsByWantNodeModuleValueRevertLive,
Words: "the operator answered \"live\" to the revert ask (asking 1)"})
if err != nil {
t.Fatal(err)
+1 -1
View File
@@ -55,7 +55,7 @@ func (a *Agent) changedLocked(module string) bool {
return runs && r.Phase != nodeengineclient.PhaseRemoved
}
if module == NodeModule {
return !runs || r.Composed != w.Want.Composed || r.Phase == nodeengineclient.PhaseFailed
return !runs || r.Composed != w.Composed || r.Phase == nodeengineclient.PhaseFailed
}
return !(runs && r.Fp == w.Want.Fp && r.Phase != nodeengineclient.PhaseRemoved && r.Phase != nodeengineclient.PhaseFailed)
}