diff --git a/crates/ghostlight-dungeon/src/compiler.rs b/crates/ghostlight-dungeon/src/compiler.rs index 45e879e..034bdb6 100644 --- a/crates/ghostlight-dungeon/src/compiler.rs +++ b/crates/ghostlight-dungeon/src/compiler.rs @@ -3938,6 +3938,50 @@ mod tests { assert_eq!(preview.campaign.player_actor_id, "actor-sable"); } + #[test] + fn approved_player_identity_cannot_be_materialized_as_a_gestalt_member() { + let mut seed = private_actor_test_seed(); + seed.gestalts.push(GestaltPersonaState { + schema: "ghostlight.gestalt_persona_state.v1".into(), + id: "corvid-collective".into(), + name: "Corvid collective".into(), + version: 0, + home_location_id: "convoy-staging".into(), + shared_capabilities: BTreeSet::new(), + shared_knowledge: BTreeSet::new(), + resources: BTreeSet::new(), + goals: vec![], + pressures: vec![], + }); + seed.gestalt_members.push(GestaltMemberDelta { + schema: "ghostlight.gestalt_member_delta.v1".into(), + id: "member-corvid-sable".into(), + gestalt_id: "corvid-collective".into(), + version: 0, + name: "Sable".into(), + capability_additions: BTreeSet::new(), + capability_removals: BTreeSet::new(), + knowledge_additions: BTreeSet::new(), + knowledge_removals: BTreeSet::new(), + equipment: BTreeSet::new(), + conditions: BTreeSet::new(), + obligations: BTreeSet::new(), + relationships: BTreeMap::new(), + goals: vec![], + memories: vec![], + last_location_id: Some("convoy-staging".into()), + materialized_actor_id: None, + last_relevant_revision: 0, + relevance_lease_until_revision: 0, + }); + + let error = + validate_shared_seed_excludes_locally_owned_subjects(&seed, &[], &["Sable".into()]) + .unwrap_err() + .to_string(); + assert!(error.contains("member:member-corvid-sable")); + } + fn private_actor_test_actor(id: &str, name: &str) -> ActorState { ActorState { id: id.into(), diff --git a/crates/ghostlight-dungeon/src/main.rs b/crates/ghostlight-dungeon/src/main.rs index 719a501..fc72dc0 100644 --- a/crates/ghostlight-dungeon/src/main.rs +++ b/crates/ghostlight-dungeon/src/main.rs @@ -1722,6 +1722,7 @@ fn transient_result_projection( source_version: u64, ) -> Option { let mut children = Vec::new(); + let mut result_version = source_version; if operation == "session_zero.invites.create" { let links = value .get("invite_tokens")? @@ -1733,8 +1734,14 @@ fn transient_result_projection( let text = (!links.is_empty()) .then(|| format!("Single-use invitations:\n{}", links.join("\n")))?; children.push(serde_json::json!({"id":"ghostlight.command-result.text","kind":"text","props":{"value":text},"children":[]})); - } else if operation == "world.assess" { + } else if operation == "world.assess" + || value.get("kind").and_then(serde_json::Value::as_str) == Some("assessed") + { let assessment = value.get("assessment")?; + result_version = assessment + .get("revision") + .and_then(serde_json::Value::as_u64) + .unwrap_or(source_version); let digest = assessment.get("digest")?.as_str()?; let admissible = assessment .get("admissible") @@ -1795,6 +1802,30 @@ fn transient_result_projection( &[], )); } + } else if operation == "world.attempt" + && value.get("kind").and_then(serde_json::Value::as_str) == Some("committed") + { + let receipt = value.get("receipt")?; + let roll = receipt.get("roll")?; + result_version = receipt + .get("revision") + .and_then(serde_json::Value::as_u64) + .unwrap_or(source_version); + let d20 = roll.get("d20")?.as_u64()?; + let modifier = roll.get("modifier_total")?.as_i64()?; + let total = roll.get("total")?.as_i64()?; + let dc = roll.get("dc")?.as_u64()?; + let outcome = roll.get("outcome")?.as_str()?.replace('_', " "); + children.push(serde_json::json!({ + "id":"ghostlight.roll.summary", + "kind":"text", + "props":{ + "value":format!( + "d20 {d20} {modifier:+} = {total} against DC {dc} — {outcome}." + ) + }, + "children":[] + })); } else if matches!( operation, "world.destination.compile" | "world.gestalt.fission.compile" @@ -1822,7 +1853,7 @@ fn transient_result_projection( "providerId":EVE_PROVIDER_ID, "providerKind":"narrative.simulation.command-result", "title":"Ghostlight result", - "version":source_version, + "version":result_version, "updatedAtUtc":Utc::now().to_rfc3339(), "surface":{ "id":"ghostlight.command-result", @@ -6195,6 +6226,69 @@ mod tests { assert!(projection["surface"]["root"]["children"].is_array()); } + #[test] + fn stale_attempt_projects_the_fresh_assessment_and_revision() { + let projection = transient_result_projection( + "world.attempt", + &serde_json::json!({ + "kind":"assessed", + "assessment": { + "revision": 9, + "digest": "sha256:fresh-assessment", + "admissible": true, + "dc": 15, + "modifier_total": 2, + "effect_ceiling": "Supervised access only", + "success_stake": "The ledger is opened.", + "mixed_stake": "The ledger is opened under scrutiny.", + "failure_stake": "Access is refused.", + "bargains": [] + } + }), + 8, + ) + .unwrap(); + + assert_eq!(projection["version"], 9); + let roll = &projection["surface"]["root"]["children"][1]; + assert_eq!(roll["kind"], "control.button"); + assert_eq!(roll["props"]["command"], "world.attempt"); + assert_eq!( + roll["props"]["action"]["assessment_digest"], + "sha256:fresh-assessment" + ); + } + + #[test] + fn committed_attempt_projects_the_exact_roll_receipt() { + let projection = transient_result_projection( + "world.attempt", + &serde_json::json!({ + "kind":"committed", + "revision": 6, + "receipt": { + "revision": 3, + "roll": { + "assessment_digest":"sha256:assessment", + "d20":12, + "modifier_total":3, + "total":15, + "dc":15, + "outcome":"success" + } + } + }), + 2, + ) + .unwrap(); + + assert_eq!(projection["version"], 3); + assert_eq!( + projection["surface"]["root"]["children"][0]["props"]["value"], + "d20 12 +3 = 15 against DC 15 — success." + ); + } + #[test] fn compiler_preview_projection_exposes_approval_shape_not_private_state() { let mut campaign = seed("Approval preview"); diff --git a/docs/architecture/ghostlight-dungeon-mvp.md b/docs/architecture/ghostlight-dungeon-mvp.md index 9a85dfd..3bf16d3 100644 --- a/docs/architecture/ghostlight-dungeon-mvp.md +++ b/docs/architecture/ghostlight-dungeon-mvp.md @@ -627,6 +627,12 @@ receive no roll. Natural 20 and 1 shift one band and cannot cross impossibility or the effect ceiling. Speech occurs as speech; persuasion, deception, and intimidation are separate intended effects. +The accepted Eve command result projects the exact persisted roll receipt—die, +modifier, total, DC, and outcome band—as one-time player-visible state. If +return catch-up makes an assessment stale, the typed `assessed` response owns +the transient projection: it presents the replacement assessment and binds its +Roll control to that assessment's current campaign revision. + Informational attempts may reveal an existing `WorldFact`; they may not author one. `WorldFact` owns branch truth and the location boundaries at which a fact can be discovered. `ActorState.knowledge` owns only which exact statements that