
    Brian A. BUCKLEY, Petitioner-Appellee, v. C.A. TERHUNE, Director of the California Department of Corrections, Respondent-Appellant.
    No. 03-55045.
    United States Court of Appeals, Ninth Circuit.
    Argued and Submitted Sept. 27, 2005.
    Filed March 17, 2006.
    
      Allen Bloom, San Diego, CA, for the petitioner-appellee.
    Bill Lockyer, Attorney General; Robert R. Anderson, Chief Assistant Attorney General; Pamela C. Hamanaka, Senior Assistant Attorney General; Kenneth C. Byrne, Supervising Deputy Attorney General; Noah P. Hill, Deputy Attorney General; Los Angeles, CA, for the respondent-appellant.
    Before: MARY M. SCHROEDER, Chief Judge, STEPHEN REINHARDT, ALEX KOZINSKI, M. MARGARET McKEOWN, KIM McLANE WARDLAW, RAYMOND C. FISHER, RICHARD A. PAEZ, MARSHA S. BERZON, RICHARD C. TALLMAN, JAY S. BYBEE, and CONSUELO M. CALLAHAN, Circuit Judges.
   REINHARDT, Circuit Judge.

The law regarding plea agreements entered into in state court is well-established. They must be construed in accordance with state law. In California, plea agreements are construed in the same manner as all other contracts. In this case, however, the California courts failed to do so and, as a result, Brian Buckley might have remained in prison for life instead of for the fifteen years for which he bargained. We are required to ensure that his constitutional rights are not so violated, and that the bargain he entered into with the state is honored.

The state appeals the district court’s order granting Buckley’s petition for a writ of habeas corpus and directing that he be released from prison because he had already served the full fifteen years. The district court ruled that the state court’s finding that Buckley “well knew” that his sentence for second degree murder was fifteen years to life was both contrary to clearly established federal law in violation of 28 U.S.C. § 2254(d)(1) and an unreasonable determination of the facts in violation of § 2254(d)(2). In accordance with the district court’s order, Buckley has now been released. We affirm the judgment of the district court because, under § 2254(d)(1), the state court’s failure to interpret Buckley’s plea agreement according to California contract law resulted in a decision that was contrary to clearly established Supreme Court law as set forth in Santobello v. New York, 404 U.S. 257, 92 S.Ct. 495, 30 L.Ed.2d 427 (1971), and Ricketts v. Adamson, 483 U.S. 1, 107 S.Ct. 2680, 97 L.Ed.2d 1 (1987).

FACTUAL AND PROCEDURAL BACKGROUND

On November 12, 1987, Buckley was charged with burglary, robbery and first degree murder in Ventura County Superi- or Court. The charges arose from allegations that Buckley and two others, Curtis Fauber and Christopher Caldwell, robbed and killed Thomas Urell in his home in July 1986.

On December 15, 1987, Donald Glynn, the deputy district attorney assigned to Buckley’s case, sent Buckley’s attorney a letter offering a plea bargain. The letter stated that, in exchange for Buckley’s sworn testimony describing Fauber and Caldwell’s participation in the Urell murder and in two additional unrelated murders, Glynn would dismiss the robbery and burglary charges against Buckley and move the court to declare the murder charge against him to be murder in the second degree. The letter was silent as to the sentence Buckley would receive. Glynn attached to the letter a typewritten felony disposition statement. That document contained the following relevant language:

CONSEQUENCES OF PLEA (Defendant to initial)
My attorney has explained to me the direct and indirect consequences of this plea including the maximum possible sentence. I understand that the following consequences could result from my plea:
I could be sentenced to the state prison for a maximum possible term of 15 year(s).
After I have served my prison term, I may be subject to a maximum parole period of LIFE {In re Carabes, 144 Cal. App.3d 927,193 Cal.Rptr. 65).

(Emphasis added). On December 17, 1987, Buckley initialed the paragraphs describing his agreed-upon sentence and signed the statement.

The district court found that at the time Buckley initialed and signed the felony disposition statement, a separate section of that document entitled “The District Attorney’s Position on Sentence” was blank. At some point after December 17, 1987, but before the change of plea hearing on January 4, 1988, Glynn added a handwritten paragraph to that section: “At the time of sentencing the people will move the court to declare the murder to be murder in the second degree, with a maxi mum term of 15 years to life.” (Emphasis added). Buckley did not initial the paragraph, and there is no evidence that he saw it before sentencing.

At the change of plea hearing, Glynn and Buckley engaged in the following colloquy:

