From 90b9b589c810c187477f6b94a6eaa7e84781a3d9 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 16 Aug 2026 22:05:19 +0200 Subject: [PATCH] Validate model-driven strategic ticks --- crates/ghostlight-dungeon/src/domain.rs | 34 +++ crates/ghostlight-dungeon/src/kernel.rs | 334 ++++++++++++++++++--- crates/ghostlight-dungeon/src/main.rs | 59 +++- crates/ghostlight-dungeon/src/mesh.rs | 5 +- crates/ghostlight-dungeon/src/model.rs | 5 +- crates/ghostlight-dungeon/src/scheduler.rs | 61 ++++ notes/fresh-workspace-handoff.md | 12 +- notes/ghostlight-current-system-map.md | 15 + notes/ghostlight-dungeon.md | 6 + notes/ghostlight-implementation-plan.md | 30 +- state/evidence.jsonl | 1 + state/map.yaml | 4 +- 12 files changed, 500 insertions(+), 66 deletions(-) diff --git a/crates/ghostlight-dungeon/src/domain.rs b/crates/ghostlight-dungeon/src/domain.rs index 33c6be3..8ebbecc 100644 --- a/crates/ghostlight-dungeon/src/domain.rs +++ b/crates/ghostlight-dungeon/src/domain.rs @@ -218,6 +218,38 @@ pub struct NewsIssue { pub reliability: String, } +#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Default)] +pub struct StrategicTickPlan { + pub institution_actions: Vec, + pub gestalt_actions: Vec, + pub actor_moves: Vec, +} + +#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] +pub struct StrategicInstitutionAction { + pub institution_id: String, + pub posture: String, + pub summary: String, + pub location_ids: Vec, + pub public_channels: Vec, +} + +#[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, +} + +#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] +pub struct StrategicActorMove { + pub actor_id: String, + pub destination_id: String, + pub summary: String, + pub public_channels: Vec, +} + #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] pub struct CanonCandidate { pub schema: String, @@ -316,6 +348,8 @@ pub enum WorldCommand { AdvanceStrategicTick { expected_revision: u64, source: TickSource, + #[serde(default)] + plan: Option, }, ExpandRegion { expected_revision: u64, diff --git a/crates/ghostlight-dungeon/src/kernel.rs b/crates/ghostlight-dungeon/src/kernel.rs index 6ecaa72..0437f92 100644 --- a/crates/ghostlight-dungeon/src/kernel.rs +++ b/crates/ghostlight-dungeon/src/kernel.rs @@ -240,6 +240,7 @@ fn execute( WorldCommand::AdvanceStrategicTick { expected_revision, source: _, + plan, } => { require_revision(&campaign, expected_revision)?; campaign.world_time += Duration::hours(i64::from(campaign.tick_hours)); @@ -247,44 +248,10 @@ fn execute( clock.progress = clock.progress.saturating_add(1).min(clock.threshold); } let tick_number = campaign.away_ticks_processed.saturating_add(1); - let mut tick_events = Vec::new(); - for institution in campaign.institutions.values_mut() { - let summary = if let Some(goal) = institution.goals.first() { - format!("{} advances its interest: {}", institution.name, goal) - } else { - format!("{} consolidates its current position", institution.name) - }; - institution.posture = format!("acting after strategic tick {tick_number}"); - let event_id = format!("strategic:{}:{}", campaign.revision + 1, institution.id); - tick_events.push(crate::domain::Event { - id: event_id, - at: campaign.world_time, - kind: "institution_action".into(), - summary, - actor_ids: vec![], - institution_ids: vec![institution.id.clone()], - location_ids: vec![], - public_channels: vec![format!("institution:{}", institution.id)], - }); - } - for gestalt in campaign.gestalts.values_mut() { - gestalt.version += 1; - let summary = if let Some(goal) = gestalt.goals.first() { - format!("{} collectively advances: {}", gestalt.name, goal) - } else { - format!("{} carries on its shared routine", gestalt.name) - }; - tick_events.push(crate::domain::Event { - id: format!("strategic:{}:gestalt:{}", campaign.revision + 1, gestalt.id), - at: campaign.world_time, - kind: "gestalt_action".into(), - summary, - actor_ids: vec![], - institution_ids: vec![], - location_ids: vec![gestalt.home_location_id.clone()], - public_channels: vec![format!("gestalt:{}", gestalt.id)], - }); - } + let tick_events = match plan { + Some(plan) => apply_strategic_tick_plan(&mut campaign, plan)?, + None => deterministic_strategic_tick(&mut campaign, tick_number), + }; let player = campaign.actors.get(&campaign.player_actor_id); for event in &tick_events { let accessible = event.public_channels.iter().find(|channel| { @@ -847,6 +814,209 @@ fn assess(c: &Campaign, intent: ActionIntent) -> ActionAssessment { a } +fn apply_strategic_tick_plan( + campaign: &mut Campaign, + plan: crate::domain::StrategicTickPlan, +) -> Result, KernelError> { + let revision = campaign.revision + 1; + let at = campaign.world_time; + let mut events = Vec::new(); + let mut seen_institutions = BTreeSet::new(); + for action in plan.institution_actions { + if !seen_institutions.insert(action.institution_id.clone()) { + return Err(KernelError::Invalid( + "institution acts twice in one strategic tick".into(), + )); + } + if action.summary.trim().is_empty() || action.posture.trim().is_empty() { + return Err(KernelError::Invalid( + "strategic institution action is empty".into(), + )); + } + if action + .location_ids + .iter() + .any(|id| !campaign.locations.contains_key(id)) + { + return Err(KernelError::Invalid( + "strategic institution action invented a location".into(), + )); + } + validate_public_channels(&action.public_channels)?; + let institution = campaign + .institutions + .get_mut(&action.institution_id) + .ok_or_else(|| KernelError::Invalid("strategic plan invented an institution".into()))?; + institution.posture = action.posture; + events.push(crate::domain::Event { + id: format!("strategic:{revision}:institution:{}", institution.id), + at, + kind: "institution_action".into(), + summary: action.summary, + actor_ids: vec![], + institution_ids: vec![institution.id.clone()], + location_ids: action.location_ids, + public_channels: action.public_channels, + }); + } + + let mut seen_gestalts = BTreeSet::new(); + for action in plan.gestalt_actions { + if !seen_gestalts.insert(action.gestalt_id.clone()) { + return Err(KernelError::Invalid( + "gestalt acts twice in one strategic tick".into(), + )); + } + if action.summary.trim().is_empty() + || action.pressure_additions.len() > 4 + || action + .pressure_additions + .iter() + .any(|p| p.trim().is_empty() || p.len() > 240) + { + return Err(KernelError::Invalid( + "strategic gestalt action is invalid".into(), + )); + } + validate_public_channels(&action.public_channels)?; + let gestalt = campaign + .gestalts + .get_mut(&action.gestalt_id) + .ok_or_else(|| KernelError::Invalid("strategic plan invented a gestalt".into()))?; + for pressure in action.pressure_additions { + if !gestalt.pressures.contains(&pressure) { + gestalt.pressures.push(pressure); + } + } + gestalt.version += 1; + events.push(crate::domain::Event { + id: format!("strategic:{revision}:gestalt:{}", gestalt.id), + at, + kind: "gestalt_action".into(), + summary: action.summary, + actor_ids: vec![], + institution_ids: vec![], + location_ids: vec![gestalt.home_location_id.clone()], + public_channels: action.public_channels, + }); + } + + let mut seen_actors = BTreeSet::new(); + for action in plan.actor_moves { + if !seen_actors.insert(action.actor_id.clone()) { + return Err(KernelError::Invalid( + "actor moves twice in one strategic tick".into(), + )); + } + if action.actor_id == campaign.player_actor_id { + return Err(KernelError::Invalid( + "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 + .get(&action.actor_id) + .ok_or_else(|| KernelError::Invalid("strategic plan invented an actor".into()))?; + let route = campaign + .locations + .get(&actor.location_id) + .and_then(|location| { + location + .routes + .values() + .find(|route| route.destination_id == action.destination_id) + }) + .ok_or_else(|| { + KernelError::Invalid("strategic actor movement has no direct route".into()) + })?; + if route.travel_minutes > campaign.tick_hours.saturating_mul(60) { + return Err(KernelError::Invalid( + "strategic actor movement exceeds the tick duration".into(), + )); + } + let origin = actor.location_id.clone(); + campaign + .actors + .get_mut(&action.actor_id) + .expect("actor was validated") + .location_id = action.destination_id.clone(); + events.push(crate::domain::Event { + id: format!("strategic:{revision}:actor:{}", action.actor_id), + at, + kind: "actor_movement".into(), + summary: action.summary, + actor_ids: vec![action.actor_id], + institution_ids: vec![], + location_ids: vec![origin, action.destination_id], + public_channels: action.public_channels, + }); + } + Ok(events) +} + +fn deterministic_strategic_tick( + campaign: &mut Campaign, + tick_number: u8, +) -> Vec { + let mut events = Vec::new(); + for institution in campaign.institutions.values_mut() { + let summary = institution + .goals + .first() + .map(|goal| format!("{} advances its interest: {}", institution.name, goal)) + .unwrap_or_else(|| format!("{} consolidates its current position", institution.name)); + institution.posture = format!("acting after strategic tick {tick_number}"); + events.push(crate::domain::Event { + id: format!("strategic:{}:{}", campaign.revision + 1, institution.id), + at: campaign.world_time, + kind: "institution_action".into(), + summary, + actor_ids: vec![], + institution_ids: vec![institution.id.clone()], + location_ids: vec![], + public_channels: vec![format!("institution:{}", institution.id)], + }); + } + for gestalt in campaign.gestalts.values_mut() { + gestalt.version += 1; + let summary = gestalt + .goals + .first() + .map(|goal| format!("{} collectively advances: {}", gestalt.name, goal)) + .unwrap_or_else(|| format!("{} carries on its shared routine", gestalt.name)); + events.push(crate::domain::Event { + id: format!("strategic:{}:gestalt:{}", campaign.revision + 1, gestalt.id), + at: campaign.world_time, + kind: "gestalt_action".into(), + summary, + actor_ids: vec![], + institution_ids: vec![], + location_ids: vec![gestalt.home_location_id.clone()], + public_channels: vec![format!("gestalt:{}", gestalt.id)], + }); + } + events +} + +fn validate_public_channels(channels: &[String]) -> Result<(), KernelError> { + if channels.len() > 8 + || channels + .iter() + .any(|c| c.trim().is_empty() || c.len() > 160) + { + return Err(KernelError::Invalid( + "strategic action has invalid information channels".into(), + )); + } + Ok(()) +} + fn commit( store: &CampaignStore, row: cultcache_legacy::CultCacheEnvelope, @@ -1117,6 +1287,7 @@ mod tests { .command(WorldCommand::AdvanceStrategicTick { expected_revision: 0, source: TickSource::Scheduler, + plan: None, }) .await .unwrap(); @@ -1129,6 +1300,93 @@ mod tests { assert!(campaign.institutions["board"].posture.contains("acting")); } + #[tokio::test] + async fn strategic_plan_moves_remote_actors_but_cannot_puppet_the_player() { + let dir = tempfile::tempdir().unwrap(); + let store = CampaignStore::open(dir.path().join("campaign.cc")).unwrap(); + let kernel = WorldKernel::start(store.clone()); + let mut seed = campaign(); + seed.locations.get_mut("room").unwrap().routes.insert( + "road".into(), + Route { + destination_id: "yard".into(), + distance: "near".into(), + travel_minutes: 20, + }, + ); + seed.locations.insert( + "yard".into(), + Location { + id: "yard".into(), + name: "Yard".into(), + container_id: None, + routes: BTreeMap::new(), + persistent_features: vec![], + }, + ); + let mut npc = seed.actors["player"].clone(); + npc.id = "runner".into(); + npc.name = "Runner".into(); + seed.actors.insert(npc.id.clone(), npc); + kernel + .command(WorldCommand::CreateCampaign { + campaign: seed.clone(), + evidence_receipts: vec![], + }) + .await + .unwrap(); + + let puppet = crate::domain::StrategicTickPlan { + 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() + }; + assert!(matches!( + kernel + .command(WorldCommand::AdvanceStrategicTick { + expected_revision: 0, + source: TickSource::Scheduler, + plan: Some(puppet), + }) + .await, + Err(KernelError::Invalid(_)) + )); + let (_, unchanged): (_, Campaign) = store + .load("campaign.v1", &seed.id.to_string()) + .unwrap() + .unwrap(); + assert_eq!(unchanged.revision, 0); + assert_eq!(unchanged.actors["player"].location_id, "room"); + + let valid = crate::domain::StrategicTickPlan { + 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() + }; + let result = kernel + .command(WorldCommand::AdvanceStrategicTick { + expected_revision: 0, + source: TickSource::Scheduler, + plan: Some(valid), + }) + .await + .unwrap(); + let CommandResult::Committed { campaign, .. } = result else { + panic!("expected commit") + }; + assert_eq!(campaign.actors["runner"].location_id, "yard"); + assert_eq!(campaign.actors["player"].location_id, "room"); + assert_eq!(campaign.events[0].kind, "actor_movement"); + } + #[tokio::test] async fn region_expansion_commits_topology_evidence_and_candidate_together() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/ghostlight-dungeon/src/main.rs b/crates/ghostlight-dungeon/src/main.rs index 6bb6ef7..e9aa926 100644 --- a/crates/ghostlight-dungeon/src/main.rs +++ b/crates/ghostlight-dungeon/src/main.rs @@ -737,7 +737,14 @@ async fn command( .into_response(); } }; - if let Err(error) = process_due_ticks(&runtime).await { + if let Err(error) = process_due_ticks( + &state, + &runtime, + ghostlight_dungeon::domain::TickSource::ReturnCatchUp, + false, + ) + .await + { return ( StatusCode::CONFLICT, Json(ErrorBody { @@ -1016,7 +1023,14 @@ async fn scheduler_loop(state: AppState) { for id in state.registry.list().await { match state.registry.runtime(id).await { Ok(runtime) => { - if let Err(error) = process_due_ticks(&runtime).await { + if let Err(error) = process_due_ticks( + &state, + &runtime, + ghostlight_dungeon::domain::TickSource::Scheduler, + true, + ) + .await + { tracing::warn!(%id,%error,"strategic scheduler pulse refused"); } } @@ -1299,8 +1313,16 @@ async fn operator_inspector(headers: HeaderMap, State(state): State) - Json(serde_json::json!({"schema":"ghostlight.operator_inspector.v1","campaign":campaign,"evidence":evidence,"commit_receipts":commits,"model_stage_receipts":stages,"rejected_proposals":rejected,"scheduler":{"live_turn_pressure":state.live_turns.load(Ordering::SeqCst)}})).into_response() } -async fn process_due_ticks(runtime: &CampaignRuntime) -> anyhow::Result<()> { +async fn process_due_ticks( + state: &AppState, + runtime: &CampaignRuntime, + source: ghostlight_dungeon::domain::TickSource, + yield_to_live_turns: bool, +) -> anyhow::Result<()> { loop { + if yield_to_live_turns && state.live_turns.load(Ordering::SeqCst) > 0 { + return Ok(()); + } let campaign = match load_campaign(&runtime.store) { Ok(value) => value, Err(_) => return Ok(()), @@ -1312,11 +1334,40 @@ async fn process_due_ticks(runtime: &CampaignRuntime) -> anyhow::Result<()> { if campaign.away_ticks_processed >= target { return Ok(()); } + let plan = if let Some(model) = &state.model { + let (plan, stage) = + ghostlight_dungeon::scheduler::propose_strategic_tick(model.as_ref(), &campaign) + .await?; + match runtime + .store + .load::( + "persona_stage_receipt.v1", + &stage.receipt.output_hash, + )? { + Some((_, existing)) if existing == stage.receipt => {} + Some(_) => anyhow::bail!("strategic model receipt hash collision"), + None => { + runtime.store.insert( + "persona_stage_receipt.v1", + "ghostlight.persona_stage_receipt.v1", + &stage.receipt.output_hash, + &stage.receipt, + )?; + } + } + Some(plan) + } else { + None + }; + if yield_to_live_turns && state.live_turns.load(Ordering::SeqCst) > 0 { + return Ok(()); + } runtime .kernel .command(WorldCommand::AdvanceStrategicTick { expected_revision: campaign.revision, - source: ghostlight_dungeon::domain::TickSource::ReturnCatchUp, + source: source.clone(), + plan, }) .await?; } diff --git a/crates/ghostlight-dungeon/src/mesh.rs b/crates/ghostlight-dungeon/src/mesh.rs index 9a91f57..ec08ee8 100644 --- a/crates/ghostlight-dungeon/src/mesh.rs +++ b/crates/ghostlight-dungeon/src/mesh.rs @@ -2,8 +2,8 @@ use crate::{ domain::{ ActionAssessment, ActorState, ActorStateDelta, Campaign, CanonCandidate, Event, GestaltMemberDelta, GestaltPersonaState, InstitutionState, Location, NarrationProjection, - NewsIssue, RollReceipt, VaultEvidenceReceipt, WorldActionProposal, WorldClock, - WorldCommitReceipt, WorldCompilePreview, WorldFact, + NewsIssue, RollReceipt, StrategicTickPlan, VaultEvidenceReceipt, WorldActionProposal, + WorldClock, WorldCommitReceipt, WorldCompilePreview, WorldFact, }, model::ModelStageReceipt, surface::player_surface, @@ -285,6 +285,7 @@ fn schema_catalog() -> Value { "ghostlight.persona_stage_receipt.v1": schemars::schema_for!(ModelStageReceipt), "ghostlight.actor_state_delta.v1": schemars::schema_for!(ActorStateDelta), "ghostlight.world_action_proposal.v1": schemars::schema_for!(WorldActionProposal), + "ghostlight.strategic_tick_plan.v1": schemars::schema_for!(StrategicTickPlan), "ghostlight.news_issue.v1": schemars::schema_for!(NewsIssue), "ghostlight.canon_candidate.v1": schemars::schema_for!(CanonCandidate), "ghostlight.gestalt_persona_state.v1": schemars::schema_for!(GestaltPersonaState), diff --git a/crates/ghostlight-dungeon/src/model.rs b/crates/ghostlight-dungeon/src/model.rs index c7810d8..fbb0e05 100644 --- a/crates/ghostlight-dungeon/src/model.rs +++ b/crates/ghostlight-dungeon/src/model.rs @@ -173,7 +173,10 @@ pub struct DeepSeekPort { impl DeepSeekPort { pub fn new(api_key: String) -> Self { Self { - client: reqwest::Client::new(), + client: reqwest::Client::builder() + .timeout(std::time::Duration::from_secs(45)) + .build() + .expect("static DeepSeek client configuration is valid"), api_key: Zeroizing::new(api_key), endpoint: "https://api.deepseek.com/chat/completions".into(), } diff --git a/crates/ghostlight-dungeon/src/scheduler.rs b/crates/ghostlight-dungeon/src/scheduler.rs index a0e0571..6822780 100644 --- a/crates/ghostlight-dungeon/src/scheduler.rs +++ b/crates/ghostlight-dungeon/src/scheduler.rs @@ -1,4 +1,65 @@ +use crate::{ + domain::{Campaign, StrategicTickPlan}, + model::{ModelPort, ModelStageOutput, ModelStageRequest, run_validated_stage}, +}; +use anyhow::{Context, Result}; use chrono::{DateTime, Utc}; +use schemars::schema_for; + +pub async fn propose_strategic_tick( + model: &dyn ModelPort, + campaign: &Campaign, +) -> Result<(StrategicTickPlan, ModelStageOutput)> { + let player_id = &campaign.player_actor_id; + let actors = campaign + .actors + .iter() + .filter(|(id, _)| *id != player_id) + .map(|(id, actor)| { + serde_json::json!({ + "id":id, + "location_id":actor.location_id, + "goals":actor.goals, + "conditions":actor.conditions, + "obligations":actor.obligations + }) + }) + .collect::>(); + let context = serde_json::json!({ + "campaign_id":campaign.id, + "revision":campaign.revision, + "world_time":campaign.world_time, + "tick_hours":campaign.tick_hours, + "locations":campaign.locations, + "remote_actors":actors, + "institutions":campaign.institutions, + "gestalts":campaign.gestalts, + "clocks":campaign.clocks, + "recent_events":campaign.events.iter().rev().take(12).collect::>() + }); + let output = run_validated_stage( + model, + &ModelStageRequest { + stage: "strategic_tick".into(), + model: "deepseek-v4-flash".into(), + snapshot_binding: format!("campaign:{}:revision:{}", campaign.id, campaign.revision), + lived_stream: format!( + "Propose one bounded offscreen strategic tick. Institutions, remote actors, and gestalt populations act in their own interests. Do not control, move, injure, or directly target the absent player. Use only supplied IDs. Actor movement must use a direct listed route whose travel time fits inside tick_hours. Keep summaries concrete. Pressure additions are branch-local population pressure, not new canon knowledge. Empty arrays are valid when nobody has a credible action. Return only the schema JSON.\nSTATE:\n{}", + serde_json::to_string(&context)? + ), + output_schema: Some(serde_json::to_value(schema_for!(StrategicTickPlan))?), + source_receipt_ids: campaign.branch_origin.evidence_receipt_ids.clone(), + }, + ) + .await?; + let plan = serde_json::from_value( + output + .structured + .clone() + .context("strategic tick stage returned no structured plan")?, + )?; + Ok((plan, output)) +} pub fn due_tick_target(now: DateTime, last_player_activity: DateTime) -> u8 { let idle = now - last_player_activity; diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 7031760..96fa36f 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -343,11 +343,13 @@ steering surfaces unless the user explicitly asks for archaeology. ## Current Next Action -Inventory Epiphany's current Persona projection body with source references: -canonical state owner, slice inputs, projector, narrative contract, Persona -invocation, Interpreter, commit boundary, receipts, model transport, and -Epiphany-specific policy. Record move/stay/split/delete decisions in the -GhostlightDungeon architecture before moving implementation code. +The Persona extraction and Epiphany handback are complete. Continue the hosted +MVP acceptance pass: prove live strategic scheduling and return catch-up use the +flash-model `StrategicTickPlan`, malformed or forbidden plans do not mutate the +campaign, gestalt individuals survive dematerialization and later population +ticks, four-actor live latency meets target, remote CultMesh publication works, +and the normal-process Starfire release has exact restart/firewall/provenance +evidence. ## Warnings diff --git a/notes/ghostlight-current-system-map.md b/notes/ghostlight-current-system-map.md index 3e7e226..7bfff48 100644 --- a/notes/ghostlight-current-system-map.md +++ b/notes/ghostlight-current-system-map.md @@ -21,6 +21,21 @@ Vault evidence receipts + typed campaign snapshot Ghostlight owns the generalized projection organ. Epiphany and other consumers own their canonical Persona state and consequence commits. +Away-time agency follows a separate proposal/commit seam: + +```text +exact campaign revision + -> flash-model StrategicTickPlan proposal + -> WorldKernel validates IDs, non-player scope, topology, duration, and bounds + -> AdvanceStrategicTick through the campaign mailbox + -> atomic campaign/event/news commit +``` + +The model owns no tick mutation. A provider failure or invalid proposal leaves +the campaign revision and world time untouched. Background inference checks +live-turn pressure before launch and again before commit; return catch-up uses +the same command path with player-turn priority. + ## Control Flow 1. Rehydrate from `state/map.yaml`, `notes/fresh-workspace-handoff.md`, this diff --git a/notes/ghostlight-dungeon.md b/notes/ghostlight-dungeon.md index d00a5ba..ef01d02 100644 --- a/notes/ghostlight-dungeon.md +++ b/notes/ghostlight-dungeon.md @@ -148,6 +148,12 @@ 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. - 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. diff --git a/notes/ghostlight-implementation-plan.md b/notes/ghostlight-implementation-plan.md index c8cbe5b..3ed43e2 100644 --- a/notes/ghostlight-implementation-plan.md +++ b/notes/ghostlight-implementation-plan.md @@ -8,19 +8,22 @@ architecture and ownership map is pipeline and fixtures remain regression evidence; they do not become hosted runtime authorities. -The Epiphany Projector → Persona → Interpreter extraction map is complete. -Ghostlight owns the generalized projection organ. Epiphany keeps her canonical -Persona mind and consumes the shared organ through a narrow adapter. +The Epiphany Projector → Persona → Interpreter extraction and handback are +complete. Ghostlight owns the generalized projection membrane in the +`ghostlight-persona-projection` crate. Epiphany consumes an exact Ghostlight Git +revision and now gives Persona only one lived narrative stream; Epiphany keeps +her canonical Persona mind, receipts, effect admission, brakes, and external +consequence authority. -The active implementation cut is the world compiler. The first Rust seam now -owns Vault witness conversion, distinct opening and role proposals, -approval-gated custom compilation, deterministic seed validation, atomic -campaign-plus-evidence admission, and the browser opening/role/custom flow. A -live DeepSeek plus VoidBot custom compilation passed without committing. A -disposable HTTP run proved approval persistence and durable hashed invite and -session state across restart. Implement material-gap decisions, on-demand -destination compilation, canon-candidate persistence, and reversible gestalt -member materialization before moving to the action/Persona loop. +The hosted runtime owns compiler approval, exact VoidBot evidence, campaign +mailboxes, fiction-first d20 resolution, parallel Persona appraisal, narration, +reversible gestalt materialization, isolated sessions/campaigns, CultMesh/Eve +publication, and away-time scheduling. Strategic ticks now use a flash-model +typed proposal; the WorldKernel forbids player puppeting, invented IDs, +unreachable movement, and unbounded information or population-pressure edits. +The active cut is acceptance and deployment truth: exercise live scheduled and +return-time ticks, the gestalt round trip, model failure, four-actor latency, +remote CultMesh publication, restart, and exact release provenance. ## Prior research-program phase @@ -107,10 +110,9 @@ not carry live next-action lists. custody, resource accounting, schema validation, source provenance, mutation authority, prompt leakage checks, and Ink compilation. -## Deferred +## Deferred from the earlier fixture program - Full world simulation loop -- Autonomous offscreen faction simulation - Economy simulation loop - Long-horizon plot generation without author scaffolding - Fine-tuning before artifact schemas, review criteria, and evaluators stabilize diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 86bc617..9f84a83 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -73,3 +73,4 @@ {"note": "World compiler live acceptance passed on 2026-08-16: DeepSeek v4 Pro consumed 30 hashed VoidBot witnesses across three receipts, emitted three locations, three actors, two institutions, two clocks, explicit gaps and branch assumptions, and remained an uncommitted revision-0 approval preview. Deterministic tests reject dangling routes and malformed typed seeds.", "status": "ok", "ts": "2026-08-16T18:12:28+00:00", "type": "implementation"} {"note": "Disposable HTTP acceptance proved unauthenticated 401, compiler-only surface before approval, explicit campaign admission with three evidence receipts, campaign reload after daemon restart, authenticated session survival after restart, and 401 on consumed-invite reuse. Auth CultCache stores token/session hashes rather than plaintext.", "status": "ok", "ts": "2026-08-16T18:17:14+00:00", "type": "verification"} {"ts": "2026-08-16T21:10:00+00:00", "type": "verification", "status": "ok", "branch": "codex/ghostlight-dungeon-mvp", "note": "Registry HTTP acceptance at commit 381cbf2: two single-use invite sessions compiled distinct live DeepSeek/VoidBot-grounded campaigns with different IDs, surfaces, evidence receipts, and per-campaign .cc stores; cross-session selection returned 403. Fork, reset, 1,056,768-byte CultCache export, session/campaign survival across daemon restart, rejected-command receipt without revision advance, committed Wait narration, and zero settled live-turn pressure all passed. Disposable witness root: F:\\GameCult\\GhostlightDungeon\\smoke\\registry-381cbf2."} +{"ts":"2026-08-16T20:04:54+00:00","type":"implementation","status":"ok","branch":"codex/ghostlight-dungeon-mvp","note":"Away-time agency now uses a revision-bound deepseek-v4-flash StrategicTickPlan proposal. WorldKernel validation rejects player puppeting, invented institutions/gestalts/actors/locations, duplicate actions, movement without a direct route or beyond tick duration, empty summaries, and unbounded channels or population pressures before mutation. The 30-test Rust suite proves a rejected player move leaves revision/location unchanged and a valid remote actor move commits one event."} diff --git a/state/map.yaml b/state/map.yaml index 2425d2d..aaedaf2 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -254,6 +254,6 @@ data_flow: - If state grows faster than understanding, cut it back. current_status: - summary: GhostlightDungeon is the active MVP program. The approval-gated compiler persists evidence, canon candidates, and bounded region expansion. Fiction-first player and NPC attempts use deterministic initiative, model assessment, server-side d20, and prevalidated typed outcome deltas. Present NPCs appraise events in parallel; gestalt populations materialize durable individuals and fold them into member deltas. Narration is a revision-bound noncanonical projection. A CampaignRegistry now isolates per-campaign stores/mailboxes, persists hashed session ownership and selection, routes scheduler and HTTP work through the selected runtime, and supports fork/reset/select/CultCache export. Live DeepSeek plus VoidBot compilation and an earlier authenticated HTTP restart smoke passed; the expanded multi-campaign runtime still needs live acceptance. - next_action: Run two-session HTTP, model-failure, restart, scheduler, live gestalt, typed-outcome, performance, and deployment acceptance against the registry runtime; repair any failures before updating deployment provenance. + summary: GhostlightDungeon is the active MVP program. The approval-gated compiler persists exact VoidBot evidence, canon candidates, bounded topology, gestalt baselines, and durable member deltas. Fiction-first player and NPC attempts use deterministic initiative, model assessment, server-side d20, and prevalidated typed outcome deltas. Present NPCs appraise events in parallel; gestalt populations materialize durable individuals and fold them back without losing identity. Ghostlight owns the generalized Persona projection membrane and Epiphany consumes it at an exact Git revision. CampaignRegistry isolates per-campaign stores/mailboxes and sessions. CultMesh/Eve publication owns hosted state sight. Away-time ticks now use revision-bound flash-model strategic proposals validated by WorldKernel; invalid plans, player puppeting, invented IDs, and unreachable movement cannot mutate state. + next_action: Run live scheduler/return-catch-up, model-failure, gestalt round-trip, four-actor latency, remote CultMesh, restart, firewall, and exact-release deployment acceptance; repair failures and publish final provenance. gestalt_population: Gestalt Personas own shared population baselines; persistent member deltas own named individuality; WorldKernel materialization commands compose and demote active actors without deleting member identity.