fix(desktop): connect managed agents with the configured relay URL, not the canonical identity URL - #4859
fix(desktop): connect managed agents with the configured relay URL, not the canonical identity URL#4859anilkishan wants to merge 2 commits into
Conversation
…ot the canonical identity URL Managed agents were spawned with BUZZ_RELAY_URL set to the canonical (pubkey, relay_url) identity URL from normalize_relay_url, which folds loopback spellings to 127.0.0.1. Relay tenancy is host-derived and does NOT fold spellings, so an agent configured against ws://localhost:PORT connected to the ws://127.0.0.1:PORT community instead — discovering 0 channels and sitting idle (block#2444, block#3283, block#3505, block#4147). Pass the configured relay URL through to the child connection at all three spawn call sites, keeping the canonical key URL for runtime identity and for the spawn-config snapshot (the restart-drift check recomputes with key.relay_url, so the stamp must agree or agents restart-loop when the spellings differ). Signed-off-by: anilkishan <10408515+anilkishan@users.noreply.github.com>
Chessing234
left a comment
There was a problem hiding this comment.
connecting with the configured relay url while identity/snapshot stay on canonical key.relay_url matches the tenancy vs identity split. any leftover call site that still builds the connect URL from the identity spelling?
Review follow-up on the same tenancy-vs-identity split: the relay-access probe built its HTTP base from the canonical key spelling (probing a different or unmapped community than the one being configured), and the post-probe start passed the canonical spelling as the child's connection URL. Both now use the requested URL; start_pair re-derives the same canonical key, so identity is unchanged. Signed-off-by: anilkishan <10408515+anilkishan@users.noreply.github.com>
|
Good question — swept the desktop crate for
Identity and bookkeeping uses of |
Summary
Desktop-managed agents can silently connect to a different relay community than the owner's desktop, discover 0 channels, and sit idle forever — never replying to mentions.
Root cause: two normalizers deliberately disagree about host equivalence, and the spawn path mixes them up.
buzz_core::relay::normalize_relay_url(the identity normalizer) folds all loopback spellings to127.0.0.1to build the stable(pubkey, relay_url)runtime key. Its doc comment explicitly says connection code should retain the configured URL.buzz_core::tenant::normalize_host(the tenancy normalizer) does not collapselocalhostvs127.0.0.1— distinct spellings are distinct communities, and the relay fails closed on unmapped hosts.spawn_agent_childviolates the first normalizer's contract: it sets the child'sBUZZ_RELAY_URLfrom the canonicalruntime_key.relay_urlinstead of the configured URL. So an agent configured againstws://localhost:3000is spawned againstws://127.0.0.1:3000, binds to the wrong (often empty) community, and goes deaf.The fix keeps the two roles separate, per
normalize_relay_url's documented intent:spawn_agent_childnow uses the configured relay URL (trimmed) for the child'sBUZZ_RELAY_URL. All three call sites (start_managed_agent_process,start_pair, launch restore) already have the configured URL in scope and now pass it through.key.relay_url. The restart-drift check recomputes the prospective snapshot withkey.relay_url, so the spawn-time stamp must agree — otherwise agents restart-loop whenever the configured spelling differs from the canonical one.No identity migration: existing
(pubkey, relay_url)runtime keys are unchanged.Related issue
Fixes #2444, #3283, #3505, #4147.
Closest existing PR: #4345 addresses the same symptom by changing
normalize_relay_urlto fold loopback tolocalhostinstead of127.0.0.1. That helps the common dev seed, but (a) it only covers loopback spellings while tenancy is host-derived for all hosts, and (b) changing the identity normalizer rewrites existing runtime keys on upgrade. This PR instead fixes the layer that violates the documented contract and covers non-loopback spelling differences too. Happy to coordinate with the author if maintainers prefer that direction.Testing
agent_connection_preserves_loopback_authoritycovering the connection-URL helper.just desktop-tauri-test(fullcargo test --workspaceindesktop/src-tauri, 2,200+ tests) passes.just desktop-tauri-clippyandcargo fmt --checkclean.