Q: And has your attorney explained all of the consequences of your plea to this charge?
A: Yes.
Q: Do you understand that for second degree murder you could be sentenced to state prison for a maximum possible term of fifteen years?
A: Yes.
Q: And do you understand that after serving a prison term you’ll be subject to a parole period — I’m sorry, your Hon- or, does the Court know the parole period for second degree murder?' I didn’t enter that in the document.
The Court: Yes, it’s — the possibility is parole for life.
Q: All right. I’ve entered this into the document. You could be subject to a parole period of life. And you could also be ordered to pay a fine of not less than a hundred dollars nor more than $10,000. Do you understand that?
A: Yes.
* * *
Q: Now as I stated before and it’s also contained in this Felony Disposition form, that at the time of sentencing the people will ask the Court to declare the murder to be murder in the second degree with a maximum term of fifteen years to life. And the People’s reason for entering into that agreement are [sic] contained in this document that’s attached to the Felony Disposition Statement.
I’d like to go into the terms of this agreement with you. In order — or as your part of the agreement you will agree to cooperate in the trials against Curtis Fauber and Christopher Cogwell [sic], and that you will testify in the Fauber case at all proceedings regarding the murder of Thomas Urell, David Church and Jack Dowdy, and testify truthfully regarding whatever you know about those murders. Do you understand that to be the situation?
A: Yes.
Q: I’m showing you the Felony Disposition form, this yellow form here, that has some initials B.B. against a number of the paragraphs..Also has the initials D.C.G. which are my initials against some of the paragraphs. And at the end of the form I see the date December 17, 1987 and your signature. Did you sign this document on that date?
A: Yes.
Q: And did you sign this document because you read each of the paragraphs that you have initialed and you understand what’s contained in these paragraphs?
A: Yes.

(Emphasis added). The December 15 letter and the felony disposition statement were entered into evidence as constituting the plea agreement, and the court accepted and entered Buckley’s guilty plea.

On January 7, 1988, Buckley testified on behalf of the prosecution at the guilt phase of Fauber’s trial. On cross-examination, Buckley stated that he had been given a sentence of “fifteen years to life” in exchange for his testimony. On January 22, 1988, Buckley testified for the prosecution at a preliminary hearing in Caldwell’s case. There, he acknowledged that his charged offense had been reduced to second degree murder, although there was no discussion of his sentence. On February 9, 1988, Buckley testified at the penalty phase of Fauber’s trial. On cross-examination, when asked by defense counsel when he “expect[ed] to be released from prison” as a result of his testimony, Buckley responded, “seven and a half years.”

Buckley’s sentencing hearing took place on March 1, 1988, after his testimony in the Fauber and Caldwell cases. At the hearing, Glynn informed the court that Buckley had “complied with the terms of the negotiated disposition.” The prosecutor moved the court to declare the murder charge against Buckley to be murder in the second degree, and to dismiss the remaining two counts. The court granted the motion, ordered Buckley to pay $10,000 in restitution, and sentenced him to a prison term of fifteen years to life and a parole term of life. Buckley’s counsel did not object to the sentence.

On May 13, 1996, approximately eight years after Buckley’s sentencing, he filed a petition for a writ of habeas corpus in the Ventura County Superior Court. On September 10, 1996, the court, in a two-page order, denied Buckley’s petition:

The court finds that with the exception of one statement in the negotiated disposition statement ... and a reference at the time of the taking of the plea on January 4, 1988, ... the records demonstrate that the advisement was that the sentence would be 15 years to life as provided by law, and that the petitioner well knew this.... During the taking of the plea on January 4, 1988, [ ] petitioner was expressly advised that the maximum term of imprisonment was 15 years to life.... Any ambiguity concerning petitioner’s understanding of the sentence he was to receive is put to rest by petitioner’s own statement found in the transcript of January 7, 1988, during petitioner’s testimony at the trial of Curtis Fauber that he understood his term of imprisonment would be 15 years to life....
* * * "
Based upon the record provided by counsel in the within matter, it is evident that petitioner well knew that the term of imprisonment for which he was to be committed to prison for the crime of second degree murder was 15 years to life. In re Mosher [sic], (1993) 6 Cal.4th 342, 354-355, 24 Cal.Rptr.2d 723, 862 P.2d 723, citing United States v. Timmreck (1979) 441 U.S. 780, 784, 99 S.Ct. 2085, 60 L.Ed.2d 634.

(Emphasis added). Buckley next filed a habeas petition in the California Court of Appeal, which issued a one-sentence summary denial. The California Supreme Court also issued a one-sentence summary denial of a separate successive petition on March 31,1999.

Buckley filed a petition for a writ of habeas corpus in district court on March 7, 2000. The court referred the case to a magistrate judge, who ordered an eviden-tiary hearing. The magistrate judge issued a report that recommended granting the writ. He found that, under 28 U.S.C. § 2254(d)(2), Buckley had demonstrated by clear and convincing evidence that the state court’s factual finding regarding Buckley’s subjective understanding of his sentence was “incorrect and unreasonable.” Buckley v. Terhune, 266 F.Supp.2d 1124, 1141 (C.D.Cal.2002). Based on this finding, the magistrate judge concluded that, under § 2254(d)(1), the trial court had failed to “fulfill petitioner’s reasonable understanding of the plea agreement,” which was contrary to clearly established federal law holding that the state must fulfill a promise that induces a guilty plea. Id. at 1142^43. The magistrate judge recommended specific performance of the plea agreement: a determinate sentence of fifteen years in prison. Id. at 1143. The district court adopted the magistrate judge’s report and recommendation, id. at 1126, and the state appealed.

