Upon the request of the prosecuting attorney, the magistrate shall require an offer of proof from the defense as to the testimony expected from the witness. The magistrate shall not permit the testimony of any defense witness unless the offer of proof discloses to the satisfaction of the magistrate, in his or her sound discretion, that the testimony of that witness, if believed, would be reasonably likely to establish an affirmative defense, negate an element of a crime charged, or impeach the testimony of a prosecution witness or the statement of a declarant testified to by a prosecution witness.
Ca. Pen. Code § 866