From 3c2bdf3a7c98b20315b1f6ef4c0d6f52348dbbe2 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 22 Sep 2026 16:36:12 +0200 Subject: [PATCH] One owner for the retired set and the exercise revision (PA.f82) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The resolver's retired set in patch.rs seeded itself with its own `matches!(assignment, ControllerAssignment::Retired)`, a second reading of the same predicate the kernel's `is_retired` already owns. Made `is_retired` `pub(crate)` and had the resolver call it (over `controller_assignments.keys()`, then `Key::Existing(scope.subject_id)`) instead of matching the assignment enum itself, so "is this subject retired" has exactly one reader — the kernel's own statement of retirement, the one audience derivation and preconditions already trust. The exercise revision had two independent computations of the same `state.revision + 1` arithmetic (action.rs's `exercise`, written out inline, and the kernel's own `resolution_revision`), and `apply_effect`'s `DecisionExercised` arm then called `resolution_revision` a second time per invocation even though `exercise` had already produced the identical value into `event.revision` moments earlier (and the arm had just proved `derived == *event`, so `event.revision` is provably that same value). Collapsed to one arithmetic owner — `exercise` now calls `super::resolution_revision(state)` instead of duplicating the `+1` inline — and cut the redundant call site: `DecisionExercised` now reads `event.revision` for `apply_operations`'s `resolves_to` rather than recomputing it. Mutation: `is_retired` forced to always return `false`. Both the kernel's own retirement tests (`tests::a_retired_institution_lends_no_authority_to_ its_office_holder`, 12 of the `clock_tests::a_retired_*`/`retiring_*` cases) and the resolver's own test (`patch::tests::a_grant_after_retiring_the_lending_institution_is_admitted`) fail together — 14 failures total — which is the shared-ownership proof; restored after confirming. PA.f48's and PA.f49's existing tests stay green (34 retirement-shaped tests including both PA.f48 resolver tests; the two PA.f49 `acquired_at`-revision tests). Full lib suite: 620 passed, 0 failed, 1 ignored. Dungeon bin suite: 63 passed, 0 failed. Co-Authored-By: Claude Sonnet 5 --- crates/ghostlight/src/action.rs | 5 +---- crates/ghostlight/src/lib.rs | 8 +++++--- crates/ghostlight/src/patch.rs | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) 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