Skip to main content

dig_node_control_interface/
method.rs

1//! The canonical control-method catalog.
2//!
3//! [`ControlMethod`] enumerates every method a client can send to a running dig-node's CONTROL
4//! plane, its stable wire name, whether it requires the local control token, whether it is a
5//! pairing-administration method (which requires the MASTER token specifically), and how the node
6//! routes it (owned by the service shell, delegated to the embedded node engine, or an open
7//! pairing-bootstrap method reachable without a token).
8//!
9//! This is the SINGLE source of truth for "what can be controlled". The node dispatchers, the
10//! client SDKs (CLI `dign`, the extension, dig-app, hub), the OpenRPC/discovery surface, and the
11//! conformance KATs all read this one table, so the method set can never drift between them.
12//!
13//! Mirrors the live dig-node surface: the shell-owned methods in
14//! `dig-node-service/src/control.rs` (`CONTROL_METHODS`) plus the peer/subscription methods
15//! delegated to `dig-node-core` (`control.peerStatus` / `control.peers.*` / `control.subscribe`
16//! / `control.unsubscribe` / `control.listSubscriptions`), and the two OPEN pairing-bootstrap
17//! methods (`pairing.request` / `pairing.poll`) a token-less MV3 extension uses to obtain a
18//! scoped token after local operator approval.
19
20/// How the node resolves a control method — the routing source of truth.
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
22pub enum Routing {
23    /// Answered by the dig-node service shell itself (config/status/cache/pins/sync/updater/pairing-admin).
24    Owned,
25    /// Delegated to the embedded dig-node engine's own control surface (peers + subscriptions).
26    Delegated,
27    /// An OPEN bootstrap method reachable WITHOUT the control token (pairing handshake).
28    OpenBootstrap,
29}
30
31/// The functional area a control method belongs to — for grouping in UIs and docs.
32#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
33pub enum Category {
34    /// Node status snapshot.
35    Status,
36    /// Node configuration (upstream override).
37    Config,
38    /// Live log-level control.
39    Log,
40    /// On-disk content cache.
41    Cache,
42    /// Hosted/pinned stores.
43    HostedStores,
44    /// §21 authenticated whole-store sync.
45    Sync,
46    /// The DIG auto-update beacon proxy.
47    Updater,
48    /// Control-token pairing lifecycle.
49    Pairing,
50    /// The L7 peer network: the live pool snapshot, the per-network peer counts, and dial/drop.
51    Peers,
52    /// The node's subscribed-store set.
53    Subscriptions,
54    /// Wallet chain transport: the read-only chain views (balance, coins, one coin by id, peak,
55    /// sync status) plus the push of an already-signed spend bundle.
56    Wallet,
57    /// dig-profile BODIES: handing the node the bytes a confirmed on-chain root commits to, and
58    /// reading one back. The chain root itself is never written here -- dig-app signs and pushes
59    /// that (§908); this category moves only the bytes an already-confirmed root commits to.
60    Profile,
61}
62
63/// A dig-node CONTROL method.
64///
65/// `#[non_exhaustive]` so adding a method in a minor release is additive; downstream matches must
66/// carry a `_ => …` arm. Convert to/from the wire name with [`ControlMethod::name`] /
67/// [`ControlMethod::from_name`].
68#[non_exhaustive]
69#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
70pub enum ControlMethod {
71    // ---- Status / config / log (shell-owned) ----
72    /// `control.status` — a rich node status snapshot.
73    Status,
74    /// `control.config.get` — the node's effective configuration.
75    ConfigGet,
76    /// `control.config.setUpstream` — persist an upstream-RPC override (effective on restart).
77    ConfigSetUpstream,
78    /// `control.log.setLevel` — live-swap the running node's tracing level filter.
79    LogSetLevel,
80
81    // ---- Cache (shell-owned) ----
82    /// `control.cache.get` — the on-disk cache view (cap/used/dir/shared).
83    CacheGet,
84    /// `control.cache.setCap` — set the cache size cap (floored at 64 MiB).
85    CacheSetCap,
86    /// `control.cache.clear` — delete all locally cached content.
87    CacheClear,
88
89    // ---- Hosted stores (shell-owned) ----
90    /// `control.hostedStores.list` — every held/pinned store with its cached capsules.
91    HostedStoresList,
92    /// `control.hostedStores.pin` — pin a store (and pre-fetch when a root is given).
93    HostedStoresPin,
94    /// `control.hostedStores.unpin` — unpin a store and evict its cached capsules.
95    HostedStoresUnpin,
96    /// `control.hostedStores.status` — per-store pinned flag + cached capsules.
97    HostedStoresStatus,
98
99    // ---- §21 sync (shell-owned) ----
100    /// `control.sync.status` — whether authenticated whole-store sync is available + pin coverage.
101    SyncStatus,
102    /// `control.sync.trigger` — trigger a §21 sync for one capsule (storeId + root).
103    SyncTrigger,
104
105    // ---- Updater beacon proxy (shell-owned) ----
106    /// `control.updater.status` — the DIG auto-update beacon's current status.
107    UpdaterStatus,
108    /// `control.updater.setChannel` — set the beacon's update channel.
109    UpdaterSetChannel,
110    /// `control.updater.pause` — suspend auto-updates (optionally until a unix time).
111    UpdaterPause,
112    /// `control.updater.resume` — resume auto-updates.
113    UpdaterResume,
114    /// `control.updater.checkNow` — force an immediate update check.
115    UpdaterCheckNow,
116
117    // ---- Pairing administration (shell-owned, MASTER-token only) ----
118    /// `control.pairing.list` — list pending pairing requests + issued paired tokens.
119    PairingList,
120    /// `control.pairing.approve` — approve a pending pairing, minting a scoped token.
121    PairingApprove,
122    /// `control.pairing.revoke` — revoke an issued paired token.
123    PairingRevoke,
124
125    // ---- Peers (delegated to the engine) ----
126    /// `control.peerStatus` — live peer-pool + relay-reservation snapshot.
127    PeerStatus,
128    /// `control.peerCounts` — how many peers this node holds on EACH network (DIG and Chia).
129    PeerCounts,
130    /// `control.peers.connect` — dial a peer by address / resolve a connected peer_id.
131    PeersConnect,
132    /// `control.peers.disconnect` — drop a pooled peer by peer_id.
133    PeersDisconnect,
134
135    // ---- Trusted CHIA full-node peers (shell-owned) ----
136    //
137    // A DIFFERENT network from `control.peers.*` above, which are DIG gossip peers. These name
138    // Chia full nodes the wallet replica will TRUST, and trust here is a real cost: NC-12 makes
139    // dialled peers untrusted precisely so that agreement across several concurrently-queried
140    // peers is what makes a read safe. A trusted peer is exempted from that agreement, so a wrong
141    // or hostile one is believed on its own. Every surface that offers these MUST say so.
142    //
143    // Trust comes from the operator declaring a node THEIR OWN — that is the whole of the
144    // authorisation, and the wording everywhere in this crate says exactly that. It is not
145    // "a node you vouch for": the unbounded authority a trusted peer holds is justified by the
146    // operator controlling both ends, which is false of a stranger's node however well
147    // recommended. A person can be talked into vouching for an address; they cannot be talked
148    // into believing they run it.
149    /// `control.chiaPeers.add` — trust a Chia full node you RUN, bypassing corroboration for it.
150    ChiaPeersAdd,
151    /// `control.chiaPeers.list` — the trusted Chia full-node peers this node tracks.
152    ChiaPeersList,
153    /// `control.chiaPeers.remove` — stop trusting a Chia full node (optionally banning it).
154    ChiaPeersRemove,
155
156    // ---- Subscriptions (delegated to the engine) ----
157    /// `control.subscribe` — subscribe the node to a store (watch + gap-fill).
158    Subscribe,
159    /// `control.unsubscribe` — stop watching a store.
160    Unsubscribe,
161    /// `control.listSubscriptions` — the node's persisted subscription set.
162    ListSubscriptions,
163
164    // ---- Wallet chain transport (delegated to the engine) ----
165    /// `control.wallet.balance` — read an address's confirmed spendable balance for an asset.
166    WalletBalance,
167    /// `control.wallet.coins` — read an address's spendable coin records for an asset.
168    WalletCoins,
169    /// `control.wallet.coinById` — read ONE coin record by coin id, spent or unspent.
170    WalletCoinById,
171    /// `control.wallet.coinSpend` — read the SPEND that spent a coin (puzzle reveal + solution).
172    WalletCoinSpend,
173    /// `control.wallet.coinsByParent` — read the direct children a coin's spend created (one hop).
174    WalletCoinsByParent,
175    /// `control.wallet.arrivals` — read confirmed INCOMING funds since a cursor position.
176    WalletArrivals,
177    /// `control.wallet.peak` — read the node's current chain peak height.
178    WalletPeak,
179    /// `control.wallet.syncStatus` — read whether the wallet's chain replica is being kept current.
180    WalletSyncStatus,
181    /// `control.wallet.broadcast` — push an ALREADY-SIGNED spend bundle to the network.
182    WalletBroadcast,
183    /// `control.wallet.watch` — enrol PUBLIC keys for the node's chain replica to follow.
184    WalletWatch,
185    /// `control.wallet.unwatch` — deregister enrolled public keys, so the following stops.
186    WalletUnwatch,
187    /// `control.wallet.watched` — list the public keys currently enrolled.
188    WalletWatched,
189
190    // ---- dig-profile bodies (delegated to the engine) ----
191    /// `control.profile.putBody` — hand the node the profile body a CONFIRMED chain root commits to.
192    ProfilePutBody,
193    /// `control.profile.getBody` — read back the profile body this node holds at a given root.
194    ProfileGetBody,
195
196    // ---- Pairing bootstrap (OPEN — no token) ----
197    /// `pairing.request` — request a control-token pairing (returns a code to compare).
198    PairingRequest,
199    /// `pairing.poll` — poll a pairing; once the operator approves, returns the scoped token once.
200    PairingPoll,
201}
202
203impl ControlMethod {
204    /// The stable JSON-RPC wire name. Never derived from anything else — the published contract.
205    pub const fn name(self) -> &'static str {
206        match self {
207            ControlMethod::Status => "control.status",
208            ControlMethod::ConfigGet => "control.config.get",
209            ControlMethod::ConfigSetUpstream => "control.config.setUpstream",
210            ControlMethod::LogSetLevel => "control.log.setLevel",
211            ControlMethod::CacheGet => "control.cache.get",
212            ControlMethod::CacheSetCap => "control.cache.setCap",
213            ControlMethod::CacheClear => "control.cache.clear",
214            ControlMethod::HostedStoresList => "control.hostedStores.list",
215            ControlMethod::HostedStoresPin => "control.hostedStores.pin",
216            ControlMethod::HostedStoresUnpin => "control.hostedStores.unpin",
217            ControlMethod::HostedStoresStatus => "control.hostedStores.status",
218            ControlMethod::SyncStatus => "control.sync.status",
219            ControlMethod::SyncTrigger => "control.sync.trigger",
220            ControlMethod::UpdaterStatus => "control.updater.status",
221            ControlMethod::UpdaterSetChannel => "control.updater.setChannel",
222            ControlMethod::UpdaterPause => "control.updater.pause",
223            ControlMethod::UpdaterResume => "control.updater.resume",
224            ControlMethod::UpdaterCheckNow => "control.updater.checkNow",
225            ControlMethod::PairingList => "control.pairing.list",
226            ControlMethod::PairingApprove => "control.pairing.approve",
227            ControlMethod::PairingRevoke => "control.pairing.revoke",
228            ControlMethod::PeerStatus => "control.peerStatus",
229            ControlMethod::PeerCounts => "control.peerCounts",
230            ControlMethod::PeersConnect => "control.peers.connect",
231            ControlMethod::PeersDisconnect => "control.peers.disconnect",
232            ControlMethod::ChiaPeersAdd => "control.chiaPeers.add",
233            ControlMethod::ChiaPeersList => "control.chiaPeers.list",
234            ControlMethod::ChiaPeersRemove => "control.chiaPeers.remove",
235            ControlMethod::Subscribe => "control.subscribe",
236            ControlMethod::Unsubscribe => "control.unsubscribe",
237            ControlMethod::ListSubscriptions => "control.listSubscriptions",
238            ControlMethod::WalletBalance => "control.wallet.balance",
239            ControlMethod::WalletCoins => "control.wallet.coins",
240            ControlMethod::WalletCoinById => "control.wallet.coinById",
241            ControlMethod::WalletCoinSpend => "control.wallet.coinSpend",
242            ControlMethod::WalletCoinsByParent => "control.wallet.coinsByParent",
243            ControlMethod::WalletArrivals => "control.wallet.arrivals",
244            ControlMethod::WalletPeak => "control.wallet.peak",
245            ControlMethod::WalletSyncStatus => "control.wallet.syncStatus",
246            ControlMethod::WalletBroadcast => "control.wallet.broadcast",
247            ControlMethod::WalletWatch => "control.wallet.watch",
248            ControlMethod::WalletUnwatch => "control.wallet.unwatch",
249            ControlMethod::WalletWatched => "control.wallet.watched",
250            ControlMethod::ProfilePutBody => "control.profile.putBody",
251            ControlMethod::ProfileGetBody => "control.profile.getBody",
252            ControlMethod::PairingRequest => "pairing.request",
253            ControlMethod::PairingPoll => "pairing.poll",
254        }
255    }
256
257    /// Resolve a wire name back to its [`ControlMethod`], or `None` for an unknown name.
258    pub fn from_name(name: &str) -> Option<ControlMethod> {
259        ControlMethod::ALL
260            .iter()
261            .copied()
262            .find(|m| m.name() == name)
263    }
264
265    /// Does calling this method require the local control token?
266    ///
267    /// Three groups are reachable WITHOUT one, and they are open for two different reasons:
268    ///
269    /// - the pairing bootstrap (`pairing.request` / `pairing.poll`), so a token-less client can
270    ///   obtain a token at all;
271    /// - the PEER COUNTS (`control.peerCounts`), which disclose three integers about this node's
272    ///   own connectivity and no address, endpoint or secret;
273    /// - the wallet CALLER-ADDRESSED CHAIN READS (`control.wallet.balance` / `.coins` /
274    ///   `.coinById` / `.coinSpend` / `.coinsByParent`) and the node's own chain POSITION
275    ///   (`.peak` / `.syncStatus`), because each needs only PUBLIC chain data the CALLER already
276    ///   named — an address, or a coin id; never a seed, a key, or a signature — and dig-node has
277    ///   served `control.wallet.balance` open since #1851. A person whose node runs as a service
278    ///   with an unreadable token file can still see their own money.
279    ///
280    /// Five wallet methods are deliberately NOT in that second group:
281    ///
282    /// - `control.wallet.broadcast` puts bytes on the network, so the token is what stands between
283    ///   a local process and a broadcast — a mutation on the chain state itself;
284    /// - `control.wallet.watch` and `.unwatch` aim what this node follows, so they are mutations
285    ///   of this node's own watched-key set;
286    /// - `control.wallet.arrivals` and `.watched` take nothing from the caller and answer back
287    ///   with this node's OWN state — watched puzzle hashes and enrolled public keys respectively.
288    ///
289    /// See [`ControlMethod::is_open_read`]. On all five, `UNAUTHORIZED` genuinely means
290    /// *unauthorized*.
291    pub const fn requires_auth(self) -> bool {
292        !self.is_open_read()
293            && !matches!(
294                self,
295                ControlMethod::PairingRequest | ControlMethod::PairingPoll
296            )
297    }
298
299    /// Is this an OPEN READ — served without a control token?
300    ///
301    /// Two kinds of method qualify, and they are open for different reasons:
302    ///
303    /// - the wallet CHAIN READS (`control.wallet.balance` / `.coins` / `.coinById` / `.coinSpend` /
304    ///   `.coinsByParent` / `.peak` / `.syncStatus`), which need only PUBLIC chain data — an
305    ///   address, or a coin id; never a seed, a key, or a signature. On the first five the CALLER
306    ///   supplies the address or coin id, so the node relays a public fact and discloses no
307    ///   association with itself; the last two name the node's own chain position and no address
308    ///   at all;
309    /// - `control.peerCounts`, which is NOT a chain read: it discloses three integers about this
310    ///   node's own connectivity, and no address, endpoint, peer identity or secret. The identity
311    ///   and topology half of the same subject stays gated behind `control.peerStatus`.
312    ///
313    /// Naming both reasons matters more than it looks. The test for membership is *does this
314    /// disclose only data that is already public, or a bare count of this node's own state?* — NOT
315    /// *is it a chain read?* A future method judged against the narrower phrasing, and found to
316    /// contradict a member that was already there, invites widening the predicate by analogy rather
317    /// than against the rule.
318    ///
319    /// `control.wallet.arrivals` is the worked example, and it was briefly a member. It passes the
320    /// narrower phrasing — every field it returns is a public chain fact — and fails the rule: the
321    /// caller supplies NOTHING, so the node volunteers its OWN watched puzzle hashes together with
322    /// the full receive history behind them. The individual facts are public; the ASSOCIATION
323    /// between this node and those addresses is not, and that association is the whole answer. A
324    /// token-less caller could then feed those addresses back into the caller-addressed reads.
325    /// Membership turns on *who names the address*, never on whether the bytes are on chain.
326    ///
327    /// Stated on the contract rather than discovered by calling, because the two refusals a client
328    /// can get here demand OPPOSITE remedies. On an open read, `UNAUTHORIZED` can only come from a
329    /// node build that predates the method and gates it generically, so the remedy is an upgrade.
330    /// On a gated method — the push — `UNAUTHORIZED` means exactly what it says, and the remedy is
331    /// the token. A client that maps the two the same way sends somebody to fix the wrong thing.
332    pub const fn is_open_read(self) -> bool {
333        matches!(
334            self,
335            ControlMethod::WalletBalance
336                | ControlMethod::WalletCoins
337                | ControlMethod::WalletCoinById
338                | ControlMethod::WalletCoinSpend
339                | ControlMethod::WalletCoinsByParent
340                | ControlMethod::WalletPeak
341                | ControlMethod::WalletSyncStatus
342                | ControlMethod::PeerCounts
343        )
344    }
345
346    /// Is this a PAIRING-ADMINISTRATION method that requires the MASTER control token specifically?
347    ///
348    /// A paired (scoped) token can drive ordinary `control.*` mutations but MUST NOT mint more
349    /// tokens or revoke itself — so listing/approving/revoking pairings requires the master token
350    /// (a local file read), never a paired token.
351    ///
352    /// This names the pairing LIFECYCLE only. The predicate an auth gate consults is
353    /// [`ControlMethod::requires_master_token`], of which this is a strict subset.
354    pub const fn is_pairing_admin(self) -> bool {
355        matches!(
356            self,
357            ControlMethod::PairingList
358                | ControlMethod::PairingApprove
359                | ControlMethod::PairingRevoke
360        )
361    }
362
363    /// Does this method require the MASTER control token — the local file read — rather than any
364    /// valid token?
365    ///
366    /// **This, not [`ControlMethod::is_pairing_admin`], is the predicate an auth gate consults.**
367    /// The master tier is not "pairing administration"; it is every method whose effect OUTLIVES
368    /// the token that invoked it, and pairing administration is one instance of that shape.
369    ///
370    /// The rule, stated so a later method can be judged against it rather than by analogy: a
371    /// method belongs here when a caller holding a paired token could use it to acquire authority
372    /// it keeps AFTER that token is revoked. `pairing.revoke` is the designated remedy for a
373    /// compromised paired app, so any method that survives it has escaped the remedy.
374    ///
375    /// The two members outside the pairing lifecycle are `control.chiaPeers.add` and
376    /// `control.chiaPeers.remove`, and they are here for exactly that reason. `add` writes a
377    /// standing entry into the peer store the wallet replica reads, and a peer in that set is
378    /// believed WITHOUT corroboration — it can dictate money-bearing chain facts (peak height, and
379    /// therefore confirmation counts). Once written, the caller no longer needs the token at all,
380    /// and revoking the token does not remove the entry. A paired token must therefore not be able
381    /// to write one. `remove` is the only un-trust remedy and is gated with it, so a paired token
382    /// cannot strip the peers an operator deliberately trusts.
383    ///
384    /// `control.chiaPeers.list` deliberately stays on the ordinary token tier: it is a READ, it
385    /// grants nothing that outlives the token, and gating it would leave a paired client unable to
386    /// show the operator the trust state it is subject to. That matches `control.wallet.arrivals`,
387    /// which is gated at the ordinary tier for disclosing an association without conferring
388    /// authority.
389    pub const fn requires_master_token(self) -> bool {
390        self.is_pairing_admin()
391            || matches!(
392                self,
393                ControlMethod::ChiaPeersAdd | ControlMethod::ChiaPeersRemove
394            )
395    }
396
397    /// How the node routes this method (shell-owned, engine-delegated, or open bootstrap).
398    pub const fn routing(self) -> Routing {
399        match self {
400            ControlMethod::PeerStatus
401            | ControlMethod::PeerCounts
402            | ControlMethod::PeersConnect
403            | ControlMethod::PeersDisconnect
404            | ControlMethod::Subscribe
405            | ControlMethod::Unsubscribe
406            | ControlMethod::ListSubscriptions
407            | ControlMethod::WalletBalance
408            | ControlMethod::WalletCoins
409            | ControlMethod::WalletCoinById
410            | ControlMethod::WalletCoinSpend
411            | ControlMethod::WalletCoinsByParent
412            | ControlMethod::WalletArrivals
413            | ControlMethod::WalletPeak
414            | ControlMethod::WalletSyncStatus
415            | ControlMethod::WalletBroadcast
416            | ControlMethod::WalletWatch
417            | ControlMethod::WalletUnwatch
418            | ControlMethod::WalletWatched
419            | ControlMethod::ProfilePutBody
420            | ControlMethod::ProfileGetBody => Routing::Delegated,
421            ControlMethod::PairingRequest | ControlMethod::PairingPoll => Routing::OpenBootstrap,
422            _ => Routing::Owned,
423        }
424    }
425
426    /// The functional area this method belongs to.
427    pub const fn category(self) -> Category {
428        match self {
429            ControlMethod::Status => Category::Status,
430            ControlMethod::ConfigGet | ControlMethod::ConfigSetUpstream => Category::Config,
431            ControlMethod::LogSetLevel => Category::Log,
432            ControlMethod::CacheGet | ControlMethod::CacheSetCap | ControlMethod::CacheClear => {
433                Category::Cache
434            }
435            ControlMethod::HostedStoresList
436            | ControlMethod::HostedStoresPin
437            | ControlMethod::HostedStoresUnpin
438            | ControlMethod::HostedStoresStatus => Category::HostedStores,
439            ControlMethod::SyncStatus | ControlMethod::SyncTrigger => Category::Sync,
440            ControlMethod::UpdaterStatus
441            | ControlMethod::UpdaterSetChannel
442            | ControlMethod::UpdaterPause
443            | ControlMethod::UpdaterResume
444            | ControlMethod::UpdaterCheckNow => Category::Updater,
445            ControlMethod::PairingList
446            | ControlMethod::PairingApprove
447            | ControlMethod::PairingRevoke
448            | ControlMethod::PairingRequest
449            | ControlMethod::PairingPoll => Category::Pairing,
450            ControlMethod::PeerStatus
451            | ControlMethod::PeerCounts
452            | ControlMethod::PeersConnect
453            | ControlMethod::PeersDisconnect
454            | ControlMethod::ChiaPeersAdd
455            | ControlMethod::ChiaPeersList
456            | ControlMethod::ChiaPeersRemove => Category::Peers,
457            ControlMethod::Subscribe
458            | ControlMethod::Unsubscribe
459            | ControlMethod::ListSubscriptions => Category::Subscriptions,
460            ControlMethod::WalletBalance
461            | ControlMethod::WalletCoins
462            | ControlMethod::WalletCoinById
463            | ControlMethod::WalletCoinSpend
464            | ControlMethod::WalletCoinsByParent
465            | ControlMethod::WalletArrivals
466            | ControlMethod::WalletPeak
467            | ControlMethod::WalletSyncStatus
468            | ControlMethod::WalletBroadcast
469            | ControlMethod::WalletWatch
470            | ControlMethod::WalletUnwatch
471            | ControlMethod::WalletWatched => Category::Wallet,
472            ControlMethod::ProfilePutBody | ControlMethod::ProfileGetBody => Category::Profile,
473        }
474    }
475
476    /// A one-line human/agent description for the discovery catalogue.
477    pub const fn summary(self) -> &'static str {
478        match self {
479            ControlMethod::ChiaPeersAdd => "Trust a Chia full node by IP. A trusted peer BYPASSES CORROBORATION: this node normally believes a chain answer only when several independently-dialled peers agree, and a trusted peer is believed on its own -- so a wrong or hostile one can feed this node a false view of the chain. Add only a node you run yourself.",
480            ControlMethod::ChiaPeersList => "The Chia full-node peers this node tracks, each flagged user_managed: true where a person added it by hand and it is therefore trusted without corroboration.",
481            ControlMethod::ChiaPeersRemove => "Stop trusting a Chia full node, optionally banning it. Removing restores corroboration for that peer: chain answers must once again be agreed by independently-dialled peers.",
482            ControlMethod::Status => "A rich node status snapshot (version, uptime, addr, cache, hosted/pinned counts, sync availability).",
483            ControlMethod::ConfigGet => "The node's effective configuration (addr/port, upstream + override, cache dir/shared, config path, sync availability).",
484            ControlMethod::ConfigSetUpstream => "Persist an upstream-RPC override; takes effect on next node start (requires_restart).",
485            ControlMethod::LogSetLevel => "Live-swap the running node's tracing EnvFilter directive (not persisted).",
486            ControlMethod::CacheGet => "The on-disk content-cache view: cap_bytes, used_bytes, dir, shared.",
487            ControlMethod::CacheSetCap => "Set the on-disk cache size cap in bytes (floored at 64 MiB).",
488            ControlMethod::CacheClear => "Delete all locally cached DIG content.",
489            ControlMethod::HostedStoresList => "Every held/pinned store, merged, with each store's cached capsules and a pinned flag.",
490            ControlMethod::HostedStoresPin => "Pin a store (storeId[:rootHash]); pre-fetches the capsule when a root is given and §21 sync is available.",
491            ControlMethod::HostedStoresUnpin => "Unpin a store and evict its cached capsules.",
492            ControlMethod::HostedStoresStatus => "Per-store status: pinned flag, cached capsules, total bytes.",
493            ControlMethod::SyncStatus => "Whether authenticated §21 whole-store sync is available, plus pinned-store cache coverage.",
494            ControlMethod::SyncTrigger => "Trigger a §21 sync for one capsule (storeId + root).",
495            ControlMethod::UpdaterStatus => "The DIG auto-update beacon's current status (proxied from dig-updater).",
496            ControlMethod::UpdaterSetChannel => "Set the beacon's update channel (\"nightly\" | \"stable\").",
497            ControlMethod::UpdaterPause => "Suspend the beacon's auto-updates (optionally until a unix time).",
498            ControlMethod::UpdaterResume => "Resume the beacon's auto-updates.",
499            ControlMethod::UpdaterCheckNow => "Force an immediate beacon update check.",
500            ControlMethod::PairingList => "List pending pairing requests and issued paired tokens (MASTER token only).",
501            ControlMethod::PairingApprove => "Approve a pending pairing, minting a scoped token (MASTER token only).",
502            ControlMethod::PairingRevoke => "Revoke an issued paired token by token_id (MASTER token only).",
503            ControlMethod::PeerStatus => "Live peer-pool + relay-reservation snapshot, including the per-peer connected array; each entry carries an always-present `software` field (the peer's advertised build). Its `relay.peer_count` counts peers connected to THE RELAY, not to this node, and is never the answer to \"how many peers does this node have\" -- that is control.peerCounts.",
504            ControlMethod::PeerCounts => "READ-only: how many peers this node holds on EACH network -- dig_peer_count (DIG content/gossip, port 9445) and chia_peer_count (Chia full nodes serving the wallet chain sync). Two unrelated numbers, each named for its network.",
505            ControlMethod::PeersConnect => "Dial a peer by address, or resolve an already-connected peer_id, via the live gossip pool.",
506            ControlMethod::PeersDisconnect => "Drop a pooled peer by peer_id, closing its mTLS link (idempotent).",
507            ControlMethod::Subscribe => "Subscribe the node to a store it actively watches and gap-fills.",
508            ControlMethod::Unsubscribe => "Stop watching a store.",
509            ControlMethod::ListSubscriptions => "The node's persisted subscription set + count.",
510            ControlMethod::WalletCoins => "READ-only: the spendable coin records for an address + asset, with the tier that answered and the height they reflect.",
511            ControlMethod::WalletCoinById => "READ-only: ONE coin record by coin id, spent or unspent, with no address and no asset scope; `coin: null` means the chain holds no such coin.",
512            ControlMethod::WalletCoinSpend => "READ-only: the SPEND that spent a coin -- its puzzle reveal, its solution and the coin itself -- named by the coin's own id. `spend: null` means the consulted chain shows that coin as unspent or unknown; it NEVER means the chain could not be reached, which is an error.",
513            ControlMethod::WalletCoinsByParent => "READ-only: the DIRECT children created by spending one coin, named by that parent's coin id. ONE hop, never a recursive walk: an empty list means the parent created no known children, and a caller wanting a lineage composes hops itself.",
514            ControlMethod::WalletArrivals => "READ-only: confirmed INCOMING funds recorded since a cursor position, oldest first -- the answer to `was I just paid?`, which no balance or coin list can give. Each row is a coin the node determined ARRIVED: confirmed on chain, above the wallet's arrival baseline, not previously reported, and not the wallet's own change. Resume from `cursor` (the last row you were handed), never from `latest`.",
515            ControlMethod::WalletPeak => "READ-only: the node's current chain peak height, independent of any address.",
516            ControlMethod::WalletSyncStatus => "READ-only: whether the wallet's CHAIN replica is being kept current (not_started/syncing/synced/no_wallet_enrolled/wallet_not_unlocked), the replica's own height, and its CHIA full-node peer count -- unrelated to control.sync.status (DIG stores) and to control.peerStatus (DIG peers).",
517            ControlMethod::WalletBroadcast => "Push an ALREADY-SIGNED spend bundle to the network; the node never signs. TOKEN-GATED.",
518            ControlMethod::WalletBalance => "READ-only: the confirmed spendable balance for an address + asset (plus pending, sync freshness, and the peak height it reflects).",
519            ControlMethod::WalletWatch => "Enrol PUBLIC keys (48-byte G1, lowercase 96-hex) for the node's chain replica to follow, so their addresses are synced and readable. IDEMPOTENT: re-enrolling a key already enrolled succeeds and changes nothing. Keys, never puzzle hashes -- the node derives the addresses itself, so one derivation serves every client. TOKEN-GATED.",
520            ControlMethod::WalletUnwatch => "Deregister enrolled public keys, so the node stops following their addresses. IDEMPOTENT: a key that was never enrolled is not an error. TOKEN-GATED.",
521            ControlMethod::ProfilePutBody => "Hand the node the dig-profile BODY that a chain root commits to. The node INDEPENDENTLY resolves that root on chain and REFUSES any body whose recomputed root is not the confirmed one -- the caller's `root` is a claim to be checked, never a fact to be trusted, and dig-app is a caller like any other. Bodies are capped at MAX_BODY_BYTES (4 MiB). TOKEN-GATED.",
522            ControlMethod::ProfileGetBody => "READ-only: the dig-profile body this node holds at a given store id + root, or `body: null` when it holds none. `null` NEVER means the body could not be read, which is an error. TOKEN-GATED.",
523            ControlMethod::WalletWatched => "READ-only: the public keys currently enrolled, so a client can reconcile what it asked for against what the node holds. TOKEN-GATED although it is a read -- the caller supplies nothing, so the answer is this node's OWN key set.",
524            ControlMethod::PairingRequest => "OPEN: request a control-token pairing; returns a pairing_id + pairing_code to compare.",
525            ControlMethod::PairingPoll => "OPEN: poll a pairing by id; once the operator approves, returns the scoped token once.",
526        }
527    }
528
529    /// Every catalogued method, in a stable order — the enumeration a machine reads to discover the
530    /// full control surface, and the anchor the conformance KATs pin against.
531    pub const ALL: &'static [ControlMethod] = &[
532        ControlMethod::Status,
533        ControlMethod::ConfigGet,
534        ControlMethod::ConfigSetUpstream,
535        ControlMethod::LogSetLevel,
536        ControlMethod::CacheGet,
537        ControlMethod::CacheSetCap,
538        ControlMethod::CacheClear,
539        ControlMethod::HostedStoresList,
540        ControlMethod::HostedStoresPin,
541        ControlMethod::HostedStoresUnpin,
542        ControlMethod::HostedStoresStatus,
543        ControlMethod::SyncStatus,
544        ControlMethod::SyncTrigger,
545        ControlMethod::UpdaterStatus,
546        ControlMethod::UpdaterSetChannel,
547        ControlMethod::UpdaterPause,
548        ControlMethod::UpdaterResume,
549        ControlMethod::UpdaterCheckNow,
550        ControlMethod::PairingList,
551        ControlMethod::PairingApprove,
552        ControlMethod::PairingRevoke,
553        ControlMethod::PeerStatus,
554        ControlMethod::PeerCounts,
555        ControlMethod::PeersConnect,
556        ControlMethod::PeersDisconnect,
557        ControlMethod::ChiaPeersAdd,
558        ControlMethod::ChiaPeersList,
559        ControlMethod::ChiaPeersRemove,
560        ControlMethod::Subscribe,
561        ControlMethod::Unsubscribe,
562        ControlMethod::ListSubscriptions,
563        ControlMethod::WalletBalance,
564        ControlMethod::WalletCoins,
565        ControlMethod::WalletCoinById,
566        ControlMethod::WalletCoinSpend,
567        ControlMethod::WalletCoinsByParent,
568        ControlMethod::WalletArrivals,
569        ControlMethod::WalletPeak,
570        ControlMethod::WalletSyncStatus,
571        ControlMethod::WalletBroadcast,
572        ControlMethod::WalletWatch,
573        ControlMethod::WalletUnwatch,
574        ControlMethod::WalletWatched,
575        ControlMethod::ProfilePutBody,
576        ControlMethod::ProfileGetBody,
577        ControlMethod::PairingRequest,
578        ControlMethod::PairingPoll,
579    ];
580}
581
582#[cfg(test)]
583mod tests {
584    use super::*;
585    use std::collections::BTreeSet;
586
587    #[test]
588    fn every_method_has_a_unique_wire_name() {
589        let names: BTreeSet<&str> = ControlMethod::ALL.iter().map(|m| m.name()).collect();
590        assert_eq!(
591            names.len(),
592            ControlMethod::ALL.len(),
593            "duplicate or missing wire names in the catalog"
594        );
595    }
596
597    #[test]
598    fn from_name_round_trips_every_method() {
599        for &m in ControlMethod::ALL {
600            assert_eq!(ControlMethod::from_name(m.name()), Some(m));
601        }
602        assert_eq!(ControlMethod::from_name("control.nope"), None);
603        assert_eq!(ControlMethod::from_name(""), None);
604    }
605
606    #[test]
607    fn the_token_less_surface_is_exactly_the_bootstrap_plus_the_chain_reads() {
608        // Written out rather than derived from `is_open_read`, so this pins the SET and not the
609        // implementation's opinion of itself. A method added to the open surface must be added
610        // here deliberately -- which is the review step a broadcast must never slip past.
611        let expected_open: BTreeSet<&str> = [
612            "pairing.request",
613            "pairing.poll",
614            "control.wallet.balance",
615            "control.wallet.coins",
616            "control.wallet.coinById",
617            "control.wallet.coinSpend",
618            "control.wallet.coinsByParent",
619            "control.wallet.peak",
620            "control.wallet.syncStatus",
621            "control.peerCounts",
622        ]
623        .into_iter()
624        .collect();
625        assert_eq!(
626            expected_open.len(),
627            10,
628            "the open surface is ten named methods"
629        );
630        let actual_open: BTreeSet<&str> = ControlMethod::ALL
631            .iter()
632            .filter(|m| !m.requires_auth())
633            .map(|m| m.name())
634            .collect();
635        assert_eq!(actual_open, expected_open);
636    }
637
638    /// **The gated wallet methods are the push, the arrival cursor, and the three enrolment
639    /// methods.** The fixture varies one thing -- which wallet method is asked -- against a category
640    /// whose other members ARE open, so both nearest wrong implementations fail here: one that opens
641    /// the whole category (the state this crate shipped in at `1190a18`) and one that gates it
642    /// wholesale.
643    ///
644    /// Written out in catalog order rather than derived, so a method joining the gated side is a
645    /// deliberate edit here -- the review step a broadcast, or an enrolment, must never slip past.
646    #[test]
647    fn the_gated_wallet_methods_are_the_push_the_cursor_and_enrolment() {
648        let gated: Vec<&str> = ControlMethod::ALL
649            .iter()
650            .filter(|m| m.category() == Category::Wallet && m.requires_auth())
651            .map(|m| m.name())
652            .collect();
653        assert_eq!(
654            gated,
655            vec![
656                "control.wallet.arrivals",
657                "control.wallet.broadcast",
658                "control.wallet.watch",
659                "control.wallet.unwatch",
660                "control.wallet.watched",
661            ]
662        );
663        assert!(!ControlMethod::WalletBroadcast.is_open_read());
664    }
665
666    /// **The arrival cursor is NOT an open read, and the reason is not "is it a chain read?".**
667    ///
668    /// The rule is *who names the address*. `control.wallet.arrivals` takes only a cursor, so the
669    /// node volunteers its OWN watched puzzle hashes and the receive history behind them -- the
670    /// node-to-address association, which is not public, and which a token-less caller could then
671    /// replay into the caller-addressed reads.
672    ///
673    /// The control keeps `control.wallet.coinById` in the same assertion: it is the neighbour the
674    /// analogy was drawn from, it is still open, and it stays open because its CALLER supplies the
675    /// coin id. Without that control this test would also pass on a wholesale gating of the wallet
676    /// category, which is a different (and wrong) implementation.
677    #[test]
678    fn the_arrival_cursor_is_not_an_open_read() {
679        assert!(
680            !ControlMethod::WalletArrivals.is_open_read(),
681            "control.wallet.arrivals discloses this node's OWN watched puzzle hashes to a caller \
682             that supplied nothing, so it MUST NOT be served token-less"
683        );
684        assert!(ControlMethod::WalletArrivals.requires_auth());
685        assert!(
686            ControlMethod::WalletCoinById.is_open_read(),
687            "the caller-addressed reads stay open -- the fix is the membership rule, not gating \
688             the wallet category"
689        );
690    }
691
692    /// **The control plane names every chain primitive `ChainSource` needs.**
693    ///
694    /// The list is written out rather than derived, because the property under test is a claim about
695    /// ANOTHER crate's trait (`dig-chainsource-interface`'s `ChainSource`) that no compiler here can
696    /// check. Five of its seven methods need a control method of their own. The other two need none:
697    /// `parent_spend` is a trait DEFAULT composed from `coin_record` + `coin_spend`, and
698    /// `resolve_singleton_lineage` is composed CLIENT-side from the primitives below rather than
699    /// served as a walk the node performs.
700    ///
701    /// `block_timestamp` is deliberately ABSENT from the control plane. dig-node's light client
702    /// (`chia-peer`'s `ChiaPeerProvider`) does not index block timestamps and answers `Unsupported`,
703    /// so a control method for it could only ever be refused — a surface that looks live and does
704    /// nothing. A consumer mirrors that refusal honestly; if one ever genuinely needs the value, the
705    /// method is an additive minor at that point.
706    ///
707    /// A missing name here is not a cosmetic gap: a client that cannot answer one of these cannot
708    /// implement the trait at all, which is what made a dig-profile mint structurally impossible
709    /// through the node before these two were added (dig_ecosystem#2572).
710    #[test]
711    fn the_catalog_serves_every_chain_source_primitive() {
712        for wire in [
713            "control.wallet.coinById",      // coin_record
714            "control.wallet.coins",         // coin_records_by_puzzle_hash
715            "control.wallet.peak",          // peak_height
716            "control.wallet.coinsByParent", // coin_records_by_parent
717            "control.wallet.coinSpend",     // coin_spend
718        ] {
719            assert!(
720                ControlMethod::from_name(wire).is_some(),
721                "{wire} is required to implement ChainSource over the control plane"
722            );
723        }
724    }
725
726    /// **The two chain primitives are `coinById`'s neighbours, not `arrivals`'.**
727    ///
728    /// Each takes a caller-supplied coin id and returns a deterministic public chain fact,
729    /// so the membership rule — *who names the subject* — puts them on the open side. The gated
730    /// control in the same assertion is what makes the test load-bearing: without it, a wholesale
731    /// opening of the wallet category would pass, and that is a different (and wrong) implementation.
732    #[test]
733    fn the_chain_primitives_are_caller_named_open_reads() {
734        for method in [
735            ControlMethod::WalletCoinSpend,
736            ControlMethod::WalletCoinsByParent,
737        ] {
738            assert!(
739                method.is_open_read(),
740                "{} names its subject in the request and discloses no node-to-address \
741                 association, exactly like control.wallet.coinById",
742                method.name()
743            );
744            assert!(!method.requires_auth());
745        }
746        assert!(
747            ControlMethod::WalletArrivals.requires_auth(),
748            "the caller-supplies-nothing read stays gated -- the rule is who names the subject, \
749             not whether the bytes are on chain"
750        );
751        assert!(ControlMethod::WalletBroadcast.requires_auth());
752    }
753
754    /// **All three enrolment methods are gated — including the one that only reads.**
755    ///
756    /// `control.wallet.watch` and `.unwatch` aim what the node follows, so they are mutations and the
757    /// question barely arises. `control.wallet.watched` is the one a future reader will be tempted to
758    /// open, because it returns nothing but public keys and every other wallet READ in this catalog is
759    /// open. It stays gated under the SAME rule that gates `control.wallet.arrivals`: the caller
760    /// supplies nothing, so the node volunteers its OWN enrolled keys — the node-to-key association,
761    /// which is not public, and which a token-less caller could replay straight into the
762    /// caller-addressed reads.
763    ///
764    /// The control keeps `control.wallet.coinById` open in the same assertion. Without it this test
765    /// would also pass on a wholesale gating of the wallet category, which is a different (and wrong)
766    /// implementation.
767    #[test]
768    fn the_enrolment_methods_are_gated_including_the_read() {
769        for wire in [
770            "control.wallet.watch",
771            "control.wallet.unwatch",
772            "control.wallet.watched",
773        ] {
774            let method = ControlMethod::from_name(wire)
775                .unwrap_or_else(|| panic!("{wire} must be in the catalog"));
776            assert!(
777                !method.is_open_read(),
778                "{wire} either aims this node's subscriptions or names the keys it already \
779                 follows, so it MUST NOT be served token-less"
780            );
781            assert!(method.requires_auth(), "{wire} must require the token");
782            assert_eq!(method.category(), Category::Wallet);
783            assert_eq!(method.routing(), Routing::Delegated);
784        }
785        assert!(
786            ControlMethod::WalletCoinById.is_open_read(),
787            "the caller-addressed reads stay open -- enrolment is gated by the membership rule, \
788             not by gating the wallet category"
789        );
790    }
791
792    #[test]
793    fn only_pairing_bootstrap_is_open_bootstrap_routed() {
794        for &m in ControlMethod::ALL {
795            let open_bootstrap = matches!(
796                m,
797                ControlMethod::PairingRequest | ControlMethod::PairingPoll
798            );
799            assert_eq!(
800                m.routing() == Routing::OpenBootstrap,
801                open_bootstrap,
802                "{} routing mismatch",
803                m.name()
804            );
805        }
806    }
807
808    #[test]
809    fn pairing_admin_methods_are_exactly_three() {
810        let admin: Vec<&str> = ControlMethod::ALL
811            .iter()
812            .filter(|m| m.is_pairing_admin())
813            .map(|m| m.name())
814            .collect();
815        assert_eq!(
816            admin,
817            vec![
818                "control.pairing.list",
819                "control.pairing.approve",
820                "control.pairing.revoke"
821            ]
822        );
823    }
824
825    /// **The master-token tier is the pairing lifecycle PLUS the trusted-peer mutations.**
826    ///
827    /// The set is asserted whole, because the risk is a method quietly joining or leaving it. The
828    /// two non-pairing members are here for a stated reason — `chiaPeers.add` grants authority
829    /// that SURVIVES `pairing.revoke`, so a paired token holding it escapes the very remedy for a
830    /// compromised paired app.
831    #[test]
832    fn the_master_token_tier_is_pairing_admin_plus_the_trusted_peer_mutations() {
833        let master: BTreeSet<&str> = ControlMethod::ALL
834            .iter()
835            .filter(|m| m.requires_master_token())
836            .map(|m| m.name())
837            .collect();
838        let expected: BTreeSet<&str> = [
839            "control.pairing.list",
840            "control.pairing.approve",
841            "control.pairing.revoke",
842            "control.chiaPeers.add",
843            "control.chiaPeers.remove",
844        ]
845        .into_iter()
846        .collect();
847        assert_eq!(master, expected);
848
849        // Pairing administration is a STRICT subset, not a synonym: a gate that consults
850        // `is_pairing_admin` instead of `requires_master_token` lets a paired token add a peer.
851        for &m in ControlMethod::ALL {
852            assert!(
853                !m.is_pairing_admin() || m.requires_master_token(),
854                "{} is pairing-admin but not master-tier",
855                m.name()
856            );
857        }
858        assert!(
859            master.len()
860                > ControlMethod::ALL
861                    .iter()
862                    .filter(|m| m.is_pairing_admin())
863                    .count(),
864            "the two predicates must not be interchangeable"
865        );
866
867        // Master implies the token is required at all.
868        for &m in ControlMethod::ALL {
869            assert!(
870                !m.requires_master_token() || m.requires_auth(),
871                "{}",
872                m.name()
873            );
874        }
875    }
876
877    /// **The trust wording stays inside NC-12's authorisation: a node the operator RUNS.**
878    ///
879    /// NC-12 permits trust only from "the operator declaring it their own node". Widening that to
880    /// vouching moves the case outside the justification for the unbounded authority the entry
881    /// carries, and "a node you vouch for" is a phrase somebody can be talked into applying to a
882    /// stranger's address.
883    #[test]
884    fn the_add_summary_authorises_only_a_node_the_operator_runs() {
885        let summary = ControlMethod::ChiaPeersAdd.summary().to_lowercase();
886        assert!(
887            summary.contains("a node you run"),
888            "add must name the operator-run scope, got: {summary}"
889        );
890        for widened in ["vouch", "otherwise trust", "trust yourself", "recommend"] {
891            assert!(
892                !summary.contains(widened),
893                "add summary widens operator trust past NC-12 with {widened:?}: {summary}"
894            );
895        }
896    }
897
898    #[test]
899    fn delegated_set_matches_the_engine_surface() {
900        let delegated: BTreeSet<&str> = ControlMethod::ALL
901            .iter()
902            .filter(|m| m.routing() == Routing::Delegated)
903            .map(|m| m.name())
904            .collect();
905        let expected: BTreeSet<&str> = [
906            "control.wallet.coins",
907            "control.wallet.coinById",
908            "control.wallet.coinSpend",
909            "control.wallet.coinsByParent",
910            "control.wallet.arrivals",
911            "control.wallet.peak",
912            "control.wallet.syncStatus",
913            "control.wallet.broadcast",
914            "control.wallet.watch",
915            "control.wallet.unwatch",
916            "control.wallet.watched",
917            "control.profile.putBody",
918            "control.profile.getBody",
919            "control.peerStatus",
920            "control.peerCounts",
921            "control.peers.connect",
922            "control.peers.disconnect",
923            "control.subscribe",
924            "control.unsubscribe",
925            "control.listSubscriptions",
926            "control.wallet.balance",
927        ]
928        .into_iter()
929        .collect();
930        assert_eq!(delegated, expected);
931    }
932
933    /// **The trusted-Chia-peer methods are declared, gated, and say what they cost.**
934    ///
935    /// A trusted peer BYPASSES corroboration (NC-12: dialled peers are untrusted and agreement
936    /// across ~5 concurrently-queried peers is what makes a read safe). The catalog is what a
937    /// machine reads before offering the control, so the cost is stated HERE and not only in a
938    /// doc page — a client that surfaces `summary()` surfaces the warning with it.
939    #[test]
940    fn the_trusted_chia_peer_methods_are_gated_and_disclose_the_corroboration_bypass() {
941        let declared: BTreeSet<&str> = ControlMethod::ALL.iter().map(|m| m.name()).collect();
942        for name in [
943            "control.chiaPeers.add",
944            "control.chiaPeers.list",
945            "control.chiaPeers.remove",
946        ] {
947            assert!(declared.contains(name), "{name} is not in the catalog");
948            let m = ControlMethod::from_name(name).expect("from_name round-trips");
949            assert_eq!(m.category(), Category::Peers, "{name} is a peers method");
950            assert_eq!(m.routing(), Routing::Owned, "{name} is served by the shell");
951            assert!(m.requires_auth(), "{name} must require the control token");
952            assert!(!m.is_open_read(), "{name} is not an open read");
953        }
954        // The MUTATIONS need the MASTER token; the READ deliberately does not. `add` writes
955        // standing, corroboration-free authority that outlives the token that wrote it — a paired
956        // token must not be able to install it, and `remove` is the only way back out.
957        assert!(ControlMethod::ChiaPeersAdd.requires_master_token());
958        assert!(ControlMethod::ChiaPeersRemove.requires_master_token());
959        assert!(
960            !ControlMethod::ChiaPeersList.requires_master_token(),
961            "list grants nothing that outlives the token; gating it would blind a paired client \
962             to the trust state it is subject to"
963        );
964        // The COST, not merely the capability: the two methods that change the trusted set must
965        // name the bypass. A summary that only described the action would let a client offer the
966        // control while silently withholding what it gives up.
967        for name in ["control.chiaPeers.add", "control.chiaPeers.remove"] {
968            let summary = ControlMethod::from_name(name).unwrap().summary();
969            assert!(
970                summary.to_lowercase().contains("corroboration"),
971                "{name} summary must name the corroboration bypass, got: {summary}"
972            );
973        }
974    }
975
976    #[test]
977    fn every_method_has_a_nonempty_summary() {
978        for &m in ControlMethod::ALL {
979            assert!(!m.summary().is_empty(), "{} has no summary", m.name());
980        }
981    }
982}