Anything created by the federal government is public domain by law. However, not all federal agencies make their code public. Some, understandably. Others, our of budget constraints or ignorance. In theory, you could file a FOIA request to get the code, assuming it's not classified.
Other levels of government can be problematic. In part, because cities and towns can copyright things they create, while the federal government cannot.
For example, the City of Chicago and some other cities have data portals open to the public. Their utility varies.
Smaller cities, however, are less likely to understand the important or value of making data public.
Back when governments started switching to data processing a lot, I belonged to an organization called Investigative Reporters and Editors. It had lots of guides for extracting data from local governments. I remember lots of newspapers rushing out to buy computers are nine-track tape readers so they could sort through the information.
Code directly written be the Government must be public domain. I'm not sure this is a step in the right direction, or a step backwards as it just pushes more software engineering to consultants.
(I've at least seen DARPA-funded work become open source. That's a good step.)
The big gotcha with that is that most government projects have collaborators in academia, NGOs, and/or industry. To a big extent, the public domain mandate doesn't apply if workers outside of the government contribute. Thus manuscripts or code often aren't public domain.
edit: Also publishers constantly "accidentally" claim copyright on public domain works (I'm looking at you, Elsevier). They never accidentally make something open-access.
People are downvoting without explaining, so I'll take a shot.
First, yes, we calculate our own income tax, but the IRS also calculates it separately, and if the two disagree, they selectively decide whether to come knocking. (For example, they once tried to bill me $300,000 for a tax year when my net income was just over $100,000, because of multiple clerical errors -- we had sold a house, and they had both erroneously tried to apply capital gains tax where it didn't apply at all, and tried to tax us for the full sale price of the house as though we had bought it for $0 and flipped it. It took months of back and forth to fix the issue, despite everything having been clearly documented.)
Second, calculating tax liability is just the first step. Actually submitting tax returns electronically required a third party for a long time, and I believe it still does for all but the most straightforward returns. There's absolutely no reason for that to be the case, other than the outsize influence of lobbying money.
That's without getting into all the loopholes, dodges, and hand-waving that make it possible for someone like Trump to avoid paying taxes entirely most years, while those of us who they know can't afford to lawyer up are the ones they try to collect from.
If the two disagree in a calculation matter, the calculations spelled out in the tax form should be upheld as the gold standard as to which side made the calculation error.
> they had both erroneously tried to apply capital gains tax where it didn't apply at all
Was this issue due to paper tax forms doing a calculation one way, but the IRS's implementation doing it another way?
Most recently, I screwed up by claiming a credit that was not allowed. However, the conditions for it are documented; I was wrong. This is where code could help, in order to clarify obtuse language in the requirements. Obviously, the government runs code which checks the conditions that determine whether a nonzero amount can be claimed in some field, so it's just another calculation. Still, it would be better for that to be crystal clear pseudo-code and not the fragment of some actual implementation.
> the tax form should be upheld as the gold standard
Should, yeah.
> Was this issue due to paper tax forms doing a calculation one way, but the IRS's implementation doing it another way?
No, it was straight up wrong, and could only have been human error. As far as I can make out, their calculation only made sense if you took the full printed tax return and lost the back half of it. (And also ignored the part of the law that says capital gains tax doesn’t apply if you lived in a home more than two years before selling).