import type { MeshClient } from "./client.js"; /** * Plan/25 — discover Pis-irmãos of every Owner this Pi is paired with. * * For each Owner pubkey (from `peers.json`), pulls the latest signed * `mesh_versions` blob from the relay, verifies it, and walks the members * list to extract all Pi-pubkeys other than this one. The same member may * appear under multiple Owners — we de-dupe by Pi-pubkey. * * Returned `pcLabel` priority: * 1. `member.nickname` (set by the Owner at pairing time) * 2. First 8 chars of the base64-encoded Pi-pubkey (defensive fallback — * keeps cross-PC addressing working even when nicknames are missing) * * Tolerates per-owner errors: a missing/malformed blob for one Owner does * NOT prevent siblings of other Owners from being discovered. Logs and * continues. */ export interface SiblingPi { pcLabel: string; pcPubkey: string; } export interface DiscoverSelfLabelResult { /** This Pi's effective `pc_label` (nickname when any Owner has set one; * pubkey prefix fallback otherwise). */ selfPcLabel: string; } export interface DiscoverOptions { client: MeshClient; ownerEpks: string[]; myPubkey: Uint8Array; log?: { warn(msg: string): void; }; } /** Derive the fallback label from a base64-encoded Pi pubkey. */ export declare function fallbackLabel(pcPubkey: string): string; /** * Resolve self pc_label by scanning every Owner's mesh blob for an entry * matching `myPubkey`. Returns the first nickname found; falls back to the * base64 prefix when no Owner has labeled us. */ export declare function discoverSelfLabel(opts: DiscoverOptions): Promise; /** * Enumerate Pis-irmãos across all Owners. De-duplicated by `pcPubkey`. * Excludes `myPubkey`. * * Label resolution rule (anti-asymmetry — see plan/25 Wave D fix): * 1. Scan EVERY Owner blob first, collecting all distinct sibling * pubkeys and any nicknames seen for each. * 2. For each pubkey, pick label as: first nickname encountered (if * any Owner labeled this Pi), else `fallbackLabel(pubkey)`. * * Why: if two Pis are paired to the same set of Owners but only some * Owners labeled them, naive first-wins dedup can pick the unlabeled * occurrence and discard the labeled one — producing different * `pc_label`s between Pis (PC-A's `discoverSelfLabel` skips non-labeled, * but old `discoverSiblings` didn't). The asymmetry triggers anti-spoof * drops in `broker_remote.handleIncoming`. This rule keeps both sides in * sync: nickname always wins over fallback. */ export declare function discoverSiblings(opts: DiscoverOptions): Promise;