From ec2c3f6afaa5987796f4b790a5db6f8848158bd9 Mon Sep 17 00:00:00 2001 From: Kalvin C Date: Mon, 30 Nov 2026 07:31:17 -0800 Subject: [PATCH] docs(nips): require the relay self key for nip-sl statuses and bound agent sends by the owner credential (#10016) ## Summary Follow-up to #9912. Specification only: closes four gaps in NIP-SL and the NIP-FI "Deferred actions" section. **NIP-SL** - A send-later status (`kind:30361`) is the relay's record of how a scheduled send ended: `sent`, `failed`, `missed` or `cancelled`. It is how the author's client learns the outcome, since the relay posts the message while the client may be offline. The relay signs each status with its NIP-11 `self` key, which NIP-11 makes optional. A relay now serves the `send_later` descriptor only with a `self` key and keeps that key while a status signed with it is readable. A client treats the descriptor as absent when `self` is missing or malformed, and reads the NIP-11 document again, once per key, when a status is signed with another key. Without this, a relay with no `self` or a rotated one makes clients reject these statuses, and a failed send whose text is still retained reads as pending. - An agent admitted through its owner could schedule past the time bound of the NIP-OA `auth` tag that proved the owner, by leaving the tag off the message. The `created_at` conditions of that tag now hold at `T`, and an `auth` tag on the message names the stored owner. - Deleting an instruction covers the instruction's copy of the message, so the wording no longer reads as covering the posted event. **NIP-FI** - An admission's time is read no later than its deny-set check, and the connection's lifetime counts from that time. Otherwise an admission that checked the deny set just before a disconnect committed could be stamped after `recorded_at` and stay unfenced. ### Related issue Follow-up to #9912. ### Testing Documentation only. `git diff --check` passes and the section links in NIP-SL resolve. To review: read the diff; each change is one or two sentences. --------- Signed-off-by: Kalvin Chau Co-authored-by: Claude Fable 5.2 --- docs/nips/NIP-FI.md | 10 ++++++---- docs/nips/NIP-SL.md | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/nips/NIP-FI.md b/docs/nips/NIP-FI.md index 5bb4b96396..e995fa09b3 100644 --- a/docs/nips/NIP-FI.md +++ b/docs/nips/NIP-FI.md @@ -548,10 +548,12 @@ record **fences** an admission when all of these hold: - The admission's proven key or recorded owner is the record's target pubkey. - The record's scope covers the admitting assertion. - The admission happened at or before `recorded_at`, or before `until`. - The relay MUST read both admission times and `recorded_at` from one clock, + The relay MUST read every admission's time and `recorded_at` from one clock, that of the durable storage, so that skew between processes cannot leave an - admission unfenced. A pending action was stored before `recorded_at`, so - this holds for it without a stored admission time. + admission unfenced. It MUST read an admission's time no later than it checks + the deny set for that admission, and count the connection's lifetime from + that time. A pending action was stored before `recorded_at`, so this holds + for it without a stored admission time. When a command passes step 7 of `VerifyCommandJwt`, the relay MUST commit one atomic change to that storage before it closes a connection or answers `200`. @@ -1088,7 +1090,7 @@ deployment-local identifiers. [FI-TRACE-DISCOVERY-PRIVATE] | `FI-TRACE-DEPENDENCY-FAIL-CLOSED` | An unreadable JWKS snapshot denies `authorization_unavailable`; no degraded Nostr-only access. | | `FI-TRACE-LEASE-BOUND` | A session closes at its earliest deadline; equality at any deadline is expired. | | `FI-TRACE-DENY-SET` | A pubkey in the deny set is denied `authorization_denied` on admission until `now >= until` when the entry covers the assertion — a whole-key entry covers every assertion, a cutoff entry only those with verified `iat <= C`, so `iat = C` denies and `iat = C + 0.5` admits; an expired or absent entry does not deny; a disconnect with C closes only sessions with `iat <= C`, and a session with `iat > C` survives every redelivery unless a stronger active merged entry widens the close scope (see Deny scope); a whole-key entry beats a same-deadline cutoff and the later of two cutoffs wins, in either order; an entry that expires before a merge is applied contributes nothing to it; a past-`until` command performs its scoped close — absent an active same-key entry it creates no future denial, while an active entry remains unchanged under the merge rule; a deny-set-full command is rejected `503` without closing sessions and without removing any existing entry; capacity is evaluated per issuer — one issuer's capacity exhaustion MUST NOT reject another issuer's command; a connection within the effective close scope that passes the deny-set check before a concurrent deny-entry insertion but completes admission after MUST still be terminated (the session's proven `k` and admitting issuer are registered before the deny-set check, ensuring the close scan catches it); a registered-but-not-admitted connection caught by the close scan MUST be cancelled terminally and MUST NOT later be admitted; a disconnect command from one issuer MUST NOT close a same-key connection registered under a different issuer, whether or not admission has completed; two overlapping commands for the same `(iss, pubkey)` in either delivery order result in `until = max(until_A, until_B)` — delivery order does not shorten the longer deny; a past-`until` command arriving over an active entry leaves the active entry's `until` unchanged; a successful disconnect responds `{"disconnected": true}` regardless of how many sessions were closed; the deny entry applies across all communities served by the relay under that issuer. | -| `FI-TRACE-DEFERRED-ACTIONS` | A relay that executes deferred actions commits a disconnect record and the cancellation of every pending deferred action whose admission the record fences, across all communities, before it closes a connection or answers `200`; a command whose change does not commit, or that would exceed the per-issuer bound on disconnect records, is rejected `503` with no connection closed and nothing cancelled, and a freshly signed command then succeeds; a freshly signed retry of a command whose change committed on a relay that stopped before its answer writes its own record, closes the matching connections and is answered `200`; a deferred action is not accepted while a process that answers disconnect commands for the same storage does not apply this section; admission times and `recorded_at` are read from the clock of the durable storage; a deferred action of an agent whose recorded owner is the target is cancelled; a deferred action accepted under another issuer is not cancelled; under a cutoff C, a deferred action whose admitting assertion has `iat = C` is cancelled and refused, and one with `iat = C + 0.5` is neither; a deferred action is refused `authorization_denied` when its admission is fenced, including on a process that never received the session close and after a relay restart; an admission after both `recorded_at` and `until` is not fenced; an acceptance that races a command is either cancelled by it or refused, never left pending; a record is retained until `max(recorded_at, until)` plus the maximum connection lifetime, unless a record the relay keeps fences every admission it fences; a cancelled deferred action is not restored by a later assertion. | +| `FI-TRACE-DEFERRED-ACTIONS` | A relay that executes deferred actions commits a disconnect record and the cancellation of every pending deferred action whose admission the record fences, across all communities, before it closes a connection or answers `200`; a command whose change does not commit, or that would exceed the per-issuer bound on disconnect records, is rejected `503` with no connection closed and nothing cancelled, and a freshly signed command then succeeds; a freshly signed retry of a command whose change committed on a relay that stopped before its answer writes its own record, closes the matching connections and is answered `200`; a deferred action is not accepted while a process that answers disconnect commands for the same storage does not apply this section; admission times and `recorded_at` are read from the clock of the durable storage, and an admission's time is read no later than its deny-set check; a deferred action of an agent whose recorded owner is the target is cancelled; a deferred action accepted under another issuer is not cancelled; under a cutoff C, a deferred action whose admitting assertion has `iat = C` is cancelled and refused, and one with `iat = C + 0.5` is neither; a deferred action is refused `authorization_denied` when its admission is fenced, including on a process that never received the session close and after a relay restart; an admission after both `recorded_at` and `until` is not fenced; an acceptance that races a command is either cancelled by it or refused, never left pending; a record is retained until `max(recorded_at, until)` plus the maximum connection lifetime, unless a record the relay keeps fences every admission it fences; a cancelled deferred action is not restored by a later assertion. | | `FI-TRACE-HTTP-INGRESS` | A protected HTTP request with both valid headers and matching pubkeys is admitted; absent, mismatched, or invalid assertion or NIP-98 event denies; a request presenting only one of the two denies; an active deny-set entry that covers the assertion denies; a route that cannot be classified as exempt is treated as protected; repeated, comma-combined, wrong-scheme, or alternative-credential `Authorization` fields deny `evidence_rejected`; a missing `Authorization` field denies `missing_evidence`; an authorization-relevant body without exactly one matching `payload` tag denies; the NIP-FI administrative API is not a protected surface. For kind-24242 (Blossom) proofs on media routes: a `t=upload` proof with valid `x`, `server`, `expiration`, and freshness is admitted on `PUT /upload`; a `t=get` proof with valid `server`, `expiration`, and freshness is admitted on `GET\|HEAD /media/{hash…}`; a kind-24242 proof on any other route denies; an upload proof with absent or mismatched `server` tag denies; a read proof with absent or mismatched `server` tag denies; a proof with a duplicate, missing, or out-of-range `expiration` tag denies; a proof dated more than 120 seconds in the future denies; a proof older than 120 seconds denies; key mismatch between assertion `nostr_pubkey` and the kind-24242 event pubkey denies; an active deny-set entry that covers the assertion denies. | | `FI-TRACE-DENIAL-ORACLE` | Each public-class row produces its exact fixed bytes; all private-state rows compare byte-identical. | | `FI-TRACE-DISCOVERY-PRIVATE` | Complete discovery bytes do not expose issuer, audience, or deployment-private state. | diff --git a/docs/nips/NIP-SL.md b/docs/nips/NIP-SL.md index b04cab1834..101000dbe2 100644 --- a/docs/nips/NIP-SL.md +++ b/docs/nips/NIP-SL.md @@ -105,7 +105,7 @@ A relay MUST NOT refuse a cancel because check 8, a timeout or a lost permission The relay stores an accepted instruction, its generation and the state of the send in one atomic change, and checks 5, 6, 12 and 13 MUST run inside it. A refused instruction MUST change nothing. Once a generation is replaced, the relay MUST NOT release it or keep it readable. -With each generation the relay MUST also store the owner it verified for the author at acceptance, if any. There is no request at release to take an owner from, so release, the `banned` cancel and the timeout check use the stored one. A NIP-OA `auth` tag on the message MUST be valid with its `created_at` condition evaluated against `T`, at acceptance and again at release. +With each generation the relay MUST also store the owner it verified for the author at acceptance, if any. There is no request at release to take an owner from, so release, the `banned` cancel and the timeout check use the stored one. If a NIP-OA `auth` tag proved that owner, its `created_at` conditions MUST hold at `T`, so an owner's time bound on an agent also bounds what the agent schedules. An `auth` tag on the message MUST name the stored owner and MUST be valid with its `created_at` conditions evaluated against `T`, at acceptance and again at release. A relay that does not know whether it stored an instruction, as after a storage error, MUST answer `error:`. A client that gets `error:` or no `OK` MUST NOT assume either outcome, and sends the same event again. Only `OK true` settles an instruction as accepted. After any other answer the client makes a [complete read](#complete-read). Before it creates a new send to replace one that is not settled, it MUST check that the message is not readable in its channel. @@ -169,7 +169,7 @@ A relay SHOULD include `reason` for `failed` and `cancelled`, and MUST omit it o A send has at most one status, and the relay MUST NOT revise it. A relay SHOULD store the status in the atomic change that ends the send. If it stores the status afterwards, it MUST record the outcome durably in that change, MUST sign the status when it stores it, and MUST keep trying until the status is stored. -The relay signs a status with its [NIP-11](11.md) `self` key, and MUST reject a `kind:30361` event that a client submits. Clients MUST accept a status only when its `pubkey` is that key. +The relay signs a status with its [NIP-11](11.md) `self` key, and MUST reject a `kind:30361` event that a client submits. Clients MUST accept a status only when its `pubkey` is that key. A client that gets a status signed with another key MUST read the NIP-11 document again, once for each such key, before it ignores the status. ## Reading @@ -219,7 +219,7 @@ The relay deletes the instruction of a `sent` or relay-cancelled send without pu | `failed`, `missed` | Readable to the author for `text_retention` after the status is stored, then deleted | Readable for `status_retention` | | Cancelled by the author | The cancel replaces the instruction it cancels, which is deleted. The cancel is readable for `status_retention`, then deleted | none | -Deleting an instruction means that the relay no longer stores the message it held in any form. +Deleting an instruction means that the relay no longer stores the instruction's copy of the message in any form. A relay MUST keep at most `max_pending` ended instructions for one author in a community. Cancels and the instructions of `failed` and `missed` sends count together. When the end of a send would take the author past that number, the relay first deletes the ended instruction whose send ended earliest. Its address stays closed. If it held the text of a `failed` or `missed` send, the author loses that text early. If it was a cancel, a complete read then reports that send under rule 3. @@ -255,11 +255,12 @@ Until this draft has an upstream NIP number, relays MUST NOT list it in [NIP-11] | `kinds` | The kinds a message may have | | `limitation` | The limits in [Limits summary](#limits-summary), each a positive integer. A relay MUST enforce the limits it advertises | -A relay that hosts several communities MUST serve the descriptor only for a community in which send later is enabled. +A relay MUST NOT serve the descriptor without a NIP-11 `self` key, and MUST NOT change that key while a status signed with it is readable. A relay that hosts several communities MUST serve the descriptor only for a community in which send later is enabled. A client MUST treat the descriptor as absent in any of these cases: - `supported_extensions` does not contain `"buzz-send-later"`. +- The NIP-11 document has no `self`, or `self` is not 64 lowercase hex characters. - `v` is not `1`. - `v`, `accepting`, `kinds`, `limitation` or a limit in [Limits summary](#limits-summary) is missing or has the wrong type.