// Package controllerdeps is the catalogue's side of the lease write's manifest test (novox/hq ADR 0571 ยง13, ADR 0582 // clause 2, issue 774): no module of this tree reads, invokes, consumes, waits on or uses the controller beyond what the // named list of mesh-sdk's catalogue.KeepList keeps to the write itself, and the lease key, which names the lease's holder // whoever that is. It decodes every manifest under root/modules and judges them with mesh-sdk's ManifestRefusals, the // judge the grants part's grants_lease_check and the other two repositories' tests run, so the rule is said once. package controllerdeps import ( "fmt" "os" "path/filepath" "sort" "git.novox.be/novox/mesh-sdk/go/catalogue" ) // Refusals is each reason the lease write's check gives over the manifests under root/modules in one phase // (catalogue.PhaseBefore or catalogue.PhaseWrite), none when it passes. A module.json that does not decode is an error: // the manifests check says which, and nothing here is judged on a tree it cannot read. func Refusals(root, phase string) ([]string, error) { files, err := filepath.Glob(filepath.Join(root, "modules", "*", "module.json")) if err != nil { return nil, err } sort.Strings(files) manifests := map[string]catalogue.Manifest{} for _, f := range files { raw, err := os.ReadFile(f) if err != nil { return nil, err } m, err := catalogue.Decode(raw) if err != nil { return nil, fmt.Errorf("%s: %w", f, err) } manifests[m.Module] = m } return catalogue.ManifestRefusals(manifests, phase), nil }