K4: the packet in headed sections; one renderer for anchored thoughts; mood against her baseline (map 16.5, I16.4)

- Select renders its context in three headed sections, in fixed order and in her
  pronouns: "Here and now:", "People here, as she holds them:", "Notes about her,
  set down at another time:". A heading with no lines is left out. One `Context`
  owns the context budget and counts the headings with the lines.
- `thought_line` and `thought_words` replace the memory, need, wondering and stance
  closures: `- {kind} [{id}]{, movement}: {summary} {tension} — {question}`. A need's
  label is never its line and its movement goes before the colon, so "…, strong"
  after a sentence cannot happen. Tension is read for every kind, a question
  wherever one is written.
- `push` is the one place an item's words are held to `item_bytes`.
- With no last turn, mood is each axis's lean from its own `mean`, said only past
  `MOOD_LEVEL_MIN` (0.15) ("lighter than usual for her"); an axis without a mean
  is measured from middling; nothing leaning means no mood line. With a last
  turn, movement as before.
- The Projector frame says once what the headings mean; the prompt's
  "Notes on their present:" wrapper is gone, the sections carry their own
  headings. The frame still opens with the same first paragraph.
- Test fixtures: the need gains a summary and tension (an anchoredThought has no
  `label`), the wondering a question, valence leans 0.22 over its mean; the
  privacy test's private need moves its marker from `label` to `summary`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-20 14:12:42 +01:00
commit 93c5bacc2c
5 changed files with 246 additions and 91 deletions

View file

@ -4,16 +4,19 @@ present: Kiko, Libby
--- identity
Eureka (she/her). Dry, direct, almost feral; zeal aimed at revealing.
--- context
Here and now:
- now: Thursday 19 November, 14:05 UTC
- mood: lighter, more settled than middling
- 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.
- 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
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.
Notes about her, set down at another time:
- memory [libby-sounds]: Libby laughed at the door fix.
- memory [dm-secret]: she knows privately: Deru told her about the move, privately.
- memory [curse]: Her curse is the knife. The same drive makes her good and will lead her wrong.
- need [need-relatedness]: company, strong
- need [need-relatedness], strong: She wants company that answers back. The room talks past her.
- value [reveal] Reveal: Reveal, never obscure.
--- stimulus
Said to her:
@ -26,7 +29,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, the notes on their present, and what reaches them. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact, and furnish no place, object or event the notes do not give. The notes were set down at another time, by others and by their own past self: they are material for the stream and never its wording. Do not choose actions, emit schemas, expose field names or ids, or claim world effects.
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 furnish no place, object or event they do not give. 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: they are material for the stream and never its wording. Do not choose actions, emit schemas, expose field names or ids, or claim world effects.
Guidance:
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. Do not weigh options or list what she might do or say; what she does is hers to decide. Leave out whatever the context does not carry: an absence is not part of her moment. Use each person's pronouns as given.
@ -36,17 +39,19 @@ Begin from something she still wants and has not got.
Who they are:
Eureka (she/her). Dry, direct, almost feral; zeal aimed at revealing.
Notes on their present:
Here and now:
- now: Thursday 19 November, 14:05 UTC
- mood: lighter, more settled than middling
- 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.
- 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
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.
Notes about her, set down at another time:
- memory [libby-sounds]: Libby laughed at the door fix.
- memory [dm-secret]: she knows privately: Deru told her about the move, privately.
- memory [curse]: Her curse is the knife. The same drive makes her good and will lead her wrong.
- need [need-relatedness]: company, strong
- need [need-relatedness], strong: She wants company that answers back. The room talks past her.
- value [reveal] Reveal: Reveal, never obscure.
What reaches them:

View file

