Although it's normally the state's prerogative to grant or deny immunity to a witness, under the due process clause of the United States Constitution, a trial court has the power to compel the state to grant immunity to a defense witness. "A trial under these circumstances is not fundamentally fair. The district court erred when it denied Straub's request to compel use immunity." United States v. Straub, 538 F3d 1147 (9th Cir. Or. 2008).
"[In] exceptional cases, the fact-finding process may be so distorted through the prosecution's decisions to grant immunity to its own witness while denying immunity to a witness with directly contradictory testimony that the defendant's due process right to a fair trial is violated."
Straub at 1166.
Note that the government had already granted immunity for its own witness, which the Straub opinion implies is a predicate to compelling the government to grant immunity to a defense witness.
One wonders how much this principle of limited reciprocity might apply in other contexts. We have some clue, based on the subsequent treatment of the famous Wardius opinion by the Oregon appellate courts.
In State v. Upton, 339 Or 673, 125 P3d 713 (2005), this court rejected a Wardius-based argument that was similar to the one defendant makes here:
"Wardius, however, does not require that every procedure relating to both a defendant and the state ensure identical rights in order to satisfy due process. Rather, Wardius addressed only a narrow procedural requirement that is not at issue here. In Wardius, the Court held that a statute may not require a defendant - who has no burden of proof at trial - to disclose certain alibi witnesses, when the state had no comparable obligation to disclose its witnesses. The holding in Wardius, however, did not establish a constitutional rule that a defendant and the state must be treated identically in all respects."
Id. at 686-87 (internal citation omitted).
State v. Moore, 349 Ore 371, 390 (2010)
Moore involved the use of 404(4) evidence by the state, which - as written in the statute - is quite one-sided in its application to the defendant.
A defendant who seeks to offer "prior bad acts" evidence against a state's witness is - using Staub as a model - arguably better off in convincing the judge that applying a balancing test of substantial prejudice/probative value to the evidence offered by the defendant is forbidden if the state - in the same trial - is attempting to forbid the use of that same test in evidence it is offering against the defendant. To apply the balance test only against one side could arguably create the same distortion that was prohibited in Staub.
Of course, the nature of criminal law is that the state often has much more 404 evidence at its disposal than the defense has. It may remind you of that quote about majestic laws, the rich, the poor and sleeping under bridges. Still, there are not a few sex or domestic violence cases where the defendant may have a right to offer evidence against the complainant - such as a history of similar accusations - that isn't explicitly permitted in the evidence code.