Files
mesh-host/internal/link/withheld.go
T
jschoubben cd7acb52d1 H-A-303: a pass that holds a module for a part withheld composes the tool runner as it runs
The node-engine restarted the tool runner at every self-compose on three machines:
a module held for a part that did not answer (the catalog half's entry, the
registry seats' versions) had its slice of the runtime process rebuilt from what
runs, with its fingerprint set to its want's and its files words dropped, so
MESH_TOOL_MODULES and MESH_TOOL_ENV differed pass by pass. A held module's
entries and words are now copied verbatim from the running process, after the
fingerprints are laid, so a holding pass digests as what runs and writes no new
revision; a module whose parts answered and changed is still composed from its
build. The composition read's grants ask names the holder it asked and why, and
says it once in the journal until the grants part answers again.

Builds: design 47 H H-A-303 (1)-(3), H-A-306 (1)-(3); H-A-296
2026-11-21 20:39:06 +01:00

70 lines
2.9 KiB
Go

package link
import (
"context"
"encoding/json"
)
// **The composition names the withheld subjects** (design 46 approval mark §6, lead answer A-239): the node-engine reads them
// through the seat mesh-grants' verb withheld, never from the grants part's state; when the verb does not answer, it says so.
// GrantsSeat is the seat of the grants part, whose verb withheld names the marked subjects withheld from a node's runtime.
const GrantsSeat = "mesh-grants"
// WithheldUnknown is what a composition says when the grants part does not answer withheld (design 46 approval mark §6),
// followed by the holder it asked and why (design 47 H, H-A-303 (3), H-A-306).
const WithheldUnknown = "withheld unknown: the grants part does not answer"
// withheldAsked names the holder the composition read asks what is withheld: the seat and its verb.
const withheldAsked = "the seat " + GrantsSeat + "'s verb withheld"
// WithheldSubject is one marked subject withheld from this node's runtime, and why.
type WithheldSubject struct {
Subject string `json:"subject"`
Why string `json:"why"`
}
// WithheldOf is what the grants part withholds of module on this node, asked through its verb withheld: the subjects, or,
// when the verb does not answer (not answered, cut by its bound, no responders) or answers what is not its answer,
// WithheldUnknown as unknown, naming the holder asked and why. That the part is withheld is said once in the journal
// (Say), until it answers again (design 47 H, H-A-303 (3), H-A-306).
func (q *Session) WithheldOf(ctx context.Context, module string) (subjects []WithheldSubject, unknown string) {
raw, err := q.askCalled(ctx, GrantsSeat, "withheld", map[string]string{"node": q.Membership.Node}, VaultWithin,
"the grants part's withheld")
if err != nil {
return nil, q.withheldUnknown("asked of " + withheldAsked + ", which did not answer: " + err.Error())
}
var answer struct {
Node string `json:"node"`
Modules []struct {
Module string `json:"module"`
Subjects []WithheldSubject `json:"subjects"`
} `json:"modules"`
}
if json.Unmarshal(raw, &answer) != nil || answer.Node != q.Membership.Node {
return nil, q.withheldUnknown("asked of " + withheldAsked + ", which answered what is not its answer for " + q.Membership.Node)
}
q.withheldMu.Lock()
q.withheldSaid = false
q.withheldMu.Unlock()
for _, m := range answer.Modules {
if m.Module == module {
subjects = append(subjects, m.Subjects...)
}
}
return subjects, ""
}
// withheldUnknown is WithheldUnknown with why, said once in the journal until the grants part answers again.
func (q *Session) withheldUnknown(why string) string {
unknown := WithheldUnknown + " (" + why + ")"
q.withheldMu.Lock()
said := q.withheldSaid
q.withheldSaid = true
q.withheldMu.Unlock()
if !said && q.Say != nil {
q.Say("the grants part is withheld from this node's composition read, which says " + unknown + " until it answers")
}
return unknown
}