We affirm, although our analysis differs from the district court’s in some respects.

STANDARD OF REVIEW

The district court’s decision to grant a 28 U.S.C. § 2254 habeas petition is reviewed de novo. See Leavitt v. Arave, 383 F.3d 809, 815 (9th Cir.2004) (per curiam). We may affirm on any ground supported by the record, even if it differs from the rationale used by the district court. See Ramirez v. Castro, 365 F.3d 755, 762 (9th Cir.2004). We review findings of fact made by the district court for clear error. See Riley v. Payne, 352 F.3d 1313, 1317 (9th Cir.2003).

Under the Antiterrorism and Effective Death Penalty Act (AEDPA), § 2254 habe-as petitions “shall not be granted with respect to any claim that was adjudicated on the merits in State court proceedings unless the adjudication of the claim — (1) resulted in a decision that was contrary to, or involved an unreasonable application of, clearly established Federal law, as determined by the Supreme Court of the United States; or (2) resulted in a decision that was based on an unreasonable determination of the facts in light of the evidence presented in the State court proceeding.” 28 U.S.C. § 2254(d); see also Lockyer v. Andrade, 538 U.S. 63, 70-73, 123 S.Ct. 1166, 155 L.Ed.2d 144 (2003). Because Buckley filed his federal habeas petition after AEDPA’s effective date, we review his petition under the AEDPA standard. See Lindh v. Murphy, 521 U.S. 320, 326-27, 117 S.Ct. 2059, 138 L.Ed.2d 481 (1997).

ANALYSIS

Under Santobello v. New York, 404 U.S. 257, 261-62, 92 S.Ct. 495, 30 L.Ed.2d 427 (1971), a criminal defendant has a due process right to enforce the terms of his plea agreement. See also Brown v. Poole, 337 F.3d 1155, 1159 (9th Cir.2003) (“[The defendant’s] due process rights conferred by the federal constitution allow [him] to enforce the tenns of the plea agreement.”). In March 1999, when the California Supreme Court summarily denied Buckley’s petition for a writ of habeas corpus, it had been clearly established federal law for more than a decade that the construction and interpretation of state court plea agreements “and the concomitant obligations flowing therefrom are, within broad bounds of reasonableness, matters of state law.” Ricketts v. Adamson, 483 U.S. 1, 6 n. 3, 107 S.Ct. 2680, 97 L.Ed.2d 1 (1987). In California, “[a] negotiated plea agreement is a form of contract, and it is interpreted according to general contract principles,” People v. Shelton, 37 Cal.4th 759, 767, 37 Cal.Rptr.3d 354, 125 P.3d 290 (2006), and “according to the same rules as other contracts,” People v. Toscano, 124 Cal.App.4th 340, 344, 20 Cal.Rptr.3d 923 (2004) (cited with approval in Shelton along with other California cases to same effect dating back to 1982). Thus, under Adamson, California courts are required to construe and interpret plea agreements in accordance with state contract law.

The analysis regarding the breach of Buckley’s plea agreement and the remedy to which he is entitled is not new to this court. We previously applied similar principles and rules of construction in Brown. In that case, on the basis of Santobello and Adamson, we held that the state court, in failing to properly apply California contract law when interpreting a plea agreement, had engaged in an objectively unreasonable application of clearly established federal law under § 2254(d)(1). Brown, 337 F.3d at 1160 n. 2. Here the California Superior Court not only failed to apply state contract law properly but failed to apply it at all. Its decision, therefore, is unquestionably contrary to clearly established federal law.

I

In California, “[a]ll contracts, whether public or private, are to be interpreted by the same rules_” Cal. Civ. Code § 1635; see also Shelton, 37 Cal.4th at 766-67, 37 Cal.Rptr.3d 354, 125 P.3d 290; Toscano, 124 Cal.App.4th at 344, 20 Cal.Rptr.3d 923. A court must first look to the plain meaning of the agreement’s language. Cal. Civ. Code §§ 1638, 1644. If the language in the contract is ambiguous, “it must be interpreted in the sense in which the promisor believed, at the time of making it, that the promisee understood it.” Cal. Civ. Code § 1649. The inquiry considers not the subjective belief of the promisor but, rather, the “objectively reasonable” expectation of the promisee. Bank of the West v. Superior Court, 2 Cal.4th 1254, 1265, 10 Cal.Rptr.2d 538, 833 P.2d 545 (1992); Badie v. Bank of Am., 67 Cal.App.4th 779, 802 n. 9, 79 Cal.Rptr.2d 273 (1998) (“Although the intent of the parties determines the meaning of the contract, the relevant intent is objective — that is, the objective intent as evidenced by the words of the instrument, not a party’s subjective intent.” (internal quotation marks and citation omitted)). Courts look to the “objective manifestations of the parties’ intent....” Shelton, 37 Cal.4th at 767, 37 Cal.Rptr.3d 354, 125 P.3d 290. If after this second inquiry the ambiguity remains, “the language of a contract should be interpreted most strongly against the party who caused the uncertainty to exist.” Cal. Civ. Code § 1654; see also Toscano, 124 Cal.App.4th at 345, 20 Cal.Rptr.3d 923 (“ambiguities [in a plea agreement] are construed in favor of the defendant”).

