feat(relay): add conditional Solo member role updates (#9667)

**Category:** improvement
**User Impact:** Solo chat owners can lower the access of any current
non-owner, including people and agents.

**Problem:** Using invitations to change Solo chat access can restore a
removed member, reject a downgrade because of the target’s invitation
policy, or show a join notice for a role change.

**Solution:** Add signed role updates that require an active member at
the expected role when the relay commits the change. A Solo owner can
downgrade any current non-owner. Moving a viewer to Participating
requires a verified agent, and granting Admin requires ownership of that
agent. The relay refreshes signed group state without emitting a join
notice.

Companion to
[block/buzz-app#3704](https://github.com/block/buzz-app/pull/3704). The
[app
review](https://github.com/block/buzz-app/pull/3704#pullrequestreview-5962147206)
identified the need for conditional writes, verified agent identity and
live relay validation. [#9592](https://github.com/block/buzz/pull/9592)
introduced the atomic removal that uses the same membership lock.

<details>
<summary>File changes</summary>

**crates/buzz-core/src/kind.rs**

Register signed Solo role updates as kind 9050.

**crates/buzz-db/src/store/channel_members.rs**

Authorize the transition under the channel membership lock and commit
the active row update and signed event together.

**crates/buzz-relay/src/handlers/event.rs**

Give the new command a bounded metrics label.

**crates/buzz-relay/src/handlers/ingest.rs**

Use the shared signed ingest path and require the channel administration
scope.

**crates/buzz-relay/src/handlers/mod.rs**

Register the command handler and its PostgreSQL test.

**crates/buzz-relay/src/handlers/solo_member_role.rs**

Parse the command, route it to the conditional write, and refresh signed
group state after commit.

**crates/buzz-relay/src/handlers/solo_member_role_postgres_tests.rs**

Exercise human and agent changes, restrictive invitation policy,
promotion authorization, stale and removed membership, duplicate
receipt, and signed roster updates through the relay’s production ingest
path.

**docs/solo-mobile-contract.md**

Describe the wire format, permitted transitions, and handling when an
older relay rejects the command.

</details>

### Try it

1. Run the updated relay and the companion app against a disposable Solo
chat with a current human and agent. Open **Chat access** as the owner.
2. Lower the human to **Viewing only**. Reopen **Chat access** and
confirm the saved role. A role change should produce no join notice.
3. Downgrade an agent with a restrictive invitation policy. Confirm its
role changes. Check that **Admin** can be granted only to your own
verified agent.
4. Run `solo_owner_edits_active_members_and_publishes_the_new_roster`
with PostgreSQL to check that a pending change for a removed member is
refused and the signed roster stays clear of that member.

### Validation

- The PostgreSQL regression passes at relay commit `405f7d1da`. It
covers role and invite-policy enforcement, signed roster refresh,
duplicate receipts, and rejection after removal.
- The companion app at `a470947dc6` passes 138 administration tests. Its
production command builder, validator, and signed roster reader also
passed over WebSocket against a local relay backed by PostgreSQL and
Redis. A human moved from Admin to Participating to Viewing only, then
was removed. The app preflight and relay both refused a further role
edit, and the signed roster still excluded the member.
- The live check exercised the app’s relay code headlessly. The UI
walkthrough is pending.

---------

Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Carl <acda9e433d19dcd0e6b6840f7f4b98f3a56f1fab98049d444c087019e6d36560@feedback.communities.buzz.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
This commit is contained in:
Taylor Ho
2026-11-18 17:16:25 -08:00
committed by GitHub
parent fd436af846
commit db40da87b4
11 changed files with 753 additions and 40 deletions

View File

@@ -40,3 +40,34 @@ placement and shared-chat ordinary sending.
These are compositional contract tests, not a live desktop/relay/device E2E
run. Physical-device installation and launch alone do not prove that journey.
## Changing an existing member's access
A Solo chat owner changes an existing member's access with a signed Buzz
kind:9050 event with `admin:channels` scope. The content is empty. Each
required tag appears once.
Relays advertise `buzz-solo-member-role` in NIP-11 `supported_extensions`.
Clients offer role changes only when the relay advertises this extension.
| Tag | Value |
| --- | --- |
| `h` | Solo channel UUID |
| `p` | Target member's hex public key |
| `expected_role` | Exact active role from the relay-signed roster: `admin`, `bot`, `member`, or `guest` |
| `role` | `admin`, `member` (Participating), or `guest` (Viewing only) |
A chat owner may lower any active non-owner to Viewing only, or lower an
Admin to Participating. A move from Viewing only to Participating requires
a verified agent. An Admin grant requires a verified agent owned by the
signer. The relay stores Participating as `bot` for verified agents and
`member` for people. Role changes bypass invitation policy.
The relay requires a private Solo stream and checks the current chat and
membership under the membership lock. It commits the command, role, signed
admin list, and signed member roster together. It emits no admission notices.
Refresh the roster after a role mismatch. Resending the same accepted event
confirms its receipt without applying another change. Relays that lack
kind:9050 support reject it. Clients must never fall back to kind:9000 for
this action.