H-15: the apply guard and the yields read the node-engine's module from the entry claiming its seat
The module is the one whose catalog entry claims node-engine, else the one this node heard run the build its own fingerprint names; no name is fixed in the guard or in the compose. Builds: design 47 G §364, §527, §428 Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
||||
mcat "git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
)
|
||||
|
||||
@@ -56,8 +57,16 @@ func systemPath(path string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// engineModule is the node-engine's own module, the one that places in engineTrees.
|
||||
const engineModule = "mesh-host"
|
||||
// ClaimsEngine is whether a manifest claims the seat node-engine: the node-engine's own module is the one whose entry of
|
||||
// the catalog half does (design 47 G §527), never a name fixed in code.
|
||||
func ClaimsEngine(m mcat.Manifest) bool {
|
||||
for _, c := range m.Claims {
|
||||
if c.Name == nodeengine.Seat {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// accessRef is how a module names one of its accesses: ${access:<id>}.
|
||||
var accessRef = regexp.MustCompile(`\$\{access:([a-z0-9][a-z0-9-]*)\}`)
|
||||
|
||||
@@ -310,16 +310,25 @@ func TestAModuleOfItsOwnAccountIsServedByARuntimeOfItsOwn(t *testing.T) {
|
||||
}
|
||||
gob, img := builder("gob", "node-build-go"), builder("img", "node-build-image")
|
||||
with.Needed["gob"], with.Needed["img"] = map[string]string{"broker": "own"}, map[string]string{"broker": "own"}
|
||||
// The node-engine's module is the one whose entry claims its seat (design 47 G §527), whatever it is called; with none in
|
||||
// the resolution its settings are not found and the default stands.
|
||||
engine := mcat.Manifest{Module: "mesh-host", Claims: []mcat.Claim{{Name: "node-engine"}}}
|
||||
for _, c := range []struct {
|
||||
settings mcat.SettingsBy
|
||||
share string
|
||||
noEngine bool
|
||||
}{
|
||||
{nil, "50"},
|
||||
{mcat.SettingsBy{"mesh-host": {{From: "anchor", Values: map[string]any{"build-cpu-share": float64(75)}}}}, "75"},
|
||||
{mcat.SettingsBy{"mesh-host": {{From: "anchor", Values: map[string]any{"build-cpu-share": float64(0)}}}}, "50"},
|
||||
{nil, "50", false},
|
||||
{mcat.SettingsBy{"mesh-host": {{From: "anchor", Values: map[string]any{"build-cpu-share": float64(75)}}}}, "75", false},
|
||||
{mcat.SettingsBy{"mesh-host": {{From: "anchor", Values: map[string]any{"build-cpu-share": float64(0)}}}}, "50", false},
|
||||
{mcat.SettingsBy{"mesh-host": {{From: "anchor", Values: map[string]any{"build-cpu-share": float64(75)}}}}, "50", true},
|
||||
} {
|
||||
with.Settings = c.settings
|
||||
runtimes, err := resolutionOwnRuntimes(mcat.Resolution{Node: "anchor", Modules: []mcat.Manifest{gob, img, telegram, goRuntime}}, with)
|
||||
modules := []mcat.Manifest{gob, img, telegram, goRuntime, engine}
|
||||
if c.noEngine {
|
||||
modules = modules[:4]
|
||||
}
|
||||
runtimes, err := resolutionOwnRuntimes(mcat.Resolution{Node: "anchor", Modules: modules}, with)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ func resolutionYieldsOf(r mcat.Resolution, m mcat.Manifest, with mcat.Rendering)
|
||||
if !yields(m) {
|
||||
return nil, nil
|
||||
}
|
||||
engine := mcat.Manifest{Module: engineModule}
|
||||
var engine mcat.Manifest // the module claiming the seat node-engine; none in the resolution leaves the default
|
||||
for _, e := range r.Modules {
|
||||
if e.Module == engineModule {
|
||||
if ClaimsEngine(e) {
|
||||
engine = e
|
||||
}
|
||||
}
|
||||
share := mcat.BuildCPUDefaultPercent
|
||||
for _, s := range Effective(engine, with.Settings[engineModule]) {
|
||||
for _, s := range Effective(engine, with.Settings[engine.Module]) {
|
||||
if s.Key == mcat.BuildCPUShareSetting {
|
||||
if n, ok := percentOf(s.Value); ok {
|
||||
share = n
|
||||
|
||||
Reference in New Issue
Block a user