Cal. Penal Code § 999f
(a) Each district attorney’s office establishing a career criminal prosecution unit and receiving state support under this chapter shall adopt and pursue the following policies for career criminal cases:
(d) This section does not prohibit the reduction of the offense charged or dismissal of counts in the interest of justice when a written declaration by the prosecuting attorney stating the specific factual and legal basis for such reduction or dismissal is presented to the court and the court, in writing, acknowledges acceptance of such declaration. A copy of such declaration and acceptance shall be retained in the case file. The only basis upon which charges may be reduced or counts dismissed by the court shall be in cases where the prosecuting attorney decides that there is insufficient evidence to prove the people’s case, the testimony of a material witness cannot be obtained, or a reduction or dismissal would not result in a substantial change in sentence.
In any case in which the court or magistrate grants the prosecuting attorney’s motion for a reduction of charges or dismissal of counts because there would be no substantial change in sentence, the court or magistrate shall require the prosecuting attorney to put on the record in open court the following:
(e) This section does not prohibit a plea agreement when there are codefendants, and the prosecuting attorney determines that the information or testimony of the defendant making the agreement is necessary for the conviction of one or more of the other codefendants. The court shall condition its acceptance of the plea agreement on the defendant giving the information or testimony.
Before the court can accept the plea agreement, the prosecuting attorney shall present a written declaration to the court, specifying the legal and factual reasons for the agreement, and the court shall acknowledge in writing its acceptance of that declaration. A copy of the declaration and acceptance shall be retained in the case file.