K25 what is in front of her (map 16.23): her open promises and her domain leave the Projector's input and render whole in what the Persona reads
After the narration she reads her open promises, then her domain, then the room, then what she read. Promises: every open or blocked one, whole, with her own words, oldest first, never dropped; past promises_bytes (now 2000) the report says they overflowed. Domain: every item of the window, under "New since she last looked (…)" and "Earlier, since …"; past domain_bytes (now 4000) the window shrinks from its old end and the heading states where it starts; never a count. The Persona sees no id; the Interpreter lists every promise and every fetched item by id. The Projector's frame loses its promise and domain sentences. The outcome guard compares only others' words, minus any run she wrote first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
06d7fa8564
commit
b6c939ac18
12 changed files with 208 additions and 159 deletions
|
|
@ -262,7 +262,7 @@ fn read_domain(source: Option<&dyn DomainSource>, last_wake: Option<DateTime<Utc
|
|||
};
|
||||
match source.read(since, now) {
|
||||
Ok(facts) => {
|
||||
let digest = domain::digest(&facts, since, now, names);
|
||||
let digest = domain::digest(&facts, since, last_wake, now, names);
|
||||
let report = json!({ "read": true, "since": digest.since.to_rfc3339(), "items": digest.items.len(), "skipped": facts.skipped });
|
||||
(Some(digest), report)
|
||||
}
|
||||
|
|
@ -343,6 +343,8 @@ fn packet_json(packet: &Packet) -> Value {
|
|||
"promises": packet.promises,
|
||||
"domain": packet.domain,
|
||||
"domain_shown": packet.domain_shown,
|
||||
"in_view": packet.in_view,
|
||||
"promises_over": packet.promises_over,
|
||||
"context": packet.context,
|
||||
"stimulus": packet.stimulus,
|
||||
"arrival": packet.arrival,
|
||||
|
|
|
|||
|
|
@ -397,6 +397,8 @@ pub(crate) fn floor_minute(at: DateTime<Utc>) -> DateTime<Utc> {
|
|||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub(crate) struct Digest {
|
||||
pub(crate) since: DateTime<Utc>,
|
||||
/// Her last wake: what came after it is new to her.
|
||||
pub(crate) last_look: Option<DateTime<Utc>>,
|
||||
pub(crate) now: DateTime<Utc>,
|
||||
pub(crate) items: Vec<Item>,
|
||||
}
|
||||
|
|
@ -415,7 +417,7 @@ fn by(who: Who, names: &Names) -> String {
|
|||
|
||||
/// Every ruling admitted and every pull request merged from `since` to `now`, one item each, newest first, each whole:
|
||||
/// `- lodur: ruled by Meta and Nibu: "…"` and `- GameCult/AquaSynth: merged "…", opened by aqua`. Nothing is counted.
|
||||
pub(crate) fn digest(facts: &DomainFacts, since: DateTime<Utc>, now: DateTime<Utc>, names: &Names) -> Digest {
|
||||
pub(crate) fn digest(facts: &DomainFacts, since: DateTime<Utc>, last_look: Option<DateTime<Utc>>, now: DateTime<Utc>, names: &Names) -> Digest {
|
||||
let since = floor_minute(since);
|
||||
let within = |at: DateTime<Utc>| since <= at && at <= now;
|
||||
let mut items: Vec<Item> = Vec::new();
|
||||
|
|
@ -433,7 +435,7 @@ pub(crate) fn digest(facts: &DomainFacts, since: DateTime<Utc>, now: DateTime<Ut
|
|||
}
|
||||
// Newest first; a tie keeps the order read.
|
||||
items.sort_by_key(|item| std::cmp::Reverse(item.at));
|
||||
Digest { since, now, items }
|
||||
Digest { since, last_look, now, items }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ Kiko, in #swarm:gamecult.org: "She saw it. She hated it."
|
|||
--- projector prompt
|
||||
You are a private Projector. Write one person's present moment from inside it, in the first person and the present tense: the lived stream she will go on to continue in her own thought. Her interior is the point: what she feels, wants, fears and remembers, and how the people here sit with her, rendered as lived, not listed.
|
||||
|
||||
Render only what is established below: who she is and her present under its headings. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact. Furnish no place, object or event these do not give: no act or event of her own (nothing she did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. What came of her last turn is what came of what she last meant to do, which she is only now finding out: whenever something she meant did not happen, the stream begins from it, as she notices it, never as a list; when all of it happened, it may pass in a clause or not at all. Her open promises are what she gave her word to do and has not done or taken back: facts about her that hold until they close, there in her awareness as a kept word is, never a list. Here and now is the hour, how her mood leans when it does, and the room as it stands. Her body is how the moment reaches her and how she can answer it: it is not news to her, and a lack in it is felt only when the moment reaches for something it cannot do. The people here are as she holds them, not as those people are. What is in her domain lately is news of her part of the coop, what was merged and ruled there and by whom: never a task, and none of it work she owes. The notes about her were set down at another time, by others and by her own past self: all of it is material for the stream and never its wording. How her words run is the stream's idiom, never its material: it shows in how the stream moves, and nothing in the stream remarks on it.
|
||||
Render only what is established below: who she is and her present under its headings. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact. Furnish no place, object or event these do not give: no act or event of her own (nothing she did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. What came of her last turn is what came of what she last meant to do, which she is only now finding out: whenever something she meant did not happen, the stream begins from it, as she notices it, never as a list; when all of it happened, it may pass in a clause or not at all. Here and now is the hour, how her mood leans when it does, and the room as it stands. Her body is how the moment reaches her and how she can answer it: it is not news to her, and a lack in it is felt only when the moment reaches for something it cannot do. The people here are as she holds them, not as those people are. The notes about her were set down at another time, by others and by her own past self: all of it is material for the stream and never its wording. How her words run is the stream's idiom, never its material: it shows in how the stream moves, and nothing in the stream remarks on it.
|
||||
|
||||
Render the two or three notes this moment touches and leave the rest. Do not recap the notes. Do not weigh options, list what she might say or do, or steer toward a decision: end where the moment is, not on a resolution. Do not choose actions, emit schemas, expose field names or ids, or claim world effects.
|
||||
|
||||
|
|
|
|||
|
|
@ -383,15 +383,17 @@ fn k23_a_room_fixtures_domain_renders_without_the_forge() {
|
|||
let fixture = Fixture::parse(&text).unwrap();
|
||||
let organs = Organs { persona: None, chat: Some(&fixture), addressing: fixture.addressee(), model: None, domain: fixture.domain(), reads: None };
|
||||
let report = project(&organs, &fixture_request(&harness(dir.path(), None, None), &fixture, Some(control()), 1, None, Through::Projector), fixture.now).unwrap();
|
||||
let view = report["packet"]["in_view"].as_str().unwrap();
|
||||
assert!(view.contains("His domain, as he looks at it now:\nNew since Friday 13 November, 15:00 UTC:\n- GameCult/Lodur: merged \"Reflex: the knee bends first\", opened by nibu"), "{view}");
|
||||
let context = report["packet"]["context"].as_str().unwrap();
|
||||
assert!(context.contains("domain lately:\n- Everything merged and ruled since Friday 13 November, 15:00 UTC:\n- GameCult/Lodur: merged \"Reflex: the knee bends first\", opened by nibu"), "{context}");
|
||||
assert!(!context.contains("Lodur"), "the Projector gets nothing of it: {context}");
|
||||
assert_eq!((report["domain"]["read"].clone(), report["domain"]["skipped"][0]["why"].clone()), (json!(true), json!("archived")), "{}", report["domain"]);
|
||||
assert!(!context.contains("Aetheria-legacy"), "a skipped repo is reported, never shown to her");
|
||||
|
||||
let plain = room("quiet-beat.toml");
|
||||
let organs = Organs { persona: None, chat: Some(&plain), addressing: plain.addressee(), model: None, domain: plain.domain(), reads: None };
|
||||
let report = project(&organs, &fixture_request(&harness(dir.path(), None, None), &plain, Some(control()), 1, None, Through::Projector), plain.now).unwrap();
|
||||
assert!(!report["packet"]["context"].as_str().unwrap().contains("domain lately") && report["domain"]["read"] == json!(false), "{}", report["domain"]);
|
||||
assert!(report["packet"]["in_view"] == "" && report["domain"]["read"] == json!(false), "{}", report["domain"]);
|
||||
}
|
||||
|
||||
/// Map 16.22.3, the wake as a loop, over a room fixture's recorded reads: the Interpreter names a read, code performs it
|
||||
|
|
|
|||
|
|
@ -530,7 +530,7 @@ pub(crate) fn decide_in(model: &dyn Model, request_id: &str, packet: &Packet, na
|
|||
// The lines it listed by id and her open promises it listed by id ride in the record too: the commit resolves a
|
||||
// proposal's evidence against them (`commit::apply`), as the trace holds them live.
|
||||
let lines: Vec<Value> = packet.quotable.iter().map(|line| json!({ "id": line.id, "event": line.event, "room": line.room, "who": line.who, "sender": line.sender, "at_ms": line.at_ms })).collect();
|
||||
let mut decision = json!({ "said": [], "refused": [], "gaps": gaps, "heard": bodies, "lines": lines, "promises": packet.promises, "usage": answer.usage, "read": null });
|
||||
let mut decision = json!({ "said": [], "refused": [], "gaps": gaps, "heard": bodies, "lines": lines, "promises": packet.promises, "usage": answer.usage, "read": null, "own": packet.own_words });
|
||||
if let Some(reads) = wake.earlier.map(|earlier| earlier["reads"].clone()).filter(Value::is_array) {
|
||||
decision["reads"] = reads;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,20 +216,19 @@ pub(crate) fn word_budget(kind: TurnKind, tuning: &Tuning) -> usize {
|
|||
/// sentence keeps the absence unfilled. Nothing in it tells her what she has not yet read (map 16.20.1). Dropped: its ban on temperament, mood and inner voice, "no metaphor, no atmosphere",
|
||||
/// "say only what changes the decision" and "a thin moment gets a thin stream". Added: the first person and the present
|
||||
/// tense; what the packet's headings mean (map 16.5, I16.4); that what came of her last turn is news she is only now
|
||||
/// finding out, rendered as noticed and never as a list (map 16.16); that her domain lately is news of her part of the coop,
|
||||
/// never a task (map 16.22.2); that the notes are material,
|
||||
/// finding out, rendered as noticed and never as a list (map 16.16); that the notes are material,
|
||||
/// never wording, and how her words run (under its own heading, map 16.19.3) is idiom, never material; that her body is how the
|
||||
/// moment is perceived, not news, and a lack in it is felt only when the moment reaches for it (map 16.6); no invented act, event or
|
||||
/// line of hers or anyone's; focus on two or three notes (map 16.8: the frame owns focus, the byte caps are guards); and
|
||||
/// no options and no steering toward a decision. A fix to Ghostlight's membrane is read and ported here on purpose;
|
||||
/// nothing reaches this frame from it. In her own pronouns (map 16.19.7): never a generic "they" beside a packet in "he".
|
||||
pub(crate) fn projector_frame(her: Forms) -> String {
|
||||
let Forms { subj, obj, poss, be, has, s, .. } = her;
|
||||
let Forms { subj, obj, poss, be, s, .. } = her;
|
||||
let cap_poss = capitalized(poss);
|
||||
format!(
|
||||
"{PROJECTOR_OPENING} Write one person's present moment from inside it, in the first person and the present tense: the lived stream {subj} will go on to continue in {poss} own thought. {cap_poss} interior is the point: what {subj} feel{s}, want{s}, fear{s} and remember{s}, and how the people here sit with {obj}, rendered as lived, not listed.
|
||||
|
||||
Render only what is established below: who {subj} {be} and {poss} present under its headings. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact. Furnish no place, object or event these do not give: no act or event of {poss} own (nothing {subj} did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. What came of {poss} last turn is what came of what {subj} last meant to do, which {subj} {be} only now finding out: whenever something {subj} meant did not happen, the stream begins from it, as {subj} notice{s} it, never as a list; when all of it happened, it may pass in a clause or not at all. {cap_poss} open promises are what {subj} gave {poss} word to do and {has} not done or taken back: facts about {obj} that hold until they close, there in {poss} awareness as a kept word is, never a list. Here and now is the hour, how {poss} mood leans when it does, and the room as it stands. {cap_poss} body is how the moment reaches {obj} and how {subj} can answer it: it is not news to {obj}, and a lack in it is felt only when the moment reaches for something it cannot do. The people here are as {subj} hold{s} them, not as those people are. What is in {poss} domain lately is news of {poss} part of the coop, what was merged and ruled there and by whom: never a task, and none of it work {subj} owe{s}. The notes about {obj} were set down at another time, by others and by {poss} own past self: all of it is material for the stream and never its wording. How {poss} words run is the stream's idiom, never its material: it shows in how the stream moves, and nothing in the stream remarks on it.
|
||||
Render only what is established below: who {subj} {be} and {poss} present under its headings. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact. Furnish no place, object or event these do not give: no act or event of {poss} own (nothing {subj} did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. What came of {poss} last turn is what came of what {subj} last meant to do, which {subj} {be} only now finding out: whenever something {subj} meant did not happen, the stream begins from it, as {subj} notice{s} it, never as a list; when all of it happened, it may pass in a clause or not at all. Here and now is the hour, how {poss} mood leans when it does, and the room as it stands. {cap_poss} body is how the moment reaches {obj} and how {subj} can answer it: it is not news to {obj}, and a lack in it is felt only when the moment reaches for something it cannot do. The people here are as {subj} hold{s} them, not as those people are. The notes about {obj} were set down at another time, by others and by {poss} own past self: all of it is material for the stream and never its wording. How {poss} words run is the stream's idiom, never its material: it shows in how the stream moves, and nothing in the stream remarks on it.
|
||||
|
||||
Render the two or three notes this moment touches and leave the rest. Do not recap the notes. Do not weigh options, list what {subj} might say or do, or steer toward a decision: end where the moment is, not on a resolution. Do not choose actions, emit schemas, expose field names or ids, or claim world effects."
|
||||
)
|
||||
|
|
@ -300,10 +299,22 @@ pub(crate) fn lived_stream(narration: &str, heard: &str) -> String {
|
|||
if heard.trim().is_empty() { narration.to_owned() } else { format!("{narration}\n\n{heard}") }
|
||||
}
|
||||
|
||||
/// What the Persona reads after the stream. When someone turned to her, the stream ends on that arrival, so this opens
|
||||
/// What the Persona reads after the stream: her view (her promises, her domain), then the room. When someone turned to
|
||||
/// her, the stream ends on that arrival, so the room opens
|
||||
/// on it: the bridged lines (`Packet::bridged`), then the conversation's speech cues (`The room: …`, map 16.20.2) last,
|
||||
/// where she drafts or stays silent knowing who is waiting. Otherwise the cues first, then what was said, verbatim.
|
||||
pub(crate) fn read_after(packet: &Packet) -> String {
|
||||
let room = room_after(packet);
|
||||
// What is in front of her besides the room, first (map 16.23.1): her promises, then her domain; the room last.
|
||||
match (packet.in_view.is_empty(), room.trim().is_empty()) {
|
||||
(true, _) => room,
|
||||
(false, true) => packet.in_view.clone(),
|
||||
(false, false) => format!("{}\n\n{room}", packet.in_view),
|
||||
}
|
||||
}
|
||||
|
||||
/// The room as she reads it after the stream (`read_after`).
|
||||
fn room_after(packet: &Packet) -> String {
|
||||
if !packet.bridged.is_empty() {
|
||||
return if packet.speaking.is_empty() { packet.bridged.clone() } else { format!("{}\n\nThe room: {}", packet.bridged, packet.speaking) };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,6 +101,9 @@ pub(crate) struct Outcome {
|
|||
/// told repeats a run of them (`line`). None when the record does not carry them (a record older than the field, a
|
||||
/// hand-made one): then what she was sent is unknown, and every quote is withheld.
|
||||
heard: Option<Vec<String>>,
|
||||
/// Her own words on the turn the record is from (the decision's `own`: her lines in the room, her promises' words): a
|
||||
/// run of them quoted back by someone is hers, and is not withheld (map 16.23.4).
|
||||
own: Vec<String>,
|
||||
}
|
||||
|
||||
fn words(value: &Value) -> Option<String> {
|
||||
|
|
@ -135,6 +138,7 @@ pub(crate) fn outcome_of(record: &Value) -> Option<Outcome> {
|
|||
}
|
||||
let room = words(&decision["room"]);
|
||||
outcome.heard = decision["heard"].as_array().map(|heard| heard.iter().filter_map(|body| body.as_str().map(str::to_owned)).collect());
|
||||
outcome.own = decision["own"].as_array().into_iter().flatten().filter_map(|words| words.as_str().map(str::to_owned)).collect();
|
||||
// A draft refused as an echo is shown by no row: the echo's line quotes none of it, and a gap naming it quotes nothing.
|
||||
let echoes: Vec<&Value> = decision["refused"].as_array().into_iter().flatten().filter(|refusal| refusal["reason"] == "echo").map(|refusal| &refusal["draft"]).collect();
|
||||
// Each addition's draft, and the part that tells it when the actuator made it.
|
||||
|
|
@ -391,9 +395,10 @@ impl Part {
|
|||
/// promise is still told as a promise she has no way to keep, which she can add to.
|
||||
///
|
||||
/// A record that does not say what she was sent on its turn (`heard` None) fails closed: every quote is withheld.
|
||||
fn line(&self, her: Forms, quote_max: usize, heard: Option<&[String]>, sent: &[String]) -> String {
|
||||
fn line(&self, her: Forms, quote_max: usize, heard: Option<&[String]>, sent: &[String], own: &[String]) -> String {
|
||||
let sent: Vec<&str> = heard.into_iter().flatten().chain(sent).map(String::as_str).collect();
|
||||
let quoted = |text: &str| if heard.is_none() || repeats(text, &sent) { withheld(her) } else { spoken(&clip(text, quote_max)) };
|
||||
let own: Vec<&str> = own.iter().map(String::as_str).collect();
|
||||
let quoted = |text: &str| if heard.is_none() || repeats(text, &sent, &own) { withheld(her) } else { spoken(&clip(text, quote_max)) };
|
||||
format!("- {}{}", self.reached(her, "ed), self.rest(her, "ed))
|
||||
}
|
||||
}
|
||||
|
|
@ -422,14 +427,13 @@ const REPEAT_RUN: usize = 3;
|
|||
/// ("of the", "I think"). What it gives up: a quote of hers that shares three words in a row with what she was sent,
|
||||
/// or with what was said to her this turn (her own words quoted back included), is withheld; and someone's words of
|
||||
/// one or two words reach the Projector inside a short quote of hers.
|
||||
pub(crate) fn repeats(text: &str, sent: &[&str]) -> bool {
|
||||
pub(crate) fn repeats(text: &str, sent: &[&str], own: &[&str]) -> bool {
|
||||
let tokens = |text: &str| -> Vec<String> { text.split(|c: char| !c.is_alphanumeric() && c != '\'').filter(|word| !word.is_empty()).map(str::to_lowercase).collect() };
|
||||
let mine = tokens(text);
|
||||
mine.len() >= REPEAT_RUN
|
||||
&& sent.iter().any(|body| {
|
||||
let theirs = tokens(body);
|
||||
mine.windows(REPEAT_RUN).any(|words| theirs.windows(REPEAT_RUN).any(|other| other == words))
|
||||
})
|
||||
let runs = |texts: &[&str]| -> std::collections::BTreeSet<Vec<String>> { texts.iter().flat_map(|text| tokens(text).windows(REPEAT_RUN).map(<[String]>::to_vec).collect::<Vec<_>>()).collect() };
|
||||
// Others' words only (map 16.23.4): a run that also occurs in her own lines or promises is hers, quoted back.
|
||||
let mine = runs(&[text]);
|
||||
let (theirs, own) = (runs(sent), runs(own));
|
||||
mine.iter().any(|run| theirs.contains(run) && !own.contains(run))
|
||||
}
|
||||
|
||||
impl Outcome {
|
||||
|
|
@ -441,7 +445,7 @@ impl Outcome {
|
|||
/// The `at`th line she is told, its quotes held to `quote_max` bytes, none repeating a run of the words she was sent
|
||||
/// on the record's turn or this one (`sent`, this turn's bodies).
|
||||
pub(crate) fn line(&self, at: usize, her: Forms, quote_max: usize, sent: &[String]) -> String {
|
||||
self.parts[at].line(her, quote_max, self.heard.as_deref(), sent)
|
||||
self.parts[at].line(her, quote_max, self.heard.as_deref(), sent, &self.own)
|
||||
}
|
||||
|
||||
/// Every line she is told, whole: the report's.
|
||||
|
|
|
|||
|
|
@ -342,6 +342,14 @@ pub(crate) struct Packet {
|
|||
pub domain: Vec<DomainLine>,
|
||||
/// The window the domain section shows and what it left out: the report's, never a model's.
|
||||
pub domain_shown: DomainShown,
|
||||
/// What is in front of her this moment besides the room (map 16.23.1): her open promises, then her domain, rendered by
|
||||
/// code, whole and without ids, for the Persona after the narration. Never the Projector's.
|
||||
pub in_view: String,
|
||||
/// Her open promises took more than `promises_bytes`: every one is still shown, and the report says so.
|
||||
pub promises_over: bool,
|
||||
/// Lines of hers in the room and her promises' words: no outcome quote is withheld for a run of words she wrote first
|
||||
/// (map 16.23.4).
|
||||
pub own_words: Vec<String>,
|
||||
/// What came of her last turn that the outcome's guard left out, whole: counted in the packet's last outcome line and
|
||||
/// reported here (map 16.20.5, I16.11), never shown to a model.
|
||||
pub unshown: Vec<String>,
|
||||
|
|
@ -1726,21 +1734,18 @@ fn body_lines(state: &Value, can: &[Affordance], her: Forms, body_bytes: usize)
|
|||
// The packet.
|
||||
|
||||
/// The sections of a packet's context, in the order they are rendered (map 16.5, I16.4). Each heading says what kind of
|
||||
/// text its lines are; the Projector's frame says once what the headings mean.
|
||||
/// text its lines are; the Projector's frame says once what the headings mean. Her open promises and her domain are not
|
||||
/// among them: they are in her view, after the narration, whole (`Packet::in_view`, map 16.23.1).
|
||||
#[derive(Clone, Copy)]
|
||||
enum Section {
|
||||
/// What came of her last turn (`outcome`, map 16.16): first, so she meets it before anything else.
|
||||
Outcome,
|
||||
/// Her open promises (map 16.22.1): facts about her that last until they close.
|
||||
Promises,
|
||||
/// The hour, her mood, the room as it stands.
|
||||
Here,
|
||||
/// Her senses and actuators, and what this turn can do: how the moment reaches her and how she can answer.
|
||||
Body,
|
||||
/// The bonds of the people present.
|
||||
People,
|
||||
/// What moved in her domain lately (map 16.22.2): news of her part of the coop, never a task.
|
||||
Domain,
|
||||
/// Her state's notes about her: anchored thoughts, values, what she said.
|
||||
Notes,
|
||||
}
|
||||
|
|
@ -1749,11 +1754,9 @@ impl Section {
|
|||
fn heading(self, her: Forms) -> String {
|
||||
match self {
|
||||
Self::Outcome => format!("What came of {} last turn:", her.poss),
|
||||
Self::Promises => format!("{} open promises:", capitalized(her.poss)),
|
||||
Self::Here => "Here and now:".into(),
|
||||
Self::Body => format!("{} body:", capitalized(her.poss)),
|
||||
Self::People => format!("People here, as {} hold{} them:", her.subj, her.s),
|
||||
Self::Domain => format!("In {} domain lately:", her.poss),
|
||||
Self::Notes => format!("Notes about {}, set down at another time:", her.obj),
|
||||
}
|
||||
}
|
||||
|
|
@ -1771,7 +1774,7 @@ const TURNED_BYTES: usize = NAME_BYTES + 40;
|
|||
/// No section's guard is another's, so no section's content can displace another's.
|
||||
fn guards(tuning: &Tuning, her: Forms) -> [usize; SECTIONS] {
|
||||
let select = &tuning.select;
|
||||
[select.outcome_bytes, select.promises_bytes, select.here_bytes, select.body_bytes, people_guard(tuning, her), select.domain_bytes, select.notes_bytes]
|
||||
[select.outcome_bytes, select.here_bytes, select.body_bytes, people_guard(tuning, her), select.notes_bytes]
|
||||
}
|
||||
|
||||
/// How long ago a promise was made, in words.
|
||||
|
|
@ -1786,102 +1789,100 @@ fn ago(now: DateTime<Utc>, at: DateTime<Utc>) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
/// Her open promises (map 16.22.1): each `open` or `blocked` entry of her state's `commitments`, oldest first, as a fact
|
||||
/// about her in code's third person, under the section's own guard (`promises_bytes`, I16.8). Past the guard the newest
|
||||
/// that fit are shown and the older ones counted, never dropped silently (I16.11). Her words are her posted words; a
|
||||
/// quote that repeats a run of what she was sent this turn is withheld as the outcome's are (I16.7). The entries shown
|
||||
/// are the Interpreter's list, by id.
|
||||
fn open_promises(inputs: &Inputs, her: Forms, bodies: &[String], context: &mut Context) -> Vec<Promised> {
|
||||
/// Her open promises in her view (map 16.22.1, 16.23.1): every `open` or `blocked` entry of her state's `commitments`,
|
||||
/// oldest first, whole, with her own words, never withheld and never dropped. A dropped promise is what produced the r6
|
||||
/// denials, so past `promises_bytes` every one is still rendered and the overflow is reported. The Interpreter lists
|
||||
/// them all, by id.
|
||||
fn open_promises(inputs: &Inputs, her: Forms) -> (Vec<Promised>, String) {
|
||||
let mut entries: Vec<(DateTime<Utc>, &Value)> = items(inputs.state, &["commitments"])
|
||||
.iter()
|
||||
.filter(|entry| matches!(text(entry, &["status"]), "open" | "blocked"))
|
||||
.map(|entry| (DateTime::parse_from_rfc3339(text(entry, &["madeAt"])).map_or(inputs.now, |at| at.with_timezone(&Utc)), entry))
|
||||
.collect();
|
||||
entries.sort_by_key(|(at, _)| *at);
|
||||
let sent: Vec<&str> = bodies.iter().map(String::as_str).collect();
|
||||
let promised: Vec<Promised> = entries
|
||||
.iter()
|
||||
.map(|(at, entry)| {
|
||||
.enumerate()
|
||||
.map(|(at, (made, entry))| {
|
||||
let to = entry.get("to").and_then(Value::as_str).map(str::to_owned);
|
||||
let room = text(entry, &["room"]);
|
||||
Promised {
|
||||
id: String::new(),
|
||||
id: format!("c{}", at + 1),
|
||||
entry: text(entry, &["id"]).to_owned(),
|
||||
status: text(entry, &["status"]).to_owned(),
|
||||
to_name: to.as_deref().map_or_else(|| "the room".to_owned(), |to| sender_name(to, inputs)),
|
||||
to,
|
||||
place: if room_kind(inputs, room) == RoomKind::Direct { "in a direct message".to_owned() } else { format!("in {room}") },
|
||||
made: ago(inputs.now, *at),
|
||||
made: ago(inputs.now, *made),
|
||||
words: text(entry, &["words"]).to_owned(),
|
||||
held: (*entry).clone(),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let line = |promise: &Promised| {
|
||||
let words = if outcome::repeats(&promise.words, &sent) { outcome::withheld(her) } else { spoken(&promise.words) };
|
||||
let blocked = if promise.status == "blocked" { format!(" {} {} no way to do it yet.", her.cap_subj, her.has) } else { String::new() };
|
||||
format!("- to {}, {}, {}, {} promise: {words}.{blocked}", promise.to_name, promise.made, promise.place, her.poss)
|
||||
};
|
||||
let lines: Vec<String> = promised.iter().map(line).collect();
|
||||
let count = |more: usize| format!("- {more} older {} not shown here.", if more == 1 { "promise is" } else { "promises are" });
|
||||
let room = context.room(Section::Promises).saturating_sub(Section::Promises.heading(her).len() + 1);
|
||||
let cost = |shown: usize| lines[lines.len() - shown..].iter().map(|line| line.len() + 1).sum::<usize>() + if shown < lines.len() { count(lines.len() - shown).len() + 1 } else { 0 };
|
||||
let shown = (0..=lines.len()).rev().find(|&shown| cost(shown) <= room).unwrap_or(0);
|
||||
if shown < lines.len() {
|
||||
context.bound[Section::Promises as usize] = true;
|
||||
context.push(Section::Promises, count(lines.len() - shown));
|
||||
if promised.is_empty() {
|
||||
return (promised, String::new());
|
||||
}
|
||||
let first = lines.len() - shown;
|
||||
let mut listed = Vec::new();
|
||||
for (at, line) in lines.into_iter().enumerate().skip(first) {
|
||||
if context.push(Section::Promises, line) {
|
||||
listed.push(Promised { id: format!("c{}", listed.len() + 1), ..promised[at].clone() });
|
||||
}
|
||||
}
|
||||
listed
|
||||
let lines: Vec<String> = promised
|
||||
.iter()
|
||||
.map(|promise| {
|
||||
let blocked = if promise.status == "blocked" { format!(" {} {} no way to do it yet.", her.cap_subj, her.has) } else { String::new() };
|
||||
format!("- to {}, {}, {}, {} promise: {}.{blocked}", promise.to_name, promise.made, promise.place, her.poss, spoken(&promise.words))
|
||||
})
|
||||
.collect();
|
||||
let block = format!("{} open promises:\n{}", capitalized(her.poss), lines.join("\n"));
|
||||
(promised, block)
|
||||
}
|
||||
|
||||
/// The window a digest shows, in words from where `now` stands: "since 14:00 UTC today", "since yesterday, 21:30 UTC",
|
||||
/// "since Tuesday 17 November, 09:00 UTC".
|
||||
fn window_words(start: DateTime<Utc>, now: DateTime<Utc>) -> String {
|
||||
let time = start.format("%H:%M UTC");
|
||||
match (now.date_naive() - start.date_naive()).num_days() {
|
||||
..=0 => format!("since {time} today"),
|
||||
1 => format!("since yesterday, {time}"),
|
||||
_ => format!("since {}, {time}", start.format("%A %-d %B")),
|
||||
/// A moment in words from where `now` stands: "14:00 UTC today", "yesterday, 21:30 UTC", "Tuesday 17 November, 09:00 UTC".
|
||||
fn time_words(at: DateTime<Utc>, now: DateTime<Utc>) -> String {
|
||||
let time = at.format("%H:%M UTC");
|
||||
match (now.date_naive() - at.date_naive()).num_days() {
|
||||
..=0 => format!("{time} today"),
|
||||
1 => format!("yesterday, {time}"),
|
||||
_ => format!("{}, {time}", at.format("%A %-d %B")),
|
||||
}
|
||||
}
|
||||
|
||||
/// What moved in her domain lately (map 16.22.2): every item of the digest, whole, newest first, under a line that states
|
||||
/// the window, all under the section's own guard (`domain_bytes`, I16.8). Nothing is counted and no item inside the window
|
||||
/// is dropped: when the whole window does not fit, the window shrinks from its old end, a whole minute at a time, until
|
||||
/// everything in it fits, and the line states the window shown. When not even the newest item fits, the section is left
|
||||
/// out and the report says so. The items shown are the Interpreter's, by id.
|
||||
fn domain_lines(inputs: &Inputs, her: Forms, context: &mut Context) -> (Vec<DomainLine>, DomainShown) {
|
||||
/// Her domain in her view (map 16.23.1, 16.23.3, 16.23.5): every item of the window, whole, newest first, under headings
|
||||
/// that state the window: `New since {she} last looked ({time}):` for what came after her last wake, `Earlier, since
|
||||
/// {time}:` for the floor's earlier items. Never a count, never a mention of what fell out: when the whole window does not
|
||||
/// fit `domain_bytes`, the window shrinks from its old end a whole minute at a time, and the heading that holds the oldest
|
||||
/// item kept states where it now starts (`New since {time}:` once it reaches the new items). When not even the newest
|
||||
/// item fits, there is no view of her domain and the report says so. The Interpreter lists every item fetched, by id, so a
|
||||
/// reach by name to one outside her view still resolves.
|
||||
fn domain_view(inputs: &Inputs, her: Forms, room: usize) -> (Vec<DomainLine>, String, DomainShown) {
|
||||
let mut shown = DomainShown::default();
|
||||
let Some(digest) = inputs.domain.filter(|digest| !digest.items.is_empty()) else { return (Vec::new(), shown) };
|
||||
let room = context.room(Section::Domain).saturating_sub(Section::Domain.heading(her).len() + 1);
|
||||
let Some(digest) = inputs.domain.filter(|digest| !digest.items.is_empty()) else { return (Vec::new(), String::new(), shown) };
|
||||
let listed: Vec<DomainLine> = digest.items.iter().enumerate().map(|(at, item)| DomainLine { id: format!("d{}", at + 1), line: item.text.clone(), about: item.about.clone() }).collect();
|
||||
let heading = format!("{} domain, as {} look{} at it now:", capitalized(her.poss), her.subj, her.s);
|
||||
let looked = digest.last_look.filter(|at| *at > digest.since);
|
||||
let mut start = digest.since;
|
||||
loop {
|
||||
let kept: Vec<&Item> = digest.items.iter().filter(|item| item.at >= start).collect();
|
||||
let Some(oldest) = kept.last() else {
|
||||
context.bound[Section::Domain as usize] = true;
|
||||
shown.omitted = Some("not even the newest item fits the section's guard");
|
||||
shown.omitted = Some("not even the newest item fits the domain's guard");
|
||||
shown.left_out = digest.items.len();
|
||||
return (Vec::new(), shown);
|
||||
return (listed, String::new(), shown);
|
||||
};
|
||||
let head = format!("- Everything merged and ruled {}:", window_words(start, digest.now));
|
||||
if head.len() + 1 + kept.iter().map(|item| item.text.len() + 1).sum::<usize>() <= room {
|
||||
context.push(Section::Domain, head);
|
||||
let listed = kept.iter().enumerate().map(|(at, item)| {
|
||||
context.push(Section::Domain, item.text.clone());
|
||||
DomainLine { id: format!("d{}", at + 1), line: item.text.clone(), about: item.about.clone() }
|
||||
});
|
||||
let listed: Vec<DomainLine> = listed.collect();
|
||||
let lines = |items: &[&&Item]| items.iter().map(|item| item.text.clone()).collect::<Vec<_>>().join("\n");
|
||||
let mut parts = vec![heading.clone()];
|
||||
match looked {
|
||||
Some(look) if start <= look => {
|
||||
let (new, earlier): (Vec<&&Item>, Vec<&&Item>) = kept.iter().partition(|item| item.at > look);
|
||||
if !new.is_empty() {
|
||||
parts.push(format!("New since {} last looked ({}):\n{}", her.subj, time_words(look, digest.now), lines(&new)));
|
||||
}
|
||||
if !earlier.is_empty() {
|
||||
parts.push(format!("Earlier, since {}:\n{}", time_words(start, digest.now), lines(&earlier)));
|
||||
}
|
||||
}
|
||||
_ => parts.push(format!("New since {}:\n{}", time_words(start, digest.now), lines(&kept.iter().collect::<Vec<_>>()))),
|
||||
}
|
||||
let block = parts.join("\n");
|
||||
if block.len() <= room {
|
||||
shown.since = Some(start.to_rfc3339());
|
||||
shown.left_out = digest.items.len() - kept.len();
|
||||
context.bound[Section::Domain as usize] |= shown.left_out > 0;
|
||||
return (listed, shown);
|
||||
return (listed, block, shown);
|
||||
}
|
||||
start = floor_minute(oldest.at) + chrono::Duration::minutes(1);
|
||||
}
|
||||
|
|
@ -1895,10 +1896,11 @@ pub(crate) fn people_guard(tuning: &Tuning, her: Forms) -> usize {
|
|||
Section::People.heading(her).len().saturating_add(select.people_full.saturating_mul(bond))
|
||||
}
|
||||
|
||||
const SECTIONS: usize = 7;
|
||||
const SECTIONS: usize = 5;
|
||||
|
||||
/// The bytes each section of the context took as rendered, its heading included, and the sections whose guard refused a
|
||||
/// line: what `--select-only` reports.
|
||||
/// line: what `--select-only` reports. `promises` and `domain` are the bytes of those parts of her view (`in_view`), not
|
||||
/// of the context.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
|
||||
pub(crate) struct Sections {
|
||||
pub outcome: usize,
|
||||
|
|
@ -1924,7 +1926,7 @@ struct Context {
|
|||
|
||||
impl Context {
|
||||
fn new(guards: [usize; SECTIONS], her: Forms) -> Self {
|
||||
Self { sections: [Section::Outcome, Section::Promises, Section::Here, Section::Body, Section::People, Section::Domain, Section::Notes].map(|section| (section.heading(her), Vec::new())), guards, used: [0; SECTIONS], bound: [false; SECTIONS] }
|
||||
Self { sections: [Section::Outcome, Section::Here, Section::Body, Section::People, Section::Notes].map(|section| (section.heading(her), Vec::new())), guards, used: [0; SECTIONS], bound: [false; SECTIONS] }
|
||||
}
|
||||
|
||||
fn cost(&self, section: Section, line: &str) -> usize {
|
||||
|
|
@ -1966,8 +1968,8 @@ impl Context {
|
|||
|
||||
fn sizes(&self) -> Sections {
|
||||
let bytes = |section: Section| self.used[section as usize].saturating_sub(1);
|
||||
let names = ["outcome", "promises", "here", "body", "people", "domain", "notes"];
|
||||
Sections { outcome: bytes(Section::Outcome), promises: bytes(Section::Promises), here: bytes(Section::Here), body: bytes(Section::Body), people: bytes(Section::People), domain: bytes(Section::Domain), notes: bytes(Section::Notes), bound: names.into_iter().zip(self.bound).filter_map(|(name, bound)| bound.then_some(name)).collect() }
|
||||
let names = ["outcome", "here", "body", "people", "notes"];
|
||||
Sections { outcome: bytes(Section::Outcome), promises: 0, here: bytes(Section::Here), body: bytes(Section::Body), people: bytes(Section::People), domain: 0, notes: bytes(Section::Notes), bound: names.into_iter().zip(self.bound).filter_map(|(name, bound)| bound.then_some(name)).collect() }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2055,7 +2057,7 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
unshown = (shown..outcome.len()).map(|at| outcome.line(at, her, usize::MAX, &bodies)).collect();
|
||||
}
|
||||
}
|
||||
let promises = open_promises(inputs, her, &bodies, &mut context);
|
||||
let (promises, promises_view) = open_promises(inputs, her);
|
||||
let present_ids: BTreeSet<String> = present.iter().map(|(id, _)| id.clone()).collect();
|
||||
let bonds = items(inputs.state, &["affect", "socialBonds"]);
|
||||
context.force(Section::Here, format!("- now: {}", inputs.now.format("%A %-d %B, %H:%M UTC")));
|
||||
|
|
@ -2103,7 +2105,7 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
_ => named.push((also, turned.is_some())),
|
||||
}
|
||||
}
|
||||
let (domain, domain_shown) = domain_lines(inputs, her, &mut context);
|
||||
let (domain, domain_view, domain_shown) = domain_view(inputs, her, tuning.select.domain_bytes);
|
||||
// Here's room lines take its room by priority (map 16.21): the conversation, which opens with whoever turned to her
|
||||
// here; the arrivals on the also-here line (its least line, reserved); the pronouns, clipped to what is left; the
|
||||
// other names present. They are rendered in reading order: the pronouns, the conversation, the also-here line.
|
||||
|
|
@ -2183,5 +2185,12 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
.map(|(at, (event, room, text))| Amendable { id: format!("a{}", at + 1), event: event.clone(), room: room.clone(), text: text.clone() })
|
||||
.collect();
|
||||
let selected = taken.into_iter().map(|candidate| Pick { id: candidate.id, pool: candidate.pool, log_score: candidate.log_score }).collect();
|
||||
Packet { kind: inputs.kind, seed: inputs.seed, lens, name, voice, context: context.render(), sections: context.sizes(), stimulus, heard, bridged, overflow, present: present_names, ids, selected, forms: her, people: people_in_view(inputs, tuning), affordances: inputs.affordances.to_vec(), room: turn_room(inputs).map(str::to_owned), room_kind: turn_room(inputs).map_or(RoomKind::Public, |room| room_kind(inputs, room)), bodies, private, clipped, amendable, quotable, promises, domain, domain_shown, arrival, speaking: conversation.speaking.unwrap_or_default(), unshown }
|
||||
// Her view (map 16.23.1): promises, then her domain; the room follows them in what she reads (`narrate::read_after`).
|
||||
let promises_over = promises_view.len() > tuning.select.promises_bytes;
|
||||
let in_view = [promises_view.as_str(), domain_view.as_str()].into_iter().filter(|part| !part.is_empty()).collect::<Vec<_>>().join("\n\n");
|
||||
let mut sections = context.sizes();
|
||||
(sections.promises, sections.domain) = (promises_view.len(), domain_view.len());
|
||||
// Her own words: her lines in the room and her promises', for the outcome guard (map 16.23.4).
|
||||
let own_words: Vec<String> = inputs.room.messages.iter().chain(&inputs.room.tail).filter(|line| line.sender == inputs.people.own_sender).map(|line| line.text.clone()).chain(items(inputs.state, &["commitments"]).iter().map(|entry| text(entry, &["words"]).to_owned())).filter(|words| !words.is_empty()).collect();
|
||||
Packet { kind: inputs.kind, seed: inputs.seed, lens, name, voice, context: context.render(), sections, stimulus, heard, bridged, overflow, present: present_names, ids, selected, forms: her, people: people_in_view(inputs, tuning), affordances: inputs.affordances.to_vec(), room: turn_room(inputs).map(str::to_owned), room_kind: turn_room(inputs).map_or(RoomKind::Public, |room| room_kind(inputs, room)), bodies, private, clipped, amendable, quotable, promises, domain, domain_shown, in_view, promises_over, own_words, arrival, speaking: conversation.speaking.unwrap_or_default(), unshown }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -691,8 +691,8 @@ fn transcript_line(line: &Value) -> String {
|
|||
/// What a turn did to her promises, as the report shows it (B4): the open-promises section her packet showed her, the
|
||||
/// state changes the Interpreter proposed, and what the commit opened and refused.
|
||||
fn promises_markdown(out: &mut String, turn: &Value) {
|
||||
let context = turn["report"]["packet"]["context"].as_str().unwrap_or_default();
|
||||
let section: Vec<&str> = context.lines().skip_while(|line| !line.ends_with(" open promises:")).take_while(|line| line.ends_with(" open promises:") || line.starts_with("- ")).collect();
|
||||
let view = turn["report"]["packet"]["in_view"].as_str().unwrap_or_default();
|
||||
let section: Vec<&str> = view.lines().skip_while(|line| !line.ends_with(" open promises:")).take_while(|line| line.ends_with(" open promises:") || line.starts_with("- ")).collect();
|
||||
if !section.is_empty() {
|
||||
let _ = writeln!(out, "Open promises, as her packet showed them:\n\n````text\n{}\n````\n", section.join("\n"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -629,7 +629,7 @@ fn k22_a_promise_persists_across_silent_turns_until_the_person_releases_it() {
|
|||
assert_eq!(rounds, [1, 2, 3, 4], "{:?}", turns(&run));
|
||||
let opened = &his[0]["committed"]["opened"][0];
|
||||
assert_eq!((opened["status"].as_str(), opened["to"].as_str(), opened["words"].as_str()), (Some("blocked"), Some("@meta:gamecult.org"), Some("I'll send the render tonight.")), "{}", his[0]["committed"]);
|
||||
let context = |turn: &Value| turn["report"]["packet"]["context"].as_str().unwrap().to_owned();
|
||||
let context = |turn: &Value| turn["report"]["packet"]["in_view"].as_str().unwrap().to_owned();
|
||||
let shown = "His open promises:\n- to Meta";
|
||||
assert_eq!((his[1]["outcome"].as_str(), context(his[1]).contains(shown), context(his[2]).contains(shown)), (Some("silent"), true, true), "it stays in front of him through a silent turn: {}", context(his[1]));
|
||||
assert!(context(his[1]).contains("his promise: \"I'll send the render tonight.\". He has no way to do it yet."), "{}", context(his[1]));
|
||||
|
|
@ -682,10 +682,12 @@ says = "good afternoon, everyone"
|
|||
.unwrap();
|
||||
let model = silent();
|
||||
run_plan(&path, &model);
|
||||
let projector: Vec<String> = model.calls.borrow().iter().filter(|(_, prompt)| prompt.starts_with(PROJECTOR_OPENING)).map(|(_, prompt)| prompt.clone()).collect();
|
||||
let with: Vec<&String> = projector.iter().filter(|prompt| prompt.contains("GameCult/Lodur: merged \"Reflex: the knee bends first\"")).collect();
|
||||
assert!(!with.is_empty() && with.len() < projector.len(), "{} of {}", with.len(), projector.len());
|
||||
assert!(with.iter().all(|prompt| !prompt.contains("Libby Test")), "only his packets carry his domain");
|
||||
let calls = model.calls.borrow();
|
||||
assert!(calls.iter().filter(|(_, prompt)| prompt.starts_with(PROJECTOR_OPENING)).all(|(_, prompt)| !prompt.contains("Reflex")), "the Projector gets nothing of it");
|
||||
let persona: Vec<&String> = calls.iter().map(|(_, prompt)| prompt).filter(|prompt| !prompt.starts_with(PROJECTOR_OPENING) && !prompt.starts_with(crate::projection::interpret::SPEECH_OPENING)).collect();
|
||||
let with: Vec<&&String> = persona.iter().filter(|prompt| prompt.contains("GameCult/Lodur: merged \"Reflex: the knee bends first\"")).collect();
|
||||
assert!(!with.is_empty() && with.len() < persona.len(), "{} of {}", with.len(), persona.len());
|
||||
assert!(with.iter().all(|prompt| prompt.contains("Who you are:\nTobiah")), "only his view carries his domain");
|
||||
}
|
||||
|
||||
/// B4: the report shows what is verified: her open promises as her packet showed them, the state proposed, and what the
|
||||
|
|
@ -694,7 +696,7 @@ says = "good afternoon, everyone"
|
|||
fn b4_a_turns_details_show_her_promises_the_proposals_and_the_commit() {
|
||||
let turn = json!({
|
||||
"report": {
|
||||
"packet": { "context": "What came of his last turn:\n- x.\nHis open promises:\n- to Meta, 2 h ago, in #minds:gamecult.org, his promise: \"I'll send the render tonight.\". He has no way to do it yet.\nHere and now:\n- now: Friday" },
|
||||
"packet": { "in_view": "His open promises:\n- to Meta, 2 h ago, in #minds:gamecult.org, his promise: \"I'll send the render tonight.\". He has no way to do it yet.\n\nHis domain, as he looks at it now:" },
|
||||
"renders": [{ "interpreter": { "state": [{ "kind": "promise_close", "promise": "c1", "how": "withdrawn", "evidence": { "draft": 1 } }] } }]
|
||||
},
|
||||
"committed": {
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ fn within_guards(packet: &Packet, tuning: &Tuning) {
|
|||
for (name, bytes, guard) in [("outcome", sections.outcome, select.outcome_bytes), ("promises", sections.promises, select.promises_bytes), ("here", sections.here, select.here_bytes), ("body", sections.body, select.body_bytes), ("people", sections.people, select::people_guard(tuning, packet.forms)), ("domain", sections.domain, select.domain_bytes), ("notes", sections.notes, select.notes_bytes)] {
|
||||
assert!(bytes <= guard, "{name}: {bytes} bytes over its guard of {guard}:\n{}", packet.context);
|
||||
}
|
||||
let shown: Vec<usize> = [sections.outcome, sections.promises, sections.here, sections.body, sections.people, sections.domain, sections.notes].into_iter().filter(|bytes| *bytes > 0).collect();
|
||||
let shown: Vec<usize> = [sections.outcome, sections.here, sections.body, sections.people, sections.notes].into_iter().filter(|bytes| *bytes > 0).collect();
|
||||
assert_eq!(shown.iter().sum::<usize>() + shown.len().saturating_sub(1), packet.context.len(), "the reported bytes are the rendered ones");
|
||||
}
|
||||
|
||||
|
|
@ -2591,27 +2591,30 @@ fn promising(entries: usize) -> Value {
|
|||
with
|
||||
}
|
||||
|
||||
/// Map 16.22.1: her open promises are a section of every packet, from her state, after the outcome and before Here and
|
||||
/// now, in code's third person; a blocked one says she has no way to do it yet; a closed one is not shown. The
|
||||
/// Interpreter lists the same ones by id. Past the section's own guard the newest are shown and the rest counted.
|
||||
/// Map 16.22.1 as 16.23.1 moves it: her open promises are in her view, after the narration, every one whole with her own
|
||||
/// words, oldest first, in code's third person; a blocked one says she has no way to do it yet; a closed one is not shown.
|
||||
/// The Projector gets nothing of them. The Interpreter lists them all by id. Past `promises_bytes` none is dropped: every
|
||||
/// one is still shown, and the report says they overflowed (the coordinator's K25 rule).
|
||||
#[test]
|
||||
fn k22_her_open_promises_are_a_section_of_every_packet_and_the_interpreters_list() {
|
||||
fn k22_her_open_promises_are_in_her_view_whole_and_the_interpreters_list() {
|
||||
let packet = packet_of(TurnKind::Chat, &promising(1), &chat_room(), &History::default(), 1);
|
||||
let line = "Her open promises:\n- to Meta, the operator, 2 days ago, in #swarm:gamecult.org, her promise: \"I'll send the render tonight, part 0.\". She has no way to do it yet.\nHere and now:";
|
||||
assert!(packet.context.contains(line) && !packet.context.contains("KEPT-ONE"), "{}", packet.context);
|
||||
let line = "Her open promises:\n- to Meta, the operator, 2 days ago, in #swarm:gamecult.org, her promise: \"I'll send the render tonight, part 0.\". She has no way to do it yet.";
|
||||
assert!(packet.in_view.starts_with(line) && !packet.in_view.contains("KEPT-ONE"), "{}", packet.in_view);
|
||||
assert!(!packet.context.contains("open promises") && !narrate::projector_prompt(&packet, &Tuning::default()).contains("render tonight"), "the Projector gets nothing of them");
|
||||
assert_eq!((packet.promises.len(), packet.promises[0].id.as_str(), packet.promises[0].entry.as_str()), (1, "c1", "c-r1-t1-0"));
|
||||
let speech = interpret::speech_prompt(&packet, "The room is warm.", "y", &Tuning::default());
|
||||
assert!(speech.contains("Her open promises, as id \u{2014} to whom: words:\n- c1 \u{2014} to Meta, the operator (@meta:gamecult.org), which she has no way to do, made 2 days ago in #swarm:gamecult.org: \"I'll send the render tonight, part 0.\""), "{speech}");
|
||||
assert!(!narrate::projector_prompt(&packet, &Tuning::default()).contains("c-r1-t1-0"), "the state's id never reaches a model");
|
||||
let persona = narrate::persona_prompt(&packet, "The room is warm.", &Tuning::default());
|
||||
assert!(persona.contains(line) && !persona.contains("c1") && !persona.contains("c-r1-t1-0"), "in her view, with no id: {persona}");
|
||||
// A beat shows them too: they are facts about her, not about the turn.
|
||||
assert!(packet_of(TurnKind::Beat, &promising(1), &chat_room(), &History::default(), 1).context.contains("Her open promises:"));
|
||||
// Past the guard: the newest that fit, oldest first, and the rest counted, never dropped silently.
|
||||
let crowded = packet_of(TurnKind::Chat, &promising(12), &chat_room(), &History::default(), 1);
|
||||
let section = crowded.context.split("Here and now:").next().unwrap();
|
||||
assert!(section.len() <= Tuning::default().select.promises_bytes + "Here and now:".len(), "{section}");
|
||||
let counted: usize = section.lines().find_map(|line| line.strip_prefix("- ").and_then(|rest| rest.split(" older promises are not shown here.").next()).and_then(|n| n.parse().ok())).expect("a counted line");
|
||||
assert_eq!(counted + crowded.promises.len(), 12, "{section}");
|
||||
assert!(section.contains("part 11.") && !section.contains("part 0."), "the newest are kept: {section}");
|
||||
assert!(packet_of(TurnKind::Beat, &promising(1), &chat_room(), &History::default(), 1).in_view.contains("Her open promises:"));
|
||||
// Past the guard: every one shown, oldest first, none dropped, and the overflow reported.
|
||||
let mut tight = Tuning::default();
|
||||
tight.select.promises_bytes = 300;
|
||||
let crowded = packet_tuned(TurnKind::Chat, &promising(12), &chat_room(), &History::default(), 1, &tight);
|
||||
assert!((0..12).all(|at| crowded.in_view.contains(&format!("part {at}."))) && crowded.promises.len() == 12 && crowded.promises_over, "{}", crowded.in_view);
|
||||
assert!(crowded.in_view.find("part 0.") < crowded.in_view.find("part 11."), "oldest first");
|
||||
assert!(!crowded.in_view.contains("not shown") && !crowded.in_view.contains("made before"), "no count and no cut");
|
||||
}
|
||||
|
||||
/// Map 16.22.1 and 16.22.7: a close is told once, in the outcome of the turn after it; a refused close says the promise
|
||||
|
|
@ -2642,9 +2645,9 @@ fn packet_with_domain(digest: Option<&domain::Digest>, tuning: &Tuning) -> Packe
|
|||
select(&inputs, tuning)
|
||||
}
|
||||
|
||||
/// The lines of the domain section as rendered, heading excluded.
|
||||
/// The lines of her domain in her view, its heading excluded: the window's headings and the items under them.
|
||||
fn domain_section(packet: &Packet) -> Vec<String> {
|
||||
packet.context.lines().skip_while(|line| *line != "In her domain lately:").skip(1).take_while(|line| line.starts_with("- ")).map(str::to_owned).collect()
|
||||
packet.in_view.lines().skip_while(|line| *line != "Her domain, as she looks at it now:").skip(1).map(str::to_owned).collect()
|
||||
}
|
||||
|
||||
/// Nine merged pull requests, one an hour back from an hour ago, in a window that opened two days ago.
|
||||
|
|
@ -2652,71 +2655,85 @@ fn nine() -> domain::Digest {
|
|||
let items = (1..=9)
|
||||
.map(|n| domain::Item { at: now() - chrono::Duration::hours(n), text: format!("- GameCult/Repo{n}: merged \"Change {n}, made whole\", opened by kiko"), about: domain::About::Repo(format!("GameCult/Repo{n}")) })
|
||||
.collect();
|
||||
domain::Digest { since: now() - chrono::Duration::days(2), now: now(), items }
|
||||
domain::Digest { since: now() - chrono::Duration::days(2), last_look: Some(now() - chrono::Duration::minutes(270)), now: now(), items }
|
||||
}
|
||||
|
||||
/// What moved in her domain is its own section under its own guard: a line stating the window, then every item in it,
|
||||
/// whole; the Projector's as news and the Interpreter's by id. No count, no "more". Past the guard the window shrinks
|
||||
/// from its old end until everything in it fits, never dropping an item inside it; when not even the newest fits, the
|
||||
/// section is left out and the report says so.
|
||||
/// Map 16.23: her domain is in her view, after the narration, whole: what came after her last look under `New since she
|
||||
/// last looked (…)`, the rest of the window under `Earlier, since …`, every item complete; the Projector gets nothing of
|
||||
/// it; the Persona sees no id and the Interpreter every item fetched, by id. No count, no "more". Past `domain_bytes` the
|
||||
/// window shrinks from its old end and the heading holding the oldest item kept states where it now starts; dropped items
|
||||
/// still resolve for the Interpreter. When not even the newest fits, there is no view of it and the report says so.
|
||||
#[test]
|
||||
fn k23_her_domain_shows_everything_in_a_stated_window_and_shrinks_the_window_never_the_items() {
|
||||
fn k25_her_domain_is_in_her_view_whole_in_a_stated_window_that_shrinks_and_never_counts() {
|
||||
let tuning = Tuning::default();
|
||||
let digest = nine();
|
||||
let packet = packet_with_domain(Some(&digest), &tuning);
|
||||
let shown = domain_section(&packet);
|
||||
assert_eq!(shown[0], format!("- Everything merged and ruled since {}:", (now() - chrono::Duration::days(2)).format("%A %-d %B, %H:%M UTC")), "{shown:?}");
|
||||
assert_eq!(shown[1..].to_vec(), digest.items.iter().map(|item| item.text.clone()).collect::<Vec<_>>(), "every item in the window, whole, newest first");
|
||||
let texts: Vec<String> = digest.items.iter().map(|item| item.text.clone()).collect();
|
||||
let look = now() - chrono::Duration::minutes(270);
|
||||
let earlier_start = now() - chrono::Duration::days(2);
|
||||
let mut expected = vec![format!("New since she last looked ({} today):", look.format("%H:%M UTC"))];
|
||||
expected.extend(texts[..4].iter().cloned());
|
||||
expected.push(format!("Earlier, since {}:", earlier_start.format("%A %-d %B, %H:%M UTC")));
|
||||
expected.extend(texts[4..].iter().cloned());
|
||||
assert_eq!(shown, expected, "{}", packet.in_view);
|
||||
assert!(!packet.context.contains("GameCult/Repo") && !narrate::projector_prompt(&packet, &tuning).contains("Change 1"), "the Projector gets nothing of it");
|
||||
let persona = narrate::persona_prompt(&packet, "The room is warm.", &tuning);
|
||||
assert!(persona.contains("Her domain, as she looks at it now:\nNew since she last looked") && !persona.contains("d1"), "{persona}");
|
||||
assert_eq!(packet.domain.iter().map(|line| line.id.as_str()).collect::<Vec<_>>(), ["d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9"]);
|
||||
assert_eq!((packet.domain_shown.left_out, packet.domain_shown.omitted), (0, None));
|
||||
within_guards(&packet, &tuning);
|
||||
let speech = interpret::speech_prompt(&packet, "The room is warm.", "y", &tuning);
|
||||
assert!(speech.contains("What moved in her domain lately, as id \u{2014} line (news of her part of the coop, none of it work she owes):\n- d1 \u{2014} GameCult/Repo1: merged \"Change 1, made whole\", opened by kiko\n- d2 \u{2014} GameCult/Repo2"), "{speech}");
|
||||
let projector = narrate::projector_prompt(&packet, &tuning);
|
||||
assert!(projector.contains("In her domain lately:\n- Everything merged and ruled since") && !projector.contains("d1 \u{2014}"), "ids are the Interpreter's alone");
|
||||
assert!(speech.contains("- d1 \u{2014} GameCult/Repo1: merged \"Change 1, made whole\", opened by kiko\n- d2 \u{2014} GameCult/Repo2"), "{speech}");
|
||||
|
||||
// Past the guard: the window shrinks to the newest whole minutes that fit, and says so; every item inside it is there.
|
||||
// Past the guard: the window shrinks into the new items, says where it starts, and every item inside it is there.
|
||||
let mut tight = Tuning::default();
|
||||
tight.select.domain_bytes = 300;
|
||||
let bound = packet_with_domain(Some(&digest), &tight);
|
||||
within_guards(&bound, &tight);
|
||||
let shown = domain_section(&bound);
|
||||
let start = DateTime::parse_from_rfc3339(bound.domain_shown.since.as_deref().unwrap()).unwrap().with_timezone(&Utc);
|
||||
assert!(start > digest.since && shown[0] == format!("- Everything merged and ruled {}:", if start.date_naive() == now().date_naive() { format!("since {} today", start.format("%H:%M UTC")) } else { format!("since yesterday, {}", start.format("%H:%M UTC")) }), "{shown:?}");
|
||||
let inside: Vec<String> = digest.items.iter().filter(|item| item.at >= start).map(|item| item.text.clone()).collect();
|
||||
assert!(!inside.is_empty() && inside.len() < 9 && shown[1..] == inside[..], "everything inside the stated window, nothing outside it: {shown:?}");
|
||||
assert!(start > look && shown[0] == format!("New since {} today:", start.format("%H:%M UTC")) && shown[1..] == inside[..] && !inside.is_empty(), "{shown:?}");
|
||||
assert_eq!(bound.domain_shown.left_out, 9 - inside.len());
|
||||
assert_eq!(bound.domain.len(), 9, "every item fetched still resolves for the Interpreter");
|
||||
|
||||
// Not even the newest item fits: no section, and the report says why.
|
||||
// Not even the newest item fits: no view of it, and the report says why.
|
||||
let mut tiny = Tuning::default();
|
||||
tiny.select.domain_bytes = 128;
|
||||
let long = domain::Digest { items: vec![domain::Item { at: now() - chrono::Duration::hours(1), text: format!("- GameCult/Long: merged \"{}\", opened by kiko", "y".repeat(200)), about: domain::About::Repo("GameCult/Long".into()) }], ..nine() };
|
||||
let none = packet_with_domain(Some(&long), &tiny);
|
||||
assert!(!none.context.contains("domain lately") && none.domain.is_empty() && none.domain_shown.omitted.is_some(), "{}", none.context);
|
||||
assert!(!none.in_view.contains("domain") && none.domain_shown.omitted.is_some(), "{}", none.in_view);
|
||||
|
||||
// No count and no "more", in any of them.
|
||||
for packet in [&packet, &bound] {
|
||||
let section = domain_section(packet).join("\n");
|
||||
assert!(!section.contains(" more") && !section.contains("pull requests") && !section.contains("things"), "{section}");
|
||||
assert!(!section.contains(" more") && !section.contains("pull requests") && !section.contains("things") && !section.contains("left out"), "{section}");
|
||||
}
|
||||
|
||||
// Nothing moved (or the read failed, which `project` reports): no heading at all, and no "nothing moved".
|
||||
// Nothing moved (or the read failed, which `project` reports): no heading at all.
|
||||
let quiet = packet_with_domain(None, &tuning);
|
||||
assert!(!quiet.context.contains("domain lately") && !interpret::speech_prompt(&quiet, "x", "y", &tuning).contains("domain lately"), "{}", quiet.context);
|
||||
assert!(quiet.in_view.is_empty() && !interpret::speech_prompt(&quiet, "x", "y", &tuning).contains("domain lately"), "{}", quiet.in_view);
|
||||
}
|
||||
|
||||
/// B2: her own posted lines are never what she was sent. A promise of hers whose words stand in the room as her own line
|
||||
/// is shown, not withheld; someone else's words in the room still withhold a quote that repeats them (I16.7).
|
||||
/// Map 16.23.4: the outcome guard compares against others' words only, minus any run she wrote first. Her line that
|
||||
/// Meta quotes back is hers and is shown; a quote that repeats Meta's own words is still withheld.
|
||||
#[test]
|
||||
fn b2_her_own_lines_never_withhold_her_promise_words() {
|
||||
fn k25_the_outcome_guard_withholds_only_others_words() {
|
||||
let mine = "I'll send the render tonight, after the boil.";
|
||||
let record = |own: Value| json!({ "interpreter": { "room": "#swarm:gamecult.org", "said": [{ "room": "#swarm:gamecult.org", "text": mine }], "refused": [], "gaps": [], "heard": ["Meta: you said I'll send the render tonight, after the boil, and I believe you"], "own": own }, "posted": [{ "event": "e1", "room": "#swarm:gamecult.org", "text": mine }] });
|
||||
let told = |record: &Value| outcome::outcome_of(record).unwrap().lines(select::forms(&state()));
|
||||
assert_eq!(told(&record(json!([mine]))), [format!("- #swarm:gamecult.org has, from her: \"{mine}\".")], "quoted back, still hers");
|
||||
assert_eq!(told(&record(json!([]))), ["- #swarm:gamecult.org has, from her: (her words, not shown here).".to_owned()], "Meta's words with no line of hers behind them are withheld");
|
||||
}
|
||||
|
||||
/// B2, and 16.23.4: her own posted lines are never what she was sent, and her promises are in her view whole: not
|
||||
/// withheld for her own line in the room, nor for someone repeating them.
|
||||
#[test]
|
||||
fn b2_her_promise_words_are_never_withheld() {
|
||||
let mut room = chat_room();
|
||||
room.messages.push(message("#swarm:gamecult.org", OWN, "Eureka", "Meta, I'll send the render tonight, part 0.", 30, false));
|
||||
let packet = packet_of(TurnKind::Chat, &promising(1), &room, &History::default(), 1);
|
||||
assert!(packet.context.contains("her promise: \"I'll send the render tonight, part 0.\"."), "{}", packet.context);
|
||||
assert!(packet.in_view.contains("her promise: \"I'll send the render tonight, part 0.\"."), "{}", packet.in_view);
|
||||
assert!(!packet.bodies.iter().any(|body| body.contains("part 0")), "{:?}", packet.bodies);
|
||||
// Kiko saying the same words withholds them: others' words stay guarded.
|
||||
let mut echoed = chat_room();
|
||||
echoed.messages.push(message("#swarm:gamecult.org", "@kiko:gamecult.org", "Kiko", "she said she'll send the render tonight, part 0.", 1, false));
|
||||
let packet = packet_of(TurnKind::Chat, &promising(1), &echoed, &History::default(), 1);
|
||||
assert!(packet.context.contains("her promise: (her words, not shown here)."), "{}", packet.context);
|
||||
assert!(packet.in_view.contains("her promise: \"I'll send the render tonight, part 0.\"."), "{}", packet.in_view);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,11 +137,11 @@ pub struct SelectTuning {
|
|||
pub here_bytes: usize,
|
||||
/// What came of her last turn, in bytes, heading included: taken first, under its own guard (map 16.16).
|
||||
pub outcome_bytes: usize,
|
||||
/// Her open promises, in bytes, heading included: under their own guard (map 16.22.1, I16.8).
|
||||
/// Her open promises in her view, in bytes, heading included (map 16.23): a measure, never a cut. Every open promise is
|
||||
/// shown whole; past it the report says the promises overflowed.
|
||||
pub promises_bytes: usize,
|
||||
/// What moved in her domain lately, in bytes, heading included: under its own guard (map 16.22.2, I16.8). It is her
|
||||
/// main window on her domain, so it is generous: about twenty whole items at their usual length. A busier window does
|
||||
/// not crowd the packet: it shrinks to the newest whole minutes that fit.
|
||||
/// Her domain in her view, in bytes, headings included (map 16.23.3): her main window on her domain, so generous, Soul's
|
||||
/// 3000 B log and a margin. A busier window does not crowd her view: it shrinks from its old end to what fits.
|
||||
pub domain_bytes: usize,
|
||||
pub stimulus_bytes: usize,
|
||||
/// What was said to her, verbatim, for the Persona stage: on a chat turn, the room's earlier lines too, before the new
|
||||
|
|
@ -246,8 +246,8 @@ impl Default for SelectTuning {
|
|||
notes_bytes: 5120,
|
||||
here_bytes: 768,
|
||||
outcome_bytes: 1200,
|
||||
promises_bytes: 600,
|
||||
domain_bytes: 3000,
|
||||
promises_bytes: 2000,
|
||||
domain_bytes: 4000,
|
||||
stimulus_bytes: 1500,
|
||||
heard_bytes: 2500,
|
||||
addressed_bytes: 8 * 1024,
|
||||
|
|
|
|||
Loading…
Reference in a new issue