From 1dea8f5d67ec605154adce764e740cdc7860f065 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 23 Sep 2026 05:36:22 +0200 Subject: [PATCH] Cut 15: the play card names the empty-submit continue while a turn is stuck Running MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A turn a process died mid-round leaves the store's own single current-turn row at Running forever: nothing resumes it on its own, and run's own admit arm for a Running turn only continues it on an empty-text submit (non-empty text is refused as TurnStillRunning). The card rendered nothing at all in that state — no narration, no question, no refusal, since none of those are set on a turn that never reached a close, a question, or a refused act since it last opened — so a player had no way to discover the empty-submit continue exists at all. eve.rs's play-card construction now adds a world.play.running row whenever the current turn's own view reports Running, naming the empty-submit continue directly. This is a control hint about the player's own turn, not world truth, so it stays within invariant 8 the same way the existing narration/question/refusal rows already do. Verified: cargo test -p ghostlight-dungeon --bin ghostlight-dungeon, 178 passed (177 + this one). Ran the mutation quoted in the new test's own doc comment (replacing the state check with `if false`) and reverted it; it failed the test as expected. Co-Authored-By: Claude Sonnet 5 --- crates/ghostlight-dungeon/src/eve.rs | 28 +++++++++++- crates/ghostlight-dungeon/src/play.rs | 65 +++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/crates/ghostlight-dungeon/src/eve.rs b/crates/ghostlight-dungeon/src/eve.rs index 382d28e..46609ef 100644 --- a/crates/ghostlight-dungeon/src/eve.rs +++ b/crates/ghostlight-dungeon/src/eve.rs @@ -1,7 +1,7 @@ //! Eve/CultUI projection for the one live world owner. use crate::mesh::{COMMAND_BOUNDARY, COMMAND_RESULT_SCHEMA, PROVIDER_ID, SURFACE_ID}; -use crate::play::PlayTurnView; +use crate::play::{PlayTurnState, PlayTurnView}; use ghostlight::{JurisdictionKey, WorldPhase, WorldSnapshot}; use anyhow::{Context, bail}; use chrono::{DateTime, Utc}; @@ -476,6 +476,32 @@ pub(crate) fn authenticated_surface( "children":[] })); } + // PA.f188 ("the interrupted turn"): a turn a process + // died mid-round leaves `Running` forever — nothing + // resumes it on its own, and the only way forward is + // submitting an empty message (`play.rs`'s own + // `Some(existing) if existing.state == + // PlayTurnState::Running` admit arm: empty text + // continues it, non-empty text is refused as + // `TurnStillRunning`). Before this the card showed + // nothing at all in that state — no narration, no + // question, no refusal, since none of those are set + // on a turn that never got to close, ask, or record a + // refused act since it last opened — so a player had + // no way to learn the empty-submit continue exists at + // all. This is a control hint about the player's own + // turn, not world truth, so it stays within + // invariant 8 the same way the narration/question/ + // refusal rows above already do. + if play.is_some_and(|view| view.state == PlayTurnState::Running) { + play_rows.push(json!({ + "id":"world.play.running", + "kind":"text", + "props":{"value":"Your last turn is still being resolved. If nothing \ + arrives, submit an empty message to continue it."}, + "children":[] + })); + } children.push(json!({ "id":"world.play.card", "kind":"card", diff --git a/crates/ghostlight-dungeon/src/play.rs b/crates/ghostlight-dungeon/src/play.rs index 499f10d..7049e71 100644 --- a/crates/ghostlight-dungeon/src/play.rs +++ b/crates/ghostlight-dungeon/src/play.rs @@ -3578,6 +3578,71 @@ pub(crate) mod tests { } } + /// PA.f188 ("the interrupted turn"): a turn a process died mid-round + /// leaves `Running` forever — the store's own single-row shape never + /// resumes it on its own, and the admit arm at `run`'s own `Some(existing) + /// if existing.state == PlayTurnState::Running` match continues it only + /// on an empty-text submit (non-empty text is refused as + /// `TurnStillRunning`). Before this fix the card showed nothing at all in + /// that state — no narration, no question, no refusal, since none of + /// those get set on a turn that never reached a close, a question, or a + /// refused act since it last opened — so a player had no way to learn the + /// empty-submit continue exists. The card now names it explicitly while + /// `Running`, and says nothing extra once the turn is `AwaitingPlayer` or + /// `Closed` again. + /// + /// Mutation: delete the `if play.is_some_and(|view| view.state == + /// PlayTurnState::Running) { ... }` block from `eve.rs`'s play-card + /// construction — the `running_hint` lookup below then finds nothing and + /// the first assertion fails. + #[tokio::test] + async fn the_play_card_names_the_empty_submit_continue_while_the_turn_is_running() { + let fixture = play_world(None, "player-interrupted-turn").await; + let world = fixture.world.snapshot().await.unwrap(); + + let running_view = PlayTurnView { + turn_id: test_turn_id(9300), + state: PlayTurnState::Running, + question: None, + narration: None, + refusal: None, + revision: 1, + }; + let surface = crate::eve::authenticated_surface( + "player-interrupted-turn", + Some(&world), + Some(&running_view), + ) + .unwrap(); + let running_hint = find_surface_node(&surface, "world.play.running") + .expect("a Running turn must render a hint naming the empty-submit continue"); + let encoded = serde_json::to_string(running_hint).unwrap(); + assert!( + encoded.to_lowercase().contains("empty"), + "the hint must actually name the empty-submit continue, not just say something is \ + happening: {encoded}" + ); + + let awaiting_view = PlayTurnView { + turn_id: test_turn_id(9301), + state: PlayTurnState::AwaitingPlayer, + question: None, + narration: None, + refusal: None, + revision: 1, + }; + let awaiting_surface = crate::eve::authenticated_surface( + "player-interrupted-turn", + Some(&world), + Some(&awaiting_view), + ) + .unwrap(); + assert!( + find_surface_node(&awaiting_surface, "world.play.running").is_none(), + "the running hint must not appear once the turn has left Running" + ); + } + /// PA.f134's own end-to-end proof: answering *through the turn view's own /// `question.id`* — the id `current_turn_view` actually exposes, never /// one this test built — resumes the turn, and the closed turn's