projector: she feels her whole state each wake
Select now renders what was written and never read: her strongest drives as pressing lines and her ready, unexpired intentions as means-to-do lines (fixed slots under the notes' guard, never drawn); named feelings in the mood line, read after decay with their source; her read of a person and the claim that last moved a bond on that bond line; a bond line for each person the lines she is shown name though absent; her standing tendencies with her identity. Words, never numbers; every line under the item's own privacy scope; no one's words reach the Projector, only her own state's text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1dbc8f443b
commit
c42ff2f39b
5 changed files with 375 additions and 29 deletions
|
|
@ -336,7 +336,7 @@ fn packet_json(packet: &Packet) -> Value {
|
||||||
"present": packet.present,
|
"present": packet.present,
|
||||||
"selected": packet.selected,
|
"selected": packet.selected,
|
||||||
// Each section's bytes under its own guard, and the sum the Projector is shown of her (map 16.19.4).
|
// Each section's bytes under its own guard, and the sum the Projector is shown of her (map 16.19.4).
|
||||||
"bytes": { "identity": packet.identity().len(), "outcome": packet.sections.outcome, "here": packet.sections.here, "body": packet.sections.body, "people": packet.sections.people, "domain": packet.sections.domain, "notes": packet.sections.notes, "total": packet.identity().len() + packet.context.len(), "stimulus": packet.stimulus.len(), "arrival": packet.arrival.len(), "heard": packet.heard.len() },
|
"bytes": { "identity": packet.identity().len(), "tendencies": packet.tendencies.len(), "outcome": packet.sections.outcome, "here": packet.sections.here, "body": packet.sections.body, "people": packet.sections.people, "domain": packet.sections.domain, "notes": packet.sections.notes, "total": packet.identity().len() + packet.tendencies.len() + packet.context.len(), "stimulus": packet.stimulus.len(), "arrival": packet.arrival.len(), "heard": packet.heard.len() },
|
||||||
"bound": packet.sections.bound,
|
"bound": packet.sections.bound,
|
||||||
"overflow": packet.overflow,
|
"overflow": packet.overflow,
|
||||||
"clipped": packet.clipped,
|
"clipped": packet.clipped,
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ fn quotes(note: &str, bodies: &[String]) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A named feeling's value after `hours` since it was set: it halves every `FEELING_HALF_LIFE_HOURS`. The one decay.
|
/// A named feeling's value after `hours` since it was set: it halves every `FEELING_HALF_LIFE_HOURS`. The one decay.
|
||||||
fn decayed(value: f64, hours: f64) -> f64 {
|
pub(super) fn decayed(value: f64, hours: f64) -> f64 {
|
||||||
value * 0.5_f64.powf(hours.max(0.0) / FEELING_HALF_LIFE_HOURS)
|
value * 0.5_f64.powf(hours.max(0.0) / FEELING_HALF_LIFE_HOURS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,7 @@ pub(crate) fn projector_frame(her: Forms) -> String {
|
||||||
|
|
||||||
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 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."
|
Render the two or three notes this moment touches and leave the rest, but what presses on {obj} and what {subj} mean{s} to do, the feelings in {poss} mood and {poss} standing tendencies are with {obj} whether or not the moment touches them: let them color the stream without naming them as a list. 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."
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -276,6 +276,8 @@ pub(crate) const PROJECTOR_OPENING: &str = "You are a private Projector.";
|
||||||
pub(crate) fn projector_prompt(packet: &Packet, tuning: &Tuning) -> String {
|
pub(crate) fn projector_prompt(packet: &Packet, tuning: &Tuning) -> String {
|
||||||
let her = packet.forms;
|
let her = packet.forms;
|
||||||
let voice = if packet.voice.is_empty() { String::new() } else { format!("How {} words run:\n{}\n\n", her.poss, packet.voice) };
|
let voice = if packet.voice.is_empty() { String::new() } else { format!("How {} words run:\n{}\n\n", her.poss, packet.voice) };
|
||||||
|
let who = if packet.tendencies.is_empty() { packet.name.clone() } else { format!("{}
|
||||||
|
{}", packet.name, packet.tendencies) };
|
||||||
let arrival = if packet.arrival.is_empty() { String::new() } else { format!("\n\nWhat reaches {}:\n{}", her.obj, packet.arrival) };
|
let arrival = if packet.arrival.is_empty() { String::new() } else { format!("\n\nWhat reaches {}:\n{}", her.obj, packet.arrival) };
|
||||||
format!(
|
format!(
|
||||||
"{}\n\n{voice}Guidance:\n{}\n\nBegin from {}.\n\nWho {} {}:\n{}\n\n{}{arrival}\n\nUse at most {} words. Return only the lived stream.",
|
"{}\n\n{voice}Guidance:\n{}\n\nBegin from {}.\n\nWho {} {}:\n{}\n\n{}{arrival}\n\nUse at most {} words. Return only the lived stream.",
|
||||||
|
|
@ -284,7 +286,7 @@ pub(crate) fn projector_prompt(packet: &Packet, tuning: &Tuning) -> String {
|
||||||
packet.lens.words(&packet.forms),
|
packet.lens.words(&packet.forms),
|
||||||
her.subj,
|
her.subj,
|
||||||
her.be,
|
her.be,
|
||||||
packet.name,
|
who,
|
||||||
packet.context,
|
packet.context,
|
||||||
word_budget(packet.kind, tuning),
|
word_budget(packet.kind, tuning),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,11 @@
|
||||||
//! it, never under a bonded person's name. Every message body and display name is rendered by one escape (`spoken`, a
|
//! it, never under a bonded person's name. Every message body and display name is rendered by one escape (`spoken`, a
|
||||||
//! JSON string), so no text can forge a line; speaker and room come from the mouth's metadata alone.
|
//! JSON string), so no text can forge a line; speaker and room come from the mouth's metadata alone.
|
||||||
//!
|
//!
|
||||||
//! Never read: `agencyPressure`, `candidateActions`, `privateNotes` and `provenance`. Whether an item is private, and
|
//! What presses on her, what she means to do and what she feels are shown as fixed lines, never drawn: her strongest drives
|
||||||
|
//! (`Pool::Pressure`), her ready intentions (`Pool::Intention`), her strongest named feelings in the mood line, her read of a
|
||||||
|
//! person and what last moved a bond on its bond line, a bond line for each person the lines she is shown name though absent,
|
||||||
|
//! and her standing tendencies with her identity (`tendencies`). All of it is her state's own text, in words and never numbers,
|
||||||
|
//! and never someone else's words (I16.7). Never read: `privateNotes` and `provenance`. Whether an item is private, and
|
||||||
//! whom it concerns, is read by one function (`concerns`); how a private item reaches the packet, by one other (`scope`).
|
//! whom it concerns, is read by one function (`concerns`); how a private item reaches the packet, by one other (`scope`).
|
||||||
|
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
|
|
@ -55,6 +59,18 @@ const INCUBATION_UNRESOLVED_MAX: f64 = 2.0;
|
||||||
/// The most bytes a bond's name or kind takes in its line.
|
/// The most bytes a bond's name or kind takes in its line.
|
||||||
const NAME_BYTES: usize = 80;
|
const NAME_BYTES: usize = 80;
|
||||||
/// The most words, and bytes, of a display name the Projector is told a person she has no bond with by (K53, `Who`).
|
/// The most words, and bytes, of a display name the Projector is told a person she has no bond with by (K53, `Who`).
|
||||||
|
/// The most drives and the most ready intentions a packet shows: the strongest, by intensity (urgency) and what the room touches.
|
||||||
|
const PRESSURES_SHOWN: usize = 2;
|
||||||
|
const INTENTIONS_SHOWN: usize = 2;
|
||||||
|
/// The most feelings the mood line names, each above `FEELING_MIN` after decay.
|
||||||
|
const FEELINGS_SHOWN: usize = 2;
|
||||||
|
const FEELING_MIN: f64 = 0.25;
|
||||||
|
/// A standing tendency shows above this value; `TENDENCIES_BYTES` holds the lot, heading included.
|
||||||
|
const TENDENCY_MIN: f64 = 0.3;
|
||||||
|
const TENDENCIES_BYTES: usize = 360;
|
||||||
|
/// What a bond line takes beyond its summary for her read of the person (the clause) and what last moved the bond.
|
||||||
|
const READ_BYTES: usize = 200;
|
||||||
|
const SHIFT_BYTES: usize = 140;
|
||||||
const WHO_WORDS: usize = 3;
|
const WHO_WORDS: usize = 3;
|
||||||
const WHO_BYTES: usize = 32;
|
const WHO_BYTES: usize = 32;
|
||||||
/// The most bytes the line naming the unbonded people present takes.
|
/// The most bytes the line naming the unbonded people present takes.
|
||||||
|
|
@ -252,6 +268,10 @@ impl Lens {
|
||||||
pub(crate) enum Pool {
|
pub(crate) enum Pool {
|
||||||
/// Her unresolved short-term notes: never drawn, every one shown first under the notes' guard (T6).
|
/// Her unresolved short-term notes: never drawn, every one shown first under the notes' guard (T6).
|
||||||
ShortTerm,
|
ShortTerm,
|
||||||
|
/// Her strongest drives: never drawn, the strongest `PRESSURES_SHOWN` shown (map 16.38.8).
|
||||||
|
Pressure,
|
||||||
|
/// Her ready intentions: never drawn, the most urgent `INTENTIONS_SHOWN` shown.
|
||||||
|
Intention,
|
||||||
MemoriesAboutPresent,
|
MemoriesAboutPresent,
|
||||||
OtherMemories,
|
OtherMemories,
|
||||||
Needs,
|
Needs,
|
||||||
|
|
@ -280,6 +300,8 @@ pub(crate) struct Packet {
|
||||||
/// Her voice summary, for the Projector alone (map 16.4, I16.1): it reaches her prose only as the Projector rendered
|
/// Her voice summary, for the Projector alone (map 16.4, I16.1): it reaches her prose only as the Projector rendered
|
||||||
/// it, so no other stage's prompt is built from it.
|
/// it, so no other stage's prompt is built from it.
|
||||||
pub voice: String,
|
pub voice: String,
|
||||||
|
/// Her standing tendencies in words, for the Projector alone, shown with her identity: empty when none stands.
|
||||||
|
pub tendencies: String,
|
||||||
pub context: String,
|
pub context: String,
|
||||||
/// What each section of the context took, and which guards bound.
|
/// What each section of the context took, and which guards bound.
|
||||||
pub sections: Sections,
|
pub sections: Sections,
|
||||||
|
|
@ -541,11 +563,11 @@ fn baseline(state: &Value, axis: &str) -> Option<f64> {
|
||||||
number(state, &["activationProfile", "situationalState", axis, "mean"])
|
number(state, &["activationProfile", "situationalState", axis, "mean"])
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mood as change since her last turn. With no last turn to measure from, each axis is measured against her own baseline
|
/// The tone of her mood as change since her last turn. With no last turn to measure from, each axis is measured against her own baseline
|
||||||
/// (its trait vector's `mean`), or against middling where it carries none, and only an axis that leans more than
|
/// (its trait vector's `mean`), or against middling where it carries none, and only an axis that leans more than
|
||||||
/// `MOOD_LEVEL_MIN` is said. None when nothing leans, or her state carries no mood: an absence is left out of the packet,
|
/// `MOOD_LEVEL_MIN` is said. None when nothing leans, or her state carries no mood: an absence is left out of the packet,
|
||||||
/// never narrated.
|
/// never narrated.
|
||||||
fn mood_line(state: &Value, previous: Option<&Value>) -> Option<String> {
|
fn mood_tone(state: &Value, previous: Option<&Value>) -> Option<String> {
|
||||||
let now: Vec<(usize, f64)> = MOOD_AXES.iter().enumerate().filter_map(|(at, (axis, ..))| activation(state, axis).map(|value| (at, value))).collect();
|
let now: Vec<(usize, f64)> = MOOD_AXES.iter().enumerate().filter_map(|(at, (axis, ..))| activation(state, axis).map(|value| (at, value))).collect();
|
||||||
if now.is_empty() {
|
if now.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
|
|
@ -562,7 +584,7 @@ fn mood_line(state: &Value, previous: Option<&Value>) -> Option<String> {
|
||||||
}
|
}
|
||||||
let obj = forms(state).obj;
|
let obj = forms(state).obj;
|
||||||
let parts: Vec<String> = [(usual, format!("than usual for {obj}")), (middling, "than middling".to_owned())].into_iter().filter(|(words, _)| !words.is_empty()).map(|(words, than)| format!("{} {than}", words.join(", "))).collect();
|
let parts: Vec<String> = [(usual, format!("than usual for {obj}")), (middling, "than middling".to_owned())].into_iter().filter(|(words, _)| !words.is_empty()).map(|(words, than)| format!("{} {than}", words.join(", "))).collect();
|
||||||
return (!parts.is_empty()).then(|| format!("- mood: {}", parts.join("; ")));
|
return (!parts.is_empty()).then(|| parts.join("; "));
|
||||||
};
|
};
|
||||||
let moves: Vec<&str> = now
|
let moves: Vec<&str> = now
|
||||||
.iter()
|
.iter()
|
||||||
|
|
@ -577,7 +599,39 @@ fn mood_line(state: &Value, previous: Option<&Value>) -> Option<String> {
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let poss = forms(state).poss;
|
let poss = forms(state).poss;
|
||||||
Some(if moves.is_empty() { format!("- mood: where it was at {poss} last turn") } else { format!("- mood: {} than at {poss} last turn", moves.join(", ")) })
|
Some(if moves.is_empty() { format!("where it was at {poss} last turn") } else { format!("{} than at {poss} last turn", moves.join(", ")) })
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Her strongest named feelings (`affect.moodDimensions`) above `FEELING_MIN` after decay, each with what it is about: the
|
||||||
|
/// bond's label when the source names a person she is bound to, else the source's words. A value is read as it is now, never
|
||||||
|
/// as stored (`decayed`). None when no feeling stands.
|
||||||
|
fn feelings_line(inputs: &Inputs) -> Option<String> {
|
||||||
|
let mut felt: Vec<(f64, String)> = items(inputs.state, &["affect", "moodDimensions"])
|
||||||
|
.iter()
|
||||||
|
.filter_map(|feeling| {
|
||||||
|
let name = one_line(text(feeling, &["name"]));
|
||||||
|
let hours = time(feeling).map_or(0.0, |at| (inputs.now - at).num_milliseconds() as f64 / 3_600_000.0);
|
||||||
|
let value = super::commit::decayed(number(feeling, &["value"])?, hours);
|
||||||
|
if name.is_empty() || value <= FEELING_MIN {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let source = one_line(text(feeling, &["source"]));
|
||||||
|
let person = inputs.people.person_of(&source);
|
||||||
|
let bound = items(inputs.state, &["affect", "socialBonds"]).iter().find(|bond| live(bond) && inputs.people.person_of(text(bond, &["object", "id"])) == person).map(|bond| text(bond, &["object", "label"])).filter(|label| !label.is_empty());
|
||||||
|
let about = bound.unwrap_or(&source);
|
||||||
|
let about = if about.is_empty() { String::new() } else { format!(" about {}", clip(&one_line(about), NAME_BYTES)) };
|
||||||
|
Some((value, format!("{} {}{about}", strength_words(value), clip(&name, NAME_BYTES))))
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
felt.sort_by(|a, b| b.0.total_cmp(&a.0));
|
||||||
|
let words: Vec<String> = felt.into_iter().take(FEELINGS_SHOWN).map(|(_, words)| words).collect();
|
||||||
|
(!words.is_empty()).then(|| format!("carrying {}", words.join(" and ")))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Her mood: its tone, then the feelings she carries. None when neither stands: an absence is left out, never narrated.
|
||||||
|
fn mood_line(inputs: &Inputs) -> Option<String> {
|
||||||
|
let parts: Vec<String> = [mood_tone(inputs.state, inputs.history.previous.as_ref()), feelings_line(inputs)].into_iter().flatten().collect();
|
||||||
|
(!parts.is_empty()).then(|| format!("- mood: {}", parts.join("; ")))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn need_movement(need: &Value, previous: Option<&Value>, poss: &str) -> String {
|
fn need_movement(need: &Value, previous: Option<&Value>, poss: &str) -> String {
|
||||||
|
|
@ -673,8 +727,8 @@ fn candidates(inputs: &Inputs, tuning: &Tuning, present: &BTreeSet<String>, touc
|
||||||
Scope::Framed => (format!("{} knows privately: {words}", her.subj), Some(one_line(words))),
|
Scope::Framed => (format!("{} knows privately: {words}", her.subj), Some(one_line(words))),
|
||||||
Scope::Plain => (words.to_owned(), None),
|
Scope::Plain => (words.to_owned(), None),
|
||||||
};
|
};
|
||||||
// A short-term note is never drawn, so how often it was shown says nothing of it.
|
// A short-term note, a drive or an intention is never drawn, so how often it was shown says nothing of it.
|
||||||
let fresh = if pool == Pool::ShortTerm { 0.0 } else { freshness_log(id, inputs.history, tuning) };
|
let fresh = if matches!(pool, Pool::ShortTerm | Pool::Pressure | Pool::Intention) { 0.0 } else { freshness_log(id, inputs.history, tuning) };
|
||||||
let log_score = salience.ln() + relevance + touch.ln() + unresolved.ln() + fresh;
|
let log_score = salience.ln() + relevance + touch.ln() + unresolved.ln() + fresh;
|
||||||
let words = clip(&shown, item_bytes);
|
let words = clip(&shown, item_bytes);
|
||||||
out.push(Candidate { id: id.to_owned(), pool, line: line(&words), words, log_score, private, clipped: shown.trim().len() > item_bytes });
|
out.push(Candidate { id: id.to_owned(), pool, line: line(&words), words, log_score, private, clipped: shown.trim().len() > item_bytes });
|
||||||
|
|
@ -711,6 +765,28 @@ fn candidates(inputs: &Inputs, tuning: &Tuning, present: &BTreeSet<String>, touc
|
||||||
push(text(need, &["id"]), Pool::Needs, scoped(need), &words, &|words: &str| thought_line("need", need, Some(&movement), words), intensity, 0.0, TOUCH_ELSE, 1.0 + intensity);
|
push(text(need, &["id"]), Pool::Needs, scoped(need), &words, &|words: &str| thought_line("need", need, Some(&movement), words), intensity, 0.0, TOUCH_ELSE, 1.0 + intensity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Her drives and her ready intentions: fixed lines, the strongest of each shown (`select`), so she feels what presses on
|
||||||
|
// her and what she means to do each wake, drawn or not.
|
||||||
|
for pressure in items(state, &["agencyPressure", "pressures"]).iter().filter(|pressure| live(pressure)) {
|
||||||
|
let words = thought_words(pressure);
|
||||||
|
if words.is_empty() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let intensity = number(pressure, &["intensity"]).unwrap_or(SALIENCE_UNSTATED);
|
||||||
|
// The kind already says "pressing": a drive at its strongest is not told so twice.
|
||||||
|
let movement = Some(need_movement(pressure, inputs.history.previous.as_ref(), her.poss)).filter(|movement| movement != "pressing");
|
||||||
|
push(text(pressure, &["id"]), Pool::Pressure, scoped(pressure), &words, &|words: &str| thought_line("pressing", pressure, movement.as_deref(), words), intensity, relevance_log(&words, touching), TOUCH_ELSE, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
let unexpired = |action: &Value| DateTime::parse_from_rfc3339(text(action, &["expiresAt"])).map_or(true, |at| at > inputs.now);
|
||||||
|
for action in items(state, &["candidateActions", "actions"]).iter().filter(|action| live(action) && text(action, &["readiness"]) == "ready" && unexpired(action)) {
|
||||||
|
let words = thought_words(action);
|
||||||
|
if words.is_empty() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
push(text(action, &["id"]), Pool::Intention, scoped(action), &words, &|words: &str| thought_line("means to do", action, None, words), number(action, &["urgency"]).unwrap_or(SALIENCE_UNSTATED), relevance_log(&words, touching), TOUCH_ELSE, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
for wondering in items(state, &["thoughtMemory", "incubation"]).iter().filter(|item| live(item)) {
|
for wondering in items(state, &["thoughtMemory", "incubation"]).iter().filter(|item| live(item)) {
|
||||||
let words = thought_words(wondering);
|
let words = thought_words(wondering);
|
||||||
if words.is_empty() {
|
if words.is_empty() {
|
||||||
|
|
@ -772,6 +848,8 @@ fn cap_of(pool: Pool, tuning: &Tuning) -> usize {
|
||||||
match pool {
|
match pool {
|
||||||
// No cap: her notes are not drawn, and only the notes' guard holds them (T6).
|
// No cap: her notes are not drawn, and only the notes' guard holds them (T6).
|
||||||
Pool::ShortTerm => usize::MAX,
|
Pool::ShortTerm => usize::MAX,
|
||||||
|
Pool::Pressure => PRESSURES_SHOWN,
|
||||||
|
Pool::Intention => INTENTIONS_SHOWN,
|
||||||
Pool::MemoriesAboutPresent => caps.memories_about_present,
|
Pool::MemoriesAboutPresent => caps.memories_about_present,
|
||||||
Pool::OtherMemories => caps.other_memories,
|
Pool::OtherMemories => caps.other_memories,
|
||||||
Pool::Needs => caps.needs,
|
Pool::Needs => caps.needs,
|
||||||
|
|
@ -1374,12 +1452,14 @@ fn present_people(inputs: &Inputs, tuning: &Tuning) -> Vec<(String, Who)> {
|
||||||
|
|
||||||
/// A bond line: the person, the kind of bond after a dash (a label may hold a comma: "Meta, the operator"), trust and
|
/// A bond line: the person, the kind of bond after a dash (a label may hold a comma: "Meta, the operator"), trust and
|
||||||
/// friction as words when the bond carries them, and its summary; then, when the person turned to her this turn, that act
|
/// friction as words when the bond carries them, and its summary; then, when the person turned to her this turn, that act
|
||||||
/// and where (`turned`, map 16.21). What the bond does not carry is left out.
|
/// and where (`turned`, map 16.21). Then what last moved the bond (`lastEvidence`'s claim) and her read of the person
|
||||||
fn bond_line(bond: &Value, name: &Who, tuning: &Tuning, scope: Scope, her: Forms, turned: Option<&str>) -> String {
|
/// (`read`, from `read_clause`). A person named but not here says so after their name (`absent`). What the bond does not
|
||||||
|
/// carry is left out.
|
||||||
|
fn bond_line(bond: &Value, name: &Who, tuning: &Tuning, scope: Scope, her: Forms, turned: Option<&str>, read: Option<&str>, absent: bool) -> String {
|
||||||
let feel: Vec<&str> = [number(bond, &["trust"]).map(trust_words), number(bond, &["tension"]).map(friction_words)].into_iter().flatten().collect();
|
let feel: Vec<&str> = [number(bond, &["trust"]).map(trust_words), number(bond, &["tension"]).map(friction_words)].into_iter().flatten().collect();
|
||||||
let custom = text(bond, &["customRelationshipKind"]);
|
let custom = text(bond, &["customRelationshipKind"]);
|
||||||
let kind = clip(&one_line(if custom.is_empty() { text(bond, &["relationshipKind"]) } else { custom }), NAME_BYTES);
|
let kind = clip(&one_line(if custom.is_empty() { text(bond, &["relationshipKind"]) } else { custom }), NAME_BYTES);
|
||||||
let mut line = format!("- bond [{}] {name}", text(bond, &["id"]));
|
let mut line = format!("- bond [{}] {name}{}", text(bond, &["id"]), if absent { " (named, not here)" } else { "" });
|
||||||
if !kind.is_empty() {
|
if !kind.is_empty() {
|
||||||
let _ = write!(line, " \u{2014} {kind}");
|
let _ = write!(line, " \u{2014} {kind}");
|
||||||
}
|
}
|
||||||
|
|
@ -1401,12 +1481,73 @@ fn bond_line(bond: &Value, name: &Who, tuning: &Tuning, scope: Scope, her: Forms
|
||||||
let _ = write!(line, ": {}. {summary}", feel.join(", "));
|
let _ = write!(line, ": {}. {summary}", feel.join(", "));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let shift = clip(&one_line(text(bond, &["lastEvidence", "claim"])), SHIFT_BYTES);
|
||||||
|
let shift = (scope != Scope::Omitted && !shift.is_empty()).then(|| format!("What last moved it: {}", ended(&shift)));
|
||||||
|
for extra in [shift.as_deref(), read].into_iter().flatten() {
|
||||||
|
let _ = write!(line, "{}{extra}", if line.ends_with('.') { " " } else { ". " });
|
||||||
|
}
|
||||||
if let Some(place) = turned {
|
if let Some(place) = turned {
|
||||||
let _ = write!(line, "{}Just now {name} turned to {}, {place}.", if line.ends_with('.') { " " } else { ". " }, her.obj);
|
let _ = write!(line, "{}Just now {name} turned to {}, {place}.", if line.ends_with('.') { " " } else { ". " }, her.obj);
|
||||||
}
|
}
|
||||||
line
|
line
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A text as a sentence's end: a full stop after it unless it already ends one.
|
||||||
|
fn ended(text: &str) -> String {
|
||||||
|
if text.ends_with(['.', '!', '?', '\u{2026}']) { text.to_owned() } else { format!("{text}.") }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Her read of one person (`affect.statusReads`, the newest live one about them), as a clause of their bond line, hedged by
|
||||||
|
/// its confidence, and under the read's own privacy (`scope`): left out where it is private and the person is in the room.
|
||||||
|
/// With the words of a private read the packet showed, for the packet's list of what may not be said.
|
||||||
|
fn read_clause(inputs: &Inputs, person: &str, present: &BTreeSet<String>) -> Option<(String, Option<String>)> {
|
||||||
|
let her = forms(inputs.state);
|
||||||
|
let read = items(inputs.state, &["affect", "statusReads"]).iter().filter(|read| live(read) && inputs.people.person_of(text(read, &["target", "id"])) == person && !one_line(text(read, &["summary"])).is_empty()).max_by_key(|read| time(read))?;
|
||||||
|
let summary = ended(&clip(&one_line(text(read, &["summary"])), READ_BYTES - 80));
|
||||||
|
let kind = one_line(text(read, &["statusKind"]));
|
||||||
|
let kind = if kind.is_empty() { "them".to_owned() } else { clip(&kind, NAME_BYTES) };
|
||||||
|
match scope(inputs, concerns(&inputs.people, read).as_ref(), present) {
|
||||||
|
Scope::Omitted => None,
|
||||||
|
Scope::Framed => Some((format!("{} knows privately, reading {kind}: {summary}", her.cap_subj), Some(summary))),
|
||||||
|
Scope::Plain => {
|
||||||
|
let hedge = match number(read, &["confidence"]).unwrap_or(0.5) {
|
||||||
|
c if c >= 0.7 => String::new(),
|
||||||
|
c if c >= 0.35 => ", loosely".to_owned(),
|
||||||
|
_ => format!(", though {} {} not sure", her.subj, her.be),
|
||||||
|
};
|
||||||
|
Some((format!("{} reads {kind}{hedge}: {summary}", her.cap_subj), None))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The bonds of people who are not here but whom the lines she is shown name: a word of the names a line would call them by
|
||||||
|
/// (`names_of`: the localpart, the display name, the bond's label; the label's first part too) in the words of what others
|
||||||
|
/// said in the rooms she hears. Only the bond is shown, never the words that named it (I16.7). Her own bond is not one.
|
||||||
|
fn named_absent<'a>(inputs: &'a Inputs, present: &BTreeSet<String>) -> Vec<(&'a Value, Who)> {
|
||||||
|
let lines: Vec<&RoomLine> = inputs.room.messages.iter().chain(&inputs.room.tail).chain(&inputs.room.elsewhere).filter(|line| line.sender != inputs.people.own_sender).collect();
|
||||||
|
let words = |text: &str| text.split(|c: char| !c.is_alphanumeric()).filter(|word| !word.is_empty()).map(str::to_lowercase).collect::<Vec<_>>().join(" ");
|
||||||
|
let said = format!(" {} ", lines.iter().map(|line| words(&line.text)).collect::<Vec<_>>().join(" . "));
|
||||||
|
let own = inputs.people.person_of(inputs.people.own_sender);
|
||||||
|
items(inputs.state, &["affect", "socialBonds"])
|
||||||
|
.iter()
|
||||||
|
.filter(|bond| live(bond))
|
||||||
|
.filter_map(|bond| {
|
||||||
|
let id = text(bond, &["object", "id"]);
|
||||||
|
let person = inputs.people.person_of(id);
|
||||||
|
if person.is_empty() || person == own || present.contains(&person) {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let display = lines.iter().filter(|line| inputs.people.person_of(&line.sender) == person).max_by_key(|line| line.at_ms).map(|line| line.display.clone()).unwrap_or_default();
|
||||||
|
let label = text(bond, &["object", "label"]);
|
||||||
|
let mut names = names_of(&RoomLine { sender: id.to_owned(), display, ..RoomLine::default() }, inputs);
|
||||||
|
names.extend(label.split(',').next().map(str::to_owned));
|
||||||
|
let named = names.iter().map(|name| words(name)).any(|name| name.len() >= 3 && said.contains(&format!(" {name} ")));
|
||||||
|
let shown = if label.is_empty() { capitalized(localpart(id)) } else { clip(&one_line(label), NAME_BYTES) };
|
||||||
|
named.then(|| (bond, Who(shown)))
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
/// What opens the Persona's reading of one person's new lines to her (map 16.21): the arrival picked up in its own
|
/// What opens the Persona's reading of one person's new lines to her (map 16.21): the arrival picked up in its own
|
||||||
/// terms, the person's name and where as the packet's arrival names them (`turned_to_her`, the act on their own line),
|
/// terms, the person's name and where as the packet's arrival names them (`turned_to_her`, the act on their own line),
|
||||||
/// and "just now", so the lines read as the very thing the narration's arrival brought. In her pronouns (16.19.7).
|
/// and "just now", so the lines read as the very thing the narration's arrival brought. In her pronouns (16.19.7).
|
||||||
|
|
@ -1938,7 +2079,7 @@ fn domain_view(inputs: &Inputs, her: Forms, room: usize) -> (Vec<DomainLine>, St
|
||||||
/// her, and its newline.
|
/// her, and its newline.
|
||||||
pub(crate) fn people_guard(tuning: &Tuning, her: Forms) -> usize {
|
pub(crate) fn people_guard(tuning: &Tuning, her: Forms) -> usize {
|
||||||
let select = &tuning.select;
|
let select = &tuning.select;
|
||||||
let bond = select.bond_summary_bytes.saturating_add(BOND_HEAD_BYTES).saturating_add(TURNED_BYTES).saturating_add(1);
|
let bond = select.bond_summary_bytes.saturating_add(BOND_HEAD_BYTES).saturating_add(TURNED_BYTES).saturating_add(READ_BYTES).saturating_add(SHIFT_BYTES).saturating_add(1);
|
||||||
Section::People.heading(her).len().saturating_add(select.people_full.saturating_mul(bond))
|
Section::People.heading(her).len().saturating_add(select.people_full.saturating_mul(bond))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2057,6 +2198,39 @@ fn guarded_outcome(len: usize, line: &dyn Fn(usize, usize) -> String, room: usiz
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Her standing tendencies (`affect.socialBiases` over `TENDENCY_MIN`, the strongest first) in words, for her identity: each
|
||||||
|
/// by its name, how strong it is, its summary and its behavioural pull, under a stance's privacy (`scope`), the lot within
|
||||||
|
/// `TENDENCIES_BYTES`, a line that would pass it left out whole. With the words of those shown as known privately.
|
||||||
|
fn tendencies(inputs: &Inputs, present: &BTreeSet<String>) -> (String, Vec<String>) {
|
||||||
|
let her = forms(inputs.state);
|
||||||
|
let heading = format!("{} standing tendencies:", capitalized(her.poss));
|
||||||
|
let mut biases: Vec<(f64, &Value)> = items(inputs.state, &["affect", "socialBiases"]).iter().filter(|bias| live(bias)).filter_map(|bias| number(bias, &["value"]).filter(|value| *value > TENDENCY_MIN).map(|value| (value, bias))).collect();
|
||||||
|
biases.sort_by(|a, b| b.0.total_cmp(&a.0));
|
||||||
|
let (mut lines, mut private, mut used) = (Vec::new(), Vec::new(), heading.len());
|
||||||
|
for (value, bias) in biases {
|
||||||
|
let scope = scope(inputs, concerns(&inputs.people, bias).as_ref(), present);
|
||||||
|
let said = [text(bias, &["summary"]), text(bias, &["behavioralPull"])].into_iter().filter(|part| !part.is_empty()).map(|part| capitalized(&ended(&one_line(part)))).collect::<Vec<_>>().join(" ");
|
||||||
|
let said = match scope {
|
||||||
|
Scope::Omitted => continue,
|
||||||
|
Scope::Framed if !said.is_empty() => format!("{} knows privately: {said}", her.cap_subj),
|
||||||
|
_ => said,
|
||||||
|
};
|
||||||
|
let name = clip(&one_line(text(bias, &["name"])), NAME_BYTES);
|
||||||
|
let line = if said.is_empty() { format!("- {name}, {}", strength_words(value)) } else { format!("- {name}, {}: {said}", strength_words(value)) };
|
||||||
|
if used + 1 + line.len() > TENDENCIES_BYTES {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
used += 1 + line.len();
|
||||||
|
if scope == Scope::Framed {
|
||||||
|
private.push(one_line(&said));
|
||||||
|
}
|
||||||
|
lines.push(line);
|
||||||
|
}
|
||||||
|
(if lines.is_empty() { String::new() } else { format!("{heading}
|
||||||
|
{}", lines.join("
|
||||||
|
")) }, private)
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
||||||
let mut draw = Draw(inputs.seed);
|
let mut draw = Draw(inputs.seed);
|
||||||
let (name, voice, identity_clipped) = identity_of(inputs.state, tuning);
|
let (name, voice, identity_clipped) = identity_of(inputs.state, tuning);
|
||||||
|
|
@ -2139,7 +2313,7 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
||||||
let present_ids: BTreeSet<String> = present.iter().map(|(id, _)| id.clone()).collect();
|
let present_ids: BTreeSet<String> = present.iter().map(|(id, _)| id.clone()).collect();
|
||||||
let bonds = items(inputs.state, &["affect", "socialBonds"]);
|
let bonds = items(inputs.state, &["affect", "socialBonds"]);
|
||||||
context.force(Section::Here, format!("- now: {}, {}", inputs.now.format("%A %-d %B"), part_of_day(inputs.now)));
|
context.force(Section::Here, format!("- now: {}, {}", inputs.now.format("%A %-d %B"), part_of_day(inputs.now)));
|
||||||
if let Some(mood) = mood_line(inputs.state, inputs.history.previous.as_ref()) {
|
if let Some(mood) = mood_line(inputs) {
|
||||||
context.force(Section::Here, mood);
|
context.force(Section::Here, mood);
|
||||||
}
|
}
|
||||||
let mut ids = Vec::new();
|
let mut ids = Vec::new();
|
||||||
|
|
@ -2156,31 +2330,39 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
||||||
// Whoever turned to her this turn is placed first, so a bond line's room goes to them before anyone else present.
|
// Whoever turned to her this turn is placed first, so a bond line's room goes to them before anyone else present.
|
||||||
let arrived = |id: &String| turned.iter().any(|(person, _)| person == id);
|
let arrived = |id: &String| turned.iter().any(|(person, _)| person == id);
|
||||||
let order = present.iter().filter(|(id, _)| arrived(id)).chain(present.iter().filter(|(id, _)| !arrived(id)));
|
let order = present.iter().filter(|(id, _)| arrived(id)).chain(present.iter().filter(|(id, _)| !arrived(id)));
|
||||||
for (id, name) in order {
|
// The people present first, then the bonds of people the lines she is shown name though they are not here (map 16.38.8),
|
||||||
let turned = turned.iter().find(|(person, _)| person == id).map(|(_, place)| place.as_str());
|
// all under `people_full`.
|
||||||
|
let mut shown: Vec<(String, Who, Option<&str>, bool, Option<&Value>)> = order
|
||||||
|
.map(|(id, name)| (id.clone(), name.clone(), turned.iter().find(|(person, _)| person == id).map(|(_, place)| place.as_str()), false, bonds.iter().find(|bond| live(bond) && inputs.people.person_of(text(bond, &["object", "id"])) == *id)))
|
||||||
|
.collect();
|
||||||
|
shown.extend(named_absent(inputs, &present_ids).into_iter().map(|(bond, name)| (inputs.people.person_of(text(bond, &["object", "id"])), name, None, true, Some(bond))));
|
||||||
|
for (id, name, turned, absent, bond) in shown {
|
||||||
// Unbonded, or no room for the bond line: named on the also-here line, with the act when there was one.
|
// Unbonded, or no room for the bond line: named on the also-here line, with the act when there was one.
|
||||||
let also = match turned {
|
let also = match turned {
|
||||||
Some("here") => format!("{name}, who turned to {} just now", her.obj),
|
Some("here") => format!("{name}, who turned to {} just now", her.obj),
|
||||||
Some(place) => format!("{name}, who turned to {} just now, {place}", her.obj),
|
Some(place) => format!("{name}, who turned to {} just now, {place}", her.obj),
|
||||||
None => name.to_string(),
|
None => name.to_string(),
|
||||||
};
|
};
|
||||||
match bonds.iter().find(|bond| live(bond) && inputs.people.person_of(text(bond, &["object", "id"])) == *id) {
|
match bond {
|
||||||
Some(bond) if full < tuning.select.people_full => {
|
Some(bond) if full < tuning.select.people_full => {
|
||||||
let scope = scope(inputs, concerns(&inputs.people, bond).as_ref(), &present_ids);
|
let scope = scope(inputs, concerns(&inputs.people, bond).as_ref(), &present_ids);
|
||||||
if context.push(Section::People, bond_line(bond, name, tuning, scope, her, turned)) {
|
let read = read_clause(inputs, &id, &present_ids);
|
||||||
|
if context.push(Section::People, bond_line(bond, &name, tuning, scope, her, turned, read.as_ref().map(|(clause, _)| clause.as_str()), absent)) {
|
||||||
full += 1;
|
full += 1;
|
||||||
ids.push(text(bond, &["id"]).to_owned());
|
ids.push(text(bond, &["id"]).to_owned());
|
||||||
if scope != Scope::Omitted && one_line(text(bond, &["summary"])).len() > tuning.select.bond_summary_bytes {
|
if scope != Scope::Omitted && one_line(text(bond, &["summary"])).len() > tuning.select.bond_summary_bytes {
|
||||||
clipped.push(text(bond, &["id"]).to_owned());
|
clipped.push(text(bond, &["id"]).to_owned());
|
||||||
}
|
}
|
||||||
if scope == Scope::Framed && !text(bond, &["summary"]).is_empty() {
|
if scope == Scope::Framed {
|
||||||
private.push(one_line(text(bond, &["summary"])));
|
private.extend([text(bond, &["summary"]), text(bond, &["lastEvidence", "claim"])].into_iter().filter(|words| !words.is_empty()).map(one_line));
|
||||||
}
|
}
|
||||||
} else {
|
private.extend(read.and_then(|(_, private)| private));
|
||||||
|
} else if !absent {
|
||||||
named.push((also, turned.is_some()));
|
named.push((also, turned.is_some()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => named.push((also, turned.is_some())),
|
_ if !absent => named.push((also, turned.is_some())),
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let (domain, domain_view, domain_shown) = domain_view(inputs, her, tuning.select.domain_bytes);
|
let (domain, domain_view, domain_shown) = domain_view(inputs, her, tuning.select.domain_bytes);
|
||||||
|
|
@ -2217,7 +2399,9 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
||||||
|
|
||||||
// What the room is touching: the content words of what was said there, and of a follow-up's finding.
|
// What the room is touching: the content words of what was said there, and of a follow-up's finding.
|
||||||
let touching: BTreeSet<String> = inputs.room.messages.iter().chain(&inputs.room.tail).map(|line| line.text.as_str()).chain(inputs.observation).flat_map(content_words).collect();
|
let touching: BTreeSet<String> = inputs.room.messages.iter().chain(&inputs.room.tail).map(|line| line.text.as_str()).chain(inputs.observation).flat_map(content_words).collect();
|
||||||
let (mut noted, pool): (Vec<Candidate>, Vec<Candidate>) = candidates(inputs, tuning, &present_ids, &touching).into_iter().partition(|candidate| candidate.pool == Pool::ShortTerm);
|
let (slotted, pool): (Vec<Candidate>, Vec<Candidate>) = candidates(inputs, tuning, &present_ids, &touching).into_iter().partition(|candidate| matches!(candidate.pool, Pool::ShortTerm | Pool::Pressure | Pool::Intention));
|
||||||
|
let (mut noted, slotted): (Vec<Candidate>, Vec<Candidate>) = slotted.into_iter().partition(|candidate| candidate.pool == Pool::ShortTerm);
|
||||||
|
let (mut pressing, mut meaning): (Vec<Candidate>, Vec<Candidate>) = slotted.into_iter().partition(|candidate| candidate.pool == Pool::Pressure);
|
||||||
// Her unresolved short-term notes, every one, before the draw and outside it (T6: drawn, a note about the person
|
// Her unresolved short-term notes, every one, before the draw and outside it (T6: drawn, a note about the person
|
||||||
// waking her was listed on 17 of 38 such wakes in R18), each whole as every item is, under the notes' guard. Past
|
// waking her was listed on 17 of 38 such wakes in R18), each whole as every item is, under the notes' guard. Past
|
||||||
// the guard the rest are left out of this wake and the notes section is bound: the notes least about who is here,
|
// the guard the rest are left out of this wake and the notes section is bound: the notes least about who is here,
|
||||||
|
|
@ -2231,6 +2415,17 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
||||||
taken.push(candidate);
|
taken.push(candidate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Then her strongest drives and her most urgent ready intentions: fixed lines under the same guard, never drawn, so what
|
||||||
|
// presses on her and what she means to do are with her each wake.
|
||||||
|
for (slot, cap) in [(&mut pressing, PRESSURES_SHOWN), (&mut meaning, INTENTIONS_SHOWN)] {
|
||||||
|
slot.sort_by(|a, b| b.log_score.total_cmp(&a.log_score));
|
||||||
|
for candidate in slot.drain(..).take(cap) {
|
||||||
|
fits = fits && context.push(Section::Notes, candidate.line.clone());
|
||||||
|
if fits {
|
||||||
|
taken.push(candidate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// Gumbel-top-k over log(score)/T orders the candidates as sampling without replacement from the softmax would; each
|
// Gumbel-top-k over log(score)/T orders the candidates as sampling without replacement from the softmax would; each
|
||||||
// is then included with a probability its score sets, so a cap is a maximum, never a target.
|
// is then included with a probability its score sets, so a cap is a maximum, never a target.
|
||||||
let temperature = tuning.select.temperature;
|
let temperature = tuning.select.temperature;
|
||||||
|
|
@ -2287,5 +2482,7 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
||||||
sections.domain = domain_view.len();
|
sections.domain = domain_view.len();
|
||||||
let now_ms = u64::try_from(inputs.now.timestamp_millis()).unwrap_or_default();
|
let now_ms = u64::try_from(inputs.now.timestamp_millis()).unwrap_or_default();
|
||||||
let readers = here.filter(|room| room_kind(inputs, room) == RoomKind::Direct).map(|room| readers(inputs, room)).unwrap_or_default();
|
let readers = here.filter(|room| room_kind(inputs, room) == RoomKind::Direct).map(|room| readers(inputs, room)).unwrap_or_default();
|
||||||
Packet { kind: inputs.kind, seed: inputs.seed, lens, name, voice, context: context.render(), sections, stimulus, heard, bridged, elsewhere, elsewhere_shown, overflow, present: present_names, ids, selected, forms: her, people: people_in_view(inputs, tuning).iter().map(|line| (name_of(line, inputs), line.sender.clone())).collect(), 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)), readers, bodies, private, clipped, amendable, quotable, domain, domain_shown, in_view, now_ms, own_sender: inputs.people.own_sender.to_owned(), already_read, refused_reads, arrival, speaking: conversation.speaking.unwrap_or_default(), unshown, memories }
|
let (tendencies, tendencies_private) = tendencies(inputs, &present_ids);
|
||||||
|
private.extend(tendencies_private);
|
||||||
|
Packet { kind: inputs.kind, seed: inputs.seed, lens, name, voice, tendencies, context: context.render(), sections, stimulus, heard, bridged, elsewhere, elsewhere_shown, overflow, present: present_names, ids, selected, forms: her, people: people_in_view(inputs, tuning).iter().map(|line| (name_of(line, inputs), line.sender.clone())).collect(), 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)), readers, bodies, private, clipped, amendable, quotable, domain, domain_shown, in_view, now_ms, own_sender: inputs.people.own_sender.to_owned(), already_read, refused_reads, arrival, speaking: conversation.speaking.unwrap_or_default(), unshown, memories }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -312,18 +312,165 @@ fn the_body_guard_clips_an_entry_reports_it_and_keeps_the_turn_line() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn mission_pressure_private_notes_and_candidate_actions_never_reach_a_packet() {
|
fn private_notes_and_candidate_actions_not_ready_never_reach_a_packet() {
|
||||||
let room = chat_room();
|
let room = chat_room();
|
||||||
for kind in [TurnKind::Chat, TurnKind::Beat, TurnKind::Reflection, TurnKind::FollowUp] {
|
for kind in [TurnKind::Chat, TurnKind::Beat, TurnKind::Reflection, TurnKind::FollowUp] {
|
||||||
for seed in 1..=20 {
|
for seed in 1..=20 {
|
||||||
let text = whole(&packet_of(kind, &state(), &room, &History::default(), seed));
|
let text = whole(&packet_of(kind, &state(), &room, &History::default(), seed));
|
||||||
for never in ["MISSION-PRESSURE", "ambition-0", "PRIVATE-NOTE", "CANDIDATE-ACTION", "act-0"] {
|
for never in ["PRIVATE-NOTE", "CANDIDATE-ACTION", "act-0"] {
|
||||||
assert!(!text.contains(never), "{kind:?} seed {seed} carried {never}");
|
assert!(!text.contains(never), "{kind:?} seed {seed} carried {never}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A line of the packet's context, by its start.
|
||||||
|
fn line_of(packet: &Packet, start: &str) -> Option<String> {
|
||||||
|
packet.context.lines().find(|line| line.starts_with(start)).map(str::to_owned)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// No number reaches a line: no digit, a point and a digit (the packet speaks in words).
|
||||||
|
fn no_numbers(line: &str) {
|
||||||
|
let bytes = line.as_bytes();
|
||||||
|
assert!(!bytes.windows(3).any(|w| w[0].is_ascii_digit() && w[1] == b'.' && w[2].is_ascii_digit()), "a number in {line}");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn chat_with(state: &Value) -> Packet {
|
||||||
|
packet_of(TurnKind::Chat, state, &chat_room(), &History::default(), 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn t_s1_pressure_slot() {
|
||||||
|
let mut drives = state();
|
||||||
|
drives["agencyPressure"]["pressures"] = json!([
|
||||||
|
{ "id": "p-weak", "summary": "She wants a quiet week.", "intensity": 0.2, "status": "active" },
|
||||||
|
{ "id": "p-strong", "summary": "She wants to be someone the others talk to.", "intensity": 0.9, "status": "active" },
|
||||||
|
{ "id": "p-mid", "summary": "She wants the pipeline to stop moving under her.", "intensity": 0.6, "status": "active" },
|
||||||
|
{ "id": "p-eased", "summary": "She wanted the door fixed.", "intensity": 0.9, "status": "resolved" },
|
||||||
|
]);
|
||||||
|
for seed in 1..=10 {
|
||||||
|
let packet = packet_of(TurnKind::Chat, &drives, &chat_room(), &History::default(), seed);
|
||||||
|
let pressing: Vec<&str> = packet.context.lines().filter(|line| line.starts_with("- pressing")).collect();
|
||||||
|
assert_eq!(pressing, ["- pressing [p-strong]: She wants to be someone the others talk to.", "- pressing [p-mid], strong: She wants the pipeline to stop moving under her."], "seed {seed}: the two strongest, no weaker, no resolved one:\n{}", packet.context);
|
||||||
|
pressing.iter().for_each(|line| no_numbers(line));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn t_s1_feeling_in_mood() {
|
||||||
|
let feeling = |name: &str, value: f64, hours: i64| {
|
||||||
|
let mut felt = state();
|
||||||
|
felt["affect"]["moodDimensions"] = json!([{ "name": name, "value": value, "source": "kiko", "updatedAt": hours_ago(hours) }]);
|
||||||
|
felt
|
||||||
|
};
|
||||||
|
let mood = line_of(&chat_with(&feeling("anger", 0.6, 0)), "- mood").unwrap();
|
||||||
|
assert!(mood.contains("; carrying strong anger about Kiko"), "{mood}");
|
||||||
|
no_numbers(&mood);
|
||||||
|
assert!(line_of(&chat_with(&feeling("anger", 0.2, 0)), "- mood").is_none_or(|mood| !mood.contains("anger")), "0.2 is no feeling");
|
||||||
|
// Read after decay, never as stored: 0.6 after one half-life is 0.3, after two 0.15.
|
||||||
|
assert!(line_of(&chat_with(&feeling("anger", 0.6, 8)), "- mood").unwrap().contains("present anger about Kiko"));
|
||||||
|
assert!(!line_of(&chat_with(&feeling("anger", 0.6, 16)), "- mood").unwrap().contains("anger"));
|
||||||
|
// Two at most, the strongest; a source that names no one she is bound to is words.
|
||||||
|
let mut many = feeling("anger", 0.6, 0);
|
||||||
|
many["affect"]["moodDimensions"] = json!([
|
||||||
|
{ "name": "unease", "value": 0.4, "source": "the review", "updatedAt": hours_ago(0) },
|
||||||
|
{ "name": "pride", "value": 0.3, "source": "", "updatedAt": hours_ago(0) },
|
||||||
|
{ "name": "anger", "value": 0.6, "source": "kiko", "updatedAt": hours_ago(0) },
|
||||||
|
]);
|
||||||
|
assert!(line_of(&chat_with(&many), "- mood").unwrap().ends_with("carrying strong anger about Kiko and present unease about the review"));
|
||||||
|
// A feeling alone makes the mood line when her tone does not lean.
|
||||||
|
let mut calm = feeling("anger", 0.6, 0);
|
||||||
|
calm["activationProfile"] = json!({});
|
||||||
|
assert_eq!(line_of(&chat_with(&calm), "- mood").as_deref(), Some("- mood: carrying strong anger about Kiko"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn t_s1_named_absent_bond() {
|
||||||
|
let room = |text: &str| Room { messages: vec![message("#swarm:gamecult.org", "@libby:gamecult.org", "Libby", text, 2, true)], here: Some("#swarm:gamecult.org".into()), ..Room::default() };
|
||||||
|
let packet = packet_of(TurnKind::Chat, &state(), &room("Eureka, did Kiko ever answer you about the review?"), &History::default(), 1);
|
||||||
|
let (libby, kiko) = (packet.context.find("- bond [bond-libby]").unwrap(), packet.context.find("- bond [bond-kiko] Kiko (named, not here) \u{2014} sparring partner: fair trust, heavy friction.").unwrap_or_else(|| panic!("{}", packet.context)));
|
||||||
|
assert!(libby < kiko, "after the people present");
|
||||||
|
assert!(!packet.context.contains("ever answer"), "the words that named her are never the Projector's");
|
||||||
|
assert!(!packet.context.contains("bond-operator"));
|
||||||
|
let quiet = packet_of(TurnKind::Chat, &state(), &room("Eureka, did you see the door fix?"), &History::default(), 1);
|
||||||
|
assert!(!quiet.context.contains("bond-kiko"), "{}", quiet.context);
|
||||||
|
// A name inside another word is not the name.
|
||||||
|
assert!(!packet_of(TurnKind::Chat, &state(), &room("Eureka, the kikonet is down."), &History::default(), 1).context.contains("bond-kiko"));
|
||||||
|
// The bonds shown, present or named, stay under people_full.
|
||||||
|
let mut busy = chat_room();
|
||||||
|
busy.messages.push(message("#swarm:gamecult.org", "@libby:gamecult.org", "Libby", "Meta asked about it, and Kiko too.", 0, false));
|
||||||
|
let packet = packet_of(TurnKind::Chat, &state(), &busy, &History::default(), 1);
|
||||||
|
assert_eq!(packet.context.matches("- bond [").count(), Tuning::default().select.people_full, "{}", packet.context);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn t_s1_read_clause_private() {
|
||||||
|
let mut reads = state();
|
||||||
|
reads["affect"]["statusReads"] = json!([
|
||||||
|
{ "id": "read-kiko-attention", "status": "active", "target": { "kind": "person", "id": "kiko" }, "statusKind": "attention", "summary": "Kiko seems stretched thin.", "confidence": 0.9, "tags": ["private"], "updatedAt": hours_ago(1) },
|
||||||
|
{ "id": "read-libby-mood", "status": "active", "target": { "kind": "person", "id": "libby" }, "statusKind": "mood", "summary": "Libby seems rested.", "confidence": 0.3, "updatedAt": hours_ago(1) },
|
||||||
|
{ "id": "read-libby-old", "status": "retired", "target": { "kind": "person", "id": "libby" }, "statusKind": "mood", "summary": "Libby seemed furious.", "confidence": 0.9, "updatedAt": hours_ago(900) },
|
||||||
|
]);
|
||||||
|
let packet = chat_with(&reads);
|
||||||
|
assert!(packet.context.contains("- bond [bond-libby] Libby \u{2014} collaborator: fair trust, a little friction. Libby holds the sounds and teases her about the pipeline. She reads mood, though she is not sure: Libby seems rested."), "{}", packet.context);
|
||||||
|
assert!(!packet.context.contains("stretched thin"), "a private read is left out in a room its person is in: {}", packet.context);
|
||||||
|
assert!(!packet.context.contains("furious"), "a retired read is not shown");
|
||||||
|
// Kiko named but not here: the private read is shown as known privately, and listed as what may not be said.
|
||||||
|
let room = Room { messages: vec![message("#swarm:gamecult.org", "@libby:gamecult.org", "Libby", "Eureka, how is Kiko?", 2, true)], here: Some("#swarm:gamecult.org".into()), ..Room::default() };
|
||||||
|
let packet = packet_of(TurnKind::Chat, &reads, &room, &History::default(), 1);
|
||||||
|
assert!(packet.context.contains("She knows privately, reading attention: Kiko seems stretched thin."), "{}", packet.context);
|
||||||
|
assert!(packet.private.iter().any(|words| words.contains("stretched thin")));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn t_s1_the_bonds_last_evidence_is_felt() {
|
||||||
|
let mut moved = state();
|
||||||
|
moved["affect"]["socialBonds"][1]["lastEvidence"] = json!({ "id": "bond-kiko-e", "status": "retired", "summary": "Kiko was cold.", "claim": "Kiko apologised for the review", "updatedAt": hours_ago(3) });
|
||||||
|
assert!(chat_with(&moved).context.contains("Kiko pokes her to stop massaging the pipeline. What last moved it: Kiko apologised for the review."));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn t_s1_ready_intention_shown() {
|
||||||
|
let mut meant = state();
|
||||||
|
let action = |id: &str, readiness: &str, status: &str, urgency: f64, expires: Option<String>| {
|
||||||
|
let mut action = json!({ "id": id, "status": status, "actionType": "custom", "customActionType": "intention", "readiness": readiness, "riskLevel": "low", "target": { "kind": "self", "id": "eureka" }, "summary": format!("She means to {id}."), "urgency": urgency, "updatedAt": hours_ago(2) });
|
||||||
|
if let Some(expires) = expires {
|
||||||
|
action["expiresAt"] = json!(expires);
|
||||||
|
}
|
||||||
|
action
|
||||||
|
};
|
||||||
|
let later = (now() + chrono::Duration::hours(3)).to_rfc3339();
|
||||||
|
meant["candidateActions"]["actions"] = json!([
|
||||||
|
action("ask-deru", "ready", "active", 0.8, Some(later.clone())),
|
||||||
|
action("wait-a-day", "waiting", "active", 0.9, Some(later.clone())),
|
||||||
|
action("dropped", "expired", "retired", 0.9, None),
|
||||||
|
action("lapsed", "ready", "active", 0.9, Some(hours_ago(1))),
|
||||||
|
action("tidy-trace", "ready", "active", 0.4, None),
|
||||||
|
action("also-ready", "ready", "active", 0.1, None),
|
||||||
|
]);
|
||||||
|
let packet = chat_with(&meant);
|
||||||
|
let means: Vec<&str> = packet.context.lines().filter(|line| line.starts_with("- means to do")).collect();
|
||||||
|
assert_eq!(means, ["- means to do [ask-deru]: She means to ask-deru.", "- means to do [tidy-trace]: She means to tidy-trace."], "{}", packet.context);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn t_s1_bias_in_identity() {
|
||||||
|
let mut tended = state();
|
||||||
|
tended["affect"]["socialBiases"] = json!([
|
||||||
|
{ "id": "b-weak", "name": "distrusts newcomers", "value": 0.2, "summary": "She keeps strangers at arm's length.", "behavioralPull": "waits", "status": "active" },
|
||||||
|
{ "id": "b-defer", "name": "defers to the operator", "value": 0.6, "summary": "She yields when the operator rules.", "behavioralPull": "yields", "status": "active" },
|
||||||
|
]);
|
||||||
|
let packet = chat_with(&tended);
|
||||||
|
assert_eq!(packet.tendencies, "Her standing tendencies:\n- defers to the operator, strong: She yields when the operator rules. Yields.");
|
||||||
|
let prompt = narrate::projector_prompt(&packet, &Tuning::default());
|
||||||
|
assert!(prompt.contains("Eureka (she/her)\nHer standing tendencies:\n- defers to the operator, strong:"), "{prompt}");
|
||||||
|
assert!(!prompt.contains("arm's length") && !prompt.contains("0.6"));
|
||||||
|
assert!(chat_with(&state()).tendencies.is_empty());
|
||||||
|
// Private to a person in the room: left out there.
|
||||||
|
tended["affect"]["socialBiases"][1]["tags"] = json!(["private", "about:kiko"]);
|
||||||
|
assert!(chat_with(&tended).tendencies.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
const DERU: &str = "@deru:gamecult.org";
|
const DERU: &str = "@deru:gamecult.org";
|
||||||
const DM_DERU: &str = "!dm-deru:gamecult.org";
|
const DM_DERU: &str = "!dm-deru:gamecult.org";
|
||||||
|
|
||||||
|
|
@ -993,7 +1140,7 @@ fn renders_are_successive_turns_under_freshness_and_carry_the_guard() {
|
||||||
assert!(calls.iter().map(|(id, ..)| id).collect::<BTreeSet<_>>().len() == 4, "each call is its own request");
|
assert!(calls.iter().map(|(id, ..)| id).collect::<BTreeSet<_>>().len() == 4, "each call is its own request");
|
||||||
assert!(calls[0].2.contains("Begin from ") && calls[0].2.contains("Use at most 90 words"), "a beat's budget and its lens reach the prompt");
|
assert!(calls[0].2.contains("Begin from ") && calls[0].2.contains("Use at most 90 words"), "a beat's budget and its lens reach the prompt");
|
||||||
for (_, _, prompt) in calls.iter() {
|
for (_, _, prompt) in calls.iter() {
|
||||||
assert!(!prompt.contains("MISSION-PRESSURE") && !prompt.contains("PRIVATE-NOTE"));
|
assert!(!prompt.contains("PRIVATE-NOTE"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue