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:
@@ -54,6 +54,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/declaration"
|
||||
@@ -303,8 +304,28 @@ func splitQuoted(s string) []string {
|
||||
return out
|
||||
}
|
||||
|
||||
// engineModule is the module whose resources may place in the engine's own trees.
|
||||
const engineModule = "mesh-host"
|
||||
// engineModuleOf answers the module whose resources may place in the engine's own trees: the module whose entry of the
|
||||
// catalog half claims the seat node-engine (design 47 G §527), asked of the node's composer; none until one is given.
|
||||
var engineModuleOf atomic.Pointer[func() string]
|
||||
|
||||
// UseEngineModule gives the apply guard the function that answers the node-engine's own module; nil takes it away. The
|
||||
// guard fixes no name (§364, §527).
|
||||
func UseEngineModule(f func() string) {
|
||||
if f == nil {
|
||||
engineModuleOf.Store(nil)
|
||||
return
|
||||
}
|
||||
engineModuleOf.Store(&f)
|
||||
}
|
||||
|
||||
// isEngineModule is whether module is the node-engine's own.
|
||||
func isEngineModule(module string) bool {
|
||||
f := engineModuleOf.Load()
|
||||
if f == nil || module == "" {
|
||||
return false
|
||||
}
|
||||
return (*f)() == module
|
||||
}
|
||||
|
||||
// passwdFile is the user database homes are read from. A variable so a test names its own.
|
||||
var passwdFile = "/etc/passwd"
|
||||
@@ -531,7 +552,7 @@ func refuseOne(path string, kind placing, module, owner string, declared map[str
|
||||
return &PlacementRefusedError{Path: path, Why: "nothing is placed in or mounted from " + tree}
|
||||
}
|
||||
}
|
||||
if module != engineModule {
|
||||
if !isEngineModule(module) {
|
||||
for _, tree := range engineTrees {
|
||||
if atOrBelow(path, tree) {
|
||||
return &PlacementRefusedError{Path: path, Why: tree + " is the node-engine's own, placed in by " +
|
||||
|
||||
@@ -193,4 +193,24 @@ func TestAModulesOwnPlacesAreStillPlaced(t *testing.T) {
|
||||
if err := refusePath("/var/lib/notes/data", placingDirectory, "notes", "1001:2000"); err != nil {
|
||||
t.Errorf("an owner below /var/lib: %v", err)
|
||||
}
|
||||
// Design 47 G §364, §527: the node-engine's own trees are placed in by the module the composer says claims its seat,
|
||||
// whatever that module is called, and by no other; with none said, by nobody.
|
||||
tree := engineTrees[0]
|
||||
t.Cleanup(func() { UseEngineModule(nil) })
|
||||
for _, c := range []struct {
|
||||
engine func() string
|
||||
module string
|
||||
placed bool
|
||||
}{
|
||||
{func() string { return "the-engine" }, "the-engine", true},
|
||||
{func() string { return "the-engine" }, "notes", false},
|
||||
{func() string { return "the-engine" }, "", false},
|
||||
{func() string { return "" }, "", false},
|
||||
{nil, "the-engine", false},
|
||||
} {
|
||||
UseEngineModule(c.engine)
|
||||
if err := refusePath(tree, placingDirectory, c.module, ""); (err == nil) != c.placed {
|
||||
t.Errorf("%s for module %q: %v, want placed %v", tree, c.module, err, c.placed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user