What about continuing to rely on private contractors, but with a mandate to open-source everything they develop with public funds? Perhaps that would address the issues you describe?
This does not solve the issues because it often already works that way today. All of the code I've ever written under GPL was as a private contractor to the government.
The code I wrote is not supported by anyone and reflects the interests of those who paid for it. All of the most advanced systems work, even if not classified, is not open source and often not in literature and this is a condition of accessing that technology at all.
For the US Federal government, they are often dysfunctional when it comes to sustainable open source. And when it comes to the more interesting computer science tech, they have no leverage to make it open source nor any real interest TBH.