
49 Cal.4th 145 (2010)
109 Cal. Rptr. 3d 346
230 P.3d 1132
THE PEOPLE, Plaintiff and Respondent,
v.
JAVIER CASTILLO, Defendant and Appellant.
No. S171163.
Supreme Court of California.
May 24, 2010.
*147 Rudy Kraft, under appointment by the Supreme Court, for Defendant and Appellant.
Michael P. Judge, Public Defender (Los Angeles), Albert J. Menaster and Jack T. Weedin, Deputy Public Defenders, for Public Defender of Los Angeles County as Amicus Curiae on behalf of Defendant and Appellant.
Steve Cooley, District Attorney (Los Angeles), Irene Wakabayashi, Head Deputy District Attorney, and Jennifer C. McDonald, Deputy District Attorney, for District Attorney of Los Angeles County as Amicus Curiae on behalf of Defendant and Appellant.
Edmund G. Brown, Jr., Attorney General, Dane R. Gillette, Chief Assistant Attorney General, Pamela C. Hamanaka, Assistant Attorney General, Lawrence M. Daniels, Susan Sullivan Pithey and Chung L. Mar, Deputy Attorneys General, for Plaintiff and Respondent.

OPINION
GEORGE, C. J.
We granted review to determine whether the Court of Appeal erred by modifying the term of appellant's civil commitment as a sexually violent predator from two yearsthe term agreed to by the Los Angeles County District Attorney, the Los Angeles County Public Defender, and the Presiding Judge of the Los Angeles County Superior Court, pursuant to a signed stipulationto an indeterminate term, as provided by Proposition 83's amendments to Welfare and Institutions Code section 6604. We reverse the judgment rendered by the Court of Appeal, and enforce the stipulation.

I.

A.
In 1985, Javier Castillo was convicted of two counts of committing lewd acts upon a child under the age of 14 years by use of force, violence, or fear *148 (Pen. Code, § 288, subd. (b)), and was sentenced to a six-year term in state prison. In 1992, he was convicted of an additional charge of committing lewd acts upon a child under the age of 14 years (id., subd. (a)), and was sentenced to an eight-year term in prison. Thereafter, in October 1999, Castillo was committed to Coalinga State Hospital as a sexually violent predator (SVP) as defined under the Sexually Violent Predators Act (SVPA) (Welf. & Inst. Code, §§ 6600-6609.3; see generally Hubbart v. Superior Court (1999) 19 Cal.4th 1138, 1143, 1147 [81 Cal.Rptr.2d 492, 969 P.2d 584] [confirming the constitutionality of the SVPA as a civil commitment program]).[1]
In August 2001, the Los Angeles County District Attorney's Office (or District Attorney) filed a petition seeking to extend Castillo's commitment for a two-year period. (Welf. & Inst. Code, former § 6604, added by Stats. 1995, ch. 763, § 3, pp. 5922, 5925-5926 [setting forth a two-year term for extension of commitment].) Apparently, Castillo, through his counsel, stipulated to continuance of trial on the commitment extension, and no such trial was held. Thereafter, in October 2003, the District Attorney filed a second petition to extend Castillo's commitment for another successive two-year period. Again, apparently, trial on the commitment extension was continued, and no trial was held. Eventually, the two cases were consolidated. Subsequently, in September 2005, the District Attorney filed a third petition to extend Castillo's commitment for yet another successive two-year period, to October 5, 2007. In January 2006, the three cases were consolidated for belated trial.

B.
By mid-April 2006, the initiative measure subsequently denominated Proposition 83 (The Sexual Predator Punishment and Control Act: Jessica's Law) had qualified for the November 2006 ballot. That measure proposed to amend the SVPA, and other related statutes, in numerous and wide-ranging ways. (See Voter Information Guide, Gen. Elec. (Nov. 7, 2006) analysis by Legis. Analyst of Prop. 83, pp. 43-44; id., text of Prop. 83, pp. 127-138.) As relevant here, Proposition 83 proposed to adopt the approach followed by all other states with SVP civil commitment laws, by providing that a person found to be an SVP would be involuntarily committed, not for a term of two years, but instead indefinitely. (Voter Information Guide, text of Prop. 83, § 2, subd. (k), p. 127 [describing the indeterminate-term procedures of other states]; id., § 27, at p. 137 [setting forth an indeterminate term, in revised *149 § 6604].) Even before Proposition 83 officially qualified for the ballot, but in light of that impending initiative measure, Senate Bill No. 1128 (2005-2006 Reg. Sess.), the Sex Offender Punishment, Control, and Containment Act of 2006 (Senate Bill No. 1128), was introduced in the Legislature as urgency legislationmeaning that if passed by both houses of the Legislature by a two-thirds vote, it would become effective upon signature of the Governor, prior to the November election. As amended in early March 2006, Senate Bill No. 1128 proposed numerous amendments to various statutes and to the existing SVPA, including the change described immediately above: it proposed to provide that a person found to be an SVP be committed, not for a term of two years, but indefinitely. (Sen. Bill No. 1128, § 63, as amended Mar. 7, 2006, pp. 104-105.)
The Legislature passed Senate Bill No. 1128, and the Governor signed it as urgency legislation, effective September 20, 2006, thereby amending the SVPA in the same manner then proposed by Proposition 83that is, providing for indefinite commitment of a person determined to be an SVP. (Stats. 2006, ch. 337, § 55 [amending § 6604].)[2]
As recently observed in People v. Taylor (2009) 174 Cal.App.4th 920, 933 [94 Cal.Rptr.3d 756] (Taylor), the SVPA, as amended by Senate Bill No. 1128 and subsequently by Proposition 83, "is not a model of legislative drafting." Neither Senate Bill No. 1128, nor Proposition 83, amended section 6601, subdivision (a)(2) of the SVPA. That subdivision, which expressly authorizes the commitment of persons who are "in custody" pursuant to a prison term, a parole revocation term, or a temporary custody "hold" pending further evaluation, specifies who may be committed for treatment by the State Department of Mental Health in a manner that implicitly excludes those *150 persons who currently are committed as SVP's.[3] Moreover, nowhere in the statutes as amended by Senate Bill No. 1128, and subsequently by Proposition 83, is there any mention of recommitment petitionsthat is, proceedings to extend the terms of individuals currently committed as SVP's; both Senate Bill No. 1128 and Proposition 83 were silent concerning the applicability of these measures to petitions pending on the date those changes became effective. Indeed, both Senate Bill No. 1128 and Proposition 83 amended former section 6604 to delete any reference to recommitments or extension of commitments, or related procedures.[4] As a result, after the 2006 amendments enacted by Senate Bill No. 1128 and Proposition 83, the SVPA no longer contains any express statutory provision authorizing recommitment of a person previously committed to the State Department of Mental Health for treatment as an SVP.

C.
On October 11, 2006, the District Attorney, the Los Angeles County Public Defender (or Public Defender), and the Los Angeles County Superior Court entered into a stipulation. It read as follows:
"On September 20, 2006 Senate Bill 1128, urgency legislation, was signed into law by the Governor. Additionally a ballot initiative commonly known as `Jessica's Law' is on the ballot in November of 2006. The legislation and the initiative include language which would lengthen the term of commitment for a SVP from two years to an indeterminate term. Due to uncertainty in the retroactive application of this change, it is the intention of the Los Angeles County District Attorney's Office to apply the current[5] two year commitment period to all currently pending initial commitment petitions, as limited below, for cases in which the trial and commitment occur after the effective date of the legislation or the initiative[,] whichever occurs first, hereafter *151 `effective date.' For all cases in which an initial commitment petition is filed after the effective date of the legislation, the District Attorney's office will seek the indeterminate term.

"24 Month Time Limit
"The District Attorney's Office will apply the two year commitment period to pending initial petitions for 24 months after the effective date. For cases in which the initial order of commitment is issued 24 months or more after the effective date, the District Attorney's Office will seek an indeterminate commitment. The Public Defender's Office does not waive its right to challenge either SB1128 or `Jessica's Law,' assuming that the latter is passed in November 2006.

"Recommitment Petitions
"For SVPs who have been committed and currently have a pending re-commitment petition for an extended commitment, the District Attorney's Office will file additional petitions for extended commitments as they become timely pursuant to Welfare and Institutions Code § 6604.1. The District Attorney's office will use the filing criteria and commitment period in effect at the time of filing the re-commitment petitions. If a pending 2 year recommitment petition filed prior to the effective date of the bill and/or initiative has not been tried prior to the expiration of the two-year commitment period and a new petition is timely filed after the effective date, the District Attorney's Office will pursue an indeterminate term.

"Evaluation Criteria
"Cases which are pending for initial commitment or are evaluated for re-commitment prior to the effective date of the legislation and/or initiative will be evaluated based upon criteria currently present in the SVP statutes. Any initial petition or re-commitment petition filed on or after the effective date of the legislation and/or initiative will be evaluated based upon the language of the legislation or initiative as passed.

"Tolling of Parole
"Provisions of the legislation tolling the period of parole until after the SVP completes the term of commitment or recommitment will be applied to a pending petition immediately following the effective date which might result from the passage of either legislation or the initiative." (Italics added.)
The stipulation concluded: "Because it is impossible to predict all implications of the legislation and initiative, it is not the intent of this agreement to *152 address all potential issues involving changes in the law. [¶] A copy of this agreement is to be filed in every SVP case in which a petition or re-petition is pending prior to the effective date of the legislation and/or initiative." The document was signed by Jane Blissert as "RepresentativeDistrict Attorney," Robert A. Fefferman as "RepresentativePublic Defender," and David Wesley as "Judge of the Superior Court." It was dated October 11, 2006.
The stipulation affected scores of persons who were facing an SVP trial and who were represented by the Public Defender. On October 31, 2006a week prior to the November election, at which the voters would consider whether to enact Proposition 83the parties in this case filed a stipulation identical to the one described immediately above.
At the November 2006 General Election, the voters adopted Proposition 83, which, as stated earlier (and as relevant here), enacted the same changes to sections 6604 and 6604.1 that had been made by Senate Bill No. 1128.[6]

D.
The jury trial to determine whether Castillo continued to qualify as an SVP during the three two-year periods commencing in October 2001 finally began in late July 2007.[7] Because the facts adduced at trial are not relevant to the issues presented on this appeal, we note simply that the evidence recounted Castillo's history of illegal sexual activities involving children, and showed that, throughout his SVP commitment, Castillo essentially refused treatment and remained focused upon creating numerous photographic collages of *153 childrenitems that he hid within the covers of magazines. Two psychologists testified that Castillo suffered from "exclusive" pedophilia, meaning that he did not engage in age-appropriate sexual activity and was sexually attracted to both male and female children, and that he posed a high risk of violently reoffending if released.
On August 10, 2007, the jury returned a verdict sustaining the People's "petition alleging that ... Javier Castillo has a currently diagnosed mental disorder and that this disorder makes him a danger to the health and safety of others in that it is likely that he will engage in sexually violent predatory criminal behavior."
Consistent with the stipulation described above, the trial court immediately ordered Castillo committed to the State Department of Mental Health for three consecutive two-year periodsone for each of the three consolidated matters, running from October 5, 2001, through October 5, 2007. The trial court also immediately arraigned Castillo on a new SVP petition (case No. ZM011971), and found probable cause to proceed (on a new commitment, this one for an indeterminate term) "`based on the trial that was just completed and the evidence that was taken in that trial as well as the documents filed by the [District Attorney] in this petition.'" As observed by the appellate court below, "[t]here is no indication in the record that a new commitment has been imposed in case No. ZM011971."
Castillo filed a timely appeal from the commitment order, raising various evidentiary objections and other claims. The People, represented by the Attorney General, did not appeal from the judgment, but sought to contravene the contentions raised in Castillo's brief. The Attorney General further argued that the court's order, committing Castillo to a series of two-year terms ending October 2007 (consistently with the stipulation signed by the parties and the superior court), was invalid because it was in derogation of the indeterminate commitment term specified by Senate Bill No. 1128 and Proposition 83both of which were enacted (and became effective) prior to Castillo's jury trial and commitment. Los Angeles County Public Defender Michael P. Judge filed an amicus curiae brief in the Court of Appeal, attaching as exhibits copies of two letters, dated June 2, 2008 (by L.A. County Dist. Atty. Steve Cooley), and August 25, 2008 (by Jane Blissert, head deputy dist. atty., sex crimes div., in Cooley's office), each addressed to the Honorable Edmund G. Brown, Jr., Attorney General, State of California. In these letters, the authors made various factual assertions concerning the background of and motivation for the stipulation.
The Court of Appeal rejected Castillo's contentions. The appellate court then addressed the Attorney General's assertion that the trial court's order *154 committing Castillo to a series of two-year terms was invalid in light of the indeterminate commitment period specified by Senate Bill No. 1128 and Proposition 83. The court first observed that, although the most recent of the three two-year terms covered by the trial court's commitment order had expired on October 5, 2007 (within a few weeks of the trial on the consolidated commitment proceedings), the matter was not moot.[8] Thereafter, the Court of Appeal rejected Castillo's argument that the Attorney General was estopped from taking a position contrary to that advanced by the District Attorney in the stipulation below. The Court of Appeal concluded: "[E]stoppel does not apply when enforcement of the stipulation would be contrary to the Legislature's plain directive, would entail a serious risk to public safety, and where the party seeking estoppel did not detrimentally rely on the position advanced by the public entity below." The appellate court also concluded that even when, as here, "the prosecution has broken its promise, specific performance" is neither a favored nor required remedy. The Court of Appeal modified Castillo's commitment order "to reflect the indeterminate term mandated by the SVPA as modified by [Senate Bill No. 1128 and] Proposition 83."
In response to Castillo's petition for review, both the Public Defender and the District Attorney urged us to grant review. After we granted review, both the Public Defender and the District Attorney filed amicus curiae briefs supporting Castillo's position that the stipulation should be enforced, contrary to the position taken by the Attorney General.

