diff --git a/crates/ghostlight-dungeon/src/bin/ghostlight-campaign-inspect.rs b/crates/ghostlight-dungeon/src/bin/ghostlight-campaign-inspect.rs index a08601e..a49b3f3 100644 --- a/crates/ghostlight-dungeon/src/bin/ghostlight-campaign-inspect.rs +++ b/crates/ghostlight-dungeon/src/bin/ghostlight-campaign-inspect.rs @@ -120,6 +120,12 @@ fn main() -> Result<()> { }) .collect::>(); recent_model_receipts.sort_by(|left, right| left.storage_key().cmp(right.storage_key())); + let mut newspaper_model_receipts = store + .load_all::("persona_stage_receipt.v1")? + .into_iter() + .filter(|receipt| receipt.stage.starts_with("newspaper_")) + .collect::>(); + newspaper_model_receipts.sort_by(|left, right| left.storage_key().cmp(right.storage_key())); let assessment_mutation_scopes = store.load_all::("assessment_mutation_scope_cache.v1")?; let mut roll_receipts = store.load_all::("roll_receipt.v1")?; @@ -227,6 +233,7 @@ fn main() -> Result<()> { "recentWorldEvents": campaign.events.iter().rev().take(24).collect::>(), "pendingWorldProposals": campaign.pending_world_proposals, "recentModelReceipts": recent_model_receipts, + "newspaperModelReceipts": newspaper_model_receipts, "assessmentMutationScopes": assessment_mutation_scopes, "recentRollReceipts": roll_receipts, "recentCommitReceipts": commit_receipts, diff --git a/crates/ghostlight-dungeon/src/bin/ghostlight-strategic-smoke.rs b/crates/ghostlight-dungeon/src/bin/ghostlight-strategic-smoke.rs index 4ebd811..135f5ef 100644 --- a/crates/ghostlight-dungeon/src/bin/ghostlight-strategic-smoke.rs +++ b/crates/ghostlight-dungeon/src/bin/ghostlight-strategic-smoke.rs @@ -182,22 +182,15 @@ async fn main() -> anyhow::Result<()> { if issue_campaign.news.is_empty() { anyhow::bail!("strategic wave {wave_index} produced no gated news") } - let issue_composition = ghostlight_dungeon::newspaper::compose_world_newspaper( + let issue_composition = compose_persisted_newspaper( model.as_ref(), &issue_campaign, format!("{newspaper_title} — Issue {wave_index}"), &newspaper_voice, 5, + &store, ) .await?; - for receipt in &issue_composition.model_receipts { - store.insert( - "persona_stage_receipt.v1", - "ghostlight.persona_stage_receipt.v1", - receipt.storage_key(), - receipt, - )?; - } let issue_path = root.join(format!("newspaper-wave-{wave_index:02}.md")); let issue_audit_path = root.join(format!("newspaper-wave-{wave_index:02}.audit.md")); std::fs::write( @@ -243,22 +236,15 @@ async fn main() -> anyhow::Result<()> { }))?, )?; } - let newspaper_composition = ghostlight_dungeon::newspaper::compose_world_newspaper( + let newspaper_composition = compose_persisted_newspaper( model.as_ref(), &campaign, &newspaper_title, &newspaper_voice, 6, + &store, ) .await?; - for receipt in &newspaper_composition.model_receipts { - store.insert( - "persona_stage_receipt.v1", - "ghostlight.persona_stage_receipt.v1", - receipt.storage_key(), - receipt, - )?; - } let newspaper_path = root.join("newspaper.md"); let newspaper_audit_path = root.join("newspaper.audit.md"); std::fs::write( @@ -333,6 +319,41 @@ async fn main() -> anyhow::Result<()> { Ok(()) } +async fn compose_persisted_newspaper( + model: &dyn ghostlight_dungeon::model::ModelPort, + campaign: &ghostlight_dungeon::domain::Campaign, + title: impl Into, + editorial_voice: &str, + max_articles: usize, + store: &ghostlight_dungeon::persistence::CampaignStore, +) -> anyhow::Result { + let result = ghostlight_dungeon::newspaper::compose_world_newspaper( + model, + campaign, + title, + editorial_voice, + max_articles, + ) + .await; + let receipts = match &result { + Ok(composition) => Some(composition.model_receipts.as_slice()), + Err(error) => error + .downcast_ref::() + .map(|failure| failure.model_receipts.as_slice()), + }; + if let Some(receipts) = receipts { + for receipt in receipts { + store.insert( + "persona_stage_receipt.v1", + "ghostlight.persona_stage_receipt.v1", + receipt.storage_key(), + receipt, + )?; + } + } + result +} + fn bounded_environment_usize( name: &str, default: usize,