You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c2c11a4
Browse filesBrowse the repository at this point in the historyBrowse files
docs(nips): add nip-sl send later and nip-fi deferred actions (#9912)
## Summary
Adds NIP-SL (Send Later) and a "Deferred actions" section to NIP-FI.
This change is specification only: the relay, schema and clients are
untouched.
**NIP-SL**
- An author signs an ordinary message dated for its release time `T` and
submits it inside a private, author-signed instruction (`kind:30360`).
The relay stores the message as an ordinary event between `T` and `T +
release_window`, so the timestamp rule and the signer rule stay as they
are.
- The relay reports how the send ended in an author-only status
(`kind:30361`) signed with its NIP-11 `self` key: `sent`, `failed`,
`missed` or `cancelled`.
- Edit, change the time, send now and cancel are replacements of the
instruction under a generation compare-and-swap. Release and cancel are
one conditional change, so a confirmed cancel is never followed by a
post.
- NIP-11 discovery through `supported_extensions` (`buzz-send-later`)
and a `send_later` descriptor that carries the limits. Recommended
limits: 120 days ahead, 100 pending per author per community, a 900
second release window, 7 days of text retention for failed or missed
sends, 30 days of status retention.
- The document also specifies the acceptance checks with their `OK`
messages, the events that end a send early (ban, disconnect, channel
deletion, operator withdrawal), retention, read access and the complete
read a client derives state from.
**NIP-FI**
- A relay that stores actions it executes without a live session writes
a disconnect record for each disconnect command and cancels the pending
actions whose admission the record fences, in one atomic change, before
it closes a connection or answers `200`. The record carries the
command's scope, and each action stores the issuer, owner and verified
`iat` of its admitting assertion, so a `revoke_through` cutoff applies
to pending actions as it does to sessions.
- A command answered `503`, or not answered, is retried with a freshly
signed command. The deny set is unchanged.
- A relay accepts no deferred action while a process that answers
disconnect commands for the same storage does not apply the section.
**Design choices worth a reviewer's eye**
- Both kinds are readable only by the author. The owner of an agent
cannot read the agent's instructions or statuses. A pending message is
stored in the clear, as a posted one is.
- Each send stores the owner verified at acceptance, and release uses
it, because there is no request at release to take an owner from.
- A relay keeps at most `max_pending` ended instructions per author, so
the instruction read fits in one request. Past that bound, the text of a
failed send or the record of an author's own cancel can be deleted
before its retention period ends.
- A disconnect covers the target key and every agent key it owns.
Nothing else in NIP-FI ends an accepted send, and release does not
evaluate issuer policy again.
- A released message carries `created_at` `T` and can arrive up to
`release_window` later. A reader whose read state is a `created_at`
frontier displays it and counts it as read; the document states this
limitation and what read state removes it.
- Channels, threads and DMs of the listed kinds are in scope. Forum
posts and recurring sends are left for later work.
**Follow-up**
- Relay implementation, including registration of kinds 30360 and 30361
in the kind registry and removal of the unused placeholder kinds 40006
and 40007 from ingest.
- Client implementation.
### Related issue
The "Deferred actions" section builds on the disconnect contract of
#9860 (retry with a freshly signed command) and #9917 (`revoke_through`
and "Deny scope"), both on main.
### Testing
Documentation only. `git diff --check` passes, every section link in
NIP-SL resolves to a heading, the link to "Deferred actions" in NIP-FI
resolves, and kinds 30360 and 30361 are unused in
`crates/buzz-core/src/kind.rs`. To review: read `docs/nips/NIP-SL.md`
top to bottom, then the "Deferred actions" section of
`docs/nips/NIP-FI.md`.
---------
Signed-off-by: Kalvin Chau <kalvin@block.xyz>
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
Any failure at any step is fail-closed: no sessions are closed and the relay
638
-
returns the appropriate error. Only an unknown shared-storage outcome, described below, can leave state behind.
702
+
returns the appropriate error. Only an unknown shared-storage outcome, described below, or a disconnect record that does not commit (see Deferred actions) can leave state behind.
639
703
640
704
### Request
641
705
@@ -653,7 +717,10 @@ performs all pure authorization checks and then, as its single atomic admission
653
717
mutation (step 7), simultaneously reserves the `(iss, jti)` replay identity and
654
718
inserts the deny entry — both or neither. A capacity failure at that step rejects
655
719
`503`; neither the jti nor the deny entry is recorded, and the caller may safely
656
-
retry the same signed command. A relay that keeps the deny set in shared storage and cannot learn whether its write applied MUST reject `503``authorization_unavailable` and close no sessions. The `jti` and deny entry may already be recorded, so the caller retries with a freshly signed command (new `jti`), not the same one. On success, the relay MUST close every live connection
720
+
retry the same signed command. A relay that keeps the deny set in shared storage and cannot learn whether its write applied MUST reject `503``authorization_unavailable` and close no sessions. The `jti` and deny entry may already be recorded, so the caller retries with a freshly signed command (new `jti`), not the same one.
721
+
After step 7 succeeds, a relay that executes deferred actions commits the
722
+
change "Deferred actions" specifies before it closes any connection. On
723
+
success, the relay MUST close every live connection
657
724
registered under the command's issuer (`claims.iss`) whose proven key equals
658
725
`CommandResult.target_pubkey` or whose recorded owner equals
659
726
`CommandResult.target_pubkey`, and whose admitting assertion falls in the
@@ -679,6 +746,7 @@ under the merge rule.
679
746
| Malformed request body or `until` exceeds ceiling |`400`|`bad request\n`|
|`FI-TRACE-DEPENDENCY-FAIL-CLOSED`| An unreadable JWKS snapshot denies `authorization_unavailable`; no degraded Nostr-only access. |
1021
1089
|`FI-TRACE-LEASE-BOUND`| A session closes at its earliest deadline; equality at any deadline is expired. |
1022
1090
| `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. |
1091
+
| `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. |
1023
1092
| `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. |
1024
1093
|`FI-TRACE-DENIAL-ORACLE`| Each public-class row produces its exact fixed bytes; all private-state rows compare byte-identical. |
1025
1094
|`FI-TRACE-DISCOVERY-PRIVATE`| Complete discovery bytes do not expose issuer, audience, or deployment-private state. |
@@ -1081,6 +1150,16 @@ attempt, the residual exposure after restart is bounded by
1081
1150
continues issuing or re-push does not complete in time, that formula does
1082
1151
not apply and access may continue beyond it.
1083
1152
1153
+
**Deferred actions.** A deferred action executes with no live session, so
1154
+
session expiry never stops it. Under this NIP only a disconnect command does:
1155
+
the durable record cancels the matching actions and fences the admissions the
1156
+
command covers, in every relay process and across restarts. An issuer that
1157
+
only stops issuing assertions leaves every accepted deferred action in place
1158
+
for as long as it can stay pending. A deployment that enables deferred actions
1159
+
in a community that requires NIP-FI MUST have each authorized issuer send a
1160
+
disconnect command when an identity loses access. A community ban of the key
1161
+
remains available to the relay operator.
1162
+
1084
1163
**HTTP ingress bypass.** Without the pairing rule, a principal holding an
1085
1164
active key can mint fresh NIP-98 events indefinitely and retain HTTP access
1086
1165
for as long as the key remains accepted — the assertion TTL provides no
0 commit comments