circle_feed_state
Overview
The circle_feed_state table extends the slow-feed pacing system to individual circles. Each row tracks when a user last checked a specific circle's feed and their current batch size. Rows are automatically created when a user joins a circle and deleted when they leave.
Relevant Invariants
- Invariant #12: "Slowness Is Baked In" -- Circle-level pacing prevents binge reading within any single circle
Schema
-- From 20260131_circle_feed_state.sql
CREATE TABLE circle_feed_state (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
circle_id UUID NOT NULL REFERENCES circles(id) ON DELETE CASCADE,
last_checked_at TIMESTAMPTZ DEFAULT NOW(),
current_batch_size INTEGER DEFAULT 5,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW(),
UNIQUE(user_id, circle_id)
);
Columns
| Column | Type | Nullable | Default | Description |
|---|---|---|---|---|
id | uuid | No | gen_random_uuid() | Primary key |
user_id | uuid | No | -- | User whose state this tracks |
circle_id | uuid | No | -- | Circle this state applies to |
last_checked_at | timestamptz | No | NOW() | When user last viewed this circle feed |
current_batch_size | integer | No | 5 | Number of posts to show in current batch |
created_at | timestamptz | No | NOW() | Row creation timestamp |
updated_at | timestamptz | No | NOW() | Last update timestamp |
RLS Policies
-- SELECT/UPDATE: Users can manage their own circle feed state
CREATE POLICY "Users can manage own circle feed state"
ON circle_feed_state FOR ALL
USING (auth.uid() = user_id);
Triggers
-- Auto-create feed state when user joins a circle
CREATE TRIGGER create_circle_feed_state_on_join
AFTER INSERT ON circle_members
FOR EACH ROW EXECUTE FUNCTION create_circle_feed_state();
-- Auto-delete feed state when user leaves a circle
CREATE TRIGGER delete_circle_feed_state_on_leave
AFTER DELETE ON circle_members
FOR EACH ROW EXECUTE FUNCTION delete_circle_feed_state();
Related
- circles -- Parent circle
- circle_members -- Triggers from membership changes
- user_feed_state -- Global feed pacing equivalent
Last updated: 2026-02-07