usesuper::*;/// RULE: A failure a person reads never prints the fold, the write clock, a CHECK constraint, a table or column name or a record id; it says what did not happen and what to do, and the raw text is handed back for the log only.#[test]fn a_failure_never_prints_the_machinery_under_it() {let raws = ["`write` was folded as stale (1 op(s)) — the write clock is behind the rows it is writing","`write` was refused by the fold: CHECK constraint failed: (state = 'open') = (decided_at IS NULL)","sqlite: UNIQUE constraint failed: cotton_media_albums.id","no record 3f2a9c1e-77aa-4b1e-9c2d-0a1b2c3d4e5f in cotton_todos","this core answers no `records.frobnicate`","invalid type: string \"x\", expected i64 at line 1 column 3","row decided_at is set","", ];for raw in raws {let said = for_person(raw, Act::Keep); assert_eq!(said.sentence, NOT_KEPT, "{raw}"); assert_eq!(said.logged.as_deref(), Some(raw)); assert!(!shows_internals(&said.sentence)); } assert_eq!(for_person("`x`", Act::Read).sentence, NOT_READ); assert_eq!(for_person("`x`", Act::Other).sentence, NOT_DONE);}/// RULE: A sentence already written for the person passes through the failure builder unchanged, so a refusal that says what to do is never flattened to "try again".#[test]fn a_sentence_for_the_person_passes_through() {let sentences = ["That todo is no longer here","There is already a group called Family.","Still copying your database — the connection dropped before the copy finished. Try again when you are on a network.","Cotton does not know which timezone this database lives in — set it once in the app.","startsAt names a day with no time — give it a time, or leave allDay out for a whole-day event","Pick a photo from example.com or upload notes.pdf first.","Sam's birthday is on 12 March.", ];for sentence in sentences {let said = for_person(sentence, Act::Keep); assert_eq!(said.sentence, sentence); assert_eq!(said.logged, None, "{sentence}"); }}/// RULE: A read refusal a person reads never names the method that failed ("Members could not be read · read.members" is wrong): any dotted method name, one part or several, is machinery, and the person gets the plain sentence instead.#[test]fn a_refusal_never_names_a_method() {for raw in ["read.members","every read connection is busy after 30 s (read.home asked): held by read.members, read.syncState","records.list.everything was refused", ] {let said = for_person(raw, Act::Read); assert_eq!(said.sentence, Act::Read.sentence(), "{raw}"); assert_eq!(said.logged.as_deref(), Some(raw)); } assert_eq!(for_person("Saved to notes.md", Act::Read).sentence, "Saved to notes.md");}