package llm // Which language a pass corrects, and which language it explains in. // // Until Phase 28 there was no question to answer: every prompt was written // around English prose explained in English, and the pair language reached her // only when she asked for it (Ask Petal, the explanation translator). That is // the right default for a writer practising English and the wrong one for a // document she wrote in her own language, where Petal would read Portuguese, // say nothing about it, and file a mechanics note about the one English // sentence at the end. // // The two fields are two different decisions reading two different pieces of // state, and collapsing them would be the bug: // // - Correct follows the DOCUMENT. Portuguese prose gets Portuguese // corrections; that is the whole point. // - Explain follows the WRITER — the half of her pair she is *not* learning // (users.direction), because an explanation is teaching, and teaching lands // in the language she reads most easily. // // Today those two coincide for every account that exists: `learnerPairs` is // {"zh"}, so fr, es and pt-PT writers are all `learning_en` and their // non-learned half *is* the pair language. That equality is a fact about // today's roster, not about the design — the same shape of assumption that had // to be unpicked from `pair_lang` in migration 0016. Keep them apart. type Target struct { // Correct is the language the writing is in, and so the language both // `original` and `replacement` must be written in. Correct Lang // Explain is the language each explanation is written in. Explain Lang // Pair is the writer's pair language regardless of what this document is // written in. The collocation coach's parenthetical gloss is addressed to // her rather than to the document, so it reads this and not Correct. Pair Lang } // English as the prompts name it. Not in `langs`: that map answers "which // language is the writer's half of the pair", and English is the constant on // the other side of every pair Petal supports. var English = Lang{Code: "en", Name: "English", Why: "why"} // EnglishTarget is the pre-Phase-28 behaviour, made explicit: an English // document, corrected and explained in English, for a writer whose pair // language is `pair`. Every existing user is on this path and the prompt it // produces is byte-identical to the one that shipped before this phase. func EnglishTarget(pair Lang) Target { return Target{Correct: English, Explain: English, Pair: pair} } // Flipped reports whether this document is in the pair language rather than in // English — i.e. whether the pass is reading her own language. func (t Target) Flipped() bool { return t.Correct.Code != English.Code }