Status: 📝 PlannedDocumentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
Spec Reference: PF-43 Tenant Resource Quotas
Last Updated: 2026-03-14
Purpose
PF-43 provides tenant resource quotas and usage tracking (storage, API calls, users, custom objects, workflow executions). This document captures integration points: PF dependencies (PF-01, PF-04, PF-10, PF-11, PF-42), the event published on quota violation, and the platform layer consumed by clients and edge functions.PF Dependencies
| Dependency | Use | Type |
|---|---|---|
| PF-01 (Organizations) | Quotas and usage scoped by organization_id; org timezone for day/month reset | Data / tenant context |
| PF-04 (Audit Logging) | All quota configuration changes audited | Platform integration |
| PF-10 (Notifications) | Violation alerts when soft/hard limits exceeded | Event consumer |
| PF-11 (Document Management) | Storage quota tracking (total storage per org) | Platform / data |
| PF-42 (Rate Limiting) | API call quota tracking (when implemented); temporary interfaces until PF-42 lands | Event / platform |
Event Contract: pf_quota_violated
Event: pf_quota_violated (canonical identifier)Publisher: PF-43 (Quota enforcement framework)
Subscribers: PF-10 (Notifications), PF-48 (Security Event Monitoring — future)
Status: 📝 Planned
Purpose
Notify platform and organization admins when a quota soft or hard limit is exceeded so they can respond and adjust usage or quotas.Trigger Conditions
- After hard limit exceeded (operation blocked) or soft limit exceeded (warning; optional alert threshold).
Payload Schema
Canonical payload uses snake_case. Envelope fields (event_id, occurred_at, source, spec_version) are required for idempotency and routing. eventVersion is required and represents the contract version for this event so producers and consumers can evolve safely (e.g. QuotaViolatedEvent.eventVersion).
| Field | Type | Required | Description |
|---|---|---|---|
event_id | string (UUID) | Yes | Unique idempotency key; consumers MUST skip duplicates |
occurred_at | string | Yes | ISO 8601 when the event occurred |
source | string | Yes | Producer identifier (e.g. pf-43-quota-enforcement) |
spec_version | string | Yes | Event contract version (e.g. semver 1.0.0) for evolution |
event_version | string | Yes | Contract version for pf_quota_violated (semver or string); required for safe evolution |
organization_id | string (UUID) | Yes | Organization the quota applies to |
resource_type | string | Yes | One of: storage, api_calls, users, custom_objects, workflow_executions |
limit_type | string | Yes | soft or hard |
quota_value | number | Yes | Configured quota value |
actual_usage | number | Yes | Usage that caused the violation |
violated_at | string | Yes | ISO 8601 timestamp of the violation |
Consumer Actions
| Consumer | Action | Status |
|---|---|---|
| PF-10 | Send notification to platform/org admins per alert threshold and mute settings | 📝 |
| PF-48 | Ingest security event for monitoring/analytics | 📝 |
Platform Layer Usage
- Client:
useResourceQuotahook for client-side quota checks (calls backend/edge that usespf_check_resource_quota()). - Server/Edge:
pf_check_resource_quota(p_organization_id, p_resource_type, p_requested_amount)for server-side checks; writes topf_resource_usageandpf_quota_violationsvia SECURITY DEFINER. Implementations MUST pinsearch_pathin the function declaration (e.g.SET search_path = publicor a tighter scope such asSET search_path = admin, pg_catalog) so untrusted schemas cannot shadow objects; this is required for security review. - Storage usage: PF-11 integration for total storage per org (implementation detail in PF-43 tasks).
- API call usage: PF-42 integration when available; until then, temporary interfaces/stubs per spec Clarifications.
API Contracts
- Quota check (DB):
pf_check_resource_quota(organization_id, resource_type, requested_amount)returns(allowed, remaining, reset_at, quota_id, limit_type)—reset_atis timestamptz for quota window reset. - Frontend hook:
useResourceQuota({ organizationId, resourceType, requestedAmount? })returns state andcheckQuota(amount?); see spec API Design.