Skip to content

feat(relay): make per-owner community limit configurable via BUZZ_MAX_COMMUNITIES_PER_OWNER#2599

Merged
tlongwell-block merged 1 commit into
block:mainfrom
leesalminen:feat/configurable-owner-community-limit
Jul 25, 2026
Merged

feat(relay): make per-owner community limit configurable via BUZZ_MAX_COMMUNITIES_PER_OWNER#2599
tlongwell-block merged 1 commit into
block:mainfrom
leesalminen:feat/configurable-owner-community-limit

Conversation

@leesalminen

@leesalminen leesalminen commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Closes #2600

Summary

Self-hosted multi-tenant deployments (one relay serving many communities via host-based tenancy) routinely need more than three communities owned by the same operator identity. MAX_COMMUNITIES_PER_OWNER is currently a hardcoded const, and hitting it surfaces as a limit_reached 409 from POST /operator/communities — which provisioning UIs tend to mislabel (mine reported it as "subdomain already taken").

This makes the limit configurable per deployment:

  • New env var BUZZ_MAX_COMMUNITIES_PER_OWNER — read once per process, must parse as a positive integer; missing/invalid/non-positive values fall back to the existing default of 3, so current deployments are unaffected.
  • Enforcement locations are unchanged and stay in the authoritative relay-layer checks: community provisioning (create_community_with_owner) and ownership transfer (inside the advisory-lock transaction).
  • Parse/fallback rules are extracted into a pure helper (effective_owner_limit) with unit tests, keeping the cached getter trivial.

Test plan

  • cargo test -p buzz-db --lib — new owner_limit_* tests cover default, invalid, non-positive, and positive-override cases. (Pre-existing unrelated failure on clean main: replica_fence::tests::fence_starts_closed_and_opens_on_advance, tracked in test(buzz-db): replica_fence unit test fails on Linux due to sub-microsecond Utc::now() precision #2369.)
  • cargo clippy -p buzz-db --all-targets and cargo fmt clean.
  • Deployed on my multi-tenant relay (vibecode.casa) with BUZZ_MAX_COMMUNITIES_PER_OWNER=100: provisioning a 4th community for the same owner succeeds; without the var the stock limit of 3 still applies.

🤖 Generated with Claude Code

Multi-tenant deployments (one relay serving many communities behind
host-based tenancy) routinely need more than three communities per
operator identity, but MAX_COMMUNITIES_PER_OWNER is a hardcoded const.
The provisioning surface then rejects new communities with
limit_reached, which downstream UIs tend to surface as a confusing
"subdomain already taken".

Introduce BUZZ_MAX_COMMUNITIES_PER_OWNER: read once per process, must
be a positive integer, anything else falls back to the stock default
of 3 so existing deployments are unaffected. Enforcement stays in the
authoritative relay-layer checks (provision + transfer), unchanged.

The parse/fallback rules live in a pure helper with unit tests; the
cached getter stays trivial.

Signed-off-by: Lee Salminen <leesalminen@gmail.com>
@leesalminen
leesalminen force-pushed the feat/configurable-owner-community-limit branch from c5d8295 to da03945 Compare July 25, 2026 11:46
@tlongwell-block
tlongwell-block enabled auto-merge (squash) July 25, 2026 13:22
@tlongwell-block

Copy link
Copy Markdown
Collaborator

Thanks for the contribution, @leesalminen 👋

@tlongwell-block
tlongwell-block merged commit 2a051a4 into block:main Jul 25, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Per-owner community limit is hardcoded (MAX_COMMUNITIES_PER_OWNER = 3), blocking multi-tenant operators

2 participants