In short, your whole thought is based on the assumption that North Korean wanted China's protection agasint US aggression, but China refused, so NK developed nukes, then China complies to US sanction on NK to stop the nukes.
That is totally opposite to the truth. Do you know that Kim il song purged his colleagues who had deep histories with both Soviet Union and China in the early time of NK? Is that the fault of China and USSR/Russia of not providing protection? Being a Chinese vessel state for over a thousand years made Kim extremely sensitive not to make NK once again a vessel state, either Soviet or China. If NK really wanted China's protection like you assumed, why didn't Kim ask PVA to stay and pay for it like SK did to US? According to you, it was China's fault that NK asked China to leave and facing the US and SK alone?
You also assume that China's joining sanction is only to please the US. On the contrary, from China's perspective, so long as SK and Japan not having nukes, NK should not have either, this isn't related with Sino-US relationship. China is not going to go as far as unilaterally sanction NK for building nukes (China never did such things), but China is not going to stop US to do the dirty job.
You seem to have the mind that anything anti-US is automatically good for China, it isn't. China's agenda is to be the number one, many of that agenda is at odd with US, but far from all. Many regional powers' anti-US agenda isn't pro-China either, they are for themselvs which is not necessrarily in line with China.
Allow me to be a troll for a moment.
From China's point of view, allowing NK to have nuclear weapons is the cheapest way to maintain balance at this stage of expenditure, though not necessarily the most correct one. As we enter the 21st century, the imbalance in military, and indeed national, power between North and South is significant, and the South has more money, so they have an unparalleled advantage in conventional weapons. A simple example is that the North is still using improved T62s, while the South has tanks based on M1A2 technology; the North's best aircraft are MiG-29s, while the South has F-35s. The Russian-Ukrainian war has proven that the lack of air power is fatal for ground troops (KA-52's slaughter of armored formations), so I don't think I need to elaborate on how big the North's military disadvantage is.
So, in this case, is there a weapon that can be used with little investment and quick results? The answer is
nuclear weapons, and the accompanying nuclear carriers, i.e., missiles. Nuclear missiles require only research on rockets and nuclear warheads than conventional weapons construction. Drawings of nuclear bombs, especially atomic bombs, are not believed to be difficult to find. As for the ability to combine warheads and missiles can be blurred, the key is to have a nuclear warhead is a deterrent. This is much less politically and economically costly than sending troops directly to North Korea, or handing over weapons directly, or hoarding troops in the northeast, and ensures China's strategic ambiguity on North Korea. At the same time, the development of rocket technology feeds into North Korea's rocket artillery and space exploration capabilities, and space rockets in particular will boost morale.
As for why China sanctioned North Korea at that time, there is a complex reason. On the one hand supporting UN sanctions, at least at the time, would project the image of China as a responsible great power. And the deeper reason is that the former Kim was unwilling to listen to China for a long time, feeling that the US was the key to solving the current situation in North Korea and that everything would be fine once the US lifted sanctions. China could not accept North Korea's defection to the US in any way, so it joined the "international community" that imposed sanctions on North Korea. Reality forced the former Kim to rethink and, of course, to thank the Americans for forcing North Korea back into the arms of China. Since then, China-North Korea trains have not been interrupted except during the epidemic. This would also explain why the current Kim needs to see Xi before meeting with Trump.
In my opinion, China's biggest mistake with respect to North Korea was made by Mao Zedong. Mao was an idealist at the time and believed that all ethnic groups would live together equally under communism, but unfortunately reality proved him wrong. So at that time there would be what I would call a very bloody drama, which was to reduce or even forbid the contact between the volunteer troops and the North Korean people because of the protest from the North Korean side. The reason was that at that time there was little difference in language and writing between the two sides, and the volunteers kept the tradition in China of reaching out to the grassroots to help the people, which would shake the foundations of the Korean Workers' Party.
Concluding words. "琉台不守,三韩为墟". Historically, the loss of Taiwan will be linked to the situation on the Korean Peninsula, and holding the Korean Peninsula is China's invisible red line. China will have to acquiesce to North Korea's possession of nuclear weapons to maintain the balance at a time of military imbalance between the North and South.