Our first inquiry here is whether the Ventura County Superior Court, in the last reasoned state court decision to address Buckley’s plea agreement, treated the plea agreement as a contract and applied the three-step approach to interpreting contracts required by California law. Initially, we note that there is no mention of or reference to state contract law in the Superior Court’s order denying Buckley’s habeas petition. Nor is there any discussion of the terms of the plea agreement. Instead, the order addresses whether Buckley was “expressly advised” by the trial court that his sentence was fifteen years to life, and it cites only cases that consider an “advisement” issue — that is, the issue of a trial court’s duty to explain the charge and the sentence to a defendant. On the basis of this analysis it concluded that Buckley knew what his sentence would be. It is evident on the face of its decision that the Superior Court failed to recognize that Buckley’s plea agreement constituted a contract that under California law must be construed like all other contracts. As a result, the Superior Court failed to construe the terms of the plea agreement entirely. Accordingly, it failed to apply controlling state law and reached a decision that both in its mode of analysis and its result was contrary to clearly established Supreme Court law.

Considering extrinsic evidence before examining the language of the plea agreement and finding it ambiguous, as the state court did in this case, is further evidence of its failure to apply California contract law. Cal. Civ. Code § 1638; Pope v. Allen, 225 Cal.App.2d 358, 364, 37 Cal.Rptr. 371 (1964) (“The code provision permitting the showing of surrounding circumstances is not applicable to every contract which comes before a court for interpretation. It is applicable only where the language used in the contract is doubtful, uncertain or ambiguous .... ”). Moreover, even if the Ventura County Superior Court had first considered the plea agreement’s language and concluded that it was ambiguous, the court was not then permitted to use parol evidence to gauge the subjective understanding of one of the contracting parties. See Bank of the West, 2 Cal.4th at 1264-65, 10 Cal.Rptr.2d 538, 833 P.2d 545; Beck v. Am. Health Group Int’l, Inc., 211 Cal.App.3d 1555, 1562, 260 Cal.Rptr. 237 (1989) (“The objective intent ... not the parties’ subjective intent, governs our interpretation.”). In failing first to consider the language of Buckley’s plea agreement and second to engage in an analysis of the parties’ objective intent in entering that agreement, the Superior Court plainly contravened California law. In light of Santobello and Adamson, its decision falls squarely within the ambit of § 2254(d)(1).

II

Under AEDPA, even where the state court has committed constitutional error under § 2254(d), “habeas relief may still be denied absent a showing of prejudice.” Medina v. Homung, 386 F.3d 872, 877 (9th Cir.2004). The relevant inquiry in this case is whether the state court’s error, which resulted in its finding that the plea agreement mandated an indeterminate prison sentence of fifteen years to life, had a “substantial and injurious effect” on Buckley. Brecht v. Abrahamson, 507 U.S. 619, 637, 113 S.Ct. 1710, 123 L.Ed.2d 353 (1993). To answer this question we must determine what Buckley’s sentence would have been had the California courts applied California contract law. Where the state court fails to apply Supreme Court law (by failing to apply California contract law) we must ourselves conduct a de novo review of that question.

With respect to the first step in California contract analysis, it is clear that the language of Buckley’s plea agreement was ambiguous. Critically, the plea agreement contained conflicting paragraphs describing the sentence to be given Buckley upon his plea of guilty to second degree murder. One paragraph, which Buckley initialed, stated, “I could be sentenced to the state prison for a maximum possible term of 15 year(s).... After I have served my prison term, I may be subject to a maximum parole period of LIFE.” A different paragraph was added later, after Buckley had already read and initiated the agreement. That paragraph, initialed only by Glynn, stated, “At the time of sentencing the people will move the court to declare the murder to be murder in the second degree, with a maximum term of 15 years to life.” Even disregarding the timing of the addition of the added paragraph, there is only one reasonable conclusion one can draw from the facts: The language of the plea agreement is ambiguous with respect to Buckley’s ■ sentence.

After finding an ambiguity in the language of a contract, we must next attempt to resolve that uncertainty by looking to the “objectively reasonable expectations” of the promisee. See Bank of the West, 2 Cal.4th at 1265, 10 Cal.Rptr.2d 538, 833 P.2d 545; Cal. Civ. Code § 1649. This inquiry considers the disputed or ambiguous language in the context of the contract as a whole and of the relevant surrounding circumstances. Nissel v. Certain Underwriters at Lloyd’s of London, 62 Cal.App.4th 1103, 1111-12, 73 Cal.Rptr.2d 174 (1998); see also Bank of the West, 2 Cal.4th at 1265, 10 Cal.Rptr.2d 538, 833 P.2d 545 (“This is because language in a contract must be construed in the context of that instrument as a whole, and in the circumstances of that case, and cannot be found to be ambiguous in the abstract.” (emphasis and internal quotation marks omitted)).

