K6b: her body in the packet: senses from state, the turn's affordances from code (map 16.6, 16.18, I16.3)
Affordance is typed by what it does (Perceive, Speak), derived by affordances(&Organs, turn room) from what the turn runs with: the room reaches her when there is a mouth, and she can speak when the turn has a room. Read (C3b) and Suggest (K12) are added with the organs that back them. Select gains Section::Body between Here and People: a line per live sense and actuator of embodiment, then the turn line rendered by turn_words, which ends with "nothing she does here builds, changes or ships anything" exactly when no affordance writes (Affordance::writes, an exhaustive match). The section is fixed like the hour, under its own guard select.body_bytes (600, at least 256) inside the context budget; an entry the guard cuts is reported as clipped. The Projector frame gains its body sentence: the body is how the moment reaches her and how she can answer, not news, and a lack is felt only when the moment reaches for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0bec1d4f3f
commit
66e144122d
8 changed files with 262 additions and 22 deletions
|
|
@ -41,7 +41,7 @@ pub use select::TurnKind;
|
|||
pub use tuning::{TUNING_FILE, TUNING_ROOT};
|
||||
|
||||
use narrate::{cap_words, distinct_2, field_names, heard_overlap, judge_prompt, judged, offers_options, persona_prompt, projector_prompt, word_budget, words};
|
||||
use select::{History, Inputs, Packet, People, Room, RoomLine, select};
|
||||
use select::{History, Inputs, Packet, People, Room, RoomLine, select, turn_room};
|
||||
|
||||
/// The agent name on the connector's request ids.
|
||||
const AGENT: &str = "mind-persona";
|
||||
|
|
@ -112,6 +112,36 @@ pub struct Organs<'a> {
|
|||
pub model: Option<&'a dyn Model>,
|
||||
}
|
||||
|
||||
/// One thing she can do this turn, typed by what it does (map 16.6, 16.18). Derived by `affordances` from what the turn
|
||||
/// runs with, never written in state or in guidance. C3b adds `Read` from the Interpreter's tool list and K12 adds
|
||||
/// `Suggest`; neither is listed before the organ that backs it exists, so she is never told she can do what this turn
|
||||
/// cannot.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub(crate) enum Affordance {
|
||||
/// The room reaches her as typed lines: the mouth's `RoomLine` carries text only, and Select renders no images.
|
||||
Perceive,
|
||||
/// She says whole lines of her prose in the turn's room (`interpret`).
|
||||
Speak,
|
||||
}
|
||||
|
||||
impl Affordance {
|
||||
/// Whether it builds, changes or ships anything in the world. None does yet: the match is exhaustive, so the day a
|
||||
/// write affordance is added it must answer here, and the body line's "nothing she does here builds…" goes with it.
|
||||
pub(crate) fn writes(self) -> bool {
|
||||
match self {
|
||||
Self::Perceive | Self::Speak => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// What this turn can do, from the organs it runs with and the turn's room (`select::turn_room`): the room's lines reach
|
||||
/// her when there is a mouth to read them, and she can speak when the turn has a room, the only one the Interpreter lets
|
||||
/// her speak in.
|
||||
pub(crate) fn affordances(organs: &Organs, room: Option<&str>) -> Vec<Affordance> {
|
||||
[(organs.chat.is_some(), Affordance::Perceive), (room.is_some(), Affordance::Speak)].into_iter().filter_map(|(can, affordance)| can.then_some(affordance)).collect()
|
||||
}
|
||||
|
||||
/// How far a render runs: the Projector's narration, or on through the Persona stage to her prose.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, serde::Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
|
@ -235,6 +265,7 @@ fn packet_json(packet: &Packet) -> Value {
|
|||
"clipped": packet.clipped,
|
||||
"name": packet.name,
|
||||
"voice": packet.voice,
|
||||
"affordances": packet.affordances,
|
||||
"context": packet.context,
|
||||
"stimulus": packet.stimulus,
|
||||
"heard": packet.heard,
|
||||
|
|
@ -327,7 +358,9 @@ pub fn project(organs: &Organs, request: &Request, now: DateTime<Utc>) -> Result
|
|||
// caller carried from earlier turns of its own.
|
||||
let history = History { recent: request.recent.clone(), ..History::default() };
|
||||
let people = People { operators: &request.operators, minds: &request.minds, own_sender: &request.own_sender };
|
||||
let inputs = Inputs { kind: request.kind, state: &state, room: &room, history: &history, observation: None, people, now, seed: request.seed };
|
||||
let inputs = Inputs { kind: request.kind, state: &state, room: &room, history: &history, observation: None, people, now, seed: request.seed, affordances: &[] };
|
||||
let can = affordances(organs, turn_room(&inputs));
|
||||
let inputs = Inputs { affordances: &can, ..inputs };
|
||||
|
||||
let mut report = json!({
|
||||
"instance": request.instance,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ Here and now:
|
|||
- mood: lighter than usual for her
|
||||
- the conversation: Lately Libby with her; Kiko to the room. The last 2 lines are the Minds' alone.
|
||||
- pronouns: Libby — she/her; Kiko — she/her
|
||||
Her body:
|
||||
- this turn the room reaches her as typed lines, and she can answer in the turn's room by typing lines of her own; nothing she does here builds, changes or ships anything.
|
||||
People here, as she holds them:
|
||||
- bond [bond-kiko] Kiko — sparring partner: fair trust, heavy friction. Kiko pokes her to stop massaging the pipeline.
|
||||
- bond [bond-libby] Libby — collaborator: fair trust, a little friction. Libby holds the sounds and teases her about the pipeline.
|
||||
|
|
@ -29,7 +31,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 they will go on to continue in their own thought. Their interior is the point: what they feel, want, fear and remember, and how the people here sit with them, rendered as lived, not listed.
|
||||
|
||||
Render only what is established below: who they are, their present under its headings, and what reaches them. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact, and say plainly what is unknown rather than filling it. Furnish no place, object or event they do not give: no act or event of their own (nothing they did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. Here and now is the hour, how their mood leans when it does, and the room as it stands. The people here are as they hold them, not as those people are. The notes about them were set down at another time, by others and by their own past self, and who they are is a sketch made at another time too: all of it is material for the stream and never its wording. Their manner shows in how the stream moves, never as a remark about their own manner.
|
||||
Render only what is established below: who they are, their present under its headings, and what reaches them. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact, and say plainly what is unknown rather than filling it. Furnish no place, object or event they do not give: no act or event of their own (nothing they did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. Here and now is the hour, how their mood leans when it does, and the room as it stands. Their body is how the moment reaches them and how they can answer it: it is not news to them, and a lack in it is felt only when the moment reaches for something it cannot do. The people here are as they hold them, not as those people are. The notes about them were set down at another time, by others and by their own past self, and who they are is a sketch made at another time too: all of it is material for the stream and never its wording. Their manner shows in how the stream moves, never as a remark about their own manner.
|
||||
|
||||
Render the two or three notes this moment touches and leave the rest. Do not recap the notes or what reaches them. Do not weigh options, list what they 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.
|
||||
|
||||
|
|
@ -46,6 +48,8 @@ Here and now:
|
|||
- mood: lighter than usual for her
|
||||
- the conversation: Lately Libby with her; Kiko to the room. The last 2 lines are the Minds' alone.
|
||||
- pronouns: Libby — she/her; Kiko — she/her
|
||||
Her body:
|
||||
- this turn the room reaches her as typed lines, and she can answer in the turn's room by typing lines of her own; nothing she does here builds, changes or ships anything.
|
||||
People here, as she holds them:
|
||||
- bond [bond-kiko] Kiko — sparring partner: fair trust, heavy friction. Kiko pokes her to stop massaging the pipeline.
|
||||
- bond [bond-libby] Libby — collaborator: fair trust, a little friction. Libby holds the sounds and teases her about the pipeline.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use serde_json::json;
|
||||
|
||||
use super::*;
|
||||
use crate::projection::Affordance;
|
||||
use crate::projection::harness::tests::{Scripted, control};
|
||||
use crate::projection::select::{History, Inputs, People, Room, RoomKind, RoomLine, TurnKind, select};
|
||||
use crate::projection::tuning::Tuning;
|
||||
|
|
@ -25,7 +26,7 @@ fn packet_in(kind: TurnKind, state: &Value, room: &Room, seed: u64) -> Packet {
|
|||
let minds = vec![HER.to_owned(), NIBU.to_owned(), VOID.to_owned(), LIBBY.to_owned(), KIKO.to_owned()];
|
||||
let operators = vec!["@meta:gamecult.org".to_owned()];
|
||||
let history = History::default();
|
||||
select(&Inputs { kind, state, room, history: &history, observation: None, people: People { operators: &operators, minds: &minds, own_sender: HER }, now: now(), seed }, &Tuning::default())
|
||||
select(&Inputs { kind, state, room, history: &history, observation: None, people: People { operators: &operators, minds: &minds, own_sender: HER }, now: now(), seed, affordances: &[Affordance::Perceive, Affordance::Speak] }, &Tuning::default())
|
||||
}
|
||||
|
||||
fn heimdall() -> Value {
|
||||
|
|
|
|||
|
|
@ -143,13 +143,14 @@ pub(crate) fn word_budget(kind: TurnKind, tuning: &Tuning) -> usize {
|
|||
/// effects, and the word budget. 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 the notes and the sketch of who they are are material,
|
||||
/// never wording, so her manner shows in how the stream moves and not as remarks about it; no invented act, event or
|
||||
/// never wording, so her manner shows in how the stream moves and not as remarks about it; 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.
|
||||
pub(crate) const PROJECTOR_FRAME: &str = "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 they will go on to continue in their own thought. Their interior is the point: what they feel, want, fear and remember, and how the people here sit with them, rendered as lived, not listed.
|
||||
|
||||
Render only what is established below: who they are, their present under its headings, and what reaches them. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact, and say plainly what is unknown rather than filling it. Furnish no place, object or event they do not give: no act or event of their own (nothing they did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. Here and now is the hour, how their mood leans when it does, and the room as it stands. The people here are as they hold them, not as those people are. The notes about them were set down at another time, by others and by their own past self, and who they are is a sketch made at another time too: all of it is material for the stream and never its wording. Their manner shows in how the stream moves, never as a remark about their own manner.
|
||||
Render only what is established below: who they are, their present under its headings, and what reaches them. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact, and say plainly what is unknown rather than filling it. Furnish no place, object or event they do not give: no act or event of their own (nothing they did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. Here and now is the hour, how their mood leans when it does, and the room as it stands. Their body is how the moment reaches them and how they can answer it: it is not news to them, and a lack in it is felt only when the moment reaches for something it cannot do. The people here are as they hold them, not as those people are. The notes about them were set down at another time, by others and by their own past self, and who they are is a sketch made at another time too: all of it is material for the stream and never its wording. Their manner shows in how the stream moves, never as a remark about their own manner.
|
||||
|
||||
Render the two or three notes this moment touches and leave the rest. Do not recap the notes or what reaches them. Do not weigh options, list what they 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.";
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
//! The Projector shows her self and her room: her persona state and what the mouth showed. Her Mind is not read
|
||||
//! here; reaching into it is the Interpreter's, through its read tools, when wondering leads to reading.
|
||||
//!
|
||||
//! Every packet carries its fixed slots: identity, the hour, her mood when it leans, a bond line for each person
|
||||
//! Every packet carries its fixed slots: identity, the hour, her mood when it leans, her body (`body_lines`: her senses
|
||||
//! and actuators from `embodiment`, and what this turn can do from `Affordance`), a bond line for each person
|
||||
//! present, the group state (who has been talking to whom, `group_line`), and the stimulus. The rest comes from her
|
||||
//! state's pools. The context is rendered in headed sections (`Section`), each saying what kind of text its lines are,
|
||||
//! and every anchored thought by one renderer (`thought_line`). Each candidate is ordered by
|
||||
|
|
@ -31,6 +32,7 @@ use serde::Serialize;
|
|||
use serde_json::Value;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
use super::Affordance;
|
||||
use super::tuning::{LensWeights, Tuning};
|
||||
use crate::address::localpart;
|
||||
|
||||
|
|
@ -48,6 +50,8 @@ const INCUBATION_UNRESOLVED_MAX: f64 = 2.0;
|
|||
const NAME_BYTES: usize = 80;
|
||||
/// The most bytes the line naming the unbonded people present takes.
|
||||
const ALSO_HERE_BYTES: usize = 300;
|
||||
/// A body entry the guard would cut to this many bytes or fewer says nothing, and is left out.
|
||||
const BODY_ENTRY_MIN: usize = 40;
|
||||
|
||||
/// Her pronouns as the packet speaks of her (from `presentation.pronouns`: he, she, or they for anything else, "any"
|
||||
/// included), with the verb forms that agree with them.
|
||||
|
|
@ -183,6 +187,8 @@ pub(crate) struct Inputs<'a> {
|
|||
pub people: People<'a>,
|
||||
pub now: DateTime<Utc>,
|
||||
pub seed: u64,
|
||||
/// What this turn can do (`super::affordances`).
|
||||
pub affordances: &'a [Affordance],
|
||||
}
|
||||
|
||||
/// Where a turn begins.
|
||||
|
|
@ -256,6 +262,9 @@ pub(crate) struct Packet {
|
|||
pub forms: Forms,
|
||||
/// Whom she may mention or reply to: the people this packet showed her from the room, (label, Matrix id).
|
||||
pub people: Vec<(String, String)>,
|
||||
/// What this turn can do: the body section's turn line and the Interpreter's "What she can do here" are both
|
||||
/// rendered from it (`turn_words`).
|
||||
pub affordances: Vec<Affordance>,
|
||||
/// The one room she may speak in this turn, and its kind.
|
||||
pub room: Option<String>,
|
||||
pub room_kind: RoomKind,
|
||||
|
|
@ -1239,6 +1248,73 @@ fn minutes(now: DateTime<Utc>, at_ms: u64) -> i64 {
|
|||
(now - at).num_minutes().max(0)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Her body.
|
||||
|
||||
/// `word` with its first letter upper-cased.
|
||||
fn capitalized(word: &str) -> String {
|
||||
let mut chars = word.chars();
|
||||
chars.next().map_or_else(String::new, |first| format!("{}{}", first.to_uppercase(), chars.as_str()))
|
||||
}
|
||||
|
||||
/// What this turn can do, in words, from the affordances alone (map 16.6, 16.18): the body section's turn line and the
|
||||
/// Interpreter's "What she can do here" are this text. It ends with "nothing she does here builds, changes or ships
|
||||
/// anything" exactly when no affordance writes (`Affordance::writes`): a derived sentence, never a constant.
|
||||
pub(crate) fn turn_words(can: &[Affordance], her: Forms) -> String {
|
||||
let clauses: Vec<String> = can
|
||||
.iter()
|
||||
.map(|affordance| match affordance {
|
||||
Affordance::Perceive => format!("the room reaches {} as typed lines", her.obj),
|
||||
Affordance::Speak => format!("{} can answer in the turn's room by typing lines of {} own", her.subj, her.poss),
|
||||
})
|
||||
.collect();
|
||||
let mut words = if clauses.is_empty() { format!("this turn no room reaches {} and {} can say nothing", her.obj, her.subj) } else { format!("this turn {}", clauses.join(", and ")) };
|
||||
if !can.iter().any(|affordance| affordance.writes()) {
|
||||
let does = if her.s.is_empty() { "do" } else { "does" };
|
||||
let _ = write!(words, "; nothing {} {does} here builds, changes or ships anything", her.subj);
|
||||
}
|
||||
words
|
||||
}
|
||||
|
||||
/// The body section's lines, the ids they name, and the ids of the entries the guard cut.
|
||||
struct Body {
|
||||
lines: Vec<String>,
|
||||
ids: Vec<String>,
|
||||
clipped: Vec<String>,
|
||||
}
|
||||
|
||||
/// Her body as the packet carries it: a line per live sense and actuator of `embodiment` (`- sense [id] label: summary
|
||||
/// lacks`), then the turn line (`turn_words`). The turn line is always there; the entries share what `body_bytes` leaves
|
||||
/// beside it and the heading, in the state's order, and an entry that does not fit is clipped to the room left, or left
|
||||
/// out when no useful room is left; either way its id is reported as clipped. Nothing here reads guidance or the voice:
|
||||
/// the body is state and code (I16.3).
|
||||
fn body_lines(state: &Value, can: &[Affordance], her: Forms, body_bytes: usize) -> Body {
|
||||
let turn = format!("- {}.", turn_words(can, her));
|
||||
let heading = Section::Body.heading(her);
|
||||
let mut room = body_bytes.saturating_sub(heading.len() + 1 + turn.len() + 1);
|
||||
let mut body = Body { lines: Vec::new(), ids: Vec::new(), clipped: Vec::new() };
|
||||
let entries = items(state, &["embodiment", "senses"]).iter().map(|entry| ("sense", entry)).chain(items(state, &["embodiment", "actuators"]).iter().map(|entry| ("actuator", entry)));
|
||||
for (kind, entry) in entries.filter(|(_, entry)| live(entry)) {
|
||||
let id = text(entry, &["id"]).to_owned();
|
||||
let said = [text(entry, &["summary"]), text(entry, &["lacks"])].into_iter().filter(|part| !part.is_empty()).collect::<Vec<_>>().join(" ");
|
||||
let whole = one_line(&format!("- {kind} [{id}] {}: {said}", clip(text(entry, &["label"]), NAME_BYTES)));
|
||||
// Each line costs its newline too.
|
||||
let fits = whole.len() < room;
|
||||
let line = if fits { whole } else { clip(&whole, room.saturating_sub(1)) };
|
||||
if !fits {
|
||||
body.clipped.push(id.clone());
|
||||
if line.len() <= BODY_ENTRY_MIN {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
room -= line.len() + 1;
|
||||
body.lines.push(line);
|
||||
body.ids.push(id);
|
||||
}
|
||||
body.lines.push(turn);
|
||||
body
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// The packet.
|
||||
|
||||
|
|
@ -1248,6 +1324,8 @@ fn minutes(now: DateTime<Utc>, at_ms: u64) -> i64 {
|
|||
enum Section {
|
||||
/// 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,
|
||||
/// Her state's notes about her: anchored thoughts, values, what she said.
|
||||
|
|
@ -1258,6 +1336,7 @@ impl Section {
|
|||
fn heading(self, her: Forms) -> String {
|
||||
match self {
|
||||
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::Notes => format!("Notes about {}, set down at another time:", her.obj),
|
||||
}
|
||||
|
|
@ -1269,12 +1348,12 @@ struct Context {
|
|||
budget: usize,
|
||||
/// The rendered bytes plus one: each heading and each line counts its newline.
|
||||
used: usize,
|
||||
sections: [(String, Vec<String>); 3],
|
||||
sections: [(String, Vec<String>); 4],
|
||||
}
|
||||
|
||||
impl Context {
|
||||
fn new(budget: usize, her: Forms) -> Self {
|
||||
Self { budget, used: 0, sections: [Section::Here, Section::People, Section::Notes].map(|section| (section.heading(her), Vec::new())) }
|
||||
Self { budget, used: 0, sections: [Section::Here, Section::Body, Section::People, Section::Notes].map(|section| (section.heading(her), Vec::new())) }
|
||||
}
|
||||
|
||||
fn cost(&self, section: Section, line: &str) -> usize {
|
||||
|
|
@ -1286,7 +1365,8 @@ impl Context {
|
|||
self.used + self.cost(section, line) <= self.budget + 1
|
||||
}
|
||||
|
||||
/// Adds a line whether or not it fits: only the hour and the mood, which the tuning's validation leaves room for.
|
||||
/// Adds a line whether or not it fits: only the hour, the mood and the body, which the tuning's validation leaves room
|
||||
/// for (`FIXED_ROOM` and `body_bytes`).
|
||||
fn force(&mut self, section: Section, line: String) {
|
||||
self.used += self.cost(section, &line);
|
||||
self.sections[section as usize].1.push(line);
|
||||
|
|
@ -1330,6 +1410,13 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
context.force(Section::Here, mood);
|
||||
}
|
||||
let mut ids = Vec::new();
|
||||
// Her body is fixed like the hour, within its own guard: the moment is perceived through it.
|
||||
let body = body_lines(inputs.state, inputs.affordances, her, tuning.select.body_bytes);
|
||||
for line in body.lines {
|
||||
context.force(Section::Body, line);
|
||||
}
|
||||
ids.extend(body.ids);
|
||||
clipped.extend(body.clipped);
|
||||
let mut named = Vec::new();
|
||||
let mut private = Vec::new();
|
||||
let mut full = 0;
|
||||
|
|
@ -1401,5 +1488,5 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
TurnKind::FollowUp | TurnKind::Reflection => Vec::new(),
|
||||
};
|
||||
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(), stimulus, heard, overflow, present: present_names, ids, selected, forms: her, people: people_in_view(inputs, tuning), 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 }
|
||||
Packet { kind: inputs.kind, seed: inputs.seed, lens, name, voice, context: context.render(), stimulus, heard, 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 }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ use crate::chat_client::{Basis, Chat, ChatDelivery, ChatFetchReceipt, ChatFetchR
|
|||
use crate::testkit::INSTANCE;
|
||||
|
||||
const OWN: &str = "@eureka:gamecult.org";
|
||||
/// A chat turn's body: the room reaches her, and she can answer in it.
|
||||
const CAN: &[Affordance] = &[Affordance::Perceive, Affordance::Speak];
|
||||
const OPERATOR: &str = "@meta:gamecult.org";
|
||||
|
||||
fn now() -> DateTime<Utc> {
|
||||
|
|
@ -99,10 +101,18 @@ fn packet_of(kind: TurnKind, state: &Value, room: &Room, history: &History, seed
|
|||
fn packet_tuned(kind: TurnKind, state: &Value, room: &Room, history: &History, seed: u64, tuning: &Tuning) -> Packet {
|
||||
let operators = operators();
|
||||
let minds = minds();
|
||||
let inputs = Inputs { kind, state, room, history, observation: None, people: People { operators: &operators, minds: &minds, own_sender: OWN }, now: now(), seed };
|
||||
let inputs = Inputs { kind, state, room, history, observation: None, people: People { operators: &operators, minds: &minds, own_sender: OWN }, now: now(), seed, affordances: CAN };
|
||||
select(&inputs, tuning)
|
||||
}
|
||||
|
||||
/// The packet's body section, heading and lines, each with its newline.
|
||||
fn body_section(packet: &Packet) -> String {
|
||||
let mut lines = packet.context.lines().skip_while(|line| !line.ends_with(" body:"));
|
||||
let heading = lines.next().unwrap_or_default();
|
||||
std::iter::once(heading).chain(lines.take_while(|line| line.starts_with("- "))).map(|line| format!("{line}
|
||||
")).collect()
|
||||
}
|
||||
|
||||
fn ids(packet: &Packet) -> Vec<String> {
|
||||
packet.selected.iter().map(|pick| pick.id.clone()).collect()
|
||||
}
|
||||
|
|
@ -218,14 +228,102 @@ fn every_anchored_thought_renders_by_one_shape_with_its_tension_and_question() {
|
|||
fn the_context_is_in_headed_sections_in_order_and_an_empty_one_is_left_out() {
|
||||
let packet = packet_of(TurnKind::Chat, &state(), &chat_room(), &History::default(), 7);
|
||||
let headings: Vec<&str> = packet.context.lines().filter(|line| !line.starts_with("- ")).collect();
|
||||
assert_eq!(headings, ["Here and now:", "People here, as she holds them:", "Notes about her, set down at another time:"], "{}", packet.context);
|
||||
assert_eq!(headings, ["Here and now:", "Her body:", "People here, as she holds them:", "Notes about her, set down at another time:"], "{}", packet.context);
|
||||
let alone = packet_of(TurnKind::Beat, &json!({ "publicName": "Eureka", "presentation": { "pronouns": "he/him" } }), &Room::default(), &History::default(), 1);
|
||||
assert_eq!(alone.context.lines().filter(|line| !line.starts_with("- ")).collect::<Vec<_>>(), ["Here and now:"], "{}", alone.context);
|
||||
assert_eq!(alone.context.lines().filter(|line| !line.starts_with("- ")).collect::<Vec<_>>(), ["Here and now:", "His body:"], "{}", alone.context);
|
||||
let him = json!({ "publicName": "Heimdall", "presentation": { "pronouns": "he/him" }, "affect": { "socialBonds": state()["affect"]["socialBonds"].clone() }, "values": state()["values"].clone() });
|
||||
let he = (1..=20).map(|seed| packet_of(TurnKind::Chat, &him, &chat_room(), &History::default(), seed).context).find(|context| context.contains("Notes about him, set down at another time:\n")).expect("a value is drawn on some seed");
|
||||
assert!(he.contains("People here, as he holds them:\n"), "{he}");
|
||||
}
|
||||
|
||||
/// Aqua's one recorded sense, written from the operator's words (map 16.6): the only body any test here gives a Mind.
|
||||
fn aqua_ears() -> Value {
|
||||
json!({ "senses": [{ "id": "sense-spectrogram", "status": "active", "label": "spectrogram hearing", "summary": "Aqua hears by rendering a sound as a spectrogram and looking at it: she can feel its shape, where its weight sits, how long it rings.", "lacks": "Not a human ear; a picture of a sound, not the sound.", "builtOn": hours_ago(400), "updatedAt": hours_ago(400) }] })
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_state_with_one_sense_renders_it_and_a_state_with_none_only_the_turn_line() {
|
||||
let mut aqua = state();
|
||||
aqua["embodiment"] = aqua_ears();
|
||||
let packet = packet_of(TurnKind::Chat, &aqua, &chat_room(), &History::default(), 1);
|
||||
let body = body_section(&packet);
|
||||
assert_eq!(
|
||||
body,
|
||||
"Her body:\n- sense [sense-spectrogram] spectrogram hearing: Aqua hears by rendering a sound as a spectrogram and looking at it: she can feel its shape, where its weight sits, how long it rings. Not a human ear; a picture of a sound, not the sound.\n- this turn the room reaches her as typed lines, and she can answer in the turn's room by typing lines of her own; nothing she does here builds, changes or ships anything.\n",
|
||||
"{}",
|
||||
packet.context
|
||||
);
|
||||
assert!(packet.ids.contains(&"sense-spectrogram".to_owned()), "the sense's id is a typed id the narration must not carry");
|
||||
// A retired sense is no sense; a state with none renders the turn line alone.
|
||||
let mut retired = aqua.clone();
|
||||
retired["embodiment"]["senses"][0]["status"] = json!("retired");
|
||||
for none in [state(), retired] {
|
||||
let body = body_section(&packet_of(TurnKind::Chat, &none, &chat_room(), &History::default(), 1));
|
||||
assert_eq!(body.lines().count(), 2, "{body}");
|
||||
assert!(body.lines().nth(1).unwrap().starts_with("- this turn the room reaches her"), "{body}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_turn_line_is_derived_from_the_affordances_alone() {
|
||||
let her = select::forms(&state());
|
||||
assert_eq!(select::turn_words(&[Affordance::Perceive, Affordance::Speak], her), "this turn the room reaches her as typed lines, and she can answer in the turn's room by typing lines of her own; nothing she does here builds, changes or ships anything");
|
||||
assert_eq!(select::turn_words(&[Affordance::Perceive], her), "this turn the room reaches her as typed lines; nothing she does here builds, changes or ships anything");
|
||||
assert_eq!(select::turn_words(&[], her), "this turn no room reaches her and she can say nothing; nothing she does here builds, changes or ships anything");
|
||||
let them = select::forms(&json!({ "presentation": { "pronouns": "any" } }));
|
||||
assert!(select::turn_words(&[Affordance::Speak], them).ends_with("nothing they do here builds, changes or ships anything"));
|
||||
// The longest turn line and the heading fit the least body guard the tuning allows.
|
||||
for forms in [her, them, select::forms(&json!({ "presentation": { "pronouns": "he/him" } }))] {
|
||||
let longest = format!("Their body:\n- {}.\n", select::turn_words(CAN, forms));
|
||||
assert!(longest.len() <= tuning::BODY_ROOM_MIN, "{} bytes", longest.len());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn what_the_turn_can_do_comes_from_its_organs_and_its_room() {
|
||||
let chat = mouth();
|
||||
let with = Organs { persona: None, chat: Some(&chat), addressing: None, model: None };
|
||||
let without = Organs { chat: None, ..with };
|
||||
assert_eq!(affordances(&with, Some("#swarm:gamecult.org")), [Affordance::Perceive, Affordance::Speak]);
|
||||
assert_eq!(affordances(&with, None), [Affordance::Perceive], "no room, nowhere to speak");
|
||||
assert_eq!(affordances(&without, Some("#swarm:gamecult.org")), [Affordance::Speak], "no mouth, no room reaches her");
|
||||
// Through `project`: the packet carries what its organs can do; the request's room is the turn's.
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let stored = Stored(state());
|
||||
let report = project(&Organs { persona: Some(&stored), ..without }, &request(dir.path(), None, None), now()).unwrap();
|
||||
assert!(report["packet"]["context"].as_str().unwrap().contains("Her body:\n- this turn she can answer in the turn's room by typing lines of her own;"), "{}", report["packet"]["context"]);
|
||||
assert_eq!(report["packet"]["affordances"], json!(["speak"]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_body_is_read_from_state_and_code_never_from_guidance_or_the_voice() {
|
||||
let mut tuning = Tuning::default();
|
||||
tuning.projector.guidance = "BODY-SENTINEL: she has no ears.".into();
|
||||
tuning.persona.guidance = "BODY-SENTINEL: her body is the rooms.".into();
|
||||
let mut voiced = state();
|
||||
voiced["presentation"]["voiceSummary"] = json!("BODY-SENTINEL: no ears, no hands.");
|
||||
let plain = body_section(&packet_of(TurnKind::Chat, &state(), &chat_room(), &History::default(), 1));
|
||||
let packet = packet_tuned(TurnKind::Chat, &voiced, &chat_room(), &History::default(), 1, &tuning);
|
||||
assert_eq!(body_section(&packet), plain, "neither guidance nor the voice reaches the body");
|
||||
assert!(!packet.context.contains("BODY-SENTINEL"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_body_guard_clips_an_entry_reports_it_and_keeps_the_turn_line() {
|
||||
let mut long = state();
|
||||
long["embodiment"] = aqua_ears();
|
||||
long["embodiment"]["senses"][0]["summary"] = json!("s".repeat(900));
|
||||
long["embodiment"]["actuators"] = json!([{ "id": "act-after", "status": "active", "label": "after", "summary": "never fits", "updatedAt": hours_ago(1) }]);
|
||||
let tuning = Tuning::default();
|
||||
let packet = packet_tuned(TurnKind::Chat, &long, &chat_room(), &History::default(), 1, &tuning);
|
||||
let body = body_section(&packet);
|
||||
assert!(body.len() <= tuning.select.body_bytes, "{} bytes", body.len());
|
||||
assert!(body.contains("- sense [sense-spectrogram]") && body.contains('\u{2026}') && body.contains("- this turn the room reaches her"), "{body}");
|
||||
assert!(!body.contains("act-after"), "{body}");
|
||||
assert_eq!(packet.clipped, ["sense-spectrogram", "act-after"], "every entry the guard cut is reported");
|
||||
assert!(packet.identity().len() + packet.context.len() <= tuning.select.context_bytes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mission_pressure_private_notes_and_candidate_actions_never_reach_a_packet() {
|
||||
let room = chat_room();
|
||||
|
|
@ -425,7 +523,7 @@ fn reflection_and_follow_up_stimuli() {
|
|||
let operators = operators();
|
||||
let room = Room::default();
|
||||
let history = History::default();
|
||||
let inputs = Inputs { kind: TurnKind::FollowUp, state: &state(), room: &room, history: &history, observation: Some("Libby's change deleted 40 lines."), people: People { operators: &operators, minds: &[], own_sender: OWN }, now: now(), seed: 1 };
|
||||
let inputs = Inputs { kind: TurnKind::FollowUp, state: &state(), room: &room, history: &history, observation: Some("Libby's change deleted 40 lines."), people: People { operators: &operators, minds: &[], own_sender: OWN }, now: now(), seed: 1, affordances: CAN };
|
||||
let state_value = state();
|
||||
let follow = select(&Inputs { state: &state_value, ..inputs }, &Tuning::default());
|
||||
assert_eq!(follow.stimulus, "She just found: Libby's change deleted 40 lines.");
|
||||
|
|
@ -1163,7 +1261,9 @@ fn a_bond_line_or_the_crowd_line_that_does_not_fit_gives_way_to_the_mood() {
|
|||
// Pools empty, so only the fixed slots compete: the hour and the mood (about 120 bytes), a bond line (about 115 each), the crowd line.
|
||||
let fixed_only = json!({ "publicName": "Eureka", "presentation": state()["presentation"].clone(), "activationProfile": state()["activationProfile"].clone(), "affect": { "socialBonds": state()["affect"]["socialBonds"].clone() } });
|
||||
let mut tuning = Tuning::default();
|
||||
let identity = packet_tuned(TurnKind::Chat, &fixed_only, &chat_room(), &History::default(), 1, &tuning).identity().len();
|
||||
let base = packet_tuned(TurnKind::Chat, &fixed_only, &chat_room(), &History::default(), 1, &tuning);
|
||||
// The body is fixed like the hour, so it is room the test does not count.
|
||||
let identity = base.identity().len() + body_section(&base).len();
|
||||
tuning.select.context_bytes = identity + 200;
|
||||
let packet = packet_tuned(TurnKind::Chat, &fixed_only, &chat_room(), &History::default(), 1, &tuning);
|
||||
assert!(packet.context.contains("- mood") && !packet.context.contains("bond ["), "{}", packet.context);
|
||||
|
|
@ -1225,7 +1325,8 @@ fn every_range_is_validated_on_its_own() {
|
|||
};
|
||||
refused(&|t| t.select.memory_tau_h = 0.0, "select.memory_tau_h");
|
||||
refused(&|t| t.select.memory_tau_h = f64::NAN, "select.memory_tau_h");
|
||||
refused(&|t| t.select.context_bytes = t.select.identity_bytes + 255, "select.context_bytes");
|
||||
refused(&|t| t.select.context_bytes = t.select.identity_bytes + t.select.body_bytes + 255, "select.context_bytes");
|
||||
refused(&|t| t.select.body_bytes = tuning::BODY_ROOM_MIN - 1, "select.body_bytes");
|
||||
refused(&|t| t.select.identity_bytes = usize::MAX, "select.identity_bytes");
|
||||
refused(&|t| t.select.identity_bytes = 32 * 1024, "select.context_bytes");
|
||||
refused(&|t| t.lens.wondering = -1.0, "lens");
|
||||
|
|
@ -1238,7 +1339,8 @@ fn every_range_is_validated_on_its_own() {
|
|||
refused(&|t| t.select.addressed_bytes = 300 * 1024, "select.addressed_bytes");
|
||||
refused(&|t| t.select.caps = tuning::PoolCaps { memories_about_present: 0, other_memories: 0, needs: 0, incubation: 0, stance: 0, value: 0, said: 0 }, "select.caps");
|
||||
let mut edge = Tuning::default();
|
||||
edge.select.context_bytes = edge.select.identity_bytes + 256;
|
||||
edge.select.body_bytes = tuning::BODY_ROOM_MIN;
|
||||
edge.select.context_bytes = edge.select.identity_bytes + edge.select.body_bytes + 256;
|
||||
edge.select.temperature = 0.01;
|
||||
edge.select.addressed_bytes = 1024;
|
||||
assert!(edge.validate().is_ok(), "the edges themselves are allowed");
|
||||
|
|
|
|||
|
|
@ -26,8 +26,10 @@ const PERSONA_GUIDANCE: &str = "Continue her inner stream where the paragraph le
|
|||
const GUIDANCE: &str = "This person is a Mind of the GameCult swarm. She lives in its chat rooms among the operator, the other Minds and whoever drops by. Render the moment as she lives it: who is here and how they sit with her, what she carries, what she wants. What was said reaches her word for word after this stream, so never retell or summarise it: render what it stirs in her and what she makes of the people who said it. Render the conversation as it stands. Leave out whatever the context does not carry: an absence is not part of her moment. Use each person's pronouns as given.";
|
||||
|
||||
|
||||
/// The context room the fixed slots need beside the identity: the hour and the mood lines always fit.
|
||||
/// The context room the fixed slots need beside the identity and the body: the hour and the mood lines always fit.
|
||||
const FIXED_ROOM: usize = 256;
|
||||
/// The least `body_bytes` may be: the body heading and the longest turn line always fit (`select::turn_words`).
|
||||
pub(crate) const BODY_ROOM_MIN: usize = 256;
|
||||
/// The temperatures a selection may run at: colder is deterministic in all but name, hotter is noise.
|
||||
const TEMPERATURE_RANGE: std::ops::RangeInclusive<f64> = 0.01..=10.0;
|
||||
/// The ceiling of the messages to her: at least a long message whole, and far under the connector's 256 KiB frame, which
|
||||
|
|
@ -128,6 +130,9 @@ pub struct SelectTuning {
|
|||
pub bond_summary_bytes: usize,
|
||||
/// One selected item's text, in bytes.
|
||||
pub item_bytes: usize,
|
||||
/// Her body section (map 16.6): its heading, her senses and actuators and the turn line. Taken after the hour and the
|
||||
/// mood and before the people, inside the context budget; the turn line always fits.
|
||||
pub body_bytes: usize,
|
||||
/// The recency time constant of her memories and short-term items, in hours.
|
||||
pub memory_tau_h: f64,
|
||||
/// freshness = base ^ (times shown in the last `freshness_window` projections); 0 never repeats an item in the window.
|
||||
|
|
@ -209,6 +214,7 @@ impl Default for SelectTuning {
|
|||
identity_bytes: 700,
|
||||
bond_summary_bytes: 600,
|
||||
item_bytes: 700,
|
||||
body_bytes: 600,
|
||||
memory_tau_h: 24.0,
|
||||
freshness_base: 0.5,
|
||||
freshness_window: 5,
|
||||
|
|
@ -270,6 +276,7 @@ impl Tuning {
|
|||
("select.identity_bytes", select.identity_bytes),
|
||||
("select.bond_summary_bytes", select.bond_summary_bytes),
|
||||
("select.item_bytes", select.item_bytes),
|
||||
("select.body_bytes", select.body_bytes),
|
||||
("select.group_lines", select.group_lines),
|
||||
("select.group_bytes", select.group_bytes),
|
||||
("projector.words", self.projector.words),
|
||||
|
|
@ -287,6 +294,7 @@ impl Tuning {
|
|||
("select.identity_bytes", select.identity_bytes),
|
||||
("select.bond_summary_bytes", select.bond_summary_bytes),
|
||||
("select.item_bytes", select.item_bytes),
|
||||
("select.body_bytes", select.body_bytes),
|
||||
("select.group_bytes", select.group_bytes),
|
||||
("projector.guidance", self.projector.guidance.len()),
|
||||
("persona.guidance", self.persona.guidance.len()),
|
||||
|
|
@ -303,8 +311,11 @@ impl Tuning {
|
|||
bail!("{name} must be at most {WORDS_MAX}, not {words}");
|
||||
}
|
||||
}
|
||||
if select.identity_bytes.checked_add(FIXED_ROOM).is_none_or(|needed| select.context_bytes < needed) {
|
||||
bail!("select.context_bytes must leave {FIXED_ROOM} bytes beside select.identity_bytes for the hour and the mood");
|
||||
if select.body_bytes < BODY_ROOM_MIN {
|
||||
bail!("select.body_bytes must be at least {BODY_ROOM_MIN}, not {}: the turn line always fits", select.body_bytes);
|
||||
}
|
||||
if select.identity_bytes.checked_add(FIXED_ROOM).and_then(|needed| needed.checked_add(select.body_bytes)).is_none_or(|needed| select.context_bytes < needed) {
|
||||
bail!("select.context_bytes must leave {FIXED_ROOM} bytes beside select.identity_bytes and select.body_bytes for the hour and the mood");
|
||||
}
|
||||
let lens = &self.lens;
|
||||
let weights = [lens.body_and_hour, lens.person_present, lens.unresolved_want, lens.memory_surfacing, lens.wondering];
|
||||
|
|
|
|||
|
|
@ -237,6 +237,7 @@ mind_body::persona: struct TraceItem # [derive (Clone , Debug , PartialEq , Eq ,
|
|||
mind_body::persona: struct TurnTrace # [derive (Clone , Debug , PartialEq , Eq , DatabaseEntry)] pub-fields[run: String, turn: u32, at: DateTime < Utc >, inputs: Vec < TraceItem >, outputs: Vec < TraceItem >, outcome: String]
|
||||
mind_body::projection: # [derive (Clone , Copy , Debug , Default , PartialEq , Eq , serde :: Deserialize)] # [serde (rename_all = "snake_case")] pub enum Through { # [default] Projector , Persona , Interpreter , }
|
||||
mind_body::projection: fn project (organs : & Organs , request : & Request , now : DateTime < Utc >) -> Result < Value >
|
||||
mind_body::projection: impl Affordance
|
||||
mind_body::projection: impl HuginnPersonaSource
|
||||
mind_body::projection: impl HuginnPersonaSource: fn new (client : HuginnClient) -> Self
|
||||
mind_body::projection: impl PersonaSource for HuginnPersonaSource
|
||||
|
|
@ -305,7 +306,7 @@ mind_body::projection::tuning: struct Loaded # [derive (Clone , Debug , PartialE
|
|||
mind_body::projection::tuning: struct PersonaTuning # [derive (Clone , Debug , PartialEq , Serialize , Deserialize)] pub-fields[model: String, guidance: String, words: usize]
|
||||
mind_body::projection::tuning: struct PoolCaps # [derive (Clone , Debug , PartialEq , Eq , Serialize , Deserialize)] pub-fields[memories_about_present: usize, other_memories: usize, needs: usize, incubation: usize, stance: usize, value: usize, said: usize]
|
||||
mind_body::projection::tuning: struct ProjectorTuning # [derive (Clone , Debug , PartialEq , Serialize , Deserialize)] pub-fields[model: String, guidance: String, words: usize, beat_words: usize]
|
||||
mind_body::projection::tuning: struct SelectTuning # [derive (Clone , Debug , PartialEq , Serialize , Deserialize)] pub-fields[temperature: f64, inclusion_score: f64, context_bytes: usize, stimulus_bytes: usize, heard_bytes: usize, addressed_bytes: usize, identity_bytes: usize, bond_summary_bytes: usize, item_bytes: usize, memory_tau_h: f64, freshness_base: f64, freshness_window: usize, people_full: usize, beat_tail_lines: usize, group_state: bool, group_lines: usize, group_bytes: usize, caps: PoolCaps]
|
||||
mind_body::projection::tuning: struct SelectTuning # [derive (Clone , Debug , PartialEq , Serialize , Deserialize)] pub-fields[temperature: f64, inclusion_score: f64, context_bytes: usize, stimulus_bytes: usize, heard_bytes: usize, addressed_bytes: usize, identity_bytes: usize, bond_summary_bytes: usize, item_bytes: usize, body_bytes: usize, memory_tau_h: f64, freshness_base: f64, freshness_window: usize, people_full: usize, beat_tail_lines: usize, group_state: bool, group_lines: usize, group_bytes: usize, caps: PoolCaps]
|
||||
mind_body::projection::tuning: struct Tuning # [derive (Clone , Debug , PartialEq , Serialize , Deserialize)] pub-fields[projector: ProjectorTuning, persona: PersonaTuning, interpreter: InterpreterTuning, select: SelectTuning, lens: LensWeights, pronouns: BTreeMap < String , String >]
|
||||
mind_body::queue: fn on_hold (mind : & dyn MindPort) -> Result < Held >
|
||||
mind_body::queue: impl Held
|
||||
|
|
|
|||
Loading…
Reference in a new issue