II.
Castillo asserts that the Attorney General should be estopped from taking a position contrary to that stipulated to by the District Attorney below. He relies first and primarily upon the doctrine of judicial estoppel.[9]
*155 (1) "`"Judicial estoppel precludes a party from gaining an advantage by taking one position, and then seeking a second advantage by taking an incompatible position. [Citations.] The doctrine's dual goals are to maintain the integrity of the judicial system and to protect parties from opponents' unfair strategies. [Citation.] Application of the doctrine is discretionary."' [Citation.] The doctrine applies when `(1) the same party has taken two positions; (2) the positions were taken in judicial or quasi-judicial administrative proceedings; (3) the party was successful in asserting the first position (i.e., the tribunal adopted the position or accepted it as true); (4) the two positions are totally inconsistent; and (5) the first position was not taken as a result of ignorance, fraud, or mistake.' [Citations.]" (Aguilar v. Lerner (2004) 32 Cal.4th 974, 986-987 [12 Cal.Rptr.3d 287, 88 P.3d 24], italics added (Aguilar); see also MW Erectors, Inc. v. Niederhauser Ornamental & Metal Works Co., Inc. (2005) 36 Cal.4th 412, 422 [30 Cal.Rptr.3d 755, 115 P.3d 41] (MW Erectors).)
Castillo asserts that each of these five elements is met: (1) the People have taken two different positionsthe District Attorney, representing the People at trial, signed the stipulation; the Attorney General, representing the People on appeal, argues that the stipulation is invalid and unenforceable; (2) these positions have been taken in judicial proceedings; (3) the People successfully asserted in the trial court that the stipulation should be enforced; (4) the two positions taken by the People are wholly inconsistent with each other; and finally (5) the People did not agree to the stipulation as a result of ignorance, fraud, or mistake; instead, the decision apparently was an informed and considered one.
The Attorney General does not contest Castillo's assertion that all five elements of the judicial estoppel doctrine are met in this case. Instead, the Attorney General focuses much of his brief upon the proposition that, as held by the Court of Appeal below, Castillo cannot satisfy the "detrimental reliance" requirement for application of equitable estoppel[10] or the "induced action or forbearance" requirement of promissory estoppel.[11] Castillo advances colorable arguments to the contrary. But regardless of whether, on the *156 facts of this case, detrimental reliance or induced forbearance can be established for purposes of equitable estoppel or promissory estoppel, that question simply has no relevance to application of judicial estoppel. The doctrine of judicial estoppel is designed to protect the integrity of the legal system as a whole, and does not require a showing of detrimental reliance by a party. (Aguilar, supra, 32 Cal.4th 974, 986-987; MW Erectors, supra, 36 Cal.4th 412, 422.)

III.
(2) We do not invariably enforce the judicial estoppel doctrine merely because all of its elements are met. "[N]umerous decisions have made clear that judicial estoppel [like the other forms of estoppel] is an equitable doctrine, and its application ... is discretionary. [Citations.]" (MW Erectors, supra, 36 Cal.4th 412, 422.) For example, we held in MW Erectors that judicial estoppel cannot be invoked to contravene the "strong and clear statutory mandate" against collection of compensation for the performance of an act for which a contractor's license was required but not possessed. (Id., at p. 423.)[12]