Applying the second step of California contract analysis in this case does not resolve the ambiguity created by the language of the plea agreement. Read in the context of the entire agreement, the conflicting pronouncements regarding the length of the sentence to be imposed offer no more clarity than they do when read in the abstract. Furthermore, the plea colloquy compounds, rather than cures, this ambiguity. At the January 4, 1988, change of plea hearing, Glynn asked Buckley whether he understood his sentence to be “a maximum possible term of fifteen years,” to which Buckley responded, ‘Tes.” However, shortly thereafter, Glynn stated, “Now as I stated before and it’s also contained in this Felony Disposition form, that at the time of sentencing the people will ask the Court to declare the murder to be murder in the second degree with a maximum term of fifteen years to life.... Do you understand that to be the situation?” Again, Buckley answered, ‘Tes.” Accordingly, the colloquy does no more than replicate the ambiguity and, in turn, lead us to the final step in our contractual analysis.

The proper interpretation of the plea agreement becomes clear when we turn, as California law provides, to § 1654 of the California Civil Code: “In cases of uncertainty not removed by the preceding rules, the language of a contract should be interpreted most strongly against the party who caused the uncertainty to exist.” There is no dispute that both the December 15, 1987, letter from Glynn to Buckley’s counsel and the felony disposition statement, which together constituted the plea agreement, were drafted by the prosecutor’s office. Thus, we are compelled by § 1654 to construe the ambiguity in the plea agreement — whether Buckley was to receive a determinate fifteen-year sentence or an indeterminate sentence of fifteen years to life — against the state. See Toscano, 124 Cal.App.4th at 345, 20 Cal.Rptr.3d 923. Given the direct conflict in the terms of the plea agreement, we must adopt the construction of the agreement that is most favorable to Buckley: a maximum prison sentence of fifteen years. Because Buckley instead received an indeterminate prison sentence of fifteen years to life, it is evident that the state breached the plea agreement and that the breach had a “substantial and injurious effect” upon Buckley. Brecht, 507 U.S. at 637, 113 S.Ct. 1710.

Ill

As the district court found, Buckley has two available remedies at law for the breach of his plea agreement: withdrawal of his plea (i.e., rescission of the contract) and specific performance. Buckley, 266 F.Supp.2d at 1143; see also Santobello, 404 U.S. at 263, 92 S.Ct. 495(positing the same two alternative remedies). Where a plea agreement is breached, the purpose of the remedy is, to the extent possible, to “repair the harm caused by the breach.” Toscano, 124 Cal.App.4th at 345, 20 Cal.Rptr.3d 923(citing People v. Kaanehe, 19 Cal.3d 1, 14, 136 Cal.Rptr. 409, 559 P.2d 1028 (1977)).

In Buckley’s case, only one of the remedies appears to us to be viable. Buckley has already fulfilled his obligations under the plea agreement, including testifying on behalf of the state against Fauber and Caldwell and serving his bargained-for sentence. In so doing, he has “paid in a coin that the state cannot refund.” Brown, 337 F.3d at 1161. Rescission of the plea agreement cannot repair the harm caused by the state’s breach. See Carter v. McCarthy, 806 F.2d 1373, 1377(9th Cir.1986). That harm can best be addressed by holding .the state to its agreement and affording Buckley the benefit of his bargain. Thus, Buckley is entitled to specific performance of the plea agreement: a maximum prison sentence of fifteen years.

We arrive at our decision notwithstanding the state’s argument that a determinate fifteen year prison term is not a lawful sentence for second degree murder under California law. Consistent or not with the state’s sentencing statute, that is the bargain that California made in 1987. Buckley has fulfilled his promises, and it is now too late for the state to argue that it was not in a position to offer him a fifteen year sentence in exchange. As we stated in Brown, addressing an identical argument: “This may be a problem for the state, but not for [the defendant].” 337 F.3d at 1161.

IV

Under Santobello, Buckley had a due process right to enforce the provisions of his plea agreement. Under Adamson, the state court was required to interpret Buckley’s plea agreement pursuant to California contract law; in not doing so, it failed to apply clearly established federal law set forth by the United States Supreme Court. 28 U.S.C. § 2254(d)(1). The consequence was that Buckley was sentenced to an indeterminate prison term of fifteen years to life when the bargained-for sentence, to which he was constitutionally entitled, was a maximum of fifteen years. Thus, the state court committed constitutional error that had a substantial and injurious effect on Buckley. He is entitled to habeas corpus relief.

The district court’s judgment granting Buckley’s petition for a writ of habeas corpus is AFFIRMED.

