// Package planhands refuses a module's line that takes a plan existing for its module handed to the provisioner (issue // 774). Whether a plan hands its module is mesh-sdk's one rule, catalogue.Plan.Hands: since the seat mesh-provisioner keys a // provision its provider's helper answers for a module not handed, a plan naming provisions alone exists for modules // whose files and own secrets stay their node's (on 2026-10-30 the vault read every such plan as handed and answered // twenty modules' own secrets to nobody, and the provisioner client refused each as a plan it could not act on). A line // that tests whether a plan exists either asks Hands on the same line, or says "not handing": it reads only who binds // whom, or that there is no plan at all. package planhands import ( "fmt" "io/fs" "os" "path/filepath" "regexp" "sort" "strings" ) // existence is a test of whether an assignment's or a plan's `provisioning` is there: nil, or an empty raw value. var existence = regexp.MustCompile(`Provisioning\s*[!=]=\s*nil|len\([^)]*Provisioning\)\s*[!=]=\s*0`) // Problems is each such line under root's modules/ that neither asks Hands nor says "not handing", as // `path:line: text`, sorted. Test files are left out: a test may build a plan by hand. func Problems(root string) ([]string, error) { var out []string err := filepath.WalkDir(filepath.Join(root, "modules"), func(p string, d fs.DirEntry, err error) error { if err != nil { return err } if d.IsDir() || !strings.HasSuffix(p, ".go") || strings.HasSuffix(p, "_test.go") { return nil } raw, err := os.ReadFile(p) if err != nil { return err } rel, _ := filepath.Rel(root, p) for i, line := range strings.Split(string(raw), "\n") { if existence.MatchString(line) && !strings.Contains(line, ".Hands()") && !strings.Contains(line, "not handing") { out = append(out, fmt.Sprintf("%s:%d: %s", rel, i+1, strings.TrimSpace(line))) } } return nil }) sort.Strings(out) return out, err }