feat: per-organization limits set by platform admins
ci / image (pull_request) Successful in 4m25s
ci / build (pull_request) Successful in 8m15s
ci / test (pull_request) Successful in 8m51s
ci / lint (pull_request) Successful in 12m8s

Admins set default limits for monitors (all types), status pages and
regions per monitor, whether an organization's own checker regions count
towards the region limit, and how many organizations an account may own,
and override them per organization or account. Defaults are not copied:
changing one applies at once to everyone without an override. 0 means
unlimited; self-hosted defaults are unlimited, the cloud allows three
organizations per account.

Creations count under a per-organization advisory lock, so concurrent
requests cannot overshoot. A lowered limit keeps everything that exists:
monitors already beyond the region limit stay editable but may not grow.
Organizations see their usage in their settings and GET /org/limits;
the admin panel lists organizations with owner, usage and limits next
to their suspend and delete actions. Empty numeric form fields marked
data-nullable are sent as null.

Refs #111

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 21:06:45 +01:00
1 parent 90e74d091a
commit e4ce619fbe
26 files changed
+2386 -82

No files matched your search

+10
View File
@@ -19,6 +19,9 @@ type Querier interface {
AddMonitorAlertGroup(ctx context.Context, arg AddMonitorAlertGroupParams) (int64, error)
AddMonitorRegion(ctx context.Context, arg AddMonitorRegionParams) error
AddStatusPageMonitor(ctx context.Context, arg AddStatusPageMonitorParams) error
// System scope: organizations with their usage, limit overrides and owner,
// newest first, matching search in name, slug or owner email.
AdminListOrgs(ctx context.Context, arg AdminListOrgsParams) ([]AdminListOrgsRow, error)
// System scope: public status pages and suspended ones, with their
// organization and its owner, newest first, matching search in title,
// slug, domain, organization or owner email.
@@ -42,7 +45,9 @@ type Querier interface {
ClearMaintenanceTargets(ctx context.Context, windowID uuid.UUID) error
ClearStatusPageGroups(ctx context.Context, pageID uuid.UUID) error
ClearStatusPageMonitors(ctx context.Context, pageID uuid.UUID) error
CountMonitors(ctx context.Context, orgID uuid.UUID) (int64, error)
CountRoleAssignments(ctx context.Context, roleID uuid.UUID) (int64, error)
CountStatusPages(ctx context.Context, orgID uuid.UUID) (int64, error)
CountUnusedRecoveryCodes(ctx context.Context, userID uuid.UUID) (int64, error)
CreateAPIToken(ctx context.Context, arg CreateAPITokenParams) (ApiToken, error)
CreateAgent(ctx context.Context, arg CreateAgentParams) (Agent, error)
@@ -193,6 +198,9 @@ type Querier interface {
// Row-level security limits this to platform regions and the scope's org;
// the org's own regions come first.
ListVisibleRegions(ctx context.Context) ([]Region, error)
// Serializes creations counted against org's limits until the transaction
// ends.
LockOrgUsage(ctx context.Context, orgID uuid.UUID) error
// System scope: windows covering any of the monitors, directly or through
// their group or one of its ancestors.
MaintenanceForMonitors(ctx context.Context, ids []uuid.UUID) ([]MaintenanceForMonitorsRow, error)
@@ -263,6 +271,7 @@ type Querier interface {
ScrubAuditEmail(ctx context.Context, email string) error
SetAgentAllowPrivate(ctx context.Context, arg SetAgentAllowPrivateParams) (int64, error)
SetOrgDisabledCheckTypes(ctx context.Context, arg SetOrgDisabledCheckTypesParams) error
SetOrgLimits(ctx context.Context, arg SetOrgLimitsParams) (SetOrgLimitsRow, error)
SetPasswordHash(ctx context.Context, arg SetPasswordHashParams) error
SetPlatformSetting(ctx context.Context, arg SetPlatformSettingParams) error
// Changing the domain drops a previous verification.
@@ -270,6 +279,7 @@ type Querier interface {
SetStatusPageMonitorGroup(ctx context.Context, arg SetStatusPageMonitorGroupParams) error
SetUserAdmin(ctx context.Context, arg SetUserAdminParams) (int64, error)
SetUserLocale(ctx context.Context, arg SetUserLocaleParams) error
SetUserOrgLimit(ctx context.Context, arg SetUserOrgLimitParams) (SetUserOrgLimitRow, error)
// Other instances of the same agent seen in the last day.
SiblingInstances(ctx context.Context, agentID uuid.UUID) ([]SiblingInstancesRow, error)
StatusPageMonitors(ctx context.Context, pageID uuid.UUID) ([]StatusPageMonitorsRow, error)