The solution is simple and every Asian country does this. You need to have nationwide testing at key intervals up to three times during your entire schooling. If you fail that you can keep retrying. Gaming it is a very hard because the people grading are thousands of miles away and have no idea who you are besides an ID number. This will also lead to a common curriculum that everyone has to prepare for. The bar for this common curriculum is very high in places like Japan, South Korea, China, and India. Doing this will also almost guarantee that a huge number of black and Latino kids are not gonna pass school. The truth is they’re culturally just not educationally focused at a family level. There might also be a genetic element to this though I’m not sure because kids of African immigrants perform pretty well. This is what all of these curricular dumbing down programs are trying to counteract.
PRC has affirmative action points on gaokao for "underperforming" minorities, well it's been phased out to economically disadvantaged minorities last few years to mitigate privilege stacking. So system not incompatible with affirmative action, but even then tier2 PRC schools the affirmative action floor is still like 95th percentile tier1 closer to 99.9 percentile, i.e. not something that can be gamed like in US by 75th percentile SAT scores, athletics, donors, personality scores, diversity.