19 KiB
19 KiB
@suaveplan/network-plugin-server-bridge - Tier-0 host ↔ central-server bridge for the Suaveplan mesh: ServerGateway (transport-agnostic, 2× heartbeat disconnect detection), GracefulDegradationFsm (online → degrading → offline → recovering → online), OfflineModeCoordinator (autonomous mode + token-grace extension), LogBuffer (circular signed-log replay queue), ReconciliationProtocol (server-watermark-driven differential with LWW conflict resolution), CommandDispatcher (Ed25519 signature + nonce-replay protection), HeartbeatMultiplexer (Tier-0 batch forwarding), four hosting-model coordinators (PURE_CLIENT, SERVER_BASED, SERVER_TO_CLIENT_FAILOVER, CLIENT_WITH_SERVER_BACKUP), and ServerBridgePlugin facade with tier gate.
Summary
Tier-0 host ↔ central-server bridge for the Suaveplan mesh.
ServerBridgePlugin ties together every subsystem the bridge needs:
ServerGateway— transport-agnostic byte channel with a heartbeat loop and 2× heartbeat disconnect detection.GracefulDegradationFsm— five-state FSM (online → degrading → offline → recovering → online) with strict transition validation.OfflineModeCoordinator— switches mesh to autonomous mode on disconnect, extends token grace, blocks new sessions, emitsserver:offline/server:online.LogBuffer— circular replay queue for signed activity logs withentryHashdedup,seq-ordered drain, partial-progress cursor.ReconciliationProtocol— server-watermark-driven differential with last-writer-wins conflict resolution (host wins ties).CommandDispatcher— Ed25519 signature validation (verifier injected), nonce + maxAge replay protection, dispatch to per-type handlers andcommand:<type>bus topics.HeartbeatMultiplexer— Tier-0 batches per-peer heartbeats and forwards aggregated batches upstream so peers don't each open a server WebSocket.- Hosting models — four coordinators (
PureClientCoordinator,ServerBasedCoordinator,FailoverCoordinator,BackupCoordinator) implementingPURE_CLIENT,SERVER_BASED,SERVER_TO_CLIENT_FAILOVER,CLIENT_WITH_SERVER_BACKUPperNET-56.
Documentation tree
- buffer — (no submodules)
- log-buffer — (no submodules)
- command — (no submodules)
- command-dispatcher — (no submodules)
- error-codes — Frozen
NET_SBerror registry for@suaveplan/network-plugin-server-bridge. Every failure path the server bridge can…- error-codes — Frozen
NET_SBerror registry for@suaveplan/network-plugin-server-bridge. Every failure path the server bridge can…
- error-codes — Frozen
- fsm — (no submodules)
- graceful-degradation-fsm — (no submodules)
- gateway — (no submodules)
- server-gateway — (no submodules)
- backup-coordinator —
BackupCoordinatorimplements theCLIENT_WITH_SERVER_BACKUPmodel: clients host normally and the server is a backup… - failover-coordinator —
FailoverCoordinatorimplements theSERVER_TO_CLIENT_FAILOVERmodel — the proposal's current default. The server is… - hosting-model-config —
hostingModelConfig(model)is the single accessor for the four hosting-model presets the proposal documents (`PURE_CLI… - pure-client-coordinator —
PureClientCoordinatorimplements thePURE_CLIENThosting model: no central server is in the picture, and token issu… - server-based-coordinator —
ServerBasedCoordinatorimplements theSERVER_BASEDhosting model: the server is always the top-tier host, clients n… - multiplexer — (no submodules)
- heartbeat-multiplexer — (no submodules)
- offline — (no submodules)
- offline-mode-coordinator — (no submodules)
- plugin — (no submodules)
- server-bridge-plugin — (no submodules)
- reconciliation — (no submodules)
- reconciliation-protocol — (no submodules)
- failover-coordinator —
FailoverCoordinatorimplements theSERVER_TO_CLIENT_FAILOVERmodel — the proposal's current default. The server is… - hosting-model-config —
hostingModelConfig(model)is the single accessor for the four hosting-model presets the proposal documents (`PURE_CLI… - pure-client-coordinator —
PureClientCoordinatorimplements thePURE_CLIENThosting model: no central server is in the picture, and token issu… - server-based-coordinator —
ServerBasedCoordinatorimplements theSERVER_BASEDhosting model: the server is always the top-tier host, clients n… - multiplexer — (no submodules)- heartbeat-multiplexer — (no submodules)- offline — (no submodules)- offline-mode-coordinator — (no submodules)- plugin — (no submodules)- server-bridge-plugin — (no submodules)- reconciliation — (no submodules)- reconciliation-protocol — (no submodules)- error-codes — Frozen
NET_SBerror registry for@suaveplan/network-plugin-server-bridge. Every failure path the server bridge can… - log-buffer — (no submodules)- command — (no submodules)- command-dispatcher — (no submodules)- fsm — (no submodules)- graceful-degradation-fsm — (no submodules)- gateway — (no submodules)- server-gateway — (no submodules)- backup-coordinator —
BackupCoordinatorimplements theCLIENT_WITH_SERVER_BACKUPmodel: clients host normally and the server is a backup… - failover-coordinator —
FailoverCoordinatorimplements theSERVER_TO_CLIENT_FAILOVERmodel — the proposal's current default. The server is… - hosting-model-config —
hostingModelConfig(model)is the single accessor for the four hosting-model presets the proposal documents (`PURE_CLI… - pure-client-coordinator —
PureClientCoordinatorimplements thePURE_CLIENThosting model: no central server is in the picture, and token issu… - server-based-coordinator —
ServerBasedCoordinatorimplements theSERVER_BASEDhosting model: the server is always the top-tier host, clients n… - multiplexer — (no submodules)- heartbeat-multiplexer — (no submodules)- offline — (no submodules)- offline-mode-coordinator — (no submodules)- plugin — (no submodules)- server-bridge-plugin — (no submodules)- reconciliation — (no submodules)- reconciliation-protocol — (no submodules)- error-codes — Frozen
NET_SBerror registry for@suaveplan/network-plugin-server-bridge. Every failure path the server bridge can… - log-buffer — (no submodules)- command — (no submodules)- command-dispatcher — (no submodules)- fsm — (no submodules)- graceful-degradation-fsm — (no submodules)- gateway — (no submodules)- server-gateway — (no submodules)- backup-coordinator —
BackupCoordinatorimplements theCLIENT_WITH_SERVER_BACKUPmodel: clients host normally and the server is a backup… - failover-coordinator —
FailoverCoordinatorimplements theSERVER_TO_CLIENT_FAILOVERmodel — the proposal's current default. The server is… - hosting-model-config —
hostingModelConfig(model)is the single accessor for the four hosting-model presets the proposal documents (`PURE_CLI… - pure-client-coordinator —
PureClientCoordinatorimplements thePURE_CLIENThosting model: no central server is in the picture, and token issu… - server-based-coordinator —
ServerBasedCoordinatorimplements theSERVER_BASEDhosting model: the server is always the top-tier host, clients n… - multiplexer — (no submodules)- heartbeat-multiplexer — (no submodules)- offline — (no submodules)- offline-mode-coordinator — (no submodules)- plugin — (no submodules)- server-bridge-plugin — (no submodules)- reconciliation — (no submodules)- reconciliation-protocol — (no submodules)- error-codes — Frozen
NET_SBerror registry for@suaveplan/network-plugin-server-bridge. Every failure path the server bridge can… - log-buffer — (no submodules)- command — (no submodules) - command-dispatcher — (no submodules)- fsm — (no submodules) - graceful-degradation-fsm — (no submodules)- gateway — (no submodules) - server-gateway — (no submodules)- backup-coordinator —
BackupCoordinatorimplements theCLIENT_WITH_SERVER_BACKUPmodel: clients host normally and the server is a backup… - failover-coordinator —
FailoverCoordinatorimplements theSERVER_TO_CLIENT_FAILOVERmodel — the proposal's current default. The server is… - hosting-model-config —
hostingModelConfig(model)is the single accessor for the four hosting-model presets the proposal documents (`PURE_CLI… - pure-client-coordinator —
PureClientCoordinatorimplements thePURE_CLIENThosting model: no central server is in the picture, and token issu… - server-based-coordinator —
ServerBasedCoordinatorimplements theSERVER_BASEDhosting model: the server is always the top-tier host, clients n… - multiplexer — (no submodules) - heartbeat-multiplexer — (no submodules)- offline — (no submodules) - offline-mode-coordinator — (no submodules)- plugin — (no submodules) - server-bridge-plugin — (no submodules)- reconciliation — (no submodules) - reconciliation-protocol — (no submodules)- error-codes — Frozen
NET_SBerror registry for@suaveplan/network-plugin-server-bridge. Every failure path the server bridge can…
Install
bun add @suaveplan/network-plugin-server-bridge
Quick start
import { NetworkBus, NetworkNode } from "@suaveplan/network";
import {
FailoverCoordinator,
ServerBridgePlugin,
} from "@suaveplan/network-plugin-server-bridge";
const node = new NetworkNode({ id: "host-1", networkBus: new NetworkBus() });
const plugin = new ServerBridgePlugin({
tierGate: () => topology.localTier() === 0,
transportFactory: () => openWebSocket(serverUrl),
heartbeatIntervalMs: 1_000,
bufferCapacity: 10_000,
tokenGraceMs: 30_000,
extendedTokenGraceMs: 5 * 60_000,
verifyCommand: (canon, sig) => ed25519Verify(sig, canon, serverPubKey),
currentMeshEpoch: () => meshEpoch.current(),
sessionAttributor: (entry) => extractSession(entry),
hostingCoordinator: new FailoverCoordinator({
serverAvailable: () => gateway.connectionState() === "open",
mintToken: (req) => sign(req),
}),
heartbeatBatchWindowMs: 500,
heartbeatSink: async (batch) => gateway.send(encode(batch)),
});
node.use(plugin);
await node.start();
Modules
error-codes—NETWORK_SB_CODESregistry +NetworkSbError.fsm/graceful-degradation-fsm— five-state bridge FSM.gateway/server-gateway— heartbeat loop + 2× disconnect detection.gateway/server-gateway.types— gateway shapes.offline/offline-mode-coordinator— autonomous mode + grace extension.buffer/log-buffer— circular replay queue.reconciliation/reconciliation-protocol— diff + LWW conflict.reconciliation/reconciliation-protocol.types— reconciliation shapes.command/command-dispatcher— signed-command pipeline.command/command-dispatcher.types— dispatcher shapes.multiplexer/heartbeat-multiplexer— Tier-0 batch forwarding.hosting/hosting-model-config— four-model preset accessor.hosting/pure-client-coordinator— Byzantine quorum.hosting/server-based-coordinator— server-only authority.hosting/failover-coordinator— current default.hosting/backup-coordinator— client-primary, server-backup.plugin/server-bridge-plugin— facade satisfyingNetworkPlugin.