Bind informational findings deterministically

This commit is contained in:
Meta Vens 2026-08-17 17:56:13 +02:00
commit b565a2b9f7
5 changed files with 65 additions and 5 deletions

View file

@ -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; copy each exact finding verbatim into that outcome's visible stake. Such 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, 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{}",
serde_json::to_string(&schema)?,
serde_json::to_string(&intent)?,
serde_json::to_string(actor)?,
@ -110,11 +110,12 @@ impl ActionAssessor {
)
.await?;
let candidate = (|| -> Result<AssessmentProposal> {
let proposal: AssessmentProposal = serde_json::from_value(
let mut proposal: AssessmentProposal = serde_json::from_value(
out.structured
.clone()
.ok_or_else(|| anyhow!("assessor returned no typed proposal"))?,
)?;
bind_visible_knowledge(&mut proposal)?;
validate_proposal(&proposal, &allowed_references)?;
for (effect, stake) in [
(&proposal.strong_effect, &proposal.success_stake),
@ -130,7 +131,7 @@ impl ActionAssessor {
Ok(proposal) => break (proposal, out),
Err(error) if attempts == 1 => {
correction = format!(
"\n\nLOCAL VALIDATOR REJECTED THE PREVIOUS ASSESSMENT: {error}\nReturn a corrected complete assessment against the same snapshot. Copy every actor and destination ID exactly from the supplied state. Bind specific directly observed findings to the acting actor and repeat them verbatim in the matching visible stake; otherwise leave the typed delta empty."
"\n\nLOCAL VALIDATOR REJECTED THE PREVIOUS ASSESSMENT: {error}\nReturn a corrected complete assessment against the same snapshot. Copy every actor and destination ID exactly from the supplied state. Bind specific directly observed findings only to the acting actor; strong and ordinary success must use identical knowledge additions. Otherwise leave the typed delta empty."
);
}
Err(error) => {
@ -169,6 +170,36 @@ impl ActionAssessor {
}
}
fn bind_visible_knowledge(proposal: &mut AssessmentProposal) -> Result<()> {
if proposal.strong_effect.actor_knowledge_additions
!= proposal.success_effect.actor_knowledge_additions
{
return Err(anyhow!(
"strong and ordinary success must expose identical knowledge because they share one visible stake"
));
}
append_visible_findings(&mut proposal.success_stake, &proposal.success_effect);
append_visible_findings(&mut proposal.mixed_stake, &proposal.mixed_effect);
append_visible_findings(&mut proposal.failure_stake, &proposal.failure_effect);
Ok(())
}
fn append_visible_findings(stake: &mut String, effect: &WorldEffectDelta) {
for finding in effect
.actor_knowledge_additions
.values()
.flat_map(|findings| findings.iter())
{
if !stake.contains(finding) {
if !stake.trim_end().is_empty() {
stake.push(' ');
}
stake.push_str("Observed finding: ");
stake.push_str(finding);
}
}
}
fn allowed_references(campaign: &Campaign, actor: &crate::domain::ActorState) -> BTreeSet<String> {
let mut refs = BTreeSet::from([
format!("actor:{}", actor.id),
@ -342,4 +373,21 @@ mod tests {
value.dc = 17;
assert!(validate_proposal(&value, &BTreeSet::from(["equipment:key".into()])).is_err());
}
#[test]
fn exact_knowledge_is_bound_into_visible_stakes_without_model_duplication() {
let finding = "The relay's backup cell is depleted.".to_string();
let mut value = proposal("equipment:key");
let additions = std::collections::BTreeMap::from([(
"player".into(),
BTreeSet::from([finding.clone()]),
)]);
value.strong_effect.actor_knowledge_additions = additions.clone();
value.success_effect.actor_knowledge_additions = additions;
bind_visible_knowledge(&mut value).unwrap();
assert!(value.success_stake.contains(&finding));
assert_eq!(value.success_stake.matches(&finding).count(), 1);
}
}

View file

@ -587,6 +587,9 @@ On resolution, only the acting character may receive those bounded knowledge
additions; the same statement is committed as a provisional branch fact. A
vague promise such as “identify any faults” is not a valid informational
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.
### Actor and world action loop

View file

@ -379,6 +379,12 @@ direct source text to the causal world seed, and narrows narration to the latest
causal turn. Browser strings use text nodes and the laboratory inputs have
programmatic labels.
The first clean-seed diagnostic then spent its correction attempt on a verbatim
stake/knowledge mismatch. The assessor now deterministically appends each
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.
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/

View file

@ -84,7 +84,9 @@ That boundary also projects less state outward than the kernel returns inward.
Player HTTP responses contain only assessment, public commit/roll receipts, and
narration. Canonical campaign state and spoiler-bearing actor or institution
state are operator-only. Informational rolls add only their exact previewed
finding to the acting character and a provisional branch fact. The compiler
finding to the acting character and a provisional branch fact. The assessor
deterministically binds typed findings into visible stakes before validation,
so formatting is not delegated to a correction attempt. The compiler
classifies each retrieved source as direct seed, setting background, or excluded
before generation. Only direct-seed source text enters causal world compilation;
background and excluded sources remain coverage provenance and cannot donate

View file

@ -41,7 +41,8 @@ The current browser/compiler hardening adds three ownership cuts before the
next isolated acceptance run: compiler evidence is triaged into direct,
background, and excluded lanes before generation, with only direct source text
admitted to the causal world seed; informational action effects
must name the exact player-visible finding they commit; and player HTTP command
must name the exact finding they commit, which the runtime binds into the
player-visible stake before validation; and player HTTP command
responses are spoiler-safe projections rather than serialized campaigns. The
browser renders these projections as labeled, escaped human-readable controls,
and narration receives only the latest causal turn rather than a route dump.