Files
mesh-sdk/go/catalogue/keyed.go
T
jschoubben 1c7356c247
mesh/delivery-group group feat/sdk1 rejected: composed together: the checker's verdict at the members' heads (428d048dd50a): unit: git.novox.be/novox/mesh-sdk/…
mesh/delivery closed: a newer head of the same pull request
mesh/check failed: unit: git.novox.be/novox/mesh-sdk/go/process.TestStatePutWritesAKeyWhole: a Put through a short blackout: 0, mesh-mail's state send…
catalogue: the composition's rules and refusals leave for the node-engine, so mesh-sdk renders no declaration and refuses no composition (ADR 0593 §7)
Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
2026-11-02 19:19:25 +01:00

49 lines
1.7 KiB
Go

package catalogue
import "slices"
// HandedByManifest is whether a module is handed to the provisioner as far as its manifest says (Rendering.Handing
// without the machine's own words, and begin's): marked moved, not a held module's stub, with a template its build
// kept or an item.
func (m Manifest) HandedByManifest() bool {
return m.Moved && m.Handed != nil && !m.Stubbed && (len(m.Handed.Templates) > 0 || len(m.Items) > 0)
}
// Awaited is, of what consumer requires (not optionally), each provision Keyed answers yes for, judged from manifests
// alone, as the assigner reads them: providers answers the modules providing a provision. A provision is a need when a
// provider offers it to the mesh, or one on the consumer's machine serves facts about it (Resolve: one answered on the
// machine with nothing served binds nothing). It is keyed when the consumer is handed, or every provider's offer is
// answered by the helper: where the providers disagree, which one answers is the composition's, and nothing is waited
// for that might never be keyed. Sorted, each once.
func Awaited(consumer Manifest, providers func(provision string) []Manifest) []string {
var out []string
for _, r := range consumer.Requires {
if consumer.OptionalRequires[r] || slices.Contains(out, r) {
continue
}
by := providers(r)
if len(by) == 0 {
continue
}
need, helper := false, true
for _, p := range by {
for _, o := range p.Provides {
if o.Name != r {
continue
}
if o.At() == ScopeMesh || len(p.Serves[r]) > 0 {
need = true
}
}
if !p.AnsweredByHelperFor(r) {
helper = false
}
}
if need && (consumer.HandedByManifest() || helper) {
out = append(out, r)
}
}
slices.Sort(out)
return out
}