feat: ephemeral channels with TTL-based auto-archiving#232
Open
feat: ephemeral channels with TTL-based auto-archiving#232
Conversation
Add ephemeral channels that auto-archive after a configurable period of inactivity. Full vertical slice: schema → DB → relay → REST API → desktop UI. Schema: - Add ttl_seconds (INT) and ttl_deadline (TIMESTAMPTZ) to channels table - Add partial index for efficient reaper queries Database (sprout-db): - Extend ChannelRecord with ttl_seconds and ttl_deadline fields - Add bump_ttl_deadline() to reset deadline on channel activity - Add reap_expired_ephemeral_channels() to archive expired channels - Thread ttl_seconds through create_channel and create_channel_with_id Relay (sprout-relay): - Parse 'ttl' tag from NIP-29 create-group events - Bump TTL deadline on every channel-scoped event (skip kind:9007 create) - Add background reaper task (configurable interval, default 60s) - Support SPROUT_EPHEMERAL_TTL_OVERRIDE env var for testing - Emit system messages and discovery events on auto-archive Desktop: - Add ephemeral checkbox to channel/forum creation forms - Thread ttl_seconds through Tauri commands and event builders - Expose ttl_seconds and ttl_deadline in TypeScript types and API layer - Bump check-file-sizes override for types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds ephemeral channels — channels that auto-archive after a configurable period of inactivity. Full vertical slice from schema through to the desktop UI.
Changes
Schema
ttl_seconds(INT) andttl_deadline(TIMESTAMPTZ) columns tochannelstableidx_channels_ttl_expiryfor efficient reaper queriesDatabase (
sprout-db)ChannelRecordwithttl_secondsandttl_deadlinefieldsbump_ttl_deadline()— resets the deadline on channel activityreap_expired_ephemeral_channels()— archives channels past their deadlinettl_secondsthroughcreate_channel()andcreate_channel_with_id()Relay (
sprout-relay)ttltag from NIP-29 create-group events via sharedresolve_ttl()helperSPROUT_REAPER_INTERVAL_SECS, default 60s)SPROUT_EPHEMERAL_TTL_OVERRIDEenv var for testing with short TTLschannel_auto_archivedsystem messages and update NIP-29 discovery events on auto-archiveDesktop
ttl_secondsthrough Tauri commands and Nostr event buildersttl_secondsandttl_deadlinein TypeScript types and API layerCode Quality
resolve_ttl()inhandlers/mod.rs(eliminates duplication betweeningest.rsandside_effects.rs)EPHEMERAL_TTL_SECONDSconstant inAppSidebar.tsxHow It Works
ttltag (e.g.,["ttl", "86400"])ttl_seconds=86400and setsttl_deadline = NOW() + 86400sttl_deadlineforwardttl_deadline < NOW()Testing
SPROUT_EPHEMERAL_TTL_OVERRIDE=60— override all ephemeral TTLs to 60sSPROUT_REAPER_INTERVAL_SECS=5— run reaper every 5s.env.exampleMulti-pod Safety
The reaper uses
archived_at IS NULLas an idempotent guard — concurrent runs from multiple relay pods are harmless. A future pass will addpg_advisory_lockcoordination alongside the workflow engine.