Skip to content

Add wildcard peer listing and shell completion to the libby CLI - #38

Merged
mikelangmayr merged 6 commits into
mainfrom
mike/list-peers-and-completion
Sep 23, 2026
Merged

mikelangmayr merged 6 commits into
mainfrom
mike/list-peers-and-completion

Conversation

@mikelangmayr

@mikelangmayr mikelangmayr commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator
  • libby list hsfei.% lists the live daemons in a group; libby list %.%.isconnected reads one keyword across the fleet. A % in the group or daemon segment is answered by broadcast
  • Libby.broadcast_request collects replies to a destination-less REQ, which bamboo sends but never waits for
  • Client.peers and Client.peer_listings expose the same broadcast programmatically; Client.list routes to it when the pattern spans daemons
  • Only daemons are listed: every Libby serves keys.list, so LibbyDaemon builds its Libby with is_daemon=True and a reply counts only if it reports that
  • libby completion bash|zsh prints shell code for TAB completion of verbs, flags and addresses, with candidates from the same broadcast, a 0.5s bound and a 10s cache in ~/.libby/completion_cache.json. Adds an argcomplete dependency
  • README now points at this broadcast for finding peers and says plainly that discovery, meaning a peer table you can ask who is alive, is not implemented yet: peers_alive is always empty since Protocol never instantiates a PeerTable, ZMQ's hello only reaches peers already in the address book, and Libby.rabbitmq never starts hello
  • These patterns always wait the full timeout, 1s by default, since nothing on the wire says how many daemons exist. Over ZMQ the broadcast reaches only the address book
  • Peer listing cases run on both transports with three daemons across two groups plus a client posing as one; also verified by driving the real CLI and argcomplete's protocol against a live fleet on a local broker

Comment thread libby/libby.py
def rpc(self, peer_id: str, key: str, payload: Dict[str, Any], ttl_ms: int = 8000):
return self.request(peer_id, key, payload, ttl_ms)

def broadcast_request(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change, I think we need to re-think a bit about "who" is replying back. Before with keys.list we are under the assumption that everyone is a daemon (and libby client is another daemon). I'm thinking when a Libby object is created, it now says whether it's is_daemon=True or not. Only LibbyDaemon instances sets that tag to True; regular Client connections default to False. When peer_listings() collects the broadcast replies, it now only keeps the ones where is_daemon=True.

@mikelangmayr

mikelangmayr commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator Author

Confirmed: a plain Client(self_id="hsfei.impostor") shows up in peers('hsfei.%').

Added is_daemon, set only by LibbyDaemon.build_libby and reported from keys.list. A reply is listed only if it reports the flag. Tested on both transports.

@mikelangmayr
mikelangmayr merged commit eeeee45 into main Sep 23, 2026
3 checks passed
@mikelangmayr
mikelangmayr deleted the mike/list-peers-and-completion branch September 23, 2026 22:52
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.

2 participants