The Mexican-American War of 1846-48 was a surprisingly one-sided affair; despite near-numerical parity and fighting occurring on mostly friendly terrain Mexico lost decisively to the USA, losing all its territory north of the Rio Grande. What does it take to change this outcome? Can it be done if Santa Anna is willing to allow his generals more operational independence, or does it take a much deeper Mexico-Wank (or US-Nerf?)? Would it be possible for a major slave uprising to begin during the war, leading to major US efforts being diverted away from Mexico? Could Britain provide military advisors, particularly if the Oregon Crisis is never resolved, negating the US' technological advantages?
What are the consequences of a Mexican victory? I would imagine that Mexico would force the US to accept Texas as part of Mexico, but would the Mexicans do any more than this? Possibly carving a Native state out of the Great Plains to act as a buffer?
Whatever the treaty, Mexico will have both great opportunities and great problems. The California Gold Rush and later Colorado Gold Rush will benefit Mexico rather than the USA, and between gold and Mexico being a Catholic nation it doesn't seem impossible that the Irish head en masse to Mexico rather than the USA. On the flip side, Mexico will still have to deal with Anglos in Texas and Alta California. Will they ever be able to reconcile the American migrants or will there be long-term civil unrest in Texas and California?