diff --git a/crates/ghostlight/src/action.rs b/crates/ghostlight/src/action.rs index d21e258..bbfddae 100644 --- a/crates/ghostlight/src/action.rs +++ b/crates/ghostlight/src/action.rs @@ -240,10 +240,7 @@ pub(super) fn exercise( fact }); - let revision = state - .revision - .checked_add(1) - .ok_or_else(|| KernelError::Serialization("world revision overflow".into()))?; + let revision = super::resolution_revision(state)?; Ok(DecisionEvent { id: EventId::for_command(command_id), revision, diff --git a/crates/ghostlight/src/lib.rs b/crates/ghostlight/src/lib.rs index f110f6e..aa15adc 100644 --- a/crates/ghostlight/src/lib.rs +++ b/crates/ghostlight/src/lib.rs @@ -3280,7 +3280,7 @@ fn channel_referents_exist(state: &WorldState, record: &ChannelRecord) -> bool { /// of retirement read by anything downstream of it (audience derivation, /// preconditions, resolvers): a mirror's assignment is `ExternallyControlled` /// and is never retired by this check, only an actual `Retire` sets it. -fn is_retired(state: &WorldState, subject_id: SubjectId) -> bool { +pub(crate) fn is_retired(state: &WorldState, subject_id: SubjectId) -> bool { matches!( state.controller_assignments.get(&DecisionScope { subject_id }), Some(ControllerAssignment::Retired) @@ -5291,8 +5291,10 @@ fn apply_effect( } state.events.push(event.clone()); if !event.effects.is_empty() { - let resolves_to = resolution_revision(state)?; - apply_operations(state, &event.effects, &[], resolves_to)?; + // `derived != *event` above already proved `event.revision` is + // exactly what `resolution_revision(state)` would compute right + // now; read it back rather than computing it a second time. + apply_operations(state, &event.effects, &[], event.revision)?; } state .last_opportunity_at diff --git a/crates/ghostlight/src/patch.rs b/crates/ghostlight/src/patch.rs index ab0377f..0e57125 100644 --- a/crates/ghostlight/src/patch.rs +++ b/crates/ghostlight/src/patch.rs @@ -3296,9 +3296,9 @@ pub(super) fn resolve_patch( // extended below for a subject this same patch declares. let mut retired: BTreeSet> = state .controller_assignments - .iter() - .filter(|(_, assignment)| matches!(assignment, ControllerAssignment::Retired)) - .map(|(scope, _)| Key::Existing(scope.subject_id)) + .keys() + .filter(|scope| super::is_retired(state, scope.subject_id)) + .map(|scope| Key::Existing(scope.subject_id)) .collect(); let mut mirrors: BTreeSet> = state .controller_assignments