Skip to main content

0040 Prefix-grouped superadmin schema contract

This document is the checked-in inventory for the source-defined database contracts behind /superadmin/. The browser reads bounded RPC results and does not receive raw table topology or unrestricted rows.

Screen delivery catalogue

The route catalogue below is the delivery checklist for the current Superadmin surface. super_operations_snapshot is the bounded read model for operational desks; platform-management-views is the existing typed authority read model for Users. Every db-function mutation is issued through GWLink to a generated RPC wrapper and then to a security-definer database function. Read-only screens are intentionally marked as such rather than receiving an invented client-side write.

StatusScreenPathRead contractMutation contractE2E contract
[ ]Overview/superadminsuper_operations_snapshotread-onlyroute-read
[ ]Users/superadmin/usersplatform-management-viewsdb-functionroute-read-and-step-up
[ ]Audit/superadmin/auditsuper_operations_snapshotread-onlyroute-read
[ ]User operations/superadmin/user-operationssuper_operations_snapshotread-onlyroute-read
[ ]Organisations/superadmin/organisationssuper_operations_snapshotread-onlyroute-read
[ ]Billing/superadmin/billingsuper_operations_snapshotdb-functionroute-read
[ ]System/superadmin/systemsuper_operations_snapshotdb-functionroute-read
[ ]Catalog/superadmin/catalogsuper_operations_snapshotdb-functionroute-read-and-step-up
[ ]Inventory/superadmin/inventorysuper_operations_snapshotdb-functionroute-read
[ ]Market/superadmin/marketsuper_operations_snapshotdb-functionroute-read
[ ]Integrations/superadmin/integrationssuper_operations_snapshotdb-functionroute-read
[ ]Content/superadmin/contentsuper_operations_snapshotdb-functionroute-read
[ ]Finance/superadmin/financesuper_operations_snapshotdb-functionroute-read
[ ]Analytics/superadmin/analyticssuper_operations_snapshotread-onlyroute-read
[ ]Compliance/superadmin/compliancesuper_operations_snapshotdb-functionroute-read
[ ]Support/superadmin/supportsuper_operations_snapshotdb-functionroute-read
[ ]Releases/superadmin/releasessuper_operations_snapshotdb-functionroute-read
[ ]Access/superadmin/accesssuper_operations_snapshotread-onlyroute-read
[ ]Sessions/superadmin/sessionssuper_operations_snapshotread-onlyroute-read
[ ]Health/superadmin/healthsuper_operations_snapshotdb-functionroute-read
[ ]Approvals/superadmin/approvalssuper_operations_snapshotdb-functionroute-read
[ ]Settings/superadmin/settingssuper_operations_snapshotdb-functionroute-read
[ ]Platform settings/superadmin/settings/platformsuper_operations_snapshotdb-functionroute-read
[ ]Security settings/superadmin/settings/securitysuper_operations_snapshotread-onlyroute-read
[ ]Notification settings/superadmin/settings/notificationssuper_operations_snapshotdb-functionroute-read
[ ]Audit settings/superadmin/settings/auditsuper_operations_snapshotread-onlyroute-read
[ ]Marketing/superadmin/marketingsuper_operations_snapshotdb-functionroute-read
[ ]Audiences/superadmin/marketing/audiencessuper_operations_snapshotread-onlyroute-read
[ ]Invites/superadmin/marketing/invitessuper_operations_snapshotdb-functionroute-read
[ ]Campaigns/superadmin/marketing/campaignssuper_operations_snapshotdb-functionroute-read
[ ]Templates/superadmin/marketing/templatessuper_operations_snapshotread-onlyroute-read
[ ]Delivery/superadmin/marketing/deliverysuper_operations_snapshotdb-functionroute-read
[ ]Moderation/superadmin/moderationsuper_operations_snapshotdb-functionroute-read
[ ]Suspicious activity/superadmin/suspicious-activitysuper_operations_snapshotdb-functionroute-read

The catalogue is checked off only after the generated contract gates and the browser E2E run pass; [ ] is therefore a live work item, not a design-only claim.

Prefix inventory

Standard class columns, timestamps, revision/audit columns supplied by an extension, and generated primary-key details are omitted from the field notes. The source path is authoritative; SQL, RPC, and XTalk files are generated from it.

BRD — billing

TypeClassOwner/referenceLifecycleSource
BrandBillingInvoice1D/entryBillingAccountprovider-neutral invoice summary; status and payment totals may be reconciledbackend/src/gwdb/common/type_brand_billing.clj
BrandBillingPayment1D/logBillingAccount; typed BrandBillingInvoice referenceappend-only payment event; corrections are compensating eventsbackend/src/gwdb/common/type_brand_billing.clj

The existing BillingAccount, provider-price, subscription, and external-event types remain canonical. No general-ledger table is introduced; authoritative money movement remains in the existing wallet/asset transaction sources.

CNT — content controls

TypeClassOwner/referenceLifecycleSource
ContentControl2D/basetyped target (class_table, class_context, class_ref); actor is a typed User referencereview, evidence, resolution, and retirementbackend/src/gwdb/common/type_content_control.clj

The proposed 2D/entry shape was not used because this generator's 2D/entry contract supplies table/context but no typed reference column. 2D/base is the reusable extension that preserves the complete typed attachment.

CMP — compliance

TypeClassOwner/referenceLifecycleSource
ComplianceRecord2D/basetyped subject (class_table, class_context, class_ref); owner is a typed User referenceprivacy, consent, legal hold, completion, release, expirybackend/src/gwdb/common/type_compliance_record.clj

Compliance uses the same 2D/base attachment rule as ContentControl; it does not create separate consent, privacy, or legal-hold tables.

FIN — settlement and exceptions

