Skip to content

feat(relay): add NIP-ER push scheduler with cross-pod delivery#957

Draft
wpfleger96 wants to merge 1 commit into
paul/nip-er-relay-corefrom
paul/nip-er-relay-scheduler
Draft

feat(relay): add NIP-ER push scheduler with cross-pod delivery#957
wpfleger96 wants to merge 1 commit into
paul/nip-er-relay-corefrom
paul/nip-er-relay-scheduler

Conversation

@wpfleger96

@wpfleger96 wpfleger96 commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Stack

Stack: #934 → this PR

This PR stacks on #934 (NIP-ER core: kind registration, validation, read-path filtering). Merge #934 first.


Adds the NIP-ER push scheduler — a background loop that queries for due reminders (not_before <= now) and publishes them to Redis pub/sub for cross-pod fan-out.

Changes

Push scheduler (main.rs)

  • Configurable tick interval (SPROUT_REMINDER_SCHEDULER_INTERVAL_SECS, default 10s) and batch limit (SPROUT_REMINDER_SCHEDULER_BATCH_LIMIT, default 100)
  • Publish-then-claim ordering: Redis publish happens before the atomic delivered_at claim, preventing silent reminder loss on publish failure. Duplicate delivery on claim failure is harmless (subscribers dedup by event ID)

Privacy enforcement (event.rs)

  • filter_fanout_by_access now enforces author-only kinds (AUTHOR_ONLY_KINDS) as its first check, before channel-based access gating. This ensures kind:30300 events are delivered only to the event's author across all delivery paths: local dispatch, cross-pod subscribe_local, and scheduler-published events
  • New test: author_only_kind_delivers_only_to_author verifies the filter rejects non-author subscribers for kind:30300

Ingest relaxation

  • not_before is now optional on kind:30300 — allows bookmarks and terminal-state reminders without a schedule
  • max_not_before_delta enforced via SPROUT_MAX_NOT_BEFORE_DELTA to prevent unbounded-future scheduling abuse

Schema

  • Nullable not_before + delivered_at columns on events table
  • Partial index for efficient scheduler queries

NIP-11 advertisement

  • supported_extensions: ["nip-er"], due_delivery_mode: "push", max_not_before_delta advertised in relay info document

… advertisement

The relay now proactively delivers due reminders via Redis pub/sub.
Cross-pod dedup uses an atomic delivered_at claim (mirrors the reaper's
archived_at guard). Ingest relaxed to allow kind:30300 without
not_before (bookmarks/terminal states). max_not_before_delta enforced
to prevent unbounded-future scheduling abuse.

Schema: nullable not_before + delivered_at columns on events, partial
index for scheduler queries. NIP-11: supported_extensions ["nip-er"],
due_delivery_mode "push", max_not_before_delta advertised.

Spec (NIP-ER.md) amended: not_before optional on kind:30300, required
only for pending reminders that may become due.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant