diff --git a/crates/ghostlight-dungeon/src/domain.rs b/crates/ghostlight-dungeon/src/domain.rs index fed7268..03dd611 100644 --- a/crates/ghostlight-dungeon/src/domain.rs +++ b/crates/ghostlight-dungeon/src/domain.rs @@ -583,7 +583,6 @@ pub struct StrategicTickPlan { pub struct StrategicInstitutionAction { pub institution_id: String, pub posture: String, - pub summary: String, pub location_ids: Vec, pub public_channels: Vec, } @@ -591,7 +590,6 @@ pub struct StrategicInstitutionAction { #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] pub struct StrategicGestaltAction { pub gestalt_id: String, - pub summary: String, pub pressure_additions: Vec, pub public_channels: Vec, } @@ -600,7 +598,6 @@ pub struct StrategicGestaltAction { pub struct StrategicActorMove { pub actor_id: String, pub destination_id: String, - pub summary: String, pub public_channels: Vec, } @@ -610,7 +607,6 @@ pub struct StrategicMemberMigration { pub source_gestalt_id: String, pub destination_gestalt_id: String, pub destination_location_id: String, - pub summary: String, pub public_channels: Vec, } diff --git a/crates/ghostlight-dungeon/src/kernel.rs b/crates/ghostlight-dungeon/src/kernel.rs index f5574ce..5785668 100644 --- a/crates/ghostlight-dungeon/src/kernel.rs +++ b/crates/ghostlight-dungeon/src/kernel.rs @@ -1195,9 +1195,9 @@ fn apply_strategic_tick_plan( "institution acts twice in one strategic tick".into(), )); } - if action.summary.trim().is_empty() || action.posture.trim().is_empty() { + if action.posture.trim().is_empty() { return Err(KernelError::Invalid( - "strategic institution action is empty".into(), + "strategic institution posture is empty".into(), )); } if action @@ -1215,11 +1215,15 @@ fn apply_strategic_tick_plan( .get_mut(&action.institution_id) .ok_or_else(|| KernelError::Invalid("strategic plan invented an institution".into()))?; institution.posture = action.posture; + let summary = format!( + "{} adopts posture: {}", + institution.name, institution.posture + ); events.push(crate::domain::Event { id: format!("strategic:{revision}:institution:{}", institution.id), at, kind: "institution_action".into(), - summary: action.summary, + summary, actor_ids: vec![], institution_ids: vec![institution.id.clone()], location_ids: action.location_ids, @@ -1234,7 +1238,7 @@ fn apply_strategic_tick_plan( "gestalt acts twice in one strategic tick".into(), )); } - if action.summary.trim().is_empty() + if action.pressure_additions.is_empty() || action.pressure_additions.len() > 4 || action .pressure_additions @@ -1246,6 +1250,7 @@ fn apply_strategic_tick_plan( )); } validate_public_channels(&action.public_channels)?; + let pressure_summary = action.pressure_additions.join("; "); let gestalt = campaign .gestalts .get_mut(&action.gestalt_id) @@ -1260,7 +1265,10 @@ fn apply_strategic_tick_plan( id: format!("strategic:{revision}:gestalt:{}", gestalt.id), at, kind: "gestalt_action".into(), - summary: action.summary, + summary: format!( + "{} changes its collective situation: {}", + gestalt.name, pressure_summary + ), actor_ids: vec![], institution_ids: vec![], location_ids: vec![gestalt.home_location_id.clone()], @@ -1280,11 +1288,6 @@ fn apply_strategic_tick_plan( "strategic simulation cannot puppet the player".into(), )); } - if action.summary.trim().is_empty() { - return Err(KernelError::Invalid( - "strategic actor movement has no summary".into(), - )); - } validate_public_channels(&action.public_channels)?; let actor = campaign .actors @@ -1308,6 +1311,7 @@ fn apply_strategic_tick_plan( )); } let origin = actor.location_id.clone(); + let actor_name = actor.name.clone(); campaign .actors .get_mut(&action.actor_id) @@ -1317,7 +1321,10 @@ fn apply_strategic_tick_plan( id: format!("strategic:{revision}:actor:{}", action.actor_id), at, kind: "actor_movement".into(), - summary: action.summary, + summary: format!( + "{actor_name} moves from {origin} to {}.", + action.destination_id + ), actor_ids: vec![action.actor_id], institution_ids: vec![], location_ids: vec![origin, action.destination_id], @@ -1332,11 +1339,6 @@ fn apply_strategic_tick_plan( "gestalt member migrates twice in one strategic tick".into(), )); } - if action.summary.trim().is_empty() { - return Err(KernelError::Invalid( - "strategic member migration has no summary".into(), - )); - } validate_public_channels(&action.public_channels)?; crate::resolution::validate_member_migration( campaign, @@ -1354,12 +1356,16 @@ fn apply_strategic_tick_plan( .home_location_id .clone() }); + let member_name = campaign.gestalt_members[&action.member_id].name.clone(); rebase_member_migration(campaign, &action)?; events.push(crate::domain::Event { id: format!("strategic:{revision}:member:{}", action.member_id), at, kind: "gestalt_member_migration".into(), - summary: action.summary, + summary: format!( + "{member_name} moves from {origin} to {} and joins {}.", + action.destination_location_id, action.destination_gestalt_id + ), actor_ids: vec![format!("member:{}", action.member_id)], institution_ids: vec![], location_ids: vec![origin, action.destination_location_id], @@ -1922,9 +1928,6 @@ mod tests { source_gestalt_id: "refugees-east".into(), destination_gestalt_id: "dock-neighbors".into(), destination_location_id: "docks".into(), - summary: - "Mira takes the resettlement ferry and joins the south-dock neighbors." - .into(), public_channels: vec![], }], ..Default::default() @@ -1953,6 +1956,10 @@ mod tests { assert_eq!(events.len(), 1); assert_eq!(events[0].kind, "gestalt_member_migration"); assert_eq!(events[0].actor_ids, vec!["member:mira"]); + assert_eq!( + events[0].summary, + "Mira Venn moves from camp to docks and joins dock-neighbors." + ); let actor = materialize_actor( &value.gestalts["dock-neighbors"], @@ -1980,7 +1987,6 @@ mod tests { source_gestalt_id: "refugees-east".into(), destination_gestalt_id: "dock-neighbors".into(), destination_location_id: "docks".into(), - summary: "Mira relocates.".into(), public_channels: vec![], }], ..Default::default() @@ -2260,7 +2266,6 @@ mod tests { actor_moves: vec![crate::domain::StrategicActorMove { actor_id: "player".into(), destination_id: "yard".into(), - summary: "The absent player obeys.".into(), public_channels: vec![], }], ..Default::default() @@ -2288,7 +2293,6 @@ mod tests { actor_moves: vec![crate::domain::StrategicActorMove { actor_id: "runner".into(), destination_id: "yard".into(), - summary: "The runner carries the warning to the yard.".into(), public_channels: vec!["courier-network".into()], }], ..Default::default() diff --git a/crates/ghostlight-dungeon/src/persona.rs b/crates/ghostlight-dungeon/src/persona.rs index d0432a2..183c272 100644 --- a/crates/ghostlight-dungeon/src/persona.rs +++ b/crates/ghostlight-dungeon/src/persona.rs @@ -87,6 +87,13 @@ pub struct CellMemberSlice { pub memories: Vec, } +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +pub struct CellPerceivedEventSlice { + pub event_id: String, + pub summary: String, + pub perceived_by_subject_ids: BTreeSet, +} + #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct PermittedCellSlice { pub cell_id: String, @@ -98,7 +105,7 @@ pub struct PermittedCellSlice { pub member_exceptions: Vec, pub shared_knowledge: BTreeSet, pub shared_capabilities: BTreeSet, - pub perceived_events: Vec, + pub perceived_events: Vec, pub world_clock_pressure: Vec, pub detail_focus_subject_id: Option, pub max_actions: usize, @@ -322,6 +329,7 @@ fn cell_projector_context(slice: &PermittedCellSlice) -> serde_json::Value { })).collect::>(), "shared_knowledge": slice.shared_knowledge, "shared_capabilities": slice.shared_capabilities, + "perceived_events": slice.perceived_events, "world_clock_pressure": slice.world_clock_pressure, "detail_focus_subject_id": slice.detail_focus_subject_id, "max_actions": slice.max_actions, @@ -372,7 +380,23 @@ impl CellProjectionEngine { .require(&slice.cell_id, &slice.snapshot_binding, "cell_projector") .await?; let projector_context = serde_json::to_string(&cell_projector_context(&slice))?; - let visible_stimulus = slice.perceived_events.join("\n"); + let visible_stimulus = slice + .perceived_events + .iter() + .map(|event| { + format!( + "Perceived by [{}]: {}", + event + .perceived_by_subject_ids + .iter() + .cloned() + .collect::>() + .join(", "), + event.summary + ) + }) + .collect::>() + .join("\n"); let mode_guidance = match slice.mode { crate::domain::SimulationCellMode::Cohesive => { "This cell has real collective authority. Render a plural lived perspective from genuinely shared knowledge and capability only; describe constituent and named-member exceptions as separately attributed exceptions. A population cannot decide for a named member." @@ -382,7 +406,7 @@ impl CellProjectionEngine { } }; let mode_guidance = format!( - "{mode_guidance} Every supplied member_exception was selected because that person has an actionable decision in this horizon. Render each selected person explicitly by name, with only their own footing and choices." + "{mode_guidance} Each perceived event names the exact constituents that can perceive it; do not teach it to anyone else. Every supplied member_exception was selected because that person has an actionable decision in this horizon. Render each selected person explicitly by name, with only their own footing and choices." ); let projected = run_validated_stage( self.model.as_ref(), @@ -833,7 +857,11 @@ mod tests { member_exceptions: vec![], shared_knowledge: BTreeSet::new(), shared_capabilities: BTreeSet::new(), - perceived_events: vec!["The final vote is public.".into()], + perceived_events: vec![CellPerceivedEventSlice { + event_id: "event:vote".into(), + summary: "The final vote is public.".into(), + perceived_by_subject_ids: BTreeSet::from(["house-a".into(), "house-b".into()]), + }], world_clock_pressure: vec!["vote 5/6".into()], detail_focus_subject_id: Some("faction-06".into()), max_actions: 1, diff --git a/crates/ghostlight-dungeon/src/resolution.rs b/crates/ghostlight-dungeon/src/resolution.rs index d0afb5b..0a8c7bb 100644 --- a/crates/ghostlight-dungeon/src/resolution.rs +++ b/crates/ghostlight-dungeon/src/resolution.rs @@ -1630,7 +1630,6 @@ pub fn validate_and_resolve_wave( } => plan.institution_actions.push(StrategicInstitutionAction { institution_id, posture, - summary: proposal.intended_effect, location_ids, public_channels: proposal.public_channels, }), @@ -1639,7 +1638,6 @@ pub fn validate_and_resolve_wave( pressure_additions, } => plan.gestalt_actions.push(StrategicGestaltAction { gestalt_id, - summary: proposal.intended_effect, pressure_additions, public_channels: proposal.public_channels, }), @@ -1649,7 +1647,6 @@ pub fn validate_and_resolve_wave( } => plan.actor_moves.push(StrategicActorMove { actor_id, destination_id, - summary: proposal.intended_effect, public_channels: proposal.public_channels, }), StrategicCellEffect::MemberMigration { @@ -1669,7 +1666,6 @@ pub fn validate_and_resolve_wave( source_gestalt_id, destination_gestalt_id, destination_location_id, - summary: proposal.intended_effect, public_channels: proposal.public_channels, }); } @@ -1739,8 +1735,18 @@ fn validate_cell_proposal( return Err(anyhow!("institution proposal exceeds constituent state")); } } - StrategicCellEffect::Gestalt { gestalt_id, .. } => { - if gestalt_id != &proposal.subject_id || !campaign.gestalts.contains_key(gestalt_id) { + StrategicCellEffect::Gestalt { + gestalt_id, + pressure_additions, + } => { + if gestalt_id != &proposal.subject_id + || !campaign.gestalts.contains_key(gestalt_id) + || pressure_additions.is_empty() + || pressure_additions.len() > 4 + || pressure_additions + .iter() + .any(|pressure| pressure.trim().is_empty() || pressure.len() > 240) + { return Err(anyhow!("gestalt proposal exceeds constituent state")); } } diff --git a/crates/ghostlight-dungeon/src/scheduler.rs b/crates/ghostlight-dungeon/src/scheduler.rs index a11f82f..f1af91a 100644 --- a/crates/ghostlight-dungeon/src/scheduler.rs +++ b/crates/ghostlight-dungeon/src/scheduler.rs @@ -5,8 +5,8 @@ use crate::{ }, model::{ModelPort, ModelStageOutput, ModelStageRequest, run_validated_stage}, persona::{ - CellConstituentSlice, CellMemberSlice, CellProjectionEngine, ExecutionPermit, - PermittedCellSlice, + CellConstituentSlice, CellMemberSlice, CellPerceivedEventSlice, CellProjectionEngine, + ExecutionPermit, PermittedCellSlice, }, resolution::{ cell_action_limit, default_demand, plan_cover, plan_receipt, validate_and_resolve_wave, @@ -393,6 +393,7 @@ fn cell_slice(campaign: &Campaign, cell: &SimulationCell) -> Result Result Result Vec { + campaign + .events + .iter() + .rev() + .take(12) + .filter_map(|event| { + let mut perceived_by_subject_ids = constituents + .iter() + .filter(|subject| { + event.actor_ids.contains(&subject.subject_id) + || event.institution_ids.contains(&subject.subject_id) + || !event + .location_ids + .iter() + .all(|location_id| !subject.location_ids.contains(location_id)) + || !event + .public_channels + .iter() + .all(|channel| !subject.information_channels.contains(channel)) + }) + .map(|subject| subject.subject_id.clone()) + .collect::>(); + perceived_by_subject_ids.extend( + member_exceptions + .iter() + .filter(|member| { + event.actor_ids.contains(&member.subject_id) + || event.location_ids.contains(&member.source_location_id) + || !event + .public_channels + .iter() + .all(|channel| !member.information_channels.contains(channel)) + }) + .map(|member| member.subject_id.clone()), + ); + (!perceived_by_subject_ids.is_empty()).then(|| CellPerceivedEventSlice { + event_id: event.id.clone(), + summary: event.summary.clone(), + perceived_by_subject_ids, + }) + }) + .collect() +} + fn member_exceptions(campaign: &Campaign, cell: &SimulationCell) -> Result> { let player_id = &campaign.player_actor_id; let mut candidates = campaign @@ -880,6 +924,98 @@ mod tests { ); } + #[test] + fn arena_event_projection_preserves_exact_viewers_including_named_members() { + use crate::domain::*; + let mut campaign = crate::resolution::tests::campaign(2, 1); + campaign + .agency_profiles + .get_mut("faction-0000") + .unwrap() + .location_ids = BTreeSet::from(["east".into()]); + let west = campaign.agency_profiles.get_mut("faction-0001").unwrap(); + west.location_ids = BTreeSet::from(["west".into()]); + west.information_channels.insert("west-wire".into()); + campaign.events = vec![ + Event { + id: "direct-east".into(), + at: Utc::now(), + kind: "test".into(), + summary: "East receives a private order.".into(), + actor_ids: vec![], + institution_ids: vec!["faction-0000".into()], + location_ids: vec![], + public_channels: vec![], + }, + Event { + id: "west-wire".into(), + at: Utc::now(), + kind: "test".into(), + summary: "A warning travels on the west wire.".into(), + actor_ids: vec![], + institution_ids: vec![], + location_ids: vec![], + public_channels: vec!["west-wire".into()], + }, + Event { + id: "mira-witnessed".into(), + at: Utc::now(), + kind: "test".into(), + summary: "Mira witnesses the departure.".into(), + actor_ids: vec!["member:mira".into()], + institution_ids: vec![], + location_ids: vec![], + public_channels: vec![], + }, + Event { + id: "unseen".into(), + at: Utc::now(), + kind: "test".into(), + summary: "Nobody in this arena can know this.".into(), + actor_ids: vec![], + institution_ids: vec![], + location_ids: vec!["far-away".into()], + public_channels: vec!["sealed-channel".into()], + }, + ]; + let constituents = ["faction-0000", "faction-0001"] + .iter() + .map(|id| constituent_slice(&campaign, id).unwrap()) + .collect::>(); + let members = vec![CellMemberSlice { + subject_id: "member:mira".into(), + member_id: "mira".into(), + name: "Mira".into(), + source_gestalt_id: "refugees".into(), + source_location_id: "east".into(), + knowledge: BTreeSet::new(), + capabilities: BTreeSet::new(), + resources: BTreeSet::new(), + information_channels: BTreeSet::from(["refugee-wire".into()]), + permitted_state_references: BTreeSet::new(), + migration_destinations: BTreeMap::new(), + goals: vec![], + pressures: vec![], + relationships: BTreeMap::new(), + memories: vec![], + }]; + + let events = cell_perceived_events(&campaign, &constituents, &members) + .into_iter() + .map(|event| (event.event_id, event.perceived_by_subject_ids)) + .collect::>(); + assert_eq!( + events["direct-east"], + BTreeSet::from(["faction-0000".into()]) + ); + assert_eq!(events["west-wire"], BTreeSet::from(["faction-0001".into()])); + assert_eq!( + events["mira-witnessed"], + BTreeSet::from(["member:mira".into()]) + ); + assert!(!events.contains_key("unseen")); + } + #[tokio::test] async fn every_selected_cell_runs_one_membrane_pipeline() { let mut campaign = crate::resolution::tests::campaign(6, 2); diff --git a/docs/architecture/ghostlight-multiresolution-agency.md b/docs/architecture/ghostlight-multiresolution-agency.md index de151d7..e0a1a08 100644 --- a/docs/architecture/ghostlight-multiresolution-agency.md +++ b/docs/architecture/ghostlight-multiresolution-agency.md @@ -226,6 +226,19 @@ caps committed consequences at `min(16, 2 × effective_budget)`, and commits the entire wave once. One missing appraisal, stale receipt, malformed stage, invalid cover, or invalid effect aborts the wave without partial mutation. +Interpreter `intent` and `intended_effect` prose is proposal rationale only. It +never becomes canonical event narration. The kernel derives each committed +event summary from the exact admitted posture, pressure markers, route, or +membership transition after applying it. Strategic plans therefore carry no +model-authored summary field that can assert a consequence outside the typed +effect. + +Recent events are projected per constituent. A cell receives an event only for +subjects that participated in it, occupy one of its locations, or possess one +of its public channels; arena streams retain those viewer attributions. There +is no global recent-event recap that can quietly teach every population the +same fact. + ## Public state and controls The schema catalog and CultCache stores publish: diff --git a/notes/ghostlight-dungeon.md b/notes/ghostlight-dungeon.md index 7283718..484cdca 100644 --- a/notes/ghostlight-dungeon.md +++ b/notes/ghostlight-dungeon.md @@ -159,12 +159,15 @@ stake prose alone never impersonates world mutation. - The daemon owns a five-minute scheduler pulse. Campaigns enter away simulation after fifteen minutes without player activity. - Each real hour awards one strategic tick, capped at eight pending ticks per absence. The compiled campaign chooses the in-world tick duration; default is six hours. - Background simulation affects remote actors, institutions, resources, movement, bargains, investigations, preparation, recruitment, obstruction, and clocks. The absent player is never puppeted or directly harmed. -- Each due tick asks the flash model for a typed `StrategicTickPlan` against the - exact campaign revision. The WorldKernel accepts only known institutions, - gestalts, and non-player actors; direct-route movement must fit inside the - tick duration, information channels are bounded, and population pressure - cannot silently become canon knowledge. Invalid, stale, timed-out, or - malformed plans leave world state unchanged. +- Each due tick derives a budgeted simulation-cell cover and runs one private + Projector → Persona → Interpreter pipeline per cell against the same campaign + revision and resolution epoch. The WorldKernel alone converts admitted typed + effects into a `StrategicTickPlan`; proposal prose cannot become event truth. + It accepts only known institutions, gestalts, members, and non-player actors; + direct-route movement must fit inside the tick duration, information channels + are bounded per constituent, and population pressure cannot silently become + canon knowledge. Invalid, stale, timed-out, or malformed waves leave world + state unchanged. - The scheduler and return-time catch-up invoke the same `AdvanceStrategicTick` command. Catch-up processes missed ticks before accepting the next player action. - Live play has inference priority; background work stops launching new calls while a player turn is active. - Offscreen events generate information-channel-aware news leads. On return, the player may receive newspapers, reports, messages, or rumors only when the character has access to them; the news layer cannot reveal omniscient state.