While it would be unconstitutional in the United States, keep in mind that in certain countries "ex post facto" making certain tax avoidance schemes retroactively unlawful is not unheard of, e.g. BN66 in the UK: https://en.wikipedia.org/wiki/BN66
I'm thinking of cases like tax credits for R&D, where a company claims the lab janitors salary because the lab isn't going to clean itself, but the IRS decides that salary doesn't count as a research cost. The law from congress doesn't usually spell such things out. Or it says "necessary personnel" but is a janitor necessary or not?