Skip to main content

user_feed_state

Overview

The user_feed_state table tracks each user's feed consumption state. It records when they last checked their feed and their current feed mode preference. This supports the slow-feed pacing system that prevents infinite scrolling and content addiction.

Relevant Invariants

  • Invariant #2: "Calm Is the Default State" -- Feed state enables paced content delivery
  • Invariant #8: "Feed Is a View, Not a Goal" -- Feed mode and pacing prevent reward-loop behavior
  • Invariant #12: "Slowness Is Baked In" -- Batched loading and session-bounded views

Schema

-- Pre-existing table (inferred from frontend code)
CREATE TABLE user_feed_state (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
user_id UUID REFERENCES auth.users(id) NOT NULL UNIQUE,
last_checked_at TIMESTAMPTZ DEFAULT NOW(),
feed_mode TEXT DEFAULT 'calm',
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);

Columns

ColumnTypeNullableDefaultDescription
iduuidNouuid_generate_v4()Primary key
user_iduuidNo--User this state belongs to (unique)
last_checked_attimestamptzNoNOW()When user last viewed their feed
feed_modetextNo'calm'Current feed mode preference
created_attimestamptzNoNOW()Row creation timestamp
updated_attimestamptzNoNOW()Last update timestamp

RLS Policies

-- SELECT: Users can read their own feed state
CREATE POLICY "Users can view own feed state"
ON user_feed_state FOR SELECT
USING (auth.uid() = user_id);

-- INSERT/UPDATE: Users can manage their own feed state
CREATE POLICY "Users can upsert own feed state"
ON user_feed_state FOR ALL
USING (auth.uid() = user_id);

Last updated: 2026-02-07