TypeClassOwner/referenceLifecycleSource
FinanceSettlement1D/entryexisting Topic/marketqueued, processing, succeeded, failed, cancelledbackend/src/gwdb/common/type_finance_settlement.clj
FinanceException1D/logFinanceSettlement; optional reference type/idappend-only operational exception; resolution is a compensating statebackend/src/gwdb/common/type_finance_settlement.clj

Settlement rows are market-scoped and unique per market. Exception reference type/id participates in the settlement-scoped idempotency key when supplied. The ledger/read model composes existing AssetTx, stake, wallet, and billing sources rather than duplicating a general ledger.

INT — integrations

TypeClassOwner/referenceLifecycleSource
IntegrationProvider1D/basetyped Global, Brand, or User owner through (class_table, class_ref)pending, active, paused, degraded, revoked; health fields are updated in placebackend/src/gwdb/common/type_integration.clj
IntegrationEvent1D/logIntegrationProviderreceived, processing, processed, ignored, failed, replaying; retry/replay counters are retainedbackend/src/gwdb/common/type_integration.clj

IntegrationEvent is idempotent on provider plus provider event id. Payloads are represented by target metadata, hash, response/error metadata, and retry state; raw provider payloads and credentials are not part of the browser contract.

MCP — connections and approvals

TypeClassOwner/referenceLifecycleSource
McpConnection2D/basetyped owner (class_table, class_context, class_ref); creator is a typed User referencepending, active, suspended, revokedbackend/src/gwdb/common/type_mcp.clj
McpApproval2D/logMcpConnectionrequested, approved, rejected, expired, cancelled; append-only decisionsbackend/src/gwdb/common/type_mcp.clj

The proposed 0D/entry connection was changed to 2D/base so connection ownership remains typed and cannot degrade into an unconstrained owner-type/id pair. Op, Audit/AuditLog, and Activity/ActivityLog remain the durable operation/audit foundations; no MCP-specific audit table is added.

MKT — audiences and campaigns

TypeClassOwner/referenceLifecycleSource
MarketingAudience1D/basetyped owner (class_table, class_ref); creator is a typed User referencesaved audience definition; recipient selection remains bounded metadatabackend/src/gwdb/common/type_marketing.clj
MarketingCampaign1D/entryMarketingAudience; typed EmailTemplate referencedraft, scheduled, running, paused, completed, cancelled, expiredbackend/src/gwdb/common/type_marketing.clj

Campaign delivery reuses EmailTemplate, EmailDelivery, and workflow types. There is no MarketingDelivery or per-recipient fan-out table in this slice; MarketingAudienceRecipient remains a measured future extension only.

SAF — safety and moderation

TypeClassOwner/referenceLifecycleSource
SafetyCase0D/entryexplicit typed target type/id; reporter and assignee are typed User referencesopen, triage, investigating, actioned, resolved, dismissedbackend/src/gwdb/common/type_safety.clj
SafetyCaseEvent2D/logSafetyCase; actor is a typed User referenceappend-only evidence, action, or note historybackend/src/gwdb/common/type_safety.clj

Moderation and suspicious activity share one case lifecycle. Existing Lock/LockLog types remain the lock/unlock foundation; no split moderation, suspicious-activity, evidence, or action tables are added.

SUP — support

TypeClassOwner/referenceLifecycleSource
SupportCase0D/entryexplicit typed subject type/id; owner is a typed User referenceopen, pending, in-progress, waiting, resolved, closedbackend/src/gwdb/common/type_support.clj

Operator notes and activity reuse ActivityLog. A separate support-event table is not needed until retention, authorization, or query scale proves a different lifecycle.

SYS — system catalog and platform approvals

TypeClassOwner/referenceLifecycleSource
SystemCatalogItem0D/entrycanonical system-owned catalog itemdraft, active, retiredbackend/src/gwdb/common/type_system_catalog.clj
SystemCatalogPlan1D/entrySystemCatalogItemversioned plan with effective start/end and draft/active/retired statebackend/src/gwdb/common/type_system_catalog.clj
SystemPlatformApproval1D/entrytarget User; request/decision actors are typed User referencesrequested, approved, rejected, expired, cancelledbackend/src/gwdb/common/type_system_catalog.clj

The active source generator has no CatalogItem/CatalogPlan definitions. The old names survive only in stale, unassembled SQL and an older superadmin schema note; SystemCatalogItem/SystemCatalogPlan are the one canonical generated pair. Existing legacy product consumers must be migrated before that stale artifact can be reactivated. This implementation does not create a second active catalog pair.

SystemPlatformApproval is a current approval entry unique per target user; the shared Op and audit/activity foundations retain the operation history.

Shared access and generation contract

  • New operational tables are source-defined and generated into main/sql/files/src/common; generated SQL, RPC, and XTalk files are not hand-authored.
  • Sensitive operational tables use hidden access and service-role grants; they do not grant authenticated table reads. Secrets, credentials, tokens, raw event payloads, and recipient sets are never returned by the browser read model.
  • super_operations_snapshot is a bounded, security-definer RPC. Its source authenticates the actor at platform-admin level and returns counts, a generation time, and named redacted projections capped at 25 rows per dataset; it never accepts arbitrary table names or returns secrets, credentials, tokens, raw payloads, or recipient sets. Loading this read model does not require a recent MFA step-up; mutation RPCs retain the reauthentication requirement.
  • Typed foreign keys, owner/status/time indexes, provider-event idempotency uniqueness, and partitioning for high-volume logs are part of the source definitions.
  • The initial target is 18 new or newly activated physical types. Existing organisation/brand identity, workflow, audit/activity, lock, email, economy, wallet, asset, and billing foundations are reused.