Appearance
RPCs
Complete inventory of named PostgreSQL functions in public defined by the migration chain. All EXECUTE is granted to service_role only (public/anon/authenticated revoked, migration 016 lockdown). See RPC layer for the architecture.
Report & contact
| Function | Migration | Operation |
|---|---|---|
rpc_create_report(...) | 006/033 | Atomic report creation + timeline + event + initial evidence |
rpc_report_action(...) | 006→034 | Action state machine (validate/invalidate/investigate/contact_reporter/claim/conclude) under row lock |
rpc_add_note(...) | 006/033 | Note + timeline + event + updated_at |
rpc_add_evidence(...) | 006/033 | Evidence + timeline + event + updated_at |
rpc_contact_reply(...) | 006/033/034 | Agent message + timeline + event + bot-DM queue |
rpc_contact_respond(...) | 006/033 | Reporter message + timeline + event |
rpc_close_contact_thread(...) | 006/033/034 | Close state + timeline + event + closing-DM queue |
rpc_delete_report(...) | 034 | Pre-image + delete + forensic audit + report.deleted (one transaction) |
rpc_list_reports(...) | 007 | Server-side filter/sort/count/pagination |
Queue
| Function | Migration | Operation |
|---|---|---|
rpc_claim_action(p_is_supervisor) | 005/033 | Atomic oldest-action claim (SKIP LOCKED) + queue.action_claimed |
rpc_requeue_stale_actions(max_age, max_attempts) | 005/033 | Stale-processing recovery (requeue or fail past cap) + events |
rpc_complete_action(action_id, result, note) | 034 | Locked terminal completion + queue.action_completed/failed |
rpc_action_requeue(action_id) | 034 | Locked failed → pending + queue.action_requeued |
Punishments & discipline
| Function | Migration | Operation |
|---|---|---|
rpc_punishment_create(...) | 029/033 | ID generation (collision retry) + row + audit + punishment.issued + issue delivery |
rpc_punishment_update(...) | 029/033 | Whitelisted edit + before/after audit + punishment.updated |
rpc_punishment_revoke(...) | 029/033 | Locked revoke + audit + punishment.revoked + revoke delivery |
rpc_discipline_enqueue(...) | 030/033 | Enqueue helper + delivery.queued |
rpc_discipline_enqueue_user_lookup(...) | 031 | Profile-lookup enqueue (one outstanding per user) |
rpc_discipline_claim() | 030/033 | Atomic pickup with live punishment embed + delivery.claimed |
rpc_discipline_complete(...) | 030/033 | Locked outcome recording (success / paced retry / terminal) + delivery events |
rpc_discipline_requeue_stale(...) | 030/033 | Stale-processing recovery + delivery events |
Agents & admin
| Function | Migration | Operation |
|---|---|---|
rpc_admin_agent_update(...) | 028/034 | Single audited agent mutation (whitelist, Director/rank/self-edit guards, audit + event) |
rpc_agent_set_onboarding_fields(...) | 034 | Bot onboarding lane → the above (no rank, system identity) |
rpc_admin_access_list() | 009/013 | Allowlist read |
rpc_admin_access_grant(...) | 010 | Allowlist grant (Director, audited) |
rpc_admin_access_revoke(...) | 010 | Soft revoke (Director, audited) |
rpc_admin_access_remove(...) | 010 | Hard remove (Director, audited, Directors protected) |
rpc_admin_queue_requeue(...) / cancel(...) / sweep(...) | 010/018 | Queue maintenance (audited) |
rpc_admin_audit_list(...) | 010/013 | Paginated admin audit trail |
rpc_admin_report_correct(...) | 018 | Whitelisted report correction (Director, audited) |
rpc_admin_schema_status() | 010 | Migration + function inventory |
rpc_admin_schema_reload(...) | 010 | PostgREST reload NOTIFY (audited) |
rpc_admin_health() | 010/014 | Raw health metrics |
rpc_admin_health_record(...) | 015 | Incident-history transition |
rpc_admin_health_history(...) | 015 | Incident history read |
Events & audit
| Function | Migration | Operation |
|---|---|---|
rpc_write_event(...) | 033 | The single validated event write path |
admin_write_audit(...) | 009/033 | Forensic audit row + dual-written canonical event |
admin_audit_event_map(action, target) | 033 | Admin action → event taxonomy mapping |
rpc_audit_log(...) | 008/032 | Audit log search/pagination |
rpc_audit_log_v2(...) | 032/034 | Audit log v2 (event filter + actor-name resolution from discord_id/agent_id) |
Helper functions (non-RPC)
| Function | Purpose |
|---|---|
events_block_mutation() | Append-only trigger for events |
admin_audit_block_mutation() | Append-only trigger for admin_audit_log |
admin_health_block_mutation() | Append-only trigger for admin_health_history |
punishments_block_delete() | DELETE/TRUNCATE block for punishments |
admin_requester_is_director(...) | Live-rank Director check (012) |
admin_requester_can_manage_rank(...) | Rank-hierarchy check (018) |