CALLAHAN, Circuit Judge, with whom TALLMAN, Circuit Judge, joins,

dissenting:

I respectfully dissent. The majority notes the standard for relief set forth in the Antiterrorism and Effective Death Penalty Act (“AEDPA”), 28 U.S.C. § 2254, but then substitutes its factual findings for those of the state court. Although the majority professes to grant relief under § 2254(d)(1), holding that the state court’s decision involved an unreasonable application of clearly established federal law, my reading of its opinion is that it actually, and incorrectly, concludes that the state court’s decision was based on an unreasonable determination of fact. See 28 U.S.C. § 2254(d)(2).

The majority’s perspective rests on two premises. First, it asserts that it was established federal law in 1999, that the construction and interpretation of plea agreements were matters of state law and that in California a plea agreement was interpreted according to the same rules as other contracts. Second, the majority concludes that under California law, the uncertainty in the plea agreement requires that the agreement be construed against the state.

I agree with the majority that the construction and interpretation of plea agreements are matters of state law, that in California plea agreements are interpreted similarly to other contracts, and that here the plea agreement is ambiguous. I also agree that the ambiguity in the plea agreement requires that we look to the expectations of the promisee in the context of the contract as a whole and the relevant surrounding circumstances. I part company with the majority on the conclusions we reach from examining the surrounding circumstances. The majority finds that the surrounding circumstances do not resolve the ambiguity. AEDPA, however, requires that we defer to the state court’s factual determination that Buckley “well knew” that he had bargained for a sentence of 15 years to life unless that finding is not supported by substantial evidence. Taylor v. Maddox, 366 F.3d 992, 999 (9th Cir.2004). Because I cannot say “that an appellate panel, applying the normal standard of appellate review, could not reasonably conclude that the finding is supported by the record,” see id. at 1000, I would deny Buckley’s petition for a writ of habe-as corpus.

In its most recent opinion concerning the interpretation of plea agreements, the California Supreme Court, after reiterating that a plea agreement is interpreted according to general contract principles, wrote:

“The fundamental goal of contractual interpretation is to give effect to the mutual intention of the parties. (Civ.Code, § 1636.) If contractual language is clear and explicit, it governs. (Civ.Code, § 1638.) On the other hand, ‘[i]f the terms of a promise are in any respect ambiguous or uncertain, it must be interpreted in the sense in which the promisor believed, at the time of making it, that the promisee understood it.’ (Id., § 1649; see AIU [Ins. Co. v. Superior Court (1990) 51 Cal.3d 807,] 822[274 Cal.Rptr. 820, 799 P.2d 1253].)” (Bank of the West v. Superior Court (1992) 2 Cal.4th 1254, 1264-1265, 10 Cal.Rptr.2d 538, 833 P.2d 545.) “The mutual intention to which the courts give effect is determined by objective manifestations of the parties’ intent, including the ivords used in the agreement, as well as extrinsic evidence of such objective matters as the surrounding circumstances under which the parties negotiated or entered into the contract; the object, nature and subject matter of the contract; and the subsequent conduct of the parties. (Civ.Code, §§ 1635-1656; Code Civ. Proc., 1859-1861, 1864; [citations].)” (Morey v. Vannucci (1998) 64 Cal.App.4th 904, 912, 75 Cal.Rptr.2d 573; see also People v. Toscano, supra, at p. 345, 20 Cal.Rptr.3d 923.)

People v. Shelton, 37 Cal.4th 759, 767, 37 Cal.Rptr.3d 354, 358, 125 P.3d 290, 294 (2006) (emphasis added) (alterations in original).

The California Supreme Court proceeded to explain that in resolving the ambiguous plea agreement before it, it would:

consider the circumstances under which this term of the plea agreement was made, and the matter to which it relates (Civ.Code, § 1647) to determine the sense in which the prosecutor and the trial court (the promisors) believed, at the time of making it, that defendant (the promisee) understood it (id., § 1649).

Id. The court further noted that one interpretation of the agreement was “reinforced by the prosecutor’s remarks at the sentencing hearing....” Id. at 768, 37 Cal.Rptr.3d at 359, 125 P.3d at 295. In reaching its conclusion, the court noted that it considered “the totality of the circumstances presented here.” Id.

Thus, under California law, a judicial determination of the parties’ expectations in a plea agreement is not confined to reviewing the four corners of the plea agreement. A plea agreement is not like a contract between two private parties. Rather, in a plea agreement, the prosecutor and the defendant agree to make certain representations to the trial judge who retains the authority to accept or reject those representations. See Frankel v. Bd. of Dental Examiners, 46 Cal.App.4th 534, 551, 54 Cal.Rptr.2d 128 (Cal.Ct.App.1996). Furthermore, a plea agreement is often, as ■in this case, before the trial court on at least two occasions at which various factors that have an influence on the agreement and the parties’ expectations may- be considered. Here, the trial court first considered the plea agreement at the change-of-plea hearing, and subsequently the trial court considered the provisions of the plea agreement when it sentenced Buckley.

