Files
buzz/desktop/src-tauri
Logan Johnson a38fedb234 fix(desktop): recognize agents without NIP-OA in Huddles (#8544)
🤖
## Summary
In a Huddle (a voice call in a channel), Buzz Desktop decides which
participants are agents. It uses that answer to choose whose text it
speaks aloud, which agents can publish voice, and when the last person
leaves and the Huddle ends.

Desktop currently treats a participant as an agent only when its channel
role is `bot`. #8494 changes the relay so that it gives `bot` only to
agents with a verified owner attestation (NIP-OA). After that change,
agents without an attestation join as ordinary members, and Desktop
treats them as people:
- their messages are not spoken,
- their voice publisher is refused,
- the Huddle stays open after the last person leaves while such an agent
is still connected.

With this PR, Desktop also counts a member as an agent when a trusted
person has published a managed-agent record for it. Desktop already
publishes such a record for every agent it runs, on every machine.
Trusted people are:
- **you**, so your own agents count as agents on all of your machines;
- **the Huddle's owner**, usually the person who started it, so the
agents they added count as agents for everyone who joins.

Some agents without an attestation still count as people: an agent added
by someone who does not own the Huddle, as seen from any machine other
than that person's. The only way to recognize those agents is an owner
attestation. This PR does not sign one.

### Details
- `huddle/roster.rs` (`fetch_huddle_roster`) is now the only place that
decides agent or person for Huddles. A member is an agent if its role is
`bot`, or if the current user or a channel `owner` published a
kind:30177 managed-agent record whose `d` tag is that member's key.
Records from other authors are ignored. Records whose signature does not
verify are ignored.
- All Huddle checks use the roster: voice-publisher authorization,
`get_huddle_agent_pubkeys` (spoken-text gating and the participant
list), the periodic roster refresh, adding an agent, cleanup at the end
of the Huddle, and the last-person check.
- Trusting the owner's records is a compatibility policy for Huddles,
not proof of identity. A record creates no owner. It lets the channel
owner mark a member as an agent for every Huddle behavior that reads the
roster: spoken text, voice publishing, remote transcription and
turn-taking (both skip agent audio), cleanup, and the last-person check.
Before #8494 the client chose the role, so an owner could already do
this by labeling a member `bot`.
- If the managed-agent records cannot be read, Desktop does not drop
agents that have the `bot` role. Spoken text, voice publishing, adding
agents and cleanup keep working for those agents. The Huddle does not
end automatically, because an agent without an attestation could be
counted as a person. When you join, and on each periodic refresh,
Desktop adds the `bot` agents to its stored list and keeps stored agents
that are still members.

### Related issue
Follow-up to #8494 (the relay stores `bot` only for attested agents). No
existing issue found.

### Testing
- New helper-level unit tests in `huddle/roster.rs`. They do not run the
relay query, the pipeline writers or the leave path.
- the `bot` role, the user's own record and the owner's record each mark
a member as an agent;
  - records from other members are ignored;
  - a record with a forged signature is ignored;
- when the record read fails, `bot` agents stay agents, the Huddle
cannot end automatically, and the next successful read restores the full
roster.
- when the record read fails, a joiner with no stored agents still
stores the `bot` agents, an agent known only by its record stays stored,
and a stored agent that left drops out.
- New tests in `huddle/roster_hydration_tests.rs` run the real
`post_connect_setup` and hot-start entrypoints against a fake relay
whose managed-agent record read fails. The voice-model, audio and
pipeline steps are passed in, so the tests replace them. Post-connect
stores the `bot` agent before media setup starts; the hot-start refresh
also keeps a still-member agent known from an earlier record and drops
one that left; the same incomplete roster gives no human count for the
last-person check. The tests fail when either entrypoint skips its
roster read, and when the roster code accepts only complete rosters.
- `cargo test --lib huddle::` (Huddle tests only), `cargo clippy --tests
-D warnings` and `cargo fmt --check` pass in `desktop/src-tauri`.
- Not yet tested in a live Huddle.

---------

Signed-off-by: Logan Johnson <loganj@squareup.com>
Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
2026-10-26 16:00:13 -04:00
..