A.
Before considering whether judicial estoppel should apply in this case, we address initially a procedural matter concerning the record in this appeal. As the Attorney General observes in his answer brief, the two "background information" letters that we noted earlier (from the Dist. Atty. and one of his head deputies, addressed to the Atty. Gen.; see, ante, p. 153), postdate the trial in this case and have not been made part of the record on appeal. *157 Moreover, neither the Court of Appeal below, nor this court, has been asked by Castillo (or either of the two amici curiae who have filed briefs on his behalf in this court) to take judicial notice of those letters. Instead, Castillo and the amici curiae on his behalf simply recite and submit for our consideration various facts asserted in those letters.[13]
(3) Although we could take judicial notice of the existence, content, and authenticity of such letters,[14] doing so would not establish the truth of critical factual matters asserted in those documents. (Mangini v. R. J. Reynolds Tobacco Co. (1994) 7 Cal.4th 1057, 1063 [31 Cal.Rptr.2d 358, 875 P.2d 73].) As we observed in Mangini, although "courts may notice official acts and public records, `we do not take judicial notice of the truth of all matters stated therein.' [Citation.] `[T]he taking of judicial notice of the official acts of a governmental entity does not in and of itself require acceptance of the truth of factual matters which might be deduced therefrom, since in many instances what is being noticed, and thereby established, is no more than the existence of such acts and not, without supporting evidence, what might factually be associated with or flow therefrom.'" (Id., at pp. 1063-1064.)
(4) In essence, by relying in part, in their briefs, upon factual assertions contained in the two letters, defendant and the amici curiae who have filed briefs on his behalf in this court seek to augment the record on appeal "in contravention of the general rule that an appellate court generally is not the forum in which to develop an additional factual record." (People v. Peevy (1998) 17 Cal.4th 1184, 1207 [73 Cal.Rptr.2d 865, 953 P.2d 1212] [rejecting defendant's attempts in the appellate court to present evidence of widespread police misconduct]; see People v. Jones (1997) 15 Cal.4th 119, 171, fn. 17 [61 Cal.Rptr.2d 386, 931 P.2d 960] [record on appeal will not be augmented to add material not a proper part of the record in the trial court]; Doers v. Golden Gate Bridge etc. Dist. (1979) 23 Cal.3d 180, 184, fn. 1 [151 Cal.Rptr. 837, 588 P.2d 1261] ["As a general rule, documents not before the trial court cannot be included as a part of the record on appeal."].)
Castillo asserts in his brief, and emphasized at oral argument, that "when the proceedings that would ultimately become the record on appeal were being conducted, no one had any reason ... to make a clear record" concerning matters such as the background facts that motivated the parties *158 and the superior court to enter into the stipulation. That may be trueand perhaps especially so because a representative of the presiding judge of the superior court was a signatory to the documentbut that circumstance still leaves this court without authority to augment the record on appeal by accepting or assuming the truth of assertions set forth in the letters and briefs but not reflected in the record.[15]
Accordingly, in resolving this appeal, we do not rely uponnor do we accept as truethe background factual assertions contained in the letters and the briefs but not reflected in the record. We instead confine ourselves to the record on appealthat is, the proceedings conducted in this case and the stipulation itself.

B.
(5) Should judicial estoppel apply to enforce the stipulation and bar the imposition of an indeterminate term of civil commitment in place of the two-year term imposed by the trial court? Bearing in mind that the "`"doctrine's dual goals are to maintain the integrity of the judicial system and to protect parties from opponents' unfair strategies"'" (Aguilar, supra, 32 Cal.4th 974, 986), as explained below we conclude that, in light of the uncertain state of the law at the time the stipulation was signed and enforced in the present case and the parties' evident intent, in signing the agreement, to avoid the unwarranted dismissal of long-pending SVP petitions, the stipulation should be enforced under the judicial estoppel doctrine, and that the contrary judgment rendered by the Court of Appeal should be reversed.

1.
We address initially the first of the dual goals of the judicial estoppel doctrineto "`"maintain the integrity of the judicial system."'" (Aguilar, supra, 32 Cal.4th 974, 986.) Achieving this goal appears to require that any stipulation entered into, in apparent good faith, by the legal representatives of both parties as well as the presiding judge of the superior court, shouldif at all possiblebe honored. To do otherwise would risk impairing the integrity of the judicial system.
We proceed to consider, as best we can based upon the limited record before us (see, ante, pt. III.A.), the circumstances confronting the parties at *159 the time the stipulation was negotiated and then eventually signed on October 11, 2006, three weeks after the effective date of Senate Bill No. 1128. As alluded to in the stipulation itself ("[d]ue to uncertainty in the retroactive application of this change ...") and explained, post, in part III.B.1.a., during this periodand, indeed, continuing until at least early 2008there existed substantial legal uncertainty concerning the status of, and procedures to be employed in, proceedings (such as the one here at issue) to extend the commitment of a person already adjudged to be an SVP. Moreover, as explained, post, in part III.B.1.b., in addition to the legal uncertainty created by the 2006 amendments to the SVPA, with regard to Castillo and others who were being represented by the Public Defender and were subject to pending SVP trials, there existed the possibility that the petitions to extend the respective commitments might be dismissedhence releasing these individuals from the strictures of the SVPAbased upon the state's failure to bring the matters to trial in a reasonably timely fashion.

a.
As observed earlier, the SVPA, in section 6601, subdivision (a)(2)which was not altered by the 2006 amendmentsspecifies those persons who are subject to involuntary treatment as an SVP and authorizes their commitment, but that statute does not authorize recommitment of a person previously committed to a term of confinement as an SVP. Indeed, as noted, ante, at pages 149-150, nowhere in the statutory scheme as amended in 2006 is there any mention of or provision for recommitment petitions or proceedings to extend existing commitments. Senate Bill No. 1128 and Proposition 83 each was silent concerning its applicability to petitions that were pending at the time of the effective date of those changes, and each amended former section 6604 to delete any reference to recommitment or extension of existing commitments, or to procedures relating thereto.[16] This statute, as amended in 2006 by Senate Bill No. 1128 (and subsequently by Prop. 83), simply provides in relevant part that a person found to be an SVP "shall be committed for an indeterminate term to the custody of the State Department of Mental Health for appropriate treatment and confinement in a secure facility designated by the Director of Mental Health." Section 6604.1, as amended by Senate Bill No. 1128 and Proposition 83, provides in relevant part that "[t]he indeterminate term of commitment provided for in Section 6604 shall commence on the date upon which the court issues the initial order of commitment pursuant to that section." (§ 6604.1, subd. (a).) Accordingly, after the 2006 amendments, the SVPA contained no express statutory provision authorizing recommitment of a person previously committed to a term of confinement as an SVP.
*160 It therefore is apparent that when the stipulation was negotiatedand even when it was signed on October 11, 2006, after the effective date of Senate Bill No. 1128there existed substantial legal uncertainties concerning the status of, and procedures to be employed in, proceedings to extend the existing commitment of a person adjudged to be an SVP.
Specifically, seen from the perspective of Castillo's position, it was possible courts might conclude that in light of the narrow authorization for commitments set out in section 6601, subdivision (a)(2), and because all references to extension of an existing SVP commitment had been removed from section 6604, the SVPA as amended in 2006 contained no express statutory provision authorizing recommitment of a person previously committed to a term of confinement as an SVPand hence the statutory scheme did not permit recommitment (or extension of commitment) proceedings at all. In other words, it could be argued that, under the statutes as amended, there could be no extension of any existing SVP term, to an indeterminate term or otherwise. Alternatively, from that perspective, it also was possible a court might conclude, by analogy to the decision in Baker v. Superior Court (1984) 35 Cal.3d 663 [200 Cal.Rptr. 293, 677 P.2d 219] (holding that despite the Legislature's repeal of mentally disordered sex offender laws, persons already committed under those provisions were subject to recommitment under the repealed laws), that although the amendments removed references to and procedures for extension of commitment, the deleted two-year extension aspects of the former statute would be revived and remain effective for all persons in Castillo's situationthat is, persons who had been initially committed, and whose recommitment petitions were awaiting trial prior to the effective dates of the amendments.
From the perspective of the District Attorney's position, it was possible courts might conclude that pursuant to amended section 6604.1, every "initial" order of commitment as an SVP for a two-year term, issued prior to the 2006 amendments, would convert retroactively into an order of commitment for an indeterminate term, thereby avoiding the need for any subsequent recommitment trial. Alternatively, from the perspective of the District Attorney, it was possible that the 2006 amendments would be construed as subjecting to an indeterminate term any person whose SVP trial (whether resulting in an initial commitment or a recommitment) occurred after the effective date of the 2006 amendments.
*161 Eventually, of course, appellate decisions, construing over the course of the years the 2006 amendments, have resolved these problems and uncertainties.[17] But at the time the stipulation was negotiated and signed in 2006 (and *162 continuing until at least early 2008see, ante, fn. 17), no one could predict with any degree of certainty how the amendments would be construed as applied to persons in Castillo's circumstances. It was simply uncertain, and unknowable, how courts eventually would resolve these and related questions.[18]
In summary, in the summer of 2006, the following scenarios were possible with respect to Castillo and the scores of persons subject to pending recommitment trials, represented by the Public Defender. Many if not all of these SVP's might have successfully advanced the argument that, in light of section 6601, subdivision (a)(2) and the 2006 amendments, there could be no extension of any currently existing SVP term. Although, in retrospect, it may seem apparent such an argument was unlikely to prevail, there were other options and arguments that posed a greater chance of success for Castillo and those in his position. Some persons might have been accorded prompt trials, and in turn some of them would have received either two-year SVP commitments or indeterminate terms, depending upon when the trial occurred and how the amended statutes would be construed. Alternatively, some of these persons might have been found to no longer qualify as SVP's, and hence would have been released from the strictures of the SVPA. Still others might *163 have had their trials continued yet again, possibly for good cause.[19] In any event, it is apparent that, at the time the stipulation was negotiated and then finally signed on October 11, 2006and until at least early 2008 there existed substantial legal uncertainty concerning how the 2006 amendments would apply to Castillo and to others similarly situated.

b.
In addition to the legal uncertainties created by the 2006 amendments to the SVPA, at the same time there existed a reasonable possibility that Castillo and others who were being represented by the Public Defender, and who were subject to pending SVP trials, might succeed in having their petitions dismissedhence securing release from the strictures of the SVPAbased upon the state's failure to bring cases to trial in a reasonably timely fashion. In this latter respectthe prospect of outright dismissal of long-pending SVP petitionsthe decision in People v. Litmon (2008) 162 Cal.App.4th 383 [76 Cal.Rptr.3d 122] (Litmon) is instructive in assessing the situation faced by the parties and the court at the time the stipulation was negotiated and signed, and hence we describe that case in some detail.
Litmon, the appellant, was found in mid-2000 to qualify as an SVP, and thereafter petitions were filed to extend his commitment for a series of two-year terms. A trial concerning Litmon's first extended two-year term (May 2002 to May 2004) was not held until September 2005, when he belatedly was found to have continued to qualify as an SVP during the May 2002 to May 2004 period. In March 2006, Litmon faced trial on consolidated petitions seeking two-year commitments for the periods from May 2004 to May 2006, and from May 2006 to May 2008. The jury deadlocked, and the court declared a mistrial. In April 2006, the court discussed scheduling a new trial, noting that the prosecutor's trial schedule reflected his unavailability until January 2007, but that counsel for the appellant had announced readiness to proceed "next week," stressing that this was her client's desire. (Litmon, supra, 162 Cal.App.4th 383, 391-392.)[20] The court proceeded to continue the trial until January 2007. (162 Cal.App.4th at p. 392.)
In August 2006, Litmon filed a motion to dismiss, citing, among other cases, Barker v. Wingo (1972) 407 U.S. 514 [33 L.Ed.2d 101, 92 S.Ct. 2182] *164 (Barker) (addressing the 6th Amend. right to a speedy trial), and arguing that postponement of the retrial from Apr. 2006 until Jan. 2007 violated his due process right to a hearing within a "meaningful time." (Litmon, supra, 162 Cal.App.4th 383, 392.) The People urged in opposition that the delay was reasonable and observed that, in any event, the SVPA provided no speedy-trial guarantee. The trial court refused to dismiss the case, stating that (1) there was no right to a speedy trial in SVPA cases, (2) "`the Court does not have the authority to dismiss the case based upon the premise that you put forth in your motion to dismiss,'" and (3) both counsel were engaged in other SVPA trials "`and we can only do so many at a time and therefore [January 2007] is the next available date ....'" (Litmon, supra, 162 Cal.App.4th 383, 393.)
Thereafter, as noted above, in September 2006 the Legislature enacted Senate Bill No. 1128, and in November 2006 the voters enacted Proposition 83both of which amended section 6604 to provide for an indeterminate commitment rather than a two-year commitment.
In early January 2007, the People again moved to continue Litmon's rescheduled SVP trial, on the ground that their expert witnesses would not be available as originally planned. (Litmon, supra, 162 Cal.App.4th 383, 393.) Litmon opposed the continuance and again moved to dismiss, advancing in essence the same arguments he had made in his earlier motion. The trial court again found good cause to continue the proceedings, denied the renewed motion to dismiss, and set trial for mid-March 2007.
In early March 2007, the People moved to impose retroactively an indeterminate term under the amended provisions of the SVPA. In other words, they sought to convert Litmon's initial order of commitmentfrom mid-2000, for a two-year terminto a new indeterminate term of commitment. The trial court granted the motion, ordering that Litmon's "`term of commitment is indeterminate retroactive to his initial order of commitment'" in mid-2000. (Litmon, supra, 162 Cal.App.4th 383, 394.)[21]
On appeal, the court in Litmon held the trial court had erred in (1) failing to grant Litmon's January 2007 motion to dismiss the consolidated petitions (Litmon, supra, 162 Cal.App.4th at pp. 394-406) and (2) retroactively converting Litmon's term of commitment into an indeterminate term (id., at pp. 407-412). We focus here on the first of these holdings.
*165 The appellate court in Litmon first reviewed long-established procedural due process decisions of the United States Supreme Court. Those cases explain that substantive rights relating to "life, liberty, and property ... cannot be deprived except pursuant to constitutionally adequate procedures" (Cleveland Board of Education v. Loudermill (1985) 470 U.S. 532, 541 [84 L.Ed.2d 494, 105 S.Ct. 1487])and they enforce, in various settings, the fundamental due process right to be heard "`at a meaningful time and in a meaningful manner.'" (Mathews v. Eldridge (1976) 424 U.S. 319, 333 [47 L.Ed.2d 18, 96 S.Ct. 893] (Mathews) [process required prior to termination of disability benefits]); see also Barker, supra, 407 U.S. 514.) As observed in Fuentes v. Shevin (1972) 407 U.S. 67, 81 [32 L.Ed.2d 556, 92 S.Ct. 1983], regarding the process required concerning prejudgment replevin statutes: "If the right to notice and a hearing is to serve its full purpose, ... it must be granted at a time when the deprivation can still be prevented." The high court has explained: "We tolerate some exceptions to the general rule requiring predeprivation notice and hearing, but only in `"extraordinary situations where some valid governmental interest is at stake that justifies postponing the hearing until after the event."'" (United States v. James Daniel Good Real Property (1993) 510 U.S. 43, 53 [126 L.Ed.2d 490, 114 S.Ct. 492].) Indeed, even when a postdeprivation hearing is justified, "[a]t some point, a delay in the ... hearing would become a constitutional violation." (Loudermill, supra, 470 U.S. 532, 547.)
Based upon this authority, and other high court cases applying these principles in the context of involuntary civil commitment and treatment (see Heller v. Doe (1993) 509 U.S. 312 [125 L.Ed.2d 257, 113 S.Ct. 2637] [concerning procedures relating to involuntary commitment of mentally retarded persons]; Washington v. Harper (1990) 494 U.S. 210 [108 L.Ed.2d 178, 110 S.Ct. 1028] [state prison inmate has no right to a judicial hearing prior to being forcibly medicated with antipsychotic drugs]; Addington v. Texas (1979) 441 U.S. 418 [60 L.Ed.2d 323, 99 S.Ct. 1804] [concerning standard of proof in an involuntary civil commitment proceeding]), the appellate court in Litmon concluded that although a person alleged by petition to be an SVP has no statutory "speedy trial" right, such a person nevertheless has a federal due process right "to be heard at a `meaningful time.'" (Litmon, supra, 162 Cal.App.4th 383, 399; see also People v. Otto (2001) 26 Cal.4th 200, 209 [109 Cal.Rptr.2d 327, 26 P.3d 1061] ["Because civil commitment involves a significant deprivation of liberty, a defendant in an SVP proceeding is entitled to due process protections."].) Applying the three-part balancing test set out in Mathews, supra, 424 U.S. 319, the court in Litmon determined that (1) forced civil confinement for mental health treatment constitutes "`"a massive curtailment of liberty,"'" requiring due process protection (Litmon, supra, 162 Cal.App.4th at p. 400); (2) "`the risk of an erroneous deprivation of such interest through the procedures used' [citation], *166 is considerable'" (ibid.);[22] and (3) although the state's interest in confinement and treatment of SVP's is very substantial, the state also has an interest in avoiding the unjustified commitment of persons who do not qualify as SVP's (Litmon, at p. 401). The court concluded that "[g]iven these competing factors"and because "under California law, the individual alleged to be an SVP is confined pending final determination of an SVP petition"it follows that the "norm to comport with the demands of procedural due process in the context of involuntary SVP commitments must be a trial in advance of the potential commitment term." (Ibid., italics added.) The court added: "A predeprivation trial is certainly feasible since persons potentially subject to commitment as an SVP are identified while incarcerated in prison or confined under a prior SVP commitment." (Id., at p. 402.)
The court in Litmon recognized that the appellant in that case did not claim "that he was constitutionally entitled to a trial prior to expiration of his last ordered term of commitment on May 2, 2004, and he is not complaining about the delay prior to the trial-setting hearing in April 2006. While we focus on the months of delay following that hearing, it is significant that at the time of that hearing appellant's last order of recommitment had expired almost two years earlier and the first of the two recommitment terms at issue was about to expire on May 2, 2006. Further, the March 2006 mistrial as the result of a hung jury emphasized the possibility that appellant might not be determined to be an SVP at trial. In considering the constitutionality of the challenged delay, the fact [that] appellant continued in confinement pending trial under the consolidated second and third petitions is highly relevant and necessarily informs our due process analysis." (Litmon, supra, 162 Cal.App.4th 383, 402-403, italics added.) The appellate court next considered the People's argument that the delay of 11 months was not undue, "`[g]iven the need for updated evaluations to ascertain appellant's current mental condition, the complexity involved in incorporating past testimony into legal strategy and the time it takes to ensure the presence for trial of both state evaluators[23] and defense experts at trial ....'" (Id., at p. 403.) The *167 appellate court responded brusquely to this argument: "This proffered justification reflects a `business as usual' approach to trial scheduling despite the ongoing deprivation of personal liberty that was occurring." (Ibid.)
The court in Litmon observed: "[C]hronic, systematic postdeprivation delays in SVP cases that only the government can rectify must be factored against the People. While delays based upon the uncontrollable unavailability of a critical witness may be justifiable [citation], postdeprivation delays due to the unwillingness or inability of the government to dedicate the resources necessary to ensure a prompt SVPA trial may be unjustifiable. Just as `unreasonable delay in run-of-the-mill criminal cases cannot be justified by simply asserting that the public resources provided by the State's criminal-justice system are limited and that that each case must await its turn' [citation], postdeprivation pretrial delays in SVPA proceedings cannot be routinely excused by systemic problems, such as understaffed public prosecutor or public defender offices facing heavy caseloads, underdeveloped expert witness pools, or insufficient judges or facilities to handle overcrowded trial dockets." (Litmon, supra, 162 Cal.App.4th 383, 403, italics added, quoting Barker, supra, 407 U.S. 514, 538 (conc. opn. of White, J.); cf. People v. Sutton (2010) 48 Cal.4th 533 [227 P.3d 437] [concluding similarly with regard to a determination of good cause under Pen. Code, § 1382 for continuing a criminal trial].)
The appellate court in Litmon concluded that "[e]ven if the initial delay in setting trial for January 2007 comported with principles of procedural due process, the postponement of the trial until mid-March 2007 cannot be reconciled with those principles given appellant's complete loss of liberty *168 awaiting trial. By January 2007, appellant had already been confined throughout the entire first `potential' two-year term and well into the second `potential' two-year term sought by the consolidated recommitment petitions.... [T]he People knew the difficulties of scheduling the state's experts at least since the April 2006 trial-setting hearing and had had nine months to secure their attendance. Putting off trial for another two months would mean a continued loss of liberty without any determination that appellant was in fact an SVP. Consequently, the proffered justification is inadequate to excuse a further delay of retrial given the magnitude of the liberty interest at stake, the serious harm to this interest already occasioned by the protracted delay, and the possibility that interim decisions (the probable cause hearings on the second and third recommitment petitions) may have been mistaken." (Litmon, supra, 162 Cal.App.4th 383, 404-405.)[24]
The court in Litmon, observing that "`"oppressive pretrial incarceration"'" is one of the facets of "fundamental unfairness that procedural due process is aimed at preventing," concluded: "In our view, lengthy postdeprivation pretrial delay in an SVP proceeding is oppressive. In this case, we cannot turn a blind eye to the years of pretrial confinement that have elapsed following expiration of the last ordered term of commitment." (Litmon, supra, 162 Cal.App.4th 383, 405-406, italics added.)
In closing, the court in Litmon stressed again that "[t]he ultimate responsibility for bringing a person to trial on an SVP petition at a `meaningful time' rests with the government. Appellant's fundamental liberty interest outweighed the state's countervailing interests in postponement of the trial set for January 2007. The approximate two-month delay of retrial until March 2007, although only incremental, meant the cumulative loss of a whole year in custody after mistrial.... If the constitutional right to procedural due process is not to be an empty concept in the context of involuntary SVP proceedings, it cannot be dispensed with so easily. The court should have granted appellant's January 2007 motion to dismiss the consolidated petitions." (Litmon, supra, 162 Cal.App.4th 383, 406, italics added.)[25]


