Preserve failed newspaper receipts in smoke

This commit is contained in:
Meta Vens 2026-08-27 07:53:46 +02:00
commit 2b0dd9e625
2 changed files with 46 additions and 18 deletions

View file

@ -120,6 +120,12 @@ fn main() -> Result<()> {
})
.collect::<Vec<_>>();
recent_model_receipts.sort_by(|left, right| left.storage_key().cmp(right.storage_key()));
let mut newspaper_model_receipts = store
.load_all::<ModelStageReceipt>("persona_stage_receipt.v1")?
.into_iter()
.filter(|receipt| receipt.stage.starts_with("newspaper_"))
.collect::<Vec<_>>();
newspaper_model_receipts.sort_by(|left, right| left.storage_key().cmp(right.storage_key()));
let assessment_mutation_scopes =
store.load_all::<serde_json::Value>("assessment_mutation_scope_cache.v1")?;
let mut roll_receipts = store.load_all::<RollReceipt>("roll_receipt.v1")?;
@ -227,6 +233,7 @@ fn main() -> Result<()> {
"recentWorldEvents": campaign.events.iter().rev().take(24).collect::<Vec<_>>(),
"pendingWorldProposals": campaign.pending_world_proposals,
"recentModelReceipts": recent_model_receipts,
"newspaperModelReceipts": newspaper_model_receipts,
"assessmentMutationScopes": assessment_mutation_scopes,
"recentRollReceipts": roll_receipts,
"recentCommitReceipts": commit_receipts,

View file

@ -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<String>,
editorial_voice: &str,
max_articles: usize,
store: &ghostlight_dungeon::persistence::CampaignStore,
) -> anyhow::Result<ghostlight_dungeon::newspaper::WorldNewspaperComposition> {
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::<ghostlight_dungeon::newspaper::WorldNewspaperCompositionFailure>()
.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,