K3: her voice reaches the Projector only; the Persona and the Interpreter get her name and pronouns (map 16.4, I16.1)
Packet.identity splits into name (publicName and pronouns) and voice (voiceSummary). The Projector's 'Who they are' is Packet::identity(), name then voice, under the same identity_bytes guard as before; the Persona's 'Who you are' and the Interpreter's 'Who she is' are built from name, a value that cannot hold the voice. The project report carries name and voice in place of identity. A sentinel test proves the voice is in the Projector's prompt and absent from the other two. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d7c04b122c
commit
121011d708
8 changed files with 73 additions and 32 deletions
|
|
@ -230,9 +230,10 @@ fn packet_json(packet: &Packet) -> Value {
|
|||
"lens": packet.lens,
|
||||
"present": packet.present,
|
||||
"selected": packet.selected,
|
||||
"bytes": { "identity": packet.identity.len(), "context": packet.context.len(), "identity_and_context": packet.identity.len() + packet.context.len(), "stimulus": packet.stimulus.len(), "heard": packet.heard.len() },
|
||||
"bytes": { "identity": packet.identity().len(), "context": packet.context.len(), "identity_and_context": packet.identity().len() + packet.context.len(), "stimulus": packet.stimulus.len(), "heard": packet.heard.len() },
|
||||
"overflow": packet.overflow,
|
||||
"identity": packet.identity,
|
||||
"name": packet.name,
|
||||
"voice": packet.voice,
|
||||
"context": packet.context,
|
||||
"stimulus": packet.stimulus,
|
||||
"heard": packet.heard,
|
||||
|
|
|
|||
|
|
@ -460,7 +460,8 @@ fn batch_markdown(plan_path: &Path, plan: &BatchFile, cases: &[Value]) -> String
|
|||
let packet = &report["packet"];
|
||||
let _ = writeln!(out, "- lens: `{}`; present: {}; room: {}", packet["lens"], packet["present"], report["room"]);
|
||||
let _ = writeln!(out, "\n<details><summary>packet</summary>\n");
|
||||
fenced(&mut out, "identity", packet["identity"].as_str().unwrap_or_default());
|
||||
fenced(&mut out, "name", packet["name"].as_str().unwrap_or_default());
|
||||
fenced(&mut out, "voice, the Projector's alone", packet["voice"].as_str().unwrap_or_default());
|
||||
fenced(&mut out, "context", packet["context"].as_str().unwrap_or_default());
|
||||
fenced(&mut out, "stimulus", packet["stimulus"].as_str().unwrap_or_default());
|
||||
fenced(&mut out, "heard", packet["heard"].as_str().unwrap_or_default());
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str) -> St
|
|||
}
|
||||
format!(
|
||||
"{SPEECH_PROMPT}\n\nWho she is:\n{}\n\nThe room: {} ({}).\nWho is in it, as label \u{2014} Matrix id:\n{people}\nWhat she knows privately, none of it to be said here:\n{private}\nWhat reached her:\n{}\n\nHer lived moment:\n{}\n\nHer prose:\n{prose}",
|
||||
packet.identity,
|
||||
packet.name,
|
||||
packet.room.as_deref().unwrap_or("none"),
|
||||
packet.room_kind.words(),
|
||||
packet.stimulus,
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ pub(crate) fn projector_prompt(packet: &Packet, tuning: &Tuning) -> String {
|
|||
"{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.",
|
||||
tuning.projector.guidance.trim(),
|
||||
packet.lens.words(&packet.forms),
|
||||
packet.identity,
|
||||
packet.identity(),
|
||||
packet.context,
|
||||
packet.stimulus,
|
||||
word_budget(packet.kind, tuning),
|
||||
|
|
@ -202,10 +202,11 @@ pub(crate) fn lived_stream(narration: &str, heard: &str) -> String {
|
|||
if heard.trim().is_empty() { narration.to_owned() } else { format!("{narration}\n\n{heard}") }
|
||||
}
|
||||
|
||||
/// The Persona stage's prompt: Ghostlight's prose-only membrane over her identity and her lived stream. No field name,
|
||||
/// number, schema or instruction of hers reaches it (invariant 7); the guidance is the tuning's setting line.
|
||||
/// The Persona stage's prompt: Ghostlight's prose-only membrane over her name and her lived stream; her voice reaches her
|
||||
/// only as the Projector rendered it (map 16.4). No field name, number, schema or instruction of hers reaches it
|
||||
/// (invariant 7); the guidance is the tuning's setting line.
|
||||
pub(crate) fn persona_prompt(packet: &Packet, narration: &str, tuning: &Tuning) -> String {
|
||||
build_persona_prompt(&PersonaPrompt { identity: &packet.identity, lived_stream: &lived_stream(narration, &packet.heard), domain_guidance: tuning.persona.guidance.trim(), word_budget: tuning.persona.words })
|
||||
build_persona_prompt(&PersonaPrompt { identity: &packet.name, lived_stream: &lived_stream(narration, &packet.heard), domain_guidance: tuning.persona.guidance.trim(), word_budget: tuning.persona.words })
|
||||
}
|
||||
|
||||
/// The share of the narration's word trigrams that also appear in what she heard: a lexical overlap, cheap and blind to
|
||||
|
|
|
|||
|
|
@ -234,7 +234,11 @@ pub(crate) struct Packet {
|
|||
pub kind: TurnKind,
|
||||
pub seed: u64,
|
||||
pub lens: Lens,
|
||||
pub identity: String,
|
||||
/// Her name and pronouns: all the Persona and the Interpreter are told of who she is.
|
||||
pub name: String,
|
||||
/// 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.
|
||||
pub voice: String,
|
||||
pub context: String,
|
||||
pub stimulus: String,
|
||||
/// What was said to her, verbatim, rendered by code for the Persona stage.
|
||||
|
|
@ -891,13 +895,28 @@ fn bond_line(bond: &Value, name: &str, tuning: &Tuning, scope: Scope, her: Forms
|
|||
line
|
||||
}
|
||||
|
||||
fn identity_of(state: &Value, tuning: &Tuning) -> String {
|
||||
impl Packet {
|
||||
/// Who she is, as the Projector is told: her name and pronouns, then her voice.
|
||||
pub(crate) fn identity(&self) -> String {
|
||||
joined(&self.name, &self.voice)
|
||||
}
|
||||
}
|
||||
|
||||
fn joined(name: &str, voice: &str) -> String {
|
||||
if voice.is_empty() { name.to_owned() } else { format!("{name}. {voice}") }
|
||||
}
|
||||
|
||||
/// Her name with her pronouns, and her voice, together within `identity_bytes`: the name first, the voice in what is left.
|
||||
fn identity_of(state: &Value, tuning: &Tuning) -> (String, String) {
|
||||
let name = text(state, &["publicName"]);
|
||||
let pronouns = text(state, &["presentation", "pronouns"]);
|
||||
let head = if pronouns.is_empty() { name.to_owned() } else { format!("{name} ({pronouns})") };
|
||||
let voice = text(state, &["presentation", "voiceSummary"]);
|
||||
let whole = if voice.is_empty() { head } else { format!("{head}. {}", one_line(voice)) };
|
||||
clip(&whole, tuning.select.identity_bytes)
|
||||
let whole = if pronouns.is_empty() { name.to_owned() } else { format!("{name} ({pronouns})") };
|
||||
let head = clip(&whole, tuning.select.identity_bytes);
|
||||
let voice = one_line(text(state, &["presentation", "voiceSummary"]));
|
||||
// A name the guard clipped took all the room: no voice after it.
|
||||
let room = if head.len() < whole.trim().len() { 0 } else { tuning.select.identity_bytes.saturating_sub(head.len() + ". ".len()) };
|
||||
let voice = if voice.is_empty() || room <= '…'.len_utf8() { String::new() } else { clip(&voice, room) };
|
||||
(head, voice)
|
||||
}
|
||||
|
||||
/// The names of unbonded people present, as many as fit `ALSO_HERE_BYTES`, then how many more.
|
||||
|
|
@ -1177,7 +1196,7 @@ fn minutes(now: DateTime<Utc>, at_ms: u64) -> i64 {
|
|||
|
||||
pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
||||
let mut draw = Draw(inputs.seed);
|
||||
let identity = identity_of(inputs.state, tuning);
|
||||
let (name, voice) = identity_of(inputs.state, tuning);
|
||||
let (stimulus, heard, overflow) = match inputs.kind {
|
||||
TurnKind::Chat => chat_stimulus(inputs, tuning),
|
||||
TurnKind::Beat => (beat_stimulus(inputs, tuning), String::new(), Overflow::default()),
|
||||
|
|
@ -1187,7 +1206,7 @@ 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(identity.len());
|
||||
let budget = tuning.select.context_bytes.saturating_sub(joined(&name, &voice).len());
|
||||
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"]);
|
||||
|
|
@ -1273,5 +1292,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, identity, 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: 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 }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ fn ids(packet: &Packet) -> Vec<String> {
|
|||
}
|
||||
|
||||
fn whole(packet: &Packet) -> String {
|
||||
format!("{}\n{}\n{}\n{}", packet.identity, packet.context, packet.stimulus, packet.heard)
|
||||
format!("{}\n{}\n{}\n{}", packet.identity(), packet.context, packet.stimulus, packet.heard)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
|
@ -122,7 +122,7 @@ fn golden_chat_packet() {
|
|||
packet.lens,
|
||||
ids(&packet).join(", "),
|
||||
packet.present.join(", "),
|
||||
packet.identity,
|
||||
packet.identity(),
|
||||
packet.context,
|
||||
packet.stimulus,
|
||||
packet.heard,
|
||||
|
|
@ -401,8 +401,8 @@ fn budgets_hold_under_adversarial_sizes() {
|
|||
for kind in [TurnKind::Chat, TurnKind::Beat, TurnKind::Reflection] {
|
||||
for seed in 1..=10 {
|
||||
let packet = packet_of(kind, &big, &room, &History::default(), seed);
|
||||
assert!(packet.identity.len() <= tuning.select.identity_bytes, "identity {}", packet.identity.len());
|
||||
assert!(packet.identity.len() + packet.context.len() <= 2500, "{kind:?}: packet {} bytes", packet.identity.len() + packet.context.len());
|
||||
assert!(packet.identity().len() <= tuning.select.identity_bytes, "identity {}", packet.identity().len());
|
||||
assert!(packet.identity().len() + packet.context.len() <= 2500, "{kind:?}: packet {} bytes", packet.identity().len() + packet.context.len());
|
||||
assert!(packet.stimulus.len() <= 1500 && packet.heard.len() <= 1500, "{kind:?}: stimulus {} heard {}", packet.stimulus.len(), packet.heard.len());
|
||||
}
|
||||
}
|
||||
|
|
@ -427,13 +427,13 @@ fn a_crowd_or_a_huge_label_never_squeezes_out_the_mood() {
|
|||
let messages: Vec<RoomLine> = (0..300).map(|at| message("#swarm:gamecult.org", &format!("@stranger{at}:gamecult.org"), &format!("Stranger {at}"), "hi", 300 - at, false)).collect();
|
||||
let packet = packet_of(TurnKind::Chat, &state(), &Room { messages, ..Room::default() }, &History::default(), 1);
|
||||
assert!(packet.context.contains("- mood") && packet.context.contains("- also here: \"Stranger 299\" (@stranger299:gamecult.org)") && packet.context.contains(" more"), "{}", packet.context);
|
||||
assert!(packet.identity.len() + packet.context.len() <= 2500);
|
||||
assert!(packet.identity().len() + packet.context.len() <= 2500);
|
||||
let mut huge = state();
|
||||
huge["affect"]["socialBonds"] = json!([{ "id": "bond-libby", "object": { "id": "libby", "kind": "person", "label": "L".repeat(3000) }, "relationshipKind": "k".repeat(3000), "status": "active", "summary": "s" }]);
|
||||
let room = Room { messages: vec![message("#swarm:gamecult.org", "@libby:gamecult.org", "Libby", "hi", 1, true)], ..Room::default() };
|
||||
let packet = packet_of(TurnKind::Chat, &huge, &room, &History::default(), 1);
|
||||
assert!(packet.context.contains("- mood") && packet.context.contains("- bond [bond-libby]"), "{}", packet.context);
|
||||
assert!(packet.identity.len() + packet.context.len() <= 2500 && packet.heard.len() < 3000);
|
||||
assert!(packet.identity().len() + packet.context.len() <= 2500 && packet.heard.len() < 3000);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -443,7 +443,7 @@ fn the_identity_cap_holds_on_its_own() {
|
|||
let mut tuning = Tuning::default();
|
||||
tuning.select.identity_bytes = 50;
|
||||
let packet = packet_tuned(TurnKind::Beat, &long, &Room::default(), &History::default(), 1, &tuning);
|
||||
assert!(packet.identity.len() <= 50 && packet.identity.starts_with("Eureka (she/her). dry") && packet.identity.ends_with('…'), "{:?}", packet.identity);
|
||||
assert!(packet.identity().len() <= 50 && packet.identity().starts_with("Eureka (she/her). dry") && packet.identity().ends_with('…'), "{:?}", packet.identity());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -456,11 +456,11 @@ 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 + 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);
|
||||
assert!(packet.identity.len() + packet.context.len() <= tuning.select.context_bytes);
|
||||
assert!(packet.identity().len() + packet.context.len() <= tuning.select.context_bytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -469,8 +469,9 @@ fn clipping_never_splits_a_grapheme() {
|
|||
let mut family = state();
|
||||
family["publicName"] = json!("👩👩👧👦".repeat(40));
|
||||
let packet = packet_of(TurnKind::Beat, &family, &Room::default(), &History::default(), 1);
|
||||
let body = packet.identity.trim_end_matches('…');
|
||||
assert!(packet.identity.len() <= 300 && !body.ends_with('\u{200d}') && body.ends_with('👦'), "{:?}", packet.identity);
|
||||
let identity = packet.identity();
|
||||
let body = identity.trim_end_matches('…');
|
||||
assert!(identity.len() <= 300 && !body.ends_with('\u{200d}') && body.ends_with('👦'), "{identity:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -782,7 +783,7 @@ fn a_given_state_is_projected_without_reading_the_stored_one() {
|
|||
given["publicName"] = json!("Hypothetical");
|
||||
let report = project(&organs, &Request { state: Some(given), ..request(dir.path(), None, None) }, now()).unwrap();
|
||||
assert_eq!((report["state"].as_str(), report["persona_receipt"].is_null()), (Some("given"), true));
|
||||
assert!(report["packet"]["identity"].as_str().unwrap().starts_with("Hypothetical"));
|
||||
assert!(report["packet"]["name"].as_str().unwrap().starts_with("Hypothetical"));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
|
@ -1076,7 +1077,7 @@ 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 identity = packet_tuned(TurnKind::Chat, &fixed_only, &chat_room(), &History::default(), 1, &tuning).identity().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);
|
||||
|
|
@ -1084,7 +1085,7 @@ fn a_bond_line_or_the_crowd_line_that_does_not_fit_gives_way_to_the_mood() {
|
|||
tuning.select.context_bytes = identity + 100;
|
||||
let packet = packet_tuned(TurnKind::Chat, &fixed_only, &chat_room(), &History::default(), 1, &tuning);
|
||||
assert!(packet.context.contains("- mood") && !packet.context.contains("also here"), "{}", packet.context);
|
||||
assert!(packet.identity.len() + packet.context.len() <= tuning.select.context_bytes);
|
||||
assert!(packet.identity().len() + packet.context.len() <= tuning.select.context_bytes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -1381,6 +1382,23 @@ fn the_projector_frame_is_huginns_lived_frame_and_carries_no_ghostlight_membrane
|
|||
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}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn her_voice_reaches_the_projector_and_no_other_stage() {
|
||||
let mut voiced = state();
|
||||
voiced["presentation"]["voiceSummary"] = json!("Speaks in quartz-sentinel cadences.");
|
||||
let packet = packet_of(TurnKind::Chat, &voiced, &chat_room(), &History::default(), 1);
|
||||
let tuning = Tuning::default();
|
||||
let projector = narrate::projector_prompt(&packet, &tuning);
|
||||
assert!(projector.contains("Who they are:\nEureka (she/her). Speaks in quartz-sentinel cadences.\n"), "{projector}");
|
||||
let persona = narrate::persona_prompt(&packet, "The room is warm.", &tuning);
|
||||
let speech = interpret::speech_prompt(&packet, "The room is warm.", "I say hi.");
|
||||
assert!(persona.contains("Who you are:\nEureka (she/her)\n"), "her name and pronouns: {persona}");
|
||||
assert!(speech.contains("Who she is:\nEureka (she/her)\n"), "her name and pronouns: {speech}");
|
||||
for (stage, prompt) in [("Persona", &persona), ("Interpreter", &speech)] {
|
||||
assert!(!prompt.contains("quartz-sentinel"), "the voice reached the {stage}: {prompt}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_projector_is_told_not_to_retell_not_to_offer_options_and_not_to_owe() {
|
||||
let packet = packet_of(TurnKind::Chat, &state(), &chat_room(), &History::default(), 1);
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ fn project_over_a_room_fixture_and_a_state_file_needs_no_daemon_and_no_mouth() {
|
|||
assert_eq!(output.status.code(), Some(0), "{}", text(&output.stderr));
|
||||
let report: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();
|
||||
assert_eq!((report["state"].as_str(), report["persona_receipt"].is_null()), (Some("given"), true), "{report}");
|
||||
assert!(report["packet"]["identity"].as_str().unwrap().starts_with("Tobiah Fenn"), "{report}");
|
||||
assert!(report["packet"]["name"].as_str().unwrap().starts_with("Tobiah Fenn"), "{report}");
|
||||
assert!(report["packet"]["stimulus"].as_str().unwrap().contains("Said to him"), "Kiko's tagged reply is for him, in his own pronouns: {report}");
|
||||
// Without any endpoint at all it runs the same.
|
||||
let output = Command::new(env!("CARGO_BIN_EXE_mind-persona")).args(args).env_clear().env("MIND_PERSONA_TUNING", "/nonexistent/persona-tuning.toml").output().unwrap();
|
||||
|
|
|
|||
|
|
@ -280,6 +280,7 @@ mind_body::projection::select: impl Addressed < '_ >
|
|||
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::simulate: fn simulate (harness : & Harness , plan_path : & Path) -> Result < String >
|
||||
|
|
|
|||
Loading…
Reference in a new issue