From 58493253b63a55e6679ca5bd0b85c0085de17c42 Mon Sep 17 00:00:00 2001 From: soul Date: Thu, 19 Nov 2026 22:01:10 +0100 Subject: [PATCH] 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 --- native/aetherlight/src/lib.rs | 143 +-------------------- native/aetherlight/src/patch.rs | 215 +------------------------------- 2 files changed, 2 insertions(+), 356 deletions(-) diff --git a/native/aetherlight/src/lib.rs b/native/aetherlight/src/lib.rs index 03d47c3dc..ba5453027 100644 --- a/native/aetherlight/src/lib.rs +++ b/native/aetherlight/src/lib.rs @@ -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>, /// Lived meaning per subject. Read by projection and by nothing that /// decides, so it enters `state_digest` and no `ScopePreimage`. - persona_material: BTreeMap, /// Pressure *on* each subject, keyed target-major then source. Never empty /// for a present key; no stored zero magnitude. pressures: BTreeMap>, @@ -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, - /// What the subject carries as lived meaning, if anything was authored. - pub(crate) material: Option, /// 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 { .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| 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 diff --git a/native/aetherlight/src/patch.rs b/native/aetherlight/src/patch.rs index 583713a79..4023addea 100644 --- a/native/aetherlight/src/patch.rs +++ b/native/aetherlight/src/patch.rs @@ -353,29 +353,6 @@ pub(crate) struct ChannelRecord { pub(crate) controller: Option, } -/// Lived meaning a subject carries: values, a voice, memories, and reads of -/// other subjects. It constrains no precondition, so it is outside every scope -/// digest and cannot interrupt a bound turn; it enriches projection and never -/// substitutes for authority, custody, topology, or knowledge. Set whole, so a -/// subject holds one value at one revision. -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] -#[serde(deny_unknown_fields)] -pub(crate) struct PersonaMaterial { - pub(crate) values: Vec, - pub(crate) voice: Statement, - pub(crate) memories: Vec, - /// One read per subject, in canonical order. - pub(crate) reads: BTreeMap, -} - -/// The proposal-time twin of a read: the subject by reference. -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] -#[serde(deny_unknown_fields)] -pub(crate) struct PersonaReadRef { - pub(crate) subject: Ref, - pub(crate) statement: Statement, -} - /// A small closed ordinal. Ordered ascending by declaration order, so derived /// `Ord` *is* the semantics and `Knows { at_least }` is one `>=`. Three levels: /// two cannot express "I heard it but I doubt it", which is the state deception @@ -1260,15 +1237,6 @@ pub(crate) enum ComponentOp { channel: Ref, controller: Option>, }, - /// Sets, whole, what a subject carries as lived meaning. Identical material - /// is `NoOperationEffect`; any non-canonical text is `NoncanonicalText`. - SetPersonaMaterial { - subject: Ref, - values: Vec, - voice: Statement, - memories: Vec, - reads: Vec, - }, /// Two identical creations are two commitments, not `NoOperationEffect`: /// the key is command-derived so they cannot collide, and two promises of /// the same thing to the same counterparty are two promises. This is where @@ -1347,28 +1315,6 @@ pub struct WorldPatch { pub(crate) evidence: Vec, } -impl WorldPatch { - /// Whether any `SetPersonaMaterial` operation in this patch targets a - /// subject the patch does not itself declare — an existing, canonical - /// subject (`Ref::Existing`) rather than a draft handle this same patch's - /// own declarations introduced (`Ref::Draft`). `WorldPatch`'s fields are - /// `pub(crate)`, so a consumer that must refuse this shape (PA.f61: the - /// play agent may author a brand-new Persona's material, but never - /// rewrite an existing one's) reads it through this query rather than - /// parsing the patch's own JSON to decide. - pub fn sets_persona_of_existing_subject(&self) -> bool { - self.operations.iter().any(|operation| { - matches!( - operation, - ComponentOp::SetPersonaMaterial { - subject: Ref::Existing(_), - .. - } - ) - }) - } -} - /// The one byte bound on a `WorldPatch` frame from any external source, and /// the three item bounds on a `WorldPatch` as a value. One owner, two /// consumers: the consumer ingress decodes against them through @@ -1681,8 +1627,7 @@ pub enum Mismatch { EmptyStatement { handle: DraftHandle, }, - /// A commitment statement or a piece of persona material that is empty, - /// padded, or spans lines. + /// A commitment statement that is empty, padded, or spans lines. NoncanonicalText { operation: usize, }, @@ -2036,10 +1981,6 @@ pub(crate) enum ResolvedOp { channel: EntityId, controller: Option, }, - SetPersonaMaterial { - subject: SubjectId, - material: PersonaMaterial, - }, /// Kernel-only: no [`ComponentOp`] twin, because no proposer may author one. /// Synthesized by `action::exercise` for a speech-carrying invocation and by /// nothing else. Inserts the entity row and the `facts` row; it writes no @@ -4955,67 +4896,6 @@ pub(super) fn resolve_patch( } } } - ComponentOp::SetPersonaMaterial { - subject, - values, - voice, - memories, - reads, - } => { - let site = Site::Operation(position); - let subject_key = - resolve_subject(site.clone(), subject, &index, &state.subjects, &mut mismatches); - let mut read_keys = Vec::with_capacity(reads.len()); - for read in reads { - read_keys.push(resolve_subject( - site.clone(), - &read.subject, - &index, - &state.subjects, - &mut mismatches, - )); - } - let texts = values - .iter() - .chain(memories.iter()) - .chain(std::iter::once(voice)) - .chain(reads.iter().map(|read| &read.statement)); - let mut read_subjects: BTreeSet<&Ref> = BTreeSet::new(); - let duplicate_read = reads.iter().any(|read| !read_subjects.insert(&read.subject)); - if texts.clone().any(|text| !is_canonical_text(text.as_str())) || duplicate_read { - mismatches.push(Mismatch::NoncanonicalText { - operation: position, - }); - } - let (Some(Key::Existing(subject_id)), true) = - (subject_key, read_keys.iter().all(Option::is_some)) - else { - continue; - }; - // Identical material on an existing subject changes nothing. A - // draft read can never equal a held one, so it is skipped here. - let held: Option> = read_keys - .iter() - .zip(reads) - .map(|(key, read)| match key { - Some(Key::Existing(id)) => Some((*id, read.statement.clone())), - _ => None, - }) - .collect(); - if let Some(held) = held - && state.persona_material.get(&subject_id) - == Some(&PersonaMaterial { - values: values.clone(), - voice: voice.clone(), - memories: memories.clone(), - reads: held, - }) - { - mismatches.push(Mismatch::NoOperationEffect { - operation: position, - }); - } - } ComponentOp::SetReach { channel, reach } => { let channel_key = resolve_entity( Site::Operation(position), @@ -5784,24 +5664,6 @@ pub(super) fn resolve_patch( channel: entity_id_of(&key_of(channel)), reach: reach_of(reach), }, - ComponentOp::SetPersonaMaterial { - subject, - values, - voice, - memories, - reads, - } => ResolvedOp::SetPersonaMaterial { - subject: subject_id_of(&key_of(subject)), - material: PersonaMaterial { - values: values.clone(), - voice: voice.clone(), - memories: memories.clone(), - reads: reads - .iter() - .map(|read| (subject_id_of(&key_of(&read.subject)), read.statement.clone())) - .collect(), - }, - }, ComponentOp::SetController { channel, controller, @@ -6052,81 +5914,6 @@ mod tests { CallerId, CommandBody, CommandId, KernelError, SubmitReceipt, WorldKernel, WorldPhase, }; - /// Owner: `WorldPatch::sets_persona_of_existing_subject`. Consumer: - /// `ghostlight-dungeon`'s play agent (PA.f61, parked at - /// `parked/ghostlight-eve-surface`), which refuses a - /// `set_persona_material` run whose patch answers true here, since - /// `WorldPatch`'s own fields are `pub(crate)` and Dungeon may not parse - /// its JSON to decide the question itself. - #[test] - fn sets_persona_of_existing_subject_reads_the_subject_refs_own_shape() { - let empty = WorldPatch::default(); - assert!(!empty.sets_persona_of_existing_subject()); - - let existing = WorldPatch { - declarations: Vec::new(), - operations: vec![ComponentOp::SetPersonaMaterial { - subject: Ref::Existing(SubjectId::issue()), - values: Vec::new(), - voice: Statement::new("flat and even").unwrap(), - memories: Vec::new(), - reads: Vec::new(), - }], - evidence: Vec::new(), - }; - assert!(existing.sets_persona_of_existing_subject()); - - let draft = WorldPatch { - declarations: Vec::new(), - operations: vec![ComponentOp::SetPersonaMaterial { - subject: Ref::Draft(DraftHandle::new("npc")), - values: Vec::new(), - voice: Statement::new("flat and even").unwrap(), - memories: Vec::new(), - reads: Vec::new(), - }], - evidence: Vec::new(), - }; - assert!(!draft.sets_persona_of_existing_subject()); - } - - /// PA.f92/PA.f110: a fixture whose persona write sits at either end of - /// `operations` only ever exercises `.take(1)` (op 0) or `.rev().take(1)` - /// (the last op) — the prior version of this test put the write last, - /// so `.rev().take(1)` would still find it and pass undetected. Here the - /// persona write to an existing subject sits strictly in the *middle*, - /// with a harmless `Relocate` both before and after it: only a scan over - /// every operation, in either direction, reports `true`. - #[test] - fn sets_persona_of_existing_subject_scans_every_operation_not_just_an_end() { - let patch = WorldPatch { - declarations: Vec::new(), - operations: vec![ - ComponentOp::Relocate { - subject: Ref::Draft(DraftHandle::new("wanderer")), - via: Ref::Draft(DraftHandle::new("path")), - }, - ComponentOp::SetPersonaMaterial { - subject: Ref::Existing(SubjectId::issue()), - values: Vec::new(), - voice: Statement::new("flat and even").unwrap(), - memories: Vec::new(), - reads: Vec::new(), - }, - ComponentOp::Relocate { - subject: Ref::Draft(DraftHandle::new("wanderer")), - via: Ref::Draft(DraftHandle::new("second-path")), - }, - ], - evidence: Vec::new(), - }; - // Op 0 and the last op (index 2) are both the harmless `Relocate`; - // only op 1, strictly in the middle, is the persona write. A - // `.take(1)` mutation sees only op 0; a `.rev().take(1)` mutation - // sees only op 2. Both would report `false` here. - assert!(patch.sets_persona_of_existing_subject()); - } - fn entity(handle: &str, label: &str, kind: EntityKind) -> Declaration { Declaration::Entity(EntityDeclaration { handle: DraftHandle::new(handle),