A general setting for halo theory