MH-2b: the node-engine reads the want by the real contract: composed, kept-on and newest go
A want carries no composed digest, no keeping node and no newest build (design 47 H 750, H-A-37): the agent takes the digest from the composition the node made for the want's build, the shadow's resolution around a missing entry (A-405) and KeptBuildOf's keeping node go, and the artifact is fetched from the store. Tests of the removed behaviour go. Builds: design 47 H §750; H-A-37 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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}}}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user