*169 c.
Although Litmon, supra, 162 Cal.App.4th 383, was decided after the stipulation at issue was negotiated and signed, the principles articulated in that opinion were derived from long-established precedent rendered by the United States Supreme Court. Accordingly, it was reasonably clear that, at the time the stipulation in the present case was negotiated and signed, there existed a possibility of eventual dismissal based upon the state's failure to allocate sufficient resources to provide a timely trialperhaps with respect to Castillo's case, or with respect to some of the scores of other pending SVP petitions covered by the stipulation. At the same time, moreover, as observed, ante, part III.B.1.a., substantial legal uncertainties, not resolved until at least early 2008, existed with respect to application of the 2006 amendments to petitions that were pending prior to the effective dates of the amendments. Furthermore, unlike the more typical cases involving stipulations, in this case the trial court did not merely accept and enforce a stipulation agreed to by the parties; the court actually signed the stipulation as a participant in the agreementand in doing so, conveyed its support and endorsement concerning the legal propriety of the agreement. In this setting, in which it is apparent that the stipulation was entered into in good faith by the District Attorney, the Public Defender, and the Presiding Judge of the Los Angeles County Superior Court, we conclude that enforcement of the stipulation indeed would promote the first goal of the judicial estoppel doctrine, that of maintaining the integrity of the judicial system.

