From ea25a8389d612b8e1ed500b88d9c8578edb176f8 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 02:31:13 +0100 Subject: [PATCH] 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) }