Files
mesh-host/internal/link/withheld.go
T
jschoubben 77e6e48ecd AM-H1: the node-engine's composition names the withheld subjects, read through mesh-grants' withheld
The node-engine never reads the grants part's state: it asks the seat's verb
withheld in its own name, and says withheld unknown when nothing answers.

Builds: design 46 7 §6 (the composition reads them through the verb withheld; the node-engine's manifest gains mesh-grants in uses; "withheld unknown: the grants part does not answer"), lead answer A-239

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-12 06:26:10 +01:00

48 lines
1.8 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).
const WithheldUnknown = "withheld unknown: the grants part does not answer"
// 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 or answers what is not its answer, WithheldUnknown as unknown.
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, WithheldUnknown
}
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, WithheldUnknown
}
for _, m := range answer.Modules {
if m.Module == module {
subjects = append(subjects, m.Subjects...)
}
}
return subjects, ""
}