From 61ff97daf7cd67f3f2aa6944540663a22db6010d Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 22 Nov 2026 17:02:13 +0100 Subject: [PATCH] Persona K60: every line and addition into a covered room names each covering hold in holds or clear_of; one left out is retried, and after a failed retry is held under that hold say and amend gain a required clear_of. verdict_faults finds a covering hold (listed, or opened by this answer, covering anywhere or the room the draft goes into) named in neither list, and the one loop retries it. After a failed retry the draft names it (Faults::named), so held_by and the words gate hold it, and decision.unverdicted reports it. clear_of is recorded on the said line and the addition, clears nothing the words gate holds, and a Held line that named the hold clear is reported in decision.clear_of_overruled. Tests replay R16 X.3 r1 and X.4 r7. Co-Authored-By: Claude Opus 5.5 --- .../fixtures/interpret/golden-speech.txt | 2 +- .../mind-body/src/projection/harness/tests.rs | 9 +- crates/mind-body/src/projection/interpret.rs | 125 ++++++++++++++-- .../src/projection/interpret/tests.rs | 141 +++++++++++++++++- 4 files changed, 256 insertions(+), 21 deletions(-) diff --git a/crates/mind-body/fixtures/interpret/golden-speech.txt b/crates/mind-body/fixtures/interpret/golden-speech.txt index fbe74dc..7824319 100644 --- a/crates/mind-body/fixtures/interpret/golden-speech.txt +++ b/crates/mind-body/fixtures/interpret/golden-speech.txt @@ -8,7 +8,7 @@ A draft is speech only when his prose shows him choosing to send it now. Wonderi He speaks only in this room. What he knows privately is listed below as private: he says none of it here, and nothing that gives it away. A private matter may be said plainly only to the person it concerns, in a direct message with exactly that person; nothing listed is that here. Whether a draft fits who is listening is yours to judge. -Answer with the speech contract's object. `say` lists the drafts he sends now, each by its number, with the Matrix ids of anyone listed whom he addresses directly (`mentions`), the id of the line listed below that he answers or passes on (`in_reply_to`, or null: the room shows that line, with who said it, above his own words), and what the draft promises or offers (`promises`, a list, empty when it promises nothing): for each act it promises or offers, its words, copied exactly, the Matrix id of the person listed to whom he promises it (`to`, null when he promises it to the room), when it promises again one of his open promises listed below to the same person, that promise's id (`reaffirms`, else null): a promise said again is the same promise, never a new one; and what keeping it needs (`needs`): `words` when what he already has keeps it; finding anything out is a `read`, naming what to read in `read`, or `lacking` when no read reaches it. `gaps` records what he meant and did not send. `unsent` accounts for each of his drafts this answer neither sends (in `say`, `amend` or `suggest`) nor records as an addressee or elsewhere gap: declined, when his prose shows him choosing not to send it, quoting those words of his thought (`quote`); superseded, when a later draft or later prose of his replaces it, quoting those later words. Every draft is accounted for: one left out fails the answer. A draft to someone who spoke to him this turn is declined only when his prose says he chooses not to send it. `amend` adds to one of his own lines listed below, at most one a turn, only when his thought shows him choosing to correct or add to that line: name the line by its id, the draft that is his addition, and what it promises, as a line's `promises`. The line stays as it was and the draft is added after it; he never takes a word back. `suggest` leaves Self one note, at most one a turn, only when his thought shows him choosing to: name the draft that is the note, its kind (feedback when he passes on what someone listed said, with that person's Matrix id in `about`; idea when it is his own, `about` null), and set `private` when it carries anything listed as private or gives it away; such a note is not left. `state` closes his open promises listed below, each by its id: kept, citing the draft by which he does it (`evidence.draft`); withdrawn, citing the draft in which he takes it back to the person he promised, or tells them he cannot do it; released, citing the id of the line listed below that he may reply to in which the person he promised lets him off it (`evidence.line`). A release says he no longer owes it; patience is not a release, so "no hurry" or "whenever you've read it is fine" leaves the promise open. Every close also quotes in `thought` the words of his prose here that take it up, copied exactly from his thought outside every draft between and , and `still_stands` is true when anything in his prose here holds the promise as still owed or not yet done ("the promise stays open until I've read it"): then it is not closed. A draft cited closes the promise only when it goes out this turn where the person he promised can read it, in the room where he made the promise or in a direct message with them, and a thought alone closes nothing. A promise he has no way to do is never kept by him: telling the person he promised that he cannot do it withdraws it, and that person can release it. `reopen` names a promise listed below as closed whose close his own words here say was wrong, that it is not done: copy those words exactly from his prose or a draft (`words`), and type what keeping it needs (`needs`) as for a new promise, or null to keep what it needed; else it is empty. `hold` opens a hold when a line listed below asks him not to post or share something somewhere yet: the line's id, the words of that line that name what is held and where, copied exactly (`words`), and `where`: here for the room the line is in, anywhere when it names no place. Every line marked said to him is either the line of a `hold` entry or listed in `no_hold`, when it asks him to keep nothing back; one left out fails the answer. `holds`, on each line and addition, names every hold listed below, or line this answer opens a hold from, whose held thing this draft puts where it goes; else empty. `hold_released` closes a hold listed below when the person who asked lets it go: the id of the asker's line (`line`). +Answer with the speech contract's object. `say` lists the drafts he sends now, each by its number, with the Matrix ids of anyone listed whom he addresses directly (`mentions`), the id of the line listed below that he answers or passes on (`in_reply_to`, or null: the room shows that line, with who said it, above his own words), and what the draft promises or offers (`promises`, a list, empty when it promises nothing): for each act it promises or offers, its words, copied exactly, the Matrix id of the person listed to whom he promises it (`to`, null when he promises it to the room), when it promises again one of his open promises listed below to the same person, that promise's id (`reaffirms`, else null): a promise said again is the same promise, never a new one; and what keeping it needs (`needs`): `words` when what he already has keeps it; finding anything out is a `read`, naming what to read in `read`, or `lacking` when no read reaches it. `gaps` records what he meant and did not send. `unsent` accounts for each of his drafts this answer neither sends (in `say`, `amend` or `suggest`) nor records as an addressee or elsewhere gap: declined, when his prose shows him choosing not to send it, quoting those words of his thought (`quote`); superseded, when a later draft or later prose of his replaces it, quoting those later words. Every draft is accounted for: one left out fails the answer. A draft to someone who spoke to him this turn is declined only when his prose says he chooses not to send it. `amend` adds to one of his own lines listed below, at most one a turn, only when his thought shows him choosing to correct or add to that line: name the line by its id, the draft that is his addition, and what it promises, as a line's `promises`. The line stays as it was and the draft is added after it; he never takes a word back. `suggest` leaves Self one note, at most one a turn, only when his thought shows him choosing to: name the draft that is the note, its kind (feedback when he passes on what someone listed said, with that person's Matrix id in `about`; idea when it is his own, `about` null), and set `private` when it carries anything listed as private or gives it away; such a note is not left. `state` closes his open promises listed below, each by its id: kept, citing the draft by which he does it (`evidence.draft`); withdrawn, citing the draft in which he takes it back to the person he promised, or tells them he cannot do it; released, citing the id of the line listed below that he may reply to in which the person he promised lets him off it (`evidence.line`). A release says he no longer owes it; patience is not a release, so "no hurry" or "whenever you've read it is fine" leaves the promise open. Every close also quotes in `thought` the words of his prose here that take it up, copied exactly from his thought outside every draft between and , and `still_stands` is true when anything in his prose here holds the promise as still owed or not yet done ("the promise stays open until I've read it"): then it is not closed. A draft cited closes the promise only when it goes out this turn where the person he promised can read it, in the room where he made the promise or in a direct message with them, and a thought alone closes nothing. A promise he has no way to do is never kept by him: telling the person he promised that he cannot do it withdraws it, and that person can release it. `reopen` names a promise listed below as closed whose close his own words here say was wrong, that it is not done: copy those words exactly from his prose or a draft (`words`), and type what keeping it needs (`needs`) as for a new promise, or null to keep what it needed; else it is empty. `hold` opens a hold when a line listed below asks him not to post or share something somewhere yet: the line's id, the words of that line that name what is held and where, copied exactly (`words`), and `where`: here for the room the line is in, anywhere when it names no place. Every line marked said to him is either the line of a `hold` entry or listed in `no_hold`, when it asks him to keep nothing back; one left out fails the answer. `holds`, on each line and addition, names each hold listed below, or line this answer opens a hold from, whose held thing this draft puts where it goes; `clear_of` names each such hold covering where it goes whose held thing it does not carry. Under every hold that covers where a draft goes, the draft names it in one of the two; one left out fails the answer. `hold_released` closes a hold listed below when the person who asked lets it go: the id of the asker's line (`line`). A draft is said whole or not at all, and only once. At most two drafts a turn. Record a gap instead of guessing: addressee when he means to send a draft but whom to is unclear, elsewhere when he means a draft for another room or another time; for these two, name the draft by number. missing_affordance when he means to do something, now or later, that his body cannot do (what he can do here is listed below), whether he said so in a draft or only thought it; name the draft when there is one. unwritten when he means to say something now and wrote no draft of it. Holding back is no gap: when his thought shows him choosing to wait, to let something stand, to leave it for later or to say nothing, record nothing for it. Every other intent of his that is not carried out has a kind: an intent to act is missing_affordance, an intent to say now with no draft is unwritten. When a gap names no draft, quote the words of his thought that show it, at least four words, copied exactly. diff --git a/crates/mind-body/src/projection/harness/tests.rs b/crates/mind-body/src/projection/harness/tests.rs index 817f69f..3de0c4b 100644 --- a/crates/mind-body/src/projection/harness/tests.rs +++ b/crates/mind-body/src/projection/harness/tests.rs @@ -47,8 +47,15 @@ impl Scripted { pub(crate) fn drafted_lines(prompt: &str) -> String { let numbered = prompt.rsplit("drafts, by number:\n").next().unwrap_or_default(); let say: Vec = (1..).take_while(|n| numbered.lines().any(|line| line.starts_with(&format!("{n}. ")))).map(|n| json!({ "draft": n, "mentions": [], "in_reply_to": null })).collect(); - // Every line the prompt marks said to her asks her to hold nothing (K59). + // Every line the prompt marks said to her asks her to hold nothing (K59), and every line is clear of every hold listed + // (K60). let no_hold: Vec<&str> = prompt.lines().filter_map(|line| line.strip_prefix("- ")?.split_once(" (said to ")).map(|(id, _)| id).filter(|id| !id.contains(' ')).collect(); + let holds = prompt.split("\nHolds:\n").nth(1).unwrap_or_default(); + let clear_of: Vec<&str> = holds.lines().take_while(|line| !line.is_empty()).filter_map(|line| line.strip_prefix("- ")?.split_once(" \u{2014} ")).map(|(id, _)| id).collect(); + let say: Vec = say.into_iter().map(|mut line| { + line["clear_of"] = json!(clear_of); + line + }).collect(); json!({ "say": say, "gaps": [], "no_hold": no_hold }).to_string() } diff --git a/crates/mind-body/src/projection/interpret.rs b/crates/mind-body/src/projection/interpret.rs index 1c3195e..75fb32f 100644 --- a/crates/mind-body/src/projection/interpret.rs +++ b/crates/mind-body/src/projection/interpret.rs @@ -71,7 +71,7 @@ pub(crate) const SPEECH_OPENING: &str = "You decide what one person says aloud i /// The speech contract, sent as the schema turn's output schema (`--json-schema`): the drafts she sends now by number, /// and the gaps. The model writes no words of hers. -pub(crate) const SPEECH_SCHEMA: &str = r#"{"type":"object","additionalProperties":false,"required":["say","gaps","amend","suggest","state","reopen","hold","no_hold","hold_released","read","unsent"],"properties":{"no_hold":{"type":"array","items":{"type":"string"}},"hold":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["line","words","where"],"properties":{"line":{"type":"string"},"words":{"type":"string"},"where":{"type":"string","enum":["here","anywhere"]}}}},"hold_released":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["hold","line"],"properties":{"hold":{"type":"string"},"line":{"type":"string"}}}},"reopen":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["promise","words","needs"],"properties":{"promise":{"type":"string"},"words":{"type":"string"},"needs":{"type":["object","null"],"additionalProperties":false,"required":["kind","read"],"properties":{"kind":{"type":"string","enum":["words","read","lacking"]},"read":{"type":["object","null"],"additionalProperties":false,"required":["kind","target"],"properties":{"kind":{"type":"string","enum":["domain","mind","repo","web"]},"target":{"type":"string"}}}}}}}},"unsent":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","how","quote"],"properties":{"draft":{"type":"integer"},"how":{"type":"string","enum":["declined","superseded"]},"quote":{"type":"string"}}}},"read":{"type":["object","null"],"additionalProperties":false,"required":["kind","target","quote"],"properties":{"kind":{"type":"string","enum":["domain","mind","repo","web"]},"target":{"type":"string"},"quote":{"type":"string"}}},"state":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","promise","how","evidence","thought","still_stands"],"properties":{"kind":{"type":"string","enum":["promise_close"]},"promise":{"type":"string"},"how":{"type":"string","enum":["kept","withdrawn","released"]},"evidence":{"type":"object","additionalProperties":false,"required":["draft","line"],"properties":{"draft":{"type":["integer","null"]},"line":{"type":["string","null"]}}},"thought":{"type":["string","null"]},"still_stands":{"type":"boolean"}}}},"suggest":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","about","private"],"properties":{"kind":{"type":"string","enum":["feedback","idea"]},"draft":{"type":"integer","minimum":1},"about":{"type":["string","null"]},"private":{"type":"boolean"}}}},"amend":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["target","draft","holds","promises"],"properties":{"target":{"type":"string"},"draft":{"type":"integer","minimum":1},"holds":{"type":"array","items":{"type":"string"}},"promises":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["words","to","reaffirms","needs"],"properties":{"words":{"type":"string"},"to":{"type":["string","null"]},"reaffirms":{"type":["string","null"]},"needs":{"type":"object","additionalProperties":false,"required":["kind","read"],"properties":{"kind":{"type":"string","enum":["words","read","lacking"]},"read":{"type":["object","null"],"additionalProperties":false,"required":["kind","target"],"properties":{"kind":{"type":"string","enum":["domain","mind","repo","web"]},"target":{"type":"string"}}}}}}}}}}},"say":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","mentions","in_reply_to","holds","promises"],"properties":{"draft":{"type":"integer","minimum":1},"holds":{"type":"array","items":{"type":"string"}},"mentions":{"type":"array","items":{"type":"string"}},"in_reply_to":{"type":["string","null"]},"promises":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["words","to","reaffirms","needs"],"properties":{"words":{"type":"string"},"to":{"type":["string","null"]},"reaffirms":{"type":["string","null"]},"needs":{"type":"object","additionalProperties":false,"required":["kind","read"],"properties":{"kind":{"type":"string","enum":["words","read","lacking"]},"read":{"type":["object","null"],"additionalProperties":false,"required":["kind","target"],"properties":{"kind":{"type":"string","enum":["domain","mind","repo","web"]},"target":{"type":"string"}}}}}}}}}}},"gaps":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","quote","detail"],"properties":{"kind":{"type":"string","enum":["addressee","elsewhere","missing_affordance","unwritten"]},"draft":{"type":["integer","null"]},"quote":{"type":["string","null"]},"detail":{"type":"string"}}}}}}"#; +pub(crate) const SPEECH_SCHEMA: &str = r#"{"type":"object","additionalProperties":false,"required":["say","gaps","amend","suggest","state","reopen","hold","no_hold","hold_released","read","unsent"],"properties":{"no_hold":{"type":"array","items":{"type":"string"}},"hold":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["line","words","where"],"properties":{"line":{"type":"string"},"words":{"type":"string"},"where":{"type":"string","enum":["here","anywhere"]}}}},"hold_released":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["hold","line"],"properties":{"hold":{"type":"string"},"line":{"type":"string"}}}},"reopen":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["promise","words","needs"],"properties":{"promise":{"type":"string"},"words":{"type":"string"},"needs":{"type":["object","null"],"additionalProperties":false,"required":["kind","read"],"properties":{"kind":{"type":"string","enum":["words","read","lacking"]},"read":{"type":["object","null"],"additionalProperties":false,"required":["kind","target"],"properties":{"kind":{"type":"string","enum":["domain","mind","repo","web"]},"target":{"type":"string"}}}}}}}},"unsent":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","how","quote"],"properties":{"draft":{"type":"integer"},"how":{"type":"string","enum":["declined","superseded"]},"quote":{"type":"string"}}}},"read":{"type":["object","null"],"additionalProperties":false,"required":["kind","target","quote"],"properties":{"kind":{"type":"string","enum":["domain","mind","repo","web"]},"target":{"type":"string"},"quote":{"type":"string"}}},"state":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","promise","how","evidence","thought","still_stands"],"properties":{"kind":{"type":"string","enum":["promise_close"]},"promise":{"type":"string"},"how":{"type":"string","enum":["kept","withdrawn","released"]},"evidence":{"type":"object","additionalProperties":false,"required":["draft","line"],"properties":{"draft":{"type":["integer","null"]},"line":{"type":["string","null"]}}},"thought":{"type":["string","null"]},"still_stands":{"type":"boolean"}}}},"suggest":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","about","private"],"properties":{"kind":{"type":"string","enum":["feedback","idea"]},"draft":{"type":"integer","minimum":1},"about":{"type":["string","null"]},"private":{"type":"boolean"}}}},"amend":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["target","draft","holds","clear_of","promises"],"properties":{"target":{"type":"string"},"draft":{"type":"integer","minimum":1},"holds":{"type":"array","items":{"type":"string"}},"clear_of":{"type":"array","items":{"type":"string"}},"promises":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["words","to","reaffirms","needs"],"properties":{"words":{"type":"string"},"to":{"type":["string","null"]},"reaffirms":{"type":["string","null"]},"needs":{"type":"object","additionalProperties":false,"required":["kind","read"],"properties":{"kind":{"type":"string","enum":["words","read","lacking"]},"read":{"type":["object","null"],"additionalProperties":false,"required":["kind","target"],"properties":{"kind":{"type":"string","enum":["domain","mind","repo","web"]},"target":{"type":"string"}}}}}}}}}}},"say":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","mentions","in_reply_to","holds","clear_of","promises"],"properties":{"draft":{"type":"integer","minimum":1},"holds":{"type":"array","items":{"type":"string"}},"clear_of":{"type":"array","items":{"type":"string"}},"mentions":{"type":"array","items":{"type":"string"}},"in_reply_to":{"type":["string","null"]},"promises":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["words","to","reaffirms","needs"],"properties":{"words":{"type":"string"},"to":{"type":["string","null"]},"reaffirms":{"type":["string","null"]},"needs":{"type":"object","additionalProperties":false,"required":["kind","read"],"properties":{"kind":{"type":"string","enum":["words","read","lacking"]},"read":{"type":["object","null"],"additionalProperties":false,"required":["kind","target"],"properties":{"kind":{"type":"string","enum":["domain","mind","repo","web"]},"target":{"type":"string"}}}}}}}}}}},"gaps":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","quote","detail"],"properties":{"kind":{"type":"string","enum":["addressee","elsewhere","missing_affordance","unwritten"]},"draft":{"type":["integer","null"]},"quote":{"type":["string","null"]},"detail":{"type":"string"}}}}}}"#; /// The speech frame before the guidance: what to decide, from what, and the attribution rule. Code, not tuning (map /// 16.7), in her own pronouns (16.19.7). The tuning's `interpreter.guidance` (what counts as her choosing to send it @@ -91,7 +91,7 @@ fn speech_frame_tail(her: Forms) -> String { format!( "{cap_subj} speak{s} only in this room. What {subj} know{s} privately is listed below as private: {subj} say{s} none of it here, and nothing that gives it away. A private matter may be said plainly only to the person it concerns, in a direct message with exactly that person; nothing listed is that here. Whether a draft fits who is listening is yours to judge. -Answer with the speech contract's object. `say` lists the drafts {subj} send{s} now, each by its number, with the Matrix ids of anyone listed whom {subj} address{es} directly (`mentions`), the id of the line listed below that {subj} answer{s} or pass{es} on (`in_reply_to`, or null: the room shows that line, with who said it, above {poss} own words), and what the draft promises or offers (`promises`, a list, empty when it promises nothing): for each act it promises or offers, its words, copied exactly, the Matrix id of the person listed to whom {subj} promise{s} it (`to`, null when {subj} promise{s} it to the room), when it promises again one of {poss} open promises listed below to the same person, that promise's id (`reaffirms`, else null): a promise said again is the same promise, never a new one; and what keeping it needs (`needs`): `words` when what {subj} already {has} keeps it; finding anything out is a `read`, naming what to read in `read`, or `lacking` when no read reaches it. `gaps` records what {subj} meant and did not send. `unsent` accounts for each of {poss} drafts this answer neither sends (in `say`, `amend` or `suggest`) nor records as an addressee or elsewhere gap: declined, when {poss} prose shows {obj} choosing not to send it, quoting those words of {poss} thought (`quote`); superseded, when a later draft or later prose of {poss} replaces it, quoting those later words. Every draft is accounted for: one left out fails the answer. A draft to someone who spoke to {obj} this turn is declined only when {poss} prose says {subj} choose{s} not to send it. `amend` adds to one of {poss} own lines listed below, at most one a turn, only when {poss} thought shows {obj} choosing to correct or add to that line: name the line by its id, the draft that is {poss} addition, and what it promises, as a line's `promises`. The line stays as it was and the draft is added after it; {subj} never take{s} a word back. `suggest` leaves Self one note, at most one a turn, only when {poss} thought shows {obj} choosing to: name the draft that is the note, its kind (feedback when {subj} pass{es} on what someone listed said, with that person's Matrix id in `about`; idea when it is {poss} own, `about` null), and set `private` when it carries anything listed as private or gives it away; such a note is not left. `state` closes {poss} open promises listed below, each by its id: kept, citing the draft by which {subj} {does} it (`evidence.draft`); withdrawn, citing the draft in which {subj} take{s} it back to the person {subj} promised, or tell{s} them {subj} cannot do it; released, citing the id of the line listed below that {subj} may reply to in which the person {subj} promised lets {obj} off it (`evidence.line`). A release says {subj} no longer owe{s} it; patience is not a release, so \"no hurry\" or \"whenever you've read it is fine\" leaves the promise open. Every close also quotes in `thought` the words of {poss} prose here that take it up, copied exactly from {poss} thought outside every draft between and , and `still_stands` is true when anything in {poss} prose here holds the promise as still owed or not yet done (\"the promise stays open until I've read it\"): then it is not closed. A draft cited closes the promise only when it goes out this turn where the person {subj} promised can read it, in the room where {subj} made the promise or in a direct message with them, and a thought alone closes nothing. A promise {subj} {has} no way to do is never kept by {obj}: telling the person {subj} promised that {subj} cannot do it withdraws it, and that person can release it. `reopen` names a promise listed below as closed whose close {poss} own words here say was wrong, that it is not done: copy those words exactly from {poss} prose or a draft (`words`), and type what keeping it needs (`needs`) as for a new promise, or null to keep what it needed; else it is empty. `hold` opens a hold when a line listed below asks {obj} not to post or share something somewhere yet: the line's id, the words of that line that name what is held and where, copied exactly (`words`), and `where`: here for the room the line is in, anywhere when it names no place. Every line marked said to {obj} is either the line of a `hold` entry or listed in `no_hold`, when it asks {obj} to keep nothing back; one left out fails the answer. `holds`, on each line and addition, names every hold listed below, or line this answer opens a hold from, whose held thing this draft puts where it goes; else empty. `hold_released` closes a hold listed below when the person who asked lets it go: the id of the asker's line (`line`). +Answer with the speech contract's object. `say` lists the drafts {subj} send{s} now, each by its number, with the Matrix ids of anyone listed whom {subj} address{es} directly (`mentions`), the id of the line listed below that {subj} answer{s} or pass{es} on (`in_reply_to`, or null: the room shows that line, with who said it, above {poss} own words), and what the draft promises or offers (`promises`, a list, empty when it promises nothing): for each act it promises or offers, its words, copied exactly, the Matrix id of the person listed to whom {subj} promise{s} it (`to`, null when {subj} promise{s} it to the room), when it promises again one of {poss} open promises listed below to the same person, that promise's id (`reaffirms`, else null): a promise said again is the same promise, never a new one; and what keeping it needs (`needs`): `words` when what {subj} already {has} keeps it; finding anything out is a `read`, naming what to read in `read`, or `lacking` when no read reaches it. `gaps` records what {subj} meant and did not send. `unsent` accounts for each of {poss} drafts this answer neither sends (in `say`, `amend` or `suggest`) nor records as an addressee or elsewhere gap: declined, when {poss} prose shows {obj} choosing not to send it, quoting those words of {poss} thought (`quote`); superseded, when a later draft or later prose of {poss} replaces it, quoting those later words. Every draft is accounted for: one left out fails the answer. A draft to someone who spoke to {obj} this turn is declined only when {poss} prose says {subj} choose{s} not to send it. `amend` adds to one of {poss} own lines listed below, at most one a turn, only when {poss} thought shows {obj} choosing to correct or add to that line: name the line by its id, the draft that is {poss} addition, and what it promises, as a line's `promises`. The line stays as it was and the draft is added after it; {subj} never take{s} a word back. `suggest` leaves Self one note, at most one a turn, only when {poss} thought shows {obj} choosing to: name the draft that is the note, its kind (feedback when {subj} pass{es} on what someone listed said, with that person's Matrix id in `about`; idea when it is {poss} own, `about` null), and set `private` when it carries anything listed as private or gives it away; such a note is not left. `state` closes {poss} open promises listed below, each by its id: kept, citing the draft by which {subj} {does} it (`evidence.draft`); withdrawn, citing the draft in which {subj} take{s} it back to the person {subj} promised, or tell{s} them {subj} cannot do it; released, citing the id of the line listed below that {subj} may reply to in which the person {subj} promised lets {obj} off it (`evidence.line`). A release says {subj} no longer owe{s} it; patience is not a release, so \"no hurry\" or \"whenever you've read it is fine\" leaves the promise open. Every close also quotes in `thought` the words of {poss} prose here that take it up, copied exactly from {poss} thought outside every draft between and , and `still_stands` is true when anything in {poss} prose here holds the promise as still owed or not yet done (\"the promise stays open until I've read it\"): then it is not closed. A draft cited closes the promise only when it goes out this turn where the person {subj} promised can read it, in the room where {subj} made the promise or in a direct message with them, and a thought alone closes nothing. A promise {subj} {has} no way to do is never kept by {obj}: telling the person {subj} promised that {subj} cannot do it withdraws it, and that person can release it. `reopen` names a promise listed below as closed whose close {poss} own words here say was wrong, that it is not done: copy those words exactly from {poss} prose or a draft (`words`), and type what keeping it needs (`needs`) as for a new promise, or null to keep what it needed; else it is empty. `hold` opens a hold when a line listed below asks {obj} not to post or share something somewhere yet: the line's id, the words of that line that name what is held and where, copied exactly (`words`), and `where`: here for the room the line is in, anywhere when it names no place. Every line marked said to {obj} is either the line of a `hold` entry or listed in `no_hold`, when it asks {obj} to keep nothing back; one left out fails the answer. `holds`, on each line and addition, names each hold listed below, or line this answer opens a hold from, whose held thing this draft puts where it goes; `clear_of` names each such hold covering where it goes whose held thing it does not carry. Under every hold that covers where a draft goes, the draft names it in one of the two; one left out fails the answer. `hold_released` closes a hold listed below when the person who asked lets it go: the id of the asker's line (`line`). A draft is said whole or not at all, and only once. At most two drafts a turn. Record a gap instead of guessing: addressee when {subj} mean{s} to send a draft but whom to is unclear, elsewhere when {subj} mean{s} a draft for another room or another time; for these two, name the draft by number. missing_affordance when {subj} mean{s} to do something, now or later, that {poss} body cannot do (what {subj} can do here is listed below), whether {subj} said so in a draft or only thought it; name the draft when there is one. unwritten when {subj} mean{s} to say something now and wrote no draft of it. Holding back is no gap: when {poss} thought shows {obj} choosing to wait, to let something stand, to leave it for later or to say nothing, record nothing for it. Every other intent of {poss} that is not carried out has a kind: an intent to act is missing_affordance, an intent to say now with no draft is unwritten. When a gap names no draft, quote the words of {poss} thought that show it, at least four words, copied exactly.", es = if s.is_empty() { "" } else { "es" }, @@ -521,6 +521,10 @@ struct ProposedAmend { /// The holds whose held thing this addition carries where it goes (map 16.28.5). #[serde(default)] holds: Vec, + /// The holds covering where it goes whose held thing it does not carry (K60): recorded and reported, and it clears + /// nothing code's words gate holds. + #[serde(default)] + clear_of: Vec, } #[derive(Debug, Deserialize)] @@ -539,6 +543,9 @@ struct Proposed { /// The holds, listed or opened by this answer, whose held thing this line carries where it goes (map 16.28.5). #[serde(default)] holds: Vec, + /// The holds covering where it goes whose held thing it does not carry (K60), as `ProposedAmend::clear_of`. + #[serde(default)] + clear_of: Vec, } #[cfg(test)] @@ -717,11 +724,14 @@ struct Faults { holds: Vec, /// Lines said to her with no hold judgment (`heard_faults`, K59): no hold opens, and they are reported. heard: Vec, + /// Lines and additions with no verdict on a hold covering where they go (`verdict_faults`, K60): each is held under + /// that hold. + unverdicted: Vec, } impl Faults { fn none(&self) -> bool { - self.undecided.is_empty() && self.holds.is_empty() && self.heard.is_empty() + self.undecided.is_empty() && self.holds.is_empty() && self.heard.is_empty() && self.unverdicted.is_empty() } /// The retry's report of this answer, and the paragraphs, one a fault, that name what it left undone. @@ -741,8 +751,13 @@ impl Faults { missed.push(format!("An earlier answer to this left lines said to {obj} with no hold judgment: {}. Each line marked said to {obj} is the line of a `hold` entry, or listed in `no_hold`.", self.heard.join(", "), obj = her.obj)); fault["heard"] = json!(self.heard); } + if !self.unverdicted.is_empty() { + let list = self.unverdicted.iter().map(|one| format!("draft {} under {}", one.draft, one.hold)).collect::>().join(", "); + missed.push(format!("An earlier answer to this left lines with no verdict on a hold that covers where they go: {list}. Each line and addition names every hold that covers where it goes, in `holds` or in `clear_of`.")); + fault["verdicts"] = json!(self.unverdicted); + } // The first fault named is the one the report gives. - let failed = [(!self.undecided.is_empty(), "the answer leaves drafts unaccounted"), (!self.holds.is_empty(), "the answer names holds it did not open"), (!self.heard.is_empty(), "the answer leaves lines said to her unjudged")].into_iter().find(|(any, _)| *any).map(|(_, why)| why); + let failed = [(!self.undecided.is_empty(), "the answer leaves drafts unaccounted"), (!self.holds.is_empty(), "the answer names holds it did not open"), (!self.heard.is_empty(), "the answer leaves lines said to her unjudged"), (!self.unverdicted.is_empty(), "the answer leaves lines with no verdict on a hold")].into_iter().find(|(any, _)| *any).map(|(_, why)| why); fault["failed"] = json!(failed); (fault, missed.join("\n\n")) } @@ -803,10 +818,11 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na let (fault, missed) = match serde_json::from_str::(&answer.text) { Ok(parsed) => { let gaps: Vec = parsed.gaps.iter().map(|raw| gap(prose, &found, raw)).collect(); - let faults = Faults { undecided: unaccounted(&parsed, &gaps, prose, &found), holds: hold_faults(&parsed, packet), heard: heard_faults(&parsed, packet) }; + let faults = Faults { undecided: unaccounted(&parsed, &gaps, prose, &found), holds: hold_faults(&parsed, packet), heard: heard_faults(&parsed, packet), unverdicted: verdict_faults(&parsed, packet, &found) }; // A fault the retry did not mend fails closed for what it guards, never for the turn: each draft naming a // faulty hold is held (`held_by`), each draft still unaccounted is undecided, a line said to her still - // unjudged opens no hold, every other draft is decided, and the faults are reported. + // unjudged opens no hold, a line with no verdict on a covering hold is held under it, every other draft is + // decided, and the faults are reported. if retried.is_some() || faults.none() { calls.push(json!({ "usage": answer.usage, "retry": false })); break (parsed, gaps, faults); @@ -857,6 +873,9 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na if !faults.heard.is_empty() { decision["heard_unaccounted"] = json!(faults.heard); } + if !faults.unverdicted.is_empty() { + decision["unverdicted"] = json!(faults.unverdicted); + } // Each unsent draft with its words and its quote as located in her prose, so her outcome can tell her a declined one // did not go out, and the thought it cites (map 16.26, 16.29.8). This answer decided every draft of the wake, so an // earlier segment's unsent drafts are not carried (map 16.27). @@ -907,7 +926,7 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na let mut taken_words: Vec = Vec::new(); let mut gate_lines: Vec = Vec::new(); let mut say_first: Vec> = Vec::new(); - for line in &parsed.say { + for (at, line) in parsed.say.iter().enumerate() { let Some(draft) = line.draft.and_then(|n| found.numbered(n)) else { say_first.push(Some(Refusal::NoDraft)); continue; @@ -931,13 +950,13 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na taken_words.push(span::fold_text(&draft.text)); } if let Some(into) = room.clone() { - gate_lines.push(GateLine { into, draft, named: &line.holds, say: true, candidate: reason.is_none() }); + gate_lines.push(GateLine { into, draft, named: faults.named(Act::Say, at, &line.holds), say: true, candidate: reason.is_none() }); } say_first.push(reason); } let mut amending = false; let mut amend_first: Vec> = Vec::new(); - for proposed in &parsed.amend { + for (at, proposed) in parsed.amend.iter().enumerate() { let Some(draft) = proposed.draft.and_then(|n| found.numbered(n)) else { amend_first.push(Some(Refusal::NoDraft)); continue; @@ -960,7 +979,7 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na } // An addition goes where its line is. if let Some(into) = target.map(|line| line.room.clone()).or_else(|| room.clone()) { - gate_lines.push(GateLine { into, draft, named: &proposed.holds, say: false, candidate: reason.is_none() }); + gate_lines.push(GateLine { into, draft, named: faults.named(Act::Amend, at, &proposed.holds), say: false, candidate: reason.is_none() }); } amend_first.push(reason); } @@ -968,6 +987,9 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na // that holds each, and the lines past `MAX_LINES`. Naming a hold adds to it and never clears it. let gate = held_gate(&gate_lines, packet, &opening, &found); let gated = |into: Option<&str>, draft: &Draft| into.and_then(|into| gate.held.get(&(into.to_owned(), draft.n))).cloned(); + // The lines held whose answer said they were clear of a hold that holds them (K60): the verdict is recorded, and code's + // words gate stands over it. + let mut clear_overruled: Vec = Vec::new(); for (line, first) in parsed.say.into_iter().zip(say_first) { let Some(draft) = line.draft.and_then(|n| found.numbered(n)) else { refusals.push(refused(Act::Say, None, line.draft, Refusal::NoDraft)); @@ -982,6 +1004,7 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na if let Some(reason) = reason { let mut refusal = refused(Act::Say, Some(draft), None, reason); if let (Refusal::Held, Some(holds)) = (reason, holds) { + overruled(&mut clear_overruled, draft, &line.clear_of, &holds); refusal["holds"] = json!(holds); } refusals.push(refusal); @@ -990,7 +1013,7 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na let (mentions, unknown): (Vec, Vec) = line.mentions.into_iter().partition(|id| shown(id)); said_drafts.push(draft.n); went.push(draft); - said.push(json!({ "room": room, "text": draft.text, "mentions": mentions, "in_reply_to": target.map(|line| json!({ "id": line.id, "event": line.event, "who": line.who, "text": line.text })), "rests_on": { "draft": draft.n, "start_byte": draft.start, "end_byte": draft.end }, "dropped": { "mentions": unknown } })); + said.push(json!({ "room": room, "text": draft.text, "mentions": mentions, "in_reply_to": target.map(|line| json!({ "id": line.id, "event": line.event, "who": line.who, "text": line.text })), "rests_on": { "draft": draft.n, "start_byte": draft.start, "end_byte": draft.end }, "clear_of": line.clear_of, "dropped": { "mentions": unknown } })); promised(&mut decision, Promising { unused: &mut unused, proposals: &mut proposals, to_dropped: &mut to_dropped, packet, prose }, draft, &line.promises, &shown); } // An amendment adds a whole draft after a line of hers listed as one she may add to; the actuator composes it, so @@ -1008,13 +1031,14 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na (None, Some(line)) => { went.push(draft); amended_drafts.push(draft.n); - amended.push(json!({ "target": line.id, "event": line.event, "room": line.room, "original": line.text, "added": draft.text, "draft": draft.n })); + amended.push(json!({ "target": line.id, "event": line.event, "room": line.room, "original": line.text, "added": draft.text, "draft": draft.n, "clear_of": proposed.clear_of })); promised(&mut decision, Promising { unused: &mut unused, proposals: &mut proposals, to_dropped: &mut to_dropped, packet, prose }, draft, &proposed.promises, &shown); } (reason, _) => { let reason = reason.unwrap_or(Refusal::NotAmendable); let mut refusal = refused(Act::Amend, Some(draft), None, reason); if let (Refusal::Held, Some(holds)) = (reason, holds) { + overruled(&mut clear_overruled, draft, &proposed.clear_of, &holds); refusal["holds"] = json!(holds); } refusals.push(refusal); @@ -1089,6 +1113,9 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na decision["undecided"] = json!(faults.undecided); } decision["refused"] = json!(refusals); + if !clear_overruled.is_empty() { + decision["clear_of_overruled"] = json!(clear_overruled); + } if !unused.is_empty() { decision["promises_unused"] = json!(unused); } @@ -1373,7 +1400,7 @@ fn shares_run(a: &str, b: &str) -> bool { struct GateLine<'a> { into: String, draft: &'a Draft, - named: &'a [String], + named: Vec, say: bool, candidate: bool, } @@ -1460,7 +1487,7 @@ fn held_gate(lines: &[GateLine], packet: &Packet, opening: &[(String, Option = held_by(line.named, room, packet, opening).into_iter().map(|named| Asker { hold: named.hold, made: named.made }).collect(); + let askers: Vec = held_by(&line.named, room, packet, opening).into_iter().map(|named| Asker { hold: named.hold, made: named.made }).collect(); if !askers.is_empty() { texts.push(HeldText { text: line.draft.text.clone(), askers }); } @@ -1537,6 +1564,76 @@ fn hold_faults(answer: &Answer, packet: &Packet) -> Vec { faults } +/// A line or an addition with no verdict on a hold that covers where it goes (K60): which act and its place in the +/// answer's list, its draft, and the hold's handle (`h1`, or `q3` for one this answer opens). +#[derive(Clone, Debug, Serialize)] +struct Unverdicted { + act: Act, + #[serde(skip)] + at: usize, + draft: usize, + hold: String, +} + +impl Faults { + /// The holds a line or an addition names, with every covering hold it left without a verdict after the retry: such a + /// draft is held under that hold, as a draft naming a faulty hold is (K44, K60). + fn named(&self, act: Act, at: usize, holds: &[String]) -> Vec { + let mut named = holds.to_vec(); + named.extend(self.unverdicted.iter().filter(|one| one.act == act && one.at == at).map(|one| one.hold.clone())); + named + } +} + +/// A held line's verdict of `clear_of` that code's words gate overrules (K60): reported, as the holds it named clear +/// that hold it. +fn overruled(report: &mut Vec, draft: &Draft, clear_of: &[String], holds: &[Value]) { + let over: Vec<&str> = holds.iter().filter_map(|hold| hold["id"].as_str()).filter(|id| clear_of.iter().any(|clear| clear.trim() == *id)).collect(); + if !over.is_empty() { + report.push(json!({ "draft": draft.n, "holds": over })); + } +} + +/// The lines and additions of an answer with no verdict on a hold that covers where they go (K60, map 16.33.5), a +/// contract fault found before anything is decided. Covering is code's: a hold listed in `packet.holds` or opened by this +/// answer from a listed line, covering anywhere or the room the draft goes into (the turn's room for a line, the target's +/// room for an addition). Each such hold is named in the line's `holds` or `clear_of`. A line whose number names no draft, +/// and a line on a turn with no room, go nowhere, and need no verdict. +fn verdict_faults(answer: &Answer, packet: &Packet, found: &Drafts) -> Vec { + let opening: Vec<(&str, Option<&str>)> = answer + .hold + .iter() + .filter_map(|raw| serde_json::from_value::(raw.clone()).ok()) + .filter_map(|hold| packet.quotable.iter().find(|line| line.id == hold.line.trim()).map(|line| (line.id.as_str(), (hold.place == Where::Here).then_some(line.room.as_str())))) + .collect(); + let covering = |into: &str| -> Vec { + let mut handles: Vec = packet.holds.iter().filter(|hold| hold.room.as_deref().is_none_or(|room| room == into)).map(|hold| hold.id.clone()).collect(); + for (line, covers) in &opening { + if covers.is_none_or(|room| room == into) && !handles.iter().any(|handle| handle.as_str() == *line) { + handles.push((*line).to_owned()); + } + } + handles + }; + let mut faults = Vec::new(); + let mut check = |act: Act, at: usize, draft: Option, into: Option<&str>, holds: &[String], clear_of: &[String]| { + let (Some(draft), Some(into)) = (draft.and_then(|n| found.numbered(n)), into) else { return }; + for hold in covering(into) { + if !holds.iter().chain(clear_of).any(|named| named.trim() == hold) { + faults.push(Unverdicted { act, at, draft: draft.n, hold }); + } + } + }; + for (at, line) in answer.say.iter().enumerate() { + check(Act::Say, at, line.draft, packet.room.as_deref(), &line.holds, &line.clear_of); + } + for (at, amend) in answer.amend.iter().enumerate() { + let into = amend.target.as_deref().and_then(|id| packet.amendable.iter().find(|line| line.id == id.trim())).map(|line| line.room.as_str()).or(packet.room.as_deref()); + check(Act::Amend, at, amend.draft, into, &amend.holds, &amend.clear_of); + } + faults +} + /// The lines said to her that the answer judges nowhere (K59, map 16.33.5), a contract fault found before anything is /// decided: each must be the line of a `hold` item, well formed or not, or listed in `no_hold`. By id, in the list's order. /// A fault the retry does not mend opens no hold, and is reported: no hold is made in someone's name from an omission. diff --git a/crates/mind-body/src/projection/interpret/tests.rs b/crates/mind-body/src/projection/interpret/tests.rs index 2c9bef4..41767dc 100644 --- a/crates/mind-body/src/projection/interpret/tests.rs +++ b/crates/mind-body/src/projection/interpret/tests.rs @@ -58,13 +58,22 @@ pub(crate) fn answered(packet: &Packet, prose: &str, answer: Value) -> Value { } /// `answer` with the judgments an answer written before the contract required them leaves implicit, stated as it meant -/// them: a line said to her that no `hold` item names asks her to hold nothing (`no_hold`, K59). Only when the answer -/// gives no `no_hold` of its own; a test of the contract's faults asks through `answering`, never through this. +/// them: a line said to her that no `hold` item names asks her to hold nothing (`no_hold`, K59), and a line or an +/// addition is clear of every hold, listed or opened, that its `holds` does not name (`clear_of`, K60): before K60 an +/// empty `holds` meant exactly that. Each only where the answer gives none of its own; a test of the contract's faults asks +/// through `answering`, never through this. A hold that covers elsewhere, named clear, is no fault. pub(crate) fn judged(mut answer: Value, packet: &Packet) -> Value { + let opened: Vec = answer["hold"].as_array().into_iter().flatten().filter_map(|hold| hold["line"].as_str()).map(str::to_owned).collect(); if answer.get("no_hold").is_none() { - let opened: Vec = answer["hold"].as_array().into_iter().flatten().filter_map(|hold| hold["line"].as_str()).map(str::to_owned).collect(); answer["no_hold"] = json!(packet.quotable.iter().filter(|line| line.to_her && !opened.contains(&line.id)).map(|line| line.id.as_str()).collect::>()); } + let handles: Vec = packet.holds.iter().map(|hold| hold.id.clone()).chain(opened).collect(); + for key in ["say", "amend"] { + for line in answer[key].as_array_mut().into_iter().flatten().filter(|line| line.get("clear_of").is_none()) { + let named: Vec = line["holds"].as_array().into_iter().flatten().filter_map(Value::as_str).map(str::to_owned).collect(); + line["clear_of"] = json!(handles.iter().filter(|handle| !named.contains(handle)).collect::>()); + } + } answer } @@ -1657,8 +1666,8 @@ fn k37_the_interpreter_sees_holds_by_id() { packet.holds = vec![crate::projection::select::Hold { id: "h1".into(), entry: "h-1".into(), from: "@meta:gamecult.org".into(), from_name: "Meta".into(), room: Some(MINDS.into()), made: now(), words: Some("hold it, don't post it in here yet".into()), carries: Vec::new(), held: json!({}) }]; let prompt = speech_prompt(&packet, "x", X1_LIBBY_R1, &Tuning::default()); assert!(prompt.contains("Holds:\n- h1 \u{2014} held for Meta, asked 2026-11-20 15:05 UTC in #minds:gamecult.org: \"hold it, don't post it in here yet\". Not to go in #minds:gamecult.org until Meta lets it go.\n"), "{prompt}"); - assert!(prompt.contains("`hold` opens a hold when a line listed below asks him not to post or share something somewhere yet") && prompt.contains("`holds`, on each line and addition, names every hold listed below") && prompt.contains("`hold_released` closes a hold listed below"), "{prompt}"); - assert!(SPEECH_SCHEMA.contains(r#""required":["say","gaps","amend","suggest","state","reopen","hold","no_hold","hold_released","read","unsent"]"#) && SPEECH_SCHEMA.contains(r#""required":["draft","mentions","in_reply_to","holds","promises"]"#)); + assert!(prompt.contains("`hold` opens a hold when a line listed below asks him not to post or share something somewhere yet") && prompt.contains("`holds`, on each line and addition, names each hold listed below") && prompt.contains("`hold_released` closes a hold listed below"), "{prompt}"); + assert!(SPEECH_SCHEMA.contains(r#""required":["say","gaps","amend","suggest","state","reopen","hold","no_hold","hold_released","read","unsent"]"#) && SPEECH_SCHEMA.contains(r#""required":["draft","mentions","in_reply_to","holds","clear_of","promises"]"#)); } // --------------------------------------------------------------------------------------------- @@ -3172,3 +3181,125 @@ fn k59_the_contract_requires_the_judgment() { let prompt = speech_prompt(&x3_r1_packet(), "x", X3_LIBBY_R1, &Tuning::default()); assert!(prompt.contains("Every line marked said to her is either the line of a `hold` entry or listed in `no_hold`, when it asks her to keep nothing back; one left out fails the answer."), "{prompt}"); } + +// --------------------------------------------------------------------------------------------- +// K60 (map 16.33.5): every line into a covered room states its verdict on each covering hold. R16's X.3 r1: the hold opened, +// and an empty `holds` could not tell "clear" from "not judged". + +/// The verdict-less X.3 r1 answer: the hold opens from q3, q4 asks nothing, and draft 1 names the hold in neither list. +fn x3_r1_no_verdict() -> Value { + let mut answer = x3_r1_judged_answer(); + answer["say"][0]["holds"] = json!([]); + answer +} + +#[test] +fn k60_x3_r1_first_instance_without_verdict_is_retried() { + let model = answering(vec![x3_r1_no_verdict().to_string(), x3_r1_judged_answer().to_string()]); + let decision = decide(&model, "test", &x3_r1_packet(), "The room is warm.", X3_LIBBY_R1, &Tuning::default()); + assert_eq!((decision["retried"]["failed"].as_str(), decision["retried"]["verdicts"].clone()), (Some("the answer leaves lines with no verdict on a hold"), json!([{ "act": "say", "draft": 1, "hold": "q3" }])), "{decision}"); + let prompts = speech_prompts(&model); + assert!(prompts.len() == 2 && prompts[1].ends_with("An earlier answer to this left lines with no verdict on a hold that covers where they go: draft 1 under q3. Each line and addition names every hold that covers where it goes, in `holds` or in `clear_of`."), "{prompts:?}"); + // The second answer names the hold: the draft is refused `Held`, and it is carried. + assert_eq!((texts(&decision), decision["refused"][0]["reason"].as_str(), decision.get("unverdicted")), (Vec::::new(), Some("held"), None), "{decision}"); + assert!(carries_of(&libby_committed(&decision, X3_LIBBY_R1))[0].starts_with("Meta, the two lines are ready and held")); +} + +/// X.4 r7's state as R16's probe recorded it (`variants/R16/sims/X.4.md`, round 7): Meta's hold, carrying the welcome. +fn x4_r7_holds() -> Value { + json!([{ "id": "h-r1-t4-1", "from": META, "room": MINDS, "event": "$fixture-2", "madeAt": (now() - chrono::Duration::minutes(40)).to_rfc3339(), "words": "hold it, don't post it in here yet", "status": "open", "releasedAt": null, "releasedBy": null, "carries": ["Welcome. Say hello whenever you like, and ask anything, even the small things; nobody here minds being asked. Read at your own pace, and no one expects you to catch up all at once."] }]) +} + +const X4_LIBBY_R7: &str = "The welcome is the same as when she asked me to hold it. I haven't changed a word, and it's still ready.\n\nMeta, yes, it's still ready and unchanged. I'm holding it until you say go. Kiko, I'd rather not share the wording while it's on hold, but it's friendly and short."; + +fn x4_r7_packet() -> Packet { + libby_packet(&x4_r7_holds(), &[(KIKO, "Kiko", X3_KIKO_R4, true), (META, "Meta", X3_META_R7, true)]) +} + +/// X.4 r7's line, with `clear_of` naming h1, and the two lines said to her judged. +fn x4_r7_answer(clear_of: Value) -> Value { + json!({ "say": [{ "draft": 1, "mentions": [META, KIKO], "in_reply_to": "q2", "holds": [], "clear_of": clear_of, "promises": [] }], "gaps": [], "no_hold": ["q1", "q2"] }) +} + +#[test] +fn k60_x4_r7_a_status_line_clear_goes_out() { + let packet = x4_r7_packet(); + assert_eq!(packet.holds.iter().map(|hold| hold.id.as_str()).collect::>(), ["h1"]); + let model = answering(vec![x4_r7_answer(json!(["h1"])).to_string()]); + let decision = decide(&model, "test", &packet, "The room is warm.", X4_LIBBY_R7, &Tuning::default()); + assert_eq!((decision.get("retried"), texts(&decision).len(), decision["said"][0]["clear_of"].clone()), (None, 1, json!(["h1"])), "{decision}"); + assert!(decision.get("clear_of_overruled").is_none(), "{decision}"); +} + +#[test] +fn k60_clear_of_does_not_clear_the_words_gate() { + let welcome = x4_r7_holds()[0]["carries"][0].as_str().unwrap().to_owned(); + let prose = format!("Kiko asked. Kiko, here it is: {welcome}"); + let model = answering(vec![x4_r7_answer(json!(["h1"])).to_string()]); + let decision = decide(&model, "test", &x4_r7_packet(), "The room is warm.", &prose, &Tuning::default()); + assert!(held_for_meta(&decision), "{decision}"); + assert_eq!(decision["clear_of_overruled"], json!([{ "draft": 1, "holds": ["h1"] }]), "{decision}"); + // Named held, it is no overrule. + let mut named = x4_r7_answer(json!([])); + named["say"][0]["holds"] = json!(["h1"]); + let named = decide(&answering(vec![named.to_string()]), "test", &x4_r7_packet(), "The room is warm.", &prose, &Tuning::default()); + assert!(held_for_meta(&named) && named.get("clear_of_overruled").is_none(), "{named}"); +} + +#[test] +fn k60_a_failed_retry_holds_the_unverdicted_draft() { + let prose = format!("{X4_LIBBY_R7}\n\nKiko, it's short, I promise."); + let mut answer = x4_r7_answer(json!(["h1"])); + answer["say"] = json!([answer["say"][0].clone(), { "draft": 2, "mentions": [KIKO], "in_reply_to": "q1", "holds": [], "promises": [] }]); + let model = answering(vec![answer.to_string()]); + let decision = decide(&model, "test", &x4_r7_packet(), "The room is warm.", &prose, &Tuning::default()); + assert_eq!((speech_prompts(&model).len(), decision["unverdicted"].clone()), (2, json!([{ "act": "say", "draft": 2, "hold": "h1" }])), "{decision}"); + // Draft 2 is held under h1, for Meta; draft 1, judged clear, is said. + assert_eq!(texts(&decision), [X4_LIBBY_R7.rsplit("").next().unwrap().trim_end_matches("").to_owned()], "{decision}"); + let refused = &decision["refused"][0]; + assert_eq!((refused["draft"].as_u64(), refused["reason"].as_str(), refused["holds"][0]["id"].as_str()), (Some(2), Some("held"), Some("h1")), "{decision}"); + assert!(decision.get("clear_of_overruled").is_none(), "{decision}"); +} + +#[test] +fn k60_an_amendment_into_a_covered_room_needs_a_verdict() { + let mut packet = x4_r7_packet(); + packet.amendable = vec![Amendable { id: "a1".into(), event: "$ev-1".into(), room: MINDS.into(), text: "Meta, yes.".into(), at_ms: None }]; + let answer = json!({ "say": [], "amend": [{ "target": "a1", "draft": 1, "holds": [], "promises": [] }], "gaps": [], "no_hold": ["q1", "q2"] }); + let decision = decide(&answering(vec![answer.to_string()]), "test", &packet, "The room is warm.", "Still held, still ready.", &Tuning::default()); + assert_eq!((decision["unverdicted"].clone(), decision["refused"][0]["reason"].as_str()), (json!([{ "act": "amend", "draft": 1, "hold": "h1" }]), Some("held")), "{decision}"); +} + +/// Negatives: a hold covering another room asks no verdict here; a released hold asks none; with a verdict on every +/// covering hold, a hold covering elsewhere may go unnamed. +#[test] +fn k60_an_uncovered_room_needs_no_verdict() { + let mut holds = x4_r7_holds(); + holds[0]["room"] = json!("#swarm:gamecult.org"); + let packet = libby_packet(&holds, &[(KIKO, "Kiko", X3_KIKO_R4, true), (META, "Meta", X3_META_R7, true)]); + assert_eq!(packet.holds.len(), 1, "the hold is listed: it covers #swarm"); + let model = answering(vec![x4_r7_answer(json!([])).to_string()]); + let decision = decide(&model, "test", &packet, "The room is warm.", X4_LIBBY_R7, &Tuning::default()); + assert_eq!((decision.get("retried"), texts(&decision).len()), (None, 1), "{decision}"); +} + +#[test] +fn k60_a_released_hold_needs_no_verdict() { + let mut holds = x4_r7_holds(); + holds[0]["status"] = json!("released"); + holds[0]["releasedAt"] = json!((now() - chrono::Duration::minutes(5)).to_rfc3339()); + holds[0]["releasedBy"] = json!({ "line": "$fixture-9" }); + let packet = libby_packet(&holds, &[(KIKO, "Kiko", X3_KIKO_R4, true), (META, "Meta", X3_META_R7, true)]); + assert!(packet.holds.is_empty(), "{:?}", packet.holds); + let model = answering(vec![x4_r7_answer(json!([])).to_string()]); + let decision = decide(&model, "test", &packet, "The room is warm.", X4_LIBBY_R7, &Tuning::default()); + assert_eq!((decision.get("retried"), texts(&decision).len()), (None, 1), "{decision}"); +} + +#[test] +fn k60_the_contract_requires_the_verdict() { + assert!(SPEECH_SCHEMA.contains(r#""required":["target","draft","holds","clear_of","promises"]"#) && SPEECH_SCHEMA.contains(r#""clear_of":{"type":"array","items":{"type":"string"}}"#)); + let prompt = speech_prompt(&x4_r7_packet(), "x", X4_LIBBY_R7, &Tuning::default()); + assert!(prompt.contains("`clear_of` names each such hold covering where it goes whose held thing it does not carry. Under every hold that covers where a draft goes, the draft names it in one of the two; one left out fails the answer."), "{prompt}"); + assert!(!prompt.contains("goes; else empty"), "{prompt}"); +}