luggage: two years ago - in SFO (international) - coming (on UA) from MEX and going (on UA) to Calgary I didn't have to get my luggage through costums but was, after picking the luggage up in the area before costums clearing, I was able to recheck-it (after I inquired with UA staff, that solution was nowhere published/announced - but it worked). I did label the luggage in MEX through to Calgary.
StarAlliance agreement: ANA signed already in late 1999 (and UA is a founding member).
Upgrades: probably not possible (if not for operational reasons = overbooking of the lower class).
Risks of missing the connecting flights: If the incoming flight is (very) late, than you have a problem. But UA flights leaving in MEX in the early morning were (my experience is limited to about 6 flights MEX-SFO in the last three years) always on time.