The controller plans config, templates and moved providers' provisions, hands bus accounts to the vault and judges the new manifest words, on the feature's SDK and node-engine validator (feature 57, config and provisioning).
67 lines
3.1 KiB
Go
67 lines
3.1 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/novox/mesh-controller/internal/broker"
|
|
"github.com/novox/mesh-controller/internal/conditions"
|
|
)
|
|
|
|
// A grant of a restricted stream that composes nothing (novox/hq ADR 0376 §2).
|
|
//
|
|
// A restricted stream is heard only by a module that runs as an account of its own (`runs-as`, ADR 0259): the
|
|
// tool runner's bus account is the one every agent session on its machine reaches the bus as, so the controller
|
|
// composes no consumer, grant or bind word for a module it carries (broker.ComposedHears). Where a grant still
|
|
// names such a module, the module hears nothing it was granted, and that is said — in `doctor` and in the
|
|
// controller's log on every raise and send — naming the module, the stream and the remedy. Never silent.
|
|
|
|
const (
|
|
// probeWithheldID is the self-check's probe of it, and kindGrantComposesNothing the condition it raises.
|
|
probeWithheldID = "D-heard"
|
|
kindGrantComposesNothing = "grant-composes-nothing"
|
|
)
|
|
|
|
// probeWithheldHearing says every granted hearing of a restricted stream composed for nothing.
|
|
func probeWithheldHearing(ctx context.Context, d *doctor) ([]conditions.Observation, error) {
|
|
records, err := d.open.inventory.BusRecords(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return withheldObservations(broker.WithheldOf(records)), nil
|
|
}
|
|
|
|
// withheldObservations is each withheld hearing as a condition of its module on its machine.
|
|
func withheldObservations(withheld []broker.Withheld) []conditions.Observation {
|
|
var out []conditions.Observation
|
|
for _, w := range withheld {
|
|
out = append(out, conditions.Observation{Scope: conditions.ScopeModule,
|
|
ID: w.Module + "." + strings.ToLower(w.Stream) + "." + w.Node,
|
|
Kind: kindGrantComposesNothing, Machine: w.Node, Severity: conditions.Warning,
|
|
Summary: w.Said(), Said: fmt.Sprintf("%s on %s granted %s; composed nothing", w.Module, w.Node, w.Stream)})
|
|
}
|
|
return sortedFound(out)
|
|
}
|
|
|
|
// sayWithheld puts every withheld hearing in the controller's log, once per raise or send that composes it.
|
|
func sayWithheld(records broker.Records, indent string) {
|
|
for _, w := range broker.WithheldOf(records) {
|
|
fmt.Printf("%sA GRANT COMPOSES NOTHING: %s\n", indent, w.Said())
|
|
}
|
|
}
|
|
|
|
// withheldWords are the plain words of a withheld hearing: the module, the machine and what to do.
|
|
func withheldWords(o conditions.Observation) words {
|
|
module, m := "a module", machineOr(o, "a machine")
|
|
if o.Scope == conditions.ScopeModule && idPart(o, 0) != "" {
|
|
module = idPart(o, 0)
|
|
}
|
|
return words{Headline: clip(conditions.Capital(fmt.Sprintf("%s on %s hears nothing it was granted", module, m)), 60),
|
|
Needs: fmt.Sprintf("give %s an account of its own in its manifest; the details say which stream.", module),
|
|
Explanation: fmt.Sprintf("You granted %s part of a stream that only modules running under an account of "+
|
|
"their own may hear. It runs inside the shared tool runner on %s, which every assistant session there "+
|
|
"also uses, so the mesh gives it none of that stream.", module, m),
|
|
Resolved: fmt.Sprintf("%s on %s hears what it was granted, or is no longer granted it", module, m)}
|
|
}
|