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 }