Governance Gossip, Service Manager, and Health API
Files: gossip.rs, service.rs, api.rs (+ bin/browser_gateway.rs, bin/ping_proxy.rs)
Crate: kinetic-host | Stage: 13
gossip.rs — Simpler Than the Node Version
The host’s governance gossip handler is a stripped-down version of the node’s (docs/learn/node/04_gossip.md).
Key differences from kinetic-node/src/gossip.rs:
- No storage writes. The node writes
NameRecord::Premiumto Sled onPremiumNameGranted. The host does not — it has no DHT authority to inject records. - No
spawn_blockingfor disk saves. The host’ssave_to_diskis called directly inside the gossip loop (still holding theGLOBAL_GOVERNANCE_STATElock). This is simpler but means the disk write is synchronous within the async loop. - No lagged message handling. The node explicitly handles
RecvError::Lagged. The host useswhile let Ok(...) = gossip_rx.recv().await— it simply exits the loop if the channel closes or on any error. - Filter is the same: Only
GOSSIP_TOPIC_GOVERNANCEis processed. Other gossip topics (Drand, etc.) are ignored. -> See:kinetic-host/src/gossip.rs— Lines 10–40
Fuzz test: doesnt_panic_on_garbage_gossip — passes random bytes directly to serde_json::from_slice::<SignedGovernanceMessage>. Proves parsing never panics.
-> See: kinetic-host/src/gossip.rs — Lines 42–55
service.rs — Standard Service Manager
Identical pattern to kinetic-node/src/service.rs and the daemon’s service management. Uses <dyn ServiceManager>::native() to register as kinetic-host with the OS service manager (systemd/launchd/SCM).
One host-specific detail: during install, it passes username: std::env::var("SUDO_USER").ok().or_else(|| Some("nobody".to_string())) — so if you run sudo kinetic-host install, it installs the service to run as the invoking user rather than root.
-> See: kinetic-host/src/service.rs — Lines 1–90
api.rs — Health API at Port 16004
Two routes, same as kinetic-node but for the host:
GET /health→"OK"GET /peer_id→ the static host Peer ID (not the ephemeral PoW one)
Port: 16004 (node uses 16003, daemon uses 16000).
start_health_api(host_peer_id, bind_ip) binds the Axum server and runs with with_graceful_shutdown(shutdown_signal()).
The peer_id endpoint returns the static host key’s Peer ID — the permanent identity. Monitoring tools use this to verify which host they’re checking, and it’s the same Peer ID that clients look up in the DNS zone record.
bin/browser_gateway.rs — Browser WebSocket Gateway (184 lines)
A standalone binary (not the main host binary). Provides a WebSocket-to-HTTP bridge so web browsers can make requests into the Kinetic P2P network without needing a local daemon installed.
Key behavior:
- Binds a WebSocket server locally.
- When a browser connects and sends a request, it forwards it through the P2P network via
NetworkClient::send_proxy_request(). - Replies to the browser with the
ProxyResponsereceived back over P2P.
This is an experimental entrypoint for browser-native Kinetic access. It is not started by the main kinetic-host binary.
bin/ping_proxy.rs — P2P Proxy Latency Tester (139 lines)
Another standalone utility binary. Sends test ProxyRequest messages through the P2P network to a target host and measures round-trip latency. Used for diagnosing connectivity and measuring proxy performance.
Not started by the main binary. Run manually: kinetic-ping-proxy <target_host_peer_id>.
Quick Reference
| File | Lines | Role |
|---|---|---|
gossip.rs | 56 | Governance gossip → disk (no Sled writes unlike node) |
service.rs | 90 | OS service manager wrapper |
api.rs | ~30 | /health + /peer_id at port 16004 |
bin/browser_gateway.rs | 184 | Experimental: WebSocket → P2P bridge |
bin/ping_proxy.rs | 139 | Utility: P2P proxy latency tester |