diff --git a/crates/ghostlight-dungeon/src/persona.rs b/crates/ghostlight-dungeon/src/persona.rs index eceb513..f86b001 100644 --- a/crates/ghostlight-dungeon/src/persona.rs +++ b/crates/ghostlight-dungeon/src/persona.rs @@ -657,7 +657,7 @@ fn append_cell_correction( rejected_appraisal: &str, ) { request.lived_stream.push_str(&format!( - "\n\nLOCAL VALIDATOR REJECTED THE PREVIOUS APPRAISAL: {error}\nPREVIOUS_REJECTED_APPRAISAL:\n{rejected_appraisal}\nReturn one corrected complete appraisal against the same snapshot, lived stream, Persona turn, and exact permission context. Change or remove every action that is unsupported or exceeds its attributed subject's permissions; explicit inaction is valid." + "\n\nLOCAL VALIDATOR REJECTED THE PREVIOUS APPRAISAL: {error}\nPREVIOUS_REJECTED_APPRAISAL:\n{rejected_appraisal}\nReturn one corrected complete appraisal against the same snapshot, lived stream, Persona turn, and exact permission context. Change or remove every action that is unsupported or exceeds its attributed subject's permissions. Every retained action must still carry a valid non-empty typed transition under the original contract. If an attempted preparation, inspection, request, or deliberation has no permitted typed consequence, remove it and use explicit inaction; never emit an empty transition or upgrade consideration into a completed consequence." )); } @@ -1355,6 +1355,36 @@ mod tests { assert_eq!(result.stage_receipts.len(), 3); assert_eq!(result.proposals.reaction_priority, 0); } + + #[test] + fn semantic_correction_restates_non_empty_effect_contract() { + let mut request = ModelStageRequest { + stage: "cell_interpreter".into(), + model: "flash".into(), + snapshot_binding: "campaign:one:revision:2".into(), + lived_stream: "original contract".into(), + output_schema: None, + source_receipt_ids: vec![], + temperature: Some(0.0), + max_output_tokens: Some(100), + }; + append_cell_correction( + &mut request, + &anyhow::anyhow!("the typed effect was unsupported"), + r#"{"actions":[{"effect":{"type":"gestalt"}}]}"#, + ); + assert!( + request + .lived_stream + .contains("valid non-empty typed transition") + ); + assert!( + request + .lived_stream + .contains("preparation, inspection, request, or deliberation") + ); + assert!(request.lived_stream.contains("use explicit inaction")); + } } fn allowed_actor_references(slice: &PermittedActorSlice) -> Vec { diff --git a/crates/ghostlight-dungeon/src/scheduler.rs b/crates/ghostlight-dungeon/src/scheduler.rs index 0d29848..4e103d4 100644 --- a/crates/ghostlight-dungeon/src/scheduler.rs +++ b/crates/ghostlight-dungeon/src/scheduler.rs @@ -411,12 +411,7 @@ fn cell_slice(campaign: &Campaign, cell: &SimulationCell) -> Result Result String { + if clock.progress >= clock.threshold { + format!( + "{}: threshold reached ({}/{}); declared consequence: {}", + clock.label, clock.progress, clock.threshold, clock.consequence + ) + } else { + format!( + "{}: progress {} of {}; {} step(s) remain before declared consequence: {}", + clock.label, + clock.progress, + clock.threshold, + clock.threshold.saturating_sub(clock.progress), + clock.consequence + ) + } +} + fn cell_perceived_events( campaign: &Campaign, constituents: &[CellConstituentSlice], @@ -728,6 +741,26 @@ mod tests { malformed_cell: bool, } + #[test] + fn clock_projection_distinguishes_remaining_time_from_reached_consequence() { + let mut clock = crate::domain::WorldClock { + id: "ferry".into(), + label: "Last protected ferry".into(), + progress: 3, + threshold: 4, + consequence: "the camp is cut off by the storm".into(), + }; + assert_eq!( + project_world_clock_pressure(&clock), + "Last protected ferry: progress 3 of 4; 1 step(s) remain before declared consequence: the camp is cut off by the storm" + ); + clock.progress = 4; + assert_eq!( + project_world_clock_pressure(&clock), + "Last protected ferry: threshold reached (4/4); declared consequence: the camp is cut off by the storm" + ); + } + impl CellFixtureModel { fn enter(&self) -> ActiveCall<'_> { let active = self.active.fetch_add(1, Ordering::SeqCst) + 1;