package orchestration import ( "crypto/rand" "encoding/hex" "io" "log/slog" "git.yeij.top/AskaEth/Cyrene_v2/internal/logger" ) // sourcedLog returns the base logger tagged with source "orchestration", // replacing a nil logger with a discard one so the scheduler can always log. func sourcedLog(l *slog.Logger) *slog.Logger { if l == nil { l = slog.New(slog.NewTextHandler(io.Discard, nil)) } return logger.WithSource(l, "orchestration") } // prefixBytes is the number of random bytes used to build the sub-agent id // prefix. const prefixBytes = 4 // randPrefix returns a short random prefix for sub-agent ids, falling back to // "sub" if the system entropy source is unavailable. func randPrefix() string { var b [prefixBytes]byte if _, err := rand.Read(b[:]); err != nil { return "sub" } return "sub-" + hex.EncodeToString(b[:]) }