We develop the foundations of a general framework for producing optimal upper and lower bounds on the sum ∑pap over primes p, where (an)x/2<n≤x is an arbitrary non-negative sequence satisfying Type I and Type II estimates. Our lower bounds on ∑pap depend on a new sieve method, which is non-iterative and uses all of the Type I and Type II information at once. We also give a complementary general procedure for constructing sequences (an) satisfying the Type I and Type II estimates, which in many cases proves that our lower bounds on ∑pap are best possible. A key role in both the sieve method and the construction method is played by the geometry of special subsets of Rk. This allows us to determine precisely the ranges of Type I and Type II estimates for which an asymptotic for ∑pap is guaranteed, that a substantial Type II range is always necessary to guarantee a non-trivial lower bound for ∑pap, and to determine the optimal bounds in some naturally occurring families of parameters from the literature. We also demonstrate that the optimal upper and lower bounds for ∑pap exhibit many discontinuities with respect to the Type I and Type II ranges, ruling out the possibility of a particularly simple characterization.