diff --git a/crates/ghostlight-dungeon/src/assessor.rs b/crates/ghostlight-dungeon/src/assessor.rs index fe7ff1c..4ba1263 100644 --- a/crates/ghostlight-dungeon/src/assessor.rs +++ b/crates/ghostlight-dungeon/src/assessor.rs @@ -81,7 +81,7 @@ impl ActionAssessor { "maximum":10 }); let base_prompt = format!( - "OUTPUT JSON SCHEMA (follow exactly):\n{}\n\nAssess an attempted effect, not whether words can be spoken. Impossible actions are inadmissible and receive bargains, not a roll. Choose DC only from 5,10,15,20,25,30. Every modifier reference must be copied exactly from ALLOWED REFERENCES. Modifier total is capped at +/-10. Never grant capability, custody, access, knowledge, or spatial reach absent from state. State concrete success, mixed, and failure consequences and a bounded effect ceiling. Outcome deltas may only name actor IDs copied exactly from PRESENT ACTORS, change their conditions or relationships, move only the acting actor along an existing route, advance existing clocks, or change existing institution posture. When an outcome directly reveals information to the acting actor, actor_knowledge_additions must contain the specific observed finding, not a vague claim that a reading or clue exists. Strong and ordinary success share one visible stake, so give them identical knowledge additions. The runtime binds each exact finding into the player-visible stake; do not spend prose repeating it solely for formatting. Findings become provisional branch facts on commit, so do not invent remote events, hidden actors, unsupported proper nouns, or conclusions beyond the effect ceiling. Keep a delta empty only when the outcome truly has no canonical state change.\nINTENT:\n{}\nACTOR:\n{}\nLOCATION:\n{}\nPRESENT ACTORS:\n{}\nVISIBLE INSTITUTIONS:\n{}\nALLOWED REFERENCES:\n{}", + "OUTPUT JSON SCHEMA (follow exactly):\n{}\n\nAssess an attempted effect, not whether words can be spoken. Impossible actions are inadmissible and receive bargains, not a roll. Choose DC only from 5,10,15,20,25,30. Every modifier reference must be copied exactly from ALLOWED REFERENCES. Modifier total is capped at +/-10. Never grant capability, custody, access, knowledge, or spatial reach absent from state. State concrete success, mixed, and failure consequences and a bounded effect ceiling. Outcome deltas may only name actor IDs copied exactly from PRESENT ACTORS, change their conditions or relationships, move only the acting actor along an existing route, advance existing clocks, or change existing institution posture. When an outcome directly reveals information to the acting actor, actor_knowledge_additions must contain the specific observed finding as a player-readable natural-language declarative statement, never a fact ID, key, slug, or label. Strong and ordinary success share one visible stake, so give them identical knowledge additions. The runtime binds each exact finding into the player-visible stake; do not spend prose repeating it solely for formatting. Findings become provisional branch facts on commit, so do not invent remote events, hidden actors, unsupported proper nouns, or conclusions beyond the effect ceiling. Keep a delta empty only when the outcome truly has no canonical state change.\nINTENT:\n{}\nACTOR:\n{}\nLOCATION:\n{}\nPRESENT ACTORS:\n{}\nVISIBLE INSTITUTIONS:\n{}\nALLOWED REFERENCES:\n{}", serde_json::to_string(&schema)?, serde_json::to_string(&intent)?, serde_json::to_string(actor)?, @@ -285,12 +285,13 @@ pub(crate) fn validate_effect( || additions.iter().any(|finding| { finding.trim().is_empty() || finding.chars().count() > 500 + || looks_like_identifier(finding) || acting_actor.knowledge.contains(finding) || !stake.contains(finding) }) { return Err(anyhow!( - "outcome knowledge must be new, bounded, directly observed by the acting actor, and visible verbatim in its stake" + "outcome knowledge must be a new bounded natural-language finding, directly observed by the acting actor and visible verbatim in its stake" )); } } @@ -324,6 +325,15 @@ pub(crate) fn validate_effect( } Ok(()) } + +fn looks_like_identifier(value: &str) -> bool { + let value = value.trim(); + !value.chars().any(char::is_whitespace) + && (value.contains('_') + || value.contains("::") + || value.starts_with("fact:") + || value.starts_with("fact-")) +} pub fn assessment_digest(assessment: &ActionAssessment) -> Result { let mut value = assessment.clone(); value.digest.clear(); @@ -390,4 +400,12 @@ mod tests { assert!(value.success_stake.contains(&finding)); assert_eq!(value.success_stake.matches(&finding).count(), 1); } + + #[test] + fn fact_identifier_cannot_masquerade_as_character_knowledge() { + assert!(looks_like_identifier("fact_distress_relay_antenna_damaged")); + assert!(!looks_like_identifier( + "The distress relay's antenna array is damaged." + )); + } } diff --git a/crates/ghostlight-dungeon/src/domain.rs b/crates/ghostlight-dungeon/src/domain.rs index d4fab43..8ced0c8 100644 --- a/crates/ghostlight-dungeon/src/domain.rs +++ b/crates/ghostlight-dungeon/src/domain.rs @@ -830,6 +830,8 @@ pub struct ConditionDelta { #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Default)] pub struct WorldEffectDelta { pub actor_conditions: BTreeMap, + /// Exact player-readable natural-language findings learned by each actor. + /// Values are declarative statements, never fact IDs, labels, or keys. #[serde(default)] pub actor_knowledge_additions: BTreeMap>, pub actor_relationship_updates: BTreeMap>, diff --git a/docs/architecture/ghostlight-dungeon-mvp.md b/docs/architecture/ghostlight-dungeon-mvp.md index 422c63e..96f47e2 100644 --- a/docs/architecture/ghostlight-dungeon-mvp.md +++ b/docs/architecture/ghostlight-dungeon-mvp.md @@ -590,6 +590,8 @@ outcome, and an unstated hidden finding cannot appear after the roll. The assessor normalizes each bounded typed finding into its visible stake before validation and digesting. Exact visibility is therefore deterministic; a model retry is reserved for semantic or authority failure, not punctuation mismatch. +The schema names these values as player-readable declarative statements, and a +fact ID, key, or slug cannot enter the character ledger as knowledge. ### Actor and world action loop diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index a4cb446..c2f294f 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -385,6 +385,11 @@ bounded typed finding to the corresponding visible stake before validation and digesting. Semantic or authority errors may retry; punctuation no longer gets a second provider call. +The next replay exposed that an unannotated string set invited an ID-shaped +finding (`fact_distress_relay_antenna_damaged`). The schema now describes +knowledge additions as player-readable declarative statements, and the local +boundary rejects unambiguous fact-ID/key syntax before it can become memory. + Next: commit and build this repaired candidate, replay the same authenticated Huygens campaign in an isolated runtime, inspect both the visible surface and the literal HTTP response, then prove away catch-up/concurrency/persistence/