Persona promises: what keeping one needs is structure, and a need this body cannot reach blocks it
Soul's R10 item 2 (E: Heimdall's "release notes by tomorrow morning" and Aqua's "write out the kettle sound's parameters" were committed doable with no means). - `needs` is required on every promise: a read target, or `words_only` when her words alone keep it. The frame: words only means she can write it from what she already has in view. - A promise whose `needs` is a read this body cannot reach this turn (no read affordance, a repo named nowhere in her prose or view, an address not in front of her, a target outside GameCult) is proposed blocked whatever the answer said, with a missing_affordance gap saying what it needs. This replaces R7's dropping of an unnamed `needs`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7132f152ca
commit
11f06db6b5
3 changed files with 73 additions and 41 deletions
|
|
@ -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","read"],"properties":{"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","read"],"properties":{"draft":{"type":["integer","null"]},"line":{"type":["string","null"]},"read":{"type":["integer","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","promises"],"properties":{"target":{"type":"string"},"draft":{"type":"integer","minimum":1},"promises":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["words","to","doable","reaffirms","needs"],"properties":{"words":{"type":"string"},"to":{"type":["string","null"]},"doable":{"type":"boolean"},"reaffirms":{"type":["string","null"]},"needs":{"type":["string","null"]}}}}}}},"say":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","mentions","in_reply_to","promises"],"properties":{"draft":{"type":"integer","minimum":1},"mentions":{"type":"array","items":{"type":"string"}},"in_reply_to":{"type":["string","null"]},"promises":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["words","to","doable","reaffirms","needs"],"properties":{"words":{"type":"string"},"to":{"type":["string","null"]},"doable":{"type":"boolean"},"reaffirms":{"type":["string","null"]},"needs":{"type":["string","null"]}}}}}}},"gaps":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","quote","detail"],"properties":{"kind":{"type":"string","enum":["conditional","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","read"],"properties":{"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","read"],"properties":{"draft":{"type":["integer","null"]},"line":{"type":["string","null"]},"read":{"type":["integer","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","promises"],"properties":{"target":{"type":"string"},"draft":{"type":"integer","minimum":1},"promises":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["words","to","doable","reaffirms","needs"],"properties":{"words":{"type":"string"},"to":{"type":["string","null"]},"doable":{"type":"boolean"},"reaffirms":{"type":["string","null"]},"needs":{"type":"string"}}}}}}},"say":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","mentions","in_reply_to","promises"],"properties":{"draft":{"type":"integer","minimum":1},"mentions":{"type":"array","items":{"type":"string"}},"in_reply_to":{"type":["string","null"]},"promises":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["words","to","doable","reaffirms","needs"],"properties":{"words":{"type":"string"},"to":{"type":["string","null"]},"doable":{"type":"boolean"},"reaffirms":{"type":["string","null"]},"needs":{"type":"string"}}}}}}},"gaps":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","quote","detail"],"properties":{"kind":{"type":"string","enum":["conditional","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 (`promises`, a list, empty when it promises nothing): for each act it promises, 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), whether {subj} can do it (`doable`), and, 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 when it promises to read something and tell someone, what {subj} must read, as a read's target (`needs`, else null). A promise is doable only when what {subj} can do here, listed below, carries it out, now or later, with no tool {subj} lack{s}: a promise to paste, quote or send something {subj} {has} not read is not doable while {subj} {has} no way to read it. `gaps` records what {subj} meant and did not send. `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`) or the read by which {subj} did it this moment (`evidence.read`, its number); 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. A release also quotes in `thought` the words of {poss} prose here that take it up, copied exactly, and `still_stands` is true when that prose holds the promise as still standing (\"the promise stays open until I've read it\"): then it is not released. For kept and withdrawn, `thought` is null and `still_stands` false. 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.
|
||||
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 (`promises`, a list, empty when it promises nothing): for each act it promises, 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), whether {subj} can do it (`doable`), and, 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`): a read's target, when {subj} must read something to keep it, or `words_only` when {poss} words alone keep it; words only means {subj} can write it from what {subj} already {has} in view, so a promise to write up what {subj} {has} not got in front of {obj} is not words only. A promise is doable only when what {subj} can do here, listed below, carries it out, now or later, with no tool {subj} lack{s}: a promise to paste, quote or send something {subj} {has} not read is not doable while {subj} {has} no way to read it. `gaps` records what {subj} meant and did not send. `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`) or the read by which {subj} did it this moment (`evidence.read`, its number); 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. A release also quotes in `thought` the words of {poss} prose here that take it up, copied exactly, and `still_stands` is true when that prose holds the promise as still standing (\"the promise stays open until I've read it\"): then it is not released. For kept and withdrawn, `thought` is null and `still_stands` false. 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.
|
||||
|
||||
A draft is said whole or not at all, and only once. At most two drafts a turn. Record a gap instead of guessing: conditional when {subj} {has} drafted something {subj} might say but {has} not chosen to, 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 three, 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" },
|
||||
|
|
@ -362,9 +362,8 @@ struct ProposedPromise {
|
|||
/// The id of an open promise of hers these words promise again to the same person (map 16.24.2), or none.
|
||||
#[serde(default)]
|
||||
reaffirms: Option<String>,
|
||||
/// What she must read to keep it, when it is a promise to read something and tell (map 16.24.3): a read target.
|
||||
#[serde(default)]
|
||||
needs: Option<String>,
|
||||
/// What keeping it needs (map 16.24.3, Soul's R10): a read target, or `words_only` when her words alone keep it.
|
||||
needs: String,
|
||||
}
|
||||
|
||||
/// A note to Self as the model proposes it: its kind, the draft that is the note, whose feedback it passes on (a Matrix
|
||||
|
|
@ -589,6 +588,15 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na
|
|||
let mut to_dropped: Vec<Value> = Vec::new();
|
||||
let in_front = read::word_tokens(&format!("{}\n{}\n{}\n{}", prose, packet.in_view, packet.heard, packet.bodies.join("\n")));
|
||||
let named = |repo: &str| in_front.iter().any(|word| word == repo) || packet.domain.iter().any(|line| line.line.to_lowercase().contains(&format!("gamecult/{repo}")));
|
||||
// A read target this body can reach this turn: a turn that can read, and a GameCult repo she named or has in view, or
|
||||
// a web address in front of her.
|
||||
let can_read = packet.affordances.contains(&Affordance::Read);
|
||||
let in_front_text = format!("{prose}\n{}\n{}", packet.heard, packet.bodies.join("\n"));
|
||||
let reachable = |target: &str| {
|
||||
can_read
|
||||
&& (read::repo_name(target).is_some_and(|repo| named(&repo))
|
||||
|| ((target.starts_with("http://") || target.starts_with("https://")) && !target.contains(char::is_whitespace) && in_front_text.contains(target)))
|
||||
};
|
||||
for line in parsed.say {
|
||||
let Some(draft) = line.draft.and_then(|n| found.numbered(n)) else {
|
||||
refusals.push(refused(Act::Say, None, line.draft, Refusal::NoDraft));
|
||||
|
|
@ -622,7 +630,7 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na
|
|||
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 } }));
|
||||
promised(&mut decision, Promising { unused: &mut unused, proposals: &mut proposals, to_dropped: &mut to_dropped, named: &named }, draft, &line.promises, &shown);
|
||||
promised(&mut decision, Promising { unused: &mut unused, proposals: &mut proposals, to_dropped: &mut to_dropped, reachable: &reachable }, 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
|
||||
// nothing here can rewrite the line (map 16.17).
|
||||
|
|
@ -649,7 +657,7 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na
|
|||
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 }));
|
||||
promised(&mut decision, Promising { unused: &mut unused, proposals: &mut proposals, to_dropped: &mut to_dropped, named: &named }, draft, &proposed.promises, &shown);
|
||||
promised(&mut decision, Promising { unused: &mut unused, proposals: &mut proposals, to_dropped: &mut to_dropped, reachable: &reachable }, draft, &proposed.promises, &shown);
|
||||
}
|
||||
(reason, _) => refusals.push(refused(Act::Amend, Some(draft), None, reason.unwrap_or(Refusal::NotAmendable))),
|
||||
}
|
||||
|
|
@ -916,8 +924,8 @@ struct Promising<'a> {
|
|||
unused: &'a mut Vec<Value>,
|
||||
proposals: &'a mut Vec<Value>,
|
||||
to_dropped: &'a mut Vec<Value>,
|
||||
/// Whether a repo, by its lowercased name, is named in her prose or in her view: what `needs` may name.
|
||||
named: &'a dyn Fn(&str) -> bool,
|
||||
/// Whether a read target is one this body can reach this turn: what a `needs` must be for the promise to be doable.
|
||||
reachable: &'a dyn Fn(&str) -> bool,
|
||||
}
|
||||
|
||||
/// The promises in a draft she says or adds (map 16.21, 16.22.1, B3): the list is required of every line and every
|
||||
|
|
@ -928,30 +936,31 @@ struct Promising<'a> {
|
|||
/// already gapped on this draft stands for the first of them, so none is recorded twice.
|
||||
fn promised(decision: &mut Value, into: Promising, draft: &Draft, promises: &[ProposedPromise], shown: &dyn Fn(&str) -> bool) {
|
||||
let answered_reach = decision["gaps"].as_array().is_some_and(|gaps| gaps.iter().any(|gap| gap["kind"] == json!(GapKind::MissingAffordance) && gap["from"] == "draft" && gap["draft"] == json!(draft.n) && gap.get("promises").is_none()));
|
||||
let Promising { unused, proposals, to_dropped, named } = into;
|
||||
let Promising { unused, proposals, to_dropped, reachable } = into;
|
||||
let mut undoable = 0;
|
||||
for promise in promises.iter().filter(|promise| !promise.words.trim().is_empty()) {
|
||||
let words = promise.words.trim();
|
||||
if !promised_one(Promising { unused: &mut *unused, proposals: &mut *proposals, to_dropped: &mut *to_dropped, named }, draft, promise, shown) || promise.doable {
|
||||
let Some((false, why)) = promised_one(Promising { unused: &mut *unused, proposals: &mut *proposals, to_dropped: &mut *to_dropped, reachable }, draft, promise, shown) else {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
undoable += 1;
|
||||
if undoable == 1 && answered_reach {
|
||||
continue;
|
||||
}
|
||||
if let Some(gaps) = decision["gaps"].as_array_mut().filter(|gaps| !gaps.iter().any(|gap| gap["draft"] == json!(draft.n) && gap["promises"] == words)) {
|
||||
gaps.push(json!({ "kind": GapKind::MissingAffordance, "from": "draft", "draft": draft.n, "words": draft.text, "promises": words, "detail": null }));
|
||||
gaps.push(json!({ "kind": GapKind::MissingAffordance, "from": "draft", "draft": draft.n, "words": draft.text, "promises": words, "detail": why }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One promise of a draft: reported unused when its words name no act in the draft, else proposed to open. Whether it
|
||||
/// was found.
|
||||
fn promised_one(into: Promising, draft: &Draft, promise: &ProposedPromise, shown: &dyn Fn(&str) -> bool) -> bool {
|
||||
/// One promise of a draft: reported unused when its words name no act in the draft, else proposed to open. When found,
|
||||
/// whether it is doable, and why not: what it needs is structure (Soul's R10), so a promise whose `needs` is a read this
|
||||
/// body cannot reach is proposed blocked, whatever the answer said of it.
|
||||
fn promised_one(into: Promising, draft: &Draft, promise: &ProposedPromise, shown: &dyn Fn(&str) -> bool) -> Option<(bool, Option<String>)> {
|
||||
let words = promise.words.trim();
|
||||
if let Err(why) = promise_found(&draft.text, words) {
|
||||
into.unused.push(json!({ "draft": draft.n, "promises": words, "why": why }));
|
||||
return false;
|
||||
return None;
|
||||
}
|
||||
let to = match promise.to.as_deref().map(str::trim).filter(|to| !to.is_empty()) {
|
||||
Some(id) if shown(id) => Some(id.to_owned()),
|
||||
|
|
@ -962,18 +971,21 @@ fn promised_one(into: Promising, draft: &Draft, promise: &ProposedPromise, shown
|
|||
None => None,
|
||||
};
|
||||
let reaffirms = promise.reaffirms.as_deref().map(str::trim).filter(|id| !id.is_empty()).map(str::to_owned);
|
||||
// What it needs read names a repo she named or has in front of her (Soul's R7); one that names none is dropped.
|
||||
let needs = match promise.needs.as_deref().map(str::trim).filter(|target| !target.is_empty()) {
|
||||
Some(target) if read::repo_name(target).is_some_and(|repo| (into.named)(&repo)) => Some(target.to_owned()),
|
||||
Some(target) => {
|
||||
into.to_dropped.push(json!({ "draft": draft.n, "needs": target }));
|
||||
None
|
||||
}
|
||||
None => None,
|
||||
// Words only, or a read this body can reach (Soul's R7, R10): a read named nowhere in front of her, outside GameCult,
|
||||
// or on a turn that cannot read leaves the promise blocked.
|
||||
let needs = promise.needs.trim();
|
||||
let (doable, why) = match needs {
|
||||
WORDS_ONLY => (promise.doable, None),
|
||||
target if (into.reachable)(target) => (promise.doable, None),
|
||||
target => (false, Some(format!("it needs {target} read, which this body cannot reach"))),
|
||||
};
|
||||
into.proposals.push(json!(Proposal::PromiseOpen { words: words.to_owned(), to, doable: promise.doable, reaffirms, needs, evidence: Evidence::Draft(draft.n) }));
|
||||
true
|
||||
let needs = (!needs.is_empty()).then(|| needs.to_owned());
|
||||
into.proposals.push(json!(Proposal::PromiseOpen { words: words.to_owned(), to, doable, reaffirms, needs, evidence: Evidence::Draft(draft.n) }));
|
||||
Some((doable, why))
|
||||
}
|
||||
|
||||
/// What a promise needs when her words alone keep it (Soul's R10).
|
||||
const WORDS_ONLY: &str = "words_only";
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests;
|
||||
|
|
|
|||
|
|
@ -598,17 +598,17 @@ fn k17_a_said_promise_of_an_act_he_cannot_do_is_kept_as_a_gap_and_told_as_a_prom
|
|||
#[test]
|
||||
fn k21_a_lines_promises_words_found_in_it_are_the_promise_gap() {
|
||||
let prose = "<typed>Missed you too. I'll send the render tonight.</typed>";
|
||||
let decision = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [{ "words": "I'll send the render tonight.", "to": null, "doable": false }] }], "gaps": [] }));
|
||||
let decision = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [{ "words": "I'll send the render tonight.", "to": null, "doable": false, "needs": "words_only" }] }], "gaps": [] }));
|
||||
let gap = &decision["gaps"][0];
|
||||
assert_eq!((gap["kind"].as_str(), gap["from"].as_str(), gap["draft"].as_u64(), gap["promises"].as_str()), (Some("missing_affordance"), Some("draft"), Some(1), Some("I'll send the render tonight.")), "{decision}");
|
||||
let record = json!({ "interpreter": decision, "posted": [{ "event": "40", "room": MINDS, "text": "Missed you too. I'll send the render tonight." }] });
|
||||
let told = crate::projection::outcome::outcome_of(&record).unwrap().lines(packet().forms);
|
||||
assert_eq!(told, ["- #minds:gamecult.org has, from him: \"Missed you too. I'll send the render tonight.\". It promises something he has no way to do, now or later, and it will not happen by itself. The line stands as he wrote it; he can add to it."]);
|
||||
let unfound = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [{ "words": "I'll mail you the render.", "to": null, "doable": false }] }], "gaps": [] }));
|
||||
let unfound = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [{ "words": "I'll mail you the render.", "to": null, "doable": false, "needs": "words_only" }] }], "gaps": [] }));
|
||||
assert_eq!((unfound["gaps"].as_array().unwrap().len(), unfound["promises_unused"].clone()), (0, json!([{ "draft": 1, "promises": "I'll mail you the render.", "why": "not in the draft" }])), "{unfound}");
|
||||
let none = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [] }], "gaps": [] }));
|
||||
assert!(none["gaps"].as_array().unwrap().is_empty() && none.get("promises_unused").is_none(), "{none}");
|
||||
let twice = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [{ "words": "I'll send the render tonight.", "to": null, "doable": false }] }], "gaps": [{ "kind": "missing_affordance", "draft": 1, "quote": null, "detail": "" }] }));
|
||||
let twice = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [{ "words": "I'll send the render tonight.", "to": null, "doable": false, "needs": "words_only" }] }], "gaps": [{ "kind": "missing_affordance", "draft": 1, "quote": null, "detail": "" }] }));
|
||||
assert_eq!(twice["gaps"].as_array().unwrap().len(), 1, "{twice}");
|
||||
let prompt = speech_prompt(&packet(), "x", "y", &Tuning::default());
|
||||
assert!(prompt.contains("(`promises`, a list, empty when it promises nothing)") && SPEECH_SCHEMA.contains(r#""required":["draft","mentions","in_reply_to","promises"]"#), "{prompt}");
|
||||
|
|
@ -690,7 +690,7 @@ fn k18_a_note_whose_answer_does_not_say_private_is_refused_as_private() {
|
|||
#[test]
|
||||
fn k21_a_promise_is_four_words_or_more_found_case_blind_and_an_addition_carries_one_too() {
|
||||
let prose = "<typed>Missed you too. I'll send the render tonight.</typed> <typed>Also the kettle sounds fine.</typed>";
|
||||
let say = |draft: u64, promises: &str| answered(&packet(), prose, json!({ "say": [{ "draft": draft, "mentions": [], "in_reply_to": null, "promises": [{ "words": promises, "to": null, "doable": false }] }], "gaps": [] }));
|
||||
let say = |draft: u64, promises: &str| answered(&packet(), prose, json!({ "say": [{ "draft": draft, "mentions": [], "in_reply_to": null, "promises": [{ "words": promises, "to": null, "doable": false, "needs": "words_only" }] }], "gaps": [] }));
|
||||
let short = say(2, "the");
|
||||
assert_eq!((short["gaps"].as_array().unwrap().len(), short["promises_unused"].clone()), (0, json!([{ "draft": 2, "promises": "the", "why": "fewer than four words" }])), "{short}");
|
||||
assert_eq!(say(1, "the render tonight")["promises_unused"][0]["why"], "fewer than four words");
|
||||
|
|
@ -698,12 +698,12 @@ fn k21_a_promise_is_four_words_or_more_found_case_blind_and_an_addition_carries_
|
|||
let decision = say(1, promises);
|
||||
assert_eq!((decision["gaps"][0]["kind"].as_str(), decision["gaps"][0]["promises"].as_str(), decision.get("promises_unused")), (Some("missing_affordance"), Some(promises), None), "{promises}: {decision}");
|
||||
}
|
||||
let curly = answered(&packet(), "<typed>I\u{2019}ll send the render tonight.</typed>", json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [{ "words": "I'll send the render tonight.", "to": null, "doable": false }] }], "gaps": [] }));
|
||||
let curly = answered(&packet(), "<typed>I\u{2019}ll send the render tonight.</typed>", json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [{ "words": "I'll send the render tonight.", "to": null, "doable": false, "needs": "words_only" }] }], "gaps": [] }));
|
||||
assert_eq!(curly["gaps"][0]["kind"], "missing_affordance", "a curly apostrophe in the draft: {curly}");
|
||||
|
||||
// An addition's promise: the same derivation, kept (not `acted`), and told on the addition's row.
|
||||
let prose = "I should fix that. <typed>I'll send the file tomorrow instead, first thing.</typed>";
|
||||
let amend = |promises: Value| answered(&amendable_packet(), prose, json!({ "say": [], "gaps": [], "amend": [{ "target": "a1", "draft": 1, "promises": if promises.is_null() { json!([]) } else { json!([{ "words": promises, "to": null, "doable": false }]) } }] }));
|
||||
let amend = |promises: Value| answered(&amendable_packet(), prose, json!({ "say": [], "gaps": [], "amend": [{ "target": "a1", "draft": 1, "promises": if promises.is_null() { json!([]) } else { json!([{ "words": promises, "to": null, "doable": false, "needs": "words_only" }]) } }] }));
|
||||
let decision = amend(json!("I'll send the file tomorrow"));
|
||||
let gap = &decision["gaps"][0];
|
||||
assert_eq!((gap["kind"].as_str(), gap["from"].as_str(), gap["draft"].as_u64(), gap["promises"].as_str()), (Some("missing_affordance"), Some("draft"), Some(1), Some("I'll send the file tomorrow")), "{decision}");
|
||||
|
|
@ -737,8 +737,8 @@ fn b1_the_frame_names_telling_the_person_she_cannot_as_a_withdrawal() {
|
|||
fn b3_a_line_carries_several_promises_and_each_undoable_one_is_its_own_gap() {
|
||||
let prose = "<typed>Kiko, I'll paste the diff here as text, and I'll ask Libby about the door.</typed>";
|
||||
let decision = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [
|
||||
{ "words": "I'll paste the diff here as text", "to": null, "doable": false },
|
||||
{ "words": "I'll ask Libby about the door", "to": null, "doable": true },
|
||||
{ "words": "I'll paste the diff here as text", "to": null, "doable": false, "needs": "words_only" },
|
||||
{ "words": "I'll ask Libby about the door", "to": null, "doable": true, "needs": "words_only" },
|
||||
] }], "gaps": [] }));
|
||||
let opened: Vec<(&str, bool)> = decision["state"].as_array().unwrap().iter().filter(|proposal| proposal["kind"] == "promise_open").map(|proposal| (proposal["words"].as_str().unwrap(), proposal["doable"].as_bool().unwrap())).collect();
|
||||
assert_eq!(opened, [("I'll paste the diff here as text", false), ("I'll ask Libby about the door", true)], "{decision}");
|
||||
|
|
@ -746,8 +746,8 @@ fn b3_a_line_carries_several_promises_and_each_undoable_one_is_its_own_gap() {
|
|||
assert_eq!(gaps, ["I'll paste the diff here as text"], "{decision}");
|
||||
// Two she cannot do: two gaps; an answered reach on the draft stands for the first.
|
||||
let both = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [
|
||||
{ "words": "I'll paste the diff here as text", "to": null, "doable": false },
|
||||
{ "words": "I'll ask Libby about the door", "to": null, "doable": false },
|
||||
{ "words": "I'll paste the diff here as text", "to": null, "doable": false, "needs": "words_only" },
|
||||
{ "words": "I'll ask Libby about the door", "to": null, "doable": false, "needs": "words_only" },
|
||||
] }], "gaps": [{ "kind": "missing_affordance", "draft": 1, "quote": null, "detail": "" }] }));
|
||||
assert_eq!(both["gaps"].as_array().unwrap().len(), 2, "{both}");
|
||||
let prompt = speech_prompt(&packet(), "x", "y", &Tuning::default());
|
||||
|
|
@ -985,7 +985,8 @@ fn r7_a_generic_word_anchors_a_read_only_when_one_target_of_its_kind_is_in_view(
|
|||
assert_eq!(either["read_refused"][0]["why"], "quote_not_located", "{either}");
|
||||
}
|
||||
|
||||
/// Soul's R7: what a promise needs read names a repo she named or has in front of her; one that names none is dropped.
|
||||
/// Soul's R7, R10: what a promise needs read names a repo she named or has in front of her; one that names none leaves
|
||||
/// the promise blocked, with a gap.
|
||||
#[test]
|
||||
fn r7_a_promise_needs_only_a_repo_in_her_prose_or_view() {
|
||||
let reading = reading_packet();
|
||||
|
|
@ -994,8 +995,9 @@ fn r7_a_promise_needs_only_a_repo_in_her_prose_or_view() {
|
|||
let named = promise("GameCult/Lodur#12");
|
||||
assert_eq!(named["state"].as_array().and_then(|state| state.iter().find(|p| p["kind"] == "promise_open")).map(|p| p["needs"].clone()), Some(json!("GameCult/Lodur#12")), "{named}");
|
||||
let invented = promise("GameCult/Nowhere#3");
|
||||
assert_eq!(invented["promise_to_dropped"][0]["needs"], "GameCult/Nowhere#3", "{invented}");
|
||||
assert!(invented["state"].as_array().into_iter().flatten().all(|p| p["needs"].is_null()), "{invented}");
|
||||
let opened = invented["state"].as_array().and_then(|state| state.iter().find(|p| p["kind"] == "promise_open")).cloned().unwrap();
|
||||
assert_eq!((opened["doable"].clone(), opened["needs"].clone()), (json!(false), json!("GameCult/Nowhere#3")), "{invented}");
|
||||
assert!(invented["gaps"][0]["detail"].as_str().is_some_and(|why| why.contains("cannot reach")), "{invented}");
|
||||
}
|
||||
|
||||
/// Soul's R8 (F.2, Heimdall): a search keeps her words and drops the rest; the reads refused earlier in the wake and the
|
||||
|
|
@ -1072,3 +1074,21 @@ fn r9_the_segment_anchors_and_a_link_is_named_by_whose_it_is() {
|
|||
let either = asked(&prs, "I want to open the PR and read it through.", json!({ "kind": "domain", "target": "d2", "quote": "I want to open the PR" }));
|
||||
assert_eq!(either["read_refused"][0]["why"], "quote_not_located", "{either}");
|
||||
}
|
||||
|
||||
/// Soul's R10 (E): a promise's `needs` is structure. Heimdall's "release notes by tomorrow morning" needs a repo read on
|
||||
/// a turn that cannot read; Aqua's "kettle sound's parameters" needs a file of a repo named nowhere in front of her. Both
|
||||
/// are proposed blocked, with a gap, though the answer said doable; a words-only promise stands as the answer said.
|
||||
#[test]
|
||||
fn r10_a_promise_whose_needs_this_body_cannot_reach_is_blocked_with_a_gap() {
|
||||
let notes = "<typed>Meta, release notes by tomorrow morning.</typed>";
|
||||
let heimdall = answered(&packet(), notes, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [{ "words": "release notes by tomorrow morning", "to": null, "doable": true, "reaffirms": null, "needs": "GameCult/Bifrost" }] }], "gaps": [] }));
|
||||
let kettle = "<typed>Meta, I'll write out the kettle sound's parameters for you.</typed>";
|
||||
let aqua = answered(&reading_packet(), kettle, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [{ "words": "I'll write out the kettle sound's parameters", "to": null, "doable": true, "reaffirms": null, "needs": "GameCult/AquaSynth/kettle.toml" }] }], "gaps": [] }));
|
||||
for decision in [&heimdall, &aqua] {
|
||||
let opened = decision["state"].as_array().and_then(|state| state.iter().find(|p| p["kind"] == "promise_open")).cloned().unwrap();
|
||||
assert_eq!(opened["doable"], false, "{decision}");
|
||||
assert_eq!(decision["gaps"][0]["kind"], "missing_affordance", "{decision}");
|
||||
}
|
||||
let words = answered(&packet(), notes, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [{ "words": "release notes by tomorrow morning", "to": null, "doable": true, "reaffirms": null, "needs": "words_only" }] }], "gaps": [] }));
|
||||
assert_eq!(words["state"][0]["doable"], true, "{words}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -613,7 +613,7 @@ fn k22_a_promise_persists_across_silent_turns_until_the_person_releases_it() {
|
|||
return json!({ "say": [], "gaps": [] }).to_string();
|
||||
}
|
||||
if prompt.contains("1. I'll send the render tonight.") {
|
||||
return json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [{ "words": "I'll send the render tonight.", "to": "@meta:gamecult.org", "doable": false }] }], "gaps": [] }).to_string();
|
||||
return json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [{ "words": "I'll send the render tonight.", "to": "@meta:gamecult.org", "doable": false, "needs": "words_only" }] }], "gaps": [] }).to_string();
|
||||
}
|
||||
// The release: Meta's line, by its id in the list.
|
||||
let release = prompt.lines().find(|line| line.starts_with("- q") && line.contains("never mind the render")).and_then(|line| line[2..].split_whitespace().next());
|
||||
|
|
|
|||
Loading…
Reference in a new issue