package web import ( "encoding/json" "net/http" ) // teamProbe answers GET /api/team, the readiness probe Alta reads before // it activates a team Base in Home's directory (oficina/alta // design/team-bundle, spec ยง1.2). Base has no Home roster mode: its owner // is seeded from BASE_OWNER, so it answers in the seeded mode. It names // the Home consumer it was configured as, and whether an owner exists yet. // It carries no address, name or count, and needs no session. // // A Base without Oficina ID has no consumer and is never ready: 404. func (a *app) teamProbe(w http.ResponseWriter, r *http.Request) { if a.cfg.Home == nil || a.cfg.Home.ConsumerID == "" { http.NotFound(w, r) return } var owners int if err := a.db.QueryRowContext(r.Context(), `SELECT count(*) FROM members WHERE role = 'owner'`).Scan(&owners); err != nil { http.Error(w, http.StatusText(http.StatusServiceUnavailable), http.StatusServiceUnavailable) return } roster := "owner-pending" if owners > 0 { roster = "ok" } w.Header().Set("Content-Type", "application/json") w.Header().Set("Cache-Control", "no-store") _ = json.NewEncoder(w).Encode(struct { TeamMode bool `json:"team_mode"` Seeded bool `json:"seeded"` Consumer string `json:"consumer"` Roster string `json:"roster"` }{false, true, a.cfg.Home.ConsumerID, roster}) }