Skip to content

feat(buzz-cli): support direct relay pubkeys in channel-template rosters - #4093

Open
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:claude/issue3953-template-pubkeys-20260801
Open

feat(buzz-cli): support direct relay pubkeys in channel-template rosters#4093
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:claude/issue3953-template-pubkeys-20260801

Conversation

@iroiro147

Copy link
Copy Markdown

Problem

A channel template's agents roster previously only accepted Desktop persona ids (which resolve through kind:30176/30177 events) and team ids. Long-running remote or VPS-managed agent identities — stable Nostr pubkeys with no local Desktop persona instance — could not be deterministically rostered. They ended up in the report's skipped bucket with the channel otherwise created successfully, leaving the operator thinking the roster was applied when it wasn't (#3953).

Fix

This implements the issue's option (a): add a third roster variant agentPubkeys: [{ pubkey, label? }] that bypasses the persona→kind:30177 slug scan entirely and adds the pubkey directly as a channel member. Template authors now have a first-class deterministic path for provider-backed agent identities.

Three behavior guarantees:

  1. Direct passthrough — the pubkey is passed verbatim to build_add_member. A malformed or short pubkey surfaces as a member_failures entry, never silently dropped, never in skipped.
  2. Readable fallback labels — when label is omitted the template report uses the first 16 chars of the pubkey (pubkey:<16>) instead of dumping the full 64-hex.
  3. Backward compatible — templates written before this field existed deserialize with agent_pubkeys: [] and behave exactly as before.

Code

  • crates/buzz-cli/src/commands/channel_templates.rs — new TemplatePubkeyEntry { pubkey, label }; TemplateAgentRoster gains #[serde(default)] agent_pubkeys: Vec<TemplatePubkeyEntry> (camelCase JSON agentPubkeys).
  • crates/buzz-cli/src/commands/channels.rs — new pure helper expand_direct_pubkeys converts the entries verbatim into ResolvedAgents; build_roster_resolution collects them alongside the existing persona/team slug scan and merges them into RosterResolution.agents before any channel creation.

Tests

New unit coverage in channels.rs:

  • expand_direct_pubkeys_uses_label_when_present
  • expand_direct_pubkeys_falls_back_to_truncated_pubkey_label — includes a short/malformed pubkey that must not panic and must truncate at its actual length
  • expand_direct_pubkeys_empty_when_no_entries

New/extended coverage in channel_templates.rs:

Verification

cargo check  -p buzz-cli                              # OK
cargo test   -p buzz-cli --lib                        # 276 passed, 0 failed
cargo clippy -p buzz-cli --all-targets -- -D warnings # OK

Fixes #3953.

A channel template's `agents` roster previously only accepted Desktop
persona ids (which resolve through kind:30176/30177 events) and team
ids. Long-running remote or VPS-managed agent identities — stable Nostr
pubkeys with no local Desktop persona instance — could not be
deterministically rostered: they ended up in the report's 'skipped''
bucket with the channel otherwise created successfully, leaving the
operator thinking the roster was applied when it wasn't.

Add a third roster variant, `agentPubkeys: [{ pubkey, label? }]`,
that bypasses the persona/team slug scan entirely and adds the pubkey
directly as a channel member. This gives template authors a first-class
deterministic path for provider-backed agents, matching the first
option listed in issue block#3953.

Behavior notes:
- Label falls back to TRUNCATED-pubkey prefix (first 16 chars, not
  full 64-hex) so the template report stays readable.
- The pubkey is passed through unchanged to build_add_member. A
  malformed/short pubkey surfaces as a member_failures entry — never
  silently dropped, never in 'skipped'.
- Direct entries are merged with persona/team-resolved agents, not
  exclusive — a template can mix all three.

Tests:
- expand_direct_pubkeys_uses_label_when_present: explicit label path.
- expand_direct_pubkeys_falls_back_to_truncated_pubkey_label: the
  fallback and its no-panic short-string safety.
- expand_direct_pubkeys_empty_when_no_entries.
- load_templates_parses_full_roster: existing test extended to assert
  the new agentPubkeys field defaults to empty on pre-block#3953 templates,
  preserving backward compatibility.
- load_templates_parses_direct_agent_pubkeys: parses the new JSON
  (camelCase agentPubkeys, optional label).
- load_templates_rejects_invalid_pubkey_entry: malformed entries fail
  parse instead of silently dropping — closing the silent-omission
  regression vector from the persona path.

Fixes block#3953.

Signed-off-by: Sarthak Singh <sarthak.singh@juspay.in>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: channel templates should not silently omit remote managed agents from the roster

1 participant