From cea7e1221be5a5b281c1b16161e40bd344f15bcd Mon Sep 17 00:00:00 2001 From: Luke Tornquist Date: Tue, 10 Nov 2026 07:58:51 -0800 Subject: [PATCH] buzz-db: require an active community on main's newer community UPDATEs Main added three communities UPDATEs after this PR was written (artifact_policy_modified_at in update_channel_on and soft_delete_on, and set_community_nip_fi_policy). Each runs under admission, so the runtime is already safe; the active predicate makes them satisfy the single-table guard policy like every other community writer. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Luke Tornquist Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> --- crates/buzz-db/src/store/channel.rs | 14 +++++++++----- crates/buzz-db/src/store/community_auth.rs | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/buzz-db/src/store/channel.rs b/crates/buzz-db/src/store/channel.rs index b868ed8b61..be0a89a354 100644 --- a/crates/buzz-db/src/store/channel.rs +++ b/crates/buzz-db/src/store/channel.rs @@ -1417,7 +1417,8 @@ async fn update_channel_on( } if policy_changed { sqlx::query( - "UPDATE communities SET artifact_policy_modified_at=clock_timestamp() WHERE id=$1", + "UPDATE communities SET artifact_policy_modified_at=clock_timestamp() \ + WHERE id=$1 AND deletion_state = 'active'", ) .bind(community_id.as_uuid()) .execute(tx.conn()) @@ -1838,10 +1839,13 @@ async fn soft_delete_on(w: &mut ChannelSettingsWriter<'_>) -> Result<()> { .bind(channel_id) .execute(w.tx.conn()) .await?; - sqlx::query("UPDATE communities SET artifact_policy_modified_at=clock_timestamp() WHERE id=$1") - .bind(community_id.as_uuid()) - .execute(w.tx.conn()) - .await?; + sqlx::query( + "UPDATE communities SET artifact_policy_modified_at=clock_timestamp() \ + WHERE id=$1 AND deletion_state = 'active'", + ) + .bind(community_id.as_uuid()) + .execute(w.tx.conn()) + .await?; Ok(()) } diff --git a/crates/buzz-db/src/store/community_auth.rs b/crates/buzz-db/src/store/community_auth.rs index 21cee02ad2..e423134b0f 100644 --- a/crates/buzz-db/src/store/community_auth.rs +++ b/crates/buzz-db/src/store/community_auth.rs @@ -412,7 +412,8 @@ impl Db { .await?; let generation = old_generation + 1; sqlx::query( - "UPDATE communities SET policy_generation = $2, requires_nip_fi = $3 WHERE id = $1", + "UPDATE communities SET policy_generation = $2, requires_nip_fi = $3 \ + WHERE id = $1 AND deletion_state = 'active'", ) .bind(request.community_id) .bind(generation)