2.
We also conclude that enforcement of the stipulation would promote the second of the dual goals of the judicial estoppel doctrineprotection of parties such as Castillo, and others similarly situated, from "`"opponents' unfair strategies."'" (Aguilar, supra, 32 Cal.4th at p. 986.) In this respect, even though detrimental reliance need not be shown in order to establish judicial estoppel, it is clear there was general reliance of this sort in the present case on the part of Castillo and others. Castillo, whose three prior SVP recommitment petitions had, by mid-2006, been pending trial for nearly six years, might have demanded trial or dismissal and thereafter pressed a potentially meritorious due process claim if not afforded a trial within a meaningful time. (See Litmon, supra, 162 Cal.App.4th 383, 394-406.) Moreover, even if, on the facts of his case, Castillo could not assert a successful due process challenge, it is quite possible that one or more of the scores of others similarly situated might eventually have been able to do so.
*170 The Attorney General observes that the record fails to demonstrate that Castillo, personally or through his counsel, demanded trial during the spring or summer of 2006. Castillo, in turn, asserts that he had no incentive or reason to press such a demand, in light of the impending stipulation. As summarized by Castillo in his brief, he "had every right to insist upon a prompt and immediate trial. He chose not to do so because he was promised by his attorney, the trial court, and the district attorney, that he would not suffer any adverse consequences" from further delay even when the law changed to provide for an indeterminate commitment. The People, at the same time, received the benefit that they apparently sought in the stipulationneither Castillo's case, nor apparently any other, was dismissed for delay in conducting an SVP trial.[26]
It is immaterial whether the Attorney General's subsequent decision on appeal not to honor the stipulation and to argue against it, after having received the benefit of it, properly might be denominated a "strategy" or something else, for the result is the same: under the circumstances, that course of action, considered from the standpoint of its impact on Castillo and those similarly situated, simply is "unfair." As amicus curiae Los Angeles County District Attorney observes, "Castillo should not be penalized because he trusted the legal analysis of the District Attorney, Public Defender and Superior Court of Los Angeles County." We conclude that enforcement of the stipulation would promote the second goal of the judicial estoppel doctrine, that of protecting parties such as Castillo and others similarly situated from "opponents' unfair strategies."

3.
The Court of Appeal below observed that estoppel does not apply when enforcement of that doctrine "would entail a serious risk to public safety." On the facts of this case, however, it seems doubtful that any substantial risk to public safety would be posed by enforcement of the stipulation under the judicial estoppel doctrine. As noted above, it appears that all parties, including the court, entered into the stipulation in order to preserve, and not to endanger, public safety. As amicus curiae Los Angeles County Public Defender observes, "[p]ursuant to the terms of the Stipulation, no individual who was pending trial was subject to release during the pendency of commitment proceedings. Nor does the fact that said individual is subject to *171 recommitment proceedings in two years endanger public safety because as long as the individual has a mental disorder that makes it likely he or she will engage in sexually violent criminal behavior, said individual will be subject to recommitment for an indefinite term."

