Keep strategic verifier diagnostics private
This commit is contained in:
parent
bc8f1c342c
commit
e0b12f9025
3 changed files with 58 additions and 21 deletions
|
|
@ -4242,13 +4242,8 @@ async fn command(
|
|||
)
|
||||
.await
|
||||
{
|
||||
return (
|
||||
StatusCode::CONFLICT,
|
||||
Json(ErrorBody {
|
||||
error: error.to_string(),
|
||||
}),
|
||||
)
|
||||
.into_response();
|
||||
let body = player_safe_strategic_failure(&error);
|
||||
return (StatusCode::CONFLICT, Json(body)).into_response();
|
||||
}
|
||||
if let WorldCommand::Wait {
|
||||
expected_revision,
|
||||
|
|
@ -4314,13 +4309,10 @@ async fn command(
|
|||
}),
|
||||
)
|
||||
.into_response(),
|
||||
Err(error) => (
|
||||
StatusCode::UNPROCESSABLE_ENTITY,
|
||||
Json(ErrorBody {
|
||||
error: error.to_string(),
|
||||
}),
|
||||
)
|
||||
.into_response(),
|
||||
Err(error) => {
|
||||
let body = player_safe_strategic_failure(&error);
|
||||
(StatusCode::UNPROCESSABLE_ENTITY, Json(body)).into_response()
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -5784,6 +5776,14 @@ struct ErrorBody {
|
|||
error: String,
|
||||
}
|
||||
|
||||
fn player_safe_strategic_failure(error: &anyhow::Error) -> ErrorBody {
|
||||
tracing::warn!(%error, "private strategic simulation failed without mutation");
|
||||
ErrorBody {
|
||||
error: "The strategic world simulation could not produce a valid atomic wave. No world state changed; retry when ready."
|
||||
.into(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
@ -5791,6 +5791,21 @@ mod tests {
|
|||
use ghostlight_dungeon::domain::{ActorState, BranchOrigin, Location};
|
||||
use tower::ServiceExt;
|
||||
|
||||
#[test]
|
||||
fn strategic_failure_projection_never_contains_private_model_diagnostics() {
|
||||
let private = anyhow::anyhow!(
|
||||
"the hidden convoy chooses a route at dawn; verifier returned private output"
|
||||
);
|
||||
let projected = player_safe_strategic_failure(&private);
|
||||
|
||||
assert_eq!(
|
||||
projected.error,
|
||||
"The strategic world simulation could not produce a valid atomic wave. No world state changed; retry when ready."
|
||||
);
|
||||
assert!(!projected.error.contains("convoy"));
|
||||
assert!(!projected.error.contains("verifier"));
|
||||
}
|
||||
|
||||
fn seed(name: &str) -> Campaign {
|
||||
let actor = ActorState {
|
||||
id: "player".into(),
|
||||
|
|
|
|||
|
|
@ -313,8 +313,12 @@ async fn verify_outcomes(
|
|||
}
|
||||
match (verdict.result, verdict.repair_guidance) {
|
||||
(OutcomeVerifierResult::Match, None) => {}
|
||||
(OutcomeVerifierResult::Mismatch, Some(guidance)) if bounded_text(&guidance, 240) => {
|
||||
mismatches.push(format!("{}: {guidance}", verdict.action_digest));
|
||||
(OutcomeVerifierResult::Mismatch, Some(guidance)) if !guidance.trim().is_empty() => {
|
||||
mismatches.push(format!(
|
||||
"{}: {}",
|
||||
verdict.action_digest,
|
||||
guidance.chars().take(240).collect::<String>()
|
||||
));
|
||||
}
|
||||
_ => {
|
||||
return Err(anyhow!(
|
||||
|
|
@ -1514,8 +1518,7 @@ fn constrain_verifier_schema(schema: &mut serde_json::Value, digests: &[String])
|
|||
"result":{"const":"mismatch"},
|
||||
"repair_guidance":{
|
||||
"type":"string",
|
||||
"minLength":1,
|
||||
"maxLength":240
|
||||
"minLength":1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1698,6 +1701,13 @@ mod tests {
|
|||
"repair_guidance":null
|
||||
}]
|
||||
})));
|
||||
assert!(validator.is_valid(&serde_json::json!({
|
||||
"verdicts":[{
|
||||
"action_digest":digest,
|
||||
"result":"mismatch",
|
||||
"repair_guidance":"The proposed transfer is not causally supported by the exact attempt. Preserve the source subject, exact resource custody, and recipient boundary; if no supplied outcome can express the actual result, replace it with no_material_change instead of inventing an exchange or acceptance that never occurred."
|
||||
}]
|
||||
})));
|
||||
assert!(!validator.is_valid(&serde_json::json!({
|
||||
"verdicts":[{
|
||||
"action_digest":digest,
|
||||
|
|
|
|||
|
|
@ -999,6 +999,9 @@ impl CellProjectionEngine {
|
|||
.repair_guidance
|
||||
.as_deref()
|
||||
.expect("validated mismatch guidance")
|
||||
.chars()
|
||||
.take(240)
|
||||
.collect::<String>()
|
||||
)
|
||||
.into()
|
||||
})
|
||||
|
|
@ -1131,7 +1134,7 @@ fn validate_effect_verification(
|
|||
) {
|
||||
(CellEffectMatchResult::Match, None, None) => {}
|
||||
(CellEffectMatchResult::Mismatch, Some(_), Some(guidance))
|
||||
if !guidance.trim().is_empty() && guidance.chars().count() <= 240 =>
|
||||
if !guidance.trim().is_empty() =>
|
||||
{
|
||||
rejected.push(expected_index)
|
||||
}
|
||||
|
|
@ -1201,8 +1204,7 @@ fn cell_effect_verifier_schema(action_count: usize) -> Result<serde_json::Value>
|
|||
},
|
||||
"repair_guidance":{
|
||||
"type":"string",
|
||||
"minLength":1,
|
||||
"maxLength":240
|
||||
"minLength":1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2323,6 +2325,16 @@ mod tests {
|
|||
});
|
||||
assert!(validator.is_valid(&faithful));
|
||||
|
||||
let long_but_semantically_coherent_guidance = serde_json::json!({
|
||||
"verdicts":[
|
||||
{"action_index":0,"result":"mismatch","mismatch_kind":"wrong_effect_kind","repair_guidance":"The Persona chose a concrete journey, so preserve that exact decision with the supplied migration effect rather than downgrading it to coordination; if no supplied effect can represent the destination, remove this action and let the world retain the attributed choice without committing an invented route."},
|
||||
{"action_index":1,"result":"match","mismatch_kind":null,"repair_guidance":null},
|
||||
{"action_index":2,"result":"match","mismatch_kind":null,"repair_guidance":null},
|
||||
{"action_index":3,"result":"match","mismatch_kind":null,"repair_guidance":null}
|
||||
]
|
||||
});
|
||||
assert!(validator.is_valid(&long_but_semantically_coherent_guidance));
|
||||
|
||||
let incoherent = serde_json::json!({
|
||||
"verdicts":[
|
||||
{"action_index":0,"result":"match","mismatch_kind":"invented_outcome","repair_guidance":null},
|
||||
|
|
|
|||
Loading…
Reference in a new issue