From 19d514dc93dcf536751a178cf73db271c7424122 Mon Sep 17 00:00:00 2001 From: soul Date: Fri, 20 Nov 2026 15:04:32 +0100 Subject: [PATCH] aetherlight: releasing a dependency removes the pressure it raised Release deleted the dependency row only, so a pressed dependency's pressure row outlived it and verify_state_shape refused the world at open (export then open failed CorruptJournal). The Release arm now clears the dependency's pressure through set_pressure, the one pressure writer. Pre-existing at 609b3ba5e. Co-Authored-By: Claude Sonnet 5.5 --- native/aetherlight/src/golden_tests.rs | 48 ++++++++++++++++++++++++++ native/aetherlight/src/lib.rs | 3 ++ 2 files changed, 51 insertions(+) diff --git a/native/aetherlight/src/golden_tests.rs b/native/aetherlight/src/golden_tests.rs index a6182b5f0..d0f242ce3 100644 --- a/native/aetherlight/src/golden_tests.rs +++ b/native/aetherlight/src/golden_tests.rs @@ -1518,3 +1518,51 @@ fn a_view_read_with_an_open_log_is_refused() { kernel.state.positions.remove(&people[3]); crate::clock::derive_motion(&kernel.state, FictionalMinutes(1)); } + +/// A dependency's pressure ends with the dependency: bind to a resource the +/// subject does not hold, let a tick press it, release it, and the row is gone +/// and the world still reopens from its export. +#[test] +fn releasing_a_dependency_removes_the_pressure_it_raised() { + use crate::patch::DependencyRef; + use crate::{DependencyTarget, PressureSource}; + let (mut kernel, people, _) = clockwork_world(20); + let grain_1 = *kernel + .state + .entities + .iter() + .find(|(_, record)| record.label == "Grain 1") + .expect("a declared resource") + .0; + let target = DependencyTarget::Resource(grain_1); + let pressed = PressureSource::Dependency(target); + let submit = |kernel: &mut WorldKernel, body| { + let envelope = clockwork_envelope(kernel, body); + kernel.submit(envelope, &AuthenticatedCaller::verified_play()).expect("the command lands"); + }; + submit( + &mut kernel, + operations(vec![ComponentOp::Bind { + subject: Ref::Existing(people[6]), + target: DependencyRef::Resource(Ref::Existing(grain_1)), + }]), + ); + submit(&mut kernel, tick_body(1)); + assert!( + kernel.state.pressures.get(&people[6]).is_some_and(|held| held.contains_key(&pressed)), + "the tick pressed the failing dependency" + ); + submit( + &mut kernel, + operations(vec![ComponentOp::Release { + subject: Ref::Existing(people[6]), + target: DependencyRef::Resource(Ref::Existing(grain_1)), + }]), + ); + assert!( + kernel.state.pressures.get(&people[6]).is_none_or(|held| !held.contains_key(&pressed)), + "the released dependency's pressure row stayed" + ); + let reopened = WorldKernel::open(&kernel.export().unwrap()).expect("the world reopens"); + assert_eq!(reopened.state, kernel.state); +} diff --git a/native/aetherlight/src/lib.rs b/native/aetherlight/src/lib.rs index 9f5ebb20c..a50c58a79 100644 --- a/native/aetherlight/src/lib.rs +++ b/native/aetherlight/src/lib.rs @@ -2006,6 +2006,9 @@ fn apply_operation( if empty { state.dependencies.remove(subject); } + // The pressure a failing dependency raised is that dependency's + // own: it ends with it, or the world fails its shape check at open. + set_pressure(state, *subject, PressureSource::Dependency(*target), 0); } } ResolvedOp::GrantAuthority { holder, grant }