4.
Finally, as the Court of Appeal observed, "estoppel does not apply when enforcement of the stipulation would be contrary to the Legislature's plain directive." Similarly, the Attorney General stresses that a stipulation is unenforceable if it is based upon an erroneous rule of law. In support, the Attorney General relies upon cases such as San Francisco Lumber Co. v. Bibb (1903) 139 Cal. 325 [73 P. 864], in which this court declined to give effect to a stipulation, entered into by litigating parties, agreeing in essence to limit the legal issues that could be considered by the court. (Id., at p. 326.) We stated broadly that "[c]ounsel ... may agree as to the facts, but they cannot control this court by stipulation as to the sole, or any, question of law to be determined under them. [¶] When a particular legal conclusion follows from a given state of facts, no stipulation of counsel can prevent the court from so declaring it." (Ibid.; see also, e.g., California State Auto. Assn. Inter-Ins. Bureau v. Superior Court (1990) 50 Cal.3d 658, 664 [268 Cal.Rptr. 284, 788 P.2d 1156] [a court may reject a stipulation that "incorporates an erroneous rule of law"]; Garabedian v. Los Angeles Cellular Telephone Co. (2004) 118 Cal.App.4th 123, 128 [12 Cal.Rptr.3d 737] ["An agreement of the parties does not bind the court if it is contrary to law or public policy."]; Western Pioneer Ins. Co. v. Estate of Taira (1982) 136 Cal.App.3d 174, 182 [185 Cal.Rptr. 887] ["interpretation of statutes or law is normally not a proper subject for stipulation of the parties, but is a matter for the courts"]; In re Marriage of Fithian (1977) 74 Cal.App.3d 397, 403 [141 Cal.Rptr. 506] ["A stipulation is not binding if, as a matter of law, it is clearly erroneous."]; Oakland Raiders v. City of Berkeley (1976) 65 Cal.App.3d 623, 629 [137 Cal.Rptr. 648] [stipulation that a city tax ordinance constituted a "regulatory measure" was ineffective, because the "interpretation of the Constitution, statutes, and ordinances is a subject within the authority of the courts, not the parties.... The matters normally subject to stipulation relate to pleadings, issues, evidence, liability, procedure, and damages, but not to interpretation of the law." (citation omitted)].)
The Attorney General concludes that in the present circumstances, "the amended version of section 6604 applied to [Castillo's] case because his trial and [re]commitment as an SVP occurred in August 2007, ... more than nine *172 months after the effective date of Proposition 83. Section 6604 therefore required the trial court to commit [Castillo] `for an indeterminate term,' and the court's imposition of a two-year term was an unauthorized act in excess of its jurisdiction." (Italics added.) The Attorney General concludes: "As the Court of Appeal correctly explained, `In light of the jury's verdict, an indeterminate term was the sole remedy available, and the legislative scheme authorizing commitment afforded the court no discretion in formulating alternative commitment terms or to delay the effective date of the modifications effected by Proposition 83.' [Citation.] Accordingly, in light of the plain terms of section 6604, the Court of Appeal properly increased the term of commitment from the unauthorized two-year term to the correct indeterminate term." (Italics added.)
Unlike the stipulations involved in decisions upon which the Attorney General relies, the stipulation here at issue was entered into not by the parties acting alone, but by the parties and the court. More significantly, unlike the decisions upon which the Attorney General relies, as explained, ante (pt. III.B.1.a.), the stipulation reflected the substantial legal uncertainties that existed at the time it was negotiated and signed. The stipulation expressly referred to the "uncertainty" concerning application of the 2006 amendments to the SVPA, and provided that despite those uncertaintiesincluding whether recommitments even were permissible under the amended statutory schemeeach potential SVP being represented by the Public Defender who faced a pending trial would indeed be subject to recommitment for a two-year term. Furthermore, the stipulation clarified that after any such two-year recommitment, the person would be subject to subsequent recommitment for an indeterminate term. Accordinglyand in light of the circumstance that the 2006 amendments to section 6604 made no provision concerning recommitments (and, indeed, deleted language authorizing recommitments)we reject the Attorney General's premise that the stipulation at issue was "clearly erroneous as a matter of law," and "unenforceable," at the time it was signed and at the time it was enforced in this case.
Nor do we agree with the Attorney General's related premise that an indeterminate term was "the only legally authorized term" in the present case. For this proposition the Attorney General relies upon the appellate courts' subsequent clarifying holdings concerning the 2006 amendments (see, ante, fn. 17), but we do not view those decisions, in what would amount to reaching well beyond the facts presented in those matters, as establishing a broad rule that would preclude the enforceability in the present case of a *173 stipulation dissimilar to anything considered in any of those prior decisions. None of the cases cited by the Attorney General (Shields, supra, 155 Cal.App.4th 559, Carroll, supra, 158 Cal.App.4th 503, Bourquez, supra, 156 Cal.App.4th 1275, and Whaley, supra, 160 Cal.App.4th 779) concerned a stipulation comparable to the one at issue in this case, and none held broadly that indefinite commitments are mandatory in all situations.[27]
Moreover, as explained, ante (pt. III.B.1.b.), it is apparent from the Litmon decision and the principles derived from United States Supreme Court cases cited by Litmon that, at the time the stipulation was negotiated and signed, a realistic possibility existed that due process principles would require the dismissal of Castillo's case, or of at least some of the scores of other pending SVP petitions covered by the stipulation. Apparently, the stipulation was designed in part to avoid this highly undesirable prospectit ensured that each potential SVP being represented by the Public Defender would not demand an immediate trial, a development that in turn successfully foreclosed the possibility of dismissal of those cases based upon a violation of due process, as occurred in Litmon, supra, 162 Cal.App.4th 383.
The circumstance that subsequent appellate decisions have clarified the law and removed many of the uncertainties that existed until at least early 2008and the additional circumstance that we know today, with the benefit of such subsequent clarification, that a stipulation similar to the one we consider in the present case now could not properly be negotiated, entered into, and enforceddoes not diminish the reality that such uncertainties did indeed exist at the time the stipulation at issue was implemented upon the conclusion of Castillo's trial in mid-August 2007. For these reasons it would be inappropriate for us, with the benefit of hindsight, to condemn the stipulation as having been unauthorized or unenforceable at the time of Castillo's trial. The highly distinctive circumstances of the present case militate in favor of enforcing the stipulation now, in the cases of Castillo and others similarly situated, as urged by amici curiae Los Angeles County District Attorney and Los Angeles County Public Defender.


*174 IV.
We reverse the judgment rendered by the Court of Appeal, with directions to reinstate the judgment of the trial court committing Castillo to a two-year term. In any future SVP proceeding, Castillopursuant to the stipulation, and under section 6604, as amended by Senate Bill No. 1128 and Proposition 83will be subject to commitment for an indeterminate term.
Kennard, J., Baxter, J., Werdegar, J., Chin, J., Moreno, J., and Corrigan, J., concurred.
NOTES
[1]  All further statutory references are to the Welfare and Institutions Code, unless otherwise noted. Section 6600, subdivision (a)(1), provides: "`Sexually violent predator' means a person who has been convicted of a sexually violent offense against one or more victims and who has a diagnosed mental disorder that makes the person a danger to the health and safety of others in that it is likely that he or she will engage in sexually violent criminal behavior."
[2]  Section 6604, as amended by Senate Bill No. 1128 (and subsequently by Prop. 83), provides in relevant part: "If the court or jury determines that the person is a sexually violent predator, the person shall be committed for an indeterminate term to the custody of the State Department of Mental Health for appropriate treatment and confinement in a secure facility designated by the Director of Mental Health." Section 6604.1, as amended by Senate Bill No. 1128 (and subsequently by Prop. 83), states, in subdivision (a): "The indeterminate term of commitment provided for in Section 6604 shall commence on the date upon which the court issues the initial order of commitment pursuant to that section."

