Aetherlight AL2a.3: delete persona material
Remove PersonaMaterial, PersonaReadRef, ComponentOp and ResolvedOp SetPersonaMaterial with its resolution, apply and confinement arms, WorldState.persona_material, the subject snapshot's material field and WorldPatch::sets_persona_of_existing_subject, with the tests whose subject they were. The op set goes from 34 to 33. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
98282a07af
commit
58493253b6
2 changed files with 2 additions and 356 deletions
|
|
@ -78,7 +78,7 @@ pub(crate) use patch::{
|
|||
BoundPrecondition, ChannelRecord, Commitment, CommitmentKind, Confidence, Cost,
|
||||
DependencyTarget, EntityKind, EvidenceRef, FactRecord,
|
||||
FactStanding, Forum, GrievanceKindName, Knowledge, KnowledgeSource, Office, OfficeName,
|
||||
PersonaMaterial, Position, PressureMagnitude, PressureSource, Quantity, Reach,
|
||||
Position, PressureMagnitude, PressureSource, Quantity, Reach,
|
||||
WorldScaleIntent, WorldScaleIntentRef,
|
||||
};
|
||||
pub use patch::ImportKey;
|
||||
|
|
@ -811,7 +811,6 @@ struct WorldState {
|
|||
commitments: BTreeMap<SubjectId, BTreeMap<CommitmentKey, Commitment>>,
|
||||
/// Lived meaning per subject. Read by projection and by nothing that
|
||||
/// decides, so it enters `state_digest` and no `ScopePreimage`.
|
||||
persona_material: BTreeMap<SubjectId, PersonaMaterial>,
|
||||
/// Pressure *on* each subject, keyed target-major then source. Never empty
|
||||
/// for a present key; no stored zero magnitude.
|
||||
pressures: BTreeMap<SubjectId, BTreeMap<PressureSource, PressureMagnitude>>,
|
||||
|
|
@ -975,8 +974,6 @@ pub struct SubjectSnapshot {
|
|||
/// itself. View-only, covered by no digest of its own: it is already bound
|
||||
/// through `components`.
|
||||
pub(crate) dependencies: Vec<DependencyTarget>,
|
||||
/// What the subject carries as lived meaning, if anything was authored.
|
||||
pub(crate) material: Option<PersonaMaterial>,
|
||||
/// A projection of `qualifies`, not a stored flag and not a second count:
|
||||
/// whether this subject already reduces its jurisdiction's scale deficit.
|
||||
/// The seed brief needs to say which subjects count; recomputing the
|
||||
|
|
@ -1890,7 +1887,6 @@ impl WorldState {
|
|||
selection: BTreeMap::new(),
|
||||
redress: BTreeMap::new(),
|
||||
commitments: BTreeMap::new(),
|
||||
persona_material: BTreeMap::new(),
|
||||
pressures: BTreeMap::new(),
|
||||
last_opportunity_at: BTreeMap::new(),
|
||||
now: FictionalMinutes::default(),
|
||||
|
|
@ -2951,22 +2947,6 @@ fn apply_operation(
|
|||
);
|
||||
}
|
||||
}
|
||||
ResolvedOp::SetPersonaMaterial { subject, material } => {
|
||||
if !state.subjects.contains_key(subject)
|
||||
|| material
|
||||
.reads
|
||||
.keys()
|
||||
.any(|other| !state.subjects.contains_key(other))
|
||||
{
|
||||
return Err(unknown());
|
||||
}
|
||||
if state.persona_material.get(subject) == Some(material) {
|
||||
return Err(KernelError::Invariant(
|
||||
"persona material changes nothing".into(),
|
||||
));
|
||||
}
|
||||
state.persona_material.insert(*subject, material.clone());
|
||||
}
|
||||
ResolvedOp::SetReach { channel, reach } => {
|
||||
let current = state
|
||||
.channels
|
||||
|
|
@ -3860,7 +3840,6 @@ fn snapshot(state: &WorldState) -> Result<WorldSnapshot, KernelError> {
|
|||
.collect(),
|
||||
dependencies: components.dependencies.iter().copied().collect(),
|
||||
components,
|
||||
material: state.persona_material.get(subject_id).cloned(),
|
||||
pressures: state
|
||||
.pressures
|
||||
.get(subject_id)
|
||||
|
|
@ -4910,13 +4889,6 @@ fn operation_ground(
|
|||
// recipients here would be a second statement of the same rule,
|
||||
// computed from state this function does not read.
|
||||
ResolvedOp::Witness { place, .. } => (Vec::new(), places(vec![*place]), Vec::new()),
|
||||
ResolvedOp::SetPersonaMaterial { subject, material } => (
|
||||
std::iter::once(*subject)
|
||||
.chain(material.reads.keys().copied())
|
||||
.collect(),
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
),
|
||||
ResolvedOp::SetReach { channel, reach } => {
|
||||
let mut subjects = Vec::new();
|
||||
let mut named = Vec::new();
|
||||
|
|
@ -12673,119 +12645,6 @@ mod witness_tests {
|
|||
assert_eq!(reopened.snapshot().unwrap(), created);
|
||||
}
|
||||
|
||||
/// Persona material is set whole, refused when any text is non-canonical
|
||||
/// or a read names a subject twice, refused when identical to what the
|
||||
/// subject holds, and outside the scope digest: setting it moves no
|
||||
/// opportunity's binding.
|
||||
#[test]
|
||||
fn soul_persona_material_is_set_whole_and_outside_the_scope_digest() {
|
||||
use crate::patch::PersonaReadRef;
|
||||
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let (mut kernel, world, active) = nesting_kernel(directory.path(), "Material");
|
||||
let text = |value: &str| Statement::new(value).unwrap();
|
||||
let material = |voice: Statement, reads: Vec<PersonaReadRef>| ComponentOp::SetPersonaMaterial {
|
||||
subject: Ref::Existing(world.villager),
|
||||
values: vec![text("Water is owed upward.")],
|
||||
voice,
|
||||
memories: vec![text("The gate froze the winter the ferry sank.")],
|
||||
reads,
|
||||
};
|
||||
let read = |subject: SubjectId| PersonaReadRef {
|
||||
subject: Ref::Existing(subject),
|
||||
statement: text("Counts every jar twice."),
|
||||
};
|
||||
let digest_of = |snapshot: &WorldSnapshot| {
|
||||
snapshot
|
||||
.opportunities
|
||||
.iter()
|
||||
.find(|opportunity| opportunity.scope.subject_id == world.villager)
|
||||
.map(|opportunity| opportunity.scope_digest.clone())
|
||||
};
|
||||
let before = digest_of(&active);
|
||||
|
||||
// Padded text is refused at resolve, as is a subject read twice.
|
||||
let padded: Statement = serde_json::from_value(serde_json::json!(" padded ")).unwrap();
|
||||
assert_eq!(
|
||||
reject_owner(
|
||||
&mut kernel,
|
||||
&active,
|
||||
operations(vec![material(padded, vec![read(world.neighbour)])]),
|
||||
),
|
||||
vec![Mismatch::NoncanonicalText { operation: 0 }]
|
||||
);
|
||||
assert_eq!(
|
||||
reject_owner(
|
||||
&mut kernel,
|
||||
&active,
|
||||
operations(vec![material(
|
||||
text("Dry and exact."),
|
||||
vec![read(world.neighbour), read(world.neighbour)],
|
||||
)]),
|
||||
),
|
||||
vec![Mismatch::NoncanonicalText { operation: 0 }]
|
||||
);
|
||||
// A read of a subject the world does not hold is refused.
|
||||
assert!(
|
||||
!reject_owner(
|
||||
&mut kernel,
|
||||
&active,
|
||||
operations(vec![material(
|
||||
text("Dry and exact."),
|
||||
vec![read(SubjectId::issue())],
|
||||
)]),
|
||||
)
|
||||
.is_empty()
|
||||
);
|
||||
|
||||
let receipt = submit_owner(
|
||||
&mut kernel,
|
||||
&active,
|
||||
operations(vec![material(text("Dry and exact."), vec![read(world.neighbour)])]),
|
||||
);
|
||||
assert!(matches!(receipt, SubmitReceipt::Applied(_)), "{receipt:?}");
|
||||
let held = kernel.snapshot().unwrap();
|
||||
let villager = held
|
||||
.subjects
|
||||
.iter()
|
||||
.find(|subject| subject.id == world.villager)
|
||||
.unwrap();
|
||||
let carried = villager.material.as_ref().expect("material was set");
|
||||
assert_eq!(carried.voice.as_str(), "Dry and exact.");
|
||||
assert_eq!(
|
||||
carried.reads.get(&world.neighbour).map(Statement::as_str),
|
||||
Some("Counts every jar twice.")
|
||||
);
|
||||
assert_eq!(digest_of(&held), before, "material moved a scope digest");
|
||||
|
||||
// Identical material changes nothing; different material replaces all.
|
||||
assert_eq!(
|
||||
reject_owner(
|
||||
&mut kernel,
|
||||
&held,
|
||||
operations(vec![material(text("Dry and exact."), vec![read(world.neighbour)])]),
|
||||
),
|
||||
vec![Mismatch::NoOperationEffect { operation: 0 }]
|
||||
);
|
||||
let held = kernel.snapshot().unwrap();
|
||||
submit_owner(
|
||||
&mut kernel,
|
||||
&held,
|
||||
operations(vec![material(text("Slow and courteous."), Vec::new())]),
|
||||
);
|
||||
let replaced = kernel.snapshot().unwrap();
|
||||
let carried = replaced
|
||||
.subjects
|
||||
.iter()
|
||||
.find(|subject| subject.id == world.villager)
|
||||
.unwrap()
|
||||
.material
|
||||
.clone()
|
||||
.unwrap();
|
||||
assert_eq!(carried.voice.as_str(), "Slow and courteous.");
|
||||
assert!(carried.reads.is_empty(), "a whole-value set kept an old read");
|
||||
}
|
||||
|
||||
/// What a witness hands the narrative lane's interruption renderer. The
|
||||
/// renderer takes a subject's own `ScopeComponents` and its own knowledge
|
||||
/// rows and nothing else, so both of its inputs are pinned here rather than
|
||||
|
|
|
|||
Loading…
Reference in a new issue