From 63623fee55608b6761b16f0a536c185261e6a7dd Mon Sep 17 00:00:00 2001 From: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> Date: Tue, 29 Sep 2026 17:32:04 -0400 Subject: [PATCH] docs(relay): state limit_reached for both owner caps and pin the can_create contract Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> --- crates/buzz-db/src/store/community.rs | 4 ++-- crates/buzz-db/src/store/relay_members.rs | 6 +++--- crates/buzz-relay/src/api/operator.rs | 2 +- crates/buzz-relay/src/handlers/community_provisioning.rs | 5 +---- docs/operator-community-deletion.md | 5 ++++- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/buzz-db/src/store/community.rs b/crates/buzz-db/src/store/community.rs index 46db43b673..cf4597662f 100644 --- a/crates/buzz-db/src/store/community.rs +++ b/crates/buzz-db/src/store/community.rs @@ -44,7 +44,7 @@ pub enum CreateCommunityWithOwnerResult { Created(CreatedCommunityRecord), /// The host already belongs to another owner. HostExists, - /// The intended owner already owns the maximum number of communities. + /// The intended owner has reached the active or lifetime community limit. LimitReached, } @@ -68,7 +68,7 @@ pub struct OwnedCommunitiesPage { pub communities: Vec, /// De-duplicated live memberships and incomplete owner deletion reservations. pub quota_used: i64, - /// Configured maximum hosted communities for one owner. + /// Configured active limit only; the lifetime cap is reflected in `can_create`. pub quota_limit: i64, /// Whether the snapshot leaves room under both the active and lifetime caps. pub can_create: bool, diff --git a/crates/buzz-db/src/store/relay_members.rs b/crates/buzz-db/src/store/relay_members.rs index 8f2bcd191e..f3ce399dd7 100644 --- a/crates/buzz-db/src/store/relay_members.rs +++ b/crates/buzz-db/src/store/relay_members.rs @@ -544,7 +544,7 @@ pub enum TransferResult { LifecycleConflict, /// Durable deletion intent exists and wins over ownership mutation. DeletionPending, - /// The transferee already owns the maximum number of communities. + /// The transferee has reached the active or lifetime community limit. /// Enforced atomically inside the transfer transaction so concurrent /// transfers to the same recipient cannot both pass the limit. LimitReached, @@ -684,8 +684,8 @@ pub(crate) async fn owner_quota_in_transaction( /// 3. Locks the current owner row `FOR UPDATE` and verifies /// `expected_owner_pubkey` matches. This prevents a stale-owner race where /// a delayed/retried request overwrites a completed transfer. -/// 4. Enforces the [`MAX_COMMUNITIES_PER_OWNER`] limit on the transferee by -/// counting owned communities inside the same transaction. +/// 4. Enforces the transferee's active and lifetime limits +/// ([`OwnerQuota::admits`]) inside the same transaction. /// 5. Upserts `new_owner_pubkey` as `owner` (insert or promote). /// 6. Demotes every other owner in this community to `member` — **not** /// `admin`, per product decision: the former owner retains no management diff --git a/crates/buzz-relay/src/api/operator.rs b/crates/buzz-relay/src/api/operator.rs index a2dcaeed93..52db37c06c 100644 --- a/crates/buzz-relay/src/api/operator.rs +++ b/crates/buzz-relay/src/api/operator.rs @@ -722,7 +722,7 @@ pub async fn transfer_community( buzz_db::relay_members::TransferResult::LimitReached => { return Err(api_error( StatusCode::CONFLICT, - "limit_reached: transferee already owns the maximum number of communities", + "limit_reached: transferee has reached the community limit", )); } }; diff --git a/crates/buzz-relay/src/handlers/community_provisioning.rs b/crates/buzz-relay/src/handlers/community_provisioning.rs index 1b13e6d921..e8a5ee90d1 100644 --- a/crates/buzz-relay/src/handlers/community_provisioning.rs +++ b/crates/buzz-relay/src/handlers/community_provisioning.rs @@ -287,10 +287,7 @@ pub async fn provision_community( return Err("community already exists".to_string()); } buzz_db::CreateCommunityWithOwnerResult::LimitReached => { - return Err( - "limit_reached: owner already owns the maximum number of communities" - .to_string(), - ); + return Err("limit_reached: owner has reached the community limit".to_string()); } }; diff --git a/docs/operator-community-deletion.md b/docs/operator-community-deletion.md index 0b2c6dbe5c..d54093d991 100644 --- a/docs/operator-community-deletion.md +++ b/docs/operator-community-deletion.md @@ -172,7 +172,10 @@ The relay enforces two per-owner caps on create and on transfer-in, both as and count only through its live membership. Owner-list responses carry `quota_used` (active), `quota_limit` (active), and -`can_create` (both caps). The projection is advisory: clients may use it for +`can_create` (both caps). `can_create: false` is the only signal a client needs: +show a generic community-limit message and do not derive a reason from the +counts, because an owner at the lifetime cap can have `quota_used` below +`quota_limit`. The projection is advisory: clients may use it for UX, but the relay's `limit_reached` is authoritative, and quota changes have no deployment order. Keep owner deletion off until this relay and the drain executor are live; on rollback, turn deletion off before rolling back the relay.