In People v. McKee (2010) 47 Cal.4th 1172 [104 Cal.Rptr.3d 427, 223 P.3d 566], we considered due process, ex post facto, and equal protection challenges to these amendments. We rejected the defendant's due process and ex post facto challenges. Concerning the equal protection challenge, we concluded that "the state has not yet carried its burden of demonstrating why SVP's, but not any other ex-felons subject to civil commitment, such as mentally disordered offenders, are subject to indefinite commitment." (Id., at p. 1184.) Accordingly, we remanded "to the trial court to permit the People the opportunity to justify the differential treatment in accord with established equal protection principles." (Ibid.)
[3]  Section 6601, subdivision (a)(2), provides that a petition to commit a person as an SVP may be filed "if the individual was in custody pursuant to his or her determinate prison term, parole revocation term, or a hold placed pursuant to Section 6601.3, at the time the petition is filed."
[4]  Former section 6604 provided, in relevant part, that a person found to be an SVP, and committed for treatment for two years in the custody of the State Department of Mental Health, "shall not be kept in actual custody longer than two years unless a subsequent extended commitment is obtained from the court incident to the filing of a petition for extended commitment under this article ...." (As amended by Stats. 2000, ch. 420, § 3.) This language was deleted by the 2006 amendments made to section 6604.
[5]  Although the stipulation characterized a two-year commitment term as the "current" law, in fact the current law as of October 11, 2006, was reflected in Senate Bill No. 1128, which had removed the two-year commitment term and replaced it with an indeterminate term. The characterization in the stipulation apparently reflects the circumstance that the document was substantially negotiated and drafted prior to September 20, 2006, the effective date of Senate Bill No. 1128 (Stats. 2006, ch. 337, § 55).
[6]  We observe that, as amended by Proposition 83, section 6604.1, subdivision (b)which addresses evaluations by mental health experts designated by the State Department of Mental Healthrefers to "evaluations performed for purposes of extended commitments." (Italics added.) This same language had been in the subdivision prior to the amendment made by Senate Bill No. 1128, but was eliminated by that bill's amendment to the statute, and hence was not operative at the time the stipulation at issue in this case was signed. Moreover, and most significantly, as observed, ante, at pages 149-150, both 2006 amendments deleted former language providing expressly for extension of commitments; accordingly, after the 2006 amendments, there existed no statutory provision expressly authorizing recommitment of a person previously committed to the State Department of Mental Health for treatment as an SVP.
[7]  In a memorandum captioned "Advisory to all California District Attorneys," dated September 26, 2006, the Attorney General of California explained that "[i]n our opinion, the indeterminate term language applies to any jury verdict or court finding rendered after September 20, 2006," and counseled all district attorneys as follows: "For all cases pending trial, amend the petition to indicate that the term will be for an indeterminate term. This measure will help us fend off arguments claiming lack of notice/unfair surprise." Despite this advice, but consistent with the stipulation, immediately prior to trial, on July 30, 2007, the parties refiled the stipulation originally filed on October 31, 2006, calling for a two-year commitment for any person covered by the stipulation.
[8]  The Court of Appeal explained: "The underlying order involved three consolidated petitions seeking separate two-year recommitmentscase Nos. ZM004837, ZM006562, and ZM009280. The commitment order was issued on August 10, 2007, with the third two-year commitment period running from October 5, 2005, to October 5, 2007. That period expired prior to the filing of the opening brief in this appeal. However, on the date of his recommitment on the consolidated petitions, Castillo was arraigned on a new SVP petition, case No. ZM011971. He denied the new allegations, but the trial court found probable cause to proceed `based on the trial that was just completed and the evidence that was taken in that trial as well as the documents filed by the [district attorney] in this petition.' There is no indication in the record that a new commitment has been imposed in case No. ZM011971 which might render this appeal moot. To the contrary, this record establishes only that Castillo's current commitment is a function of the underlying [multiple two-year] commitment order, and the issue of that order's validity is [therefore] not moot."
[9]  Castillo also relies upon the doctrines of equitable estoppel (see, post, fn. 10) and promissory estoppel (see, post, fn. 11).
[10]  "`The doctrine of equitable estoppel is founded on concepts of equity and fair dealing. It provides that a person may not deny the existence of a state of facts if he intentionally led another to believe a particular circumstance to be true and to rely upon such belief to his detriment. The elements of the doctrine are that (1) the party to be estopped must be apprised of the facts; (2) he must intend that his conduct shall be acted upon, or must so act that the party asserting the estoppel has a right to believe it was so intended; (3) the other party must be ignorant of the true state of facts; and (4) he must rely upon the conduct to his injury.'" (City of Goleta v. Superior Court (2006) 40 Cal.4th 270, 279 [52 Cal.Rptr.3d 114, 147 P.3d 1037] (Goleta), quoting City of Long Beach v. Mansell (1970) 3 Cal.3d 462, 488 [91 Cal.Rptr. 23, 476 P.2d 423] (Mansell).)
[11]  Under the doctrine of promissory estoppel, "`[a] promise which the promisor should reasonably expect to induce action or forbearance on the part of the promisee ... and which does induce such action or forbearance is binding if injustice can be avoided only by enforcement of the promise. The remedy granted for breach may be limited as justice requires.' [Citations.] Promissory estoppel is `a doctrine which employs equitable principles to satisfy the requirement that consideration must be given in exchange for the promise sought to be enforced.'" (Kajima/Ray Wilson v. Los Angeles County Metropolitan Transportation Authority (2000) 23 Cal.4th 305, 310 [96 Cal.Rptr.2d 747, 1 P.3d 63].)
[12]  As the Attorney General observes, in the related context of equitable estoppel, we have held that such an estoppel may apply against a governmental body (see Mansell, supra, 3 Cal.3d 462, 488), but only "`in unusual instances when necessary to avoid grave injustice and when the result will not defeat a strong public policy.'" (Goleta, supra, 40 Cal.4th 270, 279; accord, Mansell, supra, 3 Cal.3d at p. 493 [it is "well-established ... that an estoppel will not be applied against the government if to do so would effectively nullify `a strong rule of policy, adopted for the benefit of the public'"].) Likewise, we similarly have held that promissory estoppel will not be applied against the government if doing so would effectively nullify a strong rule of public policy, adopted for the benefit of the public. (San Marcos Water Dist. v. San Marcos Unified School Dist. (1986) 42 Cal.3d 154, 167-168 [228 Cal.Rptr. 47, 720 P.2d 935].) Related cautions apply with respect to application of judicial estoppel, even if all elements of that doctrine are met. (See MW Erectors, supra, 36 Cal.4th 412, 422-423.)
[13]  The brief filed by amicus curiae District Attorney does not cite to or quote from the letters. It instead simply reasserts (without citation to the record) various facts initially asserted in those letters.
[14]  We properly may take notice of official letters sent by a county entity to a state constitutional officer. (See Cruz v. County of Los Angeles (1985) 173 Cal.App.3d 1131, 1134 [219 Cal.Rptr. 661] [action taken pursuant to a customary practice of county agency constitutes an "official act" of which judicial notice may be taken under Evid. Code, § 452, subd. (c)].)
[15]  Nor can we accept the suggestion of amicus curiae in this court, the Public Defender, that merely because the two letters were appended to the brief it filed in the Court of Appeal below, and the Attorney General failed to object to those exhibits, these documents have become part of the record on appeal and thus this court may accept as true the factual assertions set out in the letters.
[16]  As observed, ante, footnote 4, former section 6604 provided for extension of commitments, but that language was deleted by the 2006 amendments to that statute.
[17]  On September 21, 2007, the Court of Appeal, Fourth District, decided People v. Shields (2007) 155 Cal.App.4th 559 [65 Cal.Rptr.3d 922] (Shields). The appellate court noted in its decision that prior to trial, which was held after the enactment of Senate Bill No. 1128 but before the effective date of Proposition 83, the People amended the petition, so as to seek an indeterminate term instead of a two-year term. (155 Cal.App.4th at p. 562.) The appellate court rejected an argument that the literal language of the 2006 amendments left courts without authority to order the recommitment of a person who already was committed as an SVP at the time of the amendment (id., at pp. 563-564), and concluded that enforcing the plain language of the statutes would, in this instance, "`"result in [an] absurd consequence[] which the Legislature did not intend."'" (id., at p. 564). Finally, the appellate court summarily determined that "the indeterminate term provisions of section 6604 apply" to persons who are recommitted as SVP's. (Id., at p. 564.)

