Skip to content

[Rewrite P6] Hardening: fuzz, benchmark gate, 72h soak, security review #868

Open

Description

@chappie-daemon

Parent: #860
Milestone: Phase 6: Hardening + benchmark
Host: both · Expected cost: $3.30

Prove the rewrite before cutover: security review, the benchmark gate, and the long-run soak.

  • Six-lens factory review of the whole nostream-relay + nostream-storage surface (security, architecture, performance at minimum; code/UX on the admin+MCP surface)
  • Fuzzing: cargo-fuzz targets on the message parser, filter parser, NIP-11 doc generator, settings loader — 24h fuzz run on tauceti, zero crashes (crashes found → issues → re-fuzz)
  • Benchmark gate (chappie rig, from [Rewrite P3] Storage seam + LMDB backend (strfry-style) + PG→LMDB migration #864's baseline): LMDB backend within 1.5× of Postgres on REQ p95 latency, ≥ 1× on ingest throughput, at 1M and 10M event corpora; results published in docs/rewrite/benchmarks.md
  • Soak: 72h run on tauceti under synthetic load (mixed subscribe/event/COUNT/negentropy traffic, restarts injected) — memory flat, no fd leaks, event-store checksums stable across restarts
  • Security review of the new surface: the MCP auth model, the settings surface, the migration tool (it holds DB credentials), LMDB file permissions
  • Docs: docs/rewrite/ completed — architecture map TS→Rust crate, deployment guide, operator migration runbook

Acceptance: fuzz clean, benchmark gate green, soak green with published evidence, review lenses PASS, docs complete.

  • Prometheus /metrics endpoint (feat: add Prometheus metrics endpoint #595): the soak's acceptance is that the relay stays healthy under sustained load, and health is unmeasurable from outside the process until this exists — connections, throughput and queue depth have to be scraped live, or the soak produces a log rather than a measurement. One build pass, inside this issue's estimate rather than as a row of its own.

Estimate basis (2026-10-24): $3.30 - the 72-hour soak is wall-clock, not tokens; fuzzing, the benchmark gate and an independent security review cost about two large jobs' review rounds. Model and per-unit costs: .factory/estimates.md.

Activity

  1. added
    rewrite
    factory
    on Oct 17, 2026
  2. chappie-daemon commented on Nov 29, 2026

    @chappie-daemon
    CollaboratorAuthor

    Row split for this issue, taken 2026-11-29 on the operator's steer to run the rewrite programme before defect tickets.

    Six rows, in this order, with the reason each is where it is:

    row issue what lands why here
    1 #595 relay counters + GET /metrics in Prometheus text format, and the admin SSE snapshot upgraded from its unavailable shape to the real numbers every row below is a measurement, and this is the instrument; the soak's acceptance is "the relay stays healthy under load", which is unobservable from outside the process until a scrape exists
    2 new, filed from the fuzz row cargo-fuzz targets for the message parser, filter parser, NIP-11 generator and settings loader, plus a short local run authorable now; the 24 h run waits on tauceti
    3 new, filed from the benchmark row the gate script and docs/rewrite/benchmarks.md, run against #864's baseline corpus depends on row 1 for the latency series and on nothing from tauceti
    4 new, filed from the soak row 72 h soak under synthetic load with restarts injected blocked on tauceti: the charter holds tauceti until the #871 runbook is agreed with Ada
    5 new, filed from the review row six-lens factory review of nostream-relay + nostream-storage, code/UX on admin+MCP, plus the security review of MCP auth, settings, the migration tool and LMDB permissions last among the reviews, so the lenses read the surface the other rows built rather than one still moving
    6 new, filed from the docs row the TS→Rust crate map, deployment guide and operator migration runbook settles once rows 1–5 say what is true

    Rows 2–6 are filed when their turn comes, not now, so each spec is written against the tree it will land on. This issue closes when all six are done.

    Starting row 1 (#595).

  3. chappie-daemon commented on Nov 29, 2026

    @chappie-daemon
    CollaboratorAuthor

    Row 1 amended after recon (job 042) — the SSE snapshot upgrade comes out of this row and becomes its own.

    Measured, not assumed: the console's snapshot updateSnapshot renders seven numeric keys, and two of them (eventsPerSecond, eventsRejectedPerSecond) need a rate window the process does not keep while cpuLoadPercent/memoryUsedMb need process statistics with no crate behind them (libc/sysinfo absent; the only procfs reader sits in nostream-cli). Doing the text endpoint and an honest snapshot in one pass, with the four parity/route/SSE fixtures it moves, is where this row would exceed one build pass and, per the recon's risks, turn an instrument into two jobs.

    So row 1 is #595 alone: the counters the relay can keep honestly, and a scrape endpoint with an auth a Prometheus target can actually use. The SSE snapshot upgrade is filed as a row of its own when it is picked up — it is still Phase 6 work, not dropped.

    Second finding worth the board: nostreamd still composes unavailable::stores() (main.rs:235,247), so an accepted-throughput counter reads 0 at this commit and every query duration times an error return. Rows 3 and 4 (benchmark gate, 72 h soak) cannot measure anything real until #1206 lands; row 1 is startable because the counters instrument the relay's own paths and are testable against a real-store harness.

  4. chappie-daemon commented on Nov 29, 2026

    @chappie-daemon
    CollaboratorAuthor

    Row 1 done: #595 merged as bb00f82eb350d291de47220ca3e4592fe00843ba (PR #1282), issue closed.

    The relay now keeps the counters #595 names and serves them as Prometheus text at GET <prefix>/metrics, behind Authorization: Bearer $METRICS_TOKEN (constant-time) and METRICS_ENABLED, outside the admin gate because <prefix>/admin/metrics is the console's SSE stream. ADR 0021 records the four decisions and their costs. AUTH's replies are carved out of the accepted/rejected families — before the carve-out a successful NIP-42 AUTH counted as an accepted event.

    Two corrections the job had to make to its own record, worth naming so the next row does not repeat them: ADR 0021 first claimed the accepted counter reads 0 until #1206, which the rebase onto 1514e7f2 made false; and Greptile caught a torn histogram read that six independent atomic loads made possible, fixed with a monotone clamp and a seam-backed regression case.

    Cost: $3.01 against a $1.85 first estimate, re-estimated to $2.75 at pr-open, then extended to $3.25 on Cameri's call to cover the histogram fix round. 21 sessions. The estimate was wrong because it priced one pass for a row that introduced a surface, a credential and an encoder; the regret line's forward rule is that a credential-plus-ADR row is priced as a two-round row.

    Rows 2–5 of the split are unaffected; row 3 and 4 no longer wait on #1206 (it merged), only on tauceti's runbook.

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

    factoryrewrite

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions