Skip to content

[Rewrite P2] nostream-relay: wire handlers, strategies, rate limits #865

Open

Description

@chappie-daemon

Parent: #860
Milestone: Phase 2: Protocol core
Host: both · Expected cost: $2,000

nostream-relay: the wire protocol handlers — the heart of the relay (measured 2,954 LOC in src/handlers, plus the adapter layer).

  • WebSocket server: tokio-tungstenite, per-connection state machine replacing web-socket-adapter.ts/web-socket-server-adapter.ts (742 LOC adapter layer) — ping/pong liveness, max-payload handling, RSV/compression handling, drain-on-close semantics (all measured behaviours in the TS tests)
  • Message handlers: EVENT/REQ/CLOSE/COUNT/AUTH/NEG (NIP-77 NEG-OPEN/NEG-MSG/NEG-CLOSE) with the exact notice/error strings the TS relay sends (clients depend on them)
  • Event strategies (measured: 10+ strategies — default, ephemeral, delete, gift-wrap, DVM job request, contact-list, group/invite/join/leave, replaceable) as a strategy trait; every strategy's acceptance/rejection logic carries its TS tests across
  • NIP-42 AUTH: challenge issuance, event verification, session expiry, replay rejection (measured behaviours in web-socket-adapter tests)
  • Rate limiting: the TS limiter's window semantics per message type, whitelist handling, REQ backoff-hint notices — port the algorithm, property-test the window math
  • Subscription lifecycle: subscribe/unsubscribe, filter-matching dispatch, NIP-56 actionable-report hiding, restricted kinds + authenticated read-through (measured test rows across the WS adapter suite)
  • NIP-11: the info document served from supportedNips + relay metadata; the relay_url validation ported (48fe9c4)
  • NIP-66: active monitoring probes + the published event (port relay-monitor-worker + nip66-event-publisher)

Acceptance: a differential harness drives both the TS relay (running from the capture commit) and the Rust relay with the same scripted client sessions; every response (events, notices, COUNTs, EOSEs, close codes) matches byte-for-byte modulo event ids the relays compute themselves; the negentropy flows converge to the same ranges.

Activity

  1. added
    rewritenostream 4.0 Rust/LMDB rewrite
    rustRust implementation work
    factoryBuilt by the software factory
    on Oct 17, 2026
  2. chappie-daemon commented on Oct 19, 2026

    @chappie-daemon
    CollaboratorAuthor

    Factory job 007-relay-handlers opened: base rewrite/main @ b324ef5 (004 core merged), branch factory/007-relay-handlers, worktree projects/nostream-worktrees/007-relay-handlers, factory 0.10.6, expected $2,000 (Phase 2 anchor — its phase has no measured job yet; replaced, not scaled, when this one closes). Stage: recon. Project item In progress.

    Order note: the milestones put this in Phase 2 and #864 in Phase 3, so the board's program order opens this job first even though #864's storage seam is a dependency the differential harness needs. Recon is briefed to measure whether storage is a hard prerequisite and, if it is, say so with evidence before the spec is written.

  3. chappie-daemon commented on Oct 19, 2026

    @chappie-daemon
    CollaboratorAuthor

    Not run yet, on measured evidence: recon found this job's acceptance needs the storage seam first. EventRepository/^ UserRepository declare 4/11 and 3/7 methods, so REQ/EVENT cannot be served by any implementation or test double until #864 lands, and the differential harness's TS half needs PostgreSQL + Redis, neither reachable on this host. The recon (outside the job tree) and a 12-frame capture from the real TS handlers are kept for when this runs. Order recorded on #860.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    factoryBuilt by the software factoryrewritenostream 4.0 Rust/LMDB rewriterustRust implementation work

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions