bmux_cluster_plugin
Bundled server clusters plugin for bmux.
Overview
This crate owns the bmux.cluster plugin domain.
Current scope:
- Read-only cluster inventory and health checks (
cluster hosts/status/doctor) - Inventory sourced from
[plugins.settings."bmux.cluster"].clusters - Target resolution validated against
[connections.targets] - Readiness probes delegated to core remote commands (
remote test/remote doctor) cluster upcreates/reusescluster-<name>session and launches host-bound panes- Partial-start semantics: unhealthy hosts are reported as degraded while healthy hosts still launch
cluster upsupports launch failure policy controls (--retries,--on-failure=continue|abort|prompt)cluster eventsshows connection lifecycle events (--format text|json,--cluster,--target,--state,--since,--limit);--sinceacceptsnow/0, unix ms, or relative durations like15m,2h,1h30mcluster pane newcreates an ad-hoc host-bound pane via the generic pane launch APIcluster pane moverelocates a pane to a destination host and retargets pane namingcluster pane retryrelaunches a host-bound pane by inferring target from pane naming convention- Cluster pane target metadata is persisted in plugin storage for robust move/retry behavior
- Connection lifecycle state (
connecting/retrying/degraded/failed) is tracked in pane metadata - Panes transition to
readyonly after post-launch health verification succeeds cluster pane retrysupports probe retry policy controls (--retries,--on-failure=abort|continue|prompt)cluster pane new|move|retryaccept--clusterfor deterministic gateway routing; in multi-cluster layouts, commands hard-fail when cluster inference is ambiguous- Gateway overrides are available on cluster commands:
--gateway,--gateway-mode=auto|direct|pinned,--gateway-policy=balanced|aggressive|conservative, and--gateway-no-failover - Routed cluster commands support
--dry-runto run real gateway probes/selection without executing the cluster operation itself (--format text|json) - Routed/special gateway commands support
--whyfor concise decision summaries in text and JSON (decision_summary) cluster gateway statusreports effective gateway mode, candidate order, preferred gateway cache, cooldown state, and selected candidate hint (--format text|json)cluster gateway explainprobes candidates and explains why selection would succeed/fail without mutating gateway runtime cache/cooldown state (--format text|json)cluster gateway doctorinspects gateway candidate health and emits actionable findings (--format text|json)cluster gateway whyprovides one-shot routing diagnosis, top actions, and recent history (--format text|json)cluster gateway historyshows recent gateway routing decisions and observations (--format text|json,--since <duration>,--limit <count>,--result,--reason,--candidate,--command)cluster gateway history-exportemits machine-friendly history output (--format json|ndjson)cluster gateway history-clearclears history for one cluster or all clusters (--cluster/--all, filter flags,--confirmfor broad non-interactive clears)cluster gateway resetclears persisted gateway runtime state for one cluster (--cluster) or all clusters (--all)- In multi-cluster setups,
cluster gateway status|explainrequire explicit cluster selection (--clusteror positional cluster name) - Cluster service interfaces are implemented for query/command/event-list integrations
Failure Semantics
cluster up --on-failure=abortstops launching additional hosts after the first terminal failure but preserves any panes already launched successfully.cluster up --on-failure=continuekeeps launching remaining hosts and reports failed hosts as degraded.cluster up --on-failure=promptasks for interactive retry/continue/abort decisions when prompt runtime is available; if unavailable, it safely falls back to abort.
Gateway Failover Mode
- Cluster commands can execute through a cluster member gateway before orchestration runs. This is intended for topologies where private cluster members are reachable from peers but not directly from the caller machine.
gateway_modedefaults toautofor each cluster:auto: try gateway candidates in order until one succeeds.direct: run locally (no gateway indirection).pinned: require a single configuredgateway_target.
- In
auto, candidates come fromgateway_candidateswhen provided; otherwise they fall back to clustertargets. - If every gateway candidate fails, cluster command execution hard-fails (no silent direct fallback).
- Auto mode tracks persisted last-known-good/cooldown state, per-candidate stability stats, and breaker state.
- Breaker behavior defaults: open after 3 consecutive failures, then half-open retry after cooldown.
- Cooldown is adaptive per candidate (failure streak increases delay up to
cooldown_max_ms) and resets on successful execution. - Cooldown handling is reason-class-aware (auth/service denial back off faster than transient network failures) with bounded jitter (
cooldown_jitter_pct) to reduce herd retries. - Half-open probation requires consecutive successes (
breaker_half_open_required_successes) before closing breaker again. - History retention and size are policy-driven (
history_retention_ms,history_max_entries). - Policy presets tune breaker/cooldown/probe defaults:
balanced: current defaults.aggressive: faster failover and shorter cooldown.conservative: slower failover and longer stabilization windows.
- Candidate ordering in auto mode is stability-first (latency used as tie-break), with explicit skip reasons (
cooldown/breaker_open) visible in status/explain and dry-run output. - Text output may truncate long candidate names for alignment only; JSON keeps full candidate values.
Gateway Output Examples
Text table columns are aligned and consistent across cluster gateway status, cluster gateway explain, and routed command --dry-run:
candidate preferred stability breaker cooldown_ms ok reason latency_ms skip detail
prod-a true 5000 closed - true ok 42 - gateway command bridge reachable
prod-b false 200000 open 29000 false connect 15 breaker_open connection refused
JSON example for cluster gateway explain --format json:
JSON example for routed command dry-run (cluster status prod --dry-run --format json):
Example:
[]
= ["prod-a", "prod-b", "prod-c"]
= "auto"
# optional; defaults to targets when omitted
# gateway_candidates = ["prod-a", "prod-b"]
Commands
cluster upcluster statuscluster doctorcluster hostscluster eventscluster pane newcluster pane movecluster pane retrycluster gateway statuscluster gateway explaincluster gateway doctorcluster gateway whycluster gateway historycluster gateway history-exportcluster gateway history-clearcluster gateway reset
Services
cluster-query/v1cluster-command/v1cluster-connection-events/v1
Service Contract Notes
cluster-query/v1list_clustersreturns settings-resolved cluster inventory.statusreturns host states from probe execution (readyordegraded).- Errors use
list_clusters_failed/status_failed.
cluster-command/v1upreturns session id plus per-host launch status payload.pane_new,pane_retry, andpane_movereturn operation result payloads with pane/session ids.- Errors use
up_failed,pane_new_failed,pane_retry_failed, andpane_move_failed.
cluster-connection-events/v1listreturns persisted lifecycle events ring buffer for cluster connections.- Errors use
connection_events_list_failed.