Diagrammatic expansion for positive density-response spectra: Application to the electron gas