On November 14, 2007, the Court of Appeal, Third District, decided Bourquez v. Superior Court (2007) 156 Cal.App.4th 1275 [68 Cal.Rptr.3d 142] (Bourquez). Prior to trial, the People had notified the SVP's of the People's intent to apply Proposition 83 (and the new indeterminate term provision) to the pending petitions at issue. (156 Cal.App.4th at p. 1282.) The appellate court agreed with the jurisdictional conclusion reached in Shields, albeit based upon a more probing analysis (Bourquez, at pp. 1283-1288), and further concurred that in trials conducted after the effective dates of the 2006 amendments, the new indeterminate term of commitment should be imposed. (Id., at pp. 1288-1289.) The court rejected a claim that doing so would constitute a retroactive application of the law: "Because a proceeding to extend commitment under the SVPA focuses on the person's current mental state, applying the indeterminate term of commitment of Proposition 83 does not attach new legal consequences to conduct that was completed before the effective date of the law." (Id., at p. 1289.)
On December 27, 2007, the Court of Appeal, Fifth District, decided People v. Carroll (2007) 158 Cal.App.4th 503 [69 Cal.Rptr.3d 816] (Carroll). The court noted that immediately prior to trial, the prosecutor, with apparent acquiescence by the defendant, struck the petition's language seeking a two-year term, and substituted language seeking an indeterminate term. (Id., at pp. 507-508.) Thereafter the appellate court rejected an argument that "the law in effect at the time the petition was filed should control, ... so the trial court was authorized to recommit [the defendant] only for a two-year, not an indeterminate, term." (Id., at pp. 508-509.) The court further agreed with the conclusion reached in Shields, supra, 155 Cal.App.4th 559, and Bourquez, supra, 156 Cal.App.4th 1275, that despite the 2006 amendments' removal of express authority for recommitments, courts nevertheless retained authority to order the recommitment of a person who was then currently already committed as an SVP (Carroll, at pp. 508-510), and it agreed with the conclusion in Bourquez that in a trial held after the effective dates of the 2006 amendments, imposition of the new indeterminate term does not constitute a retroactive application of the statute (Carroll, at pp. 512-515).
On March 3, 2008, the Court of Appeal, Sixth District, decided People v. Whaley (2008) 160 Cal.App.4th 779 [73 Cal.Rptr.3d 133] (Whaley). The court reversed a trial court's order that retroactively converted a two-year SVP commitment, rendered prior to the effective dates of the 2006 amendments, into an indeterminate term of commitment. The appellate court explained that such retroactive application of the amendments was not intended by the voters. (Whaley, at pp. 794-804.) In reaching that conclusion, the court rejected the People's argument that the language of section 6604.1, subdivision (a) ("[t]he indeterminate term of commitment provided for in Section 6604 shall commence on the date upon which the court issues the initial order of commitment pursuant to that section" (italics added)) indicated intent to reach back and retroactively convert into indeterminate commitments the terms of those persons who already had been committed under the SVPA. (160 Cal.App.4th at p. 798.) Instead, the court held, "we construe the reference to an `initial' order in section 6604.1, subdivision (a), as reflecting when the commitment term begins for a person first committed to an indeterminate term, rather than demonstrating intent by the voters to retroactively apply an indeterminate term to those already committed." (Ibid.) The court concluded: "[T]he provisions of amended sections 6604 and 6604.1 may be applied prospectively to all pending and future commitment proceedings." (Id., at p. 799, original italics.)
Most recently, in June 2009, the Court of Appeal, Fourth District, decided Taylor, supra, 174 Cal.App.4th 920. Consistently with Whaley, supra, 160 Cal.App.4th 779, the appellate court reversed trial court orders that retroactively had converted two-year SVP commitments, rendered prior to the effective dates of the 2006 amendments, into indeterminate terms of commitment, and the court remanded the case for new trials at which, consistent with Shields, supra, 155 Cal.App.4th 559, and Bourquez, supra, 156 Cal.App.4th 1275, the defendants would be subject to indeterminate terms of commitment. (Taylor, at pp. 932-934.) The court also rejected due process, equal protection, and ex post facto challenges to the imposition of indeterminate terms, while at the same time noting that such issues were pending before ussee People v. McKee, supra, 47 Cal.4th 1172, briefly discussed, ante, footnote 2. (Taylor, supra, 174 Cal.App.4th at pp. 928-931, 934-937.)
[18]  Castillo urges that Shields, supra, 155 Cal.App.4th 559, Carroll, supra, 158 Cal.App.4th 503, Bourquez, supra, 156 Cal.App.4th 1275, and Whaley, supra, 160 Cal.App.4th 779 (see, ante, fn. 17), all were wrongly decided insofar as they hold that (1) trial courts retained jurisdiction over petitions seeking to recommit persons as SVP's after the 2006 amendments, and (2) the litigants in those cases whose petitions were pending prior to the 2006 amendments were subject to the indeterminate term authorized by the 2006 amendments. We perceive no basis for questioning these legal conclusions reached in those cases, or for questioning the propriety of recommitment proceedings instituted after the amendments took effect.
[19]  Yet others might have had their trials continued without good cause, as discussed in part III.B.1.b., post, triggering the possibility of meritorious due process claims.
[20]  As explained in Litmon, supra, 162 Cal.App.4th 383, 392, counsel also brought to the trial court's attention language in a prior case involving her client, Litmon v. Superior Court (2004) 123 Cal.App.4th 1156 [21 Cal.Rptr.3d 21], in which the appellate court had suggested that Code of Civil Procedure section 36, subdivision (e), might support the expeditious scheduling of SVP trials "well before the expiration of the ... two-year commitment period at issue in the trial." (Litmon v. Superior Court, supra, 123 Cal.App.4th 1156, 1172.)
[21]  As observed, ante, footnote 17, until this aspect of the 2006 amendments eventually was clarified in early March 2008 (in Whaley, supra, 160 Cal.App.4th 779), other trial courts erroneously had entered similar orders, retroactively converting initial two-year commitment terms into indeterminate terms.
[22]  In this regard, the court observed: "Appellant has already experienced an extended confinement without any determination that he was an SVP under the second and third recommitment petitions. The loss of liberty following May 2, 2004, the date his last order of commitment expired, is irretrievable regardless of the outcome of trial. The risk of error is highlighted here by the mistrial declared more than two years ago, in March 2006, after jurors could not reach a decision." (Litmon, supra, 162 Cal.App.4th at p. 400.)
[23]  With regard to the state's problem of obtaining mental-health expert evaluations in SVP casesa concern that has been exacerbated by the expanded pool of inmates subject to such evaluations under the 2006 amendments to the SVPAsee Statutes 2008, chapter 601, section 1, which sets forth the following legislative declaration: "(a) There is within the State Department of Mental Health the Sex Offender Commitment Program (SOCP). The SOCP exists to implement the provisions of the sexually violent predator civil commitment program (Article 4 (commencing with Section 6600) of Part 2 of Division 6 of the Welfare and Institutions Code). [¶] (b) The sexually violent predator civil commitment program requires clinical evaluations of potential sexually violent predators for possible commitment in order to provide treatment, as well as to protect California's citizens from possible victimization by sexually violent predators. [¶] (c) Persons referred to the SOCP by the Department of Corrections and Rehabilitation as possible sexually violent predators and who meet the preliminary screening criteria must undergo precommitment evaluations by at least two professionals who meet the requirements specified in Section 6601 of the Welfare and Institutions Code. [¶] (d) It is difficult for the state to recruit and retain individuals with the required expertise within the civil service. [¶] (e) Evaluations must be conducted in a timely manner to avoid the release into society of possible sexually violent predators. [¶] (f) It is the intent of the Legislature to ensure the protection of California's residents by providing the State Department of Mental Health with the necessary flexibility in obtaining experienced professionals, both within the civil service and through contracts, so that sexually violent predator evaluations can occur within the statutory timeframe." (Italics added; see also Stats. 2008, ch. 601, § 2 [amending § 6601 and adding subd. (m), requiring a report concerning the state's efforts to hire qualified state employees to conduct the evaluations required by the SVPA]; Piller & Romney, Jessica's Law Pays Dividend for Some, L.A. Times (Aug. 10, 2008) [describing fees paid to private-contractor mental-health experts in order to evaluate the expanded pool of inmates under Prop. 83].)
[24]  The court added: "We arrive at the same due process conclusion under a Barker-type analysis. The extensive pretrial delay following the filing of the petitions certainly creates a presumption of prejudice that triggers a Barker type of balancing test. (See Doggett v. United States [(1992)] 505 U.S. [647,] 652, fn. 1 [120 L.Ed.2d 520, 112 S.Ct. 2686] [`lower courts have generally found postaccusation delay "presumptively prejudicial" at least as it approaches one year'].) The second recommitment petition was filed February 23, 2004, and the third recommitment petition was filed September 29, 2005. For all the reasons stated above, the government's proffered justification for continuance of the January trial date must be weighed against it." (Litmon, supra, 162 Cal.App.4th 383, 405.)
[25]  The court was careful to specify that its conclusion that the trial court should have dismissed the consolidated SVP petitions "of course ... does not preclude other civil commitment proceedings against appellant if appropriate. Appellant might still be involuntarily committed and treated under the [Lanterman-Petris-Short] Act. (§ 5000 et seq.)" (Litmon, supra, 162 Cal.App.4th at p. 406; cf. People v. Allen (2007) 42 Cal.4th 91, 105-108 [64 Cal.Rptr.3d 124, 164 P.3d 557] [although commitment as a mentally disordered offender was precluded, the defendant might be committed under the Lanterman-Petris-Short Act].)
[26]  Moreover, the People avoided the protracted litigation that would have been triggered by demands for prompt trials, including proceedings contesting the propriety of the continuances and the effect of the 2006 amendments.
[27]  We also observe that, in contrast to the present case, in all of the cited cases in which an indeterminate term was imposed upon a person whose trial was pending prior to the 2006 amendments, the petition had been amended to seek an indeterminate term. (See, ante, fn. 17.)
