block / block/buzz

buzz channels set-add-policy replaces the caller's whole kind:10100 agent profile, erasing name and respond_to

Open
#4,490 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
32.7k
Forks
4.3k
Avg merge
1d 13h
Merged PRs (30d)
253

Description

`buzz channels set-add-policy` overwrites the caller's whole kind:10100 agent profile, silently erasing `name` and `respond_to`.

**Where.** `crates/buzz-cli/src/commands/channels.rs` (`cmd_set_add_policy`) builds the event with the policy as the *entire* content:

```rust
let content = serde_json::json!({ "channel_add_policy": policy }).to_string();
use nostr::{EventBuilder, Kind};
let builder = EventBuilder::new(
Kind::Custom(buzz_sdk::kind::KIND_AGENT_PROFILE as u16),
&content,
)
.tags([]);
```

**Why it destroys state.** Kind 10100 is `KIND_AGENT_PROFILE` (`crates/buzz-core/src/kind.rs:87`) and is replaceable, keyed by pubkey (`kind.rs:841` asserts `is_replaceable`; `handlers/ingest.rs:421` notes "user-owned replaceable, keyed by pubkey"). The same event kind carries an agent's `name` and `respond_to` (`desktop/src-tauri/src/nostr_convert.rs:441`; test fixture at `:933` is `{"name":"Scout","respond_to":"anyone"}`).

So when an agent identity runs `set-add-policy`, the relay replaces that agent's directory entry with a blob containing only `channel_add_policy`.

**Downstream effect.** The agent then fails `relayAgentIsSharedWithUser` (`desktop/src/features/messages/lib/agentAutocompleteEligibility.ts:12`, which requires `agent.respondTo === "anyone"`), so it silently drops out of teammates' mention autocomplete. No error, no obvious cause, and the recovery is non-obvious.

**Suggested fix**, either works:
- read-modify-write the existing kind:10100 content instead of replacing it, or
- move `channel_add_policy` to its own kind.

Found by reading `main` @ b1b283c, not observed in the wild. Flagging because the failure mode is silent.

Related: #4489 (mention autocomplete), #4487 / #4488 (`respond_to` propagation).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.