H6 fingerprint-for-daemons: only a daemon whose want names a fingerprint is handed MESH_FINGERPRINT

Builds: design 47 H2 H-A-710 (1) (hq 27369077)
This commit is contained in:
2026-11-25 17:11:40 +01:00
parent 894e2c89c2
commit 4e520bffe4
2 changed files with 61 additions and 15 deletions
+25 -5
View File
@@ -167,12 +167,12 @@ func TestComparingCompositions(t *testing.T) {
t.Errorf("a composition not run is added: %+v", c)
}
// Design 47, *The fingerprint handover* (the composed resources are split here): a daemon or a container of a module
// Design 47, *The fingerprint handover* (the composed resources are split here), H2 H-A-710 (1): a daemon of a module
// is started with MESH_FINGERPRINT, the fingerprint of the want it applies, over any value its module declared of that
// name; a file, or a resource of no module, carries none.
// name; a container, a file, or a resource of no module, carries none.
split, err := Split("novox", []json.RawMessage{
json.RawMessage(`{"id":"d","type":"process","module":"nats","run":["x"],"env":{"A":"1","MESH_FINGERPRINT":"stale"}}`),
json.RawMessage(`{"id":"c","type":"container","module":"nats","image":"i"}`),
json.RawMessage(`{"id":"c","type":"container","module":"nats","image":"i","env":{"MESH_FINGERPRINT":"stale","B":"2"}}`),
file("conf", "a"),
json.RawMessage(`{"id":"own","type":"process","run":["x"]}`),
}, map[string]string{"nats": fp}, nil, NodeOwn{})
@@ -192,10 +192,10 @@ func TestComparingCompositions(t *testing.T) {
}
_ = json.Unmarshal(raw, &r)
want := fp
if r.ID == "conf" {
if r.ID == "conf" || r.ID == "c" {
want = ""
}
if r.Env[FingerprintVar] != want || (r.ID == "d" && r.Env["A"] != "1") {
if r.Env[FingerprintVar] != want || (r.ID == "d" && r.Env["A"] != "1") || (r.ID == "c" && r.Env["B"] != "2") {
t.Errorf("%s starts with %v, want %s=%q and its own words kept", r.ID, r.Env, FingerprintVar, want)
}
}
@@ -205,6 +205,26 @@ func TestComparingCompositions(t *testing.T) {
}
}
// H-A-710 (1): a daemon whose want names no fingerprint composes none, its declared value taken out and said once per
// module and node-engine process; a container's declared value likewise, and an env left empty goes.
var said []string
wasJournal := journal
t.Cleanup(func() { journal = wasJournal })
journal = func(line string) { said = append(said, line) }
takenOutSaid.Clear()
for range 2 {
for kind, in := range map[string]string{"process": `{"id":"d","type":"process","module":"nats","run":["x"],"env":{"A":"1","MESH_FINGERPRINT":"stale"}}`,
"container": `{"id":"c","type":"container","module":"nats","image":"i","env":{"MESH_FINGERPRINT":"stale"}}`} {
got, err := withFingerprint(json.RawMessage(in), kind, "nats", "")
if err != nil || strings.Contains(string(got), FingerprintVar) || (kind == "container" && strings.Contains(string(got), "env")) {
t.Errorf("a %s with no fingerprint composed %s, %v", kind, got, err)
}
}
}
if len(said) != 1 || !strings.Contains(said[0], "nats") {
t.Errorf("said %q, want one line for the module", said)
}
// §519, §618: the tool runner's process hands each bundle's module its own want's fingerprint in the words of its
// bundles, a module with bundles and no words included, and the runner's own fingerprint reaches no other module's.
fpLamp, fpBare := "src2:"+strings.Repeat("1", 64), "src2:"+strings.Repeat("2", 64)