Bind effect verification to exact proposals

This commit is contained in:
Meta Vens 2026-08-17 22:42:20 +02:00
commit 532335b90d
3 changed files with 70 additions and 11 deletions

View file

@ -459,14 +459,25 @@ fn execute(
.iter()
.find(|appraisal| appraisal.cell_id == cell.id)
.is_some_and(|appraisal| !appraisal.actions.is_empty());
if actionful
&& !stage_bindings
.contains(&("cell_effect_verifier".into(), binding.clone()))
{
return Err(KernelError::Invalid(format!(
"resolution wave lacks cell_effect_verifier receipt for {}",
cell.id
)));
if actionful {
let appraisal = wave
.appraisals
.iter()
.find(|appraisal| appraisal.cell_id == cell.id)
.expect("active cell appraisal was validated");
let verifier_binding = crate::persona::cell_effect_verification_binding(
&binding,
&appraisal.actions,
)
.map_err(|error| KernelError::Invalid(error.to_string()))?;
if !stage_bindings
.contains(&("cell_effect_verifier".into(), verifier_binding))
{
return Err(KernelError::Invalid(format!(
"resolution wave lacks action-bound cell_effect_verifier receipt for {}",
cell.id
)));
}
}
}
}
@ -3397,7 +3408,9 @@ mod tests {
.await
.unwrap_err();
assert!(
error.to_string().contains("lacks cell_effect_verifier"),
error
.to_string()
.contains("lacks action-bound cell_effect_verifier"),
"unexpected kernel rejection: {error}"
);
let stored = store

View file

@ -7,6 +7,7 @@ use ghostlight_persona_projection::{
};
use schemars::{JsonSchema, schema_for};
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use std::collections::{BTreeMap, BTreeSet};
use std::sync::Arc;
@ -563,12 +564,16 @@ impl CellProjectionEngine {
})).collect::<Vec<_>>(),
"subject_names":slice.constituents.iter().map(|subject|(&subject.subject_id, &subject.name)).chain(slice.member_exceptions.iter().map(|member|(&member.subject_id, &member.name))).collect::<BTreeMap<_,_>>(),
});
let verifier_binding = cell_effect_verification_binding(
&slice.snapshot_binding,
&appraisal.actions,
)?;
let mut verified = run_validated_stage(
self.model.as_ref(),
&ModelStageRequest {
stage: "cell_effect_verifier".into(),
model: self.interpreter_model.clone(),
snapshot_binding: slice.snapshot_binding.clone(),
snapshot_binding: verifier_binding,
lived_stream: format!(
"You are the private semantic verifier between an Interpreter and the world kernel. Decide whether every candidate typed effect faithfully represents the exact attributed subject's own attempted consequence in the Persona turn. Structural permissions were already checked. A member_migration means that named member personally chooses to travel to the destination; giving away a berth, sending somebody else, waiting, or merely considering travel does not entail it. An institution posture must express its stated commitment or withholding. A gestalt pressure resolution must be causally supported by its stated attempt, and an added pressure must be a resulting unresolved condition rather than completed-action prose. Reject omissions, reversals, subject swaps, wishful outcomes, and effects that the Persona did not choose. Be concise. Return JSON only.\n\nCONTEXT:\n{}",
serde_json::to_string(&verifier_context)?
@ -675,6 +680,17 @@ fn validate_effect_verification(
Ok(())
}
pub fn cell_effect_verification_binding(
cell_snapshot_binding: &str,
actions: &[crate::domain::CellActionProposal],
) -> Result<String> {
let payload = rmp_serde::to_vec_named(actions)?;
Ok(format!(
"{cell_snapshot_binding}:effects:sha256:{:x}",
Sha256::digest(payload)
))
}
fn bind_cell_appraisal(
slice: &PermittedCellSlice,
proposal: CellAppraisalProposal,
@ -1227,6 +1243,33 @@ mod tests {
serde_json::from_str::<serde_json::Value>(CELL_APPRAISAL_OUTPUT_CONTRACT).unwrap();
}
#[test]
fn effect_verifier_binding_changes_with_the_exact_action_bundle() {
let first = crate::domain::CellActionProposal {
subject_id: "faction-06".into(),
intent: "withhold the reserve".into(),
intended_effect: "wait for a verified count".into(),
priority: 1,
state_references: vec![],
public_channels: vec![],
effect: StrategicCellEffect::Institution {
institution_id: "faction-06".into(),
posture: "withholding pending verification".into(),
location_ids: vec!["forum".into()],
},
};
let mut second = first.clone();
second.intended_effect = "release immediately".into();
assert_eq!(
cell_effect_verification_binding("snapshot", std::slice::from_ref(&first)).unwrap(),
cell_effect_verification_binding("snapshot", std::slice::from_ref(&first)).unwrap()
);
assert_ne!(
cell_effect_verification_binding("snapshot", &[first]).unwrap(),
cell_effect_verification_binding("snapshot", &[second]).unwrap()
);
}
#[test]
fn gestalt_pressure_shape_is_rejected_before_the_world_wave() {
let mut slice = fixture_cell_slice();

View file

@ -274,7 +274,10 @@ mapping “Mira gives her berth to somebody else” into a migration of Mira
herself. The rejected appraisal and concise rationale return to one
same-snapshot Interpreter correction. Inaction cells skip the call. The kernel
requires a valid verifier receipt for every actionful cell; an invalid or
missing verifier cannot satisfy the wave receipt gate.
missing verifier cannot satisfy the wave receipt gate. The verifier receipt's
snapshot binding includes a MessagePack content hash of the ordered action
bundle. The kernel recomputes it, so a verdict for another proposal at the same
world revision and cell cannot be replayed as authority.
## Public state and controls