From a02942f11589f16597f2ceb52d87c1c964e89da0 Mon Sep 17 00:00:00 2001 From: soul Date: Thu, 19 Nov 2026 23:35:15 +0100 Subject: [PATCH] Aetherlight AL2b-1: kill the two survivors (Acted commit-time gate, event revision order) Co-Authored-By: Claude Sonnet 5.5 --- native/aetherlight/src/journal.rs | 13 +++++++++ native/aetherlight/src/lib.rs | 45 +++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/native/aetherlight/src/journal.rs b/native/aetherlight/src/journal.rs index 9ec961c2e..d680b57f8 100644 --- a/native/aetherlight/src/journal.rs +++ b/native/aetherlight/src/journal.rs @@ -2343,6 +2343,12 @@ mod custody_tests { speak(first_grant(&active, actor), "The chain holds."), ) .unwrap(); + act( + &mut kernel, + actor, + speak(first_grant(&active, actor), "And again."), + ) + .unwrap(); let accepted = kernel.snapshot().unwrap(); let world_id = accepted.world_id; drop(kernel); @@ -2356,6 +2362,13 @@ mod custody_tests { matches!(verify_state_shape(&forged), Err(JournalError::Corrupt(_))), "an event naming no subject passed the shape check" ); + + let mut reordered = reopened.state.clone(); + reordered.events.swap(0, 1); + assert!( + matches!(verify_state_shape(&reordered), Err(JournalError::Corrupt(_))), + "events out of revision order passed the shape check" + ); } /// Absence is zero and one slot holds one pair, so a stored zero, an empty diff --git a/native/aetherlight/src/lib.rs b/native/aetherlight/src/lib.rs index 2b3850cb9..7fab23d87 100644 --- a/native/aetherlight/src/lib.rs +++ b/native/aetherlight/src/lib.rs @@ -12380,6 +12380,51 @@ mod clock_tests { assert_eq!(kernel.state.events.last().unwrap().actor, clockwork.reeve); } + /// The commit-time re-decision of an `Acted` effect is Play's, in Active: + /// the same honest effect is refused for the owner and in Draft. + #[test] + fn an_acted_effect_applies_only_for_play_in_active() { + let directory = tempfile::tempdir().unwrap(); + let (kernel, clockwork, _) = clock_kernel(directory.path(), "ActedGate"); + let invocation = DecisionInvocation { + affordance: clockwork.threaten, + bindings: vec![binding("target", Target::Subject(clockwork.farmer))], + proposed: vec![ProposedEffect { + slot: 0, + magnitude: Magnitude::None, + }], + speech: None, + display: None, + }; + let command_id = CommandId::new(); + let granted = + require_granted(&kernel.state, clockwork.reeve, invocation.affordance).unwrap(); + let event = + action::exercise(&kernel.state, command_id, clockwork.reeve, &granted, &invocation) + .unwrap(); + let effect = WorldEffect::Acted { invocation, event }; + + let mut candidate = kernel.state.clone(); + let error = apply_effect( + &mut candidate, + command_id, + &CallerId::Principal(owner()), + &effect, + ) + .unwrap_err(); + assert!(matches!(error, KernelError::Invariant(_)), "{error:?}"); + assert_eq!(candidate, kernel.state); + + let mut draft = kernel.state.clone(); + draft.phase = WorldPhase::Draft; + let error = apply_effect(&mut draft, command_id, &play_caller(), &effect).unwrap_err(); + assert!(matches!(error, KernelError::Invariant(_)), "{error:?}"); + + let mut honest = kernel.state.clone(); + apply_effect(&mut honest, command_id, &play_caller(), &effect).unwrap(); + assert_eq!(honest.events.len(), kernel.state.events.len() + 1); + } + /// There is no acting before activation. #[test] fn act_in_draft_is_wrong_phase() {