## Summary Implements NIP-PM on the relay. A member signs one command to pin or unpin a message, and the relay publishes the channel's pins as one relay-signed list. The NIP is `docs/nips/NIP-PM.md`, added in #9712. - **Kinds.** `40010` pin and `40011` unpin commands (one `h`, one `e`, empty content) and the relay-signed `30623` pin list, one addressable event per channel, newest pin first. The list carries the channel in `d` and in `h`. - **Ordering.** Every writer of a channel's list takes that list's replacement lock, so pins, unpins and deletes of pinned messages apply one at a time. A command, the new list and the notice are stored in one transaction. - **Idempotency.** A command sent again answers `duplicate:` and is not applied again. Pinning a pinned message or unpinning an unpinned one is accepted and changes nothing. - **Validation.** The author must be able to post in the channel, and the channel must not be archived. A pin target must be a live message of that channel. A channel holds at most 250 pins. - **Deletes.** A delete by the author, the owner of the agent that wrote the message, a channel admin or a relay admin removes the message from the list in the deleting transaction and publishes the new list. A delete removes its messages first and then takes the list locks in channel order, rewriting each list once. Each list write records its timestamp, and a delete reads that first: a delete of a message that is not pinned locks only its own month of `events`, plus the list month when the channel has a list (#9743). The pin list itself cannot be deleted. - **Notice.** A pin that changes the list posts a `message_pinned` system message naming the member, the message and the command. - **Reads.** The list is readable by those who can read the channel. Clients read it with `#h`, which names the channel under NIP-CL, and each new list is delivered to `#h` subscribers. - **Configuration.** None. A relay running this build accepts the commands; it does not advertise pins in NIP-11. - **Threads.** A pin or unpin command cannot be the parent of a reply or the target of an edit or a vote. - **Account erasure.** Content cleanup removes a member's pin and unpin commands. One under an hour old keeps its ID, timestamp, kind and channel so that a resend stays a duplicate. The leader's periodic maintenance tick removes those records once the command is an hour old. `docs/operator-user-account-retention.md` describes this. ### Related issue N/A. #8809 is an earlier draft of message pins with a different event model. ### Testing - Postgres-backed store tests for the list writes: ordering, concurrent pins, resends, the limit, deletes, the lock order of a delete of several messages, the partitions a delete locks, the refusal to delete the list, erasure records and their expiry across communities. - Postgres-backed handler tests through ingest and REQ: the pin and unpin journey with notices and live delivery, who can read the list (private channel, DM and an unlisted channel read by a non-member), every refusal, a reply to a command, and deletes that rewrite the list. - `e2e_channel_pins` runs over WebSocket against a relay and is added to the relay integration job. - Run against a local relay started with no pins configuration: the end-to-end test. On an earlier revision, the periodic tick removed expired erasure records from an archived channel while leaving younger records, live commands and other kinds. - `cargo fmt --check`, clippy with warnings denied on the touched crates, and the file-size check. - `just test-unit`, which includes the buzz-db source-policy tests. --------- Signed-off-by: Kalvin Chau <kalvin@block.xyz> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
3.6 KiB
Account cleanup: retained records and boundaries
Account cleanup removes attributable credentials, access and personal account records. It does not mean every reference to an identity disappears. Where ownership or treatment is uncertain, preserve the record and report the gap. Do not infer permission to delete another person's data from a matching key.
| Records | Treatment |
|---|---|
| Shared channel creator attribution | Keep channels.created_by. Channel content belongs to content cleanup; account cleanup removes the target's membership. |
| Repositories, Git history and routing | Keep repositories, history, name mappings and required owner references. Do not automatically transfer repositories or make them read-only for other users. Retaining a routing reference is not proof that the target's access has been revoked. |
| Other people's role provenance | Keep non-null relay_operators.added_by on surviving roles. Removing the target's own role is separate. |
| Moderation and enforcement | Keep bans, reports, moderation actions, admin action history and rate-limit history, including identifying keys and notes. Pending actions and copied payloads still require review before claiming complete access revocation or erasure. |
| Audit history | Keep operator audit and hash-chained audit history intact. Record new role revocations in the normal audit trail. |
| Shared device registrations | Keep registrations used by other accounts. Delete only with proven exclusive ownership; preserve and report uncertain ownership. Relay identity keys and client installation strings do not establish gateway ownership. |
| Shared signed membership lists | Rebuild current member/admin/metadata lists using the existing relay signer, atomically with each channel membership removal. Preserve superseded historical events and creator attribution. Never edit a signed payload in place. |
| Multi-subject commands and membership notices | Preserve; attribution and historical-message removal remain separate. |
| Pin and unpin commands | Content cleanup removes them. A command under an hour old keeps its event ID, timestamp, kind and channel, with no author, tags or signature, so that sending it again cannot repeat a pin. A running relay removes that record on its periodic maintenance tick once the command is an hour old. The relay-signed message_pinned notice of a pin stays, and names the member and the command ID. |
| Deletion evidence and replay protection | Keep deletion requests, approvals, inventories, stage history, fences and replay watermarks. Watermark removal is not unfinished cleanup. |
These are explicit retention exceptions, not assertions of anonymous data. Other people's signed references can continue to identify the deleted key. Retaining a record must never be used to claim the deleted identity has lost authority: repository owner checks, config-backed operator roles and live sessions need separate enforcement and verification.
Profile rows, profile events, managed-agent definitions and archived identities
belong to profile cleanup. Independent leftover-data verification and final
coordinator wiring belong to the verifier change. The existing account command
must keep reporting account_erasure_complete: false while those prerequisites
and the remaining account work are incomplete.
For supported selectors and runnable commands, see offline account cleanup.
All deletion commands run offline with relay and external writers stopped. Preview is read-only. A per-community invocation must not silently mutate deployment-global privileges or registrations.