lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README

commit 724e122338cb3080616c7096cd6cbb758507c93e
parent 325d9c7264f9257d1936ab0ae703da7517074bd0
Author: triesap <tyson@radroots.org>
Date:   Tue, 28 Jul 2026 08:08:13 +0000

event_store: cover protocol write lock authority

- exercise successful singleton write-lock acquisition
- remove the lock only through trusted test-only corruption
- reject missing write-lock authority with the typed hook error
- preserve production protocol reconciliation behavior

Diffstat:
Mcrates/event_store/src/store/protocol_reconciliation_v1.rs | 30++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+), 0 deletions(-)

diff --git a/crates/event_store/src/store/protocol_reconciliation_v1.rs b/crates/event_store/src/store/protocol_reconciliation_v1.rs @@ -792,4 +792,34 @@ mod tests { }) if reason == "fixture" )); } + + #[tokio::test] + async fn protocol_write_lock_requires_singleton_authority() { + let store = crate::RadrootsEventStore::open_memory() + .await + .expect("open store"); + let mut transaction = store.pool().begin().await.expect("transaction"); + acquire_event_store_write_lock(&mut transaction) + .await + .expect("singleton write lock"); + transaction.rollback().await.expect("rollback"); + + sqlx::query("DROP TRIGGER radroots_event_store_write_lock_delete_guard") + .execute(store.pool()) + .await + .expect("trusted write-lock guard removal"); + sqlx::query("DELETE FROM radroots_event_store_write_lock") + .execute(store.pool()) + .await + .expect("trusted write-lock corruption"); + + let mut transaction = store.pool().begin().await.expect("transaction"); + assert!(matches!( + acquire_event_store_write_lock(&mut transaction).await, + Err(RadrootsEventStoreError::MigrationHookStateDrift { + hook_id: "nip09_reconciliation_v1", + reason, + }) if reason == "event-store write lock authority is missing" + )); + } }