code: func Milo(c context.Context, cfg *pb.Project) error {
  	// Sort consoles by ID.
  	sort.Slice(cfg.Consoles, func(i, j int) bool {
  		return cfg.Consoles[i].Id < cfg.Consoles[j].Id
  	})
  
  	// Inline headers.
  	headers := make(map[string]*pb.Header)
  	for _, h := range cfg.Headers {
  		headers[h.Id] = h
  		h.Id = ""
  	}
  	for _, c := range cfg.Consoles {
  		switch {
  		case c.HeaderId == "":
  			continue
  		case c.Header != nil:
  			return fmt.Errorf("bad console %q - has both 'header' and 'header_id' fields", c.Id)
  		default:
  			c.Header = headers[c.HeaderId]
  			c.HeaderId = ""
  		}
  	}
  	cfg.Headers = nil
  
  	// Normalize and sort refs.
  	for _, c := range cfg.Consoles {
  		for i, r := range c.Refs {
  			if !strings.HasPrefix(r, "regexp:") {
  				c.Refs[i] = "regexp:" + regexp.QuoteMeta(r)
  			}
  		}
  		sort.Strings(c.Refs)
  	}
  
  	// Sort alternative builder names, but not builders themselves! Their order is
  	// significant for Milo UI.
  	for _, c := range cfg.Consoles {
  		for _, b := range c.Builders {
  			sort.Strings(b.Name)
  		}
  	}
  
  	return nil
  }
docs: // Milo normalizes luci-milo.cfg config.