Skip to content

relay: the message limiter keys one bucket per address, dropping the capture's per-message-type window #1301

Done

Description

@chappie-daemon

Found by job 045's code lens (row 5 of #868), reviewing nostream-relay at 8488bf13.

The message limiter keys one bucket per address and loses the message type:

crates/nostream-relay/src/limits.rs:543
    let key = format!("{address}:message:{}", config.period_ms);

The capture buckets by a closed set of message types and keys ${client}:message:${type}:${period} (src/adapters/web-socket-adapter.ts:59-71, :354), so an EVENT burst spends the REQ budget and vice versa. Mixed traffic is therefore refused where the capture allowed it — a false positive that scales with a client's use of both.

message_backoff (limits.rs:520) takes no type, so it cannot express the capture's key, and tests/limits.rs:694-724 can only ever call it by address, which is why the test suite pins the type-free shape. ADR 0004:173 records the one-key-per-address shape as measured, not as a decision against the capture.

Acceptance

  • The key carries the message type, derived from the raw frame prefix against the capture's closed set with an other fallback, and message_backoff's signature can express it.
  • A case where an EVENT burst leaves the REQ window intact fails on the old key.
  • ADR 0004 records the decision (and the closed set) rather than the old shape.

Record: docs/rewrite/reviews/2026-11-30-relay-storage.md — finding F8, lens code, tree 8488bf13. Site: crates/nostream-relay/src/limits.rs:543.

Activity

  1. added
    bug
    rewrite
    rust
    factory
    on Nov 30, 2026
  2. chappie-daemon commented on Dec 4, 2026

    @chappie-daemon
    CollaboratorAuthor

    Factory job started (row from the 2026-12-04 plan): recon in progress, branch factory/050-*' from rewrite/mainat7019957`.

  3. chappie-daemon commented on Dec 4, 2026

    @chappie-daemon
    CollaboratorAuthor

    Closed by d8c57439c3b2405d9119ed0d99d909a672f61a57 (#1381).

    The message limiter now derives the capture's closed set (REQ, EVENT, COUNT, CLOSE, AUTH, NEG-OPEN, NEG-MSG, NEG-CLOSE, with OTHER) from the raw frame prefix and keys {address}:message:{CLASS}:{period_ms}, so an EVENT burst no longer spends the REQ window. NEG-CLOSE's nine characters exceed the capture's own eight-character bound, so that frame lands in OTHER — parity with the capture, proved by the_nine_character_neg_close_falls_to_other.

    Evidence: the socket oracle an_event_burst_leaves_the_req_window_intact fails at 7019957a (CLOSED s1 where EOSE s1 is expected) and passes at head; ADR 0004 records the decision and the closed set rather than the old shape; the security lens bounded the eight-fold bucket multiplication (8 reachable classes, 65,536-key store cap, admit fail-closed).

    Follow-ups filed: #1382 (a 20 ms liveness test that fails on a loaded runner), #1385 (from_frame allocates a String per frame). The irreversibility gate's expectation-removed finding was measured as a signature reformat with the same expectation and discharged by the operator (2026-12-04).

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

Metadata

Metadata

Labels

bugfactoryrewriterust

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions