From bef3245e653b30ab7ce7385a8674dd94bcd4cd90 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 3 Dec 2026 00:19:56 +0100 Subject: [PATCH] The player's narration is a storyteller prompt in second person, not the Persona Projector's lived stream PersonaLane::narrate ran the Projector prompt, which renders one lived stream in the person's own present: the framing a Persona is then asked to be. The model followed it into first person. The narrator now has its own prompt and context: place, who is present, open exits and where they lead. Co-Authored-By: Claude Sonnet 5.5 --- .../ghostlight-persona-projection/src/lib.rs | 36 ++++++++ crates/ghostlight/src/controllers.rs | 91 +++++++++++++++++-- 2 files changed, 117 insertions(+), 10 deletions(-) diff --git a/crates/ghostlight-persona-projection/src/lib.rs b/crates/ghostlight-persona-projection/src/lib.rs index f8bc03b..e12300d 100644 --- a/crates/ghostlight-persona-projection/src/lib.rs +++ b/crates/ghostlight-persona-projection/src/lib.rs @@ -54,6 +54,17 @@ pub struct ProjectorPrompt<'a> { pub word_budget: usize, } +/// What the storyteller is given to narrate a human player's own view. The +/// player is not a Persona: nothing here is lived from inside them. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub struct NarratorPrompt<'a> { + pub player: &'a str, + pub typed_context: &'a str, + pub visible_stimulus: &'a str, + pub domain_guidance: &'a str, + pub word_budget: usize, +} + #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct PersonaPrompt<'a> { pub identity: &'a str, @@ -93,6 +104,31 @@ pub fn build_projector_prompt(input: &ProjectorPrompt<'_>) -> String { ) } +/// The storyteller's contract: it narrates to the player, in second person, and +/// is never the player or anyone else in the story. +pub fn build_narrator_prompt(input: &NarratorPrompt<'_>) -> String { + format!( + " +You are the storyteller of a world, narrating the player's present moment to the player. The player's character is {player}. Always speak to the player in the second person, present tense (\"You stand in...\"); never in the first person, and never as {player} or any other character. Anything the player said or did is the player's own, never yours: if you refer to it, quote it as theirs (\"You said...\"). Render only what the permitted context and visible stimulus establish, as a short scene: the place you stand in, who is here with you by name, each way out and where it leads, anything pressing on you, and what you could do now. Name only the people, places, and routes the context names; invent none, and do not claim what lies beyond an exit. Anything absent from the context is unknown: say so once, plainly, rather than repeating status you do not have. Do not choose actions for the player, expose field names, or claim world effects. + +Domain guidance: +{guidance} + +Permitted typed context: +{context} + +Visible stimulus: +{stimulus} + +Use at most {word_budget} words; fewer is better. Return only the narration.", + player = input.player, + guidance = input.domain_guidance, + context = input.typed_context, + stimulus = input.visible_stimulus, + word_budget = input.word_budget, + ) +} + pub fn build_persona_prompt(input: &PersonaPrompt<'_>) -> String { format!( "Everything below is prose from inside one person's life. Be that person and respond only from what the moment establishes. Treat asserted perceptions and memories as known. Let anything beyond them appear only as suspicion, conjecture, or deliberate invention by the character, and name it as such. Do not give yourself a temperament, a history, a mood, a relationship, or a turn of phrase the moment did not give you; if the moment gives you little, say little, or nothing. You may speak, remain silent, wonder, decide, or attempt something. Do not announce an outside consequence as already accomplished.\n\nVoice and setting guidance:\n{guidance}\n\nWho you are:\n{identity}\n\nWhat this moment is like for you:\n{stream}\n\nUse at most {word_budget} words; fewer is better. Return only the character's natural response in prose.", diff --git a/crates/ghostlight/src/controllers.rs b/crates/ghostlight/src/controllers.rs index 90f65f0..996d688 100644 --- a/crates/ghostlight/src/controllers.rs +++ b/crates/ghostlight/src/controllers.rs @@ -42,9 +42,9 @@ use cultcache_rs::{CacheBackingStore, CultCacheEnvelope, OwnedRedbMessagePackBac use ghostlight_persona_projection::{ CaptureToolFeedback, GroupedAgentPrompt, InterpretationAccumulator, InterpretationFinalization, InterpretationReport, InterpreterPrompt, LabeledView, OperationalAgentPrompt, PersonaPrompt, - PersonaTurn, PersonaTurnBinding, ProjectorPrompt, RecordGapToolCall, SourceSpan, TranslationGapKind, + NarratorPrompt, PersonaTurn, PersonaTurnBinding, ProjectorPrompt, RecordGapToolCall, SourceSpan, TranslationGapKind, build_grouped_agent_prompt, build_interpreter_prompt, build_operational_agent_prompt, - build_persona_prompt, build_projector_prompt, sha256, + build_narrator_prompt, build_persona_prompt, build_projector_prompt, sha256, }; use serde::{Deserialize, Serialize}; use serde_json::{Value, json}; @@ -4794,9 +4794,9 @@ impl PersonaLane { ) } - /// The player's own view: the same Projector `turn` runs, over the - /// player's own selected slice, with no Persona stage after it (Q11, - /// P6.3). + /// The player's own view: the storyteller over the player's own selected + /// slice, in second person. Not the Persona lane's Projector, whose + /// lived stream is written from inside a person (Q11, P6.3). pub async fn narrate( &self, command_id: CommandId, @@ -4808,16 +4808,15 @@ impl PersonaLane { }); } let selected = self.select(opportunity).await?; - let projector = build_projector_invocation( + let narrator = build_narrator_invocation( |request| self.prepare(request), command_id, &self.projector_model, &selected, )?; - let projector_output = self.infer(projector.invocation).await?; - let (lived_stream, _projector_receipt) = - projector_output.prose_only(InferencePurpose::Projector)?; - Ok(lived_stream) + let narrator_output = self.infer(narrator).await?; + let (narration, _receipt) = narrator_output.prose_only(InferencePurpose::Projector)?; + Ok(narration) } } @@ -4866,6 +4865,54 @@ impl SelectedDecision { .map_err(|error| ControllerError::Serialization(error.to_string())) } + /// What the storyteller may know of the player's surroundings, all from + /// this subject's own slice: the place, who stands in it, and each open way + /// out of it with the place it leads to. Who stands beyond an exit is + /// another subject's position and stays out. + fn narrator_context(&self) -> Result { + serde_json::to_string_pretty(&json!({ + "world": self.snapshot.title, + "player": self.subject.label, + "place": self.place_label(self.subject.position), + "now": self.snapshot.now, + "permission": catalog_permissions(&self.granted), + "present": self.present_labels(), + "exits": self.narrator_exits(), + "material": self.projector_material(), + "holdings": self.projector_holdings(), + "dependencies": self.projector_dependencies(), + "authority": self.projector_authority(), + "offices_held": self.projector_offices(&self.subject.offices_held), + "offices_granted": self.projector_offices(&self.subject.offices_granted), + "redress": self.projector_redress(), + "commitments": self.projector_commitments(), + "pressures": self.projector_pressures(), + })) + .map_err(|error| ControllerError::Serialization(error.to_string())) + } + + /// The open routes that leave the subject's place, with where each leads. + fn narrator_exits(&self) -> Vec { + let Some(here) = self.subject.position else { + return Vec::new(); + }; + self.subject + .components + .routes + .keys() + .filter_map(|edge_id| self.snapshot.routes.iter().find(|route| route.id == *edge_id)) + .filter(|route| route.from == here && route.open) + .map(|route| { + json!({ + "label": route.label, + "leads_to": self.place_label(Some(route.to)), + "access": route.access, + "cost": route.cost, + }) + }) + .collect() + } + /// Who else stands in this subject's own place, by label. The same reach /// a speech audience is derived from, so a person sees the people in the /// room it speaks into. Position elsewhere stays out: that is another @@ -6732,6 +6779,30 @@ fn build_projector_invocation( }) } +/// The one builder of the storyteller's request for a human player's view. +fn build_narrator_invocation( + prepare: impl Fn(InferenceRequest) -> Result, + command_id: CommandId, + model: &str, + selected: &SelectedDecision, +) -> Result { + let prompt = build_narrator_prompt(&NarratorPrompt { + player: &selected.subject.label, + typed_context: &selected.narrator_context()?, + visible_stimulus: &selected.visible_stimulus()?, + domain_guidance: &selected.snapshot.guidance(), + word_budget: PERSONA_WORD_BUDGET, + }); + prepare(text_request( + command_id, + InferencePurpose::Projector, + model, + "Narrate the player's present moment to the player, in second person, from the private view in the user message. Return only that narration.", + prompt, + 1_200, + )?) +} + /// The Persona request these inputs build, unprepared. Its only input is the /// Projector's own prose (`lived_stream`) plus the identity and guidance /// already carried out of `build_projector_invocation`: no structured state,