A review of the record in this case shows that the state court reasonably determined that Buckley’s expectation was that he would receive a 15-years-to-life sentence. As noted in the majority opinion, there is some question as to what language was in the plea agreement when Buckley signed it. The record, however, shows that when Buckley testified in Fau-ber’s trial in January 1988, he stated that he had pled guilty to second-degree murder, with a penalty of 15 years to life, in return for the District Attorney not prosecuting him with murder in the first degree, which carried a penalty of 25 years to life, and dropping the robbery and burglary charges. Moreover, at his subsequent sentencing hearing in March 1988, the trial court sentenced Buckley to a prison term of 15 years to life and a parole term of life. Buckley was represented by counsel at the sentencing hearing and did not object to the imposed sentence. Furthermore, the attorney who represented Buckley in 1988 subsequently testified that he had no recollection of negotiating a determinant sentence of 15 years with the District Attorney or discussing such a sentence with Buckley. It was not until 1996 that Buckley advanced the contention that his plea agreement was for 15 years. Perhaps reasonable minds may differ on whether Buckley in 1988 knew that his plea agreement was for 15 years to life, but the state court’s determination that he did is not “an unreasonable determination of the facts in light of the evidence presented.” See 28 U.S.C. § 2254(d)(2): see also Taylor, 366 F.3d at 1000 (stating that “it is not enough that we would reverse in similar circumstances if this were an appeal from a district court decision;” instead, we must be convinced that the state court “could not reasonably conclude that the finding is supported by the record.”).

Finally, I note that this factual determination is further bolstered by the State’s representation — not rebutted by the majority or by Buckley — that the allegedly bargained-for sentence of 15 years was illegal under California law. This too, is part of the relevant surrounding circumstances that a court may consider in determining the parties’ intent in entering into a plea agreement. There is nothing in the record to suggest that the prosecutor intended or had any motive to agree to such an illegal sentence. Similarly, there is nothing in the record to suggest that the trial judge was not aware of the statutory sentence for second degree murder or that he intended to approve an illegal sentence.

In this case, the state court — on the basis of the same evidence as Buckley presented in his federal habeas petition— determined that Buckley “well knew that the term of imprisonment for which he was to be committed to prison for the crime of second degree murder was 15 years to life.” Pursuant to 28 U.S.C. § 2254(d)(2), this factual determination precludes federal habeas relief unless it is “unreasonable.” The fact that the state court did not refer to contract law when determining Buckley’s understanding of the plea agreement does not make the state court’s factual determination unreasonable. Accordingly, I would vacate the district court’s grant of Buckley’s petition for a writ of habeas corpus, and deny the petition. 
      
      . The number "15” was handwritten. The word “LIFE” was not added until the January 4, 1988, plea hearing. However, the question of Buckley’s parole term is not at issue here.
     
      
      . Buckley's statement that he expected to be released from prison in seven and a half years apparently reflected his erroneous belief that under California law he would be released after he had served half of his sentence if he exhibited good behavior. ■ See Cal. Penal Code § 3049.
     
      
      . Despite the sentence of fifteen years to life in prison, Buckley contends that he believed that the maximum prison sentence he faced was fifteen years. According to Buckley, this belief resulted from the explicit terms of the plea agreement he saw and initialed, the colloquy at the change of plea hearing (in which he answered "yes” to the prosecutor’s question whether he signed the plea agreement because he read and understood each of the paragraphs that he initialed), and his understanding that “fifteen to life” was simply another way of saying "fifteen years in prison followed by a parole term of life.” There is no evidence that Buckley’s trial counsel explained to him the difference between the two sentences. According to Buckley, he did not discover that his sentence was actually an indeterminate term of fifteen years to life until a 1995 administrative hearing in prison.
     
      
      . The one-year statute of limitations applicable to Buckley's federal habeas petition was tolled from the time that he filed his initial state habeas petition to thirty days after the California Supreme Court denied his last petition. Carey v. Saffold, 536 U.S. 214, 221-23, 122 S.Ct 2134, 153 L.Ed.2d 260 (2002); Nino v. Galaza, 183 F.3d 1003, 1006-07 (9th Cir.1999). Thus, his federal petition was timely, and the state does not contend otherwise.
     
      
      . The "unreasonable application” provision of § 2254(d)(1) applies where "the state court identifies the correct governing legal principle from [the Supreme Court’s] decisions but unreasonably applies that principle to the facts of the prisoner's case.” Williams v. Taylor, 529 U.S. 362, 413, 120 S.Ct. 1495, 146 L.Ed.2d 389 (2000). In this case, however, the state court's decision was "contrary to” clearly established law because it failed to apply contract law analysis at all: "[A] state court decision is contrary to our clearly established precedent if the state court applies a rule that contradicts the governing law set forth in our cases....” Andrade, 538 U.S. at 73, 123 S.Ct. 1166(internal quotation marks omitted). Whether we classify this case as an "unreasonable application of” or a "contrary to” case is irrelevant, however; the result would be the same in either instance.
     
      
      . The Superior Court's order principally cites In re Moser, 6 Cal.4th 342, 354-55, 24 Cal.Rptr.2d 723, 862 P.2d 723 (1993) (although it misspells the case name). Moser was a state habeas case in which the defendant pled guilty "after receiving inadequate or erroneous advice from the trial court" with respect to the possible consequences of his plea agreement. Id. at 345, 24 Cal.Rptr.2d 723, 862 P.2d 723. As the Moser court held, the issue in that case was "misadvisement,” not the breach of a plea agreement. Id. at 356, 24 Cal.Rptr.2d 723, 862 P.2d 723. Similarly, United States v. Timmreck, 441 U.S. 780, 99 S.Ct. 2085, 60 L.Ed.2d 634 (1979), which the Superior Court notes was cited in Moser, involves the trial court's failure to properly advise the defendant regarding his sentence as required by Federal Rule of Criminal Procedure 11. Again in Timmreck, as in Moser, the issue was not the breach of a plea agreement but a breach of the trial court's duty to inform the defendant of certain information.
     
      
      . The dissent, on the one hand, argues that the state court's finding that Buckley "well knew” that his sentence was fifteen years to life is entitled to our deference under AEDPA. On the other hand, it concedes that the state court failed both to examine the language of the plea agreement and to apply an objective test to determine the mutual intent of the parties. Dissent at 701 n. 1 ("It is true that the California Superior Court did not specify that the plea agreement should be interpreted pursuant to general contract terms. Nonetheless, the application of those terms would not have changed that court's factual determination.”). As to our dissenting colleagues' first point, whether or not the state court's determination of Buckley’s subjective state of mind was reasonable is wholly irrelevant. The fact remains that the court failed to apply California contract law or to analyze Buckley's plea agreement in that light, or indeed in any light. Although AEDPA does require deference to a state court’s factual findings, it does not permit us, as the dissent suggests, to invent factual findings and then ascribe them to the state court. Nor does it allow us to attribute a theory of law to the state court that it failed to employ.
     
      
      . The district court found that the additional paragraph, which was handwritten, was not added until after Buckley saw and initialed the first paragraph. There appears to be no doubt from the record that the district court is correct in this respect. However, the chronology is not important to our outcome here: For purposes of this opinion we attach no weight to the fact that the state's version of the bargained-for sentence was incorporated in the plea agreement after Buckley had reviewed and initialed it, and afford that version equal significance to the paragraph on which Buckley relies, although we note that were we to disregard the subsequently incorporated material, there would be no inconsistency and no ambiguity at all, as Buckley’s version of the sentence would be the only one set forth in the plea agreement.
     
      
      . That Buckley subsequently testified at his co-defendant’s trial and sentencing both that he had received a sentence of fifteen years to life and that he expected to be released from prison in seven and one half years only compounds the ambiguity further. Finally, given Buckley’s later expressed misunderstanding of the relationship between his prison sentence and his parole term, and the absence of any evidence that counsel explained to him the nature of his sentence, his failure to object to the sentence when it was ultimately imposed by no means serves to eliminate the ambiguity.
     
      
      . Buckley was taken into custody on Novem- • ber 12, 1987, the date that he was charged with burglary, robbery and first degree murder. The district court granted him habeas relief on December 6, 2002. He was thereafter released.
     
      
      . We express no view on what the proper remedy would be in a case with other facts. As the California Supreme Court has held, the appropriate remedy in breach of plea agreement cases depends on the nature of the breach, which party (e.g., the defendant, the prosecutor or the trial court) has breached the agreement, and which party seeks enforcement of the contract. Kaanehe, 19 Cal.3d at 13, 136 Cal.Rptr. 409, 559 P.2d 1028. To that we would add, "and what has transpired since the agreement was made.” Here, we hold only that in a case in which the state has already received the benefit of the bargain, the harm caused by its breach is generally best repaired by specific performance of the plea agreement, although a defendant may, if he so chooses, elect instead to rescind the agreement and take his chances from there.
     
      
      . It is trae that the California Superior Court did not specify that the plea agreement should be interpreted pursuant to general contract terms. Nonetheless, the application of those terms would not have changed that court's factual determination. Moreover, the state court’s factual finding that Buckley well knew that his bargained-for sentence was 15 years to life resolved the ambiguity in the agreement.
     
      
      . For this reason, I also disagree with the majority's holding that Buckley is entitled to specific performance of the plea agreement, as it interprets the agreement. Were I to otherwise agree with the majority, I would vacate the sentence and give Buckley an opportunity to withdraw his plea; thus placing both sides back in the positions they were in prior to their entry into the plea bargain. This is not to suggest that what has transpired since 1988 would not have a substantial impact on the parties’ subsequent actions. Rather, my concern is that a federal court should not order the specific, performance of a plea agreement in a state court that is illegal under state law.
     