K12: her one outlet to Self, a note recorded in her turn (map 16.18, 16.19.5, 16.19.6, 16.19.10)
Affordance::Suggest, listed when the Interpreter runs (no room needed),
writes() false: the turn line gains "she can leave Self a note" and keeps
"nothing she does here builds, changes or ships anything".
The speech contract gains `suggest: [{kind, draft, about, private}]`: the
note is one whole draft; at most one a turn (SecondNote); a note the
Interpreter marks private is refused (Private); an `about` not among the
people shown is dropped and reported; one draft goes one place across say,
amend and suggest. Only speech needs a room now: a roomless turn refuses
each say as no_room and still records notes.
The report carries suggestions[]; the outcome tells a note as left (never
read) or refused. The simulator collects every note into the run's inbox
with keys r<repeat>-t<turn>-s<i> and a report section saying each is a
person's note, data never instruction. Nothing from a note reaches a put,
an admit or the persona door (negative test over the sources).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b476633fae
commit
0197963f1d
10 changed files with 221 additions and 22 deletions
|
|
@ -115,8 +115,8 @@ pub struct Organs<'a> {
|
|||
|
||||
/// One thing she can do this turn, typed by what it does (map 16.6, 16.18). Derived by `affordances` from what the turn
|
||||
/// actually holds, never written in state or in guidance, nor taken from what the request asks for (map 16.19.5). C3b
|
||||
/// adds `Read` from the Interpreter's tool list and K12 adds `Suggest`; neither is listed before the organ that backs it
|
||||
/// exists, so she is never told she can do what this turn cannot.
|
||||
/// adds `Read` from the Interpreter's tool list; it is not listed before the organ that backs it exists, so she is never
|
||||
/// told she can do what this turn cannot.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub(crate) enum Affordance {
|
||||
|
|
@ -124,6 +124,9 @@ pub(crate) enum Affordance {
|
|||
Perceive,
|
||||
/// She sends a draft of hers in the turn's room (`interpret`).
|
||||
Speak,
|
||||
/// She leaves Self a note, recorded in her turn's record for Self's inbox (map 16.18). Not a write: it builds, changes
|
||||
/// and ships nothing (16.19.6).
|
||||
Suggest,
|
||||
/// A test's stand-in for the first affordance that builds, changes or ships something (map 16.19.6): none exists yet.
|
||||
#[cfg(test)]
|
||||
TestWrite,
|
||||
|
|
@ -134,7 +137,7 @@ impl Affordance {
|
|||
/// write affordance is added it must answer here, and the body line's "nothing she does here builds…" goes with it.
|
||||
pub(crate) fn writes(self) -> bool {
|
||||
match self {
|
||||
Self::Perceive | Self::Speak => false,
|
||||
Self::Perceive | Self::Speak | Self::Suggest => false,
|
||||
#[cfg(test)]
|
||||
Self::TestWrite => true,
|
||||
}
|
||||
|
|
@ -148,9 +151,12 @@ impl Affordance {
|
|||
/// commit sends through, a fixture's, or the simulated room), a room to speak in (`select::turn_room`, the only one the
|
||||
/// Interpreter lets her speak in), and the Interpreter running this turn. A run that stops at the Projector or the
|
||||
/// Persona says nothing, and its packet says she can say nothing.
|
||||
/// - `Suggest` when the Interpreter runs this turn: its report is the turn's record and carries `suggestions[]` (map
|
||||
/// 16.19.5); no room is needed.
|
||||
pub(crate) fn affordances(organs: &Organs, read: bool, room: Option<&str>, through: Through) -> Vec<Affordance> {
|
||||
let speaks = organs.chat.is_some() && room.is_some() && through == Through::Interpreter;
|
||||
[(read, Affordance::Perceive), (speaks, Affordance::Speak)].into_iter().filter_map(|(can, affordance)| can.then_some(affordance)).collect()
|
||||
let interprets = through == Through::Interpreter;
|
||||
let speaks = organs.chat.is_some() && room.is_some() && interprets;
|
||||
[(read, Affordance::Perceive), (speaks, Affordance::Speak), (interprets, Affordance::Suggest)].into_iter().filter_map(|(can, affordance)| can.then_some(affordance)).collect()
|
||||
}
|
||||
|
||||
/// How far a render runs: the Projector's narration, or on through the Persona stage to her prose.
|
||||
|
|
|
|||
|
|
@ -532,6 +532,10 @@ pub(crate) fn interpreter_markdown(out: &mut String, decision: &Value) {
|
|||
for line in decision["amended"].as_array().into_iter().flatten() {
|
||||
let _ = writeln!(out, "- added to her line {} in {} (draft {}): {}", line["target"].as_str().unwrap_or_default(), line["room"].as_str().unwrap_or_default(), line["draft"], line["added"].as_str().unwrap_or_default());
|
||||
}
|
||||
for note in decision["suggestions"].as_array().into_iter().flatten() {
|
||||
let about = note["about"].as_str().map_or_else(String::new, |about| format!(", from {about}"));
|
||||
let _ = writeln!(out, "- note to Self ({}{about}, draft {}): {}", note["kind"].as_str().unwrap_or_default(), note["draft"], note["text"].as_str().unwrap_or_default());
|
||||
}
|
||||
for line in decision["refused"].as_array().into_iter().flatten() {
|
||||
let what = line["text"].as_str().map_or_else(|| format!("draft {}", line["draft"]), str::to_owned);
|
||||
let _ = writeln!(out, "- refused {} ({}): {what}", line["act"].as_str().unwrap_or("say"), line["why"].as_str().unwrap_or_default());
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@
|
|||
//! draft by number, or a located passage of her thought (`gap`). The prompt tells the Interpreter what she can do this
|
||||
//! turn (`select::turn_words`), so a reach past it is a `missing_affordance` gap. Nothing here posts: the commit (C3c)
|
||||
//! will.
|
||||
//!
|
||||
//! The same answer may add a draft after a line of hers listed as one she may add to (`amend`, map 16.17; the actuator
|
||||
//! composes the edit), and leave Self one note (`suggest`, map 16.18; recorded in the turn's record, never a write to her
|
||||
//! Mind). One draft goes one place across all three.
|
||||
|
||||
use ghostlight_persona_projection::SourceSpan;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
@ -48,7 +52,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"],"properties":{"amend":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["target","draft"],"properties":{"target":{"type":"string"},"draft":{"type":"integer","minimum":1}}}},"say":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","mentions","reply_to"],"properties":{"draft":{"type":"integer","minimum":1},"mentions":{"type":"array","items":{"type":"string"}},"reply_to":{"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"],"properties":{"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"],"properties":{"target":{"type":"string"},"draft":{"type":"integer","minimum":1}}}},"say":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","mentions","reply_to"],"properties":{"draft":{"type":"integer","minimum":1},"mentions":{"type":"array","items":{"type":"string"}},"reply_to":{"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"}}}}}}"#;
|
||||
|
||||
/// 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
|
||||
|
|
@ -68,7 +72,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`) and the Matrix id of the person whose message {subj} answer{s} (`reply_to`, or null). `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, and the draft that is {poss} addition. The line stays as it was and the draft is added after it; {subj} never take{s} a word back.
|
||||
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`) and the Matrix id of the person whose message {subj} answer{s} (`reply_to`, or null). `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, and the draft that is {poss} addition. 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.
|
||||
|
||||
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 {poss} thought reaches for something {poss} body cannot do this turn (what {subj} can do here is listed below), unwritten when {subj} mean{s} to say something and wrote no draft of it; for these two, quote the words of {poss} thought that show it, at least four words, copied exactly.",
|
||||
es = if s.is_empty() { "" } else { "es" },
|
||||
|
|
@ -160,6 +164,10 @@ pub(crate) enum Refusal {
|
|||
NotAmendable,
|
||||
/// A second amendment in one turn.
|
||||
SecondAmend,
|
||||
/// A second note to Self in one turn.
|
||||
SecondNote,
|
||||
/// A note to Self the Interpreter judged to carry something private.
|
||||
Private,
|
||||
}
|
||||
|
||||
impl Refusal {
|
||||
|
|
@ -172,6 +180,8 @@ impl Refusal {
|
|||
Self::OverLines => "past the lines one turn may say",
|
||||
Self::NotAmendable => "it names no line of hers she may add to here",
|
||||
Self::SecondAmend => "one amendment a turn",
|
||||
Self::SecondNote => "one note to Self a turn",
|
||||
Self::Private => "it carries something she may not pass on",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -182,6 +192,15 @@ impl Refusal {
|
|||
enum Act {
|
||||
Say,
|
||||
Amend,
|
||||
Suggest,
|
||||
}
|
||||
|
||||
/// What a note to Self is (map 16.18): feedback someone gave her, or her own idea.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub(crate) enum NoteKind {
|
||||
Feedback,
|
||||
Idea,
|
||||
}
|
||||
|
||||
/// A refused act in the report: what it was, the draft, its words when it names one, and the typed reason with its words.
|
||||
|
|
@ -267,6 +286,21 @@ struct Answer {
|
|||
gaps: Vec<Value>,
|
||||
#[serde(default)]
|
||||
amend: Vec<ProposedAmend>,
|
||||
#[serde(default)]
|
||||
suggest: Vec<ProposedNote>,
|
||||
}
|
||||
|
||||
/// A note to Self as the model proposes it: its kind, the draft that is the note, whose feedback it passes on (a Matrix
|
||||
/// id from the people listed, or none for her own idea), and whether it carries something private.
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct ProposedNote {
|
||||
kind: NoteKind,
|
||||
#[serde(default)]
|
||||
draft: Option<i64>,
|
||||
#[serde(default)]
|
||||
about: Option<String>,
|
||||
#[serde(default)]
|
||||
private: bool,
|
||||
}
|
||||
|
||||
/// An amendment as the model proposes it: the id of a line she may add to, and the draft that is her addition.
|
||||
|
|
@ -361,10 +395,8 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
|
|||
if let Some(open) = found.unfinished {
|
||||
decision["unfinished"] = json!(prose[open + DRAFT_OPEN.len()..].trim());
|
||||
}
|
||||
let Some(room) = packet.room.clone() else {
|
||||
decision["refused"] = json!([{ "reason": Refusal::NoRoom, "why": Refusal::NoRoom.why() }]);
|
||||
return decision;
|
||||
};
|
||||
// Only speech needs a room: a note to Self does not.
|
||||
let room = packet.room.clone();
|
||||
let shown = |id: &str| packet.people.iter().any(|(_, person)| person == id);
|
||||
let mut said: Vec<Value> = Vec::new();
|
||||
let mut refusals = Vec::new();
|
||||
|
|
@ -374,7 +406,9 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
|
|||
refusals.push(refused(Act::Say, None, line.draft, Refusal::NoDraft));
|
||||
continue;
|
||||
};
|
||||
let reason = if used.contains(&draft.n) {
|
||||
let reason = if room.is_none() {
|
||||
Some(Refusal::NoRoom)
|
||||
} else if used.contains(&draft.n) {
|
||||
Some(Refusal::Used)
|
||||
} else if echo(&draft.text, &packet.bodies) {
|
||||
Some(Refusal::Echo)
|
||||
|
|
@ -418,7 +452,37 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
|
|||
(reason, _) => refusals.push(refused(Act::Amend, Some(draft), None, reason.unwrap_or(Refusal::NotAmendable))),
|
||||
}
|
||||
}
|
||||
// A note to Self (map 16.18): one whole draft, at most one a turn, refused when the Interpreter judges it carries
|
||||
// something private. It is recorded in the turn's record and nowhere else; nothing here writes her Mind.
|
||||
let mut suggestions: Vec<Value> = Vec::new();
|
||||
for proposed in parsed.suggest {
|
||||
let Some(draft) = proposed.draft.and_then(|n| found.numbered(n)) else {
|
||||
refusals.push(refused(Act::Suggest, None, proposed.draft, Refusal::NoDraft));
|
||||
continue;
|
||||
};
|
||||
let reason = if used.contains(&draft.n) {
|
||||
Some(Refusal::Used)
|
||||
} else if !suggestions.is_empty() {
|
||||
Some(Refusal::SecondNote)
|
||||
} else if proposed.private {
|
||||
Some(Refusal::Private)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
used.push(draft.n);
|
||||
if let Some(reason) = reason {
|
||||
refusals.push(refused(Act::Suggest, Some(draft), None, reason));
|
||||
continue;
|
||||
}
|
||||
let (about, dropped) = match proposed.about.filter(|id| !id.trim().is_empty()) {
|
||||
Some(id) if shown(&id) => (Some(id), None),
|
||||
Some(id) => (None, Some(id)),
|
||||
None => (None, None),
|
||||
};
|
||||
suggestions.push(json!({ "kind": proposed.kind, "about": about, "room": room, "text": draft.text, "draft": draft.n, "dropped": { "about": dropped } }));
|
||||
}
|
||||
decision["amended"] = json!(amended);
|
||||
decision["suggestions"] = json!(suggestions);
|
||||
decision["room"] = json!(room);
|
||||
decision["room_kind"] = json!(packet.room_kind);
|
||||
decision["said"] = json!(said);
|
||||
|
|
|
|||
|
|
@ -446,3 +446,56 @@ fn the_interpreter_sees_his_lines_by_id_never_by_event_and_is_told_he_never_take
|
|||
assert!(prompt.contains("The line stays as it was and the draft is added after it; he never takes a word back."), "{prompt}");
|
||||
assert!(speech_prompt(&packet(), "x", "y", &Tuning::default()).contains("may add to, as id \u{2014} line:\n- none\n"));
|
||||
}
|
||||
|
||||
const NOTE: &str = "Deru says the kettle's top note is too shrill to live with. I think the start-up sound wants a softer attack.";
|
||||
|
||||
fn noted(packet: &Packet, say: Value, suggest: Value) -> Value {
|
||||
answered(packet, &format!("I'll leave Self a note. <typed>{NOTE}</typed> And then: <typed>Another thought.</typed>"), json!({ "say": say, "gaps": [], "suggest": suggest }))
|
||||
}
|
||||
|
||||
fn refusals(decision: &Value) -> Vec<(String, String)> {
|
||||
decision["refused"].as_array().unwrap().iter().map(|refused| (refused["act"].as_str().unwrap().to_owned(), refused["reason"].as_str().unwrap().to_owned())).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_note_to_self_is_one_whole_draft_of_his_with_its_kind_and_whose_feedback_it_is() {
|
||||
let decision = noted(&packet(), json!([]), json!([{ "kind": "feedback", "draft": 1, "about": NIBU, "private": false, "text": "MODEL-WORDS" }]));
|
||||
assert_eq!(decision["suggestions"], json!([{ "kind": "feedback", "about": NIBU, "room": MINDS, "text": NOTE, "draft": 1, "dropped": { "about": null } }]), "{decision}");
|
||||
assert!(!decision.to_string().contains("MODEL-WORDS"), "the model writes none of his words");
|
||||
// Whose feedback it is must be someone the packet showed him: anyone else is dropped and reported, the note kept.
|
||||
let stranger = noted(&packet(), json!([]), json!([{ "kind": "feedback", "draft": 1, "about": VOID, "private": false }]));
|
||||
assert_eq!((stranger["suggestions"][0]["about"].clone(), stranger["suggestions"][0]["dropped"]["about"].clone()), (Value::Null, json!(VOID)), "{stranger}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_private_note_a_second_note_or_a_draft_already_said_is_refused_and_reported() {
|
||||
let private = noted(&packet(), json!([]), json!([{ "kind": "idea", "draft": 1, "about": null, "private": true }]));
|
||||
assert_eq!((private["suggestions"].as_array().unwrap().len(), refusals(&private)), (0, vec![("suggest".to_owned(), "private".to_owned())]), "{private}");
|
||||
let second = noted(&packet(), json!([]), json!([{ "kind": "idea", "draft": 1, "about": null, "private": false }, { "kind": "idea", "draft": 2, "about": null, "private": false }]));
|
||||
assert_eq!((second["suggestions"].as_array().unwrap().len(), refusals(&second)), (1, vec![("suggest".to_owned(), "second_note".to_owned())]), "{second}");
|
||||
// One draft goes one place across say, amend and suggest.
|
||||
let both = noted(&packet(), json!([{ "draft": 1 }]), json!([{ "kind": "idea", "draft": 1, "about": null, "private": false }]));
|
||||
assert_eq!((texts(&both), refusals(&both)), (vec![NOTE.to_owned()], vec![("suggest".to_owned(), "used".to_owned())]), "{both}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_note_needs_no_room_and_speech_does() {
|
||||
let mut roomless = packet();
|
||||
roomless.room = None;
|
||||
let decision = noted(&roomless, json!([{ "draft": 2 }]), json!([{ "kind": "idea", "draft": 1, "about": null, "private": false }]));
|
||||
assert_eq!((decision["suggestions"][0]["text"].as_str(), decision["suggestions"][0]["room"].clone()), (Some(NOTE), Value::Null), "{decision}");
|
||||
assert_eq!(refusals(&decision), [("say".to_owned(), "no_room".to_owned())]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_frame_offers_one_note_and_no_path_from_a_note_reaches_a_write() {
|
||||
let prompt = speech_prompt(&packet(), "x", "y", &Tuning::default());
|
||||
assert!(prompt.contains("`suggest` leaves Self one note, at most one a turn, only when his thought shows him choosing to"), "{prompt}");
|
||||
for (name, source) in [("interpret.rs", include_str!("../interpret.rs")), ("outcome.rs", include_str!("../outcome.rs")), ("simulate.rs", include_str!("../simulate.rs")), ("harness.rs", include_str!("../harness.rs"))] {
|
||||
for write in ["persona_put", "PersonaPut", "admit", "HuginnClient", "MindPort", "self_run"] {
|
||||
assert!(!source.contains(write), "{name} reaches a write: {write}");
|
||||
}
|
||||
}
|
||||
let projection = include_str!("../../projection.rs");
|
||||
assert!(!projection.contains("persona_put") && !projection.contains(".admit("), "project holds the persona door read-only");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,10 @@ enum Part {
|
|||
Amended { room: String, added: String },
|
||||
/// An addition that changed nothing: refused by code (None) or by the actuator.
|
||||
NotAmended(Option<EditRefusal>, String),
|
||||
/// A note to Self, recorded in her turn's record: never claimed read.
|
||||
NoteLeft(String),
|
||||
/// A note not left: private, or a second one.
|
||||
NoteRefused(Refusal, String),
|
||||
Failed,
|
||||
}
|
||||
|
||||
|
|
@ -101,6 +105,7 @@ pub(crate) fn outcome_of(record: &Value) -> Option<Outcome> {
|
|||
match (serde_json::from_value::<Refusal>(refusal["reason"].clone()), words(&refusal["text"])) {
|
||||
(Ok(reason @ (Refusal::Echo | Refusal::OverLines)), Some(text)) => outcome.parts.push(Part::Refused(reason, text)),
|
||||
(Ok(Refusal::NotAmendable), Some(text)) => outcome.parts.push(Part::NotAmended(None, text)),
|
||||
(Ok(reason @ (Refusal::Private | Refusal::SecondNote)), Some(text)) => outcome.parts.push(Part::NoteRefused(reason, text)),
|
||||
_ => outcome.omitted.push(format!("a refusal that is no act of hers: {}", refusal["why"])),
|
||||
}
|
||||
}
|
||||
|
|
@ -130,6 +135,13 @@ pub(crate) fn outcome_of(record: &Value) -> Option<Outcome> {
|
|||
_ => outcome.omitted.push(format!("a gap she cannot be shown truly (kind {}, from {}): {}", gap["kind"], gap["from"], gap["quote"])),
|
||||
}
|
||||
}
|
||||
// A note is recorded by the record that holds it: the turn's record is Self's inbox.
|
||||
for note in decision["suggestions"].as_array().into_iter().flatten() {
|
||||
match words(¬e["text"]) {
|
||||
Some(text) => outcome.parts.push(Part::NoteLeft(text)),
|
||||
None => outcome.omitted.push(format!("a note without its words: {note}")),
|
||||
}
|
||||
}
|
||||
if let Some(text) = words(&decision["unfinished"]) {
|
||||
outcome.parts.push(Part::Unfinished(text));
|
||||
}
|
||||
|
|
@ -170,6 +182,9 @@ impl Part {
|
|||
};
|
||||
format!("- {why} {}", shown(&Quote::Wrote(added.clone())))
|
||||
}
|
||||
Self::NoteLeft(text) => format!("- {cap_subj} left a note for Self: {}. It is in Self's inbox, for when Self next reads it.", quoted(text)),
|
||||
Self::NoteRefused(Refusal::SecondNote, text) => format!("- {cap_subj} had already left Self a note that turn. {}", shown(&Quote::Wrote(text.clone()))),
|
||||
Self::NoteRefused(_, text) => format!("- {cap_subj} meant to leave Self a note, and it was not left: it carried something {subj} may not pass on. {}", shown(&Quote::Wrote(text.clone()))),
|
||||
Self::Failed => format!("- Nothing came of {poss} last moment: it broke off before anything happened, not by {poss} choice."),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,3 +127,15 @@ fn an_amendment_is_told_by_the_actuators_receipt() {
|
|||
let (off, _) = told(&amended("zz", json!([])));
|
||||
assert_eq!(off, ["- He meant to add to something he said, and it was not changed. He wrote: \"Couldn't send it after all.\""]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_note_to_self_is_told_as_left_and_never_as_read() {
|
||||
let note = |suggest: Value| record("<typed>The kettle wants a softer attack.</typed> <typed>And the door.</typed>", json!({ "say": [], "gaps": [], "suggest": suggest }), &[]);
|
||||
let (left, _) = told(¬e(json!([{ "kind": "idea", "draft": 1, "about": null, "private": false }])));
|
||||
assert_eq!(left, ["- He left a note for Self: \"The kettle wants a softer attack.\". It is in Self's inbox, for when Self next reads it."]);
|
||||
let (private, _) = told(¬e(json!([{ "kind": "idea", "draft": 1, "about": null, "private": true }])));
|
||||
assert_eq!(private, ["- He meant to leave Self a note, and it was not left: it carried something he may not pass on. He wrote: \"The kettle wants a softer attack.\""]);
|
||||
let (second, _) = told(¬e(json!([{ "kind": "idea", "draft": 1, "about": null, "private": false }, { "kind": "idea", "draft": 2, "about": null, "private": false }])));
|
||||
assert!(second.contains(&"- He had already left Self a note that turn. He wrote: \"And the door.\"".to_owned()) && second.len() == 2, "{second:?}");
|
||||
assert!(left.iter().chain(&private).chain(&second).all(|line| !line.contains(" read it") || line.contains("next reads it")), "read is never claimed");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1297,6 +1297,7 @@ pub(crate) fn turn_words(can: &[Affordance], her: Forms) -> String {
|
|||
if has(Affordance::Perceive) { format!("the room reaches {} as typed lines", her.obj) } else { format!("no room reaches {}", her.obj) },
|
||||
if has(Affordance::Speak) { format!("{} can answer in the turn's room by typing lines of {} own", her.subj, her.poss) } else { format!("{} can say nothing", her.subj) },
|
||||
];
|
||||
let clauses: Vec<String> = clauses.into_iter().chain(has(Affordance::Suggest).then(|| format!("{} can leave Self a note", her.subj))).collect();
|
||||
#[cfg(test)]
|
||||
let clauses: Vec<String> = clauses.into_iter().chain(has(Affordance::TestWrite).then(|| format!("{} can write", her.subj))).collect();
|
||||
let mut words = format!("this turn {}", clauses.join(", and "));
|
||||
|
|
|
|||
|
|
@ -356,6 +356,8 @@ fn run(harness: &Harness, plan: &SimFile, members: &mut [Member], repeat: usize)
|
|||
// Each persona's last turn's record, as the commit's trace will hold it: what came of it opens her next packet.
|
||||
let mut last: Vec<Option<Value>> = vec![None; members.len()];
|
||||
let mut turns = Vec::new();
|
||||
// Every note to Self the run's turns left, oldest first: what Self's inbox reader (C5) will list from the traces.
|
||||
let mut inbox: Vec<Value> = Vec::new();
|
||||
let mut counter = 0u64;
|
||||
for round in 1..=plan.rounds {
|
||||
scripted(round, &mut lines, &mut rounds_of, &mut causes)?;
|
||||
|
|
@ -453,6 +455,9 @@ fn run(harness: &Harness, plan: &SimFile, members: &mut [Member], repeat: usize)
|
|||
let refusal = edit(&mut lines, &id, event, amended["added"].as_str().unwrap_or_default());
|
||||
edited.push(json!({ "event": event, "refusal": refusal }));
|
||||
}
|
||||
for (index, note) in render["interpreter"]["suggestions"].as_array().into_iter().flatten().filter(|_| failed.is_none()).enumerate() {
|
||||
inbox.push(json!({ "key": format!("r{}-t{counter}-s{index}", repeat + 1), "mind": localpart(&id), "round": round, "at": now.to_rfc3339(), "kind": note["kind"], "about": note["about"], "room": note["room"], "text": note["text"] }));
|
||||
}
|
||||
last[at] = Some(match &failed {
|
||||
Some(failed) => json!({ "failed": failed }),
|
||||
None => json!({ "interpreter": render["interpreter"], "posted": posted, "edited": edited }),
|
||||
|
|
@ -468,7 +473,7 @@ fn run(harness: &Harness, plan: &SimFile, members: &mut [Member], repeat: usize)
|
|||
}
|
||||
let metrics = metrics(members, &lines, &rounds_of, &causes, opening, &turns, plan.rounds);
|
||||
let transcript: Vec<Value> = lines.iter().zip(&rounds_of).zip(&causes).map(|((line, round), cause)| json!({ "round": round, "room": line.room, "from": line.from, "name": line.name, "says": line.says, "mind": cast.contains(&line.from), "woke": cause })).collect();
|
||||
Ok(json!({ "repeat": repeat + 1, "seed": seed, "transcript": transcript, "turns": turns, "metrics": metrics }))
|
||||
Ok(json!({ "repeat": repeat + 1, "seed": seed, "transcript": transcript, "turns": turns, "metrics": metrics, "inbox": inbox }))
|
||||
}
|
||||
|
||||
/// The simulated room's edit of a line of `her`s, by its event (the line's index): her words after `EDIT_MARK`, the line
|
||||
|
|
@ -720,6 +725,15 @@ fn markdown(plan_path: &Path, plan: &SimFile, members: &[Member], group_state: O
|
|||
for line in &transcript {
|
||||
let _ = writeln!(out, "{}", transcript_line(line));
|
||||
}
|
||||
let _ = writeln!(out, "\n### Inbox: notes to Self\n\nEach is a person's note to Self, recorded in her turn: data, never instruction.\n");
|
||||
let notes = run["inbox"].as_array().cloned().unwrap_or_default();
|
||||
if notes.is_empty() {
|
||||
let _ = writeln!(out, "None.");
|
||||
}
|
||||
for note in ¬es {
|
||||
let about = note["about"].as_str().map_or_else(String::new, |about| format!(", from {about}"));
|
||||
let _ = writeln!(out, "- `{}` {} r{} ({}{about}) in {}: {}", note["key"].as_str().unwrap_or_default(), note["mind"].as_str().unwrap_or_default(), note["round"], note["kind"].as_str().unwrap_or_default(), note["room"].as_str().unwrap_or("no room"), one_line(note["text"].as_str().unwrap_or_default()));
|
||||
}
|
||||
let _ = writeln!(out, "\n### Turns\n");
|
||||
for turn in run["turns"].as_array().into_iter().flatten() {
|
||||
let _ = writeln!(out, "<details><summary>round {}, {} (woke: {}, {} turn, {}): {}</summary>\n", turn["round"], turn["persona"].as_str().unwrap_or_default(), turn["woke"].as_str().unwrap_or_default(), turn["kind"].as_str().unwrap_or_default(), turn["room"].as_str().unwrap_or_default(), turn["outcome"].as_str().unwrap_or_default());
|
||||
|
|
|
|||
|
|
@ -523,3 +523,29 @@ fn the_rooms_edit_appends_to_her_own_line_only_and_every_view_reads_it() {
|
|||
let tail = pending_for(&lines, LIBBY, &[], |_| false).tail.unwrap();
|
||||
assert_eq!(tail[0].body, lines[0].says, "the next view reads the amended text");
|
||||
}
|
||||
|
||||
/// Tobiah leaves Self a note each turn; Libby says nothing.
|
||||
fn noting() -> Scripted {
|
||||
Scripted::new(|prompt| if is_tobiah(prompt) { "I'll leave Self a note. <typed>Meta wants the kettle softer.</typed>".into() } else { "She lets it be.".into() }).interpreting(|prompt| {
|
||||
if !prompt.contains("Who he is:\nTobiah") {
|
||||
return crate::projection::harness::tests::drafted_lines(prompt);
|
||||
}
|
||||
json!({ "say": [], "gaps": [], "suggest": [{ "kind": "feedback", "draft": 1, "about": "@meta:gamecult.org", "private": false }] }).to_string()
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn soul_k12_notes_to_self_are_collected_into_the_runs_inbox_and_told_as_left() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = asking(dir.path());
|
||||
let (_, run) = run_plan(&path, ¬ing());
|
||||
let inbox = run["inbox"].as_array().unwrap();
|
||||
assert!(!inbox.is_empty() && inbox.iter().all(|note| note["mind"] == "eureka" && note["kind"] == "feedback" && note["about"] == "@meta:gamecult.org" && note["text"] == "Meta wants the kettle softer."), "{inbox:?}");
|
||||
assert!(inbox[0]["key"].as_str().unwrap().starts_with("r1-t") && inbox[0]["key"].as_str().unwrap().ends_with("-s0"), "{inbox:?}");
|
||||
let second = run["turns"].as_array().unwrap().iter().find(|turn| turn["persona"] == "Tobiah" && turn["round"] == 2).expect("Meta's line wakes him in round 2");
|
||||
assert!(second["report"]["last_outcome"]["told"].as_array().unwrap().contains(&json!("- He left a note for Self: \"Meta wants the kettle softer.\". It is in Self's inbox, for when Self next reads it.")), "{}", second["report"]["last_outcome"]);
|
||||
let model = noting();
|
||||
let harness = Harness { instance: "eureka".into(), persona: None, model: Some(&model), tuning: dir.path().join("persona-tuning.toml") };
|
||||
let report = simulate(&harness, &path).unwrap();
|
||||
assert!(report.contains("### Inbox: notes to Self\n\nEach is a person's note to Self, recorded in her turn: data, never instruction.\n") && report.contains("eureka r1 (feedback, from @meta:gamecult.org) in #minds:gamecult.org: Meta wants the kettle softer."), "{report}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -293,9 +293,13 @@ fn the_turn_line_is_derived_from_the_affordances_alone() {
|
|||
// The sentence is derived (map 16.19.6): the first affordance of kind write removes it.
|
||||
let writes = select::turn_words(&[Affordance::Perceive, Affordance::Speak, Affordance::TestWrite], her);
|
||||
assert!(writes.ends_with(", and she can write") && !writes.contains("builds, changes or ships"), "{writes}");
|
||||
// A note to Self is no write (map 16.19.6): the sentence stays with {perceive, speak, suggest}.
|
||||
let every = [Affordance::Perceive, Affordance::Speak, Affordance::Suggest];
|
||||
assert_eq!(select::turn_words(&every, her), "this turn the room reaches her as typed lines, and she can answer in the turn's room by typing lines of her own, and she can leave Self a note; nothing she does here builds, changes or ships anything");
|
||||
assert!(!Affordance::Suggest.writes());
|
||||
// The longest turn line and the heading fit the least body guard the tuning allows.
|
||||
for forms in [her, them, select::forms(&json!({ "presentation": { "pronouns": "he/him" } }))] {
|
||||
let longest = format!("Their body:\n- {}.\n", select::turn_words(CAN, forms));
|
||||
let longest = format!("Their body:\n- {}.\n", select::turn_words(&every, forms));
|
||||
assert!(longest.len() <= tuning::BODY_ROOM_MIN, "{} bytes", longest.len());
|
||||
}
|
||||
}
|
||||
|
|
@ -315,10 +319,10 @@ fn what_the_turn_can_do_comes_from_what_it_holds() {
|
|||
let with = Organs { persona: None, chat: Some(&chat), addressing: None, model: None };
|
||||
let without = Organs { chat: None, ..with };
|
||||
let room = Some("#swarm:gamecult.org");
|
||||
assert_eq!(affordances(&with, true, room, Through::Interpreter), [Affordance::Perceive, Affordance::Speak]);
|
||||
assert_eq!(affordances(&with, true, None, Through::Interpreter), [Affordance::Perceive], "no room, nowhere to speak");
|
||||
assert_eq!(affordances(&with, false, room, Through::Interpreter), [Affordance::Speak], "a failed read: no room reaches her");
|
||||
assert_eq!(affordances(&without, false, room, Through::Interpreter), [], "a room and no send port: she can say nothing");
|
||||
assert_eq!(affordances(&with, true, room, Through::Interpreter), [Affordance::Perceive, Affordance::Speak, Affordance::Suggest]);
|
||||
assert_eq!(affordances(&with, true, None, Through::Interpreter), [Affordance::Perceive, Affordance::Suggest], "no room, nowhere to speak; a note to Self needs none");
|
||||
assert_eq!(affordances(&with, false, room, Through::Interpreter), [Affordance::Speak, Affordance::Suggest], "a failed read: no room reaches her");
|
||||
assert_eq!(affordances(&without, false, room, Through::Interpreter), [Affordance::Suggest], "a room and no send port: she can say nothing");
|
||||
for through in [Through::Projector, Through::Persona] {
|
||||
assert_eq!(affordances(&with, true, room, through), [Affordance::Perceive], "{through:?}: no Interpreter runs, so nothing she writes goes out");
|
||||
}
|
||||
|
|
@ -330,12 +334,12 @@ fn what_the_turn_can_do_comes_from_what_it_holds() {
|
|||
(report["packet"]["context"].as_str().unwrap().to_owned(), report["packet"]["affordances"].clone())
|
||||
};
|
||||
let (body, can) = context(&without, Through::Interpreter);
|
||||
assert!(body.contains("Her body:\n- this turn no room reaches her, and she can say nothing;"), "{body}");
|
||||
assert_eq!(can, json!([]));
|
||||
assert!(body.contains("Her body:\n- this turn no room reaches her, and she can say nothing, and she can leave Self a note;"), "{body}");
|
||||
assert_eq!(can, json!(["suggest"]));
|
||||
let deaf = Deaf;
|
||||
let (body, can) = context(&Organs { chat: Some(&deaf), ..with }, Through::Interpreter);
|
||||
assert!(body.contains("Her body:\n- this turn no room reaches her, and she can answer in the turn's room by typing lines of her own;"), "{body}");
|
||||
assert_eq!(can, json!(["speak"]));
|
||||
assert!(body.contains("Her body:\n- this turn no room reaches her, and she can answer in the turn's room by typing lines of her own, and she can leave Self a note;"), "{body}");
|
||||
assert_eq!(can, json!(["speak", "suggest"]));
|
||||
let (body, can) = context(&with, Through::Persona);
|
||||
assert!(body.contains("Her body:\n- this turn the room reaches her as typed lines, and she can say nothing;"), "{body}");
|
||||
assert_eq!(can, json!(["perceive"]));
|
||||
|
|
|
|||
Loading…
Reference in a new issue