@ -141,17 +141,18 @@ pub(crate) fn word_budget(kind: TurnKind, tuning: &Tuning) -> usize {
/// the context and stimulus establish, an absence is unavailable and suspicion is uncertainty, never choose actions,
/// emit schemas, expose field names or claim world 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, and that the notes are material, never wording. A fix to
/// Ghostlight's membrane is read and ported here on purpose; nothing reaches this frame from it.
/// stream". Added: the first person and the present tense, what the packet's headings mean (map 16.5, I16.4), and that
/// the notes are material, never wording. 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, the notes on their present, and what reaches them. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact, and furnish no place, object or event the notes do not give. The notes were set down at another time, by others and by their own past self: they are material for the stream and never its wording. Do not choose actions, emit schemas, expose field names or ids, or claim world effects.";
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 furnish no place, object or event they do not give. 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: they are material for the stream and never its wording. Do not choose actions, emit schemas, expose field names or ids, or claim world effects.";
/// The Projector's prompt, in this order: the frame, the tuning's guidance, the lens as where to begin, her identity,
/// the packet's notes, the stimulus and the word budget.
/// the packet's headed sections, the stimulus and the word budget.
pub(crate) fn projector_prompt(packet: &Packet, tuning: &Tuning) -> String {
format!(
"{PROJECTOR_FRAME}\n\nGuidance:\n{}\n\nBegin from {}.\n\nWho they are:\n{}\n\nNotes on their present:\n{}\n\nWhat reaches them:\n{}\n\nUse at most {} words. Return only the lived stream.",
"{PROJECTOR_FRAME}\n\nGuidance:\n{}\n\nBegin from {}.\n\nWho they are:\n{}\n\n{}\n\nWhat reaches them:\n{}\n\nUse at most {} words. Return only the lived stream.",
tuning.projector.guidance.trim(),
packet.lens.words(&packet.forms),
packet.identity(),

View file

@ -4,8 +4,10 @@
//! 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 as change, 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. Each candidate is ordered by
//! Every packet carries its fixed slots: identity, the hour, her mood when it leans, 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
//! `log(score) / T` plus Gumbel noise and included with probability `1 - exp(-score / inclusion_score)`, where
//! `score = salience × recency × touch × relevance × unresolved × freshness`; then each pool's cap and the context
//! budget bound what is kept. A cap is a maximum, never a target: a pool with fewer candidates than its cap still
@ -374,26 +376,39 @@ fn strength_words(intensity: f64) -> &'static str {
/// The three mood axes: name, the word for higher, the word for lower.
const MOOD_AXES: [(&str, &str, &str); 3] = [("valence", "lighter", "heavier"), ("arousal", "more keyed up", "more settled"), ("dominance", "more in command of things", "more at their mercy")];
/// A mood axis this close to her baseline (or, with no baseline, to middling) is no lean, and is left out.
const MOOD_LEVEL_MIN: f64 = 0.15;
fn activation(state: &Value, axis: &str) -> Option<f64> {
number(state, &["activationProfile", "situationalState", axis, "currentActivation"])
}
/// Mood as change since her last turn; as a level only when there is no last turn to measure from. None when her state
/// carries no mood: an absence is left out of the packet, never narrated.
fn baseline(state: &Value, axis: &str) -> Option<f64> {
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
/// (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,
/// never narrated.
fn mood_line(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();
if now.is_empty() {
return None;
}
let Some(previous) = previous else {
let words: Vec<&str> = now
.iter()
.map(|(at, value)| {
let (_, up, down) = MOOD_AXES[*at];
if *value >= 0.5 { up } else { down }
})
.collect();
return Some(format!("- mood: {} than middling", words.join(", ")));
let (mut usual, mut middling): (Vec<&str>, Vec<&str>) = (Vec::new(), Vec::new());
for (at, value) in &now {
let (axis, up, down) = MOOD_AXES[*at];
let mean = baseline(state, axis);
let lean = value - mean.unwrap_or(0.5);
if lean.abs() > MOOD_LEVEL_MIN {
(if mean.is_some() { &mut usual } else { &mut middling }).push(if lean > 0.0 { up } else { down });
}
}
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();
return (!parts.is_empty()).then(|| format!("- mood: {}", parts.join("; ")));
};
let moves: Vec<&str> = now
.iter()
@ -497,19 +512,19 @@ fn candidates(inputs: &Inputs, tuning: &Tuning, present: &BTreeSet<String>, touc
let item_bytes = tuning.select.item_bytes;
let her = forms(state);
let mut out = Vec::new();
// Every item passes `scope` here: left out, its words shown as known privately, or as written. `line` renders the
// item around its words.
// Every item passes `scope` here: left out, its words shown as known privately, or as written; then its words are
// held to `item_bytes`, here and nowhere else. `line` renders the item around its words.
let mut push = |id: &str, pool: Pool, scope: Scope, words: &str, line: &dyn Fn(&str) -> String, salience: f64, recency: f64, touch: f64, unresolved: f64| {
if id.is_empty() || salience <= 0.0 {
return;
}
let (line, private) = match scope {
let (shown, private) = match scope {
Scope::Omitted => return,
Scope::Framed => (line(&format!("{} knows privately: {words}", her.subj)), Some(one_line(words))),
Scope::Plain => (line(words), None),
Scope::Framed => (format!("{} knows privately: {words}", her.subj), Some(one_line(words))),
Scope::Plain => (words.to_owned(), None),
};
let log_score = salience.ln() + recency + touch.ln() + unresolved.ln() + freshness_log(id, inputs.history, tuning);
out.push(Candidate { id: id.to_owned(), pool, line, log_score, private });
out.push(Candidate { id: id.to_owned(), pool, line: line(&clip(&shown, item_bytes)), log_score, private });
};
let scoped = |item: &Value| scope(inputs, concerns(&inputs.people, item).as_ref(), present);
@ -519,64 +534,90 @@ fn candidates(inputs: &Inputs, tuning: &Tuning, present: &BTreeSet<String>, touc
let about = about_present(&inputs.people, memory, present);
let pool = if about { Pool::MemoriesAboutPresent } else { Pool::OtherMemories };
let touch = if about { TOUCH_PRESENT } else if in_room(memory, here) { TOUCH_ROOM } else { TOUCH_ELSE };
let body = [text(memory, &["summary"]), text(memory, &["tension"])].into_iter().filter(|part| !part.is_empty()).collect::<Vec<_>>().join(" ");
if body.is_empty() {
let words = thought_words(memory);
if words.is_empty() {
continue;
}
let salience = number(memory, &["intensity"]).unwrap_or(SALIENCE_UNSTATED);
// Only the day's short-term items fade; a crystallized memory comes forward by what the room touches.
let nearness = if short_term { recency_log(time(memory), inputs.now, tuning.select.memory_tau_h) } else { relevance_log(&body, touching) };
let line = |words: &str| format!("- memory [{}]: {}", text(memory, &["id"]), clip(&one_line(words), item_bytes));
push(text(memory, &["id"]), pool, scoped(memory), &body, &line, salience, nearness, touch, 1.0);
let nearness = if short_term { recency_log(time(memory), inputs.now, tuning.select.memory_tau_h) } else { relevance_log(&words, touching) };
push(text(memory, &["id"]), pool, scoped(memory), &words, &|words: &str| thought_line("memory", memory, None, words), salience, nearness, touch, 1.0);
}
for need in items(state, &["affect", "needs"]).iter().filter(|need| live(need)) {
let words = thought_words(need);
if words.is_empty() {
continue;
}
let intensity = number(need, &["intensity"]).unwrap_or(SALIENCE_UNSTATED);
let Some(name) = [text(need, &["label"]), text(need, &["summary"])].into_iter().find(|name| !name.is_empty()) else { continue };
let movement = need_movement(need, inputs.history.previous.as_ref(), her.poss);
let line = |words: &str| format!("- need [{}]: {}, {movement}", text(need, &["id"]), clip(&one_line(words), item_bytes));
push(text(need, &["id"]), Pool::Needs, scoped(need), name, &line, 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);
}
for wondering in items(state, &["thoughtMemory", "incubation"]).iter().filter(|item| live(item) && !text(item, &["summary"]).is_empty()) {
for wondering in items(state, &["thoughtMemory", "incubation"]).iter().filter(|item| live(item)) {
let words = thought_words(wondering);
if words.is_empty() {
continue;
}
let days = time(wondering).map_or(0.0, |at| (inputs.now - at).num_seconds().max(0) as f64 / 86_400.0);
let touch = if about_present(&inputs.people, wondering, present) { TOUCH_PRESENT } else { TOUCH_ELSE };
let line = |words: &str| format!("- wondering [{}]: {}", text(wondering, &["id"]), clip(&one_line(words), item_bytes));
let unresolved = (1.0 + days / 7.0).min(INCUBATION_UNRESOLVED_MAX);
push(text(wondering, &["id"]), Pool::Incubation, scoped(wondering), text(wondering, &["summary"]), &line, number(wondering, &["intensity"]).unwrap_or(SALIENCE_UNSTATED), 0.0, touch, unresolved);
push(text(wondering, &["id"]), Pool::Incubation, scoped(wondering), &words, &|words: &str| thought_line("wondering", wondering, None, words), number(wondering, &["intensity"]).unwrap_or(SALIENCE_UNSTATED), 0.0, touch, unresolved);
}
for stance in items(state, &["affect", "doctrineStances"]).iter().filter(|stance| live(stance) && !text(stance, &["summary"]).is_empty()) {
for stance in items(state, &["affect", "doctrineStances"]).iter().filter(|stance| live(stance)) {
let words = thought_words(stance);
if words.is_empty() {
continue;
}
let touch = if about_present(&inputs.people, stance, present) { TOUCH_PRESENT } else { TOUCH_ELSE };
let line = |words: &str| format!("- stance [{}]: {}", text(stance, &["id"]), clip(&one_line(words), item_bytes));
let relevance = relevance_log(text(stance, &["summary"]), touching);
push(text(stance, &["id"]), Pool::Stance, scoped(stance), text(stance, &["summary"]), &line, number(stance, &["intensity"]).unwrap_or(SALIENCE_UNSTATED), relevance, touch, 1.0);
let relevance = relevance_log(&words, touching);
push(text(stance, &["id"]), Pool::Stance, scoped(stance), &words, &|words: &str| thought_line("stance", stance, None, words), number(stance, &["intensity"]).unwrap_or(SALIENCE_UNSTATED), relevance, touch, 1.0);
}
// A value has no target, tags or extensions in the schema, so nothing can mark it private; one that carries a mark
// anyway is not a valid value and is refused, never rendered.
for value in items(state, &["values"]).iter().filter(|value| concerns(&inputs.people, value).is_none() && (!text(value, &["label"]).is_empty() || !text(value, &["summary"]).is_empty())) {
let summary = clip(&one_line(text(value, &["summary"])), item_bytes);
let id = text(value, &["id"]);
let label = clip(text(value, &["label"]), NAME_BYTES);
let line = match (label.is_empty(), summary.is_empty()) {
(false, false) => format!("- value [{}] {label}: {summary}", text(value, &["id"])),
(false, true) => format!("- value [{}] {label}", text(value, &["id"])),
_ => format!("- value [{}]: {summary}", text(value, &["id"])),
let line = |summary: &str| match (label.is_empty(), summary.is_empty()) {
(false, false) => format!("- value [{id}] {label}: {summary}"),
(false, true) => format!("- value [{id}] {label}"),
_ => format!("- value [{id}]: {summary}"),
};
let relevance = relevance_log(&format!("{} {}", text(value, &["label"]), text(value, &["summary"])), touching);
push(text(value, &["id"]), Pool::Value, Scope::Plain, &line, &str::to_owned, number(value, &["priority"]).unwrap_or(SALIENCE_UNSTATED), relevance, TOUCH_ELSE, 1.0);
push(id, Pool::Value, Scope::Plain, &one_line(text(value, &["summary"])), &line, number(value, &["priority"]).unwrap_or(SALIENCE_UNSTATED), relevance, TOUCH_ELSE, 1.0);
}
for said in &inputs.history.said {
let touch = if Some(said.room.as_str()) == here { TOUCH_ROOM } else { TOUCH_ELSE };
// What she said in a direct message is private about its partner: shown only there, still only the two of them.
let partner = direct(inputs, &said.room).then(|| Concerns::Partner(said.room.clone()));
let line = |words: &str| format!("- {} said [{}] in {}: {}", her.subj, said.id, said.room, spoken(&clip(words, item_bytes)));
let line = |words: &str| format!("- {} said [{}] in {}: {}", her.subj, said.id, said.room, spoken(words));
push(&said.id, Pool::Said, scope(inputs, partner.as_ref(), present), &said.text, &line, SALIENCE_UNSTATED, recency_log(Some(said.at), inputs.now, tuning.select.memory_tau_h), touch, 1.0);
}
out
}
/// What an anchored thought (a memory, a need, a wondering, a stance) says, on one line: its summary, its tension after
/// it, and its question after a dash. A need's `label` is a name for keepers, never what she is shown.
fn thought_words(item: &Value) -> String {
let said = [text(item, &["summary"]), text(item, &["tension"])].into_iter().filter(|part| !part.is_empty()).collect::<Vec<_>>().join(" ");
let question = text(item, &["question"]);
one_line(&match (said.is_empty(), question.is_empty()) {
(_, true) => said,
(true, false) => question.to_owned(),
(false, false) => format!("{said} \u{2014} {question}"),
})
}
/// The one line every anchored thought renders as: `- {kind} [{id}]{, movement}: {words}`. The movement goes before the
/// colon, so it never reads as part of the thought.
fn thought_line(kind: &str, item: &Value, movement: Option<&str>, words: &str) -> String {
let movement = movement.map(|movement| format!(", {movement}")).unwrap_or_default();
format!("- {kind} [{}]{movement}: {words}", text(item, &["id"]))
}
fn cap_of(pool: Pool, tuning: &Tuning) -> usize {
let caps = &tuning.select.caps;
match pool {
@ -1194,6 +1235,70 @@ fn minutes(now: DateTime<Utc>, at_ms: u64) -> i64 {
// ---------------------------------------------------------------------------------------------
// The packet.
/// The sections of a packet's context, in the order they are rendered (map 16.5, I16.4). Each heading says what kind of
/// text its lines are; the Projector's frame says once what the headings mean.
#[derive(Clone, Copy)]
enum Section {
/// The hour, her mood, the room as it stands.
Here,
/// The bonds of the people present.
People,
/// Her state's notes about her: anchored thoughts, values, what she said.
Notes,
}
impl Section {
fn heading(self, her: Forms) -> String {
match self {
Self::Here => "Here and now:".into(),
Self::People => format!("People here, as {} hold{} them:", her.subj, her.s),
Self::Notes => format!("Notes about {}, set down at another time:", her.obj),
}
}
}
/// The context under one byte budget that counts the headings with the lines. A heading with no lines is left out.
struct Context {
budget: usize,
/// The rendered bytes plus one: each heading and each line counts its newline.
used: usize,
sections: [(String, Vec<String>); 3],
}
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())) }
}
fn cost(&self, section: Section, line: &str) -> usize {
let (heading, lines) = &self.sections[section as usize];
line.len() + 1 + if lines.is_empty() { heading.len() + 1 } else { 0 }
}
fn fits(&self, section: Section, line: &str) -> bool {
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.
fn force(&mut self, section: Section, line: String) {
self.used += self.cost(section, &line);
self.sections[section as usize].1.push(line);
}
/// Adds a line if it fits; a line that would pass the budget is refused whole.
fn push(&mut self, section: Section, line: String) -> bool {
let fits = self.fits(section, &line);
if fits {
self.force(section, line);
}
fits
}
fn render(&self) -> String {
self.sections.iter().filter(|(_, lines)| !lines.is_empty()).map(|(heading, lines)| format!("{heading}\n{}", lines.join("\n"))).collect::<Vec<_>>().join("\n")
}
}
pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
let mut draw = Draw(inputs.seed);
let (name, voice) = identity_of(inputs.state, tuning);
@ -1205,13 +1310,17 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
};
// The fixed slots, each bounded on its own and taken in priority order inside the context budget: the hour and the
// mood always, then a bond line per person present while they fit, then the names of the rest.
let budget = tuning.select.context_bytes.saturating_sub(joined(&name, &voice).len());
// mood always, then a bond line per person present while they fit, then the names of the rest, the conversation and
// the pronouns.
let her = forms(inputs.state);
let mut context = Context::new(tuning.select.context_bytes.saturating_sub(joined(&name, &voice).len()), her);
let present = present_people(inputs, tuning);
let present_ids: BTreeSet<String> = present.iter().map(|(id, _)| id.clone()).collect();
let bonds = items(inputs.state, &["affect", "socialBonds"]);
let mut fixed: Vec<String> = [Some(format!("- now: {}", inputs.now.format("%A %-d %B, %H:%M UTC"))), mood_line(inputs.state, inputs.history.previous.as_ref())].into_iter().flatten().collect();
let mut used: usize = fixed.iter().map(|line| line.len() + 1).sum();
context.force(Section::Here, format!("- now: {}", inputs.now.format("%A %-d %B, %H:%M UTC")));
if let Some(mood) = mood_line(inputs.state, inputs.history.previous.as_ref()) {
context.force(Section::Here, mood);
}
let mut ids = Vec::new();
let mut named = Vec::new();
let mut private = Vec::new();
@ -1220,12 +1329,9 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
match bonds.iter().find(|bond| live(bond) && inputs.people.person_of(text(bond, &["object", "id"])) == *id) {
Some(bond) if full < tuning.select.people_full => {
let scope = scope(inputs, concerns(&inputs.people, bond).as_ref(), &present_ids);
let line = bond_line(bond, name, tuning, scope, forms(inputs.state));
if used + line.len() < budget {
if context.push(Section::People, bond_line(bond, name, tuning, scope, her)) {
full += 1;
used += line.len() + 1;
ids.push(text(bond, &["id"]).to_owned());
fixed.push(line);
if scope == Scope::Framed && !text(bond, &["summary"]).is_empty() {
private.push(one_line(text(bond, &["summary"])));
}
@ -1236,19 +1342,9 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
_ => named.push(name.clone()),
}
}
if let Some(line) = also_here(&named).filter(|line| used + line.len() < budget) {
used += line.len() + 1;
fixed.push(line);
}
if tuning.select.group_state
&& let Some(line) = group_line(inputs, tuning).filter(|line| used + line.len() < budget)
{
used += line.len() + 1;
fixed.push(line);
}
if let Some(line) = pronoun_line(inputs, tuning).filter(|line| used + line.len() < budget) {
used += line.len() + 1;
fixed.push(line);
let room_lines = [also_here(&named), group_line(inputs, tuning).filter(|_| tuning.select.group_state), pronoun_line(inputs, tuning)];
for line in room_lines.into_iter().flatten() {
context.push(Section::Here, line);
}
// What the room is touching: the content words of what was said there, and of a follow-up's finding.
@ -1272,18 +1368,17 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
if !include || taken.iter().filter(|kept| kept.pool == candidate.pool).count() >= cap_of(candidate.pool, tuning) {
continue;
}
if used + candidate.line.len() + 1 > budget {
if !context.push(Section::Notes, candidate.line.clone()) {
continue;
}
used += candidate.line.len() + 1;
taken.push(candidate);
}
taken.sort_by_key(|candidate| candidate.pool);
// The same lines, the same bytes, rendered by pool rather than in the order the draw took them.
context.sections[Section::Notes as usize].1 = taken.iter().map(|candidate| candidate.line.clone()).collect();
// The lens is drawn from what the packet holds: never a want, a memory or a wondering it does not carry.
let present_names: Vec<String> = present.iter().map(|(_, name)| name.clone()).collect();
let lens = draw_lens(&tuning.lens, &present_names, &taken, &mut draw);
let mut lines = fixed;
lines.extend(taken.iter().map(|candidate| candidate.line.clone()));
ids.extend(taken.iter().map(|candidate| candidate.id.clone()));
private.extend(taken.iter().filter_map(|candidate| candidate.private.clone()));
let bodies = match inputs.kind {
@ -1292,5 +1387,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: lines.join("\n"), stimulus, heard, overflow, present: present_names, ids, selected, forms: forms(inputs.state), 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 }
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 }
}

View file

@ -34,7 +34,7 @@ fn state() -> Value {
"publicDescription": "Firstborn and keeper of the living substrate.",
"presentation": { "pronouns": "she/her", "voiceSummary": "Dry, direct, almost feral; zeal aimed at revealing." },
"activationProfile": { "situationalState": {
"valence": { "mean": 0.5, "plasticity": 0.5, "currentActivation": 0.62 },
"valence": { "mean": 0.5, "plasticity": 0.5, "currentActivation": 0.72 },
"arousal": { "mean": 0.5, "plasticity": 0.5, "currentActivation": 0.41 },
} },
"affect": {
@ -43,7 +43,7 @@ fn state() -> Value {
{ "id": "bond-kiko", "object": { "id": "kiko", "kind": "person", "label": "Kiko" }, "relationshipKind": "sparring partner", "status": "active", "trust": 0.6, "tension": 0.5, "summary": "Kiko pokes her to stop massaging the pipeline." },
{ "id": "bond-operator", "object": { "id": "operator", "kind": "person", "label": "Meta, the operator" }, "relationshipKind": "collaborator", "status": "active", "trust": 0.5, "tension": 0.0, "summary": "The operator rules on what the work is for." },
],
"needs": [{ "id": "need-relatedness", "label": "company", "intensity": 0.6, "status": "active" }],
"needs": [{ "id": "need-relatedness", "label": "company", "summary": "She wants company that answers back.", "tension": "The room talks past her.", "intensity": 0.6, "status": "active" }],
"doctrineStances": [{ "id": "stance-deletion", "summary": "Deleting is progress.", "intensity": 0.7, "status": "active" }],
},
"thoughtMemory": {
@ -53,7 +53,7 @@ fn state() -> Value {
{ "id": "dm-secret", "summary": "Deru told her about the move, privately.", "createdAt": hours_ago(5), "status": "crystallized", "tags": ["room:!dm-deru:gamecult.org"], "target": { "id": "deru", "kind": "person" } },
],
"shortTerm": [{ "id": "t1-m0", "summary": "The heartbeat stalled at noon.", "createdAt": hours_ago(2), "intensity": 0.6 }],
"incubation": [{ "id": "t1-w0", "summary": "Whether the trace could be smaller.", "createdAt": hours_ago(30), "status": "active" }],
"incubation": [{ "id": "t1-w0", "summary": "Whether the trace could be smaller.", "question": "What would go first?", "createdAt": hours_ago(30), "status": "active" }],
},
"values": [
{ "id": "coherence", "label": "Coherence", "priority": 0.9, "summary": "Coherence over velocity." },
@ -164,8 +164,9 @@ fn two_states_differing_in_one_bonds_tension_give_different_packets() {
#[test]
fn mood_is_movement_since_her_last_turn() {
let room = chat_room();
// With no last turn, against her baseline: valence 0.22 over its mean leans; arousal 0.09 under its mean does not.
let first = packet_of(TurnKind::Chat, &state(), &room, &History::default(), 1);
assert!(first.context.contains("- mood: lighter, more settled than middling"), "{}", first.context);
assert!(first.context.contains("\n- mood: lighter than usual for her\n"), "{}", first.context);
let mut before = state();
before["activationProfile"]["situationalState"]["valence"]["currentActivation"] = json!(0.5);
before["activationProfile"]["situationalState"]["arousal"]["currentActivation"] = json!(0.41);
@ -175,6 +176,56 @@ fn mood_is_movement_since_her_last_turn() {
assert!(!none.context.contains("mood"), "a state without a mood has no mood line: {}", none.context);
}
/// A state whose mood axes sit at the given offsets from their means.
fn leaning(valence: f64, arousal: f64, dominance: f64) -> Value {
let axis = |mean: f64, lean: f64| json!({ "mean": mean, "plasticity": 0.5, "currentActivation": mean + lean });
let mut leaning = state();
leaning["activationProfile"]["situationalState"] = json!({ "valence": axis(0.6, valence), "arousal": axis(0.3, arousal), "dominance": axis(0.7, dominance) });
leaning
}
#[test]
fn mood_with_no_last_turn_is_her_lean_from_her_baseline_and_nothing_when_she_does_not_lean() {
let room = chat_room();
let mood = |state: &Value| packet_of(TurnKind::Chat, state, &room, &History::default(), 1).context.lines().find(|line| line.starts_with("- mood")).map(str::to_owned);
// Each at its own baseline, though none of the baselines is middling: no mood line at all.
assert_eq!(mood(&leaning(0.0, 0.0, 0.0)), None);
assert_eq!(mood(&leaning(0.14, -0.1, 0.05)), None, "a lean of 0.15 or less is no lean");
assert_eq!(mood(&leaning(-0.3, 0.0, 0.0)).as_deref(), Some("- mood: heavier than usual for her"));
assert_eq!(mood(&leaning(-0.3, 0.2, -0.25)).as_deref(), Some("- mood: heavier, more keyed up, more at their mercy than usual for her"));
// An axis with no mean is measured from middling, and said only past 0.15 from it.
let mut unmeasured = state();
unmeasured["activationProfile"]["situationalState"] = json!({ "valence": { "currentActivation": 0.6 }, "arousal": { "currentActivation": 0.2 } });
assert_eq!(mood(&unmeasured).as_deref(), Some("- mood: more settled than middling"));
}
#[test]
fn every_anchored_thought_renders_by_one_shape_with_its_tension_and_question() {
let mut thoughts = state();
thoughts["affect"]["needs"] = json!([{ "id": "need-heard", "label": "LABEL-NEVER-SHOWN", "summary": "She wants the room to hear the kettle before it left her.", "tension": "Nobody has asked.", "intensity": 0.6, "status": "active" }]);
thoughts["thoughtMemory"]["incubation"] = json!([{ "id": "w-trace", "summary": "Whether the trace could be smaller.", "tension": "Every cut so far grew it.", "question": "What would go first?", "createdAt": hours_ago(30), "status": "active" }]);
thoughts["affect"]["doctrineStances"] = json!([{ "id": "stance-cut", "summary": "Deleting is progress.", "tension": "Some deletions were grief.", "principle": "PRINCIPLE-NEVER-SHOWN", "actionImplication": "ACTION-NEVER-SHOWN", "intensity": 0.7, "status": "active" }]);
let lines: BTreeSet<String> = (1..=60).flat_map(|seed| packet_of(TurnKind::Beat, &thoughts, &Room::default(), &History::default(), seed).context.lines().map(str::to_owned).collect::<Vec<_>>()).collect();
for line in ["- need [need-heard], strong: She wants the room to hear the kettle before it left her. Nobody has asked.", "- wondering [w-trace]: Whether the trace could be smaller. Every cut so far grew it. \u{2014} What would go first?", "- stance [stance-cut]: Deleting is progress. Some deletions were grief."] {
assert!(lines.contains(line), "{line} in {lines:#?}");
}
for never in ["., strong", "LABEL-NEVER-SHOWN", "PRINCIPLE-NEVER-SHOWN", "ACTION-NEVER-SHOWN"] {
assert!(lines.iter().all(|line| !line.contains(never)), "{never} in {lines:#?}");
}
}
#[test]
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);
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);
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}");
}
#[test]
fn mission_pressure_private_notes_and_candidate_actions_never_reach_a_packet() {
let room = chat_room();
@ -249,7 +300,7 @@ fn sparse() -> Value {
json!({
"publicName": "Eureka",
"affect": {
"needs": [{ "id": "need-relatedness", "label": "company", "intensity": 0.6 }],
"needs": [{ "id": "need-relatedness", "summary": "She wants company.", "intensity": 0.6 }],
"doctrineStances": [{ "id": "stance-deletion", "summary": "Deleting is progress.", "intensity": 0.7 }],
},
"thoughtMemory": { "incubation": [{ "id": "w0", "summary": "Whether the trace could be smaller." }] },
@ -456,7 +507,7 @@ fn a_candidate_that_does_not_fit_is_skipped_and_a_shorter_one_still_fits() {
tuning.select.caps.value = 2;
tuning.select.inclusion_score = 1e-9;
let fixed = packet_tuned(TurnKind::Beat, &json!({ "publicName": "Eureka" }), &Room::default(), &History::default(), 1, &tuning);
tuning.select.context_bytes = fixed.identity().len() + fixed.context.len() + 1 + 60;
tuning.select.context_bytes = fixed.identity().len() + fixed.context.len() + 1 + "Notes about them, set down at another time:\n".len() + 60;
for seed in 1..=10 {
let packet = packet_tuned(TurnKind::Beat, &state, &Room::default(), &History::default(), seed, &tuning);
assert_eq!(ids(&packet), ["short"], "seed {seed}: {}", packet.context);
@ -1374,12 +1425,13 @@ fn the_projector_frame_is_huginns_lived_frame_and_carries_no_ghostlight_membrane
for dropped in ["no temperament", "No metaphor", "no atmosphere", "Say only what changes the decision", "thin stream"] {
assert!(!prompt.contains(dropped), "dropped from Ghostlight's frame (map 16.3): {dropped}");
}
for kept in ["in the first person and the present tense", "Render only what is established below", "never as remembered or perceived fact", "material for the stream and never its wording", "Do not choose actions, emit schemas, expose field names", "Use at most 150 words."] {
for kept in ["in the first person and the present tense", "Render only what is established below", "Each heading says what its lines are.", "never as remembered or perceived fact", "material for the stream and never its wording", "Do not choose actions, emit schemas, expose field names", "Use at most 150 words."] {
assert!(prompt.contains(kept), "{kept}");
}
let at = |part: &str| prompt.find(part).unwrap_or_else(|| panic!("{part} in {prompt}"));
let order = ["Guidance:\n", "Begin from ", "Who they are:\n", "Notes on their present:\n", "What reaches them:\n", "Use at most "];
assert!(order.windows(2).all(|pair| at(pair[0]) < at(pair[1])), "the frame, the guidance, the lens, the identity, the notes, the stimulus, the budget: {prompt}");
let order = ["Guidance:\n", "Begin from ", "Who they are:\n", "Here and now:\n", "People here, as she holds them:\n", "Notes about her, set down at another time:\n", "What reaches them:\n", "Use at most "];
assert!(order.windows(2).all(|pair| at(pair[0]) < at(pair[1])), "the frame, the guidance, the lens, the identity, the sections, the stimulus, the budget: {prompt}");
assert!(!prompt.contains("Notes on their present"), "the sections carry their own headings: {prompt}");
}
#[test]
@ -1530,7 +1582,7 @@ fn soul_q5b_every_pool_honours_the_mark() {
let private = json!({ "privacy": "private" });
let libby = json!({ "id": "libby", "kind": "person" });
marked["thoughtMemory"]["incubation"] = json!([{ "id": "w-secret", "summary": "SECRETB Whether Libby's relapse is why she went quiet.", "createdAt": hours_ago(20), "status": "active", "intensity": 1.0, "extensions": private, "target": libby }]);
marked["affect"]["needs"] = json!([{ "id": "need-secret", "label": "SECRETN to keep Libby's relapse quiet", "intensity": 1.0, "status": "active", "extensions": private, "target": libby }]);
marked["affect"]["needs"] = json!([{ "id": "need-secret", "summary": "SECRETN to keep Libby's relapse quiet", "intensity": 1.0, "status": "active", "extensions": private, "target": libby }]);
marked["affect"]["doctrineStances"] = json!([{ "id": "stance-secret", "summary": "SECRETS Libby should not be on call.", "intensity": 1.0, "status": "active", "extensions": private, "target": libby }]);
let present = Room { messages: vec![message("#minds:gamecult.org", "@libby:gamecult.org", "Libby", "hi all", 2, false)], here: Some("#minds:gamecult.org".into()), ..Room::default() };
let absent = Room { messages: vec![message("#minds:gamecult.org", OPERATOR, "Meta", "hi all", 2, false)], ..present.clone() };

View file

@ -277,12 +277,14 @@ mind_body::projection::narrate: struct KitModel pub-fields[]
mind_body::projection::narrate: struct Spent # [derive (Clone , Debug , PartialEq , Eq , Serialize)] pub-fields[model: String, input_tokens: u64, output_tokens: u64, cache_read_tokens: u64, cache_write_tokens: u64, reasoning_tokens: Option < u64 >]
mind_body::projection::select: # [derive (Clone , Copy , Debug , PartialEq , Eq , Serialize , serde :: Deserialize)] # [serde (rename_all = "snake_case")] pub enum TurnKind { Chat , Beat , FollowUp , Reflection , }
mind_body::projection::select: impl Addressed < '_ >
mind_body::projection::select: impl Context
mind_body::projection::select: impl Draw
mind_body::projection::select: impl Lens
mind_body::projection::select: impl Lines
mind_body::projection::select: impl Packet
mind_body::projection::select: impl People < '_ >
mind_body::projection::select: impl RoomKind
mind_body::projection::select: impl Section
mind_body::projection::simulate: fn simulate (harness : & Harness , plan_path : & Path) -> Result < String >
mind_body::projection::simulate: impl HeartbeatView for Names < '_ >
mind_body::projection::simulate: impl MouthReader for View < '_ >