Phase 10: Subscription Model¶
Document Type: Technical Specification
Phase: 10 - Real-Time Subscriptions
Status: Active
Subscription Types¶
Database Changes¶
Subscribe to INSERT/UPDATE/DELETE on collections:
{
"type": "subscribe",
"topic": "realtime:public:posts",
"event": "*",
"filter": "author_id=eq.123"
}
Broadcast¶
Subscribe to user-defined channels:
Presence¶
Subscribe to user presence:
Subscription Lifecycle¶
┌─────────┐ subscribe ┌────────────┐
│ NONE │ ───────────────► │ PENDING │
└─────────┘ └────────────┘
│
│ ack
▼
┌────────────┐
│ ACTIVE │
└────────────┘
│
│ unsubscribe / disconnect
▼
┌────────────┐
│ REMOVED │
└────────────┘
Subscription Filtering¶
Collection Filters¶
PostgREST-style syntax:
author_id=eq.123- Equalsstatus=in.(draft,published)- In listcreated_at=gt.2026-01-01- Greater than
RLS Filtering¶
Before delivery, each event is checked against RLS:
- Extract user_id from subscription context
- Check if user can access the record
- Only deliver if RLS passes