selfcompose: the manifest of the build a module runs here is answered in one place; every step reads it there (A-484)
Entry of the running build, else the composition this node runs of it, else the module's trunk manifest through the seat mesh-catalog's verb module; said once per module and source; words naming the three where none answers. Read there: a held module's offer (frombus Scope.RunningManifest), FormChanges (A-483), the store holder and the stand of a running module without an entry (A-461d, A-480a), and the tool composition. Builds: design 47 G A-484, A-480, A-480a, A-483, A-461d, A-482
This commit is contained in:
@@ -75,7 +75,7 @@ func Answer(ctx context.Context, r Reader, mesh Mesh, s Scope, fps map[string]st
|
||||
return refuse(fmt.Errorf("frombus: the credentials of %s: %w", s.Node, err))
|
||||
}
|
||||
}
|
||||
composed, skipped, stood, err := composeEach(in, s.Node, fps, false, s.Running, failed, ranOf(ctx, r, mesh, s.Running, fps), true)
|
||||
composed, skipped, stood, err := composeEach(in, s.Node, fps, false, s.Running, failed, s.RunningManifest, true)
|
||||
if err != nil {
|
||||
// Not one module's: the node's own (a value served elsewhere, the mesh's network), said once as the node's.
|
||||
if len(failed) == 0 {
|
||||
@@ -358,21 +358,13 @@ func composeEach(in compose.Input, node string, fps map[string]string, applied b
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
running, known := catalogue.Manifest{}, false
|
||||
if ran != nil {
|
||||
if was, ok := ran(m); ok {
|
||||
man.Contributes, man.ContributesMany, man.Listens = was.Contributes, was.ContributesMany, was.Listens
|
||||
running, known = was, true
|
||||
// A held module keeps running what it runs, so it keeps offering what that build offers, whatever its version and
|
||||
// whether the catalog lists the build: the module that requires it is no "nothing provides" (A-480, A-484).
|
||||
man.Contributes, man.ContributesMany, man.Listens, man.Provides = was.Contributes, was.ContributesMany, was.Listens, was.Provides
|
||||
}
|
||||
}
|
||||
if !known {
|
||||
running, known = heardManifest(in, node, m)
|
||||
}
|
||||
if known {
|
||||
// A held module keeps running what it runs, so it keeps providing what that build provides, whatever its version and
|
||||
// whether the catalog lists the build: the module that requires it is no "nothing provides" (A-480).
|
||||
man.Provides = running.Provides
|
||||
}
|
||||
src[m] = man
|
||||
}
|
||||
if leave != "" {
|
||||
@@ -522,19 +514,6 @@ func manifestOn(in compose.Input, node, module string) (catalogue.Manifest, bool
|
||||
return man, ok
|
||||
}
|
||||
|
||||
// heardManifest is the manifest of the build node said it runs of module (its `running` event's manifest, read by the event's digest,
|
||||
// Node.Heard): false where nothing runs of it, it is stopped or the digest could not be read.
|
||||
func heardManifest(in compose.Input, node, module string) (catalogue.Manifest, bool) {
|
||||
for _, n := range in.Nodes {
|
||||
if n.Name == node {
|
||||
if h, ok := n.Heard[module]; ok && h.Read && !h.Stopped {
|
||||
return h.Manifest, true
|
||||
}
|
||||
}
|
||||
}
|
||||
return catalogue.Manifest{}, false
|
||||
}
|
||||
|
||||
// culprit is the module placed on node whose composition the error is of, and what of its offer to leave out: the
|
||||
// first, in assignment order, whose stub (compose.Stub) makes the composition in mode succeed or fail otherwise (leave
|
||||
// ""); else the first whose stub without what it contributes to one provision does (leave that provision: de-spiegel's
|
||||
|
||||
@@ -638,7 +638,10 @@ func answerNamesEveryRefusalAndLeavesAnOldBuildToTheNode(t *testing.T) {
|
||||
siteRuns.FP = fp("7")
|
||||
b.manifests[meshcatalogclient.ManifestDigest(site)] = site
|
||||
b.builds["site "+fp("7")] = &builds.BuilderBuild{State: builds.BuildDone, Manifest: meshcatalogclient.ManifestDigest(site)}
|
||||
got, _, held, err = Compose(ctx, b, Mesh{}, Scope{Node: "n1", Running: []engcomp.Composed{siteRuns}}, fps)
|
||||
// The manifest of the build that runs is read in the one place (A-484), here the manifest of the build 7.
|
||||
ranSite, _ := catalogue.Decode(site)
|
||||
got, _, held, err = Compose(ctx, b, Mesh{}, Scope{Node: "n1", Running: []engcomp.Composed{siteRuns},
|
||||
RunningManifest: func(module string) (catalogue.Manifest, bool) { return ranSite, module == "site" }}, fps)
|
||||
if err != nil || held["site"] == "" || held["nft"] != "" {
|
||||
t.Errorf("site moved to 9090 in its new manifest: %v, held %v; want site held alone", err, held)
|
||||
}
|
||||
|
||||
@@ -197,6 +197,11 @@ type Scope struct {
|
||||
// the seat list, novox/hq ADR 0636 §1): each is held as it runs, as a module refused alone is, so no take-in or
|
||||
// artifact reference of it can refuse the node (issue 1966). Nil holds none.
|
||||
Held map[string]string
|
||||
// RunningManifest answers the manifest of the build a module runs on the composing node, from the one place that reads it
|
||||
// (design 47 G A-484: its entry, else the composition the node runs of it, else the trunk's manifest): what a held module
|
||||
// keeps offering the others (what it provides, contributes and listens on), since it keeps running what it runs. False
|
||||
// where nothing is read; the manifest it is composed from is its offer then. Nil: none is read.
|
||||
RunningManifest func(module string) (catalogue.Manifest, bool)
|
||||
}
|
||||
|
||||
// InOwn is, of the modules p places on its node, those whose resources the node's own composition it runs
|
||||
@@ -703,7 +708,7 @@ func Compose(ctx context.Context, r Reader, mesh Mesh, s Scope, fps map[string]s
|
||||
return nil, nil, held, fmt.Errorf("frombus: the credentials of %s: %w", s.Node, err)
|
||||
}
|
||||
}
|
||||
out, skipped, _, err = composeEach(in, s.Node, fps, true, s.Running, held, ranOf(ctx, r, mesh, s.Running, fps), true)
|
||||
out, skipped, _, err = composeEach(in, s.Node, fps, true, s.Running, held, s.RunningManifest, true)
|
||||
return out, skipped, held, err
|
||||
}
|
||||
|
||||
@@ -991,33 +996,6 @@ func parser(Mesh) func([]byte) (catalogue.Manifest, error) {
|
||||
return catalogue.Decode
|
||||
}
|
||||
|
||||
// ranOf is what a module last offered the others, read when it is held (composeEach, issue 1960): its manifest at the
|
||||
// build its own composition runs at (running), where that is another build than the one it is composed at (fps) and
|
||||
// the builder holds it done. False where nothing is known of it (it runs no composition of its own, it runs the build
|
||||
// it is composed at, or its build is unread): the manifest it is composed from is its offer then. Only what it says to
|
||||
// others is taken of it, which needs no take-in of its artifacts.
|
||||
func ranOf(ctx context.Context, r Reader, mesh Mesh, running []engcomp.Composed, fps map[string]string) func(string) (catalogue.Manifest, bool) {
|
||||
parse := parser(mesh)
|
||||
return func(module string) (catalogue.Manifest, bool) {
|
||||
for _, c := range running {
|
||||
if c.Module != module || c.FP == "" || c.FP == fps[module] {
|
||||
continue
|
||||
}
|
||||
b, err := r.Build(ctx, module, c.FP)
|
||||
if err != nil || b == nil || b.State != builds.BuildDone || b.Manifest == "" {
|
||||
return catalogue.Manifest{}, false
|
||||
}
|
||||
raw, err := r.Manifest(ctx, b.Manifest)
|
||||
if err != nil {
|
||||
return catalogue.Manifest{}, false
|
||||
}
|
||||
man, err := parse(raw)
|
||||
return man, err == nil
|
||||
}
|
||||
return catalogue.Manifest{}, false
|
||||
}
|
||||
}
|
||||
|
||||
// fromBuilds puts in the built manifest of each module placed on the composing node, at the trunk's FP2, and of each
|
||||
// module it keeps at another build (Scope.KeptAt, into its node's Kept), read from the builder's done key and resolved
|
||||
// by the one take-in rule (takein.Manifest), a templates archive read in the artifact store as the node reaches it
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"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"
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
"github.com/novox/mesh-host/internal/compose"
|
||||
"github.com/novox/mesh-host/internal/compose/resolution"
|
||||
engcomp "github.com/novox/mesh-host/internal/compositions"
|
||||
@@ -342,8 +343,8 @@ func TestASecondClaimantOfASeatIsHeldAndTheNodeComposesTheRest(t *testing.T) {
|
||||
// A-480 (design 47 G): a module the node holds keeps running what it runs, and so keeps providing what its running build provides,
|
||||
// whatever its catalogue entry: the module that requires it is not held for "nothing provides" (live, 2026-11-17 22:52: feh on g14
|
||||
// held for "x11-display" while xorg runs there, held only for want of an entry of its wanted build). The offer is the running
|
||||
// composition's build's manifest (the builder's done key), else the manifest the module's `running` event names; a module
|
||||
// neither running nor composable still gives "nothing provides".
|
||||
// manifest of the build it runs, from the one place that reads it (A-484); a module neither running nor composable still gives
|
||||
// "nothing provides".
|
||||
const xorgRunning = `{"module":"xorg","version":"1","provides":[{"name":"x11-display"}]}`
|
||||
feh := `{"module":"feh","version":"1","requires":["x11-display"]}`
|
||||
nameOnly := `{"module":"xorg","version":"0"}`
|
||||
@@ -352,18 +353,13 @@ func TestASecondClaimantOfASeatIsHeldAndTheNodeComposesTheRest(t *testing.T) {
|
||||
scope func(fps map[string]string, b *bus) Scope
|
||||
provided bool
|
||||
}{
|
||||
{"it runs a build its running event names", func(fps map[string]string, b *bus) Scope {
|
||||
digest := meshcatalogclient.ManifestDigest([]byte(xorgRunning))
|
||||
b.manifests[digest] = []byte(xorgRunning)
|
||||
return Scope{Heard: map[string]map[string]Heard{"n1": {"xorg": {Fingerprint: "src2:" + strings.Repeat("r", 64), Manifest: digest}}}}
|
||||
}, true},
|
||||
{"its composition runs a build the builder holds done", func(fps map[string]string, b *bus) Scope {
|
||||
fp := "src2:" + strings.Repeat("r", 64)
|
||||
digest := meshcatalogclient.ManifestDigest([]byte(xorgRunning))
|
||||
b.manifests[digest] = []byte(xorgRunning)
|
||||
b.builds["xorg "+fp] = &builds.BuilderBuild{State: builds.BuildDone, Manifest: digest}
|
||||
return Scope{Running: []engcomp.Composed{{Node: "n1", Module: "xorg", FP: fp}}}
|
||||
{"the one place answers the manifest of the build it runs (A-484)", func(fps map[string]string, b *bus) Scope {
|
||||
man, _ := catalogue.Decode([]byte(xorgRunning))
|
||||
return Scope{RunningManifest: func(module string) (catalogue.Manifest, bool) { return man, module == "xorg" }}
|
||||
}, true},
|
||||
{"the one place reads none", func(map[string]string, *bus) Scope {
|
||||
return Scope{RunningManifest: func(string) (catalogue.Manifest, bool) { return catalogue.Manifest{}, false }}
|
||||
}, false},
|
||||
{"nothing of it runs", func(map[string]string, *bus) Scope { return Scope{} }, false},
|
||||
} {
|
||||
b, fps := aNode(t, nameOnly, feh)
|
||||
|
||||
Reference in New Issue
Block a user