relay: count buzz/v1 unread forward from the read position

Count unread forward from each context's position, capped at 99 (advertised
as unread_cap). Thread read rows now mean membership: ingest writes them on
reply, mention, DM, or a reply to a thread you started, replacing the
parent lookup and giving unread_thread_count. Accounts start caught up at
the actor's first intent (personal_read_accounts.started_at); joining starts
a channel caught up. Drops the retention horizon, account, status fields,
latest_message_complete, threads.complete and context unknown.

Docs (docs/buzz-v1-read-state.md) not yet updated.

Signed-off-by: ART5 <a7397738d0f05003030d4487431db3096f2f48e09df21eb15f91f3a9aecf5f0c@buzz.block.builderlab.xyz>
Signed-off-by: hMB2 <0400eb0da32afbbf16cdd1dee6ffd243587e8f3d6a2823fe7dfa95d16b002b7d@buzz.block.builderlab.xyz>
This commit is contained in:
ART5
2026-10-06 17:07:45 -07:00
committed by hMB2
parent c96d707f6e
commit efe923445c
21 changed files with 1586 additions and 3201 deletions

View File

@@ -195,11 +195,15 @@ CREATE UNIQUE INDEX idx_users_okta ON users (community_id, okta_user_id)
-- Private accessory read progress. Never included in Nostr event queries.
-- A frontier is the relay arrival time (events.received_at) of the message a
-- context was read through; the unread cutoff alone is signed event time. An
-- empty root_id denotes a channel frontier.
-- context was read through, never signed event time. An empty root_id denotes
-- a channel frontier.
-- started_at is the actor's first read intent and the floor of every
-- position: until then nothing counts, and from then the actor starts caught
-- up. Ingest creates accounts for thread membership without starting them.
CREATE TABLE personal_read_accounts (
community_id UUID NOT NULL REFERENCES communities(id),
actor BYTEA NOT NULL CHECK (octet_length(actor) = 32),
started_at TIMESTAMPTZ,
PRIMARY KEY (community_id, actor)
);