From ea25a8389d612b8e1ed500b88d9c8578edb176f8 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 02:31:13 +0100 Subject: [PATCH 1/9] MH-2: a want is read by its version alone; the parts check and parts-differ go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The node-engine no longer reads a want's parts: the parts check (G 524) and its hold parts-differ are removed, the digests of a build are resolved through the registry seats from the want's version, and a candidate's added module is resolved from its version alone. Builds: design 47 H §750, §764; H-A-37, H-A-38 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- internal/agent/agent.go | 18 ---- internal/agent/agent_test.go | 93 ++++-------------- internal/agent/parts.go | 117 +---------------------- internal/selfcompose/kept.go | 8 +- internal/selfcompose/kept_test.go | 10 +- internal/selfcompose/selfcompose.go | 7 +- internal/selfcompose/selfcompose_test.go | 25 ++++- internal/selfcompose/shadow.go | 6 +- internal/selfcompose/versions.go | 6 +- internal/selfcompose/versions_test.go | 9 +- 10 files changed, 63 insertions(+), 236 deletions(-) diff --git a/internal/agent/agent.go b/internal/agent/agent.go index 2ae0a6d9..8daf0517 100644 --- a/internal/agent/agent.go +++ b/internal/agent/agent.go @@ -1633,24 +1633,6 @@ func (a *Agent) apply(ctx context.Context, module string, w wantNow, comp compNo ranBefore = ranBefore || a.prior[module] a.mu.Unlock() - // A want with parts is applied only when they and the digests its composition fetches agree (design 47 G §524): the - // module keeps running what it has, and the have says which digest differs. - if words := partsDifference(w.Want.Parts, comp.C.Resources, comp.C.Templates); words != "" { - a.mu.Lock() - prev, runs := a.running[module] - a.attempt[module] = attempt{FP: fp, Composed: dig, WantRev: w.Rev, CompRev: comp.Rev, Held: true, AnsweredRev: w.Rev} - a.mu.Unlock() - if !runs { - if h, found, _ := a.readHave(ctx, module); found { - prev = nodeengine.HaveByNodeModuleValue{Fp: h.FP, Composed: h.Composed} - } - } - a.env.Say(fmt.Sprintf("%s is held: %s", module, words)) - a.writeHave(ctx, Have{Module: module, FP: prev.Fp, Composed: prev.Composed, Phase: string(nodeengineclient.PhaseHeld), - Detail: words, Wait: a.composeWait(strings.TrimSuffix(PartsDiffer, ":"), words)}) - return - } - // A kept data on the bus whose form changes is taken as a restore point first, or restored at a revert (design 47 G §296, §297). held, catchUps := a.keptStep(ctx, module, w, comp, ranBefore, others) if held { diff --git a/internal/agent/agent_test.go b/internal/agent/agent_test.go index fdc8c93b..3a9de1cc 100644 --- a/internal/agent/agent_test.go +++ b/internal/agent/agent_test.go @@ -323,86 +323,26 @@ func TestAWantAndItsCompositionApplyTheModuleAndTheHaveNamesBoth(t *testing.T) { t.Fatalf("a want naming another digest applied the composition: %v", got) } - // Design 47 G section 524: a want with parts is applied only when its parts and the digests the composition fetches - // agree; a want with no parts is applied as before. - d1, d2, d3 := "sha256:"+strings.Repeat("1", 64), "sha256:"+strings.Repeat("2", 64), "sha256:"+strings.Repeat("3", 64) + // 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) archive := func(id, digest string) json.RawMessage { raw, _ := json.Marshal(map[string]any{"id": "web." + id, "type": "archive", "path": "/tmp/r6/web/" + id, "source": "https://store/" + id, "digest": digest, "module": "web"}) return raw } - for i, row := range []struct { - name string - parts map[string]string - applies bool - detail string - }{ - {"agree", map[string]string{"web:a": d1, "web:b": d2}, true, ""}, - {"no parts", nil, true, ""}, - {"fetched outside", map[string]string{"web:a": d1}, false, PartsDiffer + " fetched and not in the want's parts: " + d2}, - {"part not fetched", map[string]string{"web:a": d1, "web:b": d2, "web:c": d3}, false, - PartsDiffer + " in the want's parts and not fetched: " + d3}, - } { - before := len(b.appliedList()) - fpn := fpOf(string("5678"[i])) - ckn, crawn, dign := composition(t, "web", fpn, false, archive("a", d1), archive("b", d2)) - b.comps.put(ckn, crawn) - wkn := meshwants.WantsByWantNodeModuleKey(node, "web") - wrawn, err := bucketstest.Want(meshwants.WantsByWantNodeModuleValue{Fp: fpn, Composed: dign, Parts: row.parts}) - if err != nil { - t.Fatal(err) - } - b.wants.put(wkn, wrawn) - b.idle() - if got := len(b.appliedList()) - before; (got == 1) != row.applies { - t.Fatalf("parts %q: applied %d times, want applies=%v", row.name, got, row.applies) - } - if h := b.haves.last("web"); !row.applies && (h.Phase != string(nodeengineclient.PhaseHeld) || h.Detail != row.detail || - h.Wait == nil || h.Wait.Step != nodeengine.WaitStepCompose || h.Wait.Reason != "parts-differ" || h.Wait.Words != row.detail) { - t.Fatalf("parts %q: the have is %s %q wait %+v, want held %q waiting on parts-differ (A-453)", row.name, h.Phase, h.Detail, h.Wait, row.detail) - } + before := len(b.appliedList()) + fpn := fpOf("5") + ckn, crawn, dign := composition(t, "web", fpn, false, archive("a", d1), archive("b", d2)) + b.comps.put(ckn, crawn) + wkn, wrawn := wantFor(t, "web", fpn, dign, "") + b.wants.put(wkn, wrawn) + b.idle() + if got := len(b.appliedList()) - before; got != 1 { + t.Fatalf("a want and a composition fetching archives: applied %d times, want 1", got) } - // A container's digest is the one after its image's @. - container := json.RawMessage(`{"id":"web.c","type":"container","name":"web-c","image":"store/web@` + d3 + `","image-seat":"mesh-artifact-store","image-holder":"n1","module":"web"}`) - if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container}, nil); got != "" { - t.Fatalf("a container whose digest is in the parts differs: %q", got) - } - // A-454: an image the manifest pins from outside, by its digest, is no part of the want's parts, and a mesh-built one still is. - upstream := json.RawMessage(`{"id":"web.u","type":"container","name":"web-u","image":"registry@` + d2 + `","module":"web"}`) - if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container, upstream}, nil); got != "" { - t.Fatalf("an upstream image pinned by its digest is a part: %q", got) - } - // And neither is the registry seat's copy of an upstream image, though it is routed through the seat. - mirrored := json.RawMessage(`{"id":"web.m","type":"container","name":"web-m","image":"store:5000/upstream/docker.io/library/registry@` + d1 + `","image-seat":"container-image-registry","image-holder":"n1","module":"web"}`) - if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container, mirrored}, nil); got != "" { - t.Fatalf("an upstream copy served through the registry seat is a part: %q", got) - } - if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{upstream}, nil); !strings.Contains(got, "in the want's parts and not fetched: "+d3) || strings.Contains(got, d2) { - t.Fatalf("with only an upstream image the mesh-built one is not missing, or the upstream one is named: %q", got) - } - // A-454a: a mesh-built image whose seat holder is not on record carries no image-seat; its digest is in the parts, so it is fetched. - noSeat := json.RawMessage(`{"id":"web.n","type":"container","name":"web-n","image":"store/web@` + d3 + `","module":"web"}`) - if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{noSeat}, nil); got != "" { - t.Fatalf("a mesh-built image with no image-seat, named by the parts, is not fetched: %q", got) - } - if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{noSeat, upstream}, nil); got != "" { - t.Fatalf("an upstream image beside it is a part: %q", got) - } - // A-481: a templates archive the composition was rendered from is fetched, one the want's parts do not name is a part - // the composition lacks, and the want's digest nothing read stays not fetched. - if got := partsDifference(map[string]string{"web:c": d3, "web:files": d1}, []json.RawMessage{container}, []string{d1}); got != "" { - t.Fatalf("a templates archive named by the parts and rendered from is fetched: %q", got) - } - if got := partsDifference(map[string]string{"web:c": d3, "web:files": d1}, []json.RawMessage{container}, nil); !strings.Contains(got, "in the want's parts and not fetched: "+d1) { - t.Fatalf("a templates archive nothing read stays not fetched: %q", got) - } - if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container}, []string{d1}); !strings.Contains(got, "fetched and not in the want's parts: "+d1) { - t.Fatalf("a templates archive outside the parts differs: %q", got) - } - // A-432: a runtime of its own runs the tool runner's program, which the module's parts do not name. - ownRuntime := json.RawMessage(`{"id":"web.own-runtime","type":"process","name":"web-runtime","source":"store/node-tools","digest":"` + d1 + `","run":["./node-tools"],"module":"web"}`) - if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container, ownRuntime}, nil); got != "" { - t.Fatalf("a runtime of its own differs from the module's parts: %q", got) + if h := b.haves.last("web"); h.Phase != string(nodeengineclient.PhaseRunning) || h.Wait != nil || h.FP != fpn { + t.Fatalf("the have is %s %q wait %+v, want running at %s with no wait (§750)", h.Phase, h.Detail, h.Wait, fpn) } } @@ -870,15 +810,14 @@ func TestADataModuleIsBackedUpFirstAndHeldWhenItFails(t *testing.T) { {"restic: the repository is locked", meshwants.WantsByWantNodeModuleValueBackupAgain, 1, 1, nodeengineclient.PhaseRunning, false, ""}, {"restic: the repository is locked", meshwants.WantsByWantNodeModuleValueBackupSkip, 0, 1, nodeengineclient.PhaseRunning, false, ""}, {"restic: the repository is locked", "", 0, 0, nodeengineclient.PhaseHeld, false, ""}, - // A hold the node-engine judges again (novox's indexer, 2026-11-16): its parts differed or its entry was not + // A hold the node-engine judges again (novox's indexer, 2026-11-16): its entry was not // held, which no answer of the operator's releases; at a start it is judged again, here backed up and applied. - {PartsDiffer + " fetched and not in the want's parts: sha256:a03131c6", "", 1, 1, nodeengineclient.PhaseRunning, false, "parts-differ"}, {EntryMissing + " the catalog half holds no entry of the build", "", 1, 1, nodeengineclient.PhaseRunning, false, "entry-missing"}, // g14's feh, 2026-11-18: the kept step's hold opens "whether ..." and says its reason in its wait; the words decide nothing. {"whether feh's kept data changes form is not known", "", 1, 1, nodeengineclient.PhaseRunning, false, "entry-missing"}, {EntryAsked + " the entry is asked", "", 1, 1, nodeengineclient.PhaseRunning, false, "entry-asked"}, // Opening words alone are no reason: a failed backup's detail that opens with them waits for the answer. - {PartsDiffer + " as the words of a failed backup", "", 0, 0, nodeengineclient.PhaseHeld, false, ""}, + {"parts-differ: as the words of a failed backup", "", 0, 0, nodeengineclient.PhaseHeld, false, ""}, // A restore point not taken waits for the answer, its reason being its words. {"the restore point of db's data was not taken", "", 0, 0, nodeengineclient.PhaseHeld, false, "the restore point of db's data was not taken"}, } { diff --git a/internal/agent/parts.go b/internal/agent/parts.go index 19e47efb..07f7785b 100644 --- a/internal/agent/parts.go +++ b/internal/agent/parts.go @@ -1,19 +1,6 @@ package agent -import ( - "encoding/json" - "fmt" - "sort" - "strings" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/containerimageregistryclient/reference" - "git.novox.be/novox/mesh-sdk/go/catalogue" - "git.novox.be/novox/mesh-sdk/go/declaration" -) - -// PartsDiffer is the start of the detail of a have held because a want's parts and the digests its composition fetches -// disagree (design 47 G section 524). -const PartsDiffer = "parts-differ:" +import "strings" // EntryAsked and EntryMissing open the detail of a have held for the entry the want names (design 47 G section 421 and // section 614): the entry is asked of the catalog half and not yet answered, or the half answered that it holds none. Both @@ -24,16 +11,14 @@ const ( ) // judgedAgain says a held have is a hold the node-engine judges again at a start, not one that waits for the operator's answer: -// its wait's reason (the structured field the have carries) is that its want's parts differ from its composition (§524) or its -// entry is not held (§421), whatever words its detail opens with. Only a failed backup or restore point waits for an answer (ADR -// 0568 §4); novox, 2026-11-16: the indexer held "parts-differ" was kept at a start as "held for a failed backup"; g14, 2026-11-18: -// feh held "whether ..." with the reason entry-missing was kept the same way. +// its wait's reason (the structured field the have carries) is that its entry is not held (§421), whatever words its detail +// opens with. Only a failed backup or restore point waits for an answer (ADR 0568 §4); g14, 2026-11-18: feh held "whether ..." with the reason entry-missing was kept the same way. func judgedAgain(h Have) bool { if h.Wait == nil { return false } switch h.Wait.Reason { - case strings.TrimSuffix(PartsDiffer, ":"), strings.TrimSuffix(EntryAsked, ":"), strings.TrimSuffix(EntryMissing, ":"): + case strings.TrimSuffix(EntryAsked, ":"), strings.TrimSuffix(EntryMissing, ":"): return true } return false @@ -51,97 +36,3 @@ func heldReason(why string) string { func heldForEntry(why string) bool { return strings.HasPrefix(why, EntryAsked) || strings.HasPrefix(why, EntryMissing) } - -// upstreamCopy is whether a routed image is the registry seat's copy of an upstream image, `
/upstream//@`: -// the mesh mirrors it, but it built nothing, so it is no part of a want (design 47 G A-454). -func upstreamCopy(image string) bool { - _, path, ok := strings.Cut(image, "/") - if !ok { - return false - } - _, _, upstream := reference.InUpstream(path) - return upstream -} - -// partsDifference checks a want's `parts` against the digests of the archive, process and container resources of the -// composition, which are the digests the apply fetches and checks (design 47 G section 524). A want with no `parts` (an -// assigner of before G, or a node whose record does not state `want-parts`) is applied as today: it returns "". With -// `parts`, the want is applied only when the digest of every resource fetched is among the values of `parts` and every -// value of `parts` is the digest of a resource fetched; otherwise it returns the detail naming each digest. -func partsDifference(parts map[string]string, resources []json.RawMessage, templates []string) string { - if len(parts) == 0 { - return "" - } - inParts := map[string]bool{} - for _, d := range parts { - inParts[d] = true - } - fetched := map[string]bool{} - // A templates archive the composition was rendered from was read from the artifact store and checked by its digest: - // a part fetched (design 47 G A-481, A-481a). - for _, d := range templates { - fetched[d] = true - } - for _, raw := range resources { - r, err := declaration.ParseResource(raw) - if err != nil { - continue - } - switch res := r.(type) { - case *declaration.Archive: - if res.Source != "" { - fetched[res.Digest] = true - } - case *declaration.Process: - // A runtime of its own runs the tool runner's program, which the tool runner's want checks (A-432). - if res.Source != "" && !strings.HasSuffix(res.ID, "."+catalogue.OwnRuntimeID()) { - fetched[res.Digest] = true - } - case *declaration.Container: - // A digest the want's parts name always counts as fetched, whatever marks the resource carries; one they do not - // name counts only when it is the mesh's own: an image the manifest pins from outside, or the registry seat's - // copy of an upstream image, is no part (design 47 G A-454, A-454a). - digest := "" - if strings.HasPrefix(res.Image, "sha256:") { - digest = res.Image - } else if _, d, ok := strings.Cut(res.Image, "@"); ok { - digest = d - } - if digest == "" { - continue - } - if !inParts[digest] && (res.ImageSeat == "" || upstreamCopy(res.Image)) { - continue - } - fetched[digest] = true - } - } - named := map[string]bool{} - for _, d := range parts { - named[d] = true - } - var outside, missing []string - for d := range fetched { - if !named[d] { - outside = append(outside, d) - } - } - for d := range named { - if !fetched[d] { - missing = append(missing, d) - } - } - if len(outside) == 0 && len(missing) == 0 { - return "" - } - sort.Strings(outside) - sort.Strings(missing) - var said []string - if len(outside) > 0 { - said = append(said, "fetched and not in the want's parts: "+strings.Join(outside, ", ")) - } - if len(missing) > 0 { - said = append(said, "in the want's parts and not fetched: "+strings.Join(missing, ", ")) - } - return fmt.Sprintf("%s %s", PartsDiffer, strings.Join(said, "; ")) -} diff --git a/internal/selfcompose/kept.go b/internal/selfcompose/kept.go index 9e3daa7a..ac9487ba 100644 --- a/internal/selfcompose/kept.go +++ b/internal/selfcompose/kept.go @@ -8,7 +8,7 @@ import ( // KeptBuildOf is the node that keeps the build a module is wanted at, and its fingerprint, for the artifact store's // holder (design 47 G section 271, 526, A-50): the want's `kept-on` and nothing else names it, the builder's builds being // no read of the node-engine's (section 421). kept is false when the module has no want, its want names no keeping node, -// or its `parts` do not name the digest ("sha256:" and 64 hex digits, or bare): the artifact is then fetched from the store. +// or the digests its version resolves to do not name the digest ("sha256:" and 64 hex digits, or bare): the artifact is then fetched from the store. func (c *Composer) KeptBuildOf(_ context.Context, module, digest string) (node, fp string, kept bool, err error) { c.mu.Lock() w, ok := c.wants[module] @@ -16,9 +16,9 @@ func (c *Composer) KeptBuildOf(_ context.Context, module, digest string) (node, if !ok || w.Fp == "" || w.KeptOn == "" { return "", "", false, nil } - parts := w.Parts - if len(parts) == 0 && w.Version != "" { - // A want naming its version names its digests through the registry seats (A-430a): the resolution the composing made. + var parts map[string]string + if w.Version != "" { + // A want names its version alone, and its digests through the registry seats (design 47 H §750): the resolution the composing made. c.mu.Lock() r := c.resolved[resolvedKey{module, w.Fp, w.Version}] c.mu.Unlock() diff --git a/internal/selfcompose/kept_test.go b/internal/selfcompose/kept_test.go index 4ef6f1d5..369b722e 100644 --- a/internal/selfcompose/kept_test.go +++ b/internal/selfcompose/kept_test.go @@ -19,15 +19,17 @@ func TestTheKeepingNodeIsTheWantsKeptOn(t *testing.T) { node string kept bool }{ - {"kept, by its bare digest", kd, &meshwants.WantsByWantNodeModuleValue{Fp: "f1", KeptOn: "n3", Parts: map[string]string{"db:p": "sha256:" + kd}}, "n3", true}, - {"kept, by the declared digest", "sha256:" + kd, &meshwants.WantsByWantNodeModuleValue{Fp: "f1", KeptOn: "n3", Parts: map[string]string{"db:p": "sha256:" + kd}}, "n3", true}, - {"a digest the parts do not name", "sha256:" + strings.Repeat("7", 64), &meshwants.WantsByWantNodeModuleValue{Fp: "f1", KeptOn: "n3", Parts: map[string]string{"db:p": "sha256:" + kd}}, "", false}, - {"a want naming no keeping node", kd, &meshwants.WantsByWantNodeModuleValue{Fp: "f1", Parts: map[string]string{"db:p": "sha256:" + kd}}, "", false}, + {"kept, by its bare digest", kd, &meshwants.WantsByWantNodeModuleValue{Fp: "f1", KeptOn: "n3", Version: "1"}, "n3", true}, + {"kept, by the declared digest", "sha256:" + kd, &meshwants.WantsByWantNodeModuleValue{Fp: "f1", KeptOn: "n3", Version: "1"}, "n3", true}, + {"a digest the resolved version does not name", "sha256:" + strings.Repeat("7", 64), &meshwants.WantsByWantNodeModuleValue{Fp: "f1", KeptOn: "n3", Version: "1"}, "", false}, + {"a want naming no keeping node", kd, &meshwants.WantsByWantNodeModuleValue{Fp: "f1", Version: "1"}, "", false}, {"no want of the module", kd, nil, "", false}, } { c := &Composer{wants: map[string]meshwants.WantsByWantNodeModuleValue{}} if row.want != nil { c.wants["db"] = *row.want + // The digests the want's version resolves to through the registry seats (design 47 H §750). + c.resolved = map[resolvedKey]versionParts{{"db", "f1", "1"}: {parts: map[string]string{"db:p": "sha256:" + kd}}} } node, fp, kept, err := c.KeptBuildOf(context.Background(), "db", row.digest) if err != nil || node != row.node || kept != row.kept || (kept && fp != "f1") { diff --git a/internal/selfcompose/selfcompose.go b/internal/selfcompose/selfcompose.go index 089d1d56..9bc1ea7c 100644 --- a/internal/selfcompose/selfcompose.go +++ b/internal/selfcompose/selfcompose.go @@ -778,8 +778,8 @@ func (c *Composer) entry(bucket, key string) (v any, has, known bool) { defer c.mu.Unlock() switch bucket { case buckets.Wants: - // A want is composed by its fingerprint, version, parts and keeping node (design 47 G §525); its words, rule and newest - // change nothing composed. Judged by its fingerprint alone, a want that gained its parts at the same fingerprint asked no + // A want is composed by its fingerprint, version and keeping node (design 47 G §525); its words, rule and newest + // change nothing composed. Judged by its fingerprint alone, a want that gained its version at the same fingerprint asked no // pass, and the agent waited for a composition never made (lead-47 2026-11-16, the indexer on novox). module := agent.NodeModule if _, ok := meshwants.ParseWantsByWantNodeNodeKey(key); !ok { @@ -792,8 +792,7 @@ func (c *Composer) entry(bucket, key string) (v any, has, known bool) { w, ok := c.wants[module] return struct { Fp, Version, KeptOn string - Parts map[string]string - }{w.Fp, w.Version, w.KeptOn, w.Parts}, ok, true + }{w.Fp, w.Version, w.KeptOn}, ok, true case buckets.Assignments: // Any key of a node, its node key, a module key or its legacy key, stands for the node's whole assignment: a // module key written before its node key names it changes nothing composed. diff --git a/internal/selfcompose/selfcompose_test.go b/internal/selfcompose/selfcompose_test.go index fe33e2f4..98d689c5 100644 --- a/internal/selfcompose/selfcompose_test.go +++ b/internal/selfcompose/selfcompose_test.go @@ -437,6 +437,15 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) { var refusals []string e := b.env() e.Get = get + // The registry seats: de-spiegel's image at version 1 (design 47 H §750: a want names its version, the node-engine + // resolves the digests). + e.Registry = EntryCall(func(_ context.Context, seat, _ string, args any) (json.RawMessage, error) { + if seat == "container-image-registry" && args.(map[string]string)["name"] == "de-spiegel/site" { + return json.RawMessage(`{"name":"de-spiegel/site","versions":[{"name":"de-spiegel/site","kind":"image","digest":"sha256:` + + strings.Repeat("6", 64) + `","version":"1"}]}`), nil + } + return nil, errors.New("not held") + }) e.Refused = func(why string, held map[string]string) { for _, m := range heldModules(held) { why += "held " + m + ": " + held[m] @@ -572,11 +581,11 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) { mfp := meshcatalogclient.SourcePrefix2 + strings.Repeat(map[string]string{"de-spiegel": "d", "proxy": "e"}[m], 64) c3.holdEntry(t, m, mfp, raw) w := meshwants.WantsByWantNodeModuleValue{Fp: mfp, Self: true} - if m == "de-spiegel" { // builds an image: the entry names it, the want the digest its part has + if m == "de-spiegel" { // builds an image: the entry names it, the want its version, which the registry seat resolves k := c3.keptEnt[mfp] k.entry.Artifacts = []meshcatalog.Artifact{{Kind: "image", Ref: "de-spiegel:site"}} c3.keptEnt[mfp] = k - w.Parts = map[string]string{"de-spiegel:site": "sha256:" + strings.Repeat("6", 64)} + w.Version = "1" } c3.wants[m] = w } @@ -1117,6 +1126,14 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) { artEntry := entryOfManifest("art", artFp, artManifest) artEntry.Artifacts = []meshcatalog.Artifact{{Kind: "archive", Language: "none", Ref: "art:files"}} catalogEntries[artFp] = artEntry + // art's files archive at version 1, which the candidate "art-with" names (the candidate's version, never a digest). + senv.Registry = EntryCall(func(_ context.Context, seat, _ string, args any) (json.RawMessage, error) { + if seat == "oci-artifact-registry" && args.(map[string]string)["name"] == "art/files" { + return json.RawMessage(`{"name":"art/files","versions":[{"name":"art/files","kind":"archive","digest":"sha256:` + + strings.Repeat("9", 64) + `","version":"1"}]}`), nil + } + return nil, errors.New("not held") + }) senv.Entry = EntryCall(func(_ context.Context, _, verb string, args any) (json.RawMessage, error) { switch in := args.(type) { case meshcatalog.ModuleInput: @@ -1223,7 +1240,7 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) { // A module with an artifact: held when the candidate gives no part for it, built from its entry and the parts when it does. for group, added := range map[string]map[string]meshmoduleassigner.AddedModule{ "art-without": nil, - "art-with": {"art": {Version: "1", Parts: map[string]string{"art:files": "sha256:" + strings.Repeat("9", 64)}}}, + "art-with": {"art": {Version: "1"}}, } { p := trunk p.Modules = []meshmoduleassigner.PlacedModule{{Module: "lemurs"}, {Module: "art"}} @@ -1295,7 +1312,7 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) { }, "art-without": func(a nodeengine.CandidateAnswer) bool { return a.Verdict == nodeengine.CandidateAnswerVerdictSame && len(a.Held) == 1 && a.Held[0].Module == "art" && - strings.Contains(a.Held[0].Why, "the candidate gives no part for art:files of art's build "+artFp) + strings.Contains(a.Held[0].Why, "the candidate's version resolves no digest of art:files of art's build "+artFp) }, "art-with": func(a nodeengine.CandidateAnswer) bool { return len(a.Added) == 1 && a.Added[0].Module == "art" && len(a.Held) == 0 diff --git a/internal/selfcompose/shadow.go b/internal/selfcompose/shadow.go index 5a571bab..cc392667 100644 --- a/internal/selfcompose/shadow.go +++ b/internal/selfcompose/shadow.go @@ -628,10 +628,10 @@ func (s *Shadow) answerProposal(ctx context.Context, proposal string) (nodeengin heldAdded[pm.Module] = fmt.Sprintf("the entry of %s's build %s holds no manifest that can be read: %v", pm.Module, fp, err) continue } - // The module is built from its entry and the parts the candidate gives (A-316); an artifact it gives no part for holds it. - w := meshwants.WantsByWantNodeModuleValue{Fp: fp, Parts: own.c.Added[pm.Module].Parts, Version: own.c.Added[pm.Module].Version} + // The module is built from its entry and the version the candidate gives (A-316, H-A-38); an artifact whose digest that version does not resolve holds it. + w := meshwants.WantsByWantNodeModuleValue{Fp: fp, Version: own.c.Added[pm.Module].Version} if _, missing := c.partsOf(pm.Module, entry, w); missing != "" { - heldAdded[pm.Module] = fmt.Sprintf("the candidate gives no part for %s of %s's build %s, so the node composes nothing new of it", missing, pm.Module, fp) + heldAdded[pm.Module] = fmt.Sprintf("the candidate's version resolves no digest of %s of %s's build %s, so the node composes nothing new of it", missing, pm.Module, fp) continue } addedWants[pm.Module] = w diff --git a/internal/selfcompose/versions.go b/internal/selfcompose/versions.go index 80178265..f3bf6060 100644 --- a/internal/selfcompose/versions.go +++ b/internal/selfcompose/versions.go @@ -70,10 +70,10 @@ func registryName(module string, a meshcatalog.Artifact) string { } // partsOf is the digest of each artifact of e for want w, by artifact reference, and the artifacts it names no digest for ("" when -// each has one). A want with parts gives them; a want with a version and no parts is resolved through the registry seats. +// each has one). A want names its version alone (design 47 H §750); its digests are resolved through the registry seats. func (c *Composer) partsOf(module string, e meshcatalog.CatalogEntry, w meshwants.WantsByWantNodeModuleValue) (map[string]string, string) { - parts := w.Parts - if len(parts) == 0 && w.Version != "" && len(e.Artifacts) > 0 { + var parts map[string]string + if w.Version != "" && len(e.Artifacts) > 0 { var why string if parts, why = c.resolve(module, e, w); why != "" { return nil, why diff --git a/internal/selfcompose/versions_test.go b/internal/selfcompose/versions_test.go index 162d7d52..bda20c6d 100644 --- a/internal/selfcompose/versions_test.go +++ b/internal/selfcompose/versions_test.go @@ -13,10 +13,10 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" ) -// Design 47 G A-430, A-430a (the lead's answer A-430b): a want naming its version and no parts is resolved to its artifacts' +// Design 47 G A-430, A-430a (the lead's answer A-430b): a want naming its version is resolved to its artifacts' // digests through the verb versions of the registry seat of each artifact's kind, under `/`; an upstream copy // by the digest its manifest pins. The build is made from those digests. A lookup that fails is said, naming the module, the -// version and the seat, and holds the module whole; a want with parts is read by its parts as before. +// version and the seat, and holds the module whole. func aWantNamingItsVersionIsResolvedThroughTheRegistrySeats(t *testing.T) { fp := meshcatalogclient.SourcePrefix2 + strings.Repeat("a", 64) d := func(c string) string { return "sha256:" + strings.Repeat(c, 64) } @@ -46,9 +46,6 @@ func aWantNamingItsVersionIsResolvedThroughTheRegistrySeats(t *testing.T) { missing: "2.0.0", said: []string{"mail at version 2.0.0", "oci-artifact-registry", "container-image-registry"}}, "a seat that does not answer": {want: meshwants.WantsByWantNodeModuleValue{Fp: fp, Version: "1.2.3", Self: true}, down: "container-image-registry", missing: "mail:web", said: []string{"mail at version 1.2.3: the seat container-image-registry"}}, - "parts as before": {want: meshwants.WantsByWantNodeModuleValue{Fp: fp, Version: "1.2.3", Self: true, - Parts: map[string]string{"mail:server": d("9"), "mail:files": d("5"), "mail:web": d("6")}}, - parts: map[string]string{"mail:server": d("9"), "mail:files": d("5"), "mail:web": d("6")}}, } { var mu sync.Mutex var said []string @@ -112,7 +109,7 @@ func aWantNamingItsVersionIsResolvedThroughTheRegistrySeats(t *testing.T) { if calls != before { t.Errorf("%s: resolved again: %d calls, then %d", name, before, calls) } - c.wants["mail"] = meshwants.WantsByWantNodeModuleValue{Fp: fp, Version: row.want.Version, Parts: row.want.Parts, KeptOn: "g14", Self: true} + c.wants["mail"] = meshwants.WantsByWantNodeModuleValue{Fp: fp, Version: row.want.Version, KeptOn: "g14", Self: true} if node, _, kept, _ := c.KeptBuildOf(context.Background(), "mail", row.parts["mail:files"]); !kept || node != "g14" { t.Errorf("%s: kept on %q %v, want g14", name, node, kept) } From d2b6ecdf0edd4e9f119de9258e379f68ae4c1783 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 02:31:53 +0100 Subject: [PATCH 2/9] MH-1: the node-engine states that it reads a want by version; want-parts goes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The record's capabilities no longer hold want-parts; manifest-reads holds the word want:version, stated at the first reading and said by manifest-reads-changed. Builds: design 47 H §772, §764; H-A-45 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- internal/link/have_test.go | 17 +++++++++++++---- internal/link/record.go | 12 ++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/internal/link/have_test.go b/internal/link/have_test.go index 7c1ec527..dc27c29a 100644 --- a/internal/link/have_test.go +++ b/internal/link/have_test.go @@ -368,13 +368,17 @@ func TestTheNodeKeyCarriesTheNodesFacts(t *testing.T) { t.Fatalf("the node key holds no record: %+v, %v", got, err) } wantRecord := nodeengine.NodeRecord{V: sdkkeys.Version, Node: "n1", TunnelKey: "tk", SealingKey: "sk", ServingKey: "pk", - Certificate: "cert", Trusts: keys.Trusts, Capabilities: []string{"apt", "bus-state-calls", "ledger-calls", "systemd", CapabilityWantParts}, OutwardLinks: []string{"eth0"}, NetworksSaid: true, + Certificate: "cert", Trusts: keys.Trusts, Capabilities: []string{"apt", "bus-state-calls", "ledger-calls", "systemd"}, OutwardLinks: []string{"eth0"}, NetworksSaid: true, Networks: []nodeengine.AttachedNetwork{{Link: "eth0", Network: "192.0.2.0/24"}}, Contract: NodeKeyContract, - ManifestReads: catalogue.ManifestReads(), // what it reads of a manifest: its contract's (ADR 0614 §4) + ManifestReads: statedReads(), // what it reads of a manifest: its contract's (ADR 0614 §4) and that it reads a want by version (H §772) RunnerCapabilities: []string{"bus-state-calls", "ledger-calls"}, RunnerFingerprint: "sha256:runner"} if !nodeengineclient.SameNodeRecord(*got.Record, wantRecord) { t.Errorf("record = %+v, want %+v", *got.Record, wantRecord) } + // A node-engine of H1 reads a want by its version alone and says so in its manifest-reads, not in its capabilities (H §772, §764). + if !slices.Contains(got.Record.ManifestReads, nodeengine.ManifestReadWordWantVersion) || slices.Contains(got.Record.Capabilities, "want-parts") { + t.Errorf("the record states reads %v and capabilities %v, want the word want:version and no want-parts", got.Record.ManifestReads, got.Record.Capabilities) + } // Among them, that it fills a seat's reach from the seat holder's listen (ADR 0632 §1). // And the words and forms it builds (design 42 zfs-owns-zfs §4, answer A-13). for _, read := range []string{catalogue.ReadForm + catalogue.ReferenceFormSeatReach, "word:resources.if-config", @@ -401,7 +405,7 @@ func TestTheNodeKeyCarriesTheNodesFacts(t *testing.T) { } l.statedErr, l.stated = nil, map[string]string{} q.SayFacts(context.Background(), rep) - if got, _ = nodeengineclient.DecodeHaveNode(l.kv["n1.node"].value); l.kv["n1.node"].rev != at+1 || !slices.Equal(got.Record.Capabilities, []string{"apt", "systemd", "want-parts"}) { + if got, _ = nodeengineclient.DecodeHaveNode(l.kv["n1.node"].value); l.kv["n1.node"].rev != at+1 || !slices.Equal(got.Record.Capabilities, []string{"apt", "systemd"}) { t.Errorf("a runner stating no calls: revision %d (was %d), capabilities %v", l.kv["n1.node"].rev, at, got.Record.Capabilities) } at++ @@ -447,7 +451,7 @@ func TestTheNodeKeyCarriesTheNodesFacts(t *testing.T) { } catalogue.UseSeats(all) q.RestateReads(context.Background()) - if got, _ = nodeengineclient.DecodeHaveNode(l.kv["n1.node"].value); !slices.Equal(got.Record.ManifestReads, catalogue.ManifestReads()) { + if got, _ = nodeengineclient.DecodeHaveNode(l.kv["n1.node"].value); !slices.Equal(got.Record.ManifestReads, statedReads()) { t.Errorf("the list back whole: the record states %v, want its contract's", got.Record.ManifestReads) } @@ -1045,3 +1049,8 @@ func slicesIndex(rs []ResourceHealth, id string) int { } return -1 } + +// statedReads is the contract's reads with the word that the engine reads a want by its version (design 47 H §772). +func statedReads() []string { + return slices.Sorted(slices.Values(append(catalogue.ManifestReads(), nodeengine.ManifestReadWordWantVersion))) +} diff --git a/internal/link/record.go b/internal/link/record.go index 8cf26bc6..e0e0ce46 100644 --- a/internal/link/record.go +++ b/internal/link/record.go @@ -40,16 +40,13 @@ type RecordKeys struct { // buildReads are the words and forms this engine reads of a manifest (novox/hq ADR 0614 §4): the reader capabilities of // the mesh-sdk it is built with, its seats left out. Computed once: they are the build's, and never change while it runs. -// CapabilityWantParts is the capability a node-engine states in its node record when it reads the want's version, parts and -// kept-on (design 47 G §525); the assigner writes them into a node's want only while the record states it. -const CapabilityWantParts = "want-parts" - var buildReads = sync.OnceValue(func() []string { return slices.DeleteFunc(catalogue.ManifestReads(), func(r string) bool { return strings.HasPrefix(r, catalogue.ReadSeat) }) }) -// readsNow is what this engine reads of a manifest now: its build's words and forms, and the seats of the seat list it -// holds now (catalogue.Seats, which the engine's reader of the list gives catalogue: bootstrapped or read; ADR 0636). +// readsNow is what this engine reads of a manifest now: its build's words and forms, the word that it reads a want by its +// version alone (nodeengine.ManifestReadWordWantVersion; design 47 H §772, H-A-45, said by the event manifest-reads-changed, +// never in the capabilities), and the seats of the seat list it holds now (catalogue.Seats, which the engine's reader of the list gives catalogue: bootstrapped or read; ADR 0636). func readsNow() []string { set := map[string]bool{} for _, r := range buildReads() { @@ -59,6 +56,7 @@ func readsNow() []string { set[catalogue.ReadSeat+seat.Name] = true } out := make([]string, 0, len(set)) + set[nodeengine.ManifestReadWordWantVersion] = true for r := range set { out = append(out, r) } @@ -132,8 +130,6 @@ func recordOf(node string, r Report, keys RecordKeys) *nodeengine.NodeRecord { rec.Capabilities = append(rec.Capabilities, c.Name) } } - // A node-engine of G states that it reads the want's new fields: version, parts and where a kept build is kept (design 47 G §525). - rec.Capabilities = append(rec.Capabilities, CapabilityWantParts) for _, c := range keys.Stated { if c != "" && !slices.Contains(rec.Capabilities, c) { rec.Capabilities = append(rec.Capabilities, c) From 949b782a1e47f675f28b1bd5f9743b731fb2b8a9 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 02:37:59 +0100 Subject: [PATCH 3/9] MH-3: the apply order by rank, the revert, the backup holder and the bus module first, the engine's own module last MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit settle applies the changed wants in the order of design 47 H 771: the node's own composition, a reverted module, the holder of node-backup and the bus module (by the claims of the manifests the composer holds), each pipeline's wants by rank (older source first), the rest by name, the engine's own module last. A want of a higher rank waits on this machine alone for the lower ranks of its pipeline, held in its have as a wait of step placing and judged again at the next settle. The want's pipeline and rank are the mesh-delivery contract's stand-in until its commit. Builds: design 47 H §771; H-A-46, H-A-59, H-A-67, H-A-68 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- cmd/mesh-host/nodeagent.go | 3 +- internal/agent/agent.go | 67 +++++-- internal/agent/agent_test.go | 125 ++++++++++--- internal/agent/order.go | 249 ++++++++++++++++++++++++++ internal/agent/parts.go | 10 +- internal/selfcompose/selfcompose.go | 13 ++ internal/selfcompose/versions_test.go | 19 ++ 7 files changed, 449 insertions(+), 37 deletions(-) create mode 100644 internal/agent/order.go diff --git a/cmd/mesh-host/nodeagent.go b/cmd/mesh-host/nodeagent.go index ebb39e01..d076a771 100644 --- a/cmd/mesh-host/nodeagent.go +++ b/cmd/mesh-host/nodeagent.go @@ -702,7 +702,8 @@ func nodeAgent(ctx context.Context, opts options, signer ed25519.PublicKey, trus env.WhyUnmade, env.Waiting, env.RunningManifest = composer.WhyUnmade, composer.Waiting, composer.RunningManifest keptFetchFn := keptArtifactFetch(composer.KeptBuildOf, session.AskSeatOn, session.KeptObject) keptFetch.Store(&keptFetchFn) - env.HoldsData = composer.HoldsData // what runs from the kept declaration says Data as its manifest does + env.Claims, env.OwnModule = composer.Claims, composer.EngineModule // the order of the applies (design 47 H §771) + env.HoldsData = composer.HoldsData // what runs from the kept declaration says Data as its manifest does session.NoteComposes(linked, nodeengineclient.ComposesOwn, "it composes its own modules, and applies no composition made elsewhere") ag = agent.New(env) own.set(ag) diff --git a/internal/agent/agent.go b/internal/agent/agent.go index 8daf0517..9ece1a25 100644 --- a/internal/agent/agent.go +++ b/internal/agent/agent.go @@ -193,6 +193,11 @@ type Env struct { // transient failure only on RetryTransient or a change of either key. Backoff func(try int) time.Duration Say func(string) + // Claims says whether the manifest the node holds for a module claims a seat, and whether that manifest is read: the + // holder of the seat node-backup and the bus module are applied first (design 47 H §771). Nil reads none. + Claims func(ctx context.Context, module, seat string) (claims, known bool) + // OwnModule is the node-engine's own module, applied last (design 47 H §771); nil, or "", names none. + OwnModule func() string // SelfComposed says the compositions are the node's own (novox/hq ADR 0547 §2, issue 1126): Composed hands what the // node composed itself, unsigned, and a want names the build alone. The composition composed for the want's build is // the one applied, when it differs from what runs. @@ -266,7 +271,9 @@ type Agent struct { // heldAlone is the modules the composer holds alone (NotComposedEach): what runs of each in the node's own // composition is held out of the node's own apply until a composition of its own is handed (heldOut). heldAlone map[string]bool - retry chan []string + // placing is, by module, what a want of a higher rank waits on here (design 47 H §771): judged again at every settle. + placing map[string]string + retry chan []string // reconcile carries the judge's edges: a resource found not active (ADR 0568 §2). reconcile chan []string // failedAgain carries the modules whose failed apply a person asked to try again (RetryFailed). @@ -860,23 +867,57 @@ func (a *Agent) sayOnce(key, line string) { a.env.Say(line) } -// settle applies what the dirty modules' wants allow: the node's own first, then each module in name order. +// settle applies what the dirty modules' wants allow, in the order of design 47 H §771 (orderOf): the node's own composition +// first, the holder of the seat node-backup and the bus module, each pipeline's wants by rank, the rest by name, and the +// engine's own module last. A want of a higher rank waits, on this machine alone, until the lower ranks of its pipeline are +// applied or failed, and is held in its have, said as a wait of step placing; it is judged again at the next settle. func (a *Agent) settle(ctx context.Context, dirty map[string]bool) { - order := make([]string, 0, len(dirty)) - for m := range dirty { - order = append(order, m) + a.mu.Lock() + for m := range a.placing { + dirty[m] = true } - sort.Slice(order, func(i, j int) bool { - if (order[i] == NodeModule) != (order[j] == NodeModule) { - return order[i] == NodeModule + a.mu.Unlock() + modules := make([]string, 0, len(dirty)) + for m := range dirty { + modules = append(modules, m) + } + rows, _ := a.orderOf(ctx, modules) + todo := make([]string, 0, len(rows)) + for _, r := range rows { + todo = append(todo, r.module) + } + // Each pass applies the first want that waits on nothing, and starts again from the top: a lower rank applied may release a + // want that stands earlier in the order. + for len(todo) > 0 && ctx.Err() == nil { + at := -1 + for i, m := range todo { + a.mu.Lock() + waits := a.waitsOnLocked(m) + a.mu.Unlock() + if len(waits) == 0 { + at = i + break + } } - return order[i] < order[j] - }) - for _, m := range order { - if ctx.Err() != nil { - return + if at < 0 { + break } + m := todo[at] + todo = append(todo[:at], todo[at+1:]...) + a.mu.Lock() + _, waited := a.placing[m] + delete(a.placing, m) + a.mu.Unlock() a.settleOne(ctx, m) + if waited { + a.endPlacing(ctx, m) + } + } + for _, m := range todo { + a.mu.Lock() + waits := a.waitsOnLocked(m) + a.mu.Unlock() + a.placingHave(ctx, m, waits) } } diff --git a/internal/agent/agent_test.go b/internal/agent/agent_test.go index 3a9de1cc..f7b5cd1e 100644 --- a/internal/agent/agent_test.go +++ b/internal/agent/agent_test.go @@ -135,6 +135,8 @@ type bed struct { settledRan []bool ag *Agent // the agent run() runs env Env + // runs is, by module, a build the agent already runs when run() starts it. + runs map[string]string } func newBed(t *testing.T) *bed { @@ -214,6 +216,9 @@ func (b *bed) run() (stop func()) { ctx, cancel := context.WithCancel(context.Background()) done := make(chan struct{}) b.ag = New(b.env) + for m, fp := range b.runs { + b.ag.running[m] = nodeengine.HaveByNodeModuleValue{Fp: fp, Composed: "sha256:" + strings.Repeat("1", 64), Phase: nodeengineclient.PhaseRunning} + } go func() { defer close(done); _ = b.ag.Run(ctx) }() return func() { cancel(); <-done } } @@ -980,27 +985,107 @@ func TestARemovedWantRemovesThatModuleOnly(t *testing.T) { }) } -// The node's own composition is applied before any module's, whichever key came first. -func TestTheNodesOwnCompositionComesBeforeAnyModules(t *testing.T) { - b := newBed(t) - fp := fpOf("a") - ck, craw, dig := composition(t, "web", fp, false, file("web", "x", "1")) - wk, wraw := wantFor(t, "web", fp, dig, "") - nk, nraw, ndig := composition(t, NodeModule, "", false) - nwk := meshwants.WantsByWantNodeNodeKey(node) - nwraw, err := bucketstest.NodeWant(meshwants.WantsByWantNodeNodeValue{Composed: ndig}) - if err != nil { - t.Fatal(err) +// Design 47 H §771: the node-engine applies the wants changed at once in one order: the node's own composition, a reverted +// module, the holder of the seat node-backup and the bus module (found by their claims), each pipeline's wants by rank (the +// older source first), the rest by name, and its own module last; a want of a higher rank waits, on this machine, for the lower +// ranks of its pipeline, held in its have as a wait of step placing, and the read apply-order answers the order with why. +func TestTheOrderTheChangedWantsAreAppliedIn(t *testing.T) { + type mod struct { + name string + pipeline string // the want's pipeline, with its rank + rank int64 + claims string // the seat its manifest claims + runs string // the build it runs before, the want naming another (a revert when it is in no pipeline) + late bool // its composition is made after the start } - b.comps.before(ck, craw) - b.comps.before(nk, nraw) - b.wants.before(wk, wraw) - b.wants.before(nwk, nwraw) - stop := b.run() - defer stop() - eventually(t, "both not applied", func() bool { return len(b.appliedList()) == 2 }) - if got := b.appliedList(); got[0] != NodeModule || got[1] != "web" { - t.Fatalf("the order was %v, the node's own first", got) + base := []mod{{name: "zeta1", pipeline: "main.7", rank: 1}, {name: "alpha2", pipeline: "main.7", rank: 2}, {name: "old", pipeline: "main.5", rank: 1}, + {name: "zeta"}, {name: "alpha"}, {name: "bk", claims: SeatBackup}, {name: "bus", claims: SeatBus}, {name: "engine"}} + for _, row := range []struct { + name string + mods []mod + order []string // what is applied, in order, once the late compositions are made + first []string // what is applied before them + read []string // what apply-order answers at the start: module position:waits + }{ + {"every class in its place", base, []string{NodeModule, "bk", "bus", "old", "zeta1", "alpha2", "alpha", "zeta", "engine"}, nil, + nil}, + {"a revert comes first", append([]mod{{name: "rev", runs: "z"}}, base...), + []string{NodeModule, "rev", "bk", "bus", "old", "zeta1", "alpha2", "alpha", "zeta", "engine"}, nil, nil}, + {"a higher rank waits for its lower rank", []mod{{name: "zeta1", pipeline: "main.7", rank: 1, late: true}, {name: "alpha2", pipeline: "main.7", rank: 2}, + {name: "other"}}, []string{NodeModule, "other", "zeta1", "alpha2"}, []string{NodeModule, "other"}, + []string{"zeta1:1:", "alpha2:2:zeta1"}}, + } { + t.Run(row.name, func(t *testing.T) { + b := newBed(t) + b.runs = map[string]string{} + b.env.OwnModule = func() string { return "engine" } + b.env.Claims = func(_ context.Context, module, seat string) (bool, bool) { + for _, m := range row.mods { + if m.name == module { + return m.claims == seat, true + } + } + return false, false + } + var late []string + for i, m := range row.mods { + fp := fpOf(string("0123456789abcdef"[i])) + 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}) + if err != nil { + t.Fatal(err) + } + if m.late { + late = append(late, ck, string(craw)) + } else { + b.comps.before(ck, craw) + } + b.wants.before(meshwants.WantsByWantNodeModuleKey(node, m.name), raw) + } + nk, nraw, ndig := composition(t, NodeModule, "", false) + nwraw, err := bucketstest.NodeWant(meshwants.WantsByWantNodeNodeValue{Composed: ndig}) + if err != nil { + t.Fatal(err) + } + b.comps.before(nk, nraw) + b.wants.before(meshwants.WantsByWantNodeNodeKey(node), nwraw) + stop := b.run() + defer stop() + if row.first != nil { + eventually(t, "the first wants are applied", func() bool { return len(b.appliedList()) == len(row.first) }) + b.idle() + if got := b.appliedList(); !slices.Equal(got, row.first) { + t.Fatalf("applied %v before the late compositions, want %v", got, row.first) + } + var got []string + for _, r := range b.ag.ApplyOrder(context.Background()) { + got = append(got, fmt.Sprintf("%s:%d:%s", r.Module, r.Position, strings.Join(r.Waits, ","))) + } + // The node's own is applied; the rest stand in the order, each with what it waits on. + if !slices.Equal(got, row.read) { + t.Fatalf("apply-order answers %v, want %v", got, row.read) + } + if h := b.haves.last("alpha2"); h.Phase != string(nodeengineclient.PhaseHeld) || h.Wait == nil || h.Wait.Step != nodeengine.WaitStepPlacing || h.Wait.On != "zeta1" { + t.Fatalf("alpha2's have is %s with wait %+v, want held in a wait of step placing on zeta1", h.Phase, h.Wait) + } + for i := 0; i < len(late); i += 2 { + b.comps.put(late[i], []byte(late[i+1])) + } + } + eventually(t, "every want is applied", func() bool { return len(b.appliedList()) == len(row.order) }) + b.idle() + if got := b.appliedList(); !slices.Equal(got, row.order) { + t.Fatalf("applied %v, want %v", got, row.order) + } + if row.first != nil { + if h := b.haves.last("alpha2"); h.Wait != nil || h.Phase != string(nodeengineclient.PhaseRunning) { + t.Fatalf("alpha2's have is %s with wait %+v after the lower rank applied, want running and no wait", h.Phase, h.Wait) + } + } + }) } } diff --git a/internal/agent/order.go b/internal/agent/order.go new file mode 100644 index 00000000..23874efd --- /dev/null +++ b/internal/agent/order.go @@ -0,0 +1,249 @@ +package agent + +import ( + "context" + "fmt" + "sort" + "strconv" + "strings" + + "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" + "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" +) + +// The order on one machine (design 47 H §771, H-A-46, H-A-59): the node-engine applies its changed wants, one module at a time, +// the node's own composition first, a reverted module, then the holder of the seat node-backup and the bus module, then each pipeline's wants by +// rank (the older source first), then the rest by name, and its own module last. It reads the order from the wants alone and +// consumes no event of the runner. +const ( + // SeatBackup and SeatBus are the seats whose holders are applied first on a machine: found by the claim of the manifest the + // composer holds for the module, never by a module's name. + SeatBackup = "node-backup" + SeatBus = "mesh-broker" +) + +// order classes: the lower is applied first. +const ( + classNode = iota + classRevert + classBackup + classBus + classPipeline + classRest + classOwn +) + +// rowOf is one module's place in the order. +type rowOf struct { + module string + class int + pipeline string + branch string + source int64 + rank int64 +} + +// changedLocked says a module's want is not applied yet: it is there, and what runs of the module is not what it names +// (a.mu held). +func (a *Agent) changedLocked(module string) bool { + w, ok := a.wants[module] + if !ok || !w.Present { + return false + } + r, runs := a.running[module] + if w.Want.Removed { + return runs && r.Phase != nodeengineclient.PhaseRemoved + } + if module == NodeModule { + return !runs || r.Composed != w.Want.Composed || r.Phase == nodeengineclient.PhaseFailed + } + return !(runs && r.Fp == w.Want.Fp && r.Phase != nodeengineclient.PhaseRemoved && r.Phase != nodeengineclient.PhaseFailed) +} + +// revertLocked says a module's want is a revert: it names no pipeline and no rank (a placement's build) and a fingerprint other +// than the one the module runs (design 47 H §771, H-A-68; a.mu held). +func (a *Agent) revertLocked(module string) bool { + w, ok := a.wants[module] + if !ok || !w.Present || w.Want.Removed || module == NodeModule || w.Want.Pipeline != "" || w.Want.Rank > 0 || w.Want.Fp == "" { + return false + } + r, runs := a.running[module] + return runs && r.Phase != nodeengineclient.PhaseRemoved && r.Fp != "" && r.Fp != w.Want.Fp +} + +// waitsOn is the modules a want waits on: the changed wants of the same pipeline of a lower rank, that did not fail here +// (a.mu held). A want of no pipeline or of no rank waits on none. +func (a *Agent) waitsOnLocked(module string) []string { + w := a.wants[module].Want + if w.Pipeline == "" || w.Rank <= 0 { + return []string{} + } + out := []string{} + for m, other := range a.wants { + if m == module || other.Want.Pipeline != w.Pipeline || other.Want.Rank <= 0 || other.Want.Rank >= w.Rank || !a.changedLocked(m) { + continue + } + // A lower rank that failed here ends the wait; one retried for a failure of the bus does not (it still waits). + if att, tried := a.attempt[m]; tried && att.FP == other.Want.Fp && !att.Held && !att.Transient && !a.runsLocked(m) { + continue + } + out = append(out, m) + } + sort.Strings(out) + return out +} + +// runsLocked says the module runs what its want names (a.mu held). +func (a *Agent) runsLocked(module string) bool { + r, runs := a.running[module] + return runs && r.Fp == a.wants[module].Want.Fp && r.Phase != nodeengineclient.PhaseRemoved && r.Phase != nodeengineclient.PhaseFailed +} + +// pipelineParts splits a pipeline's key `.` into its branch and its source number. +func pipelineParts(key string) (branch string, source int64) { + i := strings.LastIndex(key, ".") + if i < 0 { + return key, 0 + } + n, err := strconv.ParseInt(key[i+1:], 10, 64) + if err != nil { + return key, 0 + } + return key[:i], n +} + +// claims says whether the manifest the node holds for the module claims the seat; a module whose manifest is not read claims none. +func (a *Agent) claims(ctx context.Context, module, seat string) bool { + if a.env.Claims == nil || module == NodeModule { + return false + } + claims, known := a.env.Claims(ctx, module, seat) + return claims && known +} + +// orderOf is the modules in the order they are applied, each with its place and why; modules are the ones asked for, whatever +// the state of their wants. +func (a *Agent) orderOf(ctx context.Context, modules []string) ([]rowOf, map[string]string) { + own := "" + if a.env.OwnModule != nil { + own = a.env.OwnModule() + } + // The claims are asked of the composer before a.mu is taken: it asks what the agent runs. + backups, buses := map[string]bool{}, map[string]bool{} + for _, m := range modules { + backups[m] = a.claims(ctx, m, SeatBackup) + buses[m] = !backups[m] && a.claims(ctx, m, SeatBus) + } + a.mu.Lock() + defer a.mu.Unlock() + reverts := map[string]bool{} + for _, m := range modules { + reverts[m] = a.revertLocked(m) + } + rows := make([]rowOf, 0, len(modules)) + why := map[string]string{} + for _, m := range modules { + w := a.wants[m].Want + r := rowOf{module: m, class: classRest} + switch { + case m == NodeModule: + r.class, why[m] = classNode, "the node's own composition, which every module's openings and accounts depend on" + case m == own && own != "": + r.class, why[m] = classOwn, "the node-engine's own module, applied last" + case reverts[m]: + r.class, why[m] = classRevert, "a revert to the build "+w.Fp+", applied first" + case backups[m]: + r.class, why[m] = classBackup, "holds the seat "+SeatBackup+", applied first" + case buses[m]: + r.class, why[m] = classBus, "claims the seat "+SeatBus+", the bus module, applied first" + case w.Pipeline != "" && w.Rank > 0: + r.class, r.pipeline, r.rank = classPipeline, w.Pipeline, w.Rank + r.branch, r.source = pipelineParts(w.Pipeline) + why[m] = fmt.Sprintf("rank %d of the pipeline %s", w.Rank, w.Pipeline) + default: + why[m] = "in no pipeline: by name" + } + rows = append(rows, r) + } + sort.SliceStable(rows, func(i, j int) bool { + x, y := rows[i], rows[j] + if x.class != y.class { + return x.class < y.class + } + if x.class == classPipeline { + if x.source != y.source { + return x.source < y.source + } + if x.branch != y.branch { + return x.branch < y.branch + } + if x.rank != y.rank { + return x.rank < y.rank + } + } + return x.module < y.module + }) + return rows, why +} + +// ApplyOrder is the order this machine's node-engine will apply its changed wants in, one row per want not applied yet (the verb +// apply-order of the seat node-engine, design 47 H §771). +func (a *Agent) ApplyOrder(ctx context.Context) []nodeengine.ApplyOrderAnswerOrderItem { + a.mu.Lock() + var modules []string + for m := range a.wants { + if a.changedLocked(m) { + modules = append(modules, m) + } + } + a.mu.Unlock() + rows, why := a.orderOf(ctx, modules) + out := make([]nodeengine.ApplyOrderAnswerOrderItem, 0, len(rows)) + a.mu.Lock() + defer a.mu.Unlock() + for i, r := range rows { + w := a.wants[r.module].Want + item := nodeengine.ApplyOrderAnswerOrderItem{Module: r.module, Position: int64(i + 1), Why: why[r.module], Waits: a.waitsOnLocked(r.module)} + if r.class == classPipeline || (w.Pipeline != "" && w.Rank > 0) { + item.Pipeline, item.Rank = w.Pipeline, w.Rank + } + out = append(out, item) + } + return out +} + +// placingHave writes a module's have held for the lower rank of its pipeline it waits on, once per distinct wait, the module +// keeping what it runs (design 47 H §771, H-A-59). The reason `placing` is a hold the engine judges again at a start. +func (a *Agent) placingHave(ctx context.Context, module string, waits []string) { + on := strings.Join(waits, ", ") + words := fmt.Sprintf("%s waits for %s of its pipeline, of a lower rank, to be applied on this machine", module, on) + a.mu.Lock() + if a.placing == nil { + a.placing = map[string]string{} + } + same := a.placing[module] == on + a.placing[module] = on + prev, runs := a.running[module] + a.mu.Unlock() + if same { + return + } + if !runs { + if h, found, _ := a.readHave(ctx, module); found { + prev.Fp, prev.Composed = h.FP, h.Composed + } + } + a.env.Say(words) + a.writeHave(ctx, Have{Module: module, FP: prev.Fp, Composed: prev.Composed, Phase: string(nodeengineclient.PhaseHeld), Detail: words, + Wait: &nodeengine.Wait{Owner: nodeengine.Seat, Step: nodeengine.WaitStepPlacing, Reason: nodeengine.WaitStepPlacing, On: on, Since: a.now(), Words: words}}) +} + +// endPlacing ends the wait of a module whose want was held for a lower rank and is judged again: when its have still carries the +// wait and the module runs a build, the have says it running again, the wait ended. +func (a *Agent) endPlacing(ctx context.Context, module string) { + h, found, _ := a.readHave(ctx, module) + if !found || h.Wait == nil || h.Wait.Reason != nodeengine.WaitStepPlacing || h.FP == "" { + return + } + a.writeHave(ctx, Have{Module: module, FP: h.FP, Composed: h.Composed, Phase: string(nodeengineclient.PhaseRunning)}) +} diff --git a/internal/agent/parts.go b/internal/agent/parts.go index 07f7785b..28ed146f 100644 --- a/internal/agent/parts.go +++ b/internal/agent/parts.go @@ -1,6 +1,10 @@ package agent -import "strings" +import ( + "strings" + + "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" +) // EntryAsked and EntryMissing open the detail of a have held for the entry the want names (design 47 G section 421 and // section 614): the entry is asked of the catalog half and not yet answered, or the half answered that it holds none. Both @@ -11,14 +15,14 @@ const ( ) // judgedAgain says a held have is a hold the node-engine judges again at a start, not one that waits for the operator's answer: -// its wait's reason (the structured field the have carries) is that its entry is not held (§421), whatever words its detail +// its wait's reason (the structured field the have carries) is that its entry is not held (§421) or it waits for a lower rank of its pipeline (§771), whatever words its detail // opens with. Only a failed backup or restore point waits for an answer (ADR 0568 §4); g14, 2026-11-18: feh held "whether ..." with the reason entry-missing was kept the same way. func judgedAgain(h Have) bool { if h.Wait == nil { return false } switch h.Wait.Reason { - case strings.TrimSuffix(EntryAsked, ":"), strings.TrimSuffix(EntryMissing, ":"): + case strings.TrimSuffix(EntryAsked, ":"), strings.TrimSuffix(EntryMissing, ":"), nodeengine.WaitStepPlacing: return true } return false diff --git a/internal/selfcompose/selfcompose.go b/internal/selfcompose/selfcompose.go index 9bc1ea7c..a6c9d76b 100644 --- a/internal/selfcompose/selfcompose.go +++ b/internal/selfcompose/selfcompose.go @@ -1473,6 +1473,19 @@ func (c *Composer) HoldsData(_ context.Context, module string) (data, known bool return len(a.Manifest.DataItems()) > 0, true } +// Claims says whether the manifest of the build the node's want of module names claims the seat, and whether that manifest is +// read: the holder of the seat node-backup and the bus module are applied first (design 47 H §771). +func (c *Composer) Claims(_ context.Context, module, seat string) (claims, known bool) { + c.mu.Lock() + fp := c.wants[module].Fp + c.mu.Unlock() + a := c.runningManifest(c.env.Node, module, fp) + if !a.Known { + return false, false + } + return a.Manifest.ClaimsSeat(seat), true +} + // taken is a module's manifest as this engine reads it (novox/hq ADR 0578 §3): decoded leniently, judging nothing, with // the indexer's verdict from the module's value (a missing one is accepted). held is why the module is held, "" when it is // not: a manifest the indexer refused, or one not read past a field this engine does not know. A field set aside is said diff --git a/internal/selfcompose/versions_test.go b/internal/selfcompose/versions_test.go index bda20c6d..b28d3d71 100644 --- a/internal/selfcompose/versions_test.go +++ b/internal/selfcompose/versions_test.go @@ -118,3 +118,22 @@ func aWantNamingItsVersionIsResolvedThroughTheRegistrySeats(t *testing.T) { } } } + +// Design 47 H §771: the order applies the holder of a seat first, found by the claim of the manifest of the build the want names. +func TestAModulesClaimsAreReadFromTheEntryOfItsWantsBuild(t *testing.T) { + fp := meshcatalogclient.SourcePrefix2 + strings.Repeat("a", 64) + c := New(Env{}) + c.keptEnt = map[string]keptEntry{} + c.wants["bus"] = meshwants.WantsByWantNodeModuleValue{Fp: fp} + c.keptEnt[fp] = keptEntry{entry: meshcatalog.CatalogEntry{Module: "bus", Fp: fp, + Manifest: map[string]any{"module": "bus", "version": "1", "claims": []any{map[string]any{"name": "mesh-broker"}}}}} + if claims, known := c.Claims(context.Background(), "bus", "mesh-broker"); !claims || !known { + t.Errorf("the bus claims mesh-broker: claims %v, known %v", claims, known) + } + if claims, known := c.Claims(context.Background(), "bus", "node-backup"); claims || !known { + t.Errorf("the bus claims no node-backup: claims %v, known %v", claims, known) + } + if claims, known := c.Claims(context.Background(), "ghost", "mesh-broker"); claims || known { + t.Errorf("a module with no want has no manifest read: claims %v, known %v", claims, known) + } +} From ad69a53032f826194c94972b1dfc5623bc950e68 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 02:38:54 +0100 Subject: [PATCH 4/9] MH-4: the verb apply-order of the seat node-engine answers the order of the applies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One row per unapplied changed want: module, pipeline, rank, position, why, waits. Served beside process-builds and claimed in module.json. Builds: design 47 H §771; H-A-46 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- cmd/mesh-host/engineseat.go | 14 ++++++++++++++ cmd/mesh-host/main.go | 1 + internal/link/handacts.go | 9 +++++++++ internal/link/handover_test.go | 5 +++++ module.json | 1 + 5 files changed, 30 insertions(+) diff --git a/cmd/mesh-host/engineseat.go b/cmd/mesh-host/engineseat.go index 00588ed0..e0decefb 100644 --- a/cmd/mesh-host/engineseat.go +++ b/cmd/mesh-host/engineseat.go @@ -309,6 +309,20 @@ func compositionFrom(current *agentNow, withheld func(ctx context.Context, modul } } +// applyOrderFrom answers the verb apply-order from the node agent that runs now (design 47 H §771): the order it applies its changed +// wants in, with why; refused in words while none does. +func applyOrderFrom(current *agentNow) func() (any, error) { + return func() (any, error) { + ag := current.get() + if ag == nil { + return nil, errors.New("this engine's node agent has not started, so it applies no want yet") + } + ctx, cancel := context.WithTimeout(context.Background(), compositionReadFor) + defer cancel() + return nodeengine.ApplyOrderAnswer{Order: ag.ApplyOrder(ctx)}, nil + } +} + // composeReadFor bounds the verb compose's wait for its pass: a pass that waits on a seat longer says what it waits on. const composeReadFor = 2 * time.Minute diff --git a/cmd/mesh-host/main.go b/cmd/mesh-host/main.go index 6c5d5d55..fb0749f4 100644 --- a/cmd/mesh-host/main.go +++ b/cmd/mesh-host/main.go @@ -1029,6 +1029,7 @@ func runLink(ctx context.Context, opts options) error { current := &agentNow{} queue.Acts.Composition = compositionFrom(current, queue.WithheldOf) queue.Acts.Compose = composeFrom(current, &composerNow) + queue.Acts.ApplyOrder = applyOrderFrom(current) queue.Acts.Packages = packagesFrom(mine.Node, queue, &composerNow) queue.Acts.FirstViews, queue.Acts.EntryAgain = firstViewsFrom(&composerNow), entryAgainFrom(&composerNow) queue.Acts.SeatList, queue.Acts.SeatListAgain = seatListRead, seatListAgain diff --git a/internal/link/handacts.go b/internal/link/handacts.go index a083f638..3e0f0706 100644 --- a/internal/link/handacts.go +++ b/internal/link/handacts.go @@ -55,6 +55,8 @@ const ( ActManifestReads = nodeengine.VerbManifestReads // ActSeatList reads the seat list this engine holds and what it waits for; ActSeatListAgain makes it read the list now // (novox/hq ADR 0636 §7). The node-engine seat's definition carries both verbs. + // ActApplyOrder reads the order this engine applies its changed wants in, with why (design 47 H §771). + ActApplyOrder = nodeengine.VerbApplyOrder ActSeatList = nodeengine.VerbSeatList ActSeatListAgain = nodeengine.VerbSeatListAgain // ActFirstViews reads the node-engine's first views: the views it follows, the entries it keeps of the builds its wants @@ -171,6 +173,8 @@ type HandActs struct { // engine keeps none of. FirstViews func() (any, error) EntryAgain func(ctx context.Context, fingerprint string) error + // ApplyOrder answers the verb apply-order: the order the engine applies its changed wants in, one row per want not applied yet. + ApplyOrder func() (any, error) // ProcessBuilds answers the build each process of the node was started with, narrowed to a module when one is given. ProcessBuilds func(module string) (any, error) // ComposeCandidate composes a check's candidate (the indexer's candidate key) on this node in shadow and answers per @@ -264,6 +268,11 @@ func (h *HandActs) Call(c EngineCall) (any, error) { arg("owner"), arg("state")) case ActEntryAgain: return h.AskEntryAgain(c.Caller, arg("fingerprint"), arg("why")) + case ActApplyOrder: + if h.ApplyOrder == nil { + return nil, errors.New("this engine applies no want yet: its node agent has not started") + } + return h.ApplyOrder() case ActProcessBuilds: if h.ProcessBuilds == nil { return nil, errors.New("this engine reads no process yet: its node agent has not started") diff --git a/internal/link/handover_test.go b/internal/link/handover_test.go index 1d386ef5..3b502ed8 100644 --- a/internal/link/handover_test.go +++ b/internal/link/handover_test.go @@ -281,6 +281,10 @@ func TestALinkThatHearsHandOversIsGivenTheQueues(t *testing.T) { } return nil }, + // Design 47 H §771: the order the engine applies its changed wants in. + ApplyOrder: func() (any, error) { + return nodeengine.ApplyOrderAnswer{Order: []nodeengine.ApplyOrderAnswerOrderItem{}}, nil + }, // Design 47: the build each process was started with, narrowed by module. ProcessBuilds: func(module string) (any, error) { return map[string]any{"processes": []any{}, "module": module}, nil @@ -330,6 +334,7 @@ func TestALinkThatHearsHandOversIsGivenTheQueues(t *testing.T) { {"entry-again", "mesh.seat.node-engine.call.entry-again.n1.person~jochen " + `{"fingerprint":"src2:a","why":"doubt"}`, `"fingerprint":"src2:a","v":1,"why":"doubt"},"read":"first-views"`}, {"entry-again", "mesh.seat.node-engine.call.entry-again.n1.person~jochen " + `{"fingerprint":"src2:gone","why":"doubt"}`, `no entry of src2:gone is kept`}, {"entry-again", "mesh.seat.node-engine.call.entry-again.n1.person~jochen " + `{"fingerprint":"src2:a"}`, `entry-again names the build's fingerprint and why`}, + {"apply-order", "mesh.seat.node-engine.call.apply-order.n1.person~jochen", `"order":[]`}, {"process-builds", "mesh.seat.node-engine.call.process-builds.n1.person~jochen " + `{"module":"web"}`, `"module":"web","processes":[]`}, {"process-builds", "mesh.seat.node-engine.call.process-builds.n1.ace~messenger", `"processes":[]`}, {"unserved", "mesh.seat.node-engine.call.unserved.n1.x", `"error":"the node seat node-engine serves no verb \"unserved\""`}, diff --git a/module.json b/module.json index 6697a3a5..8f80630e 100644 --- a/module.json +++ b/module.json @@ -30,6 +30,7 @@ "compose", "compose-candidate", "manifest-reads", + "apply-order", "seat-list", "seat-list-again", "first-views", From 6e4d0c7f47cbe167cae2198c30c5c627239028ad Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 02:40:03 +0100 Subject: [PATCH 5/9] MH-5: the whole test of the apply order against a real bus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A want of rank 2 whose composition is made first is held in a wait of step placing on the module of rank 1 of its pipeline; rank 1 is applied first, rank 2 after it, and the wait ends. Builds: design 47 H §771, §774; H-A-59 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- cmd/mesh-host/nodeagent_integration_test.go | 89 +++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/cmd/mesh-host/nodeagent_integration_test.go b/cmd/mesh-host/nodeagent_integration_test.go index d102635d..e7b4f8da 100644 --- a/cmd/mesh-host/nodeagent_integration_test.go +++ b/cmd/mesh-host/nodeagent_integration_test.go @@ -357,6 +357,95 @@ func TestNatsANodeTheAssignmentsNameComposesAndAppliesItsOwn(t *testing.T) { h8back(t, b, assignment, resolved, candidates, hkey) } +// Design 47 H §771 (acceptance test 113, the node-engine's half): against a real bus, a want of rank 2 whose composition is made first +// is held, in its have, in a wait of step placing on the module of rank 1 of its pipeline, and the node-engine applies the module of +// rank 1 first and the module of rank 2 after it; the wait ends with the apply. The read apply-order answers the order meanwhile. +func TestNatsAWantOfAHigherRankWaitsForTheLowerRankOfItsPipeline(t *testing.T) { + b := newItBed(t) + kvOf := func(bucket string) nats.KeyValue { + kv, err := b.js.CreateKeyValue(&nats.KeyValueConfig{Bucket: bucket, History: 5}) + if err != nil { + t.Fatal(err) + } + return kv + } + assignment, manifests := kvOf(buckets.Assignments), kvOf(buckets.Manifests) + kvOf(selfcompose.ResolvedBucket) + kvOf(buckets.ProposalCandidates) + kvOf(link.PackagesBucket) + manifest := func(module string) string { + return `{"module":"` + module + `","version":"1","resources":[{"id":"conf","type":"file","path":"` + + filepath.Join(b.dir, module+".conf") + `","mode":"0644","content":"` + module + `\n"}]}` + } + rec, _ := nec.EncodeHaveNode(nodeengine.HaveByNodeNodeValue{Record: &nodeengine.NodeRecord{Node: itNode, Capabilities: []string{"service-manager", "package-manager"}}}) + hkey, _ := nec.HaveNodeKey(itNode) + if _, err := b.haves.Put(hkey, rec); err != nil { + t.Fatal(err) + } + pipeline := "main.7" + fps := map[string]string{"first": fpIt("a"), "second": fpIt("b")} + ranks := map[string]int64{"first": 1, "second": 2} + for module, fp := range fps { + man := manifest(module) + mraw, _ := meshcatalogclient.EncodeManifest(meshcatalog.ManifestsByDigestValue{Module: module, Manifest: man}) + mkey, _ := meshcatalogclient.ManifestsKey(meshcatalogclient.ManifestDigest([]byte(man))) + if _, err := manifests.Put(mkey, mraw); err != nil { + t.Fatal(err) + } + raw, err := bucketstest.Want(meshwants.WantsByWantNodeModuleValue{Fp: fp, Self: true, Pipeline: pipeline, Rank: ranks[module]}) + if err != nil { + t.Fatal(err) + } + if _, err := b.wants.Put(meshwants.WantsByWantNodeModuleKey(itNode, module), raw); err != nil { + t.Fatal(err) + } + } + // Only the entry of the module of rank 2 is held: its composition is made first. + b.registerEntry("second", fps["second"], manifest("second")) + places, _ := meshmoduleassignerclient.AssignmentsValues(meshmoduleassigner.Assignments{Node: itNode, + Modules: []meshmoduleassigner.PlacedModule{{Module: "first"}, {Module: "second"}}}) + stop := b.start() + defer stop() + for key, value := range places { + if _, err := assignment.Put(key, value); err != nil { + t.Fatal(err) + } + } + within(t, 10*time.Second, "the module of rank 2 is not held in a wait of step placing on the module of rank 1", func() bool { + h := b.have("second") + return h.Phase == nec.PhaseHeld && h.Wait != nil && h.Wait.Step == nodeengine.WaitStepPlacing && h.Wait.On == "first" + }) + if b.file("second") != "" { + t.Fatal("the module of rank 2 was applied before the module of rank 1") + } + b.registerEntry("first", fps["first"], manifest("first")) + if err := composerNow.Load().EntryAgain(context.Background(), fps["first"]); err != nil { + t.Fatal(err) + } + within(t, 10*time.Second, "the modules of both ranks are not applied", func() bool { return b.file("first") != "" && b.file("second") != "" }) + within(t, 5*time.Second, "the wait of the module of rank 2 does not end", func() bool { + h := b.have("second") + return h.Phase == nec.PhaseRunning && h.Wait == nil + }) + // The first have saying a module runs is the order of the applies: the stream's sequence is the bus's own. + runningAt := func(module string) uint64 { + key, _ := nec.HaveKey(itNode, module) + history, err := b.haves.History(key) + if err != nil { + t.Fatal(err) + } + for _, e := range history { + if h, err := nec.DecodeHave(e.Value()); err == nil && h.Phase == nec.PhaseRunning && h.Fp == fps[module] { + return e.Revision() + } + } + return 0 + } + if first, second := runningAt("first"), runningAt("second"); first == 0 || second == 0 || first > second { + t.Fatalf("the first have saying a module runs is at %d for rank 1 and %d for rank 2: rank 1 is applied first", first, second) + } +} + // h8once is issue 1126, 2026-10-28 (shanks answered probe/1126-seed-7 at revision 84 every 13-17 s, its bus flooded): // a candidate revision is answered once. The node's own answer written, a module's have whose health words alone move // (each look rewrites them) and a config value written again with the value it held answer nothing again; the From ee017fe30661b98a3c58566091eb6818b53c4ac2 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 02:41:48 +0100 Subject: [PATCH 6/9] MH-6: the test budget: three pairs of tests covering one rule twice become subtests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unit test functions: 1,719 before H1, 1,717 after (three fewer by the merges, one added for the claims read); integration tests: 10 before, 11 after (budget 50). The module stays over the unit budget of 500. Builds: design 47 H §774 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- internal/agent/agent_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/agent/agent_test.go b/internal/agent/agent_test.go index f7b5cd1e..65a32c23 100644 --- a/internal/agent/agent_test.go +++ b/internal/agent/agent_test.go @@ -373,10 +373,11 @@ func TestStartingOnWhatTheKeptDeclarationHoldsAppliesNothing(t *testing.T) { if got := b.appliedList(); len(got) != 0 { t.Fatalf("a module that already runs what the want names was applied: %v", got) } + t.Run("starting on its own have applies nothing", testStartingOnItsOwnHaveAppliesNothing) } // What the node-engine itself last applied is what runs after a restart, not the kept declaration. -func TestStartingOnItsOwnHaveAppliesNothing(t *testing.T) { +func testStartingOnItsOwnHaveAppliesNothing(t *testing.T) { t.Run("1957: an engine start reads the machine's facts", testAnEngineStartReconcilesAModuleFromTheMachinesFacts) t.Run("says the have again", testStartingOnItsOwnHaveSaysTheHaveAgainSoItsHealthIsThisEngines) // An apply that failed is not what runs, though its have names the want's build and digest: the agent starting on @@ -698,6 +699,7 @@ func TestAFailedApplyIsRetriedOnlyByAChangeOfEitherKey(t *testing.T) { } }) } + t.Run("a failed apply is applied again after a restart, whatever is kept", testAFailedApplyIsAppliedAgainAfterARestartWhateverIsKept) } // R6-A AC5: a data module that ran before asks its backup before any resource changes; a refusal holds it, nothing is @@ -1111,6 +1113,7 @@ func TestApplyingOneModuleHoldsOutTheModulesStillRunningFromTheKeptDeclaration(t if len(names) != 2 || !strings.Contains(strings.Join(names, ","), "db") { t.Fatalf("the others of web were %v: db and the node's own run from the kept declaration", names) } + t.Run("the node's own apply holds out a module that moved to its own composition", testTheNodesOwnApplyHoldsOutAModuleThatMovedToItsOwnComposition) } // Everything is what runs: the agent's compositions and the kept resources of each module it does not hold. @@ -1297,7 +1300,7 @@ func (m *memApplied) get(module string) []byte { // A failed apply is applied again after a restart even when the kept declaration holds the composition: once this // node-engine wrote its haves, they are what it knows (the kept declaration is only for the first start after the switch). -func TestAFailedApplyIsAppliedAgainAfterARestartWhateverIsKept(t *testing.T) { +func testAFailedApplyIsAppliedAgainAfterARestartWhateverIsKept(t *testing.T) { b := newBed(t) fp := fpOf("a") ck, craw, dig := composition(t, "web", fp, false, file("web", "x", "1")) @@ -1335,7 +1338,7 @@ func TestAHaveWithNoCompositionDefersToTheKeptDeclaration(t *testing.T) { // run yet (issue 1945, live on 2026-10-25 at 02:32: shanks' node-engine applied a node's own composition that no longer // carried systemd-resolved, whose own composition waited for its credential, and removed its guard, so the machine lost // its resolver). -func TestTheNodesOwnApplyHoldsOutAModuleThatMovedToItsOwnComposition(t *testing.T) { +func testTheNodesOwnApplyHoldsOutAModuleThatMovedToItsOwnComposition(t *testing.T) { b := newBed(t) fp := fpOf("b") // systemd-resolved's own composition is written; no want names it yet. From dd2b3a16df4aa1427a2fa94c25ec71bd01c0f497 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 03:09:22 +0100 Subject: [PATCH 7/9] MH-2b: the node-engine reads the want by the real contract: composed, kept-on and newest go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- cmd/mesh-host/nodeagent_integration_test.go | 2 +- internal/agent/agent.go | 37 ++++++++-------- internal/agent/agent_test.go | 47 +++------------------ internal/agent/composition.go | 2 +- internal/agent/kept.go | 2 +- internal/agent/kept_test.go | 4 +- internal/agent/order.go | 2 +- internal/selfcompose/entries.go | 20 +-------- internal/selfcompose/entries_test.go | 3 +- internal/selfcompose/kept.go | 44 +++---------------- internal/selfcompose/kept_test.go | 30 ------------- internal/selfcompose/selfcompose.go | 6 +-- internal/selfcompose/selfcompose_test.go | 2 +- internal/selfcompose/versions_test.go | 7 --- 14 files changed, 43 insertions(+), 165 deletions(-) diff --git a/cmd/mesh-host/nodeagent_integration_test.go b/cmd/mesh-host/nodeagent_integration_test.go index e7b4f8da..4c49ab81 100644 --- a/cmd/mesh-host/nodeagent_integration_test.go +++ b/cmd/mesh-host/nodeagent_integration_test.go @@ -270,7 +270,7 @@ func fpDigest(c string) string { return "sha256:" + strings.Repeat(c, 64) } func (b *itBed) want(module, fp, digest, backup string) { b.t.Helper() - 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 { b.t.Fatal(err) } diff --git a/internal/agent/agent.go b/internal/agent/agent.go index 9ece1a25..e2520acb 100644 --- a/internal/agent/agent.go +++ b/internal/agent/agent.go @@ -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] diff --git a/internal/agent/agent_test.go b/internal/agent/agent_test.go index 65a32c23..f5eec6b9 100644 --- a/internal/agent/agent_test.go +++ b/internal/agent/agent_test.go @@ -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 diff --git a/internal/agent/composition.go b/internal/agent/composition.go index 9856382f..16c78b3f 100644 --- a/internal/agent/composition.go +++ b/internal/agent/composition.go @@ -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 diff --git a/internal/agent/kept.go b/internal/agent/kept.go index 9645ef5b..185e9a0d 100644 --- a/internal/agent/kept.go +++ b/internal/agent/kept.go @@ -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() diff --git a/internal/agent/kept_test.go b/internal/agent/kept_test.go index efecc12d..3fab81eb 100644 --- a/internal/agent/kept_test.go +++ b/internal/agent/kept_test.go @@ -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) diff --git a/internal/agent/order.go b/internal/agent/order.go index 23874efd..3bd9b08a 100644 --- a/internal/agent/order.go +++ b/internal/agent/order.go @@ -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) } diff --git a/internal/selfcompose/entries.go b/internal/selfcompose/entries.go index bc0311e9..d91053cc 100644 --- a/internal/selfcompose/entries.go +++ b/internal/selfcompose/entries.go @@ -269,12 +269,6 @@ func (c *Composer) wantedBuilds() map[string]bool { if module != agent.NodeModule && strings.HasPrefix(w.Fp, meshcatalogclient.SourcePrefix2) { out[w.Fp] = true } - // The build its want says is being built describes, for resolution alone, a module whose wanted build has no entry (A-405, A-407). - if module != agent.NodeModule && strings.HasPrefix(w.Newest, meshcatalogclient.SourcePrefix2) { - if _, named := out[w.Newest]; !named { - out[w.Newest] = false - } - } } for _, mods := range c.heard { for _, run := range mods { @@ -468,19 +462,7 @@ func (c *Composer) layModules() { lay(module, w.Fp) continue } - // A module the node runs whose wanted build has no entry stands as the build its want says is being built, for resolution - // alone: what that entry provides, claims and requires stands for the running build. Its want stays held (entryHolds), at - // the want's fingerprint, and nothing new of it is composed (A-405, A-407). - if k, ok := c.keptEnt[w.Newest]; ok && w.Newest != "" && k.entry.Module != "" && c.runsHere(module) { - lay(module, w.Newest) - if m, laid := modules[module]; laid { - m.Fp2 = w.Fp - modules[module] = m - said = append(said, fmt.Sprintf("%s runs a build whose entry the catalog half does not hold, so the node resolves around it as the build %s its want says is being built; its want stays held", module, w.Newest)) - } - continue - } - // Running here with no entry of its wanted build and none of the newest: it stands, for resolution alone, as the manifest of + // Running here with no entry of its wanted build: it stands, for resolution alone, as the manifest of // the build it runs, from the one place (A-484), so the module that requires what it provides is no "nothing provides"; // its want stays held. An answer from the entry of the running build is not laid here: that entry is laid where its module is heard // (above), and laying it for a module that is not (heard nowhere yet, its want moving) made the node compose and apply the move twice diff --git a/internal/selfcompose/entries_test.go b/internal/selfcompose/entries_test.go index 5c189589..abf74d75 100644 --- a/internal/selfcompose/entries_test.go +++ b/internal/selfcompose/entries_test.go @@ -283,7 +283,6 @@ func runningModuleWithoutEntryStandsAsTheNewestBuild(t *testing.T) { have string // A-482: the phase its have says, naming the build it runs ("" for none) named string // A-480a: the manifest its running event names ("held": one this node holds, "unread": one it does not) }{ - {"runs, newest entry held", true, newest, true, true, old, false, false, "", ""}, {"not running here", false, newest, true, false, old, false, false, "", ""}, {"names no newer build", true, "", false, false, old, false, false, "", ""}, {"newest entry not held", true, newest, false, false, old, false, false, "", ""}, @@ -310,7 +309,7 @@ func runningModuleWithoutEntryStandsAsTheNewestBuild(t *testing.T) { }) c := New(env) c.mu.Lock() - c.wants["postgres"] = meshwants.WantsByWantNodeModuleValue{Fp: old, Newest: tc.newest} + c.wants["postgres"] = meshwants.WantsByWantNodeModuleValue{Fp: old} c.assignments["n1"] = meshmoduleassigner.Assignments{Node: "n1", Modules: []meshmoduleassigner.PlacedModule{{Module: "postgres"}}} if tc.runs { c.heard = map[string]map[string]heardRun{"n1": {"postgres": {fingerprint: old}}} diff --git a/internal/selfcompose/kept.go b/internal/selfcompose/kept.go index ac9487ba..b8366d49 100644 --- a/internal/selfcompose/kept.go +++ b/internal/selfcompose/kept.go @@ -1,42 +1,10 @@ package selfcompose -import ( - "context" - "strings" -) +import "context" -// KeptBuildOf is the node that keeps the build a module is wanted at, and its fingerprint, for the artifact store's -// holder (design 47 G section 271, 526, A-50): the want's `kept-on` and nothing else names it, the builder's builds being -// no read of the node-engine's (section 421). kept is false when the module has no want, its want names no keeping node, -// or the digests its version resolves to do not name the digest ("sha256:" and 64 hex digits, or bare): the artifact is then fetched from the store. -func (c *Composer) KeptBuildOf(_ context.Context, module, digest string) (node, fp string, kept bool, err error) { - c.mu.Lock() - w, ok := c.wants[module] - c.mu.Unlock() - if !ok || w.Fp == "" || w.KeptOn == "" { - return "", "", false, nil - } - var parts map[string]string - if w.Version != "" { - // A want names its version alone, and its digests through the registry seats (design 47 H §750): the resolution the composing made. - c.mu.Lock() - r := c.resolved[resolvedKey{module, w.Fp, w.Version}] - c.mu.Unlock() - if r.parts == nil { - return "", "", false, nil - } - parts = r.parts - } - if len(parts) > 0 { - named := false - for _, d := range parts { - if strings.TrimPrefix(d, "sha256:") == strings.TrimPrefix(digest, "sha256:") { - named = true - } - } - if !named { - return "", "", false, nil - } - } - return w.KeptOn, w.Fp, true, nil +// KeptBuildOf is the node that keeps the build a module is wanted at, for the artifact store's holder (design 47 G section 271, +// 526, A-50). A want names a version and no keeping node any more (design 47 H §750, H-A-37: `kept-on` goes), so none is kept +// here and the artifact is fetched from the store. +func (c *Composer) KeptBuildOf(_ context.Context, _, _ string) (node, fp string, kept bool, err error) { + return "", "", false, nil } diff --git a/internal/selfcompose/kept_test.go b/internal/selfcompose/kept_test.go index 369b722e..dd08a4b8 100644 --- a/internal/selfcompose/kept_test.go +++ b/internal/selfcompose/kept_test.go @@ -3,41 +3,11 @@ package selfcompose import ( "context" "slices" - "strings" "testing" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" ) -// The node that keeps a kept build is the want's kept-on alone, for an artifact its parts name (design 47 G 526, A-50). -func TestTheKeepingNodeIsTheWantsKeptOn(t *testing.T) { - kd := strings.Repeat("6", 64) - for _, row := range []struct { - name, digest string - want *meshwants.WantsByWantNodeModuleValue - node string - kept bool - }{ - {"kept, by its bare digest", kd, &meshwants.WantsByWantNodeModuleValue{Fp: "f1", KeptOn: "n3", Version: "1"}, "n3", true}, - {"kept, by the declared digest", "sha256:" + kd, &meshwants.WantsByWantNodeModuleValue{Fp: "f1", KeptOn: "n3", Version: "1"}, "n3", true}, - {"a digest the resolved version does not name", "sha256:" + strings.Repeat("7", 64), &meshwants.WantsByWantNodeModuleValue{Fp: "f1", KeptOn: "n3", Version: "1"}, "", false}, - {"a want naming no keeping node", kd, &meshwants.WantsByWantNodeModuleValue{Fp: "f1", Version: "1"}, "", false}, - {"no want of the module", kd, nil, "", false}, - } { - c := &Composer{wants: map[string]meshwants.WantsByWantNodeModuleValue{}} - if row.want != nil { - c.wants["db"] = *row.want - // The digests the want's version resolves to through the registry seats (design 47 H §750). - c.resolved = map[resolvedKey]versionParts{{"db", "f1", "1"}: {parts: map[string]string{"db:p": "sha256:" + kd}}} - } - node, fp, kept, err := c.KeptBuildOf(context.Background(), "db", row.digest) - if err != nil || node != row.node || kept != row.kept || (kept && fp != "f1") { - t.Errorf("%s: node %q fp %q kept %v err %v", row.name, node, fp, kept, err) - } - } -} - // Design 47 G §558, A-275: a manifest's `invokes` in its long form {verb, fields} is read for its seat, and one of a form that // cannot be read is refused, never read as no seats. func TestSeatsOfReadsALongFormInvokeAndRefusesAnUnreadableOne(t *testing.T) { diff --git a/internal/selfcompose/selfcompose.go b/internal/selfcompose/selfcompose.go index a6c9d76b..49baf31b 100644 --- a/internal/selfcompose/selfcompose.go +++ b/internal/selfcompose/selfcompose.go @@ -778,7 +778,7 @@ func (c *Composer) entry(bucket, key string) (v any, has, known bool) { defer c.mu.Unlock() switch bucket { case buckets.Wants: - // A want is composed by its fingerprint, version and keeping node (design 47 G §525); its words, rule and newest + // A want is composed by its fingerprint and version (design 47 G §525); its words, rule and newest // change nothing composed. Judged by its fingerprint alone, a want that gained its version at the same fingerprint asked no // pass, and the agent waited for a composition never made (lead-47 2026-11-16, the indexer on novox). module := agent.NodeModule @@ -791,8 +791,8 @@ func (c *Composer) entry(bucket, key string) (v any, has, known bool) { } w, ok := c.wants[module] return struct { - Fp, Version, KeptOn string - }{w.Fp, w.Version, w.KeptOn}, ok, true + Fp, Version string + }{w.Fp, w.Version}, ok, true case buckets.Assignments: // Any key of a node, its node key, a module key or its legacy key, stands for the node's whole assignment: a // module key written before its node key names it changes nothing composed. diff --git a/internal/selfcompose/selfcompose_test.go b/internal/selfcompose/selfcompose_test.go index 98d689c5..8ae5dc5d 100644 --- a/internal/selfcompose/selfcompose_test.go +++ b/internal/selfcompose/selfcompose_test.go @@ -1211,7 +1211,7 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) { lemursDigest, _ = compositions.DigestOf(c) } } - wantRaw, err := bucketstest.Want(meshwants.WantsByWantNodeModuleValue{Fp: fp, Composed: lemursDigest}) + wantRaw, err := bucketstest.Want(meshwants.WantsByWantNodeModuleValue{Fp: fp}) if err != nil { t.Fatal(err) } diff --git a/internal/selfcompose/versions_test.go b/internal/selfcompose/versions_test.go index b28d3d71..65aab52a 100644 --- a/internal/selfcompose/versions_test.go +++ b/internal/selfcompose/versions_test.go @@ -109,13 +109,6 @@ func aWantNamingItsVersionIsResolvedThroughTheRegistrySeats(t *testing.T) { if calls != before { t.Errorf("%s: resolved again: %d calls, then %d", name, before, calls) } - c.wants["mail"] = meshwants.WantsByWantNodeModuleValue{Fp: fp, Version: row.want.Version, KeptOn: "g14", Self: true} - if node, _, kept, _ := c.KeptBuildOf(context.Background(), "mail", row.parts["mail:files"]); !kept || node != "g14" { - t.Errorf("%s: kept on %q %v, want g14", name, node, kept) - } - if _, _, kept, _ := c.KeptBuildOf(context.Background(), "mail", d("7")); kept { - t.Errorf("%s: a digest the want does not resolve to is said kept", name) - } } } From e4d098c4b9de7414a34401bc999cd31afd276f0d Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 04:24:53 +0100 Subject: [PATCH 8/9] MH-7: the node-engine reads a module of a catalog revision as accepted: no verdict is read The seat mesh-catalog keeps no state verdicts (H-A-79): frombus taken, the composer's parse and the composer's reading of a candidate drop the verdict branch and decode the manifest alone, a module in a catalog revision being accepted by being there; the composer no longer reads the request field Case.Verdicts (H-A-112). Tests that held a module by a verdict hold it by the decoder, or go. Builds: design 47 H, H-A-79, H-A-111, H-A-112 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- cmd/mesh-compose/main_test.go | 12 +- internal/compose/frombus/answer_rows_test.go | 20 - internal/compose/frombus/frombus.go | 21 +- .../frombus/frombustest/frombustest_test.go | 19 +- internal/compose/frombus/held_rows_test.go | 20 +- internal/composer/composer.go | 56 +-- internal/composer/composer_test.go | 69 +-- internal/selfcompose/candidate.go | 19 +- internal/selfcompose/candidate_test.go | 35 +- internal/selfcompose/selfcompose.go | 20 +- internal/selfcompose/selfcompose_test.go | 38 -- .../testdata/power-ca8d6f33.module.json | 452 ------------------ 12 files changed, 50 insertions(+), 731 deletions(-) delete mode 100644 internal/selfcompose/testdata/power-ca8d6f33.module.json diff --git a/cmd/mesh-compose/main_test.go b/cmd/mesh-compose/main_test.go index 07d216b7..12e43dbe 100644 --- a/cmd/mesh-compose/main_test.go +++ b/cmd/mesh-compose/main_test.go @@ -3,9 +3,6 @@ package main import ( "bytes" "encoding/json" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" - "github.com/novox/mesh-host/internal/buckets/bucketstest" "go/build" "os" "os/exec" @@ -110,8 +107,6 @@ func encode(t *testing.T, r composer.Request) []byte { func TestTheCommandWritesOneVerdictPerManifestAndMachine(t *testing.T) { r := request(t, composer.DepthResolve) r.Cases[0].Manifests["later"] = composer.Manifest{Raw: json.RawMessage(`{"module":"later","version":"1","shares":["x"]}`)} - r.Cases[0].Manifests["refused"] = composer.Manifest{Raw: json.RawMessage(`{"module":"refused","version":"1"}`)} - r.Cases[0].Verdicts = bucketstest.Raw(map[string]meshcatalog.VerdictsByDigestValue{"refused": {V: 1, Module: "refused", Judge: "src2:j", State: meshcatalogclient.VerdictRefused, Problems: []string{"it is wrong"}}}) code, v, stderr := runJSON(t, nil, encode(t, r)) if code != 0 { t.Fatalf("exit %d: %s", code, stderr) @@ -120,14 +115,11 @@ func TestTheCommandWritesOneVerdictPerManifestAndMachine(t *testing.T) { t.Fatalf("verdict = %+v", v) } c := v.Cases[0] - // ADR 0578 §5, §6: the composer judges nothing; it sets an unknown field aside and names it, and holds a manifest - // its verdict refuses, named in the indexer's words. + // ADR 0578 §5, §6: the composer judges nothing; it sets an unknown field aside and names it, and a manifest in the + // case is accepted by being there (design 47 H, H-A-112). if got := c.Manifests["later"]; !got.Accepted || !strings.Contains(got.SetAside, `"shares"`) { t.Errorf("the manifest with an unknown field reads %+v, want accepted naming the field set aside", got) } - if got := c.Manifests["refused"]; got.Accepted || !strings.Contains(got.Refused, "refused the manifest of refused: it is wrong") { - t.Errorf("the refused manifest reads %+v, want refused in the verdict's words", got) - } if got := c.Manifests["nats"]; !got.Accepted { t.Errorf("nats reads %+v, want accepted", got) } diff --git a/internal/compose/frombus/answer_rows_test.go b/internal/compose/frombus/answer_rows_test.go index d15ef72a..5a4011b1 100644 --- a/internal/compose/frombus/answer_rows_test.go +++ b/internal/compose/frombus/answer_rows_test.go @@ -270,26 +270,6 @@ func answerNamesEveryRefusalAndLeavesAnOldBuildToTheNode(t *testing.T) { if got, _ := compose.ContentDigest(compact.Bytes()); err == nil && (want == "" || read.ComposedHow.Manifests["spiegel"] != want || got != want) { t.Errorf("the manifest spiegel's build was made of: %v, want %s (compacted %s)", read.ComposedHow.Manifests, want, got) } - // Issue 1921: held by its manifest's verdict, spiegel is still held in what the node composes, and the input a check - // is answered with says what holds it and carries the build the node would compose it at, taken in while done; a - // node's own read takes in no build of it. - sp.Verdict, sp.Problems = meshcatalogclient.VerdictRefused, []string{"p"} - bb.modules["spiegel"] = sp - for _, done := range []bool{true, false} { - if !done { - bb.builds["spiegel "+sp.Fp2].State = builds.BuildBuilding - } - read, err = ComposingInput(ctx, bb, Mesh{}, Scope{Node: "n1"}, map[string]string{"lemurs": fp("e"), "spiegel": sp.Fp2}) - hold := read.Holds["spiegel"] - raw, _ = json.Marshal(hold.Built) - if err != nil || !read.Catalogue["spiegel"].Stubbed || hold.By != compose.HeldByVerdict || hold.Build != sp.Fp2 || - strings.Contains(string(raw), strings.Repeat("7", 64)) != done || (hold.Built == nil) == done { - t.Errorf("spiegel refused, its build done %v: %v, hold %+v (built %s)", done, err, hold, raw) - } - } - if own, err := Input(ctx, bb, Mesh{}, Scope{Node: "n1"}); err != nil || own.Holds["spiegel"] != (compose.Hold{By: compose.HeldByVerdict}) { - t.Errorf("a node's own read of spiegel refused: %v, hold %+v", err, own.Holds["spiegel"]) - } } // (C) Issue 1126, C5: what the others read of a module carried as it runs is what runs, never its stub's: the filter diff --git a/internal/compose/frombus/frombus.go b/internal/compose/frombus/frombus.go index 2f9866ef..b7240a0a 100644 --- a/internal/compose/frombus/frombus.go +++ b/internal/compose/frombus/frombus.go @@ -46,7 +46,6 @@ import ( "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" "git.novox.be/novox/mesh-contracts/identity-and-access/go/clients/meshvaultclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" engcomp "github.com/novox/mesh-host/internal/compositions" @@ -238,25 +237,19 @@ func InOwn(running []engcomp.Composed, p meshmoduleassigner.Assignments) []strin // Input is the composition input for s, read through r. // // **A refused manifest never ends the read** (novox/hq ADR 0578 §3): each manifest is decoded leniently -// (catalogue.Decode) and the indexer's verdict on it taken from its modules value (meshcatalogclient.TakeVerdict, a missing -// one accepted); a module whose manifest the indexer's judge refused, or whose bytes do not decode, stands in the +// (catalogue.Decode), a module in the catalog revision accepted by being there (H-A-111); a module whose bytes do not decode stands in the // catalogue as its stub (unusable), so what it provides and requires still shapes the rest, and is named with why in // the input's Refused; a field set aside is named in its SetAside. Every other module of the read goes on. func Input(ctx context.Context, r Reader, mesh Mesh, s Scope) (compose.Input, error) { return input(ctx, r, mesh, s, nil, nil) } -// taken is a module's manifest as a reader takes it (novox/hq ADR 0578 §3): decoded leniently, with the indexer's verdict -// from its modules value. A refused one, or bytes that do not decode, stands as its stub (unusable) and why says so; a -// manifest not read past a field it set aside holds its name alone and is held the same. +// taken is a module's manifest as a reader takes it: decoded leniently, the module accepted by being in the catalog revision +// (design 47 H, H-A-79, H-A-111: the seat keeps no state verdicts, the pipeline's validate step refuses a manifest before it is +// there). Bytes that do not decode, or a manifest not read past a field it set aside, stand as the stub (unusable) and why says so. // -// by is what holds it (compose.HeldByVerdict or compose.HeldByDecoder), empty when nothing does. -func taken(name string, raw []byte, m meshcatalog.ModulesByModuleValue) (man catalogue.Manifest, why, by string) { - if v := meshcatalogclient.ModuleVerdict(name, m); v != nil { - if refused, _ := meshcatalogclient.TakeVerdict(v); refused { - return unusable(name, raw), meshcatalogclient.VerdictWhy(*v), compose.HeldByVerdict - } - } +// by is what holds it (compose.HeldByDecoder), empty when nothing does. +func taken(name string, raw []byte) (man catalogue.Manifest, why, by string) { man, err := catalogue.Decode(raw) switch { case err != nil: @@ -416,7 +409,7 @@ func readBase(ctx context.Context, r Reader, mesh Mesh, s Scope) (base, error) { // follows (issue 774: power's bar item refused every node's composition, 2026-10-30; ADR 0578 §3: one refused // manifest silenced disk-load for 45 hours). It stands in as its stub, so what it provides and requires still // shapes the rest; it is held on the composing node where it is placed there, and elsewhere only its offer is read. - man, why, by := taken(name, raw, m) + man, why, by := taken(name, raw) if why != "" { named(&in.Refused, name, why) if in.Holds == nil { diff --git a/internal/compose/frombus/frombustest/frombustest_test.go b/internal/compose/frombus/frombustest/frombustest_test.go index 330db3dd..993966bf 100644 --- a/internal/compose/frombus/frombustest/frombustest_test.go +++ b/internal/compose/frombus/frombustest/frombustest_test.go @@ -39,9 +39,6 @@ func TestTheProvisionedMeshHandsAPlanWithItsProvision(t *testing.T) { why string // words backup's hold says // elsewhere leaves backup in the indexer's modules and places it on no node: nothing is held. elsewhere bool - // refused is the indexer's verdict on bad, a problem its judge found (novox/hq ADR 0578 §1): Plans then holds - // backup too, and never ends the read. - refused string // dataHeld says the data items' read holds backup too: a refusal it meets (a refused manifest, an unusable build, // an item composition refuses), not one only a plan meets. dataHeld bool @@ -55,14 +52,11 @@ func TestTheProvisionedMeshHandsAPlanWithItsProvision(t *testing.T) { {name: "a plan that refuses", bad: `{"module":"backup","version":"1","resources":[{"id":"conf","type":"file","path":"/etc/backup.conf",` + `"mode":"0600","content":"key=${secret:nope}"}]}`, why: "${secret:nope}"}, - {name: "an indexer's manifest the mesh refuses", bad: unusableItem, why: `"shows" is none of them`, - refused: `"shows" is none of them`, dataHeld: true}, // ADR 0578 §3: an accepted manifest whose data item its composition refuses is held by the culprit rule, in every read. {name: "a data item its composition refuses", bad: `{"module":"backup","version":"1","data":{"own":[{"id":"d","path":"${dir:nope}","class":"cache"}]}}`, why: "nope", dataHeld: true, dataOnly: true}, - {name: "an indexer's manifest the mesh refuses, placed elsewhere", bad: unusableItem, elsewhere: true, - refused: `"shows" is none of them`}, + {name: "a manifest the mesh refuses, placed elsewhere", bad: unusableItem, elsewhere: true}, } { b, err := Provisioned() if err != nil { @@ -77,10 +71,6 @@ func TestTheProvisionedMeshHandsAPlanWithItsProvision(t *testing.T) { digest := meshcatalogclient.ManifestDigest([]byte(row.bad)) b.Manifests[digest] = []byte(row.bad) b.Module["backup"] = meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: digest} - if row.refused != "" { - b.Module["backup"] = meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: digest, Verdict: meshcatalogclient.VerdictRefused, - Problems: []string{row.refused}} - } if row.built != "" { builtDigest := meshcatalogclient.ManifestDigest([]byte(row.built)) b.Manifests[builtDigest] = []byte(row.built) @@ -94,11 +84,8 @@ func TestTheProvisionedMeshHandsAPlanWithItsProvision(t *testing.T) { } continue } - plans, err := frombus.Plans(context.Background(), b, frombus.Mesh{}, frombus.Scope{Node: Node}) - switch { - case row.refused != "" && (err != nil || !planned(plans, "restic") || planned(plans, "backup")): - t.Errorf("%s: Plans did not hold the refused manifest alone: %v %v", row.name, plans, err) - case row.refused == "" && err == nil && !row.elsewhere: + _, err := frombus.Plans(context.Background(), b, frombus.Mesh{}, frombus.Scope{Node: Node}) + if err == nil && !row.elsewhere { t.Errorf("%s: Plans composed the node; the row does not refuse it", row.name) } } diff --git a/internal/compose/frombus/held_rows_test.go b/internal/compose/frombus/held_rows_test.go index 628d617e..b75ad4f9 100644 --- a/internal/compose/frombus/held_rows_test.go +++ b/internal/compose/frombus/held_rows_test.go @@ -39,7 +39,7 @@ func aNode(t *testing.T, manifests ...string) (*bus, map[string]string) { // Issue 774, 2026-10-30 19:30: a node refused whole after holding a module says what it held and why, since the last // refusal can be of the held module's stub (node-tools held, then "its build produced 0 bundle(s)", its own why unsaid). func aNodeRefusedWholeSaysWhatItHeld(t *testing.T) { - refused := `{"module":"power","version":"1","items":[{"collection":"contribution:node-bar:block","attributes":{"shows":"state"},"template":"files/a"}]}` + refused := `{"module":"power","version":"1","resources":"none"}` needs := `{"module":"lamp","version":"1","requires":["two-provide-this"]}` giverA := `{"module":"giver-a","version":"1","provides":[{"name":"two-provide-this"}]}` giverB := `{"module":"giver-b","version":"1","provides":[{"name":"two-provide-this"}]}` @@ -48,38 +48,28 @@ func aNodeRefusedWholeSaysWhatItHeld(t *testing.T) { placed := b.assignments["n1"] placed.Modules = placed.Modules[:2] b.assignments["n1"] = placed - refuse(b, "power", `"shows" is none of them`) _, _, held, err := Compose(context.Background(), b, Mesh{}, Scope{Node: "n1"}, fps) if err == nil || !strings.Contains(err.Error(), "choose one") || !strings.Contains(err.Error(), `held before: power: `) || - !strings.Contains(err.Error(), `"shows" is none of them`) { + !strings.Contains(err.Error(), `does not decode`) { t.Errorf("the node refused whole with %v (held %v), want lamp's refusal and power held before, with its why", err, held) } } -// refuse writes the indexer's refusal of module's manifest into its modules value (novox/hq ADR 0578 §1). -func refuse(b *bus, module string, problems ...string) { - m := b.modules[module] - m.Verdict, m.Problems = meshcatalogclient.VerdictRefused, problems - b.modules[module] = m -} - // ADR 0578 §3: the bus reader never ends a whole read on a refused manifest. Input, Plans and DataItems compose the rest // and hold the refused module, named with the indexer's words in Refused; a field the decoder does not know is set aside // and named, and its module composed. func aRefusedManifestNeverEndsTheRead(t *testing.T) { ok := `{"module":"lamp","version":"1","resources":[{"id":"d","type":"directory","path":"/srv/lamp","mode":"0700"}],` + `"data":{"own":[{"id":"d","path":"${dir:d}","class":"valuable"}]}}` - bad := `{"module":"power","version":"1","resources":[{"id":"d","type":"directory","path":"/srv/power","mode":"0700"}],` + - `"data":{"own":[{"id":"d","path":"${dir:d}","class":"valuable"}]}}` + bad := `{"module":"power","version":"1","resources":"none"}` later := `{"module":"later","version":"1","a-field-from-later":1}` b, _ := aNode(t, ok, bad, later) - refuse(b, "power", "removes a stream it may not") ctx := context.Background() in, err := Input(ctx, b, Mesh{}, Scope{Node: "n1"}) if err != nil { t.Fatalf("one refused manifest ended the read: %v", err) } - if why := in.Refused["power"]; !strings.Contains(why, "refused the manifest of power: removes a stream it may not") || + if why := in.Refused["power"]; !strings.Contains(why, "the manifest of power does not decode") || len(in.Refused) != 1 { t.Fatalf("refused: %v", in.Refused) } @@ -93,7 +83,7 @@ func aRefusedManifestNeverEndsTheRead(t *testing.T) { t.Fatalf("plans: %v", err) } items, _, held, err := DataItemsHeld(ctx, b, Mesh{}, Scope{Node: "n1"}) - if err != nil || len(items["lamp"]) != 1 || items["power"] != nil || !strings.Contains(held["power"], "removes a stream") { + if err != nil || len(items["lamp"]) != 1 || items["power"] != nil || !strings.Contains(held["power"], "does not decode") { t.Fatalf("data items %v held %v: %v", items, held, err) } } diff --git a/internal/composer/composer.go b/internal/composer/composer.go index 60372efa..a70800dc 100644 --- a/internal/composer/composer.go +++ b/internal/composer/composer.go @@ -13,8 +13,6 @@ import ( "fmt" "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient" "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-networking/modules/mesh-wireguard/go/overlay" "maps" "slices" @@ -23,7 +21,6 @@ import ( sdk "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer" "git.novox.be/novox/mesh-sdk/go/catalogue" - "git.novox.be/novox/mesh-sdk/go/keys" "git.novox.be/novox/mesh-sdk/go/sdkversion" "github.com/novox/mesh-host/internal/compose" @@ -96,10 +93,10 @@ func Run(r Request) (Verdict, error) { return v, nil } -// parse decodes every manifest leniently and takes its verdict (novox/hq ADR 0578 §3, §5): the composer judges none. A -// manifest refused by its verdict is held, composed as its stub without its items (as the bus reader holds one); bytes -// that do not decode are left out. Both are named in reads. -func parse(m map[string]Manifest, reads map[string]ManifestRead, verdicts map[string]json.RawMessage) (map[string]catalogue.Manifest, error) { +// parse decodes every manifest leniently (novox/hq ADR 0578 §3, §5): the composer judges none, and a manifest in a case is +// accepted by being there (design 47 H, H-A-79, H-A-112: the validate step judged it). Bytes that do not decode are left +// out and named in reads. +func parse(m map[string]Manifest, reads map[string]ManifestRead) (map[string]catalogue.Manifest, error) { out := map[string]catalogue.Manifest{} for name, man := range m { if len(man.Raw) == 0 { @@ -109,19 +106,6 @@ func parse(m map[string]Manifest, reads map[string]ManifestRead, verdicts map[st read := ManifestRead{Accepted: err == nil, SetAside: decoded.SetAside()} if err != nil { read.Refused = fmt.Sprintf("the manifest of %s does not decode: %v", name, err) - } else if raw, ok := verdicts[name]; ok { - v, verr := caseVerdict(raw) - if verr != nil { - return nil, fmt.Errorf("composer: the verdict of %s is not one: %w", name, verr) - } - if refused, _ := meshcatalogclient.TakeVerdict(&v); refused { - if v.Module == "" { - v.Module = name - } - read = ManifestRead{Refused: meshcatalogclient.VerdictWhy(v)} - decoded.Items = nil - decoded = compose.Stub(decoded) - } } if reads != nil { reads[name] = read @@ -133,31 +117,9 @@ func parse(m map[string]Manifest, reads map[string]ManifestRead, verdicts map[st return out, nil } -// caseVerdict reads a verdict a case carries. It is not the indexer's kept value but the checker's account of it, made -// from the indexer's modules value: a checker of the trunk writes it with version 0 and no judge, one of the registry -// milestone with no version and no judge, and the composer of a group's head is asked by the checker that runs. So it is -// read in the kept value's form at version 0 (or none) and at keys.Version, its judge optional; a later version, a value -// that does not decode and a state no reader knows are refused, never taken as accepted. -func caseVerdict(raw json.RawMessage) (meshcatalog.VerdictsByDigestValue, error) { - var v meshcatalog.VerdictsByDigestValue - if err := json.Unmarshal(raw, &v); err != nil { - return v, fmt.Errorf("the value does not fit a verdict's shape: %w", err) - } - if v.V != 0 && v.V != keys.Version { - return v, fmt.Errorf("%w: the value is version %d, this reader reads 0 and %d", keys.ErrUnknownVersion, v.V, keys.Version) - } - switch v.State { - case meshcatalogclient.VerdictAccepted, meshcatalogclient.VerdictRefused, meshcatalogclient.VerdictManifestWaits: - default: - return v, fmt.Errorf("the state %q is none of %s, %s and %s", v.State, meshcatalogclient.VerdictAccepted, - meshcatalogclient.VerdictRefused, meshcatalogclient.VerdictManifestWaits) - } - return v, nil -} - func runCase(r Request, c Case, depth string) (CaseVerdict, error) { cv := CaseVerdict{Name: c.Name, Manifests: map[string]ManifestRead{}} - shelf, err := parse(c.Manifests, cv.Manifests, c.Verdicts) + shelf, err := parse(c.Manifests, cv.Manifests) if err != nil { return CaseVerdict{}, err } @@ -223,7 +185,7 @@ func runCase(r Request, c Case, depth string) (CaseVerdict, error) { } in.Nodes[i].Kept = nil if kept := c.Kept[in.Nodes[i].Name]; len(kept) > 0 { - k, err := parse(kept, nil, nil) + k, err := parse(kept, nil) if err != nil { return CaseVerdict{}, err } @@ -310,9 +272,6 @@ func overrule(base compose.Input, c Case, reads map[string]ManifestRead, shelf m held = "not read by the running node-engine's decoder" } judged := "accepted by the check's own validator" - if _, given := c.Verdicts[name]; !given { - judged = "given no verdict by the check, so taken as accepted (novox/hq ADR 0578 §3)" - } awaited[name] = "" if hold.Built == nil && compose.NamesBuild(shelf[name]) { build := "its build" @@ -356,9 +315,6 @@ func overrule(base compose.Input, c Case, reads map[string]ManifestRead, shelf m "beyond what a take-in resolves" } judged := "accepted by the check's own validator" - if _, given := c.Verdicts[name]; !given { - judged = "given no verdict by the check, so taken as accepted (novox/hq ADR 0578 §3)" - } at := "" if how != nil && how.Builds[name] != "" { at = " " + how.Builds[name] diff --git a/internal/composer/composer_test.go b/internal/composer/composer_test.go index c5c33b43..12c26527 100644 --- a/internal/composer/composer_test.go +++ b/internal/composer/composer_test.go @@ -3,11 +3,8 @@ package composer import ( "context" "encoding/json" - "errors" "fmt" "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-networking/modules/mesh-wireguard/go/overlay" "github.com/novox/mesh-host/internal/buckets/bucketstest" engcomp "github.com/novox/mesh-host/internal/compositions" @@ -18,7 +15,6 @@ import ( "testing" "git.novox.be/novox/mesh-sdk/go/catalogue" - "git.novox.be/novox/mesh-sdk/go/keys" "github.com/novox/mesh-host/internal/compose" "github.com/novox/mesh-host/internal/compose/frombus" "github.com/novox/mesh-host/internal/compose/frombus/frombustest" @@ -214,9 +210,7 @@ func TestARequestItCannotRunIsRefused(t *testing.T) { for name, sent := range map[string]string{"with the mark": string(wire), "from an engine before it": older} { var r Request r = Request{V: Version, Machines: []string{"a"}, Depth: DepthCompose, - Cases: []Case{{Name: "change", Manifests: map[string]Manifest{"runner": {Raw: json.RawMessage(raw)}}, - Verdicts: bucketstest.Raw(map[string]meshcatalog.VerdictsByDigestValue{"runner": {V: 1, Module: "runner", - State: meshcatalogclient.VerdictRefused, Problems: []string{"p"}}})}}} + Cases: []Case{{Name: "change", Manifests: map[string]Manifest{"runner": {Raw: json.RawMessage(raw)}}}}} if err := json.Unmarshal([]byte(sent), &r.Input); err != nil { t.Fatal(err) } @@ -224,11 +218,11 @@ func TestARequestItCannotRunIsRefused(t *testing.T) { if err != nil { t.Fatal(err) } - if m := v.Cases[0].Machines["a"]; !m.Composes || strings.Contains(m.Reason, "bundle") { + if m := v.Cases[0].Machines["a"]; m.Reason != "" || m.NotJudged == "" { t.Errorf("%s: the node with its tool runner held: %+v", name, m) } - if read := v.Cases[0].Manifests["runner"]; read.Accepted || !strings.Contains(read.Refused, "the indexer's judge refused the manifest of runner") { - t.Errorf("%s: the runner's read names not why its node-engine holds it: %+v", name, read) + if read := v.Cases[0].Manifests["runner"]; !read.Accepted { + t.Errorf("%s: the runner's manifest is accepted by being in the case (H-A-112): %+v", name, read) } } }) @@ -250,32 +244,25 @@ func TestARequestItCannotRunIsRefused(t *testing.T) { if err != nil { t.Fatal(err) } - verdict := func(state string) map[string]json.RawMessage { - return bucketstest.Raw(map[string]meshcatalog.VerdictsByDigestValue{"app": {V: 1, Module: "app", State: state, Problems: []string{"p"}}}) - } const why = "the indexer's judge refused the manifest of app" for _, row := range []struct { name string raw string - verdicts map[string]json.RawMessage hold *compose.Hold composes bool // the machine composes, judged path string // a path declared on it words string // in NotJudged, else in the read's refusal }{ - {"an accepted verdict, its build carried", app, verdict(meshcatalogclient.VerdictAccepted), - &compose.Hold{By: compose.HeldByVerdict, Build: "fp1", Built: &built}, true, "/var/lib/app-built", ""}, - {"no verdict, its build carried", app, nil, &compose.Hold{By: compose.HeldByVerdict, Build: "fp1", Built: &built}, true, "/var/lib/app-built", ""}, - {"an accepted verdict, its build awaited", plain, verdict(meshcatalogclient.VerdictAccepted), &compose.Hold{By: compose.HeldByVerdict, Build: "fp1"}, false, "", + {"its build carried", app, &compose.Hold{By: compose.HeldByVerdict, Build: "fp1", Built: &built}, true, "/var/lib/app-built", ""}, + {"its build awaited", plain, &compose.Hold{By: compose.HeldByVerdict, Build: "fp1"}, false, "", "composed from the change's manifest without its build: app is refused only by the running indexer (" + why + ") and accepted by the check's own validator, and its build fp1 is awaited"}, - {"no verdict, from an engine before holds", plain, nil, nil, false, "", - "app is held by the running node-engine (" + why + ") and given no verdict by the check, so taken as accepted"}, - {"a container, its image awaited", app, nil, &compose.Hold{By: compose.HeldByVerdict}, false, "", + {"from an engine before holds", plain, nil, false, "", + "app is held by the running node-engine (" + why + ") and accepted by the check's own validator"}, + {"a container, its image awaited", app, &compose.Hold{By: compose.HeldByVerdict}, false, "", "composed with it held as its node-engine holds it, since it does not compose without its build: app is refused only by the running indexer"}, - {"a tool runner, its bundle awaited", runner, nil, &compose.Hold{By: compose.HeldByVerdict}, false, "", + {"a tool runner, its bundle awaited", runner, &compose.Hold{By: compose.HeldByVerdict}, false, "", "composed with it held as its node-engine holds it, since it does not compose without its build: app is refused only by the running indexer"}, - {"bytes that do not decode", `{"module": "app", "version": "1", "resources": "none"}`, nil, &compose.Hold{By: compose.HeldByVerdict, Built: &built}, true, "", "does not decode"}, - {"the case's own refusal", app, verdict(meshcatalogclient.VerdictRefused), &compose.Hold{By: compose.HeldByVerdict, Built: &built}, true, "", "refused the manifest of app"}, + {"bytes that do not decode", `{"module": "app", "version": "1", "resources": "none"}`, &compose.Hold{By: compose.HeldByVerdict, Built: &built}, true, "", "does not decode"}, } { man, _ := catalogue.Decode([]byte(app)) in := compose.Input{Catalogue: map[string]catalogue.Manifest{"app": compose.Stub(man)}, Refused: map[string]string{"app": why}, @@ -284,7 +271,7 @@ func TestARequestItCannotRunIsRefused(t *testing.T) { in.Holds = map[string]compose.Hold{"app": *row.hold} } v, err := Run(withInput(t, Request{V: Version, Machines: []string{"a"}, Depth: DepthCompose, Declarations: true, - Cases: []Case{{Name: "change", Manifests: map[string]Manifest{"app": {Raw: json.RawMessage(row.raw)}}, Verdicts: row.verdicts}}}, in)) + Cases: []Case{{Name: "change", Manifests: map[string]Manifest{"app": {Raw: json.RawMessage(row.raw)}}}}}, in)) if err != nil { t.Fatal(err) } @@ -420,9 +407,8 @@ func TestARequestItCannotRunIsRefused(t *testing.T) { // The composer judges no manifest (novox/hq ADR 0578 §5): xterm's module.json from mesh-catalog at 835bf22b, whose // config value falls back to "font-size", is read whatever list of predefined keys a request carries (a group touching -// xterm failed its composition on this, group check 18df81380db3); a module whose verdict in the input refuses it is -// held, composed as its stub, and named in the verdict's words. -func TestTheComposerTakesTheVerdictsOfItsInput(t *testing.T) { +// xterm failed its composition on this, group check 18df81380db3), and accepted by being in the case (design 47 H, H-A-112). +func TestTheComposerJudgesNoManifest(t *testing.T) { raw, err := os.ReadFile("testdata/catalogue-835bf22b-xterm.module.json") if err != nil { t.Fatal(err) @@ -436,31 +422,4 @@ func TestTheComposerTakesTheVerdictsOfItsInput(t *testing.T) { if got := v.Cases[0].Manifests["xterm"]; !got.Accepted { t.Fatalf("xterm: %+v, want accepted", got) } - r.Cases[0].Verdicts = bucketstest.Raw(map[string]meshcatalog.VerdictsByDigestValue{"xterm": {V: 1, Module: "xterm", State: meshcatalogclient.VerdictRefused, - Problems: []string{"falls back to a key not listed"}, Judge: "src2:j"}}) - shelf, err := parse(r.Cases[0].Manifests, map[string]ManifestRead{}, r.Cases[0].Verdicts) - if err != nil || !shelf["xterm"].Stubbed { - t.Fatalf("the refused module is not held as its stub: %+v %v", shelf["xterm"], err) - } - if v, err = Run(r); err != nil { - t.Fatal(err) - } - if got := v.Cases[0].Manifests["xterm"]; got.Accepted || - !strings.Contains(got.Refused, "the indexer's judge (src2:j) refused the manifest of xterm: falls back to a key not listed") { - t.Fatalf("xterm refused by its verdict: %+v, want refused in the verdict's words", got) - } - // The verdict as the trunk's checker hands it, version 0 and no judge (group try 1793952957648659842 failed on all - // four nodes: "the verdict of f1-circuits is not one: ... the value is version 0"), holds the module too; a later - // version is refused. - r.Cases[0].Verdicts = map[string]json.RawMessage{"xterm": json.RawMessage(`{"v":0,"module":"xterm","state":"refused","problems":["falls back to a key not listed"],"judge":"","at":"0001-01-01T00:00:00Z"}`)} - if v, err = Run(r); err != nil { - t.Fatalf("a version-0 verdict of the trunk's checker: %v", err) - } - if got := v.Cases[0].Manifests["xterm"]; got.Accepted || !strings.Contains(got.Refused, "refused the manifest of xterm: falls back") { - t.Fatalf("xterm refused by a version-0 verdict: %+v, want refused", got) - } - r.Cases[0].Verdicts["xterm"] = json.RawMessage(`{"v":2,"module":"xterm","state":"refused","problems":["p"]}`) - if _, err = Run(r); !errors.Is(err, keys.ErrUnknownVersion) { - t.Fatalf("a version-2 verdict: %v, want keys.ErrUnknownVersion", err) - } } diff --git a/internal/selfcompose/candidate.go b/internal/selfcompose/candidate.go index e6ec25cf..34411a5c 100644 --- a/internal/selfcompose/candidate.go +++ b/internal/selfcompose/candidate.go @@ -414,7 +414,7 @@ func (c *Composer) warm(ctx context.Context, origin *Composer, cand meshcatalog. } // layCandidate lays the candidate's modules over the indexer's: each at its fingerprint, with its manifest's digest and -// the indexer's verdict on it (read from its verdicts, none read taken as accepted); a module the candidate removes goes. +// a module the candidate removes goes (design 47 H, H-A-79: the seat keeps no verdicts). // It answers the modules laid. func (c *Composer) layCandidate(ctx context.Context, cand meshcatalog.CandidatesByGroupValue) (map[string]bool, error) { touched := map[string]bool{} @@ -430,23 +430,6 @@ func (c *Composer) layCandidate(ctx context.Context, cand meshcatalog.Candidates continue // no fingerprint at the preview: composed as the trunk holds it } m := meshcatalog.ModulesByModuleValue{Fp2: cm.Fp2, Manifest: cm.Manifest, Repository: pull.Repository, Commit: pull.Head} - if cm.Manifest != "" { - key, err := meshcatalogclient.VerdictsKey(cm.Manifest) - if err != nil { - return nil, err - } - raw, err := c.get(ctx, buckets.Verdicts, key) - if err != nil { - return nil, fmt.Errorf("the indexer's verdict on %s's manifest cannot be read: %w", module, err) - } - if raw != nil { - v, err := meshcatalogclient.DecodeVerdict(raw) - if err != nil { - return nil, fmt.Errorf("the indexer's verdict on %s's manifest cannot be read: %w", module, err) - } - m.Verdict, m.Problems, m.Warnings = v.State, v.Problems, v.Warnings - } - } c.mu.Lock() c.modules[module] = m c.mu.Unlock() diff --git a/internal/selfcompose/candidate_test.go b/internal/selfcompose/candidate_test.go index 84bde8f3..0216f65b 100644 --- a/internal/selfcompose/candidate_test.go +++ b/internal/selfcompose/candidate_test.go @@ -3,6 +3,11 @@ package selfcompose import ( "context" "encoding/json" + "strings" + "sync/atomic" + "testing" + "time" + "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient" @@ -10,10 +15,6 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" "github.com/novox/mesh-host/internal/buckets" "github.com/novox/mesh-host/internal/buckets/bucketstest" - "strings" - "sync/atomic" - "testing" - "time" nec "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" @@ -56,23 +57,7 @@ func TestTheNodeComposesACandidateOnAsk(t *testing.T) { key, _ := nec.CompositionKey(group, heads) return key } - accepted, refusedKey := candidateOf("fix/940-no-retire-on-partial-read", digest2), "" - { - // The same change, its manifest refused by the indexer's judge. - refusedMan := strings.Replace(lemurs2, `"version":"2"`, `"version":"3"`, 1) - d3 := meshcatalogclient.ManifestDigest([]byte(refusedMan)) - man, _ := meshcatalogclient.EncodeManifest(meshcatalog.ManifestsByDigestValue{Module: "lemurs", Manifest: refusedMan}) - key, _ := meshcatalogclient.ManifestsKey(d3) - b.kv[buckets.Manifests+"/"+key] = man - vkey, _ := meshcatalogclient.VerdictsKey(d3) - v, err := meshcatalogclient.EncodeVerdict(meshcatalog.VerdictsByDigestValue{Module: "lemurs", State: meshcatalogclient.VerdictRefused, - Problems: []string{"a field the judge refuses"}, Judge: "src2:j", At: func(t time.Time) *time.Time { return &t }(time.Now())}) - if err != nil { - t.Fatal(err) - } - b.kv[buckets.Verdicts+"/"+vkey] = v - refusedKey = candidateOf("fix/941-refused", d3) - } + accepted := candidateOf("fix/940-no-retire-on-partial-read", digest2) env := b.env() state := &fakeComposed{kv: map[string]ComposedEntry{}} @@ -144,14 +129,6 @@ func TestTheNodeComposesACandidateOnAsk(t *testing.T) { in.ComposedHow.Builds["lemurs"] != fpNew { t.Errorf("the input sent for the sandbox does not say how the node composes: %+v, %v", in.ComposedHow, err) } - r := s.ComposeCandidate(ctx, nodeengine.ComposeCandidateInput{Candidate: refusedKey}) - if r.Verdict != nec.Refused || len(r.Modules) != 1 || r.Modules[0].State != nec.ModuleRefused || - !strings.Contains(r.Modules[0].Words, "a field the judge refuses") { - t.Errorf("a candidate whose manifest the indexer refused answered %+v", r) - } - if _, err := nec.EncodeAnswer(r); err != nil { - t.Errorf("the refused answer does not fit the seat's shape: %v", err) - } // A-226b: a branch pipeline's revision composes as the candidate, each module at the revision's build; one the catalog does // not hold, and a run on request's key, are refused in words. revKey, _ := nec.RevisionKey("main", 362) diff --git a/internal/selfcompose/selfcompose.go b/internal/selfcompose/selfcompose.go index 49baf31b..f369f793 100644 --- a/internal/selfcompose/selfcompose.go +++ b/internal/selfcompose/selfcompose.go @@ -1454,7 +1454,7 @@ func (c *Composer) Policy(ctx context.Context, module string) string { if err != nil { return "" } - parsed, held, err := c.taken(module, m, raw) + parsed, held, err := c.taken(module, raw) if err != nil || held != "" { return "" } @@ -1486,16 +1486,11 @@ func (c *Composer) Claims(_ context.Context, module, seat string) (claims, known return a.Manifest.ClaimsSeat(seat), true } -// taken is a module's manifest as this engine reads it (novox/hq ADR 0578 §3): decoded leniently, judging nothing, with -// the indexer's verdict from the module's value (a missing one is accepted). held is why the module is held, "" when it is -// not: a manifest the indexer refused, or one not read past a field this engine does not know. A field set aside is said +// taken is a module's manifest as this engine reads it: decoded leniently, judging nothing; a module in a catalog revision is +// accepted by being there (design 47 H, H-A-79, H-A-111). held is why the module is held, "" when it is not: one not read past +// a field this engine does not know. A field set aside is said // once, and an error is returned only for bytes that are no manifest, which the caller says in its own words. -func (c *Composer) taken(module string, m meshcatalog.ModulesByModuleValue, raw []byte) (man catalogue.Manifest, held string, err error) { - if v := meshcatalogclient.ModuleVerdict(module, m); v != nil { - if refused, _ := meshcatalogclient.TakeVerdict(v); refused { - return catalogue.Manifest{}, meshcatalogclient.VerdictWhy(*v), nil - } - } +func (c *Composer) taken(module string, raw []byte) (man catalogue.Manifest, held string, err error) { man, err = catalogue.Decode(raw) if err != nil { c.sayOnceEach("the manifest of " + module + " does not decode, and the module is held: " + err.Error()) @@ -1552,10 +1547,7 @@ func (c *Composer) certificateWanted(ctx context.Context, r reader, p meshmodule if err != nil { continue } - c.mu.Lock() - mod := c.modules[m.Module] - c.mu.Unlock() - parsed, held, err := c.taken(m.Module, mod, raw) + parsed, held, err := c.taken(m.Module, raw) if err != nil || held != "" { continue // held or not read: it asks none, and its refusal is named by the composition } diff --git a/internal/selfcompose/selfcompose_test.go b/internal/selfcompose/selfcompose_test.go index 8ae5dc5d..0a924f67 100644 --- a/internal/selfcompose/selfcompose_test.go +++ b/internal/selfcompose/selfcompose_test.go @@ -624,44 +624,6 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) { strings.Contains((*told)[0], "held lemurs") { t.Errorf("the agent was told %q, want de-spiegel held alone, in its config form's words, without its routes", *told) } - // Issue 774, 2026-10-30 19:13: a manifest the mesh refuses (power's bar item at mesh-catalog ca8d6f33, captured, with - // attributes its bar places by none of) refused every node's composition and failed all its modules. Now power is - // held alone, naming why, and lemurs is handed. - power, err := os.ReadFile("testdata/power-ca8d6f33.module.json") - if err != nil { - t.Fatal(err) - } - c4, told4 := fresh(env.Get) - powerFP := meshcatalogclient.SourcePrefix2 + strings.Repeat("c", 64) - powerHalf := catalogHalf{} - powerHalf.add(t, "power", powerFP, string(power)) - powerEntry := powerHalf[powerFP] - // The verdict the catalog half's entry carries on the captured manifest (ADR 0578): the engine judges nothing, it takes this. - powerEntry.Repository, powerEntry.Commit, powerEntry.Verdict = "novox/mesh-catalog", "ca8d6f33", meshcatalogclient.VerdictRefused - powerEntry.Inputs = &meshcatalog.EntryInputs{Problems: []string{`bar item "shows" is none of them`}} - c4.mu.Lock() - c4.keptEnt[powerFP] = keptEntry{entry: powerEntry} - c4.mu.Unlock() - c4.wants["power"] = meshwants.WantsByWantNodeModuleValue{Fp: powerFP, Self: true} - p4 := c4.assignments["n1"] - p4.Modules = append(append([]meshmoduleassigner.PlacedModule{}, p4.Modules...), meshmoduleassigner.PlacedModule{Module: "power"}) - c4.assignments["n1"] = p4 - handed4 := map[string]agent.Update{} - for _, u := range c4.compose(ctx) { - handed4[u.Key] = u - } - if u, ok := handed4[lemursKey3]; !ok || u.Deleted { - t.Errorf("lemurs is not handed beside power's refused manifest: %v (told %q)", handed4, *told4) - } - if len(*told4) != 1 || !strings.HasPrefix((*told4)[0], "held power: ") || !strings.Contains((*told4)[0], `"shows" is none of them`) { - t.Errorf("the agent was told %q, want power held alone, naming its item", *told4) - } - // Issue 1921: the composition verb's held says what holds power and the build it would be composed at, as the input a - // check's composer reads says it. - if why := c4.LastHeld()["power"]; !strings.Contains(why, `"shows" is none of them`) || - !strings.Contains(why, "held by its manifest's verdict, at the build "+powerFP) { - t.Errorf("the last pass held power for %q, want its verdict and its build named", why) - } // Review of issue 774 (the kept read): mesh-wireguard, which the mesh provides and which never has a fingerprint, is // folded in the node's own and composed from the manifest mesh-sdk provides (overlay.ProvidedManifest), not from // what runs nor the kept declaration: with nothing running (the kept read retired, Running empty) the node's own diff --git a/internal/selfcompose/testdata/power-ca8d6f33.module.json b/internal/selfcompose/testdata/power-ca8d6f33.module.json deleted file mode 100644 index c43e601c..00000000 --- a/internal/selfcompose/testdata/power-ca8d6f33.module.json +++ /dev/null @@ -1,452 +0,0 @@ -{ - "module": "power", - "version": "1", - "moved": true, - "templates": "templates", - "capabilities": [ - "package-manager", - "service-manager" - ], - "claims": [ - { - "name": "node-power", - "scope": "node" - } - ], - "emits": [ - "booted", - "sleeping", - "woke", - "shutting-down", - "on-mains", - "on-battery", - "battery-low" - ], - "state": [ - { - "name": "draw", - "ttl-seconds": 30, - "per-machine": true - } - ], - "tools": [ - "power_state", - "power_hooks", - "power_history", - "power_run", - "power_check" - ], - "config": { - "handle-power-key": { - "type": "string", - "description": "What logind does when the power key is pressed: one of logind's actions, such as suspend, ignore or poweroff (logind.conf(5)); the operator's choice for this machine, with no default.", - "enum": [ - "ignore", - "poweroff", - "reboot", - "halt", - "kexec", - "suspend", - "hibernate", - "hybrid-sleep", - "suspend-then-hibernate", - "lock", - "factory-reset", - "sleep" - ], - "trusted": true, - "required": true - }, - "handle-lid-switch": { - "type": "string", - "description": "What logind does when the lid is closed on battery: one of logind's actions, such as suspend, ignore or poweroff (logind.conf(5)); the operator's choice for this machine, with no default.", - "enum": [ - "ignore", - "poweroff", - "reboot", - "halt", - "kexec", - "suspend", - "hibernate", - "hybrid-sleep", - "suspend-then-hibernate", - "lock", - "factory-reset", - "sleep" - ], - "trusted": true, - "required": true - }, - "handle-lid-switch-external-power": { - "type": "string", - "description": "What logind does when the lid is closed on external power: one of logind's actions, such as suspend, ignore or poweroff (logind.conf(5)); the operator's choice for this machine, with no default.", - "enum": [ - "ignore", - "poweroff", - "reboot", - "halt", - "kexec", - "suspend", - "hibernate", - "hybrid-sleep", - "suspend-then-hibernate", - "lock", - "factory-reset", - "sleep" - ], - "trusted": true, - "required": true - }, - "handle-lid-switch-docked": { - "type": "string", - "description": "What logind does when the lid is closed while docked or with another screen attached: one of logind's actions, such as suspend, ignore or poweroff (logind.conf(5)); the operator's choice for this machine, with no default.", - "enum": [ - "ignore", - "poweroff", - "reboot", - "halt", - "kexec", - "suspend", - "hibernate", - "hybrid-sleep", - "suspend-then-hibernate", - "lock", - "factory-reset", - "sleep" - ], - "trusted": true, - "required": true - } - }, - "resources": [ - { - "id": "polkit", - "type": "package", - "package": "polkit" - }, - { - "id": "scripts", - "type": "archive", - "path": "/usr/local/lib/mesh-power", - "artifact": "scripts", - "unknown": "program" - }, - { - "id": "config-dir", - "type": "directory", - "path": "/etc/mesh-power", - "mode": "0755", - "unknown": "program" - }, - { - "id": "moments-dir", - "type": "directory", - "path": "/etc/mesh-power/moments", - "mode": "0755", - "unknown": "program" - }, - { - "id": "moment-after-boot", - "type": "file", - "path": "/etc/mesh-power/moments/after-boot", - "mode": "0644", - "template": "templates/mesh-power/moments/after-boot" - }, - { - "id": "moment-before-sleep", - "type": "file", - "path": "/etc/mesh-power/moments/before-sleep", - "mode": "0644", - "template": "templates/mesh-power/moments/before-sleep" - }, - { - "id": "moment-after-wake", - "type": "file", - "path": "/etc/mesh-power/moments/after-wake", - "mode": "0644", - "template": "templates/mesh-power/moments/after-wake" - }, - { - "id": "moment-before-shutdown", - "type": "file", - "path": "/etc/mesh-power/moments/before-shutdown", - "mode": "0644", - "template": "templates/mesh-power/moments/before-shutdown" - }, - { - "id": "moment-on-mains", - "type": "file", - "path": "/etc/mesh-power/moments/on-mains", - "mode": "0644", - "template": "templates/mesh-power/moments/on-mains" - }, - { - "id": "moment-on-battery", - "type": "file", - "path": "/etc/mesh-power/moments/on-battery", - "mode": "0644", - "template": "templates/mesh-power/moments/on-battery" - }, - { - "id": "logind-drop-ins", - "type": "directory", - "path": "/etc/systemd/logind.conf.d", - "mode": "0755", - "unknown": "program" - }, - { - "id": "logind-power", - "type": "file", - "path": "/etc/systemd/logind.conf.d/power.conf", - "mode": "0644", - "template": "templates/systemd/logind.conf.d/power.conf" - }, - { - "id": "logind", - "type": "service", - "unit": "systemd-logind.service", - "reload-on": [ - "logind-power" - ] - }, - { - "id": "after-boot-unit", - "type": "file", - "path": "/etc/systemd/system/mesh-power-after-boot.service", - "mode": "0644", - "template": "templates/systemd/system/mesh-power-after-boot.service" - }, - { - "id": "before-shutdown-unit", - "type": "file", - "path": "/etc/systemd/system/mesh-power-before-shutdown.service", - "mode": "0644", - "template": "templates/systemd/system/mesh-power-before-shutdown.service" - }, - { - "id": "before-sleep-unit", - "type": "file", - "path": "/etc/systemd/system/mesh-power-before-sleep.service", - "mode": "0644", - "template": "templates/systemd/system/mesh-power-before-sleep.service" - }, - { - "id": "after-wake-unit", - "type": "file", - "path": "/etc/systemd/system/mesh-power-after-wake.service", - "mode": "0644", - "template": "templates/systemd/system/mesh-power-after-wake.service" - }, - { - "id": "supply-unit", - "type": "file", - "path": "/etc/systemd/system/mesh-power-supply.service", - "mode": "0644", - "template": "templates/systemd/system/mesh-power-supply.service" - }, - { - "id": "sleep-drop-ins", - "type": "directory", - "path": "/etc/systemd/system/sleep.target.d", - "mode": "0755", - "unknown": "program" - }, - { - "id": "sleep-wants", - "type": "file", - "path": "/etc/systemd/system/sleep.target.d/mesh-power.conf", - "mode": "0644", - "template": "templates/systemd/system/sleep.target.d/mesh-power.conf" - }, - { - "id": "suspend-drop-ins", - "type": "directory", - "path": "/etc/systemd/system/suspend.target.d", - "mode": "0755", - "unknown": "program" - }, - { - "id": "suspend-wants", - "type": "file", - "path": "/etc/systemd/system/suspend.target.d/mesh-power.conf", - "mode": "0644", - "template": "templates/systemd/system/suspend.target.d/mesh-power.conf" - }, - { - "id": "hibernate-drop-ins", - "type": "directory", - "path": "/etc/systemd/system/hibernate.target.d", - "mode": "0755", - "unknown": "program" - }, - { - "id": "hibernate-wants", - "type": "file", - "path": "/etc/systemd/system/hibernate.target.d/mesh-power.conf", - "mode": "0644", - "template": "templates/systemd/system/hibernate.target.d/mesh-power.conf" - }, - { - "id": "hybrid-sleep-drop-ins", - "type": "directory", - "path": "/etc/systemd/system/hybrid-sleep.target.d", - "mode": "0755", - "unknown": "program" - }, - { - "id": "hybrid-sleep-wants", - "type": "file", - "path": "/etc/systemd/system/hybrid-sleep.target.d/mesh-power.conf", - "mode": "0644", - "template": "templates/systemd/system/hybrid-sleep.target.d/mesh-power.conf" - }, - { - "id": "suspend-then-hibernate-drop-ins", - "type": "directory", - "path": "/etc/systemd/system/suspend-then-hibernate.target.d", - "mode": "0755", - "unknown": "program" - }, - { - "id": "suspend-then-hibernate-wants", - "type": "file", - "path": "/etc/systemd/system/suspend-then-hibernate.target.d/mesh-power.conf", - "mode": "0644", - "template": "templates/systemd/system/suspend-then-hibernate.target.d/mesh-power.conf" - }, - { - "id": "reboot-drop-ins", - "type": "directory", - "path": "/etc/systemd/system/reboot.target.d", - "mode": "0755", - "unknown": "program" - }, - { - "id": "reboot-bound", - "type": "file", - "path": "/etc/systemd/system/reboot.target.d/mesh-power.conf", - "mode": "0644", - "template": "templates/systemd/system/reboot.target.d/mesh-power.conf" - }, - { - "id": "poweroff-drop-ins", - "type": "directory", - "path": "/etc/systemd/system/poweroff.target.d", - "mode": "0755", - "unknown": "program" - }, - { - "id": "poweroff-bound", - "type": "file", - "path": "/etc/systemd/system/poweroff.target.d/mesh-power.conf", - "mode": "0644", - "template": "templates/systemd/system/poweroff.target.d/mesh-power.conf" - }, - { - "id": "halt-drop-ins", - "type": "directory", - "path": "/etc/systemd/system/halt.target.d", - "mode": "0755", - "unknown": "program" - }, - { - "id": "halt-bound", - "type": "file", - "path": "/etc/systemd/system/halt.target.d/mesh-power.conf", - "mode": "0644", - "template": "templates/systemd/system/halt.target.d/mesh-power.conf" - }, - { - "id": "udev-rule", - "type": "file", - "path": "/etc/udev/rules.d/90-mesh-power.rules", - "mode": "0644", - "template": "templates/udev/rules.d/90-mesh-power.rules" - }, - { - "id": "after-boot", - "type": "service", - "unit": "mesh-power-after-boot.service", - "state": "running", - "boot": "enabled" - }, - { - "id": "before-shutdown", - "type": "service", - "unit": "mesh-power-before-shutdown.service", - "state": "running", - "boot": "enabled" - }, - { - "id": "draw-dir", - "type": "directory", - "path": "/run/mesh-power", - "mode": "0755", - "unknown": "program" - }, - { - "id": "draw", - "type": "process", - "name": "mesh-power-draw", - "artifact": "tools-go", - "run": [ - "./power", - "draw" - ], - "health": { - "kind": "unit" - } - } - ], - "build": { - "artifacts": [ - { - "name": "tools-go", - "kind": "bundle", - "language": "go", - "system": "arch", - "from": "cmd/power", - "binary": "power", - "loads": [ - "power" - ] - }, - { - "name": "scripts", - "kind": "archive", - "from": "files" - }, - { - "name": "templates", - "kind": "archive", - "from": "templates" - } - ] - }, - "items": [ - { - "collection": "contribution:node-bar:block", - "name": "battery", - "if-capability": "battery", - "attributes": { - "bar": "bottom", - "place": "status", - "order": "40" - }, - "template": "templates/bar-battery" - }, - { - "collection": "contribution:node-bar:block", - "name": "power-draw", - "if-capability": "power-meter", - "attributes": { - "bar": "bottom", - "place": "status", - "order": "45", - "shows": "state", - "state": "power.draw" - }, - "template": "templates/bar-power-draw" - } - ] -} From 39e16689fa64ac01db372ff1237112ab63da22a7 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 04:25:00 +0100 Subject: [PATCH 9/9] MH-0: an entry whose ask failed is asked again, at most entry-asks times, then unanswered The node-engine consumes the entries client's asking again (H-A-60, H-A-110): the setting entry-asks (default 5; module.json config and file resource, read at the engine's start) goes to Entries.Asks; Entries.AskAgain is called at each link's start and on each catalog-revision the composer hears (the shadow's cache too); the finding entry-unanswered joins the engine's finding kinds, written with a journal line when an entry ends unanswered and cleared when it is answered or no longer wanted; the shadow's wait and the have's hold end on it instead of waiting without bound. Builds: design 47 H, H-A-60, H-A-110 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- cmd/mesh-host/nodeagent.go | 15 +++- cmd/mesh-host/nodeagent_integration_test.go | 43 +++++++++++ cmd/mesh-host/ownname_test.go | 20 ++++++ cmd/mesh-host/seatlist.go | 21 +++++- internal/seatwait/entrynotfound.go | 21 ++++++ internal/seatwait/seatwait_test.go | 11 +++ internal/selfcompose/entries.go | 42 +++++++++++ internal/selfcompose/entries_test.go | 79 +++++++++++++++++++++ internal/selfcompose/selfcompose.go | 20 +++++- internal/selfcompose/shadow.go | 3 + module.json | 13 ++++ packaging/operator_keys_test.go | 3 + 12 files changed, 286 insertions(+), 5 deletions(-) diff --git a/cmd/mesh-host/nodeagent.go b/cmd/mesh-host/nodeagent.go index d076a771..0b5e488c 100644 --- a/cmd/mesh-host/nodeagent.go +++ b/cmd/mesh-host/nodeagent.go @@ -627,6 +627,11 @@ func nodeAgent(ctx context.Context, opts options, signer ed25519.PublicKey, trus say("the finding that the catalog half holds no entry of " + fp + " cannot be kept: " + err.Error()) } }, + entryUnanswered: func(fp string, asks int, unanswered bool) { + if err := seatwait.SayEntryUnanswered(run, findings, node, findings.observer(), fp, asks, unanswered, time.Now); err != nil { + say("the finding that the entry of " + fp + " is unanswered cannot be kept: " + err.Error()) + } + }, seatList: seats, seatListFailed: err != nil, running: func() []compositions.Composed { @@ -690,10 +695,14 @@ func nodeAgent(ctx context.Context, opts options, signer ed25519.PublicKey, trus // nothing and keeps running what it runs; a assignment it cannot watch stops the agent, said, and it begins again. composer := selfComposer(session, node, hooks, say) composer.AlsoEntryAgain = shadow.EntryAgain + composer.AlsoEntriesAskAgain = shadow.EntriesAskAgain composer.OnEngine = session.Own.Set // the first composing names the engine's own module on a first start (§527, §634) machinesNow.Store(composer) // the machines a failing network part points at, by the assignments (issue 774) composerNow.Store(composer) // what the verb compose asks a pass of, this run's alone session.SetManifestOf(composer.ManifestOf) // the event running names the manifest of the build that runs + // The link is open: each entry whose ask failed in transport is asked again (design 47 H, H-A-60). + composer.EntriesAskAgain(run) + shadow.EntriesAskAgain(run) go followRunning(run, session, composer, say) go followBuildEnds(run, session, composer, say) apply.UseEngineModule(composer.EngineModule) // the guard of the engine's own trees fixes no name (§527) @@ -1132,7 +1141,9 @@ type composerHooks struct { kept func(kept map[string][]string) // entryNotFound is selfcompose.Env's EntryNotFound. entryNotFound func(fp string, notFound bool) - held func(module string) (compositions.Seals, []string, error) + // entryUnanswered is selfcompose.Env's EntryUnanswered. + entryUnanswered func(fp string, asks int, unanswered bool) + held func(module string) (compositions.Seals, []string, error) // vaultAuthority and certify are selfcompose.Env's VaultAuthority and Certify. vaultAuthority func() string certify func(ctx context.Context) error @@ -1191,7 +1202,7 @@ func composerEnv(session *link.Session, node string, say func(string), hooks com Hear: session.Hear, // And a moved module's templates archive, in the artifact store, as every archive is fetched (issue 1126). Fetch: apply.Fetch, - Running: hooks.running, Unseal: hooks.unseal, Refused: hooks.refused, Held: hooks.held, Kept: hooks.kept, EntryNotFound: hooks.entryNotFound, + Running: hooks.running, Unseal: hooks.unseal, Refused: hooks.refused, Held: hooks.held, Kept: hooks.kept, EntryNotFound: hooks.entryNotFound, EntryUnanswered: hooks.entryUnanswered, EntryAsks: entryAsks(), VaultAuthority: hooks.vaultAuthority, Certify: hooks.certify} if hooks.seatList != nil { env.SeatList, env.SeatListChanged = hooks.seatList.reader, hooks.seatList.changed diff --git a/cmd/mesh-host/nodeagent_integration_test.go b/cmd/mesh-host/nodeagent_integration_test.go index 4c49ab81..067c13c6 100644 --- a/cmd/mesh-host/nodeagent_integration_test.go +++ b/cmd/mesh-host/nodeagent_integration_test.go @@ -79,6 +79,9 @@ type itBed struct { // holder re-serves (issue 1966). seatAway atomic.Bool findings nats.KeyValue + // entryFails makes the stand-in answer the verb entry with a refusal in words the holder never gives for an unknown fingerprint: + // the ask fails to reach the holder's answer, as one on a bus that drops it does (design 47 H, H-A-60). + entryFails atomic.Bool // entries are the entries the stand-in of the seat mesh-catalog answers its verb entry from, by fingerprint (design 47 G §421). entries map[string]meshcatalog.CatalogEntry } @@ -117,6 +120,10 @@ func (b *itBed) standInEntry() { b.mu.Lock() e, ok := b.entries[in.Fingerprint] b.mu.Unlock() + if b.entryFails.Load() { + _ = m.Respond([]byte(`{"error":"the holder cannot answer now"}`)) + return + } if !ok { _ = m.Respond([]byte(`{"error":"no entry of fingerprint ` + in.Fingerprint + ` is kept"}`)) return @@ -334,6 +341,42 @@ func TestNatsANodeTheAssignmentsNameComposesAndAppliesItsOwn(t *testing.T) { t.Errorf("composed and applied under a grant without the served key: %q", b.file("web")) } }) + // Design 47 H, H-A-60 and H-A-110: an entry whose ask failed is asked again on each catalog-revision, at most entry-asks times; the + // shadow's wait on it and the have's end `unanswered`, loudly (the journal and the finding entry-unanswered), instead of waiting + // without bound; asked again by hand once the holder answers, the node composes. + t.Run("an entry whose ask failed is asked again on each catalog-revision and ends unanswered", func(t *testing.T) { + // The golden grant does not list the subscription to catalog-revision, which the manifest consumes: laid over it here. + granted := nodegrant.For(itNode, "it2.mailer.domain") + granted.Subscribe = append(granted.Subscribe, meshcatalog.SubjectCatalogRevisionAll) + b := newItBedAs(t, granted) + b.entryFails.Store(true) + stop, st := h8(t, b, false) + defer stop() + revision := func() bool { + if err := b.conn.Publish(meshcatalog.SubjectCatalogRevision("main"), []byte(`{}`)); err != nil { + t.Fatal(err) + } + h := b.have("web") + return h.Phase == nec.PhaseHeld && strings.HasPrefix(h.Detail, agent.EntryAsked) && strings.Contains(h.Detail, "is unanswered") + } + within(t, 20*time.Second, "web's entry did not end unanswered after the asks the setting allows", revision) + within(t, 5*time.Second, "the journal does not say the entry is unanswered", func() bool { + b.mu.Lock() + defer b.mu.Unlock() + return strings.Contains(strings.Join(b.said, "\n"), "is unanswered") + }) + if b.file("web") != "" { + t.Fatal("composed with an entry nobody answered") + } + b.entryFails.Store(false) + if err := composerNow.Load().EntryAgain(context.Background(), st.fp); err != nil { + t.Fatal(err) + } + if _, err := st.resolved.Put(itNode+".web.greeting", []byte(`{"value":"bonjour","source":"module"}`)); err != nil { + t.Fatal(err) + } + within(t, 5*time.Second, "the node did not compose once the entry was asked again and answered", func() bool { return b.file("web") == "greeting=bonjour\n" }) + }) b := newItBedAs(t, nodegrant.For(itNode, "it2.mailer.domain")) stop, st := h8(t, b, true) defer stop() diff --git a/cmd/mesh-host/ownname_test.go b/cmd/mesh-host/ownname_test.go index 0e77e7bf..1569c0a6 100644 --- a/cmd/mesh-host/ownname_test.go +++ b/cmd/mesh-host/ownname_test.go @@ -56,6 +56,26 @@ func TestTheEnginesOwnNameIsReadFromItsAppliedRecordOrItsFirstComposing(t *testi } } +// Design 47 H, H-A-60: how often an entry whose ask failed is asked again is the file the manifest's `entry-asks` feeds, five when it +// holds nothing usable. +func TestTheEntryAsksAreTheManifestsSetting(t *testing.T) { + was := entryAsksFile + defer func() { entryAsksFile = was }() + for content, want := range map[string]int{"2\n": 2, "": 5, "0": 5, "x": 5} { + entryAsksFile = filepath.Join(t.TempDir(), "w") + if err := os.WriteFile(entryAsksFile, []byte(content), 0o644); err != nil { + t.Fatal(err) + } + if got := entryAsks(); got != want { + t.Errorf("the file %q gives %v, want %v", content, got, want) + } + } + entryAsksFile = filepath.Join(t.TempDir(), "missing") + if got := entryAsks(); got != 5 { + t.Errorf("no file gives %v", got) + } +} + // §633: the engine's bound for the first seat list is the file the manifest's `view-waits-minutes` feeds, five minutes // when it holds nothing usable. func TestTheViewWaitsBoundIsTheManifestsSetting(t *testing.T) { diff --git a/cmd/mesh-host/seatlist.go b/cmd/mesh-host/seatlist.go index c23ceef8..15b0fd0c 100644 --- a/cmd/mesh-host/seatlist.go +++ b/cmd/mesh-host/seatlist.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "os" "strconv" "strings" @@ -124,7 +125,7 @@ func newFindingsOfTheNode(session *link.Session, node, module string, say func(s Module: module, Node: node, State: link.FindingsState{Session: session}, - Kinds: append([]string{seatwait.Kind, seatwait.HeldKind, seatwait.EntryNotFoundKind}, seatwait.NodeKinds...), + Kinds: append([]string{seatwait.Kind, seatwait.HeldKind, seatwait.EntryNotFoundKind, seatwait.EntryUnansweredKind}, seatwait.NodeKinds...), Asked: condseat.SubjectFindingsAsked, Logf: func(format string, args ...any) { say(fmt.Sprintf(format, args...)) }, Publish: session.PublishEvent, @@ -279,3 +280,21 @@ func viewWaitsBound() time.Duration { } return time.Duration(n) * time.Minute } + +// entryAsksFile is the file the manifest declares with the content ${config:entry-asks} (design 47 H, H-A-60), read at the +// engine's start as recoveryWaitFile is. +var entryAsksFile = "/var/lib/mesh-host/entry-asks" + +// entryAsks is how often an entry whose ask failed in transport is asked again before it is unanswered: the file's number, the +// design's five (meshcatalogclient.DefaultEntryAsks) when the file is missing, empty or not a positive number. +func entryAsks() int { + raw, err := os.ReadFile(entryAsksFile) + if err != nil { + return meshcatalogclient.DefaultEntryAsks + } + n, err := strconv.Atoi(strings.TrimSpace(string(raw))) + if err != nil || n <= 0 { + return meshcatalogclient.DefaultEntryAsks + } + return n +} diff --git a/internal/seatwait/entrynotfound.go b/internal/seatwait/entrynotfound.go index 2f9e37ba..6509c930 100644 --- a/internal/seatwait/entrynotfound.go +++ b/internal/seatwait/entrynotfound.go @@ -13,6 +13,10 @@ import ( // running for (design 47 G §614, A-15, A-117): scope module, its id the fingerprint escaped as a name. const EntryNotFoundKind = "entry-not-found" +// EntryUnansweredKind is the finding a part writes when its ask of the catalog half's entry of a fingerprint failed to reach the +// holder as often as the setting `entry-asks` allows (design 47 H, H-A-60): scope module, its id the fingerprint escaped as a name. +const EntryUnansweredKind = "entry-unanswered" + // EntryNotFoundID is the finding's id for a fingerprint. func EntryNotFoundID(fp string) string { return keys.EscapeName(fp) } @@ -31,3 +35,20 @@ func SayEntryNotFound(ctx context.Context, w Writer, node, observer, fp string, Explanation: "A want or a running names this build and the catalog half answered that it holds no entry of it. The finding clears when the entry is answered or nothing the node holds names the build.", At: now()}) } + +// SayEntryUnanswered writes the finding for fp when unanswered, and clears it when no longer: the entry answered later, asked +// again by hand, or nothing the node holds names the fingerprint any more (design 47 H, H-A-60). A write or a clear that fails is +// returned for the caller to say. +func SayEntryUnanswered(ctx context.Context, w Writer, node, observer, fp string, asks int, unanswered bool, now func() time.Time) error { + id := EntryNotFoundID(fp) + if !unanswered { + return w.Clear(ctx, scopeModule, id, EntryUnansweredKind, "the entry is answered, or nothing the node holds names its fingerprint") + } + return w.Write(ctx, condseat.Finding{Observer: observer, Kind: EntryUnansweredKind, Scope: scopeModule, ID: id, + Severity: condseat.FindingSeverityWarning, Source: EntryUnansweredKind, + Subject: condseat.Subject{Scope: scopeModule, ID: observer, Machine: node}, + Summary: fmt.Sprintf("the ask of the catalog half's entry of the build %s failed to reach the holder %d times, so %s composes nothing new of it", fp, asks, node), + Headline: fmt.Sprintf("the entry of the build %s is unanswered on %s", fp, node), + Explanation: "The ask failed in transport and was asked again as often as the setting entry-asks allows. The finding clears when the entry is answered, asked again by hand (the seat node-engine's verb entry-again) or nothing the node holds names the build.", + At: now()}) +} diff --git a/internal/seatwait/seatwait_test.go b/internal/seatwait/seatwait_test.go index ba7b6e58..128e1442 100644 --- a/internal/seatwait/seatwait_test.go +++ b/internal/seatwait/seatwait_test.go @@ -230,6 +230,17 @@ func caseAnEntryNotFoundIsAFindingOfTheFingerprint(t *testing.T) { if err := SayEntryNotFound(context.Background(), w, "n1", "mesh-host", fp, false, now); err != nil || len(w.cleared) != 1 || w.cleared[0].ID != w.put[0].ID { t.Fatalf("cleared %+v, %v", w.cleared, err) } + // And design 47 H, H-A-60: an entry unanswered is the finding entry-unanswered, of the same scope and id, cleared by the same. + u := &fakeFindings{} + if err := SayEntryUnanswered(context.Background(), u, "n1", "mesh-host", fp, 5, true, now); err != nil { + t.Fatal(err) + } + if len(u.put) != 1 || u.put[0].Kind != EntryUnansweredKind || u.put[0].Scope != "module" || u.put[0].ID != keys.EscapeName(fp) { + t.Fatalf("written %+v", u.put) + } + if err := SayEntryUnanswered(context.Background(), u, "n1", "mesh-host", fp, 0, false, now); err != nil || len(u.cleared) != 1 || u.cleared[0].Kind != EntryUnansweredKind || u.cleared[0].ID != u.put[0].ID { + t.Fatalf("cleared %+v, %v", u.cleared, err) + } } // ADR 0636 §1, the node's finding of a seat list unread. diff --git a/internal/selfcompose/entries.go b/internal/selfcompose/entries.go index d91053cc..5daf0032 100644 --- a/internal/selfcompose/entries.go +++ b/internal/selfcompose/entries.go @@ -76,6 +76,7 @@ func (c *Composer) newEntries() { } c.entries = meshcatalogclient.NewEntries(c.env.Entry) c.entries.Now = c.now + c.entries.Asks = c.env.EntryAsks c.entries.Changed = c.entryChanged c.keptEnt = map[string]keptEntry{} c.keptWants = map[string]bool{} @@ -153,6 +154,7 @@ func (c *Composer) entryChanged(row meshcatalogclient.EntryRow) { c.keep(entryKey(row.Fingerprint), meshcatalog.EntryAnswer{Entry: *row.Entry}) } c.tellNotFound(row.Fingerprint, row.State == meshcatalogclient.EntryNotFound) + c.tellUnanswered(row.Fingerprint, row.Asks, row.State == meshcatalogclient.EntryUnanswered) if row.State == meshcatalogclient.EntryAnswered { c.handAgainFor(row.Fingerprint) } @@ -211,6 +213,40 @@ func (c *Composer) tellNotFound(fp string, notFound bool) { } } +// tellUnanswered tells the finding entry-unanswered once when fp's entry is unanswered, with a journal line saying it, and once when +// it no longer is (design 47 H, H-A-60). +func (c *Composer) tellUnanswered(fp string, asks int, unanswered bool) { + c.mu.Lock() + was := c.unanswered[fp] + if was == unanswered { + c.mu.Unlock() + return + } + if c.unanswered == nil { + c.unanswered = map[string]bool{} + } + if unanswered { + c.unanswered[fp] = true + } else { + delete(c.unanswered, fp) + } + c.mu.Unlock() + if unanswered { + c.env.Say(fmt.Sprintf("the entry of the build %s is unanswered: its ask failed to reach the catalog half's holder %d times more, so the node composes nothing new of it until it is asked again (the seat node-engine's verb entry-again)", fp, asks)) + } + if c.env.EntryUnanswered != nil { + c.env.EntryUnanswered(fp, asks, unanswered) + } +} + +// EntriesAskAgain asks again every entry whose last ask failed in transport (meshcatalogclient.Entries.AskAgain): the node agent +// calls it when its link to the bus opens (design 47 H, H-A-60). +func (c *Composer) EntriesAskAgain(ctx context.Context) { + if c.entries != nil { + c.entries.AskAgain(ctx) + } +} + // keep writes one value into the composition state; a state that cannot be written is said, and the value is kept again by // the next pass. func (c *Composer) keep(key string, v any) { @@ -318,6 +354,7 @@ func (c *Composer) syncEntries(ctx context.Context) { if _, named := need[row.Fingerprint]; !named && !added { c.entries.Release(row.Fingerprint) c.tellNotFound(row.Fingerprint, false) + c.tellUnanswered(row.Fingerprint, 0, false) } } c.mu.Lock() @@ -701,6 +738,9 @@ func (c *Composer) entryHolds() map[string]string { case meshcatalogclient.EntryAsked: out[module] = fmt.Sprintf("%s the entry of the build %s is asked of the catalog half and not yet answered, so the node composes nothing new of %s", agent.EntryAsked, w.Fp, module) + case meshcatalogclient.EntryUnanswered: + out[module] = fmt.Sprintf("%s the entry of the build %s is unanswered: its ask failed to reach the catalog half as often as the setting entry-asks allows, so the node composes nothing new of %s", + agent.EntryAsked, w.Fp, module) case meshcatalogclient.EntryNotFound: out[module] = fmt.Sprintf("%s the catalog half holds no entry of the build %s, so the node composes nothing new of %s", agent.EntryMissing, w.Fp, module) @@ -951,6 +991,8 @@ func (c *Composer) addedModule(ctx context.Context, module string) (fp string, e return fp, e, true, false, "" case meshcatalogclient.EntryNotFound: return fp, e, false, false, fmt.Sprintf("the catalog half holds no entry of %s's build %s", module, fp) + case meshcatalogclient.EntryUnanswered: + return fp, e, false, false, fmt.Sprintf("the entry of %s's build %s is unanswered: its ask failed to reach the catalog half as often as the setting entry-asks allows", module, fp) } return fp, e, false, true, fmt.Sprintf("the entry of %s's build %s is asked of the catalog half and not yet answered", module, fp) } diff --git a/internal/selfcompose/entries_test.go b/internal/selfcompose/entries_test.go index abf74d75..ae9aec8c 100644 --- a/internal/selfcompose/entries_test.go +++ b/internal/selfcompose/entries_test.go @@ -635,6 +635,7 @@ func TestRunningBuildEntryKeptAndHandedAgain(t *testing.T) { // it is bound to), never of every module placed there, and beside the pass. func TestOnlyWhatTheNodeNeedsOfAnotherNodesPlacementIsAsked(t *testing.T) { t.Run("a trunk build the catalog gave none of waits its backoff or a catalog-revision (A-487a)", trunkAskBackoffAndCatalogRevision) + t.Run("an entry whose ask failed is asked again on each catalog-revision, at most entry-asks times, then unanswered (H-A-60, H-A-110)", entryAskedAgainThenUnanswered) env := newFakeBus().env() env.Node = "n1" var mu sync.Mutex @@ -770,3 +771,81 @@ func trunkAskBackoffAndCatalogRevision(t *testing.T) { t.Error("catalog-revision was heard and the wait of the module stands") } } + +// Design 47 H, H-A-60 and H-A-110: an entry whose ask failed in transport is asked again on each catalog-revision the composer hears +// (never on a timer), at most the setting entry-asks times; one more failure and it is unanswered, said in the journal and as the +// finding entry-unanswered, which the shadow does not wait on; asked again by hand and answered, the finding is cleared. +func entryAskedAgainThenUnanswered(t *testing.T) { + fp := meshcatalogclient.SourcePrefix2 + strings.Repeat("c", 64) + var calls atomic.Int32 + var answers atomic.Bool + env := newFakeBus().env() + env.EntryAsks = 2 + env.Entry = EntryCall(func(context.Context, string, string, any) (json.RawMessage, error) { + calls.Add(1) + if answers.Load() { + return json.Marshal(meshcatalog.EntryAnswer{Entry: meshcatalog.CatalogEntry{Module: "web", Fp: fp}}) + } + return nil, errors.New("the bus did not answer") + }) + var mu sync.Mutex + var said []string + told := []string{} + env.Say = func(line string) { mu.Lock(); said = append(said, line); mu.Unlock() } + env.EntryUnanswered = func(got string, asks int, unanswered bool) { + mu.Lock() + told = append(told, fmt.Sprintf("%s %d %v", got, asks, unanswered)) + mu.Unlock() + } + heard := make(chan []byte) + env.Hear = func(string) (<-chan []byte, func(), error) { return heard, func() {}, nil } + c := New(env) + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + go c.hearCatalogRevisions(ctx, func() {}) + state := func() meshcatalogclient.EntryState { _, st := c.entries.Need(ctx, fp); return st } + c.entries.Need(ctx, fp) + // Each catalog-revision asks the failed entry again once: three asks in all, the third being the one past the bound of two. + for deadline := time.Now().Add(10 * time.Second); state() != meshcatalogclient.EntryUnanswered; { + if time.Now().After(deadline) { + t.Fatalf("the entry is %s after %d asks, want unanswered", state(), calls.Load()) + } + select { + case heard <- nil: + case <-time.After(time.Millisecond): + } + } + for i := 0; i < 3; i++ { + heard <- nil // an unanswered entry is not asked again by an event + } + var gotTold, gotSaid string + for deadline := time.Now().Add(10 * time.Second); gotTold == "[]" || gotTold == ""; runtime.Gosched() { + mu.Lock() + gotTold, gotSaid = fmt.Sprint(told), strings.Join(said, "\n") + mu.Unlock() + if time.Now().After(deadline) { + break + } + } + if calls.Load() != 3 || gotTold != "["+fp+" 2 true]" || !strings.Contains(gotSaid, "is unanswered") || !strings.Contains(gotSaid, fp) { + t.Errorf("asked %d times, told %s, said %q; want 3 asks, the finding told once with 2 asks and the journal line", calls.Load(), gotTold, gotSaid) + } + // The shadow's wait on the entry ends: it is no longer pending. + c.mu.Lock() + c.wants = map[string]meshwants.WantsByWantNodeModuleValue{"web": {Fp: fp}} + c.mu.Unlock() + if c.syncShadowEntries(ctx) { + t.Error("the shadow still waits on an unanswered entry") + } + // Asked again by hand and answered, the finding is cleared. + answers.Store(true) + if err := c.entries.Again(ctx, fp); err != nil { + t.Fatal(err) + } + mu.Lock() + gotTold = fmt.Sprint(told) + mu.Unlock() + if gotTold != "["+fp+" 2 true "+fp+" 0 false]" { + t.Errorf("told %s after the answer, want the finding cleared", gotTold) + } +} diff --git a/internal/selfcompose/selfcompose.go b/internal/selfcompose/selfcompose.go index f369f793..1ad36a7f 100644 --- a/internal/selfcompose/selfcompose.go +++ b/internal/selfcompose/selfcompose.go @@ -67,6 +67,12 @@ type Env struct { // EntryNotFound is told when the catalog half answered it holds no entry of a fingerprint (notFound), and when that is no longer so: // the entry answered, or nothing the node holds names it (design 47 G §614, A-117). Nil tells nobody. EntryNotFound func(fp string, notFound bool) + // EntryUnanswered is told when an ask of the catalog half's entry failed to reach the holder as often as EntryAsks allows + // (unanswered), and when that is no longer so (design 47 H, H-A-60). Nil tells nobody. + EntryUnanswered func(fp string, asks int, unanswered bool) + // EntryAsks is the setting `entry-asks`: how often an entry whose ask failed in transport is asked again before it is + // unanswered; meshcatalogclient.DefaultEntryAsks when 0 (design 47 H, H-A-60). + EntryAsks int // Watch follows one bucket's keys matching pattern, as the agent's watches do. Watch func(ctx context.Context, bucket, pattern string) (<-chan agent.Update, error) // Get reads one key's latest value; nil and no error when there is none. @@ -168,7 +174,10 @@ type Composer struct { OnEngine func(module string) // AlsoEntryAgain is told each entry asked again by hand, so the shadow's own cache of entries asks it again too. AlsoEntryAgain func(ctx context.Context, fp string) - env Env + // AlsoEntriesAskAgain is told each catalog-revision the composer hears, so the shadow, which hears nothing itself, asks its + // own entries again too (design 47 H, H-A-110). + AlsoEntriesAskAgain func(ctx context.Context) + env Env mu sync.Mutex wants map[string]meshwants.WantsByWantNodeModuleValue // by module, the node's own under agent.NodeModule @@ -202,6 +211,8 @@ type Composer struct { keptEnt map[string]keptEntry // notFound is each fingerprint whose entry-not-found the composer told, so it is told once and cleared once. notFound map[string]bool + // unanswered is each fingerprint whose entry-unanswered the composer told, so it is told once and cleared once. + unanswered map[string]bool // resolved is each wanted build's digests as its version resolved them through the registry seats (versions.go, A-430a). resolved map[resolvedKey]versionParts keptWantVal map[string]keptWant @@ -706,7 +717,7 @@ func (c *Composer) Watch(ctx context.Context, _ string) (<-chan agent.Update, er return out, nil } -// hearCatalogRevisions hears the seat mesh-catalog's event catalog-revision: each one clears the backoffs of the trunk builds the +// hearCatalogRevisions hears the seat mesh-catalog's event catalog-revision: each one asks again the entries whose ask failed (H-A-110), clears the backoffs of the trunk builds the // catalog gave none of and wakes a pass (A-487a). A wake-up only, the backoff bounds the asks without it: a subscription refused // is said once with its subject and error (principle 3), the composer goes on composing, and the subscription is tried again on // laterAgain's steps until it holds. @@ -725,6 +736,11 @@ func (c *Composer) hearCatalogRevisions(ctx context.Context, wake func()) { return } c.trunkRetryCleared() + // And each entry whose ask failed in transport is asked again, once per take-in (design 47 H, H-A-110). + c.EntriesAskAgain(ctx) + if c.AlsoEntriesAskAgain != nil { + c.AlsoEntriesAskAgain(ctx) + } wake() } } diff --git a/internal/selfcompose/shadow.go b/internal/selfcompose/shadow.go index cc392667..8a6ab8aa 100644 --- a/internal/selfcompose/shadow.go +++ b/internal/selfcompose/shadow.go @@ -826,6 +826,9 @@ func (c *Composer) sameValue(a, b string) (same, known bool) { return bytes.Equal(x, y), true } +// EntriesAskAgain asks again every entry of the shadow's own cache whose last ask failed in transport (design 47 H, H-A-60). +func (s *Shadow) EntriesAskAgain(ctx context.Context) { s.c.EntriesAskAgain(ctx) } + // EntryAgain asks fp's entry of the catalog half again in the shadow's own cache, where the node's own composer was asked // again by hand: an entry the shadow holds as not found stays so until it is asked (a build the half had not yet taken in). func (s *Shadow) EntryAgain(ctx context.Context, fp string) { diff --git a/module.json b/module.json index 8f80630e..8f26a84c 100644 --- a/module.json +++ b/module.json @@ -105,6 +105,12 @@ "minimum": 1, "default": 5 }, + "entry-asks": { + "type": "number", + "description": "How often the node-engine asks the catalog half's entry of a build again after an ask that failed to reach the holder, before the entry is unanswered and the finding entry-unanswered is written (design 47 H, H-A-60).", + "minimum": 1, + "default": 5 + }, "operator-signers": { "type": "string", "description": "The operator's public keys, ed25519 in base64, one a line: the node applies a composition made by hand only when one of these signed it (ADR 0539 clause 3). Public keys, no secret. Empty trusts no operator key.", @@ -147,6 +153,13 @@ "mode": "0644", "content": "${config:recovery-wait-minutes}\n" }, + { + "id": "entry-asks", + "type": "file", + "path": "/var/lib/mesh-host/entry-asks", + "mode": "0644", + "content": "${config:entry-asks}\n" + }, { "id": "view-waits", "type": "file", diff --git a/packaging/operator_keys_test.go b/packaging/operator_keys_test.go index 1fa92620..46c6452c 100644 --- a/packaging/operator_keys_test.go +++ b/packaging/operator_keys_test.go @@ -89,6 +89,9 @@ func TestTheManifestConsumesTheBackupEvent(t *testing.T) { if !strings.Contains(string(raw), `"content": "${config:recovery-wait-minutes}\n"`) { t.Errorf("module.json declares no file with the content ${config:recovery-wait-minutes} (design 47 G A-112)") } + if !strings.Contains(string(raw), `"content": "${config:entry-asks}\n"`) || m.Config["entry-asks"].Default != float64(5) { + t.Errorf("module.json declares no file with the content ${config:entry-asks} or its default is not 5 (design 47 H, H-A-60)") + } if m.Config["recovery-wait-minutes"].Default != float64(90) { t.Errorf("config recovery-wait-minutes is %+v, want default 90", m.Config["recovery-wait-minutes"]) }