feat(boss): Boss creates nests and assigns registry crows (#43)

This commit is contained in:
Smokey committed 2026-10-28 09:11:57 -06:00
1 parent 3e4b591762
commit dab245cb73
5 files changed
+106 -11

No files matched your search

+17 -4
View File
@@ -44,9 +44,22 @@ func invalid(format string, a ...any) error {
// NestStore holds the nests and saves the ones people create to disk.
type NestStore struct {
path string
mu sync.Mutex
made []Nest // created nests, in creation order; the default nest is not stored
path string
mu sync.Mutex
made []Nest // created nests, in creation order; the default nest is not stored
allowCrow func(name string) bool // extra member names beyond the roster (spun crows)
}
// AllowCrows extends the names that may be nest members beyond the persona
// roster: the server wires it to the spun-crow registry so the Boss can
// staff a nest with registry crows (#43). It is set once at wiring time,
// before anything is served; Create stays the only mutation.
func (s *NestStore) AllowCrows(ok func(name string) bool) { s.allowCrow = ok }
// memberKnown reports whether a name may join a nest: a working persona crow
// (the roster excludes the service roles) or an allowed extra name.
func (s *NestStore) memberKnown(name string) bool {
return slices.Contains(roster, name) || (s.allowCrow != nil && s.allowCrow(name))
}
func LoadNests(path string) (*NestStore, error) {
@@ -104,7 +117,7 @@ func (s *NestStore) Create(name string, crows []string) (Nest, error) {
return Nest{}, invalid("A nest has 1 to %d crows.", len(roster))
}
for i, c := range crows {
if !slices.Contains(roster, c) {
if !s.memberKnown(c) {
return Nest{}, invalid("%q is not in the flock. Choose from %s.", c, strings.Join(roster, ", "))
}
if slices